]> git.sven.stormbind.net Git - sven/vym.git/blob - src/treemodel.h
New upstream version 2.9.22
[sven/vym.git] / src / treemodel.h
1 #ifndef TREEMODEL_H
2 #define TREEMODEL_H
3
4 #include <QAbstractItemModel>
5 #include <QModelIndex>
6 #include <QVariant>
7
8 class BranchItem;
9 class TreeItem;
10 class Link;
11 class LinkableMapObj;
12
13 class TreeModel : public QAbstractItemModel {
14     Q_OBJECT
15
16   public:
17     TreeModel(QObject *parent = 0);
18     ~TreeModel();
19
20     QVariant data(const QModelIndex &index, int role) const;
21     Qt::ItemFlags flags(const QModelIndex &index) const;
22     QVariant headerData(int section, Qt::Orientation orientation,
23                         int role = Qt::DisplayRole) const;
24     QModelIndex index(TreeItem *ti);
25     QModelIndex index(int row, int column,
26                       const QModelIndex &parent = QModelIndex()) const;
27     QModelIndex parent(const QModelIndex &index) const;
28     int rowCount(const QModelIndex &parent = QModelIndex()) const;
29     int columnCount(const QModelIndex &parent = QModelIndex()) const;
30
31     void nextBranch(BranchItem *&current, BranchItem *&previous,
32                     bool deepLevelsFirst = false, BranchItem *start = NULL);
33
34     bool removeRows(int row, int count,
35                     const QModelIndex &parent = QModelIndex());
36
37     TreeItem *getItem(const QModelIndex &index) const;
38     BranchItem *getRootItem();
39
40     virtual int xlinkCount();
41     virtual Link *getXLinkNum(const int &n);
42
43   protected:
44     BranchItem *rootItem;
45
46     QList<Link *> xlinks;
47     QList<uint> deleteLaterIDs;
48
49     QColor backgroundColor; // Set in VymModel to optimize backgroundRole
50     QColor selectionColor;  // Set in VymModel to optimize highlightedText palette
51 };
52
53 #endif