Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[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 8722ace
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/app/qgsbrowserdockwidget.cpp
Expand Up @@ -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 );
}

Expand Down Expand Up @@ -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 );
}

Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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 );
}
Expand Down Expand Up @@ -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 );
Expand Down

0 comments on commit 8722ace

Please sign in to comment.