Skip to content

Commit

Permalink
[quick] do not refresh map on click
Browse files Browse the repository at this point in the history
Whenever user would click on the map (e.g. to identify a feature),
the freeze and subsequent unfreeze would force map refresh even though
it is not needed. A new internal flag is introduced to avoid
the unnecessary map refresh in cases when map has not been moved nor zoomed.
  • Loading branch information
wonder-sk committed Feb 22, 2019
1 parent 0a0d2e9 commit 057b225
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/quickgui/qgsquickmapcanvasmap.cpp
Expand Up @@ -67,6 +67,7 @@ void QgsQuickMapCanvasMap::zoom( QPointF center, qreal scale )
// same as zoomWithCenter (no coordinate transformations are needed)
extent.scale( scale, &newCenter );
mMapSettings->setExtent( extent );
mNeedsRefresh = true;
}

void QgsQuickMapCanvasMap::pan( QPointF oldPos, QPointF newPos )
Expand All @@ -86,6 +87,7 @@ void QgsQuickMapCanvasMap::pan( QPointF oldPos, QPointF newPos )
extent.setYMinimum( extent.yMinimum() + dy );

mMapSettings->setExtent( extent );
mNeedsRefresh = true;
}

void QgsQuickMapCanvasMap::refreshMap()
Expand Down Expand Up @@ -257,8 +259,13 @@ void QgsQuickMapCanvasMap::setFreeze( bool freeze )

mFreeze = freeze;

if ( !mFreeze )
if ( !mFreeze && mNeedsRefresh )
{
refresh();
}

// we are freezing or unfreezing - either way we can reset "needs refresh"
mNeedsRefresh = false;

emit freezeChanged();
}
Expand Down
1 change: 1 addition & 0 deletions src/quickgui/qgsquickmapcanvasmap.h
Expand Up @@ -196,6 +196,7 @@ class QUICK_EXPORT QgsQuickMapCanvasMap : public QQuickItem
QTimer mRefreshTimer;
bool mDirty = false;
bool mFreeze = false;
bool mNeedsRefresh = false; //!< Whether refresh is needed after unfreezing
QList<QMetaObject::Connection> mLayerConnections;
QTimer mMapUpdateTimer;
bool mIncrementalRendering = false;
Expand Down

0 comments on commit 057b225

Please sign in to comment.