I have this table view in which I add different items on 3 columns. The items are editable so I can modify them directly in the view.
bool ClothoidTableModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
if (index.isValid() && role == Qt::EditRole) {
int row = index.row();
ClothoidCurve p = listOfCurves.value(row);
if (index.column() == 0)
p.length = value.toFloat();
else if (index.column() == 1)
p.startCurvature = value.toFloat();
else if (index.column() == 2)
p.endCurvature = value.toFloat();
else
return false;
listOfCurves.replace(row, p);
emit(dataChanged(index, index));
return true;
}
return false;
}
The method above is declared in my table model and it is called both when I add and when I modify the data in the table.
I would like to send a signal only when I modify the items in the table.How could I do that? Is there any way to differentiate between addition and modification?