Skip to content

Commit

Permalink
update list widget colors on reset/randomize colors
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8525 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed May 26, 2008
1 parent aee2f8f commit f2c4b2a
Showing 1 changed file with 27 additions and 32 deletions.
59 changes: 27 additions & 32 deletions src/app/qgsuniquevaluedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,30 +215,27 @@ void QgsUniqueValueDialog::addClass(QString value)
mClassListWidget->addItem(item);

setSymbolColor(symbol, randomColor() );
updateEntryIcon(symbol, item);
}

void QgsUniqueValueDialog::randomizeColors()
{
QList<QListWidgetItem *> selection = mClassListWidget->selectedItems();
if(selection.size()>0) {
for(int i=0; i<selection.size(); i++)
{
QListWidgetItem *item=selection[i];
if(!item)
continue;

if( !mValues.contains( item->text() ) )
continue;
if(selection.size()==0)
selection = mClassListWidget->findItems("", Qt::MatchContains);

setSymbolColor( mValues[ item->text() ], randomColor() );
}
}
else
for(int i=0; i<selection.size(); i++)
{
for(QMap<QString, QgsSymbol *>::iterator it = mValues.begin(); it!=mValues.end(); it++)
{
setSymbolColor( it.value(), randomColor() );
}
QListWidgetItem *item=selection[i];
if(!item)
continue;

if( !mValues.contains( item->text() ) )
continue;

QgsSymbol *symbol = mValues[ item->text() ];
setSymbolColor( symbol, randomColor() );
updateEntryIcon(symbol, item);
}

selectionChanged();
Expand All @@ -250,23 +247,21 @@ void QgsUniqueValueDialog::resetColors()
white.setRgb(255.0, 255.0, 255.0);

QList<QListWidgetItem *> selection = mClassListWidget->selectedItems();
if(selection.size()>0) {
for(int i=0; i<selection.size(); i++)
{
QListWidgetItem *item=selection[i];
if( !item ) continue;

if( !mValues.contains( item->text() ) )continue;
if(selection.size()==0)
selection = mClassListWidget->findItems("", Qt::MatchContains);

setSymbolColor( mValues[ item->text() ], white);
}
}
else
for(int i=0; i<selection.size(); i++)
{
for(QMap<QString, QgsSymbol *>::iterator it = mValues.begin(); it!=mValues.end(); it++)
{
setSymbolColor( it.value(), white);
}
QListWidgetItem *item=selection[i];
if( !item )
continue;

if( !mValues.contains( item->text() ) )
continue;

QgsSymbol *symbol = mValues[ item->text() ];
setSymbolColor( symbol, white);
updateEntryIcon(symbol, item);
}

selectionChanged();
Expand Down

0 comments on commit f2c4b2a

Please sign in to comment.