summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Heinecke <aheinecke@intevation.de>2016-05-12 10:51:55 (GMT)
committerAndre Heinecke <aheinecke@intevation.de>2016-07-22 09:10:27 (GMT)
commitb2c8f4d901abc0d140ece2c321bc5defa4fb9a07 (patch)
treeb557129374a7a6dc0b8e6087e925bd3c114971d2
parent1ca721ca8d983726aeeb58f07347f5ef59737dd1 (diff)
Respect custom filter column in sort filter model
-rw-r--r--src/models/keylistsortfilterproxymodel.cpp27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/models/keylistsortfilterproxymodel.cpp b/src/models/keylistsortfilterproxymodel.cpp
index d71d9e6..9c79ce9 100644
--- a/src/models/keylistsortfilterproxymodel.cpp
+++ b/src/models/keylistsortfilterproxymodel.cpp
@@ -34,6 +34,8 @@
#include "keylistsortfilterproxymodel.h"
+#include "kleopatra_debug.h"
+
#include "keylistmodel.h"
#include <Libkleo/KeyFilter>
@@ -177,21 +179,30 @@ bool KeyListSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelI
}
//
- // 1. Check that name or email matches filterRegExp
+ // 1. Check filterRegExp
//
const int role = filterRole();
-
+ const int col = filterKeyColumn();
+ const QRegExp rx = filterRegExp();
const QModelIndex nameIndex = sourceModel()->index(source_row, PrettyName, source_parent);
- const QString name = nameIndex.data(role).toString();
- const QModelIndex emailIndex = sourceModel()->index(source_row, PrettyEMail, source_parent);
- const QString email = emailIndex.data(role).toString();
+ if (col) {
+ const QModelIndex colIdx = sourceModel()->index(source_row, col, source_parent);
+ const QString content = colIdx.data(role).toString();
+ if (!content.contains(rx)) {
+ return false;
+ }
+ } else {
+ // By default match name and email
+ const QString name = nameIndex.data(role).toString();
- const QRegExp rx = filterRegExp();
- if (!name.contains(rx))
- if (!email.contains(rx)) {
+ const QModelIndex emailIndex = sourceModel()->index(source_row, PrettyEMail, source_parent);
+ const QString email = emailIndex.data(role).toString();
+
+ if (!name.contains(rx) && !email.contains(rx)) {
return false;
}
+ }
//
// 2. Check that key filters match (if any are defined)