|
26 | 26 |
|
27 | 27 | #include "qgslogger.h" |
28 | 28 |
|
| 29 | +#include <QMessageBox> |
| 30 | + |
29 | 31 | QgsUniqueValueDialog::QgsUniqueValueDialog(QgsVectorLayer* vl): QDialog(), mVectorLayer(vl), sydialog(vl, true) |
30 | 32 | { |
31 | 33 | setupUi(this); |
@@ -65,6 +67,7 @@ QgsUniqueValueDialog::QgsUniqueValueDialog(QgsVectorLayer* vl): QDialog(), mVect |
65 | 67 | //int classattr = *iter; |
66 | 68 | //QString field = provider->fields()[ classattr ].name(); |
67 | 69 | QString field = provider->fields()[ renderer->classificationField() ].name(); |
| 70 | + mOldClassificationAttribute = field; |
68 | 71 | mClassificationComboBox->setCurrentItem( mClassificationComboBox->findText(field) ); |
69 | 72 |
|
70 | 73 | const QList<QgsSymbol*> list = renderer->symbols(); |
@@ -272,6 +275,19 @@ void QgsUniqueValueDialog::changeClassificationAttribute() |
272 | 275 | { |
273 | 276 | QgsDebugMsg("called."); |
274 | 277 | QString attributeName = mClassificationComboBox->currentText(); |
| 278 | + |
| 279 | + if( !mOldClassificationAttribute.isEmpty() && |
| 280 | + attributeName!=mOldClassificationAttribute && |
| 281 | + QMessageBox::question(this, |
| 282 | + tr("Confirm Delete"), |
| 283 | + tr("The classification field was changed from '%1' to '%2'.\n" |
| 284 | + "Should the existing classes be deleted before classification?") |
| 285 | + .arg(mOldClassificationAttribute).arg(attributeName), |
| 286 | + QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok ) |
| 287 | + { |
| 288 | + deleteSelectedClasses(); |
| 289 | + } |
| 290 | + mOldClassificationAttribute=attributeName; |
275 | 291 |
|
276 | 292 | QgsVectorDataProvider *provider = dynamic_cast<QgsVectorDataProvider *>(mVectorLayer->getDataProvider()); |
277 | 293 | if (provider) |
@@ -376,6 +392,9 @@ void QgsUniqueValueDialog::deleteSelectedClasses() |
376 | 392 | { |
377 | 393 | QgsDebugMsg("called."); |
378 | 394 | QList<QListWidgetItem *> selection = mClassListWidget->selectedItems(); |
| 395 | + if(selection.size()==0) |
| 396 | + selection = mClassListWidget->findItems("", Qt::MatchContains); |
| 397 | + |
379 | 398 | for(int i=0; i<selection.size(); i++) |
380 | 399 | { |
381 | 400 | QListWidgetItem* currentItem = selection[i]; |
|
0 commit comments