summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-10-07 11:48:14 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-10-07 11:48:14 -0700
commit90b0f75d4095a23ef3a0f43cc319784d4fc6acc3 (patch)
treec7209b8d1651ae8877f5bb0fd25da0e7ae5d1ff0 /qt-ui
parentd9f24b282a1f1ed2455c20de62cf1dd9fa6ae48b (diff)
downloadsubsurface-90b0f75d4095a23ef3a0f43cc319784d4fc6acc3.tar.gz
Remove info.c/info.h
The one remaining helper function in there was moved to maintab.cpp (which was the one remaining user). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/maintab.cpp40
-rw-r--r--qt-ui/maintab.h3
2 files changed, 29 insertions, 14 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index a8d478164..5dcd09062 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -8,7 +8,6 @@
#include "mainwindow.h"
#include "../helpers.h"
#include "../statistics.h"
-#include "../info.h"
#include "divelistview.h"
#include "modeldelegates.h"
#include "globe.h"
@@ -265,9 +264,7 @@ void MainTab::updateDiveInfo(int dive)
UPDATE_TEMP(d, airtemp);
UPDATE_TEMP(d, watertemp);
if (d) {
- char buffer[256];
- print_gps_coordinates(buffer, sizeof buffer, d->latitude.udeg, d->longitude.udeg);
- ui.coordinates->setText(buffer);
+ ui.coordinates->setText(printGPSCoords(d->latitude.udeg, d->longitude.udeg));
ui.dateTimeEdit->setDateTime(QDateTime::fromTime_t(d->when - gettimezoneoffset()));
if (mainWindow() && mainWindow()->dive_list()->selectedTrips.count() == 1) {
// only use trip relevant fields
@@ -328,7 +325,7 @@ void MainTab::updateDiveInfo(int dive)
ui.airPressureText->setText(QString("%1mbar").arg(d->surface_pressure.mbar));
else
ui.airPressureText->clear();
- ui.depthLimits->setMaximum(get_depth_string(stats_selection.max_depth, TRUE));
+ ui.depthLimits->setMaximum(get_depth_string(stats_selection.max_depth, TRUE));
ui.depthLimits->setMinimum(get_depth_string(stats_selection.min_depth, TRUE));
ui.depthLimits->setAverage(get_depth_string(stats_selection.avg_depth, TRUE));
ui.sacLimits->setMaximum(get_volume_string(stats_selection.max_sac, TRUE).append(tr("/min")));
@@ -425,10 +422,7 @@ void MainTab::acceptChanges()
} else {
struct dive *curr = current_dive;
//Reset coordinates field, in case it contains garbage.
- char buffer[256];
- print_gps_coordinates(buffer, sizeof buffer
- , current_dive->latitude.udeg, current_dive->longitude.udeg);
- ui.coordinates->setText(buffer);
+ ui.coordinates->setText(printGPSCoords(current_dive->latitude.udeg, current_dive->longitude.udeg));
if (notesBackup[curr].buddy != ui.buddy->text() ||
notesBackup[curr].suit != ui.suit->text() ||
notesBackup[curr].notes != ui.notes->toPlainText() ||
@@ -657,10 +651,7 @@ void MainTab::on_location_textChanged(const QString& text)
(dive->latitude.udeg || dive->longitude.udeg)) {
EDIT_SELECTED_DIVES( mydive->latitude = dive->latitude );
EDIT_SELECTED_DIVES( mydive->longitude = dive->longitude );
- char buffer[256];
- print_gps_coordinates(buffer, sizeof buffer
- , dive->latitude.udeg, dive->longitude.udeg);
- ui.coordinates->setText(buffer);
+ ui.coordinates->setText(printGPSCoords(dive->latitude.udeg, dive->longitude.udeg));
markChangedWidget(ui.coordinates);
break;
}
@@ -734,3 +725,26 @@ void MainTab::editWeightWidget(const QModelIndex& index)
if (index.isValid() && index.column() != WeightModel::REMOVE)
ui.weights->edit(index);
}
+
+QString MainTab::printGPSCoords(int lat, int lon)
+{
+ unsigned int latdeg, londeg;
+ unsigned int ilatmin, ilonmin;
+ QString lath, lonh, result;
+
+ if (!lat && !lon)
+ return QString("");
+
+ lath = lat >= 0 ? tr("N") : tr("S");
+ lonh = lon >= 0 ? tr("E") : tr("W");
+ lat = abs(lat);
+ lon = abs(lon);
+ latdeg = lat / 1000000;
+ londeg = lon / 1000000;
+ ilatmin = (lat % 1000000) * 60;
+ ilonmin = (lon % 1000000) * 60;
+ result.sprintf("%s%u%s %2d.%05d\' , %s%u%s %2d.%05d\'",
+ lath.toLocal8Bit().data(), latdeg, UTF8_DEGREE, ilatmin / 1000000, (ilatmin % 1000000) / 10,
+ lonh.toLocal8Bit().data(), londeg, UTF8_DEGREE, ilonmin / 1000000, (ilonmin % 1000000) / 10);
+ return result;
+}
diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h
index 2a588bad8..9cfe43a26 100644
--- a/qt-ui/maintab.h
+++ b/qt-ui/maintab.h
@@ -91,7 +91,8 @@ private:
enum { NONE, DIVE, TRIP, ADD } editMode;
Completers completers;
void enableEdition();
- void resetPallete();
+ void resetPallete();
+ QString printGPSCoords(int lat, int lon);
};
#endif