Skip to content

Commit

Permalink
fix #1184
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8917 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Jul 26, 2008
1 parent 307448f commit e86fe1c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 59 deletions.
73 changes: 17 additions & 56 deletions src/app/qgssinglesymboldialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,17 @@ QgsSingleSymbolDialog::QgsSingleSymbolDialog(QgsVectorLayer * layer, bool disabl
const QgsFieldMap & fields = provider->fields();
QString str;

mRotationClassificationComboBox->addItem(DO_NOT_USE_STR);
mScaleClassificationComboBox->addItem(DO_NOT_USE_STR);
mFieldMap.insert(std::make_pair(DO_NOT_USE_STR, -1));
mRotationClassificationComboBox->addItem(DO_NOT_USE_STR, -1);
mScaleClassificationComboBox->addItem(DO_NOT_USE_STR, -1);
for (QgsFieldMap::const_iterator it = fields.begin();
it != fields.end();
++it)
{
QVariant::Type type = (*it).type();
if (type == QVariant::Int || type == QVariant::Double)
{
mRotationClassificationComboBox->addItem(it->name());
mScaleClassificationComboBox->addItem(it->name());
mFieldMap.insert(std::make_pair(it->name(), it.key()));
mRotationClassificationComboBox->addItem(it->name(), it.key());
mScaleClassificationComboBox->addItem(it->name(), it.key());
}
}
}
Expand Down Expand Up @@ -274,23 +272,12 @@ void QgsSingleSymbolDialog::apply( QgsSymbol *sy )
std::map<QString,int>::iterator iter;
if( mRotationClassificationComboBox->isEnabled() )
{
sy->setRotationClassificationField(-1);

iter=mFieldMap.find(mRotationClassificationComboBox->currentText());
if(iter!=mFieldMap.end())
{
sy->setRotationClassificationField(iter->second);
}
sy->setRotationClassificationField( mRotationClassificationComboBox->itemData( mRotationClassificationComboBox->currentIndex() ).toInt() );
}

if( mScaleClassificationComboBox->isEnabled() )
{
sy->setScaleClassificationField(-1);
iter = mFieldMap.find(mScaleClassificationComboBox->currentText());
if(iter!=mFieldMap.end())
{
sy->setScaleClassificationField(iter->second);
}
sy->setScaleClassificationField( mScaleClassificationComboBox->itemData( mScaleClassificationComboBox->currentIndex() ).toInt() );
}

//
Expand Down Expand Up @@ -368,25 +355,13 @@ void QgsSingleSymbolDialog::set ( const QgsSymbol *sy )
}
mPointSizeSpinBox->setValue ( sy->pointSize() );

QString rotationclassfield = DO_NOT_USE_STR;
QString scaleclassfield = DO_NOT_USE_STR;
for(std::map<QString,int>::iterator it=mFieldMap.begin();it!=mFieldMap.end();++it)
{
if(it->second == sy->rotationClassificationField())
{
rotationclassfield=it->first;
QgsDebugMsg(QString("Found rotation field " + rotationclassfield));
}
if(it->second == sy->scaleClassificationField())
{
scaleclassfield=it->first;
QgsDebugMsg(QString("Found scale field " + scaleclassfield));
}
}
mRotationClassificationComboBox->setItemText(
mRotationClassificationComboBox->currentIndex(), rotationclassfield);
mScaleClassificationComboBox->setItemText(
mScaleClassificationComboBox->currentIndex(), scaleclassfield);
int index;

index = mRotationClassificationComboBox->findData( sy->rotationClassificationField() );
mRotationClassificationComboBox->setCurrentIndex( index<0 ? 0 : index);

index = mScaleClassificationComboBox->findData( sy->scaleClassificationField() );
mScaleClassificationComboBox->setCurrentIndex( index<0 ? 0 : index);

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

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

QString rotationclassfield = DO_NOT_USE_STR;
QString scaleclassfield = DO_NOT_USE_STR;
for(std::map<QString,int>::iterator it=mFieldMap.begin();it!=mFieldMap.end();++it)
{
if(it->second == sy->rotationClassificationField())
{
rotationclassfield=it->first;
QgsDebugMsg(QString("Found rotation field " + rotationclassfield));
}
if(it->second == sy->scaleClassificationField())
{
scaleclassfield=it->first;
QgsDebugMsg(QString("Found scale field " + scaleclassfield));
}
}

if( mRotationClassificationComboBox->isEnabled() && mRotationClassificationComboBox->currentText()!=rotationclassfield )
if( mRotationClassificationComboBox->isEnabled() &&
mRotationClassificationComboBox->itemData( mRotationClassificationComboBox->currentIndex() ).toInt() != sy->rotationClassificationField() )
mRotationClassificationComboBox->setEnabled(false);

if( mScaleClassificationComboBox->isEnabled() && mScaleClassificationComboBox->currentText()!=scaleclassfield )
if( mScaleClassificationComboBox->isEnabled() &&
mScaleClassificationComboBox->itemData( mScaleClassificationComboBox->currentIndex() ).toInt() != sy->scaleClassificationField() )
mScaleClassificationComboBox->setEnabled(false);

if( outlinewidthspinbox->isEnabled() && outlinewidthspinbox->value() != sy->pen().widthF() )
Expand Down
3 changes: 0 additions & 3 deletions src/app/qgssinglesymboldialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ class QgsSingleSymbolDialog: public QDialog, private Ui::QgsSingleSymbolDialogBa

protected:
QgsVectorLayer* mVectorLayer;
/**Stores the names and numbers of the fields with numeric values*/
std::map<QString,int> mFieldMap;
int mAngleClassificationField;

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

0 comments on commit e86fe1c

Please sign in to comment.