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

45 lines
1.2 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 <vector>
#include <utility>
2021-09-10 22:19:00 +03:00
#include "settings.h"
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:
2022-08-25 12:47:02 +03:00
ContainersModel(std::shared_ptr<Settings> settings, QObject *parent = nullptr);
2021-09-09 20:15:44 +03:00
public:
enum SiteRoles {
NameRole = Qt::UserRole + 1,
DescRole,
2021-09-19 14:31:38 +03:00
DefaultRole,
2021-09-20 21:51:28 +03:00
ServiceTypeRole,
IsInstalledRole
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;
2021-09-20 21:51:28 +03:00
Q_INVOKABLE void setSelectedServerIndex(int index);
Q_INVOKABLE void setCurrentlyInstalledContainerIndex(int index);
Q_INVOKABLE QString getCurrentlyInstalledContainerName();
2021-09-09 20:15:44 +03:00
protected:
QHash<int, QByteArray> roleNames() const override;
private:
2021-09-10 22:19:00 +03:00
int m_selectedServerIndex;
QModelIndex m_currentlyInstalledContainerIndex;
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