Skip to content

Commit 2a3d09c

Browse files
committedAug 28, 2012
use meaningful names for new symbols and ramps
1 parent fcf1dd8 commit 2a3d09c

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed
 

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

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ void QgsStyleV2ManagerDialog::populateColorRamps( QStringList colorRamps, bool c
233233
item->setIcon( icon );
234234
item->setData( name ); // used to find out original name when user edited the name
235235
item->setCheckable( check );
236+
item->setToolTip( name );
236237
model->appendRow( item );
237238
delete ramp;
238239
}
@@ -285,16 +286,20 @@ bool QgsStyleV2ManagerDialog::addSymbol()
285286
{
286287
// create new symbol with current type
287288
QgsSymbolV2* symbol;
289+
QString name = tr( "new symbol" );
288290
switch ( currentItemType() )
289291
{
290292
case QgsSymbolV2::Marker:
291293
symbol = new QgsMarkerSymbolV2();
294+
name = tr( "new marker" );
292295
break;
293296
case QgsSymbolV2::Line:
294297
symbol = new QgsLineSymbolV2();
298+
name = tr( "new line" );
295299
break;
296300
case QgsSymbolV2::Fill:
297301
symbol = new QgsFillSymbolV2();
302+
name = tr( "new fill symbol" );
298303
break;
299304
default:
300305
Q_ASSERT( 0 && "unknown symbol type" );
@@ -309,18 +314,15 @@ bool QgsStyleV2ManagerDialog::addSymbol()
309314
return false;
310315
}
311316

312-
// get name
317+
// get unique name
313318
bool nameInvalid = true;
314-
QString name;
315319

316320
while ( nameInvalid )
317321
{
318322
bool ok;
319323
name = QInputDialog::getText( this, tr( "Symbol Name" ),
320324
tr( "Please enter a name for new symbol:" ),
321-
QLineEdit::Normal,
322-
tr( "new symbol" ),
323-
&ok );
325+
QLineEdit::Normal, name, &ok );
324326
if ( !ok )
325327
{
326328
delete symbol;
@@ -370,6 +372,8 @@ QString QgsStyleV2ManagerDialog::addColorRampStatic( QWidget* parent, QgsStyleV2
370372
if ( !ok || rampType.isEmpty() )
371373
return QString();
372374

375+
QString name = tr( "new ramp" );
376+
373377
QgsVectorColorRampV2 *ramp = NULL;
374378
if ( rampType == tr( "Gradient" ) )
375379
{
@@ -381,6 +385,7 @@ QString QgsStyleV2ManagerDialog::addColorRampStatic( QWidget* parent, QgsStyleV2
381385
return QString();
382386
}
383387
ramp = gradRamp;
388+
name = tr( "new gradient ramp" );
384389
}
385390
else if ( rampType == tr( "Random" ) )
386391
{
@@ -392,6 +397,7 @@ QString QgsStyleV2ManagerDialog::addColorRampStatic( QWidget* parent, QgsStyleV2
392397
return QString();
393398
}
394399
ramp = randRamp;
400+
name = tr( "new random ramp" );
395401
}
396402
else if ( rampType == tr( "ColorBrewer" ) )
397403
{
@@ -403,6 +409,7 @@ QString QgsStyleV2ManagerDialog::addColorRampStatic( QWidget* parent, QgsStyleV2
403409
return QString();
404410
}
405411
ramp = brewerRamp;
412+
name = brewerRamp->schemeName() + QString::number( brewerRamp->colors() );
406413
}
407414
else if ( rampType == tr( "cpt-city" ) )
408415
{
@@ -411,10 +418,11 @@ QString QgsStyleV2ManagerDialog::addColorRampStatic( QWidget* parent, QgsStyleV2
411418
if ( !dlg.exec() )
412419
{
413420
delete cptCityRamp;
414-
// return QString();
415-
return dlg.selectedName();
421+
return QString();
416422
}
417423
ramp = cptCityRamp;
424+
// name = dlg.selectedName();
425+
name = QFileInfo( cptCityRamp->schemeName() ).baseName() + cptCityRamp->variantName();
418426
}
419427
else
420428
{
@@ -424,18 +432,15 @@ QString QgsStyleV2ManagerDialog::addColorRampStatic( QWidget* parent, QgsStyleV2
424432
return QString();
425433
}
426434

427-
// get name
435+
// get unique name
428436
bool nameInvalid = true;
429-
QString name;
430437

431438
while ( nameInvalid )
432439
{
433440
bool ok;
434441
name = QInputDialog::getText( parent, tr( "Color Ramp Name" ),
435442
tr( "Please enter a name for new color ramp:" ),
436-
QLineEdit::Normal,
437-
tr( "new ramp" ),
438-
&ok );
443+
QLineEdit::Normal, name, &ok );
439444
if ( !ok )
440445
{
441446
delete ramp;

0 commit comments

Comments
 (0)
Please sign in to comment.