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