CuteLogger
Fast and simple logging solution for Qt based applications
playlistmodel.h
1/*
2 * Copyright (c) 2012-2023 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 "MltPlaylist.h"
25
26
27
28class PlaylistModel : public QAbstractTableModel
29{
30 Q_OBJECT
31public:
32 enum ViewMode {
33 Invalid,
34 Detailed,
35 Tiled,
36 Icons,
37 };
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_COUNT
48 };
49
50 enum Fields {
51 FIELD_INDEX = Qt::UserRole,
52 FIELD_THUMBNAIL,
53 FIELD_RESOURCE,
54 FIELD_IN,
55 FIELD_DURATION,
56 FIELD_START,
57 FIELD_DATE,
58 };
59
60 static const int THUMBNAIL_WIDTH = 80;
61 static const int THUMBNAIL_HEIGHT = 45;
62
63 explicit PlaylistModel(QObject *parent = 0);
64 ~PlaylistModel();
65 int rowCount(const QModelIndex &parent = QModelIndex()) const;
66 int columnCount(const QModelIndex &parent = QModelIndex()) const;
67 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
68 QVariant headerData(int section, Qt::Orientation orientation, int role) const;
69 Qt::DropActions supportedDropActions() const;
70 bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
71 bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
72 bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count,
73 const QModelIndex &destinationParent, int destinationChild);
74 void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
75 Qt::ItemFlags flags(const QModelIndex &index) const;
76 QStringList mimeTypes() const;
77 QMimeData *mimeData(const QModelIndexList &indexes) const;
78 bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column,
79 const QModelIndex &parent);
80 QModelIndex incrementIndex(const QModelIndex &index) const;
81 QModelIndex decrementIndex(const QModelIndex &index) const;
82 QModelIndex createIndex(int row, int column) const;
83 void createIfNeeded();
84 void showThumbnail(int row);
85 void refreshThumbnails();
86 Mlt::Playlist *playlist()
87 {
88 return m_playlist;
89 }
90 void setPlaylist(Mlt::Playlist &playlist);
91 void setInOut(int row, int in, int out);
92
93 ViewMode viewMode() const;
94 void setViewMode(ViewMode mode);
95
96signals:
97 void created();
98 void cleared();
99 void closed();
100 void modified();
101 void loaded();
102 void dropped(const QMimeData *data, int row);
103 void moveClip(int from, int to);
104 void inChanged(int in);
105 void outChanged(int out);
106 void removing(Mlt::Service *service);
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
127private slots:
128 void onRowsAboutToBeRemoved(const QModelIndex &parent, int first, int last);
129};
130
131#endif // PLAYLISTMODEL_H