mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 16:49:54 +00:00
Inform about State change (not a whole row) when modifying a table value
This commit is contained in:
parent
4d24eff859
commit
720aca8f3d
2 changed files with 14 additions and 10 deletions
|
@ -76,12 +76,15 @@ bool CSMWorld::IdTable::setData (const QModelIndex &index, const QVariant &value
|
|||
if (mIdCollection->getColumn (index.column()).isEditable() && role==Qt::EditRole)
|
||||
{
|
||||
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);
|
||||
int stateColumn = searchColumnIndex(Columns::ColumnId_Modification);
|
||||
if (stateColumn != -1)
|
||||
{
|
||||
QModelIndex stateIndex = this->index(index.row(), stateColumn);
|
||||
emit dataChanged(stateIndex, stateIndex);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -95,14 +95,15 @@ bool CSMWorld::IdTree::setData (const QModelIndex &index, const QVariant &value,
|
|||
const std::pair<int, int>& parentAddress(unfoldIndexAddress(index.internalId()));
|
||||
|
||||
mNestedCollection->setNestedData(parentAddress.first, parentAddress.second, value, index.row(), index.column());
|
||||
|
||||
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);
|
||||
// Modifying a value can also change the Modified status of a record.
|
||||
int stateColumn = searchColumnIndex(Columns::ColumnId_Modification);
|
||||
if (stateColumn != -1)
|
||||
{
|
||||
QModelIndex stateIndex = this->index(index.parent().row(), stateColumn);
|
||||
emit dataChanged(stateIndex, stateIndex);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue