mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 09:35:28 +00:00
formatting
This commit is contained in:
parent
51115fa5be
commit
84e07c95b1
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
CSMWorld::ModifyCommand::ModifyCommand (QAbstractItemModel& model, const QModelIndex& index,
|
CSMWorld::ModifyCommand::ModifyCommand (QAbstractItemModel& model, const QModelIndex& index,
|
||||||
const QVariant& new_, QUndoCommand* parent)
|
const QVariant& new_, QUndoCommand* parent)
|
||||||
: QUndoCommand (parent), mModel (model), mIndex (index), mNew (new_)
|
: QUndoCommand (parent), mModel (model), mIndex (index), mNew (new_)
|
||||||
{
|
{
|
||||||
mOld = mModel.data (mIndex, Qt::EditRole);
|
mOld = mModel.data (mIndex, Qt::EditRole);
|
||||||
|
|
||||||
@ -26,9 +26,9 @@ void CSMWorld::ModifyCommand::undo()
|
|||||||
}
|
}
|
||||||
|
|
||||||
CSMWorld::CreateCommand::CreateCommand (IdTable& model, const std::string& id, QUndoCommand* parent)
|
CSMWorld::CreateCommand::CreateCommand (IdTable& model, const std::string& id, QUndoCommand* parent)
|
||||||
: QUndoCommand (parent), mModel (model), mId (id), mType (UniversalId::Type_None)
|
: QUndoCommand (parent), mModel (model), mId (id), mType (UniversalId::Type_None)
|
||||||
{
|
{
|
||||||
setText ( ("Create record " + id).c_str());
|
setText (("Create record " + id).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMWorld::CreateCommand::addValue (int column, const QVariant& value)
|
void CSMWorld::CreateCommand::addValue (int column, const QVariant& value)
|
||||||
@ -45,7 +45,7 @@ void CSMWorld::CreateCommand::redo()
|
|||||||
{
|
{
|
||||||
mModel.addRecord (mId, mType);
|
mModel.addRecord (mId, mType);
|
||||||
|
|
||||||
for (std::map<int, QVariant>::const_iterator iter (mValues.begin()); iter != mValues.end(); ++iter)
|
for (std::map<int, QVariant>::const_iterator iter (mValues.begin()); iter!=mValues.end(); ++iter)
|
||||||
mModel.setData (mModel.getModelIndex (mId, iter->first), iter->second);
|
mModel.setData (mModel.getModelIndex (mId, iter->first), iter->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,9 +55,9 @@ 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)
|
||||||
{
|
{
|
||||||
setText ( ("Revert record " + id).c_str());
|
setText (("Revert record " + id).c_str());
|
||||||
|
|
||||||
mOld = model.getRecord (id).clone();
|
mOld = model.getRecord (id).clone();
|
||||||
}
|
}
|
||||||
@ -74,7 +74,7 @@ void CSMWorld::RevertCommand::redo()
|
|||||||
QModelIndex index = mModel.getModelIndex (mId, column);
|
QModelIndex index = mModel.getModelIndex (mId, column);
|
||||||
RecordBase::State state = static_cast<RecordBase::State> (mModel.data (index).toInt());
|
RecordBase::State state = static_cast<RecordBase::State> (mModel.data (index).toInt());
|
||||||
|
|
||||||
if (state == RecordBase::State_ModifiedOnly)
|
if (state==RecordBase::State_ModifiedOnly)
|
||||||
{
|
{
|
||||||
mModel.removeRows (index.row(), 1);
|
mModel.removeRows (index.row(), 1);
|
||||||
}
|
}
|
||||||
@ -90,9 +90,9 @@ void CSMWorld::RevertCommand::undo()
|
|||||||
}
|
}
|
||||||
|
|
||||||
CSMWorld::DeleteCommand::DeleteCommand (IdTable& model, const std::string& id, QUndoCommand* parent)
|
CSMWorld::DeleteCommand::DeleteCommand (IdTable& model, const std::string& id, QUndoCommand* parent)
|
||||||
: QUndoCommand (parent), mModel (model), mId (id), mOld (0)
|
: QUndoCommand (parent), mModel (model), mId (id), mOld (0)
|
||||||
{
|
{
|
||||||
setText ( ("Delete record " + id).c_str());
|
setText (("Delete record " + id).c_str());
|
||||||
|
|
||||||
mOld = model.getRecord (id).clone();
|
mOld = model.getRecord (id).clone();
|
||||||
}
|
}
|
||||||
@ -109,7 +109,7 @@ void CSMWorld::DeleteCommand::redo()
|
|||||||
QModelIndex index = mModel.getModelIndex (mId, column);
|
QModelIndex index = mModel.getModelIndex (mId, column);
|
||||||
RecordBase::State state = static_cast<RecordBase::State> (mModel.data (index).toInt());
|
RecordBase::State state = static_cast<RecordBase::State> (mModel.data (index).toInt());
|
||||||
|
|
||||||
if (state == RecordBase::State_ModifiedOnly)
|
if (state==RecordBase::State_ModifiedOnly)
|
||||||
{
|
{
|
||||||
mModel.removeRows (index.row(), 1);
|
mModel.removeRows (index.row(), 1);
|
||||||
}
|
}
|
||||||
@ -127,7 +127,7 @@ void CSMWorld::DeleteCommand::undo()
|
|||||||
|
|
||||||
CSMWorld::ReorderRowsCommand::ReorderRowsCommand (IdTable& model, int baseIndex,
|
CSMWorld::ReorderRowsCommand::ReorderRowsCommand (IdTable& model, int baseIndex,
|
||||||
const std::vector<int>& newOrder)
|
const std::vector<int>& newOrder)
|
||||||
: mModel (model), mBaseIndex (baseIndex), mNewOrder (newOrder)
|
: mModel (model), mBaseIndex (baseIndex), mNewOrder (newOrder)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void CSMWorld::ReorderRowsCommand::redo()
|
void CSMWorld::ReorderRowsCommand::redo()
|
||||||
@ -140,7 +140,7 @@ void CSMWorld::ReorderRowsCommand::undo()
|
|||||||
int size = static_cast<int> (mNewOrder.size());
|
int size = static_cast<int> (mNewOrder.size());
|
||||||
std::vector<int> reverse (size);
|
std::vector<int> reverse (size);
|
||||||
|
|
||||||
for (int i = 0; i < size; ++i)
|
for (int i=0; i < size; ++i)
|
||||||
reverse.at (mNewOrder[i]) = i;
|
reverse.at (mNewOrder[i]) = i;
|
||||||
|
|
||||||
mModel.reorderRows (mBaseIndex, reverse);
|
mModel.reorderRows (mBaseIndex, reverse);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user