Reworked the interaction between models. Now only serversModel directly interacts with server config
This commit is contained in:
parent
f3f98a50ed
commit
b4c89ad58f
19 changed files with 412 additions and 290 deletions
|
@ -11,13 +11,21 @@ class ServersModel : public QAbstractListModel
|
|||
public:
|
||||
enum Roles {
|
||||
NameRole = Qt::UserRole + 1,
|
||||
ServerDescriptionRole,
|
||||
|
||||
HostNameRole,
|
||||
|
||||
CredentialsRole,
|
||||
CredentialsLoginRole,
|
||||
|
||||
IsDefaultRole,
|
||||
IsCurrentlyProcessedRole,
|
||||
|
||||
HasWriteAccessRole,
|
||||
ContainsAmneziaDnsRole
|
||||
|
||||
ContainsAmneziaDnsRole,
|
||||
|
||||
DefaultContainerRole
|
||||
};
|
||||
|
||||
ServersModel(std::shared_ptr<Settings> settings, QObject *parent = nullptr);
|
||||
|
@ -33,6 +41,10 @@ public:
|
|||
Q_PROPERTY(int defaultIndex READ getDefaultServerIndex WRITE setDefaultServerIndex NOTIFY defaultServerIndexChanged)
|
||||
Q_PROPERTY(QString defaultServerName READ getDefaultServerName NOTIFY defaultServerNameChanged)
|
||||
Q_PROPERTY(QString defaultServerHostName READ getDefaultServerHostName NOTIFY defaultServerIndexChanged)
|
||||
Q_PROPERTY(QString defaultContainerName READ getDefaultContainerName NOTIFY defaultContainerChanged)
|
||||
Q_PROPERTY(QString defaultServerDescriptionCollapsed READ getDefaultServerDescriptionCollapsed NOTIFY defaultServerDescriptionChanged)
|
||||
Q_PROPERTY(QString defaultServerDescriptionExpanded READ getDefaultServerDescriptionExpanded NOTIFY defaultServerDescriptionChanged)
|
||||
|
||||
Q_PROPERTY(int currentlyProcessedIndex READ getCurrentlyProcessedServerIndex WRITE setCurrentlyProcessedServerIndex
|
||||
NOTIFY currentlyProcessedServerIndexChanged)
|
||||
|
||||
|
@ -41,6 +53,8 @@ public slots:
|
|||
const int getDefaultServerIndex();
|
||||
const QString getDefaultServerName();
|
||||
const QString getDefaultServerHostName();
|
||||
const QString getDefaultServerDescriptionCollapsed();
|
||||
const QString getDefaultServerDescriptionExpanded();
|
||||
bool isDefaultServerCurrentlyProcessed();
|
||||
|
||||
bool isCurrentlyProcessedServerHasWriteAccess();
|
||||
|
@ -54,15 +68,33 @@ public slots:
|
|||
|
||||
QString getCurrentlyProcessedServerHostName();
|
||||
const ServerCredentials getCurrentlyProcessedServerCredentials();
|
||||
const ServerCredentials getServerCredentials(const int index);
|
||||
|
||||
void addServer(const QJsonObject &server);
|
||||
void editServer(const QJsonObject &server);
|
||||
void removeServer();
|
||||
|
||||
bool isDefaultServerConfigContainsAmneziaDns();
|
||||
bool isAmneziaDnsContainerInstalled(const int serverIndex);
|
||||
|
||||
QJsonObject getDefaultServerConfig();
|
||||
void updateContainersConfig();
|
||||
|
||||
void reloadContainerConfig();
|
||||
void updateContainerConfig(const int containerIndex, const QJsonObject config);
|
||||
void addContainerConfig(const int containerIndex, const QJsonObject config);
|
||||
|
||||
void clearCachedProfiles();
|
||||
|
||||
ErrorCode removeContainer(const int containerIndex);
|
||||
ErrorCode removeAllContainers();
|
||||
|
||||
void setDefaultContainer(const int containerIndex);
|
||||
DockerContainer getDefaultContainer();
|
||||
const QString getDefaultContainerName();
|
||||
|
||||
QStringList getAllInstalledServicesName(const int serverIndex);
|
||||
|
||||
void toggleAmneziaDns(bool enabled);
|
||||
|
||||
protected:
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
|
@ -71,9 +103,16 @@ signals:
|
|||
void currentlyProcessedServerIndexChanged(const int index);
|
||||
void defaultServerIndexChanged(const int index);
|
||||
void defaultServerNameChanged();
|
||||
void defaultServerDescriptionChanged();
|
||||
|
||||
void containersUpdated(QJsonArray &containers);
|
||||
void defaultContainerChanged(const int containerIndex);
|
||||
|
||||
private:
|
||||
ServerCredentials serverCredentials(int index) const;
|
||||
void updateContainersModel();
|
||||
|
||||
QString getDefaultServerDescription(const QJsonObject &server);
|
||||
|
||||
QJsonArray m_servers;
|
||||
|
||||
|
@ -81,6 +120,8 @@ private:
|
|||
|
||||
int m_defaultServerIndex;
|
||||
int m_currentlyProcessedServerIndex;
|
||||
|
||||
bool m_isAmneziaDnsEnabled = m_settings->useAmneziaDns();
|
||||
};
|
||||
|
||||
#endif // SERVERSMODEL_H
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue