summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qt-ui/diveplanner.cpp113
-rw-r--r--qt-ui/diveplanner.h43
2 files changed, 146 insertions, 10 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 61ca64b34..6587185a7 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -351,6 +351,7 @@ void DivePlannerGraphics::mouseDoubleClickEvent(QMouseEvent* event)
}
}
+ DivePlannerPointsModel::instance()->addStop(meters, minutes, tr("Air"), 0);
DiveHandler *item = new DiveHandler ();
item->sec = minutes * 60;
item->mm = meters * 1000;
@@ -383,7 +384,6 @@ void DivePlannerGraphics::selectGas(const QModelIndex& index)
gasListView->hide();
}
-
void DivePlannerGraphics::createDecoStops()
{
qDeleteAll(lines);
@@ -793,6 +793,49 @@ DivePlannerWidget::DivePlannerWidget(QWidget* parent, Qt::WindowFlags f): QWidge
{
ui->setupUi(this);
ui->tablePoints->setModel(DivePlannerPointsModel::instance());
+ connect(ui->startTime, SIGNAL(timeChanged(QTime)), this, SLOT(startTimeChanged(QTime)));
+ connect(ui->ATMPressure, SIGNAL(textChanged(QString)), this, SLOT(atmPressureChanged(QString)));
+ connect(ui->bottomSAC, SIGNAL(textChanged(QString)), this, SLOT(bottomSacChanged(QString)));
+ connect(ui->decoStopSAC, SIGNAL(textChanged(QString)), this, SLOT(decoSacChanged(QString)));
+ connect(ui->highGF, SIGNAL(textChanged(QString)), this, SLOT(gfhighChanged(QString)));
+ connect(ui->lowGF, SIGNAL(textChanged(QString)), this, SLOT(gflowChanged(QString)));
+ connect(ui->highGF, SIGNAL(textChanged(QString)), this, SLOT(gfhighChanged(QString)));
+ connect(ui->lastStop, SIGNAL(toggled(bool)), this, SLOT(lastStopChanged(bool)));
+}
+
+void DivePlannerWidget::startTimeChanged(const QTime& time)
+{
+ DivePlannerPointsModel::instance()->setStartTime(time);
+}
+
+void DivePlannerWidget::atmPressureChanged(const QString& pressure)
+{
+ DivePlannerPointsModel::instance()->setSurfacePressure(pressure.toInt());
+}
+
+void DivePlannerWidget::bottomSacChanged(const QString& bottomSac)
+{
+ DivePlannerPointsModel::instance()->setBottomSac(bottomSac.toInt());
+}
+
+void DivePlannerWidget::decoSacChanged(const QString& decosac)
+{
+ DivePlannerPointsModel::instance()->setDecoSac(decosac.toInt());
+}
+
+void DivePlannerWidget::gfhighChanged(const QString& gfhigh)
+{
+ DivePlannerPointsModel::instance()->setGFHigh(gfhigh.toShort());
+}
+
+void DivePlannerWidget::gflowChanged(const QString& gflow)
+{
+ DivePlannerPointsModel::instance()->setGFLow(gflow.toShort());
+}
+
+void DivePlannerWidget::lastStopChanged(bool checked)
+{
+ DivePlannerPointsModel::instance()->setLastStop6m(checked);
}
int DivePlannerPointsModel::columnCount(const QModelIndex& parent) const
@@ -802,12 +845,21 @@ int DivePlannerPointsModel::columnCount(const QModelIndex& parent) const
QVariant DivePlannerPointsModel::data(const QModelIndex& index, int role) const
{
+ if(role == Qt::DisplayRole){
+ divedatapoint p = divepoints.at(index.row());
+ switch(index.column()){
+ case GAS: return tr("Air");
+ case CCSETPOINT: return 0;
+ case DEPTH: return p.depth;
+ case DURATION: return p.time;
+ }
+ }
return QVariant();
}
QVariant DivePlannerPointsModel::headerData(int section, Qt::Orientation orientation, int role) const
{
- if (role == Qt::DisplayRole){
+ if (role == Qt::DisplayRole && orientation == Qt::Horizontal){
switch(section){
case DEPTH: return tr("Final Depth");
case DURATION: return tr("Duration");
@@ -820,12 +872,11 @@ QVariant DivePlannerPointsModel::headerData(int section, Qt::Orientation orienta
int DivePlannerPointsModel::rowCount(const QModelIndex& parent) const
{
- return 0;
+ return divepoints.count();
}
DivePlannerPointsModel::DivePlannerPointsModel(QObject* parent): QAbstractTableModel(parent)
{
-
}
DivePlannerPointsModel* DivePlannerPointsModel::instance()
@@ -834,3 +885,57 @@ DivePlannerPointsModel* DivePlannerPointsModel::instance()
return self;
}
+void DivePlannerPointsModel::createPlan()
+{
+
+}
+
+void DivePlannerPointsModel::setBottomSac(int sac)
+{
+ diveplan.bottomsac = sac;
+}
+
+void DivePlannerPointsModel::setDecoSac(int sac)
+{
+ diveplan.decosac = sac;
+}
+
+void DivePlannerPointsModel::setGFHigh(short int gfhigh)
+{
+ diveplan.gfhigh = gfhigh;
+}
+
+void DivePlannerPointsModel::setGFLow(short int ghflow)
+{
+ diveplan.gflow = ghflow;
+}
+
+void DivePlannerPointsModel::setSurfacePressure(int pressure)
+{
+ diveplan.surface_pressure = pressure;
+}
+
+void DivePlannerPointsModel::setLastStop6m(bool value)
+{
+}
+
+void DivePlannerPointsModel::setStartTime(const QTime& t)
+{
+ diveplan.when = t.msec();
+}
+
+int DivePlannerPointsModel::addStop(int meters, int minutes, const QString& gas, int ccpoint)
+{
+ int row = divepoints.count();
+ beginInsertRows(QModelIndex(), row, row);
+ divedatapoint point;
+ point.depth = meters;
+ point.time = minutes;
+ point.o2 = 209;
+ point.he = 0;
+ point.po2 = 0;
+ divepoints.append( point );
+ endInsertRows();
+ return row;
+}
+
diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h
index dad13cd05..ab466da8e 100644
--- a/qt-ui/diveplanner.h
+++ b/qt-ui/diveplanner.h
@@ -5,6 +5,9 @@
#include <QGraphicsPathItem>
#include <QDialog>
#include <QAbstractTableModel>
+#include <QDateTime>
+
+#include "dive.h"
namespace Ui{
class DivePlanner;
@@ -19,12 +22,30 @@ class DivePlannerPointsModel : public QAbstractTableModel{
public:
static DivePlannerPointsModel* instance();
enum Sections{DEPTH, DURATION, GAS, CCSETPOINT, COLUMNS};
- 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;
- virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
+ 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;
+ virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
+
+ /**
+ * @return the row number.
+ */
+ int addStop(int meters, int minutes,const QString& gas, int ccpoint );
+
+public slots:
+ void setGFHigh(short gfhigh);
+ void setGFLow(short ghflow);
+ void setSurfacePressure(int pressure);
+ void setBottomSac(int sac);
+ void setDecoSac(int sac);
+ void setStartTime(const QTime& t);
+ void setLastStop6m(bool value);
+ void createPlan();
+
private:
- explicit DivePlannerPointsModel(QObject* parent = 0);
+ explicit DivePlannerPointsModel(QObject* parent = 0);
+ struct diveplan diveplan;
+ QVector<divedatapoint> divepoints;
};
class Button : public QObject, public QGraphicsRectItem {
@@ -49,7 +70,7 @@ public:
int sec;
int mm;
protected:
- void mousePressEvent(QGraphicsSceneMouseEvent* event);
+ void mousePressEvent(QGraphicsSceneMouseEvent* event);
};
class Ruler : public QGraphicsLineItem{
@@ -165,6 +186,16 @@ class DivePlannerWidget : public QWidget {
Q_OBJECT
public:
explicit DivePlannerWidget(QWidget* parent = 0, Qt::WindowFlags f = 0);
+
+public slots:
+ void startTimeChanged(const QTime& time);
+ void atmPressureChanged(const QString& pressure);
+ void bottomSacChanged(const QString& bottomSac);
+ void decoSacChanged(const QString& decosac);
+ void gflowChanged(const QString& gflow);
+ void gfhighChanged(const QString& gfhigh);
+ void lastStopChanged(bool checked);
+
private:
Ui::DivePlanner *ui;
};