navigationwidget.hh 1.3 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#ifndef RADIX_RADIXWIDGETS_NAVIGATIONWIDGET_HH_
#define RADIX_RADIXWIDGETS_NAVIGATIONWIDGET_HH_

#include <QSortFilterProxyModel>
#include <QStandardItemModel>
#include <QStyledItemDelegate>
#include <QWidget>

#include <memory>

QT_BEGIN_NAMESPACE
class QStandardItem;
class QTreeView;
QT_END_NAMESPACE

namespace radix
{
class NavigationItem;

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
class NavigationItemSortFilterProxyModel : public QSortFilterProxyModel
{
  Q_OBJECT

 public:
  NavigationItemSortFilterProxyModel(QObject* parent = nullptr);

 public slots:
  void clearCache();

 protected:
  bool filterAcceptsRow(int row, const QModelIndex& parent) const;

 private:
  bool accepts(const QModelIndex& index) const;
  class PImpl;
  std::unique_ptr<PImpl, void (*)(PImpl*)> p;
};

39
40
41
42
43
44
45
46
47
48
49
50
51
class NavigationWidget : public QWidget
{
  Q_OBJECT

 public:
  NavigationWidget(QWidget* parent = nullptr);

  void collapse(QStandardItem* item);

  void expand(QStandardItem* item);

  QTreeView* navigationTree() const;

52
53
54
55
 public slots:
  void filterModel(const QString& pattern);
  void itemDoubleClicked(QModelIndex index);

56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
 signals:

  void itemActivated(NavigationItem* item);

 private:
  void initLayout();

  void initMembers();

  class PImpl;
  std::unique_ptr<PImpl, void (*)(PImpl*)> p;
};
}  // namespace radix

#endif /** RADIX_RADIXWIDGETS_NAVIGATIONWIDGET_HH_ */