Skip to content

Commit

Permalink
[StyleManager] use QAction::setData() for transmitting the group-id
Browse files Browse the repository at this point in the history
Determining the group-id from QAction::text() fails when multiple groups with the same name exist.
  • Loading branch information
SebDieBln committed Jan 6, 2016
1 parent 8203fa1 commit 22fb432
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/gui/symbology-ng/qgsstylev2managerdialog.cpp
Expand Up @@ -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 );
Expand All @@ -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 )
{
Expand Down

0 comments on commit 22fb432

Please sign in to comment.