Skip to content
Permalink
Browse files

Restore API for addSymbolToStyle()

  • Loading branch information
NathanW2 committed May 6, 2014
1 parent 4efa70d commit 4bac9ce121815442f7075ff7bbb2ad2c5dcdf86e
@@ -12,6 +12,7 @@ class QgsSymbolsListWidget : QWidget
void setMarkerAngle( double angle );
void setMarkerSize( double size );
void setLineWidth( double width );
void addSymbolToStyle();
void symbolAddedToStyle( QString name, QgsSymbolV2* symbol );
void on_mSymbolUnitComboBox_currentIndexChanged( const QString & text );
void on_mTransparencySlider_valueChanged( int value );
@@ -208,6 +208,35 @@ void QgsSymbolsListWidget::symbolAddedToStyle( QString name, QgsSymbolV2* symbol
populateSymbolView();
}

void QgsSymbolsListWidget::addSymbolToStyle()
{
bool ok;
QString name = QInputDialog::getText( this, tr( "Symbol name" ),
tr( "Please enter name for the symbol:" ) , QLineEdit::Normal, tr( "New symbol" ), &ok );
if ( !ok || name.isEmpty() )
return;

// check if there is no symbol with same name
if ( mStyle->symbolNames().contains( name ) )
{
int res = QMessageBox::warning( this, tr( "Save symbol" ),
tr( "Symbol with name '%1' already exists. Overwrite?" )
.arg( name ),
QMessageBox::Yes | QMessageBox::No );
if ( res != QMessageBox::Yes )
{
return;
}
}

// add new symbol to style and re-populate the list
mStyle->addSymbol( name, mSymbol->clone() );

// make sure the symbol is stored
mStyle->saveSymbol( name, mSymbol->clone(), 0, QStringList() );
populateSymbolView();
}

void QgsSymbolsListWidget::on_mSymbolUnitComboBox_currentIndexChanged( const QString & text )
{
Q_UNUSED( text );
@@ -38,6 +38,7 @@ class GUI_EXPORT QgsSymbolsListWidget : public QWidget, private Ui::SymbolsListW
void setMarkerAngle( double angle );
void setMarkerSize( double size );
void setLineWidth( double width );
void addSymbolToStyle();
void symbolAddedToStyle( QString name, QgsSymbolV2* symbol );
void on_mSymbolUnitComboBox_currentIndexChanged( const QString & text );
void on_mTransparencySlider_valueChanged( int value );

0 comments on commit 4bac9ce

Please sign in to comment.
You can’t perform that action at this time.