[QGIS Commit] r8231 - trunk/qgis/src/app

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sun Mar 16 12:25:27 EDT 2008


Author: jef
Date: 2008-03-16 12:25:27 -0400 (Sun, 16 Mar 2008)
New Revision: 8231

Modified:
   trunk/qgis/src/app/qgscontinuouscolordialog.cpp
   trunk/qgis/src/app/qgsgraduatedsymboldialog.cpp
   trunk/qgis/src/app/qgsuniquevaluedialog.cpp
Log:
code reindented

Modified: trunk/qgis/src/app/qgscontinuouscolordialog.cpp
===================================================================
--- trunk/qgis/src/app/qgscontinuouscolordialog.cpp	2008-03-16 16:04:52 UTC (rev 8230)
+++ trunk/qgis/src/app/qgscontinuouscolordialog.cpp	2008-03-16 16:25:27 UTC (rev 8231)
@@ -30,197 +30,197 @@
 QgsContinuousColorDialog::QgsContinuousColorDialog(QgsVectorLayer * layer)
     : QDialog(), mVectorLayer(layer)
 {
-    setupUi(this);
+  setupUi(this);
 #ifdef QGISDEBUG
-    qWarning("constructor QgsContinuousColorDialog");
+  qWarning("constructor QgsContinuousColorDialog");
 #endif
 
-    QObject::connect(btnMinValue, SIGNAL(clicked()), this, SLOT(selectMinimumColor()));
-    QObject::connect(btnMaxValue, SIGNAL(clicked()), this, SLOT(selectMaximumColor()));
+  QObject::connect(btnMinValue, SIGNAL(clicked()), this, SLOT(selectMinimumColor()));
+  QObject::connect(btnMaxValue, SIGNAL(clicked()), this, SLOT(selectMaximumColor()));
 
-    //find out the numerical fields of mVectorLayer
-    QgsVectorDataProvider *provider = mVectorLayer->getDataProvider();
-    if (provider)
-    {
-	const QgsFieldMap & fields = provider->fields();
-	int fieldnumber(0), combonumber(0);
-	QString str;
+  //find out the numerical fields of mVectorLayer
+  QgsVectorDataProvider *provider = mVectorLayer->getDataProvider();
+  if (provider)
+  {
+    const QgsFieldMap & fields = provider->fields();
+    int fieldnumber(0), combonumber(0);
+    QString str;
 
-	for (QgsFieldMap::const_iterator it = fields.begin(); it != fields.end(); ++it)
-        {
-	    QVariant::Type type = (*it).type();
-	    if (type == QVariant::Int || type == QVariant::Double)
-            {
-		str = (*it).name();
-		classificationComboBox->insertItem(str);
-		mFieldMap.insert(std::make_pair(combonumber, fieldnumber));
-		combonumber++;
-            }
-	    fieldnumber++;
-        }
-    } 
-    else
+    for (QgsFieldMap::const_iterator it = fields.begin(); it != fields.end(); ++it)
     {
-	qWarning("Warning, data provider is null in QgsContinuousColorDialog::QgsContinuousColorDialog(...)");
-	return;
+      QVariant::Type type = (*it).type();
+      if (type == QVariant::Int || type == QVariant::Double)
+      {
+        str = (*it).name();
+        classificationComboBox->insertItem(str);
+        mFieldMap.insert(std::make_pair(combonumber, fieldnumber));
+        combonumber++;
+      }
+      fieldnumber++;
     }
+  } 
+  else
+  {
+    qWarning("Warning, data provider is null in QgsContinuousColorDialog::QgsContinuousColorDialog(...)");
+    return;
+  }
 
-    //restore the correct colors for minimum and maximum values
+  //restore the correct colors for minimum and maximum values
 
-    const QgsContinuousColorRenderer* renderer = dynamic_cast < const QgsContinuousColorRenderer * >(layer->renderer());;
+  const QgsContinuousColorRenderer* renderer = dynamic_cast < const QgsContinuousColorRenderer * >(layer->renderer());;
 
-    if (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())
     {
-	// 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.
+      if (iter->second == renderer->classificationField())
+        break;
+      iter++;
+    }
+    if (iter != mFieldMap.end())
+      classificationComboBox->setCurrentItem(iter->first);
+    else
+      classificationComboBox->setCurrentItem(-1);
 
-	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();
 
-	const QgsSymbol* minsymbol = renderer->minimumSymbol();
-	const QgsSymbol* maxsymbol = renderer->maximumSymbol();
-
-	if (mVectorLayer->vectorType() == QGis::Line || mVectorLayer->vectorType() == QGis::Point)
+    if (mVectorLayer->vectorType() == QGis::Line || mVectorLayer->vectorType() == QGis::Point)
     {
-        btnMinValue->setColor( minsymbol->pen().color() );
-        btnMaxValue->setColor( maxsymbol->pen().color() );
-	}
-	else
+      btnMinValue->setColor( minsymbol->pen().color() );
+      btnMaxValue->setColor( maxsymbol->pen().color() );
+    }
+    else
     {
-        btnMinValue->setColor( minsymbol->brush().color() );
-        btnMaxValue->setColor( maxsymbol->brush().color() );
+      btnMinValue->setColor( minsymbol->brush().color() );
+      btnMaxValue->setColor( maxsymbol->brush().color() );
     }
 
-	outlinewidthspinbox->setMinValue(0);
-	outlinewidthspinbox->setValue(minsymbol->pen().width());
+    outlinewidthspinbox->setMinValue(0);
+    outlinewidthspinbox->setValue(minsymbol->pen().width());
 
-	if (renderer->drawPolygonOutline()) 
-	  cb_polygonOutline->setCheckState(Qt::Checked);
-	else
-	  cb_polygonOutline->setCheckState(Qt::Unchecked);
-	if (mVectorLayer->vectorType() != QGis::Polygon)
-	  cb_polygonOutline->setVisible(false);
-    }
+    if (renderer->drawPolygonOutline()) 
+      cb_polygonOutline->setCheckState(Qt::Checked);
     else
-    {
-      cb_polygonOutline->setCheckState(Qt::Checked);
-      outlinewidthspinbox->setValue(1);
-      if (mVectorLayer->vectorType() != QGis::Polygon)
-        cb_polygonOutline->setVisible(false);
+      cb_polygonOutline->setCheckState(Qt::Unchecked);
+    if (mVectorLayer->vectorType() != QGis::Polygon)
+      cb_polygonOutline->setVisible(false);
+  }
+  else
+  {
+    cb_polygonOutline->setCheckState(Qt::Checked);
+    outlinewidthspinbox->setValue(1);
+    if (mVectorLayer->vectorType() != QGis::Polygon)
+      cb_polygonOutline->setVisible(false);
 
-      btnMinValue->setColor(Qt::black);
-      btnMaxValue->setColor(Qt::white);
+    btnMinValue->setColor(Qt::black);
+    btnMaxValue->setColor(Qt::white);
 
-    }
-    // Ensure that the state of other widgets is appropriate for the
-    // state of the polygonoutline checkbox.
-    on_cb_polygonOutline_clicked();
+  }
+  // Ensure that the state of other widgets is appropriate for the
+  // state of the polygonoutline checkbox.
+  on_cb_polygonOutline_clicked();
 }
 
 QgsContinuousColorDialog::QgsContinuousColorDialog()
 {
-    setupUi(this);
+  setupUi(this);
 #ifdef QGISDEBUG
-    qWarning("constructor QgsContinuousColorDialog");
+  qWarning("constructor QgsContinuousColorDialog");
 #endif
 }
 
 QgsContinuousColorDialog::~QgsContinuousColorDialog()
 {
 #ifdef QGISDEBUG
-    qWarning("destructor QgsContinuousColorDialog");
+  qWarning("destructor QgsContinuousColorDialog");
 #endif
 }
 
 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 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 = iter->second;
 
-    //find the minimum and maximum for the classification variable
-    double minimum, maximum;
-    QgsVectorDataProvider *provider = dynamic_cast<QgsVectorDataProvider*>(mVectorLayer->getDataProvider());
-    if (provider)
-    {
-	minimum = provider->minValue(classfield).toDouble();
-	maximum = provider->maxValue(classfield).toDouble();
-    } 
-    else
-    {
-	qWarning("Warning, provider is null in QgsGraSyExtensionWidget::QgsGraSyExtensionWidget(...)");
-	return;
-    }
+  //find the minimum and maximum for the classification variable
+  double minimum, maximum;
+  QgsVectorDataProvider *provider = dynamic_cast<QgsVectorDataProvider*>(mVectorLayer->getDataProvider());
+  if (provider)
+  {
+    minimum = provider->minValue(classfield).toDouble();
+    maximum = provider->maxValue(classfield).toDouble();
+  } 
+  else
+  {
+    qWarning("Warning, provider is null in QgsGraSyExtensionWidget::QgsGraSyExtensionWidget(...)");
+    return;
+  }
 
 
-    //create the render items for minimum and maximum value
-    QgsSymbol* minsymbol = new QgsSymbol(mVectorLayer->vectorType(), QString::number(minimum, 'f'), "", "");
-    if (mVectorLayer->vectorType() == QGis::Line || mVectorLayer->vectorType() == QGis::Point)
-    {
-	minsymbol->setPen(QPen(btnMinValue->color(), outlinewidthspinbox->value()));
-    } 
-    else
-    {
-	minsymbol->setBrush(QBrush(btnMinValue->color()));
-        minsymbol->setPen(QPen(QColor(0, 0, 0), outlinewidthspinbox->value()));
-    }
-    
-    QgsSymbol* maxsymbol = new QgsSymbol(mVectorLayer->vectorType(), QString::number(maximum, 'f'), "", "");
-    if (mVectorLayer->vectorType() == QGis::Line || mVectorLayer->vectorType() == QGis::Point)
-    {
-	maxsymbol->setPen(QPen(btnMaxValue->color(), outlinewidthspinbox->value()));
-    } 
-    else
-    {
-	maxsymbol->setBrush(QBrush(btnMaxValue->color()));
-	maxsymbol->setPen(QPen(QColor(0, 0, 0), outlinewidthspinbox->value()));
-    }
-  
-    QgsContinuousColorRenderer* renderer = new QgsContinuousColorRenderer(mVectorLayer->vectorType());
-    mVectorLayer->setRenderer(renderer);
-    
-    renderer->setMinimumSymbol(minsymbol);
-    renderer->setMaximumSymbol(maxsymbol);
-    renderer->setClassificationField(classfield);
-    bool drawOutline = (cb_polygonOutline->checkState() == Qt::Checked) ? true:false; 
-    renderer->setDrawPolygonOutline(drawOutline);
+  //create the render items for minimum and maximum value
+  QgsSymbol* minsymbol = new QgsSymbol(mVectorLayer->vectorType(), QString::number(minimum, 'f'), "", "");
+  if (mVectorLayer->vectorType() == QGis::Line || mVectorLayer->vectorType() == QGis::Point)
+  {
+    minsymbol->setPen(QPen(btnMinValue->color(), outlinewidthspinbox->value()));
+  } 
+  else
+  {
+    minsymbol->setBrush(QBrush(btnMinValue->color()));
+    minsymbol->setPen(QPen(QColor(0, 0, 0), outlinewidthspinbox->value()));
+  }
+
+  QgsSymbol* maxsymbol = new QgsSymbol(mVectorLayer->vectorType(), QString::number(maximum, 'f'), "", "");
+  if (mVectorLayer->vectorType() == QGis::Line || mVectorLayer->vectorType() == QGis::Point)
+  {
+    maxsymbol->setPen(QPen(btnMaxValue->color(), outlinewidthspinbox->value()));
+  } 
+  else
+  {
+    maxsymbol->setBrush(QBrush(btnMaxValue->color()));
+    maxsymbol->setPen(QPen(QColor(0, 0, 0), outlinewidthspinbox->value()));
+  }
+
+  QgsContinuousColorRenderer* renderer = new QgsContinuousColorRenderer(mVectorLayer->vectorType());
+  mVectorLayer->setRenderer(renderer);
+
+  renderer->setMinimumSymbol(minsymbol);
+  renderer->setMaximumSymbol(maxsymbol);
+  renderer->setClassificationField(classfield);
+  bool drawOutline = (cb_polygonOutline->checkState() == Qt::Checked) ? true:false; 
+  renderer->setDrawPolygonOutline(drawOutline);
 }
 
 void QgsContinuousColorDialog::selectMinimumColor()
 {
-    QColor mincolor = QColorDialog::getColor(btnMinValue->color(), this);
-    if(mincolor.isValid())
-    {
-      btnMinValue->setColor(mincolor);
-    }
-    setActiveWindow();
+  QColor mincolor = QColorDialog::getColor(btnMinValue->color(), this);
+  if(mincolor.isValid())
+  {
+    btnMinValue->setColor(mincolor);
+  }
+  setActiveWindow();
 }
 
 void QgsContinuousColorDialog::selectMaximumColor()
 {
-    QColor maxcolor = QColorDialog::getColor(btnMaxValue->color(), this);
-    if(maxcolor.isValid())
-    {
-      btnMaxValue->setColor(maxcolor);
-    }
-    setActiveWindow();
+  QColor maxcolor = QColorDialog::getColor(btnMaxValue->color(), this);
+  if(maxcolor.isValid())
+  {
+    btnMaxValue->setColor(maxcolor);
+  }
+  setActiveWindow();
 }
 
 void QgsContinuousColorDialog::on_cb_polygonOutline_clicked()

Modified: trunk/qgis/src/app/qgsgraduatedsymboldialog.cpp
===================================================================
--- trunk/qgis/src/app/qgsgraduatedsymboldialog.cpp	2008-03-16 16:04:52 UTC (rev 8230)
+++ trunk/qgis/src/app/qgsgraduatedsymboldialog.cpp	2008-03-16 16:25:27 UTC (rev 8231)
@@ -29,410 +29,410 @@
 
 QgsGraduatedSymbolDialog::QgsGraduatedSymbolDialog(QgsVectorLayer * layer): QDialog(), mVectorLayer(layer), sydialog(layer)
 {
-    setupUi(this);
+  setupUi(this);
 #ifdef QGISDEBUG
-    qWarning("constructor QgsGraduatedSymbolDialog");
+  qWarning("constructor QgsGraduatedSymbolDialog");
 #endif
 
-    setOrientation(Qt::Vertical);
-    setSizeGripEnabled(true);
+  setOrientation(Qt::Vertical);
+  setSizeGripEnabled(true);
 
-    //find out the numerical fields of mVectorLayer
-    QgsVectorDataProvider *provider = mVectorLayer->getDataProvider();
-    if (provider)
+  //find out the numerical fields of mVectorLayer
+  QgsVectorDataProvider *provider = mVectorLayer->getDataProvider();
+  if (provider)
+  {
+    const QgsFieldMap & fields = provider->fields();
+    QString str;
+
+    for (QgsFieldMap::const_iterator it = fields.begin(); 
+      it != fields.end(); 
+      ++it)
     {
-	const QgsFieldMap & fields = provider->fields();
-	QString str;
-	
-	for (QgsFieldMap::const_iterator it = fields.begin(); 
-             it != fields.end(); 
-             ++it)
-        {
-	    QVariant::Type type = (*it).type();
-	    if (type == QVariant::Int || type == QVariant::Double)
-            {
-	      classificationComboBox->insertItem(it->name());
-	      mFieldMap.insert(std::make_pair(it->name(), it.key()));
-            }
-        }
-    } 
-    else
+      QVariant::Type type = (*it).type();
+      if (type == QVariant::Int || type == QVariant::Double)
+      {
+        classificationComboBox->insertItem(it->name());
+        mFieldMap.insert(std::make_pair(it->name(), it.key()));
+      }
+    }
+  } 
+  else
+  {
+    qWarning("Warning, data provider is null in QgsGraduatedSymbolDialog::QgsGraduatedSymbolDialog(...)");
+    return;
+  }
+
+  modeComboBox->insertItem(tr("Equal Interval"));
+  modeComboBox->insertItem(tr("Quantiles"));
+  modeComboBox->insertItem(tr("Empty"));
+
+  //restore the correct settings
+  const QgsGraduatedSymbolRenderer* renderer = dynamic_cast < const QgsGraduatedSymbolRenderer * >(layer->renderer());
+
+  if (renderer)
+  {
+    QList < QgsSymbol * >list = renderer->symbols();
+
+    //display the classification field
+    QString classfield="";
+    for(std::map<QString,int>::iterator it=mFieldMap.begin();it!=mFieldMap.end();++it)
     {
-	qWarning("Warning, data provider is null in QgsGraduatedSymbolDialog::QgsGraduatedSymbolDialog(...)");
-	return;
+      if(it->second==renderer->classificationField())
+      {
+        classfield=it->first;
+        break;
+      }
     }
+    classificationComboBox->setCurrentText(classfield);
 
-    modeComboBox->insertItem(tr("Equal Interval"));
-    modeComboBox->insertItem(tr("Quantiles"));
-    modeComboBox->insertItem(tr("Empty"));
-    
-    //restore the correct settings
-    const QgsGraduatedSymbolRenderer* renderer = dynamic_cast < const QgsGraduatedSymbolRenderer * >(layer->renderer());
-    
-    if (renderer)
+    numberofclassesspinbox->setValue(list.size());
+    //fill the items of the renderer into mValues
+    for(QList<QgsSymbol*>::iterator it=list.begin();it!=list.end();++it)
     {
-	QList < QgsSymbol * >list = renderer->symbols();
-	
-	//display the classification field
-	QString classfield="";
-	for(std::map<QString,int>::iterator it=mFieldMap.begin();it!=mFieldMap.end();++it)
-	{
-	    if(it->second==renderer->classificationField())
-	    {
-		classfield=it->first;
-		break;
-	    }
-	}
-	classificationComboBox->setCurrentText(classfield);
-
-	numberofclassesspinbox->setValue(list.size());
-	//fill the items of the renderer into mValues
-	for(QList<QgsSymbol*>::iterator it=list.begin();it!=list.end();++it)
-	{
-          //todo: make an assignment operator and a copy constructor for QgsSymbol
-          QString classbreak=(*it)->lowerValue()+" - "+(*it)->upperValue();
-          QgsSymbol* sym=new QgsSymbol(mVectorLayer->vectorType(), (*it)->lowerValue(), (*it)->upperValue(), (*it)->label());
-          sym->setPen((*it)->pen());
-          sym->setCustomTexture((*it)->customTexture());
-          sym->setBrush((*it)->brush());
-          sym->setNamedPointSymbol((*it)->pointSymbolName());
-          sym->setPointSize((*it)->pointSize());
-          sym->setScaleClassificationField((*it)->scaleClassificationField());
-          sym->setRotationClassificationField((*it)->rotationClassificationField());
-          mEntries.insert(std::make_pair(classbreak,sym));
-          mClassListWidget->addItem(classbreak);
-	}
-	
+      //todo: make an assignment operator and a copy constructor for QgsSymbol
+      QString classbreak=(*it)->lowerValue()+" - "+(*it)->upperValue();
+      QgsSymbol* sym=new QgsSymbol(mVectorLayer->vectorType(), (*it)->lowerValue(), (*it)->upperValue(), (*it)->label());
+      sym->setPen((*it)->pen());
+      sym->setCustomTexture((*it)->customTexture());
+      sym->setBrush((*it)->brush());
+      sym->setNamedPointSymbol((*it)->pointSymbolName());
+      sym->setPointSize((*it)->pointSize());
+      sym->setScaleClassificationField((*it)->scaleClassificationField());
+      sym->setRotationClassificationField((*it)->rotationClassificationField());
+      mEntries.insert(std::make_pair(classbreak,sym));
+      mClassListWidget->addItem(classbreak);
     }
-    
-    //do the necessary signal/slot connections
-    QObject::connect(mClassifyButton, SIGNAL(clicked()), this, SLOT(adjustClassification()));
-    QObject::connect(mClassListWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(changeCurrentValue()));
-    QObject::connect(&sydialog, SIGNAL(settingsChanged()), this, SLOT(applySymbologyChanges()));
-    QObject::connect(mClassListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(modifyClass(QListWidgetItem*)));
-    QObject::connect(mDeleteClassButton, SIGNAL(clicked()), this, SLOT(deleteCurrentClass()));
 
-    mSymbolWidgetStack->addWidget(&sydialog);
-    mSymbolWidgetStack->setCurrentWidget(&sydialog); 
+  }
 
-    mClassListWidget->setCurrentRow(0);
+  //do the necessary signal/slot connections
+  QObject::connect(mClassifyButton, SIGNAL(clicked()), this, SLOT(adjustClassification()));
+  QObject::connect(mClassListWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(changeCurrentValue()));
+  QObject::connect(&sydialog, SIGNAL(settingsChanged()), this, SLOT(applySymbologyChanges()));
+  QObject::connect(mClassListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(modifyClass(QListWidgetItem*)));
+  QObject::connect(mDeleteClassButton, SIGNAL(clicked()), this, SLOT(deleteCurrentClass()));
+
+  mSymbolWidgetStack->addWidget(&sydialog);
+  mSymbolWidgetStack->setCurrentWidget(&sydialog); 
+
+  mClassListWidget->setCurrentRow(0);
 }
 
 QgsGraduatedSymbolDialog::QgsGraduatedSymbolDialog(): QDialog(), mVectorLayer(0), sydialog(0)
 {
-    setupUi(this);
+  setupUi(this);
 #ifdef QGISDEBUG
-    qWarning("constructor QgsGraduatedSymbolDialog");
+  qWarning("constructor QgsGraduatedSymbolDialog");
 #endif
 }
 
 QgsGraduatedSymbolDialog::~QgsGraduatedSymbolDialog()
 {
 #ifdef QGISDEBUG
-    qWarning("destructor QgsGraduatedSymbolDialog");
+  qWarning("destructor QgsGraduatedSymbolDialog");
 #endif
 }
 
 void QgsGraduatedSymbolDialog::adjustNumberOfClasses()
 {
-    //find out the number of the classification field
-    QString fieldstring = classificationComboBox->currentText();
-    
-    if (fieldstring.isEmpty())    //don't do anything, it there is no classification field
-    {
-	show();
-	return;
-    }
-    
-    std::map < QString, int >::iterator iter = mFieldMap.find(fieldstring);
+  //find out the number of the classification field
+  QString fieldstring = classificationComboBox->currentText();
+
+  if (fieldstring.isEmpty())    //don't do anything, it there is no classification field
+  {
+    show();
+    return;
+  }
+
+  std::map < QString, int >::iterator iter = mFieldMap.find(fieldstring);
 }
 
 void QgsGraduatedSymbolDialog::apply()
 {
-	if (classificationComboBox->currentText().isEmpty())  //don't do anything, it there is no classification field
-        {
-	    return;
-        }
-	
-	QgsGraduatedSymbolRenderer* renderer = new QgsGraduatedSymbolRenderer(mVectorLayer->vectorType());
+  if (classificationComboBox->currentText().isEmpty())  //don't do anything, it there is no classification field
+  {
+    return;
+  }
 
-	for (int item=0;item<mClassListWidget->count();++item)
-        {
-	  QString classbreak=mClassListWidget->item(item)->text();
-	  std::map<QString,QgsSymbol*>::iterator it=mEntries.find(classbreak);
-	  if(it==mEntries.end())
-	    {
-	      continue;
-	    }
-	  
-	  QString lower_bound=it->second->lowerValue();
-	  QString upper_bound=it->second->upperValue();
-	  QString label=it->second->label();
-	  
-	  QgsSymbol* sy = new QgsSymbol(mVectorLayer->vectorType(), lower_bound, upper_bound, label);
-	  
-	  sy->setColor(it->second->pen().color());
-	  sy->setLineStyle(it->second->pen().style());
-	  sy->setLineWidth(it->second->pen().width());
-	  
-	  if (mVectorLayer->vectorType() == QGis::Point)
-	    {
-	      sy->setNamedPointSymbol(it->second->pointSymbolName());
-	      sy->setPointSize(it->second->pointSize());
-              sy->setScaleClassificationField(it->second->scaleClassificationField());
-              sy->setRotationClassificationField(it->second->rotationClassificationField());
-	      
-	    }
-	  
-	  if (mVectorLayer->vectorType() != QGis::Line)
-            {
-	      sy->setFillColor(it->second->brush().color());
-	      sy->setCustomTexture(it->second->customTexture());//necessary?
-	      sy->setFillStyle(it->second->brush().style());
-            }
-	  
-	  //test, if lower_bound is numeric or not (making a subclass of QString would be the proper solution)
-	  bool lbcontainsletter = false;
-	  for (int j = 0; j < lower_bound.length(); j++)
-            {
-	      if (lower_bound.ref(j).isLetter())
-                {
-		  lbcontainsletter = true;
-                }
-            }
-	  
-	  //test, if upper_bound is numeric or not (making a subclass of QString would be the proper solution)
-	  bool ubcontainsletter = false;
-	  for (int j = 0; j < upper_bound.length(); j++)
-            {
-	      if (upper_bound.ref(j).isLetter())
-                {
-		  ubcontainsletter = true;
-                }
-            }
-	  if (lbcontainsletter == false && ubcontainsletter == false && lower_bound.length() > 0 && upper_bound.length() > 0) //only add the item if the value bounds do not contain letters and are not null strings
-            {
-	      renderer->addSymbol(sy);
-	    }
-	  else
-	    {
-	      delete sy;
-	    }
-        }
-        renderer->updateSymbolAttributes();
-	
-	std::map<QString,int>::iterator iter=mFieldMap.find(classificationComboBox->currentText());
-	if(iter!=mFieldMap.end())
-	  {
-	    renderer->setClassificationField(iter->second);
-	  }
-	mVectorLayer->setRenderer(renderer);
-}
+  QgsGraduatedSymbolRenderer* renderer = new QgsGraduatedSymbolRenderer(mVectorLayer->vectorType());
 
-void QgsGraduatedSymbolDialog::adjustClassification()
-{
-    mClassListWidget->clear();
-    QGis::VectorType m_type = mVectorLayer->vectorType();
-    QgsVectorDataProvider *provider = dynamic_cast<QgsVectorDataProvider *>(mVectorLayer->getDataProvider());
-    double minimum = 0;
-    double maximum = 0;
-    
-    //delete all previous entries
-    for(std::map<QString, QgsSymbol*>::iterator it=mEntries.begin();it!=mEntries.end();++it)
+  for (int item=0;item<mClassListWidget->count();++item)
+  {
+    QString classbreak=mClassListWidget->item(item)->text();
+    std::map<QString,QgsSymbol*>::iterator it=mEntries.find(classbreak);
+    if(it==mEntries.end())
     {
-	delete it->second;
+      continue;
     }
-    mEntries.clear();
 
-    //find out the number of the classification field
-    QString fieldstring = classificationComboBox->currentText();
+    QString lower_bound=it->second->lowerValue();
+    QString upper_bound=it->second->upperValue();
+    QString label=it->second->label();
 
-    if (fieldstring.isEmpty())    //don't do anything, it there is no classification field
+    QgsSymbol* sy = new QgsSymbol(mVectorLayer->vectorType(), lower_bound, upper_bound, label);
+
+    sy->setColor(it->second->pen().color());
+    sy->setLineStyle(it->second->pen().style());
+    sy->setLineWidth(it->second->pen().width());
+
+    if (mVectorLayer->vectorType() == QGis::Point)
     {
-	show();
-	return;
+      sy->setNamedPointSymbol(it->second->pointSymbolName());
+      sy->setPointSize(it->second->pointSize());
+      sy->setScaleClassificationField(it->second->scaleClassificationField());
+      sy->setRotationClassificationField(it->second->rotationClassificationField());
+
     }
-    
-    std::map < QString, int >::iterator iter = mFieldMap.find(fieldstring);
-    int field = iter->second;
 
+    if (mVectorLayer->vectorType() != QGis::Line)
+    {
+      sy->setFillColor(it->second->brush().color());
+      sy->setCustomTexture(it->second->customTexture());//necessary?
+      sy->setFillStyle(it->second->brush().style());
+    }
 
-    if (provider)
+    //test, if lower_bound is numeric or not (making a subclass of QString would be the proper solution)
+    bool lbcontainsletter = false;
+    for (int j = 0; j < lower_bound.length(); j++)
     {
-	if (modeComboBox->currentText() == tr("Equal Interval"))
-	{
-	    minimum = provider->minValue(field).toDouble();
-	    maximum = provider->maxValue(field).toDouble();
-	} 
-	else                    //don't waste performance if mMode is QgsGraduatedSymbolDialog::EMPTY
-	{
-	    minimum = 0;
-	    maximum = 0;
-	}
+      if (lower_bound.ref(j).isLetter())
+      {
+        lbcontainsletter = true;
+      }
     }
 
-    //todo: setup a data structure which holds the symbols
-    std::list<QgsSymbol*> symbolList;
-    for(int i = 0; i < numberofclassesspinbox->value(); ++i)
+    //test, if upper_bound is numeric or not (making a subclass of QString would be the proper solution)
+    bool ubcontainsletter = false;
+    for (int j = 0; j < upper_bound.length(); j++)
+    {
+      if (upper_bound.ref(j).isLetter())
       {
-	QgsSymbol* symbol = new QgsSymbol(m_type);
-	symbol->setLabel("");
-	QPen pen;
-	QBrush brush;
+        ubcontainsletter = true;
+      }
+    }
+    if (lbcontainsletter == false && ubcontainsletter == false && lower_bound.length() > 0 && upper_bound.length() > 0) //only add the item if the value bounds do not contain letters and are not null strings
+    {
+      renderer->addSymbol(sy);
+    }
+    else
+    {
+      delete sy;
+    }
+  }
+  renderer->updateSymbolAttributes();
 
-	// todo: These color ramps should come from a dropdown list  
-        QString ramp; 
-        ramp = "red_to_green"; 
-        if (m_type == QGis::Line) 
-        { 
-          pen.setColor(getColorFromRamp(ramp,i, numberofclassesspinbox->value())); 
-        }  
-        else //point or polygon 
-        { 
-          brush.setColor(getColorFromRamp(ramp,i, numberofclassesspinbox->value())); 
-          pen.setColor(Qt::black); 
-        } 
+  std::map<QString,int>::iterator iter=mFieldMap.find(classificationComboBox->currentText());
+  if(iter!=mFieldMap.end())
+  {
+    renderer->setClassificationField(iter->second);
+  }
+  mVectorLayer->setRenderer(renderer);
+}
 
-	pen.setWidth(1);
-	brush.setStyle(Qt::SolidPattern);
-	symbol->setPen(pen);
-	symbol->setBrush(brush);
-	symbolList.push_back(symbol);
-      }
+void QgsGraduatedSymbolDialog::adjustClassification()
+{
+  mClassListWidget->clear();
+  QGis::VectorType m_type = mVectorLayer->vectorType();
+  QgsVectorDataProvider *provider = dynamic_cast<QgsVectorDataProvider *>(mVectorLayer->getDataProvider());
+  double minimum = 0;
+  double maximum = 0;
 
-    QString listBoxText;
-    if(modeComboBox->currentText() == tr("Quantiles"))
+  //delete all previous entries
+  for(std::map<QString, QgsSymbol*>::iterator it=mEntries.begin();it!=mEntries.end();++it)
+  {
+    delete it->second;
+  }
+  mEntries.clear();
+
+  //find out the number of the classification field
+  QString fieldstring = classificationComboBox->currentText();
+
+  if (fieldstring.isEmpty())    //don't do anything, it there is no classification field
+  {
+    show();
+    return;
+  }
+
+  std::map < QString, int >::iterator iter = mFieldMap.find(fieldstring);
+  int field = iter->second;
+
+
+  if (provider)
+  {
+    if (modeComboBox->currentText() == tr("Equal Interval"))
+    {
+      minimum = provider->minValue(field).toDouble();
+      maximum = provider->maxValue(field).toDouble();
+    } 
+    else                    //don't waste performance if mMode is QgsGraduatedSymbolDialog::EMPTY
+    {
+      minimum = 0;
+      maximum = 0;
+    }
+  }
+
+  //todo: setup a data structure which holds the symbols
+  std::list<QgsSymbol*> symbolList;
+  for(int i = 0; i < numberofclassesspinbox->value(); ++i)
+  {
+    QgsSymbol* symbol = new QgsSymbol(m_type);
+    symbol->setLabel("");
+    QPen pen;
+    QBrush brush;
+
+    // todo: These color ramps should come from a dropdown list  
+    QString ramp; 
+    ramp = "red_to_green"; 
+    if (m_type == QGis::Line) 
+    { 
+      pen.setColor(getColorFromRamp(ramp,i, numberofclassesspinbox->value())); 
+    }  
+    else //point or polygon 
+    { 
+      brush.setColor(getColorFromRamp(ramp,i, numberofclassesspinbox->value())); 
+      pen.setColor(Qt::black); 
+    } 
+
+    pen.setWidth(1);
+    brush.setStyle(Qt::SolidPattern);
+    symbol->setPen(pen);
+    symbol->setBrush(brush);
+    symbolList.push_back(symbol);
+  }
+
+  QString listBoxText;
+  if(modeComboBox->currentText() == tr("Quantiles"))
+  {
+    //test: insert the values into mClassListWidget
+    std::list<double> quantileBorders;
+    quantilesFromVectorLayer(quantileBorders, field, numberofclassesspinbox->value());
+
+    std::list<double>::const_iterator it;
+    std::list<double>::const_iterator last_it = quantileBorders.end();
+    std::list<QgsSymbol*>::const_iterator symbol_it = symbolList.begin();
+    for(it = quantileBorders.begin(); it != quantileBorders.end(); ++it)
+    {
+      if(last_it != quantileBorders.end())
       {
-	//test: insert the values into mClassListWidget
-	std::list<double> quantileBorders;
-	quantilesFromVectorLayer(quantileBorders, field, numberofclassesspinbox->value());
-
-	std::list<double>::const_iterator it;
-	std::list<double>::const_iterator last_it = quantileBorders.end();
-	std::list<QgsSymbol*>::const_iterator symbol_it = symbolList.begin();
-	for(it = quantileBorders.begin(); it != quantileBorders.end(); ++it)
-	  {
-	    if(last_it != quantileBorders.end())
-	      {
-		listBoxText = QString::number(*last_it, 'f') + " - " + QString::number(*it, 'f');
-		mClassListWidget->addItem(listBoxText);
-		(*symbol_it)->setLowerValue(QString::number(*last_it, 'f'));
-		(*symbol_it)->setUpperValue(QString::number(*it, 'f'));
-		mEntries.insert(std::make_pair(listBoxText,*symbol_it));
-		++symbol_it;
-	      }
-	    last_it = it;
-	  }
+        listBoxText = QString::number(*last_it, 'f') + " - " + QString::number(*it, 'f');
+        mClassListWidget->addItem(listBoxText);
+        (*symbol_it)->setLowerValue(QString::number(*last_it, 'f'));
+        (*symbol_it)->setUpperValue(QString::number(*it, 'f'));
+        mEntries.insert(std::make_pair(listBoxText,*symbol_it));
+        ++symbol_it;
       }
-    else if(modeComboBox->currentText() == tr("Equal Interval"))
+      last_it = it;
+    }
+  }
+  else if(modeComboBox->currentText() == tr("Equal Interval"))
+  {
+    std::list<QgsSymbol*>::const_iterator symbol_it = symbolList.begin();
+    for(int i=0;i<numberofclassesspinbox->value();++i)
+    {
+      double lower=minimum + (maximum - minimum) / numberofclassesspinbox->value() * i;
+      double upper=minimum + (maximum - minimum) / numberofclassesspinbox->value() * (i+1);
+      if(i==0)//make sure all feature attributes are between minimum and maximum value (round off problem)
       {
-	std::list<QgsSymbol*>::const_iterator symbol_it = symbolList.begin();
-	for(int i=0;i<numberofclassesspinbox->value();++i)
-	  {
-	    double lower=minimum + (maximum - minimum) / numberofclassesspinbox->value() * i;
-	    double upper=minimum + (maximum - minimum) / numberofclassesspinbox->value() * (i+1);
-	    if(i==0)//make sure all feature attributes are between minimum and maximum value (round off problem)
-	      {
-		lower-=0.001;
-	      }
-	    if(i==numberofclassesspinbox->value()-1)
-	      {
-		upper+=0.001;
-	      }
-	    (*symbol_it)->setLowerValue(QString::number(lower,'f',3));
-	    (*symbol_it)->setUpperValue(QString::number(upper,'f',3));
-	    listBoxText=QString::number(lower,'f',3)+" - " +QString::number(upper,'f',3);
-	    mClassListWidget->addItem(listBoxText);
-	    
-	    mEntries.insert(std::make_pair(listBoxText,*symbol_it));
-	    ++symbol_it;
-	  }
+        lower-=0.001;
       }
-    else if(modeComboBox->currentText() == tr("Empty"))
+      if(i==numberofclassesspinbox->value()-1)
       {
-	std::list<QgsSymbol*>::const_iterator symbol_it = symbolList.begin();
-	for(int i=0;i<numberofclassesspinbox->value();++i)
-	  {
-	    listBoxText="Empty"+QString::number(i+1);
-	    mClassListWidget->addItem(listBoxText);
-	    mEntries.insert(std::make_pair(listBoxText,*symbol_it));
-	    ++symbol_it;
-	  }
+        upper+=0.001;
       }
-    
-    mClassListWidget->setCurrentRow(0);
+      (*symbol_it)->setLowerValue(QString::number(lower,'f',3));
+      (*symbol_it)->setUpperValue(QString::number(upper,'f',3));
+      listBoxText=QString::number(lower,'f',3)+" - " +QString::number(upper,'f',3);
+      mClassListWidget->addItem(listBoxText);
+
+      mEntries.insert(std::make_pair(listBoxText,*symbol_it));
+      ++symbol_it;
+    }
+  }
+  else if(modeComboBox->currentText() == tr("Empty"))
+  {
+    std::list<QgsSymbol*>::const_iterator symbol_it = symbolList.begin();
+    for(int i=0;i<numberofclassesspinbox->value();++i)
+    {
+      listBoxText="Empty"+QString::number(i+1);
+      mClassListWidget->addItem(listBoxText);
+      mEntries.insert(std::make_pair(listBoxText,*symbol_it));
+      ++symbol_it;
+    }
+  }
+
+  mClassListWidget->setCurrentRow(0);
 }
 
 void QgsGraduatedSymbolDialog::changeCurrentValue()
 {
-    sydialog.blockSignals(true);//block signals to prevent sydialog from changing the current QgsRenderItem
-    QListWidgetItem* item=mClassListWidget->currentItem();
-    if(item)
+  sydialog.blockSignals(true);//block signals to prevent sydialog from changing the current QgsRenderItem
+  QListWidgetItem* item=mClassListWidget->currentItem();
+  if(item)
+  {
+    QString value=item->text();
+    std::map<QString,QgsSymbol*>::iterator it=mEntries.find(value);
+    if(it!=mEntries.end())
     {
-	QString value=item->text();
-	std::map<QString,QgsSymbol*>::iterator it=mEntries.find(value);
-	if(it!=mEntries.end())
-	{
-	    sydialog.set((*it).second);
-	    sydialog.setLabel((*it).second->label());
-	}
+      sydialog.set((*it).second);
+      sydialog.setLabel((*it).second->label());
     }
-    sydialog.blockSignals(false);
+  }
+  sydialog.blockSignals(false);
 }
 
 void QgsGraduatedSymbolDialog::applySymbologyChanges()
 {
-    QListWidgetItem* item=mClassListWidget->currentItem();
-    if(item)
+  QListWidgetItem* item=mClassListWidget->currentItem();
+  if(item)
+  {
+    QString value=item->text();
+    std::map<QString,QgsSymbol*>::iterator it=mEntries.find(value);
+    if(it!=mEntries.end())
     {
-	QString value=item->text();
-	std::map<QString,QgsSymbol*>::iterator it=mEntries.find(value);
-	if(it!=mEntries.end())
-	{
-	    sydialog.apply((*it).second);
-	    it->second->setLabel((*it).second->label());
-	}
+      sydialog.apply((*it).second);
+      it->second->setLabel((*it).second->label());
     }
+  }
 }
 
 void QgsGraduatedSymbolDialog::modifyClass(QListWidgetItem* item)
 {
-    QString currenttext=item->text();
-    QgsSymbol* symbol=0;
-    std::map<QString,QgsSymbol*>::iterator iter=mEntries.find(currenttext);
-    if(iter!=mEntries.end())
-    {
-	symbol=iter->second;
-    }
-    QgsLUDialog dialog(this);
-    
+  QString currenttext=item->text();
+  QgsSymbol* symbol=0;
+  std::map<QString,QgsSymbol*>::iterator iter=mEntries.find(currenttext);
+  if(iter!=mEntries.end())
+  {
+    symbol=iter->second;
+  }
+  QgsLUDialog dialog(this);
+
+  if(symbol)
+  {
+    dialog.setLowerValue(symbol->lowerValue());
+    dialog.setUpperValue(symbol->upperValue());
+  }
+
+  if(dialog.exec()==QDialog::Accepted)
+  {
     if(symbol)
     {
-	dialog.setLowerValue(symbol->lowerValue());
-	dialog.setUpperValue(symbol->upperValue());
-    }
-
-    if(dialog.exec()==QDialog::Accepted)
-    {
-	if(symbol)
-	{
-	    mEntries.erase(currenttext);
-	    symbol->setLowerValue(dialog.lowerValue());
-	    symbol->setUpperValue(dialog.upperValue());
-	    QString newclass=dialog.lowerValue()+"-"+dialog.upperValue();
-	    mEntries.insert(std::make_pair(newclass,symbol));
-	    item->setText(newclass);
-	}	
-    }
+      mEntries.erase(currenttext);
+      symbol->setLowerValue(dialog.lowerValue());
+      symbol->setUpperValue(dialog.upperValue());
+      QString newclass=dialog.lowerValue()+"-"+dialog.upperValue();
+      mEntries.insert(std::make_pair(newclass,symbol));
+      item->setText(newclass);
+    }	
+  }
 }
 
 void QgsGraduatedSymbolDialog::deleteCurrentClass()
 {
   QListWidgetItem* currentItem = mClassListWidget->currentItem();
   if(!currentItem)
-    {
-      return;
-    }
+  {
+    return;
+  }
 
   QString classValue = currentItem->text();
   int currentIndex = mClassListWidget->currentRow();
@@ -442,46 +442,46 @@
   qWarning(QString::number(mClassListWidget->count()));
   //
   if(mClassListWidget->count() < (currentIndex + 1))
-    {
-      qWarning("selecting numRows - 1");
-      mClassListWidget->setCurrentRow(mClassListWidget->count() - 1);
-    }
+  {
+    qWarning("selecting numRows - 1");
+    mClassListWidget->setCurrentRow(mClassListWidget->count() - 1);
+  }
   else
-    {
-      qWarning("selecting currentIndex");
-      mClassListWidget->setCurrentRow(currentIndex);
-    }
+  {
+    qWarning("selecting currentIndex");
+    mClassListWidget->setCurrentRow(currentIndex);
+  }
 }
 
 int QgsGraduatedSymbolDialog::quantilesFromVectorLayer(std::list<double>& result, int attributeIndex, int numQuantiles) const
 {
   if(mVectorLayer)
+  {
+    QgsVectorDataProvider* provider = mVectorLayer->getDataProvider();
+
+    if(provider)
     {
-      QgsVectorDataProvider* provider = mVectorLayer->getDataProvider();
-  
-      if(provider)
-	{
-	  std::vector<double> attributeValues(provider->featureCount());
-	  QgsAttributeList attList;
-	  attList.push_back(attributeIndex);
-	  QgsFeature currentFeature;
-	  QgsAttributeMap currentAttributeMap;
-	  double currentValue;
-	  int index = 0;
-	  
-	  provider->select(attList, QgsRect(), false);
-	  while(provider->getNextFeature(currentFeature))
-	    {
-	      currentAttributeMap = currentFeature.attributeMap();
-	      currentValue = currentAttributeMap[attributeIndex].toDouble();
-	      attributeValues[index] = currentValue;
-	      ++index;
-	    }
+      std::vector<double> attributeValues(provider->featureCount());
+      QgsAttributeList attList;
+      attList.push_back(attributeIndex);
+      QgsFeature currentFeature;
+      QgsAttributeMap currentAttributeMap;
+      double currentValue;
+      int index = 0;
 
-	  sort(attributeValues.begin(), attributeValues.end());
-	  return calculateQuantiles(result, attributeValues, numQuantiles);
-	}
+      provider->select(attList, QgsRect(), false);
+      while(provider->getNextFeature(currentFeature))
+      {
+        currentAttributeMap = currentFeature.attributeMap();
+        currentValue = currentAttributeMap[attributeIndex].toDouble();
+        attributeValues[index] = currentValue;
+        ++index;
+      }
+
+      sort(attributeValues.begin(), attributeValues.end());
+      return calculateQuantiles(result, attributeValues, numQuantiles);
     }
+  }
   return 1;
 }
 
@@ -495,18 +495,18 @@
 
   result.push_back(values[0]);
   for(int i = 0; i < (numQuantiles - 1); ++i)
+  {
+    q = 100/numQuantiles * (i + 1);
+    k = values.size() * q / 100;
+    if(std::modf(k, &intPart) < 0.000000001)
     {
-      q = 100/numQuantiles * (i + 1);
-      k = values.size() * q / 100;
-      if(std::modf(k, &intPart) < 0.000000001)
-	{
-	  result.push_back(((100 - q) * values[(int)(k - 1)] + q * values[(int)k]) / 100);
-	}
-      else
-	{
-	  result.push_back(values[(int)k]);
-	}
+      result.push_back(((100 - q) * values[(int)(k - 1)] + q * values[(int)k]) / 100);
     }
+    else
+    {
+      result.push_back(values[(int)k]);
+    }
+  }
   result.push_back(values[values.size() - 1]);
   return 0;
 }

Modified: trunk/qgis/src/app/qgsuniquevaluedialog.cpp
===================================================================
--- trunk/qgis/src/app/qgsuniquevaluedialog.cpp	2008-03-16 16:04:52 UTC (rev 8230)
+++ trunk/qgis/src/app/qgsuniquevaluedialog.cpp	2008-03-16 16:25:27 UTC (rev 8231)
@@ -28,119 +28,119 @@
 
 QgsUniqueValueDialog::QgsUniqueValueDialog(QgsVectorLayer* vl): QDialog(), mVectorLayer(vl), sydialog(vl)
 {
-    setupUi(this);
-    setSizeGripEnabled(true); 
+  setupUi(this);
+  setSizeGripEnabled(true); 
 
-    //find out the fields of mVectorLayer
-    QgsVectorDataProvider *provider;
-    if ((provider = dynamic_cast<QgsVectorDataProvider *>(mVectorLayer->getDataProvider())))
+  //find out the fields of mVectorLayer
+  QgsVectorDataProvider *provider;
+  if ((provider = dynamic_cast<QgsVectorDataProvider *>(mVectorLayer->getDataProvider())))
+  {
+    const QgsFieldMap & fields = provider->fields();
+    QString str;
+
+    for (QgsFieldMap::const_iterator it = fields.begin(); it != fields.end(); ++it)
     {
-	const QgsFieldMap & fields = provider->fields();
-	QString str;
-	
-	for (QgsFieldMap::const_iterator it = fields.begin(); it != fields.end(); ++it)
-        {
-	    str = (*it).name();
-	    mClassificationComboBox->insertItem(str);
-        }
-    } 
-    else
-    {
-	qWarning("Warning, data provider is null in QgsUniqueValueDialog::QgsUniqueValueDialog");
-	return;
+      str = (*it).name();
+      mClassificationComboBox->insertItem(str);
     }
+  } 
+  else
+  {
+    qWarning("Warning, data provider is null in QgsUniqueValueDialog::QgsUniqueValueDialog");
+    return;
+  }
 
-    const QgsUniqueValueRenderer* renderer = dynamic_cast < const QgsUniqueValueRenderer * >(mVectorLayer->renderer());
-    
-    if (renderer)
+  const QgsUniqueValueRenderer* renderer = dynamic_cast < const QgsUniqueValueRenderer * >(mVectorLayer->renderer());
+
+  if (renderer)
+  {
+    mClassListWidget->clear();
+
+    // XXX - mloskot - fix for Ticket #31 (bug)
+    //QgsAttributeList attributes = renderer->classificationAttributes();
+    //QgsAttributeList::iterator iter = attributes.begin();
+    //int classattr = *iter;
+    //QString field = provider->fields()[ classattr ].name();
+    QString field = provider->fields()[ renderer->classificationField() ].name();
+    mClassificationComboBox->setCurrentItem( mClassificationComboBox->findText(field) );
+
+    const QList<QgsSymbol*> list = renderer->symbols();
+    //fill the items of the renderer into mValues
+    for(QList<QgsSymbol*>::const_iterator iter=list.begin();iter!=list.end();++iter)
     {
-	mClassListWidget->clear();
-	
-	// XXX - mloskot - fix for Ticket #31 (bug)
-	//QgsAttributeList attributes = renderer->classificationAttributes();
-	//QgsAttributeList::iterator iter = attributes.begin();
-	//int classattr = *iter;
-	//QString field = provider->fields()[ classattr ].name();
-	QString field = provider->fields()[ renderer->classificationField() ].name();
-	mClassificationComboBox->setCurrentItem( mClassificationComboBox->findText(field) );
-
-	const QList<QgsSymbol*> list = renderer->symbols();
-	//fill the items of the renderer into mValues
-	for(QList<QgsSymbol*>::const_iterator iter=list.begin();iter!=list.end();++iter)
-	{
-	    QgsSymbol* symbol=(*iter);
-	    QString symbolvalue=symbol->lowerValue();
-	    QgsSymbol* sym=new QgsSymbol(mVectorLayer->vectorType(), symbol->lowerValue(), symbol->upperValue(), symbol->label());
-	    sym->setPen(symbol->pen());
-	    sym->setCustomTexture(symbol->customTexture());
-	    sym->setBrush(symbol->brush());
-	    sym->setNamedPointSymbol(symbol->pointSymbolName());
-	    sym->setPointSize(symbol->pointSize());
-            sym->setScaleClassificationField(symbol->scaleClassificationField());
-            sym->setRotationClassificationField(symbol->rotationClassificationField());
-	    mValues.insert(std::make_pair(symbolvalue,sym));
-	    mClassListWidget->addItem(symbolvalue);
-	}
+      QgsSymbol* symbol=(*iter);
+      QString symbolvalue=symbol->lowerValue();
+      QgsSymbol* sym=new QgsSymbol(mVectorLayer->vectorType(), symbol->lowerValue(), symbol->upperValue(), symbol->label());
+      sym->setPen(symbol->pen());
+      sym->setCustomTexture(symbol->customTexture());
+      sym->setBrush(symbol->brush());
+      sym->setNamedPointSymbol(symbol->pointSymbolName());
+      sym->setPointSize(symbol->pointSize());
+      sym->setScaleClassificationField(symbol->scaleClassificationField());
+      sym->setRotationClassificationField(symbol->rotationClassificationField());
+      mValues.insert(std::make_pair(symbolvalue,sym));
+      mClassListWidget->addItem(symbolvalue);
     }
+  }
 
-    QObject::connect(mClassifyButton, SIGNAL(clicked()), this, SLOT(changeClassificationAttribute()));
-    QObject::connect(mDeletePushButton, SIGNAL(clicked()), this, SLOT(deleteCurrentClass()));
-    QObject::connect(mClassListWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(changeCurrentValue()));
-    QObject::connect(&sydialog, SIGNAL(settingsChanged()), this, SLOT(applySymbologyChanges()));
-    mSymbolWidgetStack->addWidget(&sydialog);
-    mSymbolWidgetStack->setCurrentWidget(&sydialog);
-    
-    mClassListWidget->setCurrentItem(0);
+  QObject::connect(mClassifyButton, SIGNAL(clicked()), this, SLOT(changeClassificationAttribute()));
+  QObject::connect(mDeletePushButton, SIGNAL(clicked()), this, SLOT(deleteCurrentClass()));
+  QObject::connect(mClassListWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(changeCurrentValue()));
+  QObject::connect(&sydialog, SIGNAL(settingsChanged()), this, SLOT(applySymbologyChanges()));
+  mSymbolWidgetStack->addWidget(&sydialog);
+  mSymbolWidgetStack->setCurrentWidget(&sydialog);
+
+  mClassListWidget->setCurrentItem(0);
 }
 
 QgsUniqueValueDialog::~QgsUniqueValueDialog()
 {
-    std::map<QString, QgsSymbol *>::iterator myValueIterator = mValues.begin();
-    while ( myValueIterator != mValues.end() )
-    {
-        delete myValueIterator->second;
-        
-        mValues.erase( myValueIterator );
-        
-        myValueIterator = mValues.begin(); // since iterator invalidated due to
-                                        // erase(), reset to new first element
-    }
-    mClassListWidget->setCurrentItem(0);
+  std::map<QString, QgsSymbol *>::iterator myValueIterator = mValues.begin();
+  while ( myValueIterator != mValues.end() )
+  {
+    delete myValueIterator->second;
+
+    mValues.erase( myValueIterator );
+
+    myValueIterator = mValues.begin(); // since iterator invalidated due to
+    // erase(), reset to new first element
+  }
+  mClassListWidget->setCurrentItem(0);
 }
 
 void QgsUniqueValueDialog::apply()
 {
-    QgsUniqueValueRenderer *renderer = new QgsUniqueValueRenderer(mVectorLayer->vectorType());
+  QgsUniqueValueRenderer *renderer = new QgsUniqueValueRenderer(mVectorLayer->vectorType());
 
-    //go through mValues and add the entries to the renderer
-    for(std::map<QString,QgsSymbol*>::iterator it=mValues.begin();it!=mValues.end();++it)
+  //go through mValues and add the entries to the renderer
+  for(std::map<QString,QgsSymbol*>::iterator it=mValues.begin();it!=mValues.end();++it)
+  {
+    QgsSymbol* symbol=it->second;
+    QgsSymbol* newsymbol=new QgsSymbol(mVectorLayer->vectorType(), symbol->lowerValue(), symbol->upperValue(), symbol->label());
+    newsymbol->setPen(symbol->pen());
+    newsymbol->setCustomTexture(symbol->customTexture());
+    newsymbol->setBrush(symbol->brush());
+    newsymbol->setNamedPointSymbol(symbol->pointSymbolName());
+    newsymbol->setPointSize(symbol->pointSize());
+    newsymbol->setScaleClassificationField(symbol->scaleClassificationField());
+    newsymbol->setRotationClassificationField(symbol->rotationClassificationField());
+    renderer->insertValue(it->first,newsymbol);
+  }
+  renderer->updateSymbolAttributes();
+
+  QgsVectorDataProvider *provider = dynamic_cast<QgsVectorDataProvider *>(mVectorLayer->getDataProvider());
+  if (provider)
+  {
+    int fieldIndex = provider->indexFromFieldName(mClassificationComboBox->currentText());
+    if(fieldIndex != -1)
     {
-	QgsSymbol* symbol=it->second;
-	QgsSymbol* newsymbol=new QgsSymbol(mVectorLayer->vectorType(), symbol->lowerValue(), symbol->upperValue(), symbol->label());
-	newsymbol->setPen(symbol->pen());
-	newsymbol->setCustomTexture(symbol->customTexture());
-	newsymbol->setBrush(symbol->brush());
-	newsymbol->setNamedPointSymbol(symbol->pointSymbolName());
-	newsymbol->setPointSize(symbol->pointSize());
-        newsymbol->setScaleClassificationField(symbol->scaleClassificationField());
-        newsymbol->setRotationClassificationField(symbol->rotationClassificationField());
-	renderer->insertValue(it->first,newsymbol);
+      renderer->setClassificationField(fieldIndex);
+      mVectorLayer->setRenderer(renderer);
+      return;
     }
-    renderer->updateSymbolAttributes();
+  }
 
-    QgsVectorDataProvider *provider = dynamic_cast<QgsVectorDataProvider *>(mVectorLayer->getDataProvider());
-    if (provider)
-      {
-	int fieldIndex = provider->indexFromFieldName(mClassificationComboBox->currentText());
-	if(fieldIndex != -1)
-	  {
-	    renderer->setClassificationField(fieldIndex);
-	    mVectorLayer->setRenderer(renderer);
-	    return;
-	  }
-      }
-   
-    delete renderer; //something went wrong
+  delete renderer; //something went wrong
 }
 
 void QgsUniqueValueDialog::changeClassificationAttribute()
@@ -149,105 +149,105 @@
 
   //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)
+  {
+    QString value;
+    QgsAttributeList attlist;
+
+    QgsSymbol* symbol;
+    int nr = provider->indexFromFieldName(attributeName);
+    if(nr == -1)
     {
-      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())
-	    {
-	      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)
-	{
-	  //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);
-	    }
-	  else
-	    {
-	      brush.setColor(thecolor);
-	      brush.setStyle(Qt::SolidPattern);
-	      pen.setColor(Qt::black);
-	      pen.setStyle(Qt::SolidLine);
-	      pen.setWidth(1);
-	    }
-	  sym->setPen(pen);
-	  sym->setBrush(brush);
-	}
+      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())
+      {
+        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)
+    {
+      //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);
+      }
+      else
+      {
+        brush.setColor(thecolor);
+        brush.setStyle(Qt::SolidPattern);
+        pen.setColor(Qt::black);
+        pen.setStyle(Qt::SolidLine);
+        pen.setWidth(1);
+      }
+      sym->setPen(pen);
+      sym->setBrush(brush);
+    }
+  }
   mClassListWidget->setCurrentRow(0);
 }
 
 void QgsUniqueValueDialog::changeCurrentValue()
 {
-    sydialog.blockSignals(true);//block signal to prevent sydialog from changing the current QgsRenderItem
-    QListWidgetItem* item=mClassListWidget->currentItem();
-    if(item)
-      {
-	QString value=item->text();
-	std::map<QString,QgsSymbol*>::iterator it=mValues.find(value);
-	if(it!=mValues.end())
-	  {
-	    sydialog.set( it->second);
- 	    sydialog.setLabel(it->second->label());
-	  }
-	else
-	  {
-	    //no entry found
-	  }
-      }
-    sydialog.blockSignals(false);
+  sydialog.blockSignals(true);//block signal to prevent sydialog from changing the current QgsRenderItem
+  QListWidgetItem* item=mClassListWidget->currentItem();
+  if(item)
+  {
+    QString value=item->text();
+    std::map<QString,QgsSymbol*>::iterator it=mValues.find(value);
+    if(it!=mValues.end())
+    {
+      sydialog.set( it->second);
+      sydialog.setLabel(it->second->label());
+    }
+    else
+    {
+      //no entry found
+    }
+  }
+  sydialog.blockSignals(false);
 }
 
 void QgsUniqueValueDialog::deleteCurrentClass()
 {
   QListWidgetItem* currentItem = mClassListWidget->currentItem();
   if(!currentItem)
-    {
-      return;
-    }
+  {
+    return;
+  }
 
   QString classValue = currentItem->text();
   int currentIndex = mClassListWidget->currentRow();
@@ -257,30 +257,30 @@
   qWarning(QString::number(mClassListWidget->count()));
 
   if(mClassListWidget->count() < (currentIndex + 1))
-    {
-      qWarning("selecting numRows - 1");
-      mClassListWidget->setCurrentRow(mClassListWidget->count() - 1);
-    }
+  {
+    qWarning("selecting numRows - 1");
+    mClassListWidget->setCurrentRow(mClassListWidget->count() - 1);
+  }
   else
-    {
-      qWarning("selecting currentIndex");
-      mClassListWidget->setCurrentRow(currentIndex);
-    }
+  {
+    qWarning("selecting currentIndex");
+    mClassListWidget->setCurrentRow(currentIndex);
+  }
 }
 
 void QgsUniqueValueDialog::applySymbologyChanges()
 {
   QListWidgetItem* item=mClassListWidget->currentItem();
   if(!item)
-    {
-      return;
-    }
+  {
+    return;
+  }
   QString value=item->text();
   std::map<QString,QgsSymbol*>::iterator it=mValues.find(value);
   if(it!=mValues.end())
   {
-      it->second->setLabel(sydialog.label());
-      it->second->setLowerValue(value);
-      sydialog.apply( it->second );
+    it->second->setLabel(sydialog.label());
+    it->second->setLowerValue(value);
+    sydialog.apply( it->second );
   }
 }



More information about the QGIS-commit mailing list