1
0
mirror of https://github.com/qgis/QGIS.git synced 2025-04-25 00:03:06 -04:00

use meaningful names for new symbols and ramps

This commit is contained in:
Etienne Tourigny 2012-08-28 13:31:18 -03:00
parent fcf1dd868f
commit 2a3d09c90e

@ -233,6 +233,7 @@ void QgsStyleV2ManagerDialog::populateColorRamps( QStringList colorRamps, bool c
item->setIcon( icon ); item->setIcon( icon );
item->setData( name ); // used to find out original name when user edited the name item->setData( name ); // used to find out original name when user edited the name
item->setCheckable( check ); item->setCheckable( check );
item->setToolTip( name );
model->appendRow( item ); model->appendRow( item );
delete ramp; delete ramp;
} }
@ -285,16 +286,20 @@ bool QgsStyleV2ManagerDialog::addSymbol()
{ {
// create new symbol with current type // create new symbol with current type
QgsSymbolV2* symbol; QgsSymbolV2* symbol;
QString name = tr( "new symbol" );
switch ( currentItemType() ) switch ( currentItemType() )
{ {
case QgsSymbolV2::Marker: case QgsSymbolV2::Marker:
symbol = new QgsMarkerSymbolV2(); symbol = new QgsMarkerSymbolV2();
name = tr( "new marker" );
break; break;
case QgsSymbolV2::Line: case QgsSymbolV2::Line:
symbol = new QgsLineSymbolV2(); symbol = new QgsLineSymbolV2();
name = tr( "new line" );
break; break;
case QgsSymbolV2::Fill: case QgsSymbolV2::Fill:
symbol = new QgsFillSymbolV2(); symbol = new QgsFillSymbolV2();
name = tr( "new fill symbol" );
break; break;
default: default:
Q_ASSERT( 0 && "unknown symbol type" ); Q_ASSERT( 0 && "unknown symbol type" );
@ -309,18 +314,15 @@ bool QgsStyleV2ManagerDialog::addSymbol()
return false; return false;
} }
// get name // get unique name
bool nameInvalid = true; bool nameInvalid = true;
QString name;
while ( nameInvalid ) while ( nameInvalid )
{ {
bool ok; bool ok;
name = QInputDialog::getText( this, tr( "Symbol Name" ), name = QInputDialog::getText( this, tr( "Symbol Name" ),
tr( "Please enter a name for new symbol:" ), tr( "Please enter a name for new symbol:" ),
QLineEdit::Normal, QLineEdit::Normal, name, &ok );
tr( "new symbol" ),
&ok );
if ( !ok ) if ( !ok )
{ {
delete symbol; delete symbol;
@ -370,6 +372,8 @@ QString QgsStyleV2ManagerDialog::addColorRampStatic( QWidget* parent, QgsStyleV2
if ( !ok || rampType.isEmpty() ) if ( !ok || rampType.isEmpty() )
return QString(); return QString();
QString name = tr( "new ramp" );
QgsVectorColorRampV2 *ramp = NULL; QgsVectorColorRampV2 *ramp = NULL;
if ( rampType == tr( "Gradient" ) ) if ( rampType == tr( "Gradient" ) )
{ {
@ -381,6 +385,7 @@ QString QgsStyleV2ManagerDialog::addColorRampStatic( QWidget* parent, QgsStyleV2
return QString(); return QString();
} }
ramp = gradRamp; ramp = gradRamp;
name = tr( "new gradient ramp" );
} }
else if ( rampType == tr( "Random" ) ) else if ( rampType == tr( "Random" ) )
{ {
@ -392,6 +397,7 @@ QString QgsStyleV2ManagerDialog::addColorRampStatic( QWidget* parent, QgsStyleV2
return QString(); return QString();
} }
ramp = randRamp; ramp = randRamp;
name = tr( "new random ramp" );
} }
else if ( rampType == tr( "ColorBrewer" ) ) else if ( rampType == tr( "ColorBrewer" ) )
{ {
@ -403,6 +409,7 @@ QString QgsStyleV2ManagerDialog::addColorRampStatic( QWidget* parent, QgsStyleV2
return QString(); return QString();
} }
ramp = brewerRamp; ramp = brewerRamp;
name = brewerRamp->schemeName() + QString::number( brewerRamp->colors() );
} }
else if ( rampType == tr( "cpt-city" ) ) else if ( rampType == tr( "cpt-city" ) )
{ {
@ -411,10 +418,11 @@ QString QgsStyleV2ManagerDialog::addColorRampStatic( QWidget* parent, QgsStyleV2
if ( !dlg.exec() ) if ( !dlg.exec() )
{ {
delete cptCityRamp; delete cptCityRamp;
// return QString(); return QString();
return dlg.selectedName();
} }
ramp = cptCityRamp; ramp = cptCityRamp;
// name = dlg.selectedName();
name = QFileInfo( cptCityRamp->schemeName() ).baseName() + cptCityRamp->variantName();
} }
else else
{ {
@ -424,18 +432,15 @@ QString QgsStyleV2ManagerDialog::addColorRampStatic( QWidget* parent, QgsStyleV2
return QString(); return QString();
} }
// get name // get unique name
bool nameInvalid = true; bool nameInvalid = true;
QString name;
while ( nameInvalid ) while ( nameInvalid )
{ {
bool ok; bool ok;
name = QInputDialog::getText( parent, tr( "Color Ramp Name" ), name = QInputDialog::getText( parent, tr( "Color Ramp Name" ),
tr( "Please enter a name for new color ramp:" ), tr( "Please enter a name for new color ramp:" ),
QLineEdit::Normal, QLineEdit::Normal, name, &ok );
tr( "new ramp" ),
&ok );
if ( !ok ) if ( !ok )
{ {
delete ramp; delete ramp;