Skip to content
Permalink
Browse files
Some cleanup and renaming
  • Loading branch information
pblottiere committed Sep 6, 2017
1 parent eb725f3 commit 7ef2e70
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 34 deletions.
@@ -316,7 +316,7 @@ class QgsVectorLayer : QgsMapLayer, QgsExpressionContextGenerator, QgsFeatureSin

QgsVectorLayer( const QString &path = QString(), const QString &baseName = QString(),
const QString &providerLib = "ogr", bool loadDefaultStyleFlag = true,
bool readExtent = false );
bool readExtentFromXml = false );
%Docstring
Constructor - creates a vector layer

@@ -329,7 +329,7 @@ class QgsVectorLayer : QgsMapLayer, QgsExpressionContextGenerator, QgsFeatureSin
\param baseName The name used to represent the layer in the legend
\param providerLib The name of the data provider, e.g., "memory", "postgres"
\param loadDefaultStyleFlag whether to load the default style
\param readExtent Read extent from XML if true or let provider determine it if false
\param readExtentFromXml Read extent from XML if true or let provider determine it if false
%End


@@ -1729,16 +1729,16 @@ Returns the current blending mode for features
.. versionadded:: 3.0
%End

void setReadExtent( bool readExtent );
void setReadExtentFromXml( bool readExtentFromXml );
%Docstring
Flag allowing to indicate if the extent has be read from the XML
Flag allowing to indicate if the extent has to be read from the XML
document when data source has no metadata or if the data provider has
to determine it.

.. versionadded:: 3.0
%End

bool readExtent() const;
bool readExtentFromXml() const;
%Docstring
Returns true if the extent is read from the XML document when data
source has no metadata, false if it's the data provider which determines
@@ -720,12 +720,10 @@ bool QgsProject::addLayer( const QDomElement &layerElem, QList<QDomNode> &broken

// apply specific settings to vector layer
QgsSettings s;
bool trustProject = s.value( QStringLiteral( "/qgis/trustProject" ), false ).toBool();
if ( QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( mapLayer ) )
{
if ( s.value( QStringLiteral( "/qgis/trustProject" ), false ).toBool() )
{
vl->setReadExtent( true );
}
vl->setReadExtentFromXml( trustProject );
}
}
else if ( type == QLatin1String( "raster" ) )
@@ -134,7 +134,7 @@ QgsVectorLayer::QgsVectorLayer( const QString &vectorLayerPath,
const QString &baseName,
const QString &providerKey,
bool loadDefaultStyleFlag,
bool readExtent )
bool readExtentFromXml )
: QgsMapLayer( VectorLayer, baseName, vectorLayerPath )
, mDataProvider( nullptr )
, mProviderKey( providerKey )
@@ -154,7 +154,7 @@ QgsVectorLayer::QgsVectorLayer( const QString &vectorLayerPath,
, mLazyExtent( true )
, mSymbolFeatureCounted( false )
, mEditCommandActive( false )
, mReadExtent( readExtent )
, mReadExtentFromXml( readExtentFromXml )

{
mActions = new QgsActionManager( this );
@@ -224,7 +224,7 @@ QgsVectorLayer *QgsVectorLayer::clone() const
layer->setAttributeTableConfig( attributeTableConfig() );
layer->setFeatureBlendMode( featureBlendMode() );
layer->setOpacity( opacity() );
layer->setReadExtent( readExtent() );
layer->setReadExtentFromXml( readExtentFromXml() );

Q_FOREACH ( const QgsAction &action, actions()->actions() )
{
@@ -785,7 +785,7 @@ bool QgsVectorLayer::countSymbolFeatures()
void QgsVectorLayer::updateExtents( bool force )
{
// do not update extent by default when trust project option is activated
if ( force || !mReadExtent || ( mReadExtent && mXmlExtent.isNull() ) )
if ( force || !mReadExtentFromXml || ( mReadExtentFromXml && mXmlExtent.isNull() ) )
mValidExtent = false;
}

@@ -803,7 +803,7 @@ QgsRectangle QgsVectorLayer::extent() const
if ( !isSpatial() )
return rect;

if ( !mValidExtent && mDataProvider && mReadExtent && !mXmlExtent.isNull() )
if ( !mValidExtent && mDataProvider && !mDataProvider->hasMetadata() && mReadExtentFromXml && !mXmlExtent.isNull() )
{
mExtent = mXmlExtent;
mValidExtent = true;
@@ -812,13 +812,8 @@ QgsRectangle QgsVectorLayer::extent() const

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

// get the extent data provider if not yet defined
if ( mbr.isNull() )
{
mbr = mDataProvider->extent();
}
// get the extent
QgsRectangle mbr = mDataProvider->extent();

// show the extent
QgsDebugMsg( "Extent of layer: " + mbr.toString() );
@@ -1446,7 +1441,7 @@ bool QgsVectorLayer::readXml( const QDomNode &layer_node, const QgsReadWriteCont
setLegend( QgsMapLayerLegend::defaultVectorLegend( this ) );

// read extent
if ( mReadExtent )
if ( mReadExtentFromXml )
{
QDomNode extentNode = layer_node.namedItem( QStringLiteral( "extent" ) );
if ( !extentNode.isNull() )
@@ -4446,12 +4441,12 @@ QgsAbstractVectorLayerLabeling *QgsVectorLayer::readLabelingFromCustomProperties
return labeling;
}

void QgsVectorLayer::setReadExtent( bool readExtent )
void QgsVectorLayer::setReadExtentFromXml( bool readExtentFromXml )
{
mReadExtent = readExtent;
mReadExtentFromXml = readExtentFromXml;
}

bool QgsVectorLayer::readExtent() const
bool QgsVectorLayer::readExtentFromXml() const
{
return mReadExtent;
return mReadExtentFromXml;
}
@@ -389,12 +389,12 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
* \param baseName The name used to represent the layer in the legend
* \param providerLib The name of the data provider, e.g., "memory", "postgres"
* \param loadDefaultStyleFlag whether to load the default style
* \param readExtent Read extent from XML if true or let provider determine it if false
* \param readExtentFromXml Read extent from XML if true or let provider determine it if false
*
*/
QgsVectorLayer( const QString &path = QString(), const QString &baseName = QString(),
const QString &providerLib = "ogr", bool loadDefaultStyleFlag = true,
bool readExtent = false );
bool readExtentFromXml = false );


virtual ~QgsVectorLayer();
@@ -1607,13 +1607,13 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
void setEditFormConfig( const QgsEditFormConfig &editFormConfig );

/**
* Flag allowing to indicate if the extent has be read from the XML
* Flag allowing to indicate if the extent has to be read from the XML
* document when data source has no metadata or if the data provider has
* to determine it.
*
* \since QGIS 3.0
*/
void setReadExtent( bool readExtent );
void setReadExtentFromXml( bool readExtentFromXml );

/**
* Returns true if the extent is read from the XML document when data
@@ -1622,7 +1622,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
*
* \since QGIS 3.0
*/
bool readExtent() const;
bool readExtentFromXml() const;

public slots:

@@ -2063,7 +2063,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
//! True while an undo command is active
bool mEditCommandActive;

bool mReadExtent;
bool mReadExtentFromXml;
QgsRectangle mXmlExtent;

QgsFeatureIds mDeletedFids;
@@ -759,7 +759,7 @@ def testReadExtentOnView(self):
# read xml with custom extent with readExtent option. Extent read from
# xml document should be used because we have a view
vl2 = QgsVectorLayer()
vl2.setReadExtent(True)
vl2.setReadExtentFromXml(True)
vl2.readLayerXml(elem, QgsReadWriteContext())
self.assertTrue(vl2.isValid())

@@ -793,7 +793,7 @@ def testReadExtentOnTable(self):
# xml document should NOT be used because we don't have a view or a
# materialized view
vl2 = QgsVectorLayer()
vl2.setReadExtent(True)
vl2.setReadExtentFromXml(True)
vl2.readLayerXml(elem, QgsReadWriteContext())
self.assertTrue(vl2.isValid())

0 comments on commit 7ef2e70

Please sign in to comment.