mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-17 00:04:02 -04:00
New action 'Move Out of Group' that moves layer(s) out of group(s). Deprecating the action 'Move to top level'
This commit is contained in:
parent
218e306439
commit
b9b85f923d
@ -59,7 +59,19 @@ Action to zoom to selected features of a vector layer
|
||||
%End
|
||||
QAction *actionZoomToGroup( QgsMapCanvas *canvas, QObject *parent = 0 ) /Factory/;
|
||||
|
||||
QAction *actionMakeTopLevel( QObject *parent = 0 ) /Factory/;
|
||||
QAction *actionMakeTopLevel( QObject *parent = 0 ) /Factory/;
|
||||
%Docstring
|
||||
|
||||
.. deprecated:: since QGIS 3.2, use actionMoveOutOfGroup()
|
||||
%End
|
||||
|
||||
QAction *actionMoveOutOfGroup( QObject *parent = 0 ) /Factory/;
|
||||
%Docstring
|
||||
|
||||
.. seealso:: :py:func:`moveOutOfGroup`
|
||||
|
||||
.. versionadded:: 3.2
|
||||
%End
|
||||
|
||||
QAction *actionMoveToTop( QObject *parent = 0 ) /Factory/;
|
||||
%Docstring
|
||||
@ -105,7 +117,19 @@ Slot to zoom to selected features of a vector layer
|
||||
.. versionadded:: 3.2
|
||||
%End
|
||||
void zoomToGroup();
|
||||
void makeTopLevel();
|
||||
|
||||
void makeTopLevel();
|
||||
%Docstring
|
||||
|
||||
.. deprecated:: since QGIS 3.2, use moveOutOfGroup()
|
||||
%End
|
||||
|
||||
void moveOutOfGroup();
|
||||
%Docstring
|
||||
Moves selected layer(s) out of the group(s) and places this/these above the group(s)
|
||||
|
||||
.. versionadded:: 3.2
|
||||
%End
|
||||
|
||||
void moveToTop();
|
||||
%Docstring
|
||||
|
@ -178,7 +178,7 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu()
|
||||
menu->addSeparator();
|
||||
|
||||
if ( node->parent() != mView->layerTreeModel()->rootGroup() )
|
||||
menu->addAction( actions->actionMakeTopLevel( menu ) );
|
||||
menu->addAction( actions->actionMoveOutOfGroup( menu ) );
|
||||
|
||||
if ( !( mView->selectedNodes( true ).count() == 1 && idx.row() == 0 ) )
|
||||
{
|
||||
|
@ -118,7 +118,16 @@ QAction *QgsLayerTreeViewDefaultActions::actionZoomToGroup( QgsMapCanvas *canvas
|
||||
QAction *QgsLayerTreeViewDefaultActions::actionMakeTopLevel( QObject *parent )
|
||||
{
|
||||
QAction *a = new QAction( tr( "&Move to Top-level" ), parent );
|
||||
Q_NOWARN_DEPRECATED_PUSH
|
||||
connect( a, &QAction::triggered, this, &QgsLayerTreeViewDefaultActions::makeTopLevel );
|
||||
Q_NOWARN_DEPRECATED_POP
|
||||
return a;
|
||||
}
|
||||
|
||||
QAction *QgsLayerTreeViewDefaultActions::actionMoveOutOfGroup( QObject *parent )
|
||||
{
|
||||
QAction *a = new QAction( tr( "Move Out of &Group" ), parent );
|
||||
connect( a, &QAction::triggered, this, &QgsLayerTreeViewDefaultActions::moveOutOfGroup );
|
||||
return a;
|
||||
}
|
||||
|
||||
@ -385,6 +394,29 @@ void QgsLayerTreeViewDefaultActions::makeTopLevel()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void QgsLayerTreeViewDefaultActions::moveOutOfGroup()
|
||||
{
|
||||
const QList< QgsLayerTreeLayer * > selectedLayerNodes = mView->selectedLayerNodes();
|
||||
for ( QgsLayerTreeLayer *l : selectedLayerNodes )
|
||||
{
|
||||
QgsLayerTreeGroup *rootGroup = mView->layerTreeModel()->rootGroup();
|
||||
QgsLayerTreeGroup *parentGroup = qobject_cast<QgsLayerTreeGroup *>( l->parent() );
|
||||
if ( !parentGroup || parentGroup == rootGroup )
|
||||
continue;
|
||||
QgsLayerTreeGroup *tempGroup = parentGroup;
|
||||
while ( tempGroup->parent() != rootGroup )
|
||||
{
|
||||
tempGroup = qobject_cast<QgsLayerTreeGroup *>( tempGroup->parent() );
|
||||
}
|
||||
QgsLayerTreeLayer *clonedLayer = l->clone();
|
||||
int insertIdx = rootGroup->children().indexOf( tempGroup );
|
||||
rootGroup->insertChildNode( insertIdx, clonedLayer );
|
||||
parentGroup->removeChildNode( l );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void QgsLayerTreeViewDefaultActions::moveToTop()
|
||||
{
|
||||
QMap <QgsLayerTreeGroup *, int> groupInsertIdx;
|
||||
|
@ -66,7 +66,16 @@ class GUI_EXPORT QgsLayerTreeViewDefaultActions : public QObject
|
||||
QAction *actionZoomToSelection( QgsMapCanvas *canvas, QObject *parent = nullptr ) SIP_FACTORY;
|
||||
QAction *actionZoomToGroup( QgsMapCanvas *canvas, QObject *parent = nullptr ) SIP_FACTORY;
|
||||
|
||||
QAction *actionMakeTopLevel( QObject *parent = nullptr ) SIP_FACTORY;
|
||||
/**
|
||||
* \deprecated since QGIS 3.2, use actionMoveOutOfGroup()
|
||||
*/
|
||||
Q_DECL_DEPRECATED QAction *actionMakeTopLevel( QObject *parent = nullptr ) SIP_FACTORY;
|
||||
|
||||
/**
|
||||
* \see moveOutOfGroup()
|
||||
* \since QGIS 3.2
|
||||
*/
|
||||
QAction *actionMoveOutOfGroup( QObject *parent = nullptr ) SIP_FACTORY;
|
||||
|
||||
/**
|
||||
* \see moveToTop()
|
||||
@ -106,7 +115,17 @@ class GUI_EXPORT QgsLayerTreeViewDefaultActions : public QObject
|
||||
*/
|
||||
void zoomToSelection();
|
||||
void zoomToGroup();
|
||||
void makeTopLevel();
|
||||
|
||||
/**
|
||||
* \deprecated since QGIS 3.2, use moveOutOfGroup()
|
||||
*/
|
||||
Q_DECL_DEPRECATED void makeTopLevel();
|
||||
|
||||
/**
|
||||
* Moves selected layer(s) out of the group(s) and places this/these above the group(s)
|
||||
* \since QGIS 3.2
|
||||
*/
|
||||
void moveOutOfGroup();
|
||||
|
||||
/**
|
||||
* Moves selected layer(s) and/or group(s) to the top of the layer panel
|
||||
|
Loading…
x
Reference in New Issue
Block a user