Skip to content

Commit

Permalink
use meaningful names for new symbols and ramps
Browse files Browse the repository at this point in the history
  • Loading branch information
etiennesky committed Aug 28, 2012
1 parent fcf1dd8 commit 2a3d09c
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions src/gui/symbology-ng/qgsstylev2managerdialog.cpp
Expand Up @@ -233,6 +233,7 @@ void QgsStyleV2ManagerDialog::populateColorRamps( QStringList colorRamps, bool c
item->setIcon( icon );
item->setData( name ); // used to find out original name when user edited the name
item->setCheckable( check );
item->setToolTip( name );
model->appendRow( item );
delete ramp;
}
Expand Down Expand Up @@ -285,16 +286,20 @@ bool QgsStyleV2ManagerDialog::addSymbol()
{
// create new symbol with current type
QgsSymbolV2* symbol;
QString name = tr( "new symbol" );
switch ( currentItemType() )
{
case QgsSymbolV2::Marker:
symbol = new QgsMarkerSymbolV2();
name = tr( "new marker" );
break;
case QgsSymbolV2::Line:
symbol = new QgsLineSymbolV2();
name = tr( "new line" );
break;
case QgsSymbolV2::Fill:
symbol = new QgsFillSymbolV2();
name = tr( "new fill symbol" );
break;
default:
Q_ASSERT( 0 && "unknown symbol type" );
Expand All @@ -309,18 +314,15 @@ bool QgsStyleV2ManagerDialog::addSymbol()
return false;
}

// get name
// get unique name
bool nameInvalid = true;
QString name;

while ( nameInvalid )
{
bool ok;
name = QInputDialog::getText( this, tr( "Symbol Name" ),
tr( "Please enter a name for new symbol:" ),
QLineEdit::Normal,
tr( "new symbol" ),
&ok );
QLineEdit::Normal, name, &ok );
if ( !ok )
{
delete symbol;
Expand Down Expand Up @@ -370,6 +372,8 @@ QString QgsStyleV2ManagerDialog::addColorRampStatic( QWidget* parent, QgsStyleV2
if ( !ok || rampType.isEmpty() )
return QString();

QString name = tr( "new ramp" );

QgsVectorColorRampV2 *ramp = NULL;
if ( rampType == tr( "Gradient" ) )
{
Expand All @@ -381,6 +385,7 @@ QString QgsStyleV2ManagerDialog::addColorRampStatic( QWidget* parent, QgsStyleV2
return QString();
}
ramp = gradRamp;
name = tr( "new gradient ramp" );
}
else if ( rampType == tr( "Random" ) )
{
Expand All @@ -392,6 +397,7 @@ QString QgsStyleV2ManagerDialog::addColorRampStatic( QWidget* parent, QgsStyleV2
return QString();
}
ramp = randRamp;
name = tr( "new random ramp" );
}
else if ( rampType == tr( "ColorBrewer" ) )
{
Expand All @@ -403,6 +409,7 @@ QString QgsStyleV2ManagerDialog::addColorRampStatic( QWidget* parent, QgsStyleV2
return QString();
}
ramp = brewerRamp;
name = brewerRamp->schemeName() + QString::number( brewerRamp->colors() );
}
else if ( rampType == tr( "cpt-city" ) )
{
Expand All @@ -411,10 +418,11 @@ QString QgsStyleV2ManagerDialog::addColorRampStatic( QWidget* parent, QgsStyleV2
if ( !dlg.exec() )
{
delete cptCityRamp;
// return QString();
return dlg.selectedName();
return QString();
}
ramp = cptCityRamp;
// name = dlg.selectedName();
name = QFileInfo( cptCityRamp->schemeName() ).baseName() + cptCityRamp->variantName();
}
else
{
Expand All @@ -424,18 +432,15 @@ QString QgsStyleV2ManagerDialog::addColorRampStatic( QWidget* parent, QgsStyleV2
return QString();
}

// get name
// get unique name
bool nameInvalid = true;
QString name;

while ( nameInvalid )
{
bool ok;
name = QInputDialog::getText( parent, tr( "Color Ramp Name" ),
tr( "Please enter a name for new color ramp:" ),
QLineEdit::Normal,
tr( "new ramp" ),
&ok );
QLineEdit::Normal, name, &ok );
if ( !ok )
{
delete ramp;
Expand Down

0 comments on commit 2a3d09c

Please sign in to comment.