author | llornkcor <llornkcor> | 2003-06-11 22:11:38 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-06-11 22:11:38 (UTC) |
commit | 24097a2790fd7bb241a0a8da24ef2996e4f4ad15 (patch) (side-by-side diff) | |
tree | 142e0fb758067bc9a601b3bd2dabdff27675c0f3 /core/multimedia/opieplayer/playlistwidget.cpp | |
parent | 188319af82322c84f02e1abb848d908ca8f9e26c (diff) | |
download | opie-24097a2790fd7bb241a0a8da24ef2996e4f4ad15.zip opie-24097a2790fd7bb241a0a8da24ef2996e4f4ad15.tar.gz opie-24097a2790fd7bb241a0a8da24ef2996e4f4ad15.tar.bz2 |
fix setDoc for playlists and others. remove qDebugs
Diffstat (limited to 'core/multimedia/opieplayer/playlistwidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 142 |
1 files changed, 57 insertions, 85 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 7ea95ab..1fc7dd8 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp @@ -306,15 +306,14 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) tabWidget->insertTab( vTab,tr("Video")); QWidget *LTab; LTab = new QWidget( tabWidget, "LTab" ); - playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy + playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE); QGridLayout *layoutL = new QGridLayout( LTab ); layoutL->setSpacing( 2); layoutL->setMargin( 2); layoutL->addMultiCellWidget( playLists, 0, 0, 0, 1 ); -// playLists->setMinimumSize(233,260); tabWidget->insertTab(LTab,tr("Lists")); connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); @@ -357,14 +356,14 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) setCentralWidget( vbox5 ); Config cfg( "OpiePlayer" ); readConfig( cfg ); - QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); - loadList(DocLnk( currentPlaylist)); - setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlaylist))); + + currentPlayList = cfg.readEntry("CurrentPlaylist","default"); + loadList(DocLnk( currentPlayList)); + setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlayList))); initializeStates(); - // audioUI->setFocus(); } PlayListWidget::~PlayListWidget() { @@ -420,17 +419,18 @@ void PlayListWidget::writeConfig( Config& cfg ) const { // 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." ) - ); - } +// 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++; } } @@ -446,14 +446,20 @@ void PlayListWidget::addToSelection( const DocLnk& lnk ) { d->selectedFiles->addToSelection( lnk ); } else mediaPlayerState->setPlaying( true); + } void PlayListWidget::clearList() { while ( first() ) d->selectedFiles->removeSelected(); + Config cfg( "OpiePlayer" ); + cfg.setGroup("PlayList"); + cfg.writeEntry("CurrentPlaylist",""); + currentPlayList=""; + } void PlayListWidget::addAllToList() { @@ -496,23 +502,22 @@ void PlayListWidget::addAllVideoToList() { void PlayListWidget::setDocument(const QString& fileref) { fromSetDocument = true; d->setDocumentUsed = TRUE; - d->selectedFiles->setSelected(d->selectedFiles->firstChild(),true ); - mediaPlayerState->setPlaying( FALSE ); - qApp->processEvents(); - mediaPlayerState->setPlaying( TRUE ); + setDocumentEx(fileref); } void PlayListWidget::setDocumentEx(const QString& fileref) { - + qDebug("opieplayer receive "+fileref); + clearList(); + DocLnk lnk; QFileInfo fileInfo(fileref); if ( !fileInfo.exists() ) { QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); return; } - qDebug("setDocument "+fileref); + // qDebug("<<<<<<<<<<<<<<<<<<<<<<setDocument "+fileref); QString extension = fileInfo.extension(false); if( extension.find( "m3u", 0, false) != -1) { //is m3u readm3u( fileref); } @@ -520,35 +525,41 @@ void PlayListWidget::setDocumentEx(const QString& fileref) { readPls( fileref); } else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist clearList(); - DocLnk lnk; lnk.setName( fileInfo.baseName() ); //sets name lnk.setFile( fileref ); //sets file name + lnk.setIcon("Sound"); //addToSelection( lnk ); loadList( lnk); d->selectedFiles->first(); } else { - clearList(); - DocLnk lnk; + if( fileref.find(".desktop",0,TRUE) != -1) { + lnk = DocLnk(fileref); + } else { lnk.setName( fileInfo.baseName() ); //sets name lnk.setFile( fileref ); //sets file name + lnk.setIcon("Sound"); + } + addToSelection( lnk ); // addToSelection( DocLnk( fileref ) ); + lnk.removeLinkFile(); + // qApp->processEvents(); + } + setCaption(tr("OpiePlayer")); d->setDocumentUsed = TRUE; + d->selectedFiles->setSelected(d->selectedFiles->firstChild(),true ); mediaPlayerState->setPlaying( FALSE ); qApp->processEvents(); mediaPlayerState->setPlaying( TRUE ); - // qApp->processEvents(); - setCaption(tr("OpiePlayer")); - } + } void PlayListWidget::setActiveWindow() { - qDebug("SETTING active window"); - + // qDebug("SETTING active window"); // When we get raised we need to ensure that it switches views char origView = mediaPlayerState->view(); mediaPlayerState->setView( 'l' ); // invalidate mediaPlayerState->setView( origView ); // now switch back @@ -560,28 +571,12 @@ void PlayListWidget::useSelectedDocument() { } const DocLnk *PlayListWidget::current() { // this is fugly - -// if( fromSetDocument) { -// qDebug("from setDoc"); -// DocLnkSet files; -// Global::findDocuments(&files, "video/*;audio/*"); -// QListIterator<DocLnk> dit( files.children() ); -// for ( ; dit.current(); ++dit ) { -// if(dit.current()->linkFile() == setDocFileRef) { -// qDebug(setDocFileRef); -// return dit; -// } -// } -// } else - - qDebug("current"); - switch (tabWidget->currentPageIndex()) { case 0: //playlist { - qDebug("playlist"); + // qDebug("playlist"); if ( mediaPlayerState->playlist() ) { return d->selectedFiles->current(); } else if ( d->setDocumentUsed && d->current ) { @@ -592,22 +587,20 @@ const DocLnk *PlayListWidget::current() { // this is fugly } break; case 1://audio { - qDebug("audioView"); + // qDebug("audioView"); QListIterator<DocLnk> dit( files.children() ); for ( ; dit.current(); ++dit ) { if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { - qDebug("here"); insanityBool=TRUE; return dit; } } } break; case 2: // video { - qDebug("videoView"); QListIterator<DocLnk> Vdit( vFiles.children() ); for ( ; Vdit.current(); ++Vdit ) { if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { insanityBool=TRUE; @@ -716,9 +709,8 @@ void PlayListWidget::setView( char view ) { hide(); } void PlayListWidget::addSelected() { - qDebug("addSelected"); DocLnk lnk; QString filename; switch (tabWidget->currentPageIndex()) { @@ -766,9 +758,8 @@ void PlayListWidget::removeSelected() { void PlayListWidget::playIt( QListViewItem *) { // d->setDocumentUsed = FALSE; // mediaPlayerState->curPosition =0; - qDebug("playIt"); // mediaPlayerState->setPlaying(FALSE); mediaPlayerState->setPlaying(TRUE); d->selectedFiles->unSelect(); } @@ -840,14 +831,12 @@ void PlayListWidget::tabChanged(QWidget *) { }; } void PlayListWidget::btnPlay(bool b) { - qDebug("<<<<<<<<<<<<<<<BtnPlay %d", b); // mediaPlayerState->setPlaying(b); switch ( tabWidget->currentPageIndex()) { case 0: { - qDebug("1"); // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { // QMessageBox::message("Note","You are trying to play\na malformed url."); // } else { @@ -858,9 +847,8 @@ void PlayListWidget::btnPlay(bool b) { } break; case 1: { - qDebug("2"); // d->selectedFiles->unSelect(); addToSelection( audioView->currentItem() ); mediaPlayerState->setPlaying( b); d->selectedFiles->removeSelected( ); @@ -870,9 +858,8 @@ void PlayListWidget::btnPlay(bool b) { }// audioView->clearSelection(); break; case 2: { - qDebug("3"); addToSelection( videoView->currentItem() ); mediaPlayerState->setPlaying( b); // qApp->processEvents(); @@ -921,9 +908,8 @@ void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int } void PlayListWidget::playSelected() { - qDebug("playSelected"); btnPlay( true); // d->selectedFiles->unSelect(); } @@ -948,9 +934,9 @@ void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoi void PlayListWidget::listDelete() { Config cfg( "OpiePlayer" ); cfg.setGroup("PlayList"); - QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); + currentPlayList = cfg.readEntry("CurrentPlaylist",""); QString file; // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); switch ( tabWidget->currentPageIndex()) { case 0: @@ -1072,17 +1058,15 @@ void PlayListWidget::populateVideoView() { } } void PlayListWidget::openFile() { - qDebug("<<<<<<<<<OPEN File"); QString filename, name; InputDialog *fileDlg; fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); fileDlg->exec(); if( fileDlg->result() == 1 ) { filename = fileDlg->text(); - qDebug( "Selected filename is " + filename ); -// Om3u *m3uList; + // qDebug( "Selected filename is " + filename ); DocLnk lnk; Config cfg( "OpiePlayer" ); cfg.setGroup("PlayList"); @@ -1090,23 +1074,14 @@ void PlayListWidget::openFile() { m3uFile = filename; if(filename.left(4) == "http") { if(filename.find(":",8,TRUE) != -1) { //found a port -// m3uFile = filename.left( filename.find( ":",8,TRUE)); m3uFile = filename; if( m3uFile.right( 1 ).find( '/' ) == -1) { m3uFile += "/"; } filename = m3uFile; -// qDebug("1 "+m3uFile); -// } else if(filename.left(4) == "http"){ -// m3uFile=filename; -// m3uFile = m3uFile.right( m3uFile.length() - 7); -// qDebug("2 "+m3uFile); -// } else{ -// m3uFile=filename; -// qDebug("3 "+m3uFile); - } + = } lnk.setName( m3uFile ); //sets name lnk.setFile( filename ); //sets file name lnk.setIcon("opieplayer2/musicfile"); d->selectedFiles->addToSelection( lnk ); @@ -1120,8 +1095,9 @@ void PlayListWidget::openFile() { } else { lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name lnk.setFile( filename ); //sets file name d->selectedFiles->addToSelection( lnk); + lnk.removeLinkFile(); writeCurrentM3u(); } } @@ -1133,9 +1109,9 @@ void PlayListWidget::openFile() { /* reads m3u and shows files/urls to playlist widget */ void PlayListWidget::readm3u( const QString &filename ) { - qDebug( "read m3u filename " + filename ); + // qDebug( "read m3u filename " + filename ); Om3u *m3uList; QString s, name; m3uList = new Om3u( filename, IO_ReadOnly ); @@ -1190,9 +1166,9 @@ void PlayListWidget::readm3u( const QString &filename ) { /* reads pls and adds files/urls to playlist */ void PlayListWidget::readPls( const QString &filename ) { - qDebug( "pls filename is " + filename ); + // qDebug( "pls filename is " + filename ); Om3u *m3uList; QString s, name; m3uList = new Om3u( filename, IO_ReadOnly ); m3uList->readPls(); @@ -1233,22 +1209,22 @@ void PlayListWidget::readPls( const QString &filename ) { /* writes current playlist to current m3u file */ void PlayListWidget::writeCurrentM3u() { - qDebug("writing to current m3u"); + // qDebug("writing to current m3u"); Config cfg( "OpiePlayer" ); cfg.setGroup("PlayList"); - QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); + currentPlayList = cfg.readEntry("CurrentPlaylist",""); Om3u *m3uList; - m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); + m3uList = new Om3u( currentPlayList, IO_ReadWrite | IO_Truncate ); if( d->selectedFiles->first()) { do { - qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); + // qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); m3uList->add( d->selectedFiles->current()->file() ); } while ( d->selectedFiles->next() ); - qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); + // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); m3uList->write(); m3uList->close(); if(m3uList) delete m3uList; @@ -1303,9 +1279,9 @@ void PlayListWidget::writem3u() { config.writeEntry("CurrentPlaylist",filename); currentPlayList=filename; if(!lnk.writeLink()) { - qDebug("Writing doclink did not work"); + // qDebug("Writing doclink did not work"); } setCaption(tr("OpiePlayer: ") + name); } @@ -1333,9 +1309,8 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e) case Key_F13: //mail // doUnblank(); break; case Key_Q: //add to playlist - qDebug("Add"); addSelected(); break; case Key_R: //remove from playlist removeSelected(); @@ -1344,9 +1319,8 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e) // qDebug("Play"); // playSelected(); // break; case Key_Space: - qDebug("Play"); // playSelected(); puh break; case Key_1: tabWidget->setCurrentPage(0); @@ -1397,9 +1371,9 @@ void PlayListWidget::keyPressEvent( QKeyEvent *) // } } void PlayListWidget::doBlank() { - qDebug("do blanking"); + // qDebug("do blanking"); fd=open("/dev/fb0",O_RDWR); if (fd != -1) { ioctl(fd,FBIOBLANK,1); // close(fd); @@ -1409,9 +1383,9 @@ void PlayListWidget::doBlank() { void PlayListWidget::doUnblank() { // this crashes opieplayer with a segfault // int fd; // fd=open("/dev/fb0",O_RDWR); - qDebug("do unblanking"); + // qDebug("do unblanking"); if (fd != -1) { ioctl(fd,FBIOBLANK,0); close(fd); } @@ -1460,9 +1434,9 @@ void PlayListWidget::skinsMenuActivated( int item ) { cfg.writeEntry("Skin", skinsMenu->text( item ) ); } void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { - qDebug("qcop message "+msg ); + // qDebug("qcop message "+msg ); QDataStream stream ( data, IO_ReadOnly ); if ( msg == "play()" ) { //plays current selection btnPlay( true); } else if ( msg == "stop()" ) { @@ -1497,10 +1471,8 @@ void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { addToSelection( lnk ); } else if ( msg == "rem(QString)" ) { //remove from playlist QString file; stream >> file; - } else if ( msg == "setDocument(QString)" ) { //loop or not loop QCopEnvelope h("QPE/Application/opieplayer", "raise()"); } - } |