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
|
|
|
|
|
|
|
|
#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:
|
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,
|
2023-05-17 23:28:27 +08:00
|
|
|
DockerContainerRole,
|
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
|
|
|
|
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,
|
|
|
|
|
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;
|
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:
|
2024-02-09 23:23:26 +05:00
|
|
|
void updateModel(const QJsonArray &containers);
|
2023-05-12 23:54:31 +08:00
|
|
|
|
2023-12-08 13:50:03 +07:00
|
|
|
DockerContainer getDefaultContainer();
|
|
|
|
|
void setDefaultContainer(const int containerIndex);
|
2023-07-13 11:29:26 +09:00
|
|
|
|
2023-12-08 13:50:03 +07:00
|
|
|
void setCurrentlyProcessedContainerIndex(int containerIndex);
|
2023-06-13 20:03:20 +09:00
|
|
|
int getCurrentlyProcessedContainerIndex();
|
2023-05-17 23:28:27 +08:00
|
|
|
|
2023-07-13 11:29:26 +09:00
|
|
|
QString getCurrentlyProcessedContainerName();
|
|
|
|
|
|
2023-12-08 13:50:03 +07:00
|
|
|
QJsonObject getContainerConfig(const int containerIndex);
|
2023-06-27 19:07:42 +09:00
|
|
|
|
2023-09-25 07:22:11 +08:00
|
|
|
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;
|
|
|
|
|
|
2023-07-31 00:13:08 +09:00
|
|
|
signals:
|
|
|
|
|
void defaultContainerChanged();
|
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:
|
2023-06-07 13:17:48 +03:00
|
|
|
QMap<DockerContainer, QJsonObject> m_containers;
|
|
|
|
|
|
2023-06-13 20:03:20 +09:00
|
|
|
int m_currentlyProcessedContainerIndex;
|
2023-06-07 13:17:48 +03:00
|
|
|
DockerContainer m_defaultContainerIndex;
|
2021-09-09 20:15:44 +03:00
|
|
|
};
|
|
|
|
|
|
2021-09-10 22:19:00 +03:00
|
|
|
#endif // CONTAINERS_MODEL_H
|