From 326c9130c43ec73a9d12ea65d92b60821d4f8e91 Mon Sep 17 00:00:00 2001 From: AL <26797547+Al12rs@users.noreply.github.com> Date: Sat, 1 Feb 2020 21:28:14 +0100 Subject: Moved filterWidget and eventFilter to ui base --- src/filterwidget.h | 70 ------------------------------------------------------ 1 file changed, 70 deletions(-) delete mode 100644 src/filterwidget.h (limited to 'src/filterwidget.h') 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 -#include -#include -#include -#include - -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; - - 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> m_compiled; - - void unhook(); - void createClear(); - void hookEvents(); - void repositionClearButton(); - - void onTextChanged(); - void onResized(); - - void compile(); -}; - -#endif // FILTERWIDGET_H -- cgit v1.3.1