summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Thiago Macieira <thiago@macieira.org>2013-11-14 14:59:06 -0800
committerGravatar Thiago Macieira <thiago@macieira.org>2013-12-03 13:53:00 -0800
commitbe7bbb2a7dd627f3c1361d200fbb3d0090a667e6 (patch)
tree27db63bf51da388e7a4eb7307ccb722c83784b2f /qt-ui
parentff96bcb0fc9ef47c94fee8e675431882d20ba9dc (diff)
downloadsubsurface-be7bbb2a7dd627f3c1361d200fbb3d0090a667e6.tar.gz
webservices: Move the static functions to the top of the file
Just my OCD asserting itself. It looks cleaner this way, if the static functions aren't interleaved in the middle of the WebServices class. Signed-off-by: Thiago Macieira <thiago@macieira.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/subsurfacewebservices.cpp146
1 files changed, 73 insertions, 73 deletions
diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp
index 4713ef2af..4301ced50 100644
--- a/qt-ui/subsurfacewebservices.cpp
+++ b/qt-ui/subsurfacewebservices.cpp
@@ -16,6 +16,79 @@
struct dive_table gps_location_table;
static bool merge_locations_into_dives(void);
+static bool is_automatic_fix(struct dive *gpsfix)
+{
+ if (gpsfix && gpsfix->location &&
+ (!strcmp(gpsfix->location, "automatic fix") ||
+ !strcmp(gpsfix->location, "Auto-created dive")))
+ return TRUE;
+ return FALSE;
+}
+
+#define SAME_GROUP 6 * 3600 // six hours
+
+static bool merge_locations_into_dives(void)
+{
+ int i, nr = 0, changed = 0;
+ struct dive *gpsfix, *last_named_fix = NULL, *dive;
+
+ sort_table(&gps_location_table);
+
+ for_each_gps_location(i, gpsfix) {
+ if (is_automatic_fix(gpsfix)) {
+ dive = find_dive_including(gpsfix->when);
+ if (dive && !dive_has_gps_location(dive)) {
+#if DEBUG_WEBSERVICE
+ struct tm tm;
+ utc_mkdate(gpsfix->when, &tm);
+ printf("found dive named %s @ %04d-%02d-%02d %02d:%02d:%02d\n",
+ gpsfix->location,
+ tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday,
+ tm.tm_hour, tm.tm_min, tm.tm_sec);
+#endif
+ changed++;
+ copy_gps_location(gpsfix, dive);
+ }
+ } else {
+ if (last_named_fix && dive_within_time_range(last_named_fix, gpsfix->when, SAME_GROUP)) {
+ nr++;
+ } else {
+ nr = 1;
+ last_named_fix = gpsfix;
+ }
+ dive = find_dive_n_near(gpsfix->when, nr, SAME_GROUP);
+ if (dive) {
+ if (!dive_has_gps_location(dive)) {
+ copy_gps_location(gpsfix, dive);
+ changed++;
+ }
+ if (!dive->location) {
+ dive->location = strdup(gpsfix->location);
+ changed++;
+ }
+ } else {
+ struct tm tm;
+ utc_mkdate(gpsfix->when, &tm);
+#if DEBUG_WEBSERVICE
+ printf("didn't find dive matching gps fix named %s @ %04d-%02d-%02d %02d:%02d:%02d\n",
+ gpsfix->location,
+ tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday,
+ tm.tm_hour, tm.tm_min, tm.tm_sec);
+#endif
+ }
+ }
+ }
+ return changed > 0;
+}
+
+static void clear_table(struct dive_table *table)
+{
+ int i;
+ for (i = 0; i < table->nr; i++)
+ free(table->dives[i]);
+ table->nr = 0;
+}
+
WebServices::WebServices(QWidget* parent, Qt::WindowFlags f): QDialog(parent, f)
, reply(0)
{
@@ -63,14 +136,6 @@ SubsurfaceWebServices::SubsurfaceWebServices(QWidget* parent, Qt::WindowFlags f)
hideUpload();
}
-static void clear_table(struct dive_table *table)
-{
- int i;
- for (i = 0; i < table->nr; i++)
- free(table->dives[i]);
- table->nr = 0;
-}
-
void SubsurfaceWebServices::buttonClicked(QAbstractButton* button)
{
ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
@@ -197,71 +262,6 @@ end:
return status;
}
-static bool is_automatic_fix(struct dive *gpsfix)
-{
- if (gpsfix && gpsfix->location &&
- (!strcmp(gpsfix->location, "automatic fix") ||
- !strcmp(gpsfix->location, "Auto-created dive")))
- return TRUE;
- return FALSE;
-}
-
-#define SAME_GROUP 6 * 3600 // six hours
-
-static bool merge_locations_into_dives(void)
-{
- int i, nr = 0, changed = 0;
- struct dive *gpsfix, *last_named_fix = NULL, *dive;
-
- sort_table(&gps_location_table);
-
- for_each_gps_location(i, gpsfix) {
- if (is_automatic_fix(gpsfix)) {
- dive = find_dive_including(gpsfix->when);
- if (dive && !dive_has_gps_location(dive)) {
-#if DEBUG_WEBSERVICE
- struct tm tm;
- utc_mkdate(gpsfix->when, &tm);
- printf("found dive named %s @ %04d-%02d-%02d %02d:%02d:%02d\n",
- gpsfix->location,
- tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday,
- tm.tm_hour, tm.tm_min, tm.tm_sec);
-#endif
- changed++;
- copy_gps_location(gpsfix, dive);
- }
- } else {
- if (last_named_fix && dive_within_time_range(last_named_fix, gpsfix->when, SAME_GROUP)) {
- nr++;
- } else {
- nr = 1;
- last_named_fix = gpsfix;
- }
- dive = find_dive_n_near(gpsfix->when, nr, SAME_GROUP);
- if (dive) {
- if (!dive_has_gps_location(dive)) {
- copy_gps_location(gpsfix, dive);
- changed++;
- }
- if (!dive->location) {
- dive->location = strdup(gpsfix->location);
- changed++;
- }
- } else {
- struct tm tm;
- utc_mkdate(gpsfix->when, &tm);
-#if DEBUG_WEBSERVICE
- printf("didn't find dive matching gps fix named %s @ %04d-%02d-%02d %02d:%02d:%02d\n",
- gpsfix->location,
- tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday,
- tm.tm_hour, tm.tm_min, tm.tm_sec);
-#endif
- }
- }
- }
- return changed > 0;
-}
-
// #
// #
// # Divelogs DE Web Service Implementation.