Skip to content

Commit

Permalink
[stylemanager dialog] fix crash when exporting PNG/SVG color ramp
Browse files Browse the repository at this point in the history
  • Loading branch information
slarosa committed Sep 16, 2015
1 parent 4897cdf commit 7a41a2d
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/gui/symbology-ng/qgsstylev2managerdialog.cpp
Expand Up @@ -185,11 +185,14 @@ void QgsStyleV2ManagerDialog::on_tabItemType_currentChanged( int )
// when in Color Ramp tab, add menu to add item button
if ( currentItemType() == 3 )
{
btnShare->menu()->actions().at( 0 )->setVisible( false );
btnShare->menu()->actions().at( 1 )->setVisible( false );

QStringList rampTypes;
rampTypes << tr( "Gradient" ) << tr( "Random" ) << tr( "ColorBrewer" );
rampTypes << tr( "cpt-city" ); // todo, only for rasters?
QMenu* menu = new QMenu( btnAddItem );
Q_FOREACH ( const QString& rampType, rampTypes )
Q_FOREACH( const QString& rampType, rampTypes )
{
menu->addAction( rampType );
}
Expand All @@ -199,6 +202,9 @@ void QgsStyleV2ManagerDialog::on_tabItemType_currentChanged( int )
}
else
{
btnShare->menu()->actions().at( 0 )->setVisible( true );
btnShare->menu()->actions().at( 1 )->setVisible( true );

if ( btnAddItem->menu() )
{
disconnect( btnAddItem->menu(), SIGNAL( triggered( QAction* ) ),
Expand Down Expand Up @@ -685,7 +691,7 @@ void QgsStyleV2ManagerDialog::removeItem()
bool QgsStyleV2ManagerDialog::removeSymbol()
{
QModelIndexList indexes = listItems->selectionModel()->selectedIndexes();
Q_FOREACH ( const QModelIndex& index, indexes )
Q_FOREACH( const QModelIndex& index, indexes )
{
QString symbolName = index.data().toString();
// delete from style and update list
Expand Down Expand Up @@ -760,7 +766,7 @@ void QgsStyleV2ManagerDialog::exportSelectedItemsImages( QString dir, QString fo
return;

QModelIndexList indexes = listItems->selectionModel()->selection().indexes();
Q_FOREACH ( const QModelIndex& index, indexes )
Q_FOREACH( const QModelIndex& index, indexes )
{
QString name = index.data().toString();
QString path = dir + "/" + name + "." + format;
Expand Down Expand Up @@ -1151,11 +1157,11 @@ void QgsStyleV2ManagerDialog::regrouped( QStandardItem *item )
void QgsStyleV2ManagerDialog::setSymbolsChecked( QStringList symbols )
{
QStandardItemModel *model = qobject_cast<QStandardItemModel*>( listItems->model() );
Q_FOREACH ( const QString& symbol, symbols )
Q_FOREACH( const QString& symbol, symbols )
{
QList<QStandardItem*> items = model->findItems( symbol );
Q_FOREACH ( QStandardItem* item, items )
item->setCheckState( Qt::Checked );
Q_FOREACH( QStandardItem* item, items )
item->setCheckState( Qt::Checked );
}
}

Expand Down Expand Up @@ -1198,27 +1204,27 @@ void QgsStyleV2ManagerDialog::tagsChanged()
return;
}
// compare old with new to find removed tags
Q_FOREACH ( const QString &tag, oldtags )
Q_FOREACH( const QString &tag, oldtags )
{
if ( !newtags.contains( tag ) )
removetags.append( tag );
}
if ( removetags.size() > 0 )
{
Q_FOREACH ( const QModelIndex& index, indexes )
Q_FOREACH( const QModelIndex& index, indexes )
{
mStyle->detagSymbol( type, index.data().toString(), removetags );
}
}
// compare new with old to find added tags
Q_FOREACH ( const QString &tag, newtags )
Q_FOREACH( const QString &tag, newtags )
{
if ( !oldtags.contains( tag ) )
addtags.append( tag );
}
if ( addtags.size() > 0 )
{
Q_FOREACH ( const QModelIndex& index, indexes )
Q_FOREACH( const QModelIndex& index, indexes )
{
mStyle->tagSymbol( type, index.data().toString(), addtags );
}
Expand Down Expand Up @@ -1339,7 +1345,7 @@ void QgsStyleV2ManagerDialog::listitemsContextMenu( const QPoint& point )
groupList->setTitle( tr( "Apply Group" ) );

QStringList groups = mStyle->groupNames();
Q_FOREACH ( const QString& group, groups )
Q_FOREACH( const QString& group, groups )
{
groupList->addAction( group );
}
Expand All @@ -1362,7 +1368,7 @@ void QgsStyleV2ManagerDialog::listitemsContextMenu( const QPoint& point )
groupId = mStyle->groupId( selectedItem->text() );
}
QModelIndexList indexes = listItems->selectionModel()->selectedIndexes();
Q_FOREACH ( const QModelIndex& index, indexes )
Q_FOREACH( const QModelIndex& index, indexes )
{
mStyle->group( type, index.data().toString(), groupId );
}
Expand Down

0 comments on commit 7a41a2d

Please sign in to comment.