summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp103
1 files changed, 36 insertions, 67 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 8e88e9b..a6a9eca 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -188,50 +188,51 @@ void PlayListWidget::writeDefaultPlaylist() {
QString currentString = config.readEntry( "CurrentPlaylist", filename);
if( currentString == filename) {
Om3u *m3uList;
// qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>");
if( d->selectedFiles->first() ) {
m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate);
do {
// qDebug(d->selectedFiles->current()->file());
m3uList->add( d->selectedFiles->current()->file() );
}
while ( d->selectedFiles->next() );
m3uList->write();
m3uList->close();
if(m3uList) delete m3uList;
}
}
}
void PlayListWidget::addToSelection( const DocLnk& lnk ) {
d->setDocumentUsed = FALSE;
if ( mediaPlayerState->playlist() ) {
if( QFileInfo( lnk.file() ).exists() ||
- lnk.file().left(4) == "http" )
+ lnk.file().left(4) == "http" ) {
d->selectedFiles->addToSelection( lnk );
+ }
// writeCurrentM3u();
}
else
mediaPlayerState->setPlaying( TRUE );
}
void PlayListWidget::clearList() {
while ( first() ) {
d->selectedFiles->removeSelected();
}
}
void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
switch (mouse) {
case 1:
break;
case 2:
{
QPopupMenu m;
m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
m.exec( QCursor::pos() );
}
@@ -244,75 +245,82 @@ void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoi
switch (mouse) {
case 1:
break;
case 2:
{
QPopupMenu m;
m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
m.exec( QCursor::pos() );
}
break;
}
}
void PlayListWidget::addAllToList() {
DocLnkSet filesAll;
Global::findDocuments(&filesAll, "video/*;"+audioMimes);
QListIterator<DocLnk> Adit( filesAll.children() );
for ( ; Adit.current(); ++Adit ) {
if( QFileInfo( Adit.current()->file() ).exists() ) {
d->selectedFiles->addToSelection( **Adit );
}
}
+ tabWidget->setCurrentPage(0);
+
writeCurrentM3u();
+ d->selectedFiles->first();
}
void PlayListWidget::addAllMusicToList() {
if(!audioScan)
scanForAudio();
QListIterator<DocLnk> dit( files.children() );
for ( ; dit.current(); ++dit ) {
if( QFileInfo(dit.current()->file() ).exists() ) {
d->selectedFiles->addToSelection( **dit );
}
}
+ tabWidget->setCurrentPage(0);
writeCurrentM3u();
+ d->selectedFiles->first();
}
void PlayListWidget::addAllVideoToList() {
if(!videoScan)
scanForVideo();
QListIterator<DocLnk> dit( vFiles.children() );
for ( ; dit.current(); ++dit ) {
if( QFileInfo( dit.current()->file() ).exists() ) {
d->selectedFiles->addToSelection( **dit );
}
}
+ tabWidget->setCurrentPage(0);
writeCurrentM3u();
+ d->selectedFiles->first();
}
void PlayListWidget::setDocument( const QString& fileref ) {
qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref );
fromSetDocument = TRUE;
if ( fileref.isNull() ) {
QMessageBox::warning( this, tr( "Invalid File" ),
tr( "There was a problem in getting the file." ) );
return;
}
clearList();
if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u
readm3u( fileref );
} else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) {
readm3u( DocLnk( fileref).file() );
} else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls
readPls( fileref );
} else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) {
readPls( DocLnk( fileref).file() );
} else {
clearList();
addToSelection( DocLnk( fileref ) );
@@ -402,171 +410,132 @@ bool PlayListWidget::next() {
bool PlayListWidget::first() {
if ( mediaPlayerState->playlist() )
return d->selectedFiles->first();
else
return mediaPlayerState->looping();
}
bool PlayListWidget::last() {
if ( mediaPlayerState->playlist() )
return d->selectedFiles->last();
else
return mediaPlayerState->looping();
}
void PlayListWidget::saveList() {
writem3u();
}
void PlayListWidget::loadList( const DocLnk & lnk) {
QString name = lnk.name();
- qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name);
+ // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name);
if( name.length()>0) {
setCaption("OpiePlayer: "+name);
- qDebug("<<<<<<<<<<<<load list "+ lnk.file());
+// qDebug("<<<<<<<<<<<<load list "+ lnk.file());
clearList();
readm3u(lnk.file());
tabWidget->setCurrentPage(0);
}
}
void PlayListWidget::setPlaylist( bool shown ) {
if ( shown ) {
d->playListFrame->show();
} else {
d->playListFrame->hide();
}
}
void PlayListWidget::addSelected() {
qDebug("addSelected");
+ DocLnk lnk;
+ QString filename;
switch (whichList()) {
+
case 0: //playlist
+ return;
break;
case 1: { //audio
- QListViewItemIterator it( audioView );
- // iterate through all items of the listview
- for ( ; it.current(); ++it ) {
- if ( it.current()->isSelected() ) {
- QListIterator<DocLnk> dit( files.children() );
- for ( ; dit.current(); ++dit ) {
- if( dit.current()->name() == it.current()->text(0) ) {
- if( QFileInfo( dit.current()->file()).exists()) {
- d->selectedFiles->addToSelection( **dit );
- audioView->setSelected( it.current(),FALSE);
- }
- }
- }
- }
- }
-// tabWidget->setCurrentPage(0);
- writeCurrentM3u();
- d->selectedFiles->next();
+ filename=audioView->currentItem()->text(3);
+ // d->selectedFiles->next();
}
break;
+
case 2: { // video
- QListViewItemIterator it( videoView );
- // iterate through all items of the listview
- for ( ; it.current(); ++it ) {
- if ( it.current()->isSelected() ) {
- QListIterator<DocLnk> dit( vFiles.children() );
- for ( ; dit.current(); ++dit ) {
- if( dit.current()->name() == it.current()->text(0) ) {
- if(QFileInfo( dit.current()->file()).exists()) {
- d->selectedFiles->addToSelection( **dit );
- videoView->setSelected( it.current(),FALSE);
- }
- }
- }
- }
- }
+ filename=videoView->currentItem()->text(3);
// tabWidget->setCurrentPage(0);
- writeCurrentM3u();
}
break;
};
+ lnk.setName( QFileInfo(filename).baseName() ); //sets name
+ lnk.setFile( filename ); //sets file name
+ d->selectedFiles->addToSelection( lnk);
+ tabWidget->setCurrentPage(0);
+ writeCurrentM3u();
}
void PlayListWidget::removeSelected() {
d->selectedFiles->removeSelected( );
writeCurrentM3u();
}
void PlayListWidget::playIt( QListViewItem *it) {
if(!it) return;
mediaPlayerState->setPlaying(FALSE);
mediaPlayerState->setPlaying(TRUE);
d->selectedFiles->unSelect();
}
void PlayListWidget::addToSelection( QListViewItem *it) {
d->setDocumentUsed = FALSE;
if(it) {
switch ( whichList()) {
- case 1: {
- QListIterator<DocLnk> dit( files.children() );
- for ( ; dit.current(); ++dit ) {
- if( dit.current()->name() == it->text(0)) {
- if(QFileInfo( dit.current()->file()).exists()) {
- d->selectedFiles->addToSelection( **dit );
-// qDebug("blah "+ dit.current()->name());
-// d->selectedFiles->setSelectedItem( dit.current()->name());
- }
- }
- }
- writeCurrentM3u();
- }
- break;
- case 2: {
- QListIterator<DocLnk> dit( vFiles.children() );
- for ( ; dit.current(); ++dit ) {
- if( dit.current()->name() == it->text(0)) {
- if( QFileInfo( dit.current()->file()).exists() ) {
- d->selectedFiles->addToSelection( **dit );
-// qDebug("blah "+ dit.current()->name());
-// d->selectedFiles->setSelectedItem( dit.current()->name());
- }
- }
- }
- writeCurrentM3u();
-
- }
- break;
- case 0:
+ case 0: //playlist
+ return;
break;
};
+ // case 1: {
+ DocLnk lnk;
+ QString filename;
+
+ filename=it->text(3);
+ lnk.setName( QFileInfo(filename).baseName() ); //sets name
+ lnk.setFile( filename ); //sets file name
+ d->selectedFiles->addToSelection( lnk);
+
+ writeCurrentM3u();
tabWidget->setCurrentPage(0);
}
}
void PlayListWidget::tabChanged(QWidget *) {
switch ( whichList()) {
case 0:
{
if( !tbDeletePlaylist->isHidden() ) {
tbDeletePlaylist->hide();
}
d->tbRemoveFromList->setEnabled(TRUE);
d->tbAddToList->setEnabled(FALSE);
}
break;
case 1:
{
audioView->clear();
populateAudioView();
if( !tbDeletePlaylist->isHidden() ) {