aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-01-19 18:15:03 +1200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-01-19 18:15:03 +1200
commitde9acbd30d5af81d5774a92e4734e04cdb3084b1 (patch)
treed8610aba6b152832d6a2b894584fbb77f546db2c /qt-ui
parent93058f28ea886b06a012daeba49c3c9eb95a587d (diff)
parentf448bfd574bb9aa4593b43392131174dc489a4b0 (diff)
downloadsubsurface-de9acbd30d5af81d5774a92e4734e04cdb3084b1.tar.gz
Merge branch 'latestmaster'
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/diveplanner.cpp6
-rw-r--r--qt-ui/diveplanner.h2
-rw-r--r--qt-ui/globe.cpp31
-rw-r--r--qt-ui/globe.h3
-rw-r--r--qt-ui/maintab.cpp21
-rw-r--r--qt-ui/maintab.h3
-rw-r--r--qt-ui/mainwindow.cpp2
-rw-r--r--qt-ui/printlayout.cpp1
-rw-r--r--qt-ui/profile/profilewidget2.cpp61
-rw-r--r--qt-ui/profile/tankitem.cpp2
10 files changed, 72 insertions, 60 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 44ca6baf5..2ee168413 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -181,6 +181,7 @@ DiveHandler::DiveHandler() : QGraphicsEllipseItem()
setFlags(ItemIgnoresTransformations | ItemIsSelectable | ItemIsMovable | ItemSendsGeometryChanges);
setBrush(Qt::white);
setZValue(2);
+ t.start();
}
int DiveHandler::parentIndex()
@@ -225,9 +226,14 @@ void DiveHandler::changeGas()
void DiveHandler::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
+ if (t.elapsed() < 40)
+ return;
+ t.start();
+
ProfileWidget2 *view = qobject_cast<ProfileWidget2*>(scene()->views().first());
if(view->isPointOutOfBoundaries(event->scenePos()))
return;
+
QGraphicsEllipseItem::mouseMoveEvent(event);
emit moved();
}
diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h
index e6ae8e8b5..4093bacd1 100644
--- a/qt-ui/diveplanner.h
+++ b/qt-ui/diveplanner.h
@@ -133,6 +133,8 @@ public
slots:
void selfRemove();
void changeGas();
+private:
+ QTime t;
};
#include "ui_diveplanner.h"
diff --git a/qt-ui/globe.cpp b/qt-ui/globe.cpp
index c2bbeb415..1e4639d5c 100644
--- a/qt-ui/globe.cpp
+++ b/qt-ui/globe.cpp
@@ -187,9 +187,17 @@ void GlobeGPS::repopulateLabels()
loadedDives = new GeoDataDocument;
QMap<QString, GeoDataPlacemark *> locationMap;
- int idx = 0;
+ int idx = -2;
struct dive *dive;
- for_each_dive (idx, dive) {
+ // normally we use for_each_dive (idx, dive) to loop over all dives,
+ // but we need to include the displayed_dive while things are
+ // edited, so let's hand roll this loop
+ while (++idx < dive_table.nr) {
+ dive = (idx == -1 ? &displayed_dive : get_dive(idx));
+ if (dive == current_dive)
+ // don't show that flag, it's either already shown as displayed_dive
+ // or it's the one that we are moving right now...
+ continue;
if (dive_has_gps_location(dive)) {
GeoDataPlacemark *place = new GeoDataPlacemark(dive->location);
place->setCoordinate(dive->longitude.udeg / 1000000.0, dive->latitude.udeg / 1000000.0, 0, GeoDataCoordinates::Degree);
@@ -307,21 +315,14 @@ void GlobeGPS::changeDiveGeoPosition(qreal lon, qreal lat, GeoDataCoordinates::U
lon = lon * 180 / M_PI;
lat = lat * 180 / M_PI;
}
-
- // right now we try to only ever do this with one dive selected,
- // but we keep the code here that changes the coordinates for each selected dive
- int i;
- struct dive *dive;
- for_each_dive (i, dive) {
- if (!dive->selected)
- continue;
- dive->latitude.udeg = lrint(lat * 1000000.0);
- dive->longitude.udeg = lrint(lon * 1000000.0);
- }
centerOn(lon, lat, true);
+
+ // change the location of the displayed_dive and put the UI in edit mode
+ displayed_dive.latitude.udeg = lrint(lat * 1000000.0);
+ displayed_dive.longitude.udeg = lrint(lon * 1000000.0);
+ emit(coordinatesChanged());
+ repopulateLabels();
editingDiveLocation = false;
- mark_divelist_changed(true);
- MainWindow::instance()->refreshDisplay();
}
void GlobeGPS::mousePressEvent(QMouseEvent *event)
diff --git a/qt-ui/globe.h b/qt-ui/globe.h
index 8124a4d57..b6a33bbbe 100644
--- a/qt-ui/globe.h
+++ b/qt-ui/globe.h
@@ -39,6 +39,9 @@ private:
bool editingDiveLocation;
bool doubleClick;
+signals:
+ void coordinatesChanged(void);
+
public
slots:
void changeDiveGeoPosition(qreal lon, qreal lat, GeoDataCoordinates::Unit);
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index 3c00a1bed..be55f6f29 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -428,7 +428,7 @@ void MainTab::updateDiveInfo(bool clear)
ui.DiveType->setCurrentIndex(displayed_dive.dc.divemode);
if (!clear) {
- updateGpsCoordinates(&displayed_dive);
+ updateGpsCoordinates();
// Subsurface always uses "local time" as in "whatever was the local time at the location"
// so all time stamps have no time zone information and are in UTC
QDateTime localTime = QDateTime::fromTime_t(displayed_dive.when - gettimezoneoffset(displayed_dive.when));
@@ -750,7 +750,7 @@ void MainTab::acceptChanges()
}
struct dive *cd = current_dive;
//Reset coordinates field, in case it contains garbage.
- updateGpsCoordinates(&displayed_dive);
+ updateGpsCoordinates();
// now check if something has changed and if yes, edit the selected dives that
// were identical with the master dive shown (and mark the divelist as changed)
if (!same_string(displayed_dive.buddy, cd->buddy))
@@ -1137,7 +1137,7 @@ void MainTab::on_location_editingFinished()
displayed_dive.latitude = dive->latitude;
displayed_dive.longitude = dive->longitude;
MainWindow::instance()->globe()->reload();
- updateGpsCoordinates(&displayed_dive);
+ updateGpsCoordinates();
break;
}
}
@@ -1244,14 +1244,13 @@ void MainTab::updateCoordinatesText(qreal lat, qreal lon)
ui.coordinates->setText(printGPSCoords(ulat, ulon));
}
-void MainTab::updateGpsCoordinates(const struct dive *dive)
+void MainTab::updateGpsCoordinates()
{
- if (dive) {
- ui.coordinates->setText(printGPSCoords(dive->latitude.udeg, dive->longitude.udeg));
- ui.coordinates->setModified(dive->latitude.udeg || dive->longitude.udeg);
- } else {
- ui.coordinates->clear();
- }
+ if (editMode == NONE)
+ enableEdition();
+
+ ui.coordinates->setText(printGPSCoords(displayed_dive.latitude.udeg, displayed_dive.longitude.udeg));
+ ui.coordinates->setModified(displayed_dive.latitude.udeg || displayed_dive.longitude.udeg);
}
void MainTab::escDetected()
@@ -1300,7 +1299,7 @@ void MainTab::showAndTriggerEditSelective(struct dive_components what)
if (what.visibility)
ui.visibility->setCurrentStars(displayed_dive.visibility);
if (what.gps)
- updateGpsCoordinates(&displayed_dive);
+ updateGpsCoordinates();
if (what.tags) {
char buf[1024];
taglist_get_tagstring(displayed_dive.tag_list, buf, 1024);
diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h
index 2f7277bbd..71703e3f1 100644
--- a/qt-ui/maintab.h
+++ b/qt-ui/maintab.h
@@ -92,6 +92,8 @@ slots:
void escDetected(void);
void photoDoubleClicked(const QString filePath);
void removeSelectedPhotos();
+ void updateGpsCoordinates();
+
private:
Ui::MainTab ui;
WeightModel *weightModel;
@@ -109,7 +111,6 @@ private:
bool copyPaste;
void resetPallete();
void saveTags();
- void updateGpsCoordinates(const struct dive *dive);
void markChangedWidget(QWidget *w);
dive_trip_t *currentTrip;
dive_trip_t displayedTrip;
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index 8835bb8e3..5d5a442f4 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -96,6 +96,8 @@ MainWindow::MainWindow() : QMainWindow(),
#ifdef NO_MARBLE
ui.globePane->hide();
ui.menuView->removeAction(ui.actionViewGlobe);
+#else
+ connect(ui.globe, SIGNAL(coordinatesChanged()), ui.InfoWidget, SLOT(updateGpsCoordinates()));
#endif
#ifdef NO_USERMANUAL
ui.menuHelp->removeAction(ui.actionUserManual);
diff --git a/qt-ui/printlayout.cpp b/qt-ui/printlayout.cpp
index a347e1fdb..6b88f0d29 100644
--- a/qt-ui/printlayout.cpp
+++ b/qt-ui/printlayout.cpp
@@ -2,6 +2,7 @@
#include <QDesktopWidget>
#include <QPicture>
#include <QMessageBox>
+#include <QPointer>
#include "mainwindow.h"
#include "printdialog.h"
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index 516b14c2f..850f357cf 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -15,6 +15,7 @@
#include <QtCore/qmath.h>
#include <QMessageBox>
#include <QInputDialog>
+#include <QDebug>
#ifndef QT_NO_DEBUG
#include <QTableView>
@@ -55,7 +56,7 @@ static struct _ItemPos {
_Axis temperature;
_Axis temperatureAll;
_Axis heartBeat;
- _Axis heartBeatAll;
+ _Axis heartBeatWithTankBar;
} itemPos;
ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent),
@@ -396,13 +397,11 @@ void ProfileWidget2::setupItemSizes()
// Heartbeat axis config
itemPos.heartBeat.pos.on.setX(3);
- itemPos.heartBeat.pos.on.setY(65);
+ itemPos.heartBeat.pos.on.setY(82);
itemPos.heartBeat.expanded.setP1(QPointF(0, 0));
itemPos.heartBeat.expanded.setP2(QPointF(0, 10));
- itemPos.heartBeatAll = itemPos.heartBeat;
- itemPos.heartBeatAll.pos.on.setX(3);
- itemPos.heartBeatAll.pos.on.setY(55);
- itemPos.heartBeatAll.expanded.setP2(QPointF(0, 7));
+ itemPos.heartBeatWithTankBar = itemPos.heartBeat;
+ itemPos.heartBeatWithTankBar.expanded.setP2(QPointF(0, 7));
// Percentage axis config
itemPos.percentage.pos.on.setX(3);
@@ -635,7 +634,7 @@ void ProfileWidget2::settingsChanged()
// if we are showing calculated ceilings then we have to replot()
// because the GF could have changed; otherwise we try to avoid replot()
bool needReplot = prefs.calcceiling;
- if (prefs.percentagegraph && PP_GRAPHS_ENABLED) {
+ if ((prefs.percentagegraph||prefs.hrgraph) && PP_GRAPHS_ENABLED) {
profileYAxis->animateChangeLine(itemPos.depth.shrinked);
temperatureAxis->setPos(itemPos.temperatureAll.pos.on);
temperatureAxis->animateChangeLine(itemPos.temperature.shrinked);
@@ -644,37 +643,36 @@ void ProfileWidget2::settingsChanged()
if (prefs.tankbar) {
percentageAxis->setPos(itemPos.percentageWithTankBar.pos.on);
percentageAxis->animateChangeLine(itemPos.percentageWithTankBar.expanded);
- } else {
+ heartBeatAxis->setPos(itemPos.heartBeatWithTankBar.pos.on);
+ heartBeatAxis->animateChangeLine(itemPos.heartBeatWithTankBar.expanded);
+ }else {
percentageAxis->setPos(itemPos.percentage.pos.on);
- percentageAxis->setLine(itemPos.percentage.expanded);
+ percentageAxis->animateChangeLine(itemPos.percentage.expanded);
+ heartBeatAxis->setPos(itemPos.heartBeat.pos.on);
+ heartBeatAxis->animateChangeLine(itemPos.heartBeat.expanded);
}
gasYAxis->setPos(itemPos.partialPressureTissue.pos.on);
gasYAxis->animateChangeLine(itemPos.partialPressureTissue.expanded);
- if (prefs.hrgraph) {
- heartBeatAxis->setPos(itemPos.heartBeatAll.pos.on);
- heartBeatAxis->setLine(itemPos.heartBeatAll.expanded);
- }
+
} else if (PP_GRAPHS_ENABLED || prefs.hrgraph || prefs.percentagegraph) {
profileYAxis->animateChangeLine(itemPos.depth.intermediate);
temperatureAxis->setPos(itemPos.temperature.pos.on);
temperatureAxis->animateChangeLine(itemPos.temperature.intermediate);
cylinderPressureAxis->animateChangeLine(itemPos.cylinder.intermediate);
- gasYAxis->setPos(itemPos.partialPressure.pos.on);
- gasYAxis->animateChangeLine(itemPos.partialPressure.expanded);
- percentageAxis->setPos(itemPos.percentage.pos.on);
- percentageAxis->setLine(itemPos.percentage.expanded);
- heartBeatAxis->setPos(itemPos.heartBeat.pos.on);
- heartBeatAxis->setLine(itemPos.heartBeat.expanded);
if (prefs.tankbar) {
percentageAxis->setPos(itemPos.percentageWithTankBar.pos.on);
percentageAxis->animateChangeLine(itemPos.percentageWithTankBar.expanded);
gasYAxis->setPos(itemPos.partialPressureWithTankBar.pos.on);
gasYAxis->setLine(itemPos.partialPressureWithTankBar.expanded);
+ heartBeatAxis->setPos(itemPos.heartBeatWithTankBar.pos.on);
+ heartBeatAxis->animateChangeLine(itemPos.heartBeatWithTankBar.expanded);
} else {
gasYAxis->setPos(itemPos.partialPressure.pos.on);
gasYAxis->animateChangeLine(itemPos.partialPressure.expanded);
percentageAxis->setPos(itemPos.percentage.pos.on);
percentageAxis->setLine(itemPos.percentage.expanded);
+ heartBeatAxis->setPos(itemPos.heartBeat.pos.on);
+ heartBeatAxis->animateChangeLine(itemPos.heartBeat.expanded);
}
} else {
profileYAxis->animateChangeLine(itemPos.depth.expanded);
@@ -907,7 +905,7 @@ void ProfileWidget2::setProfileState()
cylinderPressureAxis->setVisible(true);
profileYAxis->setPos(itemPos.depth.pos.on);
- if (prefs.percentagegraph && PP_GRAPHS_ENABLED) {
+ if ((prefs.percentagegraph||prefs.hrgraph) && PP_GRAPHS_ENABLED) {
profileYAxis->animateChangeLine(itemPos.depth.shrinked);
temperatureAxis->setPos(itemPos.temperatureAll.pos.on);
temperatureAxis->animateChangeLine(itemPos.temperature.shrinked);
@@ -916,37 +914,36 @@ void ProfileWidget2::setProfileState()
if (prefs.tankbar) {
percentageAxis->setPos(itemPos.percentageWithTankBar.pos.on);
percentageAxis->animateChangeLine(itemPos.percentageWithTankBar.expanded);
- } else {
+ heartBeatAxis->setPos(itemPos.heartBeatWithTankBar.pos.on);
+ heartBeatAxis->animateChangeLine(itemPos.heartBeatWithTankBar.expanded);
+ }else {
percentageAxis->setPos(itemPos.percentage.pos.on);
- percentageAxis->setLine(itemPos.percentage.expanded);
+ percentageAxis->animateChangeLine(itemPos.percentage.expanded);
+ heartBeatAxis->setPos(itemPos.heartBeat.pos.on);
+ heartBeatAxis->animateChangeLine(itemPos.heartBeat.expanded);
}
gasYAxis->setPos(itemPos.partialPressureTissue.pos.on);
gasYAxis->animateChangeLine(itemPos.partialPressureTissue.expanded);
- if (prefs.hrgraph) {
- heartBeatAxis->setPos(itemPos.heartBeatAll.pos.on);
- heartBeatAxis->setLine(itemPos.heartBeatAll.expanded);
- }
+
} else if (PP_GRAPHS_ENABLED || prefs.hrgraph || prefs.percentagegraph) {
profileYAxis->animateChangeLine(itemPos.depth.intermediate);
temperatureAxis->setPos(itemPos.temperature.pos.on);
temperatureAxis->animateChangeLine(itemPos.temperature.intermediate);
cylinderPressureAxis->animateChangeLine(itemPos.cylinder.intermediate);
- gasYAxis->setPos(itemPos.partialPressure.pos.on);
- gasYAxis->animateChangeLine(itemPos.partialPressure.expanded);
- percentageAxis->setPos(itemPos.percentage.pos.on);
- percentageAxis->setLine(itemPos.percentage.expanded);
- heartBeatAxis->setPos(itemPos.heartBeat.pos.on);
- heartBeatAxis->setLine(itemPos.heartBeat.expanded);
if (prefs.tankbar) {
percentageAxis->setPos(itemPos.percentageWithTankBar.pos.on);
percentageAxis->animateChangeLine(itemPos.percentageWithTankBar.expanded);
gasYAxis->setPos(itemPos.partialPressureWithTankBar.pos.on);
gasYAxis->setLine(itemPos.partialPressureWithTankBar.expanded);
+ heartBeatAxis->setPos(itemPos.heartBeatWithTankBar.pos.on);
+ heartBeatAxis->animateChangeLine(itemPos.heartBeatWithTankBar.expanded);
} else {
gasYAxis->setPos(itemPos.partialPressure.pos.on);
gasYAxis->animateChangeLine(itemPos.partialPressure.expanded);
percentageAxis->setPos(itemPos.percentage.pos.on);
percentageAxis->setLine(itemPos.percentage.expanded);
+ heartBeatAxis->setPos(itemPos.heartBeat.pos.on);
+ heartBeatAxis->animateChangeLine(itemPos.heartBeat.expanded);
}
} else {
profileYAxis->animateChangeLine(itemPos.depth.expanded);
diff --git a/qt-ui/profile/tankitem.cpp b/qt-ui/profile/tankitem.cpp
index 48b586dd5..c0e75a371 100644
--- a/qt-ui/profile/tankitem.cpp
+++ b/qt-ui/profile/tankitem.cpp
@@ -50,7 +50,7 @@ void TankItem::setData(DivePlotDataModel *model, struct plot_info *plotInfo, str
memcpy(pInfoEntry, plotInfo->entry, size);
copy_cylinders(d, &diveCylinderStore, false);
dataModel = model;
- connect(dataModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(modelDataChanged(QModelIndex, QModelIndex)));
+ connect(dataModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(modelDataChanged(QModelIndex, QModelIndex)), Qt::UniqueConnection);
modelDataChanged();
}