diff options
-rw-r--r-- | components/package/contents/ui/SingleMailView.qml | 15 | ||||
-rw-r--r-- | framework/domain/mailcontroller.cpp | 10 | ||||
-rw-r--r-- | framework/domain/mailcontroller.h | 2 | ||||
-rw-r--r-- | framework/domain/maillistmodel.cpp | 7 | ||||
-rw-r--r-- | framework/domain/maillistmodel.h | 4 |
5 files changed, 37 insertions, 1 deletions
diff --git a/components/package/contents/ui/SingleMailView.qml b/components/package/contents/ui/SingleMailView.qml index 9b38b5be..5576391d 100644 --- a/components/package/contents/ui/SingleMailView.qml +++ b/components/package/contents/ui/SingleMailView.qml | |||
@@ -353,9 +353,24 @@ Item { | |||
353 | leftMargin: Kirigami.Units.gridUnit | 353 | leftMargin: Kirigami.Units.gridUnit |
354 | } | 354 | } |
355 | 355 | ||
356 | KubeFramework.MailController { | ||
357 | id: mailController | ||
358 | mail: model.mail | ||
359 | } | ||
360 | |||
356 | text: "Delete Mail" | 361 | text: "Delete Mail" |
357 | color: Kirigami.Theme.textColor | 362 | color: Kirigami.Theme.textColor |
358 | opacity: 0.5 | 363 | opacity: 0.5 |
364 | enabled: mailController.moveToTrashAction.enabled | ||
365 | MouseArea { | ||
366 | anchors.fill: parent | ||
367 | enabled: mailController.moveToTrashAction.enabled | ||
368 | onClicked: { | ||
369 | if (mailController.moveToTrashAction.enabled) { | ||
370 | mailController.moveToTrashAction.execute(); | ||
371 | } | ||
372 | } | ||
373 | } | ||
359 | } | 374 | } |
360 | 375 | ||
361 | Controls1.ToolButton { | 376 | Controls1.ToolButton { |
diff --git a/framework/domain/mailcontroller.cpp b/framework/domain/mailcontroller.cpp index 4c5ae5c6..3d29ba22 100644 --- a/framework/domain/mailcontroller.cpp +++ b/framework/domain/mailcontroller.cpp | |||
@@ -32,6 +32,16 @@ MailController::MailController() | |||
32 | QObject::connect(markAsReadAction(), &Kube::ControllerAction::triggered, this, &MailController::markAsRead); | 32 | QObject::connect(markAsReadAction(), &Kube::ControllerAction::triggered, this, &MailController::markAsRead); |
33 | QObject::connect(moveToTrashAction(), &Kube::ControllerAction::triggered, this, &MailController::moveToTrash); | 33 | QObject::connect(moveToTrashAction(), &Kube::ControllerAction::triggered, this, &MailController::moveToTrash); |
34 | QObject::connect(removeAction(), &Kube::ControllerAction::triggered, this, &MailController::remove); | 34 | QObject::connect(removeAction(), &Kube::ControllerAction::triggered, this, &MailController::remove); |
35 | |||
36 | QObject::connect(this, &MailController::mailChanged, &MailController::updateActions); | ||
37 | updateActions(); | ||
38 | } | ||
39 | |||
40 | void MailController::updateActions() | ||
41 | { | ||
42 | if (auto mail = getMail()) { | ||
43 | action_moveToTrash->setEnabled(!mail->getTrash()); | ||
44 | } | ||
35 | } | 45 | } |
36 | 46 | ||
37 | void MailController::markAsRead() | 47 | void MailController::markAsRead() |
diff --git a/framework/domain/mailcontroller.h b/framework/domain/mailcontroller.h index 6c41f433..c20cf595 100644 --- a/framework/domain/mailcontroller.h +++ b/framework/domain/mailcontroller.h | |||
@@ -32,4 +32,6 @@ class MailController : public Kube::Controller | |||
32 | 32 | ||
33 | public: | 33 | public: |
34 | explicit MailController(); | 34 | explicit MailController(); |
35 | private slots: | ||
36 | void updateActions(); | ||
35 | }; | 37 | }; |
diff --git a/framework/domain/maillistmodel.cpp b/framework/domain/maillistmodel.cpp index 17b98c2b..950a2b8d 100644 --- a/framework/domain/maillistmodel.cpp +++ b/framework/domain/maillistmodel.cpp | |||
@@ -55,6 +55,7 @@ QHash< int, QByteArray > MailListModel::roleNames() const | |||
55 | roles[MimeMessage] = "mimeMessage"; | 55 | roles[MimeMessage] = "mimeMessage"; |
56 | roles[DomainObject] = "domainObject"; | 56 | roles[DomainObject] = "domainObject"; |
57 | roles[ThreadSize] = "threadSize"; | 57 | roles[ThreadSize] = "threadSize"; |
58 | roles[Mail] = "mail"; | ||
58 | 59 | ||
59 | return roles; | 60 | return roles; |
60 | } | 61 | } |
@@ -97,6 +98,8 @@ QVariant MailListModel::data(const QModelIndex &idx, int role) const | |||
97 | return mail->getProperty("importantCollected").toList().contains(true); | 98 | return mail->getProperty("importantCollected").toList().contains(true); |
98 | case Draft: | 99 | case Draft: |
99 | return mail->getDraft(); | 100 | return mail->getDraft(); |
101 | case Trash: | ||
102 | return mail->getTrash(); | ||
100 | case Id: | 103 | case Id: |
101 | return mail->identifier(); | 104 | return mail->identifier(); |
102 | case DomainObject: | 105 | case DomainObject: |
@@ -105,6 +108,8 @@ QVariant MailListModel::data(const QModelIndex &idx, int role) const | |||
105 | return mail->getMimeMessage(); | 108 | return mail->getMimeMessage(); |
106 | case ThreadSize: | 109 | case ThreadSize: |
107 | return mail->getProperty("count").toInt(); | 110 | return mail->getProperty("count").toInt(); |
111 | case Mail: | ||
112 | return QVariant::fromValue(mail); | ||
108 | } | 113 | } |
109 | return QSortFilterProxyModel::data(idx, role); | 114 | return QSortFilterProxyModel::data(idx, role); |
110 | } | 115 | } |
@@ -142,6 +147,7 @@ void MailListModel::setParentFolder(const QVariant &parentFolder) | |||
142 | query.request<Mail::Unread>(); | 147 | query.request<Mail::Unread>(); |
143 | query.request<Mail::Important>(); | 148 | query.request<Mail::Important>(); |
144 | query.request<Mail::Draft>(); | 149 | query.request<Mail::Draft>(); |
150 | query.request<Mail::Trash>(); | ||
145 | query.request<Mail::Folder>(); | 151 | query.request<Mail::Folder>(); |
146 | qWarning() << "Running folder query: " << folder->resourceInstanceIdentifier() << folder->identifier(); | 152 | qWarning() << "Running folder query: " << folder->resourceInstanceIdentifier() << folder->identifier(); |
147 | runQuery(query); | 153 | runQuery(query); |
@@ -170,6 +176,7 @@ void MailListModel::setMail(const QVariant &variant) | |||
170 | query.request<Mail::Unread>(); | 176 | query.request<Mail::Unread>(); |
171 | query.request<Mail::Important>(); | 177 | query.request<Mail::Important>(); |
172 | query.request<Mail::Draft>(); | 178 | query.request<Mail::Draft>(); |
179 | query.request<Mail::Trash>(); | ||
173 | query.request<Mail::MimeMessage>(); | 180 | query.request<Mail::MimeMessage>(); |
174 | qWarning() << "Running mail query: " << mail->resourceInstanceIdentifier() << mail->identifier(); | 181 | qWarning() << "Running mail query: " << mail->resourceInstanceIdentifier() << mail->identifier(); |
175 | runQuery(query); | 182 | runQuery(query); |
diff --git a/framework/domain/maillistmodel.h b/framework/domain/maillistmodel.h index 22b97e11..71a0a6df 100644 --- a/framework/domain/maillistmodel.h +++ b/framework/domain/maillistmodel.h | |||
@@ -51,10 +51,12 @@ public: | |||
51 | Unread, | 51 | Unread, |
52 | Important, | 52 | Important, |
53 | Draft, | 53 | Draft, |
54 | Trash, | ||
54 | Id, | 55 | Id, |
55 | MimeMessage, | 56 | MimeMessage, |
56 | DomainObject, | 57 | DomainObject, |
57 | ThreadSize | 58 | ThreadSize, |
59 | |||
58 | }; | 60 | }; |
59 | 61 | ||
60 | QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE; | 62 | QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE; |