forked from mirror/openmw-tes3mp
Changed the way the revert command works: it now clones the changed record and uses the new RecordBase::revert() method to restore the previous value
Added Flag_Dialogue_Refresh to var type and var value columns so that sub views update properly
This commit is contained in:
parent
4222b44dbb
commit
4a6457c346
4 changed files with 19 additions and 18 deletions
|
@ -136,7 +136,7 @@ namespace CSMWorld
|
||||||
struct VarTypeColumn : public Column<ESXRecordT>
|
struct VarTypeColumn : public Column<ESXRecordT>
|
||||||
{
|
{
|
||||||
VarTypeColumn (ColumnBase::Display display)
|
VarTypeColumn (ColumnBase::Display display)
|
||||||
: Column<ESXRecordT> (Columns::ColumnId_ValueType, display)
|
: Column<ESXRecordT> (Columns::ColumnId_ValueType, display, ColumnBase::Flag_Table | ColumnBase::Flag_Dialogue | ColumnBase::Flag_Dialogue_Refresh)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual QVariant get (const Record<ESXRecordT>& record) const
|
virtual QVariant get (const Record<ESXRecordT>& record) const
|
||||||
|
@ -161,7 +161,7 @@ namespace CSMWorld
|
||||||
template<typename ESXRecordT>
|
template<typename ESXRecordT>
|
||||||
struct VarValueColumn : public Column<ESXRecordT>
|
struct VarValueColumn : public Column<ESXRecordT>
|
||||||
{
|
{
|
||||||
VarValueColumn() : Column<ESXRecordT> (Columns::ColumnId_Value, ColumnBase::Display_Var) {}
|
VarValueColumn() : Column<ESXRecordT> (Columns::ColumnId_Value, ColumnBase::Display_Var, ColumnBase::Flag_Table | ColumnBase::Flag_Dialogue | ColumnBase::Flag_Dialogue_Refresh) {}
|
||||||
|
|
||||||
virtual QVariant get (const Record<ESXRecordT>& record) const
|
virtual QVariant get (const Record<ESXRecordT>& record) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -294,16 +294,19 @@ void CSMWorld::CreateCommand::undo()
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMWorld::RevertCommand::RevertCommand (IdTable& model, const std::string& id, QUndoCommand* parent)
|
CSMWorld::RevertCommand::RevertCommand (IdTable& model, const std::string& id, QUndoCommand* parent)
|
||||||
: QUndoCommand (parent), mModel (model), mId (id), mOld (0)
|
: QUndoCommand (parent), mModel (model), mId (id), mOld (0), mNew (0)
|
||||||
{
|
{
|
||||||
setText (("Revert record " + id).c_str());
|
setText (("Revert record " + id).c_str());
|
||||||
|
|
||||||
|
mNew = model.getRecord(id).clone();
|
||||||
|
mNew->revert();
|
||||||
mOld = model.getRecord (id).clone();
|
mOld = model.getRecord (id).clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMWorld::RevertCommand::~RevertCommand()
|
CSMWorld::RevertCommand::~RevertCommand()
|
||||||
{
|
{
|
||||||
delete mOld;
|
delete mOld;
|
||||||
|
delete mNew;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMWorld::RevertCommand::redo()
|
void CSMWorld::RevertCommand::redo()
|
||||||
|
@ -319,20 +322,7 @@ void CSMWorld::RevertCommand::redo()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// notify view that data has changed, previously only the modified column was
|
mModel.setRecord (mId, *mNew);
|
||||||
// updated in the view unless the user had selected another item or forced a
|
|
||||||
// repaint with other means
|
|
||||||
int count = mModel.columnCount (index.parent ());
|
|
||||||
for (int i=0; i<count; ++i)
|
|
||||||
{
|
|
||||||
if (i != index.column())
|
|
||||||
{
|
|
||||||
auto colIndex = mModel.index (index.row (), i, index.parent ());
|
|
||||||
auto data = mModel.data (colIndex);
|
|
||||||
mModel.setData (colIndex, data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mModel.setData (index, static_cast<int> (RecordBase::State_BaseOnly));
|
mModel.setData (index, static_cast<int> (RecordBase::State_BaseOnly));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,6 +201,7 @@ namespace CSMWorld
|
||||||
IdTable& mModel;
|
IdTable& mModel;
|
||||||
std::string mId;
|
std::string mId;
|
||||||
RecordBase *mOld;
|
RecordBase *mOld;
|
||||||
|
RecordBase *mNew;
|
||||||
|
|
||||||
// not implemented
|
// not implemented
|
||||||
RevertCommand (const RevertCommand&);
|
RevertCommand (const RevertCommand&);
|
||||||
|
|
|
@ -24,6 +24,8 @@ namespace CSMWorld
|
||||||
|
|
||||||
virtual RecordBase *modifiedCopy() const = 0;
|
virtual RecordBase *modifiedCopy() const = 0;
|
||||||
|
|
||||||
|
virtual void revert() = 0;
|
||||||
|
|
||||||
virtual void assign (const RecordBase& record) = 0;
|
virtual void assign (const RecordBase& record) = 0;
|
||||||
///< Will throw an exception if the types don't match.
|
///< Will throw an exception if the types don't match.
|
||||||
|
|
||||||
|
@ -49,6 +51,8 @@ namespace CSMWorld
|
||||||
|
|
||||||
virtual RecordBase *modifiedCopy() const;
|
virtual RecordBase *modifiedCopy() const;
|
||||||
|
|
||||||
|
void revert() override;
|
||||||
|
|
||||||
virtual void assign (const RecordBase& record);
|
virtual void assign (const RecordBase& record);
|
||||||
|
|
||||||
const ESXRecordT& get() const;
|
const ESXRecordT& get() const;
|
||||||
|
@ -96,6 +100,12 @@ namespace CSMWorld
|
||||||
return new Record<ESXRecordT> (*this);
|
return new Record<ESXRecordT> (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename ESXRecordT>
|
||||||
|
void Record<ESXRecordT>::revert()
|
||||||
|
{
|
||||||
|
mModified = mBase;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename ESXRecordT>
|
template <typename ESXRecordT>
|
||||||
void Record<ESXRecordT>::assign (const RecordBase& record)
|
void Record<ESXRecordT>::assign (const RecordBase& record)
|
||||||
{
|
{
|
||||||
|
@ -156,4 +166,4 @@ namespace CSMWorld
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue