diff options
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/diveplanner.cpp | 23 | ||||
-rw-r--r-- | qt-ui/diveplanner.h | 3 |
2 files changed, 26 insertions, 0 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 21d9aa236..f0dad6ca4 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -675,9 +675,25 @@ DiveHandler::DiveHandler(): QGraphicsEllipseItem() setZValue(2); } +int DiveHandler::parentIndex() +{ + DivePlannerGraphics *view = qobject_cast<DivePlannerGraphics*>(scene()->views().first()); + return view->handles.indexOf(this); +} + void DiveHandler::contextMenuEvent(QGraphicsSceneContextMenuEvent* event) { QMenu m; + GasSelectionModel *model = GasSelectionModel::instance(); + model->repopulate(); + int rowCount = model->rowCount(); + for(int i = 0; i < rowCount; i++){ + QAction *action = new QAction(&m); + action->setText( model->data(model->index(i, 0),Qt::DisplayRole).toString()); + connect(action, SIGNAL(triggered(bool)), this, SLOT(changeGas())); + m.addAction(action); + } + m.addSeparator(); m.addAction(QObject::tr("Remove this Point"), this, SLOT(selfRemove())); m.exec(event->screenPos()); } @@ -689,6 +705,13 @@ void DiveHandler::selfRemove() view->keyDeleteAction(); } +void DiveHandler::changeGas() +{ + QAction *action = qobject_cast<QAction*>(sender()); + QModelIndex index = plannerModel->index(parentIndex(), DivePlannerPointsModel::GAS); + plannerModel->setData(index, action->text()); +} + void DiveHandler::mousePressEvent(QGraphicsSceneMouseEvent* event) { if (event->button() != Qt::LeftButton) diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h index dc050a04b..c7ebe4a3a 100644 --- a/qt-ui/diveplanner.h +++ b/qt-ui/diveplanner.h @@ -117,8 +117,11 @@ public: protected: void mousePressEvent(QGraphicsSceneMouseEvent* event); void contextMenuEvent(QGraphicsSceneContextMenuEvent* event); +private: + int parentIndex(); public slots: void selfRemove(); + void changeGas(); }; class Ruler : public QGraphicsLineItem{ |