diff options
author | Tobias Markmann <tm@ayena.de> | 2018-05-07 09:06:49 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2018-05-07 09:06:49 (GMT) |
commit | e9f6129a4ce5db25bcb6de47be94ee89357713d0 (patch) | |
tree | 5992b8d0146b7e82c5564843b85578fde7a1636f /Swift/QtUI | |
parent | 699eb1459ea478b2a0e20d6867cd6be19f939d6e (diff) | |
download | swift-e9f6129a4ce5db25bcb6de47be94ee89357713d0.zip swift-e9f6129a4ce5db25bcb6de47be94ee89357713d0.tar.bz2 |
Allow to hide empty overview bundles in roster
This fixes a regression of commit 19eefe668.
Test-Information:
Ran Swift and verified that the 'Unread' bundle is never shown
if empty.
Change-Id: If13b84291e08d14bbbed57f53e0999e78e20f21d
Diffstat (limited to 'Swift/QtUI')
-rw-r--r-- | Swift/QtUI/QtChatOverviewBundle.cpp | 22 | ||||
-rw-r--r-- | Swift/QtUI/QtChatOverviewBundle.h | 3 |
2 files changed, 23 insertions, 2 deletions
diff --git a/Swift/QtUI/QtChatOverviewBundle.cpp b/Swift/QtUI/QtChatOverviewBundle.cpp index 8505541..121ae2e 100644 --- a/Swift/QtUI/QtChatOverviewBundle.cpp +++ b/Swift/QtUI/QtChatOverviewBundle.cpp @@ -8,3 +8,2 @@ -#include <QDebug> #include <QHBoxLayout> @@ -95,3 +94,3 @@ QtChatOverviewBundle::QtChatOverviewBundle(ChattablesModel* rootModel, QString n headerLayout->addStretch(); - if (!hideWhenEmpty) { + if (!hideWhenEmpty_) { filterLabel_ = new QtClickableLabel(this); @@ -108,2 +107,15 @@ QtChatOverviewBundle::QtChatOverviewBundle(ChattablesModel* rootModel, QString n mainLayout->addWidget(listView_); + + if (hideWhenEmpty_) { + connect(proxyModel_, &QAbstractItemModel::modelReset, this, [&](){ + updateVisibility(); + }); + connect(proxyModel_, &QAbstractItemModel::rowsInserted, this, [&](){ + updateVisibility(); + }); + connect(proxyModel_, &QAbstractItemModel::rowsRemoved, this, [&](){ + updateVisibility(); + }); + updateVisibility(); + } } @@ -123,2 +135,8 @@ void QtChatOverviewBundle::handleFilterClicked() { +void QtChatOverviewBundle::updateVisibility() { + auto shouldBeVisible = (proxyModel_->rowCount(listView_->rootIndex()) > 0); + setVisible(shouldBeVisible); +} + + void QtChatOverviewBundle::handleItemClicked(const QModelIndex& index) { diff --git a/Swift/QtUI/QtChatOverviewBundle.h b/Swift/QtUI/QtChatOverviewBundle.h index 6e232ca..95fd5d2 100644 --- a/Swift/QtUI/QtChatOverviewBundle.h +++ b/Swift/QtUI/QtChatOverviewBundle.h @@ -51,2 +51,5 @@ namespace Swift { private: + void updateVisibility(); + + private: ChattablesModel* rootModel_; |