Skip to content

Commit

Permalink
Const fixes for QgsSearchWidgetWrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Nov 1, 2017
1 parent 69a28d8 commit c3e2adc
Show file tree
Hide file tree
Showing 21 changed files with 47 additions and 45 deletions.
4 changes: 2 additions & 2 deletions python/gui/editorwidgets/core/qgssearchwidgetwrapper.sip
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class QgsSearchWidgetWrapper : QgsWidgetWrapper
:rtype: FilterFlags
%End

virtual QString expression() = 0;
virtual QString expression() const = 0;
%Docstring
Will be used to access the widget's value. Read the value from the widget and
return it properly formatted to be saved in the attribute.
Expand Down Expand Up @@ -206,7 +206,7 @@ class QgsSearchWidgetWrapper : QgsWidgetWrapper

protected slots:

virtual void setExpression( QString value ) = 0;
virtual void setExpression( const QString &value ) = 0;
virtual void setFeature( const QgsFeature &feature );


Expand Down
4 changes: 2 additions & 2 deletions python/gui/editorwidgets/qgscheckboxsearchwidgetwrapper.sip
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class QgsCheckboxSearchWidgetWrapper : QgsSearchWidgetWrapper

virtual bool applyDirectly();

virtual QString expression();
virtual QString expression() const;

virtual bool valid() const;

Expand All @@ -66,7 +66,7 @@ class QgsCheckboxSearchWidgetWrapper : QgsSearchWidgetWrapper


protected slots:
virtual void setExpression( QString exp );
virtual void setExpression( const QString &expression );


};
Expand Down
4 changes: 2 additions & 2 deletions python/gui/editorwidgets/qgsdatetimesearchwidgetwrapper.sip
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class QgsDateTimeSearchWidgetWrapper : QgsSearchWidgetWrapper

virtual bool applyDirectly();

virtual QString expression();
virtual QString expression() const;

virtual bool valid() const;

Expand All @@ -62,7 +62,7 @@ class QgsDateTimeSearchWidgetWrapper : QgsSearchWidgetWrapper


protected slots:
virtual void setExpression( QString exp );
virtual void setExpression( const QString &exp );


};
Expand Down
4 changes: 2 additions & 2 deletions python/gui/editorwidgets/qgsdefaultsearchwidgetwrapper.sip
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class QgsDefaultSearchWidgetWrapper : QgsSearchWidgetWrapper
explicit QgsDefaultSearchWidgetWrapper( QgsVectorLayer *vl, int fieldIdx, QWidget *parent /TransferThis/ = 0 );

public:
virtual QString expression();
virtual QString expression() const;

virtual bool applyDirectly();

Expand All @@ -40,7 +40,7 @@ class QgsDefaultSearchWidgetWrapper : QgsSearchWidgetWrapper
virtual void setEnabled( bool enabled );

protected slots:
virtual void setExpression( QString exp );
virtual void setExpression( const QString &exp );


protected:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class QgsRelationReferenceSearchWidgetWrapper : QgsSearchWidgetWrapper

virtual bool applyDirectly();

virtual QString expression();
virtual QString expression() const;

virtual bool valid() const;

Expand Down Expand Up @@ -69,7 +69,7 @@ Called when current value of search widget changes
%End

protected slots:
virtual void setExpression( QString exp );
virtual void setExpression( const QString &exp );


};
Expand Down
4 changes: 2 additions & 2 deletions python/gui/editorwidgets/qgsvaluemapsearchwidgetwrapper.sip
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class QgsValueMapSearchWidgetWrapper : QgsSearchWidgetWrapper
explicit QgsValueMapSearchWidgetWrapper( QgsVectorLayer *vl, int fieldIdx, QWidget *parent /TransferThis/ = 0 );
virtual bool applyDirectly();

virtual QString expression();
virtual QString expression() const;

virtual bool valid() const;

Expand All @@ -46,7 +46,7 @@ class QgsValueMapSearchWidgetWrapper : QgsSearchWidgetWrapper


protected slots:
virtual void setExpression( QString exp );
virtual void setExpression( const QString &exp );


};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class QgsValueRelationSearchWidgetWrapper : QgsSearchWidgetWrapper
explicit QgsValueRelationSearchWidgetWrapper( QgsVectorLayer *vl, int fieldIdx, QWidget *parent /TransferThis/ = 0 );
virtual bool applyDirectly();

virtual QString expression();
virtual QString expression() const;

virtual bool valid() const;

Expand Down Expand Up @@ -56,7 +56,7 @@ class QgsValueRelationSearchWidgetWrapper : QgsSearchWidgetWrapper
Called when current value of search widget changes
%End

virtual void setExpression( QString exp );
virtual void setExpression( const QString &exp );


};
Expand Down
1 change: 0 additions & 1 deletion src/gui/editorwidgets/core/qgssearchwidgetwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ QgsSearchWidgetWrapper::FilterFlags QgsSearchWidgetWrapper::defaultFlags() const
return FilterFlags();
}


void QgsSearchWidgetWrapper::setFeature( const QgsFeature &feature )
{
Q_UNUSED( feature )
Expand Down
4 changes: 2 additions & 2 deletions src/gui/editorwidgets/core/qgssearchwidgetwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class GUI_EXPORT QgsSearchWidgetWrapper : public QgsWidgetWrapper
*
* \returns The current value the widget represents
*/
virtual QString expression() = 0;
virtual QString expression() const = 0;

/**
* If this is true, then this search widget should take effect directly
Expand Down Expand Up @@ -225,7 +225,7 @@ class GUI_EXPORT QgsSearchWidgetWrapper : public QgsWidgetWrapper

protected slots:

virtual void setExpression( QString value ) = 0;
virtual void setExpression( const QString &value ) = 0;
void setFeature( const QgsFeature &feature ) override;

protected:
Expand Down
5 changes: 3 additions & 2 deletions src/gui/editorwidgets/qgscheckboxsearchwidgetwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ bool QgsCheckboxSearchWidgetWrapper::applyDirectly()
return true;
}

QString QgsCheckboxSearchWidgetWrapper::expression()
QString QgsCheckboxSearchWidgetWrapper::expression() const
{
return mExpression;
}
Expand Down Expand Up @@ -124,8 +124,9 @@ bool QgsCheckboxSearchWidgetWrapper::valid() const
return true;
}

void QgsCheckboxSearchWidgetWrapper::setExpression( QString exp )
void QgsCheckboxSearchWidgetWrapper::setExpression( const QString &expression )
{
QString exp = expression;
QString fieldName = layer()->fields().at( mFieldIdx ).name();

QString str = QStringLiteral( "%1 = '%3'" )
Expand Down
4 changes: 2 additions & 2 deletions src/gui/editorwidgets/qgscheckboxsearchwidgetwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class GUI_EXPORT QgsCheckboxSearchWidgetWrapper : public QgsSearchWidgetWrapper
QVariant value() const;

bool applyDirectly() override;
QString expression() override;
QString expression() const override;
bool valid() const override;
QgsSearchWidgetWrapper::FilterFlags supportedFlags() const override;
QgsSearchWidgetWrapper::FilterFlags defaultFlags() const override;
Expand All @@ -73,7 +73,7 @@ class GUI_EXPORT QgsCheckboxSearchWidgetWrapper : public QgsSearchWidgetWrapper
void initWidget( QWidget *editor ) override;

protected slots:
void setExpression( QString exp ) override;
void setExpression( const QString &expression ) override;

private slots:
void stateChanged( int state );
Expand Down
5 changes: 3 additions & 2 deletions src/gui/editorwidgets/qgsdatetimesearchwidgetwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ bool QgsDateTimeSearchWidgetWrapper::applyDirectly()
return true;
}

QString QgsDateTimeSearchWidgetWrapper::expression()
QString QgsDateTimeSearchWidgetWrapper::expression() const
{
return mExpression;
}
Expand Down Expand Up @@ -112,8 +112,9 @@ bool QgsDateTimeSearchWidgetWrapper::valid() const
return true;
}

void QgsDateTimeSearchWidgetWrapper::setExpression( QString exp )
void QgsDateTimeSearchWidgetWrapper::setExpression( const QString &expression )
{
QString exp = expression;
QString fieldName = layer()->fields().at( mFieldIdx ).name();

QString str = QStringLiteral( "%1 = '%3'" )
Expand Down
4 changes: 2 additions & 2 deletions src/gui/editorwidgets/qgsdatetimesearchwidgetwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class GUI_EXPORT QgsDateTimeSearchWidgetWrapper : public QgsSearchWidgetWrapper
QVariant value() const;

bool applyDirectly() override;
QString expression() override;
QString expression() const override;
bool valid() const override;
QgsSearchWidgetWrapper::FilterFlags supportedFlags() const override;
QgsSearchWidgetWrapper::FilterFlags defaultFlags() const override;
Expand All @@ -71,7 +71,7 @@ class GUI_EXPORT QgsDateTimeSearchWidgetWrapper : public QgsSearchWidgetWrapper
void initWidget( QWidget *editor ) override;

protected slots:
void setExpression( QString exp ) override;
void setExpression( const QString &exp ) override;

private slots:
void dateTimeChanged( const QDateTime &date );
Expand Down
6 changes: 3 additions & 3 deletions src/gui/editorwidgets/qgsdefaultsearchwidgetwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ QgsDefaultSearchWidgetWrapper::QgsDefaultSearchWidgetWrapper( QgsVectorLayer *vl
{
}

QString QgsDefaultSearchWidgetWrapper::expression()
QString QgsDefaultSearchWidgetWrapper::expression() const
{
return mExpression;
}
Expand All @@ -51,12 +51,12 @@ void QgsDefaultSearchWidgetWrapper::setCaseString( int caseSensitiveCheckState )
emit expressionChanged( mExpression );
}

void QgsDefaultSearchWidgetWrapper::setExpression( QString exp )
void QgsDefaultSearchWidgetWrapper::setExpression( const QString &expression )
{
QVariant::Type fldType = layer()->fields().at( mFieldIdx ).type();
bool numeric = ( fldType == QVariant::Int || fldType == QVariant::Double || fldType == QVariant::LongLong );

QgsSettings settings;
QString exp = expression;
QString nullValue = QgsApplication::nullRepresentation();
QString fieldName = layer()->fields().at( mFieldIdx ).name();
QString str;
Expand Down
4 changes: 2 additions & 2 deletions src/gui/editorwidgets/qgsdefaultsearchwidgetwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class GUI_EXPORT QgsDefaultSearchWidgetWrapper : public QgsSearchWidgetWrapper

// QgsSearchWidgetWrapper interface
public:
QString expression() override;
QString expression() const override;
bool applyDirectly() override;
QgsSearchWidgetWrapper::FilterFlags supportedFlags() const override;
QgsSearchWidgetWrapper::FilterFlags defaultFlags() const override;
Expand All @@ -49,7 +49,7 @@ class GUI_EXPORT QgsDefaultSearchWidgetWrapper : public QgsSearchWidgetWrapper
virtual void setEnabled( bool enabled ) override;

protected slots:
void setExpression( QString exp ) override;
void setExpression( const QString &exp ) override;

private slots:
void setCaseString( int caseSensitiveCheckState );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ bool QgsRelationReferenceSearchWidgetWrapper::applyDirectly()
return true;
}

QString QgsRelationReferenceSearchWidgetWrapper::expression()
QString QgsRelationReferenceSearchWidgetWrapper::expression() const
{
return mExpression;
}
Expand Down Expand Up @@ -141,9 +141,9 @@ void QgsRelationReferenceSearchWidgetWrapper::onValueChanged( const QVariant &va
emit expressionChanged( mExpression );
}

void QgsRelationReferenceSearchWidgetWrapper::setExpression( QString exp )
void QgsRelationReferenceSearchWidgetWrapper::setExpression( const QString &expression )
{
QgsSettings settings;
QString exp = expression;
QString nullValue = QgsApplication::nullRepresentation();
QString fieldName = layer()->fields().at( mFieldIdx ).name();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class GUI_EXPORT QgsRelationReferenceSearchWidgetWrapper : public QgsSearchWidge
QVariant value() const;

bool applyDirectly() override;
QString expression() override;
QString expression() const override;
bool valid() const override;
QgsSearchWidgetWrapper::FilterFlags supportedFlags() const override;
QgsSearchWidgetWrapper::FilterFlags defaultFlags() const override;
Expand All @@ -76,7 +76,7 @@ class GUI_EXPORT QgsRelationReferenceSearchWidgetWrapper : public QgsSearchWidge
void onValueChanged( const QVariant &value );

protected slots:
void setExpression( QString exp ) override;
void setExpression( const QString &exp ) override;

private:

Expand Down
7 changes: 4 additions & 3 deletions src/gui/editorwidgets/qgsvaluemapsearchwidgetwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ bool QgsValueMapSearchWidgetWrapper::applyDirectly()
return true;
}

QString QgsValueMapSearchWidgetWrapper::expression()
QString QgsValueMapSearchWidgetWrapper::expression() const
{
return mExpression;
}
Expand Down Expand Up @@ -143,7 +143,7 @@ void QgsValueMapSearchWidgetWrapper::initWidget( QWidget *editor )
{
const QVariantMap cfg = config();
QVariantMap::ConstIterator it = cfg.constBegin();
mComboBox->addItem( tr( "Please select" ), "" );
mComboBox->addItem( tr( "Please select" ), QString() );

while ( it != cfg.constEnd() )
{
Expand All @@ -155,8 +155,9 @@ void QgsValueMapSearchWidgetWrapper::initWidget( QWidget *editor )
}
}

void QgsValueMapSearchWidgetWrapper::setExpression( QString exp )
void QgsValueMapSearchWidgetWrapper::setExpression( const QString &expression )
{
QString exp = expression;
QString fieldName = layer()->fields().at( mFieldIdx ).name();
QString str;

Expand Down
4 changes: 2 additions & 2 deletions src/gui/editorwidgets/qgsvaluemapsearchwidgetwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class GUI_EXPORT QgsValueMapSearchWidgetWrapper : public QgsSearchWidgetWrapper
public:
explicit QgsValueMapSearchWidgetWrapper( QgsVectorLayer *vl, int fieldIdx, QWidget *parent SIP_TRANSFERTHIS = 0 );
bool applyDirectly() override;
QString expression() override;
QString expression() const override;
bool valid() const override;
QgsSearchWidgetWrapper::FilterFlags supportedFlags() const override;
QgsSearchWidgetWrapper::FilterFlags defaultFlags() const override;
Expand All @@ -50,7 +50,7 @@ class GUI_EXPORT QgsValueMapSearchWidgetWrapper : public QgsSearchWidgetWrapper
void initWidget( QWidget *editor ) override;

protected slots:
void setExpression( QString exp ) override;
void setExpression( const QString &exp ) override;

private slots:
void comboBoxIndexChanged( int idx );
Expand Down
6 changes: 3 additions & 3 deletions src/gui/editorwidgets/qgsvaluerelationsearchwidgetwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ bool QgsValueRelationSearchWidgetWrapper::applyDirectly()
return !mLineEdit;
}

QString QgsValueRelationSearchWidgetWrapper::expression()
QString QgsValueRelationSearchWidgetWrapper::expression() const
{
return mExpression;
}
Expand Down Expand Up @@ -189,9 +189,9 @@ void QgsValueRelationSearchWidgetWrapper::onValueChanged()
emit expressionChanged( mExpression );
}

void QgsValueRelationSearchWidgetWrapper::setExpression( QString exp )
void QgsValueRelationSearchWidgetWrapper::setExpression( const QString &expression )
{
QgsSettings settings;
QString exp = expression;
QString nullValue = QgsApplication::nullRepresentation();
QString fieldName = layer()->fields().at( mFieldIdx ).name();

Expand Down
4 changes: 2 additions & 2 deletions src/gui/editorwidgets/qgsvaluerelationsearchwidgetwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class GUI_EXPORT QgsValueRelationSearchWidgetWrapper : public QgsSearchWidgetWra
public:
explicit QgsValueRelationSearchWidgetWrapper( QgsVectorLayer *vl, int fieldIdx, QWidget *parent SIP_TRANSFERTHIS = 0 );
bool applyDirectly() override;
QString expression() override;
QString expression() const override;
bool valid() const override;
QVariant value() const;
QgsSearchWidgetWrapper::FilterFlags supportedFlags() const override;
Expand All @@ -59,7 +59,7 @@ class GUI_EXPORT QgsValueRelationSearchWidgetWrapper : public QgsSearchWidgetWra
//! Called when current value of search widget changes
void onValueChanged();

void setExpression( QString exp ) override;
void setExpression( const QString &exp ) override;

private:
QComboBox *mComboBox = nullptr;
Expand Down

0 comments on commit c3e2adc

Please sign in to comment.