Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Don't allow creation of visibility presets with existing name
  • Loading branch information
nyalldawson committed Aug 20, 2015
1 parent ca04bb6 commit d7c653c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/app/qgsvisibilitypresets.cpp
Expand Up @@ -27,6 +27,7 @@
#include "qgsrendererv2.h"
#include "qgsvectorlayer.h"
#include "qgisapp.h"
#include "qgsnewnamedialog.h"

#include <QInputDialog>

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


Expand Down

3 comments on commit d7c653c

@nirvn
Copy link
Contributor

@nirvn nirvn commented on d7c653c Aug 20, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@nyalldawson
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@nirvn
Copy link
Contributor

@nirvn nirvn commented on d7c653c Aug 20, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please sign in to comment.