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 "models/playlistmodel.h"
22 
23 #include <QDockWidget>
24 #include <QTimer>
25 #include <QTreeWidget>
26 #include <QUndoCommand>
27 
28 namespace Ui {
29 class PlaylistDock;
30 }
31 
32 class QAbstractItemView;
33 class QItemSelectionModel;
34 class QLabel;
35 class QMenu;
36 class PlaylistIconView;
37 class PlaylistProxyModel;
38 class LineEditClear;
39 
40 class BinTree : public QTreeWidget
41 {
42  Q_OBJECT
43 
44 public:
45  explicit BinTree(QWidget *parent = nullptr)
46  : QTreeWidget(parent)
47  {}
48 
49 signals:
50  void copied(QString);
51  void moved(QList<int>, QPointF);
52 
53 protected:
54  void dropEvent(QDropEvent *event);
55 };
56 
57 class PlaylistDock : public QDockWidget
58 {
59  Q_OBJECT
60 
61 public:
62  enum SmartBin {
63  SmartBinNone = -1,
64  SmartBinAll,
65  SmartBinDuplicates,
66  SmartBinNotInBin,
67  SmartBinNotInTimeline,
68  SmartBinCount
69  };
70 
71  explicit PlaylistDock(QWidget *parent = 0);
72  ~PlaylistDock();
73  PlaylistModel *model() { return &m_model; }
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 
80 signals:
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 
89 public 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 
105 private 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  void clearStatus();
117  void updateStatus();
118 
119 protected:
120  void keyPressEvent(QKeyEvent *event);
121  void keyReleaseEvent(QKeyEvent *event);
122 
123 private:
124  void setupActions();
125  void resetPlaylistIndex();
126  void emitDataChanged(const QVector<int> &roles);
127  void setPlaylistIndex(Mlt::Producer *producer, int row);
128  void updateViewMode();
129  void onAddFilesActionTriggered();
130  void onUpdateThumbnailsActionTriggered();
131  void onAddToTimelineActionTriggered();
132  void onAddToSlideshowActionTriggered();
133  void onSetFileDateActionTriggered();
134  void onRemoveAllActionTriggered();
135  void onGotoActionTriggered();
136  void onCopyActionTriggered();
137  void onSelectAllActionTriggered();
138  void onInsertCutActionTriggered();
139  void onUpdateActionTriggered();
140  void onRemoveActionTriggered();
141  void incrementIndex(int step);
142  void setIndex(int row);
143  void moveClipUp();
144  void moveClipDown();
145  void addFiles(int row, const QList<QUrl> &urls);
146  void loadBins();
147  void sortBins();
148  void assignToBin(Mlt::Properties &properties, QString bin = QString());
149 
150  Ui::PlaylistDock *ui;
151  QAbstractItemView *m_view;
152  PlaylistIconView *m_iconsView;
153  PlaylistModel m_model;
154  QItemSelectionModel *m_selectionModel;
155  int m_defaultRowHeight;
156  QTimer m_inChangedTimer;
157  QTimer m_outChangedTimer;
158  QMenu *m_mainMenu;
159  bool m_blockResizeColumnsToContents;
160  PlaylistProxyModel *m_proxyModel;
161  Mlt::Playlist m_binPlaylist;
162  LineEditClear *m_searchField;
163  QLabel *m_label;
164 };
165 
166 #endif // PLAYLISTDOCK_H