diff options
author | Tobias Markmann <tm@ayena.de> | 2016-09-05 15:44:24 (GMT) |
---|---|---|
committer | Kevin Smith <kevin.smith@isode.com> | 2016-09-07 10:47:40 (GMT) |
commit | 615b87497cd8d4eedc386f002931d6d353f53ccd (patch) | |
tree | 2e3b0946e74415149b33973668ba9216d6f61d13 /Swift/QtUI/MUCSearch/QtLeafSortFilterProxyModel.cpp | |
parent | b54df5d2a50d4dda0e63ac06050d4ed306952dbb (diff) | |
download | swift-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.cpp')
-rw-r--r-- | Swift/QtUI/MUCSearch/QtLeafSortFilterProxyModel.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/Swift/QtUI/MUCSearch/QtLeafSortFilterProxyModel.cpp b/Swift/QtUI/MUCSearch/QtLeafSortFilterProxyModel.cpp new file mode 100644 index 0000000..b8cf15a --- /dev/null +++ b/Swift/QtUI/MUCSearch/QtLeafSortFilterProxyModel.cpp @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2016 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + +#include <Swift/QtUI/MUCSearch/QtLeafSortFilterProxyModel.h> + +namespace Swift { + +QtLeafSortFilterProxyModel::QtLeafSortFilterProxyModel(QObject* parent) : QSortFilterProxyModel(parent) { + +} + +QtLeafSortFilterProxyModel::~QtLeafSortFilterProxyModel() { + +} + +bool QtLeafSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const { + if (!sourceModel()->hasChildren(sourceModel()->index(source_row, 0, source_parent))) { + return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent); + } + else { + return true; + } +} + +} |