CuteLogger
Fast and simple logging solution for Qt based applications
playlistdock.h
1/*
2 * Copyright (c) 2012-2025 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 PLAYLISTDOCK_H
19#define PLAYLISTDOCK_H
20
21#include <QDockWidget>
22#include <QUndoCommand>
23#include <QTimer>
24#include <QTreeWidget>
25#include "models/playlistmodel.h"
26
27namespace Ui {
28class PlaylistDock;
29}
30
31class QAbstractItemView;
32class QItemSelectionModel;
33class QMenu;
34class PlaylistIconView;
35class PlaylistProxyModel;
36class LineEditClear;
37
38class BinTree : public QTreeWidget
39{
40 Q_OBJECT
41
42public:
43 explicit BinTree(QWidget *parent = nullptr)
44 : QTreeWidget(parent)
45 {}
46
47signals:
48 void copied(QString);
49 void moved(QList<int>, QPointF);
50
51protected:
52 void dropEvent(QDropEvent *event);
53};
54
55class PlaylistDock : public QDockWidget
56{
57 Q_OBJECT
58
59public:
60 enum SmartBin {
61 SmartBinNone = -1,
62 SmartBinAll,
63 SmartBinDuplicates,
64 SmartBinNotInTimeline,
65 SmartBinCount
66 };
67
68 explicit PlaylistDock(QWidget *parent = 0);
69 ~PlaylistDock();
70 PlaylistModel *model()
71 {
72 return &m_model;
73 }
74 int position();
75 void replaceClipsWithHash(const QString &hash, Mlt::Producer &producer);
76 void getSelectionRange(int *start, int *end);
77 Mlt::Playlist *binPlaylist();
78 static void sortBins(QTreeWidget *treeWidget);
79
80signals:
81 void clipOpened(Mlt::Producer *producer, bool play = false);
82 void itemActivated(int start);
83 void showStatusMessage(QString);
84 void addAllTimeline(Mlt::Playlist *, bool skipProxy = false, bool emptyTrack = false);
85 void producerOpened();
86 void selectionChanged();
87 void enableUpdate(bool);
88
89public slots:
90 void onOpenActionTriggered();
91 void onAppendCutActionTriggered();
92 void onProducerOpened();
93 void onInChanged();
94 void onOutChanged();
95 void onProducerChanged(Mlt::Producer *producer);
96 void onProducerModified();
97 void onPlayerDragStarted();
98 void onPlaylistModified();
99 void onPlaylistCreated();
100 void onPlaylistLoaded();
101 void onPlaylistCleared();
102 void onPlaylistClosed();
103 void refreshTimelineSmartBins();
104
105private slots:
106
107 void viewCustomContextMenuRequested(const QPoint &pos);
108 void viewDoubleClicked(const QModelIndex &index);
109 void onDropped(const QMimeData *data, int row);
110 void onMoveClip(int from, int to);
111 void onMovedToEnd();
112 void onInTimerFired();
113 void onOutTimerFired();
114 void onMediaTypeClicked();
115 void on_treeWidget_itemSelectionChanged();
116
117protected:
118 void keyPressEvent(QKeyEvent *event);
119 void keyReleaseEvent(QKeyEvent *event);
120
121private:
122 void setupActions();
123 void resetPlaylistIndex();
124 void emitDataChanged(const QVector<int> &roles);
125 void setPlaylistIndex(Mlt::Producer *producer, int row);
126 void updateViewMode();
127 void onAddFilesActionTriggered();
128 void onUpdateThumbnailsActionTriggered();
129 void onAddToTimelineActionTriggered();
130 void onAddToSlideshowActionTriggered();
131 void onSetFileDateActionTriggered();
132 void onRemoveAllActionTriggered();
133 void onGotoActionTriggered();
134 void onCopyActionTriggered();
135 void onSelectAllActionTriggered();
136 void onInsertCutActionTriggered();
137 void onUpdateActionTriggered();
138 void onRemoveActionTriggered();
139 void incrementIndex(int step);
140 void setIndex(int row);
141 void moveClipUp();
142 void moveClipDown();
143 void addFiles(int row, const QList<QUrl> &urls);
144 void loadBins();
145 void sortBins();
146 void assignToBin(Mlt::Properties &properties, QString bin = QString());
147
148 Ui::PlaylistDock *ui;
149 QAbstractItemView *m_view;
150 PlaylistIconView *m_iconsView;
151 PlaylistModel m_model;
152 QItemSelectionModel *m_selectionModel;
153 int m_defaultRowHeight;
154 QTimer m_inChangedTimer;
155 QTimer m_outChangedTimer;
156 QMenu *m_mainMenu;
157 bool m_blockResizeColumnsToContents;
158 PlaylistProxyModel *m_proxyModel;
159 Mlt::Playlist m_binPlaylist;
160 LineEditClear *m_searchField;
161};
162
163#endif // PLAYLISTDOCK_H