navigationwidget.hh 1.48 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#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
{
18
// Forward declaration
19
class NavigationItem;
20
class NavigationModel;
21

22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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;
};

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

 public:
  NavigationWidget(QWidget* parent = nullptr);

  void collapse(QStandardItem* item);

  void expand(QStandardItem* item);
51
  NavigationModel* navigationModel();
52
53

  QTreeView* navigationTree() const;
54
55
 private slots:
  void contextMenuRequested(QPoint);
56
57
58
59
 public slots:
  void filterModel(const QString& pattern);
  void itemDoubleClicked(QModelIndex index);

60
 signals:
61
62
  void itemChecked(const QModelIndex& index);
  void itemUnchecked(const QModelIndex& index);
63
64
65
66
67
68
69
70
71
72
73
74

 private:
  void initLayout();

  void initMembers();

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

#endif /** RADIX_RADIXWIDGETS_NAVIGATIONWIDGET_HH_ */