Skip to content
Permalink
Browse files

[FEATURE] add default class to unique value renderer (fixes #1750)

- unique value enull" now default class (ie. class for values without a defined class)
- "add class" and "classify" now add the default class



git-svn-id: http://svn.osgeo.org/qgis/trunk@10986 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Jun 27, 2009
1 parent 394a987 commit 29450dcd7e516e66c0025490ffbcd2a462fe8946
@@ -200,15 +200,15 @@ void QgsUniqueValueDialog::setSymbolColor( QgsSymbol *symbol, QColor thecolor )
void QgsUniqueValueDialog::addClass( QString value )
{
QgsDebugMsg( "called." );
if ( value.isNull() || mValues.contains( value ) )
if ( mValues.contains( value ) )
{
int i;
for ( i = 0; mValues.contains( value + QString::number( i ) ); i++ )
;
value += QString::number( i );
}

QgsSymbol *symbol = new QgsSymbol( mVectorLayer->geometryType(), value );
QgsSymbol *symbol = new QgsSymbol( mVectorLayer->geometryType(), value, value, value.isNull() ? tr( "default" ) : "" );
mValues.insert( value, symbol );

QListWidgetItem *item = new QListWidgetItem( value );
@@ -306,6 +306,9 @@ void QgsUniqueValueDialog::changeClassificationAttribute()
if ( !mValues.contains( values[i].toString() ) )
addClass( values[i].toString() );
}

if ( !mValues.contains( QString::null ) )
addClass( QString::null );
}
}

@@ -183,6 +183,11 @@ QgsSymbol *QgsUniqueValueRenderer::symbolForFeature( const QgsFeature *f )
QString value = attrs[mClassificationField].toString();

QMap<QString, QgsSymbol*>::iterator it = mSymbols.find( value );
if ( it == mSymbols.end() )
{
it = mSymbols.find( QString::null );
}

if ( it == mSymbols.end() )
{
return 0;
@@ -445,6 +445,10 @@ void QgsSymbol::appendText( QDomElement &symbol, QDomDocument &document, QString
{
QDomElement node = document.createElement( name );
QDomText txt = document.createTextNode( value );
if ( value.isNull() )
{
node.setAttribute( "null", "1" );
}
symbol.appendChild( node );
node.appendChild( txt );
}
@@ -542,7 +546,14 @@ bool QgsSymbol::readXML( QDomNode &synode, const QgsVectorLayer *vl )
if ( ! lvalnode.isNull() )
{
QDomElement lvalelement = lvalnode.toElement();
mLowerValue = lvalelement.text();
if ( lvalelement.attribute( "null" ).toInt() == 1 )
{
mLowerValue = QString::null;
}
else
{
mLowerValue = lvalelement.text();
}
}

QDomNode uvalnode = synode.namedItem( "uppervalue" );

0 comments on commit 29450dc

Please sign in to comment.
You can’t perform that action at this time.