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