is there something that can generate diff from two git branches? Using github for this is kinda annoying.

This commit is contained in:
Marek Kochanowicz 2014-01-27 14:53:39 +01:00
parent 52176d6435
commit c91ae86084

View file

@ -6,60 +6,60 @@
#include "idtable.hpp" #include "idtable.hpp"
#include <components/misc/stringops.hpp> #include <components/misc/stringops.hpp>
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);
setText("Modify " + mModel.headerData(mIndex.column(), Qt::Horizontal, Qt::DisplayRole).toString()); setText ("Modify " + mModel.headerData (mIndex.column(), Qt::Horizontal, Qt::DisplayRole).toString());
} }
void CSMWorld::ModifyCommand::redo() void CSMWorld::ModifyCommand::redo()
{ {
mModel.setData(mIndex, mNew); mModel.setData (mIndex, mNew);
} }
void CSMWorld::ModifyCommand::undo() void CSMWorld::ModifyCommand::undo()
{ {
mModel.setData(mIndex, mOld); mModel.setData (mIndex, mOld);
} }
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)
{ {
mValues[column] = value; mValues[column] = value;
} }
void CSMWorld::CreateCommand::setType(UniversalId::Type type) void CSMWorld::CreateCommand::setType (UniversalId::Type type)
{ {
mType = type; mType = type;
} }
void CSMWorld::CreateCommand::redo() 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);
} }
void CSMWorld::CreateCommand::undo() void CSMWorld::CreateCommand::undo()
{ {
mModel.removeRow(mModel.getModelIndex(mId, 0).row()); mModel.removeRow (mModel.getModelIndex (mId, 0).row());
} }
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();
} }
CSMWorld::RevertCommand::~RevertCommand() CSMWorld::RevertCommand::~RevertCommand()
@ -69,32 +69,32 @@ CSMWorld::RevertCommand::~RevertCommand()
void CSMWorld::RevertCommand::redo() void CSMWorld::RevertCommand::redo()
{ {
int column = mModel.findColumnIndex(Columns::ColumnId_Modification); int column = mModel.findColumnIndex (Columns::ColumnId_Modification);
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);
} }
else else
{ {
mModel.setData(index, static_cast<int>(RecordBase::State_BaseOnly)); mModel.setData (index, static_cast<int> (RecordBase::State_BaseOnly));
} }
} }
void CSMWorld::RevertCommand::undo() void CSMWorld::RevertCommand::undo()
{ {
mModel.setRecord(mId, *mOld); mModel.setRecord (mId, *mOld);
} }
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();
} }
CSMWorld::DeleteCommand::~DeleteCommand() CSMWorld::DeleteCommand::~DeleteCommand()
@ -104,73 +104,73 @@ CSMWorld::DeleteCommand::~DeleteCommand()
void CSMWorld::DeleteCommand::redo() void CSMWorld::DeleteCommand::redo()
{ {
int column = mModel.findColumnIndex(Columns::ColumnId_Modification); int column = mModel.findColumnIndex (Columns::ColumnId_Modification);
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);
} }
else else
{ {
mModel.setData(index, static_cast<int>(RecordBase::State_Deleted)); mModel.setData (index, static_cast<int> (RecordBase::State_Deleted));
} }
} }
void CSMWorld::DeleteCommand::undo() void CSMWorld::DeleteCommand::undo()
{ {
mModel.setRecord(mId, *mOld); mModel.setRecord (mId, *mOld);
} }
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()
{ {
mModel.reorderRows(mBaseIndex, mNewOrder); mModel.reorderRows (mBaseIndex, mNewOrder);
} }
void CSMWorld::ReorderRowsCommand::undo() 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);
} }
CSMWorld::CloneCommand::CloneCommand(CSMWorld::IdTable& model, CSMWorld::CloneCommand::CloneCommand (CSMWorld::IdTable& model,
const std::string& idOrigin, const std::string& idOrigin,
const std::string& IdDestination, const std::string& IdDestination,
const CSMWorld::UniversalId::Type type, const CSMWorld::UniversalId::Type type,
QUndoCommand* parent) : QUndoCommand* parent) :
QUndoCommand(parent), QUndoCommand (parent),
mModel(model), mModel (model),
mIdOrigin(idOrigin), mIdOrigin (idOrigin),
mIdDestination(Misc::StringUtils::lowerCase(IdDestination)), mIdDestination (Misc::StringUtils::lowerCase (IdDestination)),
mType(type) mType (type)
{ {
setText(("Clone record " + idOrigin + " to the " + IdDestination).c_str()); setText ( ("Clone record " + idOrigin + " to the " + IdDestination).c_str());
} }
void CSMWorld::CloneCommand::redo() void CSMWorld::CloneCommand::redo()
{ {
mModel.cloneRecord(mIdOrigin, mIdDestination, mType); mModel.cloneRecord (mIdOrigin, mIdDestination, 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(mIdDestination, iter->first), iter->second); mModel.setData (mModel.getModelIndex (mIdDestination, iter->first), iter->second);
} }
void CSMWorld::CloneCommand::undo() void CSMWorld::CloneCommand::undo()
{ {
mModel.removeRow(mModel.getModelIndex(mIdDestination, 0).row()); mModel.removeRow (mModel.getModelIndex (mIdDestination, 0).row());
} }
// kate: indent-mode cstyle; indent-width 4; replace-tabs on; // kate: indent-mode cstyle; indent-width 4; replace-tabs on;