Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[layertree] update insertion point to layer tree when appropriate
  • Loading branch information
wonder-sk committed Jun 3, 2014
1 parent cf4393e commit 974a3eb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/app/qgisapp.cpp
Expand Up @@ -2029,8 +2029,12 @@ void QgisApp::setupConnections()
this, SLOT( legendLayerSelectionChanged() ) );
connect( mLayerTreeView->layerTreeModel()->rootGroup(), SIGNAL( addedChildren( QgsLayerTreeNode*, int, int ) ),
this, SLOT( markDirty() ) );
connect( mLayerTreeView->layerTreeModel()->rootGroup(), SIGNAL( addedChildren( QgsLayerTreeNode*, int, int ) ),
this, SLOT( updateNewLayerInsertionPoint() ) );
connect( mLayerTreeView->layerTreeModel()->rootGroup(), SIGNAL( removedChildren( QgsLayerTreeNode*, int, int ) ),
this, SLOT( markDirty() ) );
connect( mLayerTreeView->layerTreeModel()->rootGroup(), SIGNAL( removedChildren( QgsLayerTreeNode*, int, int ) ),
this, SLOT( updateNewLayerInsertionPoint() ) );
connect( mLayerTreeView->layerTreeModel()->rootGroup(), SIGNAL( visibilityChanged( QgsLayerTreeNode*, Qt::CheckState ) ),
this, SLOT( markDirty() ) );
connect( mLayerTreeView->layerTreeModel()->rootGroup(), SIGNAL( customPropertyChanged( QgsLayerTreeNode*, QString ) ),
Expand Down Expand Up @@ -2303,7 +2307,7 @@ void QgisApp::initLayerTreeView()

connect( mLayerTreeView, SIGNAL( doubleClicked( QModelIndex ) ), this, SLOT( layerTreeViewDoubleClicked( QModelIndex ) ) );
connect( mLayerTreeView, SIGNAL( currentLayerChanged( QgsMapLayer* ) ), this, SLOT( activeLayerChanged( QgsMapLayer* ) ) );
connect( mLayerTreeView->selectionModel(), SIGNAL( currentChanged( QModelIndex, QModelIndex ) ), this, SLOT( layerTreeViewCurrentChanged( QModelIndex, QModelIndex ) ) );
connect( mLayerTreeView->selectionModel(), SIGNAL( currentChanged( QModelIndex, QModelIndex ) ), this, SLOT( updateNewLayerInsertionPoint() ) );

mLayerTreeDock->setWidget( mLayerTreeView );
addDockWidget( Qt::LeftDockWidgetArea, mLayerTreeDock );
Expand All @@ -2326,13 +2330,12 @@ void QgisApp::initLayerTreeView()
}


void QgisApp::layerTreeViewCurrentChanged( const QModelIndex& current, const QModelIndex& previous )
void QgisApp::updateNewLayerInsertionPoint()
{
Q_UNUSED( previous );

// defaults
QgsLayerTreeGroup* parentGroup = mLayerTreeView->layerTreeModel()->rootGroup();
int index = 0;
QModelIndex current = mLayerTreeView->currentIndex();

if ( current.isValid() )
{
Expand Down
3 changes: 2 additions & 1 deletion src/app/qgisapp.h
Expand Up @@ -469,7 +469,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow

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

0 comments on commit 974a3eb

Please sign in to comment.