blob: 84d136227566292ac7b37d504b4e3b111ffb0bba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#pragma once
#include <QAbstractTableModel>
#include <QAbstractItemDelegate>
#include <QMap>
#include <QVariant>
#include "preferences/broadcastprofile.h"
class BroadcastSettings;
typedef QSharedPointer<BroadcastSettings> BroadcastSettingsPointer;
class BroadcastSettingsModel : public QAbstractTableModel {
Q_OBJECT
public:
BroadcastSettingsModel();
void resetFromSettings(BroadcastSettingsPointer pSettings);
bool addProfileToModel(BroadcastProfilePtr profile);
void deleteProfileFromModel(BroadcastProfilePtr profile);
BroadcastProfilePtr getProfileByName(const QString& profileName);
QList<BroadcastProfilePtr> profiles() {
return m_profiles.values();
}
int rowCount(const QModelIndex& parent = QModelIndex()) const;
int columnCount(const QModelIndex& parent = QModelIndex()) const;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
Qt::ItemFlags flags(const QModelIndex& index) const;
bool setData(const QModelIndex& index, const QVariant& value,
int role = Qt::EditRole);
QAbstractItemDelegate* delegateForColumn(const int i, QObject* parent);
private slots:
void onProfileNameChanged(const QString& oldName, const QString& newName);
void onConnectionStatusChanged(int newStatus);
private:
static QString connectionStatusString(BroadcastProfilePtr profile);
static QColor connectionStatusBgColor(BroadcastProfilePtr profile);
QMap<QString, BroadcastProfilePtr> m_profiles;
};
|