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