diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-11-04 20:20:32 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-12-05 10:14:25 -0800 |
commit | 029c9ccf020fdb73c148da489e0e7b1acd3ca149 (patch) | |
tree | 28e92d6662d6e6ece3755369b30164d316d76f53 /qt-models/weightmodel.h | |
parent | ab99ca85f12b92ed55219c82ec2220aebfe1dda5 (diff) | |
download | subsurface-029c9ccf020fdb73c148da489e0e7b1acd3ca149.tar.gz |
Desktop: refactor WSInfoDelegate logic
The WSInfoDelegate (weight-system-info delegate) is used to display
a combo box of known weightsystem-types and auto-fills the weight if
the weightsystem-type is changed.
This would overwrite the weight data of the displayed dive when the
user hovers over the different entries. Moreover, it saves the original
weight in case the user cancels the editing action.
This is not viable when implementing undo of weightsystem changes,
because hovering over entries should not produce individual undo
commands. Instead, implement a special "temporary" row in the
weightsystem model. On canceling of the edit actions, simply reload
the weightsystem from the unmodified dive.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models/weightmodel.h')
-rw-r--r-- | qt-models/weightmodel.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/qt-models/weightmodel.h b/qt-models/weightmodel.h index f3002a1ae..c8f9c9776 100644 --- a/qt-models/weightmodel.h +++ b/qt-models/weightmodel.h @@ -21,8 +21,10 @@ public: int rowCount(const QModelIndex &parent = QModelIndex()) const override; Qt::ItemFlags flags(const QModelIndex &index) const override; bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; + void setTempWS(int row, weightsystem_t ws); + void clearTempWS(); + void commitTempWS(); - void passInData(const QModelIndex &index, const QVariant &value); void clear(); void updateDive(dive *d); weightsystem_t weightSystemAt(const QModelIndex &index) const; @@ -36,6 +38,9 @@ slots: private: dive *d; + // If we temporarily change a line because the user is selecting a weight type + int tempRow; + weightsystem_t tempWS; }; #endif |