Skip to content


Fix a bug where the continuous colour renderer would display and use …
Browse files Browse the repository at this point in the history
…the wrong layer attribute on the second and subsequent invocations of the vector layer properties dialog box (caused by a mismatch between the combo box index and provider attribute index, due to excluding attributes that couldn't be used to colour the features)

Fix a bug where the 'draw polygon outline' toggle would appear sometimes for a linestring layer

Fix a typo in a comment

git-svn-id: c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed Nov 13, 2006
1 parent 60bceac commit fc83368
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
35 changes: 28 additions & 7 deletions src/gui/qgscontinuouscolordialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ QgsContinuousColorDialog::QgsContinuousColorDialog(QgsVectorLayer * layer)
if (provider = dynamic_cast<QgsVectorDataProvider*>(mVectorLayer->getDataProvider()))
std::vector < QgsField > const & fields = provider->fields();
int fieldnumber = 0;
int fieldnumber(0), combonumber(0);
QString str;

for (std::vector < QgsField >::const_iterator it = fields.begin(); it != fields.end(); ++it)
Expand All @@ -54,7 +54,8 @@ QgsContinuousColorDialog::QgsContinuousColorDialog(QgsVectorLayer * layer)
str = (*it).name();
str = str.left(1).upper() + str.right(str.length() - 1); //make the first letter uppercase
mFieldMap.insert(std::make_pair(str, fieldnumber));
mFieldMap.insert(std::make_pair(combonumber, fieldnumber));
Expand All @@ -78,7 +79,22 @@ QgsContinuousColorDialog::QgsContinuousColorDialog(QgsVectorLayer * layer)

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())
if (iter != mFieldMap.end())

const QgsSymbol* minsymbol = renderer->minimumSymbol();
const QgsSymbol* maxsymbol = renderer->maximumSymbol();

Expand Down Expand Up @@ -108,6 +124,8 @@ QgsContinuousColorDialog::QgsContinuousColorDialog(QgsVectorLayer * layer)
if (mVectorLayer->vectorType() != QGis::Polygon)
Expand Down Expand Up @@ -142,14 +160,17 @@ QgsContinuousColorDialog::~QgsContinuousColorDialog()

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

int classfield = iter->second;

//find the minimum and maximum for the classification variable
double minimum, maximum;
QgsVectorDataProvider *provider = dynamic_cast<QgsVectorDataProvider*>(mVectorLayer->getDataProvider());
Expand Down
5 changes: 3 additions & 2 deletions src/gui/qgscontinuouscolordialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ class QgsContinuousColorDialog: public QDialog, private Ui::QgsContinuousColorDi

QgsVectorLayer* mVectorLayer;
/**Stores the names and numbers of the fields with numeric values*/
std::map<QString,int> mFieldMap;
/**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;

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

0 comments on commit fc83368

Please sign in to comment.