Skip to content

Commit

Permalink
Editor widgets: Change default "enable sync" behavior
Browse files Browse the repository at this point in the history
More generic implementation of 024cd0b

EditorWidgetWrappers (which are connected to fields) are synced with
the layer edit mode state.
WidgetWrappers (which are not strictly related to fields being editable)
don't sync their edit state to the layer edit mode state.
  • Loading branch information
m-kuhn committed Jun 20, 2014
1 parent eb4fe78 commit 196a667
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
8 changes: 8 additions & 0 deletions src/gui/editorwidgets/core/qgseditorwidgetwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ QgsEditorWidgetWrapper* QgsEditorWidgetWrapper::fromWidget( QWidget* widget )
return qobject_cast<QgsEditorWidgetWrapper*>( widget->property( "EWV2Wrapper" ).value<QgsWidgetWrapper*>() );
}

void QgsEditorWidgetWrapper::setEnabled( bool enabled )
{
if ( widget() )
{
widget()->setEnabled( enabled );
}
}

void QgsEditorWidgetWrapper::setFeature( const QgsFeature& feature )
{
setValue( feature.attribute( mFieldIdx ) );
Expand Down
8 changes: 8 additions & 0 deletions src/gui/editorwidgets/core/qgseditorwidgetwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ class GUI_EXPORT QgsEditorWidgetWrapper : public QgsWidgetWrapper
*/
static QgsEditorWidgetWrapper* fromWidget( QWidget* widget );

/**
* Is used to enable or disable the edit functionality of the managed widget.
* By default this will enable or disable the whole widget
*
* @param enabled Enable or Disable?
*/
void setEnabled( bool enabled );

signals:
/**
* Emit this signal, whenever the value changed.
Expand Down
5 changes: 1 addition & 4 deletions src/gui/editorwidgets/core/qgswidgetwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,5 @@ void QgsWidgetWrapper::initWidget( QWidget* editor )

void QgsWidgetWrapper::setEnabled( bool enabled )
{
if ( mWidget )
{
mWidget->setEnabled( enabled );
}
Q_UNUSED( enabled );
}
2 changes: 1 addition & 1 deletion src/gui/editorwidgets/core/qgswidgetwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class GUI_EXPORT QgsWidgetWrapper : public QObject

/**
* Is used to enable or disable the edit functionality of the managed widget.
* By default this will enable or disable the whole widget
* By default this will not change the enabled state of the widget
*
* @param enabled Enable or Disable?
*/
Expand Down
5 changes: 0 additions & 5 deletions src/gui/editorwidgets/qgsrelationwidgetwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ QgsRelationWidgetWrapper::QgsRelationWidgetWrapper( QgsVectorLayer* vl, const Qg
{
}

void QgsRelationWidgetWrapper::setEnabled( bool enabled )
{
// Do nothing, we only work on the related table, so no need to disable anything
}

QWidget* QgsRelationWidgetWrapper::createWidget( QWidget* parent )
{
return new QWidget( parent );
Expand Down
2 changes: 0 additions & 2 deletions src/gui/editorwidgets/qgsrelationwidgetwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ class GUI_EXPORT QgsRelationWidgetWrapper : public QgsWidgetWrapper
public:
explicit QgsRelationWidgetWrapper( QgsVectorLayer* vl, const QgsRelation& relation, QWidget* editor = 0, QWidget* parent = 0 );

void setEnabled( bool enabled );

protected:
QWidget* createWidget( QWidget* parent );
void initWidget( QWidget* editor );
Expand Down

0 comments on commit 196a667

Please sign in to comment.