-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 79 |
1 files changed, 49 insertions, 30 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 41fcb30..2323ac2 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -227,391 +227,397 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
227 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 227 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
228 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | 228 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); |
229 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 229 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
230 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 230 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
231 | 231 | ||
232 | QWidget *aTab; | 232 | QWidget *aTab; |
233 | aTab = new QWidget( tabWidget, "aTab" ); | 233 | aTab = new QWidget( tabWidget, "aTab" ); |
234 | audioView = new QListView( aTab, "Audioview" ); | 234 | audioView = new QListView( aTab, "Audioview" ); |
235 | audioView->setMinimumSize(233,260); | 235 | audioView->setMinimumSize(233,260); |
236 | audioView->addColumn( tr("Title"),140); | 236 | audioView->addColumn( tr("Title"),140); |
237 | audioView->addColumn(tr("Size"), -1); | 237 | audioView->addColumn(tr("Size"), -1); |
238 | audioView->addColumn(tr("Media"),-1); | 238 | audioView->addColumn(tr("Media"),-1); |
239 | audioView->setColumnAlignment(1, Qt::AlignRight); | 239 | audioView->setColumnAlignment(1, Qt::AlignRight); |
240 | audioView->setColumnAlignment(2, Qt::AlignRight); | 240 | audioView->setColumnAlignment(2, Qt::AlignRight); |
241 | audioView->setAllColumnsShowFocus(TRUE); | 241 | audioView->setAllColumnsShowFocus(TRUE); |
242 | 242 | ||
243 | audioView->setMultiSelection( TRUE ); | 243 | audioView->setMultiSelection( TRUE ); |
244 | audioView->setSelectionMode( QListView::Extended); | 244 | audioView->setSelectionMode( QListView::Extended); |
245 | 245 | ||
246 | tabWidget->insertTab(aTab,tr("Audio")); | 246 | tabWidget->insertTab(aTab,tr("Audio")); |
247 | 247 | ||
248 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); | 248 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); |
249 | 249 | ||
250 | // audioView | 250 | // audioView |
251 | // populateAudioView(); | 251 | // populateAudioView(); |
252 | // videowidget | 252 | // videowidget |
253 | 253 | ||
254 | QWidget *vTab; | 254 | QWidget *vTab; |
255 | vTab = new QWidget( tabWidget, "vTab" ); | 255 | vTab = new QWidget( tabWidget, "vTab" ); |
256 | videoView = new QListView( vTab, "Videoview" ); | 256 | videoView = new QListView( vTab, "Videoview" ); |
257 | videoView->setMinimumSize(233,260); | 257 | videoView->setMinimumSize(233,260); |
258 | 258 | ||
259 | videoView->addColumn(tr("Title"),140); | 259 | videoView->addColumn(tr("Title"),140); |
260 | videoView->addColumn(tr("Size"),-1); | 260 | videoView->addColumn(tr("Size"),-1); |
261 | videoView->addColumn(tr("Media"),-1); | 261 | videoView->addColumn(tr("Media"),-1); |
262 | videoView->setColumnAlignment(1, Qt::AlignRight); | 262 | videoView->setColumnAlignment(1, Qt::AlignRight); |
263 | videoView->setColumnAlignment(2, Qt::AlignRight); | 263 | videoView->setColumnAlignment(2, Qt::AlignRight); |
264 | videoView->setAllColumnsShowFocus(TRUE); | 264 | videoView->setAllColumnsShowFocus(TRUE); |
265 | videoView->setMultiSelection( TRUE ); | 265 | videoView->setMultiSelection( TRUE ); |
266 | videoView->setSelectionMode( QListView::Extended); | 266 | videoView->setSelectionMode( QListView::Extended); |
267 | 267 | ||
268 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | 268 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); |
269 | 269 | ||
270 | tabWidget->insertTab( vTab,tr("Video")); | 270 | tabWidget->insertTab( vTab,tr("Video")); |
271 | // populateVideoView(); | 271 | // populateVideoView(); |
272 | 272 | ||
273 | //playlists list | 273 | //playlists list |
274 | QWidget *LTab; | 274 | QWidget *LTab; |
275 | LTab = new QWidget( tabWidget, "LTab" ); | 275 | LTab = new QWidget( tabWidget, "LTab" ); |
276 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy | 276 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy |
277 | playLists->setMinimumSize(233,260); | 277 | playLists->setMinimumSize(233,260); |
278 | tabWidget->insertTab(LTab,tr("Lists")); | 278 | tabWidget->insertTab(LTab,tr("Lists")); |
279 | 279 | ||
280 | // connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); | 280 | // connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); |
281 | 281 | ||
282 | // add the library area | 282 | // add the library area |
283 | 283 | ||
284 | // connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), | 284 | // connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), |
285 | // this, SLOT( fauxPlay( QListViewItem *) ) ); | 285 | // this, SLOT( fauxPlay( QListViewItem *) ) ); |
286 | // connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), | 286 | // connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), |
287 | // this, SLOT( fauxPlay( QListViewItem *)) ); | 287 | // this, SLOT( fauxPlay( QListViewItem *)) ); |
288 | 288 | ||
289 | // connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); | 289 | // connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); |
290 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); | 290 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); |
291 | 291 | ||
292 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); | 292 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); |
293 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); | 293 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); |
294 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); | 294 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); |
295 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 295 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
296 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); | 296 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); |
297 | 297 | ||
298 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 298 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
299 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 299 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
300 | 300 | ||
301 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), | 301 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), |
302 | this,SLOT( playIt( QListViewItem *)) ); | 302 | this,SLOT( playIt( QListViewItem *)) ); |
303 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 303 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
304 | 304 | ||
305 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 305 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
306 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 306 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
307 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), | 307 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), |
308 | this,SLOT( playIt( QListViewItem *)) ); | 308 | this,SLOT( playIt( QListViewItem *)) ); |
309 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 309 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
310 | 310 | ||
311 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 311 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
312 | 312 | ||
313 | 313 | ||
314 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 314 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
315 | 315 | ||
316 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 316 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
317 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 317 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
318 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 318 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
319 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 319 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
320 | 320 | ||
321 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 321 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
322 | // connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); | 322 | // connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); |
323 | 323 | ||
324 | setCentralWidget( vbox5 ); | 324 | setCentralWidget( vbox5 ); |
325 | 325 | ||
326 | Config cfg( "OpiePlayer" ); | 326 | Config cfg( "OpiePlayer" ); |
327 | readConfig( cfg ); | 327 | readConfig( cfg ); |
328 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 328 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
329 | // qDebug("currentList is "+currentPlaylist); | 329 | // qDebug("currentList is "+currentPlaylist); |
330 | loadList(DocLnk( currentPlaylist)); | 330 | loadList(DocLnk( currentPlaylist)); |
331 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); | 331 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); |
332 | 332 | ||
333 | initializeStates(); | 333 | initializeStates(); |
334 | } | 334 | } |
335 | 335 | ||
336 | 336 | ||
337 | PlayListWidget::~PlayListWidget() { | 337 | PlayListWidget::~PlayListWidget() { |
338 | Config cfg( "OpiePlayer" ); | 338 | Config cfg( "OpiePlayer" ); |
339 | writeConfig( cfg ); | 339 | writeConfig( cfg ); |
340 | 340 | ||
341 | 341 | ||
342 | if ( d->current ) | 342 | if ( d->current ) |
343 | delete d->current; | 343 | delete d->current; |
344 | delete d; | 344 | delete d; |
345 | } | 345 | } |
346 | 346 | ||
347 | 347 | ||
348 | void PlayListWidget::initializeStates() { | 348 | void PlayListWidget::initializeStates() { |
349 | 349 | ||
350 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 350 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
351 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 351 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
352 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 352 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
353 | // d->tbFull->setOn( mediaPlayerState->fullscreen() ); | 353 | // d->tbFull->setOn( mediaPlayerState->fullscreen() ); |
354 | // d->tbScale->setOn( mediaPlayerState->scaled() ); | 354 | // d->tbScale->setOn( mediaPlayerState->scaled() ); |
355 | // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); | 355 | // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); |
356 | // setPlaylist( mediaPlayerState->playlist() ); | 356 | // setPlaylist( mediaPlayerState->playlist() ); |
357 | setPlaylist( true); | 357 | setPlaylist( true); |
358 | // d->selectedFiles->first(); | 358 | // d->selectedFiles->first(); |
359 | 359 | ||
360 | } | 360 | } |
361 | 361 | ||
362 | 362 | ||
363 | void PlayListWidget::readConfig( Config& cfg ) { | 363 | void PlayListWidget::readConfig( Config& cfg ) { |
364 | cfg.setGroup("PlayList"); | 364 | cfg.setGroup("PlayList"); |
365 | QString currentString = cfg.readEntry("current", "" ); | 365 | QString currentString = cfg.readEntry("current", "" ); |
366 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 366 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
367 | for ( int i = 0; i < noOfFiles; i++ ) { | 367 | for ( int i = 0; i < noOfFiles; i++ ) { |
368 | QString entryName; | 368 | QString entryName; |
369 | entryName.sprintf( "File%i", i + 1 ); | 369 | entryName.sprintf( "File%i", i + 1 ); |
370 | QString linkFile = cfg.readEntry( entryName ); | 370 | QString linkFile = cfg.readEntry( entryName ); |
371 | DocLnk lnk( linkFile ); | 371 | DocLnk lnk( linkFile ); |
372 | if ( lnk.isValid() ) { | 372 | if ( lnk.isValid() ) { |
373 | d->selectedFiles->addToSelection( lnk ); | 373 | d->selectedFiles->addToSelection( lnk ); |
374 | } | 374 | } |
375 | } | 375 | } |
376 | d->selectedFiles->setSelectedItem( currentString); | 376 | d->selectedFiles->setSelectedItem( currentString); |
377 | // d->selectedFiles->setSelectedItem( (const QString &)currentString); | 377 | // d->selectedFiles->setSelectedItem( (const QString &)currentString); |
378 | } | 378 | } |
379 | 379 | ||
380 | 380 | ||
381 | void PlayListWidget::writeConfig( Config& cfg ) const { | 381 | void PlayListWidget::writeConfig( Config& cfg ) const { |
382 | 382 | ||
383 | d->selectedFiles->writeCurrent( cfg); | 383 | d->selectedFiles->writeCurrent( cfg); |
384 | cfg.setGroup("PlayList"); | 384 | cfg.setGroup("PlayList"); |
385 | int noOfFiles = 0; | 385 | int noOfFiles = 0; |
386 | d->selectedFiles->first(); | 386 | d->selectedFiles->first(); |
387 | do { | 387 | do { |
388 | const DocLnk *lnk = d->selectedFiles->current(); | 388 | const DocLnk *lnk = d->selectedFiles->current(); |
389 | if ( lnk ) { | 389 | if ( lnk ) { |
390 | QString entryName; | 390 | QString entryName; |
391 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 391 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
392 | // qDebug(entryName); | 392 | // qDebug(entryName); |
393 | cfg.writeEntry( entryName, lnk->linkFile() ); | 393 | cfg.writeEntry( entryName, lnk->linkFile() ); |
394 | // if this link does exist, add it so we have the file | 394 | // if this link does exist, add it so we have the file |
395 | // next time... | 395 | // next time... |
396 | if ( !QFile::exists( lnk->linkFile() ) ) { | 396 | if ( !QFile::exists( lnk->linkFile() ) ) { |
397 | // the way writing lnks doesn't really check for out | 397 | // the way writing lnks doesn't really check for out |
398 | // of disk space, but check it anyway. | 398 | // of disk space, but check it anyway. |
399 | if ( !lnk->writeLink() ) { | 399 | if ( !lnk->writeLink() ) { |
400 | QMessageBox::critical( 0, tr("Out of space"), | 400 | QMessageBox::critical( 0, tr("Out of space"), |
401 | tr( "There was a problem saving " | 401 | tr( "There was a problem saving " |
402 | "the playlist.\n" | 402 | "the playlist.\n" |
403 | "Your playlist " | 403 | "Your playlist " |
404 | "may be missing some entries\n" | 404 | "may be missing some entries\n" |
405 | "the next time you start it." ) | 405 | "the next time you start it." ) |
406 | ); | 406 | ); |
407 | } | 407 | } |
408 | } | 408 | } |
409 | noOfFiles++; | 409 | noOfFiles++; |
410 | } | 410 | } |
411 | } | 411 | } |
412 | while ( d->selectedFiles->next() ); | 412 | while ( d->selectedFiles->next() ); |
413 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 413 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
414 | } | 414 | } |
415 | 415 | ||
416 | 416 | ||
417 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 417 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
418 | // qDebug("add"); | 418 | // qDebug("add"); |
419 | d->setDocumentUsed = FALSE; | 419 | if( lnk.file().find(" ",0,TRUE) != -1 || lnk.file().find("%20",0,TRUE) != -1) { |
420 | if ( mediaPlayerState->playlist() ) { | 420 | QMessageBox::message("Note","You are trying to play\na malformed url."); |
421 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) | 421 | |
422 | d->selectedFiles->addToSelection( lnk ); | 422 | } else { |
423 | |||
424 | d->setDocumentUsed = FALSE; | ||
425 | if ( mediaPlayerState->playlist() ) { | ||
426 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) | ||
427 | d->selectedFiles->addToSelection( lnk ); | ||
428 | } | ||
429 | else | ||
430 | mediaPlayerState->setPlaying( TRUE ); | ||
423 | } | 431 | } |
424 | else | ||
425 | mediaPlayerState->setPlaying( TRUE ); | ||
426 | } | 432 | } |
427 | 433 | ||
428 | 434 | ||
429 | void PlayListWidget::clearList() { | 435 | void PlayListWidget::clearList() { |
430 | while ( first() ) | 436 | while ( first() ) |
431 | d->selectedFiles->removeSelected(); | 437 | d->selectedFiles->removeSelected(); |
432 | } | 438 | } |
433 | 439 | ||
434 | 440 | ||
435 | void PlayListWidget::addAllToList() { | 441 | void PlayListWidget::addAllToList() { |
436 | DocLnkSet filesAll; | 442 | DocLnkSet filesAll; |
437 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 443 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
438 | QListIterator<DocLnk> Adit( filesAll.children() ); | 444 | QListIterator<DocLnk> Adit( filesAll.children() ); |
439 | for ( ; Adit.current(); ++Adit ) | 445 | for ( ; Adit.current(); ++Adit ) |
440 | if(QFileInfo(Adit.current()->file()).exists()) | 446 | if(QFileInfo(Adit.current()->file()).exists()) |
441 | d->selectedFiles->addToSelection( **Adit ); | 447 | d->selectedFiles->addToSelection( **Adit ); |
442 | } | 448 | } |
443 | 449 | ||
444 | 450 | ||
445 | void PlayListWidget::addAllMusicToList() { | 451 | void PlayListWidget::addAllMusicToList() { |
446 | QListIterator<DocLnk> dit( files.children() ); | 452 | QListIterator<DocLnk> dit( files.children() ); |
447 | for ( ; dit.current(); ++dit ) | 453 | for ( ; dit.current(); ++dit ) |
448 | if(QFileInfo(dit.current()->file()).exists()) | 454 | if(QFileInfo(dit.current()->file()).exists()) |
449 | d->selectedFiles->addToSelection( **dit ); | 455 | d->selectedFiles->addToSelection( **dit ); |
450 | } | 456 | } |
451 | 457 | ||
452 | 458 | ||
453 | void PlayListWidget::addAllVideoToList() { | 459 | void PlayListWidget::addAllVideoToList() { |
454 | QListIterator<DocLnk> dit( vFiles.children() ); | 460 | QListIterator<DocLnk> dit( vFiles.children() ); |
455 | for ( ; dit.current(); ++dit ) | 461 | for ( ; dit.current(); ++dit ) |
456 | if(QFileInfo( dit.current()->file()).exists()) | 462 | if(QFileInfo( dit.current()->file()).exists()) |
457 | d->selectedFiles->addToSelection( **dit ); | 463 | d->selectedFiles->addToSelection( **dit ); |
458 | } | 464 | } |
459 | 465 | ||
460 | 466 | ||
461 | void PlayListWidget::setDocument(const QString& fileref) { | 467 | void PlayListWidget::setDocument(const QString& fileref) { |
462 | qDebug(fileref); | 468 | qDebug(fileref); |
463 | fromSetDocument = TRUE; | 469 | fromSetDocument = TRUE; |
464 | if ( fileref.isNull() ) { | 470 | if ( fileref.isNull() ) { |
465 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 471 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
466 | return; | 472 | return; |
467 | } | 473 | } |
468 | // qDebug("setDocument "+fileref); | 474 | // qDebug("setDocument "+fileref); |
469 | if(fileref.find("m3u",0,TRUE) != -1) { //is m3u | 475 | if(fileref.find("m3u",0,TRUE) != -1) { //is m3u |
470 | readm3u( fileref); | 476 | readm3u( fileref); |
471 | } | 477 | } |
472 | else if(fileref.find("pls",0,TRUE) != -1) { //is pls | 478 | else if(fileref.find("pls",0,TRUE) != -1) { //is pls |
473 | readPls( fileref); | 479 | readPls( fileref); |
474 | } | 480 | } |
475 | else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist | 481 | else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist |
476 | clearList(); | 482 | clearList(); |
477 | loadList(DocLnk(fileref)); | 483 | loadList(DocLnk(fileref)); |
478 | d->selectedFiles->first(); | 484 | d->selectedFiles->first(); |
479 | } else { | 485 | } else { |
480 | clearList(); | 486 | clearList(); |
481 | addToSelection( DocLnk( fileref ) ); | 487 | addToSelection( DocLnk( fileref ) ); |
482 | d->setDocumentUsed = TRUE; | 488 | d->setDocumentUsed = TRUE; |
483 | mediaPlayerState->setPlaying( FALSE ); | 489 | mediaPlayerState->setPlaying( FALSE ); |
484 | qApp->processEvents(); | 490 | qApp->processEvents(); |
485 | mediaPlayerState->setPlaying( TRUE ); | 491 | mediaPlayerState->setPlaying( TRUE ); |
486 | qApp->processEvents(); | 492 | qApp->processEvents(); |
487 | setCaption(tr("OpiePlayer")); | 493 | setCaption(tr("OpiePlayer")); |
488 | } | 494 | } |
489 | } | 495 | } |
490 | 496 | ||
491 | 497 | ||
492 | void PlayListWidget::setActiveWindow() { | 498 | void PlayListWidget::setActiveWindow() { |
493 | // When we get raised we need to ensure that it switches views | 499 | // When we get raised we need to ensure that it switches views |
494 | char origView = mediaPlayerState->view(); | 500 | char origView = mediaPlayerState->view(); |
495 | mediaPlayerState->setView( 'l' ); // invalidate | 501 | mediaPlayerState->setView( 'l' ); // invalidate |
496 | mediaPlayerState->setView( origView ); // now switch back | 502 | mediaPlayerState->setView( origView ); // now switch back |
497 | } | 503 | } |
498 | 504 | ||
499 | 505 | ||
500 | void PlayListWidget::useSelectedDocument() { | 506 | void PlayListWidget::useSelectedDocument() { |
501 | d->setDocumentUsed = FALSE; | 507 | d->setDocumentUsed = FALSE; |
502 | } | 508 | } |
503 | 509 | ||
504 | 510 | ||
505 | const DocLnk *PlayListWidget::current() { // this is fugly | 511 | const DocLnk *PlayListWidget::current() { // this is fugly |
506 | 512 | ||
507 | // if( fromSetDocument) { | 513 | // if( fromSetDocument) { |
508 | // qDebug("from setDoc"); | 514 | // qDebug("from setDoc"); |
509 | // DocLnkSet files; | 515 | // DocLnkSet files; |
510 | // Global::findDocuments(&files, "video/*;audio/*"); | 516 | // Global::findDocuments(&files, "video/*;audio/*"); |
511 | // QListIterator<DocLnk> dit( files.children() ); | 517 | // QListIterator<DocLnk> dit( files.children() ); |
512 | // for ( ; dit.current(); ++dit ) { | 518 | // for ( ; dit.current(); ++dit ) { |
513 | // if(dit.current()->linkFile() == setDocFileRef) { | 519 | // if(dit.current()->linkFile() == setDocFileRef) { |
514 | // qDebug(setDocFileRef); | 520 | // qDebug(setDocFileRef); |
515 | // return dit; | 521 | // return dit; |
516 | // } | 522 | // } |
517 | // } | 523 | // } |
518 | // } else | 524 | // } else |
519 | 525 | ||
520 | 526 | ||
521 | switch (tabWidget->currentPageIndex()) { | 527 | switch (tabWidget->currentPageIndex()) { |
522 | case 0: //playlist | 528 | case 0: //playlist |
523 | { | 529 | { |
524 | qDebug("playlist"); | 530 | qDebug("playlist"); |
525 | if ( mediaPlayerState->playlist() ) { | 531 | if ( mediaPlayerState->playlist() ) { |
526 | return d->selectedFiles->current(); | 532 | return d->selectedFiles->current(); |
527 | } | 533 | } |
528 | else if ( d->setDocumentUsed && d->current ) { | 534 | else if ( d->setDocumentUsed && d->current ) { |
529 | return d->current; | 535 | return d->current; |
530 | } else { | 536 | } else { |
531 | return d->files->selected(); | 537 | return d->files->selected(); |
532 | } | 538 | } |
533 | } | 539 | } |
534 | break; | 540 | break; |
535 | case 1://audio | 541 | case 1://audio |
536 | { | 542 | { |
537 | qDebug("audioView"); | 543 | qDebug("audioView"); |
538 | QListIterator<DocLnk> dit( files.children() ); | 544 | QListIterator<DocLnk> dit( files.children() ); |
539 | for ( ; dit.current(); ++dit ) { | 545 | for ( ; dit.current(); ++dit ) { |
540 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { | 546 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { |
541 | qDebug("here"); | 547 | qDebug("here"); |
542 | insanityBool=TRUE; | 548 | insanityBool=TRUE; |
543 | return dit; | 549 | return dit; |
544 | } | 550 | } |
545 | } | 551 | } |
546 | } | 552 | } |
547 | break; | 553 | break; |
548 | case 2: // video | 554 | case 2: // video |
549 | { | 555 | { |
550 | qDebug("videoView"); | 556 | qDebug("videoView"); |
551 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 557 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
552 | for ( ; Vdit.current(); ++Vdit ) { | 558 | for ( ; Vdit.current(); ++Vdit ) { |
553 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { | 559 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { |
554 | insanityBool=TRUE; | 560 | insanityBool=TRUE; |
555 | return Vdit; | 561 | return Vdit; |
556 | } | 562 | } |
557 | } | 563 | } |
558 | } | 564 | } |
559 | break; | 565 | break; |
560 | }; | 566 | }; |
561 | return 0; | 567 | return 0; |
562 | } | 568 | } |
563 | 569 | ||
564 | bool PlayListWidget::prev() { | 570 | bool PlayListWidget::prev() { |
565 | if ( mediaPlayerState->playlist() ) { | 571 | if ( mediaPlayerState->playlist() ) { |
566 | if ( mediaPlayerState->shuffled() ) { | 572 | if ( mediaPlayerState->shuffled() ) { |
567 | const DocLnk *cur = current(); | 573 | const DocLnk *cur = current(); |
568 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 574 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
569 | for ( int i = 0; i < j; i++ ) { | 575 | for ( int i = 0; i < j; i++ ) { |
570 | if ( !d->selectedFiles->next() ) | 576 | if ( !d->selectedFiles->next() ) |
571 | d->selectedFiles->first(); | 577 | d->selectedFiles->first(); |
572 | } | 578 | } |
573 | if ( cur == current() ) | 579 | if ( cur == current() ) |
574 | if ( !d->selectedFiles->next() ) | 580 | if ( !d->selectedFiles->next() ) |
575 | d->selectedFiles->first(); | 581 | d->selectedFiles->first(); |
576 | return TRUE; | 582 | return TRUE; |
577 | } else { | 583 | } else { |
578 | if ( !d->selectedFiles->prev() ) { | 584 | if ( !d->selectedFiles->prev() ) { |
579 | if ( mediaPlayerState->looping() ) { | 585 | if ( mediaPlayerState->looping() ) { |
580 | return d->selectedFiles->last(); | 586 | return d->selectedFiles->last(); |
581 | } else { | 587 | } else { |
582 | return FALSE; | 588 | return FALSE; |
583 | } | 589 | } |
584 | } | 590 | } |
585 | return TRUE; | 591 | return TRUE; |
586 | } | 592 | } |
587 | } else { | 593 | } else { |
588 | return mediaPlayerState->looping(); | 594 | return mediaPlayerState->looping(); |
589 | } | 595 | } |
590 | } | 596 | } |
591 | 597 | ||
592 | 598 | ||
593 | bool PlayListWidget::next() { | 599 | bool PlayListWidget::next() { |
594 | if ( mediaPlayerState->playlist() ) { | 600 | if ( mediaPlayerState->playlist() ) { |
595 | if ( mediaPlayerState->shuffled() ) { | 601 | if ( mediaPlayerState->shuffled() ) { |
596 | return prev(); | 602 | return prev(); |
597 | } else { | 603 | } else { |
598 | if ( !d->selectedFiles->next() ) { | 604 | if ( !d->selectedFiles->next() ) { |
599 | if ( mediaPlayerState->looping() ) { | 605 | if ( mediaPlayerState->looping() ) { |
600 | return d->selectedFiles->first(); | 606 | return d->selectedFiles->first(); |
601 | } else { | 607 | } else { |
602 | return FALSE; | 608 | return FALSE; |
603 | } | 609 | } |
604 | } | 610 | } |
605 | return TRUE; | 611 | return TRUE; |
606 | } | 612 | } |
607 | } else { | 613 | } else { |
608 | return mediaPlayerState->looping(); | 614 | return mediaPlayerState->looping(); |
609 | } | 615 | } |
610 | } | 616 | } |
611 | 617 | ||
612 | 618 | ||
613 | bool PlayListWidget::first() { | 619 | bool PlayListWidget::first() { |
614 | if ( mediaPlayerState->playlist() ) | 620 | if ( mediaPlayerState->playlist() ) |
615 | return d->selectedFiles->first(); | 621 | return d->selectedFiles->first(); |
616 | else | 622 | else |
617 | return mediaPlayerState->looping(); | 623 | return mediaPlayerState->looping(); |
@@ -657,636 +663,649 @@ void PlayListWidget::saveList() { | |||
657 | if(fileDlg) | 663 | if(fileDlg) |
658 | delete fileDlg; | 664 | delete fileDlg; |
659 | } | 665 | } |
660 | 666 | ||
661 | void PlayListWidget::loadList( const DocLnk & lnk) { | 667 | void PlayListWidget::loadList( const DocLnk & lnk) { |
662 | QString name= lnk.name(); | 668 | QString name= lnk.name(); |
663 | // qDebug("currentList is "+name); | 669 | // qDebug("currentList is "+name); |
664 | if( name.length()>1) { | 670 | if( name.length()>1) { |
665 | setCaption("OpiePlayer: "+name); | 671 | setCaption("OpiePlayer: "+name); |
666 | // qDebug("load list "+ name+".playlist"); | 672 | // qDebug("load list "+ name+".playlist"); |
667 | clearList(); | 673 | clearList(); |
668 | Config cfg( name+".playlist"); | 674 | Config cfg( name+".playlist"); |
669 | readConfig(cfg); | 675 | readConfig(cfg); |
670 | 676 | ||
671 | tabWidget->setCurrentPage(0); | 677 | tabWidget->setCurrentPage(0); |
672 | 678 | ||
673 | Config config( "OpiePlayer" ); | 679 | Config config( "OpiePlayer" ); |
674 | config.writeEntry("CurrentPlaylist", name); | 680 | config.writeEntry("CurrentPlaylist", name); |
675 | // d->selectedFiles->first(); | 681 | // d->selectedFiles->first(); |
676 | } | 682 | } |
677 | 683 | ||
678 | } | 684 | } |
679 | 685 | ||
680 | void PlayListWidget::setPlaylist( bool shown ) { | 686 | void PlayListWidget::setPlaylist( bool shown ) { |
681 | if ( shown ) | 687 | if ( shown ) |
682 | d->playListFrame->show(); | 688 | d->playListFrame->show(); |
683 | else | 689 | else |
684 | d->playListFrame->hide(); | 690 | d->playListFrame->hide(); |
685 | } | 691 | } |
686 | 692 | ||
687 | void PlayListWidget::setView( char view ) { | 693 | void PlayListWidget::setView( char view ) { |
688 | if ( view == 'l' ) | 694 | if ( view == 'l' ) |
689 | showMaximized(); | 695 | showMaximized(); |
690 | else | 696 | else |
691 | hide(); | 697 | hide(); |
692 | } | 698 | } |
693 | 699 | ||
694 | void PlayListWidget::addSelected() { | 700 | void PlayListWidget::addSelected() { |
695 | 701 | ||
696 | Config cfg( "OpiePlayer" ); | 702 | Config cfg( "OpiePlayer" ); |
697 | cfg.setGroup("PlayList"); | 703 | cfg.setGroup("PlayList"); |
698 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 704 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
699 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 705 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
700 | 706 | ||
701 | switch (tabWidget->currentPageIndex()) { | 707 | switch (tabWidget->currentPageIndex()) { |
702 | case 0: //playlist | 708 | case 0: //playlist |
703 | break; | 709 | break; |
704 | case 1: { //audio | 710 | case 1: { //audio |
705 | // QString entryName; | 711 | // QString entryName; |
706 | // entryName.sprintf( "File%i", i + 1 ); | 712 | // entryName.sprintf( "File%i", i + 1 ); |
707 | // QString linkFile = cfg.readEntry( entryName ); | 713 | // QString linkFile = cfg.readEntry( entryName ); |
708 | QListViewItemIterator it( audioView ); | 714 | QListViewItemIterator it( audioView ); |
709 | // iterate through all items of the listview | 715 | // iterate through all items of the listview |
710 | for ( ; it.current(); ++it ) { | 716 | for ( ; it.current(); ++it ) { |
711 | if ( it.current()->isSelected() ) { | 717 | if ( it.current()->isSelected() ) { |
712 | QListIterator<DocLnk> dit( files.children() ); | 718 | QListIterator<DocLnk> dit( files.children() ); |
713 | for ( ; dit.current(); ++dit ) { | 719 | for ( ; dit.current(); ++dit ) { |
714 | if( dit.current()->name() == it.current()->text(0) ) { | 720 | if( dit.current()->name() == it.current()->text(0) ) { |
715 | d->selectedFiles->addToSelection( **dit ); | 721 | d->selectedFiles->addToSelection( **dit ); |
716 | } | 722 | } |
717 | } | 723 | } |
718 | audioView->setSelected( it.current(),FALSE); | 724 | audioView->setSelected( it.current(),FALSE); |
719 | } | 725 | } |
720 | } | 726 | } |
721 | tabWidget->setCurrentPage(0); | 727 | tabWidget->setCurrentPage(0); |
722 | } | 728 | } |
723 | break; | 729 | break; |
724 | case 2: { // video | 730 | case 2: { // video |
725 | QListViewItemIterator it( videoView ); | 731 | QListViewItemIterator it( videoView ); |
726 | // iterate through all items of the listview | 732 | // iterate through all items of the listview |
727 | for ( ; it.current(); ++it ) { | 733 | for ( ; it.current(); ++it ) { |
728 | if ( it.current()->isSelected() ) { | 734 | if ( it.current()->isSelected() ) { |
729 | QListIterator<DocLnk> dit( vFiles.children() ); | 735 | QListIterator<DocLnk> dit( vFiles.children() ); |
730 | for ( ; dit.current(); ++dit ) { | 736 | for ( ; dit.current(); ++dit ) { |
731 | if( dit.current()->name() == it.current()->text(0) ) { | 737 | if( dit.current()->name() == it.current()->text(0) ) { |
732 | d->selectedFiles->addToSelection( **dit ); | 738 | d->selectedFiles->addToSelection( **dit ); |
733 | } | 739 | } |
734 | } | 740 | } |
735 | 741 | ||
736 | videoView->setSelected( it.current(),FALSE); | 742 | videoView->setSelected( it.current(),FALSE); |
737 | } | 743 | } |
738 | } | 744 | } |
739 | // for ( int i = 0; i < noOfFiles; i++ ) { | 745 | // for ( int i = 0; i < noOfFiles; i++ ) { |
740 | // QString entryName; | 746 | // QString entryName; |
741 | // entryName.sprintf( "File%i", i + 1 ); | 747 | // entryName.sprintf( "File%i", i + 1 ); |
742 | // QString linkFile = cfg.readEntry( entryName ); | 748 | // QString linkFile = cfg.readEntry( entryName ); |
743 | // if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { | 749 | // if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { |
744 | // int result= QMessageBox::warning(this,tr("OpiePlayer"), | 750 | // int result= QMessageBox::warning(this,tr("OpiePlayer"), |
745 | // tr("This is all ready in your playlist.\nContinue?"), | 751 | // tr("This is all ready in your playlist.\nContinue?"), |
746 | // tr("Yes"),tr("No"),0,0,1); | 752 | // tr("Yes"),tr("No"),0,0,1); |
747 | // if (result !=0) | 753 | // if (result !=0) |
748 | // return; | 754 | // return; |
749 | // } | 755 | // } |
750 | // } | 756 | // } |
751 | // addToSelection( videoView->selectedItem() ); | 757 | // addToSelection( videoView->selectedItem() ); |
752 | tabWidget->setCurrentPage(0); | 758 | tabWidget->setCurrentPage(0); |
753 | } | 759 | } |
754 | break; | 760 | break; |
755 | }; | 761 | }; |
756 | } | 762 | } |
757 | 763 | ||
758 | void PlayListWidget::removeSelected() { | 764 | void PlayListWidget::removeSelected() { |
759 | d->selectedFiles->removeSelected( ); | 765 | d->selectedFiles->removeSelected( ); |
760 | } | 766 | } |
761 | 767 | ||
762 | void PlayListWidget::playIt( QListViewItem *it) { | 768 | void PlayListWidget::playIt( QListViewItem *it) { |
763 | // d->setDocumentUsed = FALSE; | 769 | // d->setDocumentUsed = FALSE; |
764 | // mediaPlayerState->curPosition =0; | 770 | // mediaPlayerState->curPosition =0; |
765 | qDebug("playIt"); | 771 | qDebug("playIt"); |
766 | mediaPlayerState->setPlaying(FALSE); | 772 | mediaPlayerState->setPlaying(FALSE); |
767 | mediaPlayerState->setPlaying(TRUE); | 773 | mediaPlayerState->setPlaying(TRUE); |
768 | d->selectedFiles->unSelect(); | 774 | d->selectedFiles->unSelect(); |
769 | } | 775 | } |
770 | 776 | ||
771 | void PlayListWidget::addToSelection( QListViewItem *it) { | 777 | void PlayListWidget::addToSelection( QListViewItem *it) { |
772 | d->setDocumentUsed = FALSE; | 778 | d->setDocumentUsed = FALSE; |
773 | 779 | ||
774 | if(it) { | 780 | if(it) { |
775 | switch (tabWidget->currentPageIndex()) { | 781 | switch (tabWidget->currentPageIndex()) { |
776 | case 1: { | 782 | case 1: { |
777 | QListIterator<DocLnk> dit( files.children() ); | 783 | QListIterator<DocLnk> dit( files.children() ); |
778 | for ( ; dit.current(); ++dit ) { | 784 | for ( ; dit.current(); ++dit ) { |
779 | if( dit.current()->name() == it->text(0)) { | 785 | if( dit.current()->name() == it->text(0)) { |
780 | d->selectedFiles->addToSelection( **dit ); | 786 | d->selectedFiles->addToSelection( **dit ); |
781 | } | 787 | } |
782 | } | 788 | } |
783 | } | 789 | } |
784 | break; | 790 | break; |
785 | case 2: { | 791 | case 2: { |
786 | QListIterator<DocLnk> dit( vFiles.children() ); | 792 | QListIterator<DocLnk> dit( vFiles.children() ); |
787 | for ( ; dit.current(); ++dit ) { | 793 | for ( ; dit.current(); ++dit ) { |
788 | if( dit.current()->name() == it->text(0)) { | 794 | if( dit.current()->name() == it->text(0)) { |
789 | d->selectedFiles->addToSelection( **dit ); | 795 | d->selectedFiles->addToSelection( **dit ); |
790 | } | 796 | } |
791 | } | 797 | } |
792 | } | 798 | } |
793 | break; | 799 | break; |
794 | case 0: | 800 | case 0: |
795 | break; | 801 | break; |
796 | }; | 802 | }; |
797 | tabWidget->setCurrentPage(0); | 803 | tabWidget->setCurrentPage(0); |
798 | } | 804 | } |
799 | } | 805 | } |
800 | 806 | ||
801 | void PlayListWidget::tabChanged(QWidget *widg) { | 807 | void PlayListWidget::tabChanged(QWidget *widg) { |
802 | 808 | ||
803 | switch ( tabWidget->currentPageIndex()) { | 809 | switch ( tabWidget->currentPageIndex()) { |
804 | case 0: | 810 | case 0: |
805 | { | 811 | { |
806 | if( !tbDeletePlaylist->isHidden()) | 812 | if( !tbDeletePlaylist->isHidden()) |
807 | tbDeletePlaylist->hide(); | 813 | tbDeletePlaylist->hide(); |
808 | d->tbRemoveFromList->setEnabled(TRUE); | 814 | d->tbRemoveFromList->setEnabled(TRUE); |
809 | d->tbAddToList->setEnabled(FALSE); | 815 | d->tbAddToList->setEnabled(FALSE); |
810 | } | 816 | } |
811 | break; | 817 | break; |
812 | case 1: | 818 | case 1: |
813 | { | 819 | { |
814 | audioView->clear(); | 820 | audioView->clear(); |
815 | populateAudioView(); | 821 | populateAudioView(); |
816 | 822 | ||
817 | if( !tbDeletePlaylist->isHidden()) | 823 | if( !tbDeletePlaylist->isHidden()) |
818 | tbDeletePlaylist->hide(); | 824 | tbDeletePlaylist->hide(); |
819 | d->tbRemoveFromList->setEnabled(FALSE); | 825 | d->tbRemoveFromList->setEnabled(FALSE); |
820 | d->tbAddToList->setEnabled(TRUE); | 826 | d->tbAddToList->setEnabled(TRUE); |
821 | } | 827 | } |
822 | break; | 828 | break; |
823 | case 2: | 829 | case 2: |
824 | { | 830 | { |
825 | videoView->clear(); | 831 | videoView->clear(); |
826 | populateVideoView(); | 832 | populateVideoView(); |
827 | if( !tbDeletePlaylist->isHidden()) | 833 | if( !tbDeletePlaylist->isHidden()) |
828 | tbDeletePlaylist->hide(); | 834 | tbDeletePlaylist->hide(); |
829 | d->tbRemoveFromList->setEnabled(FALSE); | 835 | d->tbRemoveFromList->setEnabled(FALSE); |
830 | d->tbAddToList->setEnabled(TRUE); | 836 | d->tbAddToList->setEnabled(TRUE); |
831 | } | 837 | } |
832 | break; | 838 | break; |
833 | case 3: | 839 | case 3: |
834 | { | 840 | { |
835 | if( tbDeletePlaylist->isHidden()) | 841 | if( tbDeletePlaylist->isHidden()) |
836 | tbDeletePlaylist->show(); | 842 | tbDeletePlaylist->show(); |
837 | playLists->reread(); | 843 | playLists->reread(); |
838 | } | 844 | } |
839 | break; | 845 | break; |
840 | }; | 846 | }; |
841 | } | 847 | } |
842 | 848 | ||
843 | void PlayListWidget::btnPlay(bool b) { | 849 | void PlayListWidget::btnPlay(bool b) { |
844 | 850 | ||
845 | // mediaPlayerState->setPlaying(b); | 851 | // mediaPlayerState->setPlaying(b); |
846 | switch ( tabWidget->currentPageIndex()) { | 852 | switch ( tabWidget->currentPageIndex()) { |
847 | case 0: | 853 | case 0: |
848 | { | 854 | { |
849 | 855 | qDebug("here we are"); | |
850 | mediaPlayerState->setPlaying(b); | 856 | if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 || d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { |
851 | } | 857 | QMessageBox::message("Note","You are trying to play\na malformed url."); |
858 | |||
859 | } else { | ||
860 | |||
861 | mediaPlayerState->setPlaying(b); | ||
862 | } } | ||
852 | break; | 863 | break; |
853 | case 1: | 864 | case 1: |
854 | { | 865 | { |
855 | addToSelection( audioView->currentItem() ); | 866 | addToSelection( audioView->currentItem() ); |
856 | mediaPlayerState->setPlaying(b); | 867 | mediaPlayerState->setPlaying(b); |
857 | d->selectedFiles->removeSelected( ); | 868 | d->selectedFiles->removeSelected( ); |
858 | tabWidget->setCurrentPage(1); | 869 | tabWidget->setCurrentPage(1); |
859 | d->selectedFiles->unSelect(); | 870 | d->selectedFiles->unSelect(); |
860 | insanityBool=FALSE; | 871 | insanityBool=FALSE; |
861 | // audioView->clearSelection(); | 872 | }// audioView->clearSelection(); |
862 | } | ||
863 | break; | 873 | break; |
864 | case 2: | 874 | case 2: |
865 | { | 875 | { |
866 | addToSelection( videoView->currentItem() ); | 876 | addToSelection( videoView->currentItem() ); |
867 | mediaPlayerState->setPlaying(b); | 877 | mediaPlayerState->setPlaying(b); |
868 | qApp->processEvents(); | 878 | qApp->processEvents(); |
869 | d->selectedFiles->removeSelected( ); | 879 | d->selectedFiles->removeSelected( ); |
870 | tabWidget->setCurrentPage(2); | 880 | tabWidget->setCurrentPage(2); |
871 | d->selectedFiles->unSelect(); | 881 | d->selectedFiles->unSelect(); |
872 | insanityBool=FALSE; | 882 | insanityBool=FALSE; |
873 | // videoView->clearSelection(); | 883 | }// videoView->clearSelection(); |
874 | } | ||
875 | break; | 884 | break; |
876 | }; | 885 | }; |
886 | |||
877 | } | 887 | } |
878 | 888 | ||
879 | void PlayListWidget::deletePlaylist() { | 889 | void PlayListWidget::deletePlaylist() { |
880 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 890 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
881 | (tr("You really want to delete\nthis playlist?")), | 891 | (tr("You really want to delete\nthis playlist?")), |
882 | (tr("Yes")), (tr("No")), 0 )){ | 892 | (tr("Yes")), (tr("No")), 0 )){ |
883 | case 0: // Yes clicked, | 893 | case 0: // Yes clicked, |
884 | QFile().remove(playLists->selected()->file()); | 894 | QFile().remove(playLists->selected()->file()); |
885 | QFile().remove(playLists->selected()->linkFile()); | 895 | QFile().remove(playLists->selected()->linkFile()); |
886 | playLists->reread(); | 896 | playLists->reread(); |
887 | break; | 897 | break; |
888 | case 1: // Cancel | 898 | case 1: // Cancel |
889 | break; | 899 | break; |
890 | }; | 900 | }; |
891 | } | 901 | } |
892 | 902 | ||
893 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 903 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) |
894 | { | 904 | { |
895 | switch (mouse) { | 905 | switch (mouse) { |
896 | case 1: | 906 | case 1: |
897 | break; | 907 | break; |
898 | case 2:{ | 908 | case 2:{ |
899 | 909 | ||
900 | QPopupMenu m; | 910 | QPopupMenu m; |
901 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 911 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
902 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 912 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
903 | m.insertSeparator(); | 913 | m.insertSeparator(); |
904 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) | 914 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) |
905 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 915 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
906 | 916 | ||
907 | m.exec( QCursor::pos() ); | 917 | m.exec( QCursor::pos() ); |
908 | } | 918 | } |
909 | break; | 919 | break; |
910 | }; | 920 | }; |
911 | } | 921 | } |
912 | 922 | ||
913 | void PlayListWidget::playSelected() | 923 | void PlayListWidget::playSelected() |
914 | { | 924 | { |
915 | btnPlay( TRUE); | 925 | btnPlay( TRUE); |
916 | // d->selectedFiles->unSelect(); | 926 | // d->selectedFiles->unSelect(); |
917 | } | 927 | } |
918 | 928 | ||
919 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 929 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) |
920 | { | 930 | { |
921 | switch (mouse) { | 931 | switch (mouse) { |
922 | case 1: | 932 | case 1: |
923 | 933 | ||
924 | break; | 934 | break; |
925 | case 2:{ | 935 | case 2:{ |
926 | QPopupMenu m; | 936 | QPopupMenu m; |
927 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 937 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
928 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 938 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
929 | // m.insertSeparator(); | 939 | // m.insertSeparator(); |
930 | // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 940 | // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
931 | m.exec( QCursor::pos() ); | 941 | m.exec( QCursor::pos() ); |
932 | } | 942 | } |
933 | break; | 943 | break; |
934 | }; | 944 | }; |
935 | 945 | ||
936 | } | 946 | } |
937 | 947 | ||
938 | void PlayListWidget::listDelete() { | 948 | void PlayListWidget::listDelete() { |
939 | Config cfg( "OpiePlayer" ); | 949 | Config cfg( "OpiePlayer" ); |
940 | cfg.setGroup("PlayList"); | 950 | cfg.setGroup("PlayList"); |
941 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 951 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
942 | QString file; | 952 | QString file; |
943 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 953 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
944 | switch ( tabWidget->currentPageIndex()) { | 954 | switch ( tabWidget->currentPageIndex()) { |
945 | case 0: | 955 | case 0: |
946 | break; | 956 | break; |
947 | case 1: | 957 | case 1: |
948 | { | 958 | { |
949 | file = audioView->selectedItem()->text(0); | 959 | file = audioView->selectedItem()->text(0); |
950 | // Global::findDocuments(&files, "audio/*"); | 960 | // Global::findDocuments(&files, "audio/*"); |
951 | // AppLnkSet appFiles; | 961 | // AppLnkSet appFiles; |
952 | QListIterator<DocLnk> dit( files.children() ); | 962 | QListIterator<DocLnk> dit( files.children() ); |
953 | for ( ; dit.current(); ++dit ) { | 963 | for ( ; dit.current(); ++dit ) { |
954 | if( dit.current()->name() == file) { | 964 | if( dit.current()->name() == file) { |
955 | // qDebug(file); | 965 | // qDebug(file); |
956 | LnkProperties prop( dit.current() ); | 966 | LnkProperties prop( dit.current() ); |
957 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 967 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
958 | prop.showMaximized(); | 968 | prop.showMaximized(); |
959 | prop.exec(); | 969 | prop.exec(); |
960 | } | 970 | } |
961 | } | 971 | } |
962 | populateAudioView(); | 972 | populateAudioView(); |
963 | } | 973 | } |
964 | break; | 974 | break; |
965 | case 2: | 975 | case 2: |
966 | { | 976 | { |
967 | // file = videoView->selectedItem()->text(0); | 977 | // file = videoView->selectedItem()->text(0); |
968 | // for ( int i = 0; i < noOfFiles; i++ ) { | 978 | // for ( int i = 0; i < noOfFiles; i++ ) { |
969 | // QString entryName; | 979 | // QString entryName; |
970 | // entryName.sprintf( "File%i", i + 1 ); | 980 | // entryName.sprintf( "File%i", i + 1 ); |
971 | // QString linkFile = cfg.readEntry( entryName ); | 981 | // QString linkFile = cfg.readEntry( entryName ); |
972 | // AppLnk lnk( AppLnk(linkFile)); | 982 | // AppLnk lnk( AppLnk(linkFile)); |
973 | // if( lnk.name() == file ) { | 983 | // if( lnk.name() == file ) { |
974 | // LnkProperties prop( &lnk); | 984 | // LnkProperties prop( &lnk); |
975 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 985 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
976 | // prop.showMaximized(); | 986 | // prop.showMaximized(); |
977 | // prop.exec(); | 987 | // prop.exec(); |
978 | // } | 988 | // } |
979 | // } | 989 | // } |
980 | } | 990 | } |
981 | break; | 991 | break; |
982 | }; | 992 | }; |
983 | } | 993 | } |
984 | 994 | ||
985 | void PlayListWidget::scanForAudio() { | 995 | void PlayListWidget::scanForAudio() { |
986 | qDebug("scan for audio"); | 996 | qDebug("scan for audio"); |
987 | files.detachChildren(); | 997 | files.detachChildren(); |
988 | QListIterator<DocLnk> sdit( files.children() ); | 998 | QListIterator<DocLnk> sdit( files.children() ); |
989 | for ( ; sdit.current(); ++sdit ) { | 999 | for ( ; sdit.current(); ++sdit ) { |
990 | delete sdit.current(); | 1000 | delete sdit.current(); |
991 | } | 1001 | } |
992 | Global::findDocuments(&files, "audio/*"); | 1002 | Global::findDocuments(&files, "audio/*"); |
993 | audioScan = TRUE; | 1003 | audioScan = TRUE; |
994 | } | 1004 | } |
995 | void PlayListWidget::scanForVideo() { | 1005 | void PlayListWidget::scanForVideo() { |
996 | qDebug("scan for video"); | 1006 | qDebug("scan for video"); |
997 | vFiles.detachChildren(); | 1007 | vFiles.detachChildren(); |
998 | QListIterator<DocLnk> sdit( vFiles.children() ); | 1008 | QListIterator<DocLnk> sdit( vFiles.children() ); |
999 | for ( ; sdit.current(); ++sdit ) { | 1009 | for ( ; sdit.current(); ++sdit ) { |
1000 | delete sdit.current(); | 1010 | delete sdit.current(); |
1001 | } | 1011 | } |
1002 | Global::findDocuments(&vFiles, "video/*"); | 1012 | Global::findDocuments(&vFiles, "video/*"); |
1003 | videoScan = TRUE; | 1013 | videoScan = TRUE; |
1004 | } | 1014 | } |
1005 | 1015 | ||
1006 | void PlayListWidget::populateAudioView() { | 1016 | void PlayListWidget::populateAudioView() { |
1007 | 1017 | ||
1008 | audioView->clear(); | 1018 | audioView->clear(); |
1009 | StorageInfo storageInfo; | 1019 | StorageInfo storageInfo; |
1010 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 1020 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
1011 | if(!audioScan) scanForAudio(); | 1021 | if(!audioScan) scanForAudio(); |
1012 | 1022 | ||
1013 | QListIterator<DocLnk> dit( files.children() ); | 1023 | QListIterator<DocLnk> dit( files.children() ); |
1014 | QListIterator<FileSystem> it ( fs ); | 1024 | QListIterator<FileSystem> it ( fs ); |
1015 | 1025 | ||
1016 | QString storage; | 1026 | QString storage; |
1017 | for ( ; dit.current(); ++dit ) { | 1027 | for ( ; dit.current(); ++dit ) { |
1018 | for( ; it.current(); ++it ){ | 1028 | for( ; it.current(); ++it ){ |
1019 | const QString name = (*it)->name(); | 1029 | const QString name = (*it)->name(); |
1020 | const QString path = (*it)->path(); | 1030 | const QString path = (*it)->path(); |
1021 | if(dit.current()->file().find(path) != -1 ) storage=name; | 1031 | if(dit.current()->file().find(path) != -1 ) storage=name; |
1022 | } | 1032 | } |
1023 | 1033 | ||
1024 | QListViewItem * newItem; | 1034 | QListViewItem * newItem; |
1025 | if ( QFile( dit.current()->file()).exists() ) { | 1035 | if ( QFile( dit.current()->file()).exists() ) { |
1026 | // qDebug(dit.current()->name()); | 1036 | // qDebug(dit.current()->name()); |
1027 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 1037 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
1028 | QString::number( QFile( dit.current()->file()).size() ), storage); | 1038 | QString::number( QFile( dit.current()->file()).size() ), storage); |
1029 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); | 1039 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); |
1030 | } | 1040 | } |
1031 | } | 1041 | } |
1032 | 1042 | ||
1033 | } | 1043 | } |
1034 | 1044 | ||
1035 | void PlayListWidget::populateVideoView() { | 1045 | void PlayListWidget::populateVideoView() { |
1036 | videoView->clear(); | 1046 | videoView->clear(); |
1037 | StorageInfo storageInfo; | 1047 | StorageInfo storageInfo; |
1038 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 1048 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
1039 | 1049 | ||
1040 | if(!videoScan ) scanForVideo(); | 1050 | if(!videoScan ) scanForVideo(); |
1041 | 1051 | ||
1042 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 1052 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
1043 | QListIterator<FileSystem> it ( fs ); | 1053 | QListIterator<FileSystem> it ( fs ); |
1044 | videoView->clear(); | 1054 | videoView->clear(); |
1045 | QString storage; | 1055 | QString storage; |
1046 | for ( ; Vdit.current(); ++Vdit ) { | 1056 | for ( ; Vdit.current(); ++Vdit ) { |
1047 | for( ; it.current(); ++it ){ | 1057 | for( ; it.current(); ++it ){ |
1048 | const QString name = (*it)->name(); | 1058 | const QString name = (*it)->name(); |
1049 | const QString path = (*it)->path(); | 1059 | const QString path = (*it)->path(); |
1050 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 1060 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
1051 | } | 1061 | } |
1052 | 1062 | ||
1053 | QListViewItem * newItem; | 1063 | QListViewItem * newItem; |
1054 | if ( QFile( Vdit.current()->file()).exists() ) { | 1064 | if ( QFile( Vdit.current()->file()).exists() ) { |
1055 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 1065 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
1056 | QString::number( QFile( Vdit.current()->file()).size() ), storage); | 1066 | QString::number( QFile( Vdit.current()->file()).size() ), storage); |
1057 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); | 1067 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); |
1058 | } | 1068 | } |
1059 | } | 1069 | } |
1060 | } | 1070 | } |
1061 | 1071 | ||
1062 | void PlayListWidget::openFile() { | 1072 | void PlayListWidget::openFile() { |
1063 | QString filename, name; | 1073 | QString filename, name; |
1064 | InputDialog *fileDlg; | 1074 | InputDialog *fileDlg; |
1065 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 1075 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
1066 | fileDlg->exec(); | 1076 | fileDlg->exec(); |
1067 | if( fileDlg->result() == 1 ) { | 1077 | if( fileDlg->result() == 1 ) { |
1068 | filename = fileDlg->LineEdit1->text(); | 1078 | filename = fileDlg->LineEdit1->text(); |
1069 | // http://205.188.234.129:8030 | 1079 | // http://205.188.234.129:8030 |
1070 | // http://66.28.68.70:8000 | 1080 | // http://66.28.68.70:8000 |
1071 | filename.replace(QRegExp("%20")," "); | 1081 | // filename.replace(QRegExp("%20")," "); |
1072 | 1082 | if(filename.find(" ",0,TRUE) != -1 || filename.find("%20",0,TRUE) != -1) { | |
1073 | qDebug("Selected filename is "+filename); | 1083 | QMessageBox::message("Note","Spaces in urls are not allowed."); |
1084 | return; | ||
1085 | } else { | ||
1086 | qDebug("Selected filename is "+filename); | ||
1074 | if(filename.right(3) == "m3u") | 1087 | if(filename.right(3) == "m3u") |
1075 | readm3u( filename); | 1088 | readm3u( filename); |
1076 | else if(filename.right(3) == "pls") | 1089 | else if(filename.right(3) == "pls") |
1077 | readPls( filename); | 1090 | readPls( filename); |
1078 | else { | 1091 | else { |
1079 | DocLnk lnk; | 1092 | DocLnk lnk; |
1080 | 1093 | ||
1081 | lnk.setName(filename); //sets file name | 1094 | lnk.setName(filename); //sets file name |
1082 | if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3") | 1095 | if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3") |
1083 | filename += "/"; | 1096 | filename += "/"; |
1084 | lnk.setFile(filename); //sets File property | 1097 | lnk.setFile(filename); //sets File property |
1085 | 1098 | ||
1086 | lnk.setType("audio/x-mpegurl"); | 1099 | lnk.setType("audio/x-mpegurl"); |
1087 | lnk.setExec("opieplayer"); | 1100 | lnk.setExec("opieplayer"); |
1088 | lnk.setIcon("opieplayer/MPEGPlayer"); | 1101 | lnk.setIcon("opieplayer/MPEGPlayer"); |
1089 | 1102 | ||
1090 | if(!lnk.writeLink()) | 1103 | if(!lnk.writeLink()) |
1091 | qDebug("Writing doclink did not work"); | 1104 | qDebug("Writing doclink did not work"); |
1092 | d->selectedFiles->addToSelection( lnk); | 1105 | d->selectedFiles->addToSelection( lnk); |
1093 | // if(fileDlg2) | 1106 | // if(fileDlg2) |
1094 | // delete fileDlg2; | 1107 | // delete fileDlg2; |
1095 | } | 1108 | } |
1096 | } | 1109 | } |
1110 | } | ||
1097 | if(fileDlg) | 1111 | if(fileDlg) |
1098 | delete fileDlg; | 1112 | delete fileDlg; |
1099 | } | 1113 | } |
1100 | 1114 | ||
1101 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | 1115 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) |
1102 | { | 1116 | { |
1103 | switch ( e->key() ) { | 1117 | switch ( e->key() ) { |
1104 | ////////////////////////////// Zaurus keys | 1118 | ////////////////////////////// Zaurus keys |
1105 | case Key_F9: //activity | 1119 | case Key_F9: //activity |
1106 | // if(audioUI->isHidden()) | 1120 | // if(audioUI->isHidden()) |
1107 | // audioUI->showMaximized(); | 1121 | // audioUI->showMaximized(); |
1108 | break; | 1122 | break; |
1109 | case Key_F10: //contacts | 1123 | case Key_F10: //contacts |
1110 | // if( videoUI->isHidden()) | 1124 | // if( videoUI->isHidden()) |
1111 | // videoUI->showMaximized(); | 1125 | // videoUI->showMaximized(); |
1112 | break; | 1126 | break; |
1113 | case Key_F11: //menu | 1127 | case Key_F11: //menu |
1114 | break; | 1128 | break; |
1115 | case Key_F12: //home | 1129 | case Key_F12: //home |
1116 | // doBlank(); | 1130 | // doBlank(); |
1117 | break; | 1131 | break; |
1118 | case Key_F13: //mail | 1132 | case Key_F13: //mail |
1119 | // doUnblank(); | 1133 | // doUnblank(); |
1120 | break; | 1134 | break; |
1121 | case Key_Q: //add to playlist | 1135 | case Key_Q: //add to playlist |
1122 | qDebug("Add"); | 1136 | qDebug("Add"); |
1123 | addSelected(); | 1137 | addSelected(); |
1124 | break; | 1138 | break; |
1125 | case Key_R: //remove from playlist | 1139 | case Key_R: //remove from playlist |
1126 | removeSelected(); | 1140 | removeSelected(); |
1127 | break; | 1141 | break; |
1128 | // case Key_P: //play | 1142 | // case Key_P: //play |
1129 | // qDebug("Play"); | 1143 | // qDebug("Play"); |
1130 | // playSelected(); | 1144 | // playSelected(); |
1131 | // break; | 1145 | // break; |
1132 | case Key_Space: | 1146 | case Key_Space: |
1133 | qDebug("Play"); | 1147 | qDebug("Play"); |
1134 | // playSelected(); puh | 1148 | // playSelected(); puh |
1135 | break; | 1149 | break; |
1136 | case Key_1: | 1150 | case Key_1: |
1137 | tabWidget->setCurrentPage(0); | 1151 | tabWidget->setCurrentPage(0); |
1138 | break; | 1152 | break; |
1139 | case Key_2: | 1153 | case Key_2: |
1140 | tabWidget->setCurrentPage(1); | 1154 | tabWidget->setCurrentPage(1); |
1141 | break; | 1155 | break; |
1142 | case Key_3: | 1156 | case Key_3: |
1143 | tabWidget->setCurrentPage(2); | 1157 | tabWidget->setCurrentPage(2); |
1144 | break; | 1158 | break; |
1145 | case Key_4: | 1159 | case Key_4: |
1146 | tabWidget->setCurrentPage(3); | 1160 | tabWidget->setCurrentPage(3); |
1147 | break; | 1161 | break; |
1148 | } | 1162 | } |
1149 | } | 1163 | } |
1150 | 1164 | ||
1151 | void PlayListWidget::keyPressEvent( QKeyEvent *e) | 1165 | void PlayListWidget::keyPressEvent( QKeyEvent *e) |
1152 | { | 1166 | { |
1153 | // qDebug("Key press"); | 1167 | // qDebug("Key press"); |
1154 | // switch ( e->key() ) { | 1168 | // switch ( e->key() ) { |
1155 | // ////////////////////////////// Zaurus keys | 1169 | // ////////////////////////////// Zaurus keys |
1156 | // case Key_A: //add to playlist | 1170 | // case Key_A: //add to playlist |
1157 | // qDebug("Add"); | 1171 | // qDebug("Add"); |
1158 | // addSelected(); | 1172 | // addSelected(); |
1159 | // break; | 1173 | // break; |
1160 | // case Key_R: //remove from playlist | 1174 | // case Key_R: //remove from playlist |
1161 | // removeSelected(); | 1175 | // removeSelected(); |
1162 | // break; | 1176 | // break; |
1163 | // case Key_P: //play | 1177 | // case Key_P: //play |
1164 | // qDebug("Play"); | 1178 | // qDebug("Play"); |
1165 | // playSelected(); | 1179 | // playSelected(); |
1166 | // break; | 1180 | // break; |
1167 | // case Key_Space: | 1181 | // case Key_Space: |
1168 | // qDebug("Play"); | 1182 | // qDebug("Play"); |
1169 | // playSelected(); | 1183 | // playSelected(); |
1170 | // break; | 1184 | // break; |
1171 | // } | 1185 | // } |
1172 | } | 1186 | } |
1173 | 1187 | ||
1174 | void PlayListWidget::doBlank() { | 1188 | void PlayListWidget::doBlank() { |
1175 | qDebug("do blanking"); | 1189 | qDebug("do blanking"); |
1176 | fd=open("/dev/fb0",O_RDWR); | 1190 | fd=open("/dev/fb0",O_RDWR); |
1177 | if (fd != -1) { | 1191 | if (fd != -1) { |
1178 | ioctl(fd,FBIOBLANK,1); | 1192 | ioctl(fd,FBIOBLANK,1); |
1179 | // close(fd); | 1193 | // close(fd); |
1180 | } | 1194 | } |
1181 | } | 1195 | } |
1182 | 1196 | ||
1183 | void PlayListWidget::doUnblank() { | 1197 | void PlayListWidget::doUnblank() { |
1184 | // this crashes opieplayer with a segfault | 1198 | // this crashes opieplayer with a segfault |
1185 | // int fd; | 1199 | // int fd; |
1186 | // fd=open("/dev/fb0",O_RDWR); | 1200 | // fd=open("/dev/fb0",O_RDWR); |
1187 | qDebug("do unblanking"); | 1201 | qDebug("do unblanking"); |
1188 | if (fd != -1) { | 1202 | if (fd != -1) { |
1189 | ioctl(fd,FBIOBLANK,0); | 1203 | ioctl(fd,FBIOBLANK,0); |
1190 | close(fd); | 1204 | close(fd); |
1191 | } | 1205 | } |
1192 | QCopEnvelope h("QPE/System", "setBacklight(int)"); | 1206 | QCopEnvelope h("QPE/System", "setBacklight(int)"); |
1193 | h <<-3;// v[1]; // -3 Force on | 1207 | h <<-3;// v[1]; // -3 Force on |
1194 | } | 1208 | } |
1195 | 1209 | ||
1196 | void PlayListWidget::readm3u(const QString &filename) { | 1210 | void PlayListWidget::readm3u(const QString &filename) { |
1197 | 1211 | ||
1198 | qDebug("m3u filename is "+filename); | 1212 | qDebug("m3u filename is "+filename); |
1199 | QFile f(filename); | 1213 | QFile f(filename); |
1200 | 1214 | ||
1201 | if(f.open(IO_ReadOnly)) { | 1215 | if(f.open(IO_ReadOnly)) { |
1202 | QTextStream t(&f); | 1216 | QTextStream t(&f); |
1203 | QString s;//, first, second; | 1217 | QString s;//, first, second; |
1204 | int i=0; | 1218 | int i=0; |
1205 | while ( !t.atEnd()) { | 1219 | while ( !t.atEnd()) { |
1206 | // Lview->insertLine(t.readLine(),-1); | 1220 | // Lview->insertLine(t.readLine(),-1); |
1207 | s=t.readLine(); | 1221 | s=t.readLine(); |
1208 | if(s.find("#",0,TRUE) == -1) { | 1222 | if(s.find(" ",0,TRUE) != -1 || s.find("%20",0,TRUE) != -1) { |
1223 | QMessageBox::message("Note","Spaces in urls are not allowed."); | ||
1224 | } | ||
1225 | else if(s.find("#",0,TRUE) == -1) { | ||
1209 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat | 1226 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat |
1210 | if(s.left(2) == "E:" || s.left(2) == "P:") { | 1227 | if(s.left(2) == "E:" || s.left(2) == "P:") { |
1211 | s=s.right(s.length()-2); | 1228 | s=s.right(s.length()-2); |
1212 | DocLnk lnk( s ); | 1229 | DocLnk lnk( s ); |
1213 | QFileInfo f(s); | 1230 | QFileInfo f(s); |
1214 | QString name = f.baseName(); | 1231 | QString name = f.baseName(); |
1215 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | 1232 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); |
1216 | lnk.setName( name); | 1233 | lnk.setName( name); |
1217 | s=s.replace( QRegExp("\\"),"/"); | 1234 | s=s.replace( QRegExp("\\"),"/"); |
1218 | lnk.setFile( s); | 1235 | lnk.setFile( s); |
1219 | // lnk.setIcon(opieplayer/MPEGPlayer); | 1236 | // lnk.setIcon(opieplayer/MPEGPlayer); |
1220 | qDebug("add "+name); | 1237 | qDebug("add "+name); |
1221 | d->selectedFiles->addToSelection( lnk); | 1238 | d->selectedFiles->addToSelection( lnk); |
1222 | } else { // is url | 1239 | } else { // is url |
1240 | |||
1223 | s.replace(QRegExp("%20")," "); | 1241 | s.replace(QRegExp("%20")," "); |
1224 | DocLnk lnk( s); | 1242 | DocLnk lnk( s); |
1225 | QString name = s.right( s.length() - 7); | 1243 | QString name = s.right( s.length() - 7); |
1226 | // name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | 1244 | // name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); |
1227 | lnk.setName(name); | 1245 | lnk.setName(name); |
1228 | lnk.setFile( s+"/"); | 1246 | lnk.setFile( s+"/"); |
1229 | // lnk.setFile( filename); | 1247 | // lnk.setFile( filename); |
1230 | // lnk.setComment( s+"/"); | 1248 | // lnk.setComment( s+"/"); |
1231 | lnk.setType("audio/x-mpegurl"); | 1249 | lnk.setType("audio/x-mpegurl"); |
1232 | // lnk.setIcon( "opieplayer/MPEGPlayer"); | 1250 | // lnk.setIcon( "opieplayer/MPEGPlayer"); |
1233 | // qDebug("add "+s); | 1251 | // qDebug("add "+s); |
1234 | d->selectedFiles->addToSelection( lnk); | 1252 | d->selectedFiles->addToSelection( lnk); |
1235 | } | 1253 | } |
1236 | i++; | 1254 | i++; |
1237 | } | 1255 | } |
1238 | } | 1256 | } |
1239 | } | 1257 | } |
1240 | } | 1258 | } |
1259 | f.close(); | ||
1241 | } | 1260 | } |
1242 | 1261 | ||
1243 | void PlayListWidget::writem3u(const QString &filename) { | 1262 | void PlayListWidget::writem3u(const QString &filename) { |
1244 | 1263 | ||
1245 | } | 1264 | } |
1246 | 1265 | ||
1247 | void PlayListWidget::readPls(const QString &filename) { | 1266 | void PlayListWidget::readPls(const QString &filename) { |
1248 | 1267 | ||
1249 | qDebug("pls filename is "+filename); | 1268 | qDebug("pls filename is "+filename); |
1250 | QFile f(filename); | 1269 | QFile f(filename); |
1251 | 1270 | ||
1252 | if(f.open(IO_ReadOnly)) { | 1271 | if(f.open(IO_ReadOnly)) { |
1253 | QTextStream t(&f); | 1272 | QTextStream t(&f); |
1254 | QString s;//, first, second; | 1273 | QString s;//, first, second; |
1255 | int i=0; | 1274 | int i=0; |
1256 | while ( !t.atEnd()) { | 1275 | while ( !t.atEnd()) { |
1257 | s=t.readLine(); | 1276 | s=t.readLine(); |
1258 | if(s.left(4) == "File") { | 1277 | if(s.left(4) == "File") { |
1259 | s=s.right(s.length() - 6); | 1278 | s=s.right(s.length() - 6); |
1260 | s.replace(QRegExp("%20")," "); | 1279 | s.replace(QRegExp("%20")," "); |
1261 | qDebug("adding "+s+" to playlist"); | 1280 | qDebug("adding "+s+" to playlist"); |
1262 | // numberofentries=2 | 1281 | // numberofentries=2 |
1263 | // File1=http | 1282 | // File1=http |
1264 | // Title | 1283 | // Title |
1265 | // Length | 1284 | // Length |
1266 | // Version | 1285 | // Version |
1267 | // File2=http | 1286 | // File2=http |
1268 | 1287 | ||
1269 | s=s.replace( QRegExp("\\"),"/"); | 1288 | s=s.replace( QRegExp("\\"),"/"); |
1270 | // Lview->insertLine(t.readLine(),-1); | 1289 | // Lview->insertLine(t.readLine(),-1); |
1271 | // s=t.readLine(); | 1290 | // s=t.readLine(); |
1272 | // s=s.right(s.length()-2); | 1291 | // s=s.right(s.length()-2); |
1273 | DocLnk lnk( s ); | 1292 | DocLnk lnk( s ); |
1274 | QFileInfo f(s); | 1293 | QFileInfo f(s); |
1275 | QString name = f.baseName(); | 1294 | QString name = f.baseName(); |
1276 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | 1295 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); |
1277 | // QFileInfo f(s); | 1296 | // QFileInfo f(s); |
1278 | // QString name = f.baseName(); | 1297 | // QString name = f.baseName(); |
1279 | // // name = name.left(name.length()-4); | 1298 | // // name = name.left(name.length()-4); |
1280 | // name = name.right(name.findRev("/",0,TRUE)); | 1299 | // name = name.right(name.findRev("/",0,TRUE)); |
1281 | lnk.setName( name); | 1300 | lnk.setName( name); |
1282 | lnk.setFile( s+"/"); | 1301 | lnk.setFile( s+"/"); |
1283 | lnk.setType("audio/x-mpegurl"); | 1302 | lnk.setType("audio/x-mpegurl"); |
1284 | 1303 | ||
1285 | qDebug("DocLnk add "+name); | 1304 | qDebug("DocLnk add "+name); |
1286 | d->selectedFiles->addToSelection( lnk); | 1305 | d->selectedFiles->addToSelection( lnk); |
1287 | } | 1306 | } |
1288 | } | 1307 | } |
1289 | i++; | 1308 | i++; |
1290 | } | 1309 | } |
1291 | } | 1310 | } |
1292 | 1311 | ||