Olive
projectmodel.h
Go to the documentation of this file.
1 /***
2 
3  Olive - Non-Linear Video Editor
4  Copyright (C) 2019 Olive Team
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 
19 ***/
20 
21 #ifndef PROJECTMODEL_H
22 #define PROJECTMODEL_H
23 
24 #include <QAbstractItemModel>
25 
26 #include "project/media.h"
27 
28 class ProjectModel : public QAbstractItemModel
29 {
30  Q_OBJECT
31 public:
32  ProjectModel(QObject* parent = nullptr);
33  ~ProjectModel() override;
34 
35  void make_root();
36  void destroy_root();
37  void clear();
38  Media* get_root();
39  QVariant data(const QModelIndex &index, int role) const override;
40  Qt::ItemFlags flags(const QModelIndex &index) const override;
41  QVariant headerData(int section, Qt::Orientation orientation,
42  int role = Qt::DisplayRole) const override;
43  QModelIndex index(int row, int column,
44  const QModelIndex &parent = QModelIndex()) const override;
45  QModelIndex create_index(int arow, int acolumn, void *adata);
46  QModelIndex parent(const QModelIndex &index) const override;
47  bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
48  int rowCount(const QModelIndex &parent = QModelIndex()) const override;
49  int columnCount(const QModelIndex &parent = QModelIndex()) const override;
50  Media* getItem(const QModelIndex &index) const;
51 
53  void moveChild(Media* child, Media* to);
54  void removeChild(Media* parent, Media* m);
55  Media* child(int i, Media* parent = nullptr);
56  int childCount(Media* parent = nullptr);
57  void set_icon(Media* m, const QIcon &ico);
58 
59 private:
61 };
62 
63 namespace olive {
65 }
66 
67 #endif // PROJECTMODEL_H
void appendChild(Media *parent, Media *child)
Definition: projectmodel.cpp:171
Qt::ItemFlags flags(const QModelIndex &index) const override
Definition: projectmodel.cpp:72
void set_icon(Media *m, const QIcon &ico)
Definition: projectmodel.cpp:164
Media * getItem(const QModelIndex &index) const
Definition: projectmodel.cpp:155
Definition: projectmodel.h:28
void clear()
Definition: projectmodel.cpp:54
QModelIndex parent(const QModelIndex &index) const override
Definition: projectmodel.cpp:108
void destroy_root()
Definition: projectmodel.cpp:45
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Definition: projectmodel.cpp:148
Media * get_root()
Definition: projectmodel.cpp:61
void moveChild(Media *child, Media *to)
Definition: projectmodel.cpp:178
~ProjectModel() override
Definition: projectmodel.cpp:35
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Definition: projectmodel.cpp:121
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Definition: projectmodel.cpp:79
int childCount(Media *parent=nullptr)
Definition: projectmodel.cpp:205
Media * root_item
Definition: projectmodel.h:60
Definition: debugdialog.h:39
Definition: media.h:42
QModelIndex create_index(int arow, int acolumn, void *adata)
Definition: projectmodel.cpp:104
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition: projectmodel.cpp:134
Media * child(int i, Media *parent=nullptr)
Definition: projectmodel.cpp:200
void removeChild(Media *parent, Media *m)
Definition: projectmodel.cpp:193
ProjectModel(QObject *parent=nullptr)
Definition: projectmodel.cpp:31
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Definition: projectmodel.cpp:86
void make_root()
Definition: projectmodel.cpp:39
ProjectModel project_model
Definition: projectmodel.cpp:29
QVariant data(const QModelIndex &index, int role) const override
Definition: projectmodel.cpp:65