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