Implement filter

Add a proxy model class with filter logic, and use it as the model for
events ListView.
This commit is contained in:
Timotej Lazar 2021-09-05 21:16:46 +02:00
parent cb76fedcbc
commit 8d44150598
No known key found for this signature in database
GPG key ID: B6F38793D143456F
6 changed files with 144 additions and 12 deletions

25
event_filter.h Normal file
View file

@ -0,0 +1,25 @@
#ifndef EVENT_FILTER_H
#define EVENT_FILTER_H
#include <QList>
#include <QPair>
#include <QSortFilterProxyModel>
#include <QString>
#include <qqml.h>
class EventFilter : public QSortFilterProxyModel
{
Q_OBJECT
QML_ELEMENT
public slots:
void setFilter(const QString& filter = "");
bool remove(int row);
protected:
bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const override;
private:
QList<QPair<QString, QString>> filters;
};
#endif