Inform about Modified status change when modifying a value of a model

This commit is contained in:
Stanislav Bas 2015-08-02 15:06:56 +03:00
parent afb36b73eb
commit 25b653e316
2 changed files with 12 additions and 2 deletions

View file

@ -77,7 +77,11 @@ bool CSMWorld::IdTable::setData (const QModelIndex &index, const QVariant &value
{
mIdCollection->setData (index.row(), index.column(), value);
emit dataChanged (index, index);
// Modifying a value can also change the Modified status of a record.
// To track this, we inform about the change of a whole row.
QModelIndex rowStart = this->index(index.row(), 0);
QModelIndex rowEnd = this->index(index.row(), columnCount(index.parent()) - 1);
emit dataChanged(rowStart, rowEnd);
return true;
}

View file

@ -96,7 +96,13 @@ bool CSMWorld::IdTree::setData (const QModelIndex &index, const QVariant &value,
mNestedCollection->setNestedData(parentAddress.first, parentAddress.second, value, index.row(), index.column());
emit dataChanged (index, index);
emit dataChanged(index, index);
// Modifying a value can also change the Modified status of a record (located in the parent row).
// To track this, we inform about the change of a whole parent row.
QModelIndex parentRowStart = this->index(index.parent().row(), 0);
QModelIndex parentRowEnd = this->index(index.parent().row(), columnCount(index.parent()) - 1);
emit dataChanged(parentRowStart, parentRowEnd);
return true;
}