Dive site rewrite: remove a ton of code from the LocationManagement

The way I was doing the old location management was very dull: everything
was tangled on the mainwindow. Now I think I've found the correct way to
create this, and thus, this code can die.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2015-06-26 12:58:47 -03:00 committed by Dirk Hohndel
parent 4c7ce4aa1d
commit 266e754d08
2 changed files with 1 additions and 35 deletions

View file

@ -38,7 +38,6 @@
#include "divelogexportdialog.h" #include "divelogexportdialog.h"
#include "usersurvey.h" #include "usersurvey.h"
#include "divesitehelpers.h" #include "divesitehelpers.h"
#include "locationinformation.h"
#include "windowtitleupdate.h" #include "windowtitleupdate.h"
#ifndef NO_USERMANUAL #ifndef NO_USERMANUAL
#include "usermanual.h" #include "usermanual.h"
@ -80,7 +79,6 @@ MainWindow::MainWindow() : QMainWindow(),
PlannerSettingsWidget *plannerSettings = new PlannerSettingsWidget(); PlannerSettingsWidget *plannerSettings = new PlannerSettingsWidget();
DivePlannerWidget *plannerWidget = new DivePlannerWidget(); DivePlannerWidget *plannerWidget = new DivePlannerWidget();
PlannerDetails *plannerDetails = new PlannerDetails(); PlannerDetails *plannerDetails = new PlannerDetails();
LocationInformationWidget *locationInformation = new LocationInformationWidget();
// what is a sane order for those icons? we should have the ones the user is // what is a sane order for those icons? we should have the ones the user is
// most likely to want towards the top so they are always visible // most likely to want towards the top so they are always visible
@ -109,14 +107,11 @@ MainWindow::MainWindow() : QMainWindow(),
profLayout->addWidget(toolBar); profLayout->addWidget(toolBar);
profLayout->addWidget(profileWidget); profLayout->addWidget(profileWidget);
profileContainer->setLayout(profLayout); profileContainer->setLayout(profLayout);
DivePictureWidget *divePictures = new DivePictureWidget(this);
divePictures->setModel(DivePictureModel::instance());
registerApplicationState("Default", mainTab, profileContainer, diveListView, globeGps ); registerApplicationState("Default", mainTab, profileContainer, diveListView, globeGps );
registerApplicationState("AddDive", mainTab, profileContainer, diveListView, globeGps ); registerApplicationState("AddDive", mainTab, profileContainer, diveListView, globeGps );
registerApplicationState("EditDive", mainTab, profileContainer, diveListView, globeGps ); registerApplicationState("EditDive", mainTab, profileContainer, diveListView, globeGps );
registerApplicationState("PlanDive", plannerWidget, profileContainer, plannerSettings, plannerDetails ); registerApplicationState("PlanDive", plannerWidget, profileContainer, plannerSettings, plannerDetails );
registerApplicationState("EditPlannedDive", plannerWidget, profileContainer, diveListView, globeGps ); registerApplicationState("EditPlannedDive", plannerWidget, profileContainer, diveListView, globeGps );
registerApplicationState("EditDiveSite",locationInformation, divePictures, diveListView, globeGps );
setApplicationState("Default"); setApplicationState("Default");
@ -143,11 +138,6 @@ MainWindow::MainWindow() : QMainWindow(),
connect(DivePlannerPointsModel::instance(), SIGNAL(planCanceled()), this, SLOT(planCanceled())); connect(DivePlannerPointsModel::instance(), SIGNAL(planCanceled()), this, SLOT(planCanceled()));
connect(plannerDetails->printPlan(), SIGNAL(pressed()), divePlannerWidget(), SLOT(printDecoPlan())); connect(plannerDetails->printPlan(), SIGNAL(pressed()), divePlannerWidget(), SLOT(printDecoPlan()));
connect(mainTab, SIGNAL(requestDiveSiteAdd()), this, SLOT(enableDiveSiteCreation())); connect(mainTab, SIGNAL(requestDiveSiteAdd()), this, SLOT(enableDiveSiteCreation()));
connect(locationInformation, SIGNAL(informationManagementEnded()), this, SLOT(setDefaultState()));
connect(locationInformation, SIGNAL(informationManagementEnded()), information(), SLOT(showLocation()));
connect(locationInformation, SIGNAL(coordinatesChanged()), globe(), SLOT(repopulateLabels()));
connect(locationInformation, SIGNAL(startEditDiveSite(uint32_t)), globeGps, SLOT(prepareForGetDiveCoordinates()));
connect(locationInformation, SIGNAL(endEditDiveSite()), globeGps, SLOT(prepareForGetDiveCoordinates()));
connect(information(), SIGNAL(diveSiteChanged(uint32_t)), globeGps, SLOT(centerOnDiveSite(uint32_t))); connect(information(), SIGNAL(diveSiteChanged(uint32_t)), globeGps, SLOT(centerOnDiveSite(uint32_t)));
wtu = new WindowTitleUpdate(); wtu = new WindowTitleUpdate();
connect(WindowTitleUpdate::instance(), SIGNAL(updateTitle()), this, SLOT(setAutomaticTitle())); connect(WindowTitleUpdate::instance(), SIGNAL(updateTitle()), this, SLOT(setAutomaticTitle()));
@ -177,8 +167,6 @@ MainWindow::MainWindow() : QMainWindow(),
divePlannerSettingsWidget()->settingsChanged(); divePlannerSettingsWidget()->settingsChanged();
#ifdef NO_MARBLE #ifdef NO_MARBLE
ui.menuView->removeAction(ui.actionViewGlobe); ui.menuView->removeAction(ui.actionViewGlobe);
#else
connect(globe(), SIGNAL(coordinatesChanged()), locationInformation, SLOT(updateGpsCoordinates()));
#endif #endif
#ifdef NO_USERMANUAL #ifdef NO_USERMANUAL
ui.menuHelp->removeAction(ui.actionUserManual); ui.menuHelp->removeAction(ui.actionUserManual);
@ -224,24 +212,6 @@ PlannerSettingsWidget *MainWindow::divePlannerSettingsWidget() {
return qobject_cast<PlannerSettingsWidget*>(applicationState["PlanDive"].bottomLeft); return qobject_cast<PlannerSettingsWidget*>(applicationState["PlanDive"].bottomLeft);
} }
LocationInformationWidget *MainWindow::locationInformationWidget() {
return qobject_cast<LocationInformationWidget*>(applicationState["EditDiveSite"].topLeft);
}
void MainWindow::on_actionManage_dive_sites_triggered() {
enableDiveSiteEdit(displayed_dive.dive_site_uuid);
}
void MainWindow::enableDiveSiteCreation() {
locationInformationWidget()->createDiveSite();
setApplicationState("EditDiveSite");
}
void MainWindow::enableDiveSiteEdit(uint32_t id) {
locationInformationWidget()->editDiveSite(id);
setApplicationState("EditDiveSite");
}
void MainWindow::setDefaultState() { void MainWindow::setDefaultState() {
setApplicationState("Default"); setApplicationState("Default");
} }
@ -446,8 +416,7 @@ void MainWindow::cleanUpEmpty()
bool MainWindow::okToClose(QString message) bool MainWindow::okToClose(QString message)
{ {
if (DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING || if (DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING ||
information()->isEditing() || information()->isEditing() ) {
currentApplicationState == "EditDiveSite") {
QMessageBox::warning(this, tr("Warning"), message); QMessageBox::warning(this, tr("Warning"), message);
return false; return false;
} }

View file

@ -138,7 +138,6 @@ slots:
void on_actionDivePlanner_triggered(); void on_actionDivePlanner_triggered();
void on_actionReplanDive_triggered(); void on_actionReplanDive_triggered();
void on_action_Check_for_Updates_triggered(); void on_action_Check_for_Updates_triggered();
void on_actionManage_dive_sites_triggered();
void current_dive_changed(int divenr); void current_dive_changed(int divenr);
void initialUiSetup(); void initialUiSetup();
@ -168,7 +167,6 @@ slots:
void on_paste_triggered(); void on_paste_triggered();
void on_actionFilterTags_triggered(); void on_actionFilterTags_triggered();
void on_actionConfigure_Dive_Computer_triggered(); void on_actionConfigure_Dive_Computer_triggered();
void enableDiveSiteEdit(uint32_t id);
void setDefaultState(); void setDefaultState();
void setAutomaticTitle(); void setAutomaticTitle();
@ -186,7 +184,6 @@ slots:
void planCanceled(); void planCanceled();
void planCreated(); void planCreated();
void setEnabledToolbar(bool arg1); void setEnabledToolbar(bool arg1);
void enableDiveSiteCreation();
void setPlanNotes(); void setPlanNotes();