Skip to content

Commit

Permalink
Merge pull request #3909 from nyalldawson/select_in_edit_menu
Browse files Browse the repository at this point in the history
Tweak edit/view menus
  • Loading branch information
nyalldawson committed Dec 28, 2016
2 parents 97215cf + 4f73c28 commit 4b1cf80
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 21 deletions.
5 changes: 5 additions & 0 deletions python/gui/qgisinterface.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -5787,6 +5788,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()
Expand Down
3 changes: 3 additions & 0 deletions src/app/qgisapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/app/qgisappinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/app/qgisappinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/app/qgsmapthemes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" ) );
Expand Down
6 changes: 6 additions & 0 deletions src/gui/qgisinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
52 changes: 31 additions & 21 deletions src/ui/qgisapp.ui
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<x>0</x>
<y>0</y>
<width>1018</width>
<height>22</height>
<height>19</height>
</rect>
</property>
<property name="toolTip">
Expand Down Expand Up @@ -64,20 +64,6 @@
<property name="title">
<string>&amp;View</string>
</property>
<widget class="QMenu" name="menuSelect">
<property name="title">
<string>Select</string>
</property>
<addaction name="mActionSelectFeatures"/>
<addaction name="mActionSelectPolygon"/>
<addaction name="mActionSelectFreehand"/>
<addaction name="mActionSelectRadius"/>
<addaction name="mActionSelectByForm"/>
<addaction name="mActionSelectByExpression"/>
<addaction name="mActionDeselectAll"/>
<addaction name="mActionSelectAll"/>
<addaction name="mActionInvertSelection"/>
</widget>
<widget class="QMenu" name="menuMeasure">
<property name="title">
<string>Measure</string>
Expand Down Expand Up @@ -110,7 +96,6 @@
<addaction name="mActionZoomIn"/>
<addaction name="mActionZoomOut"/>
<addaction name="separator"/>
<addaction name="menuSelect"/>
<addaction name="mActionIdentify"/>
<addaction name="menuMeasure"/>
<addaction name="mActionStatisticalSummary"/>
Expand All @@ -129,6 +114,12 @@
<addaction name="mActionShowBookmarks"/>
<addaction name="mActionDraw"/>
<addaction name="separator"/>
<addaction name="mActionShowAllLayers"/>
<addaction name="mActionHideAllLayers"/>
<addaction name="mActionShowSelectedLayers"/>
<addaction name="mActionHideSelectedLayers"/>
<addaction name="mActionHideDeselectedLayers"/>
<addaction name="separator"/>
</widget>
<widget class="QMenu" name="mLayerMenu">
<property name="title">
Expand Down Expand Up @@ -190,11 +181,6 @@
<addaction name="mActionAddToOverview"/>
<addaction name="mActionAddAllToOverview"/>
<addaction name="mActionRemoveAllFromOverview"/>
<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 @@ -257,6 +243,20 @@
<property name="title">
<string>&amp;Edit</string>
</property>
<widget class="QMenu" name="menuSelect">
<property name="title">
<string>Select</string>
</property>
<addaction name="mActionSelectFeatures"/>
<addaction name="mActionSelectPolygon"/>
<addaction name="mActionSelectFreehand"/>
<addaction name="mActionSelectRadius"/>
<addaction name="mActionSelectByForm"/>
<addaction name="mActionSelectByExpression"/>
<addaction name="mActionDeselectAll"/>
<addaction name="mActionSelectAll"/>
<addaction name="mActionInvertSelection"/>
</widget>
<widget class="QMenu" name="mMenuPasteAs">
<property name="title">
<string>Paste Features as</string>
Expand All @@ -271,6 +271,7 @@
<addaction name="mActionCopyFeatures"/>
<addaction name="mActionPasteFeatures"/>
<addaction name="mMenuPasteAs"/>
<addaction name="menuSelect"/>
<addaction name="separator"/>
<addaction name="mActionAddFeature"/>
<addaction name="mActionCircularStringCurvePoint"/>
Expand Down Expand Up @@ -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">
Expand Down

0 comments on commit 4b1cf80

Please sign in to comment.