CuteLogger
Fast and simple logging solution for Qt based applications
playlistmodel.h
1/*
2 * Copyright (c) 2012-2019 Meltytech, LLC
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef PLAYLISTMODEL_H
19#define PLAYLISTMODEL_H
20
21#include <QAbstractTableModel>
22#include <qmimedata.h>
23#include <QStringList>
24#include "mltcontroller.h"
25#include "MltPlaylist.h"
26
27
28
29class PlaylistModel : public QAbstractTableModel
30{
31 Q_OBJECT
32public:
33 enum ViewMode {
34 Invalid,
35 Detailed,
36 Tiled,
37 Icons,
38 };
39
40 enum Columns {
41 COLUMN_INDEX = 0,
42 COLUMN_THUMBNAIL,
43 COLUMN_RESOURCE,
44 COLUMN_IN,
45 COLUMN_DURATION,
46 COLUMN_START,
47 COLUMN_DATE,
48 COLUMN_COUNT
49 };
50
51 enum Fields {
52 FIELD_INDEX = Qt::UserRole,
53 FIELD_THUMBNAIL,
54 FIELD_RESOURCE,
55 FIELD_IN,
56 FIELD_DURATION,
57 FIELD_START,
58 FIELD_DATE,
59 };
60
61 static const int THUMBNAIL_WIDTH = 80;
62 static const int THUMBNAIL_HEIGHT = 45;
63
64 explicit PlaylistModel(QObject *parent = 0);
65 ~PlaylistModel();
66 int rowCount(const QModelIndex &parent = QModelIndex()) const;
67 int columnCount(const QModelIndex &parent = QModelIndex()) const;
68 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
69 QVariant headerData(int section, Qt::Orientation orientation, int role) const;
70 Qt::DropActions supportedDropActions() const;
71 bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
72 bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
73 bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count,
74 const QModelIndex &destinationParent, int destinationChild);
75 void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
76 Qt::ItemFlags flags(const QModelIndex &index) const;
77 QStringList mimeTypes() const;
78 QMimeData *mimeData(const QModelIndexList &indexes) const;
79 bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column,
80 const QModelIndex &parent);
81 QModelIndex incrementIndex(const QModelIndex &index) const;
82 QModelIndex decrementIndex(const QModelIndex &index) const;
83 QModelIndex createIndex(int row, int column) const;
84 void createIfNeeded();
85 void showThumbnail(int row);
86 void refreshThumbnails();
87 Mlt::Playlist *playlist()
88 {
89 return m_playlist;
90 }
91 void setPlaylist(Mlt::Playlist &playlist);
92 void setInOut(int row, int in, int out);
93
94 ViewMode viewMode() const;
95 void setViewMode(ViewMode mode);
96
97signals:
98 void created();
99 void cleared();
100 void closed();
101 void modified();
102 void loaded();
103 void dropped(const QMimeData *data, int row);
104 void moveClip(int from, int to);
105 void inChanged(int in);
106 void outChanged(int out);
107
108public slots:
109 void clear();
110 void load();
111 void append(Mlt::Producer &, bool emitModified = true);
112 void insert(Mlt::Producer &, int row);
113 void remove(int row);
114 void update(int row, Mlt::Producer &producer, bool copyFilters = false);
115 void updateThumbnails(int row);
116 void appendBlank(int frames);
117 void insertBlank(int frames, int row);
118 void close();
119 void move(int from, int to);
120
121private:
122 Mlt::Playlist *m_playlist;
123 int m_dropRow;
124 ViewMode m_mode;
125 QList<int> m_rowsRemoved;
126};
127
128#endif // PLAYLISTMODEL_H