From b8c94cad69e59e0b0584c23b39ca9a519c84db94 Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Tue, 8 May 2018 17:26:48 +0200 Subject: Planner: Add combo box for dive mode selection I am not really sure what I am doing here but I copied code from the gas selection. Signed-off-by: Robert C. Helling --- desktop-widgets/modeldelegates.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'desktop-widgets/modeldelegates.cpp') diff --git a/desktop-widgets/modeldelegates.cpp b/desktop-widgets/modeldelegates.cpp index 24dc767c4..6a33e60f4 100644 --- a/desktop-widgets/modeldelegates.cpp +++ b/desktop-widgets/modeldelegates.cpp @@ -407,6 +407,24 @@ AirTypesDelegate::AirTypesDelegate(QObject *parent) : ComboBoxDelegate(GasSelect { } +void DiveTypesDelegate::revertModelData(QWidget *widget, QAbstractItemDelegate::EndEditHint hint) +{ + Q_UNUSED(widget) + Q_UNUSED(hint) +} + +void DiveTypesDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const +{ + if (!index.isValid()) + return; + QComboBox *combo = qobject_cast(editor); + model->setData(index, QVariant(combo->currentIndex())); +} + +DiveTypesDelegate::DiveTypesDelegate(QObject *parent) : ComboBoxDelegate(DiveTypeSelectionModel::instance(), parent, false) +{ +} + SpinBoxDelegate::SpinBoxDelegate(int min, int max, int step, QObject *parent): QStyledItemDelegate(parent), min(min), -- cgit v1.2.3-70-g09d2