diff options
author | Paolo Angelelli <paolo.angelelli@qt.io> | 2017-12-11 14:57:11 +0100 |
---|---|---|
committer | Paolo Angelelli <paolo.angelelli@qt.io> | 2018-01-15 09:06:27 +0000 |
commit | 2b6020a59ef503eeadabc532782f5e9e795fcf3f (patch) | |
tree | 2163c77dd21fef3ad21c650c3e68da1a3dea4a7e /src/location/declarativemaps/qdeclarativegeomap.cpp | |
parent | 7b8ab37beaafbe27c258a6d80d1914f982dcc9e1 (diff) | |
download | qtlocation-2b6020a59ef503eeadabc532782f5e9e795fcf3f.tar.gz |
Fix performance issue with copyright notice
Skip evaluating copyrights when the notice is not visible.
The implication of this patch is that copyright information
won't be up to date or even available unless there is an
"attached" copyright notice that has the visible property
set to true.
Task-number: QTBUG-64880
Change-Id: I3750b61913becb0cbf31273ad9a76ae1a2b6a393
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/location/declarativemaps/qdeclarativegeomap.cpp')
-rw-r--r-- | src/location/declarativemaps/qdeclarativegeomap.cpp | 57 |
1 files changed, 37 insertions, 20 deletions
diff --git a/src/location/declarativemaps/qdeclarativegeomap.cpp b/src/location/declarativemaps/qdeclarativegeomap.cpp index 52610ab6..2ee6836b 100644 --- a/src/location/declarativemaps/qdeclarativegeomap.cpp +++ b/src/location/declarativemaps/qdeclarativegeomap.cpp @@ -239,7 +239,8 @@ QDeclarativeGeoMap::~QDeclarativeGeoMap() } m_mapItemGroups.clear(); - delete m_copyrights.data(); + if (m_copyrights.data()) + delete m_copyrights.data(); m_copyrights.clear(); delete m_map; @@ -250,7 +251,7 @@ QDeclarativeGeoMap::~QDeclarativeGeoMap() */ void QDeclarativeGeoMap::onMapChildrenChanged() { - if (!m_componentCompleted || !m_map) + if (!m_componentCompleted || !m_initialized) return; int maxChildZ = 0; @@ -423,7 +424,7 @@ void QDeclarativeGeoMap::initialize() emit mapReadyChanged(true); - if (m_copyrights) + if (m_copyrights) // To not update during initialize() update(); } @@ -720,7 +721,6 @@ void QDeclarativeGeoMap::onCameraCapabilitiesChanged(const QGeoCameraCapabilitie } } - /*! \internal this function will only be ever called once @@ -732,6 +732,11 @@ void QDeclarativeGeoMap::mappingManagerInitialized() if (!m_map) return; + /* COPY NOTICE SETUP */ + m_copyrights = new QDeclarativeGeoMapCopyrightNotice(this); + m_copyrights->setCopyrightsVisible(m_copyrightsVisible); + m_copyrights->setMapSource(this); + m_gestureArea->setMap(m_map); QList<QGeoMapType> types = m_mappingManager->supportedMapTypes(); @@ -775,40 +780,26 @@ void QDeclarativeGeoMap::mappingManagerInitialized() QOverload<const QImage &>::of(&QGeoMap::copyrightsChanged), [©rightImage](const QImage ©){ copyrightImage = copy; }); m_map->setViewportSize(QSize(width(), height())); - initialize(); + initialize(); // This emits the caught signals above QObject::disconnect(copyrightStringCatcherConnection); QObject::disconnect(copyrightImageCatcherConnection); } - m_copyrights = new QDeclarativeGeoMapCopyrightNotice(this); - m_copyrights->onCopyrightsStyleSheetChanged(m_map->copyrightsStyleSheet()); - connect(m_map, SIGNAL(copyrightsChanged(QImage)), - m_copyrights.data(), SLOT(copyrightsChanged(QImage))); + /* COPYRIGHT SIGNALS REWIRING */ connect(m_map, SIGNAL(copyrightsChanged(QImage)), this, SIGNAL(copyrightsChanged(QImage))); - - connect(m_map, SIGNAL(copyrightsChanged(QString)), - m_copyrights.data(), SLOT(copyrightsChanged(QString))); connect(m_map, SIGNAL(copyrightsChanged(QString)), this, SIGNAL(copyrightsChanged(QString))); - if (!copyrightString.isEmpty()) emit m_map->copyrightsChanged(copyrightString); else if (!copyrightImage.isNull()) emit m_map->copyrightsChanged(copyrightImage); - connect(m_map, SIGNAL(copyrightsStyleSheetChanged(QString)), - m_copyrights.data(), SLOT(onCopyrightsStyleSheetChanged(QString))); - connect(m_copyrights.data(), SIGNAL(linkActivated(QString)), - this, SIGNAL(copyrightLinkActivated(QString))); connect(m_map, &QGeoMap::sgNodeChanged, this, &QQuickItem::update); connect(m_map, &QGeoMap::cameraCapabilitiesChanged, this, &QDeclarativeGeoMap::onCameraCapabilitiesChanged); - // set visibility of copyright notice - m_copyrights->setCopyrightsVisible(m_copyrightsVisible); - // This prefetches a buffer around the map m_map->prefetchData(); @@ -1604,6 +1595,32 @@ bool QDeclarativeGeoMap::isInteractive() return (m_gestureArea->enabled() && m_gestureArea->acceptedGestures()) || m_gestureArea->isActive(); } +void QDeclarativeGeoMap::attachCopyrightNotice(bool initialVisibility) +{ + if (initialVisibility) { + ++m_copyNoticesVisible; + if (m_map) + m_map->setCopyrightVisible(m_copyNoticesVisible > 0); + } +} + +void QDeclarativeGeoMap::detachCopyrightNotice(bool currentVisibility) +{ + if (currentVisibility) { + --m_copyNoticesVisible; + if (m_map) + m_map->setCopyrightVisible(m_copyNoticesVisible > 0); + } +} + +void QDeclarativeGeoMap::onAttachedCopyrightNoticeVisibilityChanged() +{ + QDeclarativeGeoMapCopyrightNotice *copy = static_cast<QDeclarativeGeoMapCopyrightNotice *>(sender()); + m_copyNoticesVisible += ( int(copy->copyrightsVisible()) * 2 - 1); + if (m_map) + m_map->setCopyrightVisible(m_copyNoticesVisible > 0); +} + /*! \internal */ |