mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Fix a bug where the continuous colour renderer would display and use 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: http://svn.osgeo.org/qgis/trunk/qgis@6084 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
60bceac4c2
commit
fc83368e29
@ -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)
|
||||
@ -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
|
||||
classificationComboBox->insertItem(str);
|
||||
mFieldMap.insert(std::make_pair(str, fieldnumber));
|
||||
mFieldMap.insert(std::make_pair(combonumber, fieldnumber));
|
||||
combonumber++;
|
||||
}
|
||||
fieldnumber++;
|
||||
}
|
||||
@ -78,7 +79,22 @@ QgsContinuousColorDialog::QgsContinuousColorDialog(QgsVectorLayer * layer)
|
||||
|
||||
if (renderer)
|
||||
{
|
||||
classificationComboBox->setCurrentItem(renderer->classificationField());
|
||||
// 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->setCurrentItem(iter->first);
|
||||
else
|
||||
classificationComboBox->setCurrentItem(-1);
|
||||
|
||||
const QgsSymbol* minsymbol = renderer->minimumSymbol();
|
||||
const QgsSymbol* maxsymbol = renderer->maximumSymbol();
|
||||
|
||||
@ -108,6 +124,8 @@ QgsContinuousColorDialog::QgsContinuousColorDialog(QgsVectorLayer * layer)
|
||||
cb_polygonOutline->setCheckState(Qt::Checked);
|
||||
else
|
||||
cb_polygonOutline->setCheckState(Qt::Unchecked);
|
||||
if (mVectorLayer->vectorType() != QGis::Polygon)
|
||||
cb_polygonOutline->setVisible(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -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
|
||||
{
|
||||
return;
|
||||
}
|
||||
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());
|
||||
|
@ -48,8 +48,9 @@ class QgsContinuousColorDialog: public QDialog, private Ui::QgsContinuousColorDi
|
||||
|
||||
protected:
|
||||
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;
|
||||
|
||||
private:
|
||||
/** Default constructor is private, do not use this */
|
||||
|
Loading…
x
Reference in New Issue
Block a user