mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
[FEATURE] Hide Deselected Layers action
Allows you to quickly hide all deselected layers. This is very handy when you have a large project and want to quickly hide all except for a couple of layers
This commit is contained in:
parent
c83426e12a
commit
4f73c28c5f
@ -483,6 +483,11 @@ class QgisInterface : QObject
|
||||
virtual QAction *actionHideAllLayers() = 0;
|
||||
virtual QAction *actionShowAllLayers() = 0;
|
||||
virtual QAction *actionHideSelectedLayers() = 0;
|
||||
/**
|
||||
* Returns the Hide Deselected Layers action.
|
||||
* @note added in QGIS 3.0
|
||||
*/
|
||||
virtual QAction *actionHideDeselectedLayers() = 0;
|
||||
virtual QAction *actionShowSelectedLayers() = 0;
|
||||
|
||||
// Plugin menu actions
|
||||
|
@ -1707,6 +1707,7 @@ void QgisApp::createActions()
|
||||
connect( mActionHideAllLayers, SIGNAL( triggered() ), this, SLOT( hideAllLayers() ) );
|
||||
connect( mActionShowSelectedLayers, SIGNAL( triggered() ), this, SLOT( showSelectedLayers() ) );
|
||||
connect( mActionHideSelectedLayers, SIGNAL( triggered() ), this, SLOT( hideSelectedLayers() ) );
|
||||
connect( mActionHideDeselectedLayers, &QAction::triggered, this, &QgisApp::hideDeselectedLayers );
|
||||
|
||||
// Plugin Menu Items
|
||||
|
||||
@ -5783,6 +5784,17 @@ void QgisApp::hideSelectedLayers()
|
||||
}
|
||||
}
|
||||
|
||||
void QgisApp::hideDeselectedLayers()
|
||||
{
|
||||
QList<QgsLayerTreeLayer*> selectedLayerNodes = mLayerTreeView->selectedLayerNodes();
|
||||
|
||||
Q_FOREACH ( QgsLayerTreeLayer* nodeLayer, mLayerTreeView->layerTreeModel()->rootGroup()->findLayers() )
|
||||
{
|
||||
if ( selectedLayerNodes.contains( nodeLayer ) )
|
||||
continue;
|
||||
nodeLayer->setVisible( Qt::Unchecked );
|
||||
}
|
||||
}
|
||||
|
||||
// reimplements method from base (gui) class
|
||||
void QgisApp::showSelectedLayers()
|
||||
|
@ -411,6 +411,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
|
||||
QAction *actionHideAllLayers() { return mActionHideAllLayers; }
|
||||
QAction *actionShowAllLayers() { return mActionShowAllLayers; }
|
||||
QAction *actionHideSelectedLayers() { return mActionHideSelectedLayers; }
|
||||
QAction *actionHideDeselectedLayers() { return mActionHideDeselectedLayers; }
|
||||
QAction *actionShowSelectedLayers() { return mActionShowSelectedLayers; }
|
||||
|
||||
QAction *actionManagePlugins() { return mActionManagePlugins; }
|
||||
@ -1027,6 +1028,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
|
||||
void showAllLayers();
|
||||
//reimplements method from base (gui) class
|
||||
void hideSelectedLayers();
|
||||
//! Hides any layers which are not selected
|
||||
void hideDeselectedLayers();
|
||||
//reimplements method from base (gui) class
|
||||
void showSelectedLayers();
|
||||
//! Return pointer to the active layer
|
||||
|
@ -631,6 +631,7 @@ QAction *QgisAppInterface::actionRemoveAllFromOverview() { return qgis->actionRe
|
||||
QAction *QgisAppInterface::actionHideAllLayers() { return qgis->actionHideAllLayers(); }
|
||||
QAction *QgisAppInterface::actionShowAllLayers() { return qgis->actionShowAllLayers(); }
|
||||
QAction *QgisAppInterface::actionHideSelectedLayers() { return qgis->actionHideSelectedLayers(); }
|
||||
QAction*QgisAppInterface::actionHideDeselectedLayers() { return qgis->actionHideDeselectedLayers(); }
|
||||
QAction *QgisAppInterface::actionShowSelectedLayers() { return qgis->actionShowSelectedLayers(); }
|
||||
|
||||
//! Plugin menu actions
|
||||
|
@ -445,6 +445,7 @@ class APP_EXPORT QgisAppInterface : public QgisInterface
|
||||
virtual QAction *actionHideAllLayers() override;
|
||||
virtual QAction *actionShowAllLayers() override;
|
||||
virtual QAction *actionHideSelectedLayers() override;
|
||||
virtual QAction *actionHideDeselectedLayers() override;
|
||||
virtual QAction *actionShowSelectedLayers() override;
|
||||
|
||||
//! Plugin menu actions
|
||||
|
@ -42,6 +42,7 @@ QgsMapThemes::QgsMapThemes()
|
||||
mMenu->addAction( QgisApp::instance()->actionHideAllLayers() );
|
||||
mMenu->addAction( QgisApp::instance()->actionShowSelectedLayers() );
|
||||
mMenu->addAction( QgisApp::instance()->actionHideSelectedLayers() );
|
||||
mMenu->addAction( QgisApp::instance()->actionHideDeselectedLayers() );
|
||||
mMenu->addSeparator();
|
||||
|
||||
mReplaceMenu = new QMenu( tr( "Replace Theme" ) );
|
||||
|
@ -539,6 +539,12 @@ class GUI_EXPORT QgisInterface : public QObject
|
||||
virtual QAction *actionHideAllLayers() = 0;
|
||||
virtual QAction *actionShowAllLayers() = 0;
|
||||
virtual QAction *actionHideSelectedLayers() = 0;
|
||||
|
||||
/**
|
||||
* Returns the Hide Deselected Layers action.
|
||||
* @note added in QGIS 3.0
|
||||
*/
|
||||
virtual QAction *actionHideDeselectedLayers() = 0;
|
||||
virtual QAction *actionShowSelectedLayers() = 0;
|
||||
|
||||
// Plugin menu actions
|
||||
|
@ -118,6 +118,7 @@
|
||||
<addaction name="mActionHideAllLayers"/>
|
||||
<addaction name="mActionShowSelectedLayers"/>
|
||||
<addaction name="mActionHideSelectedLayers"/>
|
||||
<addaction name="mActionHideDeselectedLayers"/>
|
||||
<addaction name="separator"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="mLayerMenu">
|
||||
@ -2425,6 +2426,15 @@ Acts on currently active editable layer</string>
|
||||
<string>Hide Selected Layers</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="mActionHideDeselectedLayers">
|
||||
<property name="icon">
|
||||
<iconset resource="../../images/images.qrc">
|
||||
<normaloff>:/images/themes/default/mActionHideSelectedLayers.png</normaloff>:/images/themes/default/mActionHideSelectedLayers.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Hide Deselected Layers</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="mActionNewMemoryLayer">
|
||||
<property name="icon">
|
||||
<iconset resource="../../images/images.qrc">
|
||||
|
Loading…
x
Reference in New Issue
Block a user