Skip to content
Permalink
Browse files

Refactor widget constraints to keep variables private

  • Loading branch information
m-kuhn committed Jun 2, 2016
1 parent d285134 commit c68eaeb92923638518e802baf410d55eed766f37
@@ -199,5 +199,5 @@ class QgsEditorWidgetWrapper : QgsWidgetWrapper
* This can be overwritten in subclasses to allow individual widgets to
* change the visual cue.
*/
virtual void updateConstraintWidgetStatus();
virtual void updateConstraintWidgetStatus( bool contraintValid );
};
@@ -34,5 +34,5 @@ class QgsRelationReferenceWidgetWrapper : QgsEditorWidgetWrapper
* change the visual cue.
* @note added in QGIS 2.16
*/
void updateConstraintWidgetStatus();
void updateConstraintWidgetStatus( bool constraintValid ) override;
};
@@ -97,9 +97,9 @@ void QgsEditorWidgetWrapper::valueChanged()
emit valueChanged( value() );
}

void QgsEditorWidgetWrapper::updateConstraintWidgetStatus()
void QgsEditorWidgetWrapper::updateConstraintWidgetStatus( bool constraintValid )
{
if ( mValidConstraint )
if ( constraintValid )
widget()->setStyleSheet( QString() );
else
widget()->setStyleSheet( "background-color: #dd7777;" );
@@ -162,7 +162,7 @@ void QgsEditorWidgetWrapper::updateConstraint( const QgsFeature &ft )

if ( toEmit )
{
updateConstraintWidgetStatus();
updateConstraintWidgetStatus( mValidConstraint );
emit constraintStatusChanged( expression, description, errStr, mValidConstraint );
}
}
@@ -220,11 +220,15 @@ class GUI_EXPORT QgsEditorWidgetWrapper : public QgsWidgetWrapper
*
* This can be overwritten in subclasses to allow individual widgets to
* change the visual cue.
*
* @param constraintValid The current constraint status.
*
* @note added in QGIS 2.16
*/
virtual void updateConstraintWidgetStatus();
virtual void updateConstraintWidgetStatus( bool constraintValid );

private:

/**
* Boolean storing the current validity of the constraint for this widget.
*/
@@ -78,7 +78,7 @@ void QgsColorWidgetWrapper::setValue( const QVariant& value )
mColorButton->setColor( !value.isNull() ? QColor( value.toString() ) : QColor() );
}

void QgsColorWidgetWrapper::updateConstraintWidgetStatus()
void QgsColorWidgetWrapper::updateConstraintWidgetStatus( bool constraintValid )
{
// nothing
}
@@ -46,7 +46,7 @@ class GUI_EXPORT QgsColorWidgetWrapper : public QgsEditorWidgetWrapper
void setValue( const QVariant& value ) override;

private:
void updateConstraintWidgetStatus() override;
void updateConstraintWidgetStatus( bool constraintValid ) override;

QgsColorButtonV2* mColorButton;
};
@@ -188,11 +188,11 @@ void QgsExternalResourceWidgetWrapper::setEnabled( bool enabled )
mQgsWidget->setReadOnly( !enabled );
}

void QgsExternalResourceWidgetWrapper::updateConstraintWidgetStatus()
void QgsExternalResourceWidgetWrapper::updateConstraintWidgetStatus( bool constraintValid )
{
if ( mLineEdit )
{
if ( mValidConstraint )
if ( constraintValid )
mLineEdit->setStyleSheet( QString() );
else
mLineEdit->setStyleSheet( "QgsFilterLineEdit { background-color: #dd7777; }" );
@@ -54,7 +54,7 @@ class GUI_EXPORT QgsExternalResourceWidgetWrapper : public QgsEditorWidgetWrappe
void setEnabled( bool enabled ) override;

private:
void updateConstraintWidgetStatus() override;
void updateConstraintWidgetStatus( bool constraintValid ) override;

QLineEdit* mLineEdit;
QLabel* mLabel;
@@ -152,11 +152,11 @@ void QgsFileNameWidgetWrapper::selectFileName()
mLineEdit->setText( fileName );
}

void QgsFileNameWidgetWrapper::updateConstraintWidgetStatus()
void QgsFileNameWidgetWrapper::updateConstraintWidgetStatus( bool constraintValid )
{
if ( mLineEdit )
{
if ( mValidConstraint )
if ( constraintValid )
mLineEdit->setStyleSheet( QString() );
else
{
@@ -51,7 +51,7 @@ class GUI_EXPORT QgsFileNameWidgetWrapper : public QgsEditorWidgetWrapper
void setValue( const QVariant& value ) override;

private:
void updateConstraintWidgetStatus() override;
void updateConstraintWidgetStatus( bool constraintValid ) override;

QLineEdit* mLineEdit;
QPushButton* mPushButton;
@@ -267,11 +267,11 @@ void QgsPhotoWidgetWrapper::setEnabled( bool enabled )
mButton->setEnabled( enabled );
}

void QgsPhotoWidgetWrapper::updateConstraintWidgetStatus()
void QgsPhotoWidgetWrapper::updateConstraintWidgetStatus( bool constraintValid )
{
if ( mLineEdit )
{
if ( mValidConstraint )
if ( constraintValid )
mLineEdit->setStyleSheet( QString() );
else
{
@@ -65,7 +65,7 @@ class GUI_EXPORT QgsPhotoWidgetWrapper : public QgsEditorWidgetWrapper
void loadPixmap( const QString& fileName );

private:
void updateConstraintWidgetStatus() override;
void updateConstraintWidgetStatus( bool constraintValid ) override;

//! This label is used as a container to display the picture
QLabel* mPhotoLabel;
@@ -140,11 +140,11 @@ void QgsRelationReferenceWidgetWrapper::foreignKeyChanged( QVariant value )
emit valueChanged( value );
}

void QgsRelationReferenceWidgetWrapper::updateConstraintWidgetStatus()
void QgsRelationReferenceWidgetWrapper::updateConstraintWidgetStatus( bool constraintValid )
{
if ( mWidget )
{
if ( mValidConstraint )
if ( constraintValid )
mWidget->setStyleSheet( QString() );
else
mWidget->setStyleSheet( ".QComboBox { background-color: #dd7777; }" );
@@ -71,7 +71,7 @@ class GUI_EXPORT QgsRelationReferenceWidgetWrapper : public QgsEditorWidgetWrapp
* change the visual cue.
* @note added in QGIS 2.16
*/
void updateConstraintWidgetStatus() override;
void updateConstraintWidgetStatus( bool constraintValid ) override;

private:
QgsRelationReferenceWidget* mWidget;
@@ -189,11 +189,11 @@ void QgsWebViewWidgetWrapper::selectFileName()
mLineEdit->setText( filePath );
}

void QgsWebViewWidgetWrapper::updateConstraintWidgetStatus()
void QgsWebViewWidgetWrapper::updateConstraintWidgetStatus( bool constraintValid )
{
if ( mLineEdit )
{
if ( mValidConstraint )
if ( constraintValid )
mLineEdit->setStyleSheet( QString() );
else
{
@@ -53,7 +53,7 @@ class GUI_EXPORT QgsWebViewWidgetWrapper : public QgsEditorWidgetWrapper
void selectFileName();

private:
void updateConstraintWidgetStatus() override;
void updateConstraintWidgetStatus( bool constraintValid ) override;

//! This label is used as a container to display the picture
QWebView* mWebView;

3 comments on commit c68eaeb

@m-kuhn

This comment has been minimized.

Copy link
Member Author

@m-kuhn m-kuhn replied Jun 2, 2016

@pblottiere I hope this is ok for you. Unless it is really necessary (but actually I cannot think of a real reason), member variables should always be private.

@nirvn

This comment has been minimized.

Copy link
Contributor

@nirvn nirvn replied Jun 2, 2016

@m-kuhn QGIS fails to build now, with this error message:
sip: /home/webmaster/dev/cpp/QGIS/python/gui/editorwidgets/qgsrelationreferencewidgetwrapper.sip:37: syntax error
python/CMakeFiles/python_module_qgis__gui.dir/build.make:615: recipe for target 'python/gui/sip_guipart0.cpp' failed
make[2]: *** [python/gui/sip_guipart0.cpp] Error 1
make[2]: *** Deleting file 'python/gui/sip_guipart0.cpp'
CMakeFiles/Makefile2:3797: recipe for target 'python/CMakeFiles/python_module_qgis__gui.dir/all' failed
make[1]: *** [python/CMakeFiles/python_module_qgis__gui.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2

@nirvn

This comment has been minimized.

Copy link
Contributor

@nirvn nirvn replied Jun 2, 2016

@m-kuhn removing the "override" keyword on qgsrelationreferencewidgetwrapper.sip line 37 fixes the build.

Please sign in to comment.
You can’t perform that action at this time.