Commit 34deafcc authored by Bernhard Beschow's avatar Bernhard Beschow

move static font and color properties from GeoDataFeature to StyleBuilder and make non-static

parent 3f3d7eb3
......@@ -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();
}
......
......@@ -17,10 +17,10 @@
#include "GeoDataTypes.h"
#include "GeoDataPlacemark.h"
#include "OsmPresetLibrary.h"
#include <QScreen>
#include <QApplication>
#include <QDebug>
#include <QApplication>
#include <QDate>
#include <QScreen>
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 &parameters) const
{
if (!parameters.feature) {
......
......@@ -14,6 +14,9 @@
#include <GeoDataStyle.h>
#include <GeoDataFeature.h>
#include <QColor>
#include <QFont>
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 &parameters) const;
GeoDataStyle::ConstPtr presetStyle(GeoDataFeature::GeoDataVisualCategory visualCategory) const;
......
......@@ -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<const GeoDataStyle> 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;
......
......@@ -15,8 +15,6 @@
#include <QString>
#include <QFont>
#include <QColor>
#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<const GeoDataStyle> presetStyle( GeoDataVisualCategory category );
protected:
......
......@@ -155,9 +155,6 @@ class GeoDataFeaturePrivate
QAtomicInt ref;
// Static members
static QFont s_defaultFont;
static QColor s_defaultLabelColor;
static StyleBuilder s_styleBuilder;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment