{
int row = index.row();
int col = index.column();
QMap<QString, QVariant> qMapPair = p_tagSimItems->getItemsMap().at(row);
if(index.isValid() && role == Qt::EditRole)
{
switch(col) {
case 0 :
{
qMapPair.insert("a",value.toString());
p_tagSimItems->setItemMap(row,qMapPair);
emit (dataChanged(index , index));
return true;
}
break;
case 1 :
{
qMapPair.insert("b",p_tagSimItems->isValidEnteredType(value.toString()));
p_tagSimItems->setItemMap(row,qMapPair);
emit (dataChanged(index , index));
return true;
}
break;
case 2 :
{
qMapPair.insert("c",value.toString().toUShort(0,10));
p_tagSimItems->setItemMap(row,qMapPair);
emit (dataChanged(index , index));
return true;
}
break;
case 3 :
{ [B]// the problem is here when model receive the signal from delegate in column 4 then i have to change the column 5 also manually which seems not possible because model is on column 4 .[/B]
if (value.toString().toUShort(0,10) < 256)
{
qMapPair.insert("d",value.toString().toUShort(0,10));
}else
{
qMapPair.insert("d",0);
}
p_tagSimItems->setItemMap(row,qMapPair);
emit (dataChanged(index , index));
return true;
}
break;
case 4 :
{
if (value.toString().toUShort(0,10) < 256)
{
qMapPair.insert("e",value.toString().toUShort(0,10));
}else
{
qMapPair.insert("e",0);
}
p_tagSimItems->setItemMap(row,qMapPair);
emit (dataChanged(index , index));
return true;
}
break;
default :
break;
}
}
return false;
}
bool TableModel::setData(const QModelIndex & index, const QVariant &value, int role)
{
int row = index.row();
int col = index.column();
QMap<QString, QVariant> qMapPair = p_tagSimItems->getItemsMap().at(row);
if(index.isValid() && role == Qt::EditRole)
{
switch(col) {
case 0 :
{
qMapPair.insert("a",value.toString());
p_tagSimItems->setItemMap(row,qMapPair);
emit (dataChanged(index , index));
return true;
}
break;
case 1 :
{
qMapPair.insert("b",p_tagSimItems->isValidEnteredType(value.toString()));
p_tagSimItems->setItemMap(row,qMapPair);
emit (dataChanged(index , index));
return true;
}
break;
case 2 :
{
qMapPair.insert("c",value.toString().toUShort(0,10));
p_tagSimItems->setItemMap(row,qMapPair);
emit (dataChanged(index , index));
return true;
}
break;
case 3 :
{ [B]// the problem is here when model receive the signal from delegate in column 4 then i have to change the column 5 also manually which seems not possible because model is on column 4 .[/B]
if (value.toString().toUShort(0,10) < 256)
{
qMapPair.insert("d",value.toString().toUShort(0,10));
}else
{
qMapPair.insert("d",0);
}
p_tagSimItems->setItemMap(row,qMapPair);
emit (dataChanged(index , index));
return true;
}
break;
case 4 :
{
if (value.toString().toUShort(0,10) < 256)
{
qMapPair.insert("e",value.toString().toUShort(0,10));
}else
{
qMapPair.insert("e",0);
}
p_tagSimItems->setItemMap(row,qMapPair);
emit (dataChanged(index , index));
return true;
}
break;
default :
break;
}
}
return false;
}
To copy to clipboard, switch view to plain text mode
Bookmarks