summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp13
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.h2
2 files changed, 2 insertions, 13 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index e754067..86b3424 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -1,228 +1,228 @@
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
58#include "audiowidget.h" 58#include "audiowidget.h"
59#include "videowidget.h" 59#include "videowidget.h"
60 60
61extern MediaPlayerState *mediaPlayerState; 61extern MediaPlayerState *mediaPlayerState;
62// extern AudioWidget *audioUI; 62// extern AudioWidget *audioUI;
63// extern VideoWidget *videoUI; 63// extern VideoWidget *videoUI;
64 64
65PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) 65PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name )
66 : PlayListWidgetGui( mediaPlayerState, parent, name ) { 66 : PlayListWidgetGui( mediaPlayerState, parent, name ) {
67 67
68 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), 68 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ),
69 "opieplayer2/add_to_playlist", 69 "opieplayer2/add_to_playlist",
70 this , SLOT(addSelected() ) ); 70 this , SLOT(addSelected() ) );
71 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), 71 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ),
72 "opieplayer2/remove_from_playlist", 72 "opieplayer2/remove_from_playlist",
73 this , SLOT(removeSelected() ) ); 73 this , SLOT(removeSelected() ) );
74 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", 74 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play",
75 this , SLOT( btnPlay( bool) ), TRUE ); 75 this , SLOT( btnPlay( bool) ), TRUE );
76 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", 76 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle",
77 &mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); 77 &mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE );
78 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", 78 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop",
79 &mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); 79 &mediaPlayerState, SLOT( setLooping( bool ) ), TRUE );
80 80
81 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 81 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
82 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), 82 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ),
83 this, SLOT( addAllMusicToList() ) ); 83 this, SLOT( addAllMusicToList() ) );
84 (void)new MenuItem( pmPlayList, tr( "Add all video files" ), 84 (void)new MenuItem( pmPlayList, tr( "Add all video files" ),
85 this, SLOT( addAllVideoToList() ) ); 85 this, SLOT( addAllVideoToList() ) );
86 (void)new MenuItem( pmPlayList, tr( "Add all files" ), 86 (void)new MenuItem( pmPlayList, tr( "Add all files" ),
87 this, SLOT( addAllToList() ) ); 87 this, SLOT( addAllToList() ) );
88 pmPlayList->insertSeparator(-1); 88 pmPlayList->insertSeparator(-1);
89// (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), 89// (void)new MenuItem( pmPlayList, tr( "Save PlayList" ),
90// this, SLOT( saveList() ) ); 90// this, SLOT( saveList() ) );
91 (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), 91 (void)new MenuItem( pmPlayList, tr( "Save Playlist" ),
92 this, SLOT(writem3u() ) ); 92 this, SLOT(writem3u() ) );
93 pmPlayList->insertSeparator(-1); 93 pmPlayList->insertSeparator(-1);
94 (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), 94 (void)new MenuItem( pmPlayList, tr( "Open File or URL" ),
95 this,SLOT( openFile() ) ); 95 this,SLOT( openFile() ) );
96 pmPlayList->insertSeparator(-1); 96 pmPlayList->insertSeparator(-1);
97 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), 97 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ),
98 this,SLOT( scanForAudio() ) ); 98 audioView, SLOT( scanFiles() ) );
99 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), 99 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ),
100 this,SLOT( scanForVideo() ) ); 100 videoView, SLOT( scanFiles() ) );
101 101
102 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), 102 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"),
103 &mediaPlayerState, SLOT( toggleFullscreen() ) ); 103 &mediaPlayerState, SLOT( toggleFullscreen() ) );
104 104
105 Config cfg( "OpiePlayer" ); 105 Config cfg( "OpiePlayer" );
106 bool b= cfg.readBoolEntry("FullScreen", 0); 106 bool b= cfg.readBoolEntry("FullScreen", 0);
107 mediaPlayerState.setFullscreen( b ); 107 mediaPlayerState.setFullscreen( b );
108 pmView->setItemChecked( -16, b ); 108 pmView->setItemChecked( -16, b );
109 109
110 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", 110 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up",
111 d->selectedFiles, SLOT(moveSelectedUp() ) ); 111 d->selectedFiles, SLOT(moveSelectedUp() ) );
112 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", 112 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut",
113 d->selectedFiles, SLOT(removeSelected() ) ); 113 d->selectedFiles, SLOT(removeSelected() ) );
114 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", 114 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down",
115 d->selectedFiles, SLOT(moveSelectedDown() ) ); 115 d->selectedFiles, SLOT(moveSelectedDown() ) );
116 // QVBox *stretch2 = new QVBox( vbox1 ); 116 // QVBox *stretch2 = new QVBox( vbox1 );
117 117
118 connect( tbDeletePlaylist, ( SIGNAL( released() ) ), 118 connect( tbDeletePlaylist, ( SIGNAL( released() ) ),
119 SLOT( deletePlaylist() ) ); 119 SLOT( deletePlaylist() ) );
120 connect( pmView, SIGNAL( activated( int ) ), 120 connect( pmView, SIGNAL( activated( int ) ),
121 this, SLOT( pmViewActivated( int ) ) ); 121 this, SLOT( pmViewActivated( int ) ) );
122 connect( skinsMenu, SIGNAL( activated( int ) ) , 122 connect( skinsMenu, SIGNAL( activated( int ) ) ,
123 this, SLOT( skinsMenuActivated( int ) ) ); 123 this, SLOT( skinsMenuActivated( int ) ) );
124 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), 124 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ),
125 this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); 125 this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) );
126 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), 126 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ),
127 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); 127 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) );
128 connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), 128 connect( audioView, SIGNAL( returnPressed( QListViewItem *) ),
129 this,SLOT( playIt( QListViewItem *) ) ); 129 this,SLOT( playIt( QListViewItem *) ) );
130 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), 130 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ),
131 this, SLOT( addToSelection( QListViewItem *) ) ); 131 this, SLOT( addToSelection( QListViewItem *) ) );
132 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), 132 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ),
133 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); 133 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) );
134 connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), 134 connect( videoView, SIGNAL( returnPressed( QListViewItem *) ),
135 this,SLOT( playIt( QListViewItem *) ) ); 135 this,SLOT( playIt( QListViewItem *) ) );
136 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), 136 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ),
137 this, SLOT( addToSelection( QListViewItem *) ) ); 137 this, SLOT( addToSelection( QListViewItem *) ) );
138 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), 138 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ),
139 this, SLOT( loadList( const DocLnk & ) ) ); 139 this, SLOT( loadList( const DocLnk & ) ) );
140 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), 140 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ),
141 this, SLOT( tabChanged( QWidget* ) ) ); 141 this, SLOT( tabChanged( QWidget* ) ) );
142 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), 142 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ),
143 d->tbPlay, SLOT( setOn( bool ) ) ); 143 d->tbPlay, SLOT( setOn( bool ) ) );
144 connect( &mediaPlayerState, SIGNAL( loopingToggled( bool ) ), 144 connect( &mediaPlayerState, SIGNAL( loopingToggled( bool ) ),
145 d->tbLoop, SLOT( setOn( bool ) ) ); 145 d->tbLoop, SLOT( setOn( bool ) ) );
146 connect( &mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), 146 connect( &mediaPlayerState, SIGNAL( shuffledToggled( bool ) ),
147 d->tbShuffle, SLOT( setOn( bool ) ) ); 147 d->tbShuffle, SLOT( setOn( bool ) ) );
148 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), 148 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ),
149 this, SLOT( playIt( QListViewItem *) ) ); 149 this, SLOT( playIt( QListViewItem *) ) );
150 connect ( gammaSlider, SIGNAL( valueChanged( int ) ), 150 connect ( gammaSlider, SIGNAL( valueChanged( int ) ),
151 &mediaPlayerState, SLOT( setVideoGamma( int ) ) ); 151 &mediaPlayerState, SLOT( setVideoGamma( int ) ) );
152 152
153 // see which skins are installed 153 // see which skins are installed
154 populateSkinsMenu(); 154 populateSkinsMenu();
155 initializeStates(); 155 initializeStates();
156 156
157 cfg.setGroup("PlayList"); 157 cfg.setGroup("PlayList");
158 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); 158 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
159 loadList(DocLnk( currentPlaylist ) ); 159 loadList(DocLnk( currentPlaylist ) );
160} 160}
161 161
162 162
163PlayListWidget::~PlayListWidget() { 163PlayListWidget::~PlayListWidget() {
164 delete d; 164 delete d;
165} 165}
166 166
167 167
168void PlayListWidget::initializeStates() { 168void PlayListWidget::initializeStates() {
169 d->tbPlay->setOn( mediaPlayerState.isPlaying() ); 169 d->tbPlay->setOn( mediaPlayerState.isPlaying() );
170 d->tbLoop->setOn( mediaPlayerState.isLooping() ); 170 d->tbLoop->setOn( mediaPlayerState.isLooping() );
171 d->tbShuffle->setOn( mediaPlayerState.isShuffled() ); 171 d->tbShuffle->setOn( mediaPlayerState.isShuffled() );
172 d->playListFrame->show(); 172 d->playListFrame->show();
173} 173}
174 174
175void PlayListWidget::writeDefaultPlaylist() { 175void PlayListWidget::writeDefaultPlaylist() {
176 176
177 Config config( "OpiePlayer" ); 177 Config config( "OpiePlayer" );
178 config.setGroup( "PlayList" ); 178 config.setGroup( "PlayList" );
179 QString filename=QPEApplication::documentDir() + "/default.m3u"; 179 QString filename=QPEApplication::documentDir() + "/default.m3u";
180 QString currentString = config.readEntry( "CurrentPlaylist", filename); 180 QString currentString = config.readEntry( "CurrentPlaylist", filename);
181 if( currentString == filename) { 181 if( currentString == filename) {
182 Om3u *m3uList; 182 Om3u *m3uList;
183 // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); 183 // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>");
184 if( d->selectedFiles->first() ) { 184 if( d->selectedFiles->first() ) {
185 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); 185 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate);
186 do { 186 do {
187 // qDebug(d->selectedFiles->current()->file()); 187 // qDebug(d->selectedFiles->current()->file());
188 m3uList->add( d->selectedFiles->current()->file() ); 188 m3uList->add( d->selectedFiles->current()->file() );
189 } 189 }
190 while ( d->selectedFiles->next() ); 190 while ( d->selectedFiles->next() );
191 191
192 m3uList->write(); 192 m3uList->write();
193 m3uList->close(); 193 m3uList->close();
194 if(m3uList) delete m3uList; 194 if(m3uList) delete m3uList;
195 195
196 } 196 }
197 } 197 }
198} 198}
199 199
200void PlayListWidget::addToSelection( const DocLnk& lnk ) { 200void PlayListWidget::addToSelection( const DocLnk& lnk ) {
201 d->setDocumentUsed = FALSE; 201 d->setDocumentUsed = FALSE;
202 if( QFileInfo( lnk.file() ).exists() || 202 if( QFileInfo( lnk.file() ).exists() ||
203 lnk.file().left(4) == "http" ) { 203 lnk.file().left(4) == "http" ) {
204 d->selectedFiles->addToSelection( lnk ); 204 d->selectedFiles->addToSelection( lnk );
205 } 205 }
206// writeCurrentM3u(); 206// writeCurrentM3u();
207} 207}
208 208
209 209
210void PlayListWidget::clearList() { 210void PlayListWidget::clearList() {
211 while ( first() ) { 211 while ( first() ) {
212 d->selectedFiles->removeSelected(); 212 d->selectedFiles->removeSelected();
213 } 213 }
214} 214}
215 215
216void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { 216void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
217 switch (mouse) { 217 switch (mouse) {
218 case 1: 218 case 1:
219 break; 219 break;
220 case 2: 220 case 2:
221 { 221 {
222 QPopupMenu m; 222 QPopupMenu m;
223 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 223 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
224 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 224 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
225 m.exec( QCursor::pos() ); 225 m.exec( QCursor::pos() );
226 } 226 }
227 break; 227 break;
228 } 228 }
@@ -492,265 +492,256 @@ void PlayListWidget::addSelected() {
492 492
493 DocLnk lnk; 493 DocLnk lnk;
494 lnk.setName( QFileInfo( filename ).baseName() ); //sets name 494 lnk.setName( QFileInfo( filename ).baseName() ); //sets name
495 lnk.setFile( filename ); //sets file name 495 lnk.setFile( filename ); //sets file name
496 496
497 d->selectedFiles->addToSelection( lnk ); 497 d->selectedFiles->addToSelection( lnk );
498 } 498 }
499 499
500 fileListView->clearSelection(); 500 fileListView->clearSelection();
501 501
502 tabWidget->setCurrentPage( 0 ); 502 tabWidget->setCurrentPage( 0 );
503 writeCurrentM3u(); 503 writeCurrentM3u();
504} 504}
505 505
506 506
507void PlayListWidget::removeSelected() { 507void PlayListWidget::removeSelected() {
508 d->selectedFiles->removeSelected( ); 508 d->selectedFiles->removeSelected( );
509 writeCurrentM3u(); 509 writeCurrentM3u();
510} 510}
511 511
512 512
513void PlayListWidget::playIt( QListViewItem *it) { 513void PlayListWidget::playIt( QListViewItem *it) {
514 if(!it) return; 514 if(!it) return;
515 mediaPlayerState.setPlaying(FALSE); 515 mediaPlayerState.setPlaying(FALSE);
516 mediaPlayerState.setPlaying(TRUE); 516 mediaPlayerState.setPlaying(TRUE);
517 d->selectedFiles->unSelect(); 517 d->selectedFiles->unSelect();
518} 518}
519 519
520 520
521void PlayListWidget::addToSelection( QListViewItem *it) { 521void PlayListWidget::addToSelection( QListViewItem *it) {
522 d->setDocumentUsed = FALSE; 522 d->setDocumentUsed = FALSE;
523 523
524 if(it) { 524 if(it) {
525 if ( currentTab() == CurrentPlayList ) 525 if ( currentTab() == CurrentPlayList )
526 return; 526 return;
527 // case 1: { 527 // case 1: {
528 DocLnk lnk; 528 DocLnk lnk;
529 QString filename; 529 QString filename;
530 530
531 filename=it->text(3); 531 filename=it->text(3);
532 lnk.setName( QFileInfo(filename).baseName() ); //sets name 532 lnk.setName( QFileInfo(filename).baseName() ); //sets name
533 lnk.setFile( filename ); //sets file name 533 lnk.setFile( filename ); //sets file name
534 d->selectedFiles->addToSelection( lnk); 534 d->selectedFiles->addToSelection( lnk);
535 535
536 writeCurrentM3u(); 536 writeCurrentM3u();
537 tabWidget->setCurrentPage(0); 537 tabWidget->setCurrentPage(0);
538 538
539 } 539 }
540} 540}
541 541
542 542
543void PlayListWidget::tabChanged(QWidget *) { 543void PlayListWidget::tabChanged(QWidget *) {
544 544
545 d->tbPlay->setEnabled( true ); 545 d->tbPlay->setEnabled( true );
546 546
547 switch ( currentTab() ) { 547 switch ( currentTab() ) {
548 case CurrentPlayList: 548 case CurrentPlayList:
549 { 549 {
550 if( !tbDeletePlaylist->isHidden() ) { 550 if( !tbDeletePlaylist->isHidden() ) {
551 tbDeletePlaylist->hide(); 551 tbDeletePlaylist->hide();
552 } 552 }
553 d->tbRemoveFromList->setEnabled(TRUE); 553 d->tbRemoveFromList->setEnabled(TRUE);
554 d->tbAddToList->setEnabled(FALSE); 554 d->tbAddToList->setEnabled(FALSE);
555 555
556 d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); 556 d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() );
557 } 557 }
558 break; 558 break;
559 case AudioFiles: 559 case AudioFiles:
560 { 560 {
561 audioView->populateView(); 561 audioView->populateView();
562 562
563 if( !tbDeletePlaylist->isHidden() ) { 563 if( !tbDeletePlaylist->isHidden() ) {
564 tbDeletePlaylist->hide(); 564 tbDeletePlaylist->hide();
565 } 565 }
566 d->tbRemoveFromList->setEnabled(FALSE); 566 d->tbRemoveFromList->setEnabled(FALSE);
567 d->tbAddToList->setEnabled(TRUE); 567 d->tbAddToList->setEnabled(TRUE);
568 } 568 }
569 break; 569 break;
570 case VideoFiles: 570 case VideoFiles:
571 { 571 {
572 videoView->populateView(); 572 videoView->populateView();
573 if( !tbDeletePlaylist->isHidden() ) { 573 if( !tbDeletePlaylist->isHidden() ) {
574 tbDeletePlaylist->hide(); 574 tbDeletePlaylist->hide();
575 } 575 }
576 d->tbRemoveFromList->setEnabled(FALSE); 576 d->tbRemoveFromList->setEnabled(FALSE);
577 d->tbAddToList->setEnabled(TRUE); 577 d->tbAddToList->setEnabled(TRUE);
578 } 578 }
579 break; 579 break;
580 case PlayLists: 580 case PlayLists:
581 { 581 {
582 if( tbDeletePlaylist->isHidden() ) { 582 if( tbDeletePlaylist->isHidden() ) {
583 tbDeletePlaylist->show(); 583 tbDeletePlaylist->show();
584 } 584 }
585 playLists->reread(); 585 playLists->reread();
586 d->tbAddToList->setEnabled(FALSE); 586 d->tbAddToList->setEnabled(FALSE);
587 587
588 d->tbPlay->setEnabled( false ); 588 d->tbPlay->setEnabled( false );
589 } 589 }
590 break; 590 break;
591 }; 591 };
592} 592}
593 593
594 594
595void PlayListWidget::btnPlay(bool b) { 595void PlayListWidget::btnPlay(bool b) {
596// mediaPlayerState->setPlaying(false); 596// mediaPlayerState->setPlaying(false);
597 mediaPlayerState.setPlaying(b); 597 mediaPlayerState.setPlaying(b);
598 insanityBool=FALSE; 598 insanityBool=FALSE;
599} 599}
600 600
601void PlayListWidget::deletePlaylist() { 601void PlayListWidget::deletePlaylist() {
602 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 602 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
603 (tr("You really want to delete\nthis playlist?")), 603 (tr("You really want to delete\nthis playlist?")),
604 (tr("Yes")), (tr("No")), 0 )){ 604 (tr("Yes")), (tr("No")), 0 )){
605 case 0: // Yes clicked, 605 case 0: // Yes clicked,
606 QFile().remove(playLists->selectedDocument().file()); 606 QFile().remove(playLists->selectedDocument().file());
607 QFile().remove(playLists->selectedDocument().linkFile()); 607 QFile().remove(playLists->selectedDocument().linkFile());
608 playLists->reread(); 608 playLists->reread();
609 break; 609 break;
610 case 1: // Cancel 610 case 1: // Cancel
611 break; 611 break;
612 }; 612 };
613} 613}
614 614
615 615
616void PlayListWidget::playSelected() { 616void PlayListWidget::playSelected() {
617 btnPlay( TRUE); 617 btnPlay( TRUE);
618} 618}
619 619
620
621void PlayListWidget::scanForAudio() {
622 audioView->scanFiles();
623}
624
625void PlayListWidget::scanForVideo() {
626 videoView->scanFiles();
627}
628
629QListView *PlayListWidget::currentFileListView() const 620QListView *PlayListWidget::currentFileListView() const
630{ 621{
631 switch ( currentTab() ) { 622 switch ( currentTab() ) {
632 case AudioFiles: return audioView; 623 case AudioFiles: return audioView;
633 case VideoFiles: return videoView; 624 case VideoFiles: return videoView;
634 default: assert( false ); 625 default: assert( false );
635 } 626 }
636 return 0; 627 return 0;
637} 628}
638 629
639bool PlayListWidget::inFileListMode() const 630bool PlayListWidget::inFileListMode() const
640{ 631{
641 TabType tab = currentTab(); 632 TabType tab = currentTab();
642 return tab == AudioFiles || tab == VideoFiles; 633 return tab == AudioFiles || tab == VideoFiles;
643} 634}
644 635
645void PlayListWidget::openFile() { 636void PlayListWidget::openFile() {
646 // http://66.28.164.33:2080 637 // http://66.28.164.33:2080
647 // http://somafm.com/star0242.m3u 638 // http://somafm.com/star0242.m3u
648 QString filename, name; 639 QString filename, name;
649 InputDialog *fileDlg; 640 InputDialog *fileDlg;
650 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 641 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
651 fileDlg->exec(); 642 fileDlg->exec();
652 if( fileDlg->result() == 1 ) { 643 if( fileDlg->result() == 1 ) {
653 filename = fileDlg->text(); 644 filename = fileDlg->text();
654 qDebug( "Selected filename is " + filename ); 645 qDebug( "Selected filename is " + filename );
655 // Om3u *m3uList; 646 // Om3u *m3uList;
656 DocLnk lnk; 647 DocLnk lnk;
657 Config cfg( "OpiePlayer" ); 648 Config cfg( "OpiePlayer" );
658 cfg.setGroup("PlayList"); 649 cfg.setGroup("PlayList");
659 650
660 if(filename.left(4) == "http") { 651 if(filename.left(4) == "http") {
661 QString m3uFile, m3uFilePath; 652 QString m3uFile, m3uFilePath;
662 if(filename.find(":",8,TRUE) != -1) { //found a port 653 if(filename.find(":",8,TRUE) != -1) { //found a port
663 m3uFile = filename.left( filename.find( ":",8,TRUE)); 654 m3uFile = filename.left( filename.find( ":",8,TRUE));
664 m3uFile = m3uFile.right( 7); 655 m3uFile = m3uFile.right( 7);
665 } else if(filename.left(4) == "http"){ 656 } else if(filename.left(4) == "http"){
666 m3uFile=filename; 657 m3uFile=filename;
667 m3uFile = m3uFile.right( m3uFile.length() - 7); 658 m3uFile = m3uFile.right( m3uFile.length() - 7);
668 } else{ 659 } else{
669 m3uFile=filename; 660 m3uFile=filename;
670 } 661 }
671 662
672// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); 663// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile);
673 lnk.setName( filename ); //sets name 664 lnk.setName( filename ); //sets name
674 lnk.setFile( filename ); //sets file name 665 lnk.setFile( filename ); //sets file name
675 666
676// lnk.setIcon("opieplayer2/musicfile"); 667// lnk.setIcon("opieplayer2/musicfile");
677 668
678 d->selectedFiles->addToSelection( lnk ); 669 d->selectedFiles->addToSelection( lnk );
679 writeCurrentM3u(); 670 writeCurrentM3u();
680 d->selectedFiles->setSelectedItem( lnk.name()); 671 d->selectedFiles->setSelectedItem( lnk.name());
681 } 672 }
682 else if( filename.right( 3) == "m3u" ) { 673 else if( filename.right( 3) == "m3u" ) {
683 readm3u( filename ); 674 readm3u( filename );
684 675
685 } else if( filename.right(3) == "pls" ) { 676 } else if( filename.right(3) == "pls" ) {
686 readPls( filename ); 677 readPls( filename );
687 } else { 678 } else {
688 lnk.setName( QFileInfo(filename).baseName() ); //sets name 679 lnk.setName( QFileInfo(filename).baseName() ); //sets name
689 lnk.setFile( filename ); //sets file name 680 lnk.setFile( filename ); //sets file name
690 d->selectedFiles->addToSelection( lnk); 681 d->selectedFiles->addToSelection( lnk);
691 writeCurrentM3u(); 682 writeCurrentM3u();
692 d->selectedFiles->setSelectedItem( lnk.name()); 683 d->selectedFiles->setSelectedItem( lnk.name());
693 } 684 }
694 } 685 }
695 686
696 if( fileDlg ) { 687 if( fileDlg ) {
697 delete fileDlg; 688 delete fileDlg;
698 } 689 }
699} 690}
700 691
701/* 692/*
702reads m3u and shows files/urls to playlist widget */ 693reads m3u and shows files/urls to playlist widget */
703void PlayListWidget::readm3u( const QString &filename ) { 694void PlayListWidget::readm3u( const QString &filename ) {
704 qDebug( "read m3u filename " + filename ); 695 qDebug( "read m3u filename " + filename );
705 696
706 Om3u *m3uList; 697 Om3u *m3uList;
707 QString s, name; 698 QString s, name;
708 m3uList = new Om3u( filename, IO_ReadOnly ); 699 m3uList = new Om3u( filename, IO_ReadOnly );
709 m3uList->readM3u(); 700 m3uList->readM3u();
710 DocLnk lnk; 701 DocLnk lnk;
711 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 702 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
712 s = *it; 703 s = *it;
713// qDebug("reading "+ s); 704// qDebug("reading "+ s);
714 if(s.left(4)=="http") { 705 if(s.left(4)=="http") {
715 lnk.setName( s ); //sets file name 706 lnk.setName( s ); //sets file name
716 lnk.setIcon("opieplayer2/musicfile"); 707 lnk.setIcon("opieplayer2/musicfile");
717 lnk.setFile( s ); //sets file name 708 lnk.setFile( s ); //sets file name
718 709
719 } else { 710 } else {
720 // if( QFileInfo( s ).exists() ) { 711 // if( QFileInfo( s ).exists() ) {
721 lnk.setName( QFileInfo(s).baseName()); 712 lnk.setName( QFileInfo(s).baseName());
722 // if(s.right(4) == '.') {//if regular file 713 // if(s.right(4) == '.') {//if regular file
723 if(s.left(1) != "/") { 714 if(s.left(1) != "/") {
724 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); 715 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s);
725 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); 716 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
726// lnk.setIcon(MimeType(s).pixmap() ); 717// lnk.setIcon(MimeType(s).pixmap() );
727// lnk.setIcon("SoundPlayer"); 718// lnk.setIcon("SoundPlayer");
728 } else { 719 } else {
729 // qDebug("set link2 "+s); 720 // qDebug("set link2 "+s);
730 lnk.setFile( s); 721 lnk.setFile( s);
731// lnk.setIcon(MimeType(s).pixmap() ); 722// lnk.setIcon(MimeType(s).pixmap() );
732// lnk.setIcon("SoundPlayer"); 723// lnk.setIcon("SoundPlayer");
733 } 724 }
734 } 725 }
735 d->selectedFiles->addToSelection( lnk ); 726 d->selectedFiles->addToSelection( lnk );
736 } 727 }
737 Config config( "OpiePlayer" ); 728 Config config( "OpiePlayer" );
738 config.setGroup( "PlayList" ); 729 config.setGroup( "PlayList" );
739 730
740 config.writeEntry("CurrentPlaylist",filename); 731 config.writeEntry("CurrentPlaylist",filename);
741 config.write(); 732 config.write();
742 currentPlayList=filename; 733 currentPlayList=filename;
743 734
744// m3uList->write(); 735// m3uList->write();
745 m3uList->close(); 736 m3uList->close();
746 if(m3uList) delete m3uList; 737 if(m3uList) delete m3uList;
747 738
748 d->selectedFiles->setSelectedItem( s); 739 d->selectedFiles->setSelectedItem( s);
749 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); 740 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
750 741
751} 742}
752 743
753/* 744/*
754reads pls and adds files/urls to playlist */ 745reads pls and adds files/urls to playlist */
755void PlayListWidget::readPls( const QString &filename ) { 746void PlayListWidget::readPls( const QString &filename ) {
756 747
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h
index 8c22f17..5c8f30c 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.h
+++ b/noncore/multimedia/opieplayer2/playlistwidget.h
@@ -1,141 +1,139 @@
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#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; 101 QListView *currentFileListView() const;
102 102
103 bool inFileListMode() const; 103 bool inFileListMode() const;
104 104
105private slots: 105private slots:
106 void populateSkinsMenu(); 106 void populateSkinsMenu();
107 void skinsMenuActivated(int); 107 void skinsMenuActivated(int);
108 void pmViewActivated(int); 108 void pmViewActivated(int);
109 void writem3u(); 109 void writem3u();
110 void writeCurrentM3u(); 110 void writeCurrentM3u();
111 void scanForAudio();
112 void scanForVideo();
113 void openFile(); 111 void openFile();
114 void setDocument( const QString& fileref ); 112 void setDocument( const QString& fileref );
115 void addToSelection( const DocLnk& ); // Add a media file to the playlist 113 void addToSelection( const DocLnk& ); // Add a media file to the playlist
116 void addToSelection( QListViewItem* ); // Add a media file to the playlist 114 void addToSelection( QListViewItem* ); // Add a media file to the playlist
117 void clearList(); 115 void clearList();
118 void addAllToList(); 116 void addAllToList();
119 void addAllMusicToList(); 117 void addAllMusicToList();
120 void addAllVideoToList(); 118 void addAllVideoToList();
121 void saveList(); // Save the playlist 119 void saveList(); // Save the playlist
122 void loadList( const DocLnk &); // Load a playlist 120 void loadList( const DocLnk &); // Load a playlist
123 void playIt( QListViewItem *); 121 void playIt( QListViewItem *);
124 void btnPlay(bool); 122 void btnPlay(bool);
125 void deletePlaylist(); 123 void deletePlaylist();
126 void addSelected(); 124 void addSelected();
127 void removeSelected(); 125 void removeSelected();
128 void tabChanged(QWidget*); 126 void tabChanged(QWidget*);
129 void viewPressed( int, QListViewItem *, const QPoint&, int); 127 void viewPressed( int, QListViewItem *, const QPoint&, int);
130 void playlistViewPressed( int, QListViewItem *, const QPoint&, int); 128 void playlistViewPressed( int, QListViewItem *, const QPoint&, int);
131 void playSelected(); 129 void playSelected();
132 130
133private: 131private:
134 bool fromSetDocument; 132 bool fromSetDocument;
135 bool insanityBool; 133 bool insanityBool;
136 QString setDocFileRef, currentPlayList; 134 QString setDocFileRef, currentPlayList;
137 int selected; 135 int selected;
138}; 136};
139 137
140#endif // PLAY_LIST_WIDGET_H 138#endif // PLAY_LIST_WIDGET_H
141 139