summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--info.h10
-rw-r--r--qt-ui/maintab.cpp51
-rw-r--r--qt-ui/maintab.h4
-rw-r--r--qt-ui/maintab.ui66
4 files changed, 101 insertions, 30 deletions
diff --git a/info.h b/info.h
index a27373d89..ac8f42d2b 100644
--- a/info.h
+++ b/info.h
@@ -6,6 +6,10 @@
#ifndef INFO_H
#define INFO_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
extern gboolean gps_changed(struct dive *dive, struct dive *master, const char *gps_text);
extern void print_gps_coordinates(char *buffer, int len, int lat, int lon);
extern void save_equipment_data(struct dive *dive);
@@ -13,8 +17,12 @@ extern void update_equipment_data(struct dive *dive, struct dive *master);
extern void update_time_depth(struct dive *dive, struct dive *edited);
extern const char *get_window_title(struct dive *dive);
extern char *evaluate_string_change(const char *newstring, char **textp, const char *master);
-extern int text_changed(const char *old, const char *new);
+extern int text_changed(const char *old, const char * /*new is a c++ keyword*/);
extern gboolean parse_gps_text(const char *gps_text, double *latitude, double *longitude);
extern int divename(char *buf, size_t size, struct dive *dive, char *trailer);
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index 42250b42c..cb61db84f 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -9,6 +9,7 @@
#include "mainwindow.h"
#include "../helpers.h"
#include "../statistics.h"
+#include "../info.h"
#include "divelistview.h"
#include "modeldelegates.h"
#include "globe.h"
@@ -41,6 +42,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
// we start out with the fields read-only; once things are
// filled from a dive, they are made writeable
ui->location->setReadOnly(true);
+ ui->coordinates->setReadOnly(true);
ui->divemaster->setReadOnly(true);
ui->buddy->setReadOnly(true);
ui->suit->setReadOnly(true);
@@ -52,6 +54,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
ui->editReset->hide();
ui->location->installEventFilter(this);
+ ui->coordinates->installEventFilter(this);
ui->divemaster->installEventFilter(this);
ui->buddy->installEventFilter(this);
ui->suit->installEventFilter(this);
@@ -169,9 +172,14 @@ void MainTab::updateDiveInfo(int dive)
UPDATE_TEXT(d, suit);
UPDATE_TEXT(d, divemaster);
UPDATE_TEXT(d, buddy);
+
if (d) {
+ char buffer[256];
+ print_gps_coordinates(buffer, sizeof buffer, d->latitude.udeg, d->longitude.udeg);
+ ui->coordinates->setText(buffer);
if (mainWindow() && mainWindow()->dive_list()->selectedTrips.count() == 1) {
// only use trip relevant fields
+ ui->coordinates->setVisible(false);
ui->divemaster->setVisible(false);
ui->DivemasterLabel->setVisible(false);
ui->buddy->setVisible(false);
@@ -192,11 +200,15 @@ void MainTab::updateDiveInfo(int dive)
ui->notes->setText(currentTrip->notes);
} else {
// make all the fields visible writeable
+ ui->coordinates->setVisible(true);
ui->divemaster->setVisible(true);
ui->buddy->setVisible(true);
ui->suit->setVisible(true);
+ ui->SuitLabel->setVisible(true);
ui->rating->setVisible(true);
+ ui->RatingLabel->setVisible(true);
ui->visibility->setVisible(true);
+ ui->visibilityLabel->setVisible(true);
ui->BuddyLabel->setVisible(true);
ui->DivemasterLabel->setVisible(true);
ui->divemaster->setReadOnly(false);
@@ -209,6 +221,7 @@ void MainTab::updateDiveInfo(int dive)
ui->visibility->setCurrentStars(d->visibility);
// reset labels in case we last displayed trip notes
ui->location->setReadOnly(false);
+ ui->coordinates->setReadOnly(false);
ui->LocationLabel->setText(tr("Location"));
ui->notes->setReadOnly(false);
ui->NotesLabel->setText(tr("Notes"));
@@ -261,6 +274,7 @@ void MainTab::updateDiveInfo(int dive)
} else {
/* make the fields read-only */
ui->location->setReadOnly(true);
+ ui->coordinates->setReadOnly(true);
ui->divemaster->setReadOnly(true);
ui->buddy->setReadOnly(true);
ui->suit->setReadOnly(true);
@@ -316,6 +330,7 @@ void MainTab::reload()
void MainTab::on_editAccept_clicked(bool edit)
{
ui->location->setReadOnly(!edit);
+ ui->coordinates->setReadOnly(!edit);
ui->divemaster->setReadOnly(!edit);
ui->buddy->setReadOnly(!edit);
ui->suit->setReadOnly(!edit);
@@ -357,6 +372,9 @@ void MainTab::on_editAccept_clicked(bool edit)
notesBackup[mydive].location = QString(mydive->location);
notesBackup[mydive].rating = mydive->rating;
notesBackup[mydive].visibility = mydive->visibility;
+ notesBackup[mydive].latitude = mydive->latitude;
+ notesBackup[mydive].longitude = mydive->longitude;
+ notesBackup[mydive].coordinates = ui->location->text();
}
editMode = DIVE;
}
@@ -376,12 +394,16 @@ void MainTab::on_editAccept_clicked(bool edit)
notesBackup[curr].notes != ui->notes->toPlainText() ||
notesBackup[curr].divemaster != ui->divemaster->text() ||
notesBackup[curr].location != ui->location->text() ||
+ notesBackup[curr].coordinates != ui->coordinates->text() ||
notesBackup[curr].rating != ui->visibility->currentStars() ||
notesBackup[curr].visibility != ui->rating->currentStars())
mark_divelist_changed(TRUE);
- if (notesBackup[curr].location != ui->location->text())
+ if (notesBackup[curr].location != ui->location->text() ||
+ notesBackup[curr].coordinates != ui->coordinates->text()) {
mainWindow()->globe()->reload();
+ mainWindow()->globe()->centerOn(current_dive);
+ }
}
editMode = NONE;
}
@@ -415,6 +437,7 @@ void MainTab::on_editReset_clicked()
struct dive *curr = current_dive;
ui->notes->setText(notesBackup[curr].notes );
ui->location->setText(notesBackup[curr].location);
+ ui->coordinates->setText(notesBackup[curr].coordinates);
ui->buddy->setText(notesBackup[curr].buddy);
ui->suit->setText(notesBackup[curr].suit);
ui->divemaster->setText(notesBackup[curr].divemaster);
@@ -435,6 +458,8 @@ void MainTab::on_editReset_clicked()
EDIT_TEXT2(mydive->notes, notesBackup[mydive].notes);
EDIT_TEXT2(mydive->divemaster, notesBackup[mydive].divemaster);
EDIT_TEXT2(mydive->location, notesBackup[mydive].location);
+ mydive->latitude = notesBackup[mydive].latitude;
+ mydive->longitude = notesBackup[mydive].longitude;
mydive->rating = notesBackup[mydive].rating;
mydive->visibility = notesBackup[mydive].visibility;
}
@@ -443,6 +468,7 @@ void MainTab::on_editReset_clicked()
ui->diveNotesMessage->animatedHide();
ui->location->setReadOnly(true);
+ ui->coordinates->setReadOnly(true);
ui->divemaster->setReadOnly(true);
ui->buddy->setReadOnly(true);
ui->suit->setReadOnly(true);
@@ -467,10 +493,9 @@ void MainTab::on_editReset_clicked()
#define EDIT_SELECTED_DIVES( WHAT ) \
if (editMode == NONE) \
return; \
- struct dive *mydive; \
\
for (int i = 0; i < dive_table.nr; i++) { \
- mydive = get_dive(i); \
+ struct dive *mydive = get_dive(i); \
if (!mydive) \
continue; \
if (!mydive->selected) \
@@ -506,6 +531,20 @@ void MainTab::on_location_textChanged(const QString& text)
dive_trip_t *currentTrip = *mainWindow()->dive_list()->selectedTrips.begin();
EDIT_TEXT(currentTrip->location, text);
} else if (editMode == DIVE){
+ struct dive* dive;
+ int i = 0;
+ for_each_dive(i, dive){
+ QString location(dive->location);
+ if (location == 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);
+ break;
+ }
+ }
EDIT_SELECTED_DIVES( EDIT_TEXT(mydive->location, text) )
}
@@ -534,6 +573,12 @@ void MainTab::on_notes_textChanged()
#undef EDIT_TEXT
+void MainTab::on_coordinates_textChanged(const QString& text)
+{
+ QByteArray textByteArray = text.toLocal8Bit();
+ EDIT_SELECTED_DIVES(gps_changed(mydive, NULL, textByteArray.data()));
+}
+
void MainTab::on_rating_valueChanged(int value)
{
EDIT_SELECTED_DIVES(mydive->rating = value );
diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h
index f9f65a3ff..297f27cf9 100644
--- a/qt-ui/maintab.h
+++ b/qt-ui/maintab.h
@@ -22,6 +22,9 @@ namespace Ui
struct NotesBackup{
QString location;
+ QString coordinates;
+ degrees_t latitude;
+ degrees_t longitude;
QString notes;
QString buddy;
QString suit;
@@ -56,6 +59,7 @@ public slots:
void on_editAccept_clicked(bool edit);
void on_editReset_clicked();
void on_location_textChanged(const QString& text);
+ void on_coordinates_textChanged(const QString& text);
void on_divemaster_textChanged(const QString& text);
void on_buddy_textChanged(const QString& text);
void on_suit_textChanged(const QString& text);
diff --git a/qt-ui/maintab.ui b/qt-ui/maintab.ui
index a1f5a718a..967bf133c 100644
--- a/qt-ui/maintab.ui
+++ b/qt-ui/maintab.ui
@@ -21,63 +21,70 @@
<string>Dive Notes</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
- <item row="1" column="0">
- <widget class="QLabel" name="LocationLabel">
- <property name="text">
- <string>Location</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0" colspan="2">
- <widget class="QLineEdit" name="location">
+ <item row="4" column="0" colspan="2">
+ <widget class="QLineEdit" name="coordinates">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
- <item row="3" column="0">
- <widget class="QLabel" name="DivemasterLabel">
- <property name="text">
- <string>Divemaster</string>
+ <item row="11" column="0" colspan="2">
+ <widget class="QTextEdit" name="notes">
+ <property name="readOnly">
+ <bool>true</bool>
</property>
</widget>
</item>
- <item row="3" column="1">
- <widget class="QLabel" name="BuddyLabel">
+ <item row="1" column="0">
+ <widget class="QLabel" name="LocationLabel">
<property name="text">
- <string>Buddy</string>
+ <string>Location</string>
</property>
</widget>
</item>
- <item row="4" column="0">
+ <item row="6" column="0">
<widget class="QLineEdit" name="divemaster">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
- <item row="6" column="1">
+ <item row="8" column="1">
<widget class="QLineEdit" name="suit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
- <item row="4" column="1">
+ <item row="6" column="1">
<widget class="QLineEdit" name="buddy">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
- <item row="9" column="0" colspan="2">
- <widget class="QTextEdit" name="notes">
+ <item row="2" column="0" colspan="2">
+ <widget class="QLineEdit" name="location">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0">
+ <widget class="QLabel" name="DivemasterLabel">
+ <property name="text">
+ <string>Divemaster</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="1">
+ <widget class="QLabel" name="BuddyLabel">
+ <property name="text">
+ <string>Buddy</string>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="0">
<layout class="QHBoxLayout" name="ratingVisibilityLabels">
<item>
<widget class="QLabel" name="RatingLabel">
@@ -95,21 +102,21 @@
</item>
</layout>
</item>
- <item row="5" column="1">
+ <item row="7" column="1">
<widget class="QLabel" name="SuitLabel">
<property name="text">
<string>Suit</string>
</property>
</widget>
</item>
- <item row="7" column="0">
+ <item row="9" column="0">
<widget class="QLabel" name="NotesLabel">
<property name="text">
<string>Notes</string>
</property>
</widget>
</item>
- <item row="6" column="0">
+ <item row="8" column="0">
<layout class="QHBoxLayout" name="ratingVisibilityWidgets">
<item>
<widget class="StarWidget" name="rating" native="true"/>
@@ -119,14 +126,14 @@
</item>
</layout>
</item>
- <item row="10" column="1">
+ <item row="12" column="1">
<widget class="QPushButton" name="editReset">
<property name="text">
<string>Undo</string>
</property>
</widget>
</item>
- <item row="10" column="0">
+ <item row="12" column="0">
<widget class="QPushButton" name="editAccept">
<property name="text">
<string>Save</string>
@@ -139,6 +146,13 @@
<item row="0" column="0" colspan="2">
<widget class="KMessageWidget" name="diveNotesMessage" native="true"/>
</item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="CoordinatedLabel">
+ <property name="text">
+ <string>Coordinates</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
<widget class="QWidget" name="equipmentTab">