diff options
Diffstat (limited to 'framework/src/domain/composercontroller.cpp')
-rw-r--r-- | framework/src/domain/composercontroller.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/framework/src/domain/composercontroller.cpp b/framework/src/domain/composercontroller.cpp index 4bfc34ab..09d4c154 100644 --- a/framework/src/domain/composercontroller.cpp +++ b/framework/src/domain/composercontroller.cpp | |||
@@ -94,8 +94,11 @@ public: | |||
94 | 94 | ||
95 | class AddresseeController : public Kube::ListPropertyController | 95 | class AddresseeController : public Kube::ListPropertyController |
96 | { | 96 | { |
97 | Q_OBJECT | ||
98 | Q_PROPERTY(bool foundAllKeys READ foundAllKeys NOTIFY foundAllKeysChanged) | ||
97 | public: | 99 | public: |
98 | 100 | ||
101 | bool mFoundAllKeys = true; | ||
99 | QSet<QByteArray> mMissingKeys; | 102 | QSet<QByteArray> mMissingKeys; |
100 | AddresseeController() | 103 | AddresseeController() |
101 | : Kube::ListPropertyController{{"name", "keyFound", "key"}} | 104 | : Kube::ListPropertyController{{"name", "keyFound", "key"}} |
@@ -103,11 +106,29 @@ public: | |||
103 | QObject::connect(this, &Kube::ListPropertyController::added, this, [this] (const QByteArray &id, const QVariantMap &map) { | 106 | QObject::connect(this, &Kube::ListPropertyController::added, this, [this] (const QByteArray &id, const QVariantMap &map) { |
104 | findKey(id, map.value("name").toString()); | 107 | findKey(id, map.value("name").toString()); |
105 | }); | 108 | }); |
109 | QObject::connect(this, &Kube::ListPropertyController::removed, this, [this] (const QByteArray &id) { | ||
110 | mMissingKeys.remove(id); | ||
111 | setFoundAllKeys(mMissingKeys.isEmpty()); | ||
112 | }); | ||
113 | |||
114 | |||
115 | } | ||
116 | |||
117 | bool foundAllKeys() | ||
118 | { | ||
119 | return mFoundAllKeys; | ||
120 | } | ||
121 | |||
122 | void setFoundAllKeys(bool found) | ||
123 | { | ||
124 | mFoundAllKeys = found; | ||
125 | emit foundAllKeysChanged(); | ||
106 | } | 126 | } |
107 | 127 | ||
108 | void findKey(const QByteArray &id, const QString &addressee) | 128 | void findKey(const QByteArray &id, const QString &addressee) |
109 | { | 129 | { |
110 | mMissingKeys << id; | 130 | mMissingKeys << id; |
131 | setFoundAllKeys(mMissingKeys.isEmpty()); | ||
111 | KMime::Types::Mailbox mb; | 132 | KMime::Types::Mailbox mb; |
112 | mb.fromUnicodeString(addressee); | 133 | mb.fromUnicodeString(addressee); |
113 | 134 | ||
@@ -124,7 +145,7 @@ public: | |||
124 | setValue(id, "keyFound", true); | 145 | setValue(id, "keyFound", true); |
125 | setValue(id, "key", QVariant::fromValue(keys)); | 146 | setValue(id, "key", QVariant::fromValue(keys)); |
126 | mMissingKeys.remove(id); | 147 | mMissingKeys.remove(id); |
127 | setProperty("foundAllKeys", mMissingKeys.isEmpty()); | 148 | setFoundAllKeys(mMissingKeys.isEmpty()); |
128 | } else { | 149 | } else { |
129 | SinkWarning() << "Failed to find key for recipient."; | 150 | SinkWarning() << "Failed to find key for recipient."; |
130 | } | 151 | } |
@@ -137,6 +158,8 @@ public: | |||
137 | add({{"name", email}}); | 158 | add({{"name", email}}); |
138 | } | 159 | } |
139 | } | 160 | } |
161 | signals: | ||
162 | void foundAllKeysChanged(); | ||
140 | }; | 163 | }; |
141 | 164 | ||
142 | class AttachmentController : public Kube::ListPropertyController | 165 | class AttachmentController : public Kube::ListPropertyController |
@@ -542,3 +565,4 @@ void ComposerController::saveAsDraft() | |||
542 | run(job); | 565 | run(job); |
543 | } | 566 | } |
544 | 567 | ||
568 | #include "composercontroller.moc" | ||