Skip to content

Commit

Permalink
Add a changed signal to QgsEditorConfigWidget
Browse files Browse the repository at this point in the history
And update default value expression preview whenever editor
config changes

Sponsored by DB Fahrwegdienste GmbH
  • Loading branch information
nyalldawson committed Aug 30, 2016
1 parent e35c6b4 commit 9940586
Show file tree
Hide file tree
Showing 14 changed files with 78 additions and 0 deletions.
7 changes: 7 additions & 0 deletions python/gui/editorwidgets/core/qgseditorconfigwidget.sip
Expand Up @@ -38,5 +38,12 @@ class QgsEditorConfigWidget : QWidget

virtual QgsEditorWidgetConfig config() = 0;
virtual void setConfig( const QgsEditorWidgetConfig& config ) = 0;

signals:

/** Emitted when the configuration of the widget is changed.
* @note added in QGIS 3.0
*/
void changed();
};

1 change: 1 addition & 0 deletions src/app/qgsattributetypedialog.cpp
Expand Up @@ -154,6 +154,7 @@ void QgsAttributeTypeDialog::setWidgetType( const QString& type )
stackedWidget->addWidget( cfgWdg );
stackedWidget->setCurrentWidget( cfgWdg );
mEditorConfigWidgets.insert( type, cfgWdg );
connect( cfgWdg, SIGNAL( changed() ), this, SLOT( defaultExpressionChanged() ) );
}
else
{
Expand Down
7 changes: 7 additions & 0 deletions src/gui/editorwidgets/core/qgseditorconfigwidget.h
Expand Up @@ -76,6 +76,13 @@ class GUI_EXPORT QgsEditorConfigWidget : public QWidget
*/
virtual ~QgsEditorConfigWidget() {}

signals:

/** Emitted when the configuration of the widget is changed.
* @note added in QGIS 3.0
*/
void changed();

private:
QgsVectorLayer* mLayer;
int mField;
Expand Down
3 changes: 3 additions & 0 deletions src/gui/editorwidgets/qgscheckboxconfigdlg.cpp
Expand Up @@ -19,6 +19,9 @@ QgsCheckBoxConfigDlg::QgsCheckBoxConfigDlg( QgsVectorLayer* vl, int fieldIdx, QW
: QgsEditorConfigWidget( vl, fieldIdx, parent )
{
setupUi( this );

connect( leCheckedState, SIGNAL( textEdited( QString ) ), this, SIGNAL( changed() ) );
connect( leUncheckedState, SIGNAL( textEdited( QString ) ), this, SIGNAL( changed() ) );
}

QgsEditorWidgetConfig QgsCheckBoxConfigDlg::config()
Expand Down
5 changes: 5 additions & 0 deletions src/gui/editorwidgets/qgsdatetimeeditconfig.cpp
Expand Up @@ -33,6 +33,11 @@ QgsDateTimeEditConfig::QgsDateTimeEditConfig( QgsVectorLayer* vl, int fieldIdx,
connect( mFieldHelpToolButton, SIGNAL( clicked( bool ) ), this, SLOT( showHelp( bool ) ) );
connect( mDisplayHelpToolButton, SIGNAL( clicked( bool ) ), this, SLOT( showHelp( bool ) ) );

connect( mFieldFormatEdit, SIGNAL( textChanged( QString ) ), this, SIGNAL( changed() ) );
connect( mDisplayFormatEdit, SIGNAL( textChanged( QString ) ), this, SIGNAL( changed() ) );
connect( mCalendarPopupCheckBox, SIGNAL( toggled( bool ) ), this, SIGNAL( changed() ) );
connect( mAllowNullCheckBox, SIGNAL( toggled( bool ) ), this, SIGNAL( changed() ) );

// initialize
updateFieldFormat( mFieldFormatComboBox->currentIndex() );
displayFormatChanged( mDisplayFormatComboBox->currentIndex() );
Expand Down
14 changes: 14 additions & 0 deletions src/gui/editorwidgets/qgsexternalresourceconfigdlg.cpp
Expand Up @@ -57,6 +57,20 @@ QgsExternalResourceConfigDlg::QgsExternalResourceConfigDlg( QgsVectorLayer* vl,

mDocumentViewerContentComboBox->addItem( tr( "Image" ), QgsExternalResourceWidget::Image );
mDocumentViewerContentComboBox->addItem( tr( "Web view" ), QgsExternalResourceWidget::Web );


connect( mFileWidgetGroupBox, SIGNAL( toggled( bool ) ), this, SIGNAL( changed() ) );
connect( mFileWidgetButtonGroupBox, SIGNAL( toggled( bool ) ), this, SIGNAL( changed() ) );
connect( mFileWidgetFilterLineEdit, SIGNAL( textChanged( QString ) ), this, SIGNAL( changed() ) );
connect( mUseLink, SIGNAL( toggled( bool ) ), this, SIGNAL( changed() ) );
connect( mFullUrl, SIGNAL( toggled( bool ) ), this, SIGNAL( changed() ) );
connect( mRootPath, SIGNAL( textChanged( QString ) ), this, SIGNAL( changed() ) );
connect( mStorageButtonGroup, SIGNAL( buttonClicked( int ) ), this, SIGNAL( changed() ) );
connect( mRelativeGroupBox, SIGNAL( toggled( bool ) ), this, SIGNAL( changed() ) );
connect( mDocumentViewerGroupBox, SIGNAL( toggled( bool ) ), this, SIGNAL( changed() ) );
connect( mDocumentViewerContentComboBox, SIGNAL( currentIndexChanged( int ) ), this, SIGNAL( changed() ) );
connect( mDocumentViewerHeight, SIGNAL( valueChanged( int ) ), this, SIGNAL( changed() ) );
connect( mDocumentViewerWidth, SIGNAL( valueChanged( int ) ), this, SIGNAL( changed() ) );
}

void QgsExternalResourceConfigDlg::chooseDefaultPath()
Expand Down
2 changes: 2 additions & 0 deletions src/gui/editorwidgets/qgsphotoconfigdlg.cpp
Expand Up @@ -19,6 +19,8 @@ QgsPhotoConfigDlg::QgsPhotoConfigDlg( QgsVectorLayer* vl, int fieldIdx, QWidget
: QgsEditorConfigWidget( vl, fieldIdx, parent )
{
setupUi( this );
connect( sbWidgetHeight, SIGNAL( valueChanged( int ) ), this, SIGNAL( changed() ) );
connect( sbWidgetWidth, SIGNAL( valueChanged( int ) ), this, SIGNAL( changed() ) );
}

QgsEditorWidgetConfig QgsPhotoConfigDlg::config()
Expand Down
10 changes: 10 additions & 0 deletions src/gui/editorwidgets/qgsrangeconfigdlg.cpp
Expand Up @@ -52,6 +52,16 @@ QgsRangeConfigDlg::QgsRangeConfigDlg( QgsVectorLayer* vl, int fieldIdx, QWidget
valuesLabel->setText( text );

connect( rangeWidget, SIGNAL( currentIndexChanged( int ) ), this, SLOT( rangeWidgetChanged( int ) ) );

connect( minimumSpinBox, SIGNAL( valueChanged( int ) ), this, SIGNAL( changed() ) );
connect( maximumSpinBox, SIGNAL( valueChanged( int ) ), this, SIGNAL( changed() ) );
connect( stepSpinBox, SIGNAL( valueChanged( int ) ), this, SIGNAL( changed() ) );
connect( minimumDoubleSpinBox, SIGNAL( valueChanged( double ) ), this, SIGNAL( changed() ) );
connect( maximumDoubleSpinBox, SIGNAL( valueChanged( double ) ), this, SIGNAL( changed() ) );
connect( stepDoubleSpinBox, SIGNAL( valueChanged( double ) ), this, SIGNAL( changed() ) );
connect( rangeWidget, SIGNAL( currentIndexChanged( int ) ), this, SIGNAL( changed() ) );
connect( allowNullCheckBox, SIGNAL( toggled( bool ) ), this, SIGNAL( changed() ) );
connect( suffixLineEdit, SIGNAL( textChanged( QString ) ), this, SIGNAL( changed() ) );
}

QgsEditorWidgetConfig QgsRangeConfigDlg::config()
Expand Down
12 changes: 12 additions & 0 deletions src/gui/editorwidgets/qgsrelationreferenceconfigdlg.cpp
Expand Up @@ -40,6 +40,18 @@ QgsRelationReferenceConfigDlg::QgsRelationReferenceConfigDlg( QgsVectorLayer* vl
mExpressionWidget->setField( relation.referencedLayer()->displayExpression() );
}
}

connect( mCbxAllowNull, SIGNAL( toggled( bool ) ), this, SIGNAL( changed() ) );
connect( mCbxOrderByValue, SIGNAL( toggled( bool ) ), this, SIGNAL( changed() ) );
connect( mCbxShowForm, SIGNAL( toggled( bool ) ), this, SIGNAL( changed() ) );
connect( mCbxMapIdentification, SIGNAL( toggled( bool ) ), this, SIGNAL( changed() ) );
connect( mCbxReadOnly, SIGNAL( toggled( bool ) ), this, SIGNAL( changed() ) );
connect( mComboRelation, SIGNAL( currentIndexChanged( int ) ), this, SIGNAL( changed() ) );
connect( mCbxAllowAddFeatures, SIGNAL( toggled( bool ) ), this, SIGNAL( changed() ) );
connect( mFilterGroupBox, SIGNAL( toggled( bool ) ), this, SIGNAL( changed() ) );
connect( mFilterFieldsList, SIGNAL( itemChanged( QListWidgetItem* ) ), this, SIGNAL( changed() ) );
connect( mCbxChainFilters, SIGNAL( toggled( bool ) ), this, SIGNAL( changed() ) );
connect( mExpressionWidget, SIGNAL( fieldChanged( QString ) ), this, SIGNAL( changed() ) );
}

void QgsRelationReferenceConfigDlg::setConfig( const QgsEditorWidgetConfig& config )
Expand Down
2 changes: 2 additions & 0 deletions src/gui/editorwidgets/qgstexteditconfigdlg.cpp
Expand Up @@ -20,6 +20,8 @@ QgsTextEditConfigDlg::QgsTextEditConfigDlg( QgsVectorLayer* vl, int fieldIdx, QW
: QgsEditorConfigWidget( vl, fieldIdx, parent )
{
setupUi( this );
connect( mIsMultiline, SIGNAL( toggled( bool ) ), this, SIGNAL( changed() ) );
connect( mUseHtml, SIGNAL( toggled( bool ) ), this, SIGNAL( changed() ) );
}


Expand Down
1 change: 1 addition & 0 deletions src/gui/editorwidgets/qgsuniquevaluesconfigdlg.cpp
Expand Up @@ -19,6 +19,7 @@ QgsUniqueValuesConfigDlg::QgsUniqueValuesConfigDlg( QgsVectorLayer* vl, int fiel
: QgsEditorConfigWidget( vl, fieldIdx, parent )
{
setupUi( this );
connect( editableUniqueValues, SIGNAL( toggled( bool ) ), this, SIGNAL( changed() ) );
}


Expand Down
3 changes: 3 additions & 0 deletions src/gui/editorwidgets/qgsvaluemapconfigdlg.cpp
Expand Up @@ -92,6 +92,8 @@ void QgsValueMapConfigDlg::vCellChanged( int row, int column )
{
tableWidget->insertRow( row + 1 );
} //else check type

emit changed();
}

void QgsValueMapConfigDlg::removeSelectedButtonPushed()
Expand All @@ -116,6 +118,7 @@ void QgsValueMapConfigDlg::removeSelectedButtonPushed()
tableWidget->removeRow( rowsToRemove.values().at( i ) - removed );
removed++;
}
emit changed();
}

void QgsValueMapConfigDlg::updateMap( const QMap<QString, QVariant> &map, bool insertNull )
Expand Down
9 changes: 9 additions & 0 deletions src/gui/editorwidgets/qgsvaluerelationconfigdlg.cpp
Expand Up @@ -26,6 +26,15 @@ QgsValueRelationConfigDlg::QgsValueRelationConfigDlg( QgsVectorLayer* vl, int fi
connect( mLayerName, SIGNAL( layerChanged( QgsMapLayer* ) ), mKeyColumn, SLOT( setLayer( QgsMapLayer* ) ) );
connect( mLayerName, SIGNAL( layerChanged( QgsMapLayer* ) ), mValueColumn, SLOT( setLayer( QgsMapLayer* ) ) );
connect( mEditExpression, SIGNAL( clicked() ), this, SLOT( editExpression() ) );

connect( mLayerName, SIGNAL( layerChanged( QgsMapLayer* ) ), this, SIGNAL( changed() ) );
connect( mKeyColumn, SIGNAL( currentIndexChanged( int ) ), this, SIGNAL( changed() ) );
connect( mValueColumn, SIGNAL( currentIndexChanged( int ) ), this, SIGNAL( changed() ) );
connect( mAllowMulti, SIGNAL( toggled( bool ) ), this, SIGNAL( changed() ) );
connect( mAllowNull, SIGNAL( toggled( bool ) ), this, SIGNAL( changed() ) );
connect( mOrderByValue, SIGNAL( toggled( bool ) ), this, SIGNAL( changed() ) );
connect( mFilterExpression, SIGNAL( textChanged() ), this, SIGNAL( changed() ) );
connect( mUseCompleter, SIGNAL( toggled( bool ) ), this, SIGNAL( changed() ) );
}

QgsEditorWidgetConfig QgsValueRelationConfigDlg::config()
Expand Down
2 changes: 2 additions & 0 deletions src/gui/editorwidgets/qgswebviewconfigdlg.cpp
Expand Up @@ -19,6 +19,8 @@ QgsWebViewWidgetConfigDlg::QgsWebViewWidgetConfigDlg( QgsVectorLayer* vl, int fi
: QgsEditorConfigWidget( vl, fieldIdx, parent )
{
setupUi( this );
connect( sbWidgetHeight, SIGNAL( valueChanged( int ) ), this, SIGNAL( changed() ) );
connect( sbWidgetWidth, SIGNAL( valueChanged( int ) ), this, SIGNAL( changed() ) );
}

QgsEditorWidgetConfig QgsWebViewWidgetConfigDlg::config()
Expand Down

0 comments on commit 9940586

Please sign in to comment.