File tree 2 files changed +29
-0
lines changed
2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change 15
15
#include < QFile>
16
16
#include < QFileDialog>
17
17
#include < QInputDialog>
18
+ #include < QMessageBox>
18
19
#include < QStandardItemModel>
19
20
20
21
#include " qgsapplication.h"
@@ -239,6 +240,20 @@ bool QgsStyleV2ManagerDialog::addSymbol()
239
240
return false ;
240
241
}
241
242
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
+
242
257
// add new symbol to style and re-populate the list
243
258
mStyle ->addSymbol ( name, symbol );
244
259
mModified = true ;
Original file line number Diff line number Diff line change 14
14
#include < QPainter>
15
15
#include < QStandardItemModel>
16
16
#include < QInputDialog>
17
+ #include < QMessageBox>
17
18
#include < QKeyEvent>
18
19
#include < QMenu>
19
20
@@ -222,6 +223,19 @@ void QgsSymbolV2SelectorDialog::addSymbolToStyle()
222
223
if ( !ok || name.isEmpty () )
223
224
return ;
224
225
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
+
225
239
// add new symbol to style and re-populate the list
226
240
mStyle ->addSymbol ( name, mSymbol ->clone () );
227
241
You can’t perform that action at this time.
0 commit comments