From 8fe738bf6447a16184df95956afd5123e6c0770d Mon Sep 17 00:00:00 2001 From: Grace Karanja Date: Tue, 17 Mar 2015 07:48:45 +0300 Subject: Consistent variable names in UndoCommands class Implements a uniform variable naming scheme in the undocommands class. Signed-off-by: Grace Karanja Signed-off-by: Dirk Hohndel --- qt-ui/undocommands.cpp | 35 +++++++++++++++++------------------ qt-ui/undocommands.h | 8 ++++---- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/qt-ui/undocommands.cpp b/qt-ui/undocommands.cpp index 6a15f7e03..be27e27dc 100644 --- a/qt-ui/undocommands.cpp +++ b/qt-ui/undocommands.cpp @@ -2,18 +2,18 @@ #include "mainwindow.h" #include "divelist.h" -UndoDeleteDive::UndoDeleteDive(QList diveList) +UndoDeleteDive::UndoDeleteDive(QList deletedDives) + : diveList(deletedDives) { - dives = diveList; setText("delete dive"); - if (dives.count() > 1) - setText(QString("delete %1 dives").arg(QString::number(dives.count()))); + if (diveList.count() > 1) + setText(QString("delete %1 dives").arg(QString::number(diveList.count()))); } void UndoDeleteDive::undo() { - for (int i = 0; i < dives.count(); i++) - record_dive(dives.at(i)); + for (int i = 0; i < diveList.count(); i++) + record_dive(diveList.at(i)); mark_divelist_changed(true); MainWindow::instance()->refreshDisplay(); } @@ -21,32 +21,31 @@ void UndoDeleteDive::undo() void UndoDeleteDive::redo() { QList newList; - for (int i = 0; i < dives.count(); i++) { + for (int i = 0; i < diveList.count(); i++) { //make a copy of the dive before deleting it struct dive* d = alloc_dive(); - copy_dive(dives.at(i), d); + copy_dive(diveList.at(i), d); newList.append(d); //delete the dive - delete_single_dive(get_divenr(dives.at(i))); + delete_single_dive(get_divenr(diveList.at(i))); } mark_divelist_changed(true); MainWindow::instance()->refreshDisplay(); - dives.clear(); - dives = newList; + diveList.clear(); + diveList = newList; } -UndoShiftTime::UndoShiftTime(QList diveList, int amount) +UndoShiftTime::UndoShiftTime(QList changedDives, int amount) + : diveList(changedDives), timeChanged(amount) { setText("shift time"); - dives = diveList; - timeChanged = amount; } void UndoShiftTime::undo() { - for (int i = 0; i < dives.count(); i++) { - struct dive* d = get_dive_by_uniq_id(dives.at(i)); + for (int i = 0; i < diveList.count(); i++) { + struct dive* d = get_dive_by_uniq_id(diveList.at(i)); d->when -= timeChanged; } mark_divelist_changed(true); @@ -55,8 +54,8 @@ void UndoShiftTime::undo() void UndoShiftTime::redo() { - for (int i = 0; i < dives.count(); i++) { - struct dive* d = get_dive_by_uniq_id(dives.at(i)); + for (int i = 0; i < diveList.count(); i++) { + struct dive* d = get_dive_by_uniq_id(diveList.at(i)); d->when += timeChanged; } mark_divelist_changed(true); diff --git a/qt-ui/undocommands.h b/qt-ui/undocommands.h index 36c789fee..e4f2da8e1 100644 --- a/qt-ui/undocommands.h +++ b/qt-ui/undocommands.h @@ -7,22 +7,22 @@ class UndoDeleteDive : public QUndoCommand { public: - UndoDeleteDive(QList diveList); + UndoDeleteDive(QList deletedDives); virtual void undo(); virtual void redo(); private: - QList dives; + QList diveList; }; class UndoShiftTime : public QUndoCommand { public: - UndoShiftTime(QList diveList, int amount); + UndoShiftTime(QList changedDives, int amount); virtual void undo(); virtual void redo(); private: - QList dives; + QList diveList; int timeChanged; }; -- cgit v1.2.3-70-g09d2