author | llornkcor <llornkcor> | 2002-08-16 02:46:12 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-08-16 02:46:12 (UTC) |
commit | 40527ffb82b83ad521ed766f11b47636db055ffe (patch) (unidiff) | |
tree | d94fb1f21fa57b9dfbe2aa45beab05de024c97a3 | |
parent | f25db7780ff234b2770ac13d8c02887b79a57a26 (diff) | |
download | opie-40527ffb82b83ad521ed766f11b47636db055ffe.zip opie-40527ffb82b83ad521ed766f11b47636db055ffe.tar.gz opie-40527ffb82b83ad521ed766f11b47636db055ffe.tar.bz2 |
check for local file existing before adding to playlist
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index e33998f..612fd45 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -229,198 +229,200 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
229 | tabWidget->insertTab(aTab,tr("Audio")); | 229 | tabWidget->insertTab(aTab,tr("Audio")); |
230 | 230 | ||
231 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); | 231 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); |
232 | 232 | ||
233 | QWidget *vTab; | 233 | QWidget *vTab; |
234 | vTab = new QWidget( tabWidget, "vTab" ); | 234 | vTab = new QWidget( tabWidget, "vTab" ); |
235 | videoView = new QListView( vTab, "Videoview" ); | 235 | videoView = new QListView( vTab, "Videoview" ); |
236 | videoView->setMinimumSize(233,260); | 236 | videoView->setMinimumSize(233,260); |
237 | 237 | ||
238 | videoView->addColumn(tr("Title"),140); | 238 | videoView->addColumn(tr("Title"),140); |
239 | videoView->addColumn(tr("Size"),-1); | 239 | videoView->addColumn(tr("Size"),-1); |
240 | videoView->addColumn(tr("Media"),-1); | 240 | videoView->addColumn(tr("Media"),-1); |
241 | videoView->setColumnAlignment(1, Qt::AlignRight); | 241 | videoView->setColumnAlignment(1, Qt::AlignRight); |
242 | videoView->setColumnAlignment(2, Qt::AlignRight); | 242 | videoView->setColumnAlignment(2, Qt::AlignRight); |
243 | videoView->setAllColumnsShowFocus(TRUE); | 243 | videoView->setAllColumnsShowFocus(TRUE); |
244 | videoView->setMultiSelection( TRUE ); | 244 | videoView->setMultiSelection( TRUE ); |
245 | videoView->setSelectionMode( QListView::Extended); | 245 | videoView->setSelectionMode( QListView::Extended); |
246 | 246 | ||
247 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | 247 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); |
248 | 248 | ||
249 | tabWidget->insertTab( vTab,tr("Video")); | 249 | tabWidget->insertTab( vTab,tr("Video")); |
250 | 250 | ||
251 | //playlists list | 251 | //playlists list |
252 | QWidget *LTab; | 252 | QWidget *LTab; |
253 | LTab = new QWidget( tabWidget, "LTab" ); | 253 | LTab = new QWidget( tabWidget, "LTab" ); |
254 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy | 254 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy |
255 | playLists->setMinimumSize(233,260); | 255 | playLists->setMinimumSize(233,260); |
256 | tabWidget->insertTab(LTab,tr("Lists")); | 256 | tabWidget->insertTab(LTab,tr("Lists")); |
257 | 257 | ||
258 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); | 258 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); |
259 | 259 | ||
260 | connect( pmView, SIGNAL( activated(int)), this, SLOT( pmViewActivated(int) ) ); | 260 | connect( pmView, SIGNAL( activated(int)), this, SLOT( pmViewActivated(int) ) ); |
261 | 261 | ||
262 | connect( skinsMenu, SIGNAL( activated(int)), this, SLOT(skinsMenuActivated(int) ) ); | 262 | connect( skinsMenu, SIGNAL( activated(int)), this, SLOT(skinsMenuActivated(int) ) ); |
263 | 263 | ||
264 | // connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled() ) ); | 264 | // connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled() ) ); |
265 | 265 | ||
266 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 266 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
267 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); | 267 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); |
268 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 268 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
269 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 269 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
270 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), | 270 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), |
271 | this,SLOT( playIt( QListViewItem *)) ); | 271 | this,SLOT( playIt( QListViewItem *)) ); |
272 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 272 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
273 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 273 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
274 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 274 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
275 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), | 275 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), |
276 | this,SLOT( playIt( QListViewItem *)) ); | 276 | this,SLOT( playIt( QListViewItem *)) ); |
277 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 277 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
278 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 278 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
279 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 279 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
280 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 280 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
281 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 281 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
282 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 282 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
283 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 283 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
284 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 284 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
285 | 285 | ||
286 | setCentralWidget( vbox5 ); | 286 | setCentralWidget( vbox5 ); |
287 | 287 | ||
288 | readConfig( cfg ); | 288 | readConfig( cfg ); |
289 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 289 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
290 | loadList(DocLnk( currentPlaylist)); | 290 | loadList(DocLnk( currentPlaylist)); |
291 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); | 291 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); |
292 | 292 | ||
293 | initializeStates(); | 293 | initializeStates(); |
294 | } | 294 | } |
295 | 295 | ||
296 | 296 | ||
297 | PlayListWidget::~PlayListWidget() { | 297 | PlayListWidget::~PlayListWidget() { |
298 | Config cfg( "OpiePlayer" ); | 298 | Config cfg( "OpiePlayer" ); |
299 | writeConfig( cfg ); | 299 | writeConfig( cfg ); |
300 | 300 | ||
301 | if ( d->current ) { | 301 | if ( d->current ) { |
302 | delete d->current; | 302 | delete d->current; |
303 | } | 303 | } |
304 | delete d; | 304 | delete d; |
305 | } | 305 | } |
306 | 306 | ||
307 | 307 | ||
308 | void PlayListWidget::initializeStates() { | 308 | void PlayListWidget::initializeStates() { |
309 | 309 | ||
310 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 310 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
311 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 311 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
312 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 312 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
313 | setPlaylist( true); | 313 | setPlaylist( true); |
314 | } | 314 | } |
315 | 315 | ||
316 | 316 | ||
317 | void PlayListWidget::readConfig( Config& cfg ) { | 317 | void PlayListWidget::readConfig( Config& cfg ) { |
318 | cfg.setGroup("PlayList"); | 318 | cfg.setGroup("PlayList"); |
319 | QString currentString = cfg.readEntry("current", "" ); | 319 | QString currentString = cfg.readEntry("current", "" ); |
320 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 320 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
321 | for ( int i = 0; i < noOfFiles; i++ ) { | 321 | for ( int i = 0; i < noOfFiles; i++ ) { |
322 | QString entryName; | 322 | QString entryName; |
323 | entryName.sprintf( "File%i", i + 1 ); | 323 | entryName.sprintf( "File%i", i + 1 ); |
324 | QString linkFile = cfg.readEntry( entryName ); | 324 | QString linkFile = cfg.readEntry( entryName ); |
325 | DocLnk lnk( linkFile ); | 325 | if(QFileInfo( linkFile).exists() ) { |
326 | if ( lnk.isValid() ) { | 326 | DocLnk lnk( linkFile ); |
327 | d->selectedFiles->addToSelection( lnk ); | 327 | if ( QFileInfo( lnk.file()).exists() || linkFile.find("http",0,TRUE) != -1) { |
328 | d->selectedFiles->addToSelection( lnk ); | ||
329 | } | ||
328 | } | 330 | } |
329 | } | 331 | } |
330 | d->selectedFiles->setSelectedItem( currentString); | 332 | d->selectedFiles->setSelectedItem( currentString); |
331 | } | 333 | } |
332 | 334 | ||
333 | 335 | ||
334 | void PlayListWidget::writeConfig( Config& cfg ) const { | 336 | void PlayListWidget::writeConfig( Config& cfg ) const { |
335 | 337 | ||
336 | d->selectedFiles->writeCurrent( cfg); | 338 | d->selectedFiles->writeCurrent( cfg); |
337 | cfg.setGroup("PlayList"); | 339 | cfg.setGroup("PlayList"); |
338 | int noOfFiles = 0; | 340 | int noOfFiles = 0; |
339 | d->selectedFiles->first(); | 341 | d->selectedFiles->first(); |
340 | do { | 342 | do { |
341 | const DocLnk *lnk = d->selectedFiles->current(); | 343 | const DocLnk *lnk = d->selectedFiles->current(); |
342 | if ( lnk ) { | 344 | if ( lnk ) { |
343 | QString entryName; | 345 | QString entryName; |
344 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 346 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
345 | cfg.writeEntry( entryName, lnk->linkFile() ); | 347 | cfg.writeEntry( entryName, lnk->linkFile() ); |
346 | // if this link does exist, add it so we have the file | 348 | // if this link does exist, add it so we have the file |
347 | // next time... | 349 | // next time... |
348 | if ( !QFile::exists( lnk->linkFile() ) ) { | 350 | if ( !QFile::exists( lnk->linkFile() ) ) { |
349 | // the way writing lnks doesn't really check for out | 351 | // the way writing lnks doesn't really check for out |
350 | // of disk space, but check it anyway. | 352 | // of disk space, but check it anyway. |
351 | if ( !lnk->writeLink() ) { | 353 | if ( !lnk->writeLink() ) { |
352 | QMessageBox::critical( 0, tr("Out of space"), | 354 | QMessageBox::critical( 0, tr("Out of space"), |
353 | tr( "There was a problem saving " | 355 | tr( "There was a problem saving " |
354 | "the playlist.\n" | 356 | "the playlist.\n" |
355 | "Your playlist " | 357 | "Your playlist " |
356 | "may be missing some entries\n" | 358 | "may be missing some entries\n" |
357 | "the next time you start it." ) | 359 | "the next time you start it." ) |
358 | ); | 360 | ); |
359 | } | 361 | } |
360 | } | 362 | } |
361 | noOfFiles++; | 363 | noOfFiles++; |
362 | } | 364 | } |
363 | } | 365 | } |
364 | while ( d->selectedFiles->next() ); | 366 | while ( d->selectedFiles->next() ); |
365 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 367 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
366 | } | 368 | } |
367 | 369 | ||
368 | 370 | ||
369 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 371 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
370 | d->setDocumentUsed = FALSE; | 372 | d->setDocumentUsed = FALSE; |
371 | if ( mediaPlayerState->playlist() ) { | 373 | if ( mediaPlayerState->playlist() ) { |
372 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) | 374 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) |
373 | d->selectedFiles->addToSelection( lnk ); | 375 | d->selectedFiles->addToSelection( lnk ); |
374 | } | 376 | } |
375 | else | 377 | else |
376 | mediaPlayerState->setPlaying( TRUE ); | 378 | mediaPlayerState->setPlaying( TRUE ); |
377 | } | 379 | } |
378 | 380 | ||
379 | 381 | ||
380 | void PlayListWidget::clearList() { | 382 | void PlayListWidget::clearList() { |
381 | while ( first() ) { | 383 | while ( first() ) { |
382 | d->selectedFiles->removeSelected(); | 384 | d->selectedFiles->removeSelected(); |
383 | } | 385 | } |
384 | } | 386 | } |
385 | 387 | ||
386 | 388 | ||
387 | void PlayListWidget::addAllToList() { | 389 | void PlayListWidget::addAllToList() { |
388 | DocLnkSet filesAll; | 390 | DocLnkSet filesAll; |
389 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 391 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
390 | QListIterator<DocLnk> Adit( filesAll.children() ); | 392 | QListIterator<DocLnk> Adit( filesAll.children() ); |
391 | for ( ; Adit.current(); ++Adit ) { | 393 | for ( ; Adit.current(); ++Adit ) { |
392 | if(QFileInfo(Adit.current()->file()).exists()) { | 394 | if(QFileInfo(Adit.current()->file()).exists()) { |
393 | d->selectedFiles->addToSelection( **Adit ); | 395 | d->selectedFiles->addToSelection( **Adit ); |
394 | } | 396 | } |
395 | } | 397 | } |
396 | } | 398 | } |
397 | 399 | ||
398 | 400 | ||
399 | void PlayListWidget::addAllMusicToList() { | 401 | void PlayListWidget::addAllMusicToList() { |
400 | QListIterator<DocLnk> dit( files.children() ); | 402 | QListIterator<DocLnk> dit( files.children() ); |
401 | for ( ; dit.current(); ++dit ) { | 403 | for ( ; dit.current(); ++dit ) { |
402 | if(QFileInfo(dit.current()->file()).exists()) { | 404 | if(QFileInfo(dit.current()->file()).exists()) { |
403 | d->selectedFiles->addToSelection( **dit ); | 405 | d->selectedFiles->addToSelection( **dit ); |
404 | } | 406 | } |
405 | } | 407 | } |
406 | } | 408 | } |
407 | 409 | ||
408 | 410 | ||
409 | void PlayListWidget::addAllVideoToList() { | 411 | void PlayListWidget::addAllVideoToList() { |
410 | QListIterator<DocLnk> dit( vFiles.children() ); | 412 | QListIterator<DocLnk> dit( vFiles.children() ); |
411 | for ( ; dit.current(); ++dit ) | 413 | for ( ; dit.current(); ++dit ) |
412 | if(QFileInfo( dit.current()->file()).exists()) | 414 | if(QFileInfo( dit.current()->file()).exists()) |
413 | d->selectedFiles->addToSelection( **dit ); | 415 | d->selectedFiles->addToSelection( **dit ); |
414 | } | 416 | } |
415 | 417 | ||
416 | 418 | ||
417 | void PlayListWidget::setDocument(const QString& fileref) { | 419 | void PlayListWidget::setDocument(const QString& fileref) { |
418 | qDebug(fileref); | 420 | qDebug(fileref); |
419 | fromSetDocument = TRUE; | 421 | fromSetDocument = TRUE; |
420 | if ( fileref.isNull() ) { | 422 | if ( fileref.isNull() ) { |
421 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 423 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
422 | return; | 424 | return; |
423 | } | 425 | } |
424 | 426 | ||
425 | if(fileref.find("m3u",0,TRUE) != -1) { //is m3u | 427 | if(fileref.find("m3u",0,TRUE) != -1) { //is m3u |
426 | readm3u( fileref); | 428 | readm3u( fileref); |
@@ -558,252 +560,256 @@ bool PlayListWidget::first() { | |||
558 | } | 560 | } |
559 | 561 | ||
560 | 562 | ||
561 | bool PlayListWidget::last() { | 563 | bool PlayListWidget::last() { |
562 | if ( mediaPlayerState->playlist() ) | 564 | if ( mediaPlayerState->playlist() ) |
563 | return d->selectedFiles->last(); | 565 | return d->selectedFiles->last(); |
564 | else | 566 | else |
565 | return mediaPlayerState->looping(); | 567 | return mediaPlayerState->looping(); |
566 | } | 568 | } |
567 | 569 | ||
568 | 570 | ||
569 | void PlayListWidget::saveList() { | 571 | void PlayListWidget::saveList() { |
570 | 572 | ||
571 | QString filename; | 573 | QString filename; |
572 | InputDialog *fileDlg; | 574 | InputDialog *fileDlg; |
573 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); | 575 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); |
574 | fileDlg->exec(); | 576 | fileDlg->exec(); |
575 | if( fileDlg->result() == 1 ) { | 577 | if( fileDlg->result() == 1 ) { |
576 | if ( d->current ) | 578 | if ( d->current ) |
577 | delete d->current; | 579 | delete d->current; |
578 | filename = fileDlg->LineEdit1->text();//+".playlist"; | 580 | filename = fileDlg->LineEdit1->text();//+".playlist"; |
579 | // qDebug("saving playlist "+filename+".playlist"); | 581 | // qDebug("saving playlist "+filename+".playlist"); |
580 | Config cfg( filename +".playlist"); | 582 | Config cfg( filename +".playlist"); |
581 | writeConfig( cfg ); | 583 | writeConfig( cfg ); |
582 | 584 | ||
583 | DocLnk lnk; | 585 | DocLnk lnk; |
584 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property | 586 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property |
585 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | 587 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D |
586 | lnk.setIcon("opieplayer2/playlist2"); | 588 | lnk.setIcon("opieplayer2/playlist2"); |
587 | lnk.setName( filename); //sets file name | 589 | lnk.setName( filename); //sets file name |
588 | // qDebug(filename); | 590 | // qDebug(filename); |
589 | if(!lnk.writeLink()) { | 591 | if(!lnk.writeLink()) { |
590 | qDebug("Writing doclink did not work"); | 592 | qDebug("Writing doclink did not work"); |
591 | } | 593 | } |
592 | } | 594 | } |
593 | Config config( "OpiePlayer" ); | 595 | Config config( "OpiePlayer" ); |
594 | config.writeEntry("CurrentPlaylist",filename); | 596 | config.writeEntry("CurrentPlaylist",filename); |
595 | setCaption(tr("OpiePlayer: ")+filename); | 597 | setCaption(tr("OpiePlayer: ")+filename); |
596 | d->selectedFiles->first(); | 598 | d->selectedFiles->first(); |
597 | if(fileDlg) { | 599 | if(fileDlg) { |
598 | delete fileDlg; | 600 | delete fileDlg; |
599 | } | 601 | } |
600 | } | 602 | } |
601 | 603 | ||
602 | void PlayListWidget::loadList( const DocLnk & lnk) { | 604 | void PlayListWidget::loadList( const DocLnk & lnk) { |
603 | QString name= lnk.name(); | 605 | QString name= lnk.name(); |
604 | // qDebug("currentList is "+name); | 606 | // qDebug("currentList is "+name); |
605 | if( name.length()>1) { | 607 | if( name.length()>1) { |
606 | setCaption("OpiePlayer: "+name); | 608 | setCaption("OpiePlayer: "+name); |
607 | // qDebug("load list "+ name+".playlist"); | 609 | // qDebug("load list "+ name+".playlist"); |
608 | clearList(); | 610 | clearList(); |
609 | Config cfg( name+".playlist"); | 611 | Config cfg( name+".playlist"); |
610 | readConfig(cfg); | 612 | readConfig(cfg); |
611 | 613 | ||
612 | tabWidget->setCurrentPage(0); | 614 | tabWidget->setCurrentPage(0); |
613 | 615 | ||
614 | Config config( "OpiePlayer" ); | 616 | Config config( "OpiePlayer" ); |
615 | config.writeEntry("CurrentPlaylist", name); | 617 | config.writeEntry("CurrentPlaylist", name); |
616 | // d->selectedFiles->first(); | 618 | // d->selectedFiles->first(); |
617 | } | 619 | } |
618 | 620 | ||
619 | } | 621 | } |
620 | 622 | ||
621 | void PlayListWidget::setPlaylist( bool shown ) { | 623 | void PlayListWidget::setPlaylist( bool shown ) { |
622 | if ( shown ) { | 624 | if ( shown ) { |
623 | d->playListFrame->show(); | 625 | d->playListFrame->show(); |
624 | } else { | 626 | } else { |
625 | d->playListFrame->hide(); | 627 | d->playListFrame->hide(); |
626 | } | 628 | } |
627 | } | 629 | } |
628 | 630 | ||
629 | void PlayListWidget::setView( char view ) { | 631 | void PlayListWidget::setView( char view ) { |
630 | if ( view == 'l' ) | 632 | if ( view == 'l' ) |
631 | showMaximized(); | 633 | showMaximized(); |
632 | else | 634 | else |
633 | hide(); | 635 | hide(); |
634 | } | 636 | } |
635 | 637 | ||
636 | void PlayListWidget::addSelected() { | 638 | void PlayListWidget::addSelected() { |
637 | 639 | ||
638 | Config cfg( "OpiePlayer" ); | 640 | Config cfg( "OpiePlayer" ); |
639 | cfg.setGroup("PlayList"); | 641 | cfg.setGroup("PlayList"); |
640 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 642 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
641 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 643 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
642 | 644 | ||
643 | switch (tabWidget->currentPageIndex()) { | 645 | switch (tabWidget->currentPageIndex()) { |
644 | case 0: //playlist | 646 | case 0: //playlist |
645 | break; | 647 | break; |
646 | case 1: { //audio | 648 | case 1: { //audio |
647 | QListViewItemIterator it( audioView ); | 649 | QListViewItemIterator it( audioView ); |
648 | // iterate through all items of the listview | 650 | // iterate through all items of the listview |
649 | for ( ; it.current(); ++it ) { | 651 | for ( ; it.current(); ++it ) { |
650 | if ( it.current()->isSelected() ) { | 652 | if ( it.current()->isSelected() ) { |
651 | QListIterator<DocLnk> dit( files.children() ); | 653 | QListIterator<DocLnk> dit( files.children() ); |
652 | for ( ; dit.current(); ++dit ) { | 654 | for ( ; dit.current(); ++dit ) { |
653 | if( dit.current()->name() == it.current()->text(0) ) { | 655 | if( dit.current()->name() == it.current()->text(0) ) { |
654 | d->selectedFiles->addToSelection( **dit ); | 656 | if(QFileInfo( dit.current()->file()).exists()) |
657 | d->selectedFiles->addToSelection( **dit ); | ||
655 | } | 658 | } |
656 | } | 659 | } |
657 | audioView->setSelected( it.current(),FALSE); | 660 | audioView->setSelected( it.current(),FALSE); |
658 | } | 661 | } |
659 | } | 662 | } |
660 | tabWidget->setCurrentPage(0); | 663 | tabWidget->setCurrentPage(0); |
661 | } | 664 | } |
662 | break; | 665 | break; |
663 | case 2: { // video | 666 | case 2: { // video |
664 | QListViewItemIterator it( videoView ); | 667 | QListViewItemIterator it( videoView ); |
665 | // iterate through all items of the listview | 668 | // iterate through all items of the listview |
666 | for ( ; it.current(); ++it ) { | 669 | for ( ; it.current(); ++it ) { |
667 | if ( it.current()->isSelected() ) { | 670 | if ( it.current()->isSelected() ) { |
668 | QListIterator<DocLnk> dit( vFiles.children() ); | 671 | QListIterator<DocLnk> dit( vFiles.children() ); |
669 | for ( ; dit.current(); ++dit ) { | 672 | for ( ; dit.current(); ++dit ) { |
670 | if( dit.current()->name() == it.current()->text(0) ) { | 673 | if( dit.current()->name() == it.current()->text(0) ) { |
671 | d->selectedFiles->addToSelection( **dit ); | 674 | if(QFileInfo( dit.current()->file()).exists()) |
675 | d->selectedFiles->addToSelection( **dit ); | ||
672 | } | 676 | } |
673 | } | 677 | } |
674 | videoView->setSelected( it.current(),FALSE); | 678 | videoView->setSelected( it.current(),FALSE); |
675 | } | 679 | } |
676 | } | 680 | } |
677 | tabWidget->setCurrentPage(0); | 681 | tabWidget->setCurrentPage(0); |
678 | } | 682 | } |
679 | break; | 683 | break; |
680 | }; | 684 | }; |
681 | } | 685 | } |
682 | 686 | ||
683 | void PlayListWidget::removeSelected() { | 687 | void PlayListWidget::removeSelected() { |
684 | d->selectedFiles->removeSelected( ); | 688 | d->selectedFiles->removeSelected( ); |
685 | } | 689 | } |
686 | 690 | ||
687 | void PlayListWidget::playIt( QListViewItem *it) { | 691 | void PlayListWidget::playIt( QListViewItem *it) { |
688 | // if(it==NULL) return; | 692 | // if(it==NULL) return; |
689 | qDebug("playIt"); | 693 | qDebug("playIt"); |
690 | mediaPlayerState->setPlaying(FALSE); | 694 | mediaPlayerState->setPlaying(FALSE); |
691 | mediaPlayerState->setPlaying(TRUE); | 695 | mediaPlayerState->setPlaying(TRUE); |
692 | d->selectedFiles->unSelect(); | 696 | d->selectedFiles->unSelect(); |
693 | } | 697 | } |
694 | 698 | ||
695 | void PlayListWidget::addToSelection( QListViewItem *it) { | 699 | void PlayListWidget::addToSelection( QListViewItem *it) { |
696 | d->setDocumentUsed = FALSE; | 700 | d->setDocumentUsed = FALSE; |
697 | 701 | ||
698 | if(it) { | 702 | if(it) { |
699 | switch (tabWidget->currentPageIndex()) { | 703 | switch (tabWidget->currentPageIndex()) { |
700 | case 1: { | 704 | case 1: { |
701 | QListIterator<DocLnk> dit( files.children() ); | 705 | QListIterator<DocLnk> dit( files.children() ); |
702 | for ( ; dit.current(); ++dit ) { | 706 | for ( ; dit.current(); ++dit ) { |
703 | if( dit.current()->name() == it->text(0)) { | 707 | if( dit.current()->name() == it->text(0)) { |
704 | d->selectedFiles->addToSelection( **dit ); | 708 | if(QFileInfo( dit.current()->file()).exists()) |
709 | d->selectedFiles->addToSelection( **dit ); | ||
705 | } | 710 | } |
706 | } | 711 | } |
707 | } | 712 | } |
708 | break; | 713 | break; |
709 | case 2: { | 714 | case 2: { |
710 | QListIterator<DocLnk> dit( vFiles.children() ); | 715 | QListIterator<DocLnk> dit( vFiles.children() ); |
711 | for ( ; dit.current(); ++dit ) { | 716 | for ( ; dit.current(); ++dit ) { |
712 | if( dit.current()->name() == it->text(0)) { | 717 | if( dit.current()->name() == it->text(0)) { |
713 | d->selectedFiles->addToSelection( **dit ); | 718 | if(QFileInfo( dit.current()->file()).exists()) |
719 | d->selectedFiles->addToSelection( **dit ); | ||
714 | } | 720 | } |
715 | } | 721 | } |
716 | } | 722 | } |
717 | break; | 723 | break; |
718 | case 0: | 724 | case 0: |
719 | break; | 725 | break; |
720 | }; | 726 | }; |
721 | tabWidget->setCurrentPage(0); | 727 | tabWidget->setCurrentPage(0); |
722 | } | 728 | } |
723 | } | 729 | } |
724 | 730 | ||
725 | void PlayListWidget::tabChanged(QWidget *) { | 731 | void PlayListWidget::tabChanged(QWidget *) { |
726 | 732 | ||
727 | switch ( tabWidget->currentPageIndex()) { | 733 | switch ( tabWidget->currentPageIndex()) { |
728 | case 0: | 734 | case 0: |
729 | { | 735 | { |
730 | if( !tbDeletePlaylist->isHidden()) | 736 | if( !tbDeletePlaylist->isHidden()) |
731 | tbDeletePlaylist->hide(); | 737 | tbDeletePlaylist->hide(); |
732 | d->tbRemoveFromList->setEnabled(TRUE); | 738 | d->tbRemoveFromList->setEnabled(TRUE); |
733 | d->tbAddToList->setEnabled(FALSE); | 739 | d->tbAddToList->setEnabled(FALSE); |
734 | } | 740 | } |
735 | break; | 741 | break; |
736 | case 1: | 742 | case 1: |
737 | { | 743 | { |
738 | audioView->clear(); | 744 | audioView->clear(); |
739 | populateAudioView(); | 745 | populateAudioView(); |
740 | 746 | ||
741 | if( !tbDeletePlaylist->isHidden()) | 747 | if( !tbDeletePlaylist->isHidden()) |
742 | tbDeletePlaylist->hide(); | 748 | tbDeletePlaylist->hide(); |
743 | d->tbRemoveFromList->setEnabled(FALSE); | 749 | d->tbRemoveFromList->setEnabled(FALSE); |
744 | d->tbAddToList->setEnabled(TRUE); | 750 | d->tbAddToList->setEnabled(TRUE); |
745 | } | 751 | } |
746 | break; | 752 | break; |
747 | case 2: | 753 | case 2: |
748 | { | 754 | { |
749 | videoView->clear(); | 755 | videoView->clear(); |
750 | populateVideoView(); | 756 | populateVideoView(); |
751 | if( !tbDeletePlaylist->isHidden()) | 757 | if( !tbDeletePlaylist->isHidden()) |
752 | tbDeletePlaylist->hide(); | 758 | tbDeletePlaylist->hide(); |
753 | d->tbRemoveFromList->setEnabled(FALSE); | 759 | d->tbRemoveFromList->setEnabled(FALSE); |
754 | d->tbAddToList->setEnabled(TRUE); | 760 | d->tbAddToList->setEnabled(TRUE); |
755 | } | 761 | } |
756 | break; | 762 | break; |
757 | case 3: | 763 | case 3: |
758 | { | 764 | { |
759 | if( tbDeletePlaylist->isHidden()) | 765 | if( tbDeletePlaylist->isHidden()) |
760 | tbDeletePlaylist->show(); | 766 | tbDeletePlaylist->show(); |
761 | playLists->reread(); | 767 | playLists->reread(); |
762 | } | 768 | } |
763 | break; | 769 | break; |
764 | }; | 770 | }; |
765 | } | 771 | } |
766 | 772 | ||
767 | void PlayListWidget::btnPlay(bool b) { | 773 | void PlayListWidget::btnPlay(bool b) { |
768 | 774 | ||
769 | // mediaPlayerState->setPlaying(b); | 775 | // mediaPlayerState->setPlaying(b); |
770 | switch ( tabWidget->currentPageIndex()) { | 776 | switch ( tabWidget->currentPageIndex()) { |
771 | case 0: | 777 | case 0: |
772 | { | 778 | { |
773 | mediaPlayerState->setPlaying(b); | 779 | mediaPlayerState->setPlaying(b); |
774 | } | 780 | } |
775 | break; | 781 | break; |
776 | case 1: | 782 | case 1: |
777 | { | 783 | { |
778 | addToSelection( audioView->currentItem() ); | 784 | addToSelection( audioView->currentItem() ); |
779 | mediaPlayerState->setPlaying(b); | 785 | mediaPlayerState->setPlaying(b); |
780 | d->selectedFiles->removeSelected( ); | 786 | d->selectedFiles->removeSelected( ); |
781 | tabWidget->setCurrentPage(1); | 787 | tabWidget->setCurrentPage(1); |
782 | d->selectedFiles->unSelect(); | 788 | d->selectedFiles->unSelect(); |
783 | insanityBool=FALSE; | 789 | insanityBool=FALSE; |
784 | }// audioView->clearSelection(); | 790 | }// audioView->clearSelection(); |
785 | break; | 791 | break; |
786 | case 2: | 792 | case 2: |
787 | { | 793 | { |
788 | addToSelection( videoView->currentItem() ); | 794 | addToSelection( videoView->currentItem() ); |
789 | mediaPlayerState->setPlaying(b); | 795 | mediaPlayerState->setPlaying(b); |
790 | qApp->processEvents(); | 796 | qApp->processEvents(); |
791 | d->selectedFiles->removeSelected( ); | 797 | d->selectedFiles->removeSelected( ); |
792 | tabWidget->setCurrentPage(2); | 798 | tabWidget->setCurrentPage(2); |
793 | d->selectedFiles->unSelect(); | 799 | d->selectedFiles->unSelect(); |
794 | insanityBool=FALSE; | 800 | insanityBool=FALSE; |
795 | }// videoView->clearSelection(); | 801 | }// videoView->clearSelection(); |
796 | break; | 802 | break; |
797 | }; | 803 | }; |
798 | 804 | ||
799 | } | 805 | } |
800 | 806 | ||
801 | void PlayListWidget::deletePlaylist() { | 807 | void PlayListWidget::deletePlaylist() { |
802 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 808 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
803 | (tr("You really want to delete\nthis playlist?")), | 809 | (tr("You really want to delete\nthis playlist?")), |
804 | (tr("Yes")), (tr("No")), 0 )){ | 810 | (tr("Yes")), (tr("No")), 0 )){ |
805 | case 0: // Yes clicked, | 811 | case 0: // Yes clicked, |
806 | QFile().remove(playLists->selected()->file()); | 812 | QFile().remove(playLists->selected()->file()); |
807 | QFile().remove(playLists->selected()->linkFile()); | 813 | QFile().remove(playLists->selected()->linkFile()); |
808 | playLists->reread(); | 814 | playLists->reread(); |
809 | break; | 815 | break; |
@@ -1018,202 +1024,204 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | |||
1018 | break; | 1024 | break; |
1019 | // case Key_P: //play | 1025 | // case Key_P: //play |
1020 | // qDebug("Play"); | 1026 | // qDebug("Play"); |
1021 | // playSelected(); | 1027 | // playSelected(); |
1022 | // break; | 1028 | // break; |
1023 | case Key_Space: | 1029 | case Key_Space: |
1024 | qDebug("Play"); | 1030 | qDebug("Play"); |
1025 | // playSelected(); puh | 1031 | // playSelected(); puh |
1026 | break; | 1032 | break; |
1027 | case Key_1: | 1033 | case Key_1: |
1028 | tabWidget->setCurrentPage(0); | 1034 | tabWidget->setCurrentPage(0); |
1029 | break; | 1035 | break; |
1030 | case Key_2: | 1036 | case Key_2: |
1031 | tabWidget->setCurrentPage(1); | 1037 | tabWidget->setCurrentPage(1); |
1032 | break; | 1038 | break; |
1033 | case Key_3: | 1039 | case Key_3: |
1034 | tabWidget->setCurrentPage(2); | 1040 | tabWidget->setCurrentPage(2); |
1035 | break; | 1041 | break; |
1036 | case Key_4: | 1042 | case Key_4: |
1037 | tabWidget->setCurrentPage(3); | 1043 | tabWidget->setCurrentPage(3); |
1038 | break; | 1044 | break; |
1039 | case Key_Down: | 1045 | case Key_Down: |
1040 | if ( !d->selectedFiles->next() ) | 1046 | if ( !d->selectedFiles->next() ) |
1041 | d->selectedFiles->first(); | 1047 | d->selectedFiles->first(); |
1042 | 1048 | ||
1043 | break; | 1049 | break; |
1044 | case Key_Up: | 1050 | case Key_Up: |
1045 | if ( !d->selectedFiles->prev() ) | 1051 | if ( !d->selectedFiles->prev() ) |
1046 | // d->selectedFiles->last(); | 1052 | // d->selectedFiles->last(); |
1047 | 1053 | ||
1048 | break; | 1054 | break; |
1049 | 1055 | ||
1050 | } | 1056 | } |
1051 | } | 1057 | } |
1052 | 1058 | ||
1053 | void PlayListWidget::keyPressEvent( QKeyEvent *) | 1059 | void PlayListWidget::keyPressEvent( QKeyEvent *) |
1054 | { | 1060 | { |
1055 | // qDebug("Key press"); | 1061 | // qDebug("Key press"); |
1056 | // switch ( e->key() ) { | 1062 | // switch ( e->key() ) { |
1057 | // ////////////////////////////// Zaurus keys | 1063 | // ////////////////////////////// Zaurus keys |
1058 | // case Key_A: //add to playlist | 1064 | // case Key_A: //add to playlist |
1059 | // qDebug("Add"); | 1065 | // qDebug("Add"); |
1060 | // addSelected(); | 1066 | // addSelected(); |
1061 | // break; | 1067 | // break; |
1062 | // case Key_R: //remove from playlist | 1068 | // case Key_R: //remove from playlist |
1063 | // removeSelected(); | 1069 | // removeSelected(); |
1064 | // break; | 1070 | // break; |
1065 | // case Key_P: //play | 1071 | // case Key_P: //play |
1066 | // qDebug("Play"); | 1072 | // qDebug("Play"); |
1067 | // playSelected(); | 1073 | // playSelected(); |
1068 | // break; | 1074 | // break; |
1069 | // case Key_Space: | 1075 | // case Key_Space: |
1070 | // qDebug("Play"); | 1076 | // qDebug("Play"); |
1071 | // playSelected(); | 1077 | // playSelected(); |
1072 | // break; | 1078 | // break; |
1073 | // } | 1079 | // } |
1074 | } | 1080 | } |
1075 | 1081 | ||
1076 | void PlayListWidget::doBlank() { | 1082 | void PlayListWidget::doBlank() { |
1077 | qDebug("do blanking"); | 1083 | qDebug("do blanking"); |
1078 | fd=open("/dev/fb0",O_RDWR); | 1084 | fd=open("/dev/fb0",O_RDWR); |
1079 | if (fd != -1) { | 1085 | if (fd != -1) { |
1080 | ioctl(fd,FBIOBLANK,1); | 1086 | ioctl(fd,FBIOBLANK,1); |
1081 | // close(fd); | 1087 | // close(fd); |
1082 | } | 1088 | } |
1083 | } | 1089 | } |
1084 | 1090 | ||
1085 | void PlayListWidget::doUnblank() { | 1091 | void PlayListWidget::doUnblank() { |
1086 | // this crashes opieplayer with a segfault | 1092 | // this crashes opieplayer with a segfault |
1087 | // int fd; | 1093 | // int fd; |
1088 | // fd=open("/dev/fb0",O_RDWR); | 1094 | // fd=open("/dev/fb0",O_RDWR); |
1089 | qDebug("do unblanking"); | 1095 | qDebug("do unblanking"); |
1090 | if (fd != -1) { | 1096 | if (fd != -1) { |
1091 | ioctl(fd,FBIOBLANK,0); | 1097 | ioctl(fd,FBIOBLANK,0); |
1092 | close(fd); | 1098 | close(fd); |
1093 | } | 1099 | } |
1094 | QCopEnvelope h("QPE/System", "setBacklight(int)"); | 1100 | QCopEnvelope h("QPE/System", "setBacklight(int)"); |
1095 | h <<-3;// v[1]; // -3 Force on | 1101 | h <<-3;// v[1]; // -3 Force on |
1096 | } | 1102 | } |
1097 | 1103 | ||
1098 | void PlayListWidget::readm3u(const QString &filename) { | 1104 | void PlayListWidget::readm3u(const QString &filename) { |
1099 | 1105 | ||
1100 | qDebug("m3u filename is "+filename); | 1106 | qDebug("m3u filename is "+filename); |
1101 | QFile f(filename); | 1107 | QFile f(filename); |
1102 | 1108 | ||
1103 | if(f.open(IO_ReadOnly)) { | 1109 | if(f.open(IO_ReadOnly)) { |
1104 | QTextStream t(&f); | 1110 | QTextStream t(&f); |
1105 | QString s;//, first, second; | 1111 | QString s;//, first, second; |
1106 | int i=0; | 1112 | int i=0; |
1107 | while ( !t.atEnd()) { | 1113 | while ( !t.atEnd()) { |
1108 | s=t.readLine(); | 1114 | s=t.readLine(); |
1109 | 1115 | ||
1110 | if(s.find("#",0,TRUE) == -1) { | 1116 | if(s.find("#",0,TRUE) == -1) { |
1111 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat | 1117 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat |
1112 | if(s.left(2) == "E:" || s.left(2) == "P:") { | 1118 | if(s.left(2) == "E:" || s.left(2) == "P:") { |
1113 | s=s.right(s.length()-2); | 1119 | s=s.right(s.length()-2); |
1114 | DocLnk lnk( s ); | 1120 | if(QFile(s).exists()) { |
1115 | QFileInfo f(s); | 1121 | DocLnk lnk( s ); |
1116 | QString name = f.baseName(); | 1122 | QFileInfo f(s); |
1117 | name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 ); | 1123 | QString name = f.baseName(); |
1118 | lnk.setName( name ); | 1124 | name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 ); |
1119 | s=s.replace( QRegExp("\\"),"/"); | 1125 | lnk.setName( name ); |
1120 | lnk.setFile( s ); | 1126 | s=s.replace( QRegExp("\\"),"/"); |
1121 | lnk.writeLink(); | 1127 | lnk.setFile( s ); |
1122 | qDebug("add "+name); | 1128 | lnk.writeLink(); |
1123 | d->selectedFiles->addToSelection( lnk); | 1129 | qDebug("add "+name); |
1130 | d->selectedFiles->addToSelection( lnk); | ||
1131 | } | ||
1124 | } else { // is url | 1132 | } else { // is url |
1125 | s.replace(QRegExp("%20")," "); | 1133 | s.replace(QRegExp("%20")," "); |
1126 | DocLnk lnk( s ); | 1134 | DocLnk lnk( s ); |
1127 | QString name; | 1135 | QString name; |
1128 | if(name.left(4)=="http") { | 1136 | if(name.left(4)=="http") { |
1129 | name = s.right( s.length() - 7); | 1137 | name = s.right( s.length() - 7); |
1130 | } else { | 1138 | } else { |
1131 | name = s; | 1139 | name = s; |
1132 | } | 1140 | } |
1133 | lnk.setName(name); | 1141 | lnk.setName(name); |
1134 | if(s.at(s.length()-4) == '.') { | 1142 | if(s.at(s.length()-4) == '.') { |
1135 | lnk.setFile( s); | 1143 | lnk.setFile( s); |
1136 | } else { | 1144 | } else { |
1137 | lnk.setFile( s+"/"); | 1145 | lnk.setFile( s+"/"); |
1138 | } | 1146 | } |
1139 | lnk.setType("audio/x-mpegurl"); | 1147 | lnk.setType("audio/x-mpegurl"); |
1140 | lnk.writeLink(); | 1148 | lnk.writeLink(); |
1141 | d->selectedFiles->addToSelection( lnk); | 1149 | d->selectedFiles->addToSelection( lnk); |
1142 | } | 1150 | } |
1143 | i++; | 1151 | i++; |
1144 | } | 1152 | } |
1145 | } | 1153 | } |
1146 | } | 1154 | } |
1147 | } | 1155 | } |
1148 | f.close(); | 1156 | f.close(); |
1149 | } | 1157 | } |
1150 | 1158 | ||
1151 | void PlayListWidget::writem3u() { | 1159 | void PlayListWidget::writem3u() { |
1152 | 1160 | ||
1153 | InputDialog *fileDlg; | 1161 | InputDialog *fileDlg; |
1154 | fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0); | 1162 | fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0); |
1155 | fileDlg->exec(); | 1163 | fileDlg->exec(); |
1156 | QString filename,list; | 1164 | QString filename,list; |
1157 | if( fileDlg->result() == 1 ) { | 1165 | if( fileDlg->result() == 1 ) { |
1158 | filename = fileDlg->LineEdit1->text(); | 1166 | filename = fileDlg->LineEdit1->text(); |
1159 | qDebug(filename); | 1167 | qDebug(filename); |
1160 | int noOfFiles = 0; | 1168 | int noOfFiles = 0; |
1161 | d->selectedFiles->first(); | 1169 | d->selectedFiles->first(); |
1162 | do { | 1170 | do { |
1163 | // we dont check for existance because of url's | 1171 | // we dont check for existance because of url's |
1164 | // qDebug(d->selectedFiles->current()->file()); | 1172 | // qDebug(d->selectedFiles->current()->file()); |
1165 | list += d->selectedFiles->current()->file()+"\n"; | 1173 | list += d->selectedFiles->current()->file()+"\n"; |
1166 | noOfFiles++; | 1174 | noOfFiles++; |
1167 | } | 1175 | } |
1168 | while ( d->selectedFiles->next() ); | 1176 | while ( d->selectedFiles->next() ); |
1169 | qDebug(list); | 1177 | qDebug(list); |
1170 | if(filename.left(1) != "/") | 1178 | if(filename.left(1) != "/") |
1171 | filename=QPEApplication::documentDir()+"/"+filename; | 1179 | filename=QPEApplication::documentDir()+"/"+filename; |
1172 | if(filename.right(3) != "m3u") | 1180 | if(filename.right(3) != "m3u") |
1173 | filename=filename+".m3u"; | 1181 | filename=filename+".m3u"; |
1174 | 1182 | ||
1175 | QFile f(filename); | 1183 | QFile f(filename); |
1176 | f.open(IO_WriteOnly); | 1184 | f.open(IO_WriteOnly); |
1177 | f.writeBlock(list, list.length()); | 1185 | f.writeBlock(list, list.length()); |
1178 | f.close(); | 1186 | f.close(); |
1179 | } | 1187 | } |
1180 | if(fileDlg) delete fileDlg; | 1188 | if(fileDlg) delete fileDlg; |
1181 | } | 1189 | } |
1182 | 1190 | ||
1183 | void PlayListWidget::readPls(const QString &filename) { | 1191 | void PlayListWidget::readPls(const QString &filename) { |
1184 | 1192 | ||
1185 | qDebug("pls filename is "+filename); | 1193 | qDebug("pls filename is "+filename); |
1186 | QFile f(filename); | 1194 | QFile f(filename); |
1187 | 1195 | ||
1188 | if(f.open(IO_ReadOnly)) { | 1196 | if(f.open(IO_ReadOnly)) { |
1189 | QTextStream t(&f); | 1197 | QTextStream t(&f); |
1190 | QString s;//, first, second; | 1198 | QString s;//, first, second; |
1191 | int i=0; | 1199 | int i=0; |
1192 | while ( !t.atEnd()) { | 1200 | while ( !t.atEnd()) { |
1193 | s=t.readLine(); | 1201 | s=t.readLine(); |
1194 | if(s.left(4) == "File") { | 1202 | if(s.left(4) == "File") { |
1195 | s=s.right(s.length() - 6); | 1203 | s=s.right(s.length() - 6); |
1196 | s.replace(QRegExp("%20")," "); | 1204 | s.replace(QRegExp("%20")," "); |
1197 | qDebug("adding "+s+" to playlist"); | 1205 | qDebug("adding "+s+" to playlist"); |
1198 | // numberofentries=2 | 1206 | // numberofentries=2 |
1199 | // File1=http | 1207 | // File1=http |
1200 | // Title | 1208 | // Title |
1201 | // Length | 1209 | // Length |
1202 | // Version | 1210 | // Version |
1203 | // File2=http | 1211 | // File2=http |
1204 | s=s.replace( QRegExp("\\"),"/"); | 1212 | s=s.replace( QRegExp("\\"),"/"); |
1205 | DocLnk lnk( s ); | 1213 | DocLnk lnk( s ); |
1206 | QFileInfo f(s); | 1214 | QFileInfo f(s); |
1207 | QString name = f.baseName(); | 1215 | QString name = f.baseName(); |
1208 | if(name.left(4)=="http") | 1216 | if(name.left(4)=="http") |
1209 | name = s.right( s.length() - 7); | 1217 | name = s.right( s.length() - 7); |
1210 | else | 1218 | else |
1211 | name=s; | 1219 | name=s; |
1212 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | 1220 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); |
1213 | lnk.setName( name); | 1221 | lnk.setName( name); |
1214 | if(s.at(s.length()-4) == '.') // if this is probably a file | 1222 | if(s.at(s.length()-4) == '.') // if this is probably a file |
1215 | lnk.setFile( s); | 1223 | lnk.setFile( s); |
1216 | else { //if its a url | 1224 | else { //if its a url |
1217 | if( name.right(1).find('/') == -1) | 1225 | if( name.right(1).find('/') == -1) |
1218 | s+="/"; | 1226 | s+="/"; |
1219 | lnk.setFile( s); | 1227 | lnk.setFile( s); |