Undo: use vectors for MergeDives and SplitDive

The MergeDives and SplitDive commands used addDive() and removeDive()
calls to manage their dives. Unfortunately, these calls don't send
the proper signals and thus the dive-list was not updated. Instead,
use one- and two-element vectors, which are passed to addDives()
and removeDives() [note the plural].

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2018-08-10 08:02:02 -04:00 committed by Dirk Hohndel
parent 7067e33596
commit 1afd295c41
2 changed files with 46 additions and 33 deletions

View file

@ -182,13 +182,17 @@ private:
// For redo
// For each dive to split, we remove one from and put two dives into the backend
dive *diveToSplit;
DiveToAdd splitDives[2];
// Note: we use a vector even though we split only a single dive, so
// that we can reuse the multi-dive functions of the other commands.
std::vector<dive *> diveToSplit;
std::vector<DiveToAdd> splitDives;
// For undo
// For each dive to unsplit, we remove two dives from and add one into the backend
DiveToAdd unsplitDive;
dive *divesToUnsplit[2];
// Note: we use a vector even though we unsplit only a single dive, so
// that we can reuse the multi-dive functions of the other commands.
std::vector<DiveToAdd> unsplitDive;
std::vector<dive *> divesToUnsplit;
};
class MergeDives : public DiveListBase {
@ -201,13 +205,17 @@ private:
// For redo
// Add one and remove a batch of dives
DiveToAdd mergedDive;
std::vector<dive *> divesToMerge;
// Note: we use a vector even though we add only a single dive, so
// that we can reuse the multi-dive functions of the other commands.
std::vector<DiveToAdd> mergedDive;
std::vector<dive *> divesToMerge;
// For undo
// Remove one and add a batch of dives
dive *diveToUnmerge;
std::vector<DiveToAdd> unmergedDives;
// Note: we use a vector even though we remove only a single dive, so
// that we can reuse the multi-dive functions of the other commands.
std::vector<dive *> diveToUnmerge;
std::vector<DiveToAdd> unmergedDives;
// For undo and redo
QVector<QPair<dive *, int>> divesToRenumber;