diff --git a/qt/draw_widget.cpp b/qt/draw_widget.cpp index 2aa6b14968..b0b5be6228 100644 --- a/qt/draw_widget.cpp +++ b/qt/draw_widget.cpp @@ -1,5 +1,6 @@ #include "qt/draw_widget.hpp" #include "qt/editor_dialog.hpp" +#include "qt/place_page_dialog.hpp" #include "qt/slider_ctrl.hpp" #include "qt/qtoglcontext.hpp" @@ -9,6 +10,8 @@ #include "storage/index.hpp" +#include "indexer/editable_map_object.hpp" + #include "platform/settings.hpp" #include "platform/platform.hpp" #include "platform/settings.hpp" @@ -82,16 +85,10 @@ DrawWidget::DrawWidget(QWidget * parent) m_enableScaleUpdate(true), m_emulatingLocation(false) { - m_framework->SetUserMarkActivationListener([this](unique_ptr mark) + m_framework->SetMapSelectionListeners([this](place_page::Info const & info) { - // TODO: Why do we get empty mark in some cases? - if (mark) - { - FeatureType * feature = mark->GetUserMark()->GetFeature(); - if (feature) - ShowPOIEditor(*feature); - } - }); + ShowPlacePage(info); + }, [](bool /*switchFullScreenMode*/){}); // Empty deactivation listener. m_framework->SetRouteBuildingListener([](routing::IRouter::ResultCode, storage::TCountriesVec const &) @@ -527,23 +524,38 @@ void DrawWidget::SubmitRoutingPoint(m2::PointD const & pt) m_framework->BuildRoute(m_framework->PtoG(pt), 0 /* timeoutSec */); } -void DrawWidget::ShowPOIEditor(FeatureType & feature) +void DrawWidget::ShowPlacePage(place_page::Info const & info) { - // Show Edit POI dialog. - auto & editor = osm::Editor::Instance(); - EditorDialog dlg(this, feature, *m_framework); - int const result = dlg.exec(); - if (result == QDialog::Accepted) + search::AddressInfo address; + if (info.IsFeature()) + address = m_framework->GetFeatureAddressInfo(info.GetID()); + else + address = m_framework->GetAddressInfoAtPoint(info.GetMercator()); + + PlacePageDialog dlg(this, info, address); + if (dlg.exec() == QDialog::Accepted) { - feature.SetNames(dlg.GetEditedNames()); - feature.SetMetadata(dlg.GetEditedMetadata()); - // TODO(AlexZ): Check that street was actually changed/edited. - editor.EditFeature(feature, dlg.GetEditedStreet(), dlg.GetEditedHouseNumber()); - } - else if (result == QDialogButtonBox::DestructiveRole) - { - editor.DeleteFeature(feature); + osm::EditableMapObject emo; + if (m_framework->GetEditableMapObject(info.GetID(), emo)) + { + EditorDialog dlg(this, emo); + int const result = dlg.exec(); + if (result == QDialog::Accepted) + { + m_framework->SaveEditedMapObject(emo); + m_framework->UpdatePlacePageInfoForCurrentSelection(); + } + else if (result == QDialogButtonBox::DestructiveRole) + { + m_framework->DeleteFeature(info.GetID()); + } + } + else + { + LOG(LERROR, ("Error while trying to edit feature.")); + } } + m_framework->DeactivateMapSelection(false); } void DrawWidget::ShowInfoPopup(QMouseEvent * e, m2::PointD const & pt) diff --git a/qt/draw_widget.hpp b/qt/draw_widget.hpp index fdd16b8bc7..dd9628ac1b 100644 --- a/qt/draw_widget.hpp +++ b/qt/draw_widget.hpp @@ -97,7 +97,7 @@ namespace qt void SubmitFakeLocationPoint(m2::PointD const & pt); void SubmitRoutingPoint(m2::PointD const & pt); void ShowInfoPopup(QMouseEvent * e, m2::PointD const & pt); - void ShowPOIEditor(FeatureType & feature); + void ShowPlacePage(place_page::Info const & info); void OnViewportChanged(ScreenBase const & screen); void UpdateScaleControl();