2013-06-20 12:33:26 -03:00
|
|
|
#ifndef DIVEPLANNER_H
|
|
|
|
#define DIVEPLANNER_H
|
|
|
|
|
|
|
|
#include <QGraphicsView>
|
|
|
|
#include <QGraphicsPathItem>
|
2013-06-20 18:40:59 -03:00
|
|
|
#include <QDialog>
|
2013-08-26 09:14:19 -03:00
|
|
|
#include <QAbstractTableModel>
|
2013-08-26 13:18:21 -03:00
|
|
|
#include <QDateTime>
|
|
|
|
|
|
|
|
#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();
|
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);
|
2013-11-14 18:36:21 +09:00
|
|
|
void copyCylinders(struct dive *d);
|
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-03-12 16:49:42 +01:00
|
|
|
int addStop(int millimeters = 0, int seconds = 0, int o2 = 0, int he = 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);
|
|
|
|
void setBottomSac(int sac);
|
|
|
|
void setDecoSac(int sac);
|
2014-02-27 20:09:57 -08:00
|
|
|
void setStartTime(const QTime &t);
|
2013-08-26 13:18:21 -03:00
|
|
|
void setLastStop6m(bool value);
|
|
|
|
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);
|
2013-11-18 11:55:56 -08:00
|
|
|
void restoreBackupDive();
|
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-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);
|
2013-11-12 11:19:04 +09:00
|
|
|
bool addGas(int o2, int he);
|
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
|
|
|
struct dive *tempDive;
|
2013-11-18 11:55:56 -08:00
|
|
|
struct dive backupDive;
|
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-11-10 21:02:53 +09:00
|
|
|
struct dive *stagingDive;
|
2013-12-24 10:18:56 -02:00
|
|
|
QVector<QPair<int, int> > oldGases;
|
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-05-23 19:50:09 -03:00
|
|
|
signals:
|
|
|
|
void moved();
|
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);
|
2013-08-26 13:18:21 -03:00
|
|
|
|
2014-02-27 20:09:57 -08:00
|
|
|
public
|
|
|
|
slots:
|
2013-12-09 07:43:00 +01:00
|
|
|
void settingsChanged();
|
2014-02-27 20:09:57 -08:00
|
|
|
void atmPressureChanged(const QString &pressure);
|
|
|
|
void bottomSacChanged(const QString &bottomSac);
|
|
|
|
void decoSacChanged(const QString &decosac);
|
|
|
|
|
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-01 15:25:19 -07:00
|
|
|
QString gasToStr(gasmix gas);
|
2014-05-21 23:31:26 -03:00
|
|
|
QString dpGasToStr(const divedatapoint &p);
|
|
|
|
|
2014-02-11 19:14:46 +01:00
|
|
|
#endif // DIVEPLANNER_H
|