Notify views of changes in all columns when updating the ColumnId_Modification column

remotes/1728160796594174844/tmp_0.7.0-alpha
Doc West 7 years ago committed by Alexander Stillich
parent 4a6457c346
commit 01b8ce5f70

@ -294,19 +294,16 @@ void CSMWorld::CreateCommand::undo()
}
CSMWorld::RevertCommand::RevertCommand (IdTable& model, const std::string& id, QUndoCommand* parent)
: QUndoCommand (parent), mModel (model), mId (id), mOld (0), mNew (0)
: QUndoCommand (parent), mModel (model), mId (id), mOld (0)
{
setText (("Revert record " + id).c_str());
mNew = model.getRecord(id).clone();
mNew->revert();
mOld = model.getRecord (id).clone();
}
CSMWorld::RevertCommand::~RevertCommand()
{
delete mOld;
delete mNew;
}
void CSMWorld::RevertCommand::redo()
@ -322,7 +319,6 @@ void CSMWorld::RevertCommand::redo()
}
else
{
mModel.setRecord (mId, *mNew);
mModel.setData (index, static_cast<int> (RecordBase::State_BaseOnly));
}
}

@ -201,7 +201,6 @@ namespace CSMWorld
IdTable& mModel;
std::string mId;
RecordBase *mOld;
RecordBase *mNew;
// not implemented
RevertCommand (const RevertCommand&);

@ -86,12 +86,30 @@ 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 unless .
int stateColumn = searchColumnIndex(Columns::ColumnId_Modification);
if (stateColumn != -1 && index.column() != stateColumn)
if (stateColumn != -1)
{
QModelIndex stateIndex = this->index(index.row(), stateColumn);
emit dataChanged(stateIndex, stateIndex);
if (index.column() == stateColumn)
{
// modifying the state column can modify other values. we need to tell
// views that the whole row has changed.
int count = columnCount(index.parent());
for (int i=0; i<count; ++i)
{
if (i != stateColumn) // we already notified about the state column itself
{
QModelIndex columnIndex = this->index(index.row(), i);
emit dataChanged(columnIndex, columnIndex);
}
}
} else
{
// Modifying a value can also change the Modified status of a record unless .
QModelIndex stateIndex = this->index(index.row(), stateColumn);
emit dataChanged(stateIndex, stateIndex);
}
}
return true;

@ -24,8 +24,6 @@ namespace CSMWorld
virtual RecordBase *modifiedCopy() const = 0;
virtual void revert() = 0;
virtual void assign (const RecordBase& record) = 0;
///< Will throw an exception if the types don't match.
@ -51,8 +49,6 @@ namespace CSMWorld
virtual RecordBase *modifiedCopy() const;
void revert() override;
virtual void assign (const RecordBase& record);
const ESXRecordT& get() const;
@ -100,12 +96,6 @@ namespace CSMWorld
return new Record<ESXRecordT> (*this);
}
template<typename ESXRecordT>
void Record<ESXRecordT>::revert()
{
mModified = mBase;
}
template <typename ESXRecordT>
void Record<ESXRecordT>::assign (const RecordBase& record)
{

Loading…
Cancel
Save