summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp26
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.h3
2 files changed, 12 insertions, 17 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index b78ce24..889667c 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -1,155 +1,156 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include <qpe/qpetoolbar.h> 34#include <qpe/qpetoolbar.h>
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36#include <qpe/storage.h> 36#include <qpe/storage.h>
37#include <qpe/mimetype.h> 37#include <qpe/mimetype.h>
38#include <qpe/global.h> 38#include <qpe/global.h>
39#include <qpe/resource.h> 39#include <qpe/resource.h>
40 40
41#include <qdatetime.h> 41#include <qdatetime.h>
42#include <qdir.h> 42#include <qdir.h>
43#include <qmessagebox.h> 43#include <qmessagebox.h>
44#include <qregexp.h> 44#include <qregexp.h>
45#include <qtextstream.h> 45#include <qtextstream.h>
46 46
47#include "playlistselection.h" 47#include "playlistselection.h"
48#include "playlistwidget.h" 48#include "playlistwidget.h"
49#include "mediaplayerstate.h" 49#include "mediaplayerstate.h"
50#include "inputDialog.h" 50#include "inputDialog.h"
51#include "om3u.h" 51#include "om3u.h"
52#include "playlistfileview.h" 52#include "playlistfileview.h"
53 53
54//only needed for the random play 54//only needed for the random play
55#include <stdlib.h> 55#include <stdlib.h>
56#include <assert.h> 56#include <assert.h>
57 57
58PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) 58PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name )
59 : PlayListWidgetGui( mediaPlayerState, parent, name ) { 59 : PlayListWidgetGui( mediaPlayerState, parent, name ) , currentFileListView( 0 )
60{
60 61
61 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), 62 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ),
62 "opieplayer2/add_to_playlist", 63 "opieplayer2/add_to_playlist",
63 this , SLOT(addSelected() ) ); 64 this , SLOT(addSelected() ) );
64 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), 65 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ),
65 "opieplayer2/remove_from_playlist", 66 "opieplayer2/remove_from_playlist",
66 this , SLOT(removeSelected() ) ); 67 this , SLOT(removeSelected() ) );
67 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", 68 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play",
68 this , SLOT( btnPlay( bool) ), TRUE ); 69 this , SLOT( btnPlay( bool) ), TRUE );
69 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", 70 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle",
70 &mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); 71 &mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE );
71 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", 72 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop",
72 &mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); 73 &mediaPlayerState, SLOT( setLooping( bool ) ), TRUE );
73 74
74 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 75 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
75 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), 76 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ),
76 this, SLOT( addAllMusicToList() ) ); 77 this, SLOT( addAllMusicToList() ) );
77 (void)new MenuItem( pmPlayList, tr( "Add all video files" ), 78 (void)new MenuItem( pmPlayList, tr( "Add all video files" ),
78 this, SLOT( addAllVideoToList() ) ); 79 this, SLOT( addAllVideoToList() ) );
79 (void)new MenuItem( pmPlayList, tr( "Add all files" ), 80 (void)new MenuItem( pmPlayList, tr( "Add all files" ),
80 this, SLOT( addAllToList() ) ); 81 this, SLOT( addAllToList() ) );
81 pmPlayList->insertSeparator(-1); 82 pmPlayList->insertSeparator(-1);
82// (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), 83// (void)new MenuItem( pmPlayList, tr( "Save PlayList" ),
83// this, SLOT( saveList() ) ); 84// this, SLOT( saveList() ) );
84 (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), 85 (void)new MenuItem( pmPlayList, tr( "Save Playlist" ),
85 this, SLOT(writem3u() ) ); 86 this, SLOT(writem3u() ) );
86 pmPlayList->insertSeparator(-1); 87 pmPlayList->insertSeparator(-1);
87 (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), 88 (void)new MenuItem( pmPlayList, tr( "Open File or URL" ),
88 this,SLOT( openFile() ) ); 89 this,SLOT( openFile() ) );
89 pmPlayList->insertSeparator(-1); 90 pmPlayList->insertSeparator(-1);
90 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), 91 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ),
91 audioView, SLOT( scanFiles() ) ); 92 audioView, SLOT( scanFiles() ) );
92 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), 93 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ),
93 videoView, SLOT( scanFiles() ) ); 94 videoView, SLOT( scanFiles() ) );
94 95
95 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), 96 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"),
96 &mediaPlayerState, SLOT( toggleFullscreen() ) ); 97 &mediaPlayerState, SLOT( toggleFullscreen() ) );
97 98
98 Config cfg( "OpiePlayer" ); 99 Config cfg( "OpiePlayer" );
99 bool b= cfg.readBoolEntry("FullScreen", 0); 100 bool b= cfg.readBoolEntry("FullScreen", 0);
100 mediaPlayerState.setFullscreen( b ); 101 mediaPlayerState.setFullscreen( b );
101 pmView->setItemChecked( -16, b ); 102 pmView->setItemChecked( -16, b );
102 103
103 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", 104 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up",
104 d->selectedFiles, SLOT(moveSelectedUp() ) ); 105 d->selectedFiles, SLOT(moveSelectedUp() ) );
105 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", 106 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut",
106 d->selectedFiles, SLOT(removeSelected() ) ); 107 d->selectedFiles, SLOT(removeSelected() ) );
107 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", 108 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down",
108 d->selectedFiles, SLOT(moveSelectedDown() ) ); 109 d->selectedFiles, SLOT(moveSelectedDown() ) );
109 // QVBox *stretch2 = new QVBox( vbox1 ); 110 // QVBox *stretch2 = new QVBox( vbox1 );
110 111
111 connect( tbDeletePlaylist, ( SIGNAL( released() ) ), 112 connect( tbDeletePlaylist, ( SIGNAL( released() ) ),
112 SLOT( deletePlaylist() ) ); 113 SLOT( deletePlaylist() ) );
113 connect( pmView, SIGNAL( activated( int ) ), 114 connect( pmView, SIGNAL( activated( int ) ),
114 this, SLOT( pmViewActivated( int ) ) ); 115 this, SLOT( pmViewActivated( int ) ) );
115 connect( skinsMenu, SIGNAL( activated( int ) ) , 116 connect( skinsMenu, SIGNAL( activated( int ) ) ,
116 this, SLOT( skinsMenuActivated( int ) ) ); 117 this, SLOT( skinsMenuActivated( int ) ) );
117 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), 118 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ),
118 this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); 119 this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) );
119 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), 120 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ),
120 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); 121 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) );
121 connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), 122 connect( audioView, SIGNAL( returnPressed( QListViewItem *) ),
122 this,SLOT( playIt( QListViewItem *) ) ); 123 this,SLOT( playIt( QListViewItem *) ) );
123 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), 124 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ),
124 this, SLOT( addToSelection( QListViewItem *) ) ); 125 this, SLOT( addToSelection( QListViewItem *) ) );
125 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), 126 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ),
126 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); 127 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) );
127 connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), 128 connect( videoView, SIGNAL( returnPressed( QListViewItem *) ),
128 this,SLOT( playIt( QListViewItem *) ) ); 129 this,SLOT( playIt( QListViewItem *) ) );
129 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), 130 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ),
130 this, SLOT( addToSelection( QListViewItem *) ) ); 131 this, SLOT( addToSelection( QListViewItem *) ) );
131 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), 132 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ),
132 this, SLOT( loadList( const DocLnk & ) ) ); 133 this, SLOT( loadList( const DocLnk & ) ) );
133 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), 134 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ),
134 this, SLOT( tabChanged( QWidget* ) ) ); 135 this, SLOT( tabChanged( QWidget* ) ) );
135 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), 136 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ),
136 d->tbPlay, SLOT( setOn( bool ) ) ); 137 d->tbPlay, SLOT( setOn( bool ) ) );
137 connect( &mediaPlayerState, SIGNAL( loopingToggled( bool ) ), 138 connect( &mediaPlayerState, SIGNAL( loopingToggled( bool ) ),
138 d->tbLoop, SLOT( setOn( bool ) ) ); 139 d->tbLoop, SLOT( setOn( bool ) ) );
139 connect( &mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), 140 connect( &mediaPlayerState, SIGNAL( shuffledToggled( bool ) ),
140 d->tbShuffle, SLOT( setOn( bool ) ) ); 141 d->tbShuffle, SLOT( setOn( bool ) ) );
141 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), 142 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ),
142 this, SLOT( playIt( QListViewItem *) ) ); 143 this, SLOT( playIt( QListViewItem *) ) );
143 connect ( gammaSlider, SIGNAL( valueChanged( int ) ), 144 connect ( gammaSlider, SIGNAL( valueChanged( int ) ),
144 &mediaPlayerState, SLOT( setVideoGamma( int ) ) ); 145 &mediaPlayerState, SLOT( setVideoGamma( int ) ) );
145 146
146 // see which skins are installed 147 // see which skins are installed
147 populateSkinsMenu(); 148 populateSkinsMenu();
148 initializeStates(); 149 initializeStates();
149 150
150 cfg.setGroup("PlayList"); 151 cfg.setGroup("PlayList");
151 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); 152 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
152 loadList(DocLnk( currentPlaylist ) ); 153 loadList(DocLnk( currentPlaylist ) );
153} 154}
154 155
155 156
@@ -384,350 +385,345 @@ void PlayListWidget::setDocument( const QString& fileref ) {
384 } 385 }
385} 386}
386 387
387 388
388void PlayListWidget::useSelectedDocument() { 389void PlayListWidget::useSelectedDocument() {
389 d->setDocumentUsed = FALSE; 390 d->setDocumentUsed = FALSE;
390} 391}
391 392
392 393
393const DocLnk *PlayListWidget::current() const { // this is fugly 394const DocLnk *PlayListWidget::current() const { // this is fugly
394 assert( currentTab() == CurrentPlayList ); 395 assert( currentTab() == CurrentPlayList );
395 396
396 const DocLnk *lnk = d->selectedFiles->current(); 397 const DocLnk *lnk = d->selectedFiles->current();
397 if ( !lnk ) { 398 if ( !lnk ) {
398 d->selectedFiles->first(); 399 d->selectedFiles->first();
399 lnk = d->selectedFiles->current(); 400 lnk = d->selectedFiles->current();
400 } 401 }
401 assert( lnk ); 402 assert( lnk );
402 return lnk; 403 return lnk;
403} 404}
404 405
405 406
406bool PlayListWidget::prev() { 407bool PlayListWidget::prev() {
407 if ( mediaPlayerState.isShuffled() ) { 408 if ( mediaPlayerState.isShuffled() ) {
408 const DocLnk *cur = current(); 409 const DocLnk *cur = current();
409 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 410 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
410 for ( int i = 0; i < j; i++ ) { 411 for ( int i = 0; i < j; i++ ) {
411 if ( !d->selectedFiles->next() ) 412 if ( !d->selectedFiles->next() )
412 d->selectedFiles->first(); 413 d->selectedFiles->first();
413 } 414 }
414 if ( cur == current() ) 415 if ( cur == current() )
415 if ( !d->selectedFiles->next() ) { 416 if ( !d->selectedFiles->next() ) {
416 d->selectedFiles->first(); 417 d->selectedFiles->first();
417 } 418 }
418 return TRUE; 419 return TRUE;
419 } else { 420 } else {
420 if ( !d->selectedFiles->prev() ) { 421 if ( !d->selectedFiles->prev() ) {
421 if ( mediaPlayerState.isLooping() ) { 422 if ( mediaPlayerState.isLooping() ) {
422 return d->selectedFiles->last(); 423 return d->selectedFiles->last();
423 } else { 424 } else {
424 return FALSE; 425 return FALSE;
425 } 426 }
426 } 427 }
427 return TRUE; 428 return TRUE;
428 } 429 }
429} 430}
430 431
431 432
432bool PlayListWidget::next() { 433bool PlayListWidget::next() {
433//qDebug("<<<<<<<<<<<<next()"); 434//qDebug("<<<<<<<<<<<<next()");
434 if ( mediaPlayerState.isShuffled() ) { 435 if ( mediaPlayerState.isShuffled() ) {
435 return prev(); 436 return prev();
436 } else { 437 } else {
437 if ( !d->selectedFiles->next() ) { 438 if ( !d->selectedFiles->next() ) {
438 if ( mediaPlayerState.isLooping() ) { 439 if ( mediaPlayerState.isLooping() ) {
439 return d->selectedFiles->first(); 440 return d->selectedFiles->first();
440 } else { 441 } else {
441 return FALSE; 442 return FALSE;
442 } 443 }
443 } 444 }
444 return TRUE; 445 return TRUE;
445 } 446 }
446} 447}
447 448
448 449
449bool PlayListWidget::first() { 450bool PlayListWidget::first() {
450 return d->selectedFiles->first(); 451 return d->selectedFiles->first();
451} 452}
452 453
453 454
454bool PlayListWidget::last() { 455bool PlayListWidget::last() {
455 return d->selectedFiles->last(); 456 return d->selectedFiles->last();
456} 457}
457 458
458 459
459 void PlayListWidget::saveList() { 460 void PlayListWidget::saveList() {
460 writem3u(); 461 writem3u();
461 } 462 }
462 463
463 464
464void PlayListWidget::loadList( const DocLnk & lnk) { 465void PlayListWidget::loadList( const DocLnk & lnk) {
465 QString name = lnk.name(); 466 QString name = lnk.name();
466 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); 467 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name);
467 468
468 if( name.length()>0) { 469 if( name.length()>0) {
469 setCaption("OpiePlayer: "+name); 470 setCaption("OpiePlayer: "+name);
470// qDebug("<<<<<<<<<<<<load list "+ lnk.file()); 471// qDebug("<<<<<<<<<<<<load list "+ lnk.file());
471 clearList(); 472 clearList();
472 readm3u(lnk.file()); 473 readm3u(lnk.file());
473 tabWidget->setCurrentPage(0); 474 tabWidget->setCurrentPage(0);
474 } 475 }
475} 476}
476 477
477void PlayListWidget::addSelected() { 478void PlayListWidget::addSelected() {
478 assert( inFileListMode() ); 479 assert( inFileListMode() );
479 480
480 QListView *fileListView = currentFileListView(); 481 QListViewItemIterator it( currentFileListView );
481 QListViewItemIterator it( fileListView );
482 for ( ; it.current(); ++it ) 482 for ( ; it.current(); ++it )
483 if ( it.current()->isSelected() ) { 483 if ( it.current()->isSelected() ) {
484 QString filename = it.current()->text(3); 484 QString filename = it.current()->text(3);
485 485
486 DocLnk lnk; 486 DocLnk lnk;
487 lnk.setName( QFileInfo( filename ).baseName() ); //sets name 487 lnk.setName( QFileInfo( filename ).baseName() ); //sets name
488 lnk.setFile( filename ); //sets file name 488 lnk.setFile( filename ); //sets file name
489 489
490 d->selectedFiles->addToSelection( lnk ); 490 d->selectedFiles->addToSelection( lnk );
491 } 491 }
492 492
493 fileListView->clearSelection(); 493 currentFileListView->clearSelection();
494 494
495 tabWidget->setCurrentPage( 0 ); 495 tabWidget->setCurrentPage( 0 );
496 writeCurrentM3u(); 496 writeCurrentM3u();
497} 497}
498 498
499 499
500void PlayListWidget::removeSelected() { 500void PlayListWidget::removeSelected() {
501 d->selectedFiles->removeSelected( ); 501 d->selectedFiles->removeSelected( );
502 writeCurrentM3u(); 502 writeCurrentM3u();
503} 503}
504 504
505 505
506void PlayListWidget::playIt( QListViewItem *it) { 506void PlayListWidget::playIt( QListViewItem *it) {
507 if(!it) return; 507 if(!it) return;
508 mediaPlayerState.setPlaying(FALSE); 508 mediaPlayerState.setPlaying(FALSE);
509 mediaPlayerState.setPlaying(TRUE); 509 mediaPlayerState.setPlaying(TRUE);
510 d->selectedFiles->unSelect(); 510 d->selectedFiles->unSelect();
511} 511}
512 512
513 513
514void PlayListWidget::addToSelection( QListViewItem *it) { 514void PlayListWidget::addToSelection( QListViewItem *it) {
515 d->setDocumentUsed = FALSE; 515 d->setDocumentUsed = FALSE;
516 516
517 if(it) { 517 if(it) {
518 if ( currentTab() == CurrentPlayList ) 518 if ( currentTab() == CurrentPlayList )
519 return; 519 return;
520 // case 1: { 520 // case 1: {
521 DocLnk lnk; 521 DocLnk lnk;
522 QString filename; 522 QString filename;
523 523
524 filename=it->text(3); 524 filename=it->text(3);
525 lnk.setName( QFileInfo(filename).baseName() ); //sets name 525 lnk.setName( QFileInfo(filename).baseName() ); //sets name
526 lnk.setFile( filename ); //sets file name 526 lnk.setFile( filename ); //sets file name
527 d->selectedFiles->addToSelection( lnk); 527 d->selectedFiles->addToSelection( lnk);
528 528
529 writeCurrentM3u(); 529 writeCurrentM3u();
530 tabWidget->setCurrentPage(0); 530 tabWidget->setCurrentPage(0);
531 531
532 } 532 }
533} 533}
534 534
535 535
536void PlayListWidget::tabChanged(QWidget *) { 536void PlayListWidget::tabChanged(QWidget *) {
537 537
538 d->tbPlay->setEnabled( true ); 538 d->tbPlay->setEnabled( true );
539 539
540 disconnect( audioView, SIGNAL( itemsSelected( bool ) ), 540 disconnect( audioView, SIGNAL( itemsSelected( bool ) ),
541 d->tbPlay, SLOT( setEnabled( bool ) ) ); 541 d->tbPlay, SLOT( setEnabled( bool ) ) );
542 disconnect( videoView, SIGNAL( itemsSelected( bool ) ), 542 disconnect( videoView, SIGNAL( itemsSelected( bool ) ),
543 d->tbPlay, SLOT( setEnabled( bool ) ) ); 543 d->tbPlay, SLOT( setEnabled( bool ) ) );
544 544
545 currentFileListView = 0;
546
545 switch ( currentTab() ) { 547 switch ( currentTab() ) {
546 case CurrentPlayList: 548 case CurrentPlayList:
547 { 549 {
548 if( !tbDeletePlaylist->isHidden() ) { 550 if( !tbDeletePlaylist->isHidden() ) {
549 tbDeletePlaylist->hide(); 551 tbDeletePlaylist->hide();
550 } 552 }
551 d->tbRemoveFromList->setEnabled(TRUE); 553 d->tbRemoveFromList->setEnabled(TRUE);
552 d->tbAddToList->setEnabled(FALSE); 554 d->tbAddToList->setEnabled(FALSE);
553 555
554 d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); 556 d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() );
555 } 557 }
556 break; 558 break;
557 case AudioFiles: 559 case AudioFiles:
558 { 560 {
559 audioView->populateView(); 561 audioView->populateView();
560 562
561 if( !tbDeletePlaylist->isHidden() ) { 563 if( !tbDeletePlaylist->isHidden() ) {
562 tbDeletePlaylist->hide(); 564 tbDeletePlaylist->hide();
563 } 565 }
564 d->tbRemoveFromList->setEnabled(FALSE); 566 d->tbRemoveFromList->setEnabled(FALSE);
565 d->tbAddToList->setEnabled(TRUE); 567 d->tbAddToList->setEnabled(TRUE);
566 568
567 connect( audioView, SIGNAL( itemsSelected( bool ) ), 569 connect( audioView, SIGNAL( itemsSelected( bool ) ),
568 d->tbPlay, SLOT( setEnabled( bool ) ) ); 570 d->tbPlay, SLOT( setEnabled( bool ) ) );
569 571
570 d->tbPlay->setEnabled( audioView->hasSelection() ); 572 d->tbPlay->setEnabled( audioView->hasSelection() );
573
574 currentFileListView = audioView;
571 } 575 }
572 break; 576 break;
573 case VideoFiles: 577 case VideoFiles:
574 { 578 {
575 videoView->populateView(); 579 videoView->populateView();
576 if( !tbDeletePlaylist->isHidden() ) { 580 if( !tbDeletePlaylist->isHidden() ) {
577 tbDeletePlaylist->hide(); 581 tbDeletePlaylist->hide();
578 } 582 }
579 d->tbRemoveFromList->setEnabled(FALSE); 583 d->tbRemoveFromList->setEnabled(FALSE);
580 d->tbAddToList->setEnabled(TRUE); 584 d->tbAddToList->setEnabled(TRUE);
581 585
582 connect( videoView, SIGNAL( itemsSelected( bool ) ), 586 connect( videoView, SIGNAL( itemsSelected( bool ) ),
583 d->tbPlay, SLOT( setEnabled( bool ) ) ); 587 d->tbPlay, SLOT( setEnabled( bool ) ) );
584 588
585 d->tbPlay->setEnabled( videoView->hasSelection() ); 589 d->tbPlay->setEnabled( videoView->hasSelection() );
590
591 currentFileListView = videoView;
586 } 592 }
587 break; 593 break;
588 case PlayLists: 594 case PlayLists:
589 { 595 {
590 if( tbDeletePlaylist->isHidden() ) { 596 if( tbDeletePlaylist->isHidden() ) {
591 tbDeletePlaylist->show(); 597 tbDeletePlaylist->show();
592 } 598 }
593 playLists->reread(); 599 playLists->reread();
594 d->tbAddToList->setEnabled(FALSE); 600 d->tbAddToList->setEnabled(FALSE);
595 601
596 d->tbPlay->setEnabled( false ); 602 d->tbPlay->setEnabled( false );
597 } 603 }
598 break; 604 break;
599 }; 605 };
600} 606}
601 607
602 608
603void PlayListWidget::btnPlay(bool b) { 609void PlayListWidget::btnPlay(bool b) {
604// mediaPlayerState->setPlaying(false); 610// mediaPlayerState->setPlaying(false);
605 mediaPlayerState.setPlaying(b); 611 mediaPlayerState.setPlaying(b);
606 insanityBool=FALSE; 612 insanityBool=FALSE;
607} 613}
608 614
609void PlayListWidget::deletePlaylist() { 615void PlayListWidget::deletePlaylist() {
610 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 616 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
611 (tr("You really want to delete\nthis playlist?")), 617 (tr("You really want to delete\nthis playlist?")),
612 (tr("Yes")), (tr("No")), 0 )){ 618 (tr("Yes")), (tr("No")), 0 )){
613 case 0: // Yes clicked, 619 case 0: // Yes clicked,
614 QFile().remove(playLists->selectedDocument().file()); 620 QFile().remove(playLists->selectedDocument().file());
615 QFile().remove(playLists->selectedDocument().linkFile()); 621 QFile().remove(playLists->selectedDocument().linkFile());
616 playLists->reread(); 622 playLists->reread();
617 break; 623 break;
618 case 1: // Cancel 624 case 1: // Cancel
619 break; 625 break;
620 }; 626 };
621} 627}
622 628
623 629
624void PlayListWidget::playSelected() { 630void PlayListWidget::playSelected() {
625 btnPlay( TRUE); 631 btnPlay( TRUE);
626} 632}
627 633
628QListView *PlayListWidget::currentFileListView() const
629{
630 switch ( currentTab() ) {
631 case AudioFiles: return audioView;
632 case VideoFiles: return videoView;
633 default: assert( false );
634 }
635 return 0;
636}
637
638bool PlayListWidget::inFileListMode() const 634bool PlayListWidget::inFileListMode() const
639{ 635{
640 TabType tab = currentTab(); 636 TabType tab = currentTab();
641 return tab == AudioFiles || tab == VideoFiles; 637 return tab == AudioFiles || tab == VideoFiles;
642} 638}
643 639
644void PlayListWidget::openFile() { 640void PlayListWidget::openFile() {
645 // http://66.28.164.33:2080 641 // http://66.28.164.33:2080
646 // http://somafm.com/star0242.m3u 642 // http://somafm.com/star0242.m3u
647 QString filename, name; 643 QString filename, name;
648 InputDialog *fileDlg; 644 InputDialog *fileDlg;
649 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 645 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
650 fileDlg->exec(); 646 fileDlg->exec();
651 if( fileDlg->result() == 1 ) { 647 if( fileDlg->result() == 1 ) {
652 filename = fileDlg->text(); 648 filename = fileDlg->text();
653 qDebug( "Selected filename is " + filename ); 649 qDebug( "Selected filename is " + filename );
654 // Om3u *m3uList; 650 // Om3u *m3uList;
655 DocLnk lnk; 651 DocLnk lnk;
656 Config cfg( "OpiePlayer" ); 652 Config cfg( "OpiePlayer" );
657 cfg.setGroup("PlayList"); 653 cfg.setGroup("PlayList");
658 654
659 if(filename.left(4) == "http") { 655 if(filename.left(4) == "http") {
660 QString m3uFile, m3uFilePath; 656 QString m3uFile, m3uFilePath;
661 if(filename.find(":",8,TRUE) != -1) { //found a port 657 if(filename.find(":",8,TRUE) != -1) { //found a port
662 m3uFile = filename.left( filename.find( ":",8,TRUE)); 658 m3uFile = filename.left( filename.find( ":",8,TRUE));
663 m3uFile = m3uFile.right( 7); 659 m3uFile = m3uFile.right( 7);
664 } else if(filename.left(4) == "http"){ 660 } else if(filename.left(4) == "http"){
665 m3uFile=filename; 661 m3uFile=filename;
666 m3uFile = m3uFile.right( m3uFile.length() - 7); 662 m3uFile = m3uFile.right( m3uFile.length() - 7);
667 } else{ 663 } else{
668 m3uFile=filename; 664 m3uFile=filename;
669 } 665 }
670 666
671// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); 667// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile);
672 lnk.setName( filename ); //sets name 668 lnk.setName( filename ); //sets name
673 lnk.setFile( filename ); //sets file name 669 lnk.setFile( filename ); //sets file name
674 670
675// lnk.setIcon("opieplayer2/musicfile"); 671// lnk.setIcon("opieplayer2/musicfile");
676 672
677 d->selectedFiles->addToSelection( lnk ); 673 d->selectedFiles->addToSelection( lnk );
678 writeCurrentM3u(); 674 writeCurrentM3u();
679 d->selectedFiles->setSelectedItem( lnk.name()); 675 d->selectedFiles->setSelectedItem( lnk.name());
680 } 676 }
681 else if( filename.right( 3) == "m3u" ) { 677 else if( filename.right( 3) == "m3u" ) {
682 readm3u( filename ); 678 readm3u( filename );
683 679
684 } else if( filename.right(3) == "pls" ) { 680 } else if( filename.right(3) == "pls" ) {
685 readPls( filename ); 681 readPls( filename );
686 } else { 682 } else {
687 lnk.setName( QFileInfo(filename).baseName() ); //sets name 683 lnk.setName( QFileInfo(filename).baseName() ); //sets name
688 lnk.setFile( filename ); //sets file name 684 lnk.setFile( filename ); //sets file name
689 d->selectedFiles->addToSelection( lnk); 685 d->selectedFiles->addToSelection( lnk);
690 writeCurrentM3u(); 686 writeCurrentM3u();
691 d->selectedFiles->setSelectedItem( lnk.name()); 687 d->selectedFiles->setSelectedItem( lnk.name());
692 } 688 }
693 } 689 }
694 690
695 delete fileDlg; 691 delete fileDlg;
696} 692}
697 693
698/* 694/*
699reads m3u and shows files/urls to playlist widget */ 695reads m3u and shows files/urls to playlist widget */
700void PlayListWidget::readm3u( const QString &filename ) { 696void PlayListWidget::readm3u( const QString &filename ) {
701 qDebug( "read m3u filename " + filename ); 697 qDebug( "read m3u filename " + filename );
702 698
703 Om3u *m3uList; 699 Om3u *m3uList;
704 QString s, name; 700 QString s, name;
705 m3uList = new Om3u( filename, IO_ReadOnly ); 701 m3uList = new Om3u( filename, IO_ReadOnly );
706 m3uList->readM3u(); 702 m3uList->readM3u();
707 DocLnk lnk; 703 DocLnk lnk;
708 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 704 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
709 s = *it; 705 s = *it;
710// qDebug("reading "+ s); 706// qDebug("reading "+ s);
711 if(s.left(4)=="http") { 707 if(s.left(4)=="http") {
712 lnk.setName( s ); //sets file name 708 lnk.setName( s ); //sets file name
713 lnk.setIcon("opieplayer2/musicfile"); 709 lnk.setIcon("opieplayer2/musicfile");
714 lnk.setFile( s ); //sets file name 710 lnk.setFile( s ); //sets file name
715 711
716 } else { 712 } else {
717 // if( QFileInfo( s ).exists() ) { 713 // if( QFileInfo( s ).exists() ) {
718 lnk.setName( QFileInfo(s).baseName()); 714 lnk.setName( QFileInfo(s).baseName());
719 // if(s.right(4) == '.') {//if regular file 715 // if(s.right(4) == '.') {//if regular file
720 if(s.left(1) != "/") { 716 if(s.left(1) != "/") {
721 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); 717 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s);
722 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); 718 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
723// lnk.setIcon(MimeType(s).pixmap() ); 719// lnk.setIcon(MimeType(s).pixmap() );
724// lnk.setIcon("SoundPlayer"); 720// lnk.setIcon("SoundPlayer");
725 } else { 721 } else {
726 // qDebug("set link2 "+s); 722 // qDebug("set link2 "+s);
727 lnk.setFile( s); 723 lnk.setFile( s);
728// lnk.setIcon(MimeType(s).pixmap() ); 724// lnk.setIcon(MimeType(s).pixmap() );
729// lnk.setIcon("SoundPlayer"); 725// lnk.setIcon("SoundPlayer");
730 } 726 }
731 } 727 }
732 d->selectedFiles->addToSelection( lnk ); 728 d->selectedFiles->addToSelection( lnk );
733 } 729 }
@@ -916,98 +912,98 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) {
916 case Key_4: 912 case Key_4:
917 tabWidget->setCurrentPage( 3 ); 913 tabWidget->setCurrentPage( 3 );
918 break; 914 break;
919 case Key_Down: 915 case Key_Down:
920 if ( !d->selectedFiles->next() ) 916 if ( !d->selectedFiles->next() )
921 d->selectedFiles->first(); 917 d->selectedFiles->first();
922 break; 918 break;
923 case Key_Up: 919 case Key_Up:
924 if ( !d->selectedFiles->prev() ) 920 if ( !d->selectedFiles->prev() )
925 // d->selectedFiles->last(); 921 // d->selectedFiles->last();
926 break; 922 break;
927 } 923 }
928} 924}
929 925
930void PlayListWidget::pmViewActivated(int index) { 926void PlayListWidget::pmViewActivated(int index) {
931// qDebug("%d", index); 927// qDebug("%d", index);
932 switch(index) { 928 switch(index) {
933 case -16: 929 case -16:
934 { 930 {
935 mediaPlayerState.toggleFullscreen(); 931 mediaPlayerState.toggleFullscreen();
936 bool b=mediaPlayerState.isFullscreen(); 932 bool b=mediaPlayerState.isFullscreen();
937 pmView->setItemChecked( index, b); 933 pmView->setItemChecked( index, b);
938 Config cfg( "OpiePlayer" ); 934 Config cfg( "OpiePlayer" );
939 cfg.writeEntry( "FullScreen", b ); 935 cfg.writeEntry( "FullScreen", b );
940 } 936 }
941 break; 937 break;
942 }; 938 };
943} 939}
944 940
945void PlayListWidget::populateSkinsMenu() { 941void PlayListWidget::populateSkinsMenu() {
946 int item = 0; 942 int item = 0;
947 defaultSkinIndex = 0; 943 defaultSkinIndex = 0;
948 QString skinName; 944 QString skinName;
949 Config cfg( "OpiePlayer" ); 945 Config cfg( "OpiePlayer" );
950 cfg.setGroup("Options" ); 946 cfg.setGroup("Options" );
951 QString skin = cfg.readEntry( "Skin", "default" ); 947 QString skin = cfg.readEntry( "Skin", "default" );
952 948
953 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); 949 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" );
954 skinsDir.setFilter( QDir::Dirs ); 950 skinsDir.setFilter( QDir::Dirs );
955 skinsDir.setSorting(QDir::Name ); 951 skinsDir.setSorting(QDir::Name );
956 const QFileInfoList *skinslist = skinsDir.entryInfoList(); 952 const QFileInfoList *skinslist = skinsDir.entryInfoList();
957 QFileInfoListIterator it( *skinslist ); 953 QFileInfoListIterator it( *skinslist );
958 QFileInfo *fi; 954 QFileInfo *fi;
959 while ( ( fi = it.current() ) ) { 955 while ( ( fi = it.current() ) ) {
960 skinName = fi->fileName(); 956 skinName = fi->fileName();
961// qDebug( fi->fileName() ); 957// qDebug( fi->fileName() );
962 if( skinName != "." && skinName != ".." && skinName !="CVS" ) { 958 if( skinName != "." && skinName != ".." && skinName !="CVS" ) {
963 item = skinsMenu->insertItem( fi->fileName() ) ; 959 item = skinsMenu->insertItem( fi->fileName() ) ;
964 } 960 }
965 if( skinName == "default" ) { 961 if( skinName == "default" ) {
966 defaultSkinIndex = item; 962 defaultSkinIndex = item;
967 } 963 }
968 if( skinName == skin ) { 964 if( skinName == skin ) {
969 skinsMenu->setItemChecked( item, TRUE ); 965 skinsMenu->setItemChecked( item, TRUE );
970 } 966 }
971 ++it; 967 ++it;
972 } 968 }
973} 969}
974 970
975void PlayListWidget::skinsMenuActivated( int item ) { 971void PlayListWidget::skinsMenuActivated( int item ) {
976 for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { 972 for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) {
977 skinsMenu->setItemChecked( i, FALSE ); 973 skinsMenu->setItemChecked( i, FALSE );
978 } 974 }
979 skinsMenu->setItemChecked( item, TRUE ); 975 skinsMenu->setItemChecked( item, TRUE );
980 976
981 { 977 {
982 Config cfg( "OpiePlayer" ); 978 Config cfg( "OpiePlayer" );
983 cfg.setGroup("Options"); 979 cfg.setGroup("Options");
984 cfg.writeEntry("Skin", skinsMenu->text( item ) ); 980 cfg.writeEntry("Skin", skinsMenu->text( item ) );
985 } 981 }
986 982
987 emit skinSelected(); 983 emit skinSelected();
988} 984}
989 985
990PlayListWidget::TabType PlayListWidget::currentTab() const 986PlayListWidget::TabType PlayListWidget::currentTab() const
991{ 987{
992 static const TabType indexToTabType[ TabTypeCount ] = 988 static const TabType indexToTabType[ TabTypeCount ] =
993 { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; 989 { CurrentPlayList, AudioFiles, VideoFiles, PlayLists };
994 990
995 int index = tabWidget->currentPageIndex(); 991 int index = tabWidget->currentPageIndex();
996 assert( index < TabTypeCount && index >= 0 ); 992 assert( index < TabTypeCount && index >= 0 );
997 993
998 return indexToTabType[ index ]; 994 return indexToTabType[ index ];
999} 995}
1000 996
1001PlayListWidget::Entry PlayListWidget::currentEntry() const 997PlayListWidget::Entry PlayListWidget::currentEntry() const
1002{ 998{
1003 if ( currentTab() == CurrentPlayList ) { 999 if ( currentTab() == CurrentPlayList ) {
1004 const DocLnk *lnk = current(); 1000 const DocLnk *lnk = current();
1005 return Entry( lnk->name(), lnk->file() ); 1001 return Entry( lnk->name(), lnk->file() );
1006 } 1002 }
1007 1003
1008 return Entry( currentFileListPathName() ); 1004 return Entry( currentFileListPathName() );
1009} 1005}
1010 1006
1011QString PlayListWidget::currentFileListPathName() const { 1007QString PlayListWidget::currentFileListPathName() const {
1012 return currentFileListView()->currentItem()->text( 3 ); 1008 return currentFileListView->currentItem()->text( 3 );
1013} 1009}
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h
index 5c8f30c..e8bf211 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.h
+++ b/noncore/multimedia/opieplayer2/playlistwidget.h
@@ -5,135 +5,134 @@
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef PLAY_LIST_WIDGET_H 34#ifndef PLAY_LIST_WIDGET_H
35#define PLAY_LIST_WIDGET_H 35#define PLAY_LIST_WIDGET_H
36 36
37#include <qmainwindow.h> 37#include <qmainwindow.h>
38#include <qpe/applnk.h> 38#include <qpe/applnk.h>
39#include <qtabwidget.h> 39#include <qtabwidget.h>
40#include <qpe/fileselector.h> 40#include <qpe/fileselector.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qpopupmenu.h> 42#include <qpopupmenu.h>
43 43
44#include "playlistwidgetgui.h" 44#include "playlistwidgetgui.h"
45 45
46 46
47//class PlayListWidgetPrivate; 47//class PlayListWidgetPrivate;
48class Config; 48class Config;
49class QListViewItem; 49class QListViewItem;
50class QListView; 50class QListView;
51class QPoint; 51class QPoint;
52class QAction; 52class QAction;
53class QLabel; 53class QLabel;
54 54
55class PlayListWidget : public PlayListWidgetGui { 55class PlayListWidget : public PlayListWidgetGui {
56 Q_OBJECT 56 Q_OBJECT
57public: 57public:
58 enum TabType { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; 58 enum TabType { CurrentPlayList, AudioFiles, VideoFiles, PlayLists };
59 enum { TabTypeCount = 4 }; 59 enum { TabTypeCount = 4 };
60 60
61 struct Entry 61 struct Entry
62 { 62 {
63 Entry( const QString &_name, const QString &_fileName ) 63 Entry( const QString &_name, const QString &_fileName )
64 : name( _name ), file( _fileName ) {} 64 : name( _name ), file( _fileName ) {}
65 Entry( const QString &_fileName ) 65 Entry( const QString &_fileName )
66 : name( _fileName ), file( _fileName ) {} 66 : name( _fileName ), file( _fileName ) {}
67 67
68 QString name; 68 QString name;
69 QString file; 69 QString file;
70 }; 70 };
71 71
72 PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); 72 PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 );
73 ~PlayListWidget(); 73 ~PlayListWidget();
74 74
75 // retrieve the current playlist entry (media file link) 75 // retrieve the current playlist entry (media file link)
76 const DocLnk *current() const; 76 const DocLnk *current() const;
77 void useSelectedDocument(); 77 void useSelectedDocument();
78 TabType currentTab() const; 78 TabType currentTab() const;
79 79
80 Entry currentEntry() const; 80 Entry currentEntry() const;
81 81
82public slots: 82public slots:
83 bool first(); 83 bool first();
84 bool last(); 84 bool last();
85 bool next(); 85 bool next();
86 bool prev(); 86 bool prev();
87 void writeDefaultPlaylist( ); 87 void writeDefaultPlaylist( );
88 QString currentFileListPathName() const; 88 QString currentFileListPathName() const;
89protected: 89protected:
90 void keyReleaseEvent( QKeyEvent *e); 90 void keyReleaseEvent( QKeyEvent *e);
91 91
92signals: 92signals:
93 void skinSelected(); 93 void skinSelected();
94 94
95private: 95private:
96 int defaultSkinIndex; 96 int defaultSkinIndex;
97 void readm3u(const QString &); 97 void readm3u(const QString &);
98 void readPls(const QString &); 98 void readPls(const QString &);
99 void initializeStates(); 99 void initializeStates();
100 100
101 QListView *currentFileListView() const;
102
103 bool inFileListMode() const; 101 bool inFileListMode() const;
104 102
105private slots: 103private slots:
106 void populateSkinsMenu(); 104 void populateSkinsMenu();
107 void skinsMenuActivated(int); 105 void skinsMenuActivated(int);
108 void pmViewActivated(int); 106 void pmViewActivated(int);
109 void writem3u(); 107 void writem3u();
110 void writeCurrentM3u(); 108 void writeCurrentM3u();
111 void openFile(); 109 void openFile();
112 void setDocument( const QString& fileref ); 110 void setDocument( const QString& fileref );
113 void addToSelection( const DocLnk& ); // Add a media file to the playlist 111 void addToSelection( const DocLnk& ); // Add a media file to the playlist
114 void addToSelection( QListViewItem* ); // Add a media file to the playlist 112 void addToSelection( QListViewItem* ); // Add a media file to the playlist
115 void clearList(); 113 void clearList();
116 void addAllToList(); 114 void addAllToList();
117 void addAllMusicToList(); 115 void addAllMusicToList();
118 void addAllVideoToList(); 116 void addAllVideoToList();
119 void saveList(); // Save the playlist 117 void saveList(); // Save the playlist
120 void loadList( const DocLnk &); // Load a playlist 118 void loadList( const DocLnk &); // Load a playlist
121 void playIt( QListViewItem *); 119 void playIt( QListViewItem *);
122 void btnPlay(bool); 120 void btnPlay(bool);
123 void deletePlaylist(); 121 void deletePlaylist();
124 void addSelected(); 122 void addSelected();
125 void removeSelected(); 123 void removeSelected();
126 void tabChanged(QWidget*); 124 void tabChanged(QWidget*);
127 void viewPressed( int, QListViewItem *, const QPoint&, int); 125 void viewPressed( int, QListViewItem *, const QPoint&, int);
128 void playlistViewPressed( int, QListViewItem *, const QPoint&, int); 126 void playlistViewPressed( int, QListViewItem *, const QPoint&, int);
129 void playSelected(); 127 void playSelected();
130 128
131private: 129private:
132 bool fromSetDocument; 130 bool fromSetDocument;
133 bool insanityBool; 131 bool insanityBool;
134 QString setDocFileRef, currentPlayList; 132 QString setDocFileRef, currentPlayList;
135 int selected; 133 int selected;
134 QListView *currentFileListView;
136}; 135};
137 136
138#endif // PLAY_LIST_WIDGET_H 137#endif // PLAY_LIST_WIDGET_H
139 138