Skip to content
Permalink
Browse files

[FEATURE] add update extent button in vector layer properties

and implement QgsDataProvider::updateExtents in postgres, ogr and
spatialite provider
  • Loading branch information
jef-n committed Jan 20, 2012
1 parent 3e91332 commit 2d8b1ab33dc2d93f0d114de98158d25399e10347
@@ -1255,6 +1255,12 @@ void QgsVectorLayerProperties::updateSymbologyPage()
}
}

void QgsVectorLayerProperties::on_pbnUpdateExtents_clicked()
{
layer->updateExtents();
mMetadataFilled = false;
}

void QgsVectorLayerProperties::on_tabWidget_currentChanged( int index )
{
if ( index != 4 || mMetadataFilled )
@@ -113,6 +113,7 @@ class QgsVectorLayerProperties : public QDialog, private Ui::QgsVectorLayerPrope
void on_mFindMaximumValueButton_clicked();
void on_mBackgroundColorButton_clicked();
void on_mDiagramPenColorButton_clicked();
void on_pbnUpdateExtents_clicked();

void enableLabelOptions( bool theFlag );
void addAttribute();
2 src/core/qgsvectorlayer.cpp 100644 → 100755
@@ -1461,6 +1461,8 @@ void QgsVectorLayer::updateExtents()

if ( mDeletedFeatureIds.isEmpty() && mChangedGeometries.isEmpty() )
{
mDataProvider->updateExtents();

// get the extent of the layer from the provider
// but only when there are some features already
if ( mDataProvider->featureCount() != 0 )
@@ -869,6 +869,14 @@ QgsRectangle QgsOgrProvider::extent()
return mExtentRect;
}

void QgsOgrProvider::updateExtents()
{
if( extent_ )
{
free( extent_ );
extent_ = 0;
}
}

size_t QgsOgrProvider::layerCount() const
{
@@ -156,6 +156,10 @@ class QgsOgrProvider : public QgsVectorDataProvider
*/
virtual QgsRectangle extent();

/** Update the extents
*/
virtual void updateExtents();

/** Restart reading features from previous select operation */
virtual void rewind();

@@ -442,7 +442,7 @@ bool QgsPostgresProvider::getFeature( QgsPostgresResult &queryResult, int row, b
col++;
}

QgsFeatureId fid;
QgsFeatureId fid = 0;

switch ( mPrimaryKeyType )
{
@@ -2580,6 +2580,11 @@ QgsRectangle QgsPostgresProvider::extent()
return mLayerExtent;
}

void QgsPostgresProvider::updateExtents()
{
mLayerExtent.setMinimal();
}

bool QgsPostgresProvider::getGeometryDetails()
{
if ( mGeometryColumn.isNull() )
@@ -2663,7 +2668,7 @@ bool QgsPostgresProvider::getGeometryDetails()
.arg( quotedValue( schemaName ) );

QgsDebugMsg( "Getting geography column: " + sql );
result = mConnectionRO->PQexec( sql );
result = mConnectionRO->PQexec( sql, false );
QgsDebugMsg( "Geography column query returned " + QString::number( result.PQntuples() ) );

if ( result.PQntuples() == 1 )
@@ -154,6 +154,10 @@ class QgsPostgresProvider : public QgsVectorDataProvider
*/
virtual QgsRectangle extent();

/** Update the extent
*/
virtual void updateExtents();

/** Determine the fields making up the primary key
*/
bool determinePrimaryKey();
@@ -3301,6 +3301,10 @@ QgsRectangle QgsSpatiaLiteProvider::extent()
return layerExtent;
}

void QgsSpatiaLiteProvider::updateExtents()
{
getTableSummary();
}

size_t QgsSpatiaLiteProvider::layerCount() const
{
@@ -148,6 +148,10 @@ class QgsSpatiaLiteProvider: public QgsVectorDataProvider
*/
virtual QgsRectangle extent();

/** Update the extent for this data layer
*/
virtual void updateExtents();

/** * Get the name of the primary key for the layer
*/
QString getPrimaryKey();
@@ -330,8 +330,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>746</width>
<height>569</height>
<width>736</width>
<height>542</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_3">
@@ -351,19 +351,6 @@
<item row="0" column="1">
<widget class="QLineEdit" name="txtDisplayName"/>
</item>
<item row="0" column="2">
<widget class="QLabel" name="textLabel2">
<property name="toolTip">
<string>Display field for the Identify Results dialog box</string>
</property>
<property name="whatsThis">
<string>This sets the display field for the Identify Results dialog box</string>
</property>
<property name="text">
<string>Display field</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QComboBox" name="displayFieldComboBox">
<property name="whatsThis">
@@ -399,24 +386,14 @@
</property>
</widget>
</item>
<item row="3" column="0" colspan="3">
<item row="4" column="0" colspan="3">
<widget class="QLineEdit" name="leSpatialRefSys">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1" colspan="3">
<widget class="QLineEdit" name="leEditFormInit"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Init function</string>
</property>
</widget>
</item>
<item row="3" column="3">
<item row="4" column="3">
<widget class="QPushButton" name="pbnChangeSpatialRefSys">
<property name="toolTip">
<string>Specify the coordinate reference system of the layer's geometry.</string>
@@ -429,6 +406,36 @@
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="textLabel2">
<property name="toolTip">
<string>Display field for the Identify Results dialog box</string>
</property>
<property name="whatsThis">
<string>This sets the display field for the Identify Results dialog box</string>
</property>
<property name="text">
<string>Display field</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QPushButton" name="pbnUpdateExtents">
<property name="text">
<string>Update Extents</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QLineEdit" name="leEditFormInit"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Init function</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@@ -521,6 +528,9 @@
<string>Provider-specific options</string>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">

0 comments on commit 2d8b1ab

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