25#include <QAbstractTableModel>
28#include <IceGrid/Admin.h>
52 rowCount(
const QModelIndex& parent = QModelIndex())
const override
58 columnCount(
const QModelIndex& parent = QModelIndex())
const override
64 data(
const QModelIndex&
index,
int role = Qt::DisplayRole)
const override
76 if (role == Qt::DisplayRole)
78 switch (
index.column())
88 case IceGrid::Inactive:
89 return QString(
"Inactive");
92 case IceGrid::Activating:
93 return QString(
"Activating");
96 case IceGrid::ActivationTimedOut:
97 return QString(
"ActivationTimedOut");
100 case IceGrid::Active:
101 return QString(
"Active");
104 case IceGrid::Deactivating:
105 return QString(
"Deactivating");
108 case IceGrid::Destroying:
109 return QString(
"Destroying");
112 case IceGrid::Destroyed:
113 return QString(
"Destroyed");
129 else if (role == Qt::CheckStateRole)
133 return (
serverInfo.at(
index.row()).enabled) ? Qt::Checked : Qt::Unchecked;
136 else if (role == Qt::BackgroundRole)
138 return (
serverInfo.at(
index.row()).enabled) ? QBrush(Qt::green) : QBrush(Qt::lightGray);
147 headerData(
int section, Qt::Orientation orientation,
int role = Qt::DisplayRole)
const override
149 if (role != Qt::DisplayRole)
154 if (orientation == Qt::Horizontal)
159 return QString(
"Enabled");
163 return QString(
"ID");
167 return QString(
"Status");
171 return QString(
"PID");
187 ? Qt::ItemFlags(Qt::ItemIsEnabled | Qt::ItemIsUserCheckable)
188 : Qt::ItemFlags(Qt::ItemIsEnabled);
192 setData(
const QModelIndex&
index,
const QVariant& value,
int role)
override
205 serverInfo.at(
index.row()).enabled = ((Qt::CheckState)value.toInt() == Qt::Checked);
212 setData(IceGrid::ServerDynamicInfoSeq newInfo)
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)