subsurface/desktop-widgets/diveplanner.h
Berthold Stoeger 0d011231e6 desktop: unglobalize ComboBox-models
The combo-boxes (cylinder type, weightsystem, etc.) were controlled
by global models. Keeping these models up-to-date was very combersome
and buggy.

Create a new model everytime a combobox is opened. Ultimately it
might even be better to create a copy of the strings and switch
to simple QStringListModel. Set data in the core directly and
don't do this via the models.

The result is much simpler and easier to handle.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-04-16 08:56:49 +12:00

99 lines
2.4 KiB
C++

// SPDX-License-Identifier: GPL-2.0
#ifndef DIVEPLANNER_H
#define DIVEPLANNER_H
#include "core/divemode.h"
#include "core/owning_ptrs.h"
#include <QAbstractTableModel>
#include <QAbstractButton>
#include <QDateTime>
class DivePlannerPointsModel;
class PlannerWidgets;
struct dive;
#include "ui_diveplanner.h"
class DivePlannerWidget : public QWidget {
Q_OBJECT
public:
explicit DivePlannerWidget(dive &planned_dive, PlannerWidgets *parent);
~DivePlannerWidget();
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(PlannerWidgets *parent);
~PlannerSettingsWidget();
public
slots:
void settingsChanged();
void setBackgasBreaks(bool dobreaks);
void disableDecoElements(int mode, divemode_t rebreathermode);
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();
~PlannerWidgets();
void preparePlanDive(const dive *currentDive); // Create a new planned dive
void planDive();
void prepareReplanDive(const dive *d); // Make a copy of the dive to be replanned
void replanDive(int currentDC);
struct dive *getDive() const;
divemode_t getRebreatherMode() const;
public
slots:
void printDecoPlan();
public:
OwningDivePtr planned_dive;
DivePlannerWidget plannerWidget;
PlannerSettingsWidget plannerSettingsWidget;
PlannerDetails plannerDetails;
};
#endif // DIVEPLANNER_H