CuteLogger
Fast and simple logging solution for Qt based applications
meltedplaylistdock.h
1 /*
2  * Copyright (c) 2012 Meltytech, LLC
3  * Author: Dan Dennedy <dan@dennedy.org>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef MELTEDUNITDOCK_H
20 #define MELTEDUNITDOCK_H
21 
22 #include <QDockWidget>
23 #include <QUndoCommand>
24 #include "meltedplaylistmodel.h"
25 #include "transportcontrol.h"
26 
27 namespace Ui {
28 class MeltedPlaylistDock;
29 }
30 
31 namespace MeltedPlaylist {
32 class TransportControl;
33 }
34 
35 class MeltedPlaylistDock : public QDockWidget
36 {
37  Q_OBJECT
38 
39 public:
40  explicit MeltedPlaylistDock(QWidget *parent = 0);
41  ~MeltedPlaylistDock();
42  QAbstractItemModel* model() const;
43  const TransportControllable* transportControl() const;
44 
45 signals:
46  void appendRequested();
47  void insertRequested(int row);
48 
49 public slots:
50  void onConnected(const QString& address, quint16 port = 5250, quint8 unit = 0);
51  void onDisconnected();
52  void onUnitChanged(quint8 unit);
53 
54 protected:
55  void keyPressEvent(QKeyEvent *);
56 
57 private slots:
58  void on_tableView_clicked(const QModelIndex &index);
59 
60  void on_tableView_doubleClicked(const QModelIndex &index);
61 
62  void onDropped(QString clip, int row);
63 
64  void onAppend(QString clip, int in = -1, int out = -1);
65 
66  void onInsert(QString clip, int row, int in = -1, int out = -1);
67 
68  void onMoveClip(int from, int to);
69 
70  void onSuccess();
71 
72  void on_tableView_customContextMenuRequested(const QPoint &pos);
73 
74  void on_addButton_clicked();
75 
76  void on_removeButton_clicked();
77 
78  void on_menuButton_clicked();
79 
80  void on_actionInsertCut_triggered();
81 
82  void on_actionOpen_triggered();
83 
84  void on_actionGoto_triggered();
85 
86  void on_actionRemoveAll_triggered();
87 
88  void on_actionWipe_triggered();
89 
90  void on_actionClean_triggered();
91 
92 private:
93  Ui::MeltedPlaylistDock *ui;
94  MeltedPlaylistModel m_model;
95  QList<QUndoCommand*> m_operations;
96  MeltedPlaylist::TransportControl* m_transportControl;
97 };
98 
99 namespace MeltedPlaylist
100 {
101 
102 class TransportControl : public TransportControllable
103 {
104  Q_OBJECT
105 public:
106  explicit TransportControl(MeltedPlaylistModel& model);
107 
108 public slots:
109  void play(double speed = 1.0);
110  void pause();
111  void stop();
112  void seek(int position);
113  void rewind();
114  void fastForward();
115  void previous(int currentPosition);
116  void next(int currentPosition);
117  void setIn(int in);
118  void setOut(int out);
119 
120 private:
121  MeltedPlaylistModel& m_model;
122 };
123 
124 class AppendCommand : public QUndoCommand
125 {
126 public:
127  AppendCommand(MeltedPlaylistModel& model, const QString& clip, int in = -1, int out = -1, QUndoCommand * parent = 0);
128  void redo();
129  void undo();
130 private:
131  MeltedPlaylistModel& m_model;
132  QString m_clip;
133  int m_in;
134  int m_out;
135  bool m_skip;
136 };
137 
138 class InsertCommand : public QUndoCommand
139 {
140 public:
141  InsertCommand(MeltedPlaylistModel& model, const QString& clip, int row, int in = -1, int out = -1, QUndoCommand * parent = 0);
142  void redo();
143  void undo();
144 private:
145  MeltedPlaylistModel& m_model;
146  QString m_clip;
147  int m_row;
148  int m_in;
149  int m_out;
150  bool m_skip;
151 };
152 
153 class SetInCommand : public QUndoCommand
154 {
155 public:
156  SetInCommand(MeltedPlaylistModel& model, const QString& clip, int row, int in, QUndoCommand * parent = 0);
157  void redo();
158  void undo();
159 private:
160  MeltedPlaylistModel& m_model;
161  QString m_clip;
162  int m_row;
163  int m_old;
164  int m_new;
165 };
166 
167 class SetOutCommand : public QUndoCommand
168 {
169 public:
170  SetOutCommand(MeltedPlaylistModel& model, const QString& clip, int row, int out, QUndoCommand * parent = 0);
171  void redo();
172  void undo();
173 private:
174  MeltedPlaylistModel& m_model;
175  QString m_clip;
176  int m_row;
177  int m_old;
178  int m_new;
179 };
180 
181 class RemoveCommand : public QUndoCommand
182 {
183 public:
184  RemoveCommand(MeltedPlaylistModel& model, QString& clip, int row, int in = -1, int out = -1, QUndoCommand * parent = 0);
185  void redo();
186  void undo();
187 private:
188  MeltedPlaylistModel& m_model;
189  QString m_clip;
190  int m_row;
191  int m_in;
192  int m_out;
193  bool m_skip;
194 };
195 
196 class MoveCommand : public QUndoCommand
197 {
198 public:
199  MoveCommand(MeltedPlaylistModel& model, QString& clip, int from, int to, QUndoCommand * parent = 0);
200  void redo();
201  void undo();
202 private:
203  MeltedPlaylistModel& m_model;
204  int m_from;
205  int m_to;
206  bool m_skip;
207 };
208 
209 } // namespace MeltedPlaylist
210 
211 #endif // MELTEDPLAYLISTDOCK_H
Definition: addencodepresetdialog.h:24
Definition: meltedplaylistdock.cpp:246