Skip to content

Commit 88aa50f

Browse files
author
jef
committedMay 26, 2008
update list widget colors on reset/randomize colors
git-svn-id: http://svn.osgeo.org/qgis/trunk@8525 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 1b89618 commit 88aa50f

File tree

1 file changed

+27
-32
lines changed

1 file changed

+27
-32
lines changed
 

‎src/app/qgsuniquevaluedialog.cpp

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -215,30 +215,27 @@ void QgsUniqueValueDialog::addClass(QString value)
215215
mClassListWidget->addItem(item);
216216

217217
setSymbolColor(symbol, randomColor() );
218+
updateEntryIcon(symbol, item);
218219
}
219220

220221
void QgsUniqueValueDialog::randomizeColors()
221222
{
222223
QList<QListWidgetItem *> selection = mClassListWidget->selectedItems();
223-
if(selection.size()>0) {
224-
for(int i=0; i<selection.size(); i++)
225-
{
226-
QListWidgetItem *item=selection[i];
227-
if(!item)
228-
continue;
229-
230-
if( !mValues.contains( item->text() ) )
231-
continue;
224+
if(selection.size()==0)
225+
selection = mClassListWidget->findItems("", Qt::MatchContains);
232226

233-
setSymbolColor( mValues[ item->text() ], randomColor() );
234-
}
235-
}
236-
else
227+
for(int i=0; i<selection.size(); i++)
237228
{
238-
for(QMap<QString, QgsSymbol *>::iterator it = mValues.begin(); it!=mValues.end(); it++)
239-
{
240-
setSymbolColor( it.value(), randomColor() );
241-
}
229+
QListWidgetItem *item=selection[i];
230+
if(!item)
231+
continue;
232+
233+
if( !mValues.contains( item->text() ) )
234+
continue;
235+
236+
QgsSymbol *symbol = mValues[ item->text() ];
237+
setSymbolColor( symbol, randomColor() );
238+
updateEntryIcon(symbol, item);
242239
}
243240

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

252249
QList<QListWidgetItem *> selection = mClassListWidget->selectedItems();
253-
if(selection.size()>0) {
254-
for(int i=0; i<selection.size(); i++)
255-
{
256-
QListWidgetItem *item=selection[i];
257-
if( !item ) continue;
258-
259-
if( !mValues.contains( item->text() ) )continue;
250+
if(selection.size()==0)
251+
selection = mClassListWidget->findItems("", Qt::MatchContains);
260252

261-
setSymbolColor( mValues[ item->text() ], white);
262-
}
263-
}
264-
else
253+
for(int i=0; i<selection.size(); i++)
265254
{
266-
for(QMap<QString, QgsSymbol *>::iterator it = mValues.begin(); it!=mValues.end(); it++)
267-
{
268-
setSymbolColor( it.value(), white);
269-
}
255+
QListWidgetItem *item=selection[i];
256+
if( !item )
257+
continue;
258+
259+
if( !mValues.contains( item->text() ) )
260+
continue;
261+
262+
QgsSymbol *symbol = mValues[ item->text() ];
263+
setSymbolColor( symbol, white);
264+
updateEntryIcon(symbol, item);
270265
}
271266

272267
selectionChanged();

0 commit comments

Comments
 (0)
Please sign in to comment.