heavily improved performance when adding items to file browser tree-widget (closes #2146218)

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1759 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2008-10-16 11:51:15 +00:00
parent c775cb00e3
commit d1781362a4
3 changed files with 30 additions and 20 deletions

View File

@@ -1,3 +1,10 @@
2008-10-16 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
* include/file_browser.h:
* src/gui/file_browser.cpp:
heavily improved performance when adding items to file browser
tree-widget (closes #2146218)
2008-10-15 dieEasy <dieeasy/at/cheapnet/dot/it>
* data/locale/it.qm:

View File

@@ -142,7 +142,7 @@ public:
private:
void initPixmapStuff( void );
void initPixmaps( void );
bool addItems( const QString & _path );
@@ -186,8 +186,7 @@ public:
fileItem( QTreeWidget * _parent, const QString & _name,
const QString & _path );
fileItem( QTreeWidgetItem * _parent, const QString & _name,
const QString & _path );
fileItem( const QString & _name, const QString & _path );
inline QString fullName( void ) const
{
@@ -210,7 +209,7 @@ public:
private:
void initPixmapStuff( void );
void initPixmaps( void );
void determineFileType( void );
static QPixmap * s_projectFilePixmap;

View File

@@ -47,6 +47,12 @@
#include "string_pair_drag.h"
#include "text_float.h"
enum TreeWidgetItemTypes
{
TypeFileItem = QTreeWidgetItem::UserType,
TypeDirectoryItem
} ;
fileBrowser::fileBrowser( const QString & _directories, const QString & _filter,
const QString & _title, const QPixmap & _pm,
@@ -536,12 +542,12 @@ QPixmap * directory::s_folderLockedPixmap = NULL;
directory::directory( const QString & _name, const QString & _path,
const QString & _filter ) :
QTreeWidgetItem( QStringList( _name ), TypeDirectoryItem ),
m_directories( _path ),
m_filter( _filter )
{
initPixmapStuff();
initPixmaps();
setText( 0, _name );
setChildIndicatorPolicy( QTreeWidgetItem::ShowIndicator );
if( !QDir( fullName() ).isReadable() )
@@ -557,7 +563,7 @@ directory::directory( const QString & _name, const QString & _path,
void directory::initPixmapStuff( void )
void directory::initPixmaps( void )
{
if( s_folderPixmap == NULL )
{
@@ -662,19 +668,20 @@ bool directory::addItems( const QString & _path )
}
}
QList<QTreeWidgetItem*> items;
files = thisDir.entryList( QDir::Files, QDir::Name );
for( QStringList::const_iterator it = files.constBegin();
it != files.constEnd(); ++it )
{
QString cur_file = *it;
if( cur_file[0] != '.'
&& thisDir.match( m_filter, cur_file.toLower() )
/*QDir::match( FILE_FILTER, cur_file )*/ )
if( cur_file[0] != '.' &&
thisDir.match( m_filter, cur_file.toLower() ) )
{
(void) new fileItem( this, cur_file, _path );
items << new fileItem( cur_file, _path );
added_something = true;
}
}
addChildren( items );
treeWidget()->setUpdatesEnabled( true );
@@ -694,31 +701,28 @@ QPixmap * fileItem::s_unknownFilePixmap = NULL;
fileItem::fileItem( QTreeWidget * _parent, const QString & _name,
const QString & _path ) :
QTreeWidgetItem( _parent ),
QTreeWidgetItem( _parent, QStringList( _name) , TypeFileItem ),
m_path( _path )
{
setText( 0, _name );
determineFileType();
initPixmapStuff();
initPixmaps();
}
fileItem::fileItem( QTreeWidgetItem * _parent, const QString & _name,
const QString & _path ) :
QTreeWidgetItem( _parent ),
fileItem::fileItem( const QString & _name, const QString & _path ) :
QTreeWidgetItem( QStringList( _name ), TypeFileItem ),
m_path( _path )
{
setText( 0, _name );
determineFileType();
initPixmapStuff();
initPixmaps();
}
void fileItem::initPixmapStuff( void )
void fileItem::initPixmaps( void )
{
if( s_projectFilePixmap == NULL )
{