Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
attribute editing: don't allow editing without ChangeAttributeValues …
…capability
  • Loading branch information
jef-n committed Oct 11, 2015
1 parent 84dade9 commit 15af5a1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/gui/attributetable/qgsattributetablemodel.cpp
Expand Up @@ -28,6 +28,7 @@
#include "qgsmaplayerregistry.h"
#include "qgsrendererv2.h"
#include "qgsvectorlayer.h"
#include "qgsvectordataprovider.h"
#include "qgssymbollayerv2utils.h"

#include <QVariant>
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion src/gui/qgsattributeform.cpp
Expand Up @@ -22,6 +22,7 @@
#include "qgsproject.h"
#include "qgspythonrunner.h"
#include "qgsrelationwidgetwrapper.h"
#include "qgsvectordataprovider.h"

#include <QDir>
#include <QFileInfo>
Expand Down Expand Up @@ -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 );
}
Expand Down

0 comments on commit 15af5a1

Please sign in to comment.