summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-03-30 13:51:09 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-03-30 15:16:10 +0200
commit7339cc0c0a0c63576f38f0bc96c15f28967b92d1 (patch)
treefb4a4b7c1af6163efb8587b0a463633615850347
parent911fba21c3856a497073d7018bbc12f0ba7ac74d (diff)
downloadkube-7339cc0c0a0c63576f38f0bc96c15f28967b92d1.tar.gz
kube-7339cc0c0a0c63576f38f0bc96c15f28967b92d1.zip
Indicate if the outbox is not empty
..we could of course also just hide the outbox if empty.
-rw-r--r--components/package/contents/ui/Outbox.qml13
-rw-r--r--framework/domain/outboxmodel.cpp6
-rw-r--r--framework/domain/outboxmodel.h5
3 files changed, 23 insertions, 1 deletions
diff --git a/components/package/contents/ui/Outbox.qml b/components/package/contents/ui/Outbox.qml
index 1b48aa6f..1f0400d3 100644
--- a/components/package/contents/ui/Outbox.qml
+++ b/components/package/contents/ui/Outbox.qml
@@ -40,6 +40,17 @@ Button {
40 id: outboxController 40 id: outboxController
41 } 41 }
42 42
43 KubeFramework.OutboxModel {
44 id: outboxModel
45 }
46
47 states: [
48 State {
49 name: "noempty"; when: outboxModel.count > 0
50 PropertyChanges { target: root; text: "outbox (" + outboxModel.count + ")" }
51 }
52 ]
53
43 Popup { 54 Popup {
44 id: dialog 55 id: dialog
45 56
@@ -65,7 +76,7 @@ Button {
65 width: parent.width 76 width: parent.width
66 height: count * Kirigami.Units.gridUnit * 3 77 height: count * Kirigami.Units.gridUnit * 3
67 78
68 model: KubeFramework.OutboxModel {} 79 model: outboxModel
69 80
70 delegate: Rectangle { 81 delegate: Rectangle {
71 id: delegateRoot 82 id: delegateRoot
diff --git a/framework/domain/outboxmodel.cpp b/framework/domain/outboxmodel.cpp
index b82c1c6b..68a0e8be 100644
--- a/framework/domain/outboxmodel.cpp
+++ b/framework/domain/outboxmodel.cpp
@@ -40,6 +40,8 @@ OutboxModel::OutboxModel(QObject *parent)
40 query.request<Mail::Date>(); 40 query.request<Mail::Date>();
41 query.request<Mail::Folder>(); 41 query.request<Mail::Folder>();
42 runQuery(query); 42 runQuery(query);
43 connect(this, &QAbstractItemModel::rowsInserted, this, &OutboxModel::countChanged);
44 connect(this, &QAbstractItemModel::rowsRemoved, this, &OutboxModel::countChanged);
43} 45}
44 46
45OutboxModel::~OutboxModel() 47OutboxModel::~OutboxModel()
@@ -96,3 +98,7 @@ void OutboxModel::runQuery(const Sink::Query &query)
96 setSourceModel(m_model.data()); 98 setSourceModel(m_model.data());
97} 99}
98 100
101int OutboxModel::count() const
102{
103 return rowCount();
104}
diff --git a/framework/domain/outboxmodel.h b/framework/domain/outboxmodel.h
index 86821bc2..4e226223 100644
--- a/framework/domain/outboxmodel.h
+++ b/framework/domain/outboxmodel.h
@@ -30,6 +30,7 @@ class OutboxModel : public QSortFilterProxyModel
30{ 30{
31 Q_OBJECT 31 Q_OBJECT
32 32
33 Q_PROPERTY (int count READ count NOTIFY countChanged)
33public: 34public:
34 enum Status { 35 enum Status {
35 PendingStatus, 36 PendingStatus,
@@ -58,6 +59,10 @@ public:
58 59
59 void runQuery(const Sink::Query &query); 60 void runQuery(const Sink::Query &query);
60 61
62 int count() const;
63signals:
64 void countChanged();
65
61private: 66private:
62 QSharedPointer<QAbstractItemModel> m_model; 67 QSharedPointer<QAbstractItemModel> m_model;
63}; 68};