diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-11-10 21:02:53 +0900 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-11-10 21:02:53 +0900 |
commit | 55c127f7c36ba9d46af7a4e68101c3687edc7cbc (patch) | |
tree | d92d8dd43263893708ceeacbcb6e8478c3875108 /qt-ui | |
parent | aa4931e8c613f742cb05da77dfdad73c6f3008c9 (diff) | |
download | subsurface-55c127f7c36ba9d46af7a4e68101c3687edc7cbc.tar.gz |
Enable adding cylinders in the dive planner
This is in preparation of using those to define the gases available for
planning.
Right now this doesn't seem to work quite right - I don't get the
auto-completions for the cylinders that I was hoping for...
This commit also corrects the tooltip for addint dive data points.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/diveplanner.cpp | 21 | ||||
-rw-r--r-- | qt-ui/diveplanner.h | 2 |
2 files changed, 20 insertions, 3 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index ba0bc80d7..9865c347a 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -439,8 +439,6 @@ void DivePlannerPointsModel::loadFromDive(dive* d) for(int i = 0; i < d->dc.samples-1; i++){ backupSamples.push_back( d->dc.sample[i]); } - save_dive(stdout, current_dive); - save_dive(stdout, backupDive); Q_FOREACH(const sample &s, backupSamples){ int o2 = 0, he = 0; get_gas_from_events(&backupDive->dc, s.time.seconds, &o2, &he); @@ -880,8 +878,9 @@ DivePlannerWidget::DivePlannerWidget(QWidget* parent, Qt::WindowFlags f): QWidge ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::GAS, new AirTypesDelegate(this)); ui.cylinderTableWidget->setTitle(tr("Available Gases")); ui.cylinderTableWidget->setModel(CylindersModel::instance()); -// connect(ui.cylinderTableWidget, SIGNAL(addButtonClicked()), CylindersModel::instance(), SLOT(add())); + connect(ui.cylinderTableWidget, SIGNAL(addButtonClicked()), DivePlannerPointsModel::instance(), SLOT(addCylinder_clicked())); connect(ui.tableWidget, SIGNAL(addButtonClicked()), DivePlannerPointsModel::instance(), SLOT(addStop())); + ui.tableWidget->setBtnToolTip(tr("add dive data point")); 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))); @@ -910,6 +909,15 @@ DivePlannerWidget::DivePlannerWidget(QWidget* parent, Qt::WindowFlags f): QWidge setMinimumHeight(0); } +void DivePlannerPointsModel::addCylinder_clicked() +{ + qDebug() << "add Cylinder clicked"; + if (!stagingDive) + stagingDive = alloc_dive(); + CylindersModel::instance()->setDive(stagingDive); + CylindersModel::instance()->add(); +} + void DivePlannerWidget::startTimeChanged(const QTime& time) { plannerModel->setStartTime(time); @@ -1192,6 +1200,9 @@ void DivePlannerPointsModel::cancelPlan() clear(); emit planCanceled(); setPlanMode(NOTHING); + free(stagingDive); + stagingDive = NULL; + CylindersModel::instance()->setDive(current_dive); CylindersModel::instance()->update(); } @@ -1205,6 +1216,7 @@ void DivePlannerPointsModel::clear() beginRemoveRows(QModelIndex(), 0, rowCount()-1); divepoints.clear(); endRemoveRows(); + CylindersModel::instance()->clear(); } @@ -1286,5 +1298,8 @@ void DivePlannerPointsModel::createPlan() clear(); planCreated(); setPlanMode(NOTHING); + free(stagingDive); + stagingDive = NULL; + CylindersModel::instance()->setDive(current_dive); CylindersModel::instance()->update(); } diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h index 9fc9cc641..ce89d1df1 100644 --- a/qt-ui/diveplanner.h +++ b/qt-ui/diveplanner.h @@ -43,6 +43,7 @@ public: struct diveplan getDiveplan(); public slots: int addStop(int meters = 0, int minutes = 0, int o2 = 0, int he = 0, int ccpoint = 0 ); + void addCylinder_clicked(); void setGFHigh(short gfhigh); void setGFLow(short ghflow); void setSurfacePressure(int pressure); @@ -69,6 +70,7 @@ private: struct dive *tempDive; void deleteTemporaryPlan(struct divedatapoint *dp); QVector<sample> backupSamples; // For editing added dives. + struct dive *stagingDive; }; class Button : public QObject, public QGraphicsRectItem { |