@@ -328,10 +328,10 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu()
328328 for ( int row = 0 ; row < model->rowCount (); ++row )
329329 {
330330 QModelIndex index = model->index ( row, 0 );
331+ QgsMapLayer::StyleCategory category = model->data ( index, Qt::UserRole ).value <QgsMapLayer::StyleCategory>();
331332 QString name = model->data ( index, Qt::DisplayRole ).toString ();
332333 QString tooltip = model->data ( index, Qt::ToolTipRole ).toString ();
333334 QIcon icon = model->data ( index, Qt::DecorationRole ).value <QIcon>();
334- QgsMapLayer::StyleCategory category = model->index2category ( index );
335335 QAction *copyAction = new QAction ( icon, name, copyStyleMenu );
336336 copyAction->setToolTip ( tooltip );
337337 connect ( copyAction, &QAction::triggered, this , [ = ]() {app->copyStyle ( layer, category );} );
@@ -357,10 +357,10 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu()
357357 for ( int row = 0 ; row < model->rowCount (); ++row )
358358 {
359359 QModelIndex index = model->index ( row, 0 );
360+ QgsMapLayer::StyleCategory category = model->data ( index, Qt::UserRole ).value <QgsMapLayer::StyleCategory>();
360361 QString name = model->data ( index, Qt::DisplayRole ).toString ();
361362 QString tooltip = model->data ( index, Qt::ToolTipRole ).toString ();
362363 QIcon icon = model->data ( index, Qt::DecorationRole ).value <QIcon>();
363- QgsMapLayer::StyleCategory category = model->index2category ( index );
364364 QAction *copyAction = new QAction ( icon, name, pasteStyleMenu );
365365 copyAction->setToolTip ( tooltip );
366366 connect ( copyAction, &QAction::triggered, this , [ = ]() {app->copyStyle ( layer, category );} );
0 commit comments