port UI Logic to QML

This commit is contained in:
Ngoc Diep 2021-08-09 00:41:52 +07:00
parent 8d36c31cb4
commit d1a3545912
34 changed files with 4386 additions and 12344 deletions

39
client/ui/serversmodel.h Normal file
View 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