Olive
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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() const;
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 canFetchMore(const QModelIndex &parent) const override;
48  bool hasChildren(const QModelIndex &parent = QModelIndex()) const override;
49  bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
50  int rowCount(const QModelIndex &parent = QModelIndex()) const override;
51  int columnCount(const QModelIndex &parent = QModelIndex()) const override;
52  Media* getItem(const QModelIndex &index) const;
53 
54  void appendChild(Media *parent, MediaPtr child);
55  void moveChild(MediaPtr child, Media* to);
56  void removeChild(Media* parent, Media* m);
57  Media* child(int i, Media* parent = nullptr);
58  int childCount(Media* parent = nullptr);
59  void set_icon(Media* m, const QIcon &ico);
60 
61 private:
63 };
64 
65 namespace olive {
67 }
68 
69 #endif // PROJECTMODEL_H
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition: projectmodel.cpp:163
void moveChild(MediaPtr child, Media *to)
Definition: projectmodel.cpp:218
void set_icon(Media *m, const QIcon &ico)
Definition: projectmodel.cpp:193
QVariant data(const QModelIndex &index, int role) const override
Definition: projectmodel.cpp:67
Media * get_root() const
Definition: projectmodel.cpp:63
bool hasChildren(const QModelIndex &parent=QModelIndex()) const override
Definition: projectmodel.cpp:141
Media * getItem(const QModelIndex &index) const
Definition: projectmodel.cpp:184
void destroy_root()
Definition: projectmodel.cpp:45
void appendChild(Media *parent, MediaPtr child)
Definition: projectmodel.cpp:199
std::shared_ptr< Media > MediaPtr
Definition: media.h:43
MediaPtr root_item_
Definition: projectmodel.h:62
void make_root()
Definition: projectmodel.cpp:39
Definition: projectmodel.h:28
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Definition: projectmodel.cpp:90
~ProjectModel() override
Definition: projectmodel.cpp:35
Media * child(int i, Media *parent=nullptr)
Definition: projectmodel.cpp:248
ProjectModel(QObject *parent=nullptr)
Definition: projectmodel.cpp:31
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Definition: projectmodel.cpp:177
QModelIndex parent(const QModelIndex &index) const override
Definition: projectmodel.cpp:114
Definition: media.h:45
void removeChild(Media *parent, Media *m)
Definition: projectmodel.cpp:238
QModelIndex create_index(int arow, int acolumn, void *adata)
Definition: projectmodel.cpp:110
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Definition: projectmodel.cpp:83
int childCount(Media *parent=nullptr)
Definition: projectmodel.cpp:255
bool canFetchMore(const QModelIndex &parent) const override
Definition: projectmodel.cpp:127
ProjectModel project_model
Definition: projectmodel.cpp:29
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Definition: projectmodel.cpp:150
void clear()
Definition: projectmodel.cpp:56
Qt::ItemFlags flags(const QModelIndex &index) const override
Definition: projectmodel.cpp:76