diff options
-rw-r--r-- | applications/kube-mail/package/contents/ui/FolderListView.qml | 9 | ||||
-rw-r--r-- | applications/kube-mail/package/contents/ui/MailListView.qml | 13 | ||||
-rw-r--r-- | applications/kube-mail/package/contents/ui/SingleMailView.qml | 9 | ||||
-rw-r--r-- | applications/kube-mail/package/contents/ui/main.qml | 17 | ||||
-rw-r--r-- | framework/mail/CMakeLists.txt | 4 | ||||
-rw-r--r-- | framework/mail/folderlistmodel.cpp | 3 | ||||
-rw-r--r-- | framework/mail/folderlistmodel.h | 5 | ||||
-rw-r--r-- | framework/mail/maillistmodel.cpp | 48 | ||||
-rw-r--r-- | framework/mail/maillistmodel.h | 8 | ||||
-rw-r--r-- | framework/mail/mailplugin.cpp | 15 | ||||
-rw-r--r-- | framework/mail/qmldir | 4 |
11 files changed, 93 insertions, 42 deletions
diff --git a/applications/kube-mail/package/contents/ui/FolderListView.qml b/applications/kube-mail/package/contents/ui/FolderListView.qml index f0ce7da2..1639fe70 100644 --- a/applications/kube-mail/package/contents/ui/FolderListView.qml +++ b/applications/kube-mail/package/contents/ui/FolderListView.qml | |||
@@ -22,10 +22,11 @@ import QtQuick.Layouts 1.1 | |||
22 | import org.kde.plasma.core 2.0 as PlasmaCore | 22 | import org.kde.plasma.core 2.0 as PlasmaCore |
23 | import org.kde.plasma.components 2.0 as PlasmaComponents | 23 | import org.kde.plasma.components 2.0 as PlasmaComponents |
24 | 24 | ||
25 | import org.kde.akonadi2.mail 1.0 as Mail | 25 | import org.kde.kube.mail 1.0 as Mail |
26 | 26 | ||
27 | Item { | 27 | Item { |
28 | id: root | 28 | id: root |
29 | property variant currentFolder | ||
29 | 30 | ||
30 | Item { | 31 | Item { |
31 | id: searchBox | 32 | id: searchBox |
@@ -58,7 +59,7 @@ Item { | |||
58 | 59 | ||
59 | clip: true | 60 | clip: true |
60 | 61 | ||
61 | model: folderList.model //FolderModel {} | 62 | model: Mail.FolderListModel {} |
62 | 63 | ||
63 | delegate: PlasmaComponents.ListItem { | 64 | delegate: PlasmaComponents.ListItem { |
64 | 65 | ||
@@ -69,8 +70,8 @@ Item { | |||
69 | checked: listView.currentIndex == index | 70 | checked: listView.currentIndex == index |
70 | 71 | ||
71 | onClicked: { | 72 | onClicked: { |
72 | mailList.loadMailFolder(model.id) | ||
73 | listView.currentIndex = model.index | 73 | listView.currentIndex = model.index |
74 | root.currentFolder = model.domainObject | ||
74 | } | 75 | } |
75 | 76 | ||
76 | PlasmaCore.IconItem { | 77 | PlasmaCore.IconItem { |
@@ -99,4 +100,4 @@ Item { | |||
99 | } | 100 | } |
100 | } | 101 | } |
101 | } | 102 | } |
102 | } \ No newline at end of file | 103 | } |
diff --git a/applications/kube-mail/package/contents/ui/MailListView.qml b/applications/kube-mail/package/contents/ui/MailListView.qml index f6ded917..5fb4678c 100644 --- a/applications/kube-mail/package/contents/ui/MailListView.qml +++ b/applications/kube-mail/package/contents/ui/MailListView.qml | |||
@@ -21,12 +21,19 @@ import QtQuick.Layouts 1.1 | |||
21 | 21 | ||
22 | import org.kde.plasma.components 2.0 as PlasmaComponents | 22 | import org.kde.plasma.components 2.0 as PlasmaComponents |
23 | 23 | ||
24 | import org.kde.kube.mail 1.0 as Mail | ||
25 | |||
24 | ScrollView { | 26 | ScrollView { |
25 | id: root | 27 | id: root |
28 | property variant parentFolder | ||
29 | property variant currentMail | ||
30 | |||
26 | ListView { | 31 | ListView { |
27 | id: listView | 32 | id: listView |
28 | 33 | ||
29 | model: mailList.model //MailListModel {} | 34 | model: Mail.MailListModel { |
35 | parentFolder: root.parentFolder | ||
36 | } | ||
30 | 37 | ||
31 | delegate: PlasmaComponents.ListItem { | 38 | delegate: PlasmaComponents.ListItem { |
32 | 39 | ||
@@ -41,7 +48,7 @@ ScrollView { | |||
41 | 48 | ||
42 | onClicked: { | 49 | onClicked: { |
43 | listView.currentIndex = model.index | 50 | listView.currentIndex = model.index |
44 | singleMail.loadMail(model.id) | 51 | root.currentMail = model.domainObject |
45 | } | 52 | } |
46 | } | 53 | } |
47 | 54 | ||
@@ -128,4 +135,4 @@ ScrollView { | |||
128 | } | 135 | } |
129 | } | 136 | } |
130 | } | 137 | } |
131 | } \ No newline at end of file | 138 | } |
diff --git a/applications/kube-mail/package/contents/ui/SingleMailView.qml b/applications/kube-mail/package/contents/ui/SingleMailView.qml index e307ccfd..caec88dd 100644 --- a/applications/kube-mail/package/contents/ui/SingleMailView.qml +++ b/applications/kube-mail/package/contents/ui/SingleMailView.qml | |||
@@ -19,8 +19,11 @@ import QtQuick 2.4 | |||
19 | import QtQuick.Controls 1.3 | 19 | import QtQuick.Controls 1.3 |
20 | import QtQuick.Layouts 1.1 | 20 | import QtQuick.Layouts 1.1 |
21 | 21 | ||
22 | import org.kde.kube.mail 1.0 as Mail | ||
23 | |||
22 | Item { | 24 | Item { |
23 | id: root | 25 | id: root |
26 | property variant mail; | ||
24 | 27 | ||
25 | Rectangle { | 28 | Rectangle { |
26 | id: background | 29 | id: background |
@@ -33,7 +36,9 @@ Item { | |||
33 | Repeater { | 36 | Repeater { |
34 | anchors.fill: parent | 37 | anchors.fill: parent |
35 | 38 | ||
36 | model: singleMail.model | 39 | model: Mail.MailListModel { |
40 | mail: root.mail | ||
41 | } | ||
37 | 42 | ||
38 | delegate: Item { | 43 | delegate: Item { |
39 | height: root.height | 44 | height: root.height |
@@ -61,4 +66,4 @@ Item { | |||
61 | } | 66 | } |
62 | } | 67 | } |
63 | } | 68 | } |
64 | } \ No newline at end of file | 69 | } |
diff --git a/applications/kube-mail/package/contents/ui/main.qml b/applications/kube-mail/package/contents/ui/main.qml index 88d2edde..200328f3 100644 --- a/applications/kube-mail/package/contents/ui/main.qml +++ b/applications/kube-mail/package/contents/ui/main.qml | |||
@@ -20,8 +20,6 @@ import QtQuick.Controls 1.3 | |||
20 | import QtQuick.Layouts 1.1 | 20 | import QtQuick.Layouts 1.1 |
21 | import org.kde.plasma.components 2.0 as PlasmaComponents | 21 | import org.kde.plasma.components 2.0 as PlasmaComponents |
22 | 22 | ||
23 | import org.kde.akonadi2.mail 1.0 as Mail | ||
24 | |||
25 | ApplicationWindow { | 23 | ApplicationWindow { |
26 | id: app | 24 | id: app |
27 | 25 | ||
@@ -32,19 +30,6 @@ ApplicationWindow { | |||
32 | 30 | ||
33 | visible: true | 31 | visible: true |
34 | 32 | ||
35 | //Controller: | ||
36 | Mail.FolderList { | ||
37 | id: folderList | ||
38 | } | ||
39 | |||
40 | Mail.MailList { | ||
41 | id: mailList | ||
42 | } | ||
43 | |||
44 | Mail.SingleMail{ | ||
45 | id: singleMail | ||
46 | } | ||
47 | |||
48 | //UI | 33 | //UI |
49 | toolBar: ToolBar { | 34 | toolBar: ToolBar { |
50 | 35 | ||
@@ -111,6 +96,7 @@ ApplicationWindow { | |||
111 | 96 | ||
112 | MailListView { | 97 | MailListView { |
113 | id: mailListView | 98 | id: mailListView |
99 | parentFolder: folderListView.currentFolder | ||
114 | 100 | ||
115 | width: unit.size * 80 | 101 | width: unit.size * 80 |
116 | Layout.maximumWidth: unit.size * 250 | 102 | Layout.maximumWidth: unit.size * 250 |
@@ -119,6 +105,7 @@ ApplicationWindow { | |||
119 | 105 | ||
120 | SingleMailView { | 106 | SingleMailView { |
121 | id: mailView | 107 | id: mailView |
108 | mail: mailListView.currentMail | ||
122 | 109 | ||
123 | Layout.fillWidth: true | 110 | Layout.fillWidth: true |
124 | } | 111 | } |
diff --git a/framework/mail/CMakeLists.txt b/framework/mail/CMakeLists.txt index 7d7569a7..38ba3935 100644 --- a/framework/mail/CMakeLists.txt +++ b/framework/mail/CMakeLists.txt | |||
@@ -14,5 +14,5 @@ qt5_use_modules(mailplugin Core Quick Qml) | |||
14 | target_link_libraries(mailplugin /work/install/lib64/libakonadi2common.so) | 14 | target_link_libraries(mailplugin /work/install/lib64/libakonadi2common.so) |
15 | #target_link_libraries(mailplugin /home/mike/projects/_install/lib/x86_64-linux-gnu/libakonadi2common.so) | 15 | #target_link_libraries(mailplugin /home/mike/projects/_install/lib/x86_64-linux-gnu/libakonadi2common.so) |
16 | 16 | ||
17 | install(TARGETS mailplugin DESTINATION ${QML_INSTALL_DIR}/org/kde/akonadi2/mail) | 17 | install(TARGETS mailplugin DESTINATION ${QML_INSTALL_DIR}/org/kde/kube/mail) |
18 | install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/akonadi2/mail) \ No newline at end of file | 18 | install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/kube/mail) |
diff --git a/framework/mail/folderlistmodel.cpp b/framework/mail/folderlistmodel.cpp index 0240d95a..0f66c46f 100644 --- a/framework/mail/folderlistmodel.cpp +++ b/framework/mail/folderlistmodel.cpp | |||
@@ -25,6 +25,7 @@ QHash< int, QByteArray > FolderListModel::roleNames() const | |||
25 | roles[Name] = "name"; | 25 | roles[Name] = "name"; |
26 | roles[Icon] = "icon"; | 26 | roles[Icon] = "icon"; |
27 | roles[Id] = "id"; | 27 | roles[Id] = "id"; |
28 | roles[DomainObject] = "domainObject"; | ||
28 | 29 | ||
29 | return roles; | 30 | return roles; |
30 | } | 31 | } |
@@ -39,6 +40,8 @@ QVariant FolderListModel::data(const QModelIndex &idx, int role) const | |||
39 | return srcIdx.sibling(srcIdx.row(), 1).data(Qt::DisplayRole).toString(); | 40 | return srcIdx.sibling(srcIdx.row(), 1).data(Qt::DisplayRole).toString(); |
40 | case Id: | 41 | case Id: |
41 | return srcIdx.data(Akonadi2::Store::DomainObjectBaseRole).value<Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr>()->identifier(); | 42 | return srcIdx.data(Akonadi2::Store::DomainObjectBaseRole).value<Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr>()->identifier(); |
43 | case DomainObject: | ||
44 | return srcIdx.data(Akonadi2::Store::DomainObjectRole); | ||
42 | } | 45 | } |
43 | return QIdentityProxyModel::data(idx, role); | 46 | return QIdentityProxyModel::data(idx, role); |
44 | } | 47 | } |
diff --git a/framework/mail/folderlistmodel.h b/framework/mail/folderlistmodel.h index 829bebff..9ce3ee79 100644 --- a/framework/mail/folderlistmodel.h +++ b/framework/mail/folderlistmodel.h | |||
@@ -17,8 +17,9 @@ public: | |||
17 | 17 | ||
18 | enum Roles { | 18 | enum Roles { |
19 | Name = Qt::UserRole + 1, | 19 | Name = Qt::UserRole + 1, |
20 | Icon, | 20 | Icon, |
21 | Id | 21 | Id, |
22 | DomainObject | ||
22 | }; | 23 | }; |
23 | 24 | ||
24 | QHash<int, QByteArray> roleNames() const; | 25 | QHash<int, QByteArray> roleNames() const; |
diff --git a/framework/mail/maillistmodel.cpp b/framework/mail/maillistmodel.cpp index 80fb661f..e6a9c218 100644 --- a/framework/mail/maillistmodel.cpp +++ b/framework/mail/maillistmodel.cpp | |||
@@ -25,6 +25,7 @@ QHash< int, QByteArray > MailListModel::roleNames() const | |||
25 | roles[Important] = "important"; | 25 | roles[Important] = "important"; |
26 | roles[Id] = "id"; | 26 | roles[Id] = "id"; |
27 | roles[MimeMessage] = "mimeMessage"; | 27 | roles[MimeMessage] = "mimeMessage"; |
28 | roles[DomainObject] = "domainObject"; | ||
28 | 29 | ||
29 | return roles; | 30 | return roles; |
30 | } | 31 | } |
@@ -70,3 +71,50 @@ void MailListModel::runQuery(const Akonadi2::Query &query) | |||
70 | setSourceModel(m_model.data()); | 71 | setSourceModel(m_model.data()); |
71 | } | 72 | } |
72 | 73 | ||
74 | void MailListModel::setParentFolder(const QVariant &parentFolder) | ||
75 | { | ||
76 | auto folder = parentFolder.value<Akonadi2::ApplicationDomain::Folder::Ptr>(); | ||
77 | if (!folder) { | ||
78 | qWarning() << "No folder: " << parentFolder; | ||
79 | return; | ||
80 | } | ||
81 | Akonadi2::Query query; | ||
82 | query.syncOnDemand = false; | ||
83 | query.processAll = false; | ||
84 | query.liveQuery = true; | ||
85 | query.requestedProperties << "subject" << "sender" << "senderName" << "date" << "unread" << "important" << "folder"; | ||
86 | query.propertyFilter.insert("folder", folder->identifier()); | ||
87 | query.resources << folder->resourceInstanceIdentifier(); | ||
88 | qWarning() << "Running folder query: " << folder->resourceInstanceIdentifier() << folder->identifier(); | ||
89 | runQuery(query); | ||
90 | } | ||
91 | |||
92 | QVariant MailListModel::parentFolder() const | ||
93 | { | ||
94 | return QVariant(); | ||
95 | } | ||
96 | |||
97 | void MailListModel::setMail(const QVariant &variant) | ||
98 | { | ||
99 | auto mail = variant.value<Akonadi2::ApplicationDomain::Mail::Ptr>(); | ||
100 | if (!mail) { | ||
101 | qWarning() << "No mail: " << mail; | ||
102 | return; | ||
103 | } | ||
104 | Akonadi2::Query query; | ||
105 | query.syncOnDemand = false; | ||
106 | query.processAll = false; | ||
107 | query.liveQuery = false; | ||
108 | query.requestedProperties << "subject" << "sender" << "senderName" << "date" << "unread" << "important" << "mimeMessage"; | ||
109 | query.ids << mail->identifier(); | ||
110 | query.resources << mail->resourceInstanceIdentifier(); | ||
111 | qWarning() << "Running mail query: " << mail->resourceInstanceIdentifier() << mail->identifier(); | ||
112 | runQuery(query); | ||
113 | } | ||
114 | |||
115 | QVariant MailListModel::mail() const | ||
116 | { | ||
117 | return QVariant(); | ||
118 | } | ||
119 | |||
120 | |||
diff --git a/framework/mail/maillistmodel.h b/framework/mail/maillistmodel.h index b5fa7c57..7718477c 100644 --- a/framework/mail/maillistmodel.h +++ b/framework/mail/maillistmodel.h | |||
@@ -9,6 +9,8 @@ | |||
9 | class MailListModel : public QIdentityProxyModel | 9 | class MailListModel : public QIdentityProxyModel |
10 | { | 10 | { |
11 | Q_OBJECT | 11 | Q_OBJECT |
12 | Q_PROPERTY (QVariant parentFolder READ parentFolder WRITE setParentFolder) | ||
13 | Q_PROPERTY (QVariant mail READ mail WRITE setMail) | ||
12 | 14 | ||
13 | public: | 15 | public: |
14 | MailListModel(QObject *parent = Q_NULLPTR); | 16 | MailListModel(QObject *parent = Q_NULLPTR); |
@@ -31,6 +33,12 @@ public: | |||
31 | QHash<int, QByteArray> roleNames() const; | 33 | QHash<int, QByteArray> roleNames() const; |
32 | 34 | ||
33 | void runQuery(const Akonadi2::Query &query); | 35 | void runQuery(const Akonadi2::Query &query); |
36 | |||
37 | void setParentFolder(const QVariant &parentFolder); | ||
38 | QVariant parentFolder() const; | ||
39 | |||
40 | void setMail(const QVariant &mail); | ||
41 | QVariant mail() const; | ||
34 | private: | 42 | private: |
35 | QSharedPointer<QAbstractItemModel> m_model; | 43 | QSharedPointer<QAbstractItemModel> m_model; |
36 | }; | 44 | }; |
diff --git a/framework/mail/mailplugin.cpp b/framework/mail/mailplugin.cpp index b2939acf..bf92f4e7 100644 --- a/framework/mail/mailplugin.cpp +++ b/framework/mail/mailplugin.cpp | |||
@@ -1,23 +1,14 @@ | |||
1 | #include "mailplugin.h" | 1 | #include "mailplugin.h" |
2 | 2 | ||
3 | #include "maillistcontroller.h" | ||
4 | #include "maillistmodel.h" | 3 | #include "maillistmodel.h" |
5 | #include "singlemailcontroller.h" | ||
6 | #include "folderlistcontroller.h" | ||
7 | #include "folderlistmodel.h" | 4 | #include "folderlistmodel.h" |
8 | 5 | ||
9 | #include <QAbstractItemModel> | ||
10 | #include <QtQml> | 6 | #include <QtQml> |
11 | 7 | ||
12 | void MailPlugin::registerTypes (const char *uri) | 8 | void MailPlugin::registerTypes (const char *uri) |
13 | { | 9 | { |
14 | Q_ASSERT(uri == QLatin1String("org.kde.akonadi2.mail")); | 10 | Q_ASSERT(uri == QLatin1String("org.kde.kube.mail")); |
15 | 11 | ||
16 | qmlRegisterType<FolderListModel>(); | 12 | qmlRegisterType<FolderListModel>(uri, 1, 0, "FolderListModel"); |
17 | qmlRegisterType<FolderListController>(uri, 1, 0, "FolderList"); | 13 | qmlRegisterType<MailListModel>(uri, 1, 0, "MailListModel"); |
18 | |||
19 | qmlRegisterType<MailListModel>(); | ||
20 | qmlRegisterType<MailListController>(uri, 1, 0, "MailList"); | ||
21 | |||
22 | qmlRegisterType<SingleMailController>(uri, 1, 0, "SingleMail"); | ||
23 | } | 14 | } |
diff --git a/framework/mail/qmldir b/framework/mail/qmldir index 7ca3151b..fd54e5ee 100644 --- a/framework/mail/qmldir +++ b/framework/mail/qmldir | |||
@@ -1,3 +1,3 @@ | |||
1 | module org.kde.akonadi2.mail | 1 | module org.kde.kube.mail |
2 | 2 | ||
3 | plugin mailplugin \ No newline at end of file | 3 | plugin mailplugin |