diff options
author | rachytski <siarhei.rachytski@gmail.com> | 2012-10-12 20:17:41 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:45:23 +0300 |
commit | ca29b9e478b433d1a5d1a7a4385410467e97785f (patch) | |
tree | 495139e98cfe42412cff7397884061416b9ac957 /qt/mainwindow.cpp | |
parent | f81ed7bd00ca324c400288d0a2df86151d9989cc (diff) |
refactored Location and Compass observers mechanism.
Diffstat (limited to 'qt/mainwindow.cpp')
-rw-r--r-- | qt/mainwindow.cpp | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/qt/mainwindow.cpp b/qt/mainwindow.cpp index 9f888a0f85..e0ee73b8ec 100644 --- a/qt/mainwindow.cpp +++ b/qt/mainwindow.cpp @@ -40,6 +40,7 @@ namespace qt MainWindow::MainWindow() { m_pDrawWidget = new DrawWidget(this); + m_isFirstLocation = true; m_locationService.reset(CreateDesktopLocationService(*this)); CreateNavigationBar(); @@ -301,27 +302,27 @@ void MainWindow::OnAbout() dlg.exec(); } -void MainWindow::OnLocationStatusChanged(location::TLocationStatus newStatus) +void MainWindow::OnLocationError(location::TLocationError errorCode) { - switch (newStatus) + switch (errorCode) { - case location::EFirstEvent: - m_pMyPositionAction->setIcon(QIcon(":/navig64/location.png")); - m_pMyPositionAction->setToolTip(tr("My Position")); - break; - case location::EDisabledByUser: - case location::ENotSupported: + case location::EDenied: m_pMyPositionAction->setChecked(false); break; - default: - break; } - m_pDrawWidget->GetFramework().OnLocationStatusChanged(newStatus); + m_pDrawWidget->GetFramework().OnLocationError(errorCode); } -void MainWindow::OnGpsUpdated(location::GpsInfo const & info) +void MainWindow::OnLocationUpdated(location::GpsInfo const & info) { - m_pDrawWidget->GetFramework().OnGpsUpdate(info); + if (m_isFirstLocation) + { + m_pMyPositionAction->setIcon(QIcon(":/navig64/location.png")); + m_pMyPositionAction->setToolTip(tr("My Position")); + m_isFirstLocation = false; + } + + m_pDrawWidget->GetFramework().OnLocationUpdate(info); } void MainWindow::OnMyPosition() @@ -330,6 +331,7 @@ void MainWindow::OnMyPosition() { m_pMyPositionAction->setIcon(QIcon(":/navig64/location-search.png")); m_pMyPositionAction->setToolTip(tr("Looking for position...")); + m_isFirstLocation = true; m_locationService->Start(); } else |