summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-02 14:12:57 (UTC)
committer simon <simon>2002-12-02 14:12:57 (UTC)
commit6a1400bdf754df18a1f20bd50ab5e5e4b0fd5a86 (patch) (unidiff)
treed245c2d8dff55f422ed779c6c8ebeefb0ab10ac6
parentcc1324d2def09e55e5a688fa3e2d33924f7f5ef9 (diff)
downloadopie-6a1400bdf754df18a1f20bd50ab5e5e4b0fd5a86.zip
opie-6a1400bdf754df18a1f20bd50ab5e5e4b0fd5a86.tar.gz
opie-6a1400bdf754df18a1f20bd50ab5e5e4b0fd5a86.tar.bz2
- added a currentTab method that returns an enum containing the current tab
type in a verbose manner (AudioFiles, VideoFiles, CurrentPlayList, etc.), as a future replacment for whichList() which just returns an integer
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp12
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.h3
2 files changed, 15 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index d1506db..9918eeb 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -1,438 +1,439 @@
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 52
53//only needed for the random play 53//only needed for the random play
54#include <stdlib.h> 54#include <stdlib.h>
55#include <assert.h>
55 56
56#include "audiowidget.h" 57#include "audiowidget.h"
57#include "videowidget.h" 58#include "videowidget.h"
58 59
59extern MediaPlayerState *mediaPlayerState; 60extern MediaPlayerState *mediaPlayerState;
60// extern AudioWidget *audioUI; 61// extern AudioWidget *audioUI;
61// extern VideoWidget *videoUI; 62// extern VideoWidget *videoUI;
62 63
63QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg"; 64QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg";
64// no m3u's here please 65// no m3u's here please
65 66
66PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 67PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
67 : PlayListWidgetGui( parent, name, fl ) { 68 : PlayListWidgetGui( parent, name, fl ) {
68 69
69 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), 70 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ),
70 "opieplayer2/add_to_playlist", 71 "opieplayer2/add_to_playlist",
71 this , SLOT(addSelected() ) ); 72 this , SLOT(addSelected() ) );
72 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), 73 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ),
73 "opieplayer2/remove_from_playlist", 74 "opieplayer2/remove_from_playlist",
74 this , SLOT(removeSelected() ) ); 75 this , SLOT(removeSelected() ) );
75 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", 76 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play",
76 this , SLOT( btnPlay( bool) ), TRUE ); 77 this , SLOT( btnPlay( bool) ), TRUE );
77 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", 78 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle",
78 mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); 79 mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE );
79 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", 80 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop",
80 mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); 81 mediaPlayerState, SLOT( setLooping( bool ) ), TRUE );
81 82
82 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 83 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
83 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), 84 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ),
84 this, SLOT( addAllMusicToList() ) ); 85 this, SLOT( addAllMusicToList() ) );
85 (void)new MenuItem( pmPlayList, tr( "Add all video files" ), 86 (void)new MenuItem( pmPlayList, tr( "Add all video files" ),
86 this, SLOT( addAllVideoToList() ) ); 87 this, SLOT( addAllVideoToList() ) );
87 (void)new MenuItem( pmPlayList, tr( "Add all files" ), 88 (void)new MenuItem( pmPlayList, tr( "Add all files" ),
88 this, SLOT( addAllToList() ) ); 89 this, SLOT( addAllToList() ) );
89 pmPlayList->insertSeparator(-1); 90 pmPlayList->insertSeparator(-1);
90// (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), 91// (void)new MenuItem( pmPlayList, tr( "Save PlayList" ),
91// this, SLOT( saveList() ) ); 92// this, SLOT( saveList() ) );
92 (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), 93 (void)new MenuItem( pmPlayList, tr( "Save Playlist" ),
93 this, SLOT(writem3u() ) ); 94 this, SLOT(writem3u() ) );
94 pmPlayList->insertSeparator(-1); 95 pmPlayList->insertSeparator(-1);
95 (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), 96 (void)new MenuItem( pmPlayList, tr( "Open File or URL" ),
96 this,SLOT( openFile() ) ); 97 this,SLOT( openFile() ) );
97 pmPlayList->insertSeparator(-1); 98 pmPlayList->insertSeparator(-1);
98 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), 99 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ),
99 this,SLOT( scanForAudio() ) ); 100 this,SLOT( scanForAudio() ) );
100 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), 101 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ),
101 this,SLOT( scanForVideo() ) ); 102 this,SLOT( scanForVideo() ) );
102 103
103 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), 104 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"),
104 mediaPlayerState, SLOT( toggleFullscreen() ) ); 105 mediaPlayerState, SLOT( toggleFullscreen() ) );
105 106
106 Config cfg( "OpiePlayer" ); 107 Config cfg( "OpiePlayer" );
107 bool b= cfg.readBoolEntry("FullScreen", 0); 108 bool b= cfg.readBoolEntry("FullScreen", 0);
108 mediaPlayerState->setFullscreen( b ); 109 mediaPlayerState->setFullscreen( b );
109 pmView->setItemChecked( -16, b ); 110 pmView->setItemChecked( -16, b );
110 111
111 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", 112 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up",
112 d->selectedFiles, SLOT(moveSelectedUp() ) ); 113 d->selectedFiles, SLOT(moveSelectedUp() ) );
113 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", 114 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut",
114 d->selectedFiles, SLOT(removeSelected() ) ); 115 d->selectedFiles, SLOT(removeSelected() ) );
115 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", 116 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down",
116 d->selectedFiles, SLOT(moveSelectedDown() ) ); 117 d->selectedFiles, SLOT(moveSelectedDown() ) );
117 // QVBox *stretch2 = new QVBox( vbox1 ); 118 // QVBox *stretch2 = new QVBox( vbox1 );
118 119
119 connect( tbDeletePlaylist, ( SIGNAL( released() ) ), 120 connect( tbDeletePlaylist, ( SIGNAL( released() ) ),
120 SLOT( deletePlaylist() ) ); 121 SLOT( deletePlaylist() ) );
121 connect( pmView, SIGNAL( activated( int ) ), 122 connect( pmView, SIGNAL( activated( int ) ),
122 this, SLOT( pmViewActivated( int ) ) ); 123 this, SLOT( pmViewActivated( int ) ) );
123 connect( skinsMenu, SIGNAL( activated( int ) ) , 124 connect( skinsMenu, SIGNAL( activated( int ) ) ,
124 this, SLOT( skinsMenuActivated( int ) ) ); 125 this, SLOT( skinsMenuActivated( int ) ) );
125 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), 126 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ),
126 this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); 127 this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) );
127 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), 128 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ),
128 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); 129 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) );
129 connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), 130 connect( audioView, SIGNAL( returnPressed( QListViewItem *) ),
130 this,SLOT( playIt( QListViewItem *) ) ); 131 this,SLOT( playIt( QListViewItem *) ) );
131 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), 132 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ),
132 this, SLOT( addToSelection( QListViewItem *) ) ); 133 this, SLOT( addToSelection( QListViewItem *) ) );
133 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), 134 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ),
134 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); 135 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) );
135 connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), 136 connect( videoView, SIGNAL( returnPressed( QListViewItem *) ),
136 this,SLOT( playIt( QListViewItem *) ) ); 137 this,SLOT( playIt( QListViewItem *) ) );
137 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), 138 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ),
138 this, SLOT( addToSelection( QListViewItem *) ) ); 139 this, SLOT( addToSelection( QListViewItem *) ) );
139 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), 140 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ),
140 this, SLOT( loadList( const DocLnk & ) ) ); 141 this, SLOT( loadList( const DocLnk & ) ) );
141 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), 142 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ),
142 this, SLOT( tabChanged( QWidget* ) ) ); 143 this, SLOT( tabChanged( QWidget* ) ) );
143 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), 144 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ),
144 d->tbPlay, SLOT( setOn( bool ) ) ); 145 d->tbPlay, SLOT( setOn( bool ) ) );
145 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), 146 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ),
146 d->tbLoop, SLOT( setOn( bool ) ) ); 147 d->tbLoop, SLOT( setOn( bool ) ) );
147 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), 148 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ),
148 d->tbShuffle, SLOT( setOn( bool ) ) ); 149 d->tbShuffle, SLOT( setOn( bool ) ) );
149 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), 150 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ),
150 this, SLOT( setPlaylist( bool ) ) ); 151 this, SLOT( setPlaylist( bool ) ) );
151 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), 152 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ),
152 this, SLOT( playIt( QListViewItem *) ) ); 153 this, SLOT( playIt( QListViewItem *) ) );
153 connect ( gammaSlider, SIGNAL( valueChanged( int ) ), 154 connect ( gammaSlider, SIGNAL( valueChanged( int ) ),
154 mediaPlayerState, SLOT( setVideoGamma( int ) ) ); 155 mediaPlayerState, SLOT( setVideoGamma( int ) ) );
155 156
156 // see which skins are installed 157 // see which skins are installed
157 videoScan=false; 158 videoScan=false;
158 audioScan=false; 159 audioScan=false;
159 audioPopulated=false; 160 audioPopulated=false;
160 videoPopulated=false; 161 videoPopulated=false;
161 populateSkinsMenu(); 162 populateSkinsMenu();
162 initializeStates(); 163 initializeStates();
163 164
164 cfg.setGroup("PlayList"); 165 cfg.setGroup("PlayList");
165 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); 166 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
166 loadList(DocLnk( currentPlaylist ) ); 167 loadList(DocLnk( currentPlaylist ) );
167} 168}
168 169
169 170
170PlayListWidget::~PlayListWidget() { 171PlayListWidget::~PlayListWidget() {
171 if ( d->current ) { 172 if ( d->current ) {
172 delete d->current; 173 delete d->current;
173 } 174 }
174 delete d; 175 delete d;
175} 176}
176 177
177 178
178void PlayListWidget::initializeStates() { 179void PlayListWidget::initializeStates() {
179 d->tbPlay->setOn( mediaPlayerState->isPlaying() ); 180 d->tbPlay->setOn( mediaPlayerState->isPlaying() );
180 d->tbLoop->setOn( mediaPlayerState->isLooping() ); 181 d->tbLoop->setOn( mediaPlayerState->isLooping() );
181 d->tbShuffle->setOn( mediaPlayerState->isShuffled() ); 182 d->tbShuffle->setOn( mediaPlayerState->isShuffled() );
182 setPlaylist( true ); 183 setPlaylist( true );
183} 184}
184 185
185void PlayListWidget::writeDefaultPlaylist() { 186void PlayListWidget::writeDefaultPlaylist() {
186 187
187 Config config( "OpiePlayer" ); 188 Config config( "OpiePlayer" );
188 config.setGroup( "PlayList" ); 189 config.setGroup( "PlayList" );
189 QString filename=QPEApplication::documentDir() + "/default.m3u"; 190 QString filename=QPEApplication::documentDir() + "/default.m3u";
190 QString currentString = config.readEntry( "CurrentPlaylist", filename); 191 QString currentString = config.readEntry( "CurrentPlaylist", filename);
191 if( currentString == filename) { 192 if( currentString == filename) {
192 Om3u *m3uList; 193 Om3u *m3uList;
193 // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); 194 // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>");
194 if( d->selectedFiles->first() ) { 195 if( d->selectedFiles->first() ) {
195 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); 196 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate);
196 do { 197 do {
197 // qDebug(d->selectedFiles->current()->file()); 198 // qDebug(d->selectedFiles->current()->file());
198 m3uList->add( d->selectedFiles->current()->file() ); 199 m3uList->add( d->selectedFiles->current()->file() );
199 } 200 }
200 while ( d->selectedFiles->next() ); 201 while ( d->selectedFiles->next() );
201 202
202 m3uList->write(); 203 m3uList->write();
203 m3uList->close(); 204 m3uList->close();
204 if(m3uList) delete m3uList; 205 if(m3uList) delete m3uList;
205 206
206 } 207 }
207 } 208 }
208} 209}
209 210
210void PlayListWidget::addToSelection( const DocLnk& lnk ) { 211void PlayListWidget::addToSelection( const DocLnk& lnk ) {
211 d->setDocumentUsed = FALSE; 212 d->setDocumentUsed = FALSE;
212 if ( mediaPlayerState->isUsingPlaylist() ) { 213 if ( mediaPlayerState->isUsingPlaylist() ) {
213 if( QFileInfo( lnk.file() ).exists() || 214 if( QFileInfo( lnk.file() ).exists() ||
214 lnk.file().left(4) == "http" ) { 215 lnk.file().left(4) == "http" ) {
215 d->selectedFiles->addToSelection( lnk ); 216 d->selectedFiles->addToSelection( lnk );
216 } 217 }
217// writeCurrentM3u(); 218// writeCurrentM3u();
218 } 219 }
219 else 220 else
220 mediaPlayerState->setPlaying( TRUE ); 221 mediaPlayerState->setPlaying( TRUE );
221} 222}
222 223
223 224
224void PlayListWidget::clearList() { 225void PlayListWidget::clearList() {
225 while ( first() ) { 226 while ( first() ) {
226 d->selectedFiles->removeSelected(); 227 d->selectedFiles->removeSelected();
227 } 228 }
228} 229}
229 230
230void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { 231void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
231 switch (mouse) { 232 switch (mouse) {
232 case 1: 233 case 1:
233 break; 234 break;
234 case 2: 235 case 2:
235 { 236 {
236 QPopupMenu m; 237 QPopupMenu m;
237 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 238 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
238 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 239 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
239 m.exec( QCursor::pos() ); 240 m.exec( QCursor::pos() );
240 } 241 }
241 break; 242 break;
242 } 243 }
243} 244}
244 245
245 246
246void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { 247void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) {
247 switch (mouse) { 248 switch (mouse) {
248 case 1: 249 case 1:
249 break; 250 break;
250 case 2: 251 case 2:
251 { 252 {
252 QPopupMenu m; 253 QPopupMenu m;
253 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 254 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
254 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 255 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
255 m.exec( QCursor::pos() ); 256 m.exec( QCursor::pos() );
256 } 257 }
257 break; 258 break;
258 } 259 }
259} 260}
260 261
261 262
262void PlayListWidget::addAllToList() { 263void PlayListWidget::addAllToList() {
263 264
264// QTime t; 265// QTime t;
265// t.start(); 266// t.start();
266 267
267 if(!audioScan) { 268 if(!audioScan) {
268 if(audioView->childCount() < 1) 269 if(audioView->childCount() < 1)
269 populateAudioView(); 270 populateAudioView();
270 } 271 }
271 272
272 QListViewItemIterator audioIt( audioView ); 273 QListViewItemIterator audioIt( audioView );
273 DocLnk lnk; 274 DocLnk lnk;
274 QString filename; 275 QString filename;
275 // iterate through all items of the listview 276 // iterate through all items of the listview
276 for ( ; audioIt.current(); ++audioIt ) { 277 for ( ; audioIt.current(); ++audioIt ) {
277 filename = audioIt.current()->text(3); 278 filename = audioIt.current()->text(3);
278 lnk.setName( QFileInfo(filename).baseName() ); //sets name 279 lnk.setName( QFileInfo(filename).baseName() ); //sets name
279 lnk.setFile( filename ); //sets file name 280 lnk.setFile( filename ); //sets file name
280 d->selectedFiles->addToSelection( lnk); 281 d->selectedFiles->addToSelection( lnk);
281 } 282 }
282 283
283 if(!videoScan) { 284 if(!videoScan) {
284 if(videoView->childCount() < 1) 285 if(videoView->childCount() < 1)
285 populateVideoView(); 286 populateVideoView();
286 } 287 }
287 288
288 QListViewItemIterator videoIt( videoView ); 289 QListViewItemIterator videoIt( videoView );
289 for ( ; videoIt.current(); ++videoIt ) { 290 for ( ; videoIt.current(); ++videoIt ) {
290 filename = videoIt.current()->text(3); 291 filename = videoIt.current()->text(3);
291 lnk.setName( QFileInfo(filename).baseName() ); //sets name 292 lnk.setName( QFileInfo(filename).baseName() ); //sets name
292 lnk.setFile( filename ); //sets file name 293 lnk.setFile( filename ); //sets file name
293 d->selectedFiles->addToSelection( lnk); 294 d->selectedFiles->addToSelection( lnk);
294 } 295 }
295 296
296 // d->selectedFiles->addToSelection( ); 297 // d->selectedFiles->addToSelection( );
297 // if ( it.current()->isSelected() ) 298 // if ( it.current()->isSelected() )
298 // lst->append( audioIt.current() ); 299 // lst->append( audioIt.current() );
299 // } 300 // }
300 301
301 302
302// if(!audioScan) 303// if(!audioScan)
303// scanForAudio(); 304// scanForAudio();
304// if(!videoScan) 305// if(!videoScan)
305// scanForVideo(); 306// scanForVideo();
306 307
307// DocLnkSet filesAll; 308// DocLnkSet filesAll;
308// Global::findDocuments(&filesAll, "video/*;"+audioMimes); 309// Global::findDocuments(&filesAll, "video/*;"+audioMimes);
309// QListIterator<DocLnk> Adit( filesAll.children() ); 310// QListIterator<DocLnk> Adit( filesAll.children() );
310// for ( ; Adit.current(); ++Adit ) { 311// for ( ; Adit.current(); ++Adit ) {
311// if( QFileInfo( Adit.current()->file() ).exists() ) { 312// if( QFileInfo( Adit.current()->file() ).exists() ) {
312// d->selectedFiles->addToSelection( **Adit ); 313// d->selectedFiles->addToSelection( **Adit );
313// } 314// }
314// } 315// }
315 316
316 // qDebug("elapsed time %d", t.elapsed() ); 317 // qDebug("elapsed time %d", t.elapsed() );
317 318
318 tabWidget->setCurrentPage(0); 319 tabWidget->setCurrentPage(0);
319 320
320 writeCurrentM3u(); 321 writeCurrentM3u();
321 d->selectedFiles->first(); 322 d->selectedFiles->first();
322} 323}
323 324
324 325
325void PlayListWidget::addAllMusicToList() { 326void PlayListWidget::addAllMusicToList() {
326 327
327 if(!audioScan) { 328 if(!audioScan) {
328 if(audioView->childCount() < 1) 329 if(audioView->childCount() < 1)
329 populateAudioView(); 330 populateAudioView();
330 } 331 }
331 332
332 QListViewItemIterator audioIt( audioView ); 333 QListViewItemIterator audioIt( audioView );
333 DocLnk lnk; 334 DocLnk lnk;
334 QString filename; 335 QString filename;
335 // iterate through all items of the listview 336 // iterate through all items of the listview
336 for ( ; audioIt.current(); ++audioIt ) { 337 for ( ; audioIt.current(); ++audioIt ) {
337 filename = audioIt.current()->text(3); 338 filename = audioIt.current()->text(3);
338 lnk.setName( QFileInfo(filename).baseName() ); //sets name 339 lnk.setName( QFileInfo(filename).baseName() ); //sets name
339 lnk.setFile( filename ); //sets file name 340 lnk.setFile( filename ); //sets file name
340 d->selectedFiles->addToSelection( lnk); 341 d->selectedFiles->addToSelection( lnk);
341 } 342 }
342 343
343 /* if(!audioScan) 344 /* if(!audioScan)
344 scanForAudio(); 345 scanForAudio();
345 QListIterator<DocLnk> dit( files.children() ); 346 QListIterator<DocLnk> dit( files.children() );
346 for ( ; dit.current(); ++dit ) { 347 for ( ; dit.current(); ++dit ) {
347 if( QFileInfo(dit.current()->file() ).exists() ) { 348 if( QFileInfo(dit.current()->file() ).exists() ) {
348 d->selectedFiles->addToSelection( **dit ); 349 d->selectedFiles->addToSelection( **dit );
349 } 350 }
350 } 351 }
351 */ 352 */
352 tabWidget->setCurrentPage(0); 353 tabWidget->setCurrentPage(0);
353 writeCurrentM3u(); 354 writeCurrentM3u();
354 d->selectedFiles->first(); 355 d->selectedFiles->first();
355} 356}
356 357
357 358
358void PlayListWidget::addAllVideoToList() { 359void PlayListWidget::addAllVideoToList() {
359 360
360 if(!videoScan) { 361 if(!videoScan) {
361 if(videoView->childCount() < 1) 362 if(videoView->childCount() < 1)
362 populateVideoView(); 363 populateVideoView();
363 } 364 }
364 365
365 QListViewItemIterator videoIt( videoView ); 366 QListViewItemIterator videoIt( videoView );
366 DocLnk lnk; 367 DocLnk lnk;
367 QString filename; 368 QString filename;
368 for ( ; videoIt.current(); ++videoIt ) { 369 for ( ; videoIt.current(); ++videoIt ) {
369 filename = videoIt.current()->text(3); 370 filename = videoIt.current()->text(3);
370 lnk.setName( QFileInfo(filename).baseName() ); //sets name 371 lnk.setName( QFileInfo(filename).baseName() ); //sets name
371 lnk.setFile( filename ); //sets file name 372 lnk.setFile( filename ); //sets file name
372 d->selectedFiles->addToSelection( lnk); 373 d->selectedFiles->addToSelection( lnk);
373 } 374 }
374 375
375 376
376 /* if(!videoScan) 377 /* if(!videoScan)
377 scanForVideo(); 378 scanForVideo();
378 QListIterator<DocLnk> dit( vFiles.children() ); 379 QListIterator<DocLnk> dit( vFiles.children() );
379 for ( ; dit.current(); ++dit ) { 380 for ( ; dit.current(); ++dit ) {
380 if( QFileInfo( dit.current()->file() ).exists() ) { 381 if( QFileInfo( dit.current()->file() ).exists() ) {
381 d->selectedFiles->addToSelection( **dit ); 382 d->selectedFiles->addToSelection( **dit );
382 } 383 }
383 } 384 }
384*/ 385*/
385 tabWidget->setCurrentPage(0); 386 tabWidget->setCurrentPage(0);
386 writeCurrentM3u(); 387 writeCurrentM3u();
387 d->selectedFiles->first(); 388 d->selectedFiles->first();
388} 389}
389 390
390 391
391void PlayListWidget::setDocument( const QString& fileref ) { 392void PlayListWidget::setDocument( const QString& fileref ) {
392 // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); 393 // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref );
393 fromSetDocument = TRUE; 394 fromSetDocument = TRUE;
394 if ( fileref.isNull() ) { 395 if ( fileref.isNull() ) {
395 QMessageBox::warning( this, tr( "Invalid File" ), 396 QMessageBox::warning( this, tr( "Invalid File" ),
396 tr( "There was a problem in getting the file." ) ); 397 tr( "There was a problem in getting the file." ) );
397 return; 398 return;
398 } 399 }
399 400
400 clearList(); 401 clearList();
401 if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u 402 if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u
402 readm3u( fileref ); 403 readm3u( fileref );
403 } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { 404 } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) {
404 readm3u( DocLnk( fileref).file() ); 405 readm3u( DocLnk( fileref).file() );
405 } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls 406 } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls
406 readPls( fileref ); 407 readPls( fileref );
407 } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { 408 } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) {
408 readPls( DocLnk( fileref).file() ); 409 readPls( DocLnk( fileref).file() );
409 } else { 410 } else {
410 clearList(); 411 clearList();
411 addToSelection( DocLnk( fileref ) ); 412 addToSelection( DocLnk( fileref ) );
412 writeCurrentM3u(); 413 writeCurrentM3u();
413 414
414 d->setDocumentUsed = TRUE; 415 d->setDocumentUsed = TRUE;
415 mediaPlayerState->setPlaying( FALSE ); 416 mediaPlayerState->setPlaying( FALSE );
416 mediaPlayerState->setPlaying( TRUE ); 417 mediaPlayerState->setPlaying( TRUE );
417 } 418 }
418} 419}
419 420
420 421
421void PlayListWidget::useSelectedDocument() { 422void PlayListWidget::useSelectedDocument() {
422 d->setDocumentUsed = FALSE; 423 d->setDocumentUsed = FALSE;
423} 424}
424 425
425 426
426const DocLnk *PlayListWidget::current() { // this is fugly 427const DocLnk *PlayListWidget::current() { // this is fugly
427 switch ( whichList() ) { 428 switch ( whichList() ) {
428 case 0: //playlist 429 case 0: //playlist
429 { 430 {
430// qDebug("playlist"); 431// qDebug("playlist");
431 if ( mediaPlayerState->isUsingPlaylist() ) { 432 if ( mediaPlayerState->isUsingPlaylist() ) {
432 return d->selectedFiles->current(); 433 return d->selectedFiles->current();
433 } else if ( d->setDocumentUsed && d->current ) { 434 } else if ( d->setDocumentUsed && d->current ) {
434 return d->current; 435 return d->current;
435 } else { 436 } else {
436 return &(d->files->selectedDocument()); 437 return &(d->files->selectedDocument());
437 } 438 }
438 } 439 }
@@ -764,395 +765,406 @@ void PlayListWidget::populateVideoView() {
764 StorageInfo storageInfo; 765 StorageInfo storageInfo;
765 // const QList<FileSystem> &fs = storageInfo.fileSystems(); 766 // const QList<FileSystem> &fs = storageInfo.fileSystems();
766 767
767 if(!videoScan ) { 768 if(!videoScan ) {
768 scanForVideo(); 769 scanForVideo();
769 } 770 }
770 771
771 QListIterator<DocLnk> Vdit( vFiles.children() ); 772 QListIterator<DocLnk> Vdit( vFiles.children() );
772// QListIterator<FileSystem> it ( fs ); 773// QListIterator<FileSystem> it ( fs );
773 videoView->clear(); 774 videoView->clear();
774 QString storage, pathName; 775 QString storage, pathName;
775 for ( ; Vdit.current(); ++Vdit ) { 776 for ( ; Vdit.current(); ++Vdit ) {
776// // for( ; it.current(); ++it ) { 777// // for( ; it.current(); ++it ) {
777// const QString name = (*Vdit)->name(); 778// const QString name = (*Vdit)->name();
778// const QString path = (*Vdit)->path(); 779// const QString path = (*Vdit)->path();
779// if( Vdit.current()->file().find(path) != -1 ) { 780// if( Vdit.current()->file().find(path) != -1 ) {
780// storage=name; 781// storage=name;
781// pathName=path; 782// pathName=path;
782// // } 783// // }
783// } 784// }
784 785
785 QListViewItem * newItem; 786 QListViewItem * newItem;
786 if ( QFile( Vdit.current()->file() ).exists() ) { 787 if ( QFile( Vdit.current()->file() ).exists() ) {
787 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 788 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
788 QString::number( QFile( Vdit.current()->file() ).size() ), 789 QString::number( QFile( Vdit.current()->file() ).size() ),
789 ""/*storage*/, Vdit.current()->file()); 790 ""/*storage*/, Vdit.current()->file());
790 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); 791 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) );
791 } 792 }
792 } 793 }
793 videoPopulated=true; 794 videoPopulated=true;
794} 795}
795 796
796 797
797void PlayListWidget::openFile() { 798void PlayListWidget::openFile() {
798 // http://66.28.164.33:2080 799 // http://66.28.164.33:2080
799 // http://somafm.com/star0242.m3u 800 // http://somafm.com/star0242.m3u
800 QString filename, name; 801 QString filename, name;
801 InputDialog *fileDlg; 802 InputDialog *fileDlg;
802 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 803 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
803 fileDlg->exec(); 804 fileDlg->exec();
804 if( fileDlg->result() == 1 ) { 805 if( fileDlg->result() == 1 ) {
805 filename = fileDlg->text(); 806 filename = fileDlg->text();
806 qDebug( "Selected filename is " + filename ); 807 qDebug( "Selected filename is " + filename );
807 // Om3u *m3uList; 808 // Om3u *m3uList;
808 DocLnk lnk; 809 DocLnk lnk;
809 Config cfg( "OpiePlayer" ); 810 Config cfg( "OpiePlayer" );
810 cfg.setGroup("PlayList"); 811 cfg.setGroup("PlayList");
811 812
812 if(filename.left(4) == "http") { 813 if(filename.left(4) == "http") {
813 QString m3uFile, m3uFilePath; 814 QString m3uFile, m3uFilePath;
814 if(filename.find(":",8,TRUE) != -1) { //found a port 815 if(filename.find(":",8,TRUE) != -1) { //found a port
815 m3uFile = filename.left( filename.find( ":",8,TRUE)); 816 m3uFile = filename.left( filename.find( ":",8,TRUE));
816 m3uFile = m3uFile.right( 7); 817 m3uFile = m3uFile.right( 7);
817 } else if(filename.left(4) == "http"){ 818 } else if(filename.left(4) == "http"){
818 m3uFile=filename; 819 m3uFile=filename;
819 m3uFile = m3uFile.right( m3uFile.length() - 7); 820 m3uFile = m3uFile.right( m3uFile.length() - 7);
820 } else{ 821 } else{
821 m3uFile=filename; 822 m3uFile=filename;
822 } 823 }
823 824
824// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); 825// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile);
825 lnk.setName( filename ); //sets name 826 lnk.setName( filename ); //sets name
826 lnk.setFile( filename ); //sets file name 827 lnk.setFile( filename ); //sets file name
827 828
828// lnk.setIcon("opieplayer2/musicfile"); 829// lnk.setIcon("opieplayer2/musicfile");
829 830
830 d->selectedFiles->addToSelection( lnk ); 831 d->selectedFiles->addToSelection( lnk );
831 writeCurrentM3u(); 832 writeCurrentM3u();
832 d->selectedFiles->setSelectedItem( lnk.name()); 833 d->selectedFiles->setSelectedItem( lnk.name());
833 } 834 }
834 else if( filename.right( 3) == "m3u" ) { 835 else if( filename.right( 3) == "m3u" ) {
835 readm3u( filename ); 836 readm3u( filename );
836 837
837 } else if( filename.right(3) == "pls" ) { 838 } else if( filename.right(3) == "pls" ) {
838 readPls( filename ); 839 readPls( filename );
839 } else { 840 } else {
840 lnk.setName( QFileInfo(filename).baseName() ); //sets name 841 lnk.setName( QFileInfo(filename).baseName() ); //sets name
841 lnk.setFile( filename ); //sets file name 842 lnk.setFile( filename ); //sets file name
842 d->selectedFiles->addToSelection( lnk); 843 d->selectedFiles->addToSelection( lnk);
843 writeCurrentM3u(); 844 writeCurrentM3u();
844 d->selectedFiles->setSelectedItem( lnk.name()); 845 d->selectedFiles->setSelectedItem( lnk.name());
845 } 846 }
846 } 847 }
847 848
848 if( fileDlg ) { 849 if( fileDlg ) {
849 delete fileDlg; 850 delete fileDlg;
850 } 851 }
851} 852}
852 853
853/* 854/*
854reads m3u and shows files/urls to playlist widget */ 855reads m3u and shows files/urls to playlist widget */
855void PlayListWidget::readm3u( const QString &filename ) { 856void PlayListWidget::readm3u( const QString &filename ) {
856 qDebug( "read m3u filename " + filename ); 857 qDebug( "read m3u filename " + filename );
857 858
858 Om3u *m3uList; 859 Om3u *m3uList;
859 QString s, name; 860 QString s, name;
860 m3uList = new Om3u( filename, IO_ReadOnly ); 861 m3uList = new Om3u( filename, IO_ReadOnly );
861 m3uList->readM3u(); 862 m3uList->readM3u();
862 DocLnk lnk; 863 DocLnk lnk;
863 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 864 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
864 s = *it; 865 s = *it;
865// qDebug("reading "+ s); 866// qDebug("reading "+ s);
866 if(s.left(4)=="http") { 867 if(s.left(4)=="http") {
867 lnk.setName( s ); //sets file name 868 lnk.setName( s ); //sets file name
868 lnk.setIcon("opieplayer2/musicfile"); 869 lnk.setIcon("opieplayer2/musicfile");
869 lnk.setFile( s ); //sets file name 870 lnk.setFile( s ); //sets file name
870 871
871 } else { 872 } else {
872 // if( QFileInfo( s ).exists() ) { 873 // if( QFileInfo( s ).exists() ) {
873 lnk.setName( QFileInfo(s).baseName()); 874 lnk.setName( QFileInfo(s).baseName());
874 // if(s.right(4) == '.') {//if regular file 875 // if(s.right(4) == '.') {//if regular file
875 if(s.left(1) != "/") { 876 if(s.left(1) != "/") {
876 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); 877 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s);
877 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); 878 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
878// lnk.setIcon(MimeType(s).pixmap() ); 879// lnk.setIcon(MimeType(s).pixmap() );
879// lnk.setIcon("SoundPlayer"); 880// lnk.setIcon("SoundPlayer");
880 } else { 881 } else {
881 // qDebug("set link2 "+s); 882 // qDebug("set link2 "+s);
882 lnk.setFile( s); 883 lnk.setFile( s);
883// lnk.setIcon(MimeType(s).pixmap() ); 884// lnk.setIcon(MimeType(s).pixmap() );
884// lnk.setIcon("SoundPlayer"); 885// lnk.setIcon("SoundPlayer");
885 } 886 }
886 } 887 }
887 d->selectedFiles->addToSelection( lnk ); 888 d->selectedFiles->addToSelection( lnk );
888 } 889 }
889 Config config( "OpiePlayer" ); 890 Config config( "OpiePlayer" );
890 config.setGroup( "PlayList" ); 891 config.setGroup( "PlayList" );
891 892
892 config.writeEntry("CurrentPlaylist",filename); 893 config.writeEntry("CurrentPlaylist",filename);
893 config.write(); 894 config.write();
894 currentPlayList=filename; 895 currentPlayList=filename;
895 896
896// m3uList->write(); 897// m3uList->write();
897 m3uList->close(); 898 m3uList->close();
898 if(m3uList) delete m3uList; 899 if(m3uList) delete m3uList;
899 900
900 d->selectedFiles->setSelectedItem( s); 901 d->selectedFiles->setSelectedItem( s);
901 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); 902 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
902 903
903} 904}
904 905
905/* 906/*
906reads pls and adds files/urls to playlist */ 907reads pls and adds files/urls to playlist */
907void PlayListWidget::readPls( const QString &filename ) { 908void PlayListWidget::readPls( const QString &filename ) {
908 909
909 qDebug( "pls filename is " + filename ); 910 qDebug( "pls filename is " + filename );
910 Om3u *m3uList; 911 Om3u *m3uList;
911 QString s, name; 912 QString s, name;
912 m3uList = new Om3u( filename, IO_ReadOnly ); 913 m3uList = new Om3u( filename, IO_ReadOnly );
913 m3uList->readPls(); 914 m3uList->readPls();
914 915
915 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 916 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
916 s = *it; 917 s = *it;
917 // s.replace( QRegExp( "%20" )," " ); 918 // s.replace( QRegExp( "%20" )," " );
918 DocLnk lnk( s ); 919 DocLnk lnk( s );
919 QFileInfo f( s ); 920 QFileInfo f( s );
920 QString name = f.baseName(); 921 QString name = f.baseName();
921 922
922 if( name.left( 4 ) == "http" ) { 923 if( name.left( 4 ) == "http" ) {
923 name = s.right( s.length() - 7); 924 name = s.right( s.length() - 7);
924 } else { 925 } else {
925 name = s; 926 name = s;
926 } 927 }
927 928
928 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 929 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
929 930
930 lnk.setName( name ); 931 lnk.setName( name );
931 if( s.at( s.length() - 4) == '.') {// if this is probably a file 932 if( s.at( s.length() - 4) == '.') {// if this is probably a file
932 lnk.setFile( s ); 933 lnk.setFile( s );
933 } else { //if its a url 934 } else { //if its a url
934// if( name.right( 1 ).find( '/' ) == -1) { 935// if( name.right( 1 ).find( '/' ) == -1) {
935// s += "/"; 936// s += "/";
936// } 937// }
937 lnk.setFile( s ); 938 lnk.setFile( s );
938 } 939 }
939 lnk.setType( "audio/x-mpegurl" ); 940 lnk.setType( "audio/x-mpegurl" );
940 941
941 lnk.writeLink(); 942 lnk.writeLink();
942 d->selectedFiles->addToSelection( lnk ); 943 d->selectedFiles->addToSelection( lnk );
943 } 944 }
944 945
945 m3uList->close(); 946 m3uList->close();
946 if(m3uList) delete m3uList; 947 if(m3uList) delete m3uList;
947} 948}
948 949
949/* 950/*
950 writes current playlist to current m3u file */ 951 writes current playlist to current m3u file */
951void PlayListWidget::writeCurrentM3u() { 952void PlayListWidget::writeCurrentM3u() {
952 qDebug("writing to current m3u"); 953 qDebug("writing to current m3u");
953 Config cfg( "OpiePlayer" ); 954 Config cfg( "OpiePlayer" );
954 cfg.setGroup("PlayList"); 955 cfg.setGroup("PlayList");
955 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); 956 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
956 957
957 Om3u *m3uList; 958 Om3u *m3uList;
958 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); 959 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
959 if( d->selectedFiles->first()) { 960 if( d->selectedFiles->first()) {
960 961
961 do { 962 do {
962 // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); 963 // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file());
963 m3uList->add( d->selectedFiles->current()->file() ); 964 m3uList->add( d->selectedFiles->current()->file() );
964 } 965 }
965 while ( d->selectedFiles->next() ); 966 while ( d->selectedFiles->next() );
966 // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); 967 // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
967 m3uList->write(); 968 m3uList->write();
968 m3uList->close(); 969 m3uList->close();
969 970
970 if(m3uList) delete m3uList; 971 if(m3uList) delete m3uList;
971 } 972 }
972 973
973} 974}
974 975
975 /* 976 /*
976 writes current playlist to m3u file */ 977 writes current playlist to m3u file */
977void PlayListWidget::writem3u() { 978void PlayListWidget::writem3u() {
978 InputDialog *fileDlg; 979 InputDialog *fileDlg;
979 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 980 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
980 fileDlg->exec(); 981 fileDlg->exec();
981 QString name, filename, list; 982 QString name, filename, list;
982 Om3u *m3uList; 983 Om3u *m3uList;
983 984
984 if( fileDlg->result() == 1 ) { 985 if( fileDlg->result() == 1 ) {
985 name = fileDlg->text(); 986 name = fileDlg->text();
986// qDebug( filename ); 987// qDebug( filename );
987 988
988 if( name.left( 1) != "/" ) { 989 if( name.left( 1) != "/" ) {
989 filename = QPEApplication::documentDir() + "/" + name; 990 filename = QPEApplication::documentDir() + "/" + name;
990 } 991 }
991 992
992 if( name.right( 3 ) != "m3u" ) { 993 if( name.right( 3 ) != "m3u" ) {
993 filename = QPEApplication::documentDir() + "/" +name+".m3u"; 994 filename = QPEApplication::documentDir() + "/" +name+".m3u";
994 } 995 }
995 996
996 if( d->selectedFiles->first()) { 997 if( d->selectedFiles->first()) {
997 m3uList = new Om3u(filename, IO_ReadWrite); 998 m3uList = new Om3u(filename, IO_ReadWrite);
998 999
999 do { 1000 do {
1000 m3uList->add( d->selectedFiles->current()->file()); 1001 m3uList->add( d->selectedFiles->current()->file());
1001 } 1002 }
1002 while ( d->selectedFiles->next() ); 1003 while ( d->selectedFiles->next() );
1003 // qDebug( list ); 1004 // qDebug( list );
1004 m3uList->write(); 1005 m3uList->write();
1005 m3uList->close(); 1006 m3uList->close();
1006 if(m3uList) delete m3uList; 1007 if(m3uList) delete m3uList;
1007 1008
1008 if(fileDlg) delete fileDlg; 1009 if(fileDlg) delete fileDlg;
1009 1010
1010 DocLnk lnk; 1011 DocLnk lnk;
1011 lnk.setFile( filename); 1012 lnk.setFile( filename);
1012 lnk.setIcon("opieplayer2/playlist2"); 1013 lnk.setIcon("opieplayer2/playlist2");
1013 lnk.setName( name); //sets file name 1014 lnk.setName( name); //sets file name
1014 1015
1015 // qDebug(filename); 1016 // qDebug(filename);
1016 Config config( "OpiePlayer" ); 1017 Config config( "OpiePlayer" );
1017 config.setGroup( "PlayList" ); 1018 config.setGroup( "PlayList" );
1018 1019
1019 config.writeEntry("CurrentPlaylist",filename); 1020 config.writeEntry("CurrentPlaylist",filename);
1020 currentPlayList=filename; 1021 currentPlayList=filename;
1021 1022
1022 if(!lnk.writeLink()) { 1023 if(!lnk.writeLink()) {
1023 qDebug("Writing doclink did not work"); 1024 qDebug("Writing doclink did not work");
1024 } 1025 }
1025 1026
1026 setCaption(tr("OpiePlayer: ") + name); 1027 setCaption(tr("OpiePlayer: ") + name);
1027 } 1028 }
1028 } 1029 }
1029} 1030}
1030 1031
1031void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { 1032void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) {
1032 switch ( e->key() ) { 1033 switch ( e->key() ) {
1033 ////////////////////////////// Zaurus keys 1034 ////////////////////////////// Zaurus keys
1034 case Key_F9: //activity 1035 case Key_F9: //activity
1035 // if(audioUI->isHidden()) 1036 // if(audioUI->isHidden())
1036 // audioUI->showMaximized(); 1037 // audioUI->showMaximized();
1037 break; 1038 break;
1038 case Key_F10: //contacts 1039 case Key_F10: //contacts
1039 // if( videoUI->isHidden()) 1040 // if( videoUI->isHidden())
1040 // videoUI->showMaximized(); 1041 // videoUI->showMaximized();
1041 break; 1042 break;
1042 case Key_F11: //menu 1043 case Key_F11: //menu
1043 break; 1044 break;
1044 case Key_F12: //home 1045 case Key_F12: //home
1045 // doBlank(); 1046 // doBlank();
1046 break; 1047 break;
1047 case Key_F13: //mail 1048 case Key_F13: //mail
1048 // doUnblank(); 1049 // doUnblank();
1049 break; 1050 break;
1050 case Key_Q: //add to playlist 1051 case Key_Q: //add to playlist
1051 addSelected(); 1052 addSelected();
1052 break; 1053 break;
1053 case Key_R: //remove from playlist 1054 case Key_R: //remove from playlist
1054 removeSelected(); 1055 removeSelected();
1055 break; 1056 break;
1056 // case Key_P: //play 1057 // case Key_P: //play
1057 // qDebug("Play"); 1058 // qDebug("Play");
1058 // playSelected(); 1059 // playSelected();
1059 // break; 1060 // break;
1060 case Key_Space: 1061 case Key_Space:
1061 // playSelected(); puh 1062 // playSelected(); puh
1062 break; 1063 break;
1063 case Key_1: 1064 case Key_1:
1064 tabWidget->setCurrentPage( 0 ); 1065 tabWidget->setCurrentPage( 0 );
1065 break; 1066 break;
1066 case Key_2: 1067 case Key_2:
1067 tabWidget->setCurrentPage( 1 ); 1068 tabWidget->setCurrentPage( 1 );
1068 break; 1069 break;
1069 case Key_3: 1070 case Key_3:
1070 tabWidget->setCurrentPage( 2 ); 1071 tabWidget->setCurrentPage( 2 );
1071 break; 1072 break;
1072 case Key_4: 1073 case Key_4:
1073 tabWidget->setCurrentPage( 3 ); 1074 tabWidget->setCurrentPage( 3 );
1074 break; 1075 break;
1075 case Key_Down: 1076 case Key_Down:
1076 if ( !d->selectedFiles->next() ) 1077 if ( !d->selectedFiles->next() )
1077 d->selectedFiles->first(); 1078 d->selectedFiles->first();
1078 break; 1079 break;
1079 case Key_Up: 1080 case Key_Up:
1080 if ( !d->selectedFiles->prev() ) 1081 if ( !d->selectedFiles->prev() )
1081 // d->selectedFiles->last(); 1082 // d->selectedFiles->last();
1082 break; 1083 break;
1083 } 1084 }
1084} 1085}
1085 1086
1086void PlayListWidget::pmViewActivated(int index) { 1087void PlayListWidget::pmViewActivated(int index) {
1087// qDebug("%d", index); 1088// qDebug("%d", index);
1088 switch(index) { 1089 switch(index) {
1089 case -16: 1090 case -16:
1090 { 1091 {
1091 mediaPlayerState->toggleFullscreen(); 1092 mediaPlayerState->toggleFullscreen();
1092 bool b=mediaPlayerState->isFullscreen(); 1093 bool b=mediaPlayerState->isFullscreen();
1093 pmView->setItemChecked( index, b); 1094 pmView->setItemChecked( index, b);
1094 Config cfg( "OpiePlayer" ); 1095 Config cfg( "OpiePlayer" );
1095 cfg.writeEntry( "FullScreen", b ); 1096 cfg.writeEntry( "FullScreen", b );
1096 } 1097 }
1097 break; 1098 break;
1098 }; 1099 };
1099} 1100}
1100 1101
1101void PlayListWidget::populateSkinsMenu() { 1102void PlayListWidget::populateSkinsMenu() {
1102 int item = 0; 1103 int item = 0;
1103 defaultSkinIndex = 0; 1104 defaultSkinIndex = 0;
1104 QString skinName; 1105 QString skinName;
1105 Config cfg( "OpiePlayer" ); 1106 Config cfg( "OpiePlayer" );
1106 cfg.setGroup("Options" ); 1107 cfg.setGroup("Options" );
1107 QString skin = cfg.readEntry( "Skin", "default" ); 1108 QString skin = cfg.readEntry( "Skin", "default" );
1108 1109
1109 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); 1110 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" );
1110 skinsDir.setFilter( QDir::Dirs ); 1111 skinsDir.setFilter( QDir::Dirs );
1111 skinsDir.setSorting(QDir::Name ); 1112 skinsDir.setSorting(QDir::Name );
1112 const QFileInfoList *skinslist = skinsDir.entryInfoList(); 1113 const QFileInfoList *skinslist = skinsDir.entryInfoList();
1113 QFileInfoListIterator it( *skinslist ); 1114 QFileInfoListIterator it( *skinslist );
1114 QFileInfo *fi; 1115 QFileInfo *fi;
1115 while ( ( fi = it.current() ) ) { 1116 while ( ( fi = it.current() ) ) {
1116 skinName = fi->fileName(); 1117 skinName = fi->fileName();
1117// qDebug( fi->fileName() ); 1118// qDebug( fi->fileName() );
1118 if( skinName != "." && skinName != ".." && skinName !="CVS" ) { 1119 if( skinName != "." && skinName != ".." && skinName !="CVS" ) {
1119 item = skinsMenu->insertItem( fi->fileName() ) ; 1120 item = skinsMenu->insertItem( fi->fileName() ) ;
1120 } 1121 }
1121 if( skinName == "default" ) { 1122 if( skinName == "default" ) {
1122 defaultSkinIndex = item; 1123 defaultSkinIndex = item;
1123 } 1124 }
1124 if( skinName == skin ) { 1125 if( skinName == skin ) {
1125 skinsMenu->setItemChecked( item, TRUE ); 1126 skinsMenu->setItemChecked( item, TRUE );
1126 } 1127 }
1127 ++it; 1128 ++it;
1128 } 1129 }
1129} 1130}
1130 1131
1131void PlayListWidget::skinsMenuActivated( int item ) { 1132void PlayListWidget::skinsMenuActivated( int item ) {
1132 for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { 1133 for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) {
1133 skinsMenu->setItemChecked( i, FALSE ); 1134 skinsMenu->setItemChecked( i, FALSE );
1134 } 1135 }
1135 skinsMenu->setItemChecked( item, TRUE ); 1136 skinsMenu->setItemChecked( item, TRUE );
1136 1137
1137 Config cfg( "OpiePlayer" ); 1138 Config cfg( "OpiePlayer" );
1138 cfg.setGroup("Options"); 1139 cfg.setGroup("Options");
1139 cfg.writeEntry("Skin", skinsMenu->text( item ) ); 1140 cfg.writeEntry("Skin", skinsMenu->text( item ) );
1140 QMessageBox::warning( this, tr( "OpiePlayer" ), 1141 QMessageBox::warning( this, tr( "OpiePlayer" ),
1141 tr( "You must <b>restart</b> Opieplayer<br>to see your changes." ) ); 1142 tr( "You must <b>restart</b> Opieplayer<br>to see your changes." ) );
1142} 1143}
1143 1144
1144int PlayListWidget::whichList() { 1145int PlayListWidget::whichList() {
1145 return tabWidget->currentPageIndex(); 1146 return tabWidget->currentPageIndex();
1146} 1147}
1147 1148
1149PlayListWidget::TabType PlayListWidget::currentTab() const
1150{
1151 static const TabType indexToTabType[ NumTabTypes ] =
1152 { CurrentPlaylist, AudioFiles, VideoFiles, PlayLists };
1153
1154 int index = tabWidget->currentPageIndex();
1155 assert( index < NumTabTypes && index >= 0 );
1156
1157 return indexToTabType[ index ];
1158}
1159
1148QString PlayListWidget::currentFileListPathName() { 1160QString PlayListWidget::currentFileListPathName() {
1149 switch (whichList()) { 1161 switch (whichList()) {
1150 case 1: 1162 case 1:
1151 return audioView->currentItem()->text(3); 1163 return audioView->currentItem()->text(3);
1152 break; 1164 break;
1153 case 2: 1165 case 2:
1154 return videoView->currentItem()->text(3); 1166 return videoView->currentItem()->text(3);
1155 break; 1167 break;
1156 }; 1168 };
1157 return ""; 1169 return "";
1158} 1170}
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h
index b2c389e..05d53a4 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.h
+++ b/noncore/multimedia/opieplayer2/playlistwidget.h
@@ -1,121 +1,124 @@
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, NumTabTypes = 4 };
59
58 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); 60 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 );
59 ~PlayListWidget(); 61 ~PlayListWidget();
60 DocLnkSet files; 62 DocLnkSet files;
61 DocLnkSet vFiles; 63 DocLnkSet vFiles;
62 bool fromSetDocument; 64 bool fromSetDocument;
63 bool insanityBool; 65 bool insanityBool;
64 QString setDocFileRef, currentPlayList; 66 QString setDocFileRef, currentPlayList;
65 // retrieve the current playlist entry (media file link) 67 // retrieve the current playlist entry (media file link)
66 const DocLnk *current(); 68 const DocLnk *current();
67 void useSelectedDocument(); 69 void useSelectedDocument();
68 int selected; 70 int selected;
69 int whichList(); 71 int whichList();
72 TabType currentTab() const;
70 73
71public slots: 74public slots:
72 bool first(); 75 bool first();
73 bool last(); 76 bool last();
74 bool next(); 77 bool next();
75 bool prev(); 78 bool prev();
76 void writeDefaultPlaylist( ); 79 void writeDefaultPlaylist( );
77 QString currentFileListPathName(); 80 QString currentFileListPathName();
78protected: 81protected:
79 void keyReleaseEvent( QKeyEvent *e); 82 void keyReleaseEvent( QKeyEvent *e);
80 83
81private: 84private:
82 int defaultSkinIndex; 85 int defaultSkinIndex;
83 bool audioScan, videoScan, audioPopulated, videoPopulated; 86 bool audioScan, videoScan, audioPopulated, videoPopulated;
84 void readm3u(const QString &); 87 void readm3u(const QString &);
85 void readPls(const QString &); 88 void readPls(const QString &);
86 void initializeStates(); 89 void initializeStates();
87 void populateAudioView(); 90 void populateAudioView();
88 void populateVideoView(); 91 void populateVideoView();
89 92
90private slots: 93private slots:
91 void populateSkinsMenu(); 94 void populateSkinsMenu();
92 void skinsMenuActivated(int); 95 void skinsMenuActivated(int);
93 void pmViewActivated(int); 96 void pmViewActivated(int);
94 void writem3u(); 97 void writem3u();
95 void writeCurrentM3u(); 98 void writeCurrentM3u();
96 void scanForAudio(); 99 void scanForAudio();
97 void scanForVideo(); 100 void scanForVideo();
98 void openFile(); 101 void openFile();
99 void setDocument( const QString& fileref ); 102 void setDocument( const QString& fileref );
100 void addToSelection( const DocLnk& ); // Add a media file to the playlist 103 void addToSelection( const DocLnk& ); // Add a media file to the playlist
101 void addToSelection( QListViewItem* ); // Add a media file to the playlist 104 void addToSelection( QListViewItem* ); // Add a media file to the playlist
102 void setPlaylist( bool ); // Show/Hide the playlist 105 void setPlaylist( bool ); // Show/Hide the playlist
103 void clearList(); 106 void clearList();
104 void addAllToList(); 107 void addAllToList();
105 void addAllMusicToList(); 108 void addAllMusicToList();
106 void addAllVideoToList(); 109 void addAllVideoToList();
107 void saveList(); // Save the playlist 110 void saveList(); // Save the playlist
108 void loadList( const DocLnk &); // Load a playlist 111 void loadList( const DocLnk &); // Load a playlist
109 void playIt( QListViewItem *); 112 void playIt( QListViewItem *);
110 void btnPlay(bool); 113 void btnPlay(bool);
111 void deletePlaylist(); 114 void deletePlaylist();
112 void addSelected(); 115 void addSelected();
113 void removeSelected(); 116 void removeSelected();
114 void tabChanged(QWidget*); 117 void tabChanged(QWidget*);
115 void viewPressed( int, QListViewItem *, const QPoint&, int); 118 void viewPressed( int, QListViewItem *, const QPoint&, int);
116 void playlistViewPressed( int, QListViewItem *, const QPoint&, int); 119 void playlistViewPressed( int, QListViewItem *, const QPoint&, int);
117 void playSelected(); 120 void playSelected();
118}; 121};
119 122
120#endif // PLAY_LIST_WIDGET_H 123#endif // PLAY_LIST_WIDGET_H
121 124