|
19 | 19 | #include <QMessageBox>
|
20 | 20 | #include <QRegExp>
|
21 | 21 | #include <QPushButton>
|
| 22 | +#include <QSettings> |
22 | 23 | #include "qgsvectorlayer.h"
|
23 | 24 | #include "qgsvectordataprovider.h"
|
24 | 25 |
|
@@ -100,12 +101,18 @@ void QgsQueryBuilder::fillValues( int idx, int limit )
|
100 | 101 | QList<QVariant> values;
|
101 | 102 | mLayer->uniqueValues( idx, values, limit );
|
102 | 103 |
|
| 104 | + QSettings settings; |
| 105 | + QString nullValue = settings.value( "qgis/nullValue", "NULL" ).toString(); |
| 106 | + |
| 107 | + QgsDebugMsg( QString( "nullValue: %1" ).arg( nullValue ) ); |
| 108 | + |
103 | 109 | for ( int i = 0; i < values.size(); i++ )
|
104 | 110 | {
|
105 |
| - QStandardItem *myItem = new QStandardItem( values[i].toString() ); |
| 111 | + QStandardItem *myItem = new QStandardItem( values[i].isNull() ? nullValue : values[i].toString() ); |
106 | 112 | myItem->setEditable( false );
|
107 |
| - myItem->setData( values[i] ); |
| 113 | + myItem->setData( values[i], Qt::UserRole + 1 ); |
108 | 114 | mModelValues->insertRow( mModelValues->rowCount(), myItem );
|
| 115 | + QgsDebugMsg( QString( "Value is null: %1\nvalue: %2" ).arg( values[i].isNull() ).arg( values[i].isNull() ? nullValue : values[i].toString() ) ); |
109 | 116 | }
|
110 | 117 | }
|
111 | 118 |
|
@@ -269,9 +276,9 @@ void QgsQueryBuilder::on_lstFields_doubleClicked( const QModelIndex &index )
|
269 | 276 | void QgsQueryBuilder::on_lstValues_doubleClicked( const QModelIndex &index )
|
270 | 277 | {
|
271 | 278 | QVariant value = mModelValues->data( index, Qt::UserRole + 1 );
|
272 |
| - if( value.isNull() ) |
| 279 | + if ( value.isNull() ) |
273 | 280 | txtSQL->insertPlainText( "NULL" );
|
274 |
| - else if( value.type() == QVariant::Int || value.type() == QVariant::Double || value.type() == QVariant::LongLong ) |
| 281 | + else if ( value.type() == QVariant::Int || value.type() == QVariant::Double || value.type() == QVariant::LongLong ) |
275 | 282 | txtSQL->insertPlainText( value.toString() );
|
276 | 283 | else
|
277 | 284 | txtSQL->insertPlainText( "'" + value.toString() + "'" );
|
|
0 commit comments