summaryrefslogtreecommitdiff
path: root/src/filterwidget.h
blob: 4fee598342e16676535417bc89f13bc1c6211cfc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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