summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <nienhueser@kde.org>2016-11-05 19:29:06 (GMT)
committerDennis Nienhüser <nienhueser@kde.org>2016-11-05 19:29:06 (GMT)
commitfd19557c891f1867797c81d8e1483078156d0ef7 (patch)
treed4ba4d3b65cd0946f6795c690f0dd63b8212d8f9
parent973fa9918fd815d9aa1c52fbd552609918e9f931 (diff)
Avoid repeated svg loading.
This was the reason why it "gets slow once trees appear".
-rw-r--r--src/lib/marble/StyleBuilder.cpp23
1 files changed, 8 insertions, 15 deletions
diff --git a/src/lib/marble/StyleBuilder.cpp b/src/lib/marble/StyleBuilder.cpp
index 1b8d34e..0f3ce8f 100644
--- a/src/lib/marble/StyleBuilder.cpp
+++ b/src/lib/marble/StyleBuilder.cpp
@@ -85,6 +85,8 @@ public:
QColor m_defaultLabelColor;
QFont m_defaultFont;
GeoDataStyle::Ptr m_defaultStyle[GeoDataPlacemark::LastIndex];
+ GeoDataStyle::Ptr m_styleTreeAutumn;
+ GeoDataStyle::Ptr m_styleTreeWinter;
bool m_defaultStyleInitialized;
/**
@@ -574,6 +576,8 @@ void StyleBuilder::Private::initializeDefaultStyles()
m_defaultStyle[GeoDataPlacemark::NaturalPeak] = createOsmPOIStyle(osmFont, "individual/peak", amenityColor);
m_defaultStyle[GeoDataPlacemark::NaturalPeak]->iconStyle().setScale(0.33);
m_defaultStyle[GeoDataPlacemark::NaturalTree] = createOsmPOIStyle(osmFont, "individual/tree-29", amenityColor); // tree-16 provides the official icon
+ m_styleTreeAutumn = createOsmPOIStyle(osmFont, "individual/tree-29-autumn", amenityColor);
+ m_styleTreeWinter = createOsmPOIStyle(osmFont, "individual/tree-29-winter", amenityColor);
m_defaultStyle[GeoDataPlacemark::ShopBeverages] = createOsmPOIStyle(osmFont, "shop/beverages-14", shopColor);
m_defaultStyle[GeoDataPlacemark::ShopHifi] = createOsmPOIStyle(osmFont, "shop/hifi-14", shopColor);
@@ -1218,31 +1222,20 @@ GeoDataStyle::ConstPtr StyleBuilder::createStyle(const StyleParameters &paramete
if (qAbs(lat) > 15) {
/** @todo Should maybe auto-adjust to MarbleClock at some point */
int const month = QDate::currentDate().month();
- QString season;
bool const southernHemisphere = lat < 0;
if (southernHemisphere) {
if (month >= 3 && month <= 5) {
- season = "autumn";
+ style = d->m_styleTreeAutumn;
} else if (month >= 6 && month <= 8) {
- season = "winter";
+ style = d->m_styleTreeWinter;
}
} else {
if (month >= 9 && month <= 11) {
- season = "autumn";
+ style = d->m_styleTreeAutumn;
} else if (month == 12 || month == 1 || month == 2) {
- season = "winter";
+ style = d->m_styleTreeWinter;
}
}
-
- if (!season.isEmpty()) {
- GeoDataIconStyle iconStyle = style->iconStyle();
- QString const image = QLatin1String("svg/osmcarto/svg/individual/tree-29-") + season + QLatin1String(".svg");
- iconStyle.setIconPath(MarbleDirs::path(image));
-
- GeoDataStyle::Ptr newStyle(new GeoDataStyle(*style));
- newStyle->setIconStyle(iconStyle);
- style = newStyle;
- }
}
}
} else if (placemark->geometry()->nodeType() == GeoDataTypes::GeoDataLinearRingType) {