maintab: use GlobeGPS / MapWidget abstraction

Based on NO_MARBLE, call the same methods in the two different classes.
Later the dummy Marble GlobeGPS (for NO_MARBLE) should be removed.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
Lubomir I. Ivanov 2017-07-15 23:37:02 +03:00 committed by Dirk Hohndel
parent 4334d33413
commit ae52e2a272

View file

@ -8,6 +8,7 @@
#include "desktop-widgets/tab-widgets/maintab.h" #include "desktop-widgets/tab-widgets/maintab.h"
#include "desktop-widgets/mainwindow.h" #include "desktop-widgets/mainwindow.h"
#include "desktop-widgets/globe.h" #include "desktop-widgets/globe.h"
#include "desktop-widgets/mapwidget.h"
#include "core/helpers.h" #include "core/helpers.h"
#include "core/statistics.h" #include "core/statistics.h"
#include "desktop-widgets/modeldelegates.h" #include "desktop-widgets/modeldelegates.h"
@ -74,6 +75,9 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
#ifndef NO_MARBLE #ifndef NO_MARBLE
connect(ui.location, &DiveLocationLineEdit::entered, GlobeGPS::instance(), &GlobeGPS::centerOnIndex); connect(ui.location, &DiveLocationLineEdit::entered, GlobeGPS::instance(), &GlobeGPS::centerOnIndex);
connect(ui.location, &DiveLocationLineEdit::currentChanged, GlobeGPS::instance(), &GlobeGPS::centerOnIndex); connect(ui.location, &DiveLocationLineEdit::currentChanged, GlobeGPS::instance(), &GlobeGPS::centerOnIndex);
#else
connect(ui.location, &DiveLocationLineEdit::entered, MapWidget::instance(), &MapWidget::centerOnIndex);
connect(ui.location, &DiveLocationLineEdit::currentChanged, MapWidget::instance(), &MapWidget::centerOnIndex);
#endif #endif
QAction *action = new QAction(tr("Apply changes"), this); QAction *action = new QAction(tr("Apply changes"), this);
@ -907,7 +911,11 @@ void MainTab::acceptChanges()
qDebug() << "delete now unused dive site" << ((ds && ds->name) ? ds->name : "without name"); qDebug() << "delete now unused dive site" << ((ds && ds->name) ? ds->name : "without name");
} }
delete_dive_site(oldUuid); delete_dive_site(oldUuid);
#ifndef NO_MARBLE
GlobeGPS::instance()->reload(); GlobeGPS::instance()->reload();
#else
MapWidget::instance()->reload();
#endif
} }
// the code above can change the correct uuid for the displayed dive site - and the // the code above can change the correct uuid for the displayed dive site - and the
// code below triggers an update of the display without re-initializing displayed_dive // code below triggers an update of the display without re-initializing displayed_dive
@ -1041,6 +1049,8 @@ void MainTab::rejectChanges()
// let's get the correct location back in view // let's get the correct location back in view
#ifndef NO_MARBLE #ifndef NO_MARBLE
GlobeGPS::instance()->centerOnDiveSite(get_dive_site_by_uuid(displayed_dive.dive_site_uuid)); GlobeGPS::instance()->centerOnDiveSite(get_dive_site_by_uuid(displayed_dive.dive_site_uuid));
#else
MapWidget::instance()->centerOnDiveSite(get_dive_site_by_uuid(displayed_dive.dive_site_uuid));
#endif #endif
// show the profile and dive info // show the profile and dive info
MainWindow::instance()->graphics()->replot(); MainWindow::instance()->graphics()->replot();