diff options
author | Michal Klocek <michal.klocek@theqtcompany.com> | 2016-03-01 19:35:00 +0100 |
---|---|---|
committer | Michal Klocek <michal.klocek@theqtcompany.com> | 2016-03-17 06:56:33 +0000 |
commit | e176f25daeb3d80af1fd701000fda065064227e1 (patch) | |
tree | 78c52d64b23eba8f5da1b9449edf70106350c942 /src/location/maps/qgeomap.cpp | |
parent | 3cf9f339f2a319d99e81feebb6f5f1e428eec51c (diff) | |
download | qtlocation-e176f25daeb3d80af1fd701000fda065064227e1.tar.gz |
Reduce setCameraData calls to minimum
Remove checks for cameraCapabilities during each
setCameraData call. This checks are already performed
on plugin initialization. Refactor QGeoMapPrivate
to reduce resize calls. Rename updateRequired to sgNodeChanged
to reflect real useage. Add setter setSize for QGeoMap.
Change-Id: If4e3501fa99a8a97cbc471990837b08c43b8e723
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src/location/maps/qgeomap.cpp')
-rw-r--r-- | src/location/maps/qgeomap.cpp | 64 |
1 files changed, 17 insertions, 47 deletions
diff --git a/src/location/maps/qgeomap.cpp b/src/location/maps/qgeomap.cpp index 7817553c..c3b01a3e 100644 --- a/src/location/maps/qgeomap.cpp +++ b/src/location/maps/qgeomap.cpp @@ -51,24 +51,31 @@ QGeoMap::~QGeoMap() { } -void QGeoMap::resize(int width, int height) +void QGeoMap::setSize(const QSize& size) { Q_D(QGeoMap); - d->resize(width, height); - // always emit this signal to trigger items to redraw - emit cameraDataChanged(d->m_cameraData); + if (size == d->m_size) + return; + d->m_size = size; + d->changeMapSize(size); +} + +QSize QGeoMap::size() const +{ + Q_D(const QGeoMap); + return d->m_size; } int QGeoMap::width() const { Q_D(const QGeoMap); - return d->m_width; + return d->m_size.width(); } int QGeoMap::height() const { Q_D(const QGeoMap); - return d->m_height; + return d->m_size.height(); } void QGeoMap::setCameraData(const QGeoCameraData &cameraData) @@ -76,11 +83,8 @@ void QGeoMap::setCameraData(const QGeoCameraData &cameraData) Q_D(QGeoMap); if (cameraData == d->m_cameraData) return; - - d->setCameraData(cameraData); - - update(); - + d->m_cameraData = cameraData; + d->changeCameraData(cameraData); emit cameraDataChanged(d->m_cameraData); } @@ -90,19 +94,14 @@ QGeoCameraData QGeoMap::cameraData() const return d->m_cameraData; } -void QGeoMap::update() -{ - emit updateRequired(); -} - void QGeoMap::setActiveMapType(const QGeoMapType type) { Q_D(QGeoMap); + if (type == d->m_activeMapType) + return; d->m_activeMapType = type; d->changeActiveMapType(type); - d->setCameraData(d->m_cameraData); emit activeMapTypeChanged(); - update(); } const QGeoMapType QGeoMap::activeMapType() const @@ -133,9 +132,6 @@ void QGeoMap::clearData() QGeoMapPrivate::QGeoMapPrivate(QGeoMappingManagerEngine *engine) : QObjectPrivate(), - m_width(0), - m_height(0), - m_aspectRatio(0.0), m_engine(engine), m_activeMapType(QGeoMapType()) { @@ -143,32 +139,6 @@ QGeoMapPrivate::QGeoMapPrivate(QGeoMappingManagerEngine *engine) QGeoMapPrivate::~QGeoMapPrivate() { - // controller_ is a child of map_, don't need to delete it here - - // TODO map items are not deallocated! - // However: how to ensure this is done in rendering thread? -} - -void QGeoMapPrivate::setCameraData(const QGeoCameraData &cameraData) -{ - QGeoCameraData oldCameraData = m_cameraData; - m_cameraData = cameraData; - - // Do not call this expensive function if the width is 0, since it will get called - // anyway when it is resized to a width > 0. - // this is mainly an optimization to the initialization of the geomap, which would otherwise - // call changeCameraData four or more times - if (m_width > 0) - changeCameraData(oldCameraData); -} - -void QGeoMapPrivate::resize(int width, int height) -{ - m_width = width; - m_height = height; - m_aspectRatio = 1.0 * m_width / m_height; - mapResized(width, height); - setCameraData(m_cameraData); } QT_END_NAMESPACE |