Files
amnezia-client/client/ui/models/servers_model.h
T

45 lines
1.0 KiB
C++
Raw Normal View History

2021-08-09 00:41:52 +07:00
#ifndef SERVERSMODEL_H
#define SERVERSMODEL_H
#include <QAbstractListModel>
#include "settings.h"
2021-08-09 00:41:52 +07:00
struct ServerModelContent {
QString desc;
QString address;
bool isDefault;
};
class ServersModel : public QAbstractListModel
{
Q_OBJECT
public:
enum ServersModelRoles {
2021-08-09 00:41:52 +07:00
DescRole = Qt::UserRole + 1,
AddressRole,
CredentialsRole,
2021-08-09 00:41:52 +07:00
IsDefaultRole
};
ServersModel(std::shared_ptr<Settings> settings, QObject *parent = nullptr);
2021-08-09 00:41:52 +07:00
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
2021-08-09 00:41:52 +07:00
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
public slots:
void setDefaultServerIndex(int index);
2023-05-15 13:38:17 +08:00
const int getDefaultServerIndex();
const int getServersCount();
2021-08-09 00:41:52 +07:00
protected:
QHash<int, QByteArray> roleNames() const override;
private:
std::shared_ptr<Settings> m_settings;
2021-08-09 00:41:52 +07:00
};
#endif // SERVERSMODEL_H