-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 83eb83b..98326a8 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp @@ -737,64 +737,70 @@ void PlayListWidget::openFile() { if( str.right( 3) == "m3u" || str.right(3) == "pls" ) { readListFromFile( str ); } else { QFileInfo info( str ); DocLnk lnk = addFileToPlaylist( str, info.baseName() ); d->selectedFiles->setSelectedItem( lnk.name() ); } setButtons(); } void PlayListWidget::openDirectory() { QString str = OFileDialog::getDirectory( OFileSelector::DirectorySelector, QString::null, 0, tr( "Add Files from Directory")); if(str.isEmpty() ) return; if(str.left(2) == "//") str=str.right(str.length()-1); QDir dir( str ); QStringList lst = dir.entryList(QDir::Files|QDir::Readable); for ( QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { QString filename = str + "/" + *it; if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) readListFromFile( filename ); else { addFileToPlaylist( filename, QFileInfo(*it).baseName() ); } } + + if (!d->selectedFiles->isEmpty()) { + d->selectedFiles->first(); + + setButtons(); + } } void PlayListWidget::readListFromFile( const QString &filename ) { odebug << "read list filename " + filename << oendl; QFileInfo fi(filename); Om3u *m3uList; QString s, name; m3uList = new Om3u( filename, IO_ReadOnly ); if(fi.extension(false).find("m3u",0,false) != -1 ) m3uList->readM3u(); else if(fi.extension(false).find("pls",0,false) != -1 ) m3uList->readPls(); DocLnk lnk; for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { s = *it; // odebug << s << oendl; if(s.left(4)=="http") { lnk.setName( s ); //sets file name lnk.setIcon("opieplayer2/musicfile"); lnk.setFile( s ); //sets file name } else { //is file lnk.setName( QFileInfo(s).baseName()); if(s.left(1) != "/") { lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); } else { lnk.setFile( s); } } d->selectedFiles->addToSelection( lnk ); |