summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp7
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidgetgui.h1
2 files changed, 3 insertions, 5 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index b04fe8d..55b66ab 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -1,1160 +1,1159 @@
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() const { // this is fugly 427const DocLnk *PlayListWidget::current() const { // this is fugly
428 assert( currentTab() == CurrentPlayList ); 428 assert( currentTab() == CurrentPlayList );
429 429
430// qDebug("playlist"); 430// qDebug("playlist");
431 if ( mediaPlayerState->isUsingPlaylist() ) { 431 if ( mediaPlayerState->isUsingPlaylist() ) {
432 return d->selectedFiles->current(); 432 return d->selectedFiles->current();
433 } else if ( d->setDocumentUsed && d->current ) { 433 } else if ( d->setDocumentUsed && d->current )
434 return d->current; 434 return d->current;
435 } else { 435
436 return &(d->files->selectedDocument()); 436 assert( false );
437 }
438} 437}
439 438
440 439
441bool PlayListWidget::prev() { 440bool PlayListWidget::prev() {
442 if ( mediaPlayerState->isUsingPlaylist() ) { 441 if ( mediaPlayerState->isUsingPlaylist() ) {
443 if ( mediaPlayerState->isShuffled() ) { 442 if ( mediaPlayerState->isShuffled() ) {
444 const DocLnk *cur = current(); 443 const DocLnk *cur = current();
445 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 444 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
446 for ( int i = 0; i < j; i++ ) { 445 for ( int i = 0; i < j; i++ ) {
447 if ( !d->selectedFiles->next() ) 446 if ( !d->selectedFiles->next() )
448 d->selectedFiles->first(); 447 d->selectedFiles->first();
449 } 448 }
450 if ( cur == current() ) 449 if ( cur == current() )
451 if ( !d->selectedFiles->next() ) { 450 if ( !d->selectedFiles->next() ) {
452 d->selectedFiles->first(); 451 d->selectedFiles->first();
453 } 452 }
454 return TRUE; 453 return TRUE;
455 } else { 454 } else {
456 if ( !d->selectedFiles->prev() ) { 455 if ( !d->selectedFiles->prev() ) {
457 if ( mediaPlayerState->isLooping() ) { 456 if ( mediaPlayerState->isLooping() ) {
458 return d->selectedFiles->last(); 457 return d->selectedFiles->last();
459 } else { 458 } else {
460 return FALSE; 459 return FALSE;
461 } 460 }
462 } 461 }
463 return TRUE; 462 return TRUE;
464 } 463 }
465 } else { 464 } else {
466 return mediaPlayerState->isLooping(); 465 return mediaPlayerState->isLooping();
467 } 466 }
468} 467}
469 468
470 469
471bool PlayListWidget::next() { 470bool PlayListWidget::next() {
472//qDebug("<<<<<<<<<<<<next()"); 471//qDebug("<<<<<<<<<<<<next()");
473 if ( mediaPlayerState->isUsingPlaylist() ) { 472 if ( mediaPlayerState->isUsingPlaylist() ) {
474 if ( mediaPlayerState->isShuffled() ) { 473 if ( mediaPlayerState->isShuffled() ) {
475 return prev(); 474 return prev();
476 } else { 475 } else {
477 if ( !d->selectedFiles->next() ) { 476 if ( !d->selectedFiles->next() ) {
478 if ( mediaPlayerState->isLooping() ) { 477 if ( mediaPlayerState->isLooping() ) {
479 return d->selectedFiles->first(); 478 return d->selectedFiles->first();
480 } else { 479 } else {
481 return FALSE; 480 return FALSE;
482 } 481 }
483 } 482 }
484 return TRUE; 483 return TRUE;
485 } 484 }
486 } else { 485 } else {
487 return mediaPlayerState->isLooping(); 486 return mediaPlayerState->isLooping();
488 } 487 }
489} 488}
490 489
491 490
492bool PlayListWidget::first() { 491bool PlayListWidget::first() {
493 if ( mediaPlayerState->isUsingPlaylist() ) 492 if ( mediaPlayerState->isUsingPlaylist() )
494 return d->selectedFiles->first(); 493 return d->selectedFiles->first();
495 else 494 else
496 return mediaPlayerState->isLooping(); 495 return mediaPlayerState->isLooping();
497} 496}
498 497
499 498
500bool PlayListWidget::last() { 499bool PlayListWidget::last() {
501 if ( mediaPlayerState->isUsingPlaylist() ) 500 if ( mediaPlayerState->isUsingPlaylist() )
502 return d->selectedFiles->last(); 501 return d->selectedFiles->last();
503 else 502 else
504 return mediaPlayerState->isLooping(); 503 return mediaPlayerState->isLooping();
505} 504}
506 505
507 506
508 void PlayListWidget::saveList() { 507 void PlayListWidget::saveList() {
509 writem3u(); 508 writem3u();
510 } 509 }
511 510
512 511
513void PlayListWidget::loadList( const DocLnk & lnk) { 512void PlayListWidget::loadList( const DocLnk & lnk) {
514 QString name = lnk.name(); 513 QString name = lnk.name();
515 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); 514 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name);
516 515
517 if( name.length()>0) { 516 if( name.length()>0) {
518 setCaption("OpiePlayer: "+name); 517 setCaption("OpiePlayer: "+name);
519// qDebug("<<<<<<<<<<<<load list "+ lnk.file()); 518// qDebug("<<<<<<<<<<<<load list "+ lnk.file());
520 clearList(); 519 clearList();
521 readm3u(lnk.file()); 520 readm3u(lnk.file());
522 tabWidget->setCurrentPage(0); 521 tabWidget->setCurrentPage(0);
523 } 522 }
524} 523}
525 524
526 525
527void PlayListWidget::setPlaylist( bool shown ) { 526void PlayListWidget::setPlaylist( bool shown ) {
528 if ( shown ) { 527 if ( shown ) {
529 d->playListFrame->show(); 528 d->playListFrame->show();
530 } else { 529 } else {
531 d->playListFrame->hide(); 530 d->playListFrame->hide();
532 } 531 }
533} 532}
534 533
535 534
536void PlayListWidget::addSelected() { 535void PlayListWidget::addSelected() {
537 assert( inFileListMode() ); 536 assert( inFileListMode() );
538 537
539 QListView *fileListView = currentFileListView(); 538 QListView *fileListView = currentFileListView();
540 QListViewItemIterator it( fileListView ); 539 QListViewItemIterator it( fileListView );
541 for ( ; it.current(); ++it ) 540 for ( ; it.current(); ++it )
542 if ( it.current()->isSelected() ) { 541 if ( it.current()->isSelected() ) {
543 QString filename = it.current()->text(3); 542 QString filename = it.current()->text(3);
544 543
545 DocLnk lnk; 544 DocLnk lnk;
546 lnk.setName( QFileInfo( filename ).baseName() ); //sets name 545 lnk.setName( QFileInfo( filename ).baseName() ); //sets name
547 lnk.setFile( filename ); //sets file name 546 lnk.setFile( filename ); //sets file name
548 547
549 d->selectedFiles->addToSelection( lnk ); 548 d->selectedFiles->addToSelection( lnk );
550 } 549 }
551 550
552 fileListView->clearSelection(); 551 fileListView->clearSelection();
553 552
554 tabWidget->setCurrentPage( 0 ); 553 tabWidget->setCurrentPage( 0 );
555 writeCurrentM3u(); 554 writeCurrentM3u();
556} 555}
557 556
558 557
559void PlayListWidget::removeSelected() { 558void PlayListWidget::removeSelected() {
560 d->selectedFiles->removeSelected( ); 559 d->selectedFiles->removeSelected( );
561 writeCurrentM3u(); 560 writeCurrentM3u();
562} 561}
563 562
564 563
565void PlayListWidget::playIt( QListViewItem *it) { 564void PlayListWidget::playIt( QListViewItem *it) {
566 if(!it) return; 565 if(!it) return;
567 mediaPlayerState->setPlaying(FALSE); 566 mediaPlayerState->setPlaying(FALSE);
568 mediaPlayerState->setPlaying(TRUE); 567 mediaPlayerState->setPlaying(TRUE);
569 d->selectedFiles->unSelect(); 568 d->selectedFiles->unSelect();
570} 569}
571 570
572 571
573void PlayListWidget::addToSelection( QListViewItem *it) { 572void PlayListWidget::addToSelection( QListViewItem *it) {
574 d->setDocumentUsed = FALSE; 573 d->setDocumentUsed = FALSE;
575 574
576 if(it) { 575 if(it) {
577 if ( currentTab() == CurrentPlayList ) 576 if ( currentTab() == CurrentPlayList )
578 return; 577 return;
579 // case 1: { 578 // case 1: {
580 DocLnk lnk; 579 DocLnk lnk;
581 QString filename; 580 QString filename;
582 581
583 filename=it->text(3); 582 filename=it->text(3);
584 lnk.setName( QFileInfo(filename).baseName() ); //sets name 583 lnk.setName( QFileInfo(filename).baseName() ); //sets name
585 lnk.setFile( filename ); //sets file name 584 lnk.setFile( filename ); //sets file name
586 d->selectedFiles->addToSelection( lnk); 585 d->selectedFiles->addToSelection( lnk);
587 586
588 writeCurrentM3u(); 587 writeCurrentM3u();
589 tabWidget->setCurrentPage(0); 588 tabWidget->setCurrentPage(0);
590 589
591 } 590 }
592} 591}
593 592
594 593
595void PlayListWidget::tabChanged(QWidget *) { 594void PlayListWidget::tabChanged(QWidget *) {
596 595
597 d->tbPlay->setEnabled( true ); 596 d->tbPlay->setEnabled( true );
598 597
599 switch ( currentTab() ) { 598 switch ( currentTab() ) {
600 case CurrentPlayList: 599 case CurrentPlayList:
601 { 600 {
602 if( !tbDeletePlaylist->isHidden() ) { 601 if( !tbDeletePlaylist->isHidden() ) {
603 tbDeletePlaylist->hide(); 602 tbDeletePlaylist->hide();
604 } 603 }
605 d->tbRemoveFromList->setEnabled(TRUE); 604 d->tbRemoveFromList->setEnabled(TRUE);
606 d->tbAddToList->setEnabled(FALSE); 605 d->tbAddToList->setEnabled(FALSE);
607 } 606 }
608 break; 607 break;
609 case AudioFiles: 608 case AudioFiles:
610 { 609 {
611 // audioView->clear(); 610 // audioView->clear();
612 if(!audioPopulated) populateAudioView(); 611 if(!audioPopulated) populateAudioView();
613 612
614 if( !tbDeletePlaylist->isHidden() ) { 613 if( !tbDeletePlaylist->isHidden() ) {
615 tbDeletePlaylist->hide(); 614 tbDeletePlaylist->hide();
616 } 615 }
617 d->tbRemoveFromList->setEnabled(FALSE); 616 d->tbRemoveFromList->setEnabled(FALSE);
618 d->tbAddToList->setEnabled(TRUE); 617 d->tbAddToList->setEnabled(TRUE);
619 } 618 }
620 break; 619 break;
621 case VideoFiles: 620 case VideoFiles:
622 { 621 {
623 // videoView->clear(); 622 // videoView->clear();
624 if(!videoPopulated) populateVideoView(); 623 if(!videoPopulated) populateVideoView();
625 if( !tbDeletePlaylist->isHidden() ) { 624 if( !tbDeletePlaylist->isHidden() ) {
626 tbDeletePlaylist->hide(); 625 tbDeletePlaylist->hide();
627 } 626 }
628 d->tbRemoveFromList->setEnabled(FALSE); 627 d->tbRemoveFromList->setEnabled(FALSE);
629 d->tbAddToList->setEnabled(TRUE); 628 d->tbAddToList->setEnabled(TRUE);
630 } 629 }
631 break; 630 break;
632 case PlayLists: 631 case PlayLists:
633 { 632 {
634 if( tbDeletePlaylist->isHidden() ) { 633 if( tbDeletePlaylist->isHidden() ) {
635 tbDeletePlaylist->show(); 634 tbDeletePlaylist->show();
636 } 635 }
637 playLists->reread(); 636 playLists->reread();
638 d->tbAddToList->setEnabled(FALSE); 637 d->tbAddToList->setEnabled(FALSE);
639 638
640 d->tbPlay->setEnabled( false ); 639 d->tbPlay->setEnabled( false );
641 } 640 }
642 break; 641 break;
643 }; 642 };
644} 643}
645 644
646 645
647void PlayListWidget::btnPlay(bool b) { 646void PlayListWidget::btnPlay(bool b) {
648// mediaPlayerState->setPlaying(false); 647// mediaPlayerState->setPlaying(false);
649 mediaPlayerState->setPlaying(b); 648 mediaPlayerState->setPlaying(b);
650 insanityBool=FALSE; 649 insanityBool=FALSE;
651} 650}
652 651
653void PlayListWidget::deletePlaylist() { 652void PlayListWidget::deletePlaylist() {
654 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 653 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
655 (tr("You really want to delete\nthis playlist?")), 654 (tr("You really want to delete\nthis playlist?")),
656 (tr("Yes")), (tr("No")), 0 )){ 655 (tr("Yes")), (tr("No")), 0 )){
657 case 0: // Yes clicked, 656 case 0: // Yes clicked,
658 QFile().remove(playLists->selectedDocument().file()); 657 QFile().remove(playLists->selectedDocument().file());
659 QFile().remove(playLists->selectedDocument().linkFile()); 658 QFile().remove(playLists->selectedDocument().linkFile());
660 playLists->reread(); 659 playLists->reread();
661 break; 660 break;
662 case 1: // Cancel 661 case 1: // Cancel
663 break; 662 break;
664 }; 663 };
665} 664}
666 665
667 666
668void PlayListWidget::playSelected() { 667void PlayListWidget::playSelected() {
669 btnPlay( TRUE); 668 btnPlay( TRUE);
670} 669}
671 670
672 671
673void PlayListWidget::scanForAudio() { 672void PlayListWidget::scanForAudio() {
674// qDebug("scan for audio"); 673// qDebug("scan for audio");
675 files.detachChildren(); 674 files.detachChildren();
676 QListIterator<DocLnk> sdit( files.children() ); 675 QListIterator<DocLnk> sdit( files.children() );
677 for ( ; sdit.current(); ++sdit ) { 676 for ( ; sdit.current(); ++sdit ) {
678 delete sdit.current(); 677 delete sdit.current();
679 } 678 }
680// Global::findDocuments( &files, "audio/*"); 679// Global::findDocuments( &files, "audio/*");
681 Global::findDocuments( &files, audioMimes); 680 Global::findDocuments( &files, audioMimes);
682 audioScan = true; 681 audioScan = true;
683 populateAudioView(); 682 populateAudioView();
684} 683}
685 684
686void PlayListWidget::scanForVideo() { 685void PlayListWidget::scanForVideo() {
687// qDebug("scan for video"); 686// qDebug("scan for video");
688 vFiles.detachChildren(); 687 vFiles.detachChildren();
689 QListIterator<DocLnk> sdit( vFiles.children() ); 688 QListIterator<DocLnk> sdit( vFiles.children() );
690 for ( ; sdit.current(); ++sdit ) { 689 for ( ; sdit.current(); ++sdit ) {
691 delete sdit.current(); 690 delete sdit.current();
692 } 691 }
693 Global::findDocuments(&vFiles, "video/*"); 692 Global::findDocuments(&vFiles, "video/*");
694 videoScan = true; 693 videoScan = true;
695 populateVideoView(); 694 populateVideoView();
696} 695}
697 696
698void PlayListWidget::populateAudioView() { 697void PlayListWidget::populateAudioView() {
699 audioView->clear(); 698 audioView->clear();
700 StorageInfo storageInfo; 699 StorageInfo storageInfo;
701 // const QList<FileSystem> &fs = storageInfo.fileSystems(); 700 // const QList<FileSystem> &fs = storageInfo.fileSystems();
702 if(!audioScan) { 701 if(!audioScan) {
703 scanForAudio(); 702 scanForAudio();
704 } 703 }
705 704
706 QListIterator<DocLnk> dit( files.children() ); 705 QListIterator<DocLnk> dit( files.children() );
707 // QListIterator<FileSystem> it ( fs ); 706 // QListIterator<FileSystem> it ( fs );
708 audioView->clear(); 707 audioView->clear();
709 708
710 QString storage; 709 QString storage;
711 for ( ; dit.current(); ++dit ) { 710 for ( ; dit.current(); ++dit ) {
712// // for( ; it.current(); ++it ){ 711// // for( ; it.current(); ++it ){
713// const QString name = (*dit)->name(); 712// const QString name = (*dit)->name();
714// const QString path = (*dit)->path(); 713// const QString path = (*dit)->path();
715// if(dit.current()->file().find(path) != -1 ) { 714// if(dit.current()->file().find(path) != -1 ) {
716// storage = name; 715// storage = name;
717// // } 716// // }
718// } 717// }
719 718
720 QListViewItem * newItem; 719 QListViewItem * newItem;
721 if ( QFile( dit.current()->file()).exists() || 720 if ( QFile( dit.current()->file()).exists() ||
722 dit.current()->file().left(4) == "http" ) { 721 dit.current()->file().left(4) == "http" ) {
723 long size; 722 long size;
724 if( dit.current()->file().left(4) == "http" ) 723 if( dit.current()->file().left(4) == "http" )
725 size=0; 724 size=0;
726 else 725 else
727 size = QFile( dit.current()->file() ).size(); 726 size = QFile( dit.current()->file() ).size();
728 727
729 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), 728 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
730 QString::number(size ), "" /*storage*/, 729 QString::number(size ), "" /*storage*/,
731 dit.current()->file() ); 730 dit.current()->file() );
732 newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); 731 newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) );
733// qDebug("<<<< "+dit.current()->file()); 732// qDebug("<<<< "+dit.current()->file());
734 } 733 }
735 } 734 }
736 audioPopulated=true; 735 audioPopulated=true;
737} 736}
738 737
739 738
740void PlayListWidget::populateVideoView() { 739void PlayListWidget::populateVideoView() {
741 videoView->clear(); 740 videoView->clear();
742 StorageInfo storageInfo; 741 StorageInfo storageInfo;
743 // const QList<FileSystem> &fs = storageInfo.fileSystems(); 742 // const QList<FileSystem> &fs = storageInfo.fileSystems();
744 743
745 if(!videoScan ) { 744 if(!videoScan ) {
746 scanForVideo(); 745 scanForVideo();
747 } 746 }
748 747
749 QListIterator<DocLnk> Vdit( vFiles.children() ); 748 QListIterator<DocLnk> Vdit( vFiles.children() );
750// QListIterator<FileSystem> it ( fs ); 749// QListIterator<FileSystem> it ( fs );
751 videoView->clear(); 750 videoView->clear();
752 QString storage, pathName; 751 QString storage, pathName;
753 for ( ; Vdit.current(); ++Vdit ) { 752 for ( ; Vdit.current(); ++Vdit ) {
754// // for( ; it.current(); ++it ) { 753// // for( ; it.current(); ++it ) {
755// const QString name = (*Vdit)->name(); 754// const QString name = (*Vdit)->name();
756// const QString path = (*Vdit)->path(); 755// const QString path = (*Vdit)->path();
757// if( Vdit.current()->file().find(path) != -1 ) { 756// if( Vdit.current()->file().find(path) != -1 ) {
758// storage=name; 757// storage=name;
759// pathName=path; 758// pathName=path;
760// // } 759// // }
761// } 760// }
762 761
763 QListViewItem * newItem; 762 QListViewItem * newItem;
764 if ( QFile( Vdit.current()->file() ).exists() ) { 763 if ( QFile( Vdit.current()->file() ).exists() ) {
765 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 764 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
766 QString::number( QFile( Vdit.current()->file() ).size() ), 765 QString::number( QFile( Vdit.current()->file() ).size() ),
767 ""/*storage*/, Vdit.current()->file()); 766 ""/*storage*/, Vdit.current()->file());
768 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); 767 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) );
769 } 768 }
770 } 769 }
771 videoPopulated=true; 770 videoPopulated=true;
772} 771}
773 772
774QListView *PlayListWidget::currentFileListView() const 773QListView *PlayListWidget::currentFileListView() const
775{ 774{
776 switch ( currentTab() ) { 775 switch ( currentTab() ) {
777 case AudioFiles: return audioView; 776 case AudioFiles: return audioView;
778 case VideoFiles: return videoView; 777 case VideoFiles: return videoView;
779 default: assert( false ); 778 default: assert( false );
780 } 779 }
781 return 0; 780 return 0;
782} 781}
783 782
784bool PlayListWidget::inFileListMode() const 783bool PlayListWidget::inFileListMode() const
785{ 784{
786 TabType tab = currentTab(); 785 TabType tab = currentTab();
787 return tab == AudioFiles || tab == VideoFiles; 786 return tab == AudioFiles || tab == VideoFiles;
788} 787}
789 788
790void PlayListWidget::openFile() { 789void PlayListWidget::openFile() {
791 // http://66.28.164.33:2080 790 // http://66.28.164.33:2080
792 // http://somafm.com/star0242.m3u 791 // http://somafm.com/star0242.m3u
793 QString filename, name; 792 QString filename, name;
794 InputDialog *fileDlg; 793 InputDialog *fileDlg;
795 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 794 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
796 fileDlg->exec(); 795 fileDlg->exec();
797 if( fileDlg->result() == 1 ) { 796 if( fileDlg->result() == 1 ) {
798 filename = fileDlg->text(); 797 filename = fileDlg->text();
799 qDebug( "Selected filename is " + filename ); 798 qDebug( "Selected filename is " + filename );
800 // Om3u *m3uList; 799 // Om3u *m3uList;
801 DocLnk lnk; 800 DocLnk lnk;
802 Config cfg( "OpiePlayer" ); 801 Config cfg( "OpiePlayer" );
803 cfg.setGroup("PlayList"); 802 cfg.setGroup("PlayList");
804 803
805 if(filename.left(4) == "http") { 804 if(filename.left(4) == "http") {
806 QString m3uFile, m3uFilePath; 805 QString m3uFile, m3uFilePath;
807 if(filename.find(":",8,TRUE) != -1) { //found a port 806 if(filename.find(":",8,TRUE) != -1) { //found a port
808 m3uFile = filename.left( filename.find( ":",8,TRUE)); 807 m3uFile = filename.left( filename.find( ":",8,TRUE));
809 m3uFile = m3uFile.right( 7); 808 m3uFile = m3uFile.right( 7);
810 } else if(filename.left(4) == "http"){ 809 } else if(filename.left(4) == "http"){
811 m3uFile=filename; 810 m3uFile=filename;
812 m3uFile = m3uFile.right( m3uFile.length() - 7); 811 m3uFile = m3uFile.right( m3uFile.length() - 7);
813 } else{ 812 } else{
814 m3uFile=filename; 813 m3uFile=filename;
815 } 814 }
816 815
817// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); 816// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile);
818 lnk.setName( filename ); //sets name 817 lnk.setName( filename ); //sets name
819 lnk.setFile( filename ); //sets file name 818 lnk.setFile( filename ); //sets file name
820 819
821// lnk.setIcon("opieplayer2/musicfile"); 820// lnk.setIcon("opieplayer2/musicfile");
822 821
823 d->selectedFiles->addToSelection( lnk ); 822 d->selectedFiles->addToSelection( lnk );
824 writeCurrentM3u(); 823 writeCurrentM3u();
825 d->selectedFiles->setSelectedItem( lnk.name()); 824 d->selectedFiles->setSelectedItem( lnk.name());
826 } 825 }
827 else if( filename.right( 3) == "m3u" ) { 826 else if( filename.right( 3) == "m3u" ) {
828 readm3u( filename ); 827 readm3u( filename );
829 828
830 } else if( filename.right(3) == "pls" ) { 829 } else if( filename.right(3) == "pls" ) {
831 readPls( filename ); 830 readPls( filename );
832 } else { 831 } else {
833 lnk.setName( QFileInfo(filename).baseName() ); //sets name 832 lnk.setName( QFileInfo(filename).baseName() ); //sets name
834 lnk.setFile( filename ); //sets file name 833 lnk.setFile( filename ); //sets file name
835 d->selectedFiles->addToSelection( lnk); 834 d->selectedFiles->addToSelection( lnk);
836 writeCurrentM3u(); 835 writeCurrentM3u();
837 d->selectedFiles->setSelectedItem( lnk.name()); 836 d->selectedFiles->setSelectedItem( lnk.name());
838 } 837 }
839 } 838 }
840 839
841 if( fileDlg ) { 840 if( fileDlg ) {
842 delete fileDlg; 841 delete fileDlg;
843 } 842 }
844} 843}
845 844
846/* 845/*
847reads m3u and shows files/urls to playlist widget */ 846reads m3u and shows files/urls to playlist widget */
848void PlayListWidget::readm3u( const QString &filename ) { 847void PlayListWidget::readm3u( const QString &filename ) {
849 qDebug( "read m3u filename " + filename ); 848 qDebug( "read m3u filename " + filename );
850 849
851 Om3u *m3uList; 850 Om3u *m3uList;
852 QString s, name; 851 QString s, name;
853 m3uList = new Om3u( filename, IO_ReadOnly ); 852 m3uList = new Om3u( filename, IO_ReadOnly );
854 m3uList->readM3u(); 853 m3uList->readM3u();
855 DocLnk lnk; 854 DocLnk lnk;
856 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 855 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
857 s = *it; 856 s = *it;
858// qDebug("reading "+ s); 857// qDebug("reading "+ s);
859 if(s.left(4)=="http") { 858 if(s.left(4)=="http") {
860 lnk.setName( s ); //sets file name 859 lnk.setName( s ); //sets file name
861 lnk.setIcon("opieplayer2/musicfile"); 860 lnk.setIcon("opieplayer2/musicfile");
862 lnk.setFile( s ); //sets file name 861 lnk.setFile( s ); //sets file name
863 862
864 } else { 863 } else {
865 // if( QFileInfo( s ).exists() ) { 864 // if( QFileInfo( s ).exists() ) {
866 lnk.setName( QFileInfo(s).baseName()); 865 lnk.setName( QFileInfo(s).baseName());
867 // if(s.right(4) == '.') {//if regular file 866 // if(s.right(4) == '.') {//if regular file
868 if(s.left(1) != "/") { 867 if(s.left(1) != "/") {
869 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); 868 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s);
870 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); 869 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
871// lnk.setIcon(MimeType(s).pixmap() ); 870// lnk.setIcon(MimeType(s).pixmap() );
872// lnk.setIcon("SoundPlayer"); 871// lnk.setIcon("SoundPlayer");
873 } else { 872 } else {
874 // qDebug("set link2 "+s); 873 // qDebug("set link2 "+s);
875 lnk.setFile( s); 874 lnk.setFile( s);
876// lnk.setIcon(MimeType(s).pixmap() ); 875// lnk.setIcon(MimeType(s).pixmap() );
877// lnk.setIcon("SoundPlayer"); 876// lnk.setIcon("SoundPlayer");
878 } 877 }
879 } 878 }
880 d->selectedFiles->addToSelection( lnk ); 879 d->selectedFiles->addToSelection( lnk );
881 } 880 }
882 Config config( "OpiePlayer" ); 881 Config config( "OpiePlayer" );
883 config.setGroup( "PlayList" ); 882 config.setGroup( "PlayList" );
884 883
885 config.writeEntry("CurrentPlaylist",filename); 884 config.writeEntry("CurrentPlaylist",filename);
886 config.write(); 885 config.write();
887 currentPlayList=filename; 886 currentPlayList=filename;
888 887
889// m3uList->write(); 888// m3uList->write();
890 m3uList->close(); 889 m3uList->close();
891 if(m3uList) delete m3uList; 890 if(m3uList) delete m3uList;
892 891
893 d->selectedFiles->setSelectedItem( s); 892 d->selectedFiles->setSelectedItem( s);
894 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); 893 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
895 894
896} 895}
897 896
898/* 897/*
899reads pls and adds files/urls to playlist */ 898reads pls and adds files/urls to playlist */
900void PlayListWidget::readPls( const QString &filename ) { 899void PlayListWidget::readPls( const QString &filename ) {
901 900
902 qDebug( "pls filename is " + filename ); 901 qDebug( "pls filename is " + filename );
903 Om3u *m3uList; 902 Om3u *m3uList;
904 QString s, name; 903 QString s, name;
905 m3uList = new Om3u( filename, IO_ReadOnly ); 904 m3uList = new Om3u( filename, IO_ReadOnly );
906 m3uList->readPls(); 905 m3uList->readPls();
907 906
908 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 907 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
909 s = *it; 908 s = *it;
910 // s.replace( QRegExp( "%20" )," " ); 909 // s.replace( QRegExp( "%20" )," " );
911 DocLnk lnk( s ); 910 DocLnk lnk( s );
912 QFileInfo f( s ); 911 QFileInfo f( s );
913 QString name = f.baseName(); 912 QString name = f.baseName();
914 913
915 if( name.left( 4 ) == "http" ) { 914 if( name.left( 4 ) == "http" ) {
916 name = s.right( s.length() - 7); 915 name = s.right( s.length() - 7);
917 } else { 916 } else {
918 name = s; 917 name = s;
919 } 918 }
920 919
921 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 920 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
922 921
923 lnk.setName( name ); 922 lnk.setName( name );
924 if( s.at( s.length() - 4) == '.') {// if this is probably a file 923 if( s.at( s.length() - 4) == '.') {// if this is probably a file
925 lnk.setFile( s ); 924 lnk.setFile( s );
926 } else { //if its a url 925 } else { //if its a url
927// if( name.right( 1 ).find( '/' ) == -1) { 926// if( name.right( 1 ).find( '/' ) == -1) {
928// s += "/"; 927// s += "/";
929// } 928// }
930 lnk.setFile( s ); 929 lnk.setFile( s );
931 } 930 }
932 lnk.setType( "audio/x-mpegurl" ); 931 lnk.setType( "audio/x-mpegurl" );
933 932
934 lnk.writeLink(); 933 lnk.writeLink();
935 d->selectedFiles->addToSelection( lnk ); 934 d->selectedFiles->addToSelection( lnk );
936 } 935 }
937 936
938 m3uList->close(); 937 m3uList->close();
939 if(m3uList) delete m3uList; 938 if(m3uList) delete m3uList;
940} 939}
941 940
942/* 941/*
943 writes current playlist to current m3u file */ 942 writes current playlist to current m3u file */
944void PlayListWidget::writeCurrentM3u() { 943void PlayListWidget::writeCurrentM3u() {
945 qDebug("writing to current m3u"); 944 qDebug("writing to current m3u");
946 Config cfg( "OpiePlayer" ); 945 Config cfg( "OpiePlayer" );
947 cfg.setGroup("PlayList"); 946 cfg.setGroup("PlayList");
948 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); 947 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
949 948
950 Om3u *m3uList; 949 Om3u *m3uList;
951 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); 950 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
952 if( d->selectedFiles->first()) { 951 if( d->selectedFiles->first()) {
953 952
954 do { 953 do {
955 // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); 954 // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file());
956 m3uList->add( d->selectedFiles->current()->file() ); 955 m3uList->add( d->selectedFiles->current()->file() );
957 } 956 }
958 while ( d->selectedFiles->next() ); 957 while ( d->selectedFiles->next() );
959 // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); 958 // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
960 m3uList->write(); 959 m3uList->write();
961 m3uList->close(); 960 m3uList->close();
962 961
963 if(m3uList) delete m3uList; 962 if(m3uList) delete m3uList;
964 } 963 }
965 964
966} 965}
967 966
968 /* 967 /*
969 writes current playlist to m3u file */ 968 writes current playlist to m3u file */
970void PlayListWidget::writem3u() { 969void PlayListWidget::writem3u() {
971 InputDialog *fileDlg; 970 InputDialog *fileDlg;
972 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 971 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
973 fileDlg->exec(); 972 fileDlg->exec();
974 QString name, filename, list; 973 QString name, filename, list;
975 Om3u *m3uList; 974 Om3u *m3uList;
976 975
977 if( fileDlg->result() == 1 ) { 976 if( fileDlg->result() == 1 ) {
978 name = fileDlg->text(); 977 name = fileDlg->text();
979// qDebug( filename ); 978// qDebug( filename );
980 979
981 if( name.left( 1) != "/" ) { 980 if( name.left( 1) != "/" ) {
982 filename = QPEApplication::documentDir() + "/" + name; 981 filename = QPEApplication::documentDir() + "/" + name;
983 } 982 }
984 983
985 if( name.right( 3 ) != "m3u" ) { 984 if( name.right( 3 ) != "m3u" ) {
986 filename = QPEApplication::documentDir() + "/" +name+".m3u"; 985 filename = QPEApplication::documentDir() + "/" +name+".m3u";
987 } 986 }
988 987
989 if( d->selectedFiles->first()) { 988 if( d->selectedFiles->first()) {
990 m3uList = new Om3u(filename, IO_ReadWrite); 989 m3uList = new Om3u(filename, IO_ReadWrite);
991 990
992 do { 991 do {
993 m3uList->add( d->selectedFiles->current()->file()); 992 m3uList->add( d->selectedFiles->current()->file());
994 } 993 }
995 while ( d->selectedFiles->next() ); 994 while ( d->selectedFiles->next() );
996 // qDebug( list ); 995 // qDebug( list );
997 m3uList->write(); 996 m3uList->write();
998 m3uList->close(); 997 m3uList->close();
999 if(m3uList) delete m3uList; 998 if(m3uList) delete m3uList;
1000 999
1001 if(fileDlg) delete fileDlg; 1000 if(fileDlg) delete fileDlg;
1002 1001
1003 DocLnk lnk; 1002 DocLnk lnk;
1004 lnk.setFile( filename); 1003 lnk.setFile( filename);
1005 lnk.setIcon("opieplayer2/playlist2"); 1004 lnk.setIcon("opieplayer2/playlist2");
1006 lnk.setName( name); //sets file name 1005 lnk.setName( name); //sets file name
1007 1006
1008 // qDebug(filename); 1007 // qDebug(filename);
1009 Config config( "OpiePlayer" ); 1008 Config config( "OpiePlayer" );
1010 config.setGroup( "PlayList" ); 1009 config.setGroup( "PlayList" );
1011 1010
1012 config.writeEntry("CurrentPlaylist",filename); 1011 config.writeEntry("CurrentPlaylist",filename);
1013 currentPlayList=filename; 1012 currentPlayList=filename;
1014 1013
1015 if(!lnk.writeLink()) { 1014 if(!lnk.writeLink()) {
1016 qDebug("Writing doclink did not work"); 1015 qDebug("Writing doclink did not work");
1017 } 1016 }
1018 1017
1019 setCaption(tr("OpiePlayer: ") + name); 1018 setCaption(tr("OpiePlayer: ") + name);
1020 } 1019 }
1021 } 1020 }
1022} 1021}
1023 1022
1024void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { 1023void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) {
1025 switch ( e->key() ) { 1024 switch ( e->key() ) {
1026 ////////////////////////////// Zaurus keys 1025 ////////////////////////////// Zaurus keys
1027 case Key_F9: //activity 1026 case Key_F9: //activity
1028 // if(audioUI->isHidden()) 1027 // if(audioUI->isHidden())
1029 // audioUI->showMaximized(); 1028 // audioUI->showMaximized();
1030 break; 1029 break;
1031 case Key_F10: //contacts 1030 case Key_F10: //contacts
1032 // if( videoUI->isHidden()) 1031 // if( videoUI->isHidden())
1033 // videoUI->showMaximized(); 1032 // videoUI->showMaximized();
1034 break; 1033 break;
1035 case Key_F11: //menu 1034 case Key_F11: //menu
1036 break; 1035 break;
1037 case Key_F12: //home 1036 case Key_F12: //home
1038 // doBlank(); 1037 // doBlank();
1039 break; 1038 break;
1040 case Key_F13: //mail 1039 case Key_F13: //mail
1041 // doUnblank(); 1040 // doUnblank();
1042 break; 1041 break;
1043 case Key_Q: //add to playlist 1042 case Key_Q: //add to playlist
1044 addSelected(); 1043 addSelected();
1045 break; 1044 break;
1046 case Key_R: //remove from playlist 1045 case Key_R: //remove from playlist
1047 removeSelected(); 1046 removeSelected();
1048 break; 1047 break;
1049 // case Key_P: //play 1048 // case Key_P: //play
1050 // qDebug("Play"); 1049 // qDebug("Play");
1051 // playSelected(); 1050 // playSelected();
1052 // break; 1051 // break;
1053 case Key_Space: 1052 case Key_Space:
1054 // playSelected(); puh 1053 // playSelected(); puh
1055 break; 1054 break;
1056 case Key_1: 1055 case Key_1:
1057 tabWidget->setCurrentPage( 0 ); 1056 tabWidget->setCurrentPage( 0 );
1058 break; 1057 break;
1059 case Key_2: 1058 case Key_2:
1060 tabWidget->setCurrentPage( 1 ); 1059 tabWidget->setCurrentPage( 1 );
1061 break; 1060 break;
1062 case Key_3: 1061 case Key_3:
1063 tabWidget->setCurrentPage( 2 ); 1062 tabWidget->setCurrentPage( 2 );
1064 break; 1063 break;
1065 case Key_4: 1064 case Key_4:
1066 tabWidget->setCurrentPage( 3 ); 1065 tabWidget->setCurrentPage( 3 );
1067 break; 1066 break;
1068 case Key_Down: 1067 case Key_Down:
1069 if ( !d->selectedFiles->next() ) 1068 if ( !d->selectedFiles->next() )
1070 d->selectedFiles->first(); 1069 d->selectedFiles->first();
1071 break; 1070 break;
1072 case Key_Up: 1071 case Key_Up:
1073 if ( !d->selectedFiles->prev() ) 1072 if ( !d->selectedFiles->prev() )
1074 // d->selectedFiles->last(); 1073 // d->selectedFiles->last();
1075 break; 1074 break;
1076 } 1075 }
1077} 1076}
1078 1077
1079void PlayListWidget::pmViewActivated(int index) { 1078void PlayListWidget::pmViewActivated(int index) {
1080// qDebug("%d", index); 1079// qDebug("%d", index);
1081 switch(index) { 1080 switch(index) {
1082 case -16: 1081 case -16:
1083 { 1082 {
1084 mediaPlayerState->toggleFullscreen(); 1083 mediaPlayerState->toggleFullscreen();
1085 bool b=mediaPlayerState->isFullscreen(); 1084 bool b=mediaPlayerState->isFullscreen();
1086 pmView->setItemChecked( index, b); 1085 pmView->setItemChecked( index, b);
1087 Config cfg( "OpiePlayer" ); 1086 Config cfg( "OpiePlayer" );
1088 cfg.writeEntry( "FullScreen", b ); 1087 cfg.writeEntry( "FullScreen", b );
1089 } 1088 }
1090 break; 1089 break;
1091 }; 1090 };
1092} 1091}
1093 1092
1094void PlayListWidget::populateSkinsMenu() { 1093void PlayListWidget::populateSkinsMenu() {
1095 int item = 0; 1094 int item = 0;
1096 defaultSkinIndex = 0; 1095 defaultSkinIndex = 0;
1097 QString skinName; 1096 QString skinName;
1098 Config cfg( "OpiePlayer" ); 1097 Config cfg( "OpiePlayer" );
1099 cfg.setGroup("Options" ); 1098 cfg.setGroup("Options" );
1100 QString skin = cfg.readEntry( "Skin", "default" ); 1099 QString skin = cfg.readEntry( "Skin", "default" );
1101 1100
1102 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); 1101 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" );
1103 skinsDir.setFilter( QDir::Dirs ); 1102 skinsDir.setFilter( QDir::Dirs );
1104 skinsDir.setSorting(QDir::Name ); 1103 skinsDir.setSorting(QDir::Name );
1105 const QFileInfoList *skinslist = skinsDir.entryInfoList(); 1104 const QFileInfoList *skinslist = skinsDir.entryInfoList();
1106 QFileInfoListIterator it( *skinslist ); 1105 QFileInfoListIterator it( *skinslist );
1107 QFileInfo *fi; 1106 QFileInfo *fi;
1108 while ( ( fi = it.current() ) ) { 1107 while ( ( fi = it.current() ) ) {
1109 skinName = fi->fileName(); 1108 skinName = fi->fileName();
1110// qDebug( fi->fileName() ); 1109// qDebug( fi->fileName() );
1111 if( skinName != "." && skinName != ".." && skinName !="CVS" ) { 1110 if( skinName != "." && skinName != ".." && skinName !="CVS" ) {
1112 item = skinsMenu->insertItem( fi->fileName() ) ; 1111 item = skinsMenu->insertItem( fi->fileName() ) ;
1113 } 1112 }
1114 if( skinName == "default" ) { 1113 if( skinName == "default" ) {
1115 defaultSkinIndex = item; 1114 defaultSkinIndex = item;
1116 } 1115 }
1117 if( skinName == skin ) { 1116 if( skinName == skin ) {
1118 skinsMenu->setItemChecked( item, TRUE ); 1117 skinsMenu->setItemChecked( item, TRUE );
1119 } 1118 }
1120 ++it; 1119 ++it;
1121 } 1120 }
1122} 1121}
1123 1122
1124void PlayListWidget::skinsMenuActivated( int item ) { 1123void PlayListWidget::skinsMenuActivated( int item ) {
1125 for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { 1124 for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) {
1126 skinsMenu->setItemChecked( i, FALSE ); 1125 skinsMenu->setItemChecked( i, FALSE );
1127 } 1126 }
1128 skinsMenu->setItemChecked( item, TRUE ); 1127 skinsMenu->setItemChecked( item, TRUE );
1129 1128
1130 Config cfg( "OpiePlayer" ); 1129 Config cfg( "OpiePlayer" );
1131 cfg.setGroup("Options"); 1130 cfg.setGroup("Options");
1132 cfg.writeEntry("Skin", skinsMenu->text( item ) ); 1131 cfg.writeEntry("Skin", skinsMenu->text( item ) );
1133 QMessageBox::warning( this, tr( "OpiePlayer" ), 1132 QMessageBox::warning( this, tr( "OpiePlayer" ),
1134 tr( "You must <b>restart</b> Opieplayer<br>to see your changes." ) ); 1133 tr( "You must <b>restart</b> Opieplayer<br>to see your changes." ) );
1135} 1134}
1136 1135
1137PlayListWidget::TabType PlayListWidget::currentTab() const 1136PlayListWidget::TabType PlayListWidget::currentTab() const
1138{ 1137{
1139 static const TabType indexToTabType[ TabTypeCount ] = 1138 static const TabType indexToTabType[ TabTypeCount ] =
1140 { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; 1139 { CurrentPlayList, AudioFiles, VideoFiles, PlayLists };
1141 1140
1142 int index = tabWidget->currentPageIndex(); 1141 int index = tabWidget->currentPageIndex();
1143 assert( index < TabTypeCount && index >= 0 ); 1142 assert( index < TabTypeCount && index >= 0 );
1144 1143
1145 return indexToTabType[ index ]; 1144 return indexToTabType[ index ];
1146} 1145}
1147 1146
1148PlayListWidget::Entry PlayListWidget::currentEntry() const 1147PlayListWidget::Entry PlayListWidget::currentEntry() const
1149{ 1148{
1150 if ( currentTab() == CurrentPlayList ) { 1149 if ( currentTab() == CurrentPlayList ) {
1151 const DocLnk *lnk = current(); 1150 const DocLnk *lnk = current();
1152 return Entry( lnk->name(), lnk->file() ); 1151 return Entry( lnk->name(), lnk->file() );
1153 } 1152 }
1154 1153
1155 return Entry( currentFileListPathName() ); 1154 return Entry( currentFileListPathName() );
1156} 1155}
1157 1156
1158QString PlayListWidget::currentFileListPathName() const { 1157QString PlayListWidget::currentFileListPathName() const {
1159 return currentFileListView()->currentItem()->text( 3 ); 1158 return currentFileListView()->currentItem()->text( 3 );
1160} 1159}
diff --git a/noncore/multimedia/opieplayer2/playlistwidgetgui.h b/noncore/multimedia/opieplayer2/playlistwidgetgui.h
index 61fd40d..6c35771 100644
--- a/noncore/multimedia/opieplayer2/playlistwidgetgui.h
+++ b/noncore/multimedia/opieplayer2/playlistwidgetgui.h
@@ -1,130 +1,129 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef PLAY_LIST_WIDGET_GUI_H 34#ifndef PLAY_LIST_WIDGET_GUI_H
35#define PLAY_LIST_WIDGET_GUI_H 35#define PLAY_LIST_WIDGET_GUI_H
36 36
37#include <qmainwindow.h> 37#include <qmainwindow.h>
38#include <qpe/applnk.h> 38#include <qpe/applnk.h>
39#include <qpe/resource.h> 39#include <qpe/resource.h>
40#include <qpe/qpemenubar.h> 40#include <qpe/qpemenubar.h>
41 41
42#include <qtabwidget.h> 42#include <qtabwidget.h>
43#include <qpe/fileselector.h> 43#include <qpe/fileselector.h>
44#include <qpushbutton.h> 44#include <qpushbutton.h>
45#include <qpopupmenu.h> 45#include <qpopupmenu.h>
46#include <qaction.h> 46#include <qaction.h>
47#include <qslider.h> 47#include <qslider.h>
48#include <qlcdnumber.h> 48#include <qlcdnumber.h>
49 49
50class PlayListWidgetPrivate; 50class PlayListWidgetPrivate;
51class PlayListSelection; 51class PlayListSelection;
52 52
53class Config; 53class Config;
54class QPEToolBar; 54class QPEToolBar;
55class QListViewItem; 55class QListViewItem;
56class QListView; 56class QListView;
57class QPoint; 57class QPoint;
58class QAction; 58class QAction;
59class QLabel; 59class QLabel;
60 60
61class PlayListWidgetPrivate { 61class PlayListWidgetPrivate {
62public: 62public:
63 QToolButton *tbPlay, *tbFull, *tbLoop, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; 63 QToolButton *tbPlay, *tbFull, *tbLoop, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove;
64 QFrame *playListFrame; 64 QFrame *playListFrame;
65 FileSelector *files;
66 PlayListSelection *selectedFiles; 65 PlayListSelection *selectedFiles;
67 bool setDocumentUsed; 66 bool setDocumentUsed;
68 DocLnk *current; 67 DocLnk *current;
69}; 68};
70 69
71 70
72class ToolButton : public QToolButton { 71class ToolButton : public QToolButton {
73public: 72public:
74 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 73 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
75 : QToolButton( parent, name ) { 74 : QToolButton( parent, name ) {
76 setTextLabel( name ); 75 setTextLabel( name );
77 setPixmap( Resource::loadPixmap( icon ) ); 76 setPixmap( Resource::loadPixmap( icon ) );
78 setAutoRaise( TRUE ); 77 setAutoRaise( TRUE );
79 setFocusPolicy( QWidget::NoFocus ); 78 setFocusPolicy( QWidget::NoFocus );
80 setToggleButton( t ); 79 setToggleButton( t );
81 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 80 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
82 QPEMenuToolFocusManager::manager()->addWidget( this ); 81 QPEMenuToolFocusManager::manager()->addWidget( this );
83 } 82 }
84}; 83};
85 84
86 85
87class MenuItem : public QAction { 86class MenuItem : public QAction {
88 87
89public: 88public:
90 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) 89 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot )
91 : QAction( text, QString::null, 0, 0 ) { 90 : QAction( text, QString::null, 0, 0 ) {
92 connect( this, SIGNAL( activated() ), handler, slot ); 91 connect( this, SIGNAL( activated() ), handler, slot );
93 addTo( parent ); 92 addTo( parent );
94 } 93 }
95}; 94};
96 95
97class PlayListWidgetGui : public QMainWindow { 96class PlayListWidgetGui : public QMainWindow {
98 Q_OBJECT 97 Q_OBJECT
99public: 98public:
100 PlayListWidgetGui( QWidget* parent=0, const char* name=0, WFlags fl=0 ); 99 PlayListWidgetGui( QWidget* parent=0, const char* name=0, WFlags fl=0 );
101 ~PlayListWidgetGui(); 100 ~PlayListWidgetGui();
102 101
103protected: 102protected:
104 QTabWidget * tabWidget; 103 QTabWidget * tabWidget;
105 QListView *audioView, *videoView, *playlistView; 104 QListView *audioView, *videoView, *playlistView;
106 QLabel *libString; 105 QLabel *libString;
107 QPopupMenu *pmView ; 106 QPopupMenu *pmView ;
108 QPopupMenu *gammaMenu; 107 QPopupMenu *gammaMenu;
109 QSlider *gammaSlider; 108 QSlider *gammaSlider;
110 QLCDNumber *gammaLCD; 109 QLCDNumber *gammaLCD;
111 bool fromSetDocument; 110 bool fromSetDocument;
112 bool insanityBool; 111 bool insanityBool;
113 QString setDocFileRef; 112 QString setDocFileRef;
114 // retrieve the current playlist entry (media file link) 113 // retrieve the current playlist entry (media file link)
115 QPushButton *tbDeletePlaylist; 114 QPushButton *tbDeletePlaylist;
116 int selected; 115 int selected;
117 QPopupMenu *pmPlayList; 116 QPopupMenu *pmPlayList;
118 FileSelector* playLists; 117 FileSelector* playLists;
119 QPopupMenu *skinsMenu; 118 QPopupMenu *skinsMenu;
120 PlayListWidgetPrivate *d; // Private implementation data 119 PlayListWidgetPrivate *d; // Private implementation data
121 QVBox *vbox1; 120 QVBox *vbox1;
122 QVBox *vbox5; 121 QVBox *vbox5;
123 QPEToolBar *bar; 122 QPEToolBar *bar;
124 void setActiveWindow(); // need to handle this to show the right view 123 void setActiveWindow(); // need to handle this to show the right view
125 void setView( char ); 124 void setView( char );
126 125
127}; 126};
128 127
129#endif 128#endif
130 129