mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-11 03:21:29 +00:00
Undo: don't delete dive sites when pasting dives
We used to only keep sites with dives around. This changed when implementing the dive site tab. The paste-dive code was written using the old semantics and thus, when overwriting dive sites, it deleted unused dive sites. To make things consistent, remove that code. It would be very weird when dive sites are deleted by pasting, but not by setting a different dive site manually. Bonus: no more dependencies on desktop-includes in the undo code. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
8db3e5cd59
commit
b43ecdad4e
2 changed files with 0 additions and 32 deletions
|
@ -6,7 +6,6 @@
|
||||||
#include "core/qthelper.h" // for copy_qstring
|
#include "core/qthelper.h" // for copy_qstring
|
||||||
#include "core/subsurface-string.h"
|
#include "core/subsurface-string.h"
|
||||||
#include "core/tag.h"
|
#include "core/tag.h"
|
||||||
#include "desktop-widgets/mapwidget.h" // TODO: Replace desktop-dependency by signal
|
|
||||||
|
|
||||||
namespace Command {
|
namespace Command {
|
||||||
|
|
||||||
|
@ -752,15 +751,6 @@ bool PasteDives::workToBeDone()
|
||||||
|
|
||||||
void PasteDives::undo()
|
void PasteDives::undo()
|
||||||
{
|
{
|
||||||
bool diveSiteListChanged = false;
|
|
||||||
|
|
||||||
// If we had taken ownership of dive sites, readd them to the system
|
|
||||||
for (OwningDiveSitePtr &ds: ownedDiveSites) {
|
|
||||||
register_dive_site(ds.release());
|
|
||||||
diveSiteListChanged = true;
|
|
||||||
}
|
|
||||||
ownedDiveSites.clear();
|
|
||||||
|
|
||||||
QVector<dive *> divesToNotify; // Remember dives so that we can send signals later
|
QVector<dive *> divesToNotify; // Remember dives so that we can send signals later
|
||||||
divesToNotify.reserve(dives.size());
|
divesToNotify.reserve(dives.size());
|
||||||
for (PasteState &state: dives) {
|
for (PasteState &state: dives) {
|
||||||
|
@ -769,24 +759,6 @@ void PasteDives::undo()
|
||||||
invalidate_dive_cache(state.d); // Ensure that dive is written in git_save()
|
invalidate_dive_cache(state.d); // Ensure that dive is written in git_save()
|
||||||
}
|
}
|
||||||
|
|
||||||
// If dive sites were pasted, collect all overwritten dive sites
|
|
||||||
// and remove those which don't have users anymore from the core.
|
|
||||||
// But keep an owning pointer. Thus if this undo command is freed, the
|
|
||||||
// dive-site will be automatically deleted and on redo() it can be
|
|
||||||
// readded to the system
|
|
||||||
if (what.divesite) {
|
|
||||||
std::vector<dive_site *> divesites;
|
|
||||||
for (const PasteState &d: dives) {
|
|
||||||
if (std::find(divesites.begin(), divesites.end(), d.divesite) == divesites.end())
|
|
||||||
divesites.push_back(d.divesite);
|
|
||||||
}
|
|
||||||
for (dive_site *ds: divesites) {
|
|
||||||
unregister_dive_site(ds);
|
|
||||||
ownedDiveSites.emplace_back(ds);
|
|
||||||
diveSiteListChanged = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send signals.
|
// Send signals.
|
||||||
DiveField fields(DiveField::NONE);
|
DiveField fields(DiveField::NONE);
|
||||||
fields.notes = what.notes;
|
fields.notes = what.notes;
|
||||||
|
@ -802,9 +774,6 @@ void PasteDives::undo()
|
||||||
emit diveListNotifier.cylindersReset(divesToNotify);
|
emit diveListNotifier.cylindersReset(divesToNotify);
|
||||||
if (what.weights)
|
if (what.weights)
|
||||||
emit diveListNotifier.weightsystemsReset(divesToNotify);
|
emit diveListNotifier.weightsystemsReset(divesToNotify);
|
||||||
|
|
||||||
if (diveSiteListChanged)
|
|
||||||
MapWidget::instance()->reload();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Redo and undo do the same
|
// Redo and undo do the same
|
||||||
|
|
|
@ -257,7 +257,6 @@ struct PasteState {
|
||||||
class PasteDives : public Base {
|
class PasteDives : public Base {
|
||||||
dive_components what;
|
dive_components what;
|
||||||
std::vector<PasteState> dives;
|
std::vector<PasteState> dives;
|
||||||
std::vector<OwningDiveSitePtr> ownedDiveSites;
|
|
||||||
dive *current;
|
dive *current;
|
||||||
public:
|
public:
|
||||||
PasteDives(const dive *d, dive_components what);
|
PasteDives(const dive *d, dive_components what);
|
||||||
|
|
Loading…
Reference in a new issue