diff options
| author | Jeremy Rimpo <jrim@rimpo.org> | 2019-07-03 10:24:14 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-07-03 10:24:14 -0500 |
| commit | efec72a85a351f53880bffdba2438f6802d4f9ab (patch) | |
| tree | 94cf5dd724a16f29b458776ef5a83477ccfe2a52 /src/filterwidget.h | |
| parent | 1822c1dc655e60c7693b528004ed715305df45f5 (diff) | |
| parent | 7fe637ce4421e0c6d6ee6b103db5fcc4ef676c25 (diff) | |
Merge pull request #782 from isanae/modinfodialog-rework
Mod info dialog rework
Diffstat (limited to 'src/filterwidget.h')
| -rw-r--r-- | src/filterwidget.h | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/src/filterwidget.h b/src/filterwidget.h index 4fee5983..4fb9831f 100644 --- a/src/filterwidget.h +++ b/src/filterwidget.h @@ -1,25 +1,60 @@ #ifndef FILTERWIDGET_H #define FILTERWIDGET_H +#include <QObject> +#include <QLineEdit> +#include <QToolButton> +#include <QList> +#include <QAbstractItemView> + class EventFilter; +class FilterWidget; + +class FilterWidgetProxyModel : public QSortFilterProxyModel +{ + Q_OBJECT; + +public: + 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 + +class FilterWidget : public QObject { + Q_OBJECT; + public: - std::function<void ()> changed; + using predFun = std::function<bool (const QString& what)>; FilterWidget(); - void set(QLineEdit* edit); + void setEdit(QLineEdit* edit); + void setList(QAbstractItemView* list); void clear(); + bool empty() const; - 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; + QList<QList<QString>> m_compiled; void unhook(); void createClear(); @@ -28,6 +63,8 @@ private: void onTextChanged(); void onResized(); + + void compile(); }; #endif // FILTERWIDGET_H |
