From 5a5a8c11ed1b1a90452c4f7ed36650be36fbaa2c Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 27 Mar 2017 10:56:28 +0200 Subject: Filter on all things visible --- framework/domain/maillistmodel.cpp | 12 ++++++++++++ framework/domain/maillistmodel.h | 1 + 2 files changed, 13 insertions(+) (limited to 'framework') diff --git a/framework/domain/maillistmodel.cpp b/framework/domain/maillistmodel.cpp index 278dca22..3a507e05 100644 --- a/framework/domain/maillistmodel.cpp +++ b/framework/domain/maillistmodel.cpp @@ -158,6 +158,18 @@ bool MailListModel::lessThan(const QModelIndex &left, const QModelIndex &right) return leftDate < rightDate; } +bool MailListModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const +{ + auto idx = sourceModel()->index(sourceRow, 0, sourceParent); + auto regExp = filterRegExp(); + if (regExp.isEmpty()) { + return true; + } + auto mail = idx.data(Sink::Store::DomainObjectRole).value(); + return mail->getSubject().contains(regExp) || + mail->getSender().name.contains(regExp); +} + void MailListModel::runQuery(const Sink::Query &query) { m_model = Sink::Store::loadModel(query); diff --git a/framework/domain/maillistmodel.h b/framework/domain/maillistmodel.h index 8e22da60..44347661 100644 --- a/framework/domain/maillistmodel.h +++ b/framework/domain/maillistmodel.h @@ -47,6 +47,7 @@ public: QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; bool lessThan(const QModelIndex &left, const QModelIndex &right) const Q_DECL_OVERRIDE; + bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const Q_DECL_OVERRIDE; enum Roles { Subject = Qt::UserRole + 1, -- cgit v1.2.3