Skip to content
Permalink
Browse files

[StyleManager] use QAction::setData() for transmitting the group-id

Determining the group-id from QAction::text() fails when multiple groups with the same name exist.
  • Loading branch information
SebDieBln committed Jan 2, 2016
1 parent 8203fa1 commit 22fb4321bc8d2d01e4d4a6a11c3450e2533354af
Showing with 7 additions and 8 deletions.
  1. +7 −8 src/gui/symbology-ng/qgsstylev2managerdialog.cpp
@@ -1327,10 +1327,13 @@ void QgsStyleV2ManagerDialog::listitemsContextMenu( const QPoint& point )
// Clear all actions and create new actions for every group
mGroupListMenu->clear();

QStringList groups = mStyle->groupNames();
Q_FOREACH ( const QString& group, groups )
QAction* a;
QList<int> groupIds = mStyle->groupIds();
Q_FOREACH ( int groupId, groupIds )
{
mGroupListMenu->addAction( new QAction( group, mGroupListMenu ) );
a = new QAction( mStyle->groupName( groupId ), mGroupListMenu );
a->setData( groupId );
mGroupListMenu->addAction( a );
}

QAction* selectedItem = mGroupMenu->exec( globalPos );
@@ -1343,11 +1346,7 @@ void QgsStyleV2ManagerDialog::listitemsContextMenu( const QPoint& point )
QgsDebugMsg( "unknow entity type" );
return;
}
int groupId = 0;
if ( selectedItem->text() != tr( "Un-group" ) )
{
groupId = mStyle->groupId( selectedItem->text() );
}
int groupId = selectedItem->data().toInt();
QModelIndexList indexes = listItems->selectionModel()->selectedIndexes();
Q_FOREACH ( const QModelIndex& index, indexes )
{

0 comments on commit 22fb432

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