author | llornkcor <llornkcor> | 2002-04-10 19:13:40 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-10 19:13:40 (UTC) |
commit | 9237a75548f9b932fbb1900d8ea28dbee9da81ac (patch) (side-by-side diff) | |
tree | a0249408df5ce581af8bcee5b6f58bcee1db461a | |
parent | 11d754ffa429875b526c49f125d8a844c5cda3d8 (diff) | |
download | opie-9237a75548f9b932fbb1900d8ea28dbee9da81ac.zip opie-9237a75548f9b932fbb1900d8ea28dbee9da81ac.tar.gz opie-9237a75548f9b932fbb1900d8ea28dbee9da81ac.tar.bz2 |
bug fix
-rw-r--r-- | core/multimedia/opieplayer/libmad/libmadplugin.cpp | 13 | ||||
-rw-r--r-- | core/multimedia/opieplayer/libmad/libmadplugin.h | 2 | ||||
-rw-r--r-- | core/multimedia/opieplayer/libmpeg3/mpeg3io.c | 20 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistselection.cpp | 18 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistselection.h | 4 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 98 |
6 files changed, 102 insertions, 53 deletions
diff --git a/core/multimedia/opieplayer/libmad/libmadplugin.cpp b/core/multimedia/opieplayer/libmad/libmadplugin.cpp index 9f8ba65..8ede537 100644 --- a/core/multimedia/opieplayer/libmad/libmadplugin.cpp +++ b/core/multimedia/opieplayer/libmad/libmadplugin.cpp @@ -19,47 +19,49 @@ **********************************************************************/ #include <stdio.h> #include <stdarg.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <string.h> #include <ctype.h> #include <errno.h> #include <time.h> #include <locale.h> #include <math.h> #include <assert.h> #include <qapplication.h> +#include <qpe/config.h> //#define HAVE_MMAP #if defined(HAVE_MMAP) # include <sys/mman.h> #endif #include "libmadplugin.h" extern "C" { #include "mad.h" } #define MPEG_BUFFER_SIZE 65536 +//#define MPEG_BUFFER_SIZE 32768 //16384 // 8192 //#define debugMsg(a) qDebug(a) #define debugMsg(a) class Input { public: char const *path; int fd; #if defined(HAVE_MMAP) void *fdm; #endif unsigned char *data; unsigned long length; int eof; }; @@ -152,65 +154,68 @@ bool LibMadPlugin::isFileSupported( const QString& path ) { char *ext = strrchr( path.latin1(), '.' ); // Test file extension if ( ext ) { if ( strncasecmp(ext, ".mp2", 4) == 0 ) return TRUE; if ( strncasecmp(ext, ".mp3", 4) == 0 ) return TRUE; } return FALSE; } bool LibMadPlugin::open( const QString& path ) { debugMsg( "LibMadPlugin::open" ); - + Config cfg("MediaPlayer"); + cfg.setGroup("Options"); + bufferSize = cfg.readNumEntry("MPeg_BufferSize",MPEG_BUFFER_SIZE); + qDebug("buffer size is %d", bufferSize); d->bad_last_frame = 0; d->flush = TRUE; info = QString( "" ); //qDebug( "Opening %s", path.latin1() ); d->input.path = path.latin1(); d->input.fd = ::open( d->input.path, O_RDONLY ); if (d->input.fd == -1) { qDebug("error opening %s", d->input.path ); return FALSE; } printID3Tags(); #if defined(HAVE_MMAP) struct stat stat; if (fstat(d->input.fd, &stat) == -1) { qDebug("error calling fstat"); return FALSE; } if (S_ISREG(stat.st_mode) && stat.st_size > 0) { d->input.length = stat.st_size; d->input.fdm = map_file(d->input.fd, &d->input.length); if (d->input.fdm == 0) { qDebug("error mmapping file"); return FALSE; } d->input.data = (unsigned char *)d->input.fdm; } #endif if (d->input.data == 0) { - d->input.data = (unsigned char *)malloc(MPEG_BUFFER_SIZE); + d->input.data = (unsigned char *)malloc( bufferSize /*MPEG_BUFFER_SIZE*/); if (d->input.data == 0) { qDebug("error allocating input buffer"); return FALSE; } d->input.length = 0; } d->input.eof = 0; mad_stream_init(&d->stream); mad_frame_init(&d->frame); mad_synth_init(&d->synth); return TRUE; } @@ -356,44 +361,44 @@ bool LibMadPlugin::read() { } d->input.data = (unsigned char *)d->input.fdm; } mad_stream_buffer(&d->stream, d->input.data + skip, d->input.length - skip); } else #endif { if (d->stream.next_frame) { memmove(d->input.data, d->stream.next_frame, d->input.length = &d->input.data[d->input.length] - d->stream.next_frame); } do { - len = ::read(d->input.fd, d->input.data + d->input.length, MPEG_BUFFER_SIZE - d->input.length); + len = ::read(d->input.fd, d->input.data + d->input.length, bufferSize /* MPEG_BUFFER_SIZE*/ - d->input.length); } while (len == -1 && errno == EINTR); if (len == -1) { qDebug("error reading audio"); return FALSE; } else if (len == 0) { d->input.eof = 1; - assert(MPEG_BUFFER_SIZE - d->input.length >= MAD_BUFFER_GUARD); + assert(bufferSize /*MPEG_BUFFER_SIZE*/ - d->input.length >= MAD_BUFFER_GUARD); while (len < MAD_BUFFER_GUARD) d->input.data[d->input.length + len++] = 0; } mad_stream_buffer(&d->stream, d->input.data, d->input.length += len); } return TRUE; } static mad_fixed_t left_err, right_err; static const int bits = 16; static const int shift = MAD_F_FRACBITS + 1 - bits; diff --git a/core/multimedia/opieplayer/libmad/libmadplugin.h b/core/multimedia/opieplayer/libmad/libmadplugin.h index b240b77..46cd4a1 100644 --- a/core/multimedia/opieplayer/libmad/libmadplugin.h +++ b/core/multimedia/opieplayer/libmad/libmadplugin.h @@ -90,21 +90,21 @@ public: bool setMMX( bool ) { return FALSE; } // Capabilities bool supportsAudio() { return TRUE; } bool supportsVideo() { return FALSE; } bool supportsYUV() { return FALSE; } bool supportsMMX() { return TRUE; } bool supportsSMP() { return FALSE; } bool supportsStereo() { return TRUE; } bool supportsScaling() { return FALSE; } long getPlayTime() { return -1; } private: LibMadPluginData *d; QString info; - +int bufferSize; }; #endif diff --git a/core/multimedia/opieplayer/libmpeg3/mpeg3io.c b/core/multimedia/opieplayer/libmpeg3/mpeg3io.c index c5807a7..c5cae00 100644 --- a/core/multimedia/opieplayer/libmpeg3/mpeg3io.c +++ b/core/multimedia/opieplayer/libmpeg3/mpeg3io.c @@ -21,42 +21,42 @@ mpeg3_fs_t* mpeg3_new_fs(char *path) int mpeg3_delete_fs(mpeg3_fs_t *fs) { mpeg3_delete_css(fs->css); free(fs); return 0; } int mpeg3_copy_fs(mpeg3_fs_t *dst, mpeg3_fs_t *src) { strcpy(dst->path, src->path); dst->current_byte = 0; return 0; } long mpeg3io_get_total_bytes(mpeg3_fs_t *fs) { -/* - * struct stat st; - * if(stat(fs->path, &st) < 0) return 0; - * return (long)st.st_size; - */ - - fseek(fs->fd, 0, SEEK_END); - fs->total_bytes = ftell(fs->fd); - fseek(fs->fd, 0, SEEK_SET); - return fs->total_bytes; + + struct stat st; + if(stat(fs->path, &st) < 0) return 0; + return (long)st.st_size; + + +/* fseek(fs->fd, 0, SEEK_END); */ +/* fs->total_bytes = ftell(fs->fd); */ +/* fseek(fs->fd, 0, SEEK_SET); */ +/* return fs->total_bytes; */ } int mpeg3io_open_file(mpeg3_fs_t *fs) { /* Need to perform authentication before reading a single byte. */ mpeg3_get_keys(fs->css, fs->path); if(!(fs->fd = fopen(fs->path, "rb"))) { perror("mpeg3io_open_file"); return 1; } fs->total_bytes = mpeg3io_get_total_bytes(fs); if(!fs->total_bytes) diff --git a/core/multimedia/opieplayer/playlistselection.cpp b/core/multimedia/opieplayer/playlistselection.cpp index 6259b3f..8f3711a 100644 --- a/core/multimedia/opieplayer/playlistselection.cpp +++ b/core/multimedia/opieplayer/playlistselection.cpp @@ -6,64 +6,66 @@ ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include <qpe/applnk.h> #include <qpe/resource.h> +#include <qpe/config.h> + #include <qpainter.h> #include <qimage.h> #include <qheader.h> #include <qlistview.h> #include <qlist.h> #include <qpixmap.h> #include "playlistselection.h" #include <stdlib.h> class PlayListSelectionItem : public QListViewItem { public: PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { setText( 0, f->name() ); setPixmap( 0, f->pixmap() ); } ~PlayListSelectionItem() { }; const DocLnk *file() const { return fl; } private: const DocLnk *fl; }; PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) : QListView( parent, name ) { - qDebug("starting playlistselector"); +// qDebug("starting playlistselector"); // #ifdef USE_PLAYLIST_BACKGROUND // setStaticBackground( TRUE ); // setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/background" ) ); // setBackgroundPixmap( Resource::loadPixmap( "launcher/opielogo" ) ); // #endif // addColumn("Title",236); // setAllColumnsShowFocus( TRUE ); addColumn( tr( "Playlist Selection" ) ); header()->hide(); setSorting( -1, FALSE ); } PlayListSelection::~PlayListSelection() { } @@ -172,16 +174,30 @@ bool PlayListSelection::last() { QListViewItem *item = firstChild(); while ( ( item = item->nextSibling() ) ) prevItem = item; if ( prevItem ) setSelected( prevItem, TRUE ); else return FALSE; ensureItemVisible( selectedItem() ); return TRUE; } void PlayListSelection::unSelect() { QListViewItem *item = selectedItem(); setSelected( currentItem(), FALSE); }
\ No newline at end of file + +void PlayListSelection::writeCurrent( Config& cfg ) { + cfg.setGroup("PlayList"); + QListViewItem *item = selectedItem(); + if ( item ) + cfg.writeEntry("current", item->text(0) ); + qDebug(item->text(0)); + +} + +void PlayListSelection::setSelectedItem(const QString &strk ) { +// setSelected( item, TRUE ); +// ensureItemVisible( selectedItem() ); +} diff --git a/core/multimedia/opieplayer/playlistselection.h b/core/multimedia/opieplayer/playlistselection.h index ba37271..d10bc82 100644 --- a/core/multimedia/opieplayer/playlistselection.h +++ b/core/multimedia/opieplayer/playlistselection.h @@ -10,47 +10,49 @@ ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef PLAY_LIST_SELECTION_H #define PLAY_LIST_SELECTION_H #include <qlist.h> #include <qlistview.h> #include <qpe/applnk.h> - +#include <qpe/config.h> class PlayListSelection : public QListView { Q_OBJECT public: PlayListSelection( QWidget *parent, const char *name=0 ); ~PlayListSelection(); const DocLnk *current(); // retrieve the current playlist entry (media file link) public slots: void addToSelection( const DocLnk & ); // Add a media file to the playlist void removeSelected(); // Remove a media file from the playlist void moveSelectedUp(); // Move the media file up the playlist so it is played earlier void moveSelectedDown(); // Move the media file down the playlist so it is played later void unSelect(); + void writeCurrent( Config &); + void setSelectedItem( const QString & ); bool prev(); bool next(); bool first(); bool last(); protected: virtual void contentsMouseMoveEvent(QMouseEvent *); /* #ifdef USE_PLAYLIST_BACKGROUND */ virtual void drawBackground( QPainter *p, const QRect &r ); virtual void paintEmptyArea( QPainter *p, const QRect &r ) { drawBackground( p, r ); }; /* #endif */ private: QList<DocLnk> selectedList; const DocLnk *lnk; }; diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 3b8f6d7..63df715 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp @@ -12,32 +12,33 @@ ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ // code added by L. J. Potter Sat 03-02-2002 06:17:54 #define QTOPIA_INTERNAL_FSLP #include <qpe/qpemenubar.h> #include <qpe/qpetoolbar.h> #include <qpe/fileselector.h> #include <qpe/qpeapplication.h> #include <qpe/lnkproperties.h> +#include <qpe/storage.h> #include <qpe/applnk.h> #include <qpe/config.h> #include <qpe/global.h> #include <qpe/resource.h> #include <qaction.h> #include <qimage.h> #include <qfile.h> #include <qdir.h> #include <qlayout.h> #include <qlabel.h> #include <qlist.h> #include <qlistbox.h> #include <qmainwindow.h> #include <qmessagebox.h> #include <qtoolbutton.h> @@ -203,54 +204,60 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch QWidget *aTab; aTab = new QWidget( tabWidget, "aTab" ); audioView = new QListView( aTab, "Audioview" ); audioView->setMinimumSize(233,260); audioView->addColumn( tr("Title"),140); audioView->addColumn(tr("Size"), -1); audioView->addColumn(tr("Media"),-1); audioView->setColumnAlignment(1, Qt::AlignRight); audioView->setColumnAlignment(2, Qt::AlignRight); audioView->setAllColumnsShowFocus(TRUE); +// audioView->setMultiSelection( TRUE ); +// audioView->setSelectionMode( QListView::Extended); + tabWidget->insertTab(aTab,tr("Audio")); QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); // audioView populateAudioView(); // videowidget QWidget *vTab; vTab = new QWidget( tabWidget, "vTab" ); videoView = new QListView( vTab, "Videoview" ); videoView->setMinimumSize(233,260); videoView->addColumn(tr("Title"),140); videoView->addColumn(tr("Size"),-1); videoView->addColumn(tr("Media"),-1); videoView->setColumnAlignment(1, Qt::AlignRight); videoView->setColumnAlignment(2, Qt::AlignRight); videoView->setAllColumnsShowFocus(TRUE); +// videoView->setMultiSelection( TRUE ); +// videoView->setSelectionMode( QListView::Extended); + QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); tabWidget->insertTab( vTab,tr("Video")); //playlists list QWidget *LTab; LTab = new QWidget( tabWidget, "LTab" ); playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy playLists->setMinimumSize(233,260);; tabWidget->insertTab(LTab,tr("Lists")); connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); // connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); @@ -305,121 +312,119 @@ PlayListWidget::~PlayListWidget() { void PlayListWidget::initializeStates() { d->tbPlay->setOn( mediaPlayerState->playing() ); d->tbLoop->setOn( mediaPlayerState->looping() ); d->tbShuffle->setOn( mediaPlayerState->shuffled() ); // d->tbFull->setOn( mediaPlayerState->fullscreen() ); // d->tbScale->setOn( mediaPlayerState->scaled() ); // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); // setPlaylist( mediaPlayerState->playlist() ); setPlaylist( true); d->selectedFiles->first(); } void PlayListWidget::readConfig( Config& cfg ) { cfg.setGroup("PlayList"); - + QString currentString = cfg.readEntry("current", "" ); int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); - for ( int i = 0; i < noOfFiles; i++ ) { QString entryName; entryName.sprintf( "File%i", i + 1 ); QString linkFile = cfg.readEntry( entryName ); DocLnk lnk( linkFile ); - if ( lnk.isValid() ) + if ( lnk.isValid() ) { d->selectedFiles->addToSelection( lnk ); } } +// d->selectedFiles->setSelectedItem( (const QString &)currentString); +} void PlayListWidget::writeConfig( Config& cfg ) const { - cfg.setGroup("PlayList"); + d->selectedFiles->writeCurrent( cfg); + cfg.setGroup("PlayList"); int noOfFiles = 0; - d->selectedFiles->first(); do { const DocLnk *lnk = d->selectedFiles->current(); if ( lnk ) { QString entryName; entryName.sprintf( "File%i", noOfFiles + 1 ); + qDebug(entryName); cfg.writeEntry( entryName, lnk->linkFile() ); // if this link does exist, add it so we have the file // next time... if ( !QFile::exists( lnk->linkFile() ) ) { // the way writing lnks doesn't really check for out // of disk space, but check it anyway. if ( !lnk->writeLink() ) { QMessageBox::critical( 0, tr("Out of space"), tr( "There was a problem saving " "the playlist.\n" "Your playlist " "may be missing some entries\n" "the next time you start it." ) ); } } noOfFiles++; } - } while ( d->selectedFiles->next() ); - + } + while ( d->selectedFiles->next() ); cfg.writeEntry("NumberOfFiles", noOfFiles ); - - } void PlayListWidget::addToSelection( const DocLnk& lnk ) { // qDebug("add"); d->setDocumentUsed = FALSE; if ( mediaPlayerState->playlist() ) d->selectedFiles->addToSelection( lnk ); else mediaPlayerState->setPlaying( TRUE ); } void PlayListWidget::clearList() { while ( first() ) d->selectedFiles->removeSelected(); } void PlayListWidget::addAllToList() { - DocLnkSet files; - Global::findDocuments(&files, "video/*;audio/*"); - QListIterator<DocLnk> dit( files.children() ); - for ( ; dit.current(); ++dit ) - d->selectedFiles->addToSelection( **dit ); + DocLnkSet filesAll; + Global::findDocuments(&filesAll, "video/*;audio/*"); + QListIterator<DocLnk> Adit( filesAll.children() ); + for ( ; Adit.current(); ++Adit ) + d->selectedFiles->addToSelection( **Adit ); } void PlayListWidget::addAllMusicToList() { - DocLnkSet files; - Global::findDocuments(&files, "audio/*"); +// DocLnkSet files; +// Global::findDocuments(&files, "audio/*"); QListIterator<DocLnk> dit( files.children() ); for ( ; dit.current(); ++dit ) d->selectedFiles->addToSelection( **dit ); } void PlayListWidget::addAllVideoToList() { - DocLnkSet files; - Global::findDocuments(&files, "video/*"); - QListIterator<DocLnk> dit( files.children() ); + QListIterator<DocLnk> dit( vFiles.children() ); for ( ; dit.current(); ++dit ) d->selectedFiles->addToSelection( **dit ); } void PlayListWidget::setDocument(const QString& fileref) { fromSetDocument = TRUE; if ( fileref.isNull() ) { QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); return; } // qDebug("setDocument "+fileref); if(fileref.find("playlist",0,TRUE) == -1) { clearList(); addToSelection( DocLnk( fileref ) ); d->setDocumentUsed = TRUE; @@ -575,70 +580,77 @@ bool PlayListWidget::last() { } void PlayListWidget::saveList() { QString filename; InputDialog *fileDlg; fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); fileDlg->exec(); if( fileDlg->result() == 1 ) { if ( d->current ) delete d->current; filename = fileDlg->LineEdit1->text();//+".playlist"; // qDebug("saving playlist "+filename+".playlist"); Config cfg( filename +".playlist"); writeConfig( cfg ); - if( playLists->selected()->name() == filename) { -// qDebug("same name so delete lnk"); - QFile().remove(playLists->selected()->file()); - QFile().remove(playLists->selected()->linkFile()); - playLists->reread(); - } +// qDebug("same name so delete lnk??"); +// if( playLists->selected()->name() == filename) { + +// qDebug("same name so delete lnk"); +// QFile().remove(playLists->selected()->file()); +// QFile().remove(playLists->selected()->linkFile()); +// playLists->reread(); +// } +// qDebug("new doclnk"); DocLnk lnk; // lnk.setComment( ""); lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D lnk.setIcon("mpegplayer/playlist2"); lnk.setName( filename); //sets file name + qDebug(filename); if(!lnk.writeLink()) qDebug("Writing doclink did not work"); } Config config( "MediaPlayer" ); config.writeEntry("CurrentPlaylist",filename); setCaption(tr("OpiePlayer: ")+filename); d->selectedFiles->first(); if(fileDlg) delete fileDlg; } void PlayListWidget::loadList( const DocLnk & lnk) { QString name= lnk.name(); // qDebug("currentList is "+name); if( name.length()>1) { setCaption("OpiePlayer: "+name); // qDebug("load list "+ name+".playlist"); clearList(); Config cfg( name+".playlist"); readConfig(cfg); + tabWidget->setCurrentPage(0); + Config config( "MediaPlayer" ); config.writeEntry("CurrentPlaylist", name); - d->selectedFiles->first(); +// d->selectedFiles->first(); } + } void PlayListWidget::setPlaylist( bool shown ) { if ( shown ) d->playListFrame->show(); else d->playListFrame->hide(); } void PlayListWidget::setView( char view ) { if ( view == 'l' ) showMaximized(); else hide(); } @@ -770,44 +782,46 @@ void PlayListWidget::tabChanged(QWidget *widg) { void PlayListWidget::btnPlay(bool b) { // mediaPlayerState->setPlaying(b); switch ( tabWidget->currentPageIndex()) { case 0: { mediaPlayerState->setPlaying(b); } break; case 1: { addToSelection( audioView->selectedItem() ); mediaPlayerState->setPlaying(b); // qApp->processEvents(); d->selectedFiles->removeSelected( ); tabWidget->setCurrentPage(1); - d->selectedFiles->unSelect(); + audioView->clearSelection(); +// d->selectedFiles->unSelect(); // mediaPlayerState->setPlaying(FALSE); } break; case 2: { addToSelection( videoView->selectedItem() ); mediaPlayerState->setPlaying(b); qApp->processEvents(); d->selectedFiles->removeSelected( ); tabWidget->setCurrentPage(2); - d->selectedFiles->unSelect(); + videoView->clearSelection(); +// d->selectedFiles->unSelect(); // mediaPlayerState->setPlaying(FALSE); } break; }; } void PlayListWidget::deletePlaylist() { switch( QMessageBox::information( this, (tr("Remove Playlist?")), (tr("You really want to delete\nthis playlist?")), (tr("Yes")), (tr("No")), 0 )){ case 0: // Yes clicked, QFile().remove(playLists->selected()->file()); QFile().remove(playLists->selected()->linkFile()); playLists->reread(); break; case 1: // Cancel @@ -892,50 +906,62 @@ void PlayListWidget::listDelete() { // AppLnk lnk( AppLnk(linkFile)); // if( lnk.name() == file ) { // LnkProperties prop( &lnk); // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); // prop.showMaximized(); // prop.exec(); // } // } } break; }; } void PlayListWidget::populateAudioView() { // if(files) // files.~DocLnkSet(); + StorageInfo storageInfo; + const QList<FileSystem> &fs = storageInfo.fileSystems(); + Global::findDocuments(&files, "audio/*"); QListIterator<DocLnk> dit( files.children() ); + QListIterator<FileSystem> it ( fs ); audioView->clear(); QString storage; for ( ; dit.current(); ++dit ) { + for( ; it.current(); ++it ){ + const QString name = (*it)->name(); + const QString path = (*it)->path(); + if(dit.current()->file().find(path) != -1 ) storage=name; + } + QListViewItem * newItem; - if(dit.current()->file().find("/mnt/cf") != -1 ) storage=tr("CF"); - else if(dit.current()->file().find("/mnt/hda") != -1 ) storage=tr("CF"); - else if(dit.current()->file().find("/mnt/card") != -1 ) storage=tr("SD"); - else storage=tr("RAM"); if ( QFile( dit.current()->file()).exists() ) { newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" )); } } } void PlayListWidget::populateVideoView() { + StorageInfo storageInfo; + const QList<FileSystem> &fs = storageInfo.fileSystems(); + Global::findDocuments(&vFiles, "video/*"); QListIterator<DocLnk> Vdit( vFiles.children() ); + QListIterator<FileSystem> it ( fs ); videoView->clear(); QString storage; for ( ; Vdit.current(); ++Vdit ) { - if( Vdit.current()->file().find("/mnt/cf") != -1 ) storage=tr("CF"); - else if( Vdit.current()->file().find("/mnt/hda") != -1 ) storage=tr("CF"); - else if( Vdit.current()->file().find("/mnt/card") != -1 ) storage=tr("SD"); - else storage=tr("RAM"); + for( ; it.current(); ++it ){ + const QString name = (*it)->name(); + const QString path = (*it)->path(); + if( Vdit.current()->file().find(path) != -1 ) storage=name; + } + QListViewItem * newItem; if ( QFile( Vdit.current()->file()).exists() ) { newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); } } } |