Skip to content
Permalink
Browse files

unique value dialog: ask if the existing classes should be deleted wh…

…en classifying on a new attribute

git-svn-id: http://svn.osgeo.org/qgis/trunk@8555 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed May 30, 2008
1 parent bb26fca commit bd5ec63fa19ed7e57cd77ead8a4951dd8153aae3
Showing with 21 additions and 0 deletions.
  1. +19 −0 src/app/qgsuniquevaluedialog.cpp
  2. +2 −0 src/app/qgsuniquevaluedialog.h
@@ -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 @@ QgsUniqueValueDialog::QgsUniqueValueDialog(QgsVectorLayer* vl): QDialog(), mVect
//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 @@ void QgsUniqueValueDialog::changeClassificationAttribute()
{
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 @@ void QgsUniqueValueDialog::deleteSelectedClasses()
{
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];
@@ -66,6 +66,8 @@ class QgsUniqueValueDialog: public QDialog, private Ui::QgsUniqueValueDialogBase
void updateEntryIcon(QgsSymbol * thepSymbol,QListWidgetItem * thepItem);
QColor randomColor();
void setSymbolColor(QgsSymbol *symbol, QColor thecolor);

QString mOldClassificationAttribute;
};

#endif

0 comments on commit bd5ec63

Please sign in to comment.
You can’t perform that action at this time.