summaryrefslogtreecommitdiffstats
path: root/qt-ui/maintab.h
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-06-02 18:13:50 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-06-02 23:38:36 -0700
commiteb9d6d0f94adaf390ae94428afca74c78bc53c53 (patch)
tree6394c39454e544b381692ae5c2a4eb976a1b5b57 /qt-ui/maintab.h
parentdb4a003ef52baeee8f7d56e56f8314cf61ec4b64 (diff)
downloadsubsurface-eb9d6d0f94adaf390ae94428afca74c78bc53c53.tar.gz
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>
Diffstat (limited to 'qt-ui/maintab.h')
-rw-r--r--qt-ui/maintab.h30
1 files changed, 2 insertions, 28 deletions
diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h
index 90d3c49ef..b8a5f2d7f 100644
--- a/qt-ui/maintab.h
+++ b/qt-ui/maintab.h
@@ -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);
};