Skip to content
Permalink
Browse files

Allow the browser to search into table comments

  • Loading branch information
Hugo Mercier authored and m-kuhn committed Sep 25, 2015
1 parent 96f73fd commit 44d9b351633571b91c291277a0ddfc59c8d9ac28
Showing with 20 additions and 2 deletions.
  1. +10 −1 src/app/qgsbrowserdockwidget.cpp
  2. +10 −1 src/core/qgsbrowsermodel.cpp
@@ -200,7 +200,10 @@ class QgsBrowserTreeFilterProxyModel : public QSortFilterProxyModel
if ( mFilter == "" || !mModel ) return true;

QModelIndex sourceIndex = mModel->index( sourceRow, 0, sourceParent );
return filterAcceptsItem( sourceIndex ) || filterAcceptsAncestor( sourceIndex ) || filterAcceptsDescendant( sourceIndex );
// also look into the comment column
QModelIndex commentIndex = mModel->index( sourceRow, 1, sourceParent );
return filterAcceptsItem( sourceIndex ) || filterAcceptsAncestor( sourceIndex ) || filterAcceptsDescendant( sourceIndex ) ||
filterAcceptsItem( commentIndex ) || filterAcceptsAncestor( commentIndex ) || filterAcceptsDescendant( commentIndex );
}

// returns true if at least one ancestor is accepted by filter
@@ -232,6 +235,11 @@ class QgsBrowserTreeFilterProxyModel : public QSortFilterProxyModel
return true;
if ( filterAcceptsDescendant( sourceChildIndex ) )
return true;
sourceChildIndex = mModel->index( i, 1, sourceIndex );
if ( filterAcceptsItem( sourceChildIndex ) )
return true;
if ( filterAcceptsDescendant( sourceChildIndex ) )
return true;
}
return false;
}
@@ -532,6 +540,7 @@ void QgsBrowserDockWidget::showEvent( QShowEvent * e )
// provide a horizontal scroll bar instead of using ellipse (...) for longer items
mBrowserView->setTextElideMode( Qt::ElideNone );
mBrowserView->header()->setResizeMode( 0, QHeaderView::ResizeToContents );
mBrowserView->header()->setResizeMode( 1, QHeaderView::ResizeToContents );
mBrowserView->header()->setStretchLastSection( false );

// selectionModel is created when model is set on tree
@@ -202,7 +202,16 @@ QVariant QgsBrowserModel::data( const QModelIndex &index, int role ) const
}
else if ( role == Qt::DisplayRole )
{
return item->name();
if ( index.column() == 0 )
{
return item->name();
}
if ( item->type() == QgsDataItem::Layer )
{
QgsLayerItem* lyrItem = qobject_cast<QgsLayerItem*>(item);
return lyrItem->comments();
}
return "";
}
else if ( role == Qt::ToolTipRole )
{

0 comments on commit 44d9b35

Please sign in to comment.
You can’t perform that action at this time.