aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets
diff options
context:
space:
mode:
authorGravatar Rick Walsh <rickmwalsh@gmail.com>2016-07-06 22:40:28 +1000
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-07-09 12:07:25 -0700
commitb1ed04a7f462d88b28b1abab881a0e1a8acc212a (patch)
tree3281beb6fb2789d790330e14a07266ec8df4c5c9 /desktop-widgets
parent066f79223cf49cda5f762b3b9413774b8417cb9f (diff)
downloadsubsurface-b1ed04a7f462d88b28b1abab881a0e1a8acc212a.tar.gz
Have divedatapoint store cylinder id instead of gasmix
Determining the correct cylinder index from a known gas mix can be complicated, but it is trivial to look up the gasmix from the cylinder_t structure. It makes sense to remember which cylinder is being used. This simplifies handling changing a cylinder's gas mix, either directly by the user, or indirectly in the planner. It also permits tracking of multiple cylinders of the same mix, e.g. independent twins / sidemount. Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'desktop-widgets')
-rw-r--r--desktop-widgets/diveplanner.cpp5
-rw-r--r--desktop-widgets/modeldelegates.cpp2
2 files changed, 5 insertions, 2 deletions
diff --git a/desktop-widgets/diveplanner.cpp b/desktop-widgets/diveplanner.cpp
index 0455573e4..4e462cca0 100644
--- a/desktop-widgets/diveplanner.cpp
+++ b/desktop-widgets/diveplanner.cpp
@@ -49,6 +49,7 @@ void DiveHandler::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
for (int i = 0; i < rowCount; i++) {
QAction *action = new QAction(&m);
action->setText(model->data(model->index(i, 0), Qt::DisplayRole).toString());
+ action->setData(i);
connect(action, SIGNAL(triggered(bool)), this, SLOT(changeGas()));
m.addAction(action);
}
@@ -72,7 +73,7 @@ void DiveHandler::changeGas()
{
QAction *action = qobject_cast<QAction *>(sender());
QModelIndex index = plannerModel->index(parentIndex(), DivePlannerPointsModel::GAS);
- plannerModel->gaschange(index.sibling(index.row() + 1, index.column()), action->text());
+ plannerModel->gaschange(index.sibling(index.row() + 1, index.column()), action->data().toInt());
}
void DiveHandler::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
@@ -126,6 +127,8 @@ DivePlannerWidget::DivePlannerWidget(QWidget *parent, Qt::WindowFlags f) : QWidg
connect(CylindersModel::instance(), SIGNAL(rowsRemoved(QModelIndex, int, int)),
GasSelectionModel::instance(), SLOT(repopulate()));
connect(CylindersModel::instance(), SIGNAL(dataChanged(QModelIndex, QModelIndex)),
+ plannerModel, SLOT(emitDataChanged()));
+ connect(CylindersModel::instance(), SIGNAL(dataChanged(QModelIndex, QModelIndex)),
plannerModel, SIGNAL(cylinderModelEdited()));
connect(CylindersModel::instance(), SIGNAL(rowsInserted(QModelIndex, int, int)),
plannerModel, SIGNAL(cylinderModelEdited()));
diff --git a/desktop-widgets/modeldelegates.cpp b/desktop-widgets/modeldelegates.cpp
index a80137e80..01e8f4d17 100644
--- a/desktop-widgets/modeldelegates.cpp
+++ b/desktop-widgets/modeldelegates.cpp
@@ -403,7 +403,7 @@ void AirTypesDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
if (!index.isValid())
return;
QComboBox *combo = qobject_cast<QComboBox *>(editor);
- model->setData(index, QVariant(combo->currentText()));
+ model->setData(index, QVariant(combo->currentIndex()));
}
AirTypesDelegate::AirTypesDelegate(QObject *parent) : ComboBoxDelegate(GasSelectionModel::instance(), parent)