Skip to content

Commit

Permalink
Restore API for addSymbolToStyle()
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed May 6, 2014
1 parent 4efa70d commit 4bac9ce
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions python/gui/symbology-ng/qgssymbolslistwidget.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
29 changes: 29 additions & 0 deletions src/gui/symbology-ng/qgssymbolslistwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
1 change: 1 addition & 0 deletions src/gui/symbology-ng/qgssymbolslistwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit 4bac9ce

Please sign in to comment.