Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/FileBrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* FileBrowser.h - include file for FileBrowser
*
* Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
*
* This file is part of LMMS - http://lmms.io
*
* This program is free software; you can redistribute it and/or
Expand Down Expand Up @@ -55,6 +55,7 @@ class FileBrowser : public SideBarWidget

private slots:
void reloadTree( void );
void expandItems( QTreeWidgetItem * item=NULL );
// call with item=NULL to filter the entire tree
bool filterItems( const QString & filter, QTreeWidgetItem * item=NULL );
void giveFocusToFilter();
Expand Down
39 changes: 26 additions & 13 deletions src/gui/FileBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* sample-file-browser
*
* Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
*
* This file is part of LMMS - http://lmms.io
*
* This program is free software; you can redistribute it and/or
Expand Down Expand Up @@ -118,7 +118,7 @@ FileBrowser::~FileBrowser()



bool FileBrowser::filterItems(const QString & filter, QTreeWidgetItem * item)
bool FileBrowser::filterItems( const QString & filter, QTreeWidgetItem * item )
{
// call with item=NULL to filter the entire tree
bool anyMatched = false;
Expand Down Expand Up @@ -169,7 +169,6 @@ bool FileBrowser::filterItems(const QString & filter, QTreeWidgetItem * item)




void FileBrowser::reloadTree( void )
{
const QString text = m_filterEdit->text();
Expand All @@ -180,23 +179,38 @@ void FileBrowser::reloadTree( void )
{
addItems( *it );
}
for(int i = 0; i < m_l->topLevelItemCount(); ++i)
expandItems();
m_filterEdit->setText( text );
filterItems( text );
}



void FileBrowser::expandItems( QTreeWidgetItem * item )
{
int numChildren = item ? item->childCount() : m_l->topLevelItemCount();
for( int i = 0; i < numChildren; ++i )
{
QTreeWidgetItem * it = item ? item->child( i ) : m_l->topLevelItem(i);
if ( m_recurse )
{
m_l->topLevelItem( i )->setExpanded( true);
it->setExpanded( true );
}
Directory *d = dynamic_cast<Directory *> ( m_l->topLevelItem( i ) );
Directory *d = dynamic_cast<Directory *> ( it );
if( d )
{
d->update();
d->setExpanded( false );
}
if( m_recurse && it->childCount() )
{
expandItems(it);
}
}
m_filterEdit->setText( text );
filterItems( text );
}



void FileBrowser::giveFocusToFilter()
{
if (!m_filterEdit->hasFocus())
Expand All @@ -208,6 +222,7 @@ void FileBrowser::giveFocusToFilter()
}



void FileBrowser::addItems(const QString & path )
{
if( m_dirsAsItems )
Expand Down Expand Up @@ -408,7 +423,7 @@ void FileBrowserTreeWidget::mousePressEvent(QMouseEvent * me )
m_previewPlayHandle = s;
delete tf;
}
else if( ( f->extension ()== "xiz" || f->extension() == "sf2" || f->extension() == "gig" ) &&
else if( ( f->extension ()== "xiz" || f->extension() == "sf2" || f->extension() == "gig" ) &&
! pluginFactory->pluginSupportingExtension(f->extension()).isNull() )
{
m_previewPlayHandle = new PresetPreviewPlayHandle( f->fullName(), f->handling() == FileItem::LoadByPlugin );
Expand Down Expand Up @@ -794,8 +809,6 @@ bool Directory::addItems(const QString & path )
path, m_filter ) );
orphan = false;
m_dirCount++;
//recurse for each dir
addItems( path + cur_file + QDir::separator() );
break;
}
else if( cur_file == d->text( 0 ) )
Expand Down Expand Up @@ -896,8 +909,8 @@ void FileItem::initPixmaps( void )
s_soundfontFilePixmap = new QPixmap( embed::getIconPixmap(
"soundfont_file", 16, 16 ) );
}
if ( s_vstPluginFilePixmap == NULL )

if ( s_vstPluginFilePixmap == NULL )
{
s_vstPluginFilePixmap = new QPixmap( embed::getIconPixmap(
"vst_plugin_file", 16, 16 ) );
Expand Down