summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-01-11 21:57:06 +0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-01-11 22:02:35 +0700
commit23973e8abdfb1354de9920cc1c5896a4fc84d25b (patch)
tree35a075ce121e5849c37f179157e98a21a5cf3951 /qt-ui
parentf43a3052cb3eb0bb87ea81f15e4a02487a5ed8ec (diff)
downloadsubsurface-23973e8abdfb1354de9920cc1c5896a4fc84d25b.tar.gz
Don't show tanks that aren't used during a dive
Some dive computers will always download all tanks that they store, not just the ones used in a dive. Most people only want to see the tanks that they actually used during the dive (and for the others there's an option to go back to the old behavior, just in case). All this is only in memory / during runtime. If the dive computer provided the extra data we will not throw it away. Fixes #373 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/mainwindow.cpp2
-rw-r--r--qt-ui/models.cpp3
-rw-r--r--qt-ui/models.h1
-rw-r--r--qt-ui/preferences.cpp2
-rw-r--r--qt-ui/preferences.ui11
5 files changed, 18 insertions, 1 deletions
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index c24e2733e..acbd13046 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -57,6 +57,7 @@ MainWindow::MainWindow() : helpView(0)
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.InfoWidget, SLOT(updateDiveInfo()));
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.divePlanner, SLOT(settingsChanged()));
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.divePlannerWidget, SLOT(settingsChanged()));
+ connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), TankInfoModel::instance(), SLOT(update()));
ui.mainErrorMessage->hide();
initialUiSetup();
@@ -647,6 +648,7 @@ void MainWindow::readSettings()
GET_BOOL("gf_low_at_maxdepth", gf_low_at_maxdepth);
set_gf(prefs.gflow, prefs.gfhigh, prefs.gf_low_at_maxdepth);
GET_BOOL("show_sac", show_sac);
+ GET_BOOL("display_unused_tanks", display_unused_tanks);
s.endGroup();
s.beginGroup("GeneralSettings");
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp
index 4debafd9a..1e22f7da0 100644
--- a/qt-ui/models.cpp
+++ b/qt-ui/models.cpp
@@ -301,7 +301,8 @@ void CylindersModel::setDive(dive* d)
return;
rows = 0;
for(int i = 0; i < MAX_CYLINDERS; i++) {
- if (!cylinder_none(&d->cylinder[i])) {
+ if (!cylinder_none(&d->cylinder[i]) &&
+ (prefs.display_unused_tanks || d->cylinder[i].used)) {
rows = i+1;
}
}
diff --git a/qt-ui/models.h b/qt-ui/models.h
index 06dc66aa1..16818e407 100644
--- a/qt-ui/models.h
+++ b/qt-ui/models.h
@@ -47,6 +47,7 @@ public:
/*reimp*/ bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
const QString& biggerString() const;
void clear();
+public slots:
void update();
private:
int rows;
diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp
index 382880a1f..67e2dfe8d 100644
--- a/qt-ui/preferences.cpp
+++ b/qt-ui/preferences.cpp
@@ -103,6 +103,7 @@ void PreferencesDialog::setUiFromPrefs()
ui.default_cylinder->setCurrentIndex(i);
}
ui.displayinvalid->setChecked(prefs.display_invalid_dives);
+ ui.display_unused_tanks->setChecked(prefs.display_unused_tanks);
ui.show_sac->setChecked(prefs.show_sac);
ui.vertical_speed_minutes->setChecked(prefs.units.vertical_speed_time == units::MINUTES);
ui.vertical_speed_seconds->setChecked(prefs.units.vertical_speed_time == units::SECONDS);
@@ -162,6 +163,7 @@ void PreferencesDialog::syncSettings()
s.setValue("gfhigh", ui.gfhigh->value());
SB("gf_low_at_maxdepth", ui.gf_low_at_maxdepth);
SB("show_sac", ui.show_sac);
+ SB("display_unused_tanks", ui.display_unused_tanks);
s.endGroup();
// Units
diff --git a/qt-ui/preferences.ui b/qt-ui/preferences.ui
index 283fbbb39..fb5a16abb 100644
--- a/qt-ui/preferences.ui
+++ b/qt-ui/preferences.ui
@@ -772,6 +772,17 @@
</item>
</layout>
</item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_11c">
+ <item>
+ <widget class="QCheckBox" name="display_unused_tanks">
+ <property name="text">
+ <string>unused tanks</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
</layout>
</widget>
</item>