Diffstat (limited to 'core/multimedia/opieplayer/playlistwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 212 |
1 files changed, 121 insertions, 91 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 9969526..524747e 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -96,24 +96,25 @@ public: | |||
96 | connect( this, SIGNAL( activated() ), handler, slot ); | 96 | connect( this, SIGNAL( activated() ), handler, slot ); |
97 | addTo( parent ); | 97 | addTo( parent ); |
98 | } | 98 | } |
99 | }; | 99 | }; |
100 | 100 | ||
101 | 101 | ||
102 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 102 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
103 | : QMainWindow( parent, name, fl ) { | 103 | : QMainWindow( parent, name, fl ) { |
104 | 104 | ||
105 | d = new PlayListWidgetPrivate; | 105 | d = new PlayListWidgetPrivate; |
106 | d->setDocumentUsed = FALSE; | 106 | d->setDocumentUsed = FALSE; |
107 | d->current = NULL; | 107 | d->current = NULL; |
108 | fromSetDocument = FALSE; | ||
108 | // menuTimer = new QTimer( this ,"menu timer"), | 109 | // menuTimer = new QTimer( this ,"menu timer"), |
109 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); | 110 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); |
110 | 111 | ||
111 | setBackgroundMode( PaletteButton ); | 112 | setBackgroundMode( PaletteButton ); |
112 | 113 | ||
113 | setCaption( tr("OpiePlayer") ); | 114 | setCaption( tr("OpiePlayer") ); |
114 | setIcon( Resource::loadPixmap( "MPEGPlayer" ) ); | 115 | setIcon( Resource::loadPixmap( "MPEGPlayer" ) ); |
115 | 116 | ||
116 | setToolBarsMovable( FALSE ); | 117 | setToolBarsMovable( FALSE ); |
117 | 118 | ||
118 | // Create Toolbar | 119 | // Create Toolbar |
119 | QPEToolBar *toolbar = new QPEToolBar( this ); | 120 | QPEToolBar *toolbar = new QPEToolBar( this ); |
@@ -165,55 +166,68 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
165 | scaleButton->addTo(pmView); | 166 | scaleButton->addTo(pmView); |
166 | 167 | ||
167 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); | 168 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); |
168 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | 169 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); |
169 | 170 | ||
170 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | 171 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); |
171 | 172 | ||
172 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 173 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
173 | tabWidget->setTabShape(QTabWidget::Triangular); | 174 | tabWidget->setTabShape(QTabWidget::Triangular); |
174 | 175 | ||
175 | QWidget *pTab; | 176 | QWidget *pTab; |
176 | pTab = new QWidget( tabWidget, "pTab" ); | 177 | pTab = new QWidget( tabWidget, "pTab" ); |
177 | playlistView = new QListView( pTab, "Videoview" ); | 178 | // playlistView = new QListView( pTab, "playlistview" ); |
178 | playlistView->setMinimumSize(236,260); | 179 | // playlistView->setMinimumSize(236,260); |
179 | tabWidget->insertTab( pTab,"Playlist"); | 180 | tabWidget->insertTab( pTab,"Playlist"); |
180 | 181 | ||
182 | |||
181 | // Add the playlist area | 183 | // Add the playlist area |
182 | 184 | ||
183 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); | 185 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); |
184 | d->playListFrame = vbox3; | 186 | d->playListFrame = vbox3; |
185 | d->playListFrame ->setMinimumSize(235,260); | 187 | d->playListFrame ->setMinimumSize(235,260); |
186 | 188 | ||
187 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); | 189 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); |
188 | 190 | ||
189 | d->selectedFiles = new PlayListSelection( hbox2); | 191 | d->selectedFiles = new PlayListSelection( hbox2); |
190 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); | 192 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); |
191 | 193 | ||
194 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); | ||
195 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | ||
196 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); | ||
197 | |||
198 | |||
192 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | 199 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch |
193 | new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 200 | new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
194 | new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | 201 | new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); |
195 | new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 202 | new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
196 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 203 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
197 | 204 | ||
198 | QWidget *aTab; | 205 | QWidget *aTab; |
199 | aTab = new QWidget( tabWidget, "aTab" ); | 206 | aTab = new QWidget( tabWidget, "aTab" ); |
200 | audioView = new QListView( aTab, "Audioview" ); | 207 | audioView = new QListView( aTab, "Audioview" ); |
201 | audioView->setMinimumSize(233,260); | 208 | audioView->setMinimumSize(233,260); |
202 | audioView->addColumn( "Title",150); | 209 | audioView->addColumn( "Title",150); |
203 | audioView->addColumn("Size", 45); | 210 | audioView->addColumn("Size", 45); |
204 | audioView->addColumn("Media",35); | 211 | audioView->addColumn("Media",35); |
205 | audioView->setColumnAlignment(1, Qt::AlignRight); | 212 | audioView->setColumnAlignment(1, Qt::AlignRight); |
206 | audioView->setColumnAlignment(2, Qt::AlignRight); | 213 | audioView->setColumnAlignment(2, Qt::AlignRight); |
214 | audioView->setAllColumnsShowFocus(TRUE); | ||
207 | tabWidget->insertTab(aTab,"Audio"); | 215 | tabWidget->insertTab(aTab,"Audio"); |
216 | |||
217 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); | ||
218 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | ||
219 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | ||
220 | |||
221 | |||
208 | // audioView | 222 | // audioView |
209 | Global::findDocuments(&files, "audio/*"); | 223 | Global::findDocuments(&files, "audio/*"); |
210 | QListIterator<DocLnk> dit( files.children() ); | 224 | QListIterator<DocLnk> dit( files.children() ); |
211 | QString storage; | 225 | QString storage; |
212 | for ( ; dit.current(); ++dit ) { | 226 | for ( ; dit.current(); ++dit ) { |
213 | QListViewItem * newItem; | 227 | QListViewItem * newItem; |
214 | if(dit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; | 228 | if(dit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; |
215 | else if(dit.current()->file().find("/mnt/hda") != -1 ) storage="CF"; | 229 | else if(dit.current()->file().find("/mnt/hda") != -1 ) storage="CF"; |
216 | else if(dit.current()->file().find("/mnt/card") != -1 ) storage="SD"; | 230 | else if(dit.current()->file().find("/mnt/card") != -1 ) storage="SD"; |
217 | else storage="RAM"; | 231 | else storage="RAM"; |
218 | if ( QFile( dit.current()->file()).exists() ) { | 232 | if ( QFile( dit.current()->file()).exists() ) { |
219 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); | 233 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); |
@@ -223,24 +237,28 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
223 | // videowidget | 237 | // videowidget |
224 | 238 | ||
225 | QWidget *vTab; | 239 | QWidget *vTab; |
226 | vTab = new QWidget( tabWidget, "vTab" ); | 240 | vTab = new QWidget( tabWidget, "vTab" ); |
227 | videoView = new QListView( vTab, "Videoview" ); | 241 | videoView = new QListView( vTab, "Videoview" ); |
228 | videoView->setMinimumSize(233,260); | 242 | videoView->setMinimumSize(233,260); |
229 | 243 | ||
230 | videoView->addColumn("Title",150); | 244 | videoView->addColumn("Title",150); |
231 | videoView->addColumn("Size",45); | 245 | videoView->addColumn("Size",45); |
232 | videoView->addColumn("Media",35); | 246 | videoView->addColumn("Media",35); |
233 | videoView->setColumnAlignment(1, Qt::AlignRight); | 247 | videoView->setColumnAlignment(1, Qt::AlignRight); |
234 | videoView->setColumnAlignment(2, Qt::AlignRight); | 248 | videoView->setColumnAlignment(2, Qt::AlignRight); |
249 | videoView->setAllColumnsShowFocus(TRUE); | ||
250 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | ||
251 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | ||
252 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | ||
235 | 253 | ||
236 | tabWidget->insertTab( vTab,"Video"); | 254 | tabWidget->insertTab( vTab,"Video"); |
237 | 255 | ||
238 | Global::findDocuments(&vFiles, "video/*"); | 256 | Global::findDocuments(&vFiles, "video/*"); |
239 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 257 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
240 | for ( ; Vdit.current(); ++Vdit ) { | 258 | for ( ; Vdit.current(); ++Vdit ) { |
241 | if( Vdit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; | 259 | if( Vdit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; |
242 | else if( Vdit.current()->file().find("/mnt/hda") != -1 ) storage="CF"; | 260 | else if( Vdit.current()->file().find("/mnt/hda") != -1 ) storage="CF"; |
243 | else if( Vdit.current()->file().find("/mnt/card") != -1 ) storage="SD"; | 261 | else if( Vdit.current()->file().find("/mnt/card") != -1 ) storage="SD"; |
244 | else storage="RAM"; | 262 | else storage="RAM"; |
245 | QListViewItem * newItem; | 263 | QListViewItem * newItem; |
246 | if ( QFile( Vdit.current()->file()).exists() ) { | 264 | if ( QFile( Vdit.current()->file()).exists() ) { |
@@ -252,26 +270,24 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
252 | //playlists list | 270 | //playlists list |
253 | QWidget *LTab; | 271 | QWidget *LTab; |
254 | LTab = new QWidget( tabWidget, "LTab" ); | 272 | LTab = new QWidget( tabWidget, "LTab" ); |
255 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy | 273 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy |
256 | playLists->setMinimumSize(233,260);; | 274 | playLists->setMinimumSize(233,260);; |
257 | tabWidget->insertTab(LTab,"Lists"); | 275 | tabWidget->insertTab(LTab,"Lists"); |
258 | 276 | ||
259 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 277 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
260 | // connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); | 278 | // connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); |
261 | 279 | ||
262 | 280 | ||
263 | // add the library area | 281 | // add the library area |
264 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); | ||
265 | |||
266 | 282 | ||
267 | // connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), | 283 | // connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), |
268 | // this, SLOT( fauxPlay( QListViewItem *) ) ); | 284 | // this, SLOT( fauxPlay( QListViewItem *) ) ); |
269 | // connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), | 285 | // connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), |
270 | // this, SLOT( fauxPlay( QListViewItem *)) ); | 286 | // this, SLOT( fauxPlay( QListViewItem *)) ); |
271 | 287 | ||
272 | // connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); | 288 | // connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); |
273 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); | 289 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); |
274 | 290 | ||
275 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 291 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
276 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 292 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
277 | 293 | ||
@@ -410,74 +426,109 @@ void PlayListWidget::addAllMusicToList() { | |||
410 | 426 | ||
411 | 427 | ||
412 | void PlayListWidget::addAllVideoToList() { | 428 | void PlayListWidget::addAllVideoToList() { |
413 | DocLnkSet files; | 429 | DocLnkSet files; |
414 | Global::findDocuments(&files, "video/*"); | 430 | Global::findDocuments(&files, "video/*"); |
415 | QListIterator<DocLnk> dit( files.children() ); | 431 | QListIterator<DocLnk> dit( files.children() ); |
416 | for ( ; dit.current(); ++dit ) | 432 | for ( ; dit.current(); ++dit ) |
417 | d->selectedFiles->addToSelection( **dit ); | 433 | d->selectedFiles->addToSelection( **dit ); |
418 | } | 434 | } |
419 | 435 | ||
420 | 436 | ||
421 | void PlayListWidget::setDocument(const QString& fileref) { | 437 | void PlayListWidget::setDocument(const QString& fileref) { |
438 | fromSetDocument = TRUE; | ||
422 | if ( fileref.isNull() ) { | 439 | if ( fileref.isNull() ) { |
423 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 440 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
424 | return; | 441 | return; |
425 | } | 442 | } |
426 | // qDebug("setDocument"); | 443 | // qDebug("setDocument "+fileref); |
427 | if(fileref.find("playlist",0,TRUE) == -1) { | 444 | if(fileref.find("playlist",0,TRUE) == -1) { |
428 | addToSelection( DocLnk( fileref ) ); | 445 | clearList(); |
429 | d->setDocumentUsed = TRUE; | 446 | addToSelection( DocLnk( fileref ) ); |
430 | qApp->processEvents(); | 447 | d->setDocumentUsed = TRUE; |
431 | mediaPlayerState->setPlaying( FALSE ); | 448 | mediaPlayerState->setPlaying( FALSE ); |
432 | qApp->processEvents(); | 449 | qApp->processEvents(); |
433 | mediaPlayerState->setPlaying( TRUE ); | 450 | mediaPlayerState->setPlaying( TRUE ); |
434 | d->selectedFiles->removeSelected( ); | 451 | qApp->processEvents(); |
435 | } else { | 452 | setCaption("OpiePlayer"); |
453 | |||
454 | } else { //is playlist | ||
455 | clearList(); | ||
436 | loadList(DocLnk(fileref)); | 456 | loadList(DocLnk(fileref)); |
437 | d->selectedFiles->first(); | 457 | d->selectedFiles->first(); |
438 | // mediaPlayerState->setPlaying( TRUE ); | ||
439 | // mediaPlayerState->setPlaying( FALSE ); | ||
440 | |||
441 | } | 458 | } |
442 | } | 459 | } |
443 | 460 | ||
444 | 461 | ||
445 | void PlayListWidget::setActiveWindow() { | 462 | void PlayListWidget::setActiveWindow() { |
446 | // When we get raised we need to ensure that it switches views | 463 | // When we get raised we need to ensure that it switches views |
447 | char origView = mediaPlayerState->view(); | 464 | char origView = mediaPlayerState->view(); |
448 | mediaPlayerState->setView( 'l' ); // invalidate | 465 | mediaPlayerState->setView( 'l' ); // invalidate |
449 | mediaPlayerState->setView( origView ); // now switch back | 466 | mediaPlayerState->setView( origView ); // now switch back |
450 | } | 467 | } |
451 | 468 | ||
452 | 469 | ||
453 | void PlayListWidget::useSelectedDocument() { | 470 | void PlayListWidget::useSelectedDocument() { |
454 | d->setDocumentUsed = FALSE; | 471 | d->setDocumentUsed = FALSE; |
455 | } | 472 | } |
456 | 473 | ||
457 | 474 | ||
458 | const DocLnk *PlayListWidget::current() { | 475 | const DocLnk *PlayListWidget::current() { // this is fugly |
459 | 476 | ||
460 | // qDebug("in Playlist widget ::current"); | 477 | // if( fromSetDocument) { |
461 | if ( mediaPlayerState->playlist() ) { | 478 | // qDebug("from setDoc"); |
462 | return d->selectedFiles->current(); | 479 | // DocLnkSet files; |
463 | } | 480 | // Global::findDocuments(&files, "video/*;audio/*"); |
464 | else if ( d->setDocumentUsed && d->current ) { | 481 | // QListIterator<DocLnk> dit( files.children() ); |
465 | return d->current; | 482 | // for ( ; dit.current(); ++dit ) { |
466 | } else { | 483 | // if(dit.current()->linkFile() == setDocFileRef) { |
467 | return d->files->selected(); | 484 | // qDebug(setDocFileRef); |
468 | } | 485 | // return dit; |
486 | // } | ||
487 | // } | ||
488 | // } else | ||
489 | switch (tabWidget->currentPageIndex()) { | ||
490 | case 0: //playlist | ||
491 | { | ||
492 | if ( mediaPlayerState->playlist() ) { | ||
493 | return d->selectedFiles->current(); | ||
494 | } | ||
495 | else if ( d->setDocumentUsed && d->current ) { | ||
496 | return d->current; | ||
497 | } else { | ||
498 | return d->files->selected(); | ||
499 | } | ||
500 | } | ||
501 | break; | ||
502 | case 1: { //audio | ||
503 | Global::findDocuments(&files, "audio/*"); | ||
504 | QListIterator<DocLnk> dit( files.children() ); | ||
505 | for ( ; dit.current(); ++dit ) { | ||
506 | if( dit.current()->name() == audioView->currentItem()->text(0)) | ||
507 | return dit; | ||
508 | } | ||
509 | } | ||
510 | break; | ||
511 | case 2: { // video | ||
512 | Global::findDocuments(&vFiles, "video/*"); | ||
513 | QListIterator<DocLnk> Vdit( vFiles.children() ); | ||
514 | for ( ; Vdit.current(); ++Vdit ) { | ||
515 | if( Vdit.current()->name() == videoView->currentItem()->text(0)) | ||
516 | return Vdit; | ||
517 | } | ||
518 | } | ||
519 | break; | ||
520 | }; | ||
469 | } | 521 | } |
470 | 522 | ||
471 | |||
472 | bool PlayListWidget::prev() { | 523 | bool PlayListWidget::prev() { |
473 | if ( mediaPlayerState->playlist() ) { | 524 | if ( mediaPlayerState->playlist() ) { |
474 | if ( mediaPlayerState->shuffled() ) { | 525 | if ( mediaPlayerState->shuffled() ) { |
475 | const DocLnk *cur = current(); | 526 | const DocLnk *cur = current(); |
476 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 527 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
477 | for ( int i = 0; i < j; i++ ) { | 528 | for ( int i = 0; i < j; i++ ) { |
478 | if ( !d->selectedFiles->next() ) | 529 | if ( !d->selectedFiles->next() ) |
479 | d->selectedFiles->first(); | 530 | d->selectedFiles->first(); |
480 | } | 531 | } |
481 | if ( cur == current() ) | 532 | if ( cur == current() ) |
482 | if ( !d->selectedFiles->next() ) | 533 | if ( !d->selectedFiles->next() ) |
483 | d->selectedFiles->first(); | 534 | d->selectedFiles->first(); |
@@ -560,53 +611,49 @@ void PlayListWidget::saveList() { | |||
560 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | 611 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D |
561 | lnk.setIcon("mpegplayer/playlist2"); | 612 | lnk.setIcon("mpegplayer/playlist2"); |
562 | lnk.setName( filename); //sets file name | 613 | lnk.setName( filename); //sets file name |
563 | if(!lnk.writeLink()) | 614 | if(!lnk.writeLink()) |
564 | qDebug("Writing doclink did not work"); | 615 | qDebug("Writing doclink did not work"); |
565 | } | 616 | } |
566 | Config config( "MediaPlayer" ); | 617 | Config config( "MediaPlayer" ); |
567 | config.writeEntry("CurrentPlaylist",filename); | 618 | config.writeEntry("CurrentPlaylist",filename); |
568 | setCaption("OpiePlayer: "+filename); | 619 | setCaption("OpiePlayer: "+filename); |
569 | d->selectedFiles->first(); | 620 | d->selectedFiles->first(); |
570 | if(fileDlg) | 621 | if(fileDlg) |
571 | delete fileDlg; | 622 | delete fileDlg; |
572 | |||
573 | } | 623 | } |
574 | 624 | ||
575 | |||
576 | void PlayListWidget::loadList( const DocLnk & lnk) { | 625 | void PlayListWidget::loadList( const DocLnk & lnk) { |
577 | QString name= lnk.name(); | 626 | QString name= lnk.name(); |
578 | // qDebug("currentList is "+name); | 627 | // qDebug("currentList is "+name); |
579 | if( name.length()>1) { | 628 | if( name.length()>1) { |
580 | setCaption("OpiePlayer: "+name); | 629 | setCaption("OpiePlayer: "+name); |
581 | // qDebug("load list "+ name+".playlist"); | 630 | // qDebug("load list "+ name+".playlist"); |
582 | clearList(); | 631 | clearList(); |
583 | Config cfg( name+".playlist"); | 632 | Config cfg( name+".playlist"); |
584 | readConfig(cfg); | 633 | readConfig(cfg); |
585 | tabWidget->setCurrentPage(0); | 634 | tabWidget->setCurrentPage(0); |
586 | Config config( "MediaPlayer" ); | 635 | Config config( "MediaPlayer" ); |
587 | config.writeEntry("CurrentPlaylist", name); | 636 | config.writeEntry("CurrentPlaylist", name); |
588 | d->selectedFiles->first(); | 637 | d->selectedFiles->first(); |
589 | } | 638 | } |
590 | } | 639 | } |
591 | 640 | ||
592 | |||
593 | void PlayListWidget::setPlaylist( bool shown ) { | 641 | void PlayListWidget::setPlaylist( bool shown ) { |
594 | if ( shown ) | 642 | if ( shown ) |
595 | d->playListFrame->show(); | 643 | d->playListFrame->show(); |
596 | else | 644 | else |
597 | d->playListFrame->hide(); | 645 | d->playListFrame->hide(); |
598 | } | 646 | } |
599 | 647 | ||
600 | |||
601 | void PlayListWidget::setView( char view ) { | 648 | void PlayListWidget::setView( char view ) { |
602 | if ( view == 'l' ) | 649 | if ( view == 'l' ) |
603 | showMaximized(); | 650 | showMaximized(); |
604 | else | 651 | else |
605 | hide(); | 652 | hide(); |
606 | } | 653 | } |
607 | 654 | ||
608 | void PlayListWidget::addSelected() { | 655 | void PlayListWidget::addSelected() { |
609 | 656 | ||
610 | switch (tabWidget->currentPageIndex()) { | 657 | switch (tabWidget->currentPageIndex()) { |
611 | case 0: //playlist | 658 | case 0: //playlist |
612 | break; | 659 | break; |
@@ -695,90 +742,73 @@ void PlayListWidget::tabChanged(QWidget *widg) { | |||
695 | } | 742 | } |
696 | break; | 743 | break; |
697 | case 3: | 744 | case 3: |
698 | { | 745 | { |
699 | if( tbDeletePlaylist->isHidden()) | 746 | if( tbDeletePlaylist->isHidden()) |
700 | tbDeletePlaylist->show(); | 747 | tbDeletePlaylist->show(); |
701 | playLists->reread(); | 748 | playLists->reread(); |
702 | } | 749 | } |
703 | break; | 750 | break; |
704 | }; | 751 | }; |
705 | } | 752 | } |
706 | 753 | ||
707 | /* | ||
708 | list is right clicked*/ | ||
709 | void PlayListWidget::fauxPlay(QListViewItem *it) { | ||
710 | |||
711 | switch (tabWidget->currentPageIndex()) { | ||
712 | case 0: //playlist | ||
713 | break; | ||
714 | case 1: { //audio | ||
715 | QListIterator<DocLnk> dit( files.children() ); | ||
716 | for ( ; dit.current(); ++dit ) { | ||
717 | // qDebug(dit.current()->name()); | ||
718 | if( dit.current()->name() == it->text(0)) { | ||
719 | d->selectedFiles->addToSelection( **dit ); | ||
720 | } | ||
721 | } | ||
722 | } | ||
723 | break; | ||
724 | case 2: { // video | ||
725 | QListIterator<DocLnk> dit( vFiles.children() ); | ||
726 | for ( ; dit.current(); ++dit ) { | ||
727 | // qDebug(dit.current()->name()); | ||
728 | if( dit.current()->name() == it->text(0)) { | ||
729 | d->selectedFiles->addToSelection( **dit ); | ||
730 | } | ||
731 | } | ||
732 | } | ||
733 | break; | ||
734 | }; | ||
735 | mediaPlayerState->setPlaying( TRUE ); | ||
736 | // tabWidget->setCurrentPage(0); | ||
737 | d->selectedFiles->removeSelected(); | ||
738 | } | ||
739 | 754 | ||
740 | /* | 755 | /* |
741 | play button is pressed*/ | 756 | play button is pressed*/ |
742 | void PlayListWidget::btnPlay(bool b) { // this is fugly | 757 | void PlayListWidget::btnPlay(bool b) { |
743 | switch ( tabWidget->currentPageIndex()) { | 758 | mediaPlayerState->setPlaying(b); |
744 | case 0: | ||
745 | { | ||
746 | mediaPlayerState->setPlaying(b); | ||
747 | } | ||
748 | break; | ||
749 | case 1: | ||
750 | { | ||
751 | addToSelection( audioView->selectedItem() ); | ||
752 | mediaPlayerState->setPlaying(b); | ||
753 | qApp->processEvents(); | ||
754 | d->selectedFiles->removeSelected( ); | ||
755 | tabWidget->setCurrentPage(1); | ||
756 | } | ||
757 | break; | ||
758 | case 2: | ||
759 | { | ||
760 | addToSelection( videoView->selectedItem() ); | ||
761 | mediaPlayerState->setPlaying(b); | ||
762 | qApp->processEvents(); | ||
763 | d->selectedFiles->removeSelected( ); | ||
764 | tabWidget->setCurrentPage(2); | ||
765 | } | ||
766 | break; | ||
767 | }; | ||
768 | |||
769 | } | 759 | } |
770 | 760 | ||
771 | void PlayListWidget::deletePlaylist() { | 761 | void PlayListWidget::deletePlaylist() { |
772 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 762 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
773 | (tr("You really want to delete\nthis playlist?")), | 763 | (tr("You really want to delete\nthis playlist?")), |
774 | (tr("Yes")), (tr("No")), 0 )){ | 764 | (tr("Yes")), (tr("No")), 0 )){ |
775 | case 0: // Yes clicked, | 765 | case 0: // Yes clicked, |
776 | QFile().remove(playLists->selected()->file()); | 766 | QFile().remove(playLists->selected()->file()); |
777 | QFile().remove(playLists->selected()->linkFile()); | 767 | QFile().remove(playLists->selected()->linkFile()); |
778 | playLists->reread(); | 768 | playLists->reread(); |
779 | break; | 769 | break; |
780 | case 1: // Cancel | 770 | case 1: // Cancel |
781 | break; | 771 | break; |
782 | }; | 772 | }; |
783 | 773 | ||
784 | } | 774 | } |
775 | |||
776 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | ||
777 | { | ||
778 | switch (mouse) { | ||
779 | case 1: | ||
780 | break; | ||
781 | case 2:{ | ||
782 | QPopupMenu m; | ||
783 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | ||
784 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | ||
785 | // m.insertSeparator(); | ||
786 | // m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | ||
787 | m.exec( QCursor::pos() ); | ||
788 | } | ||
789 | break; | ||
790 | }; | ||
791 | |||
792 | } | ||
793 | |||
794 | void PlayListWidget::playSelected() | ||
795 | { | ||
796 | btnPlay( TRUE); | ||
797 | } | ||
798 | |||
799 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | ||
800 | { | ||
801 | switch (mouse) { | ||
802 | case 1: | ||
803 | break; | ||
804 | case 2:{ | ||
805 | QPopupMenu m; | ||
806 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | ||
807 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | ||
808 | // m.insertSeparator(); | ||
809 | m.exec( QCursor::pos() ); | ||
810 | } | ||
811 | break; | ||
812 | }; | ||
813 | |||
814 | } | ||