Skip to content
Permalink
Browse files

fix #1666

git-svn-id: http://svn.osgeo.org/qgis/trunk@10708 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed May 2, 2009
1 parent 80b71a9 commit 782e26716c1eb2cc673239d2caebe7720dd8e880
Showing with 8 additions and 49 deletions.
  1. +8 −46 src/app/qgscontinuouscolordialog.cpp
  2. +0 −3 src/app/qgscontinuouscolordialog.h
@@ -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();
@@ -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;
@@ -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 */

0 comments on commit 782e267

Please sign in to comment.
You can’t perform that action at this time.