navigationmodel.hh 1.33 KB
Newer Older
1
2
3
4
5
6
7
8
9
#ifndef RADIX_RADIXWIDGETS_NAVIGATIONMODEL_HH_
#define RADIX_RADIXWIDGETS_NAVIGATIONMODEL_HH_
#include <QAbstractItemModel>
#include <QObject>

#include <memory>

namespace radix
{
10
11
12
// Forward declaration
class NavigationItem;

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class NavigationModel : public QAbstractItemModel
{
  Q_OBJECT
 public:
  NavigationModel(QObject *parent = nullptr);

  QVariant data(const QModelIndex &index, int role) const override;
  bool setData(const QModelIndex &index, const QVariant &value,
               int role = Qt::EditRole) override;
  Qt::ItemFlags flags(const QModelIndex &index) const override;
  QVariant headerData(int section, Qt::Orientation orientation,
                      int role = Qt::DisplayRole) const override;
  QModelIndex index(int row, int column,
                    const QModelIndex &parent = QModelIndex()) const override;
  QModelIndex parent(const QModelIndex &index) const override;
  int rowCount(const QModelIndex &parent = QModelIndex()) const override;
  int columnCount(const QModelIndex &parent = QModelIndex()) const override;
30
31
  NavigationItem *rootItem();
  NavigationItem *addItem(QVariant value, NavigationItem *parent);
32

33
34
35
36
 signals:
  void itemChecked(const QModelIndex &index);
  void itemUnChecked(const QModelIndex &index);

37
38
39
40
41
42
43
 private:
  class PImpl;
  std::unique_ptr<PImpl, void (*)(PImpl *)> p;
};
}  // namespace radix

#endif