patch_for_ticket_3157.diff
src/app/qgisapp.cpp (working copy) | ||
---|---|---|
4722 | 4722 | |
4723 | 4723 |
bool res = true; |
4724 | 4724 | |
4725 |
if( !vlayer->isEditable() ) |
|
4725 |
if( !vlayer->isEditable() && !vlayer->isReadOnly() )
|
|
4726 | 4726 |
{ |
4727 | 4727 |
vlayer->startEditing(); |
4728 | 4728 |
if( !( vlayer->dataProvider()->capabilities() & QgsVectorDataProvider::EditingCapabilities ) ) |
... | ... | |
5922 | 5922 |
//start editing/stop editing |
5923 | 5923 |
if( dprovider->capabilities() & QgsVectorDataProvider::EditingCapabilities ) |
5924 | 5924 |
{ |
5925 |
mActionToggleEditing->setEnabled( true );
|
|
5925 |
mActionToggleEditing->setEnabled( !vlayer->isReadOnly() );
|
|
5926 | 5926 |
mActionToggleEditing->setChecked( vlayer->isEditable() ); |
5927 | 5927 |
mActionSaveEdits->setEnabled( vlayer->isEditable() ); |
5928 | 5928 |
} |
src/core/qgsvectorlayer.cpp (working copy) | ||
---|---|---|
100 | 100 |
mDataProvider( NULL ), |
101 | 101 |
mProviderKey( providerKey ), |
102 | 102 |
mEditable( false ), |
103 |
mReadOnly( false ), |
|
103 | 104 |
mModified( false ), |
104 | 105 |
mMaxUpdatedIndex( -1 ), |
105 | 106 |
mActiveCommand( NULL ), |
... | ... | |
2483 | 2484 |
return false; |
2484 | 2485 |
} |
2485 | 2486 | |
2487 |
if ( mReadOnly ) |
|
2488 |
{ |
|
2489 |
return false; |
|
2490 |
} |
|
2491 | ||
2486 | 2492 |
if ( mEditable ) |
2487 | 2493 |
{ |
2488 | 2494 |
// editing already underway |
... | ... | |
4204 | 4210 |
return ( mEditable && mDataProvider ); |
4205 | 4211 |
} |
4206 | 4212 | |
4213 |
bool QgsVectorLayer::isReadOnly() const |
|
4214 |
{ |
|
4215 |
return mReadOnly; |
|
4216 |
} |
|
4217 | ||
4218 |
bool QgsVectorLayer::setReadOnly( bool readonly ) |
|
4219 |
{ |
|
4220 |
// exit if the layer is in editing mode |
|
4221 |
if ( readonly && mEditable ) |
|
4222 |
return false; |
|
4223 | ||
4224 |
mReadOnly = readonly; |
|
4225 |
return true; |
|
4226 |
} |
|
4227 | ||
4207 | 4228 |
bool QgsVectorLayer::isModified() const |
4208 | 4229 |
{ |
4209 | 4230 |
return mModified; |
src/core/qgsvectorlayer.h (working copy) | ||
---|---|---|
358 | 358 |
/** Returns true if the provider is in editing mode */ |
359 | 359 |
virtual bool isEditable() const; |
360 | 360 | |
361 |
/** Returns true if the provider is in read-only mode */ |
|
362 |
virtual bool isReadOnly() const; |
|
363 | ||
361 | 364 |
/** Returns true if the provider has been modified since the last commit */ |
362 | 365 |
virtual bool isModified() const; |
363 | 366 | |
... | ... | |
402 | 405 |
/** returns feature count after commit */ |
403 | 406 |
int pendingFeatureCount(); |
404 | 407 | |
408 |
/** Make layer read-only (editing disabled) or not |
|
409 |
* @return false if the layer is in editing yet |
|
410 |
*/ |
|
411 |
bool setReadOnly( bool readonly = true ); |
|
412 | ||
405 | 413 |
/** Sets whether some features are modified or not */ |
406 | 414 |
void setModified( bool modified = true, bool onlyGeometryWasModified = false ); |
407 | 415 | |
... | ... | |
708 | 716 |
/** Flag indicating whether the layer is in editing mode or not */ |
709 | 717 |
bool mEditable; |
710 | 718 | |
719 |
/** Flag indicating whether the layer is in read-only mode (editing disabled) or not */ |
|
720 |
bool mReadOnly; |
|
721 | ||
711 | 722 |
/** Flag indicating whether the layer has been modified since the last commit */ |
712 | 723 |
bool mModified; |
713 | 724 |
python/core/qgsvectorlayer.sip (working copy) | ||
---|---|---|
313 | 313 |
/** Returns true if the provider is in editing mode */ |
314 | 314 |
virtual bool isEditable() const; |
315 | 315 | |
316 |
/** Returns true if the provider is in read-only mode */ |
|
317 |
virtual bool isReadOnly() const; |
|
318 | ||
316 | 319 |
/** Returns true if the provider has been modified since the last commit */ |
317 | 320 |
virtual bool isModified() const; |
318 | 321 | |
... | ... | |
353 | 356 | |
354 | 357 |
/** returns feature count after commit */ |
355 | 358 |
int pendingFeatureCount(); |
359 | ||
360 |
/** Make layer read-only (editing disabled) or not |
|
361 |
* @return false if the layer is in editing yet |
|
362 |
*/ |
|
363 |
bool setReadOnly( bool readonly = true ); |
|
356 | 364 |
|
357 | 365 |
/** Sets whether some features are modified or not */ |
358 | 366 |
void setModified(bool modified = TRUE, bool onlyGeometryWasModified = FALSE); |