From 0c91d01eb26793e745138c4598cf15d9a21c0136 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 21 Mar 2017 12:11:49 +0100 Subject: Filtering for maillistmodel and peoplemodel Works surprisingly well and is very useful for testing. The searchbar in the maillistmodel is a temporary solution as the global searchbar has some usability issues. E.g. how do we reset the search? As an intermediate step we could just hide the searchbar and make it visible by clicking on the search button. --- framework/domain/maillistmodel.cpp | 11 +++++++++++ framework/domain/maillistmodel.h | 4 ++++ framework/domain/peoplemodel.cpp | 11 +++++++++++ framework/domain/peoplemodel.h | 4 ++++ 4 files changed, 30 insertions(+) (limited to 'framework') diff --git a/framework/domain/maillistmodel.cpp b/framework/domain/maillistmodel.cpp index 11fb9f82..5a462021 100644 --- a/framework/domain/maillistmodel.cpp +++ b/framework/domain/maillistmodel.cpp @@ -27,6 +27,7 @@ MailListModel::MailListModel(QObject *parent) { setDynamicSortFilter(true); sort(0, Qt::DescendingOrder); + setFilterCaseSensitivity(Qt::CaseInsensitive); } MailListModel::~MailListModel() @@ -34,6 +35,16 @@ MailListModel::~MailListModel() } +void MailListModel::setFilter(const QString &filter) +{ + setFilterWildcard(filter); +} + +QString MailListModel::filter() const +{ + return {}; +} + QHash< int, QByteArray > MailListModel::roleNames() const { QHash roles; diff --git a/framework/domain/maillistmodel.h b/framework/domain/maillistmodel.h index 5526a991..316ff4c6 100644 --- a/framework/domain/maillistmodel.h +++ b/framework/domain/maillistmodel.h @@ -31,6 +31,7 @@ class MailListModel : public QSortFilterProxyModel Q_OBJECT Q_PROPERTY (QVariant parentFolder READ parentFolder WRITE setParentFolder) Q_PROPERTY (QVariant mail READ mail WRITE setMail) + Q_PROPERTY (QString filter READ filter WRITE setFilter) public: MailListModel(QObject *parent = Q_NULLPTR); @@ -70,6 +71,9 @@ public: void setMail(const QVariant &mail); QVariant mail() const; + void setFilter(const QString &mail); + QString filter() const; + private: void fetchMail(Sink::ApplicationDomain::Mail::Ptr mail); diff --git a/framework/domain/peoplemodel.cpp b/framework/domain/peoplemodel.cpp index d33c6703..ef2cc9a0 100644 --- a/framework/domain/peoplemodel.cpp +++ b/framework/domain/peoplemodel.cpp @@ -29,6 +29,7 @@ PeopleModel::PeopleModel(QObject *parent) setDynamicSortFilter(true); sort(0, Qt::DescendingOrder); + setFilterCaseSensitivity(Qt::CaseInsensitive); Sink::Query query; query.setFlags(Sink::Query::LiveQuery); query.request(); @@ -43,6 +44,16 @@ PeopleModel::~PeopleModel() } +void PeopleModel::setFilter(const QString &filter) +{ + setFilterWildcard(filter); +} + +QString PeopleModel::filter() const +{ + return {}; +} + QHash< int, QByteArray > PeopleModel::roleNames() const { static QHash roles = { diff --git a/framework/domain/peoplemodel.h b/framework/domain/peoplemodel.h index 1e9d2d01..a59e752c 100644 --- a/framework/domain/peoplemodel.h +++ b/framework/domain/peoplemodel.h @@ -34,6 +34,7 @@ class PeopleModel : public QSortFilterProxyModel { Q_OBJECT Q_PROPERTY (QVariant addressbook READ addressbook WRITE setAddressbook) + Q_PROPERTY (QString filter READ filter WRITE setFilter) public: PeopleModel(QObject *parent = Q_NULLPTR); @@ -60,6 +61,9 @@ public: void setAddressbook(const QVariant &parentFolder); QVariant addressbook() const; + void setFilter(const QString &mail); + QString filter() const; + private: QSharedPointer mModel; }; -- cgit v1.2.3