@@ -114,9 +114,6 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa
114
114
connect ( groupSymbols, SIGNAL ( triggered () ), this , SLOT ( groupSymbolsAction () ) );
115
115
connect ( editSmartgroup, SIGNAL ( triggered () ), this , SLOT ( editSmartgroupAction () ) );
116
116
117
- connect ( btnAddGroup, SIGNAL ( clicked () ), this , SLOT ( addGroup () ) );
118
- connect ( btnRemoveGroup, SIGNAL ( clicked () ), this , SLOT ( removeGroup () ) );
119
-
120
117
connect ( searchBox, SIGNAL ( textChanged ( QString ) ), this , SLOT ( filterSymbols ( QString ) ) );
121
118
tagsLineEdit->installEventFilter ( this );
122
119
@@ -147,6 +144,7 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa
147
144
mGroupListMenu ->setEnabled ( false );
148
145
mGroupMenu ->addMenu ( mGroupListMenu );
149
146
actnUngroup->setData ( 0 );
147
+ connect ( actnUngroup, SIGNAL ( triggered ( bool ) ), this , SLOT ( groupSelectedSymbols () ) );
150
148
mGroupMenu ->addAction ( actnUngroup );
151
149
mGroupMenu ->addSeparator ()->setParent ( this );
152
150
mGroupMenu ->addAction ( actnRemoveItem );
@@ -155,6 +153,15 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa
155
153
mGroupMenu ->addAction ( actnExportAsPNG );
156
154
mGroupMenu ->addAction ( actnExportAsSVG );
157
155
156
+ // Context menu for the group tree
157
+ mGroupTreeContextMenu = new QMenu ( this );
158
+ connect ( actnEditSmartGroup, SIGNAL ( triggered ( bool ) ), this , SLOT ( editSmartgroupAction () ) );
159
+ mGroupTreeContextMenu ->addAction ( actnEditSmartGroup );
160
+ connect ( actnAddGroup, SIGNAL ( triggered ( bool ) ), this , SLOT ( addGroup () ) );
161
+ mGroupTreeContextMenu ->addAction ( actnAddGroup );
162
+ connect ( actnRemoveGroup, SIGNAL ( triggered ( bool ) ), this , SLOT ( removeGroup () ) );
163
+ mGroupTreeContextMenu ->addAction ( actnRemoveGroup );
164
+
158
165
on_tabItemType_currentChanged ( 0 );
159
166
}
160
167
@@ -1317,37 +1324,28 @@ void QgsStyleV2ManagerDialog::grouptreeContextMenu( const QPoint& point )
1317
1324
QModelIndex index = groupTree->indexAt ( point );
1318
1325
QgsDebugMsg ( " Now you clicked: " + index.data ().toString () );
1319
1326
1320
- QMenu groupMenu;
1327
+ actnEditSmartGroup->setVisible ( false );
1328
+ actnAddGroup->setVisible ( false );
1329
+ actnRemoveGroup->setVisible ( false );
1321
1330
1322
1331
if ( index.parent ().isValid () && ( index.data ().toString () != " Ungrouped" ) )
1323
1332
{
1324
1333
if ( index.parent ().data ( Qt::UserRole + 1 ).toString () == " smartgroups" )
1325
1334
{
1326
- groupMenu. addAction ( tr ( " Edit smart group " ) );
1335
+ actnEditSmartGroup-> setVisible ( true );
1327
1336
}
1328
1337
else
1329
1338
{
1330
- groupMenu. addAction ( tr ( " Add group " ) );
1339
+ actnAddGroup-> setVisible ( true );
1331
1340
}
1332
- groupMenu. addAction ( tr ( " Remove group " ) );
1341
+ actnRemoveGroup-> setVisible ( true );
1333
1342
}
1334
1343
else if ( index.data ( Qt::UserRole + 1 ) == " groups" || index.data ( Qt::UserRole + 1 ) == " smartgroups" )
1335
1344
{
1336
- groupMenu. addAction ( tr ( " Add group " ) );
1345
+ actnAddGroup-> setVisible ( true );
1337
1346
}
1338
1347
1339
-
1340
- QAction* selectedItem = groupMenu.exec ( globalPos );
1341
-
1342
- if ( selectedItem )
1343
- {
1344
- if ( selectedItem->text () == tr ( " Add group" ) )
1345
- addGroup ();
1346
- else if ( selectedItem->text () == tr ( " Remove group" ) )
1347
- removeGroup ();
1348
- else if ( selectedItem->text () == tr ( " Edit smart group" ) )
1349
- editSmartgroupAction ();
1350
- }
1348
+ mGroupTreeContextMenu ->popup ( globalPos );
1351
1349
}
1352
1350
1353
1351
void QgsStyleV2ManagerDialog::listitemsContextMenu ( const QPoint& point )
@@ -1363,10 +1361,16 @@ void QgsStyleV2ManagerDialog::listitemsContextMenu( const QPoint& point )
1363
1361
{
1364
1362
a = new QAction ( mStyle ->groupName ( groupId ), mGroupListMenu );
1365
1363
a->setData ( groupId );
1364
+ connect ( a, SIGNAL ( triggered ( bool ) ), this , SLOT ( groupSelectedSymbols () ) );
1366
1365
mGroupListMenu ->addAction ( a );
1367
1366
}
1368
1367
1369
- QAction* selectedItem = mGroupMenu ->exec ( globalPos );
1368
+ mGroupMenu ->popup ( globalPos );
1369
+ }
1370
+
1371
+ void QgsStyleV2ManagerDialog::groupSelectedSymbols ()
1372
+ {
1373
+ QAction* selectedItem = qobject_cast<QAction*>( sender () );
1370
1374
1371
1375
if ( selectedItem )
1372
1376
{
0 commit comments