Skip to content

Commit 2d8b1ab

Browse files
committedJan 20, 2012
[FEATURE] add update extent button in vector layer properties
and implement QgsDataProvider::updateExtents in postgres, ogr and spatialite provider
1 parent 3e91332 commit 2d8b1ab

10 files changed

+77
-29
lines changed
 

‎src/app/qgsvectorlayerproperties.cpp

100644100755
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,6 +1255,12 @@ void QgsVectorLayerProperties::updateSymbologyPage()
12551255
}
12561256
}
12571257

1258+
void QgsVectorLayerProperties::on_pbnUpdateExtents_clicked()
1259+
{
1260+
layer->updateExtents();
1261+
mMetadataFilled = false;
1262+
}
1263+
12581264
void QgsVectorLayerProperties::on_tabWidget_currentChanged( int index )
12591265
{
12601266
if ( index != 4 || mMetadataFilled )

‎src/app/qgsvectorlayerproperties.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ class QgsVectorLayerProperties : public QDialog, private Ui::QgsVectorLayerPrope
113113
void on_mFindMaximumValueButton_clicked();
114114
void on_mBackgroundColorButton_clicked();
115115
void on_mDiagramPenColorButton_clicked();
116+
void on_pbnUpdateExtents_clicked();
116117

117118
void enableLabelOptions( bool theFlag );
118119
void addAttribute();

‎src/core/qgsvectorlayer.cpp

100644100755
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,6 +1461,8 @@ void QgsVectorLayer::updateExtents()
14611461

14621462
if ( mDeletedFeatureIds.isEmpty() && mChangedGeometries.isEmpty() )
14631463
{
1464+
mDataProvider->updateExtents();
1465+
14641466
// get the extent of the layer from the provider
14651467
// but only when there are some features already
14661468
if ( mDataProvider->featureCount() != 0 )

‎src/providers/ogr/qgsogrprovider.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,14 @@ QgsRectangle QgsOgrProvider::extent()
869869
return mExtentRect;
870870
}
871871

872+
void QgsOgrProvider::updateExtents()
873+
{
874+
if( extent_ )
875+
{
876+
free( extent_ );
877+
extent_ = 0;
878+
}
879+
}
872880

873881
size_t QgsOgrProvider::layerCount() const
874882
{

‎src/providers/ogr/qgsogrprovider.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ class QgsOgrProvider : public QgsVectorDataProvider
156156
*/
157157
virtual QgsRectangle extent();
158158

159+
/** Update the extents
160+
*/
161+
virtual void updateExtents();
162+
159163
/** Restart reading features from previous select operation */
160164
virtual void rewind();
161165

‎src/providers/postgres/qgspostgresprovider.cpp

100644100755
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ bool QgsPostgresProvider::getFeature( QgsPostgresResult &queryResult, int row, b
442442
col++;
443443
}
444444

445-
QgsFeatureId fid;
445+
QgsFeatureId fid = 0;
446446

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

2583+
void QgsPostgresProvider::updateExtents()
2584+
{
2585+
mLayerExtent.setMinimal();
2586+
}
2587+
25832588
bool QgsPostgresProvider::getGeometryDetails()
25842589
{
25852590
if ( mGeometryColumn.isNull() )
@@ -2663,7 +2668,7 @@ bool QgsPostgresProvider::getGeometryDetails()
26632668
.arg( quotedValue( schemaName ) );
26642669

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

26692674
if ( result.PQntuples() == 1 )

‎src/providers/postgres/qgspostgresprovider.h

100644100755
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ class QgsPostgresProvider : public QgsVectorDataProvider
154154
*/
155155
virtual QgsRectangle extent();
156156

157+
/** Update the extent
158+
*/
159+
virtual void updateExtents();
160+
157161
/** Determine the fields making up the primary key
158162
*/
159163
bool determinePrimaryKey();

‎src/providers/spatialite/qgsspatialiteprovider.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3301,6 +3301,10 @@ QgsRectangle QgsSpatiaLiteProvider::extent()
33013301
return layerExtent;
33023302
}
33033303

3304+
void QgsSpatiaLiteProvider::updateExtents()
3305+
{
3306+
getTableSummary();
3307+
}
33043308

33053309
size_t QgsSpatiaLiteProvider::layerCount() const
33063310
{

‎src/providers/spatialite/qgsspatialiteprovider.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ class QgsSpatiaLiteProvider: public QgsVectorDataProvider
148148
*/
149149
virtual QgsRectangle extent();
150150

151+
/** Update the extent for this data layer
152+
*/
153+
virtual void updateExtents();
154+
151155
/** * Get the name of the primary key for the layer
152156
*/
153157
QString getPrimaryKey();

‎src/ui/qgsvectorlayerpropertiesbase.ui

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,8 @@
330330
<rect>
331331
<x>0</x>
332332
<y>0</y>
333-
<width>746</width>
334-
<height>569</height>
333+
<width>736</width>
334+
<height>542</height>
335335
</rect>
336336
</property>
337337
<layout class="QGridLayout" name="gridLayout_3">
@@ -351,19 +351,6 @@
351351
<item row="0" column="1">
352352
<widget class="QLineEdit" name="txtDisplayName"/>
353353
</item>
354-
<item row="0" column="2">
355-
<widget class="QLabel" name="textLabel2">
356-
<property name="toolTip">
357-
<string>Display field for the Identify Results dialog box</string>
358-
</property>
359-
<property name="whatsThis">
360-
<string>This sets the display field for the Identify Results dialog box</string>
361-
</property>
362-
<property name="text">
363-
<string>Display field</string>
364-
</property>
365-
</widget>
366-
</item>
367354
<item row="0" column="3">
368355
<widget class="QComboBox" name="displayFieldComboBox">
369356
<property name="whatsThis">
@@ -399,24 +386,14 @@
399386
</property>
400387
</widget>
401388
</item>
402-
<item row="3" column="0" colspan="3">
389+
<item row="4" column="0" colspan="3">
403390
<widget class="QLineEdit" name="leSpatialRefSys">
404391
<property name="readOnly">
405392
<bool>true</bool>
406393
</property>
407394
</widget>
408395
</item>
409-
<item row="2" column="1" colspan="3">
410-
<widget class="QLineEdit" name="leEditFormInit"/>
411-
</item>
412-
<item row="2" column="0">
413-
<widget class="QLabel" name="label_3">
414-
<property name="text">
415-
<string>Init function</string>
416-
</property>
417-
</widget>
418-
</item>
419-
<item row="3" column="3">
396+
<item row="4" column="3">
420397
<widget class="QPushButton" name="pbnChangeSpatialRefSys">
421398
<property name="toolTip">
422399
<string>Specify the coordinate reference system of the layer's geometry.</string>
@@ -429,6 +406,36 @@
429406
</property>
430407
</widget>
431408
</item>
409+
<item row="0" column="2">
410+
<widget class="QLabel" name="textLabel2">
411+
<property name="toolTip">
412+
<string>Display field for the Identify Results dialog box</string>
413+
</property>
414+
<property name="whatsThis">
415+
<string>This sets the display field for the Identify Results dialog box</string>
416+
</property>
417+
<property name="text">
418+
<string>Display field</string>
419+
</property>
420+
</widget>
421+
</item>
422+
<item row="2" column="3">
423+
<widget class="QPushButton" name="pbnUpdateExtents">
424+
<property name="text">
425+
<string>Update Extents</string>
426+
</property>
427+
</widget>
428+
</item>
429+
<item row="2" column="1" colspan="2">
430+
<widget class="QLineEdit" name="leEditFormInit"/>
431+
</item>
432+
<item row="2" column="0">
433+
<widget class="QLabel" name="label_3">
434+
<property name="text">
435+
<string>Init function</string>
436+
</property>
437+
</widget>
438+
</item>
432439
</layout>
433440
</widget>
434441
</item>
@@ -521,6 +528,9 @@
521528
<string>Provider-specific options</string>
522529
</property>
523530
<layout class="QFormLayout" name="formLayout">
531+
<property name="fieldGrowthPolicy">
532+
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
533+
</property>
524534
<item row="0" column="0">
525535
<widget class="QLabel" name="label_2">
526536
<property name="text">

0 commit comments

Comments
 (0)
Please sign in to comment.