improved file-browser

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@122 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2006-04-07 06:27:50 +00:00
parent 836ea65eb3
commit 8a5150677c
10 changed files with 242 additions and 89 deletions

View File

@@ -1,3 +1,21 @@
2006-04-06 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
* include/config_mgr.h:
* src/core/config_mgr.cpp:
use setup-wizard only for setting working-directory
* src/core/main_window.cpp:
when creating file-browsers, pass 2 directories:
- factory-files
- user-files
this concerns projects, presets and samples - obsoletes
copying/linking files the first time, LMMS is run (new factory files in
new versions do not cause any trouble anymore)
* include/file_browser.h:
* src/core/file_browser.cpp:
added support for merging several directory-trees into one view
2006-04-05 Danny McRae <khjklujn/at/users/dot/sourceforge/dot/net>
* include/sample_track.h:

1
TODO
View File

@@ -1,3 +1,4 @@
- replace rest of wizard by simple directory-selection-dialog for working-dir when running the first time
- do REAL release in envelopes (can't be precalculated as it depends on key-press-duration/rest of envelope)
- correctly load steps/dots from FLP-files
- vibed-plugin: do not crash at destruction

View File

@@ -2,8 +2,8 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.50)
AC_INIT(lmms, 0.1.4-cvs20060405, tobydox/at/users/dot/sourceforge/dot/net)
AM_INIT_AUTOMAKE(lmms, 0.1.4-cvs20060405)
AC_INIT(lmms, 0.1.4-cvs20060406, tobydox/at/users/dot/sourceforge/dot/net)
AM_INIT_AUTOMAKE(lmms, 0.1.4-cvs20060406)
AM_CONFIG_HEADER(config.h)

Binary file not shown.

View File

@@ -82,6 +82,11 @@ public:
return( s_instanceOfMe );
}
const QString & dataDir( void ) const
{
return( m_dataDir );
}
const QString & workingDir( void ) const
{
return( m_workingDir );
@@ -176,10 +181,10 @@ private:
void FASTCALL addPage( QWidget * _w, const QString & _title );
static void processFilesRecursively( const QString & _src_dir,
/* static void processFilesRecursively( const QString & _src_dir,
const QString & _dst_dir,
void( * _proc_func )( const QString & _src, const QString &
_dst ) );
_dst ) );*/
const QString m_lmmsRcFile;

View File

@@ -61,7 +61,7 @@ class fileBrowser : public sideBarWidget, public engineObject
{
Q_OBJECT
public:
fileBrowser( const QString & _path, const QString & _filter,
fileBrowser( const QString & _directories, const QString & _filter,
const QString & _title, const QPixmap & _pm,
QWidget * _parent, engine * _engine );
virtual ~fileBrowser();
@@ -86,12 +86,14 @@ protected slots:
private:
virtual void keyPressEvent( QKeyEvent * _ke );
void addItems( const QString & _path );
void openInNewInstrumentTrack( trackContainer * _tc );
listView * m_l;
fileItem * m_contextMenuItem;
QString m_path;
QString m_directories;
QString m_filter;
@@ -137,12 +139,16 @@ public:
void setOpen( bool );
void setup( void );
inline QString fullName( void )
inline QString fullName( QString _path = QString::null )
{
if( _path == QString::null )
{
_path = m_directories[0];
}
#ifdef QT4
return( QDir::cleanPath( m_path + "/" + text( 0 ) + "/" ) );
return( QDir::cleanPath( _path + "/" + text( 0 ) + "/" ) );
#else
return( QDir::cleanDirPath( m_path + "/" + text( 0 ) + "/" ) );
return( QDir::cleanDirPath( _path + "/" + text( 0 ) + "/" ) );
#endif
}
@@ -151,19 +157,26 @@ public:
return( m_pix );
}
inline void addDirectory( const QString & _dir )
{
m_directories.push_back( _dir );
}
private:
void initPixmapStuff( void );
//using Q3ListViewItem::setPixmap;
void FASTCALL setPixmap( QPixmap * _px );
void FASTCALL setPixmap( const QPixmap * _px );
bool addItems( const QString & _path );
static QPixmap * s_folderPixmap;
static QPixmap * s_folderOpenedPixmap;
static QPixmap * s_folderLockedPixmap;
directory * m_p;
QPixmap * m_pix;
QString m_path;
const QPixmap * m_pix;
QStringList m_directories;
QString m_filter;
} ;
@@ -175,9 +188,9 @@ class fileItem : public Q3ListViewItem
{
public:
fileItem( Q3ListView * _parent, const QString & _name,
const QString & _path );
const QString & _path );
fileItem( Q3ListViewItem * _parent, const QString & _name,
const QString & _path );
const QString & _path );
inline QString fullName( void ) const
{

View File

@@ -359,7 +359,7 @@ void configManager::createWidgets( void )
workingdir_layout->addWidget( workingdir_content );
/*
// page for files-management
m_pageFiles = new QWidget( m_contentWidget );
QHBoxLayout * files_layout = new QHBoxLayout( m_pageFiles );
@@ -502,12 +502,12 @@ void configManager::createWidgets( void )
files_layout->addWidget( files_logo_lbl );
files_layout->addWidget( files_content );
*/
addPage( m_pageIntro, tr( "Welcome to LMMS" ) );
addPage( m_pageWorkingDir, tr( "Select working directory" ) );
addPage( m_pageFiles, tr( "Copy or link files" ) );
//addPage( m_pageFiles, tr( "Copy or link files" ) );
switchPage( static_cast<csize>( 0 ) );
}
@@ -595,7 +595,11 @@ void configManager::accept( void )
return;
}
}
processFilesRecursively( m_dataDir + "samples/", m_workingDir +
mkPath( projectsDir() );
mkPath( samplesDir() );
mkPath( presetsDir() );
/* processFilesRecursively( m_dataDir + "samples/", m_workingDir +
"samples/",
m_samplesCopyRB->isChecked() ?
&copyFile :
@@ -609,7 +613,7 @@ void configManager::accept( void )
"projects/",
m_projectsCopyRB->isChecked() ?
&copyFile :
&linkFile );
&linkFile );*/
saveConfigFile();
QDialog::accept();
@@ -942,7 +946,7 @@ void configManager::saveConfigFile( void )
/*
void configManager::processFilesRecursively( const QString & _src_dir,
const QString & _dst_dir,
void( * _proc_func )( const QString & _src, const QString & _dst ) )
@@ -967,7 +971,7 @@ void configManager::processFilesRecursively( const QString & _src_dir,
}
}
}
*/

View File

@@ -61,16 +61,17 @@
#include "text_float.h"
#include "string_pair_drag.h"
#include "main_window.h"
#include "config_mgr.h"
fileBrowser::fileBrowser( const QString & _path, const QString & _filter,
fileBrowser::fileBrowser( const QString & _directories, const QString & _filter,
const QString & _title, const QPixmap & _pm,
QWidget * _parent, engine * _engine ) :
sideBarWidget( _title, _pm, _parent ),
engineObject( _engine ),
m_contextMenuItem( NULL ),
m_path( _path ),
m_directories( _directories ),
m_filter( _filter )
{
setWindowTitle( tr( "Browser" ) );
@@ -112,7 +113,49 @@ fileBrowser::~fileBrowser()
void fileBrowser::reloadTree( void )
{
m_l->clear();
QDir cdir( m_path );
QStringList paths = QStringList::split( '*', m_directories );
for( QStringList::iterator it = paths.begin(); it != paths.end(); ++it )
{
addItems( *it );
}
Q3ListViewItem * item = m_l->firstChild();
bool resort = FALSE;
// sort merged directories
while( item != NULL )
{
directory * d = dynamic_cast<directory *>( item );
if( d == NULL )
{
resort = TRUE;
}
else if( resort == TRUE )
{
Q3ListViewItem * i2 = m_l->firstChild();
d->moveItem( i2 );
i2->moveItem( d );
directory * d2 = NULL;
while( ( d2 = dynamic_cast<directory *>( i2 ) ) !=
NULL )
{
if( d->text( 0 ) > d2->text( 0 ) )
{
d->moveItem( d2 );
}
i2 = i2->nextSibling();
}
}
item = item->nextSibling();
}
}
void fileBrowser::addItems( const QString & _path )
{
QDir cdir( _path );
QStringList files = cdir.entryList( QDir::NoFilter, QDir::Name );
// TODO: after dropping qt3-support we can use QStringList's iterator
@@ -123,7 +166,7 @@ void fileBrowser::reloadTree( void )
{
QString cur_file = files[files.size() - i - 1];
if( cur_file[0] != '.' &&
!QFileInfo( m_path + "/" + cur_file ).isDir()
!QFileInfo( _path + "/" + cur_file ).isDir()
#ifdef QT4
// TBD
#else
@@ -131,7 +174,9 @@ void fileBrowser::reloadTree( void )
#endif
)
{
(void) new fileItem( m_l, cur_file, m_path );
// remove existing file-items
delete m_l->findItem( cur_file, 0 );
(void) new fileItem( m_l, cur_file, _path );
}
}
@@ -139,9 +184,19 @@ void fileBrowser::reloadTree( void )
{
QString cur_file = files[files.size() - i - 1];
if( cur_file[0] != '.' &&
QFileInfo( m_path + "/" + cur_file ).isDir() )
QFileInfo( _path + "/" + cur_file ).isDir() )
{
(void) new directory( m_l, cur_file, m_path, m_filter );
QListViewItem * item = m_l->findItem( cur_file, 0 );
if( item == NULL )
{
(void) new directory( m_l, cur_file, _path,
m_filter );
}
else if( dynamic_cast<directory *>( item ) != NULL )
{
dynamic_cast<directory *>( item )->
addDirectory( _path );
}
}
}
}
@@ -224,7 +279,8 @@ void fileBrowser::sendToActiveInstrumentTrack( void )
// instrument-track
while( w != NULL )
{
instrumentTrack * ct = dynamic_cast<instrumentTrack *>( w );
instrumentTrack * ct =
dynamic_cast<instrumentTrack *>( w );
#endif
if( ct != NULL && ct->isHidden() == FALSE )
{
@@ -355,20 +411,20 @@ void listView::contentsMouseDoubleClickEvent( QMouseEvent * _me )
{
// samples are per default opened in bb-editor because
// they're likely drum-samples etc.
instrumentTrack * ct = dynamic_cast<instrumentTrack *>(
instrumentTrack * it = dynamic_cast<instrumentTrack *>(
track::create( track::CHANNEL_TRACK,
eng()->getBBEditor() ) );
#ifdef LMMS_DEBUG
assert( ct != NULL );
assert( it != NULL );
#endif
instrument * afp = ct->loadInstrument(
instrument * afp = it->loadInstrument(
"audiofileprocessor" );
if( afp != NULL )
{
afp->setParameter( "samplefile",
f->fullName() );
}
ct->toggledInstrumentTrackButton( TRUE );
it->toggledInstrumentTrackButton( TRUE );
}
else if( f->type() == fileItem::PRESET_FILE )
{
@@ -407,6 +463,7 @@ void listView::contentsMousePressEvent( QMouseEvent * _me )
{
return;
}
QPoint p( contentsToViewport( _me->pos() ) );
Q3ListViewItem * i = itemAt( p );
if ( i )
@@ -421,6 +478,7 @@ void listView::contentsMousePressEvent( QMouseEvent * _me )
m_mousePressed = TRUE;
}
}
fileItem * f = dynamic_cast<fileItem *>( i );
if( f != NULL )
{
@@ -552,7 +610,7 @@ directory::directory( directory * _parent, const QString & _name,
Q3ListViewItem( _parent, _name ),
m_p( _parent ),
m_pix( NULL ),
m_path( _path ),
m_directories( _path ),
m_filter( _filter )
{
initPixmapStuff();
@@ -566,7 +624,7 @@ directory::directory( Q3ListView * _parent, const QString & _name,
Q3ListViewItem( _parent, _name ),
m_p( NULL ),
m_pix( NULL ),
m_path( _path ),
m_directories( _path ),
m_filter( _filter )
{
initPixmapStuff();
@@ -583,11 +641,13 @@ void directory::initPixmapStuff( void )
s_folderPixmap = new QPixmap(
embed::getIconPixmap( "folder" ) );
}
if( s_folderOpenedPixmap == NULL )
{
s_folderOpenedPixmap = new QPixmap(
embed::getIconPixmap( "folder_opened" ) );
}
if( s_folderLockedPixmap == NULL )
{
s_folderLockedPixmap = new QPixmap(
@@ -607,7 +667,7 @@ void directory::initPixmapStuff( void )
void directory::setPixmap( QPixmap * _px )
void directory::setPixmap( const QPixmap * _px )
{
m_pix = _px;
setup();
@@ -632,57 +692,18 @@ void directory::setOpen( bool _o )
if( _o && !childCount() )
{
QString s( fullName() );
QDir thisDir( s );
if( !thisDir.isReadable() )
for( QStringList::iterator it = m_directories.begin();
it != m_directories.end(); ++it )
{
//readable = FALSE;
setExpandable( FALSE );
return;
}
listView()->setUpdatesEnabled( FALSE );
QStringList files = thisDir.entryList( QDir::NoFilter,
QDir::Name );
for( csize i = 0; i < files.size(); ++i )
{
QString cur_file = files[files.size()-i-1];
#ifdef QT4
if( cur_file[0] != '.' && !QFileInfo(
thisDir.absolutePath() + "/" +
cur_file ).isDir() &&
thisDir.match( m_filter, cur_file.toLower() )
/*QDir::match( FILE_FILTER, cur_file )*/ )
#else
if( cur_file[0] != '.' && !QFileInfo(
thisDir.absPath() + "/" +
cur_file ).isDir() &&
thisDir.match( m_filter, cur_file.lower() )
/*QDir::match( FILE_FILTER, cur_file )*/ )
#endif
if( addItems( fullName( *it ) ) &&
( *it ).contains(
configManager::inst()->dataDir() ) )
{
(void) new fileItem( this, cur_file, s );
( new QListViewItem( this,
listView::tr( "--- Factory files ---" ) ) )->setPixmap( 0,
embed::getIconPixmap( "factory_files" ) );
}
}
for( csize i = 0; i < files.size(); ++i )
{
QString cur_file = files[files.size()-i-1];
#ifdef QT4
if( cur_file[0] != '.' && QFileInfo(
thisDir.absolutePath() + "/" +
cur_file ).isDir() )
#else
if( cur_file[0] != '.' && QFileInfo(
thisDir.absPath() + "/" +
cur_file ).isDir() )
#endif
{
(void) new directory( this, cur_file, s,
m_filter );
}
}
listView()->setUpdatesEnabled( TRUE );
}
Q3ListViewItem::setOpen( _o );
}
@@ -699,6 +720,90 @@ void directory::setup( void )
bool directory::addItems( const QString & _path )
{
QDir thisDir( _path );
if( !thisDir.isReadable() )
{
//readable = FALSE;
setExpandable( FALSE );
return( FALSE );
}
listView()->setUpdatesEnabled( FALSE );
bool added_something = FALSE;
QStringList files = thisDir.entryList( QDir::NoFilter, QDir::Name );
for( csize i = 0; i < files.size(); ++i )
{
QString cur_file = files[files.size() - i - 1];
#ifdef QT4
if( cur_file[0] != '.' && !QFileInfo(
thisDir.absolutePath() + "/" +
cur_file ).isDir() &&
thisDir.match( m_filter, cur_file.toLower() )
/*QDir::match( FILE_FILTER, cur_file )*/ )
#else
if( cur_file[0] != '.' && !QFileInfo(
thisDir.absPath() + "/" +
cur_file ).isDir() &&
thisDir.match( m_filter, cur_file.lower() )
/*QDir::match( FILE_FILTER, cur_file )*/ )
#endif
{
(void) new fileItem( this, cur_file, _path );
added_something = TRUE;
}
}
for( csize i = 0; i < files.size(); ++i )
{
QString cur_file = files[files.size() - i - 1];
#ifdef QT4
if( cur_file[0] != '.' && QFileInfo(
thisDir.absolutePath() + "/" +
cur_file ).isDir() )
#else
if( cur_file[0] != '.' && QFileInfo(
thisDir.absPath() + "/" +
cur_file ).isDir() )
#endif
{
new directory( this, cur_file, _path, m_filter );
added_something = TRUE;
#if 0
if( firstChild() == NULL )
{
continue;
}
bool moved = FALSE;
QListViewItem * item = firstChild();
while( item != NULL )
{
directory * cd =
dynamic_cast<directory *>( item );
if( cd != NULL )
{
/* if( moved == FALSE ||
cd->text( 0 ) < cur_file )
{*/
printf( "move item %s after %s\n", d->text(0).ascii(), cd->text(0).ascii());
d->moveItem( cd );
moved = TRUE;
//}
}
item = item->nextSibling();
}
#endif
}
}
listView()->setUpdatesEnabled( TRUE );
return( added_something );
}

View File

@@ -126,20 +126,27 @@ mainWindow::mainWindow( engine * _engine ) :
int id = 0;
QString wdir = configManager::inst()->workingDir();
side_bar->appendTab( new pluginBrowser( splitter, eng() ), ++id );
side_bar->appendTab( new fileBrowser( wdir+"projects",
side_bar->appendTab( new fileBrowser( configManager::inst()->dataDir()+
PROJECTS_PATH + "*" +
wdir+PROJECTS_PATH,
"*.mmp *.xml *.mid *.flp",
tr( "My projects" ),
embed::getIconPixmap( "project_file" ),
splitter, eng() ),
++id );
side_bar->appendTab( new fileBrowser( wdir+"samples", "*.wav *.ogg *.au"
side_bar->appendTab( new fileBrowser( configManager::inst()->dataDir()+
SAMPLES_PATH + "*" +
wdir+SAMPLES_PATH,
"*.wav *.ogg *.au"
"*.voc *.aif *.aiff *.flac *.raw",
tr( "My samples" ),
embed::getIconPixmap( "sound_file" ),
splitter, eng() ),
++id );
side_bar->appendTab( new fileBrowser( wdir+"presets", "*.cs.xml",
tr( "My presets" ),
side_bar->appendTab( new fileBrowser( configManager::inst()->dataDir()+
PRESETS_PATH + "*" +
wdir+PRESETS_PATH,
"*.cs.xml", tr( "My presets" ),
embed::getIconPixmap( "preset_file" ),
splitter, eng() ),
++id );

View File

@@ -135,7 +135,7 @@ void projectJournal::reallocID( const jo_id_t _id, journallingObject * _obj )
void projectJournal::forgetAboutID( const jo_id_t _id )
{
printf("forget about %d\n", _id );
//printf("forget about %d\n", _id );
journalEntryVector::iterator it;
while( ( it = qFind( m_journalEntries.begin(), m_journalEntries.end(),
_id ) ) != m_journalEntries.end() )