aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--deco.h4
-rw-r--r--libdivecomputer.c2
-rw-r--r--parse-xml.c8
-rw-r--r--qt-ui/diveplanner.cpp26
-rw-r--r--qt-ui/diveplanner.h2
-rw-r--r--qt-ui/maintab.cpp55
6 files changed, 72 insertions, 25 deletions
diff --git a/deco.h b/deco.h
index f9ed7d4d7..bf305b93b 100644
--- a/deco.h
+++ b/deco.h
@@ -9,4 +9,8 @@ extern "C" {
extern double buehlmann_N2_t_halflife[];
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/libdivecomputer.c b/libdivecomputer.c
index 0a8ba0487..6f2f1f66c 100644
--- a/libdivecomputer.c
+++ b/libdivecomputer.c
@@ -153,7 +153,7 @@ static void handle_event(struct divecomputer *dc, struct sample *sample, dc_samp
N_("none"), N_("deco stop"), N_("rbt"), N_("ascent"), N_("ceiling"), N_("workload"),
N_("transmitter"), N_("violation"), N_("bookmark"), N_("surface"), N_("safety stop"),
N_("gaschange"), N_("safety stop (voluntary)"), N_("safety stop (mandatory)"),
- N_("deepstop"), N_("ceiling (safety stop)"), N_("unknown"), N_("divetime"),
+ N_("deepstop"), N_("ceiling (safety stop)"), N_("below floor"), N_("divetime"),
N_("maxdepth"), N_("OLF"), N_("PO2"), N_("airtime"), N_("rgbm"), N_("heading"),
N_("tissue level warning"), N_("gaschange"), N_("non stop time")
};
diff --git a/parse-xml.c b/parse-xml.c
index 5c031fcac..370388f4f 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -1635,6 +1635,10 @@ extern int dm4_events(void *handle, int columns, char **data, char **column)
/* 6 Mandatory safety stop ceiling error */
cur_event.name = strdup("violation");
break;
+ case 7:
+ /* 7 Below deco floor */
+ cur_event.name = strdup("below floor");
+ break;
case 8:
/* 8 Dive time alarm */
cur_event.name = strdup("divetime");
@@ -1653,6 +1657,10 @@ extern int dm4_events(void *handle, int columns, char **data, char **column)
/* 12 High ppO2 */
cur_event.name = strdup("PO2");
break;
+ case 13:
+ /* 13 Air time */
+ cur_event.name = strdup("airtime");
+ break;
case 18:
/* 18 Ceiling error */
cur_event.name = strdup("ceiling");
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index fe1342112..36cd7f144 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -428,7 +428,7 @@ void DivePlannerGraphics::drawProfile()
dp = dp->next;
}
- if (timeLine->maximum() < dp->time / 60.0 + 5 || dp->time / 60.0 + 15 < timeLine->maximum()) {
+ if (!activeDraggedHandler && (timeLine->maximum() < dp->time / 60.0 + 5 || dp->time / 60.0 + 15 < timeLine->maximum())) {
double newMax = fmax(dp->time / 60.0 + 5, minMinutes);
timeLine->setMaximum(newMax);
timeLine->updateTicks();
@@ -522,7 +522,7 @@ void DivePlannerGraphics::mouseMoveEvent(QMouseEvent* event)
depthString->setBrush( QColor(redDelta, greenDelta, blueDelta));
if (activeDraggedHandler)
- moveActiveHandler(mappedPos);
+ moveActiveHandler(mappedPos, handles.indexOf(activeDraggedHandler));
if (!handles.count())
return;
@@ -535,13 +535,27 @@ void DivePlannerGraphics::mouseMoveEvent(QMouseEvent* event)
}
}
-void DivePlannerGraphics::moveActiveHandler(const QPointF& pos)
+void DivePlannerGraphics::moveActiveHandler(const QPointF& mappedPos, const int pos)
{
- double xpos = timeLine->posAtValue(rint(timeLine->valueAt(pos)));
- double ypos = depthLine->posAtValue(rint(depthLine->valueAt(pos)));
+
+ divedatapoint data = plannerModel->at(pos);
+ int minutes = rint(timeLine->valueAt(mappedPos));
+ int meters = rint(depthLine->valueAt(mappedPos));
+ double xpos = timeLine->posAtValue(minutes);
+ double ypos = depthLine->posAtValue(meters);
+
+ data.depth = rint(depthLine->valueAt(mappedPos)) * 1000;
+ data.time = rint(timeLine->valueAt(mappedPos)) * 60;
+
+ plannerModel->editStop(pos, data);
+
activeDraggedHandler->setPos(QPointF(xpos, ypos));
qDeleteAll(lines);
lines.clear();
+
+ drawProfile();
+
+
}
bool DivePlannerGraphics::isPointOutOfBoundaries(const QPointF& point)
@@ -606,8 +620,8 @@ void DivePlannerGraphics::mouseReleaseEvent(QMouseEvent* event)
activeDraggedHandler->setBrush(QBrush(Qt::white));
activeDraggedHandler->setPos(QPointF(xpos, ypos));
- drawProfile();
activeDraggedHandler = 0;
+ drawProfile();
}
}
diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h
index 016fda332..12b01cdeb 100644
--- a/qt-ui/diveplanner.h
+++ b/qt-ui/diveplanner.h
@@ -153,7 +153,7 @@ private slots:
void pointInserted(const QModelIndex&, int start, int end);
void pointsRemoved(const QModelIndex&, int start, int end);
private:
- void moveActiveHandler(const QPointF& pos);
+ void moveActiveHandler(const QPointF& MappedPos, const int pos);
/* This are the lines of the plotted dive. */
QList<QGraphicsLineItem*> lines;
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index a42ce68dd..d35fefcf9 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -141,7 +141,7 @@ void MainTab::enableEdition()
notesBackup[mydive].visibility = mydive->visibility;
notesBackup[mydive].latitude = mydive->latitude;
notesBackup[mydive].longitude = mydive->longitude;
- notesBackup[mydive].coordinates = ui->location->text();
+ notesBackup[mydive].coordinates = ui->coordinates->text();
}
editMode = DIVE;
}
@@ -374,6 +374,11 @@ void MainTab::acceptChanges()
mark_divelist_changed(TRUE);
} 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);
if (notesBackup[curr].buddy != ui->buddy->text() ||
notesBackup[curr].suit != ui->suit->text() ||
notesBackup[curr].notes != ui->notes->toPlainText() ||
@@ -403,6 +408,7 @@ void MainTab::acceptChanges()
ui->buddy->setPalette(p);
ui->notes->setPalette(p);
ui->location->setPalette(p);
+ ui->coordinates->setPalette(p);
ui->divemaster->setPalette(p);
ui->suit->setPalette(p);
}
@@ -468,6 +474,7 @@ void MainTab::rejectChanges()
ui->buddy->setPalette(p);
ui->notes->setPalette(p);
ui->location->setPalette(p);
+ ui->coordinates->setPalette(p);
ui->divemaster->setPalette(p);
ui->suit->setPalette(p);
if (editMode == ADD) {
@@ -482,7 +489,7 @@ void MainTab::rejectChanges()
}
#undef EDIT_TEXT2
-#define EDIT_SELECTED_DIVES( WHAT ) \
+#define EDIT_SELECTED_DIVES( WHAT ) do { \
if (editMode == NONE) \
return; \
\
@@ -494,7 +501,8 @@ void MainTab::rejectChanges()
continue; \
\
WHAT; \
- }
+ } \
+} while(0)
void markChangedWidget(QWidget *w){
QPalette p;
@@ -523,21 +531,26 @@ 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 || editMode == ADD){
- 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;
+ if (!ui->coordinates->isModified() ||
+ ui->coordinates->text().trimmed().isEmpty()) {
+ 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);
+ markChangedWidget(ui->coordinates);
+ break;
+ }
}
}
- EDIT_SELECTED_DIVES( EDIT_TEXT(mydive->location, text) )
+ EDIT_SELECTED_DIVES( EDIT_TEXT(mydive->location, text) );
}
markChangedWidget(ui->location);
@@ -568,7 +581,15 @@ void MainTab::on_notes_textChanged()
void MainTab::on_coordinates_textChanged(const QString& text)
{
QByteArray textByteArray = text.toLocal8Bit();
- EDIT_SELECTED_DIVES(gps_changed(mydive, NULL, textByteArray.data()));
+ gboolean gpsChanged = FALSE;
+ EDIT_SELECTED_DIVES(gpsChanged |= gps_changed(mydive, NULL, textByteArray.data()));
+ if (gpsChanged) {
+ markChangedWidget(ui->coordinates);
+ } else {
+ QPalette p;
+ p.setBrush(QPalette::Base, QColor(Qt::red).lighter());
+ ui->coordinates->setPalette(p);
+ }
}
void MainTab::on_rating_valueChanged(int value)