diff --git a/ChangeLog b/ChangeLog index d59588f9a..bcba0fb5c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2006-04-06 Tobias Doerffel + + * 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 * include/sample_track.h: diff --git a/TODO b/TODO index dc47e7a49..0cd9c1352 100644 --- a/TODO +++ b/TODO @@ -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 diff --git a/configure.in b/configure.in index d37b1cfb6..703b3007b 100644 --- a/configure.in +++ b/configure.in @@ -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) diff --git a/data/themes/default/factory_files.png b/data/themes/default/factory_files.png new file mode 100644 index 000000000..469e59c68 Binary files /dev/null and b/data/themes/default/factory_files.png differ diff --git a/include/config_mgr.h b/include/config_mgr.h index a5d0d342c..ff6659973 100644 --- a/include/config_mgr.h +++ b/include/config_mgr.h @@ -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; diff --git a/include/file_browser.h b/include/file_browser.h index a34619c54..d7894c578 100644 --- a/include/file_browser.h +++ b/include/file_browser.h @@ -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 { diff --git a/src/core/config_mgr.cpp b/src/core/config_mgr.cpp index f8d5e1fca..ee0e4d6a3 100644 --- a/src/core/config_mgr.cpp +++ b/src/core/config_mgr.cpp @@ -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( 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() ? ©File : @@ -609,7 +613,7 @@ void configManager::accept( void ) "projects/", m_projectsCopyRB->isChecked() ? ©File : - &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, } } } - +*/ diff --git a/src/core/file_browser.cpp b/src/core/file_browser.cpp index 6787a1bb4..925d3f3f6 100644 --- a/src/core/file_browser.cpp +++ b/src/core/file_browser.cpp @@ -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( 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( 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( item ) != NULL ) + { + dynamic_cast( item )-> + addDirectory( _path ); + } } } } @@ -224,7 +279,8 @@ void fileBrowser::sendToActiveInstrumentTrack( void ) // instrument-track while( w != NULL ) { - instrumentTrack * ct = dynamic_cast( w ); + instrumentTrack * ct = + dynamic_cast( 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 * it = dynamic_cast( 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( 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( 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 ); +} + diff --git a/src/core/main_window.cpp b/src/core/main_window.cpp index 9d604851e..550a54f6e 100644 --- a/src/core/main_window.cpp +++ b/src/core/main_window.cpp @@ -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 ); diff --git a/src/lib/project_journal.cpp b/src/lib/project_journal.cpp index b1381f904..e6c376a51 100644 --- a/src/lib/project_journal.cpp +++ b/src/lib/project_journal.cpp @@ -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() )