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

72 lines
1.7 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"
2021-09-10 22:19:00 +03:00
class ContainersModel : public QAbstractListModel
2021-09-09 20:15:44 +03:00
{
Q_OBJECT
public:
ContainersModel(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;
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
public slots:
2024-02-09 23:23:26 +05:00
void updateModel(const QJsonArray &containers);
DockerContainer getDefaultContainer();
void setDefaultContainer(const int containerIndex);
void setCurrentlyProcessedContainerIndex(int containerIndex);
2023-06-13 20:03:20 +09:00
int getCurrentlyProcessedContainerIndex();
QString getCurrentlyProcessedContainerName();
QJsonObject getContainerConfig(const int containerIndex);
bool isAnyContainerInstalled();
2023-08-02 20:37:43 +09:00
2021-09-09 20:15:44 +03:00
protected:
QHash<int, QByteArray> roleNames() const override;
signals:
void defaultContainerChanged();
void containersModelUpdated();
2021-09-09 20:15:44 +03:00
private:
QMap<DockerContainer, QJsonObject> m_containers;
2023-06-13 20:03:20 +09:00
int m_currentlyProcessedContainerIndex;
DockerContainer m_defaultContainerIndex;
2021-09-09 20:15:44 +03:00
};
2021-09-10 22:19:00 +03:00
#endif // CONTAINERS_MODEL_H