summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-11-12 02:36:55 (UTC)
committer llornkcor <llornkcor>2002-11-12 02:36:55 (UTC)
commitc829e55b85c20034f0ae07336fd3f5b9a03d9a48 (patch) (unidiff)
tree4bf1909c70c90a9fb1a70ad0d129f38e06d5ee80
parent03932444a6873eae016b934e540fd76a1197a0c1 (diff)
downloadopie-c829e55b85c20034f0ae07336fd3f5b9a03d9a48.zip
opie-c829e55b85c20034f0ae07336fd3f5b9a03d9a48.tar.gz
opie-c829e55b85c20034f0ae07336fd3f5b9a03d9a48.tar.bz2
fix playlist adding when two file share the same basename but different paths. made it faster adding files to playlist
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp147
1 files changed, 58 insertions, 89 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 8e88e9b..a6a9eca 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -164,179 +164,187 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
164 164
165} 165}
166 166
167 167
168PlayListWidget::~PlayListWidget() { 168PlayListWidget::~PlayListWidget() {
169 if ( d->current ) { 169 if ( d->current ) {
170 delete d->current; 170 delete d->current;
171 } 171 }
172 delete d; 172 delete d;
173} 173}
174 174
175 175
176void PlayListWidget::initializeStates() { 176void PlayListWidget::initializeStates() {
177 d->tbPlay->setOn( mediaPlayerState->playing() ); 177 d->tbPlay->setOn( mediaPlayerState->playing() );
178 d->tbLoop->setOn( mediaPlayerState->looping() ); 178 d->tbLoop->setOn( mediaPlayerState->looping() );
179 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 179 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
180 setPlaylist( true ); 180 setPlaylist( true );
181} 181}
182 182
183void PlayListWidget::writeDefaultPlaylist() { 183void PlayListWidget::writeDefaultPlaylist() {
184 184
185 Config config( "OpiePlayer" ); 185 Config config( "OpiePlayer" );
186 config.setGroup( "PlayList" ); 186 config.setGroup( "PlayList" );
187 QString filename=QPEApplication::documentDir() + "/default.m3u"; 187 QString filename=QPEApplication::documentDir() + "/default.m3u";
188 QString currentString = config.readEntry( "CurrentPlaylist", filename); 188 QString currentString = config.readEntry( "CurrentPlaylist", filename);
189 if( currentString == filename) { 189 if( currentString == filename) {
190 Om3u *m3uList; 190 Om3u *m3uList;
191 // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); 191 // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>");
192 if( d->selectedFiles->first() ) { 192 if( d->selectedFiles->first() ) {
193 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); 193 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate);
194 do { 194 do {
195 // qDebug(d->selectedFiles->current()->file()); 195 // qDebug(d->selectedFiles->current()->file());
196 m3uList->add( d->selectedFiles->current()->file() ); 196 m3uList->add( d->selectedFiles->current()->file() );
197 } 197 }
198 while ( d->selectedFiles->next() ); 198 while ( d->selectedFiles->next() );
199 199
200 m3uList->write(); 200 m3uList->write();
201 m3uList->close(); 201 m3uList->close();
202 if(m3uList) delete m3uList; 202 if(m3uList) delete m3uList;
203 203
204 } 204 }
205 } 205 }
206} 206}
207 207
208void PlayListWidget::addToSelection( const DocLnk& lnk ) { 208void PlayListWidget::addToSelection( const DocLnk& lnk ) {
209 d->setDocumentUsed = FALSE; 209 d->setDocumentUsed = FALSE;
210 if ( mediaPlayerState->playlist() ) { 210 if ( mediaPlayerState->playlist() ) {
211 if( QFileInfo( lnk.file() ).exists() || 211 if( QFileInfo( lnk.file() ).exists() ||
212 lnk.file().left(4) == "http" ) 212 lnk.file().left(4) == "http" ) {
213 d->selectedFiles->addToSelection( lnk ); 213 d->selectedFiles->addToSelection( lnk );
214 }
214// writeCurrentM3u(); 215// writeCurrentM3u();
215 } 216 }
216 else 217 else
217 mediaPlayerState->setPlaying( TRUE ); 218 mediaPlayerState->setPlaying( TRUE );
218} 219}
219 220
220 221
221void PlayListWidget::clearList() { 222void PlayListWidget::clearList() {
222 while ( first() ) { 223 while ( first() ) {
223 d->selectedFiles->removeSelected(); 224 d->selectedFiles->removeSelected();
224 } 225 }
225} 226}
226 227
227void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { 228void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
228 switch (mouse) { 229 switch (mouse) {
229 case 1: 230 case 1:
230 break; 231 break;
231 case 2: 232 case 2:
232 { 233 {
233 QPopupMenu m; 234 QPopupMenu m;
234 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 235 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
235 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 236 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
236 m.exec( QCursor::pos() ); 237 m.exec( QCursor::pos() );
237 } 238 }
238 break; 239 break;
239 } 240 }
240} 241}
241 242
242 243
243void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { 244void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) {
244 switch (mouse) { 245 switch (mouse) {
245 case 1: 246 case 1:
246 break; 247 break;
247 case 2: 248 case 2:
248 { 249 {
249 QPopupMenu m; 250 QPopupMenu m;
250 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 251 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
251 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 252 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
252 m.exec( QCursor::pos() ); 253 m.exec( QCursor::pos() );
253 } 254 }
254 break; 255 break;
255 } 256 }
256} 257}
257 258
258 259
259void PlayListWidget::addAllToList() { 260void PlayListWidget::addAllToList() {
260 DocLnkSet filesAll; 261 DocLnkSet filesAll;
261 Global::findDocuments(&filesAll, "video/*;"+audioMimes); 262 Global::findDocuments(&filesAll, "video/*;"+audioMimes);
262 QListIterator<DocLnk> Adit( filesAll.children() ); 263 QListIterator<DocLnk> Adit( filesAll.children() );
263 for ( ; Adit.current(); ++Adit ) { 264 for ( ; Adit.current(); ++Adit ) {
264 if( QFileInfo( Adit.current()->file() ).exists() ) { 265 if( QFileInfo( Adit.current()->file() ).exists() ) {
265 d->selectedFiles->addToSelection( **Adit ); 266 d->selectedFiles->addToSelection( **Adit );
266 } 267 }
267 } 268 }
268 writeCurrentM3u(); 269 tabWidget->setCurrentPage(0);
270
271 writeCurrentM3u();
272 d->selectedFiles->first();
269} 273}
270 274
271 275
272void PlayListWidget::addAllMusicToList() { 276void PlayListWidget::addAllMusicToList() {
273 if(!audioScan) 277 if(!audioScan)
274 scanForAudio(); 278 scanForAudio();
275 QListIterator<DocLnk> dit( files.children() ); 279 QListIterator<DocLnk> dit( files.children() );
276 for ( ; dit.current(); ++dit ) { 280 for ( ; dit.current(); ++dit ) {
277 if( QFileInfo(dit.current()->file() ).exists() ) { 281 if( QFileInfo(dit.current()->file() ).exists() ) {
278 d->selectedFiles->addToSelection( **dit ); 282 d->selectedFiles->addToSelection( **dit );
279 } 283 }
280 } 284 }
281 writeCurrentM3u(); 285 tabWidget->setCurrentPage(0);
286 writeCurrentM3u();
287 d->selectedFiles->first();
282} 288}
283 289
284 290
285void PlayListWidget::addAllVideoToList() { 291void PlayListWidget::addAllVideoToList() {
286 if(!videoScan) 292 if(!videoScan)
287 scanForVideo(); 293 scanForVideo();
288 QListIterator<DocLnk> dit( vFiles.children() ); 294 QListIterator<DocLnk> dit( vFiles.children() );
289 for ( ; dit.current(); ++dit ) { 295 for ( ; dit.current(); ++dit ) {
290 if( QFileInfo( dit.current()->file() ).exists() ) { 296 if( QFileInfo( dit.current()->file() ).exists() ) {
291 d->selectedFiles->addToSelection( **dit ); 297 d->selectedFiles->addToSelection( **dit );
292 } 298 }
293 } 299 }
300 tabWidget->setCurrentPage(0);
294 writeCurrentM3u(); 301 writeCurrentM3u();
302 d->selectedFiles->first();
295} 303}
296 304
297 305
298void PlayListWidget::setDocument( const QString& fileref ) { 306void PlayListWidget::setDocument( const QString& fileref ) {
299 qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); 307 qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref );
300 fromSetDocument = TRUE; 308 fromSetDocument = TRUE;
301 if ( fileref.isNull() ) { 309 if ( fileref.isNull() ) {
302 QMessageBox::warning( this, tr( "Invalid File" ), 310 QMessageBox::warning( this, tr( "Invalid File" ),
303 tr( "There was a problem in getting the file." ) ); 311 tr( "There was a problem in getting the file." ) );
304 return; 312 return;
305 } 313 }
306 314
307 clearList(); 315 clearList();
308 if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u 316 if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u
309 readm3u( fileref ); 317 readm3u( fileref );
310 } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { 318 } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) {
311 readm3u( DocLnk( fileref).file() ); 319 readm3u( DocLnk( fileref).file() );
312 } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls 320 } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls
313 readPls( fileref ); 321 readPls( fileref );
314 } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { 322 } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) {
315 readPls( DocLnk( fileref).file() ); 323 readPls( DocLnk( fileref).file() );
316 } else { 324 } else {
317 clearList(); 325 clearList();
318 addToSelection( DocLnk( fileref ) ); 326 addToSelection( DocLnk( fileref ) );
319 writeCurrentM3u(); 327 writeCurrentM3u();
320 328
321 d->setDocumentUsed = TRUE; 329 d->setDocumentUsed = TRUE;
322 mediaPlayerState->setPlaying( FALSE ); 330 mediaPlayerState->setPlaying( FALSE );
323 mediaPlayerState->setPlaying( TRUE ); 331 mediaPlayerState->setPlaying( TRUE );
324 } 332 }
325} 333}
326 334
327 335
328void PlayListWidget::useSelectedDocument() { 336void PlayListWidget::useSelectedDocument() {
329 d->setDocumentUsed = FALSE; 337 d->setDocumentUsed = FALSE;
330} 338}
331 339
332 340
333const DocLnk *PlayListWidget::current() { // this is fugly 341const DocLnk *PlayListWidget::current() { // this is fugly
334 switch ( whichList() ) { 342 switch ( whichList() ) {
335 case 0: //playlist 343 case 0: //playlist
336 { 344 {
337// qDebug("playlist"); 345// qDebug("playlist");
338 if ( mediaPlayerState->playlist() ) { 346 if ( mediaPlayerState->playlist() ) {
339 return d->selectedFiles->current(); 347 return d->selectedFiles->current();
340 } else if ( d->setDocumentUsed && d->current ) { 348 } else if ( d->setDocumentUsed && d->current ) {
341 return d->current; 349 return d->current;
342 } else { 350 } else {
@@ -378,222 +386,183 @@ bool PlayListWidget::prev() {
378 } 386 }
379} 387}
380 388
381 389
382bool PlayListWidget::next() { 390bool PlayListWidget::next() {
383//qDebug("<<<<<<<<<<<<next()"); 391//qDebug("<<<<<<<<<<<<next()");
384 if ( mediaPlayerState->playlist() ) { 392 if ( mediaPlayerState->playlist() ) {
385 if ( mediaPlayerState->shuffled() ) { 393 if ( mediaPlayerState->shuffled() ) {
386 return prev(); 394 return prev();
387 } else { 395 } else {
388 if ( !d->selectedFiles->next() ) { 396 if ( !d->selectedFiles->next() ) {
389 if ( mediaPlayerState->looping() ) { 397 if ( mediaPlayerState->looping() ) {
390 return d->selectedFiles->first(); 398 return d->selectedFiles->first();
391 } else { 399 } else {
392 return FALSE; 400 return FALSE;
393 } 401 }
394 } 402 }
395 return TRUE; 403 return TRUE;
396 } 404 }
397 } else { 405 } else {
398 return mediaPlayerState->looping(); 406 return mediaPlayerState->looping();
399 } 407 }
400} 408}
401 409
402 410
403bool PlayListWidget::first() { 411bool PlayListWidget::first() {
404 if ( mediaPlayerState->playlist() ) 412 if ( mediaPlayerState->playlist() )
405 return d->selectedFiles->first(); 413 return d->selectedFiles->first();
406 else 414 else
407 return mediaPlayerState->looping(); 415 return mediaPlayerState->looping();
408} 416}
409 417
410 418
411bool PlayListWidget::last() { 419bool PlayListWidget::last() {
412 if ( mediaPlayerState->playlist() ) 420 if ( mediaPlayerState->playlist() )
413 return d->selectedFiles->last(); 421 return d->selectedFiles->last();
414 else 422 else
415 return mediaPlayerState->looping(); 423 return mediaPlayerState->looping();
416} 424}
417 425
418 426
419 void PlayListWidget::saveList() { 427 void PlayListWidget::saveList() {
420 writem3u(); 428 writem3u();
421 } 429 }
422 430
423 431
424void PlayListWidget::loadList( const DocLnk & lnk) { 432void PlayListWidget::loadList( const DocLnk & lnk) {
425 QString name = lnk.name(); 433 QString name = lnk.name();
426 qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); 434 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name);
427 435
428 if( name.length()>0) { 436 if( name.length()>0) {
429 setCaption("OpiePlayer: "+name); 437 setCaption("OpiePlayer: "+name);
430 qDebug("<<<<<<<<<<<<load list "+ lnk.file()); 438// qDebug("<<<<<<<<<<<<load list "+ lnk.file());
431 clearList(); 439 clearList();
432 readm3u(lnk.file()); 440 readm3u(lnk.file());
433 tabWidget->setCurrentPage(0); 441 tabWidget->setCurrentPage(0);
434 } 442 }
435} 443}
436 444
437 445
438void PlayListWidget::setPlaylist( bool shown ) { 446void PlayListWidget::setPlaylist( bool shown ) {
439 if ( shown ) { 447 if ( shown ) {
440 d->playListFrame->show(); 448 d->playListFrame->show();
441 } else { 449 } else {
442 d->playListFrame->hide(); 450 d->playListFrame->hide();
443 } 451 }
444} 452}
445 453
446 454
447void PlayListWidget::addSelected() { 455void PlayListWidget::addSelected() {
448 qDebug("addSelected"); 456 qDebug("addSelected");
449 switch (whichList()) { 457 DocLnk lnk;
450 case 0: //playlist 458 QString filename;
451 break; 459 switch (whichList()) {
452 case 1: { //audio 460
453 QListViewItemIterator it( audioView ); 461 case 0: //playlist
454 // iterate through all items of the listview 462 return;
455 for ( ; it.current(); ++it ) { 463 break;
456 if ( it.current()->isSelected() ) { 464 case 1: { //audio
457 QListIterator<DocLnk> dit( files.children() ); 465 filename=audioView->currentItem()->text(3);
458 for ( ; dit.current(); ++dit ) { 466 // d->selectedFiles->next();
459 if( dit.current()->name() == it.current()->text(0) ) { 467 }
460 if( QFileInfo( dit.current()->file()).exists()) { 468 break;
461 d->selectedFiles->addToSelection( **dit );
462 audioView->setSelected( it.current(),FALSE);
463 }
464 }
465 }
466 }
467 }
468// tabWidget->setCurrentPage(0);
469 writeCurrentM3u();
470 d->selectedFiles->next();
471 }
472 break;
473 case 2: { // video
474 QListViewItemIterator it( videoView );
475 // iterate through all items of the listview
476 for ( ; it.current(); ++it ) {
477 if ( it.current()->isSelected() ) {
478 QListIterator<DocLnk> dit( vFiles.children() );
479 for ( ; dit.current(); ++dit ) {
480 if( dit.current()->name() == it.current()->text(0) ) {
481 if(QFileInfo( dit.current()->file()).exists()) {
482 d->selectedFiles->addToSelection( **dit );
483 videoView->setSelected( it.current(),FALSE);
484 }
485 }
486 }
487 }
488 }
489// tabWidget->setCurrentPage(0);
490 writeCurrentM3u();
491 469
492 } 470 case 2: { // video
493 break; 471 filename=videoView->currentItem()->text(3);
494 }; 472 // tabWidget->setCurrentPage(0);
473
474 }
475 break;
476 };
477 lnk.setName( QFileInfo(filename).baseName() ); //sets name
478 lnk.setFile( filename ); //sets file name
479 d->selectedFiles->addToSelection( lnk);
480 tabWidget->setCurrentPage(0);
481 writeCurrentM3u();
495} 482}
496 483
497 484
498void PlayListWidget::removeSelected() { 485void PlayListWidget::removeSelected() {
499 d->selectedFiles->removeSelected( ); 486 d->selectedFiles->removeSelected( );
500 writeCurrentM3u(); 487 writeCurrentM3u();
501} 488}
502 489
503 490
504void PlayListWidget::playIt( QListViewItem *it) { 491void PlayListWidget::playIt( QListViewItem *it) {
505 if(!it) return; 492 if(!it) return;
506 mediaPlayerState->setPlaying(FALSE); 493 mediaPlayerState->setPlaying(FALSE);
507 mediaPlayerState->setPlaying(TRUE); 494 mediaPlayerState->setPlaying(TRUE);
508 d->selectedFiles->unSelect(); 495 d->selectedFiles->unSelect();
509} 496}
510 497
511 498
512void PlayListWidget::addToSelection( QListViewItem *it) { 499void PlayListWidget::addToSelection( QListViewItem *it) {
513 d->setDocumentUsed = FALSE; 500 d->setDocumentUsed = FALSE;
514 501
515 if(it) { 502 if(it) {
516 switch ( whichList()) { 503 switch ( whichList()) {
517 case 1: { 504 case 0: //playlist
518 QListIterator<DocLnk> dit( files.children() ); 505 return;
519 for ( ; dit.current(); ++dit ) { 506 break;
520 if( dit.current()->name() == it->text(0)) { 507 };
521 if(QFileInfo( dit.current()->file()).exists()) { 508 // case 1: {
522 d->selectedFiles->addToSelection( **dit ); 509 DocLnk lnk;
523// qDebug("blah "+ dit.current()->name()); 510 QString filename;
524// d->selectedFiles->setSelectedItem( dit.current()->name()); 511
525 } 512 filename=it->text(3);
526 } 513 lnk.setName( QFileInfo(filename).baseName() ); //sets name
527 } 514 lnk.setFile( filename ); //sets file name
528 writeCurrentM3u(); 515 d->selectedFiles->addToSelection( lnk);
529 } 516
530 break; 517 writeCurrentM3u();
531 case 2: { 518 tabWidget->setCurrentPage(0);
532 QListIterator<DocLnk> dit( vFiles.children() );
533 for ( ; dit.current(); ++dit ) {
534 if( dit.current()->name() == it->text(0)) {
535 if( QFileInfo( dit.current()->file()).exists() ) {
536 d->selectedFiles->addToSelection( **dit );
537// qDebug("blah "+ dit.current()->name());
538// d->selectedFiles->setSelectedItem( dit.current()->name());
539 }
540 }
541 }
542 writeCurrentM3u();
543
544 }
545 break;
546 case 0:
547 break;
548 };
549 tabWidget->setCurrentPage(0);
550 519
551 } 520 }
552} 521}
553 522
554 523
555void PlayListWidget::tabChanged(QWidget *) { 524void PlayListWidget::tabChanged(QWidget *) {
556 525
557 switch ( whichList()) { 526 switch ( whichList()) {
558 case 0: 527 case 0:
559 { 528 {
560 if( !tbDeletePlaylist->isHidden() ) { 529 if( !tbDeletePlaylist->isHidden() ) {
561 tbDeletePlaylist->hide(); 530 tbDeletePlaylist->hide();
562 } 531 }
563 d->tbRemoveFromList->setEnabled(TRUE); 532 d->tbRemoveFromList->setEnabled(TRUE);
564 d->tbAddToList->setEnabled(FALSE); 533 d->tbAddToList->setEnabled(FALSE);
565 } 534 }
566 break; 535 break;
567 case 1: 536 case 1:
568 { 537 {
569 audioView->clear(); 538 audioView->clear();
570 populateAudioView(); 539 populateAudioView();
571 540
572 if( !tbDeletePlaylist->isHidden() ) { 541 if( !tbDeletePlaylist->isHidden() ) {
573 tbDeletePlaylist->hide(); 542 tbDeletePlaylist->hide();
574 } 543 }
575 d->tbRemoveFromList->setEnabled(FALSE); 544 d->tbRemoveFromList->setEnabled(FALSE);
576 d->tbAddToList->setEnabled(TRUE); 545 d->tbAddToList->setEnabled(TRUE);
577 } 546 }
578 break; 547 break;
579 case 2: 548 case 2:
580 { 549 {
581 videoView->clear(); 550 videoView->clear();
582 populateVideoView(); 551 populateVideoView();
583 if( !tbDeletePlaylist->isHidden() ) { 552 if( !tbDeletePlaylist->isHidden() ) {
584 tbDeletePlaylist->hide(); 553 tbDeletePlaylist->hide();
585 } 554 }
586 d->tbRemoveFromList->setEnabled(FALSE); 555 d->tbRemoveFromList->setEnabled(FALSE);
587 d->tbAddToList->setEnabled(TRUE); 556 d->tbAddToList->setEnabled(TRUE);
588 } 557 }
589 break; 558 break;
590 case 3: 559 case 3:
591 { 560 {
592 if( tbDeletePlaylist->isHidden() ) { 561 if( tbDeletePlaylist->isHidden() ) {
593 tbDeletePlaylist->show(); 562 tbDeletePlaylist->show();
594 } 563 }
595 playLists->reread(); 564 playLists->reread();
596 } 565 }
597 break; 566 break;
598 }; 567 };
599} 568}
@@ -874,97 +843,97 @@ void PlayListWidget::readPls( const QString &filename ) {
874/* 843/*
875 writes current playlist to current m3u file */ 844 writes current playlist to current m3u file */
876void PlayListWidget::writeCurrentM3u() { 845void PlayListWidget::writeCurrentM3u() {
877 qDebug("writing to current m3u"); 846 qDebug("writing to current m3u");
878 Config cfg( "OpiePlayer" ); 847 Config cfg( "OpiePlayer" );
879 cfg.setGroup("PlayList"); 848 cfg.setGroup("PlayList");
880 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); 849 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
881 850
882 Om3u *m3uList; 851 Om3u *m3uList;
883 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); 852 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
884 if( d->selectedFiles->first()) { 853 if( d->selectedFiles->first()) {
885 854
886 do { 855 do {
887 qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); 856 qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file());
888 m3uList->add( d->selectedFiles->current()->file() ); 857 m3uList->add( d->selectedFiles->current()->file() );
889 } 858 }
890 while ( d->selectedFiles->next() ); 859 while ( d->selectedFiles->next() );
891 qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); 860 qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
892 m3uList->write(); 861 m3uList->write();
893 m3uList->close(); 862 m3uList->close();
894 863
895 if(m3uList) delete m3uList; 864 if(m3uList) delete m3uList;
896 } 865 }
897 866
898} 867}
899 868
900 /* 869 /*
901 writes current playlist to m3u file */ 870 writes current playlist to m3u file */
902void PlayListWidget::writem3u() { 871void PlayListWidget::writem3u() {
903 InputDialog *fileDlg; 872 InputDialog *fileDlg;
904 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 873 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
905 fileDlg->exec(); 874 fileDlg->exec();
906 QString name, filename, list; 875 QString name, filename, list;
907 Om3u *m3uList; 876 Om3u *m3uList;
908 877
909 if( fileDlg->result() == 1 ) { 878 if( fileDlg->result() == 1 ) {
910 name = fileDlg->text(); 879 name = fileDlg->text();
911// qDebug( filename ); 880// qDebug( filename );
912 881
913 if( name.left( 1) != "/" ) { 882 if( name.left( 1) != "/" ) {
914 filename = QPEApplication::documentDir() + "/" + name; 883 filename = QPEApplication::documentDir() + "/" + name;
915 } 884 }
916 885
917 if( name.right( 3 ) != "m3u" ) { 886 if( name.right( 3 ) != "m3u" ) {
918 filename = QPEApplication::documentDir() + "/" +name+".m3u"; 887 filename = QPEApplication::documentDir() + "/" +name+".m3u";
919 } 888 }
920 889
921 if( d->selectedFiles->first()) { 890 if( d->selectedFiles->first()) {
922 m3uList = new Om3u(filename, IO_ReadWrite); 891 m3uList = new Om3u(filename, IO_ReadWrite);
923 892
924 do { 893 do {
925 m3uList->add( d->selectedFiles->current()->file()); 894 m3uList->add( d->selectedFiles->current()->file());
926 } 895 }
927 while ( d->selectedFiles->next() ); 896 while ( d->selectedFiles->next() );
928 // qDebug( list ); 897 // qDebug( list );
929 m3uList->write(); 898 m3uList->write();
930 m3uList->close(); 899 m3uList->close();
931 if(m3uList) delete m3uList; 900 if(m3uList) delete m3uList;
932 901
933 if(fileDlg) delete fileDlg; 902 if(fileDlg) delete fileDlg;
934 903
935 DocLnk lnk; 904 DocLnk lnk;
936 lnk.setFile( filename); 905 lnk.setFile( filename);
937// lnk.setIcon("opieplayer2/playlist2"); 906// lnk.setIcon("opieplayer2/playlist2");
938 lnk.setName( name); //sets file name 907 lnk.setName( name); //sets file name
939 908
940 // qDebug(filename); 909 // qDebug(filename);
941 Config config( "OpiePlayer" ); 910 Config config( "OpiePlayer" );
942 config.setGroup( "PlayList" ); 911 config.setGroup( "PlayList" );
943 912
944 config.writeEntry("CurrentPlaylist",filename); 913 config.writeEntry("CurrentPlaylist",filename);
945 currentPlayList=filename; 914 currentPlayList=filename;
946 915
947 if(!lnk.writeLink()) { 916 if(!lnk.writeLink()) {
948 qDebug("Writing doclink did not work"); 917 qDebug("Writing doclink did not work");
949 } 918 }
950 919
951 setCaption(tr("OpiePlayer: ") + name); 920 setCaption(tr("OpiePlayer: ") + name);
952 } 921 }
953 } 922 }
954} 923}
955 924
956void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { 925void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) {
957 switch ( e->key() ) { 926 switch ( e->key() ) {
958 ////////////////////////////// Zaurus keys 927 ////////////////////////////// Zaurus keys
959 case Key_F9: //activity 928 case Key_F9: //activity
960 // if(audioUI->isHidden()) 929 // if(audioUI->isHidden())
961 // audioUI->showMaximized(); 930 // audioUI->showMaximized();
962 break; 931 break;
963 case Key_F10: //contacts 932 case Key_F10: //contacts
964 // if( videoUI->isHidden()) 933 // if( videoUI->isHidden())
965 // videoUI->showMaximized(); 934 // videoUI->showMaximized();
966 break; 935 break;
967 case Key_F11: //menu 936 case Key_F11: //menu
968 break; 937 break;
969 case Key_F12: //home 938 case Key_F12: //home
970 // doBlank(); 939 // doBlank();