Files
amnezia-client/client/ui/models/containers_model.h
T
Nethius e0863a58aa feature/api-controller-improvements (#567)
* added error handler for api controller
* while downloading the config from the api, the Connecting status is now displayed
* added a button to delete container config for api servers
* added crc check to avoid re-import of api configs
* fixed currentIndex of serversMenuContent after DefaultServerIndexChanged
* added closing the import window after re-importing the config from api
2024-02-09 18:23:26 +00:00

72 lines
1.7 KiB
C++

#ifndef CONTAINERS_MODEL_H
#define CONTAINERS_MODEL_H
#include <QAbstractListModel>
#include <QJsonObject>
#include <utility>
#include <vector>
#include "containers/containers_defs.h"
class ContainersModel : public QAbstractListModel
{
Q_OBJECT
public:
ContainersModel(QObject *parent = nullptr);
enum Roles {
NameRole = Qt::UserRole + 1,
DescriptionRole,
DetailedDescriptionRole,
ServiceTypeRole,
ConfigRole,
DockerContainerRole,
IsEasySetupContainerRole,
EasySetupHeaderRole,
EasySetupDescriptionRole,
EasySetupOrderRole,
IsInstalledRole,
IsCurrentlyProcessedRole,
IsDefaultRole,
IsSupportedRole,
IsShareableRole
};
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;
public slots:
void updateModel(const QJsonArray &containers);
DockerContainer getDefaultContainer();
void setDefaultContainer(const int containerIndex);
void setCurrentlyProcessedContainerIndex(int containerIndex);
int getCurrentlyProcessedContainerIndex();
QString getCurrentlyProcessedContainerName();
QJsonObject getContainerConfig(const int containerIndex);
bool isAnyContainerInstalled();
protected:
QHash<int, QByteArray> roleNames() const override;
signals:
void defaultContainerChanged();
void containersModelUpdated();
private:
QMap<DockerContainer, QJsonObject> m_containers;
int m_currentlyProcessedContainerIndex;
DockerContainer m_defaultContainerIndex;
};
#endif // CONTAINERS_MODEL_H