Skip to content
Permalink
Browse files

Allow editing when _any_ of the editing capabilities is supported by …

…data provider

(instead of checking only AddFeatures)


git-svn-id: http://svn.osgeo.org/qgis/trunk@9708 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder
wonder committed Nov 25, 2008
1 parent 025b594 commit 538827ccc90f430a713ca517681aeceeda0bfd5b
@@ -28,6 +28,9 @@ class QgsVectorDataProvider : QgsDataProvider
SequentialSelectGeometryAtId = 2048
};

/** bitmask of all provider's editing capabilities */
static const int EditingCapabilities;

/**
* Constructor of the vector provider
* @param uri uniform resource locator (URI) for a dataset
@@ -383,8 +383,7 @@ void QgsLegendLayerFile::addToPopupMenu( QMenu& theMenu, QAction* toggleEditingA

// editing
int cap = vlayer->dataProvider()->capabilities();
if (( cap & QgsVectorDataProvider::AddFeatures )
|| ( cap & QgsVectorDataProvider::DeleteFeatures ) )
if ( cap & QgsVectorDataProvider::EditingCapabilities )
{
if ( toggleEditingAction )
{
@@ -3865,7 +3865,7 @@ void QgisApp::toggleEditing( QgsMapLayer *layer )
if ( !vlayer->isEditable() )
{
vlayer->startEditing();
if ( !( vlayer->dataProvider()->capabilities() & QgsVectorDataProvider::AddFeatures ) )
if ( !( vlayer->dataProvider()->capabilities() & QgsVectorDataProvider::EditingCapabilities ) )
{
QMessageBox::information( 0, tr( "Start editing failed" ), tr( "Provider cannot be opened for editing" ) );
}
@@ -4840,15 +4840,22 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
if ( dprovider )
{
//start editing/stop editing
if ( dprovider->capabilities() & QgsVectorDataProvider::AddFeatures )
if ( dprovider->capabilities() & QgsVectorDataProvider::EditingCapabilities )
{
mActionToggleEditing->setEnabled( true );
mActionToggleEditing->setChecked( vlayer->isEditable() );
mActionPasteFeatures->setEnabled( vlayer->isEditable() && !clipboard()->empty() );
}
else
{
mActionToggleEditing->setEnabled( false );
}

if ( dprovider->capabilities() & QgsVectorDataProvider::AddFeatures )
{
mActionPasteFeatures->setEnabled( vlayer->isEditable() && !clipboard()->empty() );
}
else
{
mActionPasteFeatures->setEnabled( false );
}

@@ -4863,19 +4870,26 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
mActionDeleteSelected->setEnabled( false );
mActionCutFeatures->setEnabled( false );
}


// moving enabled if geometry changes are supported
if ( vlayer->isEditable() && dprovider->capabilities() & QgsVectorDataProvider::ChangeGeometries )
{
mActionMoveFeature->setEnabled( true );
}
else
{
mActionMoveFeature->setEnabled( false );
}

if ( vlayer->geometryType() == QGis::Point )
{
if ( vlayer->isEditable() && dprovider->capabilities() & QgsVectorDataProvider::AddFeatures )
{
mActionCapturePoint->setEnabled( true );
mActionMoveFeature->setEnabled( true );
}
else
{
mActionCapturePoint->setEnabled( false );
mActionMoveFeature->setEnabled( false );
}
mActionCaptureLine->setEnabled( false );
mActionCapturePolygon->setEnabled( false );
@@ -4892,7 +4906,6 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
{
mActionMoveVertex->setEnabled( true );
}
mActionMoveFeature->setEnabled( true );
}
return;
}
@@ -4902,13 +4915,11 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
{
mActionCaptureLine->setEnabled( true );
mActionSplitFeatures->setEnabled( true );
mActionMoveFeature->setEnabled( true );
}
else
{
mActionCaptureLine->setEnabled( false );
mActionSplitFeatures->setEnabled( false );
mActionMoveFeature->setEnabled( false );
}
mActionCapturePoint->setEnabled( false );
mActionCapturePolygon->setEnabled( false );
@@ -4923,15 +4934,13 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
mActionAddRing->setEnabled( true );
mActionAddIsland->setEnabled( true );
mActionSplitFeatures->setEnabled( true );
mActionMoveFeature->setEnabled( true );
}
else
{
mActionCapturePolygon->setEnabled( false );
mActionAddRing->setEnabled( false );
mActionAddIsland->setEnabled( false );
mActionSplitFeatures->setEnabled( false );
mActionMoveFeature->setEnabled( false );
}
mActionCapturePoint->setEnabled( false );
mActionCaptureLine->setEnabled( false );
@@ -4943,7 +4952,6 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
mActionAddVertex->setEnabled( true );
mActionMoveVertex->setEnabled( true );
mActionDeleteVertex->setEnabled( true );
mActionMoveFeature->setEnabled( true );
if ( vlayer->geometryType() == QGis::Polygon )
{
mActionAddRing->setEnabled( true );
@@ -4957,7 +4965,6 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
mActionAddVertex->setEnabled( false );
mActionMoveVertex->setEnabled( false );
mActionDeleteVertex->setEnabled( false );
mActionMoveFeature->setEnabled( false );
}
return;
}
@@ -64,6 +64,10 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
RandomSelectGeometryAtId = 1 << 10,
SequentialSelectGeometryAtId = 1 << 11
};

/** bitmask of all provider's editing capabilities */
const static int EditingCapabilities = AddFeatures | DeleteFeatures |
ChangeAttributeValues | ChangeGeometries | AddAttributes | DeleteAttributes;

/**
* Constructor of the vector provider
@@ -1977,7 +1977,8 @@ bool QgsVectorLayer::startEditing()
return false;
}

if ( !( mDataProvider->capabilities() & QgsVectorDataProvider::AddFeatures ) )
// allow editing if provider supports any of the capabilities
if ( !( mDataProvider->capabilities() & QgsVectorDataProvider::EditingCapabilities ) )
{
return false;
}

0 comments on commit 538827c

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