37 using namespace YACS::HMI;
43 DEBTRACE(
"SchemaModel::SchemaModel");
56 DEBTRACE(
"SchemaModel::~SchemaModel");
63 if (!hasIndex(row, column, parent))
68 if (!parent.isValid())
71 parentItem =
static_cast<SchemaItem*
>(parent.internalPointer());
75 return createIndex(row, column, childItem);
89 return createIndex(parentItem->
row(), 0, parentItem);
96 if (parent.column() > 0)
98 if (!parent.isValid())
101 parentItem =
static_cast<SchemaItem*
>(parent.internalPointer());
110 if (parent.isValid())
111 return static_cast<SchemaItem*>(parent.internalPointer())->
columnCount();
124 if (!index.isValid())
127 return item->
data(index.column(), role);
133 if (role != Qt::DisplayRole)
136 if (orientation == Qt::Horizontal)
141 case YLabel:
return QString(
"Name");
142 case YType:
return QString(
"Type");
143 case YValue:
return QString(
"Value");
144 default:
return QString(
"- %1 -").arg(section);
149 case YLabel:
return QString(
"Name");
150 case YType:
return QString(
"Type");
151 case YState:
return QString(
"State");
152 default:
return QString(
"- %1 -").arg(section);
165 if (index.isValid() && role == Qt::EditRole)
167 DEBTRACE(
"Qt::EditRole, emit dataChanged");
168 emit dataChanged(index, index);
171 if (index.isValid() && role == Qt::CheckStateRole)
173 DEBTRACE(
"Qt::CheckStateRole, toggle state");
176 emit dataChanged(index, index);
185 if (!index.isValid())
188 return item->
flags(index);
206 const QItemSelection &deselected)
208 DEBTRACE(
"SchemaModel::updateSelection");
210 QModelIndexList items = selected.indexes();
212 foreach (index, items)
220 items = deselected.indexes();
222 foreach (index, items)
266 QModelIndex
index = indexes.first();
267 if (!index.isValid())
275 int row,
int column,
const QModelIndex& parent)
277 DEBTRACE(
"SchemaModel::dropMimeData");
278 if (action == Qt::IgnoreAction)
281 string name =
"empty";
283 if (parent.isValid())
285 item =
static_cast<SchemaItem*
>(parent.internalPointer());
288 DEBTRACE(row <<
" " << column <<
" "<< name);
290 if ((row >= 0) && (column >=0))
292 QModelIndex ind =
index(row, column, parent);
296 item =
static_cast<SchemaItem*
>(ind.internalPointer());
306 return Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
313 types <<
"yacs/subject" <<
"yacs/subjectNode" <<
"yacs/subjectOutPort"
314 <<
"yacs/cataService" <<
"yacs/cataType" <<
"yacs/cataNode"
315 <<
"yacs/subjectOutGate";