Skip to content
Permalink
Browse files
Fixed problems with classification fields in graduated symbol dialog …
…and unique value dialog. this should address ticket #732 Layer Properties/Legendtype/Individual Symbol

git-svn-id: http://svn.osgeo.org/qgis/trunk@7066 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Jul 7, 2007
1 parent c9da10c commit 31e49a2cebb6cff3e00ebff0e4a0e0d0bbd7782c
Showing with 61 additions and 57 deletions.
  1. +2 −5 src/app/qgsgraduatedsymboldialog.cpp
  2. +59 −52 src/app/qgsuniquevaluedialog.cpp
@@ -42,7 +42,6 @@ QgsGraduatedSymbolDialog::QgsGraduatedSymbolDialog(QgsVectorLayer * layer): QDia
if (provider)
{
const QgsFieldMap & fields = provider->fields();
int fieldnumber = 0;
QString str;

for (QgsFieldMap::const_iterator it = fields.begin();
@@ -52,11 +51,9 @@ QgsGraduatedSymbolDialog::QgsGraduatedSymbolDialog(QgsVectorLayer * layer): QDia
QVariant::Type type = (*it).type();
if (type == QVariant::Int || type == QVariant::Double)
{
str = (*it).name();
classificationComboBox->insertItem(str);
mFieldMap.insert(std::make_pair(str, fieldnumber));
classificationComboBox->insertItem(it->name());
mFieldMap.insert(std::make_pair(it->name(), it.key()));
}
fieldnumber++;
}
}
else
@@ -125,72 +125,79 @@ void QgsUniqueValueDialog::apply()

void QgsUniqueValueDialog::changeClassificationAttribute()
{
int nr = mClassificationComboBox->currentIndex();
//delete old entries
for(std::map<QString,QgsSymbol*>::iterator it=mValues.begin();it!=mValues.end();++it)
QString attributeName = mClassificationComboBox->currentText();

//delete old entries
for(std::map<QString,QgsSymbol*>::iterator it=mValues.begin();it!=mValues.end();++it)
{
delete it->second;
delete it->second;
}
mValues.clear();
QgsVectorDataProvider *provider = dynamic_cast<QgsVectorDataProvider *>(mVectorLayer->getDataProvider());
if (provider)
mValues.clear();

QgsVectorDataProvider *provider = dynamic_cast<QgsVectorDataProvider *>(mVectorLayer->getDataProvider());
if (provider)
{
QString value;
QgsAttributeList attlist;
attlist.append(nr);
QgsSymbol* symbol;

provider->select(attlist, QgsRect(), false);
QgsFeature feat;

//go through all the features and insert their value into the map and into mClassListWidget
mClassListWidget->clear();
while(provider->getNextFeature(feat))
QString value;
QgsAttributeList attlist;

QgsSymbol* symbol;
int nr = provider->indexFromFieldName(attributeName);
if(nr == -1)
{
return;
}
attlist.append(nr);

provider->select(attlist, QgsRect(), false);
QgsFeature feat;

//go through all the features and insert their value into the map and into mClassListWidget
mClassListWidget->clear();
while(provider->getNextFeature(feat))
{
const QgsAttributeMap& attrs = feat.attributeMap();
value = attrs[nr].toString();
if(mValues.find(value)==mValues.end())
const QgsAttributeMap& attrs = feat.attributeMap();
value = attrs[nr].toString();

if(mValues.find(value)==mValues.end())
{
symbol=new QgsSymbol(mVectorLayer->vectorType(), value);
mValues.insert(std::make_pair(value,symbol));
symbol=new QgsSymbol(mVectorLayer->vectorType(), value);
mValues.insert(std::make_pair(value,symbol));
}
}

//set symbology for all QgsSiSyDialogs
QColor thecolor;

for(std::map<QString,QgsSymbol*>::iterator it=mValues.begin();it!=mValues.end();++it)
//set symbology for all QgsSiSyDialogs
QColor thecolor;
for(std::map<QString,QgsSymbol*>::iterator it=mValues.begin();it!=mValues.end();++it)
{
//insert a random color
int red = 1 + (int) (255.0 * rand() / (RAND_MAX + 1.0));
int green = 1 + (int) (255.0 * rand() / (RAND_MAX + 1.0));
int blue = 1 + (int) (255.0 * rand() / (RAND_MAX + 1.0));
thecolor.setRgb(red, green, blue);
mClassListWidget->addItem(it->first);
QgsSymbol* sym=it->second;
QPen pen;
QBrush brush;
if(mVectorLayer->vectorType() == QGis::Line)
//insert a random color
int red = 1 + (int) (255.0 * rand() / (RAND_MAX + 1.0));
int green = 1 + (int) (255.0 * rand() / (RAND_MAX + 1.0));
int blue = 1 + (int) (255.0 * rand() / (RAND_MAX + 1.0));
thecolor.setRgb(red, green, blue);
mClassListWidget->addItem(it->first);
QgsSymbol* sym=it->second;
QPen pen;
QBrush brush;
if(mVectorLayer->vectorType() == QGis::Line)
{
pen.setColor(thecolor);
pen.setStyle(Qt::SolidLine);
pen.setWidth(1);
pen.setColor(thecolor);
pen.setStyle(Qt::SolidLine);
pen.setWidth(1);
}
else
else
{
brush.setColor(thecolor);
brush.setStyle(Qt::SolidPattern);
pen.setColor(Qt::black);
pen.setStyle(Qt::SolidLine);
pen.setWidth(1);
brush.setColor(thecolor);
brush.setStyle(Qt::SolidPattern);
pen.setColor(Qt::black);
pen.setStyle(Qt::SolidLine);
pen.setWidth(1);
}
sym->setPen(pen);
sym->setBrush(brush);
sym->setPen(pen);
sym->setBrush(brush);
}
}
mClassListWidget->setCurrentRow(0);
mClassListWidget->setCurrentRow(0);
}

void QgsUniqueValueDialog::changeCurrentValue()

0 comments on commit 31e49a2

Please sign in to comment.