Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
  • Loading branch information
wonder committed Feb 21, 2011
1 parent 89f2128 commit 47fa1ce
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/gui/symbology-ng/qgsstylev2managerdialog.cpp
Expand Up @@ -15,6 +15,7 @@
#include <QFile>
#include <QFileDialog>
#include <QInputDialog>
#include <QMessageBox>
#include <QStandardItemModel>

#include "qgsapplication.h"
Expand Down Expand Up @@ -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;
Expand Down
14 changes: 14 additions & 0 deletions src/gui/symbology-ng/qgssymbolv2selectordialog.cpp
Expand Up @@ -14,6 +14,7 @@
#include <QPainter>
#include <QStandardItemModel>
#include <QInputDialog>
#include <QMessageBox>
#include <QKeyEvent>
#include <QMenu>

Expand Down Expand Up @@ -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() );

Expand Down

0 comments on commit 47fa1ce

Please sign in to comment.