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/QtExpandedListView.h
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/QtExpandedListView.h')
-rw-r--r--Swift/QtUI/QtExpandedListView.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/Swift/QtUI/QtExpandedListView.h b/Swift/QtUI/QtExpandedListView.h
new file mode 100644
index 0000000..df78376
--- /dev/null
+++ b/Swift/QtUI/QtExpandedListView.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2018 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <QListView>
+
+namespace Swift {
+
+class QtExpandedListView : public QListView {
+public:
+ QtExpandedListView(QWidget* parent);
+ ~QtExpandedListView() override;
+
+ void setModel(QAbstractItemModel* model) override;
+ bool viewportEvent(QEvent* event) override;
+ QSize minimumSizeHint() const override;
+ QSize sizeHint() const override;
+
+protected slots:
+ void currentChanged(const QModelIndex &current, const QModelIndex &previous) override;
+
+private slots:
+ void adjustHeightToModelChange();
+
+private:
+ void connectToModel(QAbstractItemModel* model);
+ void disconnectFromModel(QAbstractItemModel* model);
+};
+
+}