mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
ab99ca85f1
commit
029c9ccf02
4 changed files with 63 additions and 52 deletions
|
|
@ -45,7 +45,7 @@ slots:
|
|||
//HACK: try to get rid of this in the future.
|
||||
void fakeActivation();
|
||||
void fixTabBehavior();
|
||||
virtual void revertModelData(QWidget *widget, QAbstractItemDelegate::EndEditHint hint) = 0;
|
||||
virtual void editorClosed(QWidget *widget, QAbstractItemDelegate::EndEditHint hint) = 0;
|
||||
private:
|
||||
bool editable;
|
||||
protected:
|
||||
|
|
@ -60,7 +60,7 @@ public:
|
|||
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||
public
|
||||
slots:
|
||||
void revertModelData(QWidget *widget, QAbstractItemDelegate::EndEditHint hint);
|
||||
void editorClosed(QWidget *widget, QAbstractItemDelegate::EndEditHint hint);
|
||||
void reenableReplot(QWidget *widget, QAbstractItemDelegate::EndEditHint hint);
|
||||
};
|
||||
|
||||
|
|
@ -78,10 +78,9 @@ class WSInfoDelegate : public ComboBoxDelegate {
|
|||
public:
|
||||
explicit WSInfoDelegate(QObject *parent = 0);
|
||||
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
|
||||
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||
public
|
||||
slots:
|
||||
void revertModelData(QWidget *widget, QAbstractItemDelegate::EndEditHint hint);
|
||||
void editorClosed(QWidget *widget, QAbstractItemDelegate::EndEditHint hint);
|
||||
};
|
||||
|
||||
class AirTypesDelegate : public ComboBoxDelegate {
|
||||
|
|
@ -91,7 +90,7 @@ public:
|
|||
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
|
||||
public
|
||||
slots:
|
||||
void revertModelData(QWidget *widget, QAbstractItemDelegate::EndEditHint hint);
|
||||
void editorClosed(QWidget *widget, QAbstractItemDelegate::EndEditHint hint);
|
||||
};
|
||||
|
||||
class DiveTypesDelegate : public ComboBoxDelegate {
|
||||
|
|
@ -101,7 +100,7 @@ public:
|
|||
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
|
||||
public
|
||||
slots:
|
||||
void revertModelData(QWidget *widget, QAbstractItemDelegate::EndEditHint hint);
|
||||
void editorClosed(QWidget *widget, QAbstractItemDelegate::EndEditHint hint);
|
||||
};
|
||||
|
||||
class SpinBoxDelegate : public QStyledItemDelegate {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue