mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
Transform GlobeGPS in a static instance() class
This is needed to start easing the transition from the completely wrong and bogus MainWindow::instance()->globe() calls. this is still wrong, but with it I removed one level of indirection. I did that now because I wanted to not taint the location management when I use it to deal with the globe. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
9130ff8a97
commit
7efa924067
6 changed files with 20 additions and 21 deletions
|
@ -24,6 +24,12 @@
|
|||
#include <marble/MarbleDebug.h>
|
||||
#endif
|
||||
|
||||
GlobeGPS *GlobeGPS::instance()
|
||||
{
|
||||
static GlobeGPS *self = new GlobeGPS();
|
||||
return self;
|
||||
}
|
||||
|
||||
GlobeGPS::GlobeGPS(QWidget *parent) : MarbleWidget(parent),
|
||||
loadedDives(0),
|
||||
messageWidget(new KMessageWidget(this)),
|
||||
|
@ -378,9 +384,9 @@ void GlobeGPS::centerOnIndex(const QModelIndex& idx)
|
|||
{
|
||||
struct dive_site *ds = get_dive_site_by_uuid(idx.model()->index(idx.row(), 0).data().toInt());
|
||||
if (!ds || !dive_site_has_gps_location(ds))
|
||||
MainWindow::instance()->globe()->centerOnDiveSite(&displayed_dive_site);
|
||||
centerOnDiveSite(&displayed_dive_site);
|
||||
else
|
||||
MainWindow::instance()->globe()->centerOnDiveSite(ds);
|
||||
centerOnDiveSite(ds);
|
||||
}
|
||||
#else
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class GlobeGPS : public MarbleWidget {
|
|||
Q_OBJECT
|
||||
public:
|
||||
using MarbleWidget::centerOn;
|
||||
GlobeGPS(QWidget *parent = 0);
|
||||
static GlobeGPS *instance();
|
||||
void reload();
|
||||
bool eventFilter(QObject *, QEvent *);
|
||||
|
||||
|
@ -38,6 +38,7 @@ private:
|
|||
bool needResetZoom;
|
||||
bool editingDiveLocation;
|
||||
bool doubleClick;
|
||||
GlobeGPS(QWidget *parent = 0);
|
||||
|
||||
signals:
|
||||
void coordinatesChanged();
|
||||
|
|
|
@ -463,7 +463,7 @@ void MainTab::updateDiveInfo(bool clear)
|
|||
// I don't like this code here - but globe() wasn't initialized on the constructor.
|
||||
{
|
||||
QListView *completerListview = qobject_cast<QListView*>(ui.location->completer()->popup());
|
||||
connect(completerListview, SIGNAL(entered(QModelIndex)), MainWindow::instance()->globe(), SLOT(centerOnIndex(QModelIndex)), Qt::UniqueConnection);
|
||||
connect(completerListview, SIGNAL(entered(QModelIndex)), GlobeGPS::instance(), SLOT(centerOnIndex(QModelIndex)), Qt::UniqueConnection);
|
||||
}
|
||||
|
||||
EditMode rememberEM = editMode;
|
||||
|
@ -1208,8 +1208,7 @@ void MainTab::rejectChanges()
|
|||
// the user could have edited the location and then canceled the edit
|
||||
// let's get the correct location back in view
|
||||
#ifndef NO_MARBLE
|
||||
MainWindow::instance()->globe()->centerOnDiveSite(get_dive_site_by_uuid(displayed_dive.dive_site_uuid));
|
||||
MainWindow::instance()->globe()->reload();
|
||||
GlobeGPS::instance()->centerOnDiveSite(get_dive_site_by_uuid(displayed_dive.dive_site_uuid));
|
||||
#endif
|
||||
// show the profile and dive info
|
||||
MainWindow::instance()->graphics()->replot();
|
||||
|
|
|
@ -73,7 +73,7 @@ MainWindow::MainWindow() : QMainWindow(),
|
|||
ProfileWidget2 *profileWidget = new ProfileWidget2();
|
||||
|
||||
#ifndef NO_MARBLE
|
||||
GlobeGPS *globeGps = new GlobeGPS();
|
||||
GlobeGPS *globeGps = GlobeGPS::instance();
|
||||
#else
|
||||
QWidget *globeGps = NULL;
|
||||
#endif
|
||||
|
@ -174,7 +174,7 @@ MainWindow::MainWindow() : QMainWindow(),
|
|||
diveListView->reload(DiveTripModel::TREE);
|
||||
diveListView->reloadHeaderActions();
|
||||
diveListView->setFocus();
|
||||
globe()->reload();
|
||||
GlobeGPS::instance()->reload();
|
||||
diveListView->expand(dive_list()->model()->index(0, 0));
|
||||
diveListView->scrollTo(dive_list()->model()->index(0, 0), QAbstractItemView::PositionAtCenter);
|
||||
divePlannerWidget()->settingsChanged();
|
||||
|
@ -258,7 +258,7 @@ void MainWindow::refreshDisplay(bool doRecreateDiveList)
|
|||
getNotificationWidget()->showNotification(get_error_string(), KMessageWidget::Error);
|
||||
information()->reload();
|
||||
TankInfoModel::instance()->update();
|
||||
globe()->reload();
|
||||
GlobeGPS::instance()->reload();
|
||||
if (doRecreateDiveList)
|
||||
recreateDiveList();
|
||||
|
||||
|
@ -286,7 +286,7 @@ void MainWindow::current_dive_changed(int divenr)
|
|||
}
|
||||
graphics()->plotDive();
|
||||
information()->updateDiveInfo();
|
||||
globe()->reload();
|
||||
GlobeGPS::instance()->reload();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionNew_triggered()
|
||||
|
@ -429,7 +429,7 @@ void MainWindow::cleanUpEmpty()
|
|||
information()->updateDiveInfo(true);
|
||||
graphics()->setEmptyState();
|
||||
dive_list()->reload(DiveTripModel::TREE);
|
||||
globe()->reload();
|
||||
GlobeGPS::instance()->reload();
|
||||
if (!existing_filename)
|
||||
setTitle(MWTF_DEFAULT);
|
||||
disableShortcuts();
|
||||
|
@ -741,7 +741,7 @@ void MainWindow::on_actionEditDive_triggered()
|
|||
disableShortcuts();
|
||||
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD);
|
||||
graphics()->setAddState();
|
||||
globe()->endGetDiveCoordinates();
|
||||
GlobeGPS::instance()->endGetDiveCoordinates();
|
||||
setApplicationState("EditDive");
|
||||
DivePlannerPointsModel::instance()->loadFromDive(current_dive);
|
||||
information()->enableEdition(MainTab::MANUALLY_ADDED_DIVE);
|
||||
|
@ -1179,11 +1179,6 @@ DiveListView *MainWindow::dive_list()
|
|||
return qobject_cast<DiveListView*>(applicationState["Default"].bottomLeft);
|
||||
}
|
||||
|
||||
GlobeGPS *MainWindow::globe()
|
||||
{
|
||||
return qobject_cast<GlobeGPS*>(applicationState["Default"].bottomRight);
|
||||
}
|
||||
|
||||
MainTab *MainWindow::information()
|
||||
{
|
||||
return qobject_cast<MainTab*>(applicationState["Default"].topLeft);
|
||||
|
|
|
@ -26,7 +26,6 @@ class Stats;
|
|||
class Equipment;
|
||||
class QItemSelection;
|
||||
class DiveListView;
|
||||
class GlobeGPS;
|
||||
class MainTab;
|
||||
class ProfileGraphicsView;
|
||||
class QWebView;
|
||||
|
@ -69,7 +68,6 @@ public:
|
|||
void addRecentFile(const QStringList &newFiles);
|
||||
void removeRecentFile(QStringList failedFiles);
|
||||
DiveListView *dive_list();
|
||||
GlobeGPS *globe();
|
||||
DivePlannerWidget *divePlannerWidget();
|
||||
PlannerSettingsWidget *divePlannerSettingsWidget();
|
||||
LocationInformationWidget *locationInformationWidget();
|
||||
|
|
|
@ -418,8 +418,8 @@ void SubsurfaceWebServices::buttonClicked(QAbstractButton *button)
|
|||
// finally now that all the extra GPS fixes that weren't used have been deleted
|
||||
// we can update the globe
|
||||
if (changed) {
|
||||
MainWindow::instance()->globe()->repopulateLabels();
|
||||
MainWindow::instance()->globe()->centerOnDiveSite(get_dive_site_by_uuid(current_dive->dive_site_uuid));
|
||||
GlobeGPS::instance()->repopulateLabels();
|
||||
GlobeGPS::instance()->centerOnDiveSite(get_dive_site_by_uuid(current_dive->dive_site_uuid));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue