Skip to content

Commit 7cc88b1

Browse files
author
jef
committed
fix #1184
git-svn-id: http://svn.osgeo.org/qgis/trunk@8917 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent fa212af commit 7cc88b1

File tree

2 files changed

+17
-59
lines changed

2 files changed

+17
-59
lines changed

src/app/qgssinglesymboldialog.cpp

Lines changed: 17 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,17 @@ QgsSingleSymbolDialog::QgsSingleSymbolDialog(QgsVectorLayer * layer, bool disabl
9494
const QgsFieldMap & fields = provider->fields();
9595
QString str;
9696

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);
10099
for (QgsFieldMap::const_iterator it = fields.begin();
101100
it != fields.end();
102101
++it)
103102
{
104103
QVariant::Type type = (*it).type();
105104
if (type == QVariant::Int || type == QVariant::Double)
106105
{
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());
110108
}
111109
}
112110
}
@@ -274,23 +272,12 @@ void QgsSingleSymbolDialog::apply( QgsSymbol *sy )
274272
std::map<QString,int>::iterator iter;
275273
if( mRotationClassificationComboBox->isEnabled() )
276274
{
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() );
284276
}
285277

286278
if( mScaleClassificationComboBox->isEnabled() )
287279
{
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() );
294281
}
295282

296283
//
@@ -368,25 +355,13 @@ void QgsSingleSymbolDialog::set ( const QgsSymbol *sy )
368355
}
369356
mPointSizeSpinBox->setValue ( sy->pointSize() );
370357

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);
390365

391366
outlinewidthspinbox->setValue(sy->pen().widthF());
392367

@@ -471,26 +446,12 @@ void QgsSingleSymbolDialog::updateSet( const QgsSymbol *sy )
471446
if( mPointSizeSpinBox->isEnabled() && mPointSizeSpinBox->value()!=sy->pointSize() )
472447
mPointSizeSpinBox->setEnabled(false);
473448

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() )
491451
mRotationClassificationComboBox->setEnabled(false);
492452

493-
if( mScaleClassificationComboBox->isEnabled() && mScaleClassificationComboBox->currentText()!=scaleclassfield )
453+
if( mScaleClassificationComboBox->isEnabled() &&
454+
mScaleClassificationComboBox->itemData( mScaleClassificationComboBox->currentIndex() ).toInt() != sy->scaleClassificationField() )
494455
mScaleClassificationComboBox->setEnabled(false);
495456

496457
if( outlinewidthspinbox->isEnabled() && outlinewidthspinbox->value() != sy->pen().widthF() )

src/app/qgssinglesymboldialog.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ class QgsSingleSymbolDialog: public QDialog, private Ui::QgsSingleSymbolDialogBa
4848

4949
protected:
5050
QgsVectorLayer* mVectorLayer;
51-
/**Stores the names and numbers of the fields with numeric values*/
52-
std::map<QString,int> mFieldMap;
53-
int mAngleClassificationField;
5451

5552
public slots:
5653
/* arrange the widgets on this dialog to reflect the current state of QgsSymbol */

0 commit comments

Comments
 (0)