Skip to content

Commit

Permalink
[StyleManager] re-use existing QAction in group action menu
Browse files Browse the repository at this point in the history
The group action menu now contains the same action the context menu contains for editing a smart group.
  • Loading branch information
SebDieBln committed Jan 6, 2016
1 parent 3b30a8c commit a9c4179
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions src/gui/symbology-ng/qgsstylev2managerdialog.cpp
Expand Up @@ -109,10 +109,9 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa

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

connect( searchBox, SIGNAL( textChanged( QString ) ), this, SLOT( filterSymbols( QString ) ) );
tagsLineEdit->installEventFilter( this );
Expand Down Expand Up @@ -935,6 +934,27 @@ void QgsStyleV2ManagerDialog::groupChanged( const QModelIndex& index )
}
if ( mGrouppingMode )
setSymbolsChecked( groupSymbols );

actnEditSmartGroup->setVisible( false );
actnAddGroup->setVisible( false );
actnRemoveGroup->setVisible( false );

if ( index.parent().isValid() && ( index.data().toString() != "Ungrouped" ) )
{
if ( index.parent().data( Qt::UserRole + 1 ).toString() == "smartgroups" )
{
actnEditSmartGroup->setVisible( true );
}
else
{
actnAddGroup->setVisible( true );
}
actnRemoveGroup->setVisible( true );
}
else if ( index.data( Qt::UserRole + 1 ) == "groups" || index.data( Qt::UserRole + 1 ) == "smartgroups" )
{
actnAddGroup->setVisible( true );
}
}

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

actnEditSmartGroup->setVisible( false );
actnAddGroup->setVisible( false );
actnRemoveGroup->setVisible( false );

if ( index.parent().isValid() && ( index.data().toString() != "Ungrouped" ) )
{
if ( index.parent().data( Qt::UserRole + 1 ).toString() == "smartgroups" )
{
actnEditSmartGroup->setVisible( true );
}
else
{
actnAddGroup->setVisible( true );
}
actnRemoveGroup->setVisible( true );
}
else if ( index.data( Qt::UserRole + 1 ) == "groups" || index.data( Qt::UserRole + 1 ) == "smartgroups" )
{
actnAddGroup->setVisible( true );
}

mGroupTreeContextMenu->popup( globalPos );
if ( index.isValid() )
mGroupTreeContextMenu->popup( globalPos );
}

void QgsStyleV2ManagerDialog::listitemsContextMenu( const QPoint& point )
Expand Down

0 comments on commit a9c4179

Please sign in to comment.