summaryrefslogtreecommitdiff
path: root/src/history/historymodels.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/history/historymodels.cpp')
-rw-r--r--src/history/historymodels.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/history/historymodels.cpp b/src/history/historymodels.cpp
index 9ffc2643..48cdc78e 100644
--- a/src/history/historymodels.cpp
+++ b/src/history/historymodels.cpp
@@ -741,3 +741,35 @@ void HistoryTreeModel::sourceRowsRemoved(const QModelIndex &parent, int start, i
endRemoveRows();
}
}
+
+
+// ----------------------------------------------------------------------------------------------------------
+
+
+UrlFilterProxyModel::UrlFilterProxyModel(QObject *parent)
+ : QSortFilterProxyModel(parent)
+{
+ setFilterCaseSensitivity(Qt::CaseInsensitive);
+}
+
+
+bool UrlFilterProxyModel::filterAcceptsRow(const int source_row, const QModelIndex &source_parent) const
+{
+ return recursiveMatch(sourceModel()->index(source_row, 0, source_parent));
+}
+
+
+bool UrlFilterProxyModel::recursiveMatch(const QModelIndex &index) const
+{
+ if (index.data().toString().contains(filterRegExp()))
+ return true;
+
+ int numChildren = sourceModel()->rowCount(index);
+ for (int childRow = 0; childRow < numChildren; ++childRow)
+ {
+ if (recursiveMatch(sourceModel()->index(childRow, 0, index)))
+ return true;
+ }
+
+ return false;
+}