summaryrefslogtreecommitdiff
path: root/src/filterwidget.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/filterwidget.h')
-rw-r--r--src/filterwidget.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/filterwidget.h b/src/filterwidget.h
new file mode 100644
index 00000000..4fee5983
--- /dev/null
+++ b/src/filterwidget.h
@@ -0,0 +1,33 @@
+#ifndef FILTERWIDGET_H
+#define FILTERWIDGET_H
+
+class EventFilter;
+
+class FilterWidget
+{
+public:
+ std::function<void ()> changed;
+
+ FilterWidget();
+
+ void set(QLineEdit* edit);
+ void clear();
+
+ bool matches(std::function<bool (const QString& what)> pred) const;
+
+private:
+ QLineEdit* m_edit;
+ EventFilter* m_eventFilter;
+ QToolButton* m_clear;
+ QString m_text;
+
+ void unhook();
+ void createClear();
+ void hookEvents();
+ void repositionClearButton();
+
+ void onTextChanged();
+ void onResized();
+};
+
+#endif // FILTERWIDGET_H