Skip to content
Permalink
Browse files

Don't allow creation of visibility presets with existing name

  • Loading branch information
nyalldawson committed Aug 20, 2015
1 parent ca04bb6 commit d7c653c5aca43a253b4a17891891e792c3713f2d
Showing with 9 additions and 4 deletions.
  1. +9 −4 src/app/qgsvisibilitypresets.cpp
@@ -27,6 +27,7 @@
#include "qgsrendererv2.h"
#include "qgsvectorlayer.h"
#include "qgisapp.h"
#include "qgsnewnamedialog.h"

#include <QInputDialog>

@@ -152,12 +153,16 @@ QMenu* QgsVisibilityPresets::menu()

void QgsVisibilityPresets::addPreset()
{
bool ok;
QString name = QInputDialog::getText( 0, tr( "Visibility Presets" ), tr( "Name of the new preset" ), QLineEdit::Normal, QString(), &ok );
if ( !ok && name.isEmpty() )
QStringList existingNames = QgsProject::instance()->visibilityPresetCollection()->presets();
QgsNewNameDialog dlg( tr( "preset" ) , tr( "Preset" ), QStringList(), existingNames, QRegExp(), Qt::CaseInsensitive, mMenu );
dlg.setWindowTitle( tr( "Visibility Presets" ) );
dlg.setHintString( tr( "Name of the new preset" ) );
dlg.setOverwriteEnabled( false );
dlg.setConflictingNameWarning( tr( "A preset with this name already exists" ) );
if ( dlg.exec() != QDialog::Accepted || dlg.name().isEmpty() )
return;

addPreset( name );
addPreset( dlg.name() );
}


3 comments on commit d7c653c

@nirvn

This comment has been minimized.

Copy link
Contributor

@nirvn nirvn replied Aug 20, 2015

Wasn't that the way you'd be able to update existing presets?

@nyalldawson

This comment has been minimized.

Copy link
Collaborator Author

@nyalldawson nyalldawson replied Aug 20, 2015

Yes, and it wasn't very friendly! That's what 0df7102 is for

@nirvn

This comment has been minimized.

Copy link
Contributor

@nirvn nirvn replied Aug 20, 2015

👍

Please sign in to comment.
You can’t perform that action at this time.