summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/diveplanner.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-11-25 18:30:49 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-12-12 15:52:40 -0800
commit3b2ae46eb81281b1e145fe58121b542ce30e3925 (patch)
treecc1c967901726edc017285824329884f09b32faa /desktop-widgets/diveplanner.cpp
parentcd33d88768a14f1ce9651fbd80a40c89aaaec91f (diff)
downloadsubsurface-3b2ae46eb81281b1e145fe58121b542ce30e3925.tar.gz
profile: move DiveHandler to profile-widget folder
These are the small dots that describe dragable points on the profile when in the planner. It makes no sense to have them in desktop's planner-widget code. They belong to the profile. Therefore, move the code there and compile on mobile. Not everything can be compiled on mobile for now, but it is a start. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/diveplanner.cpp')
-rw-r--r--desktop-widgets/diveplanner.cpp85
1 files changed, 0 insertions, 85 deletions
diff --git a/desktop-widgets/diveplanner.cpp b/desktop-widgets/diveplanner.cpp
index 166783453..f1efa3f27 100644
--- a/desktop-widgets/diveplanner.cpp
+++ b/desktop-widgets/diveplanner.cpp
@@ -15,8 +15,6 @@
#include "profile-widget/profilewidget2.h"
#include "qt-models/diveplannermodel.h"
-#include <QGraphicsSceneMouseEvent>
-#include <QSettings>
#include <QShortcut>
#ifndef NO_PRINTING
#include <QPrintDialog>
@@ -24,89 +22,6 @@
#include <QBuffer>
#endif
-DiveHandler::DiveHandler() : QGraphicsEllipseItem()
-{
- setRect(-5, -5, 10, 10);
- setFlags(ItemIgnoresTransformations | ItemIsSelectable | ItemIsMovable | ItemSendsGeometryChanges);
- setBrush(Qt::white);
- setZValue(2);
- t.start();
-}
-
-int DiveHandler::parentIndex()
-{
- ProfileWidget2 *view = qobject_cast<ProfileWidget2 *>(scene()->views().first());
- return view->handles.indexOf(this);
-}
-
-void DiveHandler::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
-{
- QMenu m;
- // Don't have a gas selection for the last point
- emit released();
- 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++) {
- QAction *action = new QAction(&m);
- action->setText(model->data(model->index(i, 0), Qt::DisplayRole).toString());
- action->setData(i);
- connect(action, &QAction::triggered, this, &DiveHandler::changeGas);
- m.addAction(action);
- }
- }
- // don't allow removing the last point
- if (plannerModel->rowCount() > 1) {
- m.addSeparator();
- m.addAction(gettextFromC::tr("Remove this point"), this, &DiveHandler::selfRemove);
- m.exec(event->screenPos());
- }
-}
-
-void DiveHandler::selfRemove()
-{
- setSelected(true);
- ProfileWidget2 *view = qobject_cast<ProfileWidget2 *>(scene()->views().first());
- view->keyDeleteAction();
-}
-
-void DiveHandler::changeGas()
-{
- QAction *action = qobject_cast<QAction *>(sender());
- DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance();
- QModelIndex index = plannerModel->index(parentIndex(), DivePlannerPointsModel::GAS);
- plannerModel->gasChange(index.sibling(index.row() + 1, index.column()), action->data().toInt());
-}
-
-void DiveHandler::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
-{
- if (t.elapsed() < 40)
- return;
- t.start();
-
- ProfileWidget2 *view = qobject_cast<ProfileWidget2*>(scene()->views().first());
- if(view->isPointOutOfBoundaries(event->scenePos()))
- return;
-
- QGraphicsEllipseItem::mouseMoveEvent(event);
- emit moved();
-}
-
-void DiveHandler::mousePressEvent(QGraphicsSceneMouseEvent *event)
-{
- QGraphicsItem::mousePressEvent(event);
- emit clicked();
-}
-
-void DiveHandler::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
-{
- QGraphicsItem::mouseReleaseEvent(event);
- emit released();
-}
-
DivePlannerWidget::DivePlannerWidget(QWidget *parent) : QWidget(parent, QFlag(0))
{
DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance();