-
Notifications
You must be signed in to change notification settings - Fork 0
/
ServersListModel.h
executable file
·58 lines (49 loc) · 1.98 KB
/
ServersListModel.h
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
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef ServersListModel_H
#define ServersListModel_H
#include <QAbstractItemModel>
#include <QJsonArray>
#include <QJsonObject>
#include <QFile>
#include <QException>
#include <QDebug>
#include <QFileInfo>
#include <QJsonDocument>
#include "SettingsModel.h"
class ServersListModel : public QAbstractListModel
{
Q_OBJECT
Q_ENUMS(ServersListModelRoles)
protected:
QString sFilePath;
SettingsModel* poSettingsModel;
public:
enum ServersListModelRoles {
IsEnabledRole = Qt::UserRole + 1,
HostRole,
PortRole
};
explicit ServersListModel(SettingsModel* poSettingsModel, QObject *poParent = nullptr);
~ServersListModel() override;
QHash<int,QByteArray> roleNames() const override;
QVariant data(const QModelIndex &oIndex, int iRole) const override;
bool setData(const QModelIndex &oIndex, const QVariant &oValue, int iRole = Qt::EditRole) override;
QVariant headerData(int iSection, Qt::Orientation oOrientation, int iRole = Qt::DisplayRole) const override;
Qt::ItemFlags flags(const QModelIndex &oIndex) const override;
bool insertRows(int iPosition, int iRows, const QModelIndex &oParent = QModelIndex()) override;
bool removeRows(int iPosition, int iRows, const QModelIndex &oParent = QModelIndex()) override;
QModelIndex index(int iRow, int iColumn, const QModelIndex &oParent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex &oChild) const override;
int rowCount(const QModelIndex &oParent = QModelIndex()) const override;
int columnCount(const QModelIndex &oParent = QModelIndex()) const override;
bool hasChildren(const QModelIndex &oParent) const override;
public slots:
void fnUpdate();
QVariant fnLoad();
QVariant fnSave();
QVariant fnAddRow();
void fnRemoveRow(int iIndex);
QVariant fnSize();
QVariant fnGetStringValue(int iIndex, QVariant sName, QVariant sDefaultValue="");
QVariant fnGetBoolValue(int iIndex, QVariant sName);
};
#endif // ServersListModel_H