mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-26 00:02:08 -05:00
fieldEditable -> readOnly
This commit is contained in:
parent
d70a47e7cf
commit
4cd1e38631
@ -190,9 +190,9 @@ class QgsEditFormConfig : QObject
|
||||
QgsEditorWidgetConfig widgetConfig( const QString& fieldName ) const;
|
||||
|
||||
/**
|
||||
* If this returns false, the widget at the given index will always be read-only.
|
||||
* If this returns true, the field is manually set to read only.
|
||||
*/
|
||||
bool fieldEditable( int idx );
|
||||
bool readOnly( int idx );
|
||||
|
||||
/**
|
||||
* If set to false, the widget at the given index will be read-only, regardless of the
|
||||
@ -200,7 +200,7 @@ class QgsEditFormConfig : QObject
|
||||
* If it is set to true, the widget's editable state will be synchronized with the layer's
|
||||
* edit state.
|
||||
*/
|
||||
void setFieldEditable( int idx, bool editable );
|
||||
void setReadOnly(int idx, bool readOnly );
|
||||
|
||||
/**
|
||||
* If this returns true, the widget at the given index will receive its label on the previous line
|
||||
|
@ -1006,7 +1006,7 @@ class QgsVectorLayer : QgsMapLayer
|
||||
/** Make layer read-only (editing disabled) or not
|
||||
* @return false if the layer is in editing yet
|
||||
*/
|
||||
bool setReadOnly( bool readonly = true );
|
||||
bool setFieldEditable( bool editable = true );
|
||||
|
||||
/**
|
||||
* Make layer editable.
|
||||
|
@ -848,7 +848,7 @@ void QgsFieldsProperties::apply()
|
||||
int idx = mFieldsList->item( i, attrIdCol )->text().toInt();
|
||||
FieldConfig cfg = configForRow( i );
|
||||
|
||||
mLayer->editFormConfig()->setFieldEditable( i, cfg.mEditable );
|
||||
mLayer->editFormConfig()->setReadOnly( i, !cfg.mEditable );
|
||||
mLayer->editFormConfig()->setLabelOnTop( i, cfg.mLabelOnTop );
|
||||
|
||||
mLayer->editFormConfig()->setWidgetType( idx, cfg.mEditorWidgetV2Type );
|
||||
@ -900,7 +900,7 @@ QgsFieldsProperties::FieldConfig::FieldConfig()
|
||||
QgsFieldsProperties::FieldConfig::FieldConfig( QgsVectorLayer* layer, int idx )
|
||||
: mButton( 0 )
|
||||
{
|
||||
mEditable = layer->editFormConfig()->fieldEditable( idx );
|
||||
mEditable = !layer->editFormConfig()->readOnly( idx );
|
||||
mEditableEnabled = layer->fields().fieldOrigin( idx ) != QgsFields::OriginJoin
|
||||
&& layer->fields().fieldOrigin( idx ) != QgsFields::OriginExpression;
|
||||
mLabelOnTop = layer->editFormConfig()->labelOnTop( idx );
|
||||
|
@ -4,8 +4,8 @@
|
||||
QgsEditFormConfig::QgsEditFormConfig( QObject* parent )
|
||||
: QObject( parent )
|
||||
, mEditorLayout( GeneratedLayout )
|
||||
, mUseInitCode( false )
|
||||
, mFeatureFormSuppress( SuppressDefault )
|
||||
, mUseInitCode( false )
|
||||
{
|
||||
connect( QgsProject::instance()->relationManager(), SIGNAL( relationsLoaded() ), this, SLOT( onRelationsLoaded() ) );
|
||||
}
|
||||
@ -72,17 +72,17 @@ void QgsEditFormConfig::setUiForm( const QString& ui )
|
||||
mEditForm = ui;
|
||||
}
|
||||
|
||||
bool QgsEditFormConfig::fieldEditable( int idx )
|
||||
bool QgsEditFormConfig::readOnly( int idx )
|
||||
{
|
||||
if ( idx >= 0 && idx < mFields.count() )
|
||||
{
|
||||
if ( mFields.fieldOrigin( idx ) == QgsFields::OriginJoin
|
||||
|| mFields.fieldOrigin( idx ) == QgsFields::OriginExpression )
|
||||
return false;
|
||||
return mFieldEditables.value( mFields.at( idx ).name(), true );
|
||||
return true;
|
||||
return !mFieldEditables.value( mFields.at( idx ).name(), true );
|
||||
}
|
||||
else
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool QgsEditFormConfig::labelOnTop( int idx )
|
||||
@ -93,10 +93,10 @@ bool QgsEditFormConfig::labelOnTop( int idx )
|
||||
return false;
|
||||
}
|
||||
|
||||
void QgsEditFormConfig::setFieldEditable( int idx, bool editable )
|
||||
void QgsEditFormConfig::setReadOnly( int idx, bool readOnly )
|
||||
{
|
||||
if ( idx >= 0 && idx < mFields.count() )
|
||||
mFieldEditables[ mFields.at( idx ).name()] = editable;
|
||||
mFieldEditables[ mFields.at( idx ).name()] = !readOnly;
|
||||
}
|
||||
|
||||
void QgsEditFormConfig::setLabelOnTop( int idx, bool onTop )
|
||||
|
@ -441,17 +441,15 @@ class CORE_EXPORT QgsEditFormConfig : public QObject
|
||||
QgsEditorWidgetConfig widgetConfig( const QString& fieldName ) const;
|
||||
|
||||
/**
|
||||
* If this returns false, the widget at the given index will always be read-only.
|
||||
* This returns true if the field is manually set to read only or if the field
|
||||
* does not support editing like joins or vitual fields.
|
||||
*/
|
||||
bool fieldEditable( int idx );
|
||||
bool readOnly( int idx );
|
||||
|
||||
/**
|
||||
* If set to false, the widget at the given index will be read-only, regardless of the
|
||||
* layer's editable state and data provider capacities.
|
||||
* If it is set to true, the widget's editable state will be synchronized with the layer's
|
||||
* edit state.
|
||||
* If set to false, the widget at the given index will be read-only.
|
||||
*/
|
||||
void setFieldEditable( int idx, bool editable );
|
||||
void setReadOnly( int idx, bool readOnly = true );
|
||||
|
||||
/**
|
||||
* If this returns true, the widget at the given index will receive its label on the previous line
|
||||
|
@ -2719,7 +2719,7 @@ bool QgsVectorLayer::isReadOnly() const
|
||||
return mReadOnly;
|
||||
}
|
||||
|
||||
bool QgsVectorLayer::setReadOnly( bool readonly )
|
||||
bool QgsVectorLayer::setFieldEditable( bool readonly )
|
||||
{
|
||||
// exit if the layer is in editing mode
|
||||
if ( readonly && mEditBuffer )
|
||||
|
@ -1126,7 +1126,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
|
||||
/** Make layer read-only (editing disabled) or not
|
||||
* @return false if the layer is in editing yet
|
||||
*/
|
||||
bool setReadOnly( bool readonly = true );
|
||||
bool setFieldEditable( bool editable = true );
|
||||
|
||||
/**
|
||||
* Make layer editable.
|
||||
@ -1469,9 +1469,9 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
|
||||
/**
|
||||
* Is edit widget editable
|
||||
*
|
||||
* @deprecated Use `editFormConfig()->readOnly()` instead
|
||||
* @deprecated Use `editFormConfig()->fieldEditable()` instead
|
||||
*/
|
||||
Q_DECL_DEPRECATED bool fieldEditable( int idx ) { return mEditFormConfig->readOnly( idx ); }
|
||||
Q_DECL_DEPRECATED bool fieldEditable( int idx ) { return !mEditFormConfig->readOnly( idx ); }
|
||||
|
||||
/**
|
||||
* Label widget on top
|
||||
@ -1481,9 +1481,9 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
|
||||
|
||||
/**
|
||||
* Set edit widget editable
|
||||
* @deprecated Use `editFormConfig()->setReadOnly()` instead
|
||||
* @deprecated Use `editFormConfig()->setFieldEditable()` instead
|
||||
*/
|
||||
Q_DECL_DEPRECATED void setReadOnly( int idx, bool editable ) { mEditFormConfig->setFieldEditable( idx, editable ); }
|
||||
Q_DECL_DEPRECATED void setFieldEditable( int idx, bool editable ) { mEditFormConfig->setReadOnly( idx, !editable ); }
|
||||
|
||||
/**
|
||||
* Label widget on top
|
||||
|
@ -75,7 +75,7 @@ QWidget *QgsAttributeTableDelegate::createEditor(
|
||||
|
||||
w->setAutoFillBackground( true );
|
||||
|
||||
eww->setEnabled( vl->editFormConfig()->fieldEditable( fieldIdx ) );
|
||||
eww->setEnabled( !vl->editFormConfig()->readOnly( fieldIdx ) );
|
||||
|
||||
return w;
|
||||
}
|
||||
|
@ -681,7 +681,7 @@ Qt::ItemFlags QgsAttributeTableModel::flags( const QModelIndex &index ) const
|
||||
Qt::ItemFlags flags = QAbstractItemModel::flags( index );
|
||||
|
||||
if ( layer()->isEditable() &&
|
||||
layer()->editFormConfig()->fieldEditable( mAttributes[ index.column()] ) &&
|
||||
!layer()->editFormConfig()->readOnly( mAttributes[ index.column()] ) &&
|
||||
(( layer()->dataProvider() && layer()->dataProvider()->capabilities() & QgsVectorDataProvider::ChangeAttributeValues ) ||
|
||||
FID_IS_NEW( rowToId( index.row() ) ) ) )
|
||||
flags |= Qt::ItemIsEditable;
|
||||
|
@ -245,7 +245,7 @@ void QgsEditorWidgetRegistry::readMapLayer( QgsMapLayer* mapLayer, const QDomEle
|
||||
cfg = mWidgetFactories[ewv2Type]->readEditorConfig( ewv2CfgElem, vectorLayer, idx );
|
||||
}
|
||||
|
||||
vectorLayer->editFormConfig()->setFieldEditable( idx, ewv2CfgElem.attribute( "fieldEditable", "1" ) == "1" );
|
||||
vectorLayer->editFormConfig()->setReadOnly( idx, ewv2CfgElem.attribute( "fieldEditable", "1" ) != "1" );
|
||||
vectorLayer->editFormConfig()->setLabelOnTop( idx, ewv2CfgElem.attribute( "labelOnTop", "0" ) == "1" );
|
||||
vectorLayer->editFormConfig()->setWidgetConfig( idx, cfg );
|
||||
}
|
||||
@ -301,7 +301,7 @@ void QgsEditorWidgetRegistry::writeMapLayer( QgsMapLayer* mapLayer, QDomElement&
|
||||
if ( mWidgetFactories.contains( widgetType ) )
|
||||
{
|
||||
QDomElement ewv2CfgElem = doc.createElement( "widgetv2config" );
|
||||
ewv2CfgElem.setAttribute( "fieldEditable", vectorLayer->editFormConfig()->fieldEditable( idx ) );
|
||||
ewv2CfgElem.setAttribute( "fieldEditable", !vectorLayer->editFormConfig()->readOnly( idx ) );
|
||||
ewv2CfgElem.setAttribute( "labelOnTop", vectorLayer->editFormConfig()->labelOnTop( idx ) );
|
||||
|
||||
mWidgetFactories[widgetType]->writeConfig( vectorLayer->editFormConfig()->widgetConfig( idx ), ewv2CfgElem, doc, vectorLayer, idx );
|
||||
|
@ -175,7 +175,7 @@ bool QgsAttributeForm::save()
|
||||
QVariant srcVar = eww->value();
|
||||
// need to check dstVar.isNull() != srcVar.isNull()
|
||||
// otherwise if dstVar=NULL and scrVar=0, then dstVar = srcVar
|
||||
if (( dstVar != srcVar || dstVar.isNull() != srcVar.isNull() ) && srcVar.isValid() && mLayer->editFormConfig()->fieldEditable( eww->fieldIdx() ) )
|
||||
if (( dstVar != srcVar || dstVar.isNull() != srcVar.isNull() ) && srcVar.isValid() && !mLayer->editFormConfig()->readOnly( eww->fieldIdx() ) )
|
||||
{
|
||||
dst[eww->fieldIdx()] = srcVar;
|
||||
|
||||
@ -220,7 +220,7 @@ bool QgsAttributeForm::save()
|
||||
{
|
||||
if (( dst.at( i ) == src.at( i ) && dst.at( i ).isNull() == src.at( i ).isNull() ) // If field is not changed...
|
||||
|| !dst.at( i ).isValid() // or the widget returns invalid (== do not change)
|
||||
|| !mLayer->editFormConfig()->fieldEditable( i ) ) // or the field cannot be edited ...
|
||||
|| mLayer->editFormConfig()->readOnly( i ) ) // or the field cannot be edited ...
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -367,7 +367,7 @@ void QgsAttributeForm::synchronizeEnabledState()
|
||||
QgsEditorWidgetWrapper* eww = qobject_cast<QgsEditorWidgetWrapper*>( ww );
|
||||
if ( eww )
|
||||
{
|
||||
fieldEditable = mLayer->editFormConfig()->fieldEditable( eww->fieldIdx() ) &&
|
||||
fieldEditable = !mLayer->editFormConfig()->readOnly( eww->fieldIdx() ) &&
|
||||
(( mLayer->dataProvider() && layer()->dataProvider()->capabilities() & QgsVectorDataProvider::ChangeAttributeValues ) ||
|
||||
FID_IS_NEW( mFeature.id() ) );
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ QgsGeometryCheckerResultTab::QgsGeometryCheckerResultTab( QgisInterface* iface,
|
||||
QgsGeometryCheckerResultTab::~QgsGeometryCheckerResultTab()
|
||||
{
|
||||
if ( mFeaturePool->getLayer() )
|
||||
mFeaturePool->getLayer()->setReadOnly( false );
|
||||
mFeaturePool->getLayer()->setFieldEditable( false );
|
||||
delete mChecker;
|
||||
delete mFeaturePool;
|
||||
qDeleteAll( mCurrentRubberBands );
|
||||
|
@ -286,7 +286,7 @@ void QgsGeometryCheckerSetupTab::runChecks()
|
||||
emit checkerStarted( checker, featurePool );
|
||||
|
||||
/** Add result layer (do this after checkerStarted, otherwise warning about removing of result layer may appear) **/
|
||||
layer->setReadOnly( true );
|
||||
layer->setFieldEditable( true );
|
||||
if ( ui.radioButtonOutputNew->isChecked() )
|
||||
{
|
||||
QgsMapLayerRegistry::instance()->addMapLayers( QList<QgsMapLayer*>() << layer );
|
||||
|
@ -261,7 +261,7 @@ void QgsGeometrySnapperDialog::run()
|
||||
}
|
||||
}
|
||||
|
||||
layer->setReadOnly( true );
|
||||
layer->setFieldEditable( true );
|
||||
if ( ui.radioButtonOutputNew->isChecked() )
|
||||
{
|
||||
QgsMapLayerRegistry::instance()->addMapLayers( QList<QgsMapLayer*>() << layer );
|
||||
@ -294,7 +294,7 @@ void QgsGeometrySnapperDialog::run()
|
||||
ui.progressBar->hide();
|
||||
ui.widgetInputs->setEnabled( true );
|
||||
|
||||
layer->setReadOnly( false );
|
||||
layer->setFieldEditable( false );
|
||||
|
||||
/** Refresh canvas **/
|
||||
mIface->mapCanvas()->refresh();
|
||||
|
@ -1138,8 +1138,8 @@ void QgsGrassProvider::startEditing( QgsVectorLayer *vectorLayer )
|
||||
|
||||
// TODO: enable cats editing once all consequences are implemented
|
||||
// disable cat and topo symbol editing
|
||||
vectorLayer->editFormConfig()->setFieldEditable( mLayer->keyColumn(), false );
|
||||
vectorLayer->editFormConfig()->setFieldEditable( mLayer->fields().size() - 1, false );
|
||||
vectorLayer->editFormConfig()->setReadOnly( mLayer->keyColumn(), true );
|
||||
vectorLayer->editFormConfig()->setReadOnly( mLayer->fields().size() - 1, true );
|
||||
|
||||
mEditedCount++;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user