mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
145f70aab5
Allow splitting out a dive computer into a distinct dive. This is realized by generating a base class from SplitDive. This turned out to be more cumbersome than expected: we don't know a-priori which of the split dives will come first. Since the undo-command saves the indices where the dives will be insert, these have to be calculated. This is an premature optimization, which makes more pain than necessary. Let's remove it and simply determine the insertion index when executing the command. Original code by Linus Torvalds <torvalds@linux-foundation.org>. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
79 lines
1.6 KiB
C++
79 lines
1.6 KiB
C++
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#include "command.h"
|
|
#include "command_divelist.h"
|
|
|
|
namespace Command {
|
|
|
|
// Dive-list related commands
|
|
void addDive(dive *d, bool autogroup, bool newNumber)
|
|
{
|
|
execute(new AddDive(d, autogroup, newNumber));
|
|
}
|
|
|
|
void importDives(struct dive_table *dives, struct trip_table *trips, int flags, const QString &source)
|
|
{
|
|
execute(new ImportDives(dives, trips, flags, source));
|
|
}
|
|
|
|
void deleteDive(const QVector<struct dive*> &divesToDelete)
|
|
{
|
|
execute(new DeleteDive(divesToDelete));
|
|
}
|
|
|
|
void shiftTime(const QVector<dive *> &changedDives, int amount)
|
|
{
|
|
execute(new ShiftTime(changedDives, amount));
|
|
}
|
|
|
|
void renumberDives(const QVector<QPair<dive *, int>> &divesToRenumber)
|
|
{
|
|
execute(new RenumberDives(divesToRenumber));
|
|
}
|
|
|
|
void removeDivesFromTrip(const QVector<dive *> &divesToRemove)
|
|
{
|
|
execute(new RemoveDivesFromTrip(divesToRemove));
|
|
}
|
|
|
|
void removeAutogenTrips()
|
|
{
|
|
execute(new RemoveAutogenTrips);
|
|
}
|
|
|
|
void addDivesToTrip(const QVector<dive *> &divesToAddIn, dive_trip *trip)
|
|
{
|
|
execute(new AddDivesToTrip(divesToAddIn, trip));
|
|
}
|
|
|
|
void createTrip(const QVector<dive *> &divesToAddIn)
|
|
{
|
|
execute(new CreateTrip(divesToAddIn));
|
|
}
|
|
|
|
void autogroupDives()
|
|
{
|
|
execute(new AutogroupDives);
|
|
}
|
|
|
|
void mergeTrips(dive_trip *trip1, dive_trip *trip2)
|
|
{
|
|
execute(new MergeTrips(trip1, trip2));
|
|
}
|
|
|
|
void splitDives(dive *d, duration_t time)
|
|
{
|
|
execute(new SplitDives(d, time));
|
|
}
|
|
|
|
void splitDiveComputer(dive *d, int dc_num)
|
|
{
|
|
execute(new SplitDiveComputer(d, dc_num));
|
|
}
|
|
|
|
void mergeDives(const QVector <dive *> &dives)
|
|
{
|
|
execute(new MergeDives(dives));
|
|
}
|
|
|
|
} // namespace Command
|