@@ -47,11 +47,14 @@ QgsRendererV2PropertiesDialog::QgsRendererV2PropertiesDialog(QgsVectorLayer* lay
47
47
labels << " Value" << " Label" ;
48
48
m->setHorizontalHeaderLabels (labels);
49
49
viewCategories->setModel (m);
50
-
50
+
51
+ mCategorizedSymbol = createDefaultSymbol ();
52
+
51
53
connect (cboCategorizedColumn, SIGNAL (currentIndexChanged (int )), this , SLOT (categoryColumnChanged ()));
52
54
53
55
connect (viewCategories, SIGNAL (doubleClicked (const QModelIndex &)), this , SLOT (categoriesDoubleClicked (const QModelIndex &)));
54
56
57
+ connect (btnChangeCategorizedSymbol, SIGNAL (clicked ()), this , SLOT (changeCategorizedSymbol ()));
55
58
connect (btnAddCategories, SIGNAL (clicked ()), this , SLOT (addCategories ()));
56
59
connect (btnDeleteCategory, SIGNAL (clicked ()), this , SLOT (deleteCategory ()));
57
60
connect (btnDeleteAllCategories, SIGNAL (clicked ()), this , SLOT (deleteAllCategories ()));
@@ -144,7 +147,8 @@ void QgsRendererV2PropertiesDialog::updateUiFromRenderer()
144
147
radCategorized->setChecked (true );
145
148
146
149
stackedWidget->setCurrentWidget (pageCategorized);
147
-
150
+ updateCategorizedSymbolIcon ();
151
+
148
152
{
149
153
int idx = rendererCategorized ()->attributeIndex ();
150
154
cboCategorizedColumn->setCurrentIndex (idx >= 0 ? idx : 0 );
@@ -201,6 +205,21 @@ QgsSymbolV2* QgsRendererV2PropertiesDialog::createDefaultSymbol()
201
205
}
202
206
}
203
207
208
+ void QgsRendererV2PropertiesDialog::changeCategorizedSymbol ()
209
+ {
210
+ QgsSymbolV2SelectorDialog dlg (mCategorizedSymbol , mStyle , this );
211
+ if (!dlg.exec ())
212
+ return ;
213
+
214
+ updateCategorizedSymbolIcon ();
215
+ }
216
+
217
+ void QgsRendererV2PropertiesDialog::updateCategorizedSymbolIcon ()
218
+ {
219
+ QIcon icon = QgsSymbolLayerV2Utils::symbolPreviewIcon (mCategorizedSymbol , btnChangeCategorizedSymbol->iconSize ());
220
+ btnChangeCategorizedSymbol->setIcon (icon);
221
+ }
222
+
204
223
void QgsRendererV2PropertiesDialog::populateCategories ()
205
224
{
206
225
QStandardItemModel* m = qobject_cast<QStandardItemModel*>(viewCategories->model ());
@@ -310,16 +329,10 @@ void QgsRendererV2PropertiesDialog::addCategories()
310
329
// if (!dlg.exec())
311
330
// return;
312
331
313
- QgsSymbolV2* newSymbol = createDefaultSymbol ();
314
- QgsSymbolV2SelectorDialog dlg (newSymbol, mStyle , this );
315
- if (!dlg.exec ())
316
- {
317
- delete newSymbol;
318
- return ;
319
- }
332
+ QgsVectorColorRampV2* ramp = mStyle ->colorRamp ( cboCategorizedColorRamp->currentText () );
320
333
321
334
QgsCategoryList cats;
322
- ::createCategories (cats, unique_vals, newSymbol, new QgsVectorGradientColorRampV2()); // dlg.activeRamp() );
335
+ ::createCategories (cats, unique_vals, mCategorizedSymbol , ramp );
323
336
324
337
// TODO: if not all categories are desired, delete some!
325
338
/*
@@ -393,11 +406,15 @@ void QgsRendererV2PropertiesDialog::populateColorRamps()
393
406
{
394
407
QSize rampIconSize (50 ,16 );
395
408
cboGraduatedColorRamp->setIconSize (rampIconSize);
409
+ cboCategorizedColorRamp->setIconSize (rampIconSize);
410
+
396
411
QStringList rampNames = mStyle ->colorRampNames ();
397
412
for (QStringList::iterator it = rampNames.begin (); it != rampNames.end (); ++it)
398
413
{
399
414
QgsVectorColorRampV2* ramp = mStyle ->colorRamp (*it);
400
- cboGraduatedColorRamp->addItem ( QgsSymbolLayerV2Utils::colorRampPreviewIcon (ramp, rampIconSize), *it);
415
+ QIcon icon = QgsSymbolLayerV2Utils::colorRampPreviewIcon (ramp, rampIconSize);
416
+ cboGraduatedColorRamp->addItem (icon, *it);
417
+ cboCategorizedColorRamp->addItem (icon, *it);
401
418
delete ramp;
402
419
}
403
420
}
0 commit comments