Skip to content
Permalink
Browse files

attribute editing: don't allow editing without ChangeAttributeValues …

…capability
  • Loading branch information
jef-n committed Oct 11, 2015
1 parent 84dade9 commit 15af5a11701fc8f0b3723b2d45423c19b07e4df5
Showing with 8 additions and 2 deletions.
  1. +4 −1 src/gui/attributetable/qgsattributetablemodel.cpp
  2. +4 −1 src/gui/qgsattributeform.cpp
@@ -28,6 +28,7 @@
#include "qgsmaplayerregistry.h"
#include "qgsrendererv2.h"
#include "qgsvectorlayer.h"
#include "qgsvectordataprovider.h"
#include "qgssymbollayerv2utils.h"

#include <QVariant>
@@ -680,7 +681,9 @@ Qt::ItemFlags QgsAttributeTableModel::flags( const QModelIndex &index ) const
Qt::ItemFlags flags = QAbstractItemModel::flags( index );

if ( layer()->isEditable() &&
layer()->fieldEditable( mAttributes[ index.column()] ) )
layer()->fieldEditable( mAttributes[ index.column()] ) &&
(( layer()->dataProvider() && layer()->dataProvider()->capabilities() & QgsVectorDataProvider::ChangeAttributeValues ) ||
FID_IS_NEW( rowToId( index.row() ) ) ) )
flags |= Qt::ItemIsEditable;

return flags;
@@ -22,6 +22,7 @@
#include "qgsproject.h"
#include "qgspythonrunner.h"
#include "qgsrelationwidgetwrapper.h"
#include "qgsvectordataprovider.h"

#include <QDir>
#include <QFileInfo>
@@ -366,7 +367,9 @@ void QgsAttributeForm::synchronizeEnabledState()
QgsEditorWidgetWrapper* eww = qobject_cast<QgsEditorWidgetWrapper*>( ww );
if ( eww )
{
fieldEditable = mLayer->fieldEditable( eww->fieldIdx() );
fieldEditable = mLayer->fieldEditable( eww->fieldIdx() ) &&
(( mLayer->dataProvider() && layer()->dataProvider()->capabilities() & QgsVectorDataProvider::ChangeAttributeValues ) ||
FID_IS_NEW( mFeature.id() ) );
}
ww->setEnabled( isEditable && fieldEditable );
}

0 comments on commit 15af5a1

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