mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Allow the browser to search into table comments
This commit is contained in:
parent
96f73fd549
commit
44d9b35163
@ -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 )
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user