subsurface/desktop-widgets/diveplanner.h
Berthold Stoeger bb76cb56d4 desktop: move planner-code to diveplanner.cpp
Around 2015 there was a push to move planner UI code from
mainwindow.cpp to diveplanner.cpp. That never was completed,
presumably because the planner is actually three widgets.

Collect these widgets in one PlannerWidgets class and move
the code there.

This is not a full dis-entanglement, as the plannerwidgets
have to access the profile via the mainwindow. But at least
it collects the planner UI code at a single place.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-12 15:52:40 -08:00

117 lines
2.5 KiB
C++

// SPDX-License-Identifier: GPL-2.0
#ifndef DIVEPLANNER_H
#define DIVEPLANNER_H
#include <QGraphicsPathItem>
#include <QAbstractTableModel>
#include <QAbstractButton>
#include <QDateTime>
#include <QSignalMapper>
#include <QElapsedTimer>
class QListView;
class QModelIndex;
class DivePlannerPointsModel;
class DiveHandler : public QObject, public QGraphicsEllipseItem {
Q_OBJECT
public:
DiveHandler();
protected:
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
void mousePressEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
signals:
void moved();
void clicked();
void released();
private:
int parentIndex();
public
slots:
void selfRemove();
void changeGas();
private:
QElapsedTimer t;
};
#include "ui_diveplanner.h"
class DivePlannerWidget : public QWidget {
Q_OBJECT
public:
explicit DivePlannerWidget(QWidget *parent = 0);
void setReplanButton(bool replan);
public
slots:
void setupStartTime(QDateTime startTime);
void settingsChanged();
void atmPressureChanged(const int pressure);
void heightChanged(const int height);
void waterTypeChanged(const int index);
void customSalinityChanged(double density);
void setSurfacePressure(int surface_pressure);
void setSalinity(int salinity);
private:
Ui::DivePlanner ui;
QAbstractButton *replanButton;
void waterTypeUpdateTexts();
};
#include "ui_plannerSettings.h"
class PlannerSettingsWidget : public QWidget {
Q_OBJECT
public:
explicit PlannerSettingsWidget(QWidget *parent = 0);
~PlannerSettingsWidget();
public
slots:
void settingsChanged();
void setBackgasBreaks(bool dobreaks);
void disableDecoElements(int mode);
void disableBackgasBreaks(bool enabled);
void setDiveMode(int mode);
void setBailoutVisibility(int mode);
private:
Ui::plannerSettingsWidget ui;
void updateUnitsUI();
};
#include "ui_plannerDetails.h"
class PlannerDetails : public QWidget {
Q_OBJECT
public:
explicit PlannerDetails(QWidget *parent = 0);
QPushButton *printPlan() const { return ui.printPlan; }
QTextEdit *divePlanOutput() const { return ui.divePlanOutput; }
public
slots:
void setPlanNotes(QString plan);
private:
Ui::plannerDetails ui;
};
// The planner widgets make up three quadrants
class PlannerWidgets : public QObject {
Q_OBJECT
public:
PlannerWidgets();
void planDive();
void replanDive();
public
slots:
void printDecoPlan();
public:
DivePlannerWidget plannerWidget;
PlannerSettingsWidget plannerSettingsWidget;
PlannerDetails plannerDetails;
};
#endif // DIVEPLANNER_H