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 
27 namespace Ui {
28 class PlaylistDock;
29 }
30 
31 class QAbstractItemView;
32 class QItemSelectionModel;
33 class QMenu;
34 class PlaylistIconView;
35 class PlaylistProxyModel;
36 
37 class BinTree : public QTreeWidget
38 {
39  Q_OBJECT
40 
41 public:
42  explicit BinTree(QWidget *parent = nullptr)
43  : QTreeWidget(parent)
44  {}
45 
46 signals:
47  void copied(QString);
48  void moved(QList<int>, QPointF);
49 
50 protected:
51  void dropEvent(QDropEvent *event);
52 };
53 
54 class PlaylistDock : public QDockWidget
55 {
56  Q_OBJECT
57 
58 public:
59  enum SmartBin {
60  SmartBinNone = -1,
61  SmartBinAll,
62  SmartBinDuplicates,
63  SmartBinNotInTimeline,
64  SmartBinCount
65  };
66 
67  explicit PlaylistDock(QWidget *parent = 0);
68  ~PlaylistDock();
69  PlaylistModel *model()
70  {
71  return &m_model;
72  }
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 refreshTimelineSmartBins();
102 
103 private slots:
104 
105  void viewCustomContextMenuRequested(const QPoint &pos);
106  void viewDoubleClicked(const QModelIndex &index);
107  void onDropped(const QMimeData *data, int row);
108  void onMoveClip(int from, int to);
109  void onMovedToEnd();
110  void onInTimerFired();
111  void onOutTimerFired();
112  void onMediaTypeClicked();
113  void on_treeWidget_itemSelectionChanged();
114 
115 protected:
116  void keyPressEvent(QKeyEvent *event);
117  void keyReleaseEvent(QKeyEvent *event);
118 
119 private:
120  void setupActions();
121  void resetPlaylistIndex();
122  void emitDataChanged(const QVector<int> &roles);
123  void setPlaylistIndex(Mlt::Producer *producer, int row);
124  void updateViewMode();
125  void onAddFilesActionTriggered();
126  void onUpdateThumbnailsActionTriggered();
127  void onAddToTimelineActionTriggered();
128  void onAddToSlideshowActionTriggered();
129  void onSetFileDateActionTriggered();
130  void onRemoveAllActionTriggered();
131  void onGotoActionTriggered();
132  void onCopyActionTriggered();
133  void onSelectAllActionTriggered();
134  void onInsertCutActionTriggered();
135  void onUpdateActionTriggered();
136  void onRemoveActionTriggered();
137  void incrementIndex(int step);
138  void setIndex(int row);
139  void moveClipUp();
140  void moveClipDown();
141  void addFiles(int row, const QList<QUrl> &urls);
142  void loadBins();
143  void sortBins();
144  void assignToBin(Mlt::Properties &properties, QString bin = QString());
145 
146  Ui::PlaylistDock *ui;
147  QAbstractItemView *m_view;
148  PlaylistIconView *m_iconsView;
149  PlaylistModel m_model;
150  QItemSelectionModel *m_selectionModel;
151  int m_defaultRowHeight;
152  QTimer m_inChangedTimer;
153  QTimer m_outChangedTimer;
154  QMenu *m_mainMenu;
155  bool m_blockResizeColumnsToContents;
156  PlaylistProxyModel *m_proxyModel;
157  Mlt::Playlist m_binPlaylist;
158 };
159 
160 #endif // PLAYLISTDOCK_H