Review fixes.

This commit is contained in:
Alex Zolotarev 2016-01-18 16:22:01 +03:00 committed by Sergey Yershov
parent cb2d67f229
commit 4cef71402c
8 changed files with 16 additions and 16 deletions

View file

@ -27,20 +27,21 @@ public:
ChangesetWrapper(TKeySecret const & keySecret, ServerApi06::TKeyValueTags const & comments);
~ChangesetWrapper();
/// Throws many exceptions, including XMLNode's parsing ones.
/// Throws many exceptions from above list, plus including XMLNode's parsing ones.
/// OsmObjectWasDeletedException means that node was deleted from OSM server by someone else.
editor::XMLFeature GetMatchingFeatureFromOSM(editor::XMLFeature const & ourPatch, FeatureType const & feature);
/// Throws.
/// Throws exceptions from above list.
void ModifyNode(editor::XMLFeature node);
private:
// Unfortunately, pugi can't return xml_documents from methods.
/// Unfortunately, pugi can't return xml_documents from methods.
/// Throws exceptions from above list.
void LoadXmlFromOSM(ms::LatLon const & ll, pugi::xml_document & doc);
ServerApi06::TKeyValueTags m_changesetComments;
ServerApi06 m_api;
static constexpr int const kInvalidChangesetId = 0;
static constexpr uint64_t kInvalidChangesetId = 0;
uint64_t m_changesetId = kInvalidChangesetId;
};

View file

@ -16,7 +16,7 @@ namespace
{
constexpr int const kLatLonTolerance = 7;
constexpr char const * kTimestamp = "timestamp";
constexpr char const * kIndex = "mwmFileIndex";
constexpr char const * kIndex = "mwm_file_index";
constexpr char const * kUploadTimestamp = "upload_timestamp";
constexpr char const * kUploadStatus = "upload_status";
constexpr char const * kUploadError = "upload_error";

View file

@ -266,7 +266,7 @@ void FeatureType::ParseMetadata() const
m_bMetadataParsed = true;
}
StringUtf8Multilang FeatureType::GetNames() const
StringUtf8Multilang const & FeatureType::GetNames() const
{
return m_params.name;
}

View file

@ -167,7 +167,7 @@ public:
/// @name Editor functions.
//@{
StringUtf8Multilang GetNames() const;
StringUtf8Multilang const & GetNames() const;
void SetNames(StringUtf8Multilang const & newNames);
void SetMetadata(feature::Metadata const & newMetadata);
//@}

View file

@ -129,7 +129,7 @@ void Index::FeaturesLoaderGuard::GetFeatureByIndex(uint32_t index, FeatureType &
}
}
void Index::FeaturesLoaderGuard::GetNotEditedFeatureByIndex(uint32_t index, FeatureType & ft) const
void Index::FeaturesLoaderGuard::GetOriginalFeatureByIndex(uint32_t index, FeatureType & ft) const
{
MwmId const & id = m_handle.GetId();
m_vector.GetByIndex(index, ft);

View file

@ -287,7 +287,7 @@ public:
/// Everyone, except Editor core, should use this method.
void GetFeatureByIndex(uint32_t index, FeatureType & ft) const;
/// Editor core only method, to get 'untouched', original version of feature.
void GetNotEditedFeatureByIndex(uint32_t index, FeatureType & ft) const;
void GetOriginalFeatureByIndex(uint32_t index, FeatureType & ft) const;
inline FeaturesVector const & GetFeaturesVector() const { return m_vector; }
private:

View file

@ -254,7 +254,7 @@ void Editor::LoadMapEdits()
MwmSet::MwmId const id = m_mwmIdByMapNameFn(mapName);
if (!id.IsAlive())
{
// TODO(AlexZ): MWM file was deleted, but changes have left. What should we do in this case?
// TODO(AlexZ): MWM file was deleted, but changes remain. What should we do in this case?
LOG(LWARNING, (mapName, "version", mapVersion, "references not existing MWM file."));
continue;
}
@ -421,11 +421,9 @@ void Editor::EditFeature(FeatureType const & editedFeature, string const & edite
fti.m_modificationTimestamp = time(nullptr);
fti.m_street = editedStreet;
if (editedHouseNumber.empty())
fti.m_feature.SetHouseNumber(string());
else if (feature::IsHouseNumber(editedHouseNumber))
if (editedHouseNumber.empty() || feature::IsHouseNumber(editedHouseNumber))
fti.m_feature.SetHouseNumber(editedHouseNumber);
// else TODO(AlexZ): Store edited house number as house name.
// TODO(AlexZ): Store edited house number as house name if feature::IsHouseNumber() returned false.
// TODO(AlexZ): Synchronize Save call/make it on a separate thread.
Save(GetEditorFilePath());
@ -530,10 +528,11 @@ bool Editor::IsNameEditable(FeatureType const & feature) const
bool Editor::IsAddressEditable(FeatureType const & feature) const
{
feature::TypesHolder const types(feature);
auto & isBuilding = ftypes::IsBuildingChecker::Instance();
for (auto type : types)
{
// Building addresses are always editable.
if (ftypes::IsBuildingChecker::Instance().HasTypeValue(type))
if (isBuilding.HasTypeValue(type))
return true;
auto const * typeDesc = GetTypeDescription(type);
if (typeDesc && typeDesc->address)

View file

@ -331,7 +331,7 @@ Framework::Framework()
{
unique_ptr<FeatureType> feature(new FeatureType());
Index::FeaturesLoaderGuard const guard(m_model.GetIndex(), fid.m_mwmId);
guard.GetNotEditedFeatureByIndex(fid.m_index, *feature);
guard.GetOriginalFeatureByIndex(fid.m_index, *feature);
feature->ParseEverything();
return feature;
});