Skip to content

Commit 4b1cf80

Browse files
authoredDec 28, 2016
Merge pull request #3909 from nyalldawson/select_in_edit_menu
Tweak edit/view menus
2 parents 97215cf + 4f73c28 commit 4b1cf80

File tree

8 files changed

+60
-21
lines changed

8 files changed

+60
-21
lines changed
 

‎python/gui/qgisinterface.sip

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,11 @@ class QgisInterface : QObject
483483
virtual QAction *actionHideAllLayers() = 0;
484484
virtual QAction *actionShowAllLayers() = 0;
485485
virtual QAction *actionHideSelectedLayers() = 0;
486+
/**
487+
* Returns the Hide Deselected Layers action.
488+
* @note added in QGIS 3.0
489+
*/
490+
virtual QAction *actionHideDeselectedLayers() = 0;
486491
virtual QAction *actionShowSelectedLayers() = 0;
487492

488493
// Plugin menu actions

‎src/app/qgisapp.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1707,6 +1707,7 @@ void QgisApp::createActions()
17071707
connect( mActionHideAllLayers, SIGNAL( triggered() ), this, SLOT( hideAllLayers() ) );
17081708
connect( mActionShowSelectedLayers, SIGNAL( triggered() ), this, SLOT( showSelectedLayers() ) );
17091709
connect( mActionHideSelectedLayers, SIGNAL( triggered() ), this, SLOT( hideSelectedLayers() ) );
1710+
connect( mActionHideDeselectedLayers, &QAction::triggered, this, &QgisApp::hideDeselectedLayers );
17101711

17111712
// Plugin Menu Items
17121713

@@ -5787,6 +5788,17 @@ void QgisApp::hideSelectedLayers()
57875788
}
57885789
}
57895790

5791+
void QgisApp::hideDeselectedLayers()
5792+
{
5793+
QList<QgsLayerTreeLayer*> selectedLayerNodes = mLayerTreeView->selectedLayerNodes();
5794+
5795+
Q_FOREACH ( QgsLayerTreeLayer* nodeLayer, mLayerTreeView->layerTreeModel()->rootGroup()->findLayers() )
5796+
{
5797+
if ( selectedLayerNodes.contains( nodeLayer ) )
5798+
continue;
5799+
nodeLayer->setVisible( Qt::Unchecked );
5800+
}
5801+
}
57905802

57915803
// reimplements method from base (gui) class
57925804
void QgisApp::showSelectedLayers()

‎src/app/qgisapp.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
411411
QAction *actionHideAllLayers() { return mActionHideAllLayers; }
412412
QAction *actionShowAllLayers() { return mActionShowAllLayers; }
413413
QAction *actionHideSelectedLayers() { return mActionHideSelectedLayers; }
414+
QAction *actionHideDeselectedLayers() { return mActionHideDeselectedLayers; }
414415
QAction *actionShowSelectedLayers() { return mActionShowSelectedLayers; }
415416

416417
QAction *actionManagePlugins() { return mActionManagePlugins; }
@@ -1027,6 +1028,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
10271028
void showAllLayers();
10281029
//reimplements method from base (gui) class
10291030
void hideSelectedLayers();
1031+
//! Hides any layers which are not selected
1032+
void hideDeselectedLayers();
10301033
//reimplements method from base (gui) class
10311034
void showSelectedLayers();
10321035
//! Return pointer to the active layer

‎src/app/qgisappinterface.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,7 @@ QAction *QgisAppInterface::actionRemoveAllFromOverview() { return qgis->actionRe
631631
QAction *QgisAppInterface::actionHideAllLayers() { return qgis->actionHideAllLayers(); }
632632
QAction *QgisAppInterface::actionShowAllLayers() { return qgis->actionShowAllLayers(); }
633633
QAction *QgisAppInterface::actionHideSelectedLayers() { return qgis->actionHideSelectedLayers(); }
634+
QAction*QgisAppInterface::actionHideDeselectedLayers() { return qgis->actionHideDeselectedLayers(); }
634635
QAction *QgisAppInterface::actionShowSelectedLayers() { return qgis->actionShowSelectedLayers(); }
635636

636637
//! Plugin menu actions

‎src/app/qgisappinterface.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ class APP_EXPORT QgisAppInterface : public QgisInterface
445445
virtual QAction *actionHideAllLayers() override;
446446
virtual QAction *actionShowAllLayers() override;
447447
virtual QAction *actionHideSelectedLayers() override;
448+
virtual QAction *actionHideDeselectedLayers() override;
448449
virtual QAction *actionShowSelectedLayers() override;
449450

450451
//! Plugin menu actions

‎src/app/qgsmapthemes.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ QgsMapThemes::QgsMapThemes()
4242
mMenu->addAction( QgisApp::instance()->actionHideAllLayers() );
4343
mMenu->addAction( QgisApp::instance()->actionShowSelectedLayers() );
4444
mMenu->addAction( QgisApp::instance()->actionHideSelectedLayers() );
45+
mMenu->addAction( QgisApp::instance()->actionHideDeselectedLayers() );
4546
mMenu->addSeparator();
4647

4748
mReplaceMenu = new QMenu( tr( "Replace Theme" ) );

‎src/gui/qgisinterface.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,12 @@ class GUI_EXPORT QgisInterface : public QObject
539539
virtual QAction *actionHideAllLayers() = 0;
540540
virtual QAction *actionShowAllLayers() = 0;
541541
virtual QAction *actionHideSelectedLayers() = 0;
542+
543+
/**
544+
* Returns the Hide Deselected Layers action.
545+
* @note added in QGIS 3.0
546+
*/
547+
virtual QAction *actionHideDeselectedLayers() = 0;
542548
virtual QAction *actionShowSelectedLayers() = 0;
543549

544550
// Plugin menu actions

‎src/ui/qgisapp.ui

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<x>0</x>
1818
<y>0</y>
1919
<width>1018</width>
20-
<height>22</height>
20+
<height>19</height>
2121
</rect>
2222
</property>
2323
<property name="toolTip">
@@ -64,20 +64,6 @@
6464
<property name="title">
6565
<string>&amp;View</string>
6666
</property>
67-
<widget class="QMenu" name="menuSelect">
68-
<property name="title">
69-
<string>Select</string>
70-
</property>
71-
<addaction name="mActionSelectFeatures"/>
72-
<addaction name="mActionSelectPolygon"/>
73-
<addaction name="mActionSelectFreehand"/>
74-
<addaction name="mActionSelectRadius"/>
75-
<addaction name="mActionSelectByForm"/>
76-
<addaction name="mActionSelectByExpression"/>
77-
<addaction name="mActionDeselectAll"/>
78-
<addaction name="mActionSelectAll"/>
79-
<addaction name="mActionInvertSelection"/>
80-
</widget>
8167
<widget class="QMenu" name="menuMeasure">
8268
<property name="title">
8369
<string>Measure</string>
@@ -110,7 +96,6 @@
11096
<addaction name="mActionZoomIn"/>
11197
<addaction name="mActionZoomOut"/>
11298
<addaction name="separator"/>
113-
<addaction name="menuSelect"/>
11499
<addaction name="mActionIdentify"/>
115100
<addaction name="menuMeasure"/>
116101
<addaction name="mActionStatisticalSummary"/>
@@ -129,6 +114,12 @@
129114
<addaction name="mActionShowBookmarks"/>
130115
<addaction name="mActionDraw"/>
131116
<addaction name="separator"/>
117+
<addaction name="mActionShowAllLayers"/>
118+
<addaction name="mActionHideAllLayers"/>
119+
<addaction name="mActionShowSelectedLayers"/>
120+
<addaction name="mActionHideSelectedLayers"/>
121+
<addaction name="mActionHideDeselectedLayers"/>
122+
<addaction name="separator"/>
132123
</widget>
133124
<widget class="QMenu" name="mLayerMenu">
134125
<property name="title">
@@ -190,11 +181,6 @@
190181
<addaction name="mActionAddToOverview"/>
191182
<addaction name="mActionAddAllToOverview"/>
192183
<addaction name="mActionRemoveAllFromOverview"/>
193-
<addaction name="separator"/>
194-
<addaction name="mActionShowAllLayers"/>
195-
<addaction name="mActionHideAllLayers"/>
196-
<addaction name="mActionShowSelectedLayers"/>
197-
<addaction name="mActionHideSelectedLayers"/>
198184
</widget>
199185
<widget class="QMenu" name="mPluginMenu">
200186
<property name="title">
@@ -257,6 +243,20 @@
257243
<property name="title">
258244
<string>&amp;Edit</string>
259245
</property>
246+
<widget class="QMenu" name="menuSelect">
247+
<property name="title">
248+
<string>Select</string>
249+
</property>
250+
<addaction name="mActionSelectFeatures"/>
251+
<addaction name="mActionSelectPolygon"/>
252+
<addaction name="mActionSelectFreehand"/>
253+
<addaction name="mActionSelectRadius"/>
254+
<addaction name="mActionSelectByForm"/>
255+
<addaction name="mActionSelectByExpression"/>
256+
<addaction name="mActionDeselectAll"/>
257+
<addaction name="mActionSelectAll"/>
258+
<addaction name="mActionInvertSelection"/>
259+
</widget>
260260
<widget class="QMenu" name="mMenuPasteAs">
261261
<property name="title">
262262
<string>Paste Features as</string>
@@ -271,6 +271,7 @@
271271
<addaction name="mActionCopyFeatures"/>
272272
<addaction name="mActionPasteFeatures"/>
273273
<addaction name="mMenuPasteAs"/>
274+
<addaction name="menuSelect"/>
274275
<addaction name="separator"/>
275276
<addaction name="mActionAddFeature"/>
276277
<addaction name="mActionCircularStringCurvePoint"/>
@@ -2425,6 +2426,15 @@ Acts on currently active editable layer</string>
24252426
<string>Hide Selected Layers</string>
24262427
</property>
24272428
</action>
2429+
<action name="mActionHideDeselectedLayers">
2430+
<property name="icon">
2431+
<iconset resource="../../images/images.qrc">
2432+
<normaloff>:/images/themes/default/mActionHideSelectedLayers.png</normaloff>:/images/themes/default/mActionHideSelectedLayers.png</iconset>
2433+
</property>
2434+
<property name="text">
2435+
<string>Hide Deselected Layers</string>
2436+
</property>
2437+
</action>
24282438
<action name="mActionNewMemoryLayer">
24292439
<property name="icon">
24302440
<iconset resource="../../images/images.qrc">

0 commit comments

Comments
 (0)
Please sign in to comment.