summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-01-03 16:04:54 +0100
committerGravatar bstoeger <32835590+bstoeger@users.noreply.github.com>2020-03-06 10:00:13 +0100
commitc495a49b1b044ab54ee60d4b0db14caa3f8e3de1 (patch)
treea32ec02598b1cc53690c72f7c783c25e8ce38096 /commands
parent62adc24d150b0566b9cc9ab449de4ed30ac2ab62 (diff)
downloadsubsurface-c495a49b1b044ab54ee60d4b0db14caa3f8e3de1.tar.gz
Cleanup: use getDiveSelection() for shifting time
There are two cases where dive-times are shifted: in an explicit dialog and when editing the date/time of a dive. In each of these cases, the selected dives were collected manually. Instead use the getDiveSelection() function. Since this returns a std::vector, change the argument of Command::ShiftTime() to such a std::vector. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'commands')
-rw-r--r--commands/command.cpp2
-rw-r--r--commands/command.h2
-rw-r--r--commands/command_divelist.cpp13
-rw-r--r--commands/command_divelist.h4
4 files changed, 11 insertions, 10 deletions
diff --git a/commands/command.cpp b/commands/command.cpp
index 29702c703..721f51c64 100644
--- a/commands/command.cpp
+++ b/commands/command.cpp
@@ -24,7 +24,7 @@ void deleteDive(const QVector<struct dive*> &divesToDelete)
execute(new DeleteDive(divesToDelete));
}
-void shiftTime(const QVector<dive *> &changedDives, int amount)
+void shiftTime(const std::vector<dive *> &changedDives, int amount)
{
execute(new ShiftTime(changedDives, amount));
}
diff --git a/commands/command.h b/commands/command.h
index bf9bd13ec..7a8ea81b0 100644
--- a/commands/command.h
+++ b/commands/command.h
@@ -28,7 +28,7 @@ void addDive(dive *d, bool autogroup, bool newNumber);
void importDives(struct dive_table *dives, struct trip_table *trips,
struct dive_site_table *sites, int flags, const QString &source); // The tables are consumed!
void deleteDive(const QVector<struct dive*> &divesToDelete);
-void shiftTime(const QVector<dive *> &changedDives, int amount);
+void shiftTime(const std::vector<dive *> &changedDives, int amount);
void renumberDives(const QVector<QPair<dive *, int>> &divesToRenumber);
void removeDivesFromTrip(const QVector<dive *> &divesToRemove);
void removeAutogenTrips();
diff --git a/commands/command_divelist.cpp b/commands/command_divelist.cpp
index 908b366a6..28857c8fa 100644
--- a/commands/command_divelist.cpp
+++ b/commands/command_divelist.cpp
@@ -579,10 +579,10 @@ void DeleteDive::redoit()
}
-ShiftTime::ShiftTime(const QVector<dive *> &changedDives, int amount)
+ShiftTime::ShiftTime(std::vector<dive *> changedDives, int amount)
: diveList(changedDives), timeChanged(amount)
{
- setText(tr("shift time of %n dives", "", changedDives.count()));
+ setText(tr("shift time of %n dives", "", changedDives.size()));
}
void ShiftTime::redoit()
@@ -601,11 +601,12 @@ void ShiftTime::redoit()
sort_dive_table(&trip->dives); // Keep the trip-table in order
// Send signals
- emit diveListNotifier.divesTimeChanged(timeChanged, diveList);
- emit diveListNotifier.divesChanged(diveList, DiveField::DATETIME);
+ QVector<dive *> dives = QVector<dive *>::fromStdVector(diveList);
+ emit diveListNotifier.divesTimeChanged(timeChanged, dives);
+ emit diveListNotifier.divesChanged(dives, DiveField::DATETIME);
// Select the changed dives
- setSelection(std::vector<dive *>(diveList.begin(), diveList.end()), diveList[0]);
+ setSelection(diveList, diveList[0]);
// Negate the time-shift so that the next call does the reverse
timeChanged = -timeChanged;
@@ -613,7 +614,7 @@ void ShiftTime::redoit()
bool ShiftTime::workToBeDone()
{
- return !diveList.isEmpty();
+ return !diveList.empty();
}
void ShiftTime::undoit()
diff --git a/commands/command_divelist.h b/commands/command_divelist.h
index 20d031f54..f1bbc7a91 100644
--- a/commands/command_divelist.h
+++ b/commands/command_divelist.h
@@ -133,14 +133,14 @@ private:
class ShiftTime : public DiveListBase {
public:
- ShiftTime(const QVector<dive *> &changedDives, int amount);
+ ShiftTime(std::vector<dive *> changedDives, int amount);
private:
void undoit() override;
void redoit() override;
bool workToBeDone() override;
// For redo and undo
- QVector<dive *> diveList;
+ std::vector<dive *> diveList;
int timeChanged;
};