summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-09-05 15:44:24 (GMT)
committerKevin Smith <kevin.smith@isode.com>2016-09-07 10:47:40 (GMT)
commit615b87497cd8d4eedc386f002931d6d353f53ccd (patch)
tree2e3b0946e74415149b33973668ba9216d6f61d13 /Swift/QtUI/MUCSearch/QtLeafSortFilterProxyModel.h
parentb54df5d2a50d4dda0e63ac06050d4ed306952dbb (diff)
downloadswift-615b87497cd8d4eedc386f002931d6d353f53ccd.zip
swift-615b87497cd8d4eedc386f002931d6d353f53ccd.tar.bz2
Add ability to filter results in "Search Room" dialog
This is implemented with the help of an implementation of QSortFilterProxyModel which filters room names based on a user search string. Test-Information: Tested on OS X 10.11.6 with Qt 5.5.1. Tested UX with different MUC services and search strings. Change-Id: I88085d089493008b2197a4aeb45d8c4d75724b9c
Diffstat (limited to 'Swift/QtUI/MUCSearch/QtLeafSortFilterProxyModel.h')
-rw-r--r--Swift/QtUI/MUCSearch/QtLeafSortFilterProxyModel.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/Swift/QtUI/MUCSearch/QtLeafSortFilterProxyModel.h b/Swift/QtUI/MUCSearch/QtLeafSortFilterProxyModel.h
new file mode 100644
index 0000000..b4be622
--- /dev/null
+++ b/Swift/QtUI/MUCSearch/QtLeafSortFilterProxyModel.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2016 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <QSortFilterProxyModel>
+
+namespace Swift {
+
+/**
+ * @brief The QtLeafSortFilterProxyModel class is similar to the QSortFilterProxyModel
+ * class. While the basic QSortFilterProxyModel class filters all hierarchical items,
+ * the QtLeafSortFilterProxyModel class will only filter on items without children.
+ */
+class QtLeafSortFilterProxyModel : public QSortFilterProxyModel {
+ Q_OBJECT
+
+public:
+ QtLeafSortFilterProxyModel(QObject* parent = nullptr);
+ virtual ~QtLeafSortFilterProxyModel();
+
+protected:
+ virtual bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const;
+};
+
+}