Skip to content
Permalink
Browse files

[browser] Set focus to filter edit when filter activated

Also clean up some code
  • Loading branch information
nyalldawson committed Apr 8, 2016
1 parent edee876 commit 8722acea574548776a0f39e85c11e30cba34af50
Showing with 14 additions and 7 deletions.
  1. +14 −7 src/app/qgsbrowserdockwidget.cpp
@@ -107,7 +107,7 @@ QgsBrowserLayerProperties::QgsBrowserLayerProperties( QWidget* parent ) :
{
setupUi( this );

mUriLabel = new QgsBrowserPropertiesWrapLabel( "", this );
mUriLabel = new QgsBrowserPropertiesWrapLabel( QString(), this );
mHeaderGridLayout->addItem( new QWidgetItem( mUriLabel ), 1, 1 );
}

@@ -221,7 +221,7 @@ QgsBrowserDirectoryProperties::QgsBrowserDirectoryProperties( QWidget* parent )
{
setupUi( this );

mPathLabel = new QgsBrowserPropertiesWrapLabel( "", mHeaderWidget );
mPathLabel = new QgsBrowserPropertiesWrapLabel( QString(), mHeaderWidget );
mHeaderGridLayout->addItem( new QWidgetItem( mPathLabel ), 0, 1 );
}

@@ -277,7 +277,7 @@ QgsBrowserDockWidget::QgsBrowserDockWidget( const QString& name, QWidget * paren
mLayoutBrowser->addWidget( mBrowserView );

mWidgetFilter->hide();
mLeFilter->setPlaceholderText( tr( "Type here to filter current item..." ) );
mLeFilter->setPlaceholderText( tr( "Type here to visible items..." ) );

This comment has been minimized.

Copy link
@m-kuhn

m-kuhn Apr 9, 2016

Member

did you forget the word "filter" here?

This comment has been minimized.

Copy link
@nyalldawson

nyalldawson Apr 9, 2016

Author Collaborator

Thanks, fixed

// icons from http://www.fatcow.com/free-icons License: CC Attribution 3.0

QMenu* menu = new QMenu( this );
@@ -664,9 +664,13 @@ void QgsBrowserDockWidget::showFilterWidget( bool visible )
mWidgetFilter->setVisible( visible );
if ( ! visible )
{
mLeFilter->setText( "" );
mLeFilter->setText( QString() );
setFilter();
}
else
{
mLeFilter->setFocus();
}
}

void QgsBrowserDockWidget::setFilter()
@@ -808,8 +812,10 @@ void QgsDockBrowserTreeView::dragMoveEvent( QDragMoveEvent* e )
//

QgsBrowserTreeFilterProxyModel::QgsBrowserTreeFilterProxyModel( QObject* parent )
: QSortFilterProxyModel( parent ), mModel( nullptr )
, mFilter( "" ), mPatternSyntax( "normal" ), mCaseSensitivity( Qt::CaseInsensitive )
: QSortFilterProxyModel( parent )
, mModel( nullptr )
, mPatternSyntax( "normal" )
, mCaseSensitivity( Qt::CaseInsensitive )
{
setDynamicSortFilter( true );
}
@@ -903,7 +909,8 @@ bool QgsBrowserTreeFilterProxyModel::filterAcceptsString( const QString& value )

bool QgsBrowserTreeFilterProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const
{
if ( mFilter == "" || !mModel ) return true;
if ( mFilter.isEmpty() || !mModel )
return true;

QModelIndex sourceIndex = mModel->index( sourceRow, 0, sourceParent );
return filterAcceptsItem( sourceIndex ) || filterAcceptsAncestor( sourceIndex ) || filterAcceptsDescendant( sourceIndex );

0 comments on commit 8722ace

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