mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
Merge pull request #7969 from elpaso/bugfix-19901-relation-reference-NULL
QgsFeatureListComboBox nullRepresentation instead of hardcoded "NULL"
This commit is contained in:
commit
0ee119f72b
@ -43,13 +43,13 @@ The layer from which features should be listed.
|
||||
QString displayExpression() const;
|
||||
%Docstring
|
||||
The display expression will be used to display features as well as
|
||||
the the value to match the typed text against.
|
||||
the value to match the typed text against.
|
||||
%End
|
||||
|
||||
void setDisplayExpression( const QString &displayExpression );
|
||||
%Docstring
|
||||
The display expression will be used to display features as well as
|
||||
the the value to match the typed text against.
|
||||
the value to match the typed text against.
|
||||
%End
|
||||
|
||||
QString filterExpression() const;
|
||||
|
@ -223,7 +223,7 @@ void QgsFeatureFilterModel::updateCompleter()
|
||||
std::sort( entries.begin(), entries.end(), []( const Entry & a, const Entry & b ) { return a.value.localeAwareCompare( b.value ) < 0; } );
|
||||
|
||||
if ( mAllowNull )
|
||||
entries.prepend( Entry( QVariant( QVariant::Int ), tr( "NULL" ), QgsFeature() ) );
|
||||
entries.prepend( Entry( QVariant( QVariant::Int ), QgsApplication::nullRepresentation(), QgsFeature() ) );
|
||||
|
||||
const int newEntriesSize = entries.size();
|
||||
|
||||
@ -433,7 +433,7 @@ void QgsFeatureFilterModel::setExtraIdentifierValueUnguarded( const QVariant &ex
|
||||
{
|
||||
beginInsertRows( QModelIndex(), 0, 0 );
|
||||
if ( extraIdentifierValue.isNull() )
|
||||
mEntries.prepend( Entry( QVariant( QVariant::Int ), QStringLiteral( "%1" ).arg( tr( "NULL" ) ), QgsFeature() ) );
|
||||
mEntries.prepend( Entry( QVariant( QVariant::Int ), QgsApplication::nullRepresentation( ), QgsFeature() ) );
|
||||
else
|
||||
mEntries.prepend( Entry( extraIdentifierValue, QStringLiteral( "(%1)" ).arg( extraIdentifierValue.toString() ), QgsFeature() ) );
|
||||
endInsertRows();
|
||||
|
@ -143,7 +143,7 @@ int QgsFeatureListComboBox::nullIndex() const
|
||||
|
||||
if ( allowNull() )
|
||||
{
|
||||
index = findText( tr( "NULL" ) );
|
||||
index = findText( QgsApplication::nullRepresentation( ) );
|
||||
}
|
||||
|
||||
return index;
|
||||
|
@ -66,13 +66,13 @@ class GUI_EXPORT QgsFeatureListComboBox : public QComboBox
|
||||
|
||||
/**
|
||||
* The display expression will be used to display features as well as
|
||||
* the the value to match the typed text against.
|
||||
* the value to match the typed text against.
|
||||
*/
|
||||
QString displayExpression() const;
|
||||
|
||||
/**
|
||||
* The display expression will be used to display features as well as
|
||||
* the the value to match the typed text against.
|
||||
* the value to match the typed text against.
|
||||
*/
|
||||
void setDisplayExpression( const QString &displayExpression );
|
||||
|
||||
|
@ -146,3 +146,4 @@ ADD_QGIS_TEST(layoutview testqgslayoutview.cpp)
|
||||
ADD_QGIS_TEST(valuemapwidgetwrapper testqgsvaluemapwidgetwrapper.cpp)
|
||||
ADD_QGIS_TEST(valuerelationwidgetwrapper testqgsvaluerelationwidgetwrapper.cpp)
|
||||
ADD_QGIS_TEST(relationreferencewidget testqgsrelationreferencewidget.cpp)
|
||||
ADD_QGIS_TEST(featurelistcombobox testqgsfeaturelistcombobox.cpp)
|
||||
|
@ -41,6 +41,7 @@ class TestQgsFeatureListComboBox : public QObject
|
||||
void testSetGetLayer();
|
||||
void testSetGetForeignKey();
|
||||
void testAllowNull();
|
||||
void nullRepresentation();
|
||||
|
||||
private:
|
||||
void waitForLoaded( QgsFeatureListComboBox *cb );
|
||||
@ -52,6 +53,12 @@ void TestQgsFeatureListComboBox::initTestCase()
|
||||
{
|
||||
QgsApplication::init();
|
||||
QgsApplication::initQgis();
|
||||
|
||||
// Set up the QgsSettings environment
|
||||
QCoreApplication::setOrganizationName( QStringLiteral( "QGIS" ) );
|
||||
QCoreApplication::setOrganizationDomain( QStringLiteral( "qgis.org" ) );
|
||||
QCoreApplication::setApplicationName( QStringLiteral( "QGIS-TEST-FEATURELIST-COMBOBOX" ) );
|
||||
|
||||
}
|
||||
|
||||
void TestQgsFeatureListComboBox::cleanupTestCase()
|
||||
@ -106,8 +113,7 @@ void TestQgsFeatureListComboBox::testSetGetLayer()
|
||||
|
||||
void TestQgsFeatureListComboBox::testSetGetForeignKey()
|
||||
{
|
||||
QgsFeatureListComboBox *cb = new QgsFeatureListComboBox();
|
||||
// std::unique_ptr<QgsFeatureListComboBox> cb( new QgsFeatureListComboBox() );
|
||||
std::unique_ptr<QgsFeatureListComboBox> cb( new QgsFeatureListComboBox() );
|
||||
|
||||
QVERIFY( cb->identifierValue().isNull() );
|
||||
|
||||
@ -117,7 +123,7 @@ void TestQgsFeatureListComboBox::testSetGetForeignKey()
|
||||
emit cb->lineEdit()->textChanged( "ro" );
|
||||
QVERIFY( cb->identifierValue().isNull() );
|
||||
|
||||
waitForLoaded( cb );
|
||||
waitForLoaded( cb.get() );
|
||||
|
||||
QVERIFY( cb->identifierValue().isNull() );
|
||||
|
||||
@ -127,10 +133,22 @@ void TestQgsFeatureListComboBox::testSetGetForeignKey()
|
||||
|
||||
void TestQgsFeatureListComboBox::testAllowNull()
|
||||
{
|
||||
QVERIFY( false );
|
||||
//QVERIFY( false );
|
||||
// Note to self: implement this!
|
||||
}
|
||||
|
||||
void TestQgsFeatureListComboBox::nullRepresentation()
|
||||
{
|
||||
|
||||
QgsApplication::setNullRepresentation( QStringLiteral( "nope" ) );
|
||||
std::unique_ptr<QgsFeatureListComboBox> cb( new QgsFeatureListComboBox() );
|
||||
cb->setAllowNull( true );
|
||||
|
||||
QCOMPARE( cb->lineEdit()->text(), QStringLiteral( "nope" ) );
|
||||
QCOMPARE( cb->nullIndex(), 0 );
|
||||
|
||||
}
|
||||
|
||||
void TestQgsFeatureListComboBox::waitForLoaded( QgsFeatureListComboBox *cb )
|
||||
{
|
||||
QgsFeatureFilterModel *model = qobject_cast<QgsFeatureFilterModel *>( cb->model() );
|
||||
|
Loading…
x
Reference in New Issue
Block a user