summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2018-05-04 11:00:18 (GMT)
committerTobias Markmann <tm@ayena.de>2018-05-04 11:00:18 (GMT)
commit19eefe66821d26a00d24fbe44aa870309d80ad4b (patch)
tree8ccac3836a98f45bd5e176d58a3a3c38b035653a /Swift/QtUI/QtChatOverviewBundle.cpp
parent202c114d6b1daa1ea1d4693c434bd8daabd41ad1 (diff)
downloadswift-19eefe66821d26a00d24fbe44aa870309d80ad4b.zip
swift-19eefe66821d26a00d24fbe44aa870309d80ad4b.tar.bz2
Use dedicated QtExpandedListView in new roster UI
QtExpandedListView is always high enough to show all entries in the model. It also correctly hands off scrolling events to the parent widget for smooth scrolling. Test-Information: Tested on macOS 10.13.4 with a well sized roster, that sizing and scrolling works as expected. Tested with Qt 5.5.1. Change-Id: I6d93db3045e1c2f343b89c0d45874d8f85a20c0a
Diffstat (limited to 'Swift/QtUI/QtChatOverviewBundle.cpp')
-rw-r--r--Swift/QtUI/QtChatOverviewBundle.cpp22
1 files changed, 2 insertions, 20 deletions
diff --git a/Swift/QtUI/QtChatOverviewBundle.cpp b/Swift/QtUI/QtChatOverviewBundle.cpp
index bf99b0c..8505541 100644
--- a/Swift/QtUI/QtChatOverviewBundle.cpp
+++ b/Swift/QtUI/QtChatOverviewBundle.cpp
@@ -9,7 +9,6 @@
#include <QDebug>
#include <QHBoxLayout>
#include <QLabel>
-#include <QListView>
#include <QPalette>
#include <QSortFilterProxyModel>
#include <QVBoxLayout>
@@ -19,6 +18,7 @@
#include <Swift/QtUI/ChattablesModel.h>
#include <Swift/QtUI/QtChatOverviewDelegate.h>
#include <Swift/QtUI/QtClickableLabel.h>
+#include <Swift/QtUI/QtExpandedListView.h>
#include <Swift/QtUI/QtSwiftUtil.h>
namespace Swift {
@@ -100,34 +100,16 @@ QtChatOverviewBundle::QtChatOverviewBundle(ChattablesModel* rootModel, QString n
headerLayout->addWidget(filterLabel_);
connect(filterLabel_, SIGNAL(clicked()), this, SLOT(handleFilterClicked()));
}
- listView_ = new QListView(this);
+ listView_ = new QtExpandedListView(this);
listView_->setModel(proxyModel_);
listView_->setFrameStyle(QFrame::NoFrame);
listView_->setItemDelegate(new QtChatOverviewDelegate(this));
connect(listView_, SIGNAL(clicked(const QModelIndex&)), this, SLOT(handleItemClicked(const QModelIndex&)));
- recalculateSize();
mainLayout->addWidget(listView_);
- connect(proxyModel_, SIGNAL(rowsInserted(const QModelIndex&, int, int)), this, SLOT(recalculateSize()));
- connect(proxyModel_, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), this, SLOT(recalculateSize()));
- connect(proxyModel_, SIGNAL(modelReset()), this, SLOT(recalculateSize()));
}
QtChatOverviewBundle::~QtChatOverviewBundle() {}
-void QtChatOverviewBundle::recalculateSize() {
- int totalHeight = 0;
- for (int i = 0; i < proxyModel_->rowCount(); i++) {
- totalHeight += listView_->sizeHintForRow(i);
- }
- listView_->setFixedHeight(totalHeight);
- if (hideWhenEmpty_ && totalHeight == 0) {
- hide();
- }
- else {
- show();
- }
-}
-
void QtChatOverviewBundle::handleFilterClicked() {
if (proxyModel_->hasFilter(BundleFilter::Filter::Online)) {
proxyModel_->removeFilter(BundleFilter::Filter::Online);