| Line |
Branch |
Exec |
Source |
| 1 |
|
|
/***************************************************************************** |
| 2 |
|
|
* |
| 3 |
|
|
* Copyright (C) 2009-2023 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 BROADCASTMODEL_H |
| 23 |
|
|
#define BROADCASTMODEL_H |
| 24 |
|
|
|
| 25 |
|
|
#include <QAbstractTableModel> |
| 26 |
|
|
#include <QList> |
| 27 |
|
|
#include <QString> |
| 28 |
|
|
|
| 29 |
|
|
#include "Export.h" |
| 30 |
|
|
#include "Process.h" |
| 31 |
|
|
|
| 32 |
|
|
namespace QtPdCom { |
| 33 |
|
|
|
| 34 |
|
|
class BroadcastModelPrivate; |
| 35 |
|
|
|
| 36 |
|
|
/** |
| 37 |
|
|
* \brief Model for capturing broadcast messages. |
| 38 |
|
|
* |
| 39 |
|
|
* It contains three columns (date, message, username). |
| 40 |
|
|
* Please note that broadcasts have to be enabled in pdserv. |
| 41 |
|
|
*/ |
| 42 |
|
✗ |
class QTPDCOM_PUBLIC BroadcastModel: public QAbstractTableModel |
| 43 |
|
|
{ |
| 44 |
|
✗ |
Q_OBJECT |
| 45 |
|
|
Q_PROPERTY(QtPdCom::Process *process READ getProcess WRITE connectProcess) |
| 46 |
|
|
|
| 47 |
|
|
public: |
| 48 |
|
|
explicit BroadcastModel(QObject *parent = nullptr); |
| 49 |
|
|
~BroadcastModel(); |
| 50 |
|
|
|
| 51 |
|
|
int rowCount(const QModelIndex & = {}) const override; |
| 52 |
|
|
int columnCount(const QModelIndex & = {}) const override; |
| 53 |
|
|
QVariant |
| 54 |
|
|
data(const QModelIndex &index, int role = Qt::DisplayRole) const override; |
| 55 |
|
|
QVariant headerData( |
| 56 |
|
|
int section, |
| 57 |
|
|
Qt::Orientation orientation, |
| 58 |
|
|
int role = Qt::DisplayRole) const override; |
| 59 |
|
|
|
| 60 |
|
|
/** Connect to a Process. |
| 61 |
|
|
* |
| 62 |
|
|
* The old Process will be disconnected. |
| 63 |
|
|
* \param process New Process. |
| 64 |
|
|
*/ |
| 65 |
|
|
void connectProcess(QtPdCom::Process *process); |
| 66 |
|
|
QtPdCom::Process *getProcess() const; |
| 67 |
|
|
/** |
| 68 |
|
|
* Clear all stored broadcasts. |
| 69 |
|
|
*/ |
| 70 |
|
|
Q_INVOKABLE void clear(); |
| 71 |
|
|
|
| 72 |
|
|
enum Roles { |
| 73 |
|
|
DateStringRole = Qt::UserRole + 1, |
| 74 |
|
|
MessageStringRole, |
| 75 |
|
|
UsernameRole, |
| 76 |
|
|
}; |
| 77 |
|
|
Q_ENUM(Roles); |
| 78 |
|
|
QHash<int, QByteArray> roleNames() const override; |
| 79 |
|
|
|
| 80 |
|
|
private: |
| 81 |
|
✗ |
Q_DECLARE_PRIVATE(BroadcastModel); |
| 82 |
|
|
|
| 83 |
|
|
QScopedPointer<BroadcastModelPrivate> const d_ptr; |
| 84 |
|
|
}; |
| 85 |
|
|
|
| 86 |
|
|
} // namespace QtPdCom |
| 87 |
|
|
|
| 88 |
|
|
|
| 89 |
|
|
#endif // BROADCASTMODEL_H |
| 90 |
|
|
|