Skip to content

Commit 22fb432

Browse files
committed
[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.
1 parent 8203fa1 commit 22fb432

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/gui/symbology-ng/qgsstylev2managerdialog.cpp

+7-8
Original file line numberDiff line numberDiff line change
@@ -1327,10 +1327,13 @@ void QgsStyleV2ManagerDialog::listitemsContextMenu( const QPoint& point )
13271327
// Clear all actions and create new actions for every group
13281328
mGroupListMenu->clear();
13291329

1330-
QStringList groups = mStyle->groupNames();
1331-
Q_FOREACH ( const QString& group, groups )
1330+
QAction* a;
1331+
QList<int> groupIds = mStyle->groupIds();
1332+
Q_FOREACH ( int groupId, groupIds )
13321333
{
1333-
mGroupListMenu->addAction( new QAction( group, mGroupListMenu ) );
1334+
a = new QAction( mStyle->groupName( groupId ), mGroupListMenu );
1335+
a->setData( groupId );
1336+
mGroupListMenu->addAction( a );
13341337
}
13351338

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

0 commit comments

Comments
 (0)