diff options
Diffstat (limited to 'framework/domain/outboxmodel.cpp')
-rw-r--r-- | framework/domain/outboxmodel.cpp | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/framework/domain/outboxmodel.cpp b/framework/domain/outboxmodel.cpp index 68a0e8be..7cfdc71a 100644 --- a/framework/domain/outboxmodel.cpp +++ b/framework/domain/outboxmodel.cpp | |||
@@ -25,10 +25,14 @@ | |||
25 | #include <QString> | 25 | #include <QString> |
26 | 26 | ||
27 | #include <sink/standardqueries.h> | 27 | #include <sink/standardqueries.h> |
28 | #include <sink/notifier.h> | ||
29 | #include <sink/notification.h> | ||
28 | 30 | ||
29 | 31 | ||
30 | OutboxModel::OutboxModel(QObject *parent) | 32 | OutboxModel::OutboxModel(QObject *parent) |
31 | : QSortFilterProxyModel() | 33 | : QSortFilterProxyModel(), |
34 | mNotifier(new Sink::Notifier{Sink::Query{}.containsFilter<Sink::ApplicationDomain::SinkResource::Capabilities>(Sink::ApplicationDomain::ResourceCapabilities::Mail::transport)}), | ||
35 | mStatus(NoStatus) | ||
32 | { | 36 | { |
33 | setDynamicSortFilter(true); | 37 | setDynamicSortFilter(true); |
34 | sort(0, Qt::DescendingOrder); | 38 | sort(0, Qt::DescendingOrder); |
@@ -42,6 +46,25 @@ OutboxModel::OutboxModel(QObject *parent) | |||
42 | runQuery(query); | 46 | runQuery(query); |
43 | connect(this, &QAbstractItemModel::rowsInserted, this, &OutboxModel::countChanged); | 47 | connect(this, &QAbstractItemModel::rowsInserted, this, &OutboxModel::countChanged); |
44 | connect(this, &QAbstractItemModel::rowsRemoved, this, &OutboxModel::countChanged); | 48 | connect(this, &QAbstractItemModel::rowsRemoved, this, &OutboxModel::countChanged); |
49 | |||
50 | mNotifier->registerHandler([this] (const Sink::Notification &n) { | ||
51 | if (n.type == Sink::Notification::Status) { | ||
52 | switch (n.code) { | ||
53 | case Sink::ApplicationDomain::Status::ErrorStatus: | ||
54 | mStatus = ErrorStatus; | ||
55 | break; | ||
56 | case Sink::ApplicationDomain::Status::BusyStatus: | ||
57 | mStatus = InProgressStatus; | ||
58 | break; | ||
59 | default: | ||
60 | mStatus = NoStatus; | ||
61 | break; | ||
62 | } | ||
63 | emit statusChanged(); | ||
64 | } | ||
65 | |||
66 | }); | ||
67 | |||
45 | } | 68 | } |
46 | 69 | ||
47 | OutboxModel::~OutboxModel() | 70 | OutboxModel::~OutboxModel() |
@@ -94,11 +117,16 @@ bool OutboxModel::lessThan(const QModelIndex &left, const QModelIndex &right) co | |||
94 | 117 | ||
95 | void OutboxModel::runQuery(const Sink::Query &query) | 118 | void OutboxModel::runQuery(const Sink::Query &query) |
96 | { | 119 | { |
97 | m_model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); | 120 | mModel = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); |
98 | setSourceModel(m_model.data()); | 121 | setSourceModel(mModel.data()); |
99 | } | 122 | } |
100 | 123 | ||
101 | int OutboxModel::count() const | 124 | int OutboxModel::count() const |
102 | { | 125 | { |
103 | return rowCount(); | 126 | return rowCount(); |
104 | } | 127 | } |
128 | |||
129 | int OutboxModel::status() const | ||
130 | { | ||
131 | return mStatus; | ||
132 | } | ||