Skip to content
Permalink
Browse files

Do not update extent by default if trust project option is activated

  • Loading branch information
pblottiere committed Aug 28, 2017
1 parent b55c134 commit eb725f330501d466e0e7fc720744a8421bbbb467
Showing with 19 additions and 12 deletions.
  1. +3 −1 python/core/qgsvectorlayer.sip
  2. +1 −1 src/app/qgsvectorlayerproperties.cpp
  3. +12 −9 src/core/qgsvectorlayer.cpp
  4. +3 −1 src/core/qgsvectorlayer.h
@@ -1793,10 +1793,12 @@ Returns the current blending mode for features
.. seealso:: selectByIds()
%End

virtual void updateExtents();
virtual void updateExtents( bool force = false );
%Docstring
Update the extents for the layer. This is necessary if features are
added/deleted or the layer has been subsetted.

\param force true to update layer extent even if it's read from xml by default, false otherwise
%End

bool startEditing();
@@ -1387,7 +1387,7 @@ void QgsVectorLayerProperties::setPbnQueryBuilderEnabled()

void QgsVectorLayerProperties::on_pbnUpdateExtents_clicked()
{
mLayer->updateExtents();
mLayer->updateExtents( true ); // force update whatever options activated
mMetadataFilled = false;
}

@@ -782,9 +782,11 @@ bool QgsVectorLayer::countSymbolFeatures()
return true;
}

void QgsVectorLayer::updateExtents()
void QgsVectorLayer::updateExtents( bool force )
{
mValidExtent = false;
// do not update extent by default when trust project option is activated
if ( force || !mReadExtent || ( mReadExtent && mXmlExtent.isNull() ) )
mValidExtent = false;
}

void QgsVectorLayer::setExtent( const QgsRectangle &r )
@@ -801,16 +803,17 @@ QgsRectangle QgsVectorLayer::extent() const
if ( !isSpatial() )
return rect;

if ( !mValidExtent && mDataProvider && mReadExtent && !mXmlExtent.isNull() )
{
mExtent = mXmlExtent;
mValidExtent = true;
mLazyExtent = false;
}

if ( !mValidExtent && mLazyExtent && mDataProvider )
{
QgsRectangle mbr;

// get the extent from xml
if ( mReadExtent && !mXmlExtent.isNull() && !mDataProvider->hasMetadata() )
{
mbr = mXmlExtent;
}

// get the extent data provider if not yet defined
if ( mbr.isNull() )
{
@@ -1524,7 +1527,7 @@ bool QgsVectorLayer::setDataProvider( QString const &provider )
}

// TODO: Check if the provider has the capability to send fullExtentCalculated
connect( mDataProvider, &QgsVectorDataProvider::fullExtentCalculated, this, &QgsVectorLayer::updateExtents );
connect( mDataProvider, &QgsVectorDataProvider::fullExtentCalculated, this, [ = ] { updateExtents(); } );

// get and store the feature type
mWkbType = mDataProvider->wkbType();
@@ -1671,8 +1671,10 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte

/** Update the extents for the layer. This is necessary if features are
* added/deleted or the layer has been subsetted.
*
* \param force true to update layer extent even if it's read from xml by default, false otherwise
*/
virtual void updateExtents();
virtual void updateExtents( bool force = false );

/**
* Make layer editable.

0 comments on commit eb725f3

Please sign in to comment.
You can’t perform that action at this time.