summaryrefslogtreecommitdiffstats
path: root/qt-ui/diveplanner.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2014-07-11 17:42:43 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-11 16:58:42 -0700
commitaf9d62bac3add0de07744f3d8a42e3a058e32a41 (patch)
treea9d510538dab29065b1800b396331abbc5fe11ff /qt-ui/diveplanner.cpp
parent3dbc5bfeaa554f519da0bed0abddddb17da26f20 (diff)
downloadsubsurface-af9d62bac3add0de07744f3d8a42e3a058e32a41.tar.gz
Fixed input in the DivePlanner table
Based on Glance's idea on rewritting the Delegates, but we don't need to redo the wheel as Qt already gives us the correct Delegate, we just need to set some boundaries on it before returning. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/diveplanner.cpp')
-rw-r--r--qt-ui/diveplanner.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 5e07dcb39..a24f1487e 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -289,6 +289,12 @@ DivePlannerWidget::DivePlannerWidget(QWidget *parent, Qt::WindowFlags f) : QWidg
QShortcut *closeKey = new QShortcut(QKeySequence(Qt::Key_Escape), this);
connect(closeKey, SIGNAL(activated()), plannerModel, SLOT(cancelPlan()));
+ // This makes shure the spinbox gets a setMinimum(0) on it so we can't have negative time or depth.
+ ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::DEPTH, new SpinBoxDelegate(0, INT_MAX, this));
+ ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::RUNTIME, new SpinBoxDelegate(0, INT_MAX, this));
+ ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::DURATION, new SpinBoxDelegate(0, INT_MAX, this));
+ ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::CCSETPOINT, new DoubleSpinBoxDelegate(0.2, 2, this));
+
/* set defaults. */
ui.ATMPressure->setValue(1013);
ui.atmHeight->setValue(0);
@@ -510,7 +516,7 @@ QVariant DivePlannerPointsModel::data(const QModelIndex &index, int role) const
case CCSETPOINT:
return (double)p.po2 / 1000;
case DEPTH:
- return rint(get_depth_units(p.depth, NULL, NULL));
+ return (int) rint(get_depth_units(p.depth, NULL, NULL));
case RUNTIME:
return p.time / 60;
case DURATION: