diff options
Diffstat (limited to 'profile-widget')
-rw-r--r-- | profile-widget/divehandler.cpp | 13 | ||||
-rw-r--r-- | profile-widget/divehandler.h | 5 | ||||
-rw-r--r-- | profile-widget/profilewidget2.cpp | 2 |
3 files changed, 11 insertions, 9 deletions
diff --git a/profile-widget/divehandler.cpp b/profile-widget/divehandler.cpp index ab56feb6f..4a5088964 100644 --- a/profile-widget/divehandler.cpp +++ b/profile-widget/divehandler.cpp @@ -1,15 +1,16 @@ // SPDX-License-Identifier: GPL-2.0 #include "divehandler.h" #include "profilewidget2.h" +#include "core/dive.h" #include "core/gettextfromc.h" +#include "core/qthelper.h" #include "qt-models/diveplannermodel.h" -#include "qt-models/models.h" #include <QMenu> #include <QGraphicsSceneMouseEvent> #include <QSettings> -DiveHandler::DiveHandler() : QGraphicsEllipseItem() +DiveHandler::DiveHandler(const struct dive *d) : dive(d) { setRect(-5, -5, 10, 10); setFlags(ItemIgnoresTransformations | ItemIsSelectable | ItemIsMovable | ItemSendsGeometryChanges); @@ -32,12 +33,10 @@ void DiveHandler::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance(); QModelIndex index = plannerModel->index(parentIndex(), DivePlannerPointsModel::GAS); if (index.sibling(index.row() + 1, index.column()).isValid()) { - GasSelectionModel *model = GasSelectionModel::instance(); - model->repopulate(); - int rowCount = model->rowCount(); - for (int i = 0; i < rowCount; i++) { + QStringList gases = get_dive_gas_list(dive); + for (int i = 0; i < gases.size(); i++) { QAction *action = new QAction(&m); - action->setText(model->data(model->index(i, 0), Qt::DisplayRole).toString()); + action->setText(gases[i]); action->setData(i); connect(action, &QAction::triggered, this, &DiveHandler::changeGas); m.addAction(action); diff --git a/profile-widget/divehandler.h b/profile-widget/divehandler.h index ecd0248c8..2bf3527ac 100644 --- a/profile-widget/divehandler.h +++ b/profile-widget/divehandler.h @@ -5,10 +5,12 @@ #include <QGraphicsPathItem> #include <QElapsedTimer> +struct dive; + class DiveHandler : public QObject, public QGraphicsEllipseItem { Q_OBJECT public: - DiveHandler(); + DiveHandler(const struct dive *d); protected: void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); @@ -26,6 +28,7 @@ slots: void selfRemove(); void changeGas(); private: + const struct dive *dive; QElapsedTimer t; }; diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index 90638649d..a20504be2 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -1695,7 +1695,7 @@ void ProfileWidget2::disconnectTemporaryConnections() #ifndef SUBSURFACE_MOBILE void ProfileWidget2::pointInserted(const QModelIndex&, int, int) { - DiveHandler *item = new DiveHandler(); + DiveHandler *item = new DiveHandler(&displayed_dive); scene()->addItem(item); handles << item; |