summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-09-11 00:51:09 (UTC)
committer llornkcor <llornkcor>2002-09-11 00:51:09 (UTC)
commit6013fac8a6ea871453565faf0f8b51c62465cf71 (patch) (unidiff)
treee93c0418bef8bd0f1ebcbd8dda42111ba4aeefba
parentd478be344e2ba383a1e38d2a1705de1cdbe2e838 (diff)
downloadopie-6013fac8a6ea871453565faf0f8b51c62465cf71.zip
opie-6013fac8a6ea871453565faf0f8b51c62465cf71.tar.gz
opie-6013fac8a6ea871453565faf0f8b51c62465cf71.tar.bz2
fix for 2.3.4
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp39
1 files changed, 5 insertions, 34 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 8d66407..5be0d6d 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -224,257 +224,227 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
224 224
225 225
226 226
227 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch 227 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
228 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); 228 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) );
229 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); 229 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) );
230 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); 230 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) );
231 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch 231 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
232 232
233 QWidget *aTab; 233 QWidget *aTab;
234 aTab = new QWidget( tabWidget, "aTab" ); 234 aTab = new QWidget( tabWidget, "aTab" );
235 audioView = new QListView( aTab, "Audioview" ); 235 audioView = new QListView( aTab, "Audioview" );
236 audioView->setMinimumSize(233,260); 236 audioView->setMinimumSize(233,260);
237 audioView->addColumn( tr("Title"),140); 237 audioView->addColumn( tr("Title"),140);
238 audioView->addColumn(tr("Size"), -1); 238 audioView->addColumn(tr("Size"), -1);
239 audioView->addColumn(tr("Media"),-1); 239 audioView->addColumn(tr("Media"),-1);
240 audioView->setColumnAlignment(1, Qt::AlignRight); 240 audioView->setColumnAlignment(1, Qt::AlignRight);
241 audioView->setColumnAlignment(2, Qt::AlignRight); 241 audioView->setColumnAlignment(2, Qt::AlignRight);
242 audioView->setAllColumnsShowFocus(TRUE); 242 audioView->setAllColumnsShowFocus(TRUE);
243 243
244 audioView->setMultiSelection( TRUE ); 244 audioView->setMultiSelection( TRUE );
245 audioView->setSelectionMode( QListView::Extended); 245 audioView->setSelectionMode( QListView::Extended);
246 246
247 tabWidget->insertTab(aTab,tr("Audio")); 247 tabWidget->insertTab(aTab,tr("Audio"));
248 248
249 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); 249 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold);
250 250
251// audioView 251// audioView
252// populateAudioView(); 252// populateAudioView();
253// videowidget 253// videowidget
254 254
255 QWidget *vTab; 255 QWidget *vTab;
256 vTab = new QWidget( tabWidget, "vTab" ); 256 vTab = new QWidget( tabWidget, "vTab" );
257 videoView = new QListView( vTab, "Videoview" ); 257 videoView = new QListView( vTab, "Videoview" );
258 videoView->setMinimumSize(233,260); 258 videoView->setMinimumSize(233,260);
259 259
260 videoView->addColumn(tr("Title"),140); 260 videoView->addColumn(tr("Title"),140);
261 videoView->addColumn(tr("Size"),-1); 261 videoView->addColumn(tr("Size"),-1);
262 videoView->addColumn(tr("Media"),-1); 262 videoView->addColumn(tr("Media"),-1);
263 videoView->setColumnAlignment(1, Qt::AlignRight); 263 videoView->setColumnAlignment(1, Qt::AlignRight);
264 videoView->setColumnAlignment(2, Qt::AlignRight); 264 videoView->setColumnAlignment(2, Qt::AlignRight);
265 videoView->setAllColumnsShowFocus(TRUE); 265 videoView->setAllColumnsShowFocus(TRUE);
266 videoView->setMultiSelection( TRUE ); 266 videoView->setMultiSelection( TRUE );
267 videoView->setSelectionMode( QListView::Extended); 267 videoView->setSelectionMode( QListView::Extended);
268 268
269 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); 269 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold);
270 270
271 tabWidget->insertTab( vTab,tr("Video")); 271 tabWidget->insertTab( vTab,tr("Video"));
272// populateVideoView();
273 272
274//playlists list
275 QWidget *LTab; 273 QWidget *LTab;
276 LTab = new QWidget( tabWidget, "LTab" ); 274 LTab = new QWidget( tabWidget, "LTab" );
277 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy 275 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy
278 playLists->setMinimumSize(233,260); 276 playLists->setMinimumSize(233,260);
279 tabWidget->insertTab(LTab,tr("Lists")); 277 tabWidget->insertTab(LTab,tr("Lists"));
280 278
281// connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) );
282
283// add the library area
284
285// connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)),
286// this, SLOT( fauxPlay( QListViewItem *) ) );
287// connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)),
288// this, SLOT( fauxPlay( QListViewItem *)) );
289
290// connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) );
291// connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) );
292
293 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); 279 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist()));
294 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); 280 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) );
295 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); 281 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) );
296 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 282 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
297 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); 283 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) );
298 284
299 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 285 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
300 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 286 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
301 287
302 connect( audioView, SIGNAL( returnPressed( QListViewItem *)), 288 connect( audioView, SIGNAL( returnPressed( QListViewItem *)),
303 this,SLOT( playIt( QListViewItem *)) ); 289 this,SLOT( playIt( QListViewItem *)) );
304 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 290 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
305 291
306 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 292 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
307 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 293 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
308 connect( videoView, SIGNAL( returnPressed( QListViewItem *)), 294 connect( videoView, SIGNAL( returnPressed( QListViewItem *)),
309 this,SLOT( playIt( QListViewItem *)) ); 295 this,SLOT( playIt( QListViewItem *)) );
310 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 296 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
311 297
312 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); 298 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
313 299
314 300
315 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); 301 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
316 302
317 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); 303 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
318 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); 304 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
319 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); 305 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
320 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); 306 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
321 307
322 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 308 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
323// connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) );
324 309
325 setCentralWidget( vbox5 ); 310 setCentralWidget( vbox5 );
326 311
327 Config cfg( "OpiePlayer" ); 312 Config cfg( "OpiePlayer" );
328 readConfig( cfg ); 313 readConfig( cfg );
329 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 314 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
330// qDebug("currentList is "+currentPlaylist);
331 loadList(DocLnk( currentPlaylist)); 315 loadList(DocLnk( currentPlaylist));
332 setCaption(tr("OpiePlayer: ")+ currentPlaylist ); 316 setCaption(tr("OpiePlayer: ")+ currentPlaylist );
333 317
334 initializeStates(); 318 initializeStates();
335} 319}
336 320
337 321
338PlayListWidget::~PlayListWidget() { 322PlayListWidget::~PlayListWidget() {
339 Config cfg( "OpiePlayer" ); 323 Config cfg( "OpiePlayer" );
340 writeConfig( cfg ); 324 writeConfig( cfg );
341 325
342 326
343 if ( d->current ) 327 if ( d->current )
344 delete d->current; 328 delete d->current;
345 delete d; 329 delete d;
346} 330}
347 331
348 332
349void PlayListWidget::initializeStates() { 333void PlayListWidget::initializeStates() {
350 334
351 d->tbPlay->setOn( mediaPlayerState->playing() ); 335 d->tbPlay->setOn( mediaPlayerState->playing() );
352 d->tbLoop->setOn( mediaPlayerState->looping() ); 336 d->tbLoop->setOn( mediaPlayerState->looping() );
353 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 337 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
354// d->tbFull->setOn( mediaPlayerState->fullscreen() );
355// d->tbScale->setOn( mediaPlayerState->scaled() );
356// d->tbScale->setEnabled( mediaPlayerState->fullscreen() );
357// setPlaylist( mediaPlayerState->playlist() );
358 setPlaylist( true); 338 setPlaylist( true);
359// d->selectedFiles->first();
360
361} 339}
362 340
363 341
364void PlayListWidget::readConfig( Config& cfg ) { 342void PlayListWidget::readConfig( Config& cfg ) {
365 cfg.setGroup("PlayList"); 343 cfg.setGroup("PlayList");
366 QString currentString = cfg.readEntry("current", "" ); 344 QString currentString = cfg.readEntry("current", "" );
367 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 345 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
368 for ( int i = 0; i < noOfFiles; i++ ) { 346 for ( int i = 0; i < noOfFiles; i++ ) {
369 QString entryName; 347 QString entryName;
370 entryName.sprintf( "File%i", i + 1 ); 348 entryName.sprintf( "File%i", i + 1 );
371 QString linkFile = cfg.readEntry( entryName ); 349 QString linkFile = cfg.readEntry( entryName );
372 DocLnk lnk( linkFile ); 350 DocLnk lnk( linkFile );
373 if ( lnk.isValid() ) { 351 if ( lnk.isValid() ) {
374 d->selectedFiles->addToSelection( lnk ); 352 d->selectedFiles->addToSelection( lnk );
375 } 353 }
376 } 354 }
377 d->selectedFiles->setSelectedItem( currentString); 355 d->selectedFiles->setSelectedItem( currentString);
378// d->selectedFiles->setSelectedItem( (const QString &)currentString);
379} 356}
380 357
381 358
382void PlayListWidget::writeConfig( Config& cfg ) const { 359void PlayListWidget::writeConfig( Config& cfg ) const {
383 360
384 d->selectedFiles->writeCurrent( cfg); 361 d->selectedFiles->writeCurrent( cfg);
385 cfg.setGroup("PlayList"); 362 cfg.setGroup("PlayList");
386 int noOfFiles = 0; 363 int noOfFiles = 0;
387 d->selectedFiles->first(); 364 d->selectedFiles->first();
388 do { 365 do {
389 const DocLnk *lnk = d->selectedFiles->current(); 366 const DocLnk *lnk = d->selectedFiles->current();
390 if ( lnk ) { 367 if ( lnk ) {
391 QString entryName; 368 QString entryName;
392 entryName.sprintf( "File%i", noOfFiles + 1 ); 369 entryName.sprintf( "File%i", noOfFiles + 1 );
393// qDebug(entryName); 370// qDebug(entryName);
394 cfg.writeEntry( entryName, lnk->linkFile() ); 371 cfg.writeEntry( entryName, lnk->linkFile() );
395 // if this link does exist, add it so we have the file 372 // if this link does exist, add it so we have the file
396 // next time... 373 // next time...
397 if ( !QFile::exists( lnk->linkFile() ) ) { 374 if ( !QFile::exists( lnk->linkFile() ) ) {
398 // the way writing lnks doesn't really check for out 375 // the way writing lnks doesn't really check for out
399 // of disk space, but check it anyway. 376 // of disk space, but check it anyway.
400 if ( !lnk->writeLink() ) { 377 if ( !lnk->writeLink() ) {
401 QMessageBox::critical( 0, tr("Out of space"), 378 QMessageBox::critical( 0, tr("Out of space"),
402 tr( "There was a problem saving " 379 tr( "There was a problem saving "
403 "the playlist.\n" 380 "the playlist.\n"
404 "Your playlist " 381 "Your playlist "
405 "may be missing some entries\n" 382 "may be missing some entries\n"
406 "the next time you start it." ) 383 "the next time you start it." )
407 ); 384 );
408 } 385 }
409 } 386 }
410 noOfFiles++; 387 noOfFiles++;
411 } 388 }
412 } 389 }
413 while ( d->selectedFiles->next() ); 390 while ( d->selectedFiles->next() );
414 cfg.writeEntry("NumberOfFiles", noOfFiles ); 391 cfg.writeEntry("NumberOfFiles", noOfFiles );
415} 392}
416 393
417 394
418void PlayListWidget::addToSelection( const DocLnk& lnk ) { 395void PlayListWidget::addToSelection( const DocLnk& lnk ) {
419// qDebug("add");
420// if( lnk.file().find(" ",0,TRUE) != -1 || lnk.file().find("%20",0,TRUE) != -1) {
421// QMessageBox::message("Note","You are trying to play\na malformed url.");
422
423// } else {
424
425 d->setDocumentUsed = FALSE; 396 d->setDocumentUsed = FALSE;
426 if ( mediaPlayerState->playlist() ) { 397 if ( mediaPlayerState->playlist() ) {
427 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) 398 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" )
428 d->selectedFiles->addToSelection( lnk ); 399 d->selectedFiles->addToSelection( lnk );
429 } 400 }
430 else 401 else
431 mediaPlayerState->setPlaying( TRUE ); 402 mediaPlayerState->setPlaying( TRUE );
432// }
433} 403}
434 404
435 405
436void PlayListWidget::clearList() { 406void PlayListWidget::clearList() {
437 while ( first() ) 407 while ( first() )
438 d->selectedFiles->removeSelected(); 408 d->selectedFiles->removeSelected();
439} 409}
440 410
441 411
442void PlayListWidget::addAllToList() { 412void PlayListWidget::addAllToList() {
443 DocLnkSet filesAll; 413 DocLnkSet filesAll;
444 Global::findDocuments(&filesAll, "video/*;audio/*"); 414 Global::findDocuments(&filesAll, "video/*;audio/*");
445 QListIterator<DocLnk> Adit( filesAll.children() ); 415 QListIterator<DocLnk> Adit( filesAll.children() );
446 for ( ; Adit.current(); ++Adit ) 416 for ( ; Adit.current(); ++Adit )
447 if(QFileInfo(Adit.current()->file()).exists()) 417 if(QFileInfo(Adit.current()->file()).exists())
448 d->selectedFiles->addToSelection( **Adit ); 418 d->selectedFiles->addToSelection( **Adit );
449} 419}
450 420
451 421
452void PlayListWidget::addAllMusicToList() { 422void PlayListWidget::addAllMusicToList() {
453 QListIterator<DocLnk> dit( files.children() ); 423 QListIterator<DocLnk> dit( files.children() );
454 for ( ; dit.current(); ++dit ) 424 for ( ; dit.current(); ++dit )
455 if(QFileInfo(dit.current()->file()).exists()) 425 if(QFileInfo(dit.current()->file()).exists())
456 d->selectedFiles->addToSelection( **dit ); 426 d->selectedFiles->addToSelection( **dit );
457} 427}
458 428
459 429
460void PlayListWidget::addAllVideoToList() { 430void PlayListWidget::addAllVideoToList() {
461 QListIterator<DocLnk> dit( vFiles.children() ); 431 QListIterator<DocLnk> dit( vFiles.children() );
462 for ( ; dit.current(); ++dit ) 432 for ( ; dit.current(); ++dit )
463 if(QFileInfo( dit.current()->file()).exists()) 433 if(QFileInfo( dit.current()->file()).exists())
464 d->selectedFiles->addToSelection( **dit ); 434 d->selectedFiles->addToSelection( **dit );
465} 435}
466 436
467 437
468void PlayListWidget::setDocument(const QString& fileref) { 438void PlayListWidget::setDocument(const QString& fileref) {
469 qDebug(fileref); 439 qDebug(fileref);
470 fromSetDocument = TRUE; 440 fromSetDocument = TRUE;
471 if ( fileref.isNull() ) { 441 if ( fileref.isNull() ) {
472 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); 442 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) );
473 return; 443 return;
474 } 444 }
475// qDebug("setDocument "+fileref); 445// qDebug("setDocument "+fileref);
476 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u 446 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u
477 readm3u( fileref); 447 readm3u( fileref);
478 } 448 }
479 else if(fileref.find("pls",0,TRUE) != -1) { //is pls 449 else if(fileref.find("pls",0,TRUE) != -1) { //is pls
480 readPls( fileref); 450 readPls( fileref);
@@ -492,97 +462,97 @@ void PlayListWidget::setDocument(const QString& fileref) {
492 mediaPlayerState->setPlaying( TRUE ); 462 mediaPlayerState->setPlaying( TRUE );
493 qApp->processEvents(); 463 qApp->processEvents();
494 setCaption(tr("OpiePlayer")); 464 setCaption(tr("OpiePlayer"));
495 } 465 }
496} 466}
497 467
498 468
499void PlayListWidget::setActiveWindow() { 469void PlayListWidget::setActiveWindow() {
500 qDebug("SETTING active window"); 470 qDebug("SETTING active window");
501 471
502 // When we get raised we need to ensure that it switches views 472 // When we get raised we need to ensure that it switches views
503 char origView = mediaPlayerState->view(); 473 char origView = mediaPlayerState->view();
504 mediaPlayerState->setView( 'l' ); // invalidate 474 mediaPlayerState->setView( 'l' ); // invalidate
505 mediaPlayerState->setView( origView ); // now switch back 475 mediaPlayerState->setView( origView ); // now switch back
506} 476}
507 477
508 478
509void PlayListWidget::useSelectedDocument() { 479void PlayListWidget::useSelectedDocument() {
510 d->setDocumentUsed = FALSE; 480 d->setDocumentUsed = FALSE;
511} 481}
512 482
513 483
514const DocLnk *PlayListWidget::current() { // this is fugly 484const DocLnk *PlayListWidget::current() { // this is fugly
515 485
516// if( fromSetDocument) { 486// if( fromSetDocument) {
517// qDebug("from setDoc"); 487// qDebug("from setDoc");
518// DocLnkSet files; 488// DocLnkSet files;
519// Global::findDocuments(&files, "video/*;audio/*"); 489// Global::findDocuments(&files, "video/*;audio/*");
520// QListIterator<DocLnk> dit( files.children() ); 490// QListIterator<DocLnk> dit( files.children() );
521// for ( ; dit.current(); ++dit ) { 491// for ( ; dit.current(); ++dit ) {
522// if(dit.current()->linkFile() == setDocFileRef) { 492// if(dit.current()->linkFile() == setDocFileRef) {
523// qDebug(setDocFileRef); 493// qDebug(setDocFileRef);
524// return dit; 494// return dit;
525// } 495// }
526// } 496// }
527// } else 497// } else
528 498
529 499
530 switch (tabWidget->currentPageIndex()) { 500 switch (tabWidget->currentPageIndex()) {
531 case 0: //playlist 501 case 0: //playlist
532 { 502 {
533 qDebug("playlist"); 503 qDebug("playlist");
534 if ( mediaPlayerState->playlist() ) { 504 if ( mediaPlayerState->playlist() ) {
535 return d->selectedFiles->current(); 505 return d->selectedFiles->current();
536 } 506 }
537 else if ( d->setDocumentUsed && d->current ) { 507 else if ( d->setDocumentUsed && d->current ) {
538 return d->current; 508 return d->current;
539 } else { 509 } else {
540 return d->files->selected(); 510 return &(d->files->selectedDocument());
541 } 511 }
542 } 512 }
543 break; 513 break;
544 case 1://audio 514 case 1://audio
545 { 515 {
546 qDebug("audioView"); 516 qDebug("audioView");
547 QListIterator<DocLnk> dit( files.children() ); 517 QListIterator<DocLnk> dit( files.children() );
548 for ( ; dit.current(); ++dit ) { 518 for ( ; dit.current(); ++dit ) {
549 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { 519 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) {
550 qDebug("here"); 520 qDebug("here");
551 insanityBool=TRUE; 521 insanityBool=TRUE;
552 return dit; 522 return dit;
553 } 523 }
554 } 524 }
555 } 525 }
556 break; 526 break;
557 case 2: // video 527 case 2: // video
558 { 528 {
559 qDebug("videoView"); 529 qDebug("videoView");
560 QListIterator<DocLnk> Vdit( vFiles.children() ); 530 QListIterator<DocLnk> Vdit( vFiles.children() );
561 for ( ; Vdit.current(); ++Vdit ) { 531 for ( ; Vdit.current(); ++Vdit ) {
562 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { 532 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) {
563 insanityBool=TRUE; 533 insanityBool=TRUE;
564 return Vdit; 534 return Vdit;
565 } 535 }
566 } 536 }
567 } 537 }
568 break; 538 break;
569 }; 539 };
570 return 0; 540 return 0;
571} 541}
572 542
573bool PlayListWidget::prev() { 543bool PlayListWidget::prev() {
574 if ( mediaPlayerState->playlist() ) { 544 if ( mediaPlayerState->playlist() ) {
575 if ( mediaPlayerState->shuffled() ) { 545 if ( mediaPlayerState->shuffled() ) {
576 const DocLnk *cur = current(); 546 const DocLnk *cur = current();
577 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 547 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
578 for ( int i = 0; i < j; i++ ) { 548 for ( int i = 0; i < j; i++ ) {
579 if ( !d->selectedFiles->next() ) 549 if ( !d->selectedFiles->next() )
580 d->selectedFiles->first(); 550 d->selectedFiles->first();
581 } 551 }
582 if ( cur == current() ) 552 if ( cur == current() )
583 if ( !d->selectedFiles->next() ) 553 if ( !d->selectedFiles->next() )
584 d->selectedFiles->first(); 554 d->selectedFiles->first();
585 return TRUE; 555 return TRUE;
586 } else { 556 } else {
587 if ( !d->selectedFiles->prev() ) { 557 if ( !d->selectedFiles->prev() ) {
588 if ( mediaPlayerState->looping() ) { 558 if ( mediaPlayerState->looping() ) {
@@ -848,99 +818,99 @@ void PlayListWidget::tabChanged(QWidget *widg) {
848 break; 818 break;
849 }; 819 };
850} 820}
851 821
852void PlayListWidget::btnPlay(bool b) { 822void PlayListWidget::btnPlay(bool b) {
853 823
854// mediaPlayerState->setPlaying(b); 824// mediaPlayerState->setPlaying(b);
855 switch ( tabWidget->currentPageIndex()) { 825 switch ( tabWidget->currentPageIndex()) {
856 case 0: 826 case 0:
857 { 827 {
858// if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 828// if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1
859// if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { 829// if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) {
860// QMessageBox::message("Note","You are trying to play\na malformed url."); 830// QMessageBox::message("Note","You are trying to play\na malformed url.");
861// } else { 831// } else {
862 mediaPlayerState->setPlaying(b); 832 mediaPlayerState->setPlaying(b);
863// } 833// }
864 } 834 }
865 break; 835 break;
866 case 1: 836 case 1:
867 { 837 {
868 addToSelection( audioView->currentItem() ); 838 addToSelection( audioView->currentItem() );
869 mediaPlayerState->setPlaying(b); 839 mediaPlayerState->setPlaying(b);
870 d->selectedFiles->removeSelected( ); 840 d->selectedFiles->removeSelected( );
871 tabWidget->setCurrentPage(1); 841 tabWidget->setCurrentPage(1);
872 d->selectedFiles->unSelect(); 842 d->selectedFiles->unSelect();
873 insanityBool=FALSE; 843 insanityBool=FALSE;
874 }// audioView->clearSelection(); 844 }// audioView->clearSelection();
875 break; 845 break;
876 case 2: 846 case 2:
877 { 847 {
878 addToSelection( videoView->currentItem() ); 848 addToSelection( videoView->currentItem() );
879 mediaPlayerState->setPlaying(b); 849 mediaPlayerState->setPlaying(b);
880 qApp->processEvents(); 850 qApp->processEvents();
881 d->selectedFiles->removeSelected( ); 851 d->selectedFiles->removeSelected( );
882 tabWidget->setCurrentPage(2); 852 tabWidget->setCurrentPage(2);
883 d->selectedFiles->unSelect(); 853 d->selectedFiles->unSelect();
884 insanityBool=FALSE; 854 insanityBool=FALSE;
885 }// videoView->clearSelection(); 855 }// videoView->clearSelection();
886 break; 856 break;
887 }; 857 };
888 858
889} 859}
890 860
891void PlayListWidget::deletePlaylist() { 861void PlayListWidget::deletePlaylist() {
892 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 862 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
893 (tr("You really want to delete\nthis playlist?")), 863 (tr("You really want to delete\nthis playlist?")),
894 (tr("Yes")), (tr("No")), 0 )){ 864 (tr("Yes")), (tr("No")), 0 )){
895 case 0: // Yes clicked, 865 case 0: // Yes clicked,
896 QFile().remove(playLists->selected()->file()); 866// QFile().remove(playLists->selected()->file());
897 QFile().remove(playLists->selected()->linkFile()); 867// QFile().remove(playLists->selected()->linkFile());
898 playLists->reread(); 868// playLists->reread();
899 break; 869 break;
900 case 1: // Cancel 870 case 1: // Cancel
901 break; 871 break;
902 }; 872 };
903} 873}
904 874
905void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) 875void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i)
906{ 876{
907 switch (mouse) { 877 switch (mouse) {
908 case 1: 878 case 1:
909 break; 879 break;
910 case 2:{ 880 case 2:{
911 881
912 QPopupMenu m; 882 QPopupMenu m;
913 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 883 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
914 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 884 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
915 m.insertSeparator(); 885 m.insertSeparator();
916 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) 886 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() )
917 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 887 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
918 888
919 m.exec( QCursor::pos() ); 889 m.exec( QCursor::pos() );
920 } 890 }
921 break; 891 break;
922 }; 892 };
923} 893}
924 894
925void PlayListWidget::playSelected() 895void PlayListWidget::playSelected()
926{ 896{
927 btnPlay( TRUE); 897 btnPlay( TRUE);
928// d->selectedFiles->unSelect(); 898// d->selectedFiles->unSelect();
929} 899}
930 900
931void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) 901void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i)
932{ 902{
933 switch (mouse) { 903 switch (mouse) {
934 case 1: 904 case 1:
935 905
936 break; 906 break;
937 case 2:{ 907 case 2:{
938 QPopupMenu m; 908 QPopupMenu m;
939 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 909 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
940 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 910 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
941// m.insertSeparator(); 911// m.insertSeparator();
942// m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 912// m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
943 m.exec( QCursor::pos() ); 913 m.exec( QCursor::pos() );
944 } 914 }
945 break; 915 break;
946 }; 916 };
@@ -991,96 +961,97 @@ void PlayListWidget::listDelete() {
991} 961}
992 962
993void PlayListWidget::scanForAudio() { 963void PlayListWidget::scanForAudio() {
994 qDebug("scan for audio"); 964 qDebug("scan for audio");
995 files.detachChildren(); 965 files.detachChildren();
996 QListIterator<DocLnk> sdit( files.children() ); 966 QListIterator<DocLnk> sdit( files.children() );
997 for ( ; sdit.current(); ++sdit ) { 967 for ( ; sdit.current(); ++sdit ) {
998 delete sdit.current(); 968 delete sdit.current();
999 } 969 }
1000 Global::findDocuments(&files, "audio/*"); 970 Global::findDocuments(&files, "audio/*");
1001 audioScan = TRUE; 971 audioScan = TRUE;
1002} 972}
1003void PlayListWidget::scanForVideo() { 973void PlayListWidget::scanForVideo() {
1004 qDebug("scan for video"); 974 qDebug("scan for video");
1005 vFiles.detachChildren(); 975 vFiles.detachChildren();
1006 QListIterator<DocLnk> sdit( vFiles.children() ); 976 QListIterator<DocLnk> sdit( vFiles.children() );
1007 for ( ; sdit.current(); ++sdit ) { 977 for ( ; sdit.current(); ++sdit ) {
1008 delete sdit.current(); 978 delete sdit.current();
1009 } 979 }
1010 Global::findDocuments(&vFiles, "video/*"); 980 Global::findDocuments(&vFiles, "video/*");
1011 videoScan = TRUE; 981 videoScan = TRUE;
1012} 982}
1013 983
1014void PlayListWidget::populateAudioView() { 984void PlayListWidget::populateAudioView() {
1015 985
1016 audioView->clear(); 986 audioView->clear();
1017 StorageInfo storageInfo; 987 StorageInfo storageInfo;
1018 const QList<FileSystem> &fs = storageInfo.fileSystems(); 988 const QList<FileSystem> &fs = storageInfo.fileSystems();
1019 if(!audioScan) scanForAudio(); 989 if(!audioScan) scanForAudio();
1020 990
1021 QListIterator<DocLnk> dit( files.children() ); 991 QListIterator<DocLnk> dit( files.children() );
1022 QListIterator<FileSystem> it ( fs ); 992 QListIterator<FileSystem> it ( fs );
1023 993
1024 QString storage; 994 QString storage;
1025 for ( ; dit.current(); ++dit ) { 995 for ( ; dit.current(); ++dit ) {
1026 for( ; it.current(); ++it ){ 996 for( ; it.current(); ++it ){
1027 const QString name = (*it)->name(); 997 const QString name = (*it)->name();
1028 const QString path = (*it)->path(); 998 const QString path = (*it)->path();
1029 if(dit.current()->file().find(path) != -1 ) storage=name; 999 if(dit.current()->file().find(path) != -1 ) storage=name;
1030 } 1000 }
1031 1001
1032 QListViewItem * newItem; 1002 QListViewItem * newItem;
1033 if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { 1003 if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) {
1034 long size; 1004 long size;
1035 if( dit.current()->file().left(4) == "http" ) 1005 if( dit.current()->file().left(4) == "http" )
1036 size=0; 1006 size=0;
1037 else 1007 else
1038 size = QFile( dit.current()->file() ).size(); 1008 size = QFile( dit.current()->file() ).size();
1009 qDebug(dit.current()->name());
1039 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), 1010 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
1040 QString::number(size ), storage); 1011 QString::number(size ), storage);
1041 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); 1012 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" ));
1042 } 1013 }
1043 } 1014 }
1044 1015
1045} 1016}
1046 1017
1047void PlayListWidget::populateVideoView() { 1018void PlayListWidget::populateVideoView() {
1048 videoView->clear(); 1019 videoView->clear();
1049 StorageInfo storageInfo; 1020 StorageInfo storageInfo;
1050 const QList<FileSystem> &fs = storageInfo.fileSystems(); 1021 const QList<FileSystem> &fs = storageInfo.fileSystems();
1051 1022
1052 if(!videoScan ) scanForVideo(); 1023 if(!videoScan ) scanForVideo();
1053 1024
1054 QListIterator<DocLnk> Vdit( vFiles.children() ); 1025 QListIterator<DocLnk> Vdit( vFiles.children() );
1055 QListIterator<FileSystem> it ( fs ); 1026 QListIterator<FileSystem> it ( fs );
1056 videoView->clear(); 1027 videoView->clear();
1057 QString storage; 1028 QString storage;
1058 for ( ; Vdit.current(); ++Vdit ) { 1029 for ( ; Vdit.current(); ++Vdit ) {
1059 for( ; it.current(); ++it ){ 1030 for( ; it.current(); ++it ){
1060 const QString name = (*it)->name(); 1031 const QString name = (*it)->name();
1061 const QString path = (*it)->path(); 1032 const QString path = (*it)->path();
1062 if( Vdit.current()->file().find(path) != -1 ) storage=name; 1033 if( Vdit.current()->file().find(path) != -1 ) storage=name;
1063 } 1034 }
1064 1035
1065 QListViewItem * newItem; 1036 QListViewItem * newItem;
1066 if ( QFile( Vdit.current()->file()).exists() ) { 1037 if ( QFile( Vdit.current()->file()).exists() ) {
1067 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 1038 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
1068 QString::number( QFile( Vdit.current()->file()).size() ), storage); 1039 QString::number( QFile( Vdit.current()->file()).size() ), storage);
1069 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); 1040 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" ));
1070 } 1041 }
1071 } 1042 }
1072} 1043}
1073 1044
1074void PlayListWidget::openFile() { 1045void PlayListWidget::openFile() {
1075 QString filename, name; 1046 QString filename, name;
1076 InputDialog *fileDlg; 1047 InputDialog *fileDlg;
1077 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 1048 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
1078 fileDlg->exec(); 1049 fileDlg->exec();
1079 if( fileDlg->result() == 1 ) { 1050 if( fileDlg->result() == 1 ) {
1080 filename = fileDlg->LineEdit1->text(); 1051 filename = fileDlg->LineEdit1->text();
1081// http://205.188.234.129:8030 1052// http://205.188.234.129:8030
1082// http://66.28.68.70:8000 1053// http://66.28.68.70:8000
1083// filename.replace(QRegExp("%20")," "); 1054// filename.replace(QRegExp("%20")," ");
1084 qDebug("Selected filename is "+filename); 1055 qDebug("Selected filename is "+filename);
1085 if(filename.right(3) == "m3u") 1056 if(filename.right(3) == "m3u")
1086 readm3u( filename); 1057 readm3u( filename);