Skip to content

Commit

Permalink
constexpr instead of static
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Nov 2, 2019
1 parent 208ea9b commit ab18dd3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/gui/editorwidgets/qgsdoublespinbox.cpp
Expand Up @@ -29,7 +29,7 @@
// This is required because private implementation of
// QAbstractSpinBoxPrivate checks for specialText emptiness
// and skips specialText handling if it's empty
QString QgsDoubleSpinBox::SPECIAL_TEXT_WHEN_EMPTY = QChar( 0x2063 );
static constexpr QChar const &SPECIAL_TEXT_WHEN_EMPTY = QChar( 0x2063 );


QgsDoubleSpinBox::QgsDoubleSpinBox( QWidget *parent )
Expand Down
5 changes: 0 additions & 5 deletions src/gui/editorwidgets/qgsdoublespinbox.h
Expand Up @@ -168,11 +168,6 @@ class GUI_EXPORT QgsDoubleSpinBox : public QDoubleSpinBox

QString stripped( const QString &originalText ) const;

// This is required because private implementation of
// QAbstractSpinBoxPrivate checks for specialText emptiness
// and skips specialText handling if it's empty
static QString SPECIAL_TEXT_WHEN_EMPTY;

friend class TestQgsRangeWidgetWrapper;
};

Expand Down
3 changes: 1 addition & 2 deletions src/gui/editorwidgets/qgsspinbox.cpp
Expand Up @@ -29,8 +29,7 @@
// This is required because private implementation of
// QAbstractSpinBoxPrivate checks for specialText emptiness
// and skips specialText handling if it's empty
QString QgsSpinBox::SPECIAL_TEXT_WHEN_EMPTY = QChar( 0x2063 );

static constexpr QChar const &SPECIAL_TEXT_WHEN_EMPTY = QChar( 0x2063 );

QgsSpinBox::QgsSpinBox( QWidget *parent )
: QSpinBox( parent )
Expand Down
14 changes: 8 additions & 6 deletions tests/src/gui/testqgsrangewidgetwrapper.cpp
Expand Up @@ -33,6 +33,8 @@

#include <memory>

static constexpr QChar const &SPECIAL_TEXT_WHEN_EMPTY = QChar( 0x2063 );

/**
* @ingroup UnitTests
* This is a unit test for the range widget
Expand Down Expand Up @@ -306,10 +308,10 @@ void TestQgsRangeWidgetWrapper::test_nulls()
// Null
QCOMPARE( editor1->value( ), editor1->minimum() );
QCOMPARE( widget1->value( ), QVariant( QVariant::Double ) );
QCOMPARE( editor1->mLineEdit->text(), QgsDoubleSpinBox::SPECIAL_TEXT_WHEN_EMPTY );
editor1->mLineEdit->setText( QString( "151%1" ).arg( QgsDoubleSpinBox::SPECIAL_TEXT_WHEN_EMPTY ) );
QCOMPARE( editor1->mLineEdit->text(), SPECIAL_TEXT_WHEN_EMPTY );
editor1->mLineEdit->setText( QString( "151%1" ).arg( SPECIAL_TEXT_WHEN_EMPTY ) );
QCOMPARE( widget1->value( ).toInt(), 151 );
editor1->mLineEdit->setText( QString( QgsDoubleSpinBox::SPECIAL_TEXT_WHEN_EMPTY ).append( QStringLiteral( "161" ) ) );
editor1->mLineEdit->setText( QString( SPECIAL_TEXT_WHEN_EMPTY ).append( QStringLiteral( "161" ) ) );
QCOMPARE( widget1->value( ).toInt(), 161 );


Expand All @@ -325,11 +327,11 @@ void TestQgsRangeWidgetWrapper::test_nulls()
// Null
QCOMPARE( editor0->value( ), editor0->minimum() );
QCOMPARE( widget0->value( ), QVariant( QVariant::Int ) );
QCOMPARE( editor0->mLineEdit->text(), QgsDoubleSpinBox::SPECIAL_TEXT_WHEN_EMPTY );
QCOMPARE( editor0->mLineEdit->text(), SPECIAL_TEXT_WHEN_EMPTY );

editor0->mLineEdit->setText( QString( "150%1" ).arg( QgsDoubleSpinBox::SPECIAL_TEXT_WHEN_EMPTY ) );
editor0->mLineEdit->setText( QString( "150%1" ).arg( SPECIAL_TEXT_WHEN_EMPTY ) );
QCOMPARE( widget0->value( ).toInt(), 150 );
editor0->mLineEdit->setText( QString( QgsDoubleSpinBox::SPECIAL_TEXT_WHEN_EMPTY ).append( QStringLiteral( "160" ) ) );
editor0->mLineEdit->setText( QString( SPECIAL_TEXT_WHEN_EMPTY ).append( QStringLiteral( "160" ) ) );
QCOMPARE( widget0->value( ).toInt(), 160 );

}
Expand Down

0 comments on commit ab18dd3

Please sign in to comment.