@@ -215,30 +215,27 @@ void QgsUniqueValueDialog::addClass(QString value)
215
215
mClassListWidget ->addItem (item);
216
216
217
217
setSymbolColor (symbol, randomColor () );
218
+ updateEntryIcon (symbol, item);
218
219
}
219
220
220
221
void QgsUniqueValueDialog::randomizeColors ()
221
222
{
222
223
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);
232
226
233
- setSymbolColor ( mValues [ item->text () ], randomColor () );
234
- }
235
- }
236
- else
227
+ for (int i=0 ; i<selection.size (); i++)
237
228
{
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);
242
239
}
243
240
244
241
selectionChanged ();
@@ -250,23 +247,21 @@ void QgsUniqueValueDialog::resetColors()
250
247
white.setRgb (255.0 , 255.0 , 255.0 );
251
248
252
249
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);
260
252
261
- setSymbolColor ( mValues [ item->text () ], white);
262
- }
263
- }
264
- else
253
+ for (int i=0 ; i<selection.size (); i++)
265
254
{
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);
270
265
}
271
266
272
267
selectionChanged ();
0 commit comments