mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
applied patch to make a vector layer read-only, to fix #3157
git-svn-id: http://svn.osgeo.org/qgis/trunk@14451 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
6253fb72fe
commit
519f120602
@ -313,6 +313,10 @@ public:
|
||||
/** Returns true if the provider is in editing mode */
|
||||
virtual bool isEditable() const;
|
||||
|
||||
/** Returns true if the provider is in read-only mode
|
||||
@note added in version 1.6 */
|
||||
virtual bool isReadOnly() const;
|
||||
|
||||
/** Returns true if the provider has been modified since the last commit */
|
||||
virtual bool isModified() const;
|
||||
|
||||
@ -353,6 +357,11 @@ public:
|
||||
|
||||
/** returns feature count after commit */
|
||||
int pendingFeatureCount();
|
||||
|
||||
/** Make layer read-only (editing disabled) or not
|
||||
@return false if the layer is in editing yet
|
||||
@note added in version 1.6 */
|
||||
bool setReadOnly( bool readonly = true );
|
||||
|
||||
/** Sets whether some features are modified or not */
|
||||
void setModified(bool modified = TRUE, bool onlyGeometryWasModified = FALSE);
|
||||
|
@ -4724,7 +4724,7 @@ bool QgisApp::toggleEditing( QgsMapLayer *layer, bool allowCancel )
|
||||
|
||||
bool res = true;
|
||||
|
||||
if( !vlayer->isEditable() )
|
||||
if( !vlayer->isEditable() && !vlayer->isReadOnly() )
|
||||
{
|
||||
vlayer->startEditing();
|
||||
if( !( vlayer->dataProvider()->capabilities() & QgsVectorDataProvider::EditingCapabilities ) )
|
||||
@ -5927,7 +5927,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
|
||||
//start editing/stop editing
|
||||
if( dprovider->capabilities() & QgsVectorDataProvider::EditingCapabilities )
|
||||
{
|
||||
mActionToggleEditing->setEnabled( true );
|
||||
mActionToggleEditing->setEnabled( !vlayer->isReadOnly() );
|
||||
mActionToggleEditing->setChecked( vlayer->isEditable() );
|
||||
mActionSaveEdits->setEnabled( vlayer->isEditable() );
|
||||
}
|
||||
|
@ -100,6 +100,7 @@ QgsVectorLayer::QgsVectorLayer( QString vectorLayerPath,
|
||||
mDataProvider( NULL ),
|
||||
mProviderKey( providerKey ),
|
||||
mEditable( false ),
|
||||
mReadOnly( false ),
|
||||
mModified( false ),
|
||||
mMaxUpdatedIndex( -1 ),
|
||||
mActiveCommand( NULL ),
|
||||
@ -2483,6 +2484,11 @@ bool QgsVectorLayer::startEditing()
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( mReadOnly )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( mEditable )
|
||||
{
|
||||
// editing already underway
|
||||
@ -4204,6 +4210,21 @@ bool QgsVectorLayer::isEditable() const
|
||||
return ( mEditable && mDataProvider );
|
||||
}
|
||||
|
||||
bool QgsVectorLayer::isReadOnly() const
|
||||
{
|
||||
return mReadOnly;
|
||||
}
|
||||
|
||||
bool QgsVectorLayer::setReadOnly( bool readonly )
|
||||
{
|
||||
// exit if the layer is in editing mode
|
||||
if ( readonly && mEditable )
|
||||
return false;
|
||||
|
||||
mReadOnly = readonly;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QgsVectorLayer::isModified() const
|
||||
{
|
||||
return mModified;
|
||||
|
@ -358,6 +358,9 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
|
||||
/** Returns true if the provider is in editing mode */
|
||||
virtual bool isEditable() const;
|
||||
|
||||
/** Returns true if the provider is in read-only mode */
|
||||
virtual bool isReadOnly() const;
|
||||
|
||||
/** Returns true if the provider has been modified since the last commit */
|
||||
virtual bool isModified() const;
|
||||
|
||||
@ -402,6 +405,11 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
|
||||
/** returns feature count after commit */
|
||||
int pendingFeatureCount();
|
||||
|
||||
/** Make layer read-only (editing disabled) or not
|
||||
* @return false if the layer is in editing yet
|
||||
*/
|
||||
bool setReadOnly( bool readonly = true );
|
||||
|
||||
/** Sets whether some features are modified or not */
|
||||
void setModified( bool modified = true, bool onlyGeometryWasModified = false );
|
||||
|
||||
@ -708,6 +716,9 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
|
||||
/** Flag indicating whether the layer is in editing mode or not */
|
||||
bool mEditable;
|
||||
|
||||
/** Flag indicating whether the layer is in read-only mode (editing disabled) or not */
|
||||
bool mReadOnly;
|
||||
|
||||
/** Flag indicating whether the layer has been modified since the last commit */
|
||||
bool mModified;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user