]> git.sven.stormbind.net Git - sven/vym.git/blob - slidemodel.h
a0f6e40016d4bed32761ab20f80e2904c7f813db
[sven/vym.git] / 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 {
18     Q_OBJECT
19
20 public:
21     SlideModel( VymModel *vm);
22     ~SlideModel();
23     void clear();
24     
25     VymModel* getVymModel();
26     QVariant data(const QModelIndex &index, int role) const;
27     QVariant headerData(int section, Qt::Orientation orientation,
28                         int role = Qt::DisplayRole) const;
29
30     QModelIndex index (SlideItem *fri);
31     QModelIndex index(int row, int column,
32                       const QModelIndex &parent = QModelIndex()) const;
33     QModelIndex parent(const QModelIndex &index) const;
34
35     int count();
36     int rowCount(const QModelIndex &parent = QModelIndex()) const;
37     int columnCount(const QModelIndex &parent = QModelIndex()) const;
38
39     Qt::ItemFlags flags(const QModelIndex &index) const;
40     bool setData(const QModelIndex &index, const QVariant &value,
41                  int role = Qt::EditRole);
42     bool setHeaderData(int section, Qt::Orientation orientation,
43                        const QVariant &value, int role = Qt::EditRole);
44
45     bool insertColumns(int position, int columns,
46                        const QModelIndex &parent = QModelIndex());
47     bool removeColumns(int position, int columns,
48                        const QModelIndex &parent = QModelIndex());
49     bool insertRows(int position, int rows,
50                     const QModelIndex &parent = QModelIndex());
51     bool removeRows(int position, int rows,
52                     const QModelIndex &parent = QModelIndex());
53
54     SlideItem* addSlide ( SlideItem *dst=NULL, int n=-1);
55     void deleteSlide (SlideItem *si);
56     bool relinkSlide (SlideItem *si, SlideItem *dst, int pos);
57
58     SlideItem* getItem (const QModelIndex &index) const;
59     SlideItem* getSlide (int n); 
60     SlideItem* findSlideID (uint n);
61     QString saveToDir ();
62
63     void setSearchString( const QString &s);
64     QString getSearchString();
65     void setSearchFlags( QTextDocument::FindFlags f);
66     QTextDocument::FindFlags getSearchFlags();
67
68 // Selection related
69 public:
70     void setSelectionModel(QItemSelectionModel *);
71     QItemSelectionModel* getSelectionModel();
72     QModelIndex getSelectedIndex();
73     SlideItem* getSelectedItem();
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