diff --git a/src/lib/marble/MarbleMap.cpp b/src/lib/marble/MarbleMap.cpp index 347b5279bd587f669fa47221385a6ab6b8809f2a..f03f2382c806c416a06f0f903715ff9b6b421eab 100644 --- a/src/lib/marble/MarbleMap.cpp +++ b/src/lib/marble/MarbleMap.cpp @@ -991,7 +991,7 @@ void MarbleMapPrivate::updateMapTheme() m_placemarkLayer.setShowCraters( q->propertyValue("craters") ); m_placemarkLayer.setShowMaria( q->propertyValue("maria") ); - GeoDataFeature::setDefaultLabelColor( m_model->mapTheme()->map()->labelColor() ); + m_styleBuilder.setDefaultLabelColor(m_model->mapTheme()->map()->labelColor()); m_placemarkLayer.requestStyleReset(); foreach( RenderPlugin *renderPlugin, m_layerManager.renderPlugins() ) { @@ -1250,12 +1250,12 @@ void MarbleMap::setDefaultAngleUnit( AngleUnit angleUnit ) QFont MarbleMap::defaultFont() const { - return GeoDataFeature::defaultFont(); + return d->m_styleBuilder.defaultFont(); } void MarbleMap::setDefaultFont( const QFont& font ) { - GeoDataFeature::setDefaultFont( font ); + d->m_styleBuilder.setDefaultFont(font); d->m_placemarkLayer.requestStyleReset(); } diff --git a/src/lib/marble/StyleBuilder.cpp b/src/lib/marble/StyleBuilder.cpp index 5170419e45979857868c565b063eda58d7857ecb..f1e439ea875c04d9cbd31e174fc04b5768e2500c 100644 --- a/src/lib/marble/StyleBuilder.cpp +++ b/src/lib/marble/StyleBuilder.cpp @@ -17,10 +17,10 @@ #include "GeoDataTypes.h" #include "GeoDataPlacemark.h" #include "OsmPresetLibrary.h" -#include -#include -#include +#include +#include +#include namespace Marble { @@ -61,10 +61,14 @@ public: int m_defaultMinZoomLevels[GeoDataFeature::LastIndex]; int m_maximumZoomLevel; + QFont m_defaultFont; + QColor m_defaultLabelColor; }; StyleBuilder::Private::Private() : - m_maximumZoomLevel(15) + m_maximumZoomLevel(15), + m_defaultFont(QStringLiteral("Sans Serif")), + m_defaultLabelColor(Qt::black) { for ( int i = 0; i < GeoDataFeature::LastIndex; i++ ) m_defaultMinZoomLevels[i] = m_maximumZoomLevel; @@ -250,7 +254,7 @@ void StyleBuilder::Private::initializeDefaultStyles() } s_defaultStyleInitialized = true; - QString defaultFamily = GeoDataFeature::defaultFont().family(); + QString defaultFamily = m_defaultFont.family(); #ifdef Q_OS_MACX int defaultSize = 10; @@ -258,7 +262,7 @@ void StyleBuilder::Private::initializeDefaultStyles() int defaultSize = 8; #endif - QColor const defaultLabelColor = GeoDataFeature::defaultLabelColor(); + QColor const defaultLabelColor = m_defaultLabelColor; s_defaultStyle[GeoDataFeature::None] = GeoDataStyle::Ptr(new GeoDataStyle( QString(), @@ -792,6 +796,28 @@ StyleBuilder::~StyleBuilder() delete d; } +QFont StyleBuilder::defaultFont() const +{ + return d->m_defaultFont; +} + +void StyleBuilder::setDefaultFont( const QFont& font ) +{ + d->m_defaultFont = font; + reset(); +} + +QColor StyleBuilder::defaultLabelColor() const +{ + return d->m_defaultLabelColor; +} + +void StyleBuilder::setDefaultLabelColor( const QColor& color ) +{ + d->m_defaultLabelColor = color; + reset(); +} + GeoDataStyle::ConstPtr StyleBuilder::createStyle(const StyleParameters ¶meters) const { if (!parameters.feature) { diff --git a/src/lib/marble/StyleBuilder.h b/src/lib/marble/StyleBuilder.h index be869829368dd15bebdfc2a90f09ab62cd588266..155174fc1c8e131f7f426950fd4eff5b7823d545 100644 --- a/src/lib/marble/StyleBuilder.h +++ b/src/lib/marble/StyleBuilder.h @@ -14,6 +14,9 @@ #include #include +#include +#include + namespace Marble { class StyleParameters @@ -31,6 +34,15 @@ public: StyleBuilder(); ~StyleBuilder(); + /** + * Return the label font of the placemark. + */ + QFont defaultFont() const; + void setDefaultFont( const QFont& font ); + + QColor defaultLabelColor() const; + void setDefaultLabelColor( const QColor& color ); + GeoDataStyle::ConstPtr createStyle(const StyleParameters ¶meters) const; GeoDataStyle::ConstPtr presetStyle(GeoDataFeature::GeoDataVisualCategory visualCategory) const; diff --git a/src/lib/marble/geodata/data/GeoDataFeature.cpp b/src/lib/marble/geodata/data/GeoDataFeature.cpp index d30612c25f4803b8db221a156b3dadfd427f416e..cbf786176fd2c15522bc4fc537d25f4b33aa178f 100644 --- a/src/lib/marble/geodata/data/GeoDataFeature.cpp +++ b/src/lib/marble/geodata/data/GeoDataFeature.cpp @@ -34,8 +34,6 @@ namespace Marble { -QFont GeoDataFeaturePrivate::s_defaultFont = QFont(QStringLiteral("Sans Serif")); -QColor GeoDataFeaturePrivate::s_defaultLabelColor = QColor( Qt::black ); StyleBuilder GeoDataFeaturePrivate::s_styleBuilder; GeoDataFeature::GeoDataFeature() @@ -168,28 +166,6 @@ QSharedPointer GeoDataFeature::presetStyle( GeoDataVisualCat return GeoDataFeaturePrivate::s_styleBuilder.presetStyle(category); } -QFont GeoDataFeature::defaultFont() -{ - return GeoDataFeaturePrivate::s_defaultFont; -} - -void GeoDataFeature::setDefaultFont( const QFont& font ) -{ - GeoDataFeaturePrivate::s_defaultFont = font; - GeoDataFeaturePrivate::s_styleBuilder.reset(); -} - -QColor GeoDataFeature::defaultLabelColor() -{ - return GeoDataFeaturePrivate::s_defaultLabelColor; -} - -void GeoDataFeature::setDefaultLabelColor( const QColor& color ) -{ - GeoDataFeaturePrivate::s_defaultLabelColor = color; - GeoDataFeaturePrivate::s_styleBuilder.reset(); -} - QString GeoDataFeature::name() const { return d->m_name; diff --git a/src/lib/marble/geodata/data/GeoDataFeature.h b/src/lib/marble/geodata/data/GeoDataFeature.h index a633a1a67d7c23b4f203f66b18fac4fa5467089f..b5050fcf132320e39aa3b53fc69e2f5a71dda1a5 100644 --- a/src/lib/marble/geodata/data/GeoDataFeature.h +++ b/src/lib/marble/geodata/data/GeoDataFeature.h @@ -15,8 +15,6 @@ #include -#include -#include #include "GeoDataObject.h" @@ -634,9 +632,6 @@ class GEODATA_EXPORT GeoDataFeature : public GeoDataObject // ---------------------------------------------------------------- // The following functions are use for painting, and mostly for placemarks. - /** - * Return the label font of the placemark. - */ static void resetDefaultStyles(); /// Serialize the contents of the feature to @p stream. @@ -644,12 +639,6 @@ class GEODATA_EXPORT GeoDataFeature : public GeoDataObject /// Unserialize the contents of the feature from @p stream. virtual void unpack( QDataStream& stream ); - static QFont defaultFont(); - static void setDefaultFont( const QFont& font ); - - static QColor defaultLabelColor(); - static void setDefaultLabelColor( const QColor& color ); - static QSharedPointer presetStyle( GeoDataVisualCategory category ); protected: diff --git a/src/lib/marble/geodata/data/GeoDataFeature_p.h b/src/lib/marble/geodata/data/GeoDataFeature_p.h index a8acda8a9a759d0eff1dceb6053e3aea5d9a7d2f..85d058a9c201fa116781503bcb92ddbdf1ad9b18 100644 --- a/src/lib/marble/geodata/data/GeoDataFeature_p.h +++ b/src/lib/marble/geodata/data/GeoDataFeature_p.h @@ -155,9 +155,6 @@ class GeoDataFeaturePrivate QAtomicInt ref; // Static members - static QFont s_defaultFont; - static QColor s_defaultLabelColor; - static StyleBuilder s_styleBuilder; };