summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <[email protected]>2015-10-31 19:14:38 +0100
committerDennis Nienhüser <[email protected]>2015-10-31 19:15:32 +0100
commit1082ea5d1640e9da12b4d82d4dcaa920fd213c7a (patch)
treec8b943f4477b6b12da1d674f83f9f0de63f94073
parentd60999685175a4652e474389608633fe790d3ca4 (diff)
Move placemarkLayoutOrderCompare to GeoDataPlacemark
Replaced getter function calls with direct private member access to avoid the function call overhead during sorting
-rw-r--r--src/lib/marble/PlacemarkLayout.cpp16
-rw-r--r--src/lib/marble/geodata/data/GeoDataPlacemark.cpp13
-rw-r--r--src/lib/marble/geodata/data/GeoDataPlacemark.h2
3 files changed, 16 insertions, 15 deletions
diff --git a/src/lib/marble/PlacemarkLayout.cpp b/src/lib/marble/PlacemarkLayout.cpp
index 0862f94..a6a7e6c 100644
--- a/src/lib/marble/PlacemarkLayout.cpp
+++ b/src/lib/marble/PlacemarkLayout.cpp
@@ -40,20 +40,6 @@
#include "MathHelper.h"
namespace
-{
- bool placemarkLayoutOrderCompare(const Marble::GeoDataPlacemark *left, const Marble::GeoDataPlacemark *right)
- {
- if (left->zoomLevel() != right->zoomLevel())
- return (left->zoomLevel() < right->zoomLevel()); //lower zoom level comes first
-
- if (left->popularity() != right->popularity())
- return left->popularity() > right->popularity(); //higher popularity comes first
-
- return left < right; //lower pointer value comes first
- }
-}
-
-namespace
{ //Helper function that checks for available room for the label
bool hasRoomFor(const QVector<Marble::VisiblePlacemark*> & placemarks, const QRectF &labelRect)
{
@@ -481,7 +467,7 @@ QVector<VisiblePlacemark *> PlacemarkLayout::generateLayout( const ViewportParam
foreach ( const TileId &tileId, tileIdList ) {
placemarkList += m_placemarkCache.value( tileId );
}
- qSort(placemarkList.begin(), placemarkList.end(), placemarkLayoutOrderCompare);
+ qSort(placemarkList.begin(), placemarkList.end(), GeoDataPlacemark::placemarkLayoutOrderCompare);
foreach ( const GeoDataPlacemark *placemark, placemarkList ) {
const GeoDataCoordinates coordinates = placemarkIconCoordinates( placemark );
diff --git a/src/lib/marble/geodata/data/GeoDataPlacemark.cpp b/src/lib/marble/geodata/data/GeoDataPlacemark.cpp
index 9edaa84..f7f57b3 100644
--- a/src/lib/marble/geodata/data/GeoDataPlacemark.cpp
+++ b/src/lib/marble/geodata/data/GeoDataPlacemark.cpp
@@ -212,6 +212,19 @@ GeoDataLookAt *GeoDataPlacemark::lookAt()
return dynamic_cast<GeoDataLookAt*>( abstractView() );
}
+bool GeoDataPlacemark::placemarkLayoutOrderCompare(const GeoDataPlacemark *left, const GeoDataPlacemark *right)
+{
+ if (left->d->m_zoomLevel != right->d->m_zoomLevel) {
+ return (left->d->m_zoomLevel < right->d->m_zoomLevel); // lower zoom level comes first
+ }
+
+ if (left->d->m_popularity != right->d->m_popularity) {
+ return left->d->m_popularity > right->d->m_popularity; // higher popularity comes first
+ }
+
+ return left < right; // lower pointer value comes first
+}
+
GeoDataCoordinates GeoDataPlacemark::coordinate( const QDateTime &dateTime, bool *iconAtCoordinates ) const
{
bool hasIcon = false;
diff --git a/src/lib/marble/geodata/data/GeoDataPlacemark.h b/src/lib/marble/geodata/data/GeoDataPlacemark.h
index ad9f434..1de60d9 100644
--- a/src/lib/marble/geodata/data/GeoDataPlacemark.h
+++ b/src/lib/marble/geodata/data/GeoDataPlacemark.h
@@ -234,6 +234,8 @@ class GEODATA_EXPORT GeoDataPlacemark: public GeoDataFeature
const GeoDataLookAt *lookAt() const;
GeoDataLookAt *lookAt();
+ static bool placemarkLayoutOrderCompare(const GeoDataPlacemark *a, const GeoDataPlacemark* b);
+
private:
GeoDataPlacemarkPrivate *p();
const GeoDataPlacemarkPrivate *p() const;