Skip to content

Commit 58ee9bb

Browse files
committedNov 26, 2015
attribute editing: don't allow editing without ChangeAttributeValues capability
(cherry picked from commit 15af5a1)
1 parent 27c6995 commit 58ee9bb

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed
 

‎src/gui/attributetable/qgsattributetablemodel.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "qgsmaplayerregistry.h"
2828
#include "qgsrendererv2.h"
2929
#include "qgsvectorlayer.h"
30+
#include "qgsvectordataprovider.h"
3031

3132
#include <QVariant>
3233

@@ -560,7 +561,9 @@ Qt::ItemFlags QgsAttributeTableModel::flags( const QModelIndex &index ) const
560561
Qt::ItemFlags flags = QAbstractItemModel::flags( index );
561562

562563
if ( layer()->isEditable() &&
563-
layer()->fieldEditable( mAttributes[ index.column()] ) )
564+
layer()->fieldEditable( mAttributes[ index.column()] ) &&
565+
(( layer()->dataProvider() && layer()->dataProvider()->capabilities() & QgsVectorDataProvider::ChangeAttributeValues ) ||
566+
FID_IS_NEW( rowToId( index.row() ) ) ) )
564567
flags |= Qt::ItemIsEditable;
565568

566569
return flags;

‎src/gui/qgsattributeform.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "qgsproject.h"
2323
#include "qgspythonrunner.h"
2424
#include "qgsrelationwidgetwrapper.h"
25+
#include "qgsvectordataprovider.h"
2526

2627
#include <QDir>
2728
#include <QFileInfo>
@@ -323,7 +324,9 @@ void QgsAttributeForm::synchronizeEnabledState()
323324
QgsEditorWidgetWrapper* eww = qobject_cast<QgsEditorWidgetWrapper*>( ww );
324325
if ( eww )
325326
{
326-
fieldEditable = mLayer->fieldEditable( eww->fieldIdx() );
327+
fieldEditable = mLayer->fieldEditable( eww->fieldIdx() ) &&
328+
(( mLayer->dataProvider() && layer()->dataProvider()->capabilities() & QgsVectorDataProvider::ChangeAttributeValues ) ||
329+
FID_IS_NEW( mFeature.id() ) );
327330
}
328331
ww->setEnabled( isEditable && fieldEditable );
329332
}

0 commit comments

Comments
 (0)
Please sign in to comment.