Commit 1082ea5d authored by Dennis Nienhüser's avatar Dennis Nienhüser
Browse files

Move placemarkLayoutOrderCompare to GeoDataPlacemark

Replaced getter function calls with direct private member access to
avoid the function call overhead during sorting
parent d6099968
......@@ -39,20 +39,6 @@
#include "VisiblePlacemark.h"
#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 );
......
......@@ -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;
......
......@@ -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;
......
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