Prompt whether to overwrite a symbol. Contributed by Alex Bruy (#3405)

git-svn-id: http://svn.osgeo.org/qgis/trunk@15237 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
wonder 2011-02-21 22:26:35 +00:00
parent 89f2128ab9
commit 47fa1cebb4
2 changed files with 29 additions and 0 deletions

View File

@ -15,6 +15,7 @@
#include <QFile>
#include <QFileDialog>
#include <QInputDialog>
#include <QMessageBox>
#include <QStandardItemModel>
#include "qgsapplication.h"
@ -239,6 +240,20 @@ bool QgsStyleV2ManagerDialog::addSymbol()
return false;
}
// check if there is no symbol with same name
if ( mStyle->symbolNames().contains( name ) )
{
int res = QMessageBox::warning( this, tr( "Save symbol" ),
tr( "Symbol with name '%1' already exists. Overwrite?" )
.arg( name ),
QMessageBox::Yes | QMessageBox::No );
if ( res != QMessageBox::Yes )
{
delete symbol;
return false;
}
}
// add new symbol to style and re-populate the list
mStyle->addSymbol( name, symbol );
mModified = true;

View File

@ -14,6 +14,7 @@
#include <QPainter>
#include <QStandardItemModel>
#include <QInputDialog>
#include <QMessageBox>
#include <QKeyEvent>
#include <QMenu>
@ -222,6 +223,19 @@ void QgsSymbolV2SelectorDialog::addSymbolToStyle()
if ( !ok || name.isEmpty() )
return;
// check if there is no symbol with same name
if ( mStyle->symbolNames().contains( name ) )
{
int res = QMessageBox::warning( this, tr( "Save symbol" ),
tr( "Symbol with name '%1' already exists. Overwrite?" )
.arg( name ),
QMessageBox::Yes | QMessageBox::No );
if ( res != QMessageBox::Yes )
{
return;
}
}
// add new symbol to style and re-populate the list
mStyle->addSymbol( name, mSymbol->clone() );