From 7780f858891e5a08fc06b0d9d0d192f89fdcb962 Mon Sep 17 00:00:00 2001 From: Janne Kiiski Date: Wed, 24 Nov 2010 15:10:25 +0200 Subject: [PATCH] function timing macros added to geomap.cpp and logger.h added to project --- src/qmlui/geomap.cpp | 38 ++++++++++++++++++++++++++------------ src/src.pro | 3 ++- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/qmlui/geomap.cpp b/src/qmlui/geomap.cpp index c20c276..649121f 100644 --- a/src/qmlui/geomap.cpp +++ b/src/qmlui/geomap.cpp @@ -1,12 +1,11 @@ #include "geomap.h" -#include #include #include #include "../user/friendmodel.h" #include "../coordinates/geocoordinate.h" #include "../routing/routemodel.h" -#include #include "../ui/avatarimage.h" +#include "../logger.h" using namespace QtMobility; @@ -27,6 +26,8 @@ public: */ void filterCoordinatePoints(QList* geometryPoints) { + DEBUG_FUNCTION_TIME; + // Rough guess for maximum point count for smooth use // Produces max 500+n items to result array (rounding error in division)... static const int MAX_POINT_COUNT = 500; @@ -60,7 +61,7 @@ GeoMap::GeoMap(QGraphicsItem* parent) prevGpsLocation(0,0), initialized(false) { - qDebug() << __PRETTY_FUNCTION__; + DEBUG_FUNCTION_TIME; connect(this, SIGNAL(panned(QPoint)), this, SLOT(panned())); setCenter(prevGpsLocation); @@ -72,11 +73,12 @@ GeoMap::GeoMap(QGraphicsItem* parent) GeoMap::~GeoMap() { - qDebug() << __PRETTY_FUNCTION__; + DEBUG_FUNCTION_TIME; } qreal GeoMap::angleToGpsLocation() const { + DEBUG_FUNCTION_TIME; const qreal result = prevGpsLocation.isValid() ? center().azimuthTo(prevGpsLocation) : 0.0; qDebug() << "QmlMap::angleToGpsLocation: " << result; return result; @@ -84,6 +86,7 @@ qreal GeoMap::angleToGpsLocation() const qreal GeoMap::distanceToGpsLocation() const { + DEBUG_FUNCTION_TIME; const qreal result = prevGpsLocation.isValid() ? center().distanceTo(prevGpsLocation) : 0.0; qDebug() << "QmlMap::distanceToGpsLocation: " << result << " meters"; return result; @@ -91,6 +94,7 @@ qreal GeoMap::distanceToGpsLocation() const QString GeoMap::distanceToGpsLocationText() const { + DEBUG_FUNCTION_TIME; const qreal distance = distanceToGpsLocation(); // copy/paste from: IndicatorButtonPanel::updateValues const int MAX_TO_METERS = 999.5; @@ -118,11 +122,14 @@ QString GeoMap::distanceToGpsLocationText() const return distanceText; } -double GeoMap::centerLatitude() const { +double GeoMap::centerLatitude() const +{ return center().latitude(); } -void GeoMap::setCenterLatitude(const double latitude) { +void GeoMap::setCenterLatitude(const double latitude) +{ + DEBUG_FUNCTION_TIME; QGeoCoordinate newCenter = center(); newCenter.setLatitude(latitude); setCenter(newCenter); @@ -134,7 +141,9 @@ double GeoMap::centerLongitude() const return center().longitude(); } -void GeoMap::setCenterLongitude(const double longitude) { +void GeoMap::setCenterLongitude(const double longitude) +{ + DEBUG_FUNCTION_TIME; QGeoCoordinate newCenter = center(); newCenter.setLongitude(longitude); setCenter(newCenter); @@ -154,6 +163,7 @@ double GeoMap::gpsLocationLongitude() const void GeoMap::setFriendModels(FriendModel* friendModel, FilteredFriendModel* friendFilterModel) { + DEBUG_FUNCTION_TIME; Q_D(GeoMap); Q_ASSERT(friendModel && friendFilterModel); if (friendModel && friendFilterModel) { @@ -165,6 +175,7 @@ void GeoMap::setFriendModels(FriendModel* friendModel, FilteredFriendModel* frie void GeoMap::setRouteModel(RouteModel* routeModel) { + DEBUG_FUNCTION_TIME; Q_D(GeoMap); Q_ASSERT(routeModel); d->routeModel = routeModel; @@ -173,14 +184,15 @@ void GeoMap::setRouteModel(RouteModel* routeModel) void GeoMap::panned() { + DEBUG_FUNCTION_TIME; emit positionChanged(); } void GeoMap::onFriendModelReset() { + DEBUG_FUNCTION_TIME; Q_D(GeoMap); Q_ASSERT(d->friendModel); - foreach(QGeoMapPixmapObject* mapObject, d->friendMapObjects) { removeMapObject(mapObject); delete mapObject; @@ -214,7 +226,7 @@ void GeoMap::onFriendModelReset() void GeoMap::onRouteModelReset() { - qDebug() << __PRETTY_FUNCTION__; + DEBUG_FUNCTION_TIME; Q_D(GeoMap); Q_ASSERT(d->routeModel); @@ -231,10 +243,7 @@ void GeoMap::onRouteModelReset() removeMapObject(d->routeMapObject); } if (!path.isEmpty()) { - qDebug() << "PATH BEFORE: " << path.count(); d->filterCoordinatePoints(&path); - qDebug() << "PATH AFTER: " << path.count(); - d->routeMapObject->setPath(path); QPen pen(Qt::red); pen.setWidth(5); @@ -245,6 +254,7 @@ void GeoMap::onRouteModelReset() void GeoMap::goToGpsLocation() { + DEBUG_FUNCTION_TIME; qDebug() << "QmlMap::goToGpsLocation"; if (!source) source = QGeoPositionInfoSource::createDefaultSource(this); @@ -259,6 +269,7 @@ void GeoMap::goToGpsLocation() void GeoMap::onClicked(qreal mouseX, qreal mouseY) { + DEBUG_FUNCTION_TIME; Q_D(GeoMap); QList mapObjects = mapObjectsAtScreenPosition(QPointF(mouseX, mouseY)); QList filter; @@ -274,11 +285,13 @@ void GeoMap::onClicked(qreal mouseX, qreal mouseY) void GeoMap::zoomIn() { + DEBUG_FUNCTION_TIME; setZoomLevel(zoomLevel() + 1.0); } void GeoMap::zoomOut() { + DEBUG_FUNCTION_TIME; if (zoomLevel() > 2.0) setZoomLevel(zoomLevel() - 1.0); } @@ -286,6 +299,7 @@ void GeoMap::zoomOut() void GeoMap::positionUpdated(const QGeoPositionInfo& positionInfo) { + DEBUG_FUNCTION_TIME; qDebug() << "QmlMap::positionUpdated: " << positionInfo.coordinate(); prevGpsLocation = positionInfo.coordinate(); Q_D(GeoMap); diff --git a/src/src.pro b/src/src.pro index 619e7ba..8bc5cfd 100644 --- a/src/src.pro +++ b/src/src.pro @@ -190,7 +190,8 @@ HEADERS += application.h \ user/profile.h \ qmlui/userimageprovider.h \ routing/searchhistorymodel.h \ - routing/searchresultsmodel.h + routing/searchresultsmodel.h \ + logger.h OTHER_FILES += qmlui/Main.qml \ qmlui/Dialog.qml \ -- 1.7.9.5