Skip to content

Commit a9c4179

Browse files
committed
[StyleManager] re-use existing QAction in group action menu
The group action menu now contains the same action the context menu contains for editing a smart group.
1 parent 3b30a8c commit a9c4179

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

src/gui/symbology-ng/qgsstylev2managerdialog.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,9 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa
109109

110110
QMenu *groupMenu = new QMenu( tr( "Group actions" ), this );
111111
QAction *groupSymbols = groupMenu->addAction( tr( "Group symbols" ) );
112-
QAction *editSmartgroup = groupMenu->addAction( tr( "Edit smart group" ) );
112+
groupMenu->addAction( actnEditSmartGroup );
113113
btnManageGroups->setMenu( groupMenu );
114114
connect( groupSymbols, SIGNAL( triggered() ), this, SLOT( groupSymbolsAction() ) );
115-
connect( editSmartgroup, SIGNAL( triggered() ), this, SLOT( editSmartgroupAction() ) );
116115

117116
connect( searchBox, SIGNAL( textChanged( QString ) ), this, SLOT( filterSymbols( QString ) ) );
118117
tagsLineEdit->installEventFilter( this );
@@ -935,6 +934,27 @@ void QgsStyleV2ManagerDialog::groupChanged( const QModelIndex& index )
935934
}
936935
if ( mGrouppingMode )
937936
setSymbolsChecked( groupSymbols );
937+
938+
actnEditSmartGroup->setVisible( false );
939+
actnAddGroup->setVisible( false );
940+
actnRemoveGroup->setVisible( false );
941+
942+
if ( index.parent().isValid() && ( index.data().toString() != "Ungrouped" ) )
943+
{
944+
if ( index.parent().data( Qt::UserRole + 1 ).toString() == "smartgroups" )
945+
{
946+
actnEditSmartGroup->setVisible( true );
947+
}
948+
else
949+
{
950+
actnAddGroup->setVisible( true );
951+
}
952+
actnRemoveGroup->setVisible( true );
953+
}
954+
else if ( index.data( Qt::UserRole + 1 ) == "groups" || index.data( Qt::UserRole + 1 ) == "smartgroups" )
955+
{
956+
actnAddGroup->setVisible( true );
957+
}
938958
}
939959

940960
void QgsStyleV2ManagerDialog::addGroup()
@@ -1324,28 +1344,8 @@ void QgsStyleV2ManagerDialog::grouptreeContextMenu( const QPoint& point )
13241344
QModelIndex index = groupTree->indexAt( point );
13251345
QgsDebugMsg( "Now you clicked: " + index.data().toString() );
13261346

1327-
actnEditSmartGroup->setVisible( false );
1328-
actnAddGroup->setVisible( false );
1329-
actnRemoveGroup->setVisible( false );
1330-
1331-
if ( index.parent().isValid() && ( index.data().toString() != "Ungrouped" ) )
1332-
{
1333-
if ( index.parent().data( Qt::UserRole + 1 ).toString() == "smartgroups" )
1334-
{
1335-
actnEditSmartGroup->setVisible( true );
1336-
}
1337-
else
1338-
{
1339-
actnAddGroup->setVisible( true );
1340-
}
1341-
actnRemoveGroup->setVisible( true );
1342-
}
1343-
else if ( index.data( Qt::UserRole + 1 ) == "groups" || index.data( Qt::UserRole + 1 ) == "smartgroups" )
1344-
{
1345-
actnAddGroup->setVisible( true );
1346-
}
1347-
1348-
mGroupTreeContextMenu->popup( globalPos );
1347+
if ( index.isValid() )
1348+
mGroupTreeContextMenu->popup( globalPos );
13491349
}
13501350

13511351
void QgsStyleV2ManagerDialog::listitemsContextMenu( const QPoint& point )

0 commit comments

Comments
 (0)