]> git.sven.stormbind.net Git - sven/vym.git/blob - src/slidemodel.h
Replace Pierre as the maintainer
[sven/vym.git] / src / slidemodel.h
1 #ifndef SLIDEMODEL_H
2 #define SLIDEMODEL_H
3
4 #include <QAbstractItemModel>
5 #include <QModelIndex>
6 #include <QTextDocument>
7 #include <QVariant>
8
9 #include "xmlobj.h"
10
11 class QItemSelectionModel;
12 class SlideItem;
13 class TreeItem;
14 class VymModel;
15
16 class SlideModel : public QAbstractItemModel, XMLObj {
17     Q_OBJECT
18
19   public:
20     SlideModel(VymModel *vm);
21     ~SlideModel();
22     void clear();
23
24     VymModel *getVymModel();
25     QVariant data(const QModelIndex &index, int role) const;
26     QVariant headerData(int section, Qt::Orientation orientation,
27                         int role = Qt::DisplayRole) const;
28
29     QModelIndex index(SlideItem *fri);
30     QModelIndex index(int row, int column,
31                       const QModelIndex &parent = QModelIndex()) const;
32     QModelIndex parent(const QModelIndex &index) const;
33
34     int count();
35     int rowCount(const QModelIndex &parent = QModelIndex()) const;
36     int columnCount(const QModelIndex &parent = QModelIndex()) const;
37
38     Qt::ItemFlags flags(const QModelIndex &index) const;
39     bool setData(const QModelIndex &index, const QVariant &value,
40                  int role = Qt::EditRole);
41     bool setHeaderData(int section, Qt::Orientation orientation,
42                        const QVariant &value, int role = Qt::EditRole);
43
44     bool insertColumns(int position, int columns,
45                        const QModelIndex &parent = QModelIndex());
46     bool removeColumns(int position, int columns,
47                        const QModelIndex &parent = QModelIndex());
48     bool insertRows(int position, int rows,
49                     const QModelIndex &parent = QModelIndex());
50     bool removeRows(int position, int rows,
51                     const QModelIndex &parent = QModelIndex());
52
53     SlideItem *addSlide(SlideItem *dst = NULL, int n = -1);
54     void deleteSlide(SlideItem *si);
55     bool relinkSlide(SlideItem *si, SlideItem *dst, int pos);
56
57     SlideItem *getItem(const QModelIndex &index) const;
58     SlideItem *getSlide(int n);
59     SlideItem *findSlideID(uint n);
60     QString saveToDir();
61
62     void setSearchString(const QString &s);
63     QString getSearchString();
64     void setSearchFlags(QTextDocument::FindFlags f);
65     QTextDocument::FindFlags getSearchFlags();
66
67     // Selection related
68   public:
69     void setSelectionModel(QItemSelectionModel *);
70     QItemSelectionModel *getSelectionModel();
71     QModelIndex getSelectedIndex();
72     SlideItem *getSelectedItem();
73
74   private:
75     QItemSelectionModel *selModel;
76     VymModel *vymModel; // needed for saveToDir
77
78   private:
79     SlideItem *rootItem;
80
81     QString searchString;
82     QTextDocument::FindFlags searchFlags;
83 };
84
85 #endif