mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
1aa06e6802
commit
1dcc885bb2
3 changed files with 106 additions and 34 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue