mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Manage null representation value in QgsApplication::nullRepresentation()
This commit is contained in:
parent
35a2be634b
commit
f4bc53695e
@ -123,7 +123,7 @@ QString QgsClipboard::generateClipboardText() const
|
||||
textFields += it->geometry().exportToWkt();
|
||||
else
|
||||
{
|
||||
textFields += settings.value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString();
|
||||
textFields += QgsApplication::nullRepresentation();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -640,7 +640,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl )
|
||||
else
|
||||
mComboCopyFeatureFormat->setCurrentIndex( mComboCopyFeatureFormat->findData( mSettings->value( QStringLiteral( "/qgis/copyGeometryAsWKT" ), true ).toBool() ?
|
||||
QgsClipboard::AttributesWithWKT : QgsClipboard::AttributesOnly ) );
|
||||
leNullValue->setText( mSettings->value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString() );
|
||||
leNullValue->setText( QgsApplication::nullRepresentation() );
|
||||
cbxIgnoreShapeEncoding->setChecked( mSettings->value( QStringLiteral( "/qgis/ignoreShapeEncoding" ), true ).toBool() );
|
||||
|
||||
cmbLegendDoubleClickAction->setCurrentIndex( mSettings->value( QStringLiteral( "/qgis/legendDoubleClickAction" ), 0 ).toInt() );
|
||||
@ -1254,7 +1254,7 @@ void QgsOptions::saveOptions()
|
||||
}
|
||||
mSettings->setValue( QStringLiteral( "/qgis/enableMacros" ), cmbEnableMacros->currentIndex() );
|
||||
|
||||
mSettings->setValue( QStringLiteral( "/qgis/nullValue" ), leNullValue->text() );
|
||||
QgsApplication::setNullRepresentation( leNullValue->text() );
|
||||
mSettings->setValue( QStringLiteral( "/qgis/style" ), cmbStyle->currentText() );
|
||||
mSettings->setValue( QStringLiteral( "/IconSize" ), cmbIconSize->currentText() );
|
||||
|
||||
|
@ -34,7 +34,7 @@ QString QgsDateTimeFieldFormatter::representValue( QgsVectorLayer* layer, int fi
|
||||
if ( value.isNull() )
|
||||
{
|
||||
QSettings settings;
|
||||
return settings.value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString();
|
||||
return QgsApplication::nullRepresentation();
|
||||
}
|
||||
|
||||
const QgsField field = layer->fields().at( fieldIndex );
|
||||
|
@ -14,6 +14,7 @@
|
||||
* *
|
||||
***************************************************************************/
|
||||
#include "qgskeyvaluefieldformatter.h"
|
||||
#include "qgsapplication.h"
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
@ -32,7 +33,7 @@ QString QgsKeyValueFieldFormatter::representValue( QgsVectorLayer* layer, int fi
|
||||
if ( value.isNull() )
|
||||
{
|
||||
QSettings settings;
|
||||
return settings.value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString();
|
||||
return QgsApplication::nullRepresentation();
|
||||
}
|
||||
|
||||
QString result;
|
||||
|
@ -14,7 +14,7 @@
|
||||
* *
|
||||
***************************************************************************/
|
||||
#include "qgslistfieldformatter.h"
|
||||
|
||||
#include "qgsapplication.h"
|
||||
#include <QSettings>
|
||||
|
||||
QString QgsListFieldFormatter::id() const
|
||||
@ -32,7 +32,7 @@ QString QgsListFieldFormatter::representValue( QgsVectorLayer* layer, int fieldI
|
||||
if ( value.isNull() )
|
||||
{
|
||||
QSettings settings;
|
||||
return settings.value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString();
|
||||
return QgsApplication::nullRepresentation();
|
||||
}
|
||||
|
||||
QString result;
|
||||
|
@ -47,7 +47,7 @@ QString QgsValueRelationFieldFormatter::representValue( QgsVectorLayer* layer, i
|
||||
Q_UNUSED( layer )
|
||||
Q_UNUSED( fieldIndex )
|
||||
|
||||
QgsValueRelationFieldFormatter::ValueRelationCache vrCache;
|
||||
ValueRelationCache vrCache;
|
||||
|
||||
if ( cache.isValid() )
|
||||
{
|
||||
@ -77,8 +77,7 @@ QString QgsValueRelationFieldFormatter::representValue( QgsVectorLayer* layer, i
|
||||
{
|
||||
if ( value.isNull() )
|
||||
{
|
||||
QSettings settings;
|
||||
return settings.value( "qgis/nullValue", "NULL" ).toString();
|
||||
return QgsApplication::nullRepresentation();
|
||||
}
|
||||
|
||||
Q_FOREACH ( const QgsValueRelationFieldFormatter::ValueRelationItem& item, vrCache )
|
||||
|
@ -1258,6 +1258,25 @@ void QgsApplication::copyPath( const QString& src, const QString& dst )
|
||||
}
|
||||
}
|
||||
|
||||
QString QgsApplication::nullRepresentation()
|
||||
{
|
||||
QgsApplication* app = instance();
|
||||
if ( app->mNullRepresentation.isNull() )
|
||||
app->mNullRepresentation = QSettings().value( QStringLiteral( "qgis/nullValue" ), QStringLiteral( "NULL" ) ).toString();
|
||||
return app->mNullRepresentation;
|
||||
}
|
||||
|
||||
void QgsApplication::setNullRepresentation( const QString& nullRepresentation )
|
||||
{
|
||||
QgsApplication* app = instance();
|
||||
if ( app->mNullRepresentation == nullRepresentation )
|
||||
return;
|
||||
|
||||
app->mNullRepresentation = nullRepresentation;
|
||||
QSettings().setValue( QStringLiteral( "qgis/nullValue" ), nullRepresentation );
|
||||
emit app->nullRepresentationChanged();
|
||||
}
|
||||
|
||||
QgsActionScopeRegistry* QgsApplication::actionScopeRegistry()
|
||||
{
|
||||
return instance()->mActionScopeRegistry;
|
||||
|
@ -402,6 +402,21 @@ class CORE_EXPORT QgsApplication : public QApplication
|
||||
*/
|
||||
static QgsFieldFormatterRegistry* fieldKitRegistry();
|
||||
|
||||
/**
|
||||
* This string is used to represent the value `NULL` throughout QGIS.
|
||||
*
|
||||
* In general, when passing values around, prefer to use a null QVariant
|
||||
* `QVariant( field.type() )` or `QVariant( QVariant::Int )`. This value
|
||||
* should only be used in the final presentation step when showing values
|
||||
* in a widget or sending it to a web browser.
|
||||
*/
|
||||
static QString nullRepresentation();
|
||||
|
||||
/**
|
||||
* \copydoc nullRepresentation()
|
||||
*/
|
||||
static void setNullRepresentation( const QString& nullRepresentation );
|
||||
|
||||
public slots:
|
||||
|
||||
/** Causes the application instance to emit the settingsChanged() signal. This should
|
||||
@ -422,6 +437,11 @@ class CORE_EXPORT QgsApplication : public QApplication
|
||||
*/
|
||||
void settingsChanged();
|
||||
|
||||
/**
|
||||
* \copydoc nullRepresentation()
|
||||
*/
|
||||
void nullRepresentationChanged();
|
||||
|
||||
private:
|
||||
static void copyPath( const QString& src, const QString& dst );
|
||||
static QObject* ABISYM( mFileOpenEventReceiver );
|
||||
@ -472,6 +492,7 @@ class CORE_EXPORT QgsApplication : public QApplication
|
||||
QgsRuntimeProfiler* mProfiler;
|
||||
QgsTaskManager* mTaskManager;
|
||||
QgsFieldFormatterRegistry* mFieldFormatterRegistry;
|
||||
QString mNullRepresentation;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -211,7 +211,7 @@ QString QgsField::displayString( const QVariant& v ) const
|
||||
if ( v.isNull() )
|
||||
{
|
||||
QSettings settings;
|
||||
return settings.value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString();
|
||||
return QgsApplication::nullRepresentation();
|
||||
}
|
||||
|
||||
if ( d->type == QVariant::Double && d->precision > 0 )
|
||||
|
@ -73,7 +73,7 @@ QVariant QgsFeatureListModel::data( const QModelIndex &index, int role ) const
|
||||
{
|
||||
if ( role == Qt::DisplayRole )
|
||||
{
|
||||
return QSettings().value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString();
|
||||
return QgsApplication::nullRepresentation();
|
||||
}
|
||||
else if ( role == QgsAttributeTableModel::FeatureIdRole )
|
||||
{
|
||||
|
@ -37,7 +37,7 @@ QgsDateTimeEdit::QgsDateTimeEdit( QWidget *parent )
|
||||
mClearButton->hide();
|
||||
connect( mClearButton, SIGNAL( clicked() ), this, SLOT( clear() ) );
|
||||
|
||||
mNullLabel = new QLineEdit( QSettings().value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString(), this );
|
||||
mNullLabel = new QLineEdit( QgsApplication::nullRepresentation(), this );
|
||||
mNullLabel->setReadOnly( true );
|
||||
mNullLabel->setStyleSheet( QStringLiteral( "position: absolute; border: none; font-style: italic; color: grey;" ) );
|
||||
mNullLabel->hide();
|
||||
|
@ -58,7 +58,7 @@ void QgsDefaultSearchWidgetWrapper::setExpression( QString exp )
|
||||
bool numeric = ( fldType == QVariant::Int || fldType == QVariant::Double || fldType == QVariant::LongLong );
|
||||
|
||||
QSettings settings;
|
||||
QString nullValue = settings.value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString();
|
||||
QString nullValue = QgsApplication::nullRepresentation();
|
||||
QString fieldName = layer()->fields().at( mFieldIdx ).name();
|
||||
QString str;
|
||||
if ( exp == nullValue )
|
||||
|
@ -41,7 +41,7 @@ QVariant QgsExternalResourceWidgetWrapper::value() const
|
||||
|
||||
if ( mLineEdit )
|
||||
{
|
||||
if ( mLineEdit->text().isEmpty() || mLineEdit->text() == QSettings().value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString() )
|
||||
if ( mLineEdit->text().isEmpty() || mLineEdit->text() == QgsApplication::nullRepresentation() )
|
||||
{
|
||||
return QVariant( field().type() );
|
||||
}
|
||||
@ -93,7 +93,7 @@ void QgsExternalResourceWidgetWrapper::initWidget( QWidget* editor )
|
||||
QgsFilterLineEdit* fle = qobject_cast<QgsFilterLineEdit*>( editor );
|
||||
if ( fle )
|
||||
{
|
||||
fle->setNullValue( QSettings().value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString() );
|
||||
fle->setNullValue( QgsApplication::nullRepresentation() );
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -151,7 +151,7 @@ void QgsExternalResourceWidgetWrapper::setValue( const QVariant& value )
|
||||
{
|
||||
if ( value.isNull() )
|
||||
{
|
||||
mLineEdit->setText( QSettings().value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString() );
|
||||
mLineEdit->setText( QgsApplication::nullRepresentation() );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -169,7 +169,7 @@ void QgsExternalResourceWidgetWrapper::setValue( const QVariant& value )
|
||||
{
|
||||
if ( value.isNull() )
|
||||
{
|
||||
mQgsWidget->setDocumentPath( QSettings().value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString() );
|
||||
mQgsWidget->setDocumentPath( QgsApplication::nullRepresentation() );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -36,7 +36,7 @@ QVariant QgsFileNameWidgetWrapper::value() const
|
||||
|
||||
if ( mLineEdit )
|
||||
{
|
||||
if ( mLineEdit->text() == QSettings().value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString() )
|
||||
if ( mLineEdit->text() == QgsApplication::nullRepresentation() )
|
||||
value = QVariant( field().type() );
|
||||
else
|
||||
value = mLineEdit->text();
|
||||
@ -103,7 +103,7 @@ void QgsFileNameWidgetWrapper::initWidget( QWidget* editor )
|
||||
QgsFilterLineEdit* fle = qobject_cast<QgsFilterLineEdit*>( editor );
|
||||
if ( fle )
|
||||
{
|
||||
fle->setNullValue( QSettings().value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString() );
|
||||
fle->setNullValue( QgsApplication::nullRepresentation() );
|
||||
}
|
||||
|
||||
connect( mLineEdit, SIGNAL( textChanged( QString ) ), this, SLOT( valueChanged( QString ) ) );
|
||||
@ -115,7 +115,7 @@ void QgsFileNameWidgetWrapper::setValue( const QVariant& value )
|
||||
if ( mLineEdit )
|
||||
{
|
||||
if ( value.isNull() )
|
||||
mLineEdit->setText( QSettings().value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString() );
|
||||
mLineEdit->setText( QgsApplication::nullRepresentation() );
|
||||
else
|
||||
mLineEdit->setText( value.toString() );
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ QVariant QgsPhotoWidgetWrapper::value() const
|
||||
|
||||
if ( mLineEdit )
|
||||
{
|
||||
if ( mLineEdit->text() == QSettings().value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString() )
|
||||
if ( mLineEdit->text() == QgsApplication::nullRepresentation() )
|
||||
v = QVariant( QVariant::String );
|
||||
else
|
||||
v = mLineEdit->text();
|
||||
@ -223,7 +223,7 @@ void QgsPhotoWidgetWrapper::initWidget( QWidget* editor )
|
||||
QgsFilterLineEdit *fle = qobject_cast<QgsFilterLineEdit*>( mLineEdit );
|
||||
if ( fle )
|
||||
{
|
||||
fle->setNullValue( QSettings().value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString() );
|
||||
fle->setNullValue( QgsApplication::nullRepresentation() );
|
||||
}
|
||||
|
||||
connect( mLineEdit, SIGNAL( textChanged( QString ) ), this, SLOT( valueChanged( QString ) ) );
|
||||
@ -246,7 +246,7 @@ void QgsPhotoWidgetWrapper::setValue( const QVariant& value )
|
||||
{
|
||||
if ( value.isNull() )
|
||||
{
|
||||
whileBlocking( mLineEdit )->setText( QSettings().value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString() );
|
||||
whileBlocking( mLineEdit )->setText( QgsApplication::nullRepresentation() );
|
||||
clearPicture();
|
||||
}
|
||||
else
|
||||
|
@ -116,7 +116,7 @@ void QgsRangeWidgetWrapper::initWidget( QWidget* editor )
|
||||
minval -= stepval;
|
||||
}
|
||||
mDoubleSpinBox->setValue( minval );
|
||||
mDoubleSpinBox->setSpecialValueText( QSettings().value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString() );
|
||||
mDoubleSpinBox->setSpecialValueText( QgsApplication::nullRepresentation() );
|
||||
}
|
||||
mDoubleSpinBox->setMinimum( min.isValid() ? min.toDouble() : std::numeric_limits<double>::min() );
|
||||
mDoubleSpinBox->setMaximum( max.isValid() ? max.toDouble() : std::numeric_limits<double>::max() );
|
||||
@ -137,7 +137,7 @@ void QgsRangeWidgetWrapper::initWidget( QWidget* editor )
|
||||
int stepval = step.toInt();
|
||||
minval -= stepval;
|
||||
mIntSpinBox->setValue( minval );
|
||||
mIntSpinBox->setSpecialValueText( QSettings().value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString() );
|
||||
mIntSpinBox->setSpecialValueText( QgsApplication::nullRepresentation() );
|
||||
}
|
||||
setupIntEditor( min, max, step, mIntSpinBox, this );
|
||||
if ( config( QStringLiteral( "Suffix" ) ).isValid() )
|
||||
|
@ -137,7 +137,7 @@ void QgsRelationReferenceSearchWidgetWrapper::onValueChanged( const QVariant& va
|
||||
else
|
||||
{
|
||||
QSettings settings;
|
||||
setExpression( value.isNull() ? settings.value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString() : value.toString() );
|
||||
setExpression( value.isNull() ? QgsApplication::nullRepresentation() : value.toString() );
|
||||
emit valueChanged();
|
||||
}
|
||||
emit expressionChanged( mExpression );
|
||||
@ -146,7 +146,7 @@ void QgsRelationReferenceSearchWidgetWrapper::onValueChanged( const QVariant& va
|
||||
void QgsRelationReferenceSearchWidgetWrapper::setExpression( QString exp )
|
||||
{
|
||||
QSettings settings;
|
||||
QString nullValue = settings.value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString();
|
||||
QString nullValue = QgsApplication::nullRepresentation();
|
||||
QString fieldName = layer()->fields().at( mFieldIdx ).name();
|
||||
|
||||
QString str;
|
||||
|
@ -302,7 +302,7 @@ void QgsRelationReferenceWidget::setForeignKey( const QVariant& value )
|
||||
|
||||
void QgsRelationReferenceWidget::deleteForeignKey()
|
||||
{
|
||||
QVariant nullValue = QSettings().value( QStringLiteral( "qgis/nullValue" ), "NULL" );
|
||||
QVariant nullValue = QgsApplication::nullRepresentation();
|
||||
if ( mReadOnlySelector )
|
||||
{
|
||||
QString nullText = QLatin1String( "" );
|
||||
@ -477,7 +477,7 @@ void QgsRelationReferenceWidget::init()
|
||||
mFilterComboBoxes << cb;
|
||||
mReferencedLayer->uniqueValues( idx, uniqueValues );
|
||||
cb->addItem( mReferencedLayer->attributeDisplayName( idx ) );
|
||||
QVariant nullValue = QSettings().value( QStringLiteral( "qgis/nullValue" ), "NULL" );
|
||||
QVariant nullValue = QgsApplication::nullRepresentation();
|
||||
cb->addItem( nullValue.toString(), QVariant( mReferencedLayer->fields().at( idx ).type() ) );
|
||||
|
||||
qSort( uniqueValues.begin(), uniqueValues.end(), qgsVariantLessThan );
|
||||
@ -496,7 +496,7 @@ void QgsRelationReferenceWidget::init()
|
||||
|
||||
if ( mChainFilters )
|
||||
{
|
||||
QVariant nullValue = QSettings().value( QStringLiteral( "qgis/nullValue" ), "NULL" );
|
||||
QVariant nullValue = QgsApplication::nullRepresentation();
|
||||
|
||||
QgsFeature ft;
|
||||
QgsFeatureIterator fit = layerCache->getFeatures();
|
||||
@ -552,7 +552,7 @@ void QgsRelationReferenceWidget::init()
|
||||
mComboBox->setCompleter( completer );
|
||||
|
||||
|
||||
QVariant nullValue = QSettings().value( QStringLiteral( "qgis/nullValue" ), "NULL" );
|
||||
QVariant nullValue = QgsApplication::nullRepresentation();
|
||||
|
||||
if ( mChainFilters && mFeature.isValid() )
|
||||
{
|
||||
@ -797,7 +797,7 @@ void QgsRelationReferenceWidget::mapToolDeactivated()
|
||||
|
||||
void QgsRelationReferenceWidget::filterChanged()
|
||||
{
|
||||
QVariant nullValue = QSettings().value( QStringLiteral( "qgis/nullValue" ), "NULL" );
|
||||
QVariant nullValue = QgsApplication::nullRepresentation();
|
||||
|
||||
QStringList filters;
|
||||
QgsAttributeList attrs;
|
||||
|
@ -56,7 +56,7 @@ QVariant QgsTextEditWrapper::value() const
|
||||
}
|
||||
|
||||
if (( v.isEmpty() && ( field().type() == QVariant::Int || field().type() == QVariant::Double || field().type() == QVariant::LongLong || field().type() == QVariant::Date ) ) ||
|
||||
v == QSettings().value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString() )
|
||||
v == QgsApplication::nullRepresentation() )
|
||||
return QVariant( field().type() );
|
||||
|
||||
if ( !defaultValue().isNull() && v == defaultValue().toString() )
|
||||
@ -119,7 +119,7 @@ void QgsTextEditWrapper::initWidget( QWidget* editor )
|
||||
QVariant defVal = defaultValue();
|
||||
if ( defVal.isNull() )
|
||||
{
|
||||
defVal = QSettings().value( QStringLiteral( "qgis/nullValue" ), "NULL" );
|
||||
defVal = QgsApplication::nullRepresentation();
|
||||
}
|
||||
|
||||
QgsFilterLineEdit *fle = qobject_cast<QgsFilterLineEdit*>( mLineEdit );
|
||||
@ -215,7 +215,7 @@ void QgsTextEditWrapper::setWidgetValue( const QVariant& val )
|
||||
if ( val.isNull() )
|
||||
{
|
||||
if ( !( field().type() == QVariant::Int || field().type() == QVariant::Double || field().type() == QVariant::LongLong || field().type() == QVariant::Date ) )
|
||||
v = QSettings().value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString();
|
||||
v = QgsApplication::nullRepresentation();
|
||||
}
|
||||
else
|
||||
v = val.toString();
|
||||
|
@ -37,7 +37,7 @@ QVariant QgsUniqueValuesWidgetWrapper::value() const
|
||||
|
||||
if ( mLineEdit )
|
||||
{
|
||||
if ( mLineEdit->text() == QSettings().value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString() )
|
||||
if ( mLineEdit->text() == QgsApplication::nullRepresentation() )
|
||||
value = QVariant( field().type() );
|
||||
else
|
||||
value = mLineEdit->text();
|
||||
@ -83,7 +83,7 @@ void QgsUniqueValuesWidgetWrapper::initWidget( QWidget* editor )
|
||||
QgsFilterLineEdit* fle = qobject_cast<QgsFilterLineEdit*>( editor );
|
||||
if ( fle && !( field().type() == QVariant::Int || field().type() == QVariant::Double || field().type() == QVariant::LongLong || field().type() == QVariant::Date ) )
|
||||
{
|
||||
fle->setNullValue( QSettings().value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString() );
|
||||
fle->setNullValue( QgsApplication::nullRepresentation() );
|
||||
}
|
||||
|
||||
QCompleter* c = new QCompleter( sValues );
|
||||
@ -127,7 +127,7 @@ void QgsUniqueValuesWidgetWrapper::setValue( const QVariant& value )
|
||||
if ( mLineEdit )
|
||||
{
|
||||
if ( value.isNull() )
|
||||
mLineEdit->setText( QSettings().value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString() );
|
||||
mLineEdit->setText( QgsApplication::nullRepresentation() );
|
||||
else
|
||||
mLineEdit->setText( value.toString() );
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include "qgsattributetypeloaddialog.h"
|
||||
#include "qgsvaluemapfieldformatter.h"
|
||||
#include "qgsapplication.h"
|
||||
|
||||
#include <QSettings>
|
||||
#include <QFileDialog>
|
||||
@ -52,7 +53,7 @@ QVariantMap QgsValueMapConfigDlg::config()
|
||||
continue;
|
||||
|
||||
QString ks = ki->text();
|
||||
if (( ks == settings.value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString() ) && !( ki->flags() & Qt::ItemIsEditable ) )
|
||||
if (( ks == QgsApplication::nullRepresentation() ) && !( ki->flags() & Qt::ItemIsEditable ) )
|
||||
ks = VALUEMAP_NULL_TEXT;
|
||||
|
||||
if ( !vi || vi->text().isNull() )
|
||||
@ -159,7 +160,7 @@ void QgsValueMapConfigDlg::setRow( int row, const QString& value, const QString&
|
||||
{
|
||||
QFont cellFont;
|
||||
cellFont.setItalic( true );
|
||||
valueCell = new QTableWidgetItem( settings.value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString() );
|
||||
valueCell = new QTableWidgetItem( QgsApplication::nullRepresentation() );
|
||||
valueCell->setFont( cellFont );
|
||||
valueCell->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
|
||||
descriptionCell->setFont( cellFont );
|
||||
@ -246,7 +247,7 @@ void QgsValueMapConfigDlg::loadFromCSVButtonPushed()
|
||||
val = val.mid( 1, val.length() - 2 );
|
||||
}
|
||||
|
||||
if ( key == settings.value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString() )
|
||||
if ( key == QgsApplication::nullRepresentation() )
|
||||
key = VALUEMAP_NULL_TEXT;
|
||||
|
||||
map[ key ] = val;
|
||||
|
@ -190,7 +190,7 @@ void QgsValueRelationSearchWidgetWrapper::onValueChanged()
|
||||
else
|
||||
{
|
||||
QSettings settings;
|
||||
setExpression( vl.isNull() ? settings.value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString() : vl.toString() );
|
||||
setExpression( vl.isNull() ? QgsApplication::nullRepresentation() : vl.toString() );
|
||||
emit valueChanged();
|
||||
}
|
||||
emit expressionChanged( mExpression );
|
||||
@ -199,7 +199,7 @@ void QgsValueRelationSearchWidgetWrapper::onValueChanged()
|
||||
void QgsValueRelationSearchWidgetWrapper::setExpression( QString exp )
|
||||
{
|
||||
QSettings settings;
|
||||
QString nullValue = settings.value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString();
|
||||
QString nullValue = QgsApplication::nullRepresentation();
|
||||
QString fieldName = layer()->fields().at( mFieldIdx ).name();
|
||||
|
||||
QString str;
|
||||
|
@ -48,7 +48,7 @@ QVariant QgsWebViewWidgetWrapper::value() const
|
||||
|
||||
if ( mLineEdit )
|
||||
{
|
||||
if ( mLineEdit->text() == QSettings().value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString() )
|
||||
if ( mLineEdit->text() == QgsApplication::nullRepresentation() )
|
||||
v = QVariant( QVariant::String );
|
||||
else
|
||||
v = mLineEdit->text();
|
||||
@ -101,7 +101,7 @@ void QgsWebViewWidgetWrapper::initWidget( QWidget* editor )
|
||||
QgsFilterLineEdit* fle = qobject_cast<QgsFilterLineEdit*>( mLineEdit );
|
||||
if ( fle )
|
||||
{
|
||||
fle->setNullValue( QSettings().value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString() );
|
||||
fle->setNullValue( QgsApplication::nullRepresentation() );
|
||||
}
|
||||
|
||||
container = qobject_cast<QWidget*>( mLineEdit->parent() );
|
||||
@ -151,7 +151,7 @@ void QgsWebViewWidgetWrapper::setValue( const QVariant& value )
|
||||
if ( mLineEdit )
|
||||
{
|
||||
if ( value.isNull() )
|
||||
mLineEdit->setText( QSettings().value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString() );
|
||||
mLineEdit->setText( QgsApplication::nullRepresentation() );
|
||||
else
|
||||
mLineEdit->setText( value.toString() );
|
||||
}
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "qgslogger.h"
|
||||
#include "qgslonglongvalidator.h"
|
||||
#include "qgsfields.h"
|
||||
#include "qgsapplication.h"
|
||||
|
||||
QgsFieldValidator::QgsFieldValidator( QObject *parent, const QgsField &field, const QString& defaultValue, const QString& dateFormat )
|
||||
: QValidator( parent )
|
||||
@ -84,7 +85,7 @@ QgsFieldValidator::QgsFieldValidator( QObject *parent, const QgsField &field, co
|
||||
}
|
||||
|
||||
QSettings settings;
|
||||
mNullValue = settings.value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString();
|
||||
mNullValue = QgsApplication::nullRepresentation();
|
||||
}
|
||||
|
||||
QgsFieldValidator::~QgsFieldValidator()
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "qgsfilterlineedit.h"
|
||||
#include "qgslogger.h"
|
||||
#include "qgsproject.h"
|
||||
#include "qgsapplication.h"
|
||||
|
||||
QgsFileWidget::QgsFileWidget( QWidget *parent )
|
||||
: QWidget( parent )
|
||||
@ -82,7 +83,7 @@ QString QgsFileWidget::filePath()
|
||||
|
||||
void QgsFileWidget::setFilePath( QString path )
|
||||
{
|
||||
if ( path == QSettings().value( QStringLiteral( "qgis/nullValue" ), "NULL" ) )
|
||||
if ( path == QgsApplication::nullRepresentation() )
|
||||
{
|
||||
path = QLatin1String( "" );
|
||||
}
|
||||
@ -286,7 +287,7 @@ QString QgsFileWidget::toUrl( const QString& path ) const
|
||||
QString rep;
|
||||
if ( path.isEmpty() )
|
||||
{
|
||||
return QSettings().value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString();
|
||||
return QgsApplication::nullRepresentation();
|
||||
}
|
||||
|
||||
QString urlStr = relativePath( path, false );
|
||||
|
@ -120,7 +120,7 @@ void QgsQueryBuilder::fillValues( int idx, int limit )
|
||||
mLayer->uniqueValues( idx, values, limit );
|
||||
|
||||
QSettings settings;
|
||||
QString nullValue = settings.value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString();
|
||||
QString nullValue = QgsApplication::nullRepresentation();
|
||||
|
||||
QgsDebugMsg( QString( "nullValue: %1" ).arg( nullValue ) );
|
||||
|
||||
|
@ -15,6 +15,7 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_SOURCE_DIR}/src/core/layertree
|
||||
${CMAKE_SOURCE_DIR}/src/core/raster
|
||||
${CMAKE_SOURCE_DIR}/src/core/symbology-ng
|
||||
${CMAKE_SOURCE_DIR}/src/test
|
||||
)
|
||||
INCLUDE_DIRECTORIES(SYSTEM
|
||||
${QT_INCLUDE_DIR}
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include <QSharedPointer>
|
||||
|
||||
#include "qgsfield.h"
|
||||
#include "qgsapplication.h"
|
||||
#include "qgstest.h"
|
||||
|
||||
class TestQgsField: public QObject
|
||||
{
|
||||
@ -299,8 +301,7 @@ void TestQgsField::displayString()
|
||||
QCOMPARE( stringField.displayString( test ), test );
|
||||
|
||||
//test NULL
|
||||
QSettings s;
|
||||
s.setValue( QStringLiteral( "qgis/nullValue" ), "TEST NULL" );
|
||||
QgsApplication::setNullRepresentation( "TEST NULL" );
|
||||
QVariant nullString = QVariant( QVariant::String );
|
||||
QCOMPARE( stringField.displayString( nullString ), QString( "TEST NULL" ) );
|
||||
|
||||
@ -513,5 +514,5 @@ void TestQgsField::collection()
|
||||
QVERIFY( !field.convertCompatible( str ) );
|
||||
}
|
||||
|
||||
QTEST_MAIN( TestQgsField )
|
||||
QGSTEST_MAIN( TestQgsField )
|
||||
#include "testqgsfield.moc"
|
||||
|
Loading…
x
Reference in New Issue
Block a user