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>
|
2023-06-23 15:24:40 +09:00
|
|
|
#include <vector>
|
2021-09-09 20:15:44 +03:00
|
|
|
|
2026-04-30 14:53:03 +08:00
|
|
|
#include "core/utils/containerEnum.h"
|
|
|
|
|
#include "core/utils/containers/containerUtils.h"
|
|
|
|
|
#include "core/utils/protocolEnum.h"
|
|
|
|
|
#include "core/models/containerConfig.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:
|
2023-12-08 13:50:03 +07:00
|
|
|
ContainersModel(QObject *parent = nullptr);
|
2023-05-22 00:10:51 +08:00
|
|
|
|
2023-05-17 23:28:27 +08:00
|
|
|
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,
|
2023-05-12 23:54:31 +08:00
|
|
|
ConfigRole,
|
2025-12-11 15:18:36 +08:00
|
|
|
IsThirdPartyConfigRole,
|
2023-05-17 23:28:27 +08:00
|
|
|
DockerContainerRole,
|
2026-04-30 14:53:03 +08:00
|
|
|
ContainerStringRole,
|
2023-05-22 00:10:51 +08:00
|
|
|
|
|
|
|
|
IsEasySetupContainerRole,
|
|
|
|
|
EasySetupHeaderRole,
|
|
|
|
|
EasySetupDescriptionRole,
|
2023-09-18 21:06:10 +05:00
|
|
|
EasySetupOrderRole,
|
2023-05-22 00:10:51 +08:00
|
|
|
|
2025-12-11 15:18:36 +08:00
|
|
|
IsInstallationAllowedRole,
|
2023-05-12 23:54:31 +08:00
|
|
|
IsInstalledRole,
|
2023-06-13 20:03:20 +09:00
|
|
|
IsCurrentlyProcessedRole,
|
2023-05-22 00:10:51 +08:00
|
|
|
IsDefaultRole,
|
2023-08-22 14:37:29 +05:00
|
|
|
IsSupportedRole,
|
2024-07-02 22:00:28 +02:00
|
|
|
IsShareableRole,
|
|
|
|
|
|
2026-04-30 14:53:03 +08:00
|
|
|
InstallPageOrderRole,
|
|
|
|
|
|
|
|
|
|
// Container type check roles
|
|
|
|
|
IsVpnContainerRole,
|
|
|
|
|
IsServiceContainerRole,
|
|
|
|
|
IsIpsecRole,
|
|
|
|
|
IsDnsRole,
|
|
|
|
|
IsSftpRole,
|
|
|
|
|
IsTorWebsiteRole,
|
2026-05-18 14:52:58 +03:00
|
|
|
IsSocks5ProxyRole,
|
|
|
|
|
IsMtProxyRole,
|
2026-05-18 15:01:09 +03:00
|
|
|
IsTelemtRole,
|
2021-09-09 20:15:44 +03:00
|
|
|
};
|
2026-04-30 14:53:03 +08:00
|
|
|
|
|
|
|
|
Q_INVOKABLE void openContainerSettings(int containerIndex);
|
2021-09-09 20:15:44 +03:00
|
|
|
|
|
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
|
|
|
|
|
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
2023-07-31 00:13:08 +09:00
|
|
|
QVariant data(const int index, int role) const;
|
2021-09-09 20:15:44 +03:00
|
|
|
|
2023-05-12 23:54:31 +08:00
|
|
|
public slots:
|
2026-04-30 14:53:03 +08:00
|
|
|
void updateModel(const QMap<amnezia::DockerContainer, amnezia::ContainerConfig> &containers);
|
2023-05-12 23:54:31 +08:00
|
|
|
|
2024-04-01 20:20:02 +07:00
|
|
|
void setProcessedContainerIndex(int containerIndex);
|
2023-05-17 23:28:27 +08:00
|
|
|
|
2024-04-01 20:20:02 +07:00
|
|
|
QString getProcessedContainerName();
|
2023-07-13 11:29:26 +09:00
|
|
|
|
2023-12-08 13:50:03 +07:00
|
|
|
QJsonObject getContainerConfig(const int containerIndex);
|
2023-06-27 19:07:42 +09:00
|
|
|
|
2024-04-07 01:42:17 +07:00
|
|
|
bool isSupportedByCurrentPlatform(const int containerIndex);
|
|
|
|
|
bool isServiceContainer(const int containerIndex);
|
|
|
|
|
|
2024-08-20 16:54:05 +07:00
|
|
|
bool hasInstalledServices();
|
|
|
|
|
bool hasInstalledProtocols();
|
|
|
|
|
|
2026-04-30 14:53:03 +08:00
|
|
|
static bool isInstallationAllowed(amnezia::DockerContainer container);
|
2025-12-11 15:18:36 +08:00
|
|
|
|
2021-09-09 20:15:44 +03:00
|
|
|
protected:
|
|
|
|
|
QHash<int, QByteArray> roleNames() const override;
|
|
|
|
|
|
2023-07-31 00:13:08 +09:00
|
|
|
signals:
|
2023-10-26 23:34:39 +05:00
|
|
|
void containersModelUpdated();
|
2023-07-31 00:13:08 +09:00
|
|
|
|
2021-09-09 20:15:44 +03:00
|
|
|
private:
|
2026-04-30 14:53:03 +08:00
|
|
|
QMap<amnezia::DockerContainer, amnezia::ContainerConfig> m_containers;
|
2023-06-07 13:17:48 +03:00
|
|
|
|
2026-04-30 14:53:03 +08:00
|
|
|
int m_processedContainerIndex = -1;
|
2021-09-09 20:15:44 +03:00
|
|
|
};
|
|
|
|
|
|
2021-09-10 22:19:00 +03:00
|
|
|
#endif // CONTAINERS_MODEL_H
|