Skip to content

Commit

Permalink
allow setting visiblity of selected layers (fixes #10835)
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Oct 15, 2014
1 parent d1e23a6 commit c90d810
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 7 deletions.
Binary file added images/themes/default/mActionHideSelectedLayers.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/themes/default/mActionShowSelectedLayers.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions python/gui/qgisinterface.sip
Expand Up @@ -496,6 +496,8 @@ class QgisInterface : QObject
virtual QAction *actionRemoveAllFromOverview() = 0;
virtual QAction *actionHideAllLayers() = 0;
virtual QAction *actionShowAllLayers() = 0;
virtual QAction *actionHideSelectedLayers() = 0;
virtual QAction *actionShowSelectedLayers() = 0;

// Plugin menu actions
virtual QAction *actionManagePlugins() = 0;
Expand Down
33 changes: 33 additions & 0 deletions src/app/qgisapp.cpp
Expand Up @@ -1176,6 +1176,8 @@ void QgisApp::createActions()
connect( mActionRemoveAllFromOverview, SIGNAL( triggered() ), this, SLOT( removeAllFromOverview() ) );
connect( mActionShowAllLayers, SIGNAL( triggered() ), this, SLOT( showAllLayers() ) );
connect( mActionHideAllLayers, SIGNAL( triggered() ), this, SLOT( hideAllLayers() ) );
connect( mActionShowSelectedLayers, SIGNAL( triggered() ), this, SLOT( showSelectedLayers() ) );
connect( mActionHideSelectedLayers, SIGNAL( triggered() ), this, SLOT( hideSelectedLayers() ) );

// Plugin Menu Items

Expand Down Expand Up @@ -1876,6 +1878,8 @@ void QgisApp::setTheme( QString theThemeName )
mActionAddAllToOverview->setIcon( QgsApplication::getThemeIcon( "/mActionAddAllToOverview.svg" ) );
mActionHideAllLayers->setIcon( QgsApplication::getThemeIcon( "/mActionHideAllLayers.png" ) );
mActionShowAllLayers->setIcon( QgsApplication::getThemeIcon( "/mActionShowAllLayers.png" ) );
mActionHideSelectedLayers->setIcon( QgsApplication::getThemeIcon( "/mActionHideSelectedLayers.png" ) );
mActionShowSelectedLayers->setIcon( QgsApplication::getThemeIcon( "/mActionShowSelectedLayers.png" ) );
mActionRemoveAllFromOverview->setIcon( QgsApplication::getThemeIcon( "/mActionRemoveAllFromOverview.svg" ) );
mActionToggleFullScreen->setIcon( QgsApplication::getThemeIcon( "/mActionToggleFullScreen.png" ) );
mActionProjectProperties->setIcon( QgsApplication::getThemeIcon( "/mActionProjectProperties.png" ) );
Expand Down Expand Up @@ -4430,6 +4434,35 @@ void QgisApp::showAllLayers()
nodeLayer->setVisible( Qt::Checked );
}

//reimplements method from base (gui) class
void QgisApp::hideSelectedLayers()
{
QgsDebugMsg( "hiding selected layers!" );

foreach ( QgsLayerTreeNode* node, mLayerTreeView->selectedNodes() )
{
if ( QgsLayerTree::isGroup( node ) )
QgsLayerTree::toGroup( node )->setVisible( Qt::Unchecked );
else if ( QgsLayerTree::isLayer( node ) )
QgsLayerTree::toLayer( node )->setVisible( Qt::Unchecked );
}
}


// reimplements method from base (gui) class
void QgisApp::showSelectedLayers()
{
QgsDebugMsg( "show selected layers!" );

foreach ( QgsLayerTreeNode* node, mLayerTreeView->selectedNodes() )
{
if ( QgsLayerTree::isGroup( node ) )
QgsLayerTree::toGroup( node )->setVisible( Qt::Checked );
else if ( QgsLayerTree::isLayer( node ) )
QgsLayerTree::toLayer( node )->setVisible( Qt::Checked );
}
}


void QgisApp::zoomIn()
{
Expand Down
12 changes: 6 additions & 6 deletions src/app/qgisapp.h
Expand Up @@ -360,6 +360,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
QAction *actionRemoveAllFromOverview() { return mActionRemoveAllFromOverview; }
QAction *actionHideAllLayers() { return mActionHideAllLayers; }
QAction *actionShowAllLayers() { return mActionShowAllLayers; }
QAction *actionHideSelectedLayers() { return mActionHideSelectedLayers; }
QAction *actionShowSelectedLayers() { return mActionShowSelectedLayers; }

QAction *actionManagePlugins() { return mActionManagePlugins; }
QAction *actionPluginListSeparator() { return mActionPluginSeparator1; }
Expand Down Expand Up @@ -924,12 +926,10 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
void hideAllLayers();
//reimplements method from base (gui) class
void showAllLayers();
// TODO: remove exportMapServer declaration once the mapserver export plugin is complete
// and tested
/*
//! Export current view as a mapserver map file
void exportMapServer();
*/
//reimplements method from base (gui) class
void hideSelectedLayers();
//reimplements method from base (gui) class
void showSelectedLayers();
//! Return pointer to the active layer
QgsMapLayer *activeLayer();
//! set the active layer
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgisappinterface.cpp
Expand Up @@ -556,6 +556,8 @@ QAction *QgisAppInterface::actionAddAllToOverview() { return qgis->actionAddAllT
QAction *QgisAppInterface::actionRemoveAllFromOverview() { return qgis->actionRemoveAllFromOverview(); }
QAction *QgisAppInterface::actionHideAllLayers() { return qgis->actionHideAllLayers(); }
QAction *QgisAppInterface::actionShowAllLayers() { return qgis->actionShowAllLayers(); }
QAction *QgisAppInterface::actionHideSelectedLayers() { return qgis->actionHideSelectedLayers(); }
QAction *QgisAppInterface::actionShowSelectedLayers() { return qgis->actionShowSelectedLayers(); }

//! Plugin menu actions
QAction *QgisAppInterface::actionManagePlugins() { return qgis->actionManagePlugins(); }
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgisappinterface.h
Expand Up @@ -417,6 +417,8 @@ class APP_EXPORT QgisAppInterface : public QgisInterface
virtual QAction *actionRemoveAllFromOverview();
virtual QAction *actionHideAllLayers();
virtual QAction *actionShowAllLayers();
virtual QAction *actionHideSelectedLayers();
virtual QAction *actionShowSelectedLayers();

//! Plugin menu actions
virtual QAction *actionManagePlugins();
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsvisibilitypresets.cpp
Expand Up @@ -38,6 +38,8 @@ QgsVisibilityPresets::QgsVisibilityPresets()

mMenu->addAction( QgisApp::instance()->actionShowAllLayers() );
mMenu->addAction( QgisApp::instance()->actionHideAllLayers() );
mMenu->addAction( QgisApp::instance()->actionShowSelectedLayers() );
mMenu->addAction( QgisApp::instance()->actionHideSelectedLayers() );
mMenu->addSeparator();

mMenu->addAction( tr( "Add Preset..." ), this, SLOT( addPreset() ) );
Expand Down
2 changes: 2 additions & 0 deletions src/gui/qgisinterface.h
Expand Up @@ -551,6 +551,8 @@ class GUI_EXPORT QgisInterface : public QObject
virtual QAction *actionRemoveAllFromOverview() = 0;
virtual QAction *actionHideAllLayers() = 0;
virtual QAction *actionShowAllLayers() = 0;
virtual QAction *actionHideSelectedLayers() = 0;
virtual QAction *actionShowSelectedLayers() = 0;

// Plugin menu actions
virtual QAction *actionManagePlugins() = 0;
Expand Down
22 changes: 21 additions & 1 deletion src/ui/qgisapp.ui
Expand Up @@ -17,7 +17,7 @@
<x>0</x>
<y>0</y>
<width>1050</width>
<height>20</height>
<height>18</height>
</rect>
</property>
<widget class="QMenu" name="mProjectMenu">
Expand Down Expand Up @@ -178,6 +178,8 @@
<addaction name="separator"/>
<addaction name="mActionShowAllLayers"/>
<addaction name="mActionHideAllLayers"/>
<addaction name="mActionShowSelectedLayers"/>
<addaction name="mActionHideSelectedLayers"/>
</widget>
<widget class="QMenu" name="mPluginMenu">
<property name="title">
Expand Down Expand Up @@ -2242,6 +2244,24 @@ Acts on currently active editable layer</string>
<string>Set Scale Visibility of Layer(s)</string>
</property>
</action>
<action name="mActionShowSelectedLayers">
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionShowAllLayers.png</normaloff>:/images/themes/default/mActionShowSelectedLayers.png</iconset>
</property>
<property name="text">
<string>Show Selected Layers</string>
</property>
</action>
<action name="mActionHideSelectedLayers">
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionHideAllLayers.png</normaloff>:/images/themes/default/mActionHideSelectedLayers.png</iconset>
</property>
<property name="text">
<string>Hide Selected Layers</string>
</property>
</action>
</widget>
<resources>
<include location="../../images/images.qrc"/>
Expand Down

0 comments on commit c90d810

Please sign in to comment.