From kde-commits Mon Oct 03 20:29:24 2016 From: Bernhard Beschow Date: Mon, 03 Oct 2016 20:29:24 +0000 To: kde-commits Subject: [marble] src/lib/marble: no need for an icon on tags Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=147552657407423 Git commit 74b35067566f9b48f591e2f65d176e39381a402f by Bernhard Beschow. Committed on 03/10/2016 at 20:14. Pushed by beschow into branch 'master'. no need for an icon on tags Icons other than yellow circles were only visible in very rare cases (which= ones anyway?). Moreover, multiple tags with icons could even be misleading= : If there was e.g. a building with an amenity, the tag icons would compete= with each other. Therefore, and for the sake of simplicity, remove tag ico= ns. M +15 -16 src/lib/marble/StyleBuilder.cpp M +0 -6 src/lib/marble/StyleBuilder.h M +0 -8 src/lib/marble/osm/OsmTagEditorWidget_p.cpp http://commits.kde.org/marble/74b35067566f9b48f591e2f65d176e39381a402f diff --git a/src/lib/marble/StyleBuilder.cpp b/src/lib/marble/StyleBuilder.= cpp index d8eabd6..8d0878d 100644 --- a/src/lib/marble/StyleBuilder.cpp +++ b/src/lib/marble/StyleBuilder.cpp @@ -37,6 +37,8 @@ class StyleBuilder::Private public: Private(); = + GeoDataStyle::ConstPtr presetStyle(GeoDataPlacemark::GeoDataVisualCate= gory visualCategory) const; + GeoDataStyle::Ptr createStyle(qreal width, qreal realWidth, const QCol= or& color, const QColor& outlineColor, bool fil= l, bool outline, Qt::BrushStyle brushStyle, Qt::PenSt= yle penStyle, @@ -1201,7 +1203,7 @@ GeoDataStyle::ConstPtr StyleBuilder::createStyle(cons= t StyleParameters ¶mete } = auto const visualCategory =3D placemark->visualCategory(); - GeoDataStyle::ConstPtr style =3D presetStyle(visualCategory); + GeoDataStyle::ConstPtr style =3D d->presetStyle(visualCategory); = OsmPlacemarkData const & osmData =3D placemark->osmData(); if (placemark->geometry()->nodeType() =3D=3D GeoDataTypes::GeoDataPoin= tType) { @@ -1291,7 +1293,7 @@ GeoDataStyle::ConstPtr StyleBuilder::createStyle(cons= t StyleParameters ¶mete = if (style->iconStyle().iconPath().isEmpty()) { const GeoDataPlacemark::GeoDataVisualCategory category =3D det= ermineVisualCategory(osmData); - const GeoDataStyle::ConstPtr categoryStyle =3D presetStyle(cat= egory); + const GeoDataStyle::ConstPtr categoryStyle =3D d->presetStyle(= category); if (category !=3D GeoDataPlacemark::None && !categoryStyle->ic= onStyle().icon().isNull()) { GeoDataStyle::Ptr newStyle(new GeoDataStyle(*style)); newStyle->setIconStyle(categoryStyle->iconStyle()); @@ -1425,16 +1427,16 @@ GeoDataStyle::ConstPtr StyleBuilder::createStyle(co= nst StyleParameters ¶mete return style; } = -GeoDataStyle::ConstPtr StyleBuilder::presetStyle(GeoDataPlacemark::GeoData= VisualCategory visualCategory) const +GeoDataStyle::ConstPtr StyleBuilder::Private::presetStyle(GeoDataPlacemark= ::GeoDataVisualCategory visualCategory) const { - if (!d->m_defaultStyleInitialized) { - d->initializeDefaultStyles(); + if (!m_defaultStyleInitialized) { + const_cast(this)->initializeDefaultStyles= (); // const cast due to lazy initialization } = - if (visualCategory !=3D GeoDataPlacemark::None && d->m_defaultStyle[vi= sualCategory] ) { - return d->m_defaultStyle[visualCategory]; + if (visualCategory !=3D GeoDataPlacemark::None && m_defaultStyle[visua= lCategory] ) { + return m_defaultStyle[visualCategory]; } else { - return d->m_defaultStyle[GeoDataPlacemark::Default]; + return m_defaultStyle[GeoDataPlacemark::Default]; } } = @@ -1886,13 +1888,6 @@ QString StyleBuilder::visualCategoryName(GeoDataPlac= emark::GeoDataVisualCategory return visualCategoryNames[category]; } = -GeoDataPlacemark::GeoDataVisualCategory StyleBuilder::osmVisualCategory(co= nst StyleBuilder::OsmTag &tag) -{ - Private::initializeOsmVisualCategories(); - - return Private::s_visualCategories.value(tag, GeoDataPlacemark::None); -} - QHash::cons= t_iterator StyleBuilder::begin() { Private::initializeOsmVisualCategories(); @@ -2029,9 +2024,11 @@ GeoDataPlacemark::GeoDataVisualCategory StyleBuilder= ::determineVisualCategory(co return GeoDataPlacemark::NaturalIceShelf; } = + Private::initializeOsmVisualCategories(); + for (auto iter =3D osmData.tagsBegin(), end=3DosmData.tagsEnd(); iter = !=3D end; ++iter) { const auto tag =3D OsmTag(iter.key(), iter.value()); - GeoDataPlacemark::GeoDataVisualCategory category =3D osmVisualCate= gory(tag); + GeoDataPlacemark::GeoDataVisualCategory category =3D Private::s_vi= sualCategories.value(tag, GeoDataPlacemark::None); if (category !=3D GeoDataPlacemark::None) { if (category =3D=3D GeoDataPlacemark::PlaceCity && osmData.con= tainsTag("capital", "yes")) { category =3D GeoDataPlacemark::PlaceCityCapital; @@ -2040,7 +2037,9 @@ GeoDataPlacemark::GeoDataVisualCategory StyleBuilder:= :determineVisualCategory(co } else if (category =3D=3D GeoDataPlacemark::PlaceVillage && o= smData.containsTag("capital", "yes")) { category =3D GeoDataPlacemark::PlaceVillageCapital; } + } = + if (category !=3D GeoDataPlacemark::None) { return category; } } diff --git a/src/lib/marble/StyleBuilder.h b/src/lib/marble/StyleBuilder.h index d3fb756..c0d7d5e 100644 --- a/src/lib/marble/StyleBuilder.h +++ b/src/lib/marble/StyleBuilder.h @@ -52,7 +52,6 @@ public: void setDefaultLabelColor( const QColor& color ); = GeoDataStyle::ConstPtr createStyle(const StyleParameters ¶meters) = const; - GeoDataStyle::ConstPtr presetStyle(GeoDataPlacemark::GeoDataVisualCate= gory visualCategory) const; = /** * @brief Returns the order in which the visual categories used in the= theme shall be painted on the map. @@ -78,11 +77,6 @@ public: static QString visualCategoryName(GeoDataPlacemark::GeoDataVisualCateg= ory category); = /** - * @brief Convenience categorization of placemarks for Osm key=3Dvalu= e pairs - */ - static GeoDataPlacemark::GeoDataVisualCategory osmVisualCategory(const= OsmTag &tag); - - /** * @brief begin and end provide an stl style iterator for the preset m= ap */ static QHash::const_i= terator begin(); diff --git a/src/lib/marble/osm/OsmTagEditorWidget_p.cpp b/src/lib/marble/o= sm/OsmTagEditorWidget_p.cpp index bf9df71..dfa880a 100644 --- a/src/lib/marble/osm/OsmTagEditorWidget_p.cpp +++ b/src/lib/marble/osm/OsmTagEditorWidget_p.cpp @@ -99,8 +99,6 @@ void OsmTagEditorWidgetPrivate::populatePresetTagsList() = QTreeWidgetItem *OsmTagEditorWidgetPrivate::tagWidgetItem( const OsmTag &t= ag ) const { - static const StyleBuilder styleBuilder; - QStringList itemText; = itemText << tag.first; @@ -108,12 +106,6 @@ QTreeWidgetItem *OsmTagEditorWidgetPrivate::tagWidgetI= tem( const OsmTag &tag ) c = QTreeWidgetItem *tagItem =3D new QTreeWidgetItem( itemText ); = - // Getting the icon preset for the tag ( if there's one available ) - const GeoDataPlacemark::GeoDataVisualCategory category =3D StyleBuilde= r::osmVisualCategory(tag); - GeoDataStyle::ConstPtr style =3D styleBuilder.presetStyle(category); - QPixmap iconPixmap =3D QPixmap::fromImage( style->iconStyle().icon() ); - tagItem->setIcon( 1, QIcon( iconPixmap ) ); - return tagItem; } =20