Skip to content

Commit

Permalink
Refactor widget constraints to keep variables private
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Jun 2, 2016
1 parent d285134 commit c68eaeb
Show file tree
Hide file tree
Showing 16 changed files with 27 additions and 23 deletions.
2 changes: 1 addition & 1 deletion python/gui/editorwidgets/core/qgseditorwidgetwrapper.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
};
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ class QgsRelationReferenceWidgetWrapper : QgsEditorWidgetWrapper
* change the visual cue.
* @note added in QGIS 2.16
*/
void updateConstraintWidgetStatus();
void updateConstraintWidgetStatus( bool constraintValid ) override;
};
6 changes: 3 additions & 3 deletions src/gui/editorwidgets/core/qgseditorwidgetwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;" );
Expand Down Expand Up @@ -162,7 +162,7 @@ void QgsEditorWidgetWrapper::updateConstraint( const QgsFeature &ft )

if ( toEmit )
{
updateConstraintWidgetStatus();
updateConstraintWidgetStatus( mValidConstraint );
emit constraintStatusChanged( expression, description, errStr, mValidConstraint );
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/gui/editorwidgets/core/qgseditorwidgetwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/gui/editorwidgets/qgscolorwidgetwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion src/gui/editorwidgets/qgscolorwidgetwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
4 changes: 2 additions & 2 deletions src/gui/editorwidgets/qgsexternalresourcewidgetwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }" );
Expand Down
2 changes: 1 addition & 1 deletion src/gui/editorwidgets/qgsexternalresourcewidgetwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/gui/editorwidgets/qgsfilenamewidgetwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/gui/editorwidgets/qgsfilenamewidgetwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/gui/editorwidgets/qgsphotowidgetwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/gui/editorwidgets/qgsphotowidgetwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/gui/editorwidgets/qgsrelationreferencewidgetwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }" );
Expand Down
2 changes: 1 addition & 1 deletion src/gui/editorwidgets/qgsrelationreferencewidgetwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/gui/editorwidgets/qgswebviewwidgetwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/gui/editorwidgets/qgswebviewwidgetwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

3 comments on commit c68eaeb

@m-kuhn
Copy link
Member Author

@m-kuhn m-kuhn commented on c68eaeb Jun 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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
Copy link
Contributor

@nirvn nirvn commented on c68eaeb Jun 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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
Copy link
Contributor

@nirvn nirvn commented on c68eaeb Jun 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Please sign in to comment.