diff options
Diffstat (limited to 'Swift/QtUI/QtChatOverviewBundle.cpp')
-rw-r--r-- | Swift/QtUI/QtChatOverviewBundle.cpp | 22 |
1 files changed, 20 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) { |