summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index ab6b593..26c2896 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -1,1167 +1,1167 @@
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 <qdir.h> 41#include <qdir.h>
42#include <qmessagebox.h> 42#include <qmessagebox.h>
43#include <qregexp.h> 43#include <qregexp.h>
44#include <qtextstream.h> 44#include <qtextstream.h>
45 45
46#include "playlistselection.h" 46#include "playlistselection.h"
47#include "playlistwidget.h" 47#include "playlistwidget.h"
48#include "mediaplayerstate.h" 48#include "mediaplayerstate.h"
49#include "inputDialog.h" 49#include "inputDialog.h"
50#include "om3u.h" 50#include "om3u.h"
51 51
52//only needed for the random play 52//only needed for the random play
53#include <stdlib.h> 53#include <stdlib.h>
54 54
55#include "audiowidget.h" 55#include "audiowidget.h"
56#include "videowidget.h" 56#include "videowidget.h"
57 57
58extern MediaPlayerState *mediaPlayerState; 58extern MediaPlayerState *mediaPlayerState;
59 59
60 60
61PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 61PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
62 : PlayListWidgetGui( parent, name, fl ) { 62 : PlayListWidgetGui( parent, name, fl ) {
63 63
64 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), 64 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ),
65 "opieplayer2/add_to_playlist", 65 "opieplayer2/add_to_playlist",
66 this , SLOT(addSelected() ) ); 66 this , SLOT(addSelected() ) );
67 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), 67 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ),
68 "opieplayer2/remove_from_playlist", 68 "opieplayer2/remove_from_playlist",
69 this , SLOT(removeSelected() ) ); 69 this , SLOT(removeSelected() ) );
70 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", 70 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play",
71 this , SLOT( btnPlay( bool) ), TRUE ); 71 this , SLOT( btnPlay( bool) ), TRUE );
72 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", 72 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle",
73 mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); 73 mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE );
74 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", 74 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop",
75 mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); 75 mediaPlayerState, SLOT( setLooping( bool ) ), TRUE );
76 76
77 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 77 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
78 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), 78 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ),
79 this, SLOT( addAllMusicToList() ) ); 79 this, SLOT( addAllMusicToList() ) );
80 (void)new MenuItem( pmPlayList, tr( "Add all video files" ), 80 (void)new MenuItem( pmPlayList, tr( "Add all video files" ),
81 this, SLOT( addAllVideoToList() ) ); 81 this, SLOT( addAllVideoToList() ) );
82 (void)new MenuItem( pmPlayList, tr( "Add all files" ), 82 (void)new MenuItem( pmPlayList, tr( "Add all files" ),
83 this, SLOT( addAllToList() ) ); 83 this, SLOT( addAllToList() ) );
84 pmPlayList->insertSeparator(-1); 84 pmPlayList->insertSeparator(-1);
85// (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), 85// (void)new MenuItem( pmPlayList, tr( "Save PlayList" ),
86// this, SLOT( saveList() ) ); 86// this, SLOT( saveList() ) );
87 (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), 87 (void)new MenuItem( pmPlayList, tr( "Save Playlist" ),
88 this, SLOT(writem3u() ) ); 88 this, SLOT(writem3u() ) );
89 pmPlayList->insertSeparator(-1); 89 pmPlayList->insertSeparator(-1);
90 (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), 90 (void)new MenuItem( pmPlayList, tr( "Open File or URL" ),
91 this,SLOT( openFile() ) ); 91 this,SLOT( openFile() ) );
92 pmPlayList->insertSeparator(-1); 92 pmPlayList->insertSeparator(-1);
93 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), 93 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ),
94 this,SLOT( scanForAudio() ) ); 94 this,SLOT( scanForAudio() ) );
95 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), 95 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ),
96 this,SLOT( scanForVideo() ) ); 96 this,SLOT( scanForVideo() ) );
97 97
98 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), 98 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"),
99 mediaPlayerState, SLOT( toggleFullscreen() ) ); 99 mediaPlayerState, SLOT( toggleFullscreen() ) );
100 100
101 Config cfg( "OpiePlayer" ); 101 Config cfg( "OpiePlayer" );
102 bool b= cfg.readBoolEntry("FullScreen", 0); 102 bool b= cfg.readBoolEntry("FullScreen", 0);
103 mediaPlayerState->setFullscreen( b ); 103 mediaPlayerState->setFullscreen( b );
104 pmView->setItemChecked( -16, b ); 104 pmView->setItemChecked( -16, b );
105 105
106 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", 106 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up",
107 d->selectedFiles, SLOT(moveSelectedUp() ) ); 107 d->selectedFiles, SLOT(moveSelectedUp() ) );
108 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", 108 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut",
109 d->selectedFiles, SLOT(removeSelected() ) ); 109 d->selectedFiles, SLOT(removeSelected() ) );
110 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", 110 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down",
111 d->selectedFiles, SLOT(moveSelectedDown() ) ); 111 d->selectedFiles, SLOT(moveSelectedDown() ) );
112 QVBox *stretch2 = new QVBox( vbox1 ); 112 QVBox *stretch2 = new QVBox( vbox1 );
113 113
114 connect( tbDeletePlaylist, ( SIGNAL( released() ) ), 114 connect( tbDeletePlaylist, ( SIGNAL( released() ) ),
115 SLOT( deletePlaylist() ) ); 115 SLOT( deletePlaylist() ) );
116 connect( pmView, SIGNAL( activated( int ) ), 116 connect( pmView, SIGNAL( activated( int ) ),
117 this, SLOT( pmViewActivated( int ) ) ); 117 this, SLOT( pmViewActivated( int ) ) );
118 connect( skinsMenu, SIGNAL( activated( int ) ) , 118 connect( skinsMenu, SIGNAL( activated( int ) ) ,
119 this, SLOT( skinsMenuActivated( int ) ) ); 119 this, SLOT( skinsMenuActivated( int ) ) );
120 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), 120 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ),
121 this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); 121 this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) );
122 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), 122 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ),
123 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); 123 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) );
124 connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), 124 connect( audioView, SIGNAL( returnPressed( QListViewItem *) ),
125 this,SLOT( playIt( QListViewItem *) ) ); 125 this,SLOT( playIt( QListViewItem *) ) );
126 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), 126 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ),
127 this, SLOT( addToSelection( QListViewItem *) ) ); 127 this, SLOT( addToSelection( QListViewItem *) ) );
128 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), 128 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ),
129 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); 129 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) );
130 connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), 130 connect( videoView, SIGNAL( returnPressed( QListViewItem *) ),
131 this,SLOT( playIt( QListViewItem *) ) ); 131 this,SLOT( playIt( QListViewItem *) ) );
132 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), 132 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ),
133 this, SLOT( addToSelection( QListViewItem *) ) ); 133 this, SLOT( addToSelection( QListViewItem *) ) );
134 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), 134 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ),
135 this, SLOT( loadList( const DocLnk & ) ) ); 135 this, SLOT( loadList( const DocLnk & ) ) );
136 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), 136 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ),
137 this, SLOT( tabChanged( QWidget* ) ) ); 137 this, SLOT( tabChanged( QWidget* ) ) );
138 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), 138 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ),
139 d->tbPlay, SLOT( setOn( bool ) ) ); 139 d->tbPlay, SLOT( setOn( bool ) ) );
140 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), 140 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ),
141 d->tbLoop, SLOT( setOn( bool ) ) ); 141 d->tbLoop, SLOT( setOn( bool ) ) );
142 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), 142 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ),
143 d->tbShuffle, SLOT( setOn( bool ) ) ); 143 d->tbShuffle, SLOT( setOn( bool ) ) );
144 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), 144 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ),
145 this, SLOT( setPlaylist( bool ) ) ); 145 this, SLOT( setPlaylist( bool ) ) );
146 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), 146 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ),
147 this, SLOT( playIt( QListViewItem *) ) ); 147 this, SLOT( playIt( QListViewItem *) ) );
148 connect ( gammaSlider, SIGNAL( valueChanged( int ) ), 148 connect ( gammaSlider, SIGNAL( valueChanged( int ) ),
149 mediaPlayerState, SLOT( setVideoGamma( int ) ) ); 149 mediaPlayerState, SLOT( setVideoGamma( int ) ) );
150 150
151// cfg.setGroup( "PlayList" ); 151// cfg.setGroup( "PlayList" );
152// if( cfg.readBoolEntry("newPlaylist") ){ 152// if( cfg.readBoolEntry("newPlaylist") ){
153 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "" ); 153 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "" );
154 loadList(DocLnk( currentPlaylist ) ); 154 loadList(DocLnk( currentPlaylist ) );
155 setCaption( tr( "OpiePlayer: " ) + currentPlaylist ); 155 setCaption( tr( "OpiePlayer: " ) + currentPlaylist );
156// } else { 156// } else {
157// readConfig( cfg ); 157// readConfig( cfg );
158 158
159// } 159// }
160 // see which skins are installed 160 // see which skins are installed
161 videoScan=FALSE; 161 videoScan=FALSE;
162 audioScan=FALSE; 162 audioScan=FALSE;
163 populateSkinsMenu(); 163 populateSkinsMenu();
164 initializeStates(); 164 initializeStates();
165} 165}
166 166
167 167
168PlayListWidget::~PlayListWidget() { 168PlayListWidget::~PlayListWidget() {
169 // WTF?!@?! 169 // WTF?!@?!
170 170
171 if ( d->current ) { 171 if ( d->current ) {
172 delete d->current; 172 delete d->current;
173 } 173 }
174 delete d; 174 delete d;
175} 175}
176 176
177 177
178void PlayListWidget::initializeStates() { 178void PlayListWidget::initializeStates() {
179 d->tbPlay->setOn( mediaPlayerState->playing() ); 179 d->tbPlay->setOn( mediaPlayerState->playing() );
180 d->tbLoop->setOn( mediaPlayerState->looping() ); 180 d->tbLoop->setOn( mediaPlayerState->looping() );
181 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 181 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
182 setPlaylist( true ); 182 setPlaylist( true );
183} 183}
184 184
185 185
186void PlayListWidget::readConfig( Config& cfg ) { 186void PlayListWidget::readConfig( Config& cfg ) {
187 187
188 cfg.setGroup( "PlayList" ); 188 cfg.setGroup( "PlayList" );
189 QString currentString = cfg.readEntry( "current", "" ); 189 QString currentString = cfg.readEntry( "current", "" );
190 int noOfFiles = cfg.readNumEntry( "NumberOfFiles", 0 ); 190 int noOfFiles = cfg.readNumEntry( "NumberOfFiles", 0 );
191 191
192 for ( int i = 0; i < noOfFiles; i++ ) { 192 for ( int i = 0; i < noOfFiles; i++ ) {
193 QString entryName; 193 QString entryName;
194 entryName.sprintf( "File%i", i + 1 ); 194 entryName.sprintf( "File%i", i + 1 );
195 195
196 QString linkFile = cfg.readEntry( entryName ); 196 QString linkFile = cfg.readEntry( entryName );
197 197
198 qDebug("reading "+linkFile); 198 qDebug("reading "+linkFile);
199 199
200 if( QFileInfo( linkFile ).exists() ) { 200 if( QFileInfo( linkFile ).exists() ) {
201 201
202 DocLnk lnk( linkFile ); 202 DocLnk lnk( linkFile );
203 203
204 if ( QFileInfo( lnk.file() ).exists() || 204 if ( QFileInfo( lnk.file() ).exists() ||
205 205
206 linkFile.find( "http" , 0, TRUE) != -1) { 206 linkFile.find( "http" , 0, TRUE) != -1) {
207 207
208 d->selectedFiles->addToSelection( lnk ); 208 d->selectedFiles->addToSelection( lnk );
209 209
210 } 210 }
211 } 211 }
212 } 212 }
213 d->selectedFiles->setSelectedItem( currentString ); 213 d->selectedFiles->setSelectedItem( currentString );
214 214
215} 215}
216 216
217 217
218void PlayListWidget::writeConfig( Config& cfg ) const { 218void PlayListWidget::writeConfig( Config& cfg ) const {
219 219
220// Config config( "OpiePlayer" ); 220 Config config( "OpiePlayer" );
221// config.setGroup( "PlayList" ); 221 config.setGroup( "PlayList" );
222 222
223// if(config.readBoolEntry("newPlaylist")) { 223// if(config.readBoolEntry("newPlaylist")) {
224// new for testing 224// new for testing
225 QString name, filename, list; 225 QString name, filename, list;
226 Om3u *m3uList; 226 Om3u *m3uList;
227 name = "default"; 227 name = "default";
228 228
229 filename=QPEApplication::documentDir() + "/" + name+".m3u"; 229 filename=QPEApplication::documentDir() + "/" + name+".m3u";
230 230
231 m3uList = new Om3u(filename); 231 m3uList = new Om3u(filename);
232 232
233 d->selectedFiles->first(); 233 d->selectedFiles->first();
234 do { 234 do {
235 m3uList->add( d->selectedFiles->current()->file()); 235 m3uList->add( d->selectedFiles->current()->file());
236 } 236 }
237 while ( d->selectedFiles->next() ); 237 while ( d->selectedFiles->next() );
238 238
239 qDebug( list ); 239 qDebug( list );
240 240
241 m3uList->write(); 241 m3uList->write();
242 m3uList->close(); 242 m3uList->close();
243 if(m3uList) delete m3uList; 243 if(m3uList) delete m3uList;
244 244
245 DocLnk lnk; 245 DocLnk lnk;
246 lnk.setFile( filename); 246 lnk.setFile( filename);
247 lnk.setIcon("opieplayer2/playlist2"); 247 lnk.setIcon("opieplayer2/playlist2");
248 lnk.setName( name); //sets file name 248 lnk.setName( name); //sets file name
249 249
250 qDebug("writing default playlist "+filename); 250 qDebug("writing default playlist "+filename);
251 251
252 config.writeEntry("CurrentPlaylist", filename); 252 config.writeEntry("CurrentPlaylist", filename);
253// currentPlayList=filename; 253// currentPlayList=filename;
254 254
255 if(!lnk.writeLink()) { 255 if(!lnk.writeLink()) {
256 qDebug("Writing doclink did not work"); 256 qDebug("Writing doclink did not work");
257 } 257 }
258 258
259// } else { 259// } else {
260 260
261// d->selectedFiles->writeCurrent( cfg ); 261// d->selectedFiles->writeCurrent( cfg );
262// int noOfFiles = 0; 262// int noOfFiles = 0;
263// d->selectedFiles->first(); 263// d->selectedFiles->first();
264 264
265// do { 265// do {
266// const DocLnk *lnk = d->selectedFiles->current(); 266// const DocLnk *lnk = d->selectedFiles->current();
267 267
268// if ( lnk ) { 268// if ( lnk ) {
269 269
270// QString entryName; 270// QString entryName;
271// entryName.sprintf( "File%i", noOfFiles + 1 ); 271// entryName.sprintf( "File%i", noOfFiles + 1 );
272 272
273// cfg.writeEntry( entryName, lnk->linkFile() ); 273// cfg.writeEntry( entryName, lnk->linkFile() );
274// // if this link does exist, add it so we have the file 274// // if this link does exist, add it so we have the file
275// // next time... 275// // next time...
276 276
277// if ( !QFile::exists( lnk->linkFile() ) ) { 277// if ( !QFile::exists( lnk->linkFile() ) ) {
278// lnk->writeLink(); 278// lnk->writeLink();
279// } 279// }
280// } 280// }
281// noOfFiles++; 281// noOfFiles++;
282// } 282// }
283// while ( d->selectedFiles->next() ); 283// while ( d->selectedFiles->next() );
284// cfg.writeEntry("NumberOfFiles", noOfFiles ); 284// cfg.writeEntry("NumberOfFiles", noOfFiles );
285// } 285// }
286} 286}
287 287
288 288
289void PlayListWidget::addToSelection( const DocLnk& lnk ) { 289void PlayListWidget::addToSelection( const DocLnk& lnk ) {
290 d->setDocumentUsed = FALSE; 290 d->setDocumentUsed = FALSE;
291 if ( mediaPlayerState->playlist() ) { 291 if ( mediaPlayerState->playlist() ) {
292 if( QFileInfo( lnk.file() ).exists() || 292 if( QFileInfo( lnk.file() ).exists() ||
293 lnk.file().left(4) == "http" ) 293 lnk.file().left(4) == "http" )
294 d->selectedFiles->addToSelection( lnk ); 294 d->selectedFiles->addToSelection( lnk );
295 } 295 }
296 else 296 else
297 mediaPlayerState->setPlaying( TRUE ); 297 mediaPlayerState->setPlaying( TRUE );
298} 298}
299 299
300 300
301void PlayListWidget::clearList() { 301void PlayListWidget::clearList() {
302 while ( first() ) { 302 while ( first() ) {
303 d->selectedFiles->removeSelected(); 303 d->selectedFiles->removeSelected();
304 } 304 }
305} 305}
306 306
307 307
308void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { 308void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
309 switch (mouse) { 309 switch (mouse) {
310 case 1: 310 case 1:
311 break; 311 break;
312 case 2: 312 case 2:
313 { 313 {
314 QPopupMenu m; 314 QPopupMenu m;
315 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 315 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
316 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 316 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
317 m.exec( QCursor::pos() ); 317 m.exec( QCursor::pos() );
318 } 318 }
319 break; 319 break;
320 } 320 }
321} 321}
322 322
323 323
324void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { 324void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) {
325 switch (mouse) { 325 switch (mouse) {
326 case 1: 326 case 1:
327 break; 327 break;
328 case 2: 328 case 2:
329 { 329 {
330 QPopupMenu m; 330 QPopupMenu m;
331 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 331 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
332 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 332 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
333 m.exec( QCursor::pos() ); 333 m.exec( QCursor::pos() );
334 } 334 }
335 break; 335 break;
336 } 336 }
337} 337}
338 338
339 339
340void PlayListWidget::addAllToList() { 340void PlayListWidget::addAllToList() {
341 DocLnkSet filesAll; 341 DocLnkSet filesAll;
342 Global::findDocuments(&filesAll, "video/*;audio/*"); 342 Global::findDocuments(&filesAll, "video/*;audio/*");
343 QListIterator<DocLnk> Adit( filesAll.children() ); 343 QListIterator<DocLnk> Adit( filesAll.children() );
344 for ( ; Adit.current(); ++Adit ) { 344 for ( ; Adit.current(); ++Adit ) {
345 if( QFileInfo( Adit.current()->file() ).exists() ) { 345 if( QFileInfo( Adit.current()->file() ).exists() ) {
346 d->selectedFiles->addToSelection( **Adit ); 346 d->selectedFiles->addToSelection( **Adit );
347 } 347 }
348 } 348 }
349} 349}
350 350
351 351
352void PlayListWidget::addAllMusicToList() { 352void PlayListWidget::addAllMusicToList() {
353 QListIterator<DocLnk> dit( files.children() ); 353 QListIterator<DocLnk> dit( files.children() );
354 for ( ; dit.current(); ++dit ) { 354 for ( ; dit.current(); ++dit ) {
355 if( QFileInfo(dit.current()->file() ).exists() ) { 355 if( QFileInfo(dit.current()->file() ).exists() ) {
356 d->selectedFiles->addToSelection( **dit ); 356 d->selectedFiles->addToSelection( **dit );
357 } 357 }
358 } 358 }
359} 359}
360 360
361 361
362void PlayListWidget::addAllVideoToList() { 362void PlayListWidget::addAllVideoToList() {
363 QListIterator<DocLnk> dit( vFiles.children() ); 363 QListIterator<DocLnk> dit( vFiles.children() );
364 for ( ; dit.current(); ++dit ) { 364 for ( ; dit.current(); ++dit ) {
365 if( QFileInfo( dit.current()->file() ).exists() ) { 365 if( QFileInfo( dit.current()->file() ).exists() ) {
366 d->selectedFiles->addToSelection( **dit ); 366 d->selectedFiles->addToSelection( **dit );
367 } 367 }
368 } 368 }
369} 369}
370 370
371 371
372void PlayListWidget::setDocument( const QString& fileref ) { 372void PlayListWidget::setDocument( const QString& fileref ) {
373 //qDebug( fileref ); 373 //qDebug( fileref );
374 fromSetDocument = TRUE; 374 fromSetDocument = TRUE;
375 if ( fileref.isNull() ) { 375 if ( fileref.isNull() ) {
376 QMessageBox::critical( 0, tr( "Invalid File" ), 376 QMessageBox::critical( 0, tr( "Invalid File" ),
377 tr( "There was a problem in getting the file." ) ); 377 tr( "There was a problem in getting the file." ) );
378 return; 378 return;
379 } 379 }
380 380
381 if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u 381 if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u
382 readm3u( fileref ); 382 readm3u( fileref );
383 } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls 383 } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls
384 readPls( fileref ); 384 readPls( fileref );
385 } else if( fileref.find( "playlist", 0, TRUE) != -1 ) {//is playlist 385 } else if( fileref.find( "playlist", 0, TRUE) != -1 ) {//is playlist
386 clearList(); 386 clearList();
387 loadList( DocLnk( fileref ) ); 387 loadList( DocLnk( fileref ) );
388 d->selectedFiles->first(); 388 d->selectedFiles->first();
389 } else { 389 } else {
390 clearList(); 390 clearList();
391 addToSelection( DocLnk( fileref ) ); 391 addToSelection( DocLnk( fileref ) );
392 d->setDocumentUsed = TRUE; 392 d->setDocumentUsed = TRUE;
393 mediaPlayerState->setPlaying( FALSE ); 393 mediaPlayerState->setPlaying( FALSE );
394// qApp->processEvents(); 394// qApp->processEvents();
395 mediaPlayerState->setPlaying( TRUE ); 395 mediaPlayerState->setPlaying( TRUE );
396// qApp->processEvents(); 396// qApp->processEvents();
397 setCaption( tr("OpiePlayer") ); 397 setCaption( tr("OpiePlayer") );
398 } 398 }
399} 399}
400 400
401 401
402void PlayListWidget::useSelectedDocument() { 402void PlayListWidget::useSelectedDocument() {
403 d->setDocumentUsed = FALSE; 403 d->setDocumentUsed = FALSE;
404} 404}
405 405
406 406
407const DocLnk *PlayListWidget::current() { // this is fugly 407const DocLnk *PlayListWidget::current() { // this is fugly
408 switch ( whichList() ) { 408 switch ( whichList() ) {
409 case 0: //playlist 409 case 0: //playlist
410 { 410 {
411// qDebug("playlist"); 411// qDebug("playlist");
412 if ( mediaPlayerState->playlist() ) { 412 if ( mediaPlayerState->playlist() ) {
413 return d->selectedFiles->current(); 413 return d->selectedFiles->current();
414 } else if ( d->setDocumentUsed && d->current ) { 414 } else if ( d->setDocumentUsed && d->current ) {
415 return d->current; 415 return d->current;
416 } else { 416 } else {
417 return &(d->files->selectedDocument()); 417 return &(d->files->selectedDocument());
418 } 418 }
419 } 419 }
420 break; 420 break;
421 }; 421 };
422 return 0; 422 return 0;
423} 423}
424 424
425 425
426bool PlayListWidget::prev() { 426bool PlayListWidget::prev() {
427 if ( mediaPlayerState->playlist() ) { 427 if ( mediaPlayerState->playlist() ) {
428 if ( mediaPlayerState->shuffled() ) { 428 if ( mediaPlayerState->shuffled() ) {
429 const DocLnk *cur = current(); 429 const DocLnk *cur = current();
430 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 430 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
431 for ( int i = 0; i < j; i++ ) { 431 for ( int i = 0; i < j; i++ ) {
432 if ( !d->selectedFiles->next() ) 432 if ( !d->selectedFiles->next() )
433 d->selectedFiles->first(); 433 d->selectedFiles->first();
434 } 434 }
435 if ( cur == current() ) 435 if ( cur == current() )
436 if ( !d->selectedFiles->next() ) { 436 if ( !d->selectedFiles->next() ) {
437 d->selectedFiles->first(); 437 d->selectedFiles->first();
438 } 438 }
439 return TRUE; 439 return TRUE;
440 } else { 440 } else {
441 if ( !d->selectedFiles->prev() ) { 441 if ( !d->selectedFiles->prev() ) {
442 if ( mediaPlayerState->looping() ) { 442 if ( mediaPlayerState->looping() ) {
443 return d->selectedFiles->last(); 443 return d->selectedFiles->last();
444 } else { 444 } else {
445 return FALSE; 445 return FALSE;
446 } 446 }
447 } 447 }
448 return TRUE; 448 return TRUE;
449 } 449 }
450 } else { 450 } else {
451 return mediaPlayerState->looping(); 451 return mediaPlayerState->looping();
452 } 452 }
453} 453}
454 454
455 455
456bool PlayListWidget::next() { 456bool PlayListWidget::next() {
457//qDebug("<<<<<<<<<<<<next()"); 457//qDebug("<<<<<<<<<<<<next()");
458 if ( mediaPlayerState->playlist() ) { 458 if ( mediaPlayerState->playlist() ) {
459 if ( mediaPlayerState->shuffled() ) { 459 if ( mediaPlayerState->shuffled() ) {
460 return prev(); 460 return prev();
461 } else { 461 } else {
462 if ( !d->selectedFiles->next() ) { 462 if ( !d->selectedFiles->next() ) {
463 if ( mediaPlayerState->looping() ) { 463 if ( mediaPlayerState->looping() ) {
464 return d->selectedFiles->first(); 464 return d->selectedFiles->first();
465 } else { 465 } else {
466 return FALSE; 466 return FALSE;
467 } 467 }
468 } 468 }
469 return TRUE; 469 return TRUE;
470 } 470 }
471 } else { 471 } else {
472 return mediaPlayerState->looping(); 472 return mediaPlayerState->looping();
473 } 473 }
474} 474}
475 475
476 476
477bool PlayListWidget::first() { 477bool PlayListWidget::first() {
478 if ( mediaPlayerState->playlist() ) 478 if ( mediaPlayerState->playlist() )
479 return d->selectedFiles->first(); 479 return d->selectedFiles->first();
480 else 480 else
481 return mediaPlayerState->looping(); 481 return mediaPlayerState->looping();
482} 482}
483 483
484 484
485bool PlayListWidget::last() { 485bool PlayListWidget::last() {
486 if ( mediaPlayerState->playlist() ) 486 if ( mediaPlayerState->playlist() )
487 return d->selectedFiles->last(); 487 return d->selectedFiles->last();
488 else 488 else
489 return mediaPlayerState->looping(); 489 return mediaPlayerState->looping();
490} 490}
491 491
492 492
493 void PlayListWidget::saveList() { 493 void PlayListWidget::saveList() {
494// Config config( "OpiePlayer" ); 494// Config config( "OpiePlayer" );
495// config.setGroup( "PlayList" ); 495// config.setGroup( "PlayList" );
496 496
497// if(config.readBoolEntry("newPlaylist") ){ 497// if(config.readBoolEntry("newPlaylist") ){
498 writem3u(); 498 writem3u();
499 499
500// } else { 500// } else {
501 501
502// QString filename; 502// QString filename;
503// InputDialog *fileDlg = 0l; 503// InputDialog *fileDlg = 0l;
504// fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); 504// fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0);
505// fileDlg->exec(); 505// fileDlg->exec();
506// if( fileDlg->result() == 1 ) { 506// if( fileDlg->result() == 1 ) {
507// if ( d->current ) 507// if ( d->current )
508// delete d->current; 508// delete d->current;
509// filename = fileDlg->text();//+".playlist"; 509// filename = fileDlg->text();//+".playlist";
510// // qDebug("saving playlist "+filename+".playlist"); 510// // qDebug("saving playlist "+filename+".playlist");
511 511
512// Config cfg( filename +".playlist"); 512// Config cfg( filename +".playlist");
513// writeConfig( cfg ); 513// writeConfig( cfg );
514 514
515// DocLnk lnk; 515// DocLnk lnk;
516// lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); 516// lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf");
517// //sets File property 517// //sets File property
518// lnk.setType("playlist/plain"); 518// lnk.setType("playlist/plain");
519// lnk.setIcon("opieplayer2/playlist2"); 519// lnk.setIcon("opieplayer2/playlist2");
520// lnk.setName( filename); //sets file name 520// lnk.setName( filename); //sets file name
521// // qDebug(filename); 521// // qDebug(filename);
522// if(!lnk.writeLink()) { 522// if(!lnk.writeLink()) {
523// qDebug("Writing doclink did not work"); 523// qDebug("Writing doclink did not work");
524// } 524// }
525// } 525// }
526 526
527// config.writeEntry("CurrentPlaylist",filename); 527// config.writeEntry("CurrentPlaylist",filename);
528// setCaption(tr("OpiePlayer: ")+filename); 528// setCaption(tr("OpiePlayer: ")+filename);
529// d->selectedFiles->first(); 529// d->selectedFiles->first();
530// if(fileDlg) { 530// if(fileDlg) {
531// delete fileDlg; 531// delete fileDlg;
532// } 532// }
533// } 533// }
534 } 534 }
535 535
536 536
537void PlayListWidget::loadList( const DocLnk & lnk) { 537void PlayListWidget::loadList( const DocLnk & lnk) {
538 QString name = lnk.name(); 538 QString name = lnk.name();
539 qDebug("currentList is "+name); 539 qDebug("currentList is "+name);
540 540
541 if( name.length()>0) { 541 if( name.length()>0) {
542 setCaption("OpiePlayer: "+name); 542 setCaption("OpiePlayer: "+name);
543 qDebug("<<<<<<<<<<<<load list "+ lnk.file()); 543 qDebug("<<<<<<<<<<<<load list "+ lnk.file());
544 clearList(); 544 clearList();
545 545
546// if(name.right(3) == "m3u") { 546// if(name.right(3) == "m3u") {
547 547
548 readm3u(lnk.file()); 548 readm3u(lnk.file());
549// } else { 549// } else {
550// / Config cfg( name+".playlist"); 550// / Config cfg( name+".playlist");
551// readConfig(cfg); 551// readConfig(cfg);
552 552
553 tabWidget->setCurrentPage(0); 553 tabWidget->setCurrentPage(0);
554 554
555 Config config( "OpiePlayer" ); 555 Config config( "OpiePlayer" );
556 config.setGroup( "PlayList" ); 556 config.setGroup( "PlayList" );
557 config.writeEntry("CurrentPlaylist", lnk.file()); 557 config.writeEntry("CurrentPlaylist", lnk.file());
558// // d->selectedFiles->first(); 558// // d->selectedFiles->first();
559// } 559// }
560 } 560 }
561} 561}
562 562
563 563
564void PlayListWidget::setPlaylist( bool shown ) { 564void PlayListWidget::setPlaylist( bool shown ) {
565 if ( shown ) { 565 if ( shown ) {
566 d->playListFrame->show(); 566 d->playListFrame->show();
567 } else { 567 } else {
568 d->playListFrame->hide(); 568 d->playListFrame->hide();
569 } 569 }
570} 570}
571 571
572 572
573void PlayListWidget::addSelected() { 573void PlayListWidget::addSelected() {
574 574
575 Config cfg( "OpiePlayer" ); 575 Config cfg( "OpiePlayer" );
576 cfg.setGroup("PlayList"); 576 cfg.setGroup("PlayList");
577 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 577 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
578 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 578 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
579 579
580 switch (whichList()) { 580 switch (whichList()) {
581 case 0: //playlist 581 case 0: //playlist
582 break; 582 break;
583 case 1: { //audio 583 case 1: { //audio
584 QListViewItemIterator it( audioView ); 584 QListViewItemIterator it( audioView );
585 // iterate through all items of the listview 585 // iterate through all items of the listview
586 for ( ; it.current(); ++it ) { 586 for ( ; it.current(); ++it ) {
587 if ( it.current()->isSelected() ) { 587 if ( it.current()->isSelected() ) {
588 QListIterator<DocLnk> dit( files.children() ); 588 QListIterator<DocLnk> dit( files.children() );
589 for ( ; dit.current(); ++dit ) { 589 for ( ; dit.current(); ++dit ) {
590 if( dit.current()->name() == it.current()->text(0) ) { 590 if( dit.current()->name() == it.current()->text(0) ) {
591 if(QFileInfo( dit.current()->file()).exists()) 591 if(QFileInfo( dit.current()->file()).exists())
592 d->selectedFiles->addToSelection( **dit ); 592 d->selectedFiles->addToSelection( **dit );
593 } 593 }
594 } 594 }
595 audioView->setSelected( it.current(),FALSE); 595 audioView->setSelected( it.current(),FALSE);
596 } 596 }
597 } 597 }
598 tabWidget->setCurrentPage(0); 598 tabWidget->setCurrentPage(0);
599 } 599 }
600 break; 600 break;
601 case 2: { // video 601 case 2: { // video
602 QListViewItemIterator it( videoView ); 602 QListViewItemIterator it( videoView );
603 // iterate through all items of the listview 603 // iterate through all items of the listview
604 for ( ; it.current(); ++it ) { 604 for ( ; it.current(); ++it ) {
605 if ( it.current()->isSelected() ) { 605 if ( it.current()->isSelected() ) {
606 QListIterator<DocLnk> dit( vFiles.children() ); 606 QListIterator<DocLnk> dit( vFiles.children() );
607 for ( ; dit.current(); ++dit ) { 607 for ( ; dit.current(); ++dit ) {
608 if( dit.current()->name() == it.current()->text(0) ) { 608 if( dit.current()->name() == it.current()->text(0) ) {
609 if(QFileInfo( dit.current()->file()).exists()) 609 if(QFileInfo( dit.current()->file()).exists())
610 d->selectedFiles->addToSelection( **dit ); 610 d->selectedFiles->addToSelection( **dit );
611 } 611 }
612 } 612 }
613 videoView->setSelected( it.current(),FALSE); 613 videoView->setSelected( it.current(),FALSE);
614 } 614 }
615 } 615 }
616 tabWidget->setCurrentPage(0); 616 tabWidget->setCurrentPage(0);
617 } 617 }
618 break; 618 break;
619 }; 619 };
620} 620}
621 621
622 622
623void PlayListWidget::removeSelected() { 623void PlayListWidget::removeSelected() {
624 d->selectedFiles->removeSelected( ); 624 d->selectedFiles->removeSelected( );
625} 625}
626 626
627 627
628void PlayListWidget::playIt( QListViewItem *it) { 628void PlayListWidget::playIt( QListViewItem *it) {
629 if(!it) return; 629 if(!it) return;
630 mediaPlayerState->setPlaying(FALSE); 630 mediaPlayerState->setPlaying(FALSE);
631 mediaPlayerState->setPlaying(TRUE); 631 mediaPlayerState->setPlaying(TRUE);
632 d->selectedFiles->unSelect(); 632 d->selectedFiles->unSelect();
633} 633}
634 634
635 635
636void PlayListWidget::addToSelection( QListViewItem *it) { 636void PlayListWidget::addToSelection( QListViewItem *it) {
637 d->setDocumentUsed = FALSE; 637 d->setDocumentUsed = FALSE;
638 638
639 if(it) { 639 if(it) {
640 switch ( whichList()) { 640 switch ( whichList()) {
641 case 1: { 641 case 1: {
642 QListIterator<DocLnk> dit( files.children() ); 642 QListIterator<DocLnk> dit( files.children() );
643 for ( ; dit.current(); ++dit ) { 643 for ( ; dit.current(); ++dit ) {
644 if( dit.current()->name() == it->text(0)) { 644 if( dit.current()->name() == it->text(0)) {
645 if(QFileInfo( dit.current()->file()).exists()) 645 if(QFileInfo( dit.current()->file()).exists())
646 d->selectedFiles->addToSelection( **dit ); 646 d->selectedFiles->addToSelection( **dit );
647 } 647 }
648 } 648 }
649 } 649 }
650 break; 650 break;
651 case 2: { 651 case 2: {
652 QListIterator<DocLnk> dit( vFiles.children() ); 652 QListIterator<DocLnk> dit( vFiles.children() );
653 for ( ; dit.current(); ++dit ) { 653 for ( ; dit.current(); ++dit ) {
654 if( dit.current()->name() == it->text(0)) { 654 if( dit.current()->name() == it->text(0)) {
655 if( QFileInfo( dit.current()->file()).exists() ) 655 if( QFileInfo( dit.current()->file()).exists() )
656 d->selectedFiles->addToSelection( **dit ); 656 d->selectedFiles->addToSelection( **dit );
657 } 657 }
658 } 658 }
659 } 659 }
660 break; 660 break;
661 case 0: 661 case 0:
662 break; 662 break;
663 }; 663 };
664 tabWidget->setCurrentPage(0); 664 tabWidget->setCurrentPage(0);
665 } 665 }
666} 666}
667 667
668 668
669void PlayListWidget::tabChanged(QWidget *) { 669void PlayListWidget::tabChanged(QWidget *) {
670 670
671 switch ( whichList()) { 671 switch ( whichList()) {
672 case 0: 672 case 0:
673 { 673 {
674 if( !tbDeletePlaylist->isHidden() ) { 674 if( !tbDeletePlaylist->isHidden() ) {
675 tbDeletePlaylist->hide(); 675 tbDeletePlaylist->hide();
676 } 676 }
677 d->tbRemoveFromList->setEnabled(TRUE); 677 d->tbRemoveFromList->setEnabled(TRUE);
678 d->tbAddToList->setEnabled(FALSE); 678 d->tbAddToList->setEnabled(FALSE);
679 } 679 }
680 break; 680 break;
681 case 1: 681 case 1:
682 { 682 {
683 audioView->clear(); 683 audioView->clear();
684 populateAudioView(); 684 populateAudioView();
685 685
686 if( !tbDeletePlaylist->isHidden() ) { 686 if( !tbDeletePlaylist->isHidden() ) {
687 tbDeletePlaylist->hide(); 687 tbDeletePlaylist->hide();
688 } 688 }
689 d->tbRemoveFromList->setEnabled(FALSE); 689 d->tbRemoveFromList->setEnabled(FALSE);
690 d->tbAddToList->setEnabled(TRUE); 690 d->tbAddToList->setEnabled(TRUE);
691 } 691 }
692 break; 692 break;
693 case 2: 693 case 2:
694 { 694 {
695 videoView->clear(); 695 videoView->clear();
696 populateVideoView(); 696 populateVideoView();
697 if( !tbDeletePlaylist->isHidden() ) { 697 if( !tbDeletePlaylist->isHidden() ) {
698 tbDeletePlaylist->hide(); 698 tbDeletePlaylist->hide();
699 } 699 }
700 d->tbRemoveFromList->setEnabled(FALSE); 700 d->tbRemoveFromList->setEnabled(FALSE);
701 d->tbAddToList->setEnabled(TRUE); 701 d->tbAddToList->setEnabled(TRUE);
702 } 702 }
703 break; 703 break;
704 case 3: 704 case 3:
705 { 705 {
706 if( tbDeletePlaylist->isHidden() ) { 706 if( tbDeletePlaylist->isHidden() ) {
707 tbDeletePlaylist->show(); 707 tbDeletePlaylist->show();
708 } 708 }
709 playLists->reread(); 709 playLists->reread();
710 } 710 }
711 break; 711 break;
712 }; 712 };
713} 713}
714 714
715 715
716void PlayListWidget::btnPlay(bool b) { 716void PlayListWidget::btnPlay(bool b) {
717// mediaPlayerState->setPlaying(false); 717// mediaPlayerState->setPlaying(false);
718 mediaPlayerState->setPlaying(b); 718 mediaPlayerState->setPlaying(b);
719 insanityBool=FALSE; 719 insanityBool=FALSE;
720} 720}
721 721
722void PlayListWidget::deletePlaylist() { 722void PlayListWidget::deletePlaylist() {
723 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 723 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
724 (tr("You really want to delete\nthis playlist?")), 724 (tr("You really want to delete\nthis playlist?")),
725 (tr("Yes")), (tr("No")), 0 )){ 725 (tr("Yes")), (tr("No")), 0 )){
726 case 0: // Yes clicked, 726 case 0: // Yes clicked,
727 QFile().remove(playLists->selectedDocument().file()); 727 QFile().remove(playLists->selectedDocument().file());
728 QFile().remove(playLists->selectedDocument().linkFile()); 728 QFile().remove(playLists->selectedDocument().linkFile());
729 playLists->reread(); 729 playLists->reread();
730 break; 730 break;
731 case 1: // Cancel 731 case 1: // Cancel
732 break; 732 break;
733 }; 733 };
734} 734}
735 735
736 736
737void PlayListWidget::playSelected() { 737void PlayListWidget::playSelected() {
738 btnPlay( TRUE); 738 btnPlay( TRUE);
739} 739}
740 740
741 741
742void PlayListWidget::scanForAudio() { 742void PlayListWidget::scanForAudio() {
743// qDebug("scan for audio"); 743// qDebug("scan for audio");
744 files.detachChildren(); 744 files.detachChildren();
745 QListIterator<DocLnk> sdit( files.children() ); 745 QListIterator<DocLnk> sdit( files.children() );
746 for ( ; sdit.current(); ++sdit ) { 746 for ( ; sdit.current(); ++sdit ) {
747 delete sdit.current(); 747 delete sdit.current();
748 } 748 }
749// Global::findDocuments( &files, "audio/*"); 749// Global::findDocuments( &files, "audio/*");
750 Global::findDocuments( &files, "audio/mpeg;audio/x-wav;audio/x-ogg"); 750 Global::findDocuments( &files, "audio/mpeg;audio/x-wav;audio/x-ogg");
751 audioScan = TRUE; 751 audioScan = TRUE;
752} 752}
753 753
754void PlayListWidget::scanForVideo() { 754void PlayListWidget::scanForVideo() {
755// qDebug("scan for video"); 755// qDebug("scan for video");
756 vFiles.detachChildren(); 756 vFiles.detachChildren();
757 QListIterator<DocLnk> sdit( vFiles.children() ); 757 QListIterator<DocLnk> sdit( vFiles.children() );
758 for ( ; sdit.current(); ++sdit ) { 758 for ( ; sdit.current(); ++sdit ) {
759 delete sdit.current(); 759 delete sdit.current();
760 } 760 }
761 Global::findDocuments(&vFiles, "video/*"); 761 Global::findDocuments(&vFiles, "video/*");
762 videoScan = TRUE; 762 videoScan = TRUE;
763} 763}
764 764
765void PlayListWidget::populateAudioView() { 765void PlayListWidget::populateAudioView() {
766 audioView->clear(); 766 audioView->clear();
767 StorageInfo storageInfo; 767 StorageInfo storageInfo;
768 const QList<FileSystem> &fs = storageInfo.fileSystems(); 768 const QList<FileSystem> &fs = storageInfo.fileSystems();
769 if(!audioScan) { 769 if(!audioScan) {
770 scanForAudio(); 770 scanForAudio();
771 } 771 }
772 772
773 QListIterator<DocLnk> dit( files.children() ); 773 QListIterator<DocLnk> dit( files.children() );
774 QListIterator<FileSystem> it ( fs ); 774 QListIterator<FileSystem> it ( fs );
775 775
776 QString storage; 776 QString storage;
777 for ( ; dit.current(); ++dit ) { 777 for ( ; dit.current(); ++dit ) {
778 for( ; it.current(); ++it ){ 778 for( ; it.current(); ++it ){
779 const QString name = (*it)->name(); 779 const QString name = (*it)->name();
780 const QString path = (*it)->path(); 780 const QString path = (*it)->path();
781 if(dit.current()->file().find(path) != -1 ) { 781 if(dit.current()->file().find(path) != -1 ) {
782 storage = name; 782 storage = name;
783 } 783 }
784 } 784 }
785 785
786 QListViewItem * newItem; 786 QListViewItem * newItem;
787 if ( QFile( dit.current()->file()).exists() || 787 if ( QFile( dit.current()->file()).exists() ||
788 dit.current()->file().left(4) == "http" ) { 788 dit.current()->file().left(4) == "http" ) {
789 long size; 789 long size;
790 if( dit.current()->file().left(4) == "http" ) 790 if( dit.current()->file().left(4) == "http" )
791 size=0; 791 size=0;
792 else 792 else
793 size = QFile( dit.current()->file() ).size(); 793 size = QFile( dit.current()->file() ).size();
794 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), 794 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
795 QString::number(size ), storage, dit.current()->file()); 795 QString::number(size ), storage, dit.current()->file());
796 newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); 796 newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) );
797 } 797 }
798 } 798 }
799} 799}
800 800
801 801
802void PlayListWidget::populateVideoView() { 802void PlayListWidget::populateVideoView() {
803 videoView->clear(); 803 videoView->clear();
804 StorageInfo storageInfo; 804 StorageInfo storageInfo;
805 const QList<FileSystem> &fs = storageInfo.fileSystems(); 805 const QList<FileSystem> &fs = storageInfo.fileSystems();
806 806
807 if(!videoScan ) { 807 if(!videoScan ) {
808 scanForVideo(); 808 scanForVideo();
809 } 809 }
810 810
811 QListIterator<DocLnk> Vdit( vFiles.children() ); 811 QListIterator<DocLnk> Vdit( vFiles.children() );
812 QListIterator<FileSystem> it ( fs ); 812 QListIterator<FileSystem> it ( fs );
813 videoView->clear(); 813 videoView->clear();
814 QString storage, pathName; 814 QString storage, pathName;
815 for ( ; Vdit.current(); ++Vdit ) { 815 for ( ; Vdit.current(); ++Vdit ) {
816 for( ; it.current(); ++it ) { 816 for( ; it.current(); ++it ) {
817 const QString name = (*it)->name(); 817 const QString name = (*it)->name();
818 const QString path = (*it)->path(); 818 const QString path = (*it)->path();
819 if( Vdit.current()->file().find(path) != -1 ) { 819 if( Vdit.current()->file().find(path) != -1 ) {
820 storage=name; 820 storage=name;
821 pathName=path; 821 pathName=path;
822 } 822 }
823 } 823 }
824 824
825 QListViewItem * newItem; 825 QListViewItem * newItem;
826 if ( QFile( Vdit.current()->file() ).exists() ) { 826 if ( QFile( Vdit.current()->file() ).exists() ) {
827 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 827 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
828 QString::number( QFile( Vdit.current()->file() ).size() ), 828 QString::number( QFile( Vdit.current()->file() ).size() ),
829 storage, Vdit.current()->file()); 829 storage, Vdit.current()->file());
830 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); 830 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) );
831 } 831 }
832 } 832 }
833} 833}
834 834
835 835
836void PlayListWidget::openFile() { 836void PlayListWidget::openFile() {
837 QString filename, name; 837 QString filename, name;
838 InputDialog *fileDlg; 838 InputDialog *fileDlg;
839 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 839 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
840 fileDlg->exec(); 840 fileDlg->exec();
841 if( fileDlg->result() == 1 ) { 841 if( fileDlg->result() == 1 ) {
842 filename = fileDlg->text(); 842 filename = fileDlg->text();
843 843
844 qDebug( "Selected filename is " + filename ); 844 qDebug( "Selected filename is " + filename );
845 845
846 if(filename.left(4) == "http") { //if http, lets write a new m3u 846 if(filename.left(4) == "http") { //if http, lets write a new m3u
847 Om3u *m3uList; 847 Om3u *m3uList;
848 DocLnk lnk; 848 DocLnk lnk;
849 QString m3uFile, m3uFilePath; 849 QString m3uFile, m3uFilePath;
850 850
851 if(filename.find(":",8,TRUE) != -1) { //found a port 851 if(filename.find(":",8,TRUE) != -1) { //found a port
852 m3uFile = filename.left( filename.find( ":",8,TRUE)); 852 m3uFile = filename.left( filename.find( ":",8,TRUE));
853 853
854 m3uFile = m3uFile.right( 7); 854 m3uFile = m3uFile.right( 7);
855 855
856 } else if(filename.left(4) == "http"){ 856 } else if(filename.left(4) == "http"){
857 857
858 m3uFile=filename; 858 m3uFile=filename;
859 m3uFile = m3uFile.right( m3uFile.length() - 7); 859 m3uFile = m3uFile.right( m3uFile.length() - 7);
860 860
861 } else{ 861 } else{
862 m3uFile=filename; 862 m3uFile=filename;
863 } 863 }
864 864
865// qDebug( m3uFile); 865// qDebug( m3uFile);
866 866
867//this is where this new m3u is going to live at 867//this is where this new m3u is going to live at
868 m3uFilePath = QDir::homeDirPath() + "/" + m3uFile + ".m3u"; 868 m3uFilePath = QDir::homeDirPath() + "/" + m3uFile + ".m3u";
869// m3uFile += ".m3u"; 869// m3uFile += ".m3u";
870 m3uList = new Om3u( m3uFile+".m3u"); 870 m3uList = new Om3u( m3uFile+".m3u");
871 871
872 m3uList->add( filename); 872 m3uList->add( filename);
873 m3uList->write(); 873 m3uList->write();
874 if(m3uList) delete m3uList; 874 if(m3uList) delete m3uList;
875 875
876// qDebug( m3uFile); 876// qDebug( m3uFile);
877 lnk.setName( filename ); //sets file name 877 lnk.setName( filename ); //sets file name
878 lnk.setFile( m3uFilePath ); //sets File property 878 lnk.setFile( m3uFilePath ); //sets File property
879 lnk.setType( MimeType( QFile::encodeName(m3uFilePath) ).id() ); 879 lnk.setType( MimeType( QFile::encodeName(m3uFilePath) ).id() );
880 880
881 lnk.setExec( "opieplayer2" ); 881 lnk.setExec( "opieplayer2" );
882 lnk.setIcon("opieplayer2/playlist2"); 882 lnk.setIcon("opieplayer2/playlist2");
883 883
884 if( !lnk.writeLink() ) { 884 if( !lnk.writeLink() ) {
885 qDebug( "Writing doclink did not work" ); 885 qDebug( "Writing doclink did not work" );
886 } 886 }
887 d->selectedFiles->addToSelection( lnk ); 887 d->selectedFiles->addToSelection( lnk );
888 888
889 } 889 }
890 else if( filename.right( 3 ) == "m3u" ) { 890 else if( filename.right( 3 ) == "m3u" ) {
891 readm3u( filename ); 891 readm3u( filename );
892 892
893 } else if( filename.right(3) == "pls" ) { 893 } else if( filename.right(3) == "pls" ) {
894 readPls( filename ); 894 readPls( filename );
895 } 895 }
896 } 896 }
897 if( fileDlg ) { 897 if( fileDlg ) {
898 delete fileDlg; 898 delete fileDlg;
899 } 899 }
900} 900}
901 901
902/* 902/*
903reads m3u and adds files/urls to playlist */ 903reads m3u and adds files/urls to playlist */
904void PlayListWidget::readm3u( const QString &filename ) { 904void PlayListWidget::readm3u( const QString &filename ) {
905 qDebug( "read m3u filename " + filename ); 905 qDebug( "read m3u filename " + filename );
906 906
907 Om3u *m3uList; 907 Om3u *m3uList;
908 QString s, name; 908 QString s, name;
909 m3uList = new Om3u( filename); 909 m3uList = new Om3u( filename);
910 m3uList->readM3u(); 910 m3uList->readM3u();
911 DocLnk lnk; 911 DocLnk lnk;
912 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 912 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
913 s = *it; 913 s = *it;
914 s.replace( QRegExp( "%20" )," " ); 914 s.replace( QRegExp( "%20" )," " );
915 qDebug("reading "+ s); 915 qDebug("reading "+ s);
916 916
917 if( QFileInfo( s ).exists() ) { 917 if( QFileInfo( s ).exists() ) {
918 lnk.setName( QFileInfo(s).baseName()); 918 lnk.setName( QFileInfo(s).baseName());
919 qDebug("set link "+s); 919 qDebug("set link "+s);
920 if(s.at(s.length()-4) == '.') //if regular file 920 if(s.at(s.length()-4) == '.') //if regular file
921 lnk.setFile( s); 921 lnk.setFile( s);
922 else 922 else
923 lnk.setFile( s+"/"); //if url with no extension 923 lnk.setFile( s+"/"); //if url with no extension
924 924
925 d->selectedFiles->addToSelection( lnk ); 925 d->selectedFiles->addToSelection( lnk );
926 } 926 }
927 } 927 }
928 Config config( "OpiePlayer" ); 928 Config config( "OpiePlayer" );
929 config.setGroup( "PlayList" ); 929 config.setGroup( "PlayList" );
930 930
931 config.writeEntry("CurrentPlaylist",filename); 931 config.writeEntry("CurrentPlaylist",filename);
932 currentPlayList=filename; 932 currentPlayList=filename;
933 933
934 m3uList->close(); 934 m3uList->close();
935 if(m3uList) delete m3uList; 935 if(m3uList) delete m3uList;
936 936
937 d->selectedFiles->setSelectedItem( s); 937 d->selectedFiles->setSelectedItem( s);
938 setCaption(tr("OpiePlayer: ")+ QFileInfo(s).baseName()); 938 setCaption(tr("OpiePlayer: ")+ QFileInfo(s).baseName());
939 939
940} 940}
941 941
942/* 942/*
943reads pls and adds files/urls to playlist */ 943reads pls and adds files/urls to playlist */
944void PlayListWidget::readPls( const QString &filename ) { 944void PlayListWidget::readPls( const QString &filename ) {
945 945
946 qDebug( "pls filename is " + filename ); 946 qDebug( "pls filename is " + filename );
947 Om3u *m3uList; 947 Om3u *m3uList;
948 QString s, name; 948 QString s, name;
949 m3uList = new Om3u( filename); 949 m3uList = new Om3u( filename);
950 m3uList->readPls(); 950 m3uList->readPls();
951 951
952 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 952 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
953 s = *it; 953 s = *it;
954 s.replace( QRegExp( "%20" )," " ); 954 s.replace( QRegExp( "%20" )," " );
955 DocLnk lnk( s ); 955 DocLnk lnk( s );
956 QFileInfo f( s ); 956 QFileInfo f( s );
957 QString name = f.baseName(); 957 QString name = f.baseName();
958 958
959 if( name.left( 4 ) == "http" ) { 959 if( name.left( 4 ) == "http" ) {
960 name = s.right( s.length() - 7); 960 name = s.right( s.length() - 7);
961 } else { 961 } else {
962 name = s; 962 name = s;
963 } 963 }
964 964
965 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 965 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
966 966
967 lnk.setName( name ); 967 lnk.setName( name );
968 if( s.at( s.length() - 4) == '.') {// if this is probably a file 968 if( s.at( s.length() - 4) == '.') {// if this is probably a file
969 lnk.setFile( s ); 969 lnk.setFile( s );
970 } else { //if its a url 970 } else { //if its a url
971 if( name.right( 1 ).find( '/' ) == -1) { 971 if( name.right( 1 ).find( '/' ) == -1) {
972 s += "/"; 972 s += "/";
973 } 973 }
974 lnk.setFile( s ); 974 lnk.setFile( s );
975 } 975 }
976 lnk.setType( "audio/x-mpegurl" ); 976 lnk.setType( "audio/x-mpegurl" );
977 977
978 lnk.writeLink(); 978 lnk.writeLink();
979 d->selectedFiles->addToSelection( lnk ); 979 d->selectedFiles->addToSelection( lnk );
980 } 980 }
981 981
982 m3uList->close(); 982 m3uList->close();
983 if(m3uList) delete m3uList; 983 if(m3uList) delete m3uList;
984} 984}
985 985
986/* 986/*
987 writes current playlist to m3u file */ 987 writes current playlist to m3u file */
988void PlayListWidget::writem3u() { 988void PlayListWidget::writem3u() {
989 InputDialog *fileDlg; 989 InputDialog *fileDlg;
990 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 990 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
991 fileDlg->exec(); 991 fileDlg->exec();
992 QString name, filename, list; 992 QString name, filename, list;
993 Om3u *m3uList; 993 Om3u *m3uList;
994 994
995 if( fileDlg->result() == 1 ) { 995 if( fileDlg->result() == 1 ) {
996 name = fileDlg->text(); 996 name = fileDlg->text();
997 qDebug( filename ); 997 qDebug( filename );
998 998
999 if( name.left( 1) != "/" ) { 999 if( name.left( 1) != "/" ) {
1000 filename = QPEApplication::documentDir() + "/" + name; 1000 filename = QPEApplication::documentDir() + "/" + name;
1001 } 1001 }
1002 1002
1003 if( name.right( 3 ) != "m3u" ) { 1003 if( name.right( 3 ) != "m3u" ) {
1004 filename = QPEApplication::documentDir() + "/" +name+".m3u"; 1004 filename = QPEApplication::documentDir() + "/" +name+".m3u";
1005 } 1005 }
1006 1006
1007 m3uList = new Om3u(filename); 1007 m3uList = new Om3u(filename);
1008 1008
1009 d->selectedFiles->first(); 1009 d->selectedFiles->first();
1010 1010
1011 do { 1011 do {
1012 m3uList->add( d->selectedFiles->current()->file()); 1012 m3uList->add( d->selectedFiles->current()->file());
1013 } 1013 }
1014 while ( d->selectedFiles->next() ); 1014 while ( d->selectedFiles->next() );
1015// qDebug( list ); 1015// qDebug( list );
1016 1016
1017 m3uList->write(); 1017 m3uList->write();
1018 m3uList->close(); 1018 m3uList->close();
1019 } 1019 }
1020 if(m3uList) delete m3uList; 1020 if(m3uList) delete m3uList;
1021 if(fileDlg) delete fileDlg; 1021 if(fileDlg) delete fileDlg;
1022 1022
1023 DocLnk lnk; 1023 DocLnk lnk;
1024 lnk.setFile( filename); 1024 lnk.setFile( filename);
1025 lnk.setIcon("opieplayer2/playlist2"); 1025 lnk.setIcon("opieplayer2/playlist2");
1026 lnk.setName( name); //sets file name 1026 lnk.setName( name); //sets file name
1027 1027
1028// qDebug(filename); 1028// qDebug(filename);
1029 Config config( "OpiePlayer" ); 1029 Config config( "OpiePlayer" );
1030 config.setGroup( "PlayList" ); 1030 config.setGroup( "PlayList" );
1031 1031
1032 config.writeEntry("CurrentPlaylist",filename); 1032 config.writeEntry("CurrentPlaylist",filename);
1033 currentPlayList=filename; 1033 currentPlayList=filename;
1034 1034
1035 if(!lnk.writeLink()) { 1035 if(!lnk.writeLink()) {
1036 qDebug("Writing doclink did not work"); 1036 qDebug("Writing doclink did not work");
1037 } 1037 }
1038 1038
1039 setCaption(tr("OpiePlayer: ") + name); 1039 setCaption(tr("OpiePlayer: ") + name);
1040} 1040}
1041 1041
1042void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { 1042void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) {
1043 switch ( e->key() ) { 1043 switch ( e->key() ) {
1044 ////////////////////////////// Zaurus keys 1044 ////////////////////////////// Zaurus keys
1045 case Key_F9: //activity 1045 case Key_F9: //activity
1046 // if(audioUI->isHidden()) 1046 // if(audioUI->isHidden())
1047 // audioUI->showMaximized(); 1047 // audioUI->showMaximized();
1048 break; 1048 break;
1049 case Key_F10: //contacts 1049 case Key_F10: //contacts
1050 // if( videoUI->isHidden()) 1050 // if( videoUI->isHidden())
1051 // videoUI->showMaximized(); 1051 // videoUI->showMaximized();
1052 break; 1052 break;
1053 case Key_F11: //menu 1053 case Key_F11: //menu
1054 break; 1054 break;
1055 case Key_F12: //home 1055 case Key_F12: //home
1056 // doBlank(); 1056 // doBlank();
1057 break; 1057 break;
1058 case Key_F13: //mail 1058 case Key_F13: //mail
1059 // doUnblank(); 1059 // doUnblank();
1060 break; 1060 break;
1061 case Key_Q: //add to playlist 1061 case Key_Q: //add to playlist
1062 addSelected(); 1062 addSelected();
1063 break; 1063 break;
1064 case Key_R: //remove from playlist 1064 case Key_R: //remove from playlist
1065 removeSelected(); 1065 removeSelected();
1066 break; 1066 break;
1067 // case Key_P: //play 1067 // case Key_P: //play
1068 // qDebug("Play"); 1068 // qDebug("Play");
1069 // playSelected(); 1069 // playSelected();
1070 // break; 1070 // break;
1071 case Key_Space: 1071 case Key_Space:
1072 // playSelected(); puh 1072 // playSelected(); puh
1073 break; 1073 break;
1074 case Key_1: 1074 case Key_1:
1075 tabWidget->setCurrentPage( 0 ); 1075 tabWidget->setCurrentPage( 0 );
1076 break; 1076 break;
1077 case Key_2: 1077 case Key_2:
1078 tabWidget->setCurrentPage( 1 ); 1078 tabWidget->setCurrentPage( 1 );
1079 break; 1079 break;
1080 case Key_3: 1080 case Key_3:
1081 tabWidget->setCurrentPage( 2 ); 1081 tabWidget->setCurrentPage( 2 );
1082 break; 1082 break;
1083 case Key_4: 1083 case Key_4:
1084 tabWidget->setCurrentPage( 3 ); 1084 tabWidget->setCurrentPage( 3 );
1085 break; 1085 break;
1086 case Key_Down: 1086 case Key_Down:
1087 if ( !d->selectedFiles->next() ) 1087 if ( !d->selectedFiles->next() )
1088 d->selectedFiles->first(); 1088 d->selectedFiles->first();
1089 break; 1089 break;
1090 case Key_Up: 1090 case Key_Up:
1091 if ( !d->selectedFiles->prev() ) 1091 if ( !d->selectedFiles->prev() )
1092 // d->selectedFiles->last(); 1092 // d->selectedFiles->last();
1093 break; 1093 break;
1094 } 1094 }
1095} 1095}
1096 1096
1097void PlayListWidget::pmViewActivated(int index) { 1097void PlayListWidget::pmViewActivated(int index) {
1098// qDebug("%d", index); 1098// qDebug("%d", index);
1099 switch(index) { 1099 switch(index) {
1100 case -16: 1100 case -16:
1101 { 1101 {
1102 mediaPlayerState->toggleFullscreen(); 1102 mediaPlayerState->toggleFullscreen();
1103 bool b=mediaPlayerState->fullscreen(); 1103 bool b=mediaPlayerState->fullscreen();
1104 pmView->setItemChecked( index, b); 1104 pmView->setItemChecked( index, b);
1105 Config cfg( "OpiePlayer" ); 1105 Config cfg( "OpiePlayer" );
1106 cfg.writeEntry( "FullScreen", b ); 1106 cfg.writeEntry( "FullScreen", b );
1107 } 1107 }
1108 break; 1108 break;
1109 }; 1109 };
1110} 1110}
1111 1111
1112void PlayListWidget::populateSkinsMenu() { 1112void PlayListWidget::populateSkinsMenu() {
1113 int item = 0; 1113 int item = 0;
1114 defaultSkinIndex = 0; 1114 defaultSkinIndex = 0;
1115 QString skinName; 1115 QString skinName;
1116 Config cfg( "OpiePlayer" ); 1116 Config cfg( "OpiePlayer" );
1117 cfg.setGroup("Options" ); 1117 cfg.setGroup("Options" );
1118 QString skin = cfg.readEntry( "Skin", "default" ); 1118 QString skin = cfg.readEntry( "Skin", "default" );
1119 1119
1120 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); 1120 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" );
1121 skinsDir.setFilter( QDir::Dirs ); 1121 skinsDir.setFilter( QDir::Dirs );
1122 skinsDir.setSorting(QDir::Name ); 1122 skinsDir.setSorting(QDir::Name );
1123 const QFileInfoList *skinslist = skinsDir.entryInfoList(); 1123 const QFileInfoList *skinslist = skinsDir.entryInfoList();
1124 QFileInfoListIterator it( *skinslist ); 1124 QFileInfoListIterator it( *skinslist );
1125 QFileInfo *fi; 1125 QFileInfo *fi;
1126 while ( ( fi = it.current() ) ) { 1126 while ( ( fi = it.current() ) ) {
1127 skinName = fi->fileName(); 1127 skinName = fi->fileName();
1128// qDebug( fi->fileName() ); 1128// qDebug( fi->fileName() );
1129 if( skinName != "." && skinName != ".." && skinName !="CVS" ) { 1129 if( skinName != "." && skinName != ".." && skinName !="CVS" ) {
1130 item = skinsMenu->insertItem( fi->fileName() ) ; 1130 item = skinsMenu->insertItem( fi->fileName() ) ;
1131 } 1131 }
1132 if( skinName == "default" ) { 1132 if( skinName == "default" ) {
1133 defaultSkinIndex = item; 1133 defaultSkinIndex = item;
1134 } 1134 }
1135 if( skinName == skin ) { 1135 if( skinName == skin ) {
1136 skinsMenu->setItemChecked( item, TRUE ); 1136 skinsMenu->setItemChecked( item, TRUE );
1137 } 1137 }
1138 ++it; 1138 ++it;
1139 } 1139 }
1140} 1140}
1141 1141
1142void PlayListWidget::skinsMenuActivated( int item ) { 1142void PlayListWidget::skinsMenuActivated( int item ) {
1143 for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { 1143 for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) {
1144 skinsMenu->setItemChecked( i, FALSE ); 1144 skinsMenu->setItemChecked( i, FALSE );
1145 } 1145 }
1146 skinsMenu->setItemChecked( item, TRUE ); 1146 skinsMenu->setItemChecked( item, TRUE );
1147 1147
1148 Config cfg( "OpiePlayer" ); 1148 Config cfg( "OpiePlayer" );
1149 cfg.setGroup("Options"); 1149 cfg.setGroup("Options");
1150 cfg.writeEntry("Skin", skinsMenu->text( item ) ); 1150 cfg.writeEntry("Skin", skinsMenu->text( item ) );
1151} 1151}
1152 1152
1153int PlayListWidget::whichList() { 1153int PlayListWidget::whichList() {
1154 return tabWidget->currentPageIndex(); 1154 return tabWidget->currentPageIndex();
1155} 1155}
1156 1156
1157QString PlayListWidget::currentFileListPathName() { 1157QString PlayListWidget::currentFileListPathName() {
1158 switch (whichList()) { 1158 switch (whichList()) {
1159 case 1: 1159 case 1:
1160 return audioView->currentItem()->text(3); 1160 return audioView->currentItem()->text(3);
1161 break; 1161 break;
1162 case 2: 1162 case 2:
1163 return videoView->currentItem()->text(3); 1163 return videoView->currentItem()->text(3);
1164 break; 1164 break;
1165 }; 1165 };
1166 return ""; 1166 return "";
1167} 1167}