aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--commands/command_divelist.cpp8
-rw-r--r--desktop-widgets/divelistview.cpp19
2 files changed, 9 insertions, 18 deletions
diff --git a/commands/command_divelist.cpp b/commands/command_divelist.cpp
index b19075581..262197214 100644
--- a/commands/command_divelist.cpp
+++ b/commands/command_divelist.cpp
@@ -740,8 +740,14 @@ void TripBase::undoit()
redoit();
}
-RemoveDivesFromTrip::RemoveDivesFromTrip(const QVector<dive *> &divesToRemove)
+RemoveDivesFromTrip::RemoveDivesFromTrip(const QVector<dive *> &divesToRemoveIn)
{
+ // Filter out dives outside of trip. Note: This is in a separate loop to get the command-description right.
+ QVector<dive *> divesToRemove;
+ for (dive *d: divesToRemoveIn) {
+ if (d->divetrip)
+ divesToRemove.push_back(d);
+ }
setText(QStringLiteral("%1 [%2]").arg(Command::Base::tr("remove %n dive(s) from trip", "", divesToRemove.size())).arg(getListOfDives(divesToRemove)));
divesToMove.divesToMove.reserve(divesToRemove.size());
for (dive *d: divesToRemove) {
diff --git a/desktop-widgets/divelistview.cpp b/desktop-widgets/divelistview.cpp
index 14973cf0a..3d5974c53 100644
--- a/desktop-widgets/divelistview.cpp
+++ b/desktop-widgets/divelistview.cpp
@@ -679,15 +679,7 @@ void DiveListView::mergeTripBelow()
void DiveListView::removeFromTrip()
{
- //TODO: move this to C-code.
- int i;
- struct dive *d;
- QVector<dive *> divesToRemove;
- for_each_dive (i, d) {
- if (d->selected && d->divetrip)
- divesToRemove.append(d);
- }
- Command::removeDivesFromTrip(divesToRemove);
+ Command::removeDivesFromTrip(stdToQt(getDiveSelection()));
}
void DiveListView::newTripAbove()
@@ -695,14 +687,7 @@ void DiveListView::newTripAbove()
struct dive *d = contextMenuIndex.data(DiveTripModelBase::DIVE_ROLE).value<struct dive *>();
if (!d) // shouldn't happen as we only are setting up this action if this is a dive
return;
- //TODO: port to c-code.
- int idx;
- QVector<dive *> dives;
- for_each_dive (idx, d) {
- if (d->selected)
- dives.append(d);
- }
- Command::createTrip(dives);
+ Command::createTrip(stdToQt(getDiveSelection()));
}
void DiveListView::addToTripBelow()