Skip to content

Commit fcf1dd8

Browse files
committedAug 28, 2012
Merge branch 'style-docs' of https://github.com/tecoholic/Quantum-GIS
2 parents 9226e84 + 2900646 commit fcf1dd8

File tree

1 file changed

+37
-6
lines changed

1 file changed

+37
-6
lines changed
 

‎src/gui/symbology-ng/qgsstylev2managerdialog.cpp

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -425,18 +425,49 @@ QString QgsStyleV2ManagerDialog::addColorRampStatic( QWidget* parent, QgsStyleV2
425425
}
426426

427427
// get name
428-
QString name = QInputDialog::getText( parent, tr( "Color ramp name" ),
429-
tr( "Please enter name for new color ramp:" ), QLineEdit::Normal, tr( "new color ramp" ), &ok );
430-
if ( !ok || name.isEmpty() )
428+
bool nameInvalid = true;
429+
QString name;
430+
431+
while ( nameInvalid )
431432
{
432-
if ( ramp )
433+
bool ok;
434+
name = QInputDialog::getText( parent, tr( "Color Ramp Name" ),
435+
tr( "Please enter a name for new color ramp:" ),
436+
QLineEdit::Normal,
437+
tr( "new ramp" ),
438+
&ok );
439+
if ( !ok )
440+
{
433441
delete ramp;
434-
return QString();
442+
return QString();
443+
}
444+
// validate name
445+
if ( name.isEmpty() )
446+
{
447+
QMessageBox::warning( parent, tr( "Save Color Ramp" ),
448+
tr( "Cannot save color ramp without name. Enter a name." ) );
449+
}
450+
else if ( style->colorRampNames().contains( name ) )
451+
{
452+
int res = QMessageBox::warning( parent, tr( "Save color ramp" ),
453+
tr( "Color ramp with name '%1' already exists. Overwrite?" )
454+
.arg( name ),
455+
QMessageBox::Yes | QMessageBox::No );
456+
if ( res == QMessageBox::Yes )
457+
{
458+
nameInvalid = false;
459+
}
460+
}
461+
else
462+
{
463+
// valid name
464+
nameInvalid = false;
465+
}
435466
}
436467

437468
// add new symbol to style and re-populate the list
438469
style->addColorRamp( name, ramp, true );
439-
// TODO groups and tags
470+
// TODO groups and tags, using saveColorRamp
440471
return name;
441472
}
442473

0 commit comments

Comments
 (0)
Please sign in to comment.