summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-12-20 09:20:18 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-12-20 09:53:06 -0800
commit4ab58d6b47e8786d0a10c1308ee487e10af7fa83 (patch)
treecdfc5b1c428c09e48973ac651d206325675a55e5
parentf0da41c937b9381e67a57b8103bbf2d4aca7bb39 (diff)
downloadsubsurface-4ab58d6b47e8786d0a10c1308ee487e10af7fa83.tar.gz
Use M_OR_FT macro instead of switch statement
This is easier to read and also avoids an incorrect gcc warning. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--helpers.h2
-rw-r--r--qt-ui/diveplanner.cpp2
-rw-r--r--qt-ui/profilegraphics.cpp15
3 files changed, 4 insertions, 15 deletions
diff --git a/helpers.h b/helpers.h
index 067ec386a..bfd47f0fe 100644
--- a/helpers.h
+++ b/helpers.h
@@ -35,6 +35,8 @@ QString get_trip_date_string(timestamp_t when, int nr);
extern DiveComputerList dcList;
+#define M_OR_FT(_m,_f) ((prefs.units.length == units::METERS) ? ((_m) * 1000) : (feet_to_mm(_f)))
+
#if defined __APPLE__
#define TITLE_OR_TEXT(_t,_m) "", _t + "\n" + _m
#else
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 223d9d657..303327d42 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -30,8 +30,6 @@
#define MAX_DEPTH M_OR_FT(150, 450)
#define MIN_DEPTH M_OR_FT(20, 60)
-#define M_OR_FT(_m,_f) ((prefs.units.length == units::METERS) ? ((_m) * 1000) : (feet_to_mm(_f)))
-
QString gasToStr(const int o2Permille, const int hePermille) {
uint o2 = (o2Permille + 5) / 10, he = (hePermille + 5) / 10;
QString result = is_air(o2Permille, hePermille) ? QObject::tr("AIR")
diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp
index a1150052f..f826e02de 100644
--- a/qt-ui/profilegraphics.cpp
+++ b/qt-ui/profilegraphics.cpp
@@ -505,11 +505,7 @@ void ProfileGraphicsView::plot_depth_scale()
/* Depth markers: every 30 ft or 10 m*/
maxdepth = get_maxdepth(&gc.pi);
gc.topy = 0; gc.bottomy = maxdepth;
-
- switch (prefs.units.length) {
- case units::METERS: marker = 10000; break;
- case units::FEET: marker = 9144; break; /* 30 ft */
- }
+ marker = M_OR_FT(10,30);
/* don't write depth labels all the way to the bottom as
* there may be other graphs below the depth plot (like
@@ -1155,14 +1151,7 @@ void ProfileGraphicsView::plot_depth_profile()
/* Depth markers: every 30 ft or 10 m*/
gc.leftx = 0; gc.rightx = 1.0;
gc.topy = 0; gc.bottomy = maxdepth;
- switch (prefs.units.length) {
- case units::METERS:
- marker = 10000;
- break;
- case units::FEET:
- marker = 9144;
- break; /* 30 ft */
- }
+ marker = M_OR_FT(10,30);
maxline = qMax(gc.pi.maxdepth + marker, maxdepth * 2 / 3);
c = getColor(DEPTH_GRID);