mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Attempt to fix the 'click goes to 0,0' thing on the globe.
This patch attempts to fix the 'click goes to 0,0' bug on the globe. it moves a bit of code around and I particulary don't like the way that we are dealing with 'EditMode', I think I'll refactor that for 4.1. We are alredy dealing with a bunch of states, maybe a State Machine will help on removing code-complexity. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
d128b74a8a
commit
9190c97a3c
3 changed files with 15 additions and 16 deletions
|
@ -197,23 +197,21 @@ void GlobeGPS::reload()
|
||||||
{
|
{
|
||||||
editingDiveLocation = false;
|
editingDiveLocation = false;
|
||||||
if (messageWidget->isVisible())
|
if (messageWidget->isVisible())
|
||||||
messageWidget->animatedHide();
|
messageWidget->hide();
|
||||||
repopulateLabels();
|
repopulateLabels();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobeGPS::centerOn(dive* dive)
|
void GlobeGPS::centerOn(dive* dive)
|
||||||
{
|
{
|
||||||
// dive has changed, if we had the 'editingDive', hide it.
|
// dive has changed, if we had the 'editingDive', hide it.
|
||||||
if (messageWidget->isVisible() && (!dive || dive_has_gps_location(dive))) {
|
if (messageWidget->isVisible() && (!dive || dive_has_gps_location(dive)))
|
||||||
messageWidget->animatedHide();
|
messageWidget->hide();
|
||||||
}
|
|
||||||
if (!dive)
|
if (!dive)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
qreal longitude = dive->longitude.udeg / 1000000.0;
|
qreal longitude = dive->longitude.udeg / 1000000.0;
|
||||||
qreal latitude = dive->latitude.udeg / 1000000.0;
|
qreal latitude = dive->latitude.udeg / 1000000.0;
|
||||||
|
|
||||||
if (!longitude || !latitude) {
|
if (!longitude || !latitude || mainWindow()->information()->isEditing()) {
|
||||||
prepareForGetDiveCoordinates();
|
prepareForGetDiveCoordinates();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -241,7 +239,7 @@ void GlobeGPS::prepareForGetDiveCoordinates()
|
||||||
{
|
{
|
||||||
if (!messageWidget->isVisible()) {
|
if (!messageWidget->isVisible()) {
|
||||||
messageWidget->setMessageType(KMessageWidget::Warning);
|
messageWidget->setMessageType(KMessageWidget::Warning);
|
||||||
messageWidget->setText(QObject::tr("No location data - move the map and double-click to set the dive location"));
|
messageWidget->setText(QObject::tr("Move the map and double-click to set the dive location"));
|
||||||
messageWidget->setWordWrap(true);
|
messageWidget->setWordWrap(true);
|
||||||
messageWidget->animatedShow();
|
messageWidget->animatedShow();
|
||||||
editingDiveLocation = true;
|
editingDiveLocation = true;
|
||||||
|
@ -250,6 +248,8 @@ void GlobeGPS::prepareForGetDiveCoordinates()
|
||||||
|
|
||||||
void GlobeGPS::changeDiveGeoPosition(qreal lon, qreal lat, GeoDataCoordinates::Unit unit)
|
void GlobeGPS::changeDiveGeoPosition(qreal lon, qreal lat, GeoDataCoordinates::Unit unit)
|
||||||
{
|
{
|
||||||
|
messageWidget->hide();
|
||||||
|
|
||||||
if (mainWindow()->dive_list()->selectionModel()->selection().isEmpty())
|
if (mainWindow()->dive_list()->selectionModel()->selection().isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -271,7 +271,6 @@ void GlobeGPS::changeDiveGeoPosition(qreal lon, qreal lat, GeoDataCoordinates::U
|
||||||
centerOn(lon, lat, true);
|
centerOn(lon, lat, true);
|
||||||
editingDiveLocation = false;
|
editingDiveLocation = false;
|
||||||
mark_divelist_changed(TRUE);
|
mark_divelist_changed(TRUE);
|
||||||
messageWidget->animatedHide();
|
|
||||||
mainWindow()->refreshDisplay();
|
mainWindow()->refreshDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -602,11 +602,6 @@ void MainTab::acceptChanges()
|
||||||
else if (selected_dive == dive_table.nr - 1 && get_dive(dive_table.nr - 2)->number)
|
else if (selected_dive == dive_table.nr - 1 && get_dive(dive_table.nr - 2)->number)
|
||||||
current_dive->number = get_dive(dive_table.nr - 2)->number + 1;
|
current_dive->number = get_dive(dive_table.nr - 2)->number + 1;
|
||||||
DivePlannerPointsModel::instance()->cancelPlan();
|
DivePlannerPointsModel::instance()->cancelPlan();
|
||||||
// now make sure the selection logic is in a sane state
|
|
||||||
// it's ok to hold on to the dive pointer for this short stretch of code
|
|
||||||
// unselectDives() doesn't mess with the dive_table at all
|
|
||||||
mainWindow()->dive_list()->unselectDives();
|
|
||||||
mainWindow()->dive_list()->selectDive(selected_dive, true, true);
|
|
||||||
mainWindow()->showProfile();
|
mainWindow()->showProfile();
|
||||||
mark_divelist_changed(TRUE);
|
mark_divelist_changed(TRUE);
|
||||||
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::NOTHING);
|
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::NOTHING);
|
||||||
|
@ -619,7 +614,7 @@ void MainTab::acceptChanges()
|
||||||
}
|
}
|
||||||
|
|
||||||
resetPallete();
|
resetPallete();
|
||||||
if(editMode == ADD){
|
if(editMode == ADD || editMode == MANUALLY_ADDED_DIVE){
|
||||||
mainWindow()->dive_list()->unselectDives();
|
mainWindow()->dive_list()->unselectDives();
|
||||||
struct dive *d = get_dive(dive_table.nr -1 );
|
struct dive *d = get_dive(dive_table.nr -1 );
|
||||||
// HACK. this shouldn't be here. but apparently it's
|
// HACK. this shouldn't be here. but apparently it's
|
||||||
|
@ -630,14 +625,16 @@ void MainTab::acceptChanges()
|
||||||
for_each_dive(i,d){
|
for_each_dive(i,d){
|
||||||
if (d->selected) break;
|
if (d->selected) break;
|
||||||
}
|
}
|
||||||
|
editMode = NONE;
|
||||||
|
mainWindow()->refreshDisplay();
|
||||||
mainWindow()->dive_list()->selectDive( i, true );
|
mainWindow()->dive_list()->selectDive( i, true );
|
||||||
}else{
|
}else{
|
||||||
|
editMode = NONE;
|
||||||
mainWindow()->dive_list()->rememberSelection();
|
mainWindow()->dive_list()->rememberSelection();
|
||||||
sort_table(&dive_table);
|
sort_table(&dive_table);
|
||||||
mainWindow()->refreshDisplay();
|
mainWindow()->refreshDisplay();
|
||||||
mainWindow()->dive_list()->restoreSelection();
|
mainWindow()->dive_list()->restoreSelection();
|
||||||
}
|
}
|
||||||
editMode = NONE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainTab::resetPallete()
|
void MainTab::resetPallete()
|
||||||
|
|
|
@ -295,6 +295,9 @@ void MainWindow::on_actionAddDive_triggered()
|
||||||
struct dive *dive = alloc_dive();
|
struct dive *dive = alloc_dive();
|
||||||
dive->when = QDateTime::currentMSecsSinceEpoch() / 1000L + gettimezoneoffset();
|
dive->when = QDateTime::currentMSecsSinceEpoch() / 1000L + gettimezoneoffset();
|
||||||
dive->dc.model = "manually added dive"; // don't translate! this is stored in the XML file
|
dive->dc.model = "manually added dive"; // don't translate! this is stored in the XML file
|
||||||
|
|
||||||
|
dive->latitude.udeg = 0;
|
||||||
|
dive->longitude.udeg = 0;
|
||||||
record_dive(dive);
|
record_dive(dive);
|
||||||
// this isn't in the UI yet, so let's call the C helper function - we'll fix this up when
|
// this isn't in the UI yet, so let's call the C helper function - we'll fix this up when
|
||||||
// accepting the dive
|
// accepting the dive
|
||||||
|
@ -306,7 +309,7 @@ void MainWindow::on_actionAddDive_triggered()
|
||||||
ui.infoPane->setCurrentIndex(MAINTAB);
|
ui.infoPane->setCurrentIndex(MAINTAB);
|
||||||
DivePlannerPointsModel::instance()->clear();
|
DivePlannerPointsModel::instance()->clear();
|
||||||
DivePlannerPointsModel::instance()->createSimpleDive();
|
DivePlannerPointsModel::instance()->createSimpleDive();
|
||||||
refreshDisplay();
|
ui.ListWidget->reload(DiveTripModel::CURRENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionRenumber_triggered()
|
void MainWindow::on_actionRenumber_triggered()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue