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

48 lines
1.1 KiB
C++
Raw Normal View History

2021-09-10 22:19:00 +03:00
#ifndef PROTOCOLS_MODEL_H
#define PROTOCOLS_MODEL_H
2021-09-09 20:15:44 +03:00
#include <QAbstractListModel>
#include <QJsonObject>
#include "../controllers/pageController.h"
2021-09-10 22:19:00 +03:00
#include "settings.h"
2021-09-09 20:15:44 +03:00
2021-09-10 22:19:00 +03:00
class ProtocolsModel : public QAbstractListModel
2021-09-09 20:15:44 +03:00
{
Q_OBJECT
public:
enum Roles {
ProtocolNameRole = Qt::UserRole + 1,
2024-09-13 12:38:48 +04:00
ServerProtocolPageRole,
ClientProtocolPageRole,
ProtocolIndexRole,
2024-09-13 12:38:48 +04:00
RawConfigRole,
IsClientProtocolExistsRole
2021-09-09 20:15:44 +03:00
};
ProtocolsModel(std::shared_ptr<Settings> settings, QObject *parent = nullptr);
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;
public slots:
void updateModel(const QJsonObject &content);
QJsonObject getConfig();
2021-09-09 20:15:44 +03:00
protected:
QHash<int, QByteArray> roleNames() const override;
private:
2024-09-13 12:38:48 +04:00
PageLoader::PageEnum serverProtocolPage(Proto protocol) const;
PageLoader::PageEnum clientProtocolPage(Proto protocol) const;
2022-08-25 12:47:02 +03:00
std::shared_ptr<Settings> m_settings;
DockerContainer m_container;
QJsonObject m_content;
2021-09-09 20:15:44 +03:00
};
2021-09-10 22:19:00 +03:00
#endif // PROTOCOLS_MODEL_H