Skip to content
Permalink
Browse files

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@11137 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder
wonder committed Jul 21, 2009
1 parent 2360886 commit 8b1fb78d8da43801b8c2163bcb4be4c51717e69e
@@ -48,7 +48,11 @@ QgsAttributeTableView::QgsAttributeTableView( QWidget* parent )

void QgsAttributeTableView::setLayer( QgsVectorLayer* layer )
{
if ( layer->dataProvider()->capabilities() & QgsVectorDataProvider::RandomSelectGeometryAtId )
// in case the provider allows fast access to features
// we will use the model that calls featureAtId() to fetch only the
// features in the current view. Otherwise we'll have to store
// everything in the memory because using featureAtId() would be too slow
if ( layer->dataProvider()->capabilities() & QgsVectorDataProvider::SelectAtId )
mModel = new QgsAttributeTableModel( layer );
else
mModel = new QgsAttributeTableMemoryModel( layer );
@@ -198,8 +198,7 @@ QString QgsVectorDataProvider::capabilitiesString() const

if ( abilities & QgsVectorDataProvider::SelectAtId )
{
// Not really meaningful to the user.
// abilitiesList += "Select at ID";
abilitiesList += "Fast Access to Features at ID";
QgsDebugMsg( "Capability: Select at ID" );
}

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

if ( abilities & QgsVectorDataProvider::SelectGeometryAtId )
{

if ( abilities & QgsVectorDataProvider::RandomSelectGeometryAtId )
{
abilitiesList += "Select Geometries by ID (random access)";
QgsDebugMsg( "Capability: Select Geometries by ID (random access)" );
}
else if ( abilities & QgsVectorDataProvider::SequentialSelectGeometryAtId )
{
abilitiesList += "Select Geometries by ID (sequential access)";
QgsDebugMsg( "Capability: Select Geometries by ID (sequential access)" );
}
else
{
abilitiesList += "Select Geometries by ID (unknown access method)";
QgsDebugMsg( "Capability: Select Geometries by ID (unknown access method)" );
}
}

return abilitiesList.join( ", " );

}
@@ -47,18 +47,31 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
*/
enum Capability
{
/** provider has no capabilities */
NoCapabilities = 0,
/** allows adding features */
AddFeatures = 1,
/** allows deletion of features */
DeleteFeatures = 1 << 1,
/** allows modification of attribute values */
ChangeAttributeValues = 1 << 2,
/** allows addition of new attributes (fields) */
AddAttributes = 1 << 3,
/** allows deletion of attributes (fields) */
DeleteAttributes = 1 << 4,
/** DEPRECATED - do not use */
SaveAsShapefile = 1 << 5,
/** allows creation of spatial index */
CreateSpatialIndex = 1 << 6,
/** fast access to features using their ID */
SelectAtId = 1 << 7,
/** allows modifications of geometries */
ChangeGeometries = 1 << 8,
/** DEPRECATED - do not use */
SelectGeometryAtId = 1 << 9,
/** DEPRECATED - do not use */
RandomSelectGeometryAtId = 1 << 10,
/** DEPRECATED - do not use */
SequentialSelectGeometryAtId = 1 << 11
};

@@ -506,7 +506,7 @@ bool QgsDelimitedTextProvider::boundsCheck( double x, double y )

int QgsDelimitedTextProvider::capabilities() const
{
return 0;
return NoCapabilities;
}


@@ -360,7 +360,7 @@ int QgsMemoryProvider::capabilities() const
{
return AddFeatures | DeleteFeatures | ChangeGeometries |
ChangeAttributeValues | AddAttributes | DeleteAttributes | CreateSpatialIndex |
SelectAtId | SelectGeometryAtId | RandomSelectGeometryAtId | SequentialSelectGeometryAtId;
SelectAtId | SelectGeometryAtId;
}


@@ -896,13 +896,9 @@ int QgsOgrProvider::capabilities() const
// TODO: Perhaps influence if QGIS caches into memory
// (vs read from disk every time) based on this setting.
{
ability |= QgsVectorDataProvider::RandomSelectGeometryAtId;
// the latter flag is here just for compatibility
ability |= QgsVectorDataProvider::SelectAtId | QgsVectorDataProvider::SelectGeometryAtId;
}
else
{
ability |= QgsVectorDataProvider::SequentialSelectGeometryAtId;
}
ability |= QgsVectorDataProvider::SelectGeometryAtId;

if ( OGR_L_TestCapability( ogrLayer, "SequentialWrite" ) )
// TRUE if the CreateFeature() method works for this layer.
@@ -131,7 +131,9 @@ QgsPostgresProvider::QgsPostgresProvider( QString const & uri )
return;
}

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

if ( QString::fromUtf8( PQgetvalue( testAccess, 0, 0 ) ) == "t" )
{
@@ -71,7 +71,7 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri ): QgsVectorDat
}
sqliteHandle = handle->handle();

enabledCapabilities = QgsVectorDataProvider::SelectGeometryAtId;
enabledCapabilities = QgsVectorDataProvider::SelectAtId | QgsVectorDataProvider::SelectGeometryAtId;
enabledCapabilities |= QgsVectorDataProvider::DeleteFeatures;
enabledCapabilities |= QgsVectorDataProvider::ChangeGeometries;
enabledCapabilities |= QgsVectorDataProvider::ChangeAttributeValues;

0 comments on commit 8b1fb78

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