port UI Logic to QML
This commit is contained in:
parent
8d36c31cb4
commit
d1a3545912
34 changed files with 4386 additions and 12344 deletions
39
client/ui/serversmodel.h
Normal file
39
client/ui/serversmodel.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
#ifndef SERVERSMODEL_H
|
||||
#define SERVERSMODEL_H
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
|
||||
struct ServerModelContent {
|
||||
QString desc;
|
||||
QString address;
|
||||
bool isDefault;
|
||||
};
|
||||
|
||||
class ServersModel : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ServersModel(QObject *parent = nullptr);
|
||||
public:
|
||||
enum SiteRoles {
|
||||
DescRole = Qt::UserRole + 1,
|
||||
AddressRole,
|
||||
IsDefaultRole
|
||||
};
|
||||
|
||||
void clearData();
|
||||
void setContent(const std::vector<ServerModelContent>& data);
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
protected:
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
|
||||
private:
|
||||
std::vector<ServerModelContent> content;
|
||||
};
|
||||
|
||||
#endif // SERVERSMODEL_H
|
Loading…
Add table
Add a link
Reference in a new issue