Merge branch 'latestmaster'

This commit is contained in:
Dirk Hohndel 2015-01-19 18:15:03 +12:00
commit de9acbd30d
10 changed files with 72 additions and 60 deletions

View file

@ -181,6 +181,7 @@ DiveHandler::DiveHandler() : QGraphicsEllipseItem()
setFlags(ItemIgnoresTransformations | ItemIsSelectable | ItemIsMovable | ItemSendsGeometryChanges); setFlags(ItemIgnoresTransformations | ItemIsSelectable | ItemIsMovable | ItemSendsGeometryChanges);
setBrush(Qt::white); setBrush(Qt::white);
setZValue(2); setZValue(2);
t.start();
} }
int DiveHandler::parentIndex() int DiveHandler::parentIndex()
@ -225,9 +226,14 @@ void DiveHandler::changeGas()
void DiveHandler::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void DiveHandler::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
if (t.elapsed() < 40)
return;
t.start();
ProfileWidget2 *view = qobject_cast<ProfileWidget2*>(scene()->views().first()); ProfileWidget2 *view = qobject_cast<ProfileWidget2*>(scene()->views().first());
if(view->isPointOutOfBoundaries(event->scenePos())) if(view->isPointOutOfBoundaries(event->scenePos()))
return; return;
QGraphicsEllipseItem::mouseMoveEvent(event); QGraphicsEllipseItem::mouseMoveEvent(event);
emit moved(); emit moved();
} }

View file

@ -133,6 +133,8 @@ public
slots: slots:
void selfRemove(); void selfRemove();
void changeGas(); void changeGas();
private:
QTime t;
}; };
#include "ui_diveplanner.h" #include "ui_diveplanner.h"

View file

@ -187,9 +187,17 @@ void GlobeGPS::repopulateLabels()
loadedDives = new GeoDataDocument; loadedDives = new GeoDataDocument;
QMap<QString, GeoDataPlacemark *> locationMap; QMap<QString, GeoDataPlacemark *> locationMap;
int idx = 0; int idx = -2;
struct dive *dive; 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)) { if (dive_has_gps_location(dive)) {
GeoDataPlacemark *place = new GeoDataPlacemark(dive->location); GeoDataPlacemark *place = new GeoDataPlacemark(dive->location);
place->setCoordinate(dive->longitude.udeg / 1000000.0, dive->latitude.udeg / 1000000.0, 0, GeoDataCoordinates::Degree); 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; lon = lon * 180 / M_PI;
lat = lat * 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); 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; editingDiveLocation = false;
mark_divelist_changed(true);
MainWindow::instance()->refreshDisplay();
} }
void GlobeGPS::mousePressEvent(QMouseEvent *event) void GlobeGPS::mousePressEvent(QMouseEvent *event)

View file

@ -39,6 +39,9 @@ private:
bool editingDiveLocation; bool editingDiveLocation;
bool doubleClick; bool doubleClick;
signals:
void coordinatesChanged(void);
public public
slots: slots:
void changeDiveGeoPosition(qreal lon, qreal lat, GeoDataCoordinates::Unit); void changeDiveGeoPosition(qreal lon, qreal lat, GeoDataCoordinates::Unit);

View file

@ -428,7 +428,7 @@ void MainTab::updateDiveInfo(bool clear)
ui.DiveType->setCurrentIndex(displayed_dive.dc.divemode); ui.DiveType->setCurrentIndex(displayed_dive.dc.divemode);
if (!clear) { if (!clear) {
updateGpsCoordinates(&displayed_dive); updateGpsCoordinates();
// Subsurface always uses "local time" as in "whatever was the local time at the location" // 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 // 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)); QDateTime localTime = QDateTime::fromTime_t(displayed_dive.when - gettimezoneoffset(displayed_dive.when));
@ -750,7 +750,7 @@ void MainTab::acceptChanges()
} }
struct dive *cd = current_dive; struct dive *cd = current_dive;
//Reset coordinates field, in case it contains garbage. //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 // 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) // were identical with the master dive shown (and mark the divelist as changed)
if (!same_string(displayed_dive.buddy, cd->buddy)) if (!same_string(displayed_dive.buddy, cd->buddy))
@ -1137,7 +1137,7 @@ void MainTab::on_location_editingFinished()
displayed_dive.latitude = dive->latitude; displayed_dive.latitude = dive->latitude;
displayed_dive.longitude = dive->longitude; displayed_dive.longitude = dive->longitude;
MainWindow::instance()->globe()->reload(); MainWindow::instance()->globe()->reload();
updateGpsCoordinates(&displayed_dive); updateGpsCoordinates();
break; break;
} }
} }
@ -1244,14 +1244,13 @@ void MainTab::updateCoordinatesText(qreal lat, qreal lon)
ui.coordinates->setText(printGPSCoords(ulat, ulon)); ui.coordinates->setText(printGPSCoords(ulat, ulon));
} }
void MainTab::updateGpsCoordinates(const struct dive *dive) void MainTab::updateGpsCoordinates()
{ {
if (dive) { if (editMode == NONE)
ui.coordinates->setText(printGPSCoords(dive->latitude.udeg, dive->longitude.udeg)); enableEdition();
ui.coordinates->setModified(dive->latitude.udeg || dive->longitude.udeg);
} else { ui.coordinates->setText(printGPSCoords(displayed_dive.latitude.udeg, displayed_dive.longitude.udeg));
ui.coordinates->clear(); ui.coordinates->setModified(displayed_dive.latitude.udeg || displayed_dive.longitude.udeg);
}
} }
void MainTab::escDetected() void MainTab::escDetected()
@ -1300,7 +1299,7 @@ void MainTab::showAndTriggerEditSelective(struct dive_components what)
if (what.visibility) if (what.visibility)
ui.visibility->setCurrentStars(displayed_dive.visibility); ui.visibility->setCurrentStars(displayed_dive.visibility);
if (what.gps) if (what.gps)
updateGpsCoordinates(&displayed_dive); updateGpsCoordinates();
if (what.tags) { if (what.tags) {
char buf[1024]; char buf[1024];
taglist_get_tagstring(displayed_dive.tag_list, buf, 1024); taglist_get_tagstring(displayed_dive.tag_list, buf, 1024);

View file

@ -92,6 +92,8 @@ slots:
void escDetected(void); void escDetected(void);
void photoDoubleClicked(const QString filePath); void photoDoubleClicked(const QString filePath);
void removeSelectedPhotos(); void removeSelectedPhotos();
void updateGpsCoordinates();
private: private:
Ui::MainTab ui; Ui::MainTab ui;
WeightModel *weightModel; WeightModel *weightModel;
@ -109,7 +111,6 @@ private:
bool copyPaste; bool copyPaste;
void resetPallete(); void resetPallete();
void saveTags(); void saveTags();
void updateGpsCoordinates(const struct dive *dive);
void markChangedWidget(QWidget *w); void markChangedWidget(QWidget *w);
dive_trip_t *currentTrip; dive_trip_t *currentTrip;
dive_trip_t displayedTrip; dive_trip_t displayedTrip;

View file

@ -96,6 +96,8 @@ MainWindow::MainWindow() : QMainWindow(),
#ifdef NO_MARBLE #ifdef NO_MARBLE
ui.globePane->hide(); ui.globePane->hide();
ui.menuView->removeAction(ui.actionViewGlobe); ui.menuView->removeAction(ui.actionViewGlobe);
#else
connect(ui.globe, SIGNAL(coordinatesChanged()), ui.InfoWidget, SLOT(updateGpsCoordinates()));
#endif #endif
#ifdef NO_USERMANUAL #ifdef NO_USERMANUAL
ui.menuHelp->removeAction(ui.actionUserManual); ui.menuHelp->removeAction(ui.actionUserManual);

View file

@ -2,6 +2,7 @@
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QPicture> #include <QPicture>
#include <QMessageBox> #include <QMessageBox>
#include <QPointer>
#include "mainwindow.h" #include "mainwindow.h"
#include "printdialog.h" #include "printdialog.h"

View file

@ -15,6 +15,7 @@
#include <QtCore/qmath.h> #include <QtCore/qmath.h>
#include <QMessageBox> #include <QMessageBox>
#include <QInputDialog> #include <QInputDialog>
#include <QDebug>
#ifndef QT_NO_DEBUG #ifndef QT_NO_DEBUG
#include <QTableView> #include <QTableView>
@ -55,7 +56,7 @@ static struct _ItemPos {
_Axis temperature; _Axis temperature;
_Axis temperatureAll; _Axis temperatureAll;
_Axis heartBeat; _Axis heartBeat;
_Axis heartBeatAll; _Axis heartBeatWithTankBar;
} itemPos; } itemPos;
ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent), ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent),
@ -396,13 +397,11 @@ void ProfileWidget2::setupItemSizes()
// Heartbeat axis config // Heartbeat axis config
itemPos.heartBeat.pos.on.setX(3); 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.setP1(QPointF(0, 0));
itemPos.heartBeat.expanded.setP2(QPointF(0, 10)); itemPos.heartBeat.expanded.setP2(QPointF(0, 10));
itemPos.heartBeatAll = itemPos.heartBeat; itemPos.heartBeatWithTankBar = itemPos.heartBeat;
itemPos.heartBeatAll.pos.on.setX(3); itemPos.heartBeatWithTankBar.expanded.setP2(QPointF(0, 7));
itemPos.heartBeatAll.pos.on.setY(55);
itemPos.heartBeatAll.expanded.setP2(QPointF(0, 7));
// Percentage axis config // Percentage axis config
itemPos.percentage.pos.on.setX(3); itemPos.percentage.pos.on.setX(3);
@ -635,7 +634,7 @@ void ProfileWidget2::settingsChanged()
// if we are showing calculated ceilings then we have to replot() // if we are showing calculated ceilings then we have to replot()
// because the GF could have changed; otherwise we try to avoid replot() // because the GF could have changed; otherwise we try to avoid replot()
bool needReplot = prefs.calcceiling; bool needReplot = prefs.calcceiling;
if (prefs.percentagegraph && PP_GRAPHS_ENABLED) { if ((prefs.percentagegraph||prefs.hrgraph) && PP_GRAPHS_ENABLED) {
profileYAxis->animateChangeLine(itemPos.depth.shrinked); profileYAxis->animateChangeLine(itemPos.depth.shrinked);
temperatureAxis->setPos(itemPos.temperatureAll.pos.on); temperatureAxis->setPos(itemPos.temperatureAll.pos.on);
temperatureAxis->animateChangeLine(itemPos.temperature.shrinked); temperatureAxis->animateChangeLine(itemPos.temperature.shrinked);
@ -644,37 +643,36 @@ void ProfileWidget2::settingsChanged()
if (prefs.tankbar) { if (prefs.tankbar) {
percentageAxis->setPos(itemPos.percentageWithTankBar.pos.on); percentageAxis->setPos(itemPos.percentageWithTankBar.pos.on);
percentageAxis->animateChangeLine(itemPos.percentageWithTankBar.expanded); 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->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->setPos(itemPos.partialPressureTissue.pos.on);
gasYAxis->animateChangeLine(itemPos.partialPressureTissue.expanded); 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) { } else if (PP_GRAPHS_ENABLED || prefs.hrgraph || prefs.percentagegraph) {
profileYAxis->animateChangeLine(itemPos.depth.intermediate); profileYAxis->animateChangeLine(itemPos.depth.intermediate);
temperatureAxis->setPos(itemPos.temperature.pos.on); temperatureAxis->setPos(itemPos.temperature.pos.on);
temperatureAxis->animateChangeLine(itemPos.temperature.intermediate); temperatureAxis->animateChangeLine(itemPos.temperature.intermediate);
cylinderPressureAxis->animateChangeLine(itemPos.cylinder.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) { if (prefs.tankbar) {
percentageAxis->setPos(itemPos.percentageWithTankBar.pos.on); percentageAxis->setPos(itemPos.percentageWithTankBar.pos.on);
percentageAxis->animateChangeLine(itemPos.percentageWithTankBar.expanded); percentageAxis->animateChangeLine(itemPos.percentageWithTankBar.expanded);
gasYAxis->setPos(itemPos.partialPressureWithTankBar.pos.on); gasYAxis->setPos(itemPos.partialPressureWithTankBar.pos.on);
gasYAxis->setLine(itemPos.partialPressureWithTankBar.expanded); gasYAxis->setLine(itemPos.partialPressureWithTankBar.expanded);
heartBeatAxis->setPos(itemPos.heartBeatWithTankBar.pos.on);
heartBeatAxis->animateChangeLine(itemPos.heartBeatWithTankBar.expanded);
} else { } else {
gasYAxis->setPos(itemPos.partialPressure.pos.on); gasYAxis->setPos(itemPos.partialPressure.pos.on);
gasYAxis->animateChangeLine(itemPos.partialPressure.expanded); gasYAxis->animateChangeLine(itemPos.partialPressure.expanded);
percentageAxis->setPos(itemPos.percentage.pos.on); percentageAxis->setPos(itemPos.percentage.pos.on);
percentageAxis->setLine(itemPos.percentage.expanded); percentageAxis->setLine(itemPos.percentage.expanded);
heartBeatAxis->setPos(itemPos.heartBeat.pos.on);
heartBeatAxis->animateChangeLine(itemPos.heartBeat.expanded);
} }
} else { } else {
profileYAxis->animateChangeLine(itemPos.depth.expanded); profileYAxis->animateChangeLine(itemPos.depth.expanded);
@ -907,7 +905,7 @@ void ProfileWidget2::setProfileState()
cylinderPressureAxis->setVisible(true); cylinderPressureAxis->setVisible(true);
profileYAxis->setPos(itemPos.depth.pos.on); 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); profileYAxis->animateChangeLine(itemPos.depth.shrinked);
temperatureAxis->setPos(itemPos.temperatureAll.pos.on); temperatureAxis->setPos(itemPos.temperatureAll.pos.on);
temperatureAxis->animateChangeLine(itemPos.temperature.shrinked); temperatureAxis->animateChangeLine(itemPos.temperature.shrinked);
@ -916,37 +914,36 @@ void ProfileWidget2::setProfileState()
if (prefs.tankbar) { if (prefs.tankbar) {
percentageAxis->setPos(itemPos.percentageWithTankBar.pos.on); percentageAxis->setPos(itemPos.percentageWithTankBar.pos.on);
percentageAxis->animateChangeLine(itemPos.percentageWithTankBar.expanded); 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->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->setPos(itemPos.partialPressureTissue.pos.on);
gasYAxis->animateChangeLine(itemPos.partialPressureTissue.expanded); 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) { } else if (PP_GRAPHS_ENABLED || prefs.hrgraph || prefs.percentagegraph) {
profileYAxis->animateChangeLine(itemPos.depth.intermediate); profileYAxis->animateChangeLine(itemPos.depth.intermediate);
temperatureAxis->setPos(itemPos.temperature.pos.on); temperatureAxis->setPos(itemPos.temperature.pos.on);
temperatureAxis->animateChangeLine(itemPos.temperature.intermediate); temperatureAxis->animateChangeLine(itemPos.temperature.intermediate);
cylinderPressureAxis->animateChangeLine(itemPos.cylinder.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) { if (prefs.tankbar) {
percentageAxis->setPos(itemPos.percentageWithTankBar.pos.on); percentageAxis->setPos(itemPos.percentageWithTankBar.pos.on);
percentageAxis->animateChangeLine(itemPos.percentageWithTankBar.expanded); percentageAxis->animateChangeLine(itemPos.percentageWithTankBar.expanded);
gasYAxis->setPos(itemPos.partialPressureWithTankBar.pos.on); gasYAxis->setPos(itemPos.partialPressureWithTankBar.pos.on);
gasYAxis->setLine(itemPos.partialPressureWithTankBar.expanded); gasYAxis->setLine(itemPos.partialPressureWithTankBar.expanded);
heartBeatAxis->setPos(itemPos.heartBeatWithTankBar.pos.on);
heartBeatAxis->animateChangeLine(itemPos.heartBeatWithTankBar.expanded);
} else { } else {
gasYAxis->setPos(itemPos.partialPressure.pos.on); gasYAxis->setPos(itemPos.partialPressure.pos.on);
gasYAxis->animateChangeLine(itemPos.partialPressure.expanded); gasYAxis->animateChangeLine(itemPos.partialPressure.expanded);
percentageAxis->setPos(itemPos.percentage.pos.on); percentageAxis->setPos(itemPos.percentage.pos.on);
percentageAxis->setLine(itemPos.percentage.expanded); percentageAxis->setLine(itemPos.percentage.expanded);
heartBeatAxis->setPos(itemPos.heartBeat.pos.on);
heartBeatAxis->animateChangeLine(itemPos.heartBeat.expanded);
} }
} else { } else {
profileYAxis->animateChangeLine(itemPos.depth.expanded); profileYAxis->animateChangeLine(itemPos.depth.expanded);

View file

@ -50,7 +50,7 @@ void TankItem::setData(DivePlotDataModel *model, struct plot_info *plotInfo, str
memcpy(pInfoEntry, plotInfo->entry, size); memcpy(pInfoEntry, plotInfo->entry, size);
copy_cylinders(d, &diveCylinderStore, false); copy_cylinders(d, &diveCylinderStore, false);
dataModel = model; 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(); modelDataChanged();
} }