CuteLogger
Fast and simple logging solution for Qt based applications
meltedunitsmodel.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 MELTEDUNITSMODEL_H
20 #define MELTEDUNITSMODEL_H
21 
22 #include <QAbstractTableModel>
23 #include <QTcpSocket>
24 #include "mvcpthread.h"
25 #include <mvcp_tokeniser.h>
26 
27 class QTimer;
28 
29 class MeltedUnitsModel : public QAbstractTableModel
30 {
31  Q_OBJECT
32 public:
33  explicit MeltedUnitsModel(QObject *parent = 0);
34  ~MeltedUnitsModel();
35 
36  int rowCount(const QModelIndex& parent = QModelIndex()) const;
37  int columnCount(const QModelIndex& parent = QModelIndex()) const;
38  QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
39  QVariant headerData(int section, Qt::Orientation orientation, int role) const;
40 
41 signals:
42  void disconnected();
43  void clipIndexChanged(quint8 unit, int index);
44  void generationChanged(quint8 unit);
45  void positionUpdated(quint8 unit, int position, double fps, int in, int out, int length, bool isPlaying);
46 
47 public slots:
48  void onConnected(MvcpThread*);
49  void onConnected(const QString& address, quint16 port = 5250, quint8 unit = 0);
50  void onDisconnected();
51 
52 private slots:
53  void readResponse();
54 
55 private:
56  MvcpThread* m_mvcp;
57  QTcpSocket m_socket;
58  QObjectList m_units;
59  mvcp_tokeniser m_tokeniser;
60  QByteArray m_data;
61  bool m_statusSent;
62 
63  QString decodeStatus(unit_status status);
64 
65 private slots:
66  void onUlsResult(QStringList);
67 };
68 
69 #endif // MELTEDUNITSMODEL_H
Definition: mvcp_tokeniser.h:32