@@ -233,6 +233,7 @@ void QgsStyleV2ManagerDialog::populateColorRamps( QStringList colorRamps, bool c
233
233
item->setIcon ( icon );
234
234
item->setData ( name ); // used to find out original name when user edited the name
235
235
item->setCheckable ( check );
236
+ item->setToolTip ( name );
236
237
model->appendRow ( item );
237
238
delete ramp;
238
239
}
@@ -285,16 +286,20 @@ bool QgsStyleV2ManagerDialog::addSymbol()
285
286
{
286
287
// create new symbol with current type
287
288
QgsSymbolV2* symbol;
289
+ QString name = tr ( " new symbol" );
288
290
switch ( currentItemType () )
289
291
{
290
292
case QgsSymbolV2::Marker:
291
293
symbol = new QgsMarkerSymbolV2 ();
294
+ name = tr ( " new marker" );
292
295
break ;
293
296
case QgsSymbolV2::Line:
294
297
symbol = new QgsLineSymbolV2 ();
298
+ name = tr ( " new line" );
295
299
break ;
296
300
case QgsSymbolV2::Fill:
297
301
symbol = new QgsFillSymbolV2 ();
302
+ name = tr ( " new fill symbol" );
298
303
break ;
299
304
default :
300
305
Q_ASSERT ( 0 && " unknown symbol type" );
@@ -309,18 +314,15 @@ bool QgsStyleV2ManagerDialog::addSymbol()
309
314
return false ;
310
315
}
311
316
312
- // get name
317
+ // get unique name
313
318
bool nameInvalid = true ;
314
- QString name;
315
319
316
320
while ( nameInvalid )
317
321
{
318
322
bool ok;
319
323
name = QInputDialog::getText ( this , tr ( " Symbol Name" ),
320
324
tr ( " Please enter a name for new symbol:" ),
321
- QLineEdit::Normal,
322
- tr ( " new symbol" ),
323
- &ok );
325
+ QLineEdit::Normal, name, &ok );
324
326
if ( !ok )
325
327
{
326
328
delete symbol;
@@ -370,6 +372,8 @@ QString QgsStyleV2ManagerDialog::addColorRampStatic( QWidget* parent, QgsStyleV2
370
372
if ( !ok || rampType.isEmpty () )
371
373
return QString ();
372
374
375
+ QString name = tr ( " new ramp" );
376
+
373
377
QgsVectorColorRampV2 *ramp = NULL ;
374
378
if ( rampType == tr ( " Gradient" ) )
375
379
{
@@ -381,6 +385,7 @@ QString QgsStyleV2ManagerDialog::addColorRampStatic( QWidget* parent, QgsStyleV2
381
385
return QString ();
382
386
}
383
387
ramp = gradRamp;
388
+ name = tr ( " new gradient ramp" );
384
389
}
385
390
else if ( rampType == tr ( " Random" ) )
386
391
{
@@ -392,6 +397,7 @@ QString QgsStyleV2ManagerDialog::addColorRampStatic( QWidget* parent, QgsStyleV2
392
397
return QString ();
393
398
}
394
399
ramp = randRamp;
400
+ name = tr ( " new random ramp" );
395
401
}
396
402
else if ( rampType == tr ( " ColorBrewer" ) )
397
403
{
@@ -403,6 +409,7 @@ QString QgsStyleV2ManagerDialog::addColorRampStatic( QWidget* parent, QgsStyleV2
403
409
return QString ();
404
410
}
405
411
ramp = brewerRamp;
412
+ name = brewerRamp->schemeName () + QString::number ( brewerRamp->colors () );
406
413
}
407
414
else if ( rampType == tr ( " cpt-city" ) )
408
415
{
@@ -411,10 +418,11 @@ QString QgsStyleV2ManagerDialog::addColorRampStatic( QWidget* parent, QgsStyleV2
411
418
if ( !dlg.exec () )
412
419
{
413
420
delete cptCityRamp;
414
- // return QString();
415
- return dlg.selectedName ();
421
+ return QString ();
416
422
}
417
423
ramp = cptCityRamp;
424
+ // name = dlg.selectedName();
425
+ name = QFileInfo ( cptCityRamp->schemeName () ).baseName () + cptCityRamp->variantName ();
418
426
}
419
427
else
420
428
{
@@ -424,18 +432,15 @@ QString QgsStyleV2ManagerDialog::addColorRampStatic( QWidget* parent, QgsStyleV2
424
432
return QString ();
425
433
}
426
434
427
- // get name
435
+ // get unique name
428
436
bool nameInvalid = true ;
429
- QString name;
430
437
431
438
while ( nameInvalid )
432
439
{
433
440
bool ok;
434
441
name = QInputDialog::getText ( parent, tr ( " Color Ramp Name" ),
435
442
tr ( " Please enter a name for new color ramp:" ),
436
- QLineEdit::Normal,
437
- tr ( " new ramp" ),
438
- &ok );
443
+ QLineEdit::Normal, name, &ok );
439
444
if ( !ok )
440
445
{
441
446
delete ramp;
0 commit comments