Skip to content
Permalink
Browse files
[layertree] Underline current layer
  • Loading branch information
wonder-sk committed May 22, 2014
1 parent af5f1aa commit 2837778905e75d93bf31fd3fc47c7f24037d965f
@@ -32,6 +32,7 @@ QgsLayerTreeModel::QgsLayerTreeModel( QgsLayerTreeGroup* rootNode, QObject *pare
: QAbstractItemModel( parent )
, mRootNode( rootNode )
, mFlags( ShowSymbology )
, mCurrentNode( 0 )
{
Q_ASSERT( mRootNode );

@@ -236,6 +237,8 @@ QVariant QgsLayerTreeModel::data( const QModelIndex &index, int role ) const
f.setItalic( true );
if ( QgsLayerTree::isLayer( node ) )
f.setBold( true );
if ( node == mCurrentNode )
f.setUnderline( true );
return f;
}
else if ( role == Qt::ToolTipRole )
@@ -382,6 +385,23 @@ void QgsLayerTreeModel::refreshLayerSymbology( QgsLayerTreeLayer* nodeLayer )
addSymbologyToLayer( nodeLayer );
}

void QgsLayerTreeModel::setCurrentNode( QgsLayerTreeNode* currentNode )
{
if ( mCurrentNode )
{
QModelIndex idx = node2index( mCurrentNode );
emit dataChanged( idx, idx );
}

mCurrentNode = currentNode;

if ( mCurrentNode )
{
QModelIndex idx = node2index( mCurrentNode );
emit dataChanged( idx, idx );
}
}

void QgsLayerTreeModel::nodeWillAddChildren( QgsLayerTreeNode* node, int indexFrom, int indexTo )
{
Q_ASSERT( node );
@@ -92,6 +92,9 @@ class GUI_EXPORT QgsLayerTreeModel : public QAbstractItemModel

void refreshLayerSymbology( QgsLayerTreeLayer* nodeLayer );

QgsLayerTreeNode* currentNode() const { return mCurrentNode; }
void setCurrentNode( QgsLayerTreeNode* currentNode );

signals:

protected slots:
@@ -122,6 +125,8 @@ class GUI_EXPORT QgsLayerTreeModel : public QAbstractItemModel
Flags mFlags;

QMap<QgsLayerTreeLayer*, QList<QgsLayerTreeModelSymbologyNode*> > mSymbologyNodes;

QgsLayerTreeNode* mCurrentNode;
};

Q_DECLARE_OPERATORS_FOR_FLAGS( QgsLayerTreeModel::Flags )
@@ -142,6 +142,11 @@ void QgsLayerTreeView::onCurrentChanged( QModelIndex current, QModelIndex previo
if ( layerPrevious == layerCurrent )
return;

if ( layerCurrent )
layerTreeModel()->setCurrentNode( layerTreeModel()->rootGroup()->findLayer( layerCurrent->id() ) );
else
layerTreeModel()->setCurrentNode( 0 );

emit currentLayerChanged( layerCurrent );
}

0 comments on commit 2837778

Please sign in to comment.