summaryrefslogtreecommitdiff
path: root/src/filterwidget.h
diff options
context:
space:
mode:
authorisanae <14251494+isanae@users.noreply.github.com>2019-06-25 16:41:32 -0400
committerisanae <14251494+isanae@users.noreply.github.com>2019-07-02 10:10:19 -0400
commit19a19ead4059c600680d6e7ac193490e32e03245 (patch)
tree3d19e3d8aa6f92207344a24a470bffb83ffde67d /src/filterwidget.h
parent00d4921e47e5eef08b10dac127795ecc8ccf84ae (diff)
filterwidget now support automatically installing a proxy on lists
filters on txt and ini tabs
Diffstat (limited to 'src/filterwidget.h')
-rw-r--r--src/filterwidget.h41
1 files changed, 37 insertions, 4 deletions
diff --git a/src/filterwidget.h b/src/filterwidget.h
index 762d9b15..5b08c3ae 100644
--- a/src/filterwidget.h
+++ b/src/filterwidget.h
@@ -1,22 +1,55 @@
#ifndef FILTERWIDGET_H
#define FILTERWIDGET_H
+#include <QObject>
+#include <QLineEdit>
+#include <QToolButton>
+#include <QList>
+#include <QAbstractItemView>
+
class EventFilter;
+class FilterWidget;
-class FilterWidget
+class FilterWidgetProxyModel : public QSortFilterProxyModel
{
+ Q_OBJECT;
+
public:
- std::function<void ()> changed;
+ FilterWidgetProxyModel(FilterWidget& fw, QWidget* parent=nullptr);
+ using QSortFilterProxyModel::invalidateFilter;
+
+protected:
+ bool filterAcceptsRow(int row, const QModelIndex& parent) const override;
+
+private:
+ FilterWidget& m_filter;
+};
+
+
+class FilterWidget : public QObject
+{
+ Q_OBJECT;
+
+public:
+ using predFun = std::function<bool (const QString& what)>;
FilterWidget();
- void set(QLineEdit* edit);
+ void setEdit(QLineEdit* edit);
+ void setList(QAbstractItemView* list);
void clear();
- bool matches(std::function<bool (const QString& what)> pred) const;
+ QModelIndex map(const QModelIndex& index);
+
+ bool matches(predFun pred) const;
+
+signals:
+ void changed();
private:
QLineEdit* m_edit;
+ QAbstractItemView* m_list;
+ FilterWidgetProxyModel* m_proxy;
EventFilter* m_eventFilter;
QToolButton* m_clear;
QString m_text;