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

87 lines
2.3 KiB
C++
Raw Normal View History

2021-09-10 22:19:00 +03:00
#ifndef CONTAINERS_MODEL_H
#define CONTAINERS_MODEL_H
2021-09-09 20:15:44 +03:00
#include <QAbstractListModel>
#include <QJsonObject>
#include <utility>
#include <vector>
2021-09-09 20:15:44 +03:00
#include "containers/containers_defs.h"
#include "settings.h"
2021-09-09 20:15:44 +03:00
2021-09-10 22:19:00 +03:00
class ContainersModel : public QAbstractListModel
2021-09-09 20:15:44 +03:00
{
Q_OBJECT
public:
2022-08-25 12:47:02 +03:00
ContainersModel(std::shared_ptr<Settings> settings, QObject *parent = nullptr);
enum Roles {
2021-09-09 20:15:44 +03:00
NameRole = Qt::UserRole + 1,
2023-08-20 13:36:54 +05:00
DescriptionRole,
DetailedDescriptionRole,
2021-09-20 21:51:28 +03:00
ServiceTypeRole,
ConfigRole,
DockerContainerRole,
IsEasySetupContainerRole,
EasySetupHeaderRole,
EasySetupDescriptionRole,
2023-09-18 21:06:10 +05:00
EasySetupOrderRole,
IsInstalledRole,
2023-06-13 20:03:20 +09:00
IsCurrentlyProcessedRole,
IsDefaultRole,
2023-08-22 14:37:29 +05:00
IsSupportedRole,
IsShareableRole
2021-09-09 20:15:44 +03:00
};
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
2021-09-09 20:15:44 +03:00
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
QVariant data(const int index, int role) const;
2021-09-09 20:15:44 +03:00
Q_PROPERTY(QString defaultContainerName READ getDefaultContainerName NOTIFY defaultContainerChanged)
public slots:
DockerContainer getDefaultContainer();
QString getDefaultContainerName();
void setCurrentlyProcessedServerIndex(const int index);
2023-06-13 20:03:20 +09:00
void setCurrentlyProcessedContainerIndex(int index);
int getCurrentlyProcessedContainerIndex();
QString getCurrentlyProcessedContainerName();
QJsonObject getCurrentlyProcessedContainerConfig();
QStringList getAllInstalledServicesName(const int serverIndex);
ErrorCode removeAllContainers();
ErrorCode removeCurrentlyProcessedContainer();
2023-06-01 11:25:33 +08:00
void clearCachedProfiles();
bool isAmneziaDnsContainerInstalled();
bool isAmneziaDnsContainerInstalled(const int serverIndex);
bool isAnyContainerInstalled();
2023-08-02 20:37:43 +09:00
void updateContainersConfig();
2021-09-09 20:15:44 +03:00
protected:
QHash<int, QByteArray> roleNames() const override;
signals:
void defaultContainerChanged();
2021-09-09 20:15:44 +03:00
private:
QMap<DockerContainer, QJsonObject> m_containers;
int m_currentlyProcessedServerIndex;
2023-06-13 20:03:20 +09:00
int m_currentlyProcessedContainerIndex;
DockerContainer m_defaultContainerIndex;
2022-08-25 12:47:02 +03:00
std::shared_ptr<Settings> m_settings;
2021-09-09 20:15:44 +03:00
};
2021-09-10 22:19:00 +03:00
#endif // CONTAINERS_MODEL_H