mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
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:
parent
89f2128ab9
commit
47fa1cebb4
@ -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;
|
||||
|
@ -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() );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user