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