Skip to content

Commit 498c8ee

Browse files
author
wonder
committed
Prompt whether to overwrite a symbol. Contributed by Alex Bruy (#3405)
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15237 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 2e01079 commit 498c8ee

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/gui/symbology-ng/qgsstylev2managerdialog.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <QFile>
1616
#include <QFileDialog>
1717
#include <QInputDialog>
18+
#include <QMessageBox>
1819
#include <QStandardItemModel>
1920

2021
#include "qgsapplication.h"
@@ -239,6 +240,20 @@ bool QgsStyleV2ManagerDialog::addSymbol()
239240
return false;
240241
}
241242

243+
// check if there is no symbol with same name
244+
if ( mStyle->symbolNames().contains( name ) )
245+
{
246+
int res = QMessageBox::warning( this, tr( "Save symbol" ),
247+
tr( "Symbol with name '%1' already exists. Overwrite?" )
248+
.arg( name ),
249+
QMessageBox::Yes | QMessageBox::No );
250+
if ( res != QMessageBox::Yes )
251+
{
252+
delete symbol;
253+
return false;
254+
}
255+
}
256+
242257
// add new symbol to style and re-populate the list
243258
mStyle->addSymbol( name, symbol );
244259
mModified = true;

src/gui/symbology-ng/qgssymbolv2selectordialog.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <QPainter>
1515
#include <QStandardItemModel>
1616
#include <QInputDialog>
17+
#include <QMessageBox>
1718
#include <QKeyEvent>
1819
#include <QMenu>
1920

@@ -222,6 +223,19 @@ void QgsSymbolV2SelectorDialog::addSymbolToStyle()
222223
if ( !ok || name.isEmpty() )
223224
return;
224225

226+
// check if there is no symbol with same name
227+
if ( mStyle->symbolNames().contains( name ) )
228+
{
229+
int res = QMessageBox::warning( this, tr( "Save symbol" ),
230+
tr( "Symbol with name '%1' already exists. Overwrite?" )
231+
.arg( name ),
232+
QMessageBox::Yes | QMessageBox::No );
233+
if ( res != QMessageBox::Yes )
234+
{
235+
return;
236+
}
237+
}
238+
225239
// add new symbol to style and re-populate the list
226240
mStyle->addSymbol( name, mSymbol->clone() );
227241

0 commit comments

Comments
 (0)