Skip to content

Commit c90d810

Browse files
committedOct 15, 2014
allow setting visiblity of selected layers (fixes #10835)
1 parent d1e23a6 commit c90d810

File tree

10 files changed

+70
-7
lines changed

10 files changed

+70
-7
lines changed
 
805 Bytes
Loading
1003 Bytes
Loading

‎python/gui/qgisinterface.sip

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,8 @@ class QgisInterface : QObject
496496
virtual QAction *actionRemoveAllFromOverview() = 0;
497497
virtual QAction *actionHideAllLayers() = 0;
498498
virtual QAction *actionShowAllLayers() = 0;
499+
virtual QAction *actionHideSelectedLayers() = 0;
500+
virtual QAction *actionShowSelectedLayers() = 0;
499501

500502
// Plugin menu actions
501503
virtual QAction *actionManagePlugins() = 0;

‎src/app/qgisapp.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,6 +1176,8 @@ void QgisApp::createActions()
11761176
connect( mActionRemoveAllFromOverview, SIGNAL( triggered() ), this, SLOT( removeAllFromOverview() ) );
11771177
connect( mActionShowAllLayers, SIGNAL( triggered() ), this, SLOT( showAllLayers() ) );
11781178
connect( mActionHideAllLayers, SIGNAL( triggered() ), this, SLOT( hideAllLayers() ) );
1179+
connect( mActionShowSelectedLayers, SIGNAL( triggered() ), this, SLOT( showSelectedLayers() ) );
1180+
connect( mActionHideSelectedLayers, SIGNAL( triggered() ), this, SLOT( hideSelectedLayers() ) );
11791181

11801182
// Plugin Menu Items
11811183

@@ -1876,6 +1878,8 @@ void QgisApp::setTheme( QString theThemeName )
18761878
mActionAddAllToOverview->setIcon( QgsApplication::getThemeIcon( "/mActionAddAllToOverview.svg" ) );
18771879
mActionHideAllLayers->setIcon( QgsApplication::getThemeIcon( "/mActionHideAllLayers.png" ) );
18781880
mActionShowAllLayers->setIcon( QgsApplication::getThemeIcon( "/mActionShowAllLayers.png" ) );
1881+
mActionHideSelectedLayers->setIcon( QgsApplication::getThemeIcon( "/mActionHideSelectedLayers.png" ) );
1882+
mActionShowSelectedLayers->setIcon( QgsApplication::getThemeIcon( "/mActionShowSelectedLayers.png" ) );
18791883
mActionRemoveAllFromOverview->setIcon( QgsApplication::getThemeIcon( "/mActionRemoveAllFromOverview.svg" ) );
18801884
mActionToggleFullScreen->setIcon( QgsApplication::getThemeIcon( "/mActionToggleFullScreen.png" ) );
18811885
mActionProjectProperties->setIcon( QgsApplication::getThemeIcon( "/mActionProjectProperties.png" ) );
@@ -4430,6 +4434,35 @@ void QgisApp::showAllLayers()
44304434
nodeLayer->setVisible( Qt::Checked );
44314435
}
44324436

4437+
//reimplements method from base (gui) class
4438+
void QgisApp::hideSelectedLayers()
4439+
{
4440+
QgsDebugMsg( "hiding selected layers!" );
4441+
4442+
foreach ( QgsLayerTreeNode* node, mLayerTreeView->selectedNodes() )
4443+
{
4444+
if ( QgsLayerTree::isGroup( node ) )
4445+
QgsLayerTree::toGroup( node )->setVisible( Qt::Unchecked );
4446+
else if ( QgsLayerTree::isLayer( node ) )
4447+
QgsLayerTree::toLayer( node )->setVisible( Qt::Unchecked );
4448+
}
4449+
}
4450+
4451+
4452+
// reimplements method from base (gui) class
4453+
void QgisApp::showSelectedLayers()
4454+
{
4455+
QgsDebugMsg( "show selected layers!" );
4456+
4457+
foreach ( QgsLayerTreeNode* node, mLayerTreeView->selectedNodes() )
4458+
{
4459+
if ( QgsLayerTree::isGroup( node ) )
4460+
QgsLayerTree::toGroup( node )->setVisible( Qt::Checked );
4461+
else if ( QgsLayerTree::isLayer( node ) )
4462+
QgsLayerTree::toLayer( node )->setVisible( Qt::Checked );
4463+
}
4464+
}
4465+
44334466

44344467
void QgisApp::zoomIn()
44354468
{

‎src/app/qgisapp.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
360360
QAction *actionRemoveAllFromOverview() { return mActionRemoveAllFromOverview; }
361361
QAction *actionHideAllLayers() { return mActionHideAllLayers; }
362362
QAction *actionShowAllLayers() { return mActionShowAllLayers; }
363+
QAction *actionHideSelectedLayers() { return mActionHideSelectedLayers; }
364+
QAction *actionShowSelectedLayers() { return mActionShowSelectedLayers; }
363365

364366
QAction *actionManagePlugins() { return mActionManagePlugins; }
365367
QAction *actionPluginListSeparator() { return mActionPluginSeparator1; }
@@ -924,12 +926,10 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
924926
void hideAllLayers();
925927
//reimplements method from base (gui) class
926928
void showAllLayers();
927-
// TODO: remove exportMapServer declaration once the mapserver export plugin is complete
928-
// and tested
929-
/*
930-
//! Export current view as a mapserver map file
931-
void exportMapServer();
932-
*/
929+
//reimplements method from base (gui) class
930+
void hideSelectedLayers();
931+
//reimplements method from base (gui) class
932+
void showSelectedLayers();
933933
//! Return pointer to the active layer
934934
QgsMapLayer *activeLayer();
935935
//! set the active layer

‎src/app/qgisappinterface.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,8 @@ QAction *QgisAppInterface::actionAddAllToOverview() { return qgis->actionAddAllT
556556
QAction *QgisAppInterface::actionRemoveAllFromOverview() { return qgis->actionRemoveAllFromOverview(); }
557557
QAction *QgisAppInterface::actionHideAllLayers() { return qgis->actionHideAllLayers(); }
558558
QAction *QgisAppInterface::actionShowAllLayers() { return qgis->actionShowAllLayers(); }
559+
QAction *QgisAppInterface::actionHideSelectedLayers() { return qgis->actionHideSelectedLayers(); }
560+
QAction *QgisAppInterface::actionShowSelectedLayers() { return qgis->actionShowSelectedLayers(); }
559561

560562
//! Plugin menu actions
561563
QAction *QgisAppInterface::actionManagePlugins() { return qgis->actionManagePlugins(); }

‎src/app/qgisappinterface.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,8 @@ class APP_EXPORT QgisAppInterface : public QgisInterface
417417
virtual QAction *actionRemoveAllFromOverview();
418418
virtual QAction *actionHideAllLayers();
419419
virtual QAction *actionShowAllLayers();
420+
virtual QAction *actionHideSelectedLayers();
421+
virtual QAction *actionShowSelectedLayers();
420422

421423
//! Plugin menu actions
422424
virtual QAction *actionManagePlugins();

‎src/app/qgsvisibilitypresets.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ QgsVisibilityPresets::QgsVisibilityPresets()
3838

3939
mMenu->addAction( QgisApp::instance()->actionShowAllLayers() );
4040
mMenu->addAction( QgisApp::instance()->actionHideAllLayers() );
41+
mMenu->addAction( QgisApp::instance()->actionShowSelectedLayers() );
42+
mMenu->addAction( QgisApp::instance()->actionHideSelectedLayers() );
4143
mMenu->addSeparator();
4244

4345
mMenu->addAction( tr( "Add Preset..." ), this, SLOT( addPreset() ) );

‎src/gui/qgisinterface.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,8 @@ class GUI_EXPORT QgisInterface : public QObject
551551
virtual QAction *actionRemoveAllFromOverview() = 0;
552552
virtual QAction *actionHideAllLayers() = 0;
553553
virtual QAction *actionShowAllLayers() = 0;
554+
virtual QAction *actionHideSelectedLayers() = 0;
555+
virtual QAction *actionShowSelectedLayers() = 0;
554556

555557
// Plugin menu actions
556558
virtual QAction *actionManagePlugins() = 0;

‎src/ui/qgisapp.ui

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<x>0</x>
1818
<y>0</y>
1919
<width>1050</width>
20-
<height>20</height>
20+
<height>18</height>
2121
</rect>
2222
</property>
2323
<widget class="QMenu" name="mProjectMenu">
@@ -178,6 +178,8 @@
178178
<addaction name="separator"/>
179179
<addaction name="mActionShowAllLayers"/>
180180
<addaction name="mActionHideAllLayers"/>
181+
<addaction name="mActionShowSelectedLayers"/>
182+
<addaction name="mActionHideSelectedLayers"/>
181183
</widget>
182184
<widget class="QMenu" name="mPluginMenu">
183185
<property name="title">
@@ -2242,6 +2244,24 @@ Acts on currently active editable layer</string>
22422244
<string>Set Scale Visibility of Layer(s)</string>
22432245
</property>
22442246
</action>
2247+
<action name="mActionShowSelectedLayers">
2248+
<property name="icon">
2249+
<iconset resource="../../images/images.qrc">
2250+
<normaloff>:/images/themes/default/mActionShowAllLayers.png</normaloff>:/images/themes/default/mActionShowSelectedLayers.png</iconset>
2251+
</property>
2252+
<property name="text">
2253+
<string>Show Selected Layers</string>
2254+
</property>
2255+
</action>
2256+
<action name="mActionHideSelectedLayers">
2257+
<property name="icon">
2258+
<iconset resource="../../images/images.qrc">
2259+
<normaloff>:/images/themes/default/mActionHideAllLayers.png</normaloff>:/images/themes/default/mActionHideSelectedLayers.png</iconset>
2260+
</property>
2261+
<property name="text">
2262+
<string>Hide Selected Layers</string>
2263+
</property>
2264+
</action>
22452265
</widget>
22462266
<resources>
22472267
<include location="../../images/images.qrc"/>

0 commit comments

Comments
 (0)
Please sign in to comment.