summaryrefslogtreecommitdiff
authorbipolar <bipolar>2002-03-03 20:00:13 (UTC)
committer bipolar <bipolar>2002-03-03 20:00:13 (UTC)
commit1c2cb5505bd88b1f38cf65936486a73081da8cf4 (patch) (unidiff)
tree876541302b9d1c5e0be619cc44338f2538d68c58
parent86ade8478229710d4a31d1c0604b79565935734e (diff)
downloadopie-1c2cb5505bd88b1f38cf65936486a73081da8cf4.zip
opie-1c2cb5505bd88b1f38cf65936486a73081da8cf4.tar.gz
opie-1c2cb5505bd88b1f38cf65936486a73081da8cf4.tar.bz2
committed by ljp (llornkcor): small fix for player redraw not going so well
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index ae03ec8..de36551 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -220,542 +220,544 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
220 newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" )); 220 newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" ));
221 } 221 }
222 } 222 }
223// videowidget 223// videowidget
224 224
225 QWidget *vTab; 225 QWidget *vTab;
226 vTab = new QWidget( tabWidget, "vTab" ); 226 vTab = new QWidget( tabWidget, "vTab" );
227 videoView = new QListView( vTab, "Videoview" ); 227 videoView = new QListView( vTab, "Videoview" );
228 videoView->setMinimumSize(233,260); 228 videoView->setMinimumSize(233,260);
229 229
230 videoView->addColumn("Title",150); 230 videoView->addColumn("Title",150);
231 videoView->addColumn("Size",45); 231 videoView->addColumn("Size",45);
232 videoView->addColumn("Media",35); 232 videoView->addColumn("Media",35);
233 videoView->setColumnAlignment(1, Qt::AlignRight); 233 videoView->setColumnAlignment(1, Qt::AlignRight);
234 videoView->setColumnAlignment(2, Qt::AlignRight); 234 videoView->setColumnAlignment(2, Qt::AlignRight);
235 235
236 tabWidget->insertTab( vTab,"Video"); 236 tabWidget->insertTab( vTab,"Video");
237 237
238 Global::findDocuments(&vFiles, "video/*"); 238 Global::findDocuments(&vFiles, "video/*");
239 QListIterator<DocLnk> Vdit( vFiles.children() ); 239 QListIterator<DocLnk> Vdit( vFiles.children() );
240 for ( ; Vdit.current(); ++Vdit ) { 240 for ( ; Vdit.current(); ++Vdit ) {
241 if( Vdit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; 241 if( Vdit.current()->file().find("/mnt/cf") != -1 ) storage="CF";
242 else if( Vdit.current()->file().find("/mnt/hda") != -1 ) storage="CF"; 242 else if( Vdit.current()->file().find("/mnt/hda") != -1 ) storage="CF";
243 else if( Vdit.current()->file().find("/mnt/card") != -1 ) storage="SD"; 243 else if( Vdit.current()->file().find("/mnt/card") != -1 ) storage="SD";
244 else storage="RAM"; 244 else storage="RAM";
245 QListViewItem * newItem; 245 QListViewItem * newItem;
246 if ( QFile( Vdit.current()->file()).exists() ) { 246 if ( QFile( Vdit.current()->file()).exists() ) {
247 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); 247 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage);
248 newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); 248 newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" ));
249 } 249 }
250 } 250 }
251 251
252//playlists list 252//playlists list
253 QWidget *LTab; 253 QWidget *LTab;
254 LTab = new QWidget( tabWidget, "LTab" ); 254 LTab = new QWidget( tabWidget, "LTab" );
255 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy 255 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy
256 playLists->setMinimumSize(233,260);; 256 playLists->setMinimumSize(233,260);;
257 tabWidget->insertTab(LTab,"Lists"); 257 tabWidget->insertTab(LTab,"Lists");
258 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); 258 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
259// connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); 259// connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) );
260 260
261 261
262// add the library area 262// add the library area
263 QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); 263 QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold );
264 264
265 265
266 connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), 266 connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)),
267 this, SLOT( fauxPlay( QListViewItem *) ) ); 267 this, SLOT( fauxPlay( QListViewItem *) ) );
268 connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), 268 connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)),
269 this, SLOT( fauxPlay( QListViewItem *)) ); 269 this, SLOT( fauxPlay( QListViewItem *)) );
270 270
271// connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); 271// connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) );
272// connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); 272// connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) );
273 273
274 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 274 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
275 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 275 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
276 276
277 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); 277 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
278 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); 278 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
279 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); 279 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
280 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); 280 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
281 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); 281 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
282 282
283 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 283 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
284// connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); 284// connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) );
285 285
286 setCentralWidget( vbox5 ); 286 setCentralWidget( vbox5 );
287 287
288 Config cfg( "MediaPlayer" ); 288 Config cfg( "MediaPlayer" );
289 readConfig( cfg ); 289 readConfig( cfg );
290 290
291 initializeStates(); 291 initializeStates();
292} 292}
293 293
294 294
295PlayListWidget::~PlayListWidget() { 295PlayListWidget::~PlayListWidget() {
296 Config cfg( "MediaPlayer" ); 296 Config cfg( "MediaPlayer" );
297 writeConfig( cfg ); 297 writeConfig( cfg );
298 298
299 if ( d->current ) 299 if ( d->current )
300 delete d->current; 300 delete d->current;
301 delete d; 301 delete d;
302} 302}
303 303
304 304
305void PlayListWidget::initializeStates() { 305void PlayListWidget::initializeStates() {
306 306
307 d->tbPlay->setOn( mediaPlayerState->playing() ); 307 d->tbPlay->setOn( mediaPlayerState->playing() );
308 d->tbLoop->setOn( mediaPlayerState->looping() ); 308 d->tbLoop->setOn( mediaPlayerState->looping() );
309 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 309 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
310// d->tbFull->setOn( mediaPlayerState->fullscreen() ); 310// d->tbFull->setOn( mediaPlayerState->fullscreen() );
311// d->tbScale->setOn( mediaPlayerState->scaled() ); 311// d->tbScale->setOn( mediaPlayerState->scaled() );
312// d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); 312// d->tbScale->setEnabled( mediaPlayerState->fullscreen() );
313// setPlaylist( mediaPlayerState->playlist() ); 313// setPlaylist( mediaPlayerState->playlist() );
314 setPlaylist( true); 314 setPlaylist( true);
315 d->selectedFiles->first(); 315 d->selectedFiles->first();
316 316
317} 317}
318 318
319 319
320void PlayListWidget::readConfig( Config& cfg ) { 320void PlayListWidget::readConfig( Config& cfg ) {
321 cfg.setGroup("PlayList"); 321 cfg.setGroup("PlayList");
322 322
323 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 323 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
324 324
325 for ( int i = 0; i < noOfFiles; i++ ) { 325 for ( int i = 0; i < noOfFiles; i++ ) {
326 QString entryName; 326 QString entryName;
327 entryName.sprintf( "File%i", i + 1 ); 327 entryName.sprintf( "File%i", i + 1 );
328 QString linkFile = cfg.readEntry( entryName ); 328 QString linkFile = cfg.readEntry( entryName );
329 DocLnk lnk( linkFile ); 329 DocLnk lnk( linkFile );
330 if ( lnk.isValid() ) 330 if ( lnk.isValid() )
331 d->selectedFiles->addToSelection( lnk ); 331 d->selectedFiles->addToSelection( lnk );
332 } 332 }
333} 333}
334 334
335 335
336void PlayListWidget::writeConfig( Config& cfg ) const { 336void PlayListWidget::writeConfig( Config& cfg ) const {
337 cfg.setGroup("PlayList"); 337 cfg.setGroup("PlayList");
338 338
339 int noOfFiles = 0; 339 int noOfFiles = 0;
340 340
341 d->selectedFiles->first(); 341 d->selectedFiles->first();
342 do { 342 do {
343 const DocLnk *lnk = d->selectedFiles->current(); 343 const DocLnk *lnk = d->selectedFiles->current();
344 if ( lnk ) { 344 if ( lnk ) {
345 QString entryName; 345 QString entryName;
346 entryName.sprintf( "File%i", noOfFiles + 1 ); 346 entryName.sprintf( "File%i", noOfFiles + 1 );
347 cfg.writeEntry( entryName, lnk->linkFile() ); 347 cfg.writeEntry( entryName, lnk->linkFile() );
348 // if this link does exist, add it so we have the file 348 // if this link does exist, add it so we have the file
349 // next time... 349 // next time...
350 if ( !QFile::exists( lnk->linkFile() ) ) { 350 if ( !QFile::exists( lnk->linkFile() ) ) {
351 // the way writing lnks doesn't really check for out 351 // the way writing lnks doesn't really check for out
352 // of disk space, but check it anyway. 352 // of disk space, but check it anyway.
353 if ( !lnk->writeLink() ) { 353 if ( !lnk->writeLink() ) {
354 QMessageBox::critical( 0, tr("Out of space"), 354 QMessageBox::critical( 0, tr("Out of space"),
355 tr( "There was a problem saving " 355 tr( "There was a problem saving "
356 "the playlist.\n" 356 "the playlist.\n"
357 "Your playlist " 357 "Your playlist "
358 "may be missing some entries\n" 358 "may be missing some entries\n"
359 "the next time you start it." ) 359 "the next time you start it." )
360 ); 360 );
361 } 361 }
362 } 362 }
363 noOfFiles++; 363 noOfFiles++;
364 } 364 }
365 } while ( d->selectedFiles->next() ); 365 } while ( d->selectedFiles->next() );
366 366
367 cfg.writeEntry("NumberOfFiles", noOfFiles ); 367 cfg.writeEntry("NumberOfFiles", noOfFiles );
368 368
369 369
370} 370}
371 371
372 372
373void PlayListWidget::addToSelection( const DocLnk& lnk ) { 373void PlayListWidget::addToSelection( const DocLnk& lnk ) {
374 qDebug("add"); 374 qDebug("add");
375 d->setDocumentUsed = FALSE; 375 d->setDocumentUsed = FALSE;
376 if ( mediaPlayerState->playlist() ) 376 if ( mediaPlayerState->playlist() )
377 d->selectedFiles->addToSelection( lnk ); 377 d->selectedFiles->addToSelection( lnk );
378 else 378 else
379 mediaPlayerState->setPlaying( TRUE ); 379 mediaPlayerState->setPlaying( TRUE );
380} 380}
381 381
382 382
383void PlayListWidget::clearList() { 383void PlayListWidget::clearList() {
384 while ( first() ) 384 while ( first() )
385 d->selectedFiles->removeSelected(); 385 d->selectedFiles->removeSelected();
386} 386}
387 387
388 388
389void PlayListWidget::addAllToList() { 389void PlayListWidget::addAllToList() {
390 DocLnkSet files; 390 DocLnkSet files;
391 Global::findDocuments(&files, "video/*;audio/*"); 391 Global::findDocuments(&files, "video/*;audio/*");
392 QListIterator<DocLnk> dit( files.children() ); 392 QListIterator<DocLnk> dit( files.children() );
393 for ( ; dit.current(); ++dit ) 393 for ( ; dit.current(); ++dit )
394 d->selectedFiles->addToSelection( **dit ); 394 d->selectedFiles->addToSelection( **dit );
395} 395}
396 396
397 397
398void PlayListWidget::addAllMusicToList() { 398void PlayListWidget::addAllMusicToList() {
399 DocLnkSet files; 399 DocLnkSet files;
400 Global::findDocuments(&files, "audio/*"); 400 Global::findDocuments(&files, "audio/*");
401 QListIterator<DocLnk> dit( files.children() ); 401 QListIterator<DocLnk> dit( files.children() );
402 for ( ; dit.current(); ++dit ) 402 for ( ; dit.current(); ++dit )
403 d->selectedFiles->addToSelection( **dit ); 403 d->selectedFiles->addToSelection( **dit );
404} 404}
405 405
406 406
407void PlayListWidget::addAllVideoToList() { 407void PlayListWidget::addAllVideoToList() {
408 DocLnkSet files; 408 DocLnkSet files;
409 Global::findDocuments(&files, "video/*"); 409 Global::findDocuments(&files, "video/*");
410 QListIterator<DocLnk> dit( files.children() ); 410 QListIterator<DocLnk> dit( files.children() );
411 for ( ; dit.current(); ++dit ) 411 for ( ; dit.current(); ++dit )
412 d->selectedFiles->addToSelection( **dit ); 412 d->selectedFiles->addToSelection( **dit );
413} 413}
414 414
415 415
416void PlayListWidget::setDocument(const QString& fileref) { 416void PlayListWidget::setDocument(const QString& fileref) {
417 if ( fileref.isNull() ) { 417 if ( fileref.isNull() ) {
418 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); 418 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) );
419 return; 419 return;
420 } 420 }
421 if ( mediaPlayerState->playlist() ) 421 if ( mediaPlayerState->playlist() )
422 addToSelection( DocLnk( fileref ) ); 422 addToSelection( DocLnk( fileref ) );
423 else { 423 else {
424 d->setDocumentUsed = TRUE; 424 d->setDocumentUsed = TRUE;
425 if ( d->current ) 425 if ( d->current )
426 delete d->current; 426 delete d->current;
427 d->current = new DocLnk( fileref ); 427 d->current = new DocLnk( fileref );
428 } 428 }
429 mediaPlayerState->setPlaying( FALSE ); 429 mediaPlayerState->setPlaying( FALSE );
430 mediaPlayerState->setPlaying( TRUE ); 430 mediaPlayerState->setPlaying( TRUE );
431} 431}
432 432
433 433
434void PlayListWidget::setActiveWindow() { 434void PlayListWidget::setActiveWindow() {
435 // When we get raised we need to ensure that it switches views 435 // When we get raised we need to ensure that it switches views
436 char origView = mediaPlayerState->view(); 436 char origView = mediaPlayerState->view();
437 mediaPlayerState->setView( 'l' ); // invalidate 437 mediaPlayerState->setView( 'l' ); // invalidate
438 mediaPlayerState->setView( origView ); // now switch back 438 mediaPlayerState->setView( origView ); // now switch back
439} 439}
440 440
441 441
442void PlayListWidget::useSelectedDocument() { 442void PlayListWidget::useSelectedDocument() {
443 d->setDocumentUsed = FALSE; 443 d->setDocumentUsed = FALSE;
444} 444}
445 445
446 446
447const DocLnk *PlayListWidget::current() { 447const DocLnk *PlayListWidget::current() {
448 448
449// qDebug("in Playlist widget ::current"); 449// qDebug("in Playlist widget ::current");
450 if ( mediaPlayerState->playlist() ) { 450 if ( mediaPlayerState->playlist() ) {
451 return d->selectedFiles->current(); 451 return d->selectedFiles->current();
452 } 452 }
453 else if ( d->setDocumentUsed && d->current ) { 453 else if ( d->setDocumentUsed && d->current ) {
454 return d->current; 454 return d->current;
455 } else { 455 } else {
456 return d->files->selected(); 456 return d->files->selected();
457 } 457 }
458} 458}
459 459
460 460
461bool PlayListWidget::prev() { 461bool PlayListWidget::prev() {
462 if ( mediaPlayerState->playlist() ) { 462 if ( mediaPlayerState->playlist() ) {
463 if ( mediaPlayerState->shuffled() ) { 463 if ( mediaPlayerState->shuffled() ) {
464 const DocLnk *cur = current(); 464 const DocLnk *cur = current();
465 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 465 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
466 for ( int i = 0; i < j; i++ ) { 466 for ( int i = 0; i < j; i++ ) {
467 if ( !d->selectedFiles->next() ) 467 if ( !d->selectedFiles->next() )
468 d->selectedFiles->first(); 468 d->selectedFiles->first();
469 } 469 }
470 if ( cur == current() ) 470 if ( cur == current() )
471 if ( !d->selectedFiles->next() ) 471 if ( !d->selectedFiles->next() )
472 d->selectedFiles->first(); 472 d->selectedFiles->first();
473 return TRUE; 473 return TRUE;
474 } else { 474 } else {
475 if ( !d->selectedFiles->prev() ) { 475 if ( !d->selectedFiles->prev() ) {
476 if ( mediaPlayerState->looping() ) { 476 if ( mediaPlayerState->looping() ) {
477 return d->selectedFiles->last(); 477 return d->selectedFiles->last();
478 } else { 478 } else {
479 return FALSE; 479 return FALSE;
480 } 480 }
481 } 481 }
482 return TRUE; 482 return TRUE;
483 } 483 }
484 } else { 484 } else {
485 return mediaPlayerState->looping(); 485 return mediaPlayerState->looping();
486 } 486 }
487} 487}
488 488
489 489
490bool PlayListWidget::next() { 490bool PlayListWidget::next() {
491 if ( mediaPlayerState->playlist() ) { 491 if ( mediaPlayerState->playlist() ) {
492 if ( mediaPlayerState->shuffled() ) { 492 if ( mediaPlayerState->shuffled() ) {
493 return prev(); 493 return prev();
494 } else { 494 } else {
495 if ( !d->selectedFiles->next() ) { 495 if ( !d->selectedFiles->next() ) {
496 if ( mediaPlayerState->looping() ) { 496 if ( mediaPlayerState->looping() ) {
497 return d->selectedFiles->first(); 497 return d->selectedFiles->first();
498 } else { 498 } else {
499 return FALSE; 499 return FALSE;
500 } 500 }
501 } 501 }
502 return TRUE; 502 return TRUE;
503 } 503 }
504 } else { 504 } else {
505 return mediaPlayerState->looping(); 505 return mediaPlayerState->looping();
506 } 506 }
507} 507}
508 508
509 509
510bool PlayListWidget::first() { 510bool PlayListWidget::first() {
511 if ( mediaPlayerState->playlist() ) 511 if ( mediaPlayerState->playlist() )
512 return d->selectedFiles->first(); 512 return d->selectedFiles->first();
513 else 513 else
514 return mediaPlayerState->looping(); 514 return mediaPlayerState->looping();
515} 515}
516 516
517 517
518bool PlayListWidget::last() { 518bool PlayListWidget::last() {
519 if ( mediaPlayerState->playlist() ) 519 if ( mediaPlayerState->playlist() )
520 return d->selectedFiles->last(); 520 return d->selectedFiles->last();
521 else 521 else
522 return mediaPlayerState->looping(); 522 return mediaPlayerState->looping();
523} 523}
524 524
525 525
526void PlayListWidget::saveList() { 526void PlayListWidget::saveList() {
527 527
528 QString filename; 528 QString filename;
529 InputDialog *fileDlg; 529 InputDialog *fileDlg;
530 fileDlg=new InputDialog(this,"Save Playlist",TRUE, 0); 530 fileDlg=new InputDialog(this,"Save Playlist",TRUE, 0);
531 fileDlg->exec(); 531 fileDlg->exec();
532 if( fileDlg->result() == 1 ) { 532 if( fileDlg->result() == 1 ) {
533 filename = fileDlg->LineEdit1->text();//+".playlist"; 533 filename = fileDlg->LineEdit1->text();//+".playlist";
534 qDebug("saving playlist "+filename+".playlist"); 534 qDebug("saving playlist "+filename+".playlist");
535 535
536// DocLnk *lnk; 536// DocLnk *lnk;
537// lnk.setName( filename); //sets file name 537// lnk.setName( filename); //sets file name
538// // lnk.setComment(title); 538// // lnk.setComment(title);
539// lnk.setFile( filename+".playlist"); //sets File property 539// lnk.setFile( filename+".playlist"); //sets File property
540// lnk.setType("player/plain");// hey is this a REGISTERED mime type?!?!? ;D 540// lnk.setType("player/plain");// hey is this a REGISTERED mime type?!?!? ;D
541// lnk.setIcon("MPEGPlayer"); 541// lnk.setIcon("MPEGPlayer");
542// if(!lnk.writeLink()) 542// if(!lnk.writeLink())
543// qDebug("Writing doclink did not work"); 543// qDebug("Writing doclink did not work");
544 544
545 Config cfg( filename +".playlist"); 545 Config cfg( filename +".playlist");
546 writeConfig( cfg ); 546 writeConfig( cfg );
547 } 547 }
548 DocLnk lnk; 548 DocLnk lnk;
549 lnk.setName( filename); //sets file name 549 lnk.setName( filename); //sets file name
550// lnk.setComment(title); 550// lnk.setComment(title);
551 lnk.setFile(QPEApplication::qpeDir()+"Settings/"+filename+".playlist.conf"); //sets File property 551 lnk.setFile(QPEApplication::qpeDir()+"Settings/"+filename+".playlist.conf"); //sets File property
552 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D 552 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D
553 lnk.setIcon("MPEGPlayer"); 553 lnk.setIcon("MPEGPlayer");
554 if(!lnk.writeLink()) 554 if(!lnk.writeLink())
555 qDebug("Writing doclink did not work"); 555 qDebug("Writing doclink did not work");
556 556
557 if(fileDlg) 557 if(fileDlg)
558 delete fileDlg; 558 delete fileDlg;
559} 559}
560 560
561 561
562void PlayListWidget::loadList( const DocLnk & lnk) { 562void PlayListWidget::loadList( const DocLnk & lnk) {
563 qDebug("load list "+ lnk.name()+".playlist"); 563 qDebug("load list "+ lnk.name()+".playlist");
564 clearList(); 564 clearList();
565 Config cfg( lnk.name()+".playlist"); 565 Config cfg( lnk.name()+".playlist");
566 readConfig(cfg); 566 readConfig(cfg);
567 tabWidget->setCurrentPage(0); 567 tabWidget->setCurrentPage(0);
568 setCaption("OpiePlayer: "+lnk.name()); 568 setCaption("OpiePlayer: "+lnk.name());
569} 569}
570 570
571 571
572void PlayListWidget::setPlaylist( bool shown ) { 572void PlayListWidget::setPlaylist( bool shown ) {
573 if ( shown ) 573 if ( shown )
574 d->playListFrame->show(); 574 d->playListFrame->show();
575 else 575 else
576 d->playListFrame->hide(); 576 d->playListFrame->hide();
577} 577}
578 578
579 579
580void PlayListWidget::setView( char view ) { 580void PlayListWidget::setView( char view ) {
581 if ( view == 'l' ) 581 if ( view == 'l' )
582 showMaximized(); 582 showMaximized();
583 else 583 else
584 hide(); 584 hide();
585} 585}
586 586
587void PlayListWidget::addSelected() { 587void PlayListWidget::addSelected() {
588 588
589 switch (tabWidget->currentPageIndex()) { 589 switch (tabWidget->currentPageIndex()) {
590 case 0: //playlist 590 case 0: //playlist
591 break; 591 break;
592 case 1: { //audio 592 case 1: { //audio
593 addToSelection( audioView->selectedItem() ); 593 addToSelection( audioView->selectedItem() );
594 } 594 }
595 break; 595 break;
596 case 2: { // video 596 case 2: { // video
597 addToSelection( videoView->selectedItem() ); 597 addToSelection( videoView->selectedItem() );
598 } 598 }
599 break; 599 break;
600 }; 600 };
601} 601}
602 602
603void PlayListWidget::removeSelected() { 603void PlayListWidget::removeSelected() {
604 d->selectedFiles->removeSelected( ); 604 d->selectedFiles->removeSelected( );
605} 605}
606 606
607 607
608void PlayListWidget::playIt( QListViewItem *it) { 608void PlayListWidget::playIt( QListViewItem *it) {
609// d->setDocumentUsed = FALSE; 609// d->setDocumentUsed = FALSE;
610 mediaPlayerState->setPlaying(TRUE); 610 mediaPlayerState->setPlaying(TRUE);
611} 611}
612 612
613void PlayListWidget::addToSelection( QListViewItem *it) { 613void PlayListWidget::addToSelection( QListViewItem *it) {
614 d->setDocumentUsed = FALSE; 614 d->setDocumentUsed = FALSE;
615 615
616 if(it) { 616 if(it) {
617// qDebug("add to selection"); 617// qDebug("add to selection");
618 switch (tabWidget->currentPageIndex()) { 618 switch (tabWidget->currentPageIndex()) {
619 case 1: { 619 case 1: {
620// qDebug("case 1"); 620// qDebug("case 1");
621 QListIterator<DocLnk> dit( files.children() ); 621 QListIterator<DocLnk> dit( files.children() );
622 for ( ; dit.current(); ++dit ) { 622 for ( ; dit.current(); ++dit ) {
623// qDebug(dit.current()->name()); 623// qDebug(dit.current()->name());
624 if( dit.current()->name() == it->text(0)) { 624 if( dit.current()->name() == it->text(0)) {
625 d->selectedFiles->addToSelection( **dit ); 625 d->selectedFiles->addToSelection( **dit );
626 } 626 }
627 } 627 }
628 } 628 }
629 break; 629 break;
630 case 2: { 630 case 2: {
631// qDebug("case 2"); 631// qDebug("case 2");
632 QListIterator<DocLnk> dit( vFiles.children() ); 632 QListIterator<DocLnk> dit( vFiles.children() );
633 for ( ; dit.current(); ++dit ) { 633 for ( ; dit.current(); ++dit ) {
634// qDebug(dit.current()->name()); 634// qDebug(dit.current()->name());
635 if( dit.current()->name() == it->text(0)) { 635 if( dit.current()->name() == it->text(0)) {
636 d->selectedFiles->addToSelection( **dit ); 636 d->selectedFiles->addToSelection( **dit );
637 } 637 }
638 } 638 }
639 } 639 }
640 break; 640 break;
641 case 0: 641 case 0:
642 break; 642 break;
643 }; 643 };
644 tabWidget->setCurrentPage(0); 644 tabWidget->setCurrentPage(0);
645// mediaPlayerState->setPlaying( TRUE ); 645// mediaPlayerState->setPlaying( TRUE );
646 } 646 }
647} 647}
648 648
649void PlayListWidget::tabChanged(QWidget *widg) { 649void PlayListWidget::tabChanged(QWidget *widg) {
650 650
651 switch ( tabWidget->currentPageIndex()) { 651 switch ( tabWidget->currentPageIndex()) {
652 case 0: 652 case 0:
653 { 653 {
654 if( !tbDeletePlaylist->isHidden()) 654 if( !tbDeletePlaylist->isHidden())
655 tbDeletePlaylist->hide(); 655 tbDeletePlaylist->hide();
656 d->tbRemoveFromList->setEnabled(TRUE); 656 d->tbRemoveFromList->setEnabled(TRUE);
657 d->tbAddToList->setEnabled(FALSE); 657 d->tbAddToList->setEnabled(FALSE);
658 } 658 }
659 break; 659 break;
660 case 1: 660 case 1:
661 { 661 {
662 if( !tbDeletePlaylist->isHidden()) 662 if( !tbDeletePlaylist->isHidden())
663 tbDeletePlaylist->hide(); 663 tbDeletePlaylist->hide();
664 d->tbRemoveFromList->setEnabled(FALSE); 664 d->tbRemoveFromList->setEnabled(FALSE);
665 d->tbAddToList->setEnabled(TRUE); 665 d->tbAddToList->setEnabled(TRUE);
666 } 666 }
667 break; 667 break;
668 case 2: 668 case 2:
669 { 669 {
670 if( !tbDeletePlaylist->isHidden()) 670 if( !tbDeletePlaylist->isHidden())
671 tbDeletePlaylist->hide(); 671 tbDeletePlaylist->hide();
672 d->tbRemoveFromList->setEnabled(FALSE); 672 d->tbRemoveFromList->setEnabled(FALSE);
673 d->tbAddToList->setEnabled(TRUE); 673 d->tbAddToList->setEnabled(TRUE);
674 } 674 }
675 break; 675 break;
676 case 3: 676 case 3:
677 { 677 {
678 if( tbDeletePlaylist->isHidden()) 678 if( tbDeletePlaylist->isHidden())
679 tbDeletePlaylist->show(); 679 tbDeletePlaylist->show();
680 playLists->reread(); 680 playLists->reread();
681 } 681 }
682 break; 682 break;
683 }; 683 };
684} 684}
685 685
686/* 686/*
687 list is right clicked*/ 687 list is right clicked*/
688void PlayListWidget::fauxPlay(QListViewItem *it) { 688void PlayListWidget::fauxPlay(QListViewItem *it) {
689 689
690 switch (tabWidget->currentPageIndex()) { 690 switch (tabWidget->currentPageIndex()) {
691 case 0: //playlist 691 case 0: //playlist
692 break; 692 break;
693 case 1: { //audio 693 case 1: { //audio
694 QListIterator<DocLnk> dit( files.children() ); 694 QListIterator<DocLnk> dit( files.children() );
695 for ( ; dit.current(); ++dit ) { 695 for ( ; dit.current(); ++dit ) {
696// qDebug(dit.current()->name()); 696// qDebug(dit.current()->name());
697 if( dit.current()->name() == it->text(0)) { 697 if( dit.current()->name() == it->text(0)) {
698 d->selectedFiles->addToSelection( **dit ); 698 d->selectedFiles->addToSelection( **dit );
699 } 699 }
700 } 700 }
701 } 701 }
702 break; 702 break;
703 case 2: { // video 703 case 2: { // video
704 QListIterator<DocLnk> dit( vFiles.children() ); 704 QListIterator<DocLnk> dit( vFiles.children() );
705 for ( ; dit.current(); ++dit ) { 705 for ( ; dit.current(); ++dit ) {
706// qDebug(dit.current()->name()); 706// qDebug(dit.current()->name());
707 if( dit.current()->name() == it->text(0)) { 707 if( dit.current()->name() == it->text(0)) {
708 d->selectedFiles->addToSelection( **dit ); 708 d->selectedFiles->addToSelection( **dit );
709 } 709 }
710 } 710 }
711 } 711 }
712 break; 712 break;
713 }; 713 };
714 mediaPlayerState->setPlaying( TRUE ); 714 mediaPlayerState->setPlaying( TRUE );
715// tabWidget->setCurrentPage(0); 715// tabWidget->setCurrentPage(0);
716 d->selectedFiles->removeSelected(); 716 d->selectedFiles->removeSelected();
717} 717}
718 718
719/* 719/*
720 play button is pressed*/ 720 play button is pressed*/
721void PlayListWidget::btnPlay(bool b) { // this is fugly 721void PlayListWidget::btnPlay(bool b) { // this is fugly
722 switch ( tabWidget->currentPageIndex()) { 722 switch ( tabWidget->currentPageIndex()) {
723 case 0: 723 case 0:
724 { 724 {
725 mediaPlayerState->setPlaying(b); 725 mediaPlayerState->setPlaying(b);
726 } 726 }
727 break; 727 break;
728 case 1: 728 case 1:
729 { 729 {
730 addToSelection( audioView->selectedItem() ); 730 addToSelection( audioView->selectedItem() );
731 mediaPlayerState->setPlaying(b); 731 mediaPlayerState->setPlaying(b);
732 qApp->processEvents();
732 d->selectedFiles->removeSelected( ); 733 d->selectedFiles->removeSelected( );
733 tabWidget->setCurrentPage(1); 734 tabWidget->setCurrentPage(1);
734 } 735 }
735 break; 736 break;
736 case 2: 737 case 2:
737 { 738 {
738 addToSelection( videoView->selectedItem() ); 739 addToSelection( videoView->selectedItem() );
739 mediaPlayerState->setPlaying(b); 740 mediaPlayerState->setPlaying(b);
741 qApp->processEvents();
740 d->selectedFiles->removeSelected( ); 742 d->selectedFiles->removeSelected( );
741 tabWidget->setCurrentPage(2); 743 tabWidget->setCurrentPage(2);
742 } 744 }
743 break; 745 break;
744 }; 746 };
745 747
746} 748}
747 749
748void PlayListWidget::deletePlaylist() { 750void PlayListWidget::deletePlaylist() {
749 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 751 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
750 (tr("You really want to delete\nthis playlist?")), 752 (tr("You really want to delete\nthis playlist?")),
751 (tr("Yes")), (tr("No")), 0 )){ 753 (tr("Yes")), (tr("No")), 0 )){
752 case 0: // Yes clicked, 754 case 0: // Yes clicked,
753 QFile().remove(playLists->selected()->file()); 755 QFile().remove(playLists->selected()->file());
754 QFile().remove(playLists->selected()->linkFile()); 756 QFile().remove(playLists->selected()->linkFile());
755 playLists->reread(); 757 playLists->reread();
756 break; 758 break;
757 case 1: // Cancel 759 case 1: // Cancel
758 break; 760 break;
759 }; 761 };
760 762
761} 763}