mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Rewrite dive edit logic
The existing code took an odd approach. It tried to change all selected dives whenever the user edited a field, and kept all this backup data in case the user rejected the edits. This code takes the opposite approach. Only edit a copy of the selected dive and then when the user accepts it, edit all the dives and when the user rejects the edit simply redraw the screen (as all the "real" data is still unchanged). This not only saves quite a bit of code, it should be much easier to get correct. Admitedly this code will need quite a bit more testing to make sure it works as intended, but as far as I can tell it already gets more scenarios right than the previous implementation. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
db4a003ef5
commit
eb9d6d0f94
4 changed files with 148 additions and 214 deletions
|
@ -18,25 +18,6 @@
|
|||
class QCompleter;
|
||||
struct dive;
|
||||
|
||||
struct NotesBackup {
|
||||
QString airtemp;
|
||||
QString watertemp;
|
||||
QString datetime;
|
||||
QString location;
|
||||
QString coordinates;
|
||||
degrees_t latitude;
|
||||
degrees_t longitude;
|
||||
QString notes;
|
||||
QString buddy;
|
||||
QString suit;
|
||||
int rating;
|
||||
int visibility;
|
||||
QString divemaster;
|
||||
QString tags;
|
||||
cylinder_t cylinders[MAX_CYLINDERS];
|
||||
weightsystem_t weightsystem[MAX_WEIGHTSYSTEMS];
|
||||
};
|
||||
|
||||
struct Completers {
|
||||
QCompleter *location;
|
||||
QCompleter *divemaster;
|
||||
|
@ -106,24 +87,17 @@ private:
|
|||
Ui::MainTab ui;
|
||||
WeightModel *weightModel;
|
||||
CylindersModel *cylindersModel;
|
||||
QMap<dive *, NotesBackup> notesBackup;
|
||||
EditMode editMode;
|
||||
|
||||
BuddyCompletionModel buddyModel;
|
||||
DiveMasterCompletionModel diveMasterModel;
|
||||
LocationCompletionModel locationModel;
|
||||
SuitCompletionModel suitModel;
|
||||
TagCompletionModel tagModel;
|
||||
|
||||
/* since the multi-edition of the equipment is fairly more
|
||||
* complex than a single item, because it involves a Qt
|
||||
* Model to edit things, we are copying the first selected
|
||||
* dive to this structure, making all editions there,
|
||||
* then applying the changes on the other dives.*/
|
||||
struct dive multiEditEquipmentPlaceholder;
|
||||
struct dive editedDive; // when editing we do all changes on a copy of the real data and only apply when saved
|
||||
Completers completers;
|
||||
void resetPallete();
|
||||
void saveTags();
|
||||
bool tagsChanged(struct dive *a, struct dive *b);
|
||||
void updateGpsCoordinates(const struct dive *dive);
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue