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

svn_qgis at osgeo.org svn_qgis at osgeo.org
Fri May 30 12:23:40 EDT 2008


Author: jef
Date: 2008-05-30 12:23:40 -0400 (Fri, 30 May 2008)
New Revision: 8555

Modified:
   trunk/qgis/src/app/qgsuniquevaluedialog.cpp
   trunk/qgis/src/app/qgsuniquevaluedialog.h
Log:
unique value dialog: ask if the existing classes should be deleted when classifying on a new attribute

Modified: trunk/qgis/src/app/qgsuniquevaluedialog.cpp
===================================================================
--- trunk/qgis/src/app/qgsuniquevaluedialog.cpp	2008-05-30 15:59:46 UTC (rev 8554)
+++ trunk/qgis/src/app/qgsuniquevaluedialog.cpp	2008-05-30 16:23:40 UTC (rev 8555)
@@ -26,6 +26,8 @@
 
 #include "qgslogger.h"
 
+#include <QMessageBox>
+
 QgsUniqueValueDialog::QgsUniqueValueDialog(QgsVectorLayer* vl): QDialog(), mVectorLayer(vl), sydialog(vl, true)
 {
   setupUi(this);
@@ -65,6 +67,7 @@
     //int classattr = *iter;
     //QString field = provider->fields()[ classattr ].name();
     QString field = provider->fields()[ renderer->classificationField() ].name();
+    mOldClassificationAttribute = field;
     mClassificationComboBox->setCurrentItem( mClassificationComboBox->findText(field) );
 
     const QList<QgsSymbol*> list = renderer->symbols();
@@ -272,6 +275,19 @@
 {
   QgsDebugMsg("called.");
   QString attributeName = mClassificationComboBox->currentText();
+  
+  if( !mOldClassificationAttribute.isEmpty() &&
+      attributeName!=mOldClassificationAttribute &&
+      QMessageBox::question(this,
+                            tr("Confirm Delete"),
+      			    tr("The classification field was changed from '%1' to '%2'.\n"
+			       "Should the existing classes be deleted before classification?")
+			     .arg(mOldClassificationAttribute).arg(attributeName),
+			     QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok )
+  {
+    deleteSelectedClasses();
+  }
+  mOldClassificationAttribute=attributeName;
 
   QgsVectorDataProvider *provider = dynamic_cast<QgsVectorDataProvider *>(mVectorLayer->getDataProvider());
   if (provider)
@@ -376,6 +392,9 @@
 {
   QgsDebugMsg("called.");
   QList<QListWidgetItem *> selection = mClassListWidget->selectedItems();
+  if(selection.size()==0)
+    selection = mClassListWidget->findItems("", Qt::MatchContains);
+
   for(int i=0; i<selection.size(); i++) 
   {
     QListWidgetItem* currentItem = selection[i];

Modified: trunk/qgis/src/app/qgsuniquevaluedialog.h
===================================================================
--- trunk/qgis/src/app/qgsuniquevaluedialog.h	2008-05-30 15:59:46 UTC (rev 8554)
+++ trunk/qgis/src/app/qgsuniquevaluedialog.h	2008-05-30 16:23:40 UTC (rev 8555)
@@ -66,6 +66,8 @@
     void updateEntryIcon(QgsSymbol * thepSymbol,QListWidgetItem * thepItem);
     QColor randomColor();
     void setSymbolColor(QgsSymbol *symbol, QColor thecolor);
+
+    QString mOldClassificationAttribute;
 };
 
 #endif



More information about the QGIS-commit mailing list