summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSandro Knauß <sknauss@kde.org>2016-10-11 16:19:01 +0200
committerSandro Knauß <sknauss@kde.org>2016-10-11 16:19:01 +0200
commit7d6ec8866c90918be94364e52bbdd4f3e53da915 (patch)
tree007cc6ded7358a7dcdf8a5a87202bb5378f60d93
parent1974c19eadd497e355ac985a00d0571f3e6c7712 (diff)
parentfd3a6901f17f3dcfd446e531dd10c0eb61cf0b93 (diff)
downloadkube-7d6ec8866c90918be94364e52bbdd4f3e53da915.tar.gz
kube-7d6ec8866c90918be94364e52bbdd4f3e53da915.zip
Merge branch 'develop' into dev/mimetreeinterface
-rw-r--r--accounts/maildir/package/contents/ui/MaildirAccountSettings.qml1
-rw-r--r--components/mail/contents/ui/main.qml1
-rw-r--r--components/package/contents/ui/FolderListView.qml1
-rw-r--r--components/package/contents/ui/ListItem.qml1
-rw-r--r--components/package/contents/ui/MailListView.qml8
-rw-r--r--components/package/contents/ui/Outbox.qml7
-rw-r--r--components/package/contents/ui/SingleMailView.qml1
-rw-r--r--framework/domain/CMakeLists.txt1
-rw-r--r--framework/domain/maillistmodel.cpp18
-rw-r--r--framework/domain/maillistmodel.h5
-rw-r--r--framework/domain/mailplugin.cpp2
-rw-r--r--framework/domain/outboxmodel.cpp114
-rw-r--r--framework/domain/outboxmodel.h60
13 files changed, 200 insertions, 20 deletions
diff --git a/accounts/maildir/package/contents/ui/MaildirAccountSettings.qml b/accounts/maildir/package/contents/ui/MaildirAccountSettings.qml
index d867c264..a5d35d5c 100644
--- a/accounts/maildir/package/contents/ui/MaildirAccountSettings.qml
+++ b/accounts/maildir/package/contents/ui/MaildirAccountSettings.qml
@@ -24,7 +24,6 @@ import QtQuick.Dialogs 1.0
24import org.kde.kirigami 1.0 as Kirigami 24import org.kde.kirigami 1.0 as Kirigami
25 25
26import org.kube.framework.settings 1.0 as KubeSettings 26import org.kube.framework.settings 1.0 as KubeSettings
27import org.kube.framework.theme 1.0
28import org.kube.accounts.maildir 1.0 as MaildirAccount 27import org.kube.accounts.maildir 1.0 as MaildirAccount
29 28
30 29
diff --git a/components/mail/contents/ui/main.qml b/components/mail/contents/ui/main.qml
index ef167bbe..279e280d 100644
--- a/components/mail/contents/ui/main.qml
+++ b/components/mail/contents/ui/main.qml
@@ -25,7 +25,6 @@ import org.kde.kirigami 1.0 as Kirigami
25import org.kube.framework.actions 1.0 as KubeAction 25import org.kube.framework.actions 1.0 as KubeAction
26import org.kube.framework.settings 1.0 as KubeSettings 26import org.kube.framework.settings 1.0 as KubeSettings
27import org.kube.framework.domain 1.0 as KubeFramework 27import org.kube.framework.domain 1.0 as KubeFramework
28import org.kube.framework.theme 1.0
29import org.kube.components 1.0 as KubeComponents 28import org.kube.components 1.0 as KubeComponents
30 29
31ApplicationWindow { 30ApplicationWindow {
diff --git a/components/package/contents/ui/FolderListView.qml b/components/package/contents/ui/FolderListView.qml
index bf4263c4..41f152de 100644
--- a/components/package/contents/ui/FolderListView.qml
+++ b/components/package/contents/ui/FolderListView.qml
@@ -24,7 +24,6 @@ import QtQuick.Layouts 1.1
24import org.kde.kirigami 1.0 as Kirigami 24import org.kde.kirigami 1.0 as Kirigami
25 25
26import org.kube.framework.domain 1.0 as KubeFramework 26import org.kube.framework.domain 1.0 as KubeFramework
27import org.kube.framework.theme 1.0
28 27
29Item { 28Item {
30 id: root 29 id: root
diff --git a/components/package/contents/ui/ListItem.qml b/components/package/contents/ui/ListItem.qml
index 0f3b7af9..165ac3ab 100644
--- a/components/package/contents/ui/ListItem.qml
+++ b/components/package/contents/ui/ListItem.qml
@@ -17,7 +17,6 @@
17*/ 17*/
18 18
19import QtQuick 2.4 19import QtQuick 2.4
20import org.kube.framework.theme 1.0
21 20
22Item { 21Item {
23 id: delegateRoot 22 id: delegateRoot
diff --git a/components/package/contents/ui/MailListView.qml b/components/package/contents/ui/MailListView.qml
index ff71e43e..cda8bbda 100644
--- a/components/package/contents/ui/MailListView.qml
+++ b/components/package/contents/ui/MailListView.qml
@@ -24,7 +24,6 @@ import QtQml 2.2 as QtQml
24import org.kde.kirigami 1.0 as Kirigami 24import org.kde.kirigami 1.0 as Kirigami
25 25
26import org.kube.framework.domain 1.0 as KubeFramework 26import org.kube.framework.domain 1.0 as KubeFramework
27import org.kube.framework.theme 1.0
28 27
29Controls.ScrollView { 28Controls.ScrollView {
30 id: root 29 id: root
@@ -127,6 +126,13 @@ Controls.ScrollView {
127 color: Kirigami.Theme.textColor 126 color: Kirigami.Theme.textColor
128 } 127 }
129 } 128 }
129 Text {
130 text: model.threadSize
131
132 renderType: Text.NativeRendering
133 font.weight: Font.Light
134 color: Kirigami.Theme.textColor
135 }
130 } 136 }
131 } 137 }
132 } 138 }
diff --git a/components/package/contents/ui/Outbox.qml b/components/package/contents/ui/Outbox.qml
index 01501410..c7b1f7b0 100644
--- a/components/package/contents/ui/Outbox.qml
+++ b/components/package/contents/ui/Outbox.qml
@@ -39,7 +39,7 @@ ToolButton {
39 Rectangle { 39 Rectangle {
40 id: dialog 40 id: dialog
41 41
42 property int modelCount: 5 //FIXME replace with actual model 42 property int modelCount: listView.count
43 43
44 anchors { 44 anchors {
45 top: parent.bottom 45 top: parent.bottom
@@ -68,7 +68,8 @@ ToolButton {
68 ListView { 68 ListView {
69 id: listView 69 id: listView
70 70
71 model: 5 71 model: KubeFramework.OutboxModel {
72 }
72 73
73 delegate: Kirigami.AbstractListItem { 74 delegate: Kirigami.AbstractListItem {
74 75
@@ -76,7 +77,7 @@ ToolButton {
76 77
77 Kirigami.Label { 78 Kirigami.Label {
78 anchors.centerIn: parent 79 anchors.centerIn: parent
79 text: "Subjext subxetson" 80 text: model.subject
80 } 81 }
81 } 82 }
82 } 83 }
diff --git a/components/package/contents/ui/SingleMailView.qml b/components/package/contents/ui/SingleMailView.qml
index b06216dd..73dedc7e 100644
--- a/components/package/contents/ui/SingleMailView.qml
+++ b/components/package/contents/ui/SingleMailView.qml
@@ -24,7 +24,6 @@ import org.kde.kirigami 1.0 as Kirigami
24import QtQml 2.2 as QtQml 24import QtQml 2.2 as QtQml
25 25
26import org.kube.framework.domain 1.0 as KubeFramework 26import org.kube.framework.domain 1.0 as KubeFramework
27import org.kube.framework.theme 1.0
28 27
29Item { 28Item {
30 id: root 29 id: root
diff --git a/framework/domain/CMakeLists.txt b/framework/domain/CMakeLists.txt
index c41da377..55bc2f24 100644
--- a/framework/domain/CMakeLists.txt
+++ b/framework/domain/CMakeLists.txt
@@ -14,6 +14,7 @@ set(mailplugin_SRCS
14 accountfactory.cpp 14 accountfactory.cpp
15 accountscontroller.cpp 15 accountscontroller.cpp
16 accountsmodel.cpp 16 accountsmodel.cpp
17 outboxmodel.cpp
17 identitiesmodel.cpp 18 identitiesmodel.cpp
18 settings/accountsettings.cpp 19 settings/accountsettings.cpp
19) 20)
diff --git a/framework/domain/maillistmodel.cpp b/framework/domain/maillistmodel.cpp
index 9afb6408..746f3523 100644
--- a/framework/domain/maillistmodel.cpp
+++ b/framework/domain/maillistmodel.cpp
@@ -23,6 +23,7 @@
23#include <QFile> 23#include <QFile>
24#include <QDateTime> 24#include <QDateTime>
25 25
26#include <sink/standardqueries.h>
26 27
27MailListModel::MailListModel(QObject *parent) 28MailListModel::MailListModel(QObject *parent)
28 : QSortFilterProxyModel() 29 : QSortFilterProxyModel()
@@ -50,6 +51,7 @@ QHash< int, QByteArray > MailListModel::roleNames() const
50 roles[Id] = "id"; 51 roles[Id] = "id";
51 roles[MimeMessage] = "mimeMessage"; 52 roles[MimeMessage] = "mimeMessage";
52 roles[DomainObject] = "domainObject"; 53 roles[DomainObject] = "domainObject";
54 roles[ThreadSize] = "threadSize";
53 55
54 return roles; 56 return roles;
55} 57}
@@ -68,18 +70,19 @@ QVariant MailListModel::data(const QModelIndex &idx, int role) const
68 case Date: 70 case Date:
69 return mail->getDate(); 71 return mail->getDate();
70 case Unread: 72 case Unread:
71 return mail->getUnread(); 73 return mail->getProperty("unreadCollected").toList().contains(true);
72 case Important: 74 case Important:
73 return mail->getImportant(); 75 return mail->getProperty("importantCollected").toList().contains(true);
74 case Draft: 76 case Draft:
75 return mail->getDraft(); 77 return mail->getDraft();
76 case Id: 78 case Id:
77 return mail->identifier(); 79 return mail->identifier();
78 case DomainObject: 80 case DomainObject:
79 return QVariant::fromValue(mail); 81 return QVariant::fromValue(mail);
80 case MimeMessage: { 82 case MimeMessage:
81 return mail->getMimeMessage(); 83 return mail->getMimeMessage();
82 } 84 case ThreadSize:
85 return mail->getProperty("count").toInt();
83 } 86 }
84 return QSortFilterProxyModel::data(idx, role); 87 return QSortFilterProxyModel::data(idx, role);
85} 88}
@@ -105,10 +108,8 @@ void MailListModel::setParentFolder(const QVariant &parentFolder)
105 qWarning() << "No folder: " << parentFolder; 108 qWarning() << "No folder: " << parentFolder;
106 return; 109 return;
107 } 110 }
108 Sink::Query query; 111 Sink::Query query = Sink::StandardQueries::threadLeaders(*folder);
109 query.liveQuery = true; 112 query.liveQuery = true;
110 query.resourceFilter(folder->resourceInstanceIdentifier());
111 query.sort<Mail::Date>();
112 query.limit = 100; 113 query.limit = 100;
113 query.request<Mail::Subject>(); 114 query.request<Mail::Subject>();
114 query.request<Mail::Sender>(); 115 query.request<Mail::Sender>();
@@ -118,7 +119,6 @@ void MailListModel::setParentFolder(const QVariant &parentFolder)
118 query.request<Mail::Important>(); 119 query.request<Mail::Important>();
119 query.request<Mail::Draft>(); 120 query.request<Mail::Draft>();
120 query.request<Mail::Folder>(); 121 query.request<Mail::Folder>();
121 query.filter<Mail::Folder>(*folder);
122 qWarning() << "Running folder query: " << folder->resourceInstanceIdentifier() << folder->identifier(); 122 qWarning() << "Running folder query: " << folder->resourceInstanceIdentifier() << folder->identifier();
123 runQuery(query); 123 runQuery(query);
124} 124}
@@ -136,7 +136,7 @@ void MailListModel::setMail(const QVariant &variant)
136 qWarning() << "No mail: " << mail; 136 qWarning() << "No mail: " << mail;
137 return; 137 return;
138 } 138 }
139 Sink::Query query(*mail); 139 Sink::Query query = Sink::StandardQueries::completeThread(*mail);
140 query.liveQuery = false; 140 query.liveQuery = false;
141 query.request<Mail::Subject>(); 141 query.request<Mail::Subject>();
142 query.request<Mail::Sender>(); 142 query.request<Mail::Sender>();
diff --git a/framework/domain/maillistmodel.h b/framework/domain/maillistmodel.h
index 13662a17..a7cb5d84 100644
--- a/framework/domain/maillistmodel.h
+++ b/framework/domain/maillistmodel.h
@@ -50,10 +50,11 @@ public:
50 Draft, 50 Draft,
51 Id, 51 Id,
52 MimeMessage, 52 MimeMessage,
53 DomainObject 53 DomainObject,
54 ThreadSize
54 }; 55 };
55 56
56 QHash<int, QByteArray> roleNames() const; 57 QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
57 58
58 void runQuery(const Sink::Query &query); 59 void runQuery(const Sink::Query &query);
59 60
diff --git a/framework/domain/mailplugin.cpp b/framework/domain/mailplugin.cpp
index 9f06fd5f..c7023bde 100644
--- a/framework/domain/mailplugin.cpp
+++ b/framework/domain/mailplugin.cpp
@@ -28,6 +28,7 @@
28#include "accountfactory.h" 28#include "accountfactory.h"
29#include "accountscontroller.h" 29#include "accountscontroller.h"
30#include "accountsmodel.h" 30#include "accountsmodel.h"
31#include "outboxmodel.h"
31 32
32#include <QtQml> 33#include <QtQml>
33 34
@@ -43,4 +44,5 @@ void MailPlugin::registerTypes (const char *uri)
43 qmlRegisterType<AccountFactory>(uri, 1, 0, "AccountFactory"); 44 qmlRegisterType<AccountFactory>(uri, 1, 0, "AccountFactory");
44 qmlRegisterType<AccountsController>(uri, 1, 0, "AccountsController"); 45 qmlRegisterType<AccountsController>(uri, 1, 0, "AccountsController");
45 qmlRegisterType<AccountsModel>(uri, 1, 0, "AccountsModel"); 46 qmlRegisterType<AccountsModel>(uri, 1, 0, "AccountsModel");
47 qmlRegisterType<OutboxModel>(uri, 1, 0, "OutboxModel");
46} 48}
diff --git a/framework/domain/outboxmodel.cpp b/framework/domain/outboxmodel.cpp
new file mode 100644
index 00000000..b3533976
--- /dev/null
+++ b/framework/domain/outboxmodel.cpp
@@ -0,0 +1,114 @@
1/*
2 Copyright (c) 2016 Michael Bohlender <michael.bohlender@kdemail.net>
3 Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com>
4
5 This library is free software; you can redistribute it and/or modify it
6 under the terms of the GNU Library General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or (at your
8 option) any later version.
9
10 This library is distributed in the hope that it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 02110-1301, USA.
19*/
20
21#include "outboxmodel.h"
22
23#include <QFile>
24#include <QDateTime>
25
26#include <sink/standardqueries.h>
27
28
29OutboxModel::OutboxModel(QObject *parent)
30 : QSortFilterProxyModel()
31{
32 setDynamicSortFilter(true);
33 sort(0, Qt::DescendingOrder);
34
35 using namespace Sink::ApplicationDomain;
36 auto query = Sink::StandardQueries::outboxMails();
37 query.liveQuery = true;
38 query.request<Mail::Subject>();
39 query.request<Mail::Sender>();
40 query.request<Mail::SenderName>();
41 query.request<Mail::Date>();
42 query.request<Mail::Unread>();
43 query.request<Mail::Important>();
44 query.request<Mail::Draft>();
45 query.request<Mail::Folder>();
46 runQuery(query);
47}
48
49OutboxModel::~OutboxModel()
50{
51
52}
53
54QHash< int, QByteArray > OutboxModel::roleNames() const
55{
56 QHash<int, QByteArray> roles;
57
58 roles[Subject] = "subject";
59 roles[Sender] = "sender";
60 roles[SenderName] = "senderName";
61 roles[Date] = "date";
62 roles[Unread] = "unread";
63 roles[Important] = "important";
64 roles[Draft] = "draft";
65 roles[Id] = "id";
66 roles[MimeMessage] = "mimeMessage";
67 roles[DomainObject] = "domainObject";
68
69 return roles;
70}
71
72QVariant OutboxModel::data(const QModelIndex &idx, int role) const
73{
74 auto srcIdx = mapToSource(idx);
75 auto mail = srcIdx.data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Mail::Ptr>();
76 switch (role) {
77 case Subject:
78 return mail->getSubject();
79 case Sender:
80 return mail->getSender();
81 case SenderName:
82 return mail->getSenderName();
83 case Date:
84 return mail->getDate();
85 case Unread:
86 return mail->getUnread();
87 case Important:
88 return mail->getImportant();
89 case Draft:
90 return mail->getDraft();
91 case Id:
92 return mail->identifier();
93 case DomainObject:
94 return QVariant::fromValue(mail);
95 case MimeMessage: {
96 return mail->getMimeMessage();
97 }
98 }
99 return QSortFilterProxyModel::data(idx, role);
100}
101
102bool OutboxModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
103{
104 const auto leftDate = left.data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Mail::Ptr>()->getDate();
105 const auto rightDate = right.data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Mail::Ptr>()->getDate();
106 return leftDate < rightDate;
107}
108
109void OutboxModel::runQuery(const Sink::Query &query)
110{
111 m_model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query);
112 setSourceModel(m_model.data());
113}
114
diff --git a/framework/domain/outboxmodel.h b/framework/domain/outboxmodel.h
new file mode 100644
index 00000000..d2fa17ac
--- /dev/null
+++ b/framework/domain/outboxmodel.h
@@ -0,0 +1,60 @@
1/*
2 Copyright (c) 2016 Michael Bohlender <michael.bohlender@kdemail.net>
3 Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com>
4
5 This library is free software; you can redistribute it and/or modify it
6 under the terms of the GNU Library General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or (at your
8 option) any later version.
9
10 This library is distributed in the hope that it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 02110-1301, USA.
19*/
20
21#pragma once
22
23#include <sink/store.h>
24
25#include <QSortFilterProxyModel>
26#include <QSharedPointer>
27#include <QStringList>
28
29class OutboxModel : public QSortFilterProxyModel
30{
31 Q_OBJECT
32
33public:
34 OutboxModel(QObject *parent = Q_NULLPTR);
35 ~OutboxModel();
36
37 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
38
39 bool lessThan(const QModelIndex &left, const QModelIndex &right) const Q_DECL_OVERRIDE;
40
41 enum Roles {
42 Subject = Qt::UserRole + 1,
43 Sender,
44 SenderName,
45 Date,
46 Unread,
47 Important,
48 Draft,
49 Id,
50 MimeMessage,
51 DomainObject
52 };
53
54 QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
55
56 void runQuery(const Sink::Query &query);
57
58private:
59 QSharedPointer<QAbstractItemModel> m_model;
60};