mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Undo: make dive site removal undoable
Create a new undo-command for deleting dive sites. If there are dives associated with that site, the dives will be removed. The frontend is not yet updated in such a case, as that infrastructure is in a different PR. Connect the trashcan icon of the dive site table to the undo command. Currently, this code is in the dive site model, which makes little sense, but is how the TableView class works. We might want to change that when cylinder and weight editing are made undoable. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
e99c4c9059
commit
8e1f736d2b
7 changed files with 153 additions and 1 deletions
31
desktop-widgets/command_divesite.h
Normal file
31
desktop-widgets/command_divesite.h
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
// Note: this header file is used by the undo-machinery and should not be included elsewhere.
|
||||
|
||||
#ifndef COMMAND_DIVESITE_H
|
||||
#define COMMAND_DIVESITE_H
|
||||
|
||||
#include "command_base.h"
|
||||
|
||||
#include <QVector>
|
||||
|
||||
// We put everything in a namespace, so that we can shorten names without polluting the global namespace
|
||||
namespace Command {
|
||||
|
||||
class DeleteDiveSites : public Base {
|
||||
public:
|
||||
DeleteDiveSites(const QVector<dive_site *> &sites);
|
||||
private:
|
||||
bool workToBeDone() override;
|
||||
|
||||
// For redo
|
||||
std::vector<dive_site *> sitesToRemove;
|
||||
|
||||
// For undo
|
||||
std::vector<OwningDiveSitePtr> sitesToAdd;
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
};
|
||||
|
||||
} // namespace Command
|
||||
|
||||
#endif // COMMAND_DIVESITE_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue