Skip to content
Permalink
Browse files

Merge pull request #2318 from slarosa/fix_crash_export_ramp

[stylemanager dialog] fix crash when exporting to PNG/SVG color ramp
  • Loading branch information
NathanW2 committed Sep 16, 2015
2 parents 4897cdf + 7a41a2d commit 29fc46a3774fd129c9405f0adad47714c67c7ebe
Showing with 18 additions and 12 deletions.
  1. +18 −12 src/gui/symbology-ng/qgsstylev2managerdialog.cpp
@@ -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 );
}
@@ -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* ) ),
@@ -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
@@ -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;
@@ -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 );
}
}

@@ -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 );
}
@@ -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 );
}
@@ -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 );
}

0 comments on commit 29fc46a

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