summaryrefslogtreecommitdiffstats
path: root/qt-models/cylindermodel.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-02-28 20:38:04 +0100
committerGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-04-07 00:13:35 +0200
commit1dcc885bb257d6c8c64074f8788b468397c34aaa (patch)
tree39c987e36b7f0f103dbdf412c582da1b1907a0e1 /qt-models/cylindermodel.h
parent1aa06e680230351024c05152aeca9a189c5a8d4f (diff)
downloadsubsurface-1dcc885bb257d6c8c64074f8788b468397c34aaa.tar.gz
undo/cylinders: Implement editing of the type
This one is tricky, as when browsing through the types-combobox, the user is presented with presets without actually changing the dive. We do not want an undo-command for every change-event in the combo-box. Therefore, implement a scheme analoguous to the weight-editing: A temporary row can be set / committed or reset. Sadly, the code is more complex because we have to consider the planner, which is not included in the undo system. Firstly, the planner uses a different model, therefore all interactions are channeled through setData() with special roles. Secondly, in the planner we shouldn't place an undo command, but simply overwrite the dive. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models/cylindermodel.h')
-rw-r--r--qt-models/cylindermodel.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/qt-models/cylindermodel.h b/qt-models/cylindermodel.h
index d3d87b900..e4585b0ac 100644
--- a/qt-models/cylindermodel.h
+++ b/qt-models/cylindermodel.h
@@ -31,7 +31,9 @@ public:
};
enum Roles {
- PASS_IN_ROLE = Qt::UserRole + 1 // For setting data: don't do any conversions
+ TEMP_ROLE = Qt::UserRole + 1, // Temporarily set data, but don't store in dive
+ COMMIT_ROLE, // Save the temporary data to the dive. Must be set with Column == TYPE.
+ REVERT_ROLE // Revert to original data from dive. Must be set with Column == TYPE.
};
explicit CylindersModel(QObject *parent = 0);
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
@@ -59,7 +61,14 @@ slots:
private:
dive *d;
+ // Used if we temporarily change a line because the user is selecting a weight type
+ int tempRow;
+ cylinder_t tempCyl;
+
cylinder_t *cylinderAt(const QModelIndex &index);
+ void initTempCyl(int row);
+ void clearTempCyl();
+ void commitTempCyl(int row);
};
// Cylinder model that hides unused cylinders if the pref.show_unused_cylinders flag is not set