CuteLogger
Fast and simple logging solution for Qt based applications
playlistmodel.h
1/*
2 * Copyright (c) 2012-2024 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 <MltPlaylist.h>
22#include <QAbstractTableModel>
23#include <QMimeData>
24#include <QStringList>
25
26class PlaylistModel : public QAbstractTableModel
27{
28 Q_OBJECT
29public:
30 enum ViewMode {
31 Invalid,
32 Detailed,
33 Tiled,
34 Icons,
35 };
36
37 enum MediaType { Video, Image, Audio, Other, Pending };
38
39 enum Columns {
40 COLUMN_INDEX = 0,
41 COLUMN_THUMBNAIL,
42 COLUMN_RESOURCE,
43 COLUMN_IN,
44 COLUMN_DURATION,
45 COLUMN_START,
46 COLUMN_DATE,
47 COLUMN_MEDIA_TYPE,
48 COLUMN_COMMENT,
49 COLUMN_BIN,
50 COLUMN_COUNT
51 };
52
53 enum Fields {
54 FIELD_INDEX = Qt::UserRole,
55 FIELD_THUMBNAIL,
56 FIELD_RESOURCE,
57 FIELD_IN,
58 FIELD_DURATION,
59 FIELD_START,
60 FIELD_DATE,
61 FIELD_MEDIA_TYPE,
62 FIELD_MEDIA_TYPE_ENUM,
63 FIELD_COMMENT,
64 FIELD_BIN
65 };
66
67 static const int THUMBNAIL_WIDTH = 80;
68 static const int THUMBNAIL_HEIGHT = 45;
69
70 explicit PlaylistModel(QObject *parent = 0);
71 ~PlaylistModel();
72 int rowCount(const QModelIndex &parent = QModelIndex()) const;
73 int columnCount(const QModelIndex &parent = QModelIndex()) const;
74 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
75 QVariant headerData(int section, Qt::Orientation orientation, int role) const;
76 Qt::DropActions supportedDropActions() const;
77 bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
78 bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
79 bool moveRows(const QModelIndex &sourceParent,
80 int sourceRow,
81 int count,
82 const QModelIndex &destinationParent,
83 int destinationChild);
84 void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
85 Qt::ItemFlags flags(const QModelIndex &index) const;
86 QStringList mimeTypes() const;
87 QMimeData *mimeData(const QModelIndexList &indexes) const;
88 bool dropMimeData(const QMimeData *data,
89 Qt::DropAction action,
90 int row,
91 int column,
92 const QModelIndex &parent);
93 QModelIndex createIndex(int row, int column) const;
94 void createIfNeeded();
95 void showThumbnail(int row);
96 void refreshThumbnails();
97 Mlt::Playlist *playlist() { return m_playlist; }
98 void setPlaylist(Mlt::Playlist &playlist);
99 void setInOut(int row, int in, int out);
100
101 ViewMode viewMode() const;
102 void setViewMode(ViewMode mode);
103 void setBin(int row, const QString &name);
104 void renameBin(const QString &bin, const QString &newName = QString());
105
106signals:
107 void created();
108 void cleared();
109 void closed();
110 void modified();
111 void loaded();
112 void dropped(const QMimeData *data, int row);
113 void moveClip(int from, int to);
114 void inChanged(int in);
115 void outChanged(int out);
116 void removing(Mlt::Service *service);
117
118public slots:
119 void clear();
120 void load();
121 void append(Mlt::Producer &, bool emitModified = true);
122 void insert(Mlt::Producer &, int row);
123 void remove(int row);
124 void update(int row, Mlt::Producer &producer, bool copyFilters = false);
125 void updateThumbnails(int row);
126 void appendBlank(int frames);
127 void insertBlank(int frames, int row);
128 void close();
129 void move(int from, int to);
130
131private:
132 Mlt::Playlist *m_playlist;
133 int m_dropRow;
134 ViewMode m_mode;
135 QList<int> m_rowsRemoved;
136
137private slots:
138 void onRowsAboutToBeRemoved(const QModelIndex &parent, int first, int last);
139};
140
141#endif // PLAYLISTMODEL_H