[QGIS Commit] r10724 - branches/Version-1_0/src/app

svn_qgis at osgeo.org svn_qgis at osgeo.org
Mon May 4 07:55:44 EDT 2009


Author: jef
Date: 2009-05-04 07:55:44 -0400 (Mon, 04 May 2009)
New Revision: 10724

Modified:
   branches/Version-1_0/src/app/qgscontinuouscolordialog.cpp
   branches/Version-1_0/src/app/qgscontinuouscolordialog.h
Log:
backport r10708 to 1.0

Modified: branches/Version-1_0/src/app/qgscontinuouscolordialog.cpp
===================================================================
--- branches/Version-1_0/src/app/qgscontinuouscolordialog.cpp	2009-05-04 11:55:20 UTC (rev 10723)
+++ branches/Version-1_0/src/app/qgscontinuouscolordialog.cpp	2009-05-04 11:55:44 UTC (rev 10724)
@@ -41,31 +41,16 @@
   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
-  {
-    qWarning( "Warning, data provider is null in QgsContinuousColorDialog::QgsContinuousColorDialog(...)" );
-    return;
-  }
 
   //restore the correct colors for minimum and maximum values
 
@@ -73,22 +58,8 @@
 
   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.
+    classificationComboBox->setCurrentIndex( classificationComboBox->findData( renderer->classificationField() ) );
 
-    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 );
-
     const QgsSymbol* minsymbol = renderer->minimumSymbol();
     const QgsSymbol* maxsymbol = renderer->maximumSymbol();
 
@@ -153,17 +124,8 @@
 
 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 = classificationComboBox->itemData( classificationComboBox->currentIndex() ).toInt();
 
-  int classfield = iter->second;
-
   //find the minimum and maximum for the classification variable
   double minimum, maximum;
   QgsVectorDataProvider *provider = dynamic_cast<QgsVectorDataProvider*>( mVectorLayer->dataProvider() );

Modified: branches/Version-1_0/src/app/qgscontinuouscolordialog.h
===================================================================
--- branches/Version-1_0/src/app/qgscontinuouscolordialog.h	2009-05-04 11:55:20 UTC (rev 10723)
+++ branches/Version-1_0/src/app/qgscontinuouscolordialog.h	2009-05-04 11:55:44 UTC (rev 10724)
@@ -44,9 +44,6 @@
 
   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 */



More information about the QGIS-commit mailing list