2018-07-23 21:41:23 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
|
|
|
|
#include "command.h"
|
|
|
|
#include "command_divelist.h"
|
|
|
|
|
|
|
|
namespace Command {
|
|
|
|
|
|
|
|
// Dive-list related commands
|
Undo: make adding of planned dive undo-able
Planned dives were still added by directly calling core code.
This could confuse the undo-machinery, leading to crashes.
Instead, use the proper undo-command. The problem is that as
opposed to the other AddDive-commands, planned dives may
belong to a trip. Thus, the interface to the AddDive command
was changed to respect the divetrip field. Make sure that
the other callers reset that field (actually, it should never
be set). Add a comment describing the perhaps surprising
interface (the passed-in dive, usually displayed dive, is
reset).
Moreover, a dive cloned in the planner is not assigned a
new number. Thus, add an argument to the AddDive-command,
which expresses whether a new number should be generated
for the to-be-added dive.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-09-08 17:58:11 +00:00
|
|
|
void addDive(dive *d, bool autogroup, bool newNumber)
|
2018-07-23 21:41:23 +00:00
|
|
|
{
|
Undo: make adding of planned dive undo-able
Planned dives were still added by directly calling core code.
This could confuse the undo-machinery, leading to crashes.
Instead, use the proper undo-command. The problem is that as
opposed to the other AddDive-commands, planned dives may
belong to a trip. Thus, the interface to the AddDive command
was changed to respect the divetrip field. Make sure that
the other callers reset that field (actually, it should never
be set). Add a comment describing the perhaps surprising
interface (the passed-in dive, usually displayed dive, is
reset).
Moreover, a dive cloned in the planner is not assigned a
new number. Thus, add an argument to the AddDive-command,
which expresses whether a new number should be generated
for the to-be-added dive.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-09-08 17:58:11 +00:00
|
|
|
execute(new AddDive(d, autogroup, newNumber));
|
2018-07-23 21:41:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void deleteDive(const QVector<struct dive*> &divesToDelete)
|
|
|
|
{
|
|
|
|
execute(new DeleteDive(divesToDelete));
|
|
|
|
}
|
|
|
|
|
|
|
|
void shiftTime(const QVector<dive *> &changedDives, int amount)
|
|
|
|
{
|
|
|
|
execute(new ShiftTime(changedDives, amount));
|
|
|
|
}
|
|
|
|
|
2018-07-30 13:55:29 +00:00
|
|
|
void renumberDives(const QVector<QPair<dive *, int>> &divesToRenumber)
|
2018-07-23 21:41:23 +00:00
|
|
|
{
|
|
|
|
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 mergeDives(const QVector <dive *> &dives)
|
|
|
|
{
|
|
|
|
execute(new MergeDives(dives));
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Command
|