Skip to content

Commit

Permalink
[FEATURE] add update extent button in vector layer properties
Browse files Browse the repository at this point in the history
and implement QgsDataProvider::updateExtents in postgres, ogr and
spatialite provider
  • Loading branch information
jef-n committed Jan 20, 2012
1 parent 3e91332 commit 2d8b1ab
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 29 deletions.
6 changes: 6 additions & 0 deletions src/app/qgsvectorlayerproperties.cpp 100644 → 100755
Expand Up @@ -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 )
Expand Down
1 change: 1 addition & 0 deletions src/app/qgsvectorlayerproperties.h
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions src/core/qgsvectorlayer.cpp 100644 → 100755
Expand Up @@ -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 )
Expand Down
8 changes: 8 additions & 0 deletions src/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -869,6 +869,14 @@ QgsRectangle QgsOgrProvider::extent()
return mExtentRect;
}

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

size_t QgsOgrProvider::layerCount() const
{
Expand Down
4 changes: 4 additions & 0 deletions src/providers/ogr/qgsogrprovider.h
Expand Up @@ -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();

Expand Down
9 changes: 7 additions & 2 deletions src/providers/postgres/qgspostgresprovider.cpp 100644 → 100755
Expand Up @@ -442,7 +442,7 @@ bool QgsPostgresProvider::getFeature( QgsPostgresResult &queryResult, int row, b
col++;
}

QgsFeatureId fid;
QgsFeatureId fid = 0;

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

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

bool QgsPostgresProvider::getGeometryDetails()
{
if ( mGeometryColumn.isNull() )
Expand Down Expand Up @@ -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 )
Expand Down
4 changes: 4 additions & 0 deletions src/providers/postgres/qgspostgresprovider.h 100644 → 100755
Expand Up @@ -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();
Expand Down
4 changes: 4 additions & 0 deletions src/providers/spatialite/qgsspatialiteprovider.cpp
Expand Up @@ -3301,6 +3301,10 @@ QgsRectangle QgsSpatiaLiteProvider::extent()
return layerExtent;
}

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

size_t QgsSpatiaLiteProvider::layerCount() const
{
Expand Down
4 changes: 4 additions & 0 deletions src/providers/spatialite/qgsspatialiteprovider.h
Expand Up @@ -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();
Expand Down
64 changes: 37 additions & 27 deletions src/ui/qgsvectorlayerpropertiesbase.ui
Expand Up @@ -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">
Expand All @@ -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">
Expand Down Expand Up @@ -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>
Expand All @@ -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>
Expand Down Expand Up @@ -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">
Expand Down

0 comments on commit 2d8b1ab

Please sign in to comment.