2026-04-30 14:53:03 +08:00
|
|
|
#ifndef SERVERSMODEL_H
|
|
|
|
|
#define SERVERSMODEL_H
|
|
|
|
|
|
|
|
|
|
#include <QAbstractListModel>
|
|
|
|
|
#include <QVector>
|
|
|
|
|
|
|
|
|
|
#include "core/utils/selfhosted/sshSession.h"
|
2026-05-15 12:33:36 +08:00
|
|
|
#include "core/models/serverDescription.h"
|
2026-04-30 14:53:03 +08:00
|
|
|
|
|
|
|
|
class ServersModel : public QAbstractListModel
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
enum Roles {
|
|
|
|
|
NameRole = Qt::UserRole + 1,
|
|
|
|
|
ServerDescriptionRole,
|
|
|
|
|
HostNameRole,
|
2026-05-28 10:57:08 +08:00
|
|
|
ServerIdRole,
|
2026-04-30 14:53:03 +08:00
|
|
|
|
|
|
|
|
CredentialsLoginRole,
|
|
|
|
|
|
|
|
|
|
IsDefaultRole,
|
|
|
|
|
|
|
|
|
|
HasWriteAccessRole,
|
|
|
|
|
|
|
|
|
|
DefaultContainerRole,
|
|
|
|
|
|
|
|
|
|
HasInstalledContainers,
|
|
|
|
|
|
|
|
|
|
IsServerFromGatewayApiRole,
|
|
|
|
|
IsSubscriptionExpiredRole,
|
|
|
|
|
IsSubscriptionExpiringSoonRole,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ServersModel(QObject *parent = nullptr);
|
|
|
|
|
|
|
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
|
|
|
|
QVariant data(const int index, int role = Qt::DisplayRole) const;
|
|
|
|
|
|
|
|
|
|
public slots:
|
2026-05-28 10:57:08 +08:00
|
|
|
void updateModel(const QVector<amnezia::ServerDescription> &descriptions,
|
|
|
|
|
const QString &defaultServerId);
|
|
|
|
|
void setDefaultServerId(const QString &serverId);
|
2026-05-15 12:33:36 +08:00
|
|
|
|
2026-04-30 14:53:03 +08:00
|
|
|
protected:
|
|
|
|
|
QHash<int, QByteArray> roleNames() const override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
ServerCredentials serverCredentials(int index) const;
|
|
|
|
|
|
2026-05-15 12:33:36 +08:00
|
|
|
QVector<amnezia::ServerDescription> m_descriptions;
|
2026-04-30 14:53:03 +08:00
|
|
|
|
2026-05-28 10:57:08 +08:00
|
|
|
QString m_defaultServerId;
|
2026-04-30 14:53:03 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // SERVERSMODEL_H
|