[PATCH 1/3] Planner: use a QSpinBox for GFLow/GFHigh

Anton Lundin glance at acc.umu.se
Thu Nov 14 10:55:33 UTC 2013


Switch to using a QSpinBox instead of a QLineEdit. This makes it a bit
more intuitive and now you can see how the deco plan changes based on
the GF's.

Signed-off-by: Anton Lundin <glance at acc.umu.se>
---
 qt-ui/diveplanner.cpp | 23 ++++++-----------------
 qt-ui/diveplanner.h   |  6 ++----
 qt-ui/diveplanner.ui  | 25 +++++++++++++++++++++----
 3 files changed, 29 insertions(+), 25 deletions(-)

diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 49d89da..b5d7f5d 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -929,9 +929,8 @@ DivePlannerWidget::DivePlannerWidget(QWidget* parent, Qt::WindowFlags f): QWidge
 	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.gfhigh, SIGNAL(valueChanged(int)), plannerModel, SLOT(setGFHigh(int)));
+	connect(ui.gflow, SIGNAL(valueChanged(int)), plannerModel, SLOT(setGFLow(int)));
 	connect(ui.lastStop, SIGNAL(toggled(bool)), this, SLOT(lastStopChanged(bool)));
 
 	// Creating the plan
@@ -946,8 +945,8 @@ DivePlannerWidget::DivePlannerWidget(QWidget* parent, Qt::WindowFlags f): QWidge
 	ui.ATMPressure->setText( "1013" );
 	ui.bottomSAC->setText("20");
 	ui.decoStopSAC->setText("17");
-	ui.lowGF->setText("30");
-	ui.highGF->setText("75");
+	ui.gflow->setValue(30);
+	ui.gfhigh->setValue(75);
 
 	setMinimumWidth(0);
 	setMinimumHeight(0);
@@ -978,16 +977,6 @@ void DivePlannerWidget::decoSacChanged(const QString& decosac)
 	plannerModel->setDecoSac(decosac.toInt());
 }
 
-void DivePlannerWidget::gfhighChanged(const QString& gfhigh)
-{
-	plannerModel->setGFHigh(gfhigh.toShort());
-}
-
-void DivePlannerWidget::gflowChanged(const QString& gflow)
-{
-	plannerModel->setGFLow(gflow.toShort());
-}
-
 void DivePlannerWidget::lastStopChanged(bool checked)
 {
 	plannerModel->setLastStop6m(checked);
@@ -1104,13 +1093,13 @@ void DivePlannerPointsModel::setDecoSac(int sac)
 	emit dataChanged(createIndex(0, 0), createIndex(rowCount()-1, COLUMNS-1));
 }
 
-void DivePlannerPointsModel::setGFHigh(short int gfhigh)
+void DivePlannerPointsModel::setGFHigh(const int gfhigh)
 {
 	diveplan.gfhigh = gfhigh;
 	emit dataChanged(createIndex(0, 0), createIndex(rowCount()-1, COLUMNS-1));
 }
 
-void DivePlannerPointsModel::setGFLow(short int ghflow)
+void DivePlannerPointsModel::setGFLow(const int ghflow)
 {
 	diveplan.gflow = ghflow;
 	emit dataChanged(createIndex(0, 0), createIndex(rowCount()-1, COLUMNS-1));
diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h
index 8f51c93..e59fd55 100644
--- a/qt-ui/diveplanner.h
+++ b/qt-ui/diveplanner.h
@@ -51,8 +51,8 @@ public:
 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 setGFHigh(const int gfhigh);
+	void setGFLow(const int ghflow);
 	void setSurfacePressure(int pressure);
 	void setBottomSac(int sac);
 	void setDecoSac(int sac);
@@ -227,8 +227,6 @@ public slots:
 	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;
diff --git a/qt-ui/diveplanner.ui b/qt-ui/diveplanner.ui
index 9a3f7cf..d545bbb 100644
--- a/qt-ui/diveplanner.ui
+++ b/qt-ui/diveplanner.ui
@@ -78,7 +78,7 @@
        <item row="4" column="1">
         <widget class="QLabel" name="label_6">
          <property name="text">
-          <string>High GF</string>
+          <string>GFHigh</string>
          </property>
         </widget>
        </item>
@@ -98,15 +98,32 @@
        <item row="4" column="0">
         <widget class="QLabel" name="label_5">
          <property name="text">
-          <string>Low GF</string>
+          <string>GFLow</string>
          </property>
         </widget>
        </item>
        <item row="5" column="0">
-        <widget class="QLineEdit" name="lowGF"/>
+        <widget class="QSpinBox" name="gflow">
+         <property name="suffix">
+          <string>%</string>
+         </property>
+         <property name="minimum">
+          <number>1</number>
+         </property>
+         <property name="maximum">
+          <number>100</number>
+         </property>
+        </widget>
        </item>
        <item row="5" column="1">
-        <widget class="QLineEdit" name="highGF"/>
+        <widget class="QSpinBox" name="gfhigh">
+         <property name="suffix">
+          <string>%</string>
+         </property>
+         <property name="minimum">
+          <number>1</number>
+         </property>
+        </widget>
        </item>
        <item row="6" column="0">
         <widget class="QCheckBox" name="lastStop">
-- 
1.8.3.2



More information about the subsurface mailing list