Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[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/qgis@10986 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Jun 27, 2009
1 parent 4371548 commit e7ca3ff
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/app/qgsuniquevaluedialog.cpp
Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/core/renderer/qgsuniquevaluerenderer.cpp
Expand Up @@ -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;
Expand Down
13 changes: 12 additions & 1 deletion src/core/symbology/qgssymbol.cpp
Expand Up @@ -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 );
}
Expand Down Expand Up @@ -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" );
Expand Down

0 comments on commit e7ca3ff

Please sign in to comment.