diff options
| author | AL <26797547+Al12rs@users.noreply.github.com> | 2020-02-01 21:28:14 +0100 |
|---|---|---|
| committer | AL <26797547+Al12rs@users.noreply.github.com> | 2020-02-01 21:28:14 +0100 |
| commit | 326c9130c43ec73a9d12ea65d92b60821d4f8e91 (patch) | |
| tree | fd21871a39ca48e98a92e88c4ec6a35631ee191a /src/filterwidget.h | |
| parent | 9c8412a051013f0ba8b70d4cb56d3d0428d827f0 (diff) | |
Moved filterWidget and eventFilter to ui base
Diffstat (limited to 'src/filterwidget.h')
| -rw-r--r-- | src/filterwidget.h | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/src/filterwidget.h b/src/filterwidget.h deleted file mode 100644 index 4fb9831f..00000000 --- a/src/filterwidget.h +++ /dev/null @@ -1,70 +0,0 @@ -#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 : public QObject -{ - Q_OBJECT; - -public: - using predFun = std::function<bool (const QString& what)>; - - FilterWidget(); - - void setEdit(QLineEdit* edit); - void setList(QAbstractItemView* list); - void clear(); - bool empty() 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(); - void hookEvents(); - void repositionClearButton(); - - void onTextChanged(); - void onResized(); - - void compile(); -}; - -#endif // FILTERWIDGET_H |
