Skip to content

Commit 2f68613

Browse files
author
wonder
committed
providers: deprecated some overlapping capabilities and added doxygen docs for them.
All providers should have now correctly set capability for fast access to features by id (SelectAtId). Until now, attribute table was using memory model for Postgres provider (i.e. very slow open) From now it uses the "good" model, so the attribute table opens much faster. git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@11137 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 3a8592b commit 2f68613

8 files changed

+27
-33
lines changed

src/app/attributetable/qgsattributetableview.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ QgsAttributeTableView::QgsAttributeTableView( QWidget* parent )
4848

4949
void QgsAttributeTableView::setLayer( QgsVectorLayer* layer )
5050
{
51-
if ( layer->dataProvider()->capabilities() & QgsVectorDataProvider::RandomSelectGeometryAtId )
51+
// in case the provider allows fast access to features
52+
// we will use the model that calls featureAtId() to fetch only the
53+
// features in the current view. Otherwise we'll have to store
54+
// everything in the memory because using featureAtId() would be too slow
55+
if ( layer->dataProvider()->capabilities() & QgsVectorDataProvider::SelectAtId )
5256
mModel = new QgsAttributeTableModel( layer );
5357
else
5458
mModel = new QgsAttributeTableMemoryModel( layer );

src/core/qgsvectordataprovider.cpp

+1-22
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,7 @@ QString QgsVectorDataProvider::capabilitiesString() const
198198

199199
if ( abilities & QgsVectorDataProvider::SelectAtId )
200200
{
201-
// Not really meaningful to the user.
202-
// abilitiesList += "Select at ID";
201+
abilitiesList += "Fast Access to Features at ID";
203202
QgsDebugMsg( "Capability: Select at ID" );
204203
}
205204

@@ -209,26 +208,6 @@ QString QgsVectorDataProvider::capabilitiesString() const
209208
QgsDebugMsg( "Capability: Change Geometries" );
210209
}
211210

212-
if ( abilities & QgsVectorDataProvider::SelectGeometryAtId )
213-
{
214-
215-
if ( abilities & QgsVectorDataProvider::RandomSelectGeometryAtId )
216-
{
217-
abilitiesList += "Select Geometries by ID (random access)";
218-
QgsDebugMsg( "Capability: Select Geometries by ID (random access)" );
219-
}
220-
else if ( abilities & QgsVectorDataProvider::SequentialSelectGeometryAtId )
221-
{
222-
abilitiesList += "Select Geometries by ID (sequential access)";
223-
QgsDebugMsg( "Capability: Select Geometries by ID (sequential access)" );
224-
}
225-
else
226-
{
227-
abilitiesList += "Select Geometries by ID (unknown access method)";
228-
QgsDebugMsg( "Capability: Select Geometries by ID (unknown access method)" );
229-
}
230-
}
231-
232211
return abilitiesList.join( ", " );
233212

234213
}

src/core/qgsvectordataprovider.h

+13
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,31 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
4747
*/
4848
enum Capability
4949
{
50+
/** provider has no capabilities */
5051
NoCapabilities = 0,
52+
/** allows adding features */
5153
AddFeatures = 1,
54+
/** allows deletion of features */
5255
DeleteFeatures = 1 << 1,
56+
/** allows modification of attribute values */
5357
ChangeAttributeValues = 1 << 2,
58+
/** allows addition of new attributes (fields) */
5459
AddAttributes = 1 << 3,
60+
/** allows deletion of attributes (fields) */
5561
DeleteAttributes = 1 << 4,
62+
/** DEPRECATED - do not use */
5663
SaveAsShapefile = 1 << 5,
64+
/** allows creation of spatial index */
5765
CreateSpatialIndex = 1 << 6,
66+
/** fast access to features using their ID */
5867
SelectAtId = 1 << 7,
68+
/** allows modifications of geometries */
5969
ChangeGeometries = 1 << 8,
70+
/** DEPRECATED - do not use */
6071
SelectGeometryAtId = 1 << 9,
72+
/** DEPRECATED - do not use */
6173
RandomSelectGeometryAtId = 1 << 10,
74+
/** DEPRECATED - do not use */
6275
SequentialSelectGeometryAtId = 1 << 11
6376
};
6477

src/providers/delimitedtext/qgsdelimitedtextprovider.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ bool QgsDelimitedTextProvider::boundsCheck( double x, double y )
506506

507507
int QgsDelimitedTextProvider::capabilities() const
508508
{
509-
return 0;
509+
return NoCapabilities;
510510
}
511511

512512

src/providers/memory/qgsmemoryprovider.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ int QgsMemoryProvider::capabilities() const
360360
{
361361
return AddFeatures | DeleteFeatures | ChangeGeometries |
362362
ChangeAttributeValues | AddAttributes | DeleteAttributes | CreateSpatialIndex |
363-
SelectAtId | SelectGeometryAtId | RandomSelectGeometryAtId | SequentialSelectGeometryAtId;
363+
SelectAtId | SelectGeometryAtId;
364364
}
365365

366366

src/providers/ogr/qgsogrprovider.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -896,13 +896,9 @@ int QgsOgrProvider::capabilities() const
896896
// TODO: Perhaps influence if QGIS caches into memory
897897
// (vs read from disk every time) based on this setting.
898898
{
899-
ability |= QgsVectorDataProvider::RandomSelectGeometryAtId;
899+
// the latter flag is here just for compatibility
900+
ability |= QgsVectorDataProvider::SelectAtId | QgsVectorDataProvider::SelectGeometryAtId;
900901
}
901-
else
902-
{
903-
ability |= QgsVectorDataProvider::SequentialSelectGeometryAtId;
904-
}
905-
ability |= QgsVectorDataProvider::SelectGeometryAtId;
906902

907903
if ( OGR_L_TestCapability( ogrLayer, "SequentialWrite" ) )
908904
// TRUE if the CreateFeature() method works for this layer.

src/providers/postgres/qgspostgresprovider.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ QgsPostgresProvider::QgsPostgresProvider( QString const & uri )
131131
return;
132132
}
133133

134-
enabledCapabilities = QgsVectorDataProvider::SelectGeometryAtId;
134+
// postgres has fast access to features at id (thanks to primary key / unique index)
135+
// the latter flag is here just for compatibility
136+
enabledCapabilities = QgsVectorDataProvider::SelectAtId | QgsVectorDataProvider::SelectGeometryAtId;
135137

136138
if ( QString::fromUtf8( PQgetvalue( testAccess, 0, 0 ) ) == "t" )
137139
{

src/providers/spatialite/qgsspatialiteprovider.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri ): QgsVectorDat
7171
}
7272
sqliteHandle = handle->handle();
7373

74-
enabledCapabilities = QgsVectorDataProvider::SelectGeometryAtId;
74+
enabledCapabilities = QgsVectorDataProvider::SelectAtId | QgsVectorDataProvider::SelectGeometryAtId;
7575
enabledCapabilities |= QgsVectorDataProvider::DeleteFeatures;
7676
enabledCapabilities |= QgsVectorDataProvider::ChangeGeometries;
7777
enabledCapabilities |= QgsVectorDataProvider::ChangeAttributeValues;

0 commit comments

Comments
 (0)