Improve style to match project standards.

This commit is contained in:
Keith Wansbrough 2015-11-07 12:35:41 +00:00
parent 1117b9d17d
commit 792b52df47
9 changed files with 128 additions and 120 deletions

View file

@ -1,7 +1,7 @@
#include "api_mark_container.hpp"
#include "api_mark_point.hpp"
#include "map/api_mark_container.hpp"
#include "map/api_mark_point.hpp"
#include "framework.hpp"
#include "map/framework.hpp"
ApiUserMarkContainer::ApiUserMarkContainer(double layerDepth, Framework & framework)
: UserMarkContainer(layerDepth, framework)

View file

@ -1,18 +1,19 @@
#pragma once
#include "user_mark_container.hpp"
#include "api_mark_point.hpp"
#include "map/api_mark_point.hpp"
#include "map/user_mark_container.hpp"
class ApiUserMarkContainer : public UserMarkContainer
{
public:
ApiUserMarkContainer(double layerDepth, Framework & framework);
virtual Type GetType() const { return API_MARK; }
virtual string GetActiveTypeName() const;
// UserMarkContainer overrides:
Type GetType() const override { return API_MARK; }
string GetActiveTypeName() const override;
protected:
virtual string GetTypeName() const;
virtual UserMark * AllocateUserMark(m2::PointD const & ptOrg);
// UserMarkContainer overrides:
string GetTypeName() const override;
UserMark * AllocateUserMark(m2::PointD const & ptOrg) override;
};

View file

@ -17,21 +17,21 @@ public:
{
}
UserMark::Type GetMarkType() const override { return UserMark::Type::API; }
string const & GetName() const { return m_name; }
void SetName(string const & name) { m_name = name; }
string const & GetID() const { return m_id; }
void SetID(string const & id) { m_id = id; }
// UserMark overrides:
UserMark::Type GetMarkType() const override { return UserMark::Type::API; }
unique_ptr<UserMarkCopy> Copy() const override
{
return unique_ptr<UserMarkCopy>(
new UserMarkCopy(new ApiMarkPoint(m_name, m_id, GetStyle(), m_ptOrg, m_container)));
return make_unique<UserMarkCopy>(new ApiMarkPoint(m_name, m_id, GetStyle(), m_ptOrg, m_container));
}
virtual void FillLogEvent(TEventContainer & details) const override
void FillLogEvent(TEventContainer & details) const override
{
UserMark::FillLogEvent(details);
details["markType"] = "API";

View file

@ -123,7 +123,7 @@ void BookmarkCategory::DeleteBookmark(size_t index)
size_t animIndex = 0;
for (; animIndex < m_anims.size(); ++animIndex)
{
anim_node_t const & anim = m_anims[animIndex];
TAnimNode const & anim = m_anims[animIndex];
if (anim.first == markForDelete)
{
anim.second->Cancel();
@ -167,14 +167,14 @@ size_t BookmarkCategory::FindBookmark(Bookmark const * bookmark) const
namespace
{
string const PLACEMARK = "Placemark";
string const STYLE = "Style";
string const DOCUMENT = "Document";
string const STYLE_MAP = "StyleMap";
string const STYLE_URL = "styleUrl";
string const PAIR = "Pair";
string const kPlacemark = "Placemark";
string const kStyle = "Style";
string const kDocument = "Document";
string const kStyleMap = "StyleMap";
string const kStyleUrl = "styleUrl";
string const kPair = "Pair";
graphics::Color const DEFAULT_TRACK_COLOR = graphics::Color::fromARGB(0xFF33CCFF);
graphics::Color const kDefaultTrackColor = graphics::Color::fromARGB(0xFF33CCFF);
string PointToString(m2::PointD const & org)
{
@ -190,17 +190,18 @@ namespace
enum GeometryType
{
UNKNOWN,
POINT,
LINE
GEOMETRY_TYPE_UNKNOWN,
GEOMETRY_TYPE_POINT,
GEOMETRY_TYPE_LINE
};
class KMLParser
{
// Fixes icons which are not supported by MapsWithMe
// Fixes icons which are not supported by MapsWithMe.
string GetSupportedBMType(string const & s) const
{
// Remove leading '#' symbol
// Remove leading '#' symbol.
ASSERT(!s.empty(), ());
string const result = s.substr(1);
return style::GetSupportedStyle(result, m_name, style::GetDefaultStyle());
}
@ -235,13 +236,13 @@ namespace
m_scale = -1.0;
m_timeStamp = my::INVALID_TIME_STAMP;
m_trackColor = DEFAULT_TRACK_COLOR;
m_trackColor = kDefaultTrackColor;
m_styleId.clear();
m_mapStyleId.clear();
m_styleUrlKey.clear();
m_points.Clear();
m_geometryType = UNKNOWN;
m_geometryType = GEOMETRY_TYPE_UNKNOWN;
}
bool ParsePoint(string const & s, char const * delim, m2::PointD & pt)
@ -270,7 +271,7 @@ namespace
void SetOrigin(string const & s)
{
m_geometryType = POINT;
m_geometryType = GEOMETRY_TYPE_POINT;
m2::PointD pt;
if (ParsePoint(s, ", \n\r\t", pt))
@ -279,7 +280,7 @@ namespace
void ParseLineCoordinates(string const & s, char const * blockSeparator, char const * coordSeparator)
{
m_geometryType = LINE;
m_geometryType = GEOMETRY_TYPE_LINE;
strings::SimpleTokenizer cortegeIter(s, blockSeparator);
while (cortegeIter)
@ -293,7 +294,7 @@ namespace
bool MakeValid()
{
if (POINT == m_geometryType)
if (GEOMETRY_TYPE_POINT == m_geometryType)
{
if (MercatorBounds::ValidX(m_org.x) && MercatorBounds::ValidY(m_org.y))
{
@ -309,7 +310,7 @@ namespace
}
return false;
}
else if (LINE == m_geometryType)
else if (GEOMETRY_TYPE_LINE == m_geometryType)
{
return m_points.GetSize() > 1;
}
@ -331,7 +332,7 @@ namespace
return false;
// Remove leading '#' symbol
map<string, graphics::Color>::const_iterator it = m_styleUrl2Color.find(styleUrl.substr(1));
auto it = m_styleUrl2Color.find(styleUrl.substr(1));
if (it != m_styleUrl2Color.end())
{
color = it->second;
@ -357,9 +358,9 @@ namespace
string attrInLowerCase = attr;
strings::AsciiToLower(attrInLowerCase);
if (IsValidAttribute(STYLE, value, attrInLowerCase))
if (IsValidAttribute(kStyle, value, attrInLowerCase))
m_styleId = value;
else if (IsValidAttribute(STYLE_MAP, value, attrInLowerCase))
else if (IsValidAttribute(kStyleMap, value, attrInLowerCase))
m_mapStyleId = value;
}
@ -378,13 +379,13 @@ namespace
{
ASSERT_EQUAL(m_tags.back(), tag, ());
if (tag == PLACEMARK)
if (tag == kPlacemark)
{
if (MakeValid())
{
if (POINT == m_geometryType)
if (GEOMETRY_TYPE_POINT == m_geometryType)
m_category.AddBookmark(m_org, BookmarkData(m_name, m_type, m_description, m_scale, m_timeStamp));
else if (LINE == m_geometryType)
else if (GEOMETRY_TYPE_LINE == m_geometryType)
{
Track track(m_points);
track.SetName(m_name);
@ -398,14 +399,14 @@ namespace
}
Reset();
}
else if (tag == STYLE)
else if (tag == kStyle)
{
if (GetTagFromEnd(1) == DOCUMENT)
if (GetTagFromEnd(1) == kDocument)
{
if (!m_styleId.empty())
{
m_styleUrl2Color[m_styleId] = m_trackColor;
m_trackColor = DEFAULT_TRACK_COLOR;
m_trackColor = kDefaultTrackColor;
}
}
}
@ -424,14 +425,14 @@ namespace
string const & prevTag = m_tags[count - 2];
string const ppTag = count > 3 ? m_tags[count - 3] : string();
if (prevTag == DOCUMENT)
if (prevTag == kDocument)
{
if (currTag == "name")
m_category.SetName(value);
else if (currTag == "visibility")
m_category.SetVisible(value == "0" ? false : true);
}
else if (prevTag == PLACEMARK)
else if (prevTag == kPlacemark)
{
if (currTag == "name")
m_name = value;
@ -456,16 +457,16 @@ namespace
{
ParseColor(value);
}
else if (ppTag == STYLE_MAP && prevTag == PAIR && currTag == STYLE_URL && m_styleUrlKey == "normal")
else if (ppTag == kStyleMap && prevTag == kPair && currTag == kStyleUrl && m_styleUrlKey == "normal")
{
if (!m_mapStyleId.empty())
m_mapStyle2Style[m_mapStyleId] = value;
}
else if (ppTag == STYLE_MAP && prevTag == PAIR && currTag == "key")
else if (ppTag == kStyleMap && prevTag == kPair && currTag == "key")
{
m_styleUrlKey = value;
}
else if (ppTag == PLACEMARK)
else if (ppTag == kPlacemark)
{
if (prevTag == "Point")
{
@ -499,7 +500,7 @@ namespace
LOG(LWARNING, ("Invalid timestamp in Placemark:", value));
}
}
else if (currTag == STYLE_URL)
else if (currTag == kStyleUrl)
{
GetColorForStyle(value, m_trackColor);
}
@ -824,10 +825,10 @@ string BookmarkCategory::GenerateUniqueFileName(const string & path, string name
void BookmarkCategory::ReleaseAnimations()
{
vector<anim_node_t> tempAnims;
vector<TAnimNode> tempAnims;
for (size_t i = 0; i < m_anims.size(); ++i)
{
anim_node_t const & anim = m_anims[i];
TAnimNode const & anim = m_anims[i];
if (!anim.second->IsEnded() &&
!anim.second->IsCancelled())
{

View file

@ -203,8 +203,8 @@ private:
private:
bool m_blockAnimation;
typedef pair<UserMark *, shared_ptr<anim::Task> > anim_node_t;
vector<anim_node_t> m_anims;
using TAnimNode = pair<UserMark *, shared_ptr<anim::Task> >;
vector<TAnimNode> m_anims;
};
/// <category index, bookmark index>

View file

@ -11,72 +11,72 @@ INCLUDEPATH *= $$ROOT_DIR/3party/protobuf/src $$ROOT_DIR/3party/expat/lib $$ROOT
include($$ROOT_DIR/common.pri)
HEADERS += \
framework.hpp \
feature_vec_model.hpp \
navigator.hpp \
information_display.hpp \
location_state.hpp \
benchmark_provider.hpp \
benchmark_engine.hpp \
ruler.hpp \
bookmark.hpp \
styled_point.hpp \
geourl_process.hpp \
country_status_display.hpp \
rotate_screen_task.hpp \
compass_arrow.hpp \
animator.hpp \
move_screen_task.hpp \
change_viewport_task.hpp \
mwm_url.hpp \
bookmark_manager.hpp \
ge0_parser.hpp \
track.hpp \
active_maps_layout.hpp \
alfa_animation_task.hpp \
user_mark_container.hpp \
user_mark.hpp \
user_mark_dl_cache.hpp \
anim_phase_chain.hpp \
animator.hpp \
api_mark_container.hpp \
api_mark_point.hpp \
anim_phase_chain.hpp \
pin_click_manager.hpp \
benchmark_engine.hpp \
benchmark_provider.hpp \
bookmark.hpp \
bookmark_manager.hpp \
change_viewport_task.hpp \
compass_arrow.hpp \
country_status_display.hpp \
country_tree.hpp \
active_maps_layout.hpp \
feature_vec_model.hpp \
framework.hpp \
ge0_parser.hpp \
geourl_process.hpp \
information_display.hpp \
location_state.hpp \
move_screen_task.hpp \
mwm_url.hpp \
navigator.hpp \
navigator_utils.hpp \
pin_click_manager.hpp \
rotate_screen_task.hpp \
ruler.hpp \
styled_point.hpp \
track.hpp \
user_mark.hpp \
user_mark_container.hpp \
user_mark_dl_cache.hpp \
SOURCES += \
../api/src/c/api-client.c \
active_maps_layout.cpp \
address_finder.cpp \
alfa_animation_task.cpp \
anim_phase_chain.cpp \
animator.cpp \
api_mark_container.cpp \
benchmark_engine.cpp \
benchmark_provider.cpp \
bookmark.cpp \
bookmark_manager.cpp \
change_viewport_task.cpp \
compass_arrow.cpp \
country_status_display.cpp \
country_tree.cpp \
feature_vec_model.cpp \
framework.cpp \
navigator.cpp \
ge0_parser.cpp \
geourl_process.cpp \
information_display.cpp \
location_state.cpp \
benchmark_provider.cpp \
benchmark_engine.cpp \
ruler.cpp \
address_finder.cpp \
geourl_process.cpp \
bookmark.cpp \
styled_point.cpp \
country_status_display.cpp \
rotate_screen_task.cpp \
compass_arrow.cpp \
animator.cpp \
move_screen_task.cpp \
change_viewport_task.cpp \
mwm_url.cpp \
bookmark_manager.cpp \
ge0_parser.cpp \
../api/src/c/api-client.c \
navigator.cpp \
navigator_utils.cpp \
pin_click_manager.cpp \
rotate_screen_task.cpp \
ruler.cpp \
styled_point.cpp \
track.cpp \
alfa_animation_task.cpp \
user_mark_container.cpp \
user_mark_dl_cache.cpp \
api_mark_container.cpp \
anim_phase_chain.cpp \
pin_click_manager.cpp \
country_tree.cpp \
active_maps_layout.cpp \
navigator_utils.cpp \
!iphone*:!tizen*:!android* {
HEADERS += qgl_render_context.hpp

View file

@ -26,9 +26,12 @@ m2::PointD const & StyledPoint::GetPixelOffset() const
return GetStyle().empty() ? s_centre : s_offset;
}
static char const * s_arrSupportedColors[] = {
namespace
{
char const * kSupportedColors[] = {
"placemark-red", "placemark-blue", "placemark-purple", "placemark-yellow",
"placemark-pink", "placemark-brown", "placemark-green", "placemark-orange"};
}
namespace style
{
@ -37,15 +40,17 @@ string GetSupportedStyle(string const & s, string const & context, string const
if (s.empty())
return fallback;
for (size_t i = 0; i < ARRAY_SIZE(s_arrSupportedColors); ++i)
if (s == s_arrSupportedColors[i])
for (size_t i = 0; i < ARRAY_SIZE(kSupportedColors); ++i)
{
if (s == kSupportedColors[i])
return s;
}
// Not recognized symbols are replaced with default one
LOG(LWARNING, ("Icon", s, "for point", context, "is not supported"));
return fallback;
}
string GetDefaultStyle() { return s_arrSupportedColors[0]; }
string GetDefaultStyle() { return kSupportedColors[0]; }
} // namespace style

View file

@ -34,9 +34,10 @@ public:
{
}
virtual graphics::DisplayList * GetDisplayList(UserMarkDLCache * cache) const override;
virtual double GetAnimScaleFactor() const override;
virtual m2::PointD const & GetPixelOffset() const override;
// ICustomDrawable overrides:
graphics::DisplayList * GetDisplayList(UserMarkDLCache * cache) const override;
double GetAnimScaleFactor() const override;
m2::PointD const & GetPixelOffset() const override;
string const & GetStyle() const { return m_style; }
void SetStyle(const string & style) { m_style = style; }

View file

@ -173,8 +173,8 @@ void UserMarkContainer::Clear(size_t skipCount/* = 0*/)
namespace
{
static unique_ptr<PoiMarkPoint> s_selectionUserMark;
static unique_ptr<MyPositionMarkPoint> s_myPosition;
unique_ptr<PoiMarkPoint> g_selectionUserMark;
unique_ptr<MyPositionMarkPoint> g_myPosition;
}
UserMarkDLCache::Key UserMarkContainer::GetDefaultKey() const
@ -184,23 +184,23 @@ UserMarkDLCache::Key UserMarkContainer::GetDefaultKey() const
void UserMarkContainer::InitStaticMarks(UserMarkContainer * container)
{
if (s_selectionUserMark == NULL)
s_selectionUserMark.reset(new PoiMarkPoint(container));
if (g_selectionUserMark == NULL)
g_selectionUserMark.reset(new PoiMarkPoint(container));
if (s_myPosition == NULL)
s_myPosition.reset(new MyPositionMarkPoint(container));
if (g_myPosition == NULL)
g_myPosition.reset(new MyPositionMarkPoint(container));
}
PoiMarkPoint * UserMarkContainer::UserMarkForPoi()
{
ASSERT(s_selectionUserMark != NULL, ());
return s_selectionUserMark.get();
ASSERT(g_selectionUserMark != NULL, ());
return g_selectionUserMark.get();
}
MyPositionMarkPoint * UserMarkContainer::UserMarkForMyPostion()
{
ASSERT(s_myPosition != NULL, ());
return s_myPosition.get();
ASSERT(g_myPosition != NULL, ());
return g_myPosition.get();
}
UserMark * UserMarkContainer::CreateUserMark(m2::PointD const & ptOrg)