From 64864fea9c5248b61d7f6f01e3d4dab3e100945a Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Mon, 9 Sep 2013 06:48:03 -0300 Subject: Enable the CC SetPoint on the planner, also input bug fix. Enabled the CC SetPoint settings on the table, changing it will automatically reflect the canvas. Also fixed a bug that prevented the 'Air' handling on the diveplanner table to show the list of options using arrow up and down. Signed-off-by: Tomaz Canabrava --- qt-ui/diveplanner.cpp | 9 +++++++-- qt-ui/modeldelegates.cpp | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index d64485b6c..ed3091ec1 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -888,7 +888,7 @@ QVariant DivePlannerPointsModel::data(const QModelIndex& index, int role) const if(role == Qt::DisplayRole){ divedatapoint p = divepoints.at(index.row()); switch(index.column()){ - case CCSETPOINT: return 0; + case CCSETPOINT: return p.po2; case DEPTH: return p.depth / 1000; case DURATION: return p.time / 60; case GAS: return strForAir(p); @@ -912,7 +912,12 @@ bool DivePlannerPointsModel::setData(const QModelIndex& index, const QVariant& v switch(index.column()){ case DEPTH: p.depth = value.toInt() * 1000; break; case DURATION: p.time = value.toInt() * 60; break; - case CCSETPOINT: /* what do I do here? */ + case CCSETPOINT:{ + int po2 = 0; + QByteArray gasv = value.toByteArray(); + if (validate_po2(gasv.data(), &po2)) + p.po2 = po2; + } break; case GAS: { int o2 = 0; int he = 0; diff --git a/qt-ui/modeldelegates.cpp b/qt-ui/modeldelegates.cpp index b183e170b..3549625f3 100644 --- a/qt-ui/modeldelegates.cpp +++ b/qt-ui/modeldelegates.cpp @@ -108,7 +108,7 @@ void ComboBoxDelegate::testActivation(const QString& s) bool ComboBoxDelegate::eventFilter(QObject* object, QEvent* event) { // Reacts on Key_UP and Key_DOWN to show the QComboBox - list of choices. - if (event->type() == QEvent::KeyPress){ + if (event->type() == QEvent::KeyPress || event->type() == QEvent::ShortcutOverride){ if (object == currCombo.comboEditor){ // the 'LineEdit' part QKeyEvent *ev = static_cast(event); if(ev->key() == Qt::Key_Up || ev->key() == Qt::Key_Down){ -- cgit v1.2.3-70-g09d2 From 545c76992a6a9fb3de59c26e782b95d30d5cd513 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Mon, 9 Sep 2013 07:18:22 -0300 Subject: Plug most of the dive planner - non - model stuff. Plug most of the dive planner controls that weren't plugged yet - StartTime, ATMPressure, BottomSAC, DecoStopSAC, LowGF and highGF are being used by the calculations now. Signed-off-by: Tomaz Canabrava --- qt-ui/diveplanner.cpp | 19 +++++++++++++++---- qt-ui/diveplanner.h | 1 + 2 files changed, 16 insertions(+), 4 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index ed3091ec1..10ee31e5d 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -426,13 +426,10 @@ void DivePlannerGraphics::createDecoStops() // Get the user-input and calculate the dive info // Not sure if this is the place to create the diveplan... // We just start with a surface node at time = 0 - struct diveplan diveplan; + struct diveplan diveplan = plannerModel->getDiveplan(); struct divedatapoint *dp = create_dp(0, 0, 209, 0, 0); dp->entered = TRUE; diveplan.dp = dp; - diveplan.gflow = 30; - diveplan.gfhigh = 70; - diveplan.surface_pressure = 1013; int rowCount = plannerModel->rowCount(); int lastIndex = -1; @@ -841,6 +838,15 @@ DivePlannerWidget::DivePlannerWidget(QWidget* parent, Qt::WindowFlags f): QWidge 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))); + + /* set defaults. */ + ui->startTime->setTime( QTime(1, 0) ); + ui->ATMPressure->setText( "1013" ); + ui->bottomSAC->setText("20"); + ui->decoStopSAC->setText("17"); + ui->lowGF->setText("30"); + ui->highGF->setText("75"); + } void DivePlannerWidget::startTimeChanged(const QTime& time) @@ -1058,3 +1064,8 @@ void DivePlannerPointsModel::remove(const QModelIndex& index) divepoints.remove(index.row()); endRemoveRows(); } + +struct diveplan DivePlannerPointsModel::getDiveplan() +{ + return diveplan; +} diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h index ccce6b16f..417128df2 100644 --- a/qt-ui/diveplanner.h +++ b/qt-ui/diveplanner.h @@ -39,6 +39,7 @@ public: 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: void setGFHigh(short gfhigh); void setGFLow(short ghflow); -- cgit v1.2.3-70-g09d2 From b4a609f46fb2c66798d4d56f59ce44c26fc8f3f8 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Mon, 9 Sep 2013 07:27:46 -0300 Subject: Signal that the model changed when editing plan specific information. Signal that the model changed when editing plan specific information, when you changes the ATM pressure or any other information, the graphic of the plan will be generated again to mirror your actual dive. Signed-off-by: Tomaz Canabrava --- qt-ui/diveplanner.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'qt-ui') diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 10ee31e5d..cd0eaceec 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -983,26 +983,31 @@ void DivePlannerPointsModel::createPlan() void DivePlannerPointsModel::setBottomSac(int sac) { diveplan.bottomsac = sac; + emit dataChanged(createIndex(0, 0), createIndex(rowCount()-1, COLUMNS-1)); } void DivePlannerPointsModel::setDecoSac(int sac) { diveplan.decosac = sac; + emit dataChanged(createIndex(0, 0), createIndex(rowCount()-1, COLUMNS-1)); } void DivePlannerPointsModel::setGFHigh(short int gfhigh) { diveplan.gfhigh = gfhigh; + emit dataChanged(createIndex(0, 0), createIndex(rowCount()-1, COLUMNS-1)); } void DivePlannerPointsModel::setGFLow(short int ghflow) { diveplan.gflow = ghflow; + emit dataChanged(createIndex(0, 0), createIndex(rowCount()-1, COLUMNS-1)); } void DivePlannerPointsModel::setSurfacePressure(int pressure) { diveplan.surface_pressure = pressure; + emit dataChanged(createIndex(0, 0), createIndex(rowCount()-1, COLUMNS-1)); } void DivePlannerPointsModel::setLastStop6m(bool value) @@ -1012,6 +1017,7 @@ void DivePlannerPointsModel::setLastStop6m(bool value) void DivePlannerPointsModel::setStartTime(const QTime& t) { diveplan.when = t.msec(); + emit dataChanged(createIndex(0, 0), createIndex(rowCount()-1, COLUMNS-1)); } bool divePointsLessThan(const divedatapoint& p1, const divedatapoint& p2){ -- cgit v1.2.3-70-g09d2