@@ -94,19 +94,17 @@ QgsSingleSymbolDialog::QgsSingleSymbolDialog(QgsVectorLayer * layer, bool disabl
94
94
const QgsFieldMap & fields = provider->fields ();
95
95
QString str;
96
96
97
- mRotationClassificationComboBox ->addItem (DO_NOT_USE_STR);
98
- mScaleClassificationComboBox ->addItem (DO_NOT_USE_STR);
99
- mFieldMap .insert (std::make_pair (DO_NOT_USE_STR, -1 ));
97
+ mRotationClassificationComboBox ->addItem (DO_NOT_USE_STR, -1 );
98
+ mScaleClassificationComboBox ->addItem (DO_NOT_USE_STR, -1 );
100
99
for (QgsFieldMap::const_iterator it = fields.begin ();
101
100
it != fields.end ();
102
101
++it)
103
102
{
104
103
QVariant::Type type = (*it).type ();
105
104
if (type == QVariant::Int || type == QVariant::Double)
106
105
{
107
- mRotationClassificationComboBox ->addItem (it->name ());
108
- mScaleClassificationComboBox ->addItem (it->name ());
109
- mFieldMap .insert (std::make_pair (it->name (), it.key ()));
106
+ mRotationClassificationComboBox ->addItem (it->name (), it.key ());
107
+ mScaleClassificationComboBox ->addItem (it->name (), it.key ());
110
108
}
111
109
}
112
110
}
@@ -274,23 +272,12 @@ void QgsSingleSymbolDialog::apply( QgsSymbol *sy )
274
272
std::map<QString,int >::iterator iter;
275
273
if ( mRotationClassificationComboBox ->isEnabled () )
276
274
{
277
- sy->setRotationClassificationField (-1 );
278
-
279
- iter=mFieldMap .find (mRotationClassificationComboBox ->currentText ());
280
- if (iter!=mFieldMap .end ())
281
- {
282
- sy->setRotationClassificationField (iter->second );
283
- }
275
+ sy->setRotationClassificationField ( mRotationClassificationComboBox ->itemData ( mRotationClassificationComboBox ->currentIndex () ).toInt () );
284
276
}
285
277
286
278
if ( mScaleClassificationComboBox ->isEnabled () )
287
279
{
288
- sy->setScaleClassificationField (-1 );
289
- iter = mFieldMap .find (mScaleClassificationComboBox ->currentText ());
290
- if (iter!=mFieldMap .end ())
291
- {
292
- sy->setScaleClassificationField (iter->second );
293
- }
280
+ sy->setScaleClassificationField ( mScaleClassificationComboBox ->itemData ( mScaleClassificationComboBox ->currentIndex () ).toInt () );
294
281
}
295
282
296
283
//
@@ -368,25 +355,13 @@ void QgsSingleSymbolDialog::set ( const QgsSymbol *sy )
368
355
}
369
356
mPointSizeSpinBox ->setValue ( sy->pointSize () );
370
357
371
- QString rotationclassfield = DO_NOT_USE_STR;
372
- QString scaleclassfield = DO_NOT_USE_STR;
373
- for (std::map<QString,int >::iterator it=mFieldMap .begin ();it!=mFieldMap .end ();++it)
374
- {
375
- if (it->second == sy->rotationClassificationField ())
376
- {
377
- rotationclassfield=it->first ;
378
- QgsDebugMsg (QString (" Found rotation field " + rotationclassfield));
379
- }
380
- if (it->second == sy->scaleClassificationField ())
381
- {
382
- scaleclassfield=it->first ;
383
- QgsDebugMsg (QString (" Found scale field " + scaleclassfield));
384
- }
385
- }
386
- mRotationClassificationComboBox ->setItemText (
387
- mRotationClassificationComboBox ->currentIndex (), rotationclassfield);
388
- mScaleClassificationComboBox ->setItemText (
389
- mScaleClassificationComboBox ->currentIndex (), scaleclassfield);
358
+ int index;
359
+
360
+ index = mRotationClassificationComboBox ->findData ( sy->rotationClassificationField () );
361
+ mRotationClassificationComboBox ->setCurrentIndex ( index<0 ? 0 : index);
362
+
363
+ index = mScaleClassificationComboBox ->findData ( sy->scaleClassificationField () );
364
+ mScaleClassificationComboBox ->setCurrentIndex ( index<0 ? 0 : index);
390
365
391
366
outlinewidthspinbox->setValue (sy->pen ().widthF ());
392
367
@@ -471,26 +446,12 @@ void QgsSingleSymbolDialog::updateSet( const QgsSymbol *sy )
471
446
if ( mPointSizeSpinBox ->isEnabled () && mPointSizeSpinBox ->value ()!=sy->pointSize () )
472
447
mPointSizeSpinBox ->setEnabled (false );
473
448
474
- QString rotationclassfield = DO_NOT_USE_STR;
475
- QString scaleclassfield = DO_NOT_USE_STR;
476
- for (std::map<QString,int >::iterator it=mFieldMap .begin ();it!=mFieldMap .end ();++it)
477
- {
478
- if (it->second == sy->rotationClassificationField ())
479
- {
480
- rotationclassfield=it->first ;
481
- QgsDebugMsg (QString (" Found rotation field " + rotationclassfield));
482
- }
483
- if (it->second == sy->scaleClassificationField ())
484
- {
485
- scaleclassfield=it->first ;
486
- QgsDebugMsg (QString (" Found scale field " + scaleclassfield));
487
- }
488
- }
489
-
490
- if ( mRotationClassificationComboBox ->isEnabled () && mRotationClassificationComboBox ->currentText ()!=rotationclassfield )
449
+ if ( mRotationClassificationComboBox ->isEnabled () &&
450
+ mRotationClassificationComboBox ->itemData ( mRotationClassificationComboBox ->currentIndex () ).toInt () != sy->rotationClassificationField () )
491
451
mRotationClassificationComboBox ->setEnabled (false );
492
452
493
- if ( mScaleClassificationComboBox ->isEnabled () && mScaleClassificationComboBox ->currentText ()!=scaleclassfield )
453
+ if ( mScaleClassificationComboBox ->isEnabled () &&
454
+ mScaleClassificationComboBox ->itemData ( mScaleClassificationComboBox ->currentIndex () ).toInt () != sy->scaleClassificationField () )
494
455
mScaleClassificationComboBox ->setEnabled (false );
495
456
496
457
if ( outlinewidthspinbox->isEnabled () && outlinewidthspinbox->value () != sy->pen ().widthF () )
0 commit comments