[QGIS Commit] r14451 - in trunk/qgis: python/core src/app src/core
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Fri Oct 29 18:12:42 EDT 2010
Author: brushtyler
Date: 2010-10-29 15:12:42 -0700 (Fri, 29 Oct 2010)
New Revision: 14451
Modified:
trunk/qgis/python/core/qgsvectorlayer.sip
trunk/qgis/src/app/qgisapp.cpp
trunk/qgis/src/core/qgsvectorlayer.cpp
trunk/qgis/src/core/qgsvectorlayer.h
Log:
applied patch to make a vector layer read-only, to fix #3157
Modified: trunk/qgis/python/core/qgsvectorlayer.sip
===================================================================
--- trunk/qgis/python/core/qgsvectorlayer.sip 2010-10-29 22:07:56 UTC (rev 14450)
+++ trunk/qgis/python/core/qgsvectorlayer.sip 2010-10-29 22:12:42 UTC (rev 14451)
@@ -313,6 +313,10 @@
/** 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 @@
/** 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);
Modified: trunk/qgis/src/app/qgisapp.cpp
===================================================================
--- trunk/qgis/src/app/qgisapp.cpp 2010-10-29 22:07:56 UTC (rev 14450)
+++ trunk/qgis/src/app/qgisapp.cpp 2010-10-29 22:12:42 UTC (rev 14451)
@@ -4724,7 +4724,7 @@
bool res = true;
- if( !vlayer->isEditable() )
+ if( !vlayer->isEditable() && !vlayer->isReadOnly() )
{
vlayer->startEditing();
if( !( vlayer->dataProvider()->capabilities() & QgsVectorDataProvider::EditingCapabilities ) )
@@ -5927,7 +5927,7 @@
//start editing/stop editing
if( dprovider->capabilities() & QgsVectorDataProvider::EditingCapabilities )
{
- mActionToggleEditing->setEnabled( true );
+ mActionToggleEditing->setEnabled( !vlayer->isReadOnly() );
mActionToggleEditing->setChecked( vlayer->isEditable() );
mActionSaveEdits->setEnabled( vlayer->isEditable() );
}
Modified: trunk/qgis/src/core/qgsvectorlayer.cpp
===================================================================
--- trunk/qgis/src/core/qgsvectorlayer.cpp 2010-10-29 22:07:56 UTC (rev 14450)
+++ trunk/qgis/src/core/qgsvectorlayer.cpp 2010-10-29 22:12:42 UTC (rev 14451)
@@ -100,6 +100,7 @@
mDataProvider( NULL ),
mProviderKey( providerKey ),
mEditable( false ),
+ mReadOnly( false ),
mModified( false ),
mMaxUpdatedIndex( -1 ),
mActiveCommand( NULL ),
@@ -2483,6 +2484,11 @@
return false;
}
+ if ( mReadOnly )
+ {
+ return false;
+ }
+
if ( mEditable )
{
// editing already underway
@@ -4204,6 +4210,21 @@
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;
Modified: trunk/qgis/src/core/qgsvectorlayer.h
===================================================================
--- trunk/qgis/src/core/qgsvectorlayer.h 2010-10-29 22:07:56 UTC (rev 14450)
+++ trunk/qgis/src/core/qgsvectorlayer.h 2010-10-29 22:12:42 UTC (rev 14451)
@@ -358,6 +358,9 @@
/** 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 @@
/** 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 @@
/** 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;
More information about the QGIS-commit
mailing list