Skip to content

Commit 974a3eb

Browse files
committed
[layertree] update insertion point to layer tree when appropriate
1 parent cf4393e commit 974a3eb

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/app/qgisapp.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2029,8 +2029,12 @@ void QgisApp::setupConnections()
20292029
this, SLOT( legendLayerSelectionChanged() ) );
20302030
connect( mLayerTreeView->layerTreeModel()->rootGroup(), SIGNAL( addedChildren( QgsLayerTreeNode*, int, int ) ),
20312031
this, SLOT( markDirty() ) );
2032+
connect( mLayerTreeView->layerTreeModel()->rootGroup(), SIGNAL( addedChildren( QgsLayerTreeNode*, int, int ) ),
2033+
this, SLOT( updateNewLayerInsertionPoint() ) );
20322034
connect( mLayerTreeView->layerTreeModel()->rootGroup(), SIGNAL( removedChildren( QgsLayerTreeNode*, int, int ) ),
20332035
this, SLOT( markDirty() ) );
2036+
connect( mLayerTreeView->layerTreeModel()->rootGroup(), SIGNAL( removedChildren( QgsLayerTreeNode*, int, int ) ),
2037+
this, SLOT( updateNewLayerInsertionPoint() ) );
20342038
connect( mLayerTreeView->layerTreeModel()->rootGroup(), SIGNAL( visibilityChanged( QgsLayerTreeNode*, Qt::CheckState ) ),
20352039
this, SLOT( markDirty() ) );
20362040
connect( mLayerTreeView->layerTreeModel()->rootGroup(), SIGNAL( customPropertyChanged( QgsLayerTreeNode*, QString ) ),
@@ -2303,7 +2307,7 @@ void QgisApp::initLayerTreeView()
23032307

23042308
connect( mLayerTreeView, SIGNAL( doubleClicked( QModelIndex ) ), this, SLOT( layerTreeViewDoubleClicked( QModelIndex ) ) );
23052309
connect( mLayerTreeView, SIGNAL( currentLayerChanged( QgsMapLayer* ) ), this, SLOT( activeLayerChanged( QgsMapLayer* ) ) );
2306-
connect( mLayerTreeView->selectionModel(), SIGNAL( currentChanged( QModelIndex, QModelIndex ) ), this, SLOT( layerTreeViewCurrentChanged( QModelIndex, QModelIndex ) ) );
2310+
connect( mLayerTreeView->selectionModel(), SIGNAL( currentChanged( QModelIndex, QModelIndex ) ), this, SLOT( updateNewLayerInsertionPoint() ) );
23072311

23082312
mLayerTreeDock->setWidget( mLayerTreeView );
23092313
addDockWidget( Qt::LeftDockWidgetArea, mLayerTreeDock );
@@ -2326,13 +2330,12 @@ void QgisApp::initLayerTreeView()
23262330
}
23272331

23282332

2329-
void QgisApp::layerTreeViewCurrentChanged( const QModelIndex& current, const QModelIndex& previous )
2333+
void QgisApp::updateNewLayerInsertionPoint()
23302334
{
2331-
Q_UNUSED( previous );
2332-
23332335
// defaults
23342336
QgsLayerTreeGroup* parentGroup = mLayerTreeView->layerTreeModel()->rootGroup();
23352337
int index = 0;
2338+
QModelIndex current = mLayerTreeView->currentIndex();
23362339

23372340
if ( current.isValid() )
23382341
{

src/app/qgisapp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
469469

470470
public slots:
471471
void layerTreeViewDoubleClicked( const QModelIndex& index );
472-
void layerTreeViewCurrentChanged( const QModelIndex& current, const QModelIndex& previous );
472+
//! Make sure the insertion point for new layers is up-to-date with the current item in layer tree view
473+
void updateNewLayerInsertionPoint();
473474
void activeLayerChanged( QgsMapLayer* layer );
474475
//! Zoom to full extent
475476
void zoomFull();

0 commit comments

Comments
 (0)