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