2013-06-20 12:33:26 -03:00
|
|
|
#ifndef DIVEPLANNER_H
|
|
|
|
#define DIVEPLANNER_H
|
|
|
|
|
|
|
|
#include <QGraphicsPathItem>
|
2013-08-26 09:14:19 -03:00
|
|
|
#include <QAbstractTableModel>
|
2014-06-28 08:07:28 -07:00
|
|
|
#include <QDateTime>
|
2013-08-26 13:18:21 -03:00
|
|
|
|
|
|
|
#include "dive.h"
|
2013-08-26 08:43:37 -03:00
|
|
|
|
2013-07-21 13:54:21 -03:00
|
|
|
class QListView;
|
|
|
|
class QModelIndex;
|
|
|
|
|
2014-02-27 20:09:57 -08:00
|
|
|
class DivePlannerPointsModel : public QAbstractTableModel {
|
2013-08-26 09:14:19 -03:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2014-02-27 20:09:57 -08:00
|
|
|
static DivePlannerPointsModel *instance();
|
|
|
|
enum Sections {
|
|
|
|
REMOVE,
|
|
|
|
DEPTH,
|
|
|
|
DURATION,
|
2014-04-17 10:54:55 +02:00
|
|
|
RUNTIME,
|
2014-02-27 20:09:57 -08:00
|
|
|
GAS,
|
|
|
|
CCSETPOINT,
|
|
|
|
COLUMNS
|
|
|
|
};
|
|
|
|
enum Mode {
|
|
|
|
NOTHING,
|
|
|
|
PLAN,
|
|
|
|
ADD
|
|
|
|
};
|
|
|
|
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
|
|
|
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
|
|
|
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
2013-08-26 13:18:21 -03:00
|
|
|
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
2014-02-27 20:09:57 -08:00
|
|
|
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
|
|
|
|
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
|
|
|
|
void removeSelectedPoints(const QVector<int> &rows);
|
2013-11-08 22:09:46 -02:00
|
|
|
void setPlanMode(Mode mode);
|
2013-09-18 21:33:53 -05:00
|
|
|
bool isPlanner();
|
2014-05-27 11:28:42 -07:00
|
|
|
void createSimpleDive();
|
2014-06-28 08:07:28 -07:00
|
|
|
void setupStartTime();
|
2013-11-08 22:09:46 -02:00
|
|
|
void clear();
|
|
|
|
Mode currentMode() const;
|
2014-04-17 10:54:55 +02:00
|
|
|
bool setRecalc(bool recalc);
|
|
|
|
bool recalcQ();
|
2013-11-13 21:45:54 +09:00
|
|
|
void tanksUpdated();
|
|
|
|
void rememberTanks();
|
2014-06-01 15:25:19 -07:00
|
|
|
bool tankInUse(struct gasmix gasmix);
|
2014-05-28 17:01:18 -07:00
|
|
|
void setupCylinders();
|
2013-08-26 13:18:21 -03:00
|
|
|
/**
|
|
|
|
* @return the row number.
|
|
|
|
*/
|
2014-02-27 20:09:57 -08:00
|
|
|
void editStop(int row, divedatapoint newData);
|
2013-08-26 14:17:39 -03:00
|
|
|
divedatapoint at(int row);
|
2013-09-22 11:01:18 -07:00
|
|
|
int size();
|
2014-05-22 11:40:22 -07:00
|
|
|
struct diveplan &getDiveplan();
|
2013-11-11 17:09:19 +09:00
|
|
|
QStringList &getGasList();
|
2013-12-24 10:18:56 -02:00
|
|
|
QVector<QPair<int, int> > collectGases(dive *d);
|
2014-04-17 10:54:55 +02:00
|
|
|
int lastEnteredPoint();
|
2014-04-24 16:42:10 +02:00
|
|
|
void removeDeco();
|
2014-04-17 10:54:55 +02:00
|
|
|
static bool addingDeco;
|
2013-11-13 21:45:54 +09:00
|
|
|
|
2014-02-27 20:09:57 -08:00
|
|
|
public
|
|
|
|
slots:
|
2014-06-02 12:36:05 -07:00
|
|
|
int addStop(int millimeters = 0, int seconds = 0, struct gasmix *gas = 0, int ccpoint = 0, bool entered = true);
|
2013-11-10 21:02:53 +09:00
|
|
|
void addCylinder_clicked();
|
2013-11-14 19:55:33 +01:00
|
|
|
void setGFHigh(const int gfhigh);
|
|
|
|
void setGFLow(const int ghflow);
|
2013-08-26 13:18:21 -03:00
|
|
|
void setSurfacePressure(int pressure);
|
2014-08-03 22:24:56 +02:00
|
|
|
int getSurfacePressure();
|
2013-08-26 13:18:21 -03:00
|
|
|
void setBottomSac(int sac);
|
|
|
|
void setDecoSac(int sac);
|
2014-02-27 20:09:57 -08:00
|
|
|
void setStartTime(const QTime &t);
|
2014-06-28 08:07:28 -07:00
|
|
|
void setStartDate(const QDate &date);
|
2013-08-26 13:18:21 -03:00
|
|
|
void setLastStop6m(bool value);
|
2014-06-23 19:21:29 +02:00
|
|
|
void setDropStoneMode(bool value);
|
2014-06-02 16:25:58 +02:00
|
|
|
void setVerbatim(bool value);
|
|
|
|
void setDisplayRuntime(bool value);
|
|
|
|
void setDisplayDuration(bool value);
|
|
|
|
void setDisplayTransitions(bool value);
|
2013-08-26 13:18:21 -03:00
|
|
|
void createPlan();
|
2014-02-27 20:09:57 -08:00
|
|
|
void remove(const QModelIndex &index);
|
2013-09-18 21:33:53 -05:00
|
|
|
void cancelPlan();
|
|
|
|
void createTemporaryPlan();
|
|
|
|
void deleteTemporaryPlan();
|
2014-02-27 20:09:57 -08:00
|
|
|
void loadFromDive(dive *d);
|
2014-06-04 09:34:08 -07:00
|
|
|
void emitDataChanged();
|
2014-04-17 10:54:55 +02:00
|
|
|
|
2013-09-16 11:38:41 -03:00
|
|
|
signals:
|
|
|
|
void planCreated();
|
|
|
|
void planCanceled();
|
2014-04-17 21:48:00 -05:00
|
|
|
void cylinderModelEdited();
|
2014-06-28 08:07:28 -07:00
|
|
|
void startTimeChanged(QDateTime);
|
2014-02-27 20:09:57 -08:00
|
|
|
|
2013-08-26 09:14:19 -03:00
|
|
|
private:
|
2014-02-27 20:09:57 -08:00
|
|
|
explicit DivePlannerPointsModel(QObject *parent = 0);
|
2014-06-01 18:18:29 -07:00
|
|
|
bool addGas(struct gasmix mix);
|
2013-08-26 13:18:21 -03:00
|
|
|
struct diveplan diveplan;
|
2013-11-08 22:09:46 -02:00
|
|
|
Mode mode;
|
2014-04-17 10:54:55 +02:00
|
|
|
bool recalc;
|
2013-08-26 13:18:21 -03:00
|
|
|
QVector<divedatapoint> divepoints;
|
2013-09-16 12:11:06 -03:00
|
|
|
void deleteTemporaryPlan(struct divedatapoint *dp);
|
2013-11-01 13:45:14 -04:00
|
|
|
QVector<sample> backupSamples; // For editing added dives.
|
2013-12-24 10:18:56 -02:00
|
|
|
QVector<QPair<int, int> > oldGases;
|
2014-06-28 08:07:28 -07:00
|
|
|
QDateTime startTime;
|
2013-08-26 09:14:19 -03:00
|
|
|
};
|
|
|
|
|
2014-02-27 20:09:57 -08:00
|
|
|
class DiveHandler : public QObject, public QGraphicsEllipseItem {
|
|
|
|
Q_OBJECT
|
2013-06-20 14:29:32 -03:00
|
|
|
public:
|
2013-06-23 13:09:29 -07:00
|
|
|
DiveHandler();
|
2014-02-27 20:09:57 -08:00
|
|
|
|
2013-07-04 11:01:59 -03:00
|
|
|
protected:
|
2014-02-27 20:09:57 -08:00
|
|
|
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
|
2014-05-23 20:51:30 -03:00
|
|
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
2014-06-30 19:08:16 -03:00
|
|
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
|
|
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
2014-05-23 19:50:09 -03:00
|
|
|
signals:
|
|
|
|
void moved();
|
2014-06-30 19:08:16 -03:00
|
|
|
void clicked();
|
|
|
|
void released();
|
2013-11-19 20:42:05 -02:00
|
|
|
private:
|
|
|
|
int parentIndex();
|
2014-02-27 20:09:57 -08:00
|
|
|
public
|
|
|
|
slots:
|
2013-11-14 23:29:36 -02:00
|
|
|
void selfRemove();
|
2013-11-19 20:42:05 -02:00
|
|
|
void changeGas();
|
2013-06-20 14:29:32 -03:00
|
|
|
};
|
2013-06-20 15:52:27 -03:00
|
|
|
|
2013-10-05 00:29:09 -07:00
|
|
|
#include "ui_diveplanner.h"
|
|
|
|
|
2013-08-26 08:43:37 -03:00
|
|
|
class DivePlannerWidget : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2014-02-27 20:09:57 -08:00
|
|
|
explicit DivePlannerWidget(QWidget *parent = 0, Qt::WindowFlags f = 0);
|
|
|
|
public
|
|
|
|
slots:
|
2014-06-28 08:07:28 -07:00
|
|
|
void setupStartTime(QDateTime startTime);
|
2013-12-09 07:43:00 +01:00
|
|
|
void settingsChanged();
|
2014-06-26 17:04:39 +02:00
|
|
|
void atmPressureChanged(const int pressure);
|
|
|
|
void heightChanged(const int height);
|
2014-06-03 10:06:18 +02:00
|
|
|
void printDecoPlan();
|
2014-02-27 20:09:57 -08:00
|
|
|
|
2013-08-26 08:43:37 -03:00
|
|
|
private:
|
2013-10-03 11:54:25 -07:00
|
|
|
Ui::DivePlanner ui;
|
2013-08-26 08:43:37 -03:00
|
|
|
};
|
|
|
|
|
2014-06-10 17:40:02 +02:00
|
|
|
#include "ui_plannerSettings.h"
|
|
|
|
|
|
|
|
class PlannerSettingsWidget : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit PlannerSettingsWidget(QWidget *parent = 0, Qt::WindowFlags f = 0);
|
2014-07-15 15:39:13 -03:00
|
|
|
virtual ~PlannerSettingsWidget();
|
2014-06-10 17:40:02 +02:00
|
|
|
public
|
|
|
|
slots:
|
|
|
|
void settingsChanged();
|
|
|
|
void atmPressureChanged(const QString &pressure);
|
2014-06-20 13:43:09 +02:00
|
|
|
void bottomSacChanged(const int bottomSac);
|
|
|
|
void decoSacChanged(const int decosac);
|
2014-06-10 17:40:02 +02:00
|
|
|
void printDecoPlan();
|
2014-06-25 00:08:36 +02:00
|
|
|
void setAscRate75(int rate);
|
|
|
|
void setAscRate50(int rate);
|
|
|
|
void setAscRateStops(int rate);
|
|
|
|
void setAscRateLast6m(int rate);
|
|
|
|
void setDescRate(int rate);
|
2014-06-25 14:00:03 +02:00
|
|
|
void setBottomPo2(double po2);
|
|
|
|
void setDecoPo2(double po2);
|
2014-07-02 22:07:38 +02:00
|
|
|
void setBackgasBreaks(bool dobreaks);
|
2014-06-10 17:40:02 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
Ui::plannerSettingsWidget ui;
|
2014-07-17 08:03:52 -07:00
|
|
|
void updateUnitsUI();
|
2014-06-10 17:40:02 +02:00
|
|
|
};
|
|
|
|
|
2014-05-21 23:31:26 -03:00
|
|
|
QString dpGasToStr(const divedatapoint &p);
|
|
|
|
|
2014-02-11 19:14:46 +01:00
|
|
|
#endif // DIVEPLANNER_H
|