CuteLogger
Fast and simple logging solution for Qt based applications
meltedplaylistmodel.h
1 /*
2  * Copyright (c) 2012-2013 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 MELTEDPLAYLISTMODEL_H
20 #define MELTEDPLAYLISTMODEL_H
21 
22 #include <QAbstractTableModel>
23 #include <QTcpSocket>
24 #include <QStringList>
25 #include <QMimeData>
26 #include <mvcp.h>
27 #include <mvcp_tokeniser.h>
28 
29 class MeltedPlaylistModel : public QAbstractTableModel
30 {
31  Q_OBJECT
32 public:
33  enum Columns {
34  COLUMN_ACTIVE = 0,
35  COLUMN_INDEX,
36  COLUMN_RESOURCE,
37  COLUMN_IN,
38  COLUMN_OUT,
39  COLUMN_COUNT
40  };
41 
42  enum MvcpCommands {
43  MVCP_IGNORE,
44  MVCP_LIST,
45  MVCP_GOTO,
46  MVCP_APND,
47  MVCP_REMOVE,
48  MVCP_INSERT,
49  MVCP_MOVE
50  };
51 
52  explicit MeltedPlaylistModel(QObject *parent = 0);
53  ~MeltedPlaylistModel();
54 
55  int rowCount(const QModelIndex& parent = QModelIndex()) const;
56  int columnCount(const QModelIndex& parent = QModelIndex()) const;
57  QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
58  QVariant headerData(int section, Qt::Orientation orientation, int role) const;
59  Qt::DropActions supportedDropActions() const;
60  bool insertRows(int row, int count, const QModelIndex & parent = QModelIndex());
61  bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex());
62  Qt::ItemFlags flags(const QModelIndex &index) const;
63  QStringList mimeTypes() const;
64  bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
65 
66  void gotoClip(int);
67  void append(const QString& clip, int in = -1, int out = -1, bool notify = true);
68  void remove(int row, bool notify = true);
69  void insert(const QString& clip, int row, int in = -1, int out = -1, bool notify = true);
70  void move(int from, int to, bool notify = true);
71  void wipe();
72  void clean();
73  void clear();
74  void play(double speed);
75  void pause();
76  void stop();
77  void seek(int position);
78  void rewind();
79  void fastForward();
80  void previous();
81  void next();
82  void setIn(int in);
83  void setOut(int out);
84 
85 signals:
86  void loaded();
87  void dropped(QString clip, int row);
88  void moveClip(int from, int to);
89  void success();
90 
91 public slots:
92  void onConnected(const QString& address, quint16 port = 5250, quint8 unit = 0);
93  void onDisconnected();
94  void refresh();
95  void onUnitChanged(quint8 unit);
96  void onClipIndexChanged(quint8 unit, int index);
97  void onGenerationChanged(quint8 unit);
98 
99 private slots:
100  void readResponse();
101 // void onSocketError(QAbstractSocket::SocketError socketError);
102 
103 private:
104  QTcpSocket m_socket;
105  quint8 m_unit;
106  mvcp_list m_list;
107  mvcp_response m_response;
108  int m_index;
109  QList<int> m_commands;
110  int m_dropRow;
111  QByteArray m_data;
112  mvcp_tokeniser m_tokeniser;
113 };
114 
115 #endif // MELTEDPLAYLISTMODEL_H
Definition: mvcp_tokeniser.h:32
Definition: mvcp.h:176
Definition: mvcp_response.h:34