diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-06-14 17:24:07 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-06-14 17:24:07 +0200 |
commit | d7b40aeb125ece23bf2f039f4bb938f5cd010896 (patch) | |
tree | 6b7fbd67d772f4f8bd6c3b826ccb4fd8d00b7f18 | |
parent | 86cbba1d765f27845d3f332cec60222e862b502c (diff) | |
download | kube-d7b40aeb125ece23bf2f039f4bb938f5cd010896.tar.gz kube-d7b40aeb125ece23bf2f039f4bb938f5cd010896.zip |
Attachment removal
We'd rather do something via the model index instead of requering an
additional role, but this works for the time being.
-rw-r--r-- | components/kube/contents/ui/ComposerView.qml | 1 | ||||
-rw-r--r-- | framework/src/domain/composercontroller.cpp | 15 | ||||
-rw-r--r-- | framework/src/domain/composercontroller.h | 5 |
3 files changed, 18 insertions, 3 deletions
diff --git a/components/kube/contents/ui/ComposerView.qml b/components/kube/contents/ui/ComposerView.qml index b92b0f2a..b8da8a83 100644 --- a/components/kube/contents/ui/ComposerView.qml +++ b/components/kube/contents/ui/ComposerView.qml | |||
@@ -271,6 +271,7 @@ Kube.View { | |||
271 | icon: model.iconName | 271 | icon: model.iconName |
272 | clip: true | 272 | clip: true |
273 | actionIcon: Kube.Icons.remove | 273 | actionIcon: Kube.Icons.remove |
274 | onExecute: composerController.removeAttachment(model.url) | ||
274 | } | 275 | } |
275 | } | 276 | } |
276 | } | 277 | } |
diff --git a/framework/src/domain/composercontroller.cpp b/framework/src/domain/composercontroller.cpp index 31cb896d..9e006af4 100644 --- a/framework/src/domain/composercontroller.cpp +++ b/framework/src/domain/composercontroller.cpp | |||
@@ -97,6 +97,7 @@ ComposerController::ComposerController() | |||
97 | {MimeTypeRole, "mimetype"}, | 97 | {MimeTypeRole, "mimetype"}, |
98 | {DescriptionRole, "description"}, | 98 | {DescriptionRole, "description"}, |
99 | {IconNameRole, "iconName"}, | 99 | {IconNameRole, "iconName"}, |
100 | {UrlRole, "url"}, | ||
100 | {InlineRole, "inline"}}); | 101 | {InlineRole, "inline"}}); |
101 | updateSaveAsDraftAction(); | 102 | updateSaveAsDraftAction(); |
102 | // mSendAction->monitorProperty<To>(); | 103 | // mSendAction->monitorProperty<To>(); |
@@ -218,13 +219,25 @@ void ComposerController::addAttachment(const QUrl &url) | |||
218 | item->setData(fileInfo.fileName(), FilenameRole); | 219 | item->setData(fileInfo.fileName(), FilenameRole); |
219 | item->setData(false, InlineRole); | 220 | item->setData(false, InlineRole); |
220 | item->setData(mimeType.iconName(), IconNameRole); | 221 | item->setData(mimeType.iconName(), IconNameRole); |
222 | item->setData(url, UrlRole); | ||
221 | item->setData(data, ContentRole); | 223 | item->setData(data, ContentRole); |
222 | mAttachmentModel->appendRow(item); | 224 | mAttachmentModel->appendRow(item); |
223 | } | 225 | } |
224 | } | 226 | } |
225 | 227 | ||
226 | void ComposerController::removeAttachment(const QString &s) | 228 | void ComposerController::removeAttachment(const QUrl &url) |
227 | { | 229 | { |
230 | auto root = mAttachmentModel->invisibleRootItem(); | ||
231 | if (root->hasChildren()) { | ||
232 | for (int row = 0; row < root->rowCount(); row++) { | ||
233 | auto item = root->child(row, 0); | ||
234 | const auto url = item->data(UrlRole).toUrl(); | ||
235 | if (url == item->data(UrlRole).toUrl()) { | ||
236 | root->removeRow(row); | ||
237 | return; | ||
238 | } | ||
239 | } | ||
240 | } | ||
228 | } | 241 | } |
229 | 242 | ||
230 | Completer *ComposerController::recipientCompleter() const | 243 | Completer *ComposerController::recipientCompleter() const |
diff --git a/framework/src/domain/composercontroller.h b/framework/src/domain/composercontroller.h index de154b66..b2486cee 100644 --- a/framework/src/domain/composercontroller.h +++ b/framework/src/domain/composercontroller.h | |||
@@ -92,7 +92,7 @@ public: | |||
92 | Q_INVOKABLE void addBcc(const QString &); | 92 | Q_INVOKABLE void addBcc(const QString &); |
93 | Q_INVOKABLE void removeBcc(const QString &); | 93 | Q_INVOKABLE void removeBcc(const QString &); |
94 | Q_INVOKABLE void addAttachment(const QUrl &); | 94 | Q_INVOKABLE void addAttachment(const QUrl &); |
95 | Q_INVOKABLE void removeAttachment(const QString &); | 95 | Q_INVOKABLE void removeAttachment(const QUrl &); |
96 | 96 | ||
97 | public slots: | 97 | public slots: |
98 | virtual void clear() Q_DECL_OVERRIDE; | 98 | virtual void clear() Q_DECL_OVERRIDE; |
@@ -109,7 +109,8 @@ private: | |||
109 | MimeTypeRole, | 109 | MimeTypeRole, |
110 | DescriptionRole, | 110 | DescriptionRole, |
111 | InlineRole, | 111 | InlineRole, |
112 | IconNameRole | 112 | IconNameRole, |
113 | UrlRole | ||
113 | }; | 114 | }; |
114 | 115 | ||
115 | void recordForAutocompletion(const QByteArray &addrSpec, const QByteArray &displayName); | 116 | void recordForAutocompletion(const QByteArray &addrSpec, const QByteArray &displayName); |