Skip to content

Commit

Permalink
fix #1666
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@10708 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed May 2, 2009
1 parent 80b71a9 commit 782e267
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 49 deletions.
54 changes: 8 additions & 46 deletions src/app/qgscontinuouscolordialog.cpp
Expand Up @@ -39,53 +39,24 @@ QgsContinuousColorDialog::QgsContinuousColorDialog( QgsVectorLayer * layer )
QObject::connect( btnMaxValue, SIGNAL( clicked() ), this, SLOT( selectMaximumColor() ) );

//find out the numerical fields of mVectorLayer
QgsVectorDataProvider *provider = mVectorLayer->dataProvider();
if ( provider )
{
const QgsFieldMap & fields = provider->fields();
int fieldNumber( 0 ), comboNumber( 0 );
QString str;
const QgsFieldMap & fields = mVectorLayer->pendingFields();

for ( QgsFieldMap::const_iterator it = fields.begin(); it != fields.end(); ++it )
for ( QgsFieldMap::const_iterator it = fields.begin(); it != fields.end(); ++it )
{
QVariant::Type type = it->type();
if ( type == QVariant::Int || type == QVariant::Double )
{
QVariant::Type type = ( *it ).type();
if ( type == QVariant::Int || type == QVariant::Double )
{
str = ( *it ).name();
classificationComboBox->addItem( str );
mFieldMap.insert( std::make_pair( comboNumber, fieldNumber ) );
comboNumber++;
}
fieldNumber++;
classificationComboBox->addItem( it->name(), it.key() );
}
}
else
{
QgsDebugMsg( "data provider is null" );
return;
}

//restore the correct colors for minimum and maximum values

const QgsContinuousColorRenderer* renderer = dynamic_cast < const QgsContinuousColorRenderer * >( layer->renderer() );;

if ( renderer )
{
// Awkard - here we want to search through mFieldMap for a
// particular value, while elsewhere in this code we need to search
// for a particular key, so one or the other loses out, which is here.

std::map<int, int>::const_iterator iter = mFieldMap.begin();
while ( iter != mFieldMap.end() )
{
if ( iter->second == renderer->classificationField() )
break;
iter++;
}
if ( iter != mFieldMap.end() )
classificationComboBox->setCurrentIndex( iter->first );
else
classificationComboBox->setCurrentIndex( -1 );
classificationComboBox->setCurrentIndex( classificationComboBox->findData( renderer->classificationField() ) );

const QgsSymbol* minsymbol = renderer->minimumSymbol();
const QgsSymbol* maxsymbol = renderer->maximumSymbol();
Expand Down Expand Up @@ -147,16 +118,7 @@ QgsContinuousColorDialog::~QgsContinuousColorDialog()

void QgsContinuousColorDialog::apply()
{
int comboIndex = classificationComboBox->currentIndex();
if ( comboIndex == -1 ) //don't do anything, if there is no classification field
{
return;
}
std::map < int, int >::iterator iter = mFieldMap.find( comboIndex );
// Should never happen...
assert( iter != mFieldMap.end() );

int classfield = iter->second;
int classfield = classificationComboBox->itemData( classificationComboBox->currentIndex() ).toInt();

//find the minimum and maximum for the classification variable
double minimum, maximum;
Expand Down
3 changes: 0 additions & 3 deletions src/app/qgscontinuouscolordialog.h
Expand Up @@ -44,9 +44,6 @@ class QgsContinuousColorDialog: public QDialog, private Ui::QgsContinuousColorDi

protected:
QgsVectorLayer* mVectorLayer;
/**Stores the relationship between provider field indices and field selection
combobox indices. First is the combobox index, second is the provider field index */
std::map<int, int> mFieldMap;

private:
/** Default constructor is private, do not use this */
Expand Down

0 comments on commit 782e267

Please sign in to comment.