diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2013-09-09 22:57:22 +0000 |
---|---|---|
committer | Tomaz Canabrava <tcanabrava@kde.org> | 2013-09-09 22:57:22 +0000 |
commit | 923b4cd9b1932c13ef52567ea095740887345b38 (patch) | |
tree | 766106f3fd063af1a9d20af23af386e34b160ecf /qt-ui | |
parent | 813722633df15f6d5615938ae7200b14f725069a (diff) | |
download | subsurface-923b4cd9b1932c13ef52567ea095740887345b38.tar.gz |
Make the Plus Button on the planner work.
Clicking on the plus button now adds a new stop on the planner.
The depth is always 10m and the time is 10 minutes after the
last stop. can be changed by double clicking or dragging the
balls around the canvas.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/diveplanner.cpp | 15 | ||||
-rw-r--r-- | qt-ui/diveplanner.h | 2 |
2 files changed, 15 insertions, 2 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index e2374e1f1..ab7bda17d 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -830,6 +830,7 @@ DivePlannerWidget::DivePlannerWidget(QWidget* parent, Qt::WindowFlags f): QWidge ui->tableWidget->setModel(DivePlannerPointsModel::instance()); ui->tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::GAS, new AirTypesDelegate(this)); + connect(ui->tableWidget, SIGNAL(addButtonClicked()), DivePlannerPointsModel::instance(), SLOT(addStop())); 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))); @@ -846,7 +847,6 @@ DivePlannerWidget::DivePlannerWidget(QWidget* parent, Qt::WindowFlags f): QWidge ui->decoStopSAC->setText("17"); ui->lowGF->setText("30"); ui->highGF->setText("75"); - } void DivePlannerWidget::startTimeChanged(const QTime& time) @@ -1026,6 +1026,18 @@ bool divePointsLessThan(const divedatapoint& p1, const divedatapoint& p2){ int DivePlannerPointsModel::addStop(int meters, int minutes, const QString& gas, int ccpoint) { int row = divepoints.count(); + if(meters == 0 && minutes == 0){ + if(row == 0){ + meters = 10000; + minutes = 600; + } + else{ + divedatapoint p = at(row-1); + meters = p.depth; + minutes = p.time + 600; + } + } + // check if there's already a new stop before this one: for(int i = 0; i < divepoints.count(); i++){ const divedatapoint& dp = divepoints.at(i); @@ -1048,6 +1060,7 @@ int DivePlannerPointsModel::addStop(int meters, int minutes, const QString& gas, divedatapoint before = at(row-1); point.o2 = before.o2; point.he = before.he; + point.po2 = 0; } divepoints.append( point ); std::sort(divepoints.begin(), divepoints.end(), divePointsLessThan); diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h index 417128df2..091b9f80c 100644 --- a/qt-ui/diveplanner.h +++ b/qt-ui/diveplanner.h @@ -36,11 +36,11 @@ public: /** * @return the row number. */ - int addStop(int meters, int minutes,const QString& gas, int ccpoint ); void editStop(int row, divedatapoint newData ); divedatapoint at(int row); struct diveplan getDiveplan(); public slots: + int addStop(int meters = 0, int minutes = 0,const QString& gas = QString(), int ccpoint = 0 ); void setGFHigh(short gfhigh); void setGFLow(short ghflow); void setSurfacePressure(int pressure); |