Skip to content

Commit

Permalink
unique value dialog: ask if the existing classes should be deleted wh…
Browse files Browse the repository at this point in the history
…en classifying on a new attribute

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8555 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed May 30, 2008
1 parent 0313460 commit bb91d14
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/app/qgsuniquevaluedialog.cpp
Expand Up @@ -26,6 +26,8 @@

#include "qgslogger.h"

#include <QMessageBox>

QgsUniqueValueDialog::QgsUniqueValueDialog(QgsVectorLayer* vl): QDialog(), mVectorLayer(vl), sydialog(vl, true)
{
setupUi(this);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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];
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsuniquevaluedialog.h
Expand Up @@ -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 bb91d14

Please sign in to comment.