diff -r 241d3e452b32 -r 265b2e95a8e8 src/editHistory.cpp --- a/src/editHistory.cpp Fri Dec 28 00:03:47 2018 +0200 +++ b/src/editHistory.cpp Thu Jun 20 08:54:35 2019 +0300 @@ -137,10 +137,10 @@ return m_parent; } -AddHistoryEntry::AddHistoryEntry(const QModelIndex& index, EditHistory* parent) : +AddHistoryEntry::AddHistoryEntry(const Uuid& id, const int row, EditHistory* parent) : AbstractHistoryEntry {parent}, - m_row {index.row()}, - m_code {Serializer::store(parent->document()->lookup(index))} {} + m_row {row}, + m_code {Serializer::store(parent->document()->lookup(id))} {} void AddHistoryEntry::undo() { @@ -164,13 +164,13 @@ } EditHistoryEntry::EditHistoryEntry( - const QModelIndex& index, + const int row, const Serializer::Archive& oldState, const Serializer::Archive& newState, EditHistory* parent ) : AbstractHistoryEntry {parent}, - row {index.row()}, + row {row}, oldState {oldState}, newState {newState} {} @@ -183,32 +183,3 @@ { parent()->document()->setObjectAt(row, newState); } - -MoveHistoryEntry::MoveHistoryEntry(int top, int bottom, int destination, EditHistory* parent) : - AbstractHistoryEntry {parent}, - top {top}, - bottom {bottom}, - destination {destination} {} - -void MoveHistoryEntry::undo() -{ - bool downwards = (destination < top); - parent()->document()->moveRows( - {}, - downwards ? (destination) : (destination - (bottom - top) - 1), - bottom - top + 1, - {}, - downwards ? (bottom + 1) : top - ); -} - -void MoveHistoryEntry::redo() -{ - parent()->document()->moveRows( - {}, - top, - bottom - top + 1, - {}, - destination - ); -}