27#include <QAbstractTableModel>
30#include <IceGrid/Admin.h>
54 rowCount(
const QModelIndex& parent = QModelIndex())
const override
60 columnCount(
const QModelIndex& parent = QModelIndex())
const override
66 data(
const QModelIndex&
index,
int role = Qt::DisplayRole)
const override
78 if (role == Qt::DisplayRole)
82 switch (
index.column())
92 case IceGrid::Inactive:
93 return QString(
"Inactive");
96 case IceGrid::Activating:
97 return QString(
"Activating");
100 case IceGrid::ActivationTimedOut:
101 return QString(
"ActivationTimedOut");
104 case IceGrid::Active:
105 return QString(
"Active");
108 case IceGrid::Deactivating:
109 return QString(
"Deactivating");
112 case IceGrid::Destroying:
113 return QString(
"Destroying");
116 case IceGrid::Destroyed:
117 return QString(
"Destroyed");
131 else if (role == Qt::CheckStateRole)
135 return (
serverInfo.at(
index.row()).enabled) ? Qt::Checked : Qt::Unchecked;
138 else if (role == Qt::BackgroundRole)
140 return (
serverInfo.at(
index.row()).enabled) ? QBrush(Qt::green) : QBrush(Qt::lightGray);
142 else if (role == Qt::EditRole)
144 return (
index.column() == 0);
151 headerData(
int section, Qt::Orientation orientation,
int role = Qt::DisplayRole)
const override
153 if (role != Qt::DisplayRole)
158 if (orientation == Qt::Horizontal)
163 return QString(
"Enabled");
167 return QString(
"ID");
171 return QString(
"Status");
175 return QString(
"PID");
191 ? Qt::ItemFlags(Qt::ItemIsEnabled | Qt::ItemIsUserCheckable)
192 : Qt::ItemFlags(Qt::ItemIsEnabled);
196 setData(
const QModelIndex&
index,
const QVariant& value,
int role)
override
203 serverInfo.at(
index.row()).enabled = ((Qt::CheckState)value.toInt() == Qt::Checked);
210 setData(IceGrid::ServerDynamicInfoSeq newInfo)
std::mutex serverInfoMutex
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Qt::ItemFlags flags(const QModelIndex &index) const override
bool setData(const QModelIndex &index, const QVariant &value, int role) override
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
IceGrid::ServerDynamicInfoSeq serverInfo
ServerInfoModel(IceGrid::ServerDynamicInfoSeq serverInfo)
int columnCount(const QModelIndex &parent=QModelIndex()) const override
bool setData(IceGrid::ServerDynamicInfoSeq newInfo)
void serverInfoChanged(IceGrid::ServerDynamicInfo serverInfo)