ServerContainers qml ui started to fix
This commit is contained in:
parent
40fa2d6779
commit
542f363e92
17 changed files with 837 additions and 507 deletions
58
client/ui/models/containers_model.cpp
Normal file
58
client/ui/models/containers_model.cpp
Normal file
|
@ -0,0 +1,58 @@
|
|||
#include "containers_model.h"
|
||||
|
||||
ContainersModel::ContainersModel(QObject *parent) :
|
||||
QAbstractListModel(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int ContainersModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
return amnezia::allContainers().size();
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> ContainersModel::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";
|
||||
return roles;
|
||||
}
|
||||
|
||||
QVariant ContainersModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid() || index.row() < 0
|
||||
|| index.row() >= amnezia::allContainers().size()) {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
DockerContainer c = amnezia::allContainers().at(index.row());
|
||||
if (role == NameRole) {
|
||||
return containerHumanNames().value(c);
|
||||
}
|
||||
if (role == DescRole) {
|
||||
return containerDescriptions().value(c);
|
||||
}
|
||||
if (role == isVpnTypeRole) {
|
||||
return isContainerVpnType(c);
|
||||
}
|
||||
// if (role == isOtherTypeRole) {
|
||||
// return isContainerVpnType(c)
|
||||
// }
|
||||
if (role == isInstalledRole) {
|
||||
return m_settings.containers(m_selectedServerIndex).contains(c);
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void ContainersModel::setSelectedServerIndex(int index)
|
||||
{
|
||||
beginResetModel();
|
||||
m_selectedServerIndex = index;
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue