Line |
Branch |
Exec |
Source |
1 |
|
|
/***************************************************************************** |
2 |
|
|
* |
3 |
|
|
* Copyright (C) 2009 - 2022 Bjarne von Horn <vh@igh.de> |
4 |
|
|
* |
5 |
|
|
* This file is part of the QtPdCom library. |
6 |
|
|
* |
7 |
|
|
* The QtPdCom library is free software: you can redistribute it and/or modify |
8 |
|
|
* it under the terms of the GNU Lesser General Public License as published by |
9 |
|
|
* the Free Software Foundation, either version 3 of the License, or (at your |
10 |
|
|
* option) any later version. |
11 |
|
|
* |
12 |
|
|
* The QtPdCom library is distributed in the hope that it will be useful, but |
13 |
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
14 |
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public |
15 |
|
|
* License for more details. |
16 |
|
|
* |
17 |
|
|
* You should have received a copy of the GNU Lesser General Public License |
18 |
|
|
* along with the QtPdCom Library. If not, see <http://www.gnu.org/licenses/>. |
19 |
|
|
* |
20 |
|
|
****************************************************************************/ |
21 |
|
|
|
22 |
|
|
#ifndef QTPDCOM_CLIENTSTATISTICSMODEL_H |
23 |
|
|
#define QTPDCOM_CLIENTSTATISTICSMODEL_H |
24 |
|
|
|
25 |
|
|
#include <QAbstractTableModel> |
26 |
|
|
#include "Export.h" |
27 |
|
|
// moc needs full definition of Process to register the metatype for the |
28 |
|
|
// property automatically. See https://bugreports.qt.io/browse/QTBUG-50242 |
29 |
|
|
#include "Process.h" |
30 |
|
|
|
31 |
|
|
namespace QtPdCom { |
32 |
|
|
|
33 |
|
|
class ClientStatisticsModelPrivate; |
34 |
|
|
|
35 |
|
✗ |
class QTPDCOM_PUBLIC ClientStatisticsModel: public QAbstractTableModel |
36 |
|
|
{ |
37 |
|
✗ |
Q_OBJECT |
38 |
|
|
Q_PROPERTY(QtPdCom::Process *process READ getProcess WRITE setProcess) |
39 |
|
|
|
40 |
|
|
public: |
41 |
|
|
explicit ClientStatisticsModel(QObject *parent = nullptr); |
42 |
|
|
virtual ~ClientStatisticsModel(); |
43 |
|
|
|
44 |
|
|
|
45 |
|
|
int rowCount(const QModelIndex &) const override; |
46 |
|
|
int columnCount(const QModelIndex &) const override; |
47 |
|
|
QVariant data(const QModelIndex &, int) const override; |
48 |
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role) |
49 |
|
|
const override; |
50 |
|
|
|
51 |
|
|
/** |
52 |
|
|
* Update statistics from server. |
53 |
|
|
*/ |
54 |
|
|
Q_INVOKABLE void poll(); |
55 |
|
|
/** |
56 |
|
|
* Clear stored statistics. |
57 |
|
|
*/ |
58 |
|
|
Q_INVOKABLE void clear(); |
59 |
|
|
void setProcess(QtPdCom::Process *); |
60 |
|
|
QtPdCom::Process *getProcess() const; |
61 |
|
|
|
62 |
|
|
QHash<int, QByteArray> roleNames() const override; |
63 |
|
|
|
64 |
|
|
enum Roles { |
65 |
|
|
NameRole = Qt::UserRole + 1, |
66 |
|
|
ApplicationNameRole, |
67 |
|
|
RxByteRole, |
68 |
|
|
TxByteRole, |
69 |
|
|
ConnectedTimeRole, |
70 |
|
|
}; |
71 |
|
|
Q_ENUM(Roles) |
72 |
|
|
|
73 |
|
|
|
74 |
|
|
private: |
75 |
|
✗ |
Q_DECLARE_PRIVATE(ClientStatisticsModel) |
76 |
|
|
Q_DISABLE_COPY(ClientStatisticsModel) |
77 |
|
|
|
78 |
|
|
QScopedPointer<ClientStatisticsModelPrivate> d_ptr; |
79 |
|
|
}; |
80 |
|
|
|
81 |
|
|
} // namespace QtPdCom |
82 |
|
|
|
83 |
|
|
|
84 |
|
|
#endif // QTPDCOM_CLIENTSTATISTICSMODEL_H |
85 |
|
|
|