Various types containers support
This commit is contained in:
parent
0d9f1ba95b
commit
157d7c4f23
39 changed files with 609 additions and 479 deletions
|
@ -9,7 +9,7 @@ ContainersModel::ContainersModel(QObject *parent) :
|
|||
int ContainersModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
return amnezia::allContainers().size();
|
||||
return ContainerProps::allContainers().size();
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> ContainersModel::roleNames() const {
|
||||
|
@ -17,36 +17,32 @@ QHash<int, QByteArray> ContainersModel::roleNames() const {
|
|||
roles[NameRole] = "name_role";
|
||||
roles[DescRole] = "desc_role";
|
||||
roles[DefaultRole] = "default_role";
|
||||
roles[isVpnTypeRole] = "is_vpn_role";
|
||||
roles[isOtherTypeRole] = "is_other_role";
|
||||
roles[isInstalledRole] = "is_installed_role";
|
||||
roles[ServiceTypeRole] = "service_type_role";
|
||||
roles[IsInstalledRole] = "is_installed_role";
|
||||
return roles;
|
||||
}
|
||||
|
||||
QVariant ContainersModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid() || index.row() < 0
|
||||
|| index.row() >= amnezia::allContainers().size()) {
|
||||
|| index.row() >= ContainerProps::allContainers().size()) {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
DockerContainer c = amnezia::allContainers().at(index.row());
|
||||
DockerContainer c = ContainerProps::allContainers().at(index.row());
|
||||
if (role == NameRole) {
|
||||
return containerHumanNames().value(c);
|
||||
return ContainerProps::containerHumanNames().value(c);
|
||||
}
|
||||
if (role == DescRole) {
|
||||
return containerDescriptions().value(c);
|
||||
return ContainerProps::containerDescriptions().value(c);
|
||||
}
|
||||
if (role == DefaultRole) {
|
||||
return c == m_settings.defaultContainer(m_selectedServerIndex);
|
||||
}
|
||||
if (role == isVpnTypeRole) {
|
||||
return isContainerVpnType(c);
|
||||
if (role == ServiceTypeRole) {
|
||||
return ContainerProps::containerService(c);
|
||||
}
|
||||
// if (role == isOtherTypeRole) {
|
||||
// return isContainerVpnType(c)
|
||||
// }
|
||||
if (role == isInstalledRole) {
|
||||
if (role == IsInstalledRole) {
|
||||
return m_settings.containers(m_selectedServerIndex).contains(c);
|
||||
}
|
||||
return QVariant();
|
||||
|
|
|
@ -19,15 +19,14 @@ public:
|
|||
NameRole = Qt::UserRole + 1,
|
||||
DescRole,
|
||||
DefaultRole,
|
||||
isVpnTypeRole,
|
||||
isOtherTypeRole,
|
||||
isInstalledRole
|
||||
ServiceTypeRole,
|
||||
IsInstalledRole
|
||||
};
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
void setSelectedServerIndex(int index);
|
||||
Q_INVOKABLE void setSelectedServerIndex(int index);
|
||||
|
||||
protected:
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
|
|
|
@ -9,41 +9,37 @@ ProtocolsModel::ProtocolsModel(QObject *parent) :
|
|||
int ProtocolsModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
return amnezia::allProtocols().size();
|
||||
return ProtocolProps::allProtocols().size();
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> ProtocolsModel::roleNames() const {
|
||||
QHash<int, QByteArray> roles;
|
||||
roles[NameRole] = "name_role";
|
||||
roles[DescRole] = "desc_role";
|
||||
roles[isVpnTypeRole] = "is_vpn_role";
|
||||
roles[isOtherTypeRole] = "is_other_role";
|
||||
roles[isInstalledRole] = "is_installed_role";
|
||||
roles[ServiceTypeRole] = "service_type_role";
|
||||
roles[IsInstalledRole] = "is_installed_role";
|
||||
return roles;
|
||||
}
|
||||
|
||||
QVariant ProtocolsModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid() || index.row() < 0
|
||||
|| index.row() >= amnezia::allContainers().size()) {
|
||||
|| index.row() >= ContainerProps::allContainers().size()) {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
Protocol p = amnezia::allProtocols().at(index.row());
|
||||
Protocol p = ProtocolProps::allProtocols().at(index.row());
|
||||
if (role == NameRole) {
|
||||
return protocolHumanNames().value(p);
|
||||
return ProtocolProps::protocolHumanNames().value(p);
|
||||
}
|
||||
if (role == DescRole) {
|
||||
return protocolDescriptions().value(p);
|
||||
return ProtocolProps::protocolDescriptions().value(p);
|
||||
}
|
||||
if (role == isVpnTypeRole) {
|
||||
return isProtocolVpnType(p);
|
||||
if (role == ServiceTypeRole) {
|
||||
return ProtocolProps::protocolService(p);
|
||||
}
|
||||
// if (role == isOtherTypeRole) {
|
||||
// return isContainerVpnType(c)
|
||||
// }
|
||||
if (role == isInstalledRole) {
|
||||
return protocolsForContainer(m_selectedDockerContainer).contains(p);
|
||||
if (role == IsInstalledRole) {
|
||||
return ContainerProps::protocolsForContainer(m_selectedDockerContainer).contains(p);
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
|
|
@ -18,9 +18,8 @@ public:
|
|||
enum SiteRoles {
|
||||
NameRole = Qt::UserRole + 1,
|
||||
DescRole,
|
||||
isVpnTypeRole,
|
||||
isOtherTypeRole,
|
||||
isInstalledRole
|
||||
ServiceTypeRole,
|
||||
IsInstalledRole
|
||||
};
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue