mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
[StyleManager] change context-menu handling to signal/slot mechanism
Both context-menus affected: Group-Tree and Item-List
This commit is contained in:
parent
e6214b6fed
commit
3b30a8c630
@ -66,6 +66,7 @@ class QgsStyleV2ManagerDialog : QDialog
|
||||
|
||||
protected slots:
|
||||
bool addColorRamp( QAction* action );
|
||||
void groupSelectedSymbols();
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -114,9 +114,6 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa
|
||||
connect( groupSymbols, SIGNAL( triggered() ), this, SLOT( groupSymbolsAction() ) );
|
||||
connect( editSmartgroup, SIGNAL( triggered() ), this, SLOT( editSmartgroupAction() ) );
|
||||
|
||||
connect( btnAddGroup, SIGNAL( clicked() ), this, SLOT( addGroup() ) );
|
||||
connect( btnRemoveGroup, SIGNAL( clicked() ), this, SLOT( removeGroup() ) );
|
||||
|
||||
connect( searchBox, SIGNAL( textChanged( QString ) ), this, SLOT( filterSymbols( QString ) ) );
|
||||
tagsLineEdit->installEventFilter( this );
|
||||
|
||||
@ -147,6 +144,7 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa
|
||||
mGroupListMenu->setEnabled( false );
|
||||
mGroupMenu->addMenu( mGroupListMenu );
|
||||
actnUngroup->setData( 0 );
|
||||
connect( actnUngroup, SIGNAL( triggered( bool ) ), this, SLOT( groupSelectedSymbols() ) );
|
||||
mGroupMenu->addAction( actnUngroup );
|
||||
mGroupMenu->addSeparator()->setParent( this );
|
||||
mGroupMenu->addAction( actnRemoveItem );
|
||||
@ -155,6 +153,15 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa
|
||||
mGroupMenu->addAction( actnExportAsPNG );
|
||||
mGroupMenu->addAction( actnExportAsSVG );
|
||||
|
||||
// Context menu for the group tree
|
||||
mGroupTreeContextMenu = new QMenu( this );
|
||||
connect( actnEditSmartGroup, SIGNAL( triggered( bool ) ), this, SLOT( editSmartgroupAction() ) );
|
||||
mGroupTreeContextMenu->addAction( actnEditSmartGroup );
|
||||
connect( actnAddGroup, SIGNAL( triggered( bool ) ), this, SLOT( addGroup() ) );
|
||||
mGroupTreeContextMenu->addAction( actnAddGroup );
|
||||
connect( actnRemoveGroup, SIGNAL( triggered( bool ) ), this, SLOT( removeGroup() ) );
|
||||
mGroupTreeContextMenu->addAction( actnRemoveGroup );
|
||||
|
||||
on_tabItemType_currentChanged( 0 );
|
||||
}
|
||||
|
||||
@ -1317,37 +1324,28 @@ void QgsStyleV2ManagerDialog::grouptreeContextMenu( const QPoint& point )
|
||||
QModelIndex index = groupTree->indexAt( point );
|
||||
QgsDebugMsg( "Now you clicked: " + index.data().toString() );
|
||||
|
||||
QMenu groupMenu;
|
||||
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" )
|
||||
{
|
||||
groupMenu.addAction( tr( "Edit smart group" ) );
|
||||
actnEditSmartGroup->setVisible( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
groupMenu.addAction( tr( "Add group" ) );
|
||||
actnAddGroup->setVisible( true );
|
||||
}
|
||||
groupMenu.addAction( tr( "Remove group" ) );
|
||||
actnRemoveGroup->setVisible( true );
|
||||
}
|
||||
else if ( index.data( Qt::UserRole + 1 ) == "groups" || index.data( Qt::UserRole + 1 ) == "smartgroups" )
|
||||
{
|
||||
groupMenu.addAction( tr( "Add group" ) );
|
||||
actnAddGroup->setVisible( true );
|
||||
}
|
||||
|
||||
|
||||
QAction* selectedItem = groupMenu.exec( globalPos );
|
||||
|
||||
if ( selectedItem )
|
||||
{
|
||||
if ( selectedItem->text() == tr( "Add group" ) )
|
||||
addGroup();
|
||||
else if ( selectedItem->text() == tr( "Remove group" ) )
|
||||
removeGroup();
|
||||
else if ( selectedItem->text() == tr( "Edit smart group" ) )
|
||||
editSmartgroupAction();
|
||||
}
|
||||
mGroupTreeContextMenu->popup( globalPos );
|
||||
}
|
||||
|
||||
void QgsStyleV2ManagerDialog::listitemsContextMenu( const QPoint& point )
|
||||
@ -1363,10 +1361,16 @@ void QgsStyleV2ManagerDialog::listitemsContextMenu( const QPoint& point )
|
||||
{
|
||||
a = new QAction( mStyle->groupName( groupId ), mGroupListMenu );
|
||||
a->setData( groupId );
|
||||
connect( a, SIGNAL( triggered( bool ) ), this, SLOT( groupSelectedSymbols() ) );
|
||||
mGroupListMenu->addAction( a );
|
||||
}
|
||||
|
||||
QAction* selectedItem = mGroupMenu->exec( globalPos );
|
||||
mGroupMenu->popup( globalPos );
|
||||
}
|
||||
|
||||
void QgsStyleV2ManagerDialog::groupSelectedSymbols()
|
||||
{
|
||||
QAction* selectedItem = qobject_cast<QAction*>( sender() );
|
||||
|
||||
if ( selectedItem )
|
||||
{
|
||||
|
@ -92,6 +92,7 @@ class GUI_EXPORT QgsStyleV2ManagerDialog : public QDialog, private Ui::QgsStyleV
|
||||
|
||||
protected slots:
|
||||
bool addColorRamp( QAction* action );
|
||||
void groupSelectedSymbols();
|
||||
|
||||
protected:
|
||||
|
||||
@ -156,6 +157,9 @@ class GUI_EXPORT QgsStyleV2ManagerDialog : public QDialog, private Ui::QgsStyleV
|
||||
//! Sub-menu of @c mGroupMenu, dynamically filled to show one entry for every group
|
||||
QMenu *mGroupListMenu;
|
||||
|
||||
//! Context menu for the group tree
|
||||
QMenu* mGroupTreeContextMenu;
|
||||
|
||||
//! Menu for the "Add item" toolbutton when in colorramp mode
|
||||
QMenu* mMenuBtnAddItemColorRamp;
|
||||
};
|
||||
|
@ -461,6 +461,29 @@ QMenu::item:selected { background-color: gray; } */
|
||||
<string>Ungroup</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actnEditSmartGroup">
|
||||
<property name="text">
|
||||
<string>Edit smart group...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actnAddGroup">
|
||||
<property name="icon">
|
||||
<iconset resource="../../images/images.qrc">
|
||||
<normaloff>:/images/themes/default/symbologyAdd.png</normaloff>:/images/themes/default/symbologyAdd.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add group</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actnRemoveGroup">
|
||||
<property name="icon">
|
||||
<iconset resource="../../images/images.qrc">
|
||||
<normaloff>:/images/themes/default/symbologyRemove.png</normaloff>:/images/themes/default/symbologyRemove.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove group</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actnExportAsPNG">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
@ -533,5 +556,37 @@ QMenu::item:selected { background-color: gray; } */
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>btnAddGroup</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>actnAddGroup</receiver>
|
||||
<slot>trigger()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>46</x>
|
||||
<y>362</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>-1</x>
|
||||
<y>-1</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>btnRemoveGroup</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>actnRemoveGroup</receiver>
|
||||
<slot>trigger()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>133</x>
|
||||
<y>362</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>-1</x>
|
||||
<y>-1</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
|
Loading…
x
Reference in New Issue
Block a user