2013-06-20 15:33:26 +00:00
|
|
|
#ifndef DIVEPLANNER_H
|
|
|
|
#define DIVEPLANNER_H
|
|
|
|
|
|
|
|
#include <QGraphicsView>
|
|
|
|
#include <QGraphicsPathItem>
|
2013-06-20 21:40:59 +00:00
|
|
|
#include <QDialog>
|
2013-08-26 12:14:19 +00:00
|
|
|
#include <QAbstractTableModel>
|
2013-08-26 16:18:21 +00:00
|
|
|
#include <QDateTime>
|
|
|
|
|
|
|
|
#include "dive.h"
|
2013-08-26 11:43:37 +00:00
|
|
|
|
2013-07-21 16:54:21 +00:00
|
|
|
class QListView;
|
|
|
|
class QModelIndex;
|
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
class DivePlannerPointsModel : public QAbstractTableModel {
|
2013-08-26 12:14:19 +00:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2014-02-28 04:09:57 +00:00
|
|
|
static DivePlannerPointsModel *instance();
|
|
|
|
enum Sections {
|
|
|
|
REMOVE,
|
|
|
|
DEPTH,
|
|
|
|
DURATION,
|
2014-04-17 08:54:55 +00:00
|
|
|
RUNTIME,
|
2014-02-28 04:09:57 +00: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 16:18:21 +00:00
|
|
|
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
2014-02-28 04:09:57 +00: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-09 00:09:46 +00:00
|
|
|
void setPlanMode(Mode mode);
|
2013-09-19 02:33:53 +00:00
|
|
|
bool isPlanner();
|
2013-09-20 12:36:14 +00:00
|
|
|
void createSimpleDive();
|
2013-11-09 00:09:46 +00:00
|
|
|
void clear();
|
|
|
|
Mode currentMode() const;
|
2014-04-17 08:54:55 +00:00
|
|
|
bool setRecalc(bool recalc);
|
|
|
|
bool recalcQ();
|
2013-11-13 12:45:54 +00:00
|
|
|
void tanksUpdated();
|
|
|
|
void rememberTanks();
|
|
|
|
bool tankInUse(int o2, int he);
|
2013-11-14 09:36:21 +00:00
|
|
|
void copyCylinders(struct dive *d);
|
2014-05-08 21:36:45 +00:00
|
|
|
void copyCylindersFrom(struct dive *d);
|
2013-08-26 16:18:21 +00:00
|
|
|
/**
|
|
|
|
* @return the row number.
|
|
|
|
*/
|
2014-02-28 04:09:57 +00:00
|
|
|
void editStop(int row, divedatapoint newData);
|
2013-08-26 17:17:39 +00:00
|
|
|
divedatapoint at(int row);
|
2013-09-22 18:01:18 +00:00
|
|
|
int size();
|
2014-05-22 18:40:22 +00:00
|
|
|
struct diveplan &getDiveplan();
|
2013-11-11 08:09:19 +00:00
|
|
|
QStringList &getGasList();
|
2013-12-24 12:18:56 +00:00
|
|
|
QVector<QPair<int, int> > collectGases(dive *d);
|
2014-04-17 08:54:55 +00:00
|
|
|
int lastEnteredPoint();
|
2014-04-24 14:42:10 +00:00
|
|
|
void removeDeco();
|
2014-04-17 08:54:55 +00:00
|
|
|
static bool addingDeco;
|
2013-11-13 12:45:54 +00:00
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
public
|
|
|
|
slots:
|
2014-03-12 15:49:42 +00:00
|
|
|
int addStop(int millimeters = 0, int seconds = 0, int o2 = 0, int he = 0, int ccpoint = 0, bool entered = true);
|
2013-11-10 12:02:53 +00:00
|
|
|
void addCylinder_clicked();
|
2013-11-14 18:55:33 +00:00
|
|
|
void setGFHigh(const int gfhigh);
|
|
|
|
void setGFLow(const int ghflow);
|
2013-08-26 16:18:21 +00:00
|
|
|
void setSurfacePressure(int pressure);
|
|
|
|
void setBottomSac(int sac);
|
|
|
|
void setDecoSac(int sac);
|
2014-02-28 04:09:57 +00:00
|
|
|
void setStartTime(const QTime &t);
|
2013-08-26 16:18:21 +00:00
|
|
|
void setLastStop6m(bool value);
|
|
|
|
void createPlan();
|
2014-02-28 04:09:57 +00:00
|
|
|
void remove(const QModelIndex &index);
|
2013-09-19 02:33:53 +00:00
|
|
|
void cancelPlan();
|
|
|
|
void createTemporaryPlan();
|
|
|
|
void deleteTemporaryPlan();
|
2014-02-28 04:09:57 +00:00
|
|
|
void loadFromDive(dive *d);
|
2013-11-18 19:55:56 +00:00
|
|
|
void restoreBackupDive();
|
2014-04-17 08:54:55 +00:00
|
|
|
|
2013-09-16 14:38:41 +00:00
|
|
|
signals:
|
|
|
|
void planCreated();
|
|
|
|
void planCanceled();
|
2014-04-18 02:48:00 +00:00
|
|
|
void cylinderModelEdited();
|
2014-02-28 04:09:57 +00:00
|
|
|
|
2013-08-26 12:14:19 +00:00
|
|
|
private:
|
2014-02-28 04:09:57 +00:00
|
|
|
explicit DivePlannerPointsModel(QObject *parent = 0);
|
2013-11-12 02:19:04 +00:00
|
|
|
bool addGas(int o2, int he);
|
2013-08-26 16:18:21 +00:00
|
|
|
struct diveplan diveplan;
|
2013-11-09 00:09:46 +00:00
|
|
|
Mode mode;
|
2014-04-17 08:54:55 +00:00
|
|
|
bool recalc;
|
2013-08-26 16:18:21 +00:00
|
|
|
QVector<divedatapoint> divepoints;
|
2013-09-16 15:11:06 +00:00
|
|
|
struct dive *tempDive;
|
2013-11-18 19:55:56 +00:00
|
|
|
struct dive backupDive;
|
2013-09-16 15:11:06 +00:00
|
|
|
void deleteTemporaryPlan(struct divedatapoint *dp);
|
2013-11-01 17:45:14 +00:00
|
|
|
QVector<sample> backupSamples; // For editing added dives.
|
2013-11-10 12:02:53 +00:00
|
|
|
struct dive *stagingDive;
|
2013-12-24 12:18:56 +00:00
|
|
|
QVector<QPair<int, int> > oldGases;
|
2013-08-26 12:14:19 +00:00
|
|
|
};
|
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
class DiveHandler : public QObject, public QGraphicsEllipseItem {
|
|
|
|
Q_OBJECT
|
2013-06-20 17:29:32 +00:00
|
|
|
public:
|
2013-06-23 20:09:29 +00:00
|
|
|
DiveHandler();
|
2014-02-28 04:09:57 +00:00
|
|
|
|
2013-07-04 14:01:59 +00:00
|
|
|
protected:
|
2014-02-28 04:09:57 +00:00
|
|
|
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
|
2014-05-23 23:51:30 +00:00
|
|
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
2014-05-23 22:50:09 +00:00
|
|
|
signals:
|
|
|
|
void moved();
|
2013-11-19 22:42:05 +00:00
|
|
|
private:
|
|
|
|
int parentIndex();
|
2014-02-28 04:09:57 +00:00
|
|
|
public
|
|
|
|
slots:
|
2013-11-15 01:29:36 +00:00
|
|
|
void selfRemove();
|
2013-11-19 22:42:05 +00:00
|
|
|
void changeGas();
|
2013-06-20 17:29:32 +00:00
|
|
|
};
|
2013-06-20 18:52:27 +00:00
|
|
|
|
2013-06-20 21:40:59 +00:00
|
|
|
class DivePlannerGraphics : public QGraphicsView {
|
2013-06-20 15:33:26 +00:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2014-02-28 04:09:57 +00:00
|
|
|
DivePlannerGraphics(QWidget *parent = 0);
|
|
|
|
private
|
|
|
|
slots:
|
2014-05-24 15:39:40 +00:00
|
|
|
|
2013-06-20 15:33:26 +00:00
|
|
|
};
|
2013-06-20 21:40:59 +00:00
|
|
|
|
2013-10-05 07:29:09 +00:00
|
|
|
#include "ui_diveplanner.h"
|
|
|
|
|
2013-08-26 11:43:37 +00:00
|
|
|
class DivePlannerWidget : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2014-02-28 04:09:57 +00:00
|
|
|
explicit DivePlannerWidget(QWidget *parent = 0, Qt::WindowFlags f = 0);
|
2013-08-26 16:18:21 +00:00
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
public
|
|
|
|
slots:
|
2013-12-09 06:43:00 +00:00
|
|
|
void settingsChanged();
|
2014-02-28 04:09:57 +00:00
|
|
|
void atmPressureChanged(const QString &pressure);
|
|
|
|
void bottomSacChanged(const QString &bottomSac);
|
|
|
|
void decoSacChanged(const QString &decosac);
|
|
|
|
|
2013-08-26 11:43:37 +00:00
|
|
|
private:
|
2013-10-03 18:54:25 +00:00
|
|
|
Ui::DivePlanner ui;
|
2013-08-26 11:43:37 +00:00
|
|
|
};
|
|
|
|
|
2014-05-22 02:31:26 +00:00
|
|
|
QString gasToStr(const int o2Permille, const int hePermille);
|
|
|
|
QString dpGasToStr(const divedatapoint &p);
|
|
|
|
|
2014-02-11 18:14:46 +00:00
|
|
|
#endif // DIVEPLANNER_H
|