From 7339cc0c0a0c63576f38f0bc96c15f28967b92d1 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 30 Mar 2017 13:51:09 +0200 Subject: Indicate if the outbox is not empty ..we could of course also just hide the outbox if empty. --- framework/domain/outboxmodel.cpp | 6 ++++++ framework/domain/outboxmodel.h | 5 +++++ 2 files changed, 11 insertions(+) (limited to 'framework/domain') 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) query.request(); query.request(); runQuery(query); + connect(this, &QAbstractItemModel::rowsInserted, this, &OutboxModel::countChanged); + connect(this, &QAbstractItemModel::rowsRemoved, this, &OutboxModel::countChanged); } OutboxModel::~OutboxModel() @@ -96,3 +98,7 @@ void OutboxModel::runQuery(const Sink::Query &query) setSourceModel(m_model.data()); } +int OutboxModel::count() const +{ + return rowCount(); +} 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 { Q_OBJECT + Q_PROPERTY (int count READ count NOTIFY countChanged) public: enum Status { PendingStatus, @@ -58,6 +59,10 @@ public: void runQuery(const Sink::Query &query); + int count() const; +signals: + void countChanged(); + private: QSharedPointer m_model; }; -- cgit v1.2.3