Diffstat (limited to 'core/multimedia/opieplayer/playlistwidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 474 |
1 files changed, 247 insertions, 227 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 5be0d6d..6580a88 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -74,24 +74,25 @@ | |||
74 | #include <sys/types.h> | 74 | #include <sys/types.h> |
75 | #include <sys/stat.h> | 75 | #include <sys/stat.h> |
76 | #include <stdlib.h> | 76 | #include <stdlib.h> |
77 | 77 | ||
78 | #define BUTTONS_ON_TOOLBAR | 78 | #define BUTTONS_ON_TOOLBAR |
79 | #define SIDE_BUTTONS | 79 | #define SIDE_BUTTONS |
80 | #define CAN_SAVE_LOAD_PLAYLISTS | 80 | #define CAN_SAVE_LOAD_PLAYLISTS |
81 | 81 | ||
82 | extern AudioWidget *audioUI; | 82 | extern AudioWidget *audioUI; |
83 | extern VideoWidget *videoUI; | 83 | extern VideoWidget *videoUI; |
84 | extern MediaPlayerState *mediaPlayerState; | 84 | extern MediaPlayerState *mediaPlayerState; |
85 | 85 | ||
86 | QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg"; | ||
86 | // class myFileSelector { | 87 | // class myFileSelector { |
87 | 88 | ||
88 | // }; | 89 | // }; |
89 | class PlayListWidgetPrivate { | 90 | class PlayListWidgetPrivate { |
90 | public: | 91 | public: |
91 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; | 92 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; |
92 | QFrame *playListFrame; | 93 | QFrame *playListFrame; |
93 | FileSelector *files; | 94 | FileSelector *files; |
94 | PlayListSelection *selectedFiles; | 95 | PlayListSelection *selectedFiles; |
95 | bool setDocumentUsed; | 96 | bool setDocumentUsed; |
96 | DocLnk *current; | 97 | DocLnk *current; |
97 | }; | 98 | }; |
@@ -170,26 +171,24 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
170 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", | 171 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", |
171 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | 172 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); |
172 | tbDeletePlaylist->hide(); | 173 | tbDeletePlaylist->hide(); |
173 | 174 | ||
174 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | 175 | QPopupMenu *pmPlayList = new QPopupMenu( this ); |
175 | menu->insertItem( tr( "File" ), pmPlayList ); | 176 | menu->insertItem( tr( "File" ), pmPlayList ); |
176 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 177 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
177 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 178 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
178 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 179 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
179 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 180 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
180 | pmPlayList->insertSeparator(-1); | 181 | pmPlayList->insertSeparator(-1); |
181 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 182 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
182 | new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); | ||
183 | pmPlayList->insertSeparator(-1); | ||
184 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); | 183 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); |
185 | pmPlayList->insertSeparator(-1); | 184 | pmPlayList->insertSeparator(-1); |
186 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); | 185 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); |
187 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); | 186 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); |
188 | 187 | ||
189 | QPopupMenu *pmView = new QPopupMenu( this ); | 188 | QPopupMenu *pmView = new QPopupMenu( this ); |
190 | menu->insertItem( tr( "View" ), pmView ); | 189 | menu->insertItem( tr( "View" ), pmView ); |
191 | 190 | ||
192 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); | 191 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); |
193 | fullScreenButton->addTo(pmView); | 192 | fullScreenButton->addTo(pmView); |
194 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); | 193 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); |
195 | scaleButton->addTo(pmView); | 194 | scaleButton->addTo(pmView); |
@@ -270,69 +269,69 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
270 | 269 | ||
271 | tabWidget->insertTab( vTab,tr("Video")); | 270 | tabWidget->insertTab( vTab,tr("Video")); |
272 | 271 | ||
273 | QWidget *LTab; | 272 | QWidget *LTab; |
274 | LTab = new QWidget( tabWidget, "LTab" ); | 273 | LTab = new QWidget( tabWidget, "LTab" ); |
275 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy | 274 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy |
276 | playLists->setMinimumSize(233,260); | 275 | playLists->setMinimumSize(233,260); |
277 | tabWidget->insertTab(LTab,tr("Lists")); | 276 | tabWidget->insertTab(LTab,tr("Lists")); |
278 | 277 | ||
279 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); | 278 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); |
280 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); | 279 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); |
281 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); | 280 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); |
281 | |||
282 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 282 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
283 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); | 283 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); |
284 | 284 | ||
285 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 285 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
286 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 286 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
287 | 287 | ||
288 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), | 288 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), |
289 | this,SLOT( playIt( QListViewItem *)) ); | 289 | this,SLOT( playIt( QListViewItem *)) ); |
290 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 290 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
291 | 291 | ||
292 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 292 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
293 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 293 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
294 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), | 294 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), |
295 | this,SLOT( playIt( QListViewItem *)) ); | 295 | this,SLOT( playIt( QListViewItem *)) ); |
296 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 296 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
297 | 297 | ||
298 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 298 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
299 | 299 | ||
300 | 300 | ||
301 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 301 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
302 | 302 | ||
303 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 303 | // connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
304 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 304 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
305 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 305 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
306 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 306 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
307 | 307 | ||
308 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 308 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
309 | 309 | ||
310 | setCentralWidget( vbox5 ); | 310 | setCentralWidget( vbox5 ); |
311 | 311 | ||
312 | Config cfg( "OpiePlayer" ); | 312 | Config cfg( "OpiePlayer" ); |
313 | readConfig( cfg ); | 313 | readConfig( cfg ); |
314 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 314 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
315 | loadList(DocLnk( currentPlaylist)); | 315 | loadList(DocLnk( currentPlaylist)); |
316 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); | 316 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); |
317 | 317 | ||
318 | initializeStates(); | 318 | initializeStates(); |
319 | } | 319 | } |
320 | 320 | ||
321 | 321 | ||
322 | PlayListWidget::~PlayListWidget() { | 322 | PlayListWidget::~PlayListWidget() { |
323 | Config cfg( "OpiePlayer" ); | 323 | Config cfg( "OpiePlayer" ); |
324 | writeConfig( cfg ); | 324 | writeConfig( cfg ); |
325 | 325 | ||
326 | |||
327 | if ( d->current ) | 326 | if ( d->current ) |
328 | delete d->current; | 327 | delete d->current; |
329 | delete d; | 328 | delete d; |
330 | } | 329 | } |
331 | 330 | ||
332 | 331 | ||
333 | void PlayListWidget::initializeStates() { | 332 | void PlayListWidget::initializeStates() { |
334 | 333 | ||
335 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 334 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
336 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 335 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
337 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 336 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
338 | setPlaylist( true); | 337 | setPlaylist( true); |
@@ -384,31 +383,31 @@ void PlayListWidget::writeConfig( Config& cfg ) const { | |||
384 | ); | 383 | ); |
385 | } | 384 | } |
386 | } | 385 | } |
387 | noOfFiles++; | 386 | noOfFiles++; |
388 | } | 387 | } |
389 | } | 388 | } |
390 | while ( d->selectedFiles->next() ); | 389 | while ( d->selectedFiles->next() ); |
391 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 390 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
392 | } | 391 | } |
393 | 392 | ||
394 | 393 | ||
395 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 394 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
396 | d->setDocumentUsed = FALSE; | 395 | d->setDocumentUsed = false; |
397 | if ( mediaPlayerState->playlist() ) { | 396 | if ( mediaPlayerState->playlist() ) { |
398 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) | 397 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) |
399 | d->selectedFiles->addToSelection( lnk ); | 398 | d->selectedFiles->addToSelection( lnk ); |
400 | } | 399 | } |
401 | else | 400 | else |
402 | mediaPlayerState->setPlaying( TRUE ); | 401 | mediaPlayerState->setPlaying( true); |
403 | } | 402 | } |
404 | 403 | ||
405 | 404 | ||
406 | void PlayListWidget::clearList() { | 405 | void PlayListWidget::clearList() { |
407 | while ( first() ) | 406 | while ( first() ) |
408 | d->selectedFiles->removeSelected(); | 407 | d->selectedFiles->removeSelected(); |
409 | } | 408 | } |
410 | 409 | ||
411 | 410 | ||
412 | void PlayListWidget::addAllToList() { | 411 | void PlayListWidget::addAllToList() { |
413 | DocLnkSet filesAll; | 412 | DocLnkSet filesAll; |
414 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 413 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
@@ -487,24 +486,25 @@ const DocLnk *PlayListWidget::current() { // this is fugly | |||
487 | // qDebug("from setDoc"); | 486 | // qDebug("from setDoc"); |
488 | // DocLnkSet files; | 487 | // DocLnkSet files; |
489 | // Global::findDocuments(&files, "video/*;audio/*"); | 488 | // Global::findDocuments(&files, "video/*;audio/*"); |
490 | // QListIterator<DocLnk> dit( files.children() ); | 489 | // QListIterator<DocLnk> dit( files.children() ); |
491 | // for ( ; dit.current(); ++dit ) { | 490 | // for ( ; dit.current(); ++dit ) { |
492 | // if(dit.current()->linkFile() == setDocFileRef) { | 491 | // if(dit.current()->linkFile() == setDocFileRef) { |
493 | // qDebug(setDocFileRef); | 492 | // qDebug(setDocFileRef); |
494 | // return dit; | 493 | // return dit; |
495 | // } | 494 | // } |
496 | // } | 495 | // } |
497 | // } else | 496 | // } else |
498 | 497 | ||
498 | qDebug("current"); | ||
499 | 499 | ||
500 | switch (tabWidget->currentPageIndex()) { | 500 | switch (tabWidget->currentPageIndex()) { |
501 | case 0: //playlist | 501 | case 0: //playlist |
502 | { | 502 | { |
503 | qDebug("playlist"); | 503 | qDebug("playlist"); |
504 | if ( mediaPlayerState->playlist() ) { | 504 | if ( mediaPlayerState->playlist() ) { |
505 | return d->selectedFiles->current(); | 505 | return d->selectedFiles->current(); |
506 | } | 506 | } |
507 | else if ( d->setDocumentUsed && d->current ) { | 507 | else if ( d->setDocumentUsed && d->current ) { |
508 | return d->current; | 508 | return d->current; |
509 | } else { | 509 | } else { |
510 | return &(d->files->selectedDocument()); | 510 | return &(d->files->selectedDocument()); |
@@ -597,94 +597,60 @@ bool PlayListWidget::first() { | |||
597 | } | 597 | } |
598 | 598 | ||
599 | 599 | ||
600 | bool PlayListWidget::last() { | 600 | bool PlayListWidget::last() { |
601 | if ( mediaPlayerState->playlist() ) | 601 | if ( mediaPlayerState->playlist() ) |
602 | return d->selectedFiles->last(); | 602 | return d->selectedFiles->last(); |
603 | else | 603 | else |
604 | return mediaPlayerState->looping(); | 604 | return mediaPlayerState->looping(); |
605 | } | 605 | } |
606 | 606 | ||
607 | 607 | ||
608 | void PlayListWidget::saveList() { | 608 | void PlayListWidget::saveList() { |
609 | 609 | writem3u(); | |
610 | QString filename; | ||
611 | InputDialog *fileDlg; | ||
612 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); | ||
613 | fileDlg->exec(); | ||
614 | if( fileDlg->result() == 1 ) { | ||
615 | if ( d->current ) | ||
616 | delete d->current; | ||
617 | filename = fileDlg->LineEdit1->text();//+".playlist"; | ||
618 | // qDebug("saving playlist "+filename+".playlist"); | ||
619 | Config cfg( filename +".playlist"); | ||
620 | writeConfig( cfg ); | ||
621 | |||
622 | DocLnk lnk; | ||
623 | // lnk.setComment( ""); | ||
624 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property | ||
625 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | ||
626 | lnk.setIcon("opieplayer/playlist2"); | ||
627 | lnk.setName( filename); //sets file name | ||
628 | // qDebug(filename); | ||
629 | if(!lnk.writeLink()) | ||
630 | qDebug("Writing doclink did not work"); | ||
631 | } | ||
632 | Config config( "OpiePlayer" ); | ||
633 | config.writeEntry("CurrentPlaylist",filename); | ||
634 | setCaption(tr("OpiePlayer: ")+filename); | ||
635 | d->selectedFiles->first(); | ||
636 | if(fileDlg) | ||
637 | delete fileDlg; | ||
638 | } | 610 | } |
639 | 611 | ||
640 | void PlayListWidget::loadList( const DocLnk & lnk) { | 612 | void PlayListWidget::loadList( const DocLnk & lnk) { |
641 | QString name= lnk.name(); | 613 | QString name= lnk.name(); |
642 | // qDebug("currentList is "+name); | 614 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); |
643 | if( name.length()>1) { | 615 | |
616 | if( name.length()>0) { | ||
644 | setCaption("OpiePlayer: "+name); | 617 | setCaption("OpiePlayer: "+name); |
645 | // qDebug("load list "+ name+".playlist"); | 618 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); |
646 | clearList(); | 619 | clearList(); |
647 | Config cfg( name+".playlist"); | 620 | readm3u(lnk.file()); |
648 | readConfig(cfg); | ||
649 | |||
650 | tabWidget->setCurrentPage(0); | 621 | tabWidget->setCurrentPage(0); |
651 | |||
652 | Config config( "OpiePlayer" ); | ||
653 | config.writeEntry("CurrentPlaylist", name); | ||
654 | // d->selectedFiles->first(); | ||
655 | } | 622 | } |
656 | |||
657 | } | 623 | } |
658 | 624 | ||
659 | void PlayListWidget::setPlaylist( bool shown ) { | 625 | void PlayListWidget::setPlaylist( bool shown ) { |
660 | if ( shown ) | 626 | if ( shown ) |
661 | d->playListFrame->show(); | 627 | d->playListFrame->show(); |
662 | else | 628 | else |
663 | d->playListFrame->hide(); | 629 | d->playListFrame->hide(); |
664 | } | 630 | } |
665 | 631 | ||
666 | void PlayListWidget::setView( char view ) { | 632 | void PlayListWidget::setView( char view ) { |
667 | if ( view == 'l' ) | 633 | if ( view == 'l' ) |
668 | showMaximized(); | 634 | showMaximized(); |
669 | else | 635 | else |
670 | hide(); | 636 | hide(); |
671 | } | 637 | } |
672 | 638 | ||
673 | void PlayListWidget::addSelected() { | 639 | void PlayListWidget::addSelected() { |
674 | 640 | ||
675 | Config cfg( "OpiePlayer" ); | 641 | Config cfg( "OpiePlayer" ); |
676 | cfg.setGroup("PlayList"); | 642 | cfg.setGroup("PlayList"); |
677 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 643 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
678 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 644 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
679 | 645 | ||
680 | switch (tabWidget->currentPageIndex()) { | 646 | switch (tabWidget->currentPageIndex()) { |
681 | case 0: //playlist | 647 | case 0: //playlist |
682 | break; | 648 | break; |
683 | case 1: { //audio | 649 | case 1: { //audio |
684 | // QString entryName; | 650 | // QString entryName; |
685 | // entryName.sprintf( "File%i", i + 1 ); | 651 | // entryName.sprintf( "File%i", i + 1 ); |
686 | // QString linkFile = cfg.readEntry( entryName ); | 652 | // QString linkFile = cfg.readEntry( entryName ); |
687 | QListViewItemIterator it( audioView ); | 653 | QListViewItemIterator it( audioView ); |
688 | // iterate through all items of the listview | 654 | // iterate through all items of the listview |
689 | for ( ; it.current(); ++it ) { | 655 | for ( ; it.current(); ++it ) { |
690 | if ( it.current()->isSelected() ) { | 656 | if ( it.current()->isSelected() ) { |
@@ -729,25 +695,25 @@ void PlayListWidget::addSelected() { | |||
729 | // } | 695 | // } |
730 | // addToSelection( videoView->selectedItem() ); | 696 | // addToSelection( videoView->selectedItem() ); |
731 | tabWidget->setCurrentPage(0); | 697 | tabWidget->setCurrentPage(0); |
732 | } | 698 | } |
733 | break; | 699 | break; |
734 | }; | 700 | }; |
735 | } | 701 | } |
736 | 702 | ||
737 | void PlayListWidget::removeSelected() { | 703 | void PlayListWidget::removeSelected() { |
738 | d->selectedFiles->removeSelected( ); | 704 | d->selectedFiles->removeSelected( ); |
739 | } | 705 | } |
740 | 706 | ||
741 | void PlayListWidget::playIt( QListViewItem *it) { | 707 | void PlayListWidget::playIt( QListViewItem *) { |
742 | // d->setDocumentUsed = FALSE; | 708 | // d->setDocumentUsed = FALSE; |
743 | // mediaPlayerState->curPosition =0; | 709 | // mediaPlayerState->curPosition =0; |
744 | qDebug("playIt"); | 710 | qDebug("playIt"); |
745 | mediaPlayerState->setPlaying(FALSE); | 711 | mediaPlayerState->setPlaying(FALSE); |
746 | mediaPlayerState->setPlaying(TRUE); | 712 | mediaPlayerState->setPlaying(TRUE); |
747 | d->selectedFiles->unSelect(); | 713 | d->selectedFiles->unSelect(); |
748 | } | 714 | } |
749 | 715 | ||
750 | void PlayListWidget::addToSelection( QListViewItem *it) { | 716 | void PlayListWidget::addToSelection( QListViewItem *it) { |
751 | d->setDocumentUsed = FALSE; | 717 | d->setDocumentUsed = FALSE; |
752 | 718 | ||
753 | if(it) { | 719 | if(it) { |
@@ -768,25 +734,25 @@ void PlayListWidget::addToSelection( QListViewItem *it) { | |||
768 | d->selectedFiles->addToSelection( **dit ); | 734 | d->selectedFiles->addToSelection( **dit ); |
769 | } | 735 | } |
770 | } | 736 | } |
771 | } | 737 | } |
772 | break; | 738 | break; |
773 | case 0: | 739 | case 0: |
774 | break; | 740 | break; |
775 | }; | 741 | }; |
776 | tabWidget->setCurrentPage(0); | 742 | tabWidget->setCurrentPage(0); |
777 | } | 743 | } |
778 | } | 744 | } |
779 | 745 | ||
780 | void PlayListWidget::tabChanged(QWidget *widg) { | 746 | void PlayListWidget::tabChanged(QWidget *) { |
781 | 747 | ||
782 | switch ( tabWidget->currentPageIndex()) { | 748 | switch ( tabWidget->currentPageIndex()) { |
783 | case 0: | 749 | case 0: |
784 | { | 750 | { |
785 | if( !tbDeletePlaylist->isHidden()) | 751 | if( !tbDeletePlaylist->isHidden()) |
786 | tbDeletePlaylist->hide(); | 752 | tbDeletePlaylist->hide(); |
787 | d->tbRemoveFromList->setEnabled(TRUE); | 753 | d->tbRemoveFromList->setEnabled(TRUE); |
788 | d->tbAddToList->setEnabled(FALSE); | 754 | d->tbAddToList->setEnabled(FALSE); |
789 | } | 755 | } |
790 | break; | 756 | break; |
791 | case 1: | 757 | case 1: |
792 | { | 758 | { |
@@ -811,127 +777,134 @@ void PlayListWidget::tabChanged(QWidget *widg) { | |||
811 | break; | 777 | break; |
812 | case 3: | 778 | case 3: |
813 | { | 779 | { |
814 | if( tbDeletePlaylist->isHidden()) | 780 | if( tbDeletePlaylist->isHidden()) |
815 | tbDeletePlaylist->show(); | 781 | tbDeletePlaylist->show(); |
816 | playLists->reread(); | 782 | playLists->reread(); |
817 | } | 783 | } |
818 | break; | 784 | break; |
819 | }; | 785 | }; |
820 | } | 786 | } |
821 | 787 | ||
822 | void PlayListWidget::btnPlay(bool b) { | 788 | void PlayListWidget::btnPlay(bool b) { |
823 | 789 | qDebug("<<<<<<<<<<<<<<<BtnPlay"); | |
824 | // mediaPlayerState->setPlaying(b); | 790 | // mediaPlayerState->setPlaying(b); |
825 | switch ( tabWidget->currentPageIndex()) { | 791 | switch ( tabWidget->currentPageIndex()) { |
826 | case 0: | 792 | case 0: |
827 | { | 793 | { |
794 | qDebug("1"); | ||
828 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 | 795 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 |
829 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { | 796 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { |
830 | // QMessageBox::message("Note","You are trying to play\na malformed url."); | 797 | // QMessageBox::message("Note","You are trying to play\na malformed url."); |
831 | // } else { | 798 | // } else { |
832 | mediaPlayerState->setPlaying(b); | 799 | mediaPlayerState->setPlaying(b); |
800 | insanityBool=FALSE; | ||
801 | qDebug("insanity"); | ||
833 | // } | 802 | // } |
834 | } | 803 | } |
835 | break; | 804 | break; |
836 | case 1: | 805 | case 1: |
837 | { | 806 | { |
807 | qDebug("2"); | ||
838 | addToSelection( audioView->currentItem() ); | 808 | addToSelection( audioView->currentItem() ); |
839 | mediaPlayerState->setPlaying(b); | 809 | mediaPlayerState->setPlaying(b); |
840 | d->selectedFiles->removeSelected( ); | 810 | d->selectedFiles->removeSelected( ); |
841 | tabWidget->setCurrentPage(1); | 811 | tabWidget->setCurrentPage(1); |
842 | d->selectedFiles->unSelect(); | 812 | d->selectedFiles->unSelect(); |
843 | insanityBool=FALSE; | 813 | insanityBool=FALSE; |
844 | }// audioView->clearSelection(); | 814 | }// audioView->clearSelection(); |
845 | break; | 815 | break; |
846 | case 2: | 816 | case 2: |
847 | { | 817 | { |
818 | qDebug("3"); | ||
819 | |||
848 | addToSelection( videoView->currentItem() ); | 820 | addToSelection( videoView->currentItem() ); |
849 | mediaPlayerState->setPlaying(b); | 821 | mediaPlayerState->setPlaying(b); |
850 | qApp->processEvents(); | 822 | qApp->processEvents(); |
851 | d->selectedFiles->removeSelected( ); | 823 | d->selectedFiles->removeSelected( ); |
852 | tabWidget->setCurrentPage(2); | 824 | tabWidget->setCurrentPage(2); |
853 | d->selectedFiles->unSelect(); | 825 | d->selectedFiles->unSelect(); |
854 | insanityBool=FALSE; | 826 | insanityBool=FALSE; |
855 | }// videoView->clearSelection(); | 827 | }// videoView->clearSelection(); |
856 | break; | 828 | break; |
857 | }; | 829 | }; |
858 | 830 | ||
859 | } | 831 | } |
860 | 832 | ||
861 | void PlayListWidget::deletePlaylist() { | 833 | void PlayListWidget::deletePlaylist() { |
862 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 834 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
863 | (tr("You really want to delete\nthis playlist?")), | 835 | (tr("You really want to delete\nthis playlist?")), |
864 | (tr("Yes")), (tr("No")), 0 )){ | 836 | (tr("Yes")), (tr("No")), 0 )){ |
865 | case 0: // Yes clicked, | 837 | case 0: // Yes clicked, |
866 | // QFile().remove(playLists->selected()->file()); | 838 | QFile().remove(playLists->selectedDocument().file()); |
867 | // QFile().remove(playLists->selected()->linkFile()); | 839 | QFile().remove(playLists->selectedDocument().linkFile()); |
868 | // playLists->reread(); | 840 | playLists->reread(); |
869 | break; | 841 | break; |
870 | case 1: // Cancel | 842 | case 1: // Cancel |
871 | break; | 843 | break; |
872 | }; | 844 | }; |
873 | } | 845 | } |
874 | 846 | ||
875 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 847 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int ) |
876 | { | 848 | { |
877 | switch (mouse) { | 849 | switch (mouse) { |
878 | case 1: | 850 | case 1: |
879 | break; | 851 | break; |
880 | case 2:{ | 852 | case 2:{ |
881 | 853 | ||
882 | QPopupMenu m; | 854 | QPopupMenu m; |
883 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 855 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
884 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 856 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
885 | m.insertSeparator(); | 857 | m.insertSeparator(); |
886 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) | 858 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) |
887 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 859 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
888 | 860 | ||
889 | m.exec( QCursor::pos() ); | 861 | m.exec( QCursor::pos() ); |
890 | } | 862 | } |
891 | break; | 863 | break; |
892 | }; | 864 | }; |
893 | } | 865 | } |
894 | 866 | ||
895 | void PlayListWidget::playSelected() | 867 | void PlayListWidget::playSelected() |
896 | { | 868 | { |
897 | btnPlay( TRUE); | 869 | qDebug("playSelected"); |
870 | btnPlay( true); | ||
898 | // d->selectedFiles->unSelect(); | 871 | // d->selectedFiles->unSelect(); |
899 | } | 872 | } |
900 | 873 | ||
901 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 874 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) |
902 | { | 875 | { |
903 | switch (mouse) { | 876 | switch (mouse) { |
904 | case 1: | 877 | case 1: |
905 | 878 | ||
906 | break; | 879 | break; |
907 | case 2:{ | 880 | case 2:{ |
908 | QPopupMenu m; | 881 | QPopupMenu m; |
909 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 882 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
910 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 883 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
911 | // m.insertSeparator(); | 884 | // m.insertSeparator(); |
912 | // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 885 | // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
913 | m.exec( QCursor::pos() ); | 886 | m.exec( QCursor::pos() ); |
914 | } | 887 | } |
915 | break; | 888 | break; |
916 | }; | 889 | }; |
917 | 890 | ||
918 | } | 891 | } |
919 | 892 | ||
920 | void PlayListWidget::listDelete() { | 893 | void PlayListWidget::listDelete() { |
921 | Config cfg( "OpiePlayer" ); | 894 | Config cfg( "OpiePlayer" ); |
922 | cfg.setGroup("PlayList"); | 895 | cfg.setGroup("PlayList"); |
923 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 896 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
924 | QString file; | 897 | QString file; |
925 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 898 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
926 | switch ( tabWidget->currentPageIndex()) { | 899 | switch ( tabWidget->currentPageIndex()) { |
927 | case 0: | 900 | case 0: |
928 | break; | 901 | break; |
929 | case 1: | 902 | case 1: |
930 | { | 903 | { |
931 | file = audioView->currentItem()->text(0); | 904 | file = audioView->currentItem()->text(0); |
932 | QListIterator<DocLnk> Pdit( files.children() ); | 905 | QListIterator<DocLnk> Pdit( files.children() ); |
933 | for ( ; Pdit.current(); ++Pdit ) { | 906 | for ( ; Pdit.current(); ++Pdit ) { |
934 | if( Pdit.current()->name() == file) { | 907 | if( Pdit.current()->name() == file) { |
935 | LnkProperties prop( Pdit.current() ); | 908 | LnkProperties prop( Pdit.current() ); |
936 | prop.showMaximized(); | 909 | prop.showMaximized(); |
937 | prop.exec(); | 910 | prop.exec(); |
@@ -952,42 +925,42 @@ void PlayListWidget::listDelete() { | |||
952 | // LnkProperties prop( &lnk); | 925 | // LnkProperties prop( &lnk); |
953 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 926 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
954 | // prop.showMaximized(); | 927 | // prop.showMaximized(); |
955 | // prop.exec(); | 928 | // prop.exec(); |
956 | // } | 929 | // } |
957 | // } | 930 | // } |
958 | } | 931 | } |
959 | break; | 932 | break; |
960 | }; | 933 | }; |
961 | } | 934 | } |
962 | 935 | ||
963 | void PlayListWidget::scanForAudio() { | 936 | void PlayListWidget::scanForAudio() { |
964 | qDebug("scan for audio"); | 937 | // qDebug("scan for audio"); |
965 | files.detachChildren(); | 938 | files.detachChildren(); |
966 | QListIterator<DocLnk> sdit( files.children() ); | 939 | QListIterator<DocLnk> sdit( files.children() ); |
967 | for ( ; sdit.current(); ++sdit ) { | 940 | for ( ; sdit.current(); ++sdit ) { |
968 | delete sdit.current(); | 941 | delete sdit.current(); |
969 | } | 942 | } |
970 | Global::findDocuments(&files, "audio/*"); | 943 | Global::findDocuments( &files, audioMimes); |
971 | audioScan = TRUE; | 944 | audioScan = true; |
972 | } | 945 | } |
973 | void PlayListWidget::scanForVideo() { | 946 | void PlayListWidget::scanForVideo() { |
974 | qDebug("scan for video"); | 947 | // qDebug("scan for video"); |
975 | vFiles.detachChildren(); | 948 | vFiles.detachChildren(); |
976 | QListIterator<DocLnk> sdit( vFiles.children() ); | 949 | QListIterator<DocLnk> sdit( vFiles.children() ); |
977 | for ( ; sdit.current(); ++sdit ) { | 950 | for ( ; sdit.current(); ++sdit ) { |
978 | delete sdit.current(); | 951 | delete sdit.current(); |
979 | } | 952 | } |
980 | Global::findDocuments(&vFiles, "video/*"); | 953 | Global::findDocuments(&vFiles, "video/*"); |
981 | videoScan = TRUE; | 954 | videoScan = true; |
982 | } | 955 | } |
983 | 956 | ||
984 | void PlayListWidget::populateAudioView() { | 957 | void PlayListWidget::populateAudioView() { |
985 | 958 | ||
986 | audioView->clear(); | 959 | audioView->clear(); |
987 | StorageInfo storageInfo; | 960 | StorageInfo storageInfo; |
988 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 961 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
989 | if(!audioScan) scanForAudio(); | 962 | if(!audioScan) scanForAudio(); |
990 | 963 | ||
991 | QListIterator<DocLnk> dit( files.children() ); | 964 | QListIterator<DocLnk> dit( files.children() ); |
992 | QListIterator<FileSystem> it ( fs ); | 965 | QListIterator<FileSystem> it ( fs ); |
993 | 966 | ||
@@ -997,25 +970,25 @@ void PlayListWidget::populateAudioView() { | |||
997 | const QString name = (*it)->name(); | 970 | const QString name = (*it)->name(); |
998 | const QString path = (*it)->path(); | 971 | const QString path = (*it)->path(); |
999 | if(dit.current()->file().find(path) != -1 ) storage=name; | 972 | if(dit.current()->file().find(path) != -1 ) storage=name; |
1000 | } | 973 | } |
1001 | 974 | ||
1002 | QListViewItem * newItem; | 975 | QListViewItem * newItem; |
1003 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { | 976 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { |
1004 | long size; | 977 | long size; |
1005 | if( dit.current()->file().left(4) == "http" ) | 978 | if( dit.current()->file().left(4) == "http" ) |
1006 | size=0; | 979 | size=0; |
1007 | else | 980 | else |
1008 | size = QFile( dit.current()->file() ).size(); | 981 | size = QFile( dit.current()->file() ).size(); |
1009 | qDebug(dit.current()->name()); | 982 | // qDebug(dit.current()->name()); |
1010 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 983 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
1011 | QString::number(size ), storage); | 984 | QString::number(size ), storage); |
1012 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); | 985 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); |
1013 | } | 986 | } |
1014 | } | 987 | } |
1015 | 988 | ||
1016 | } | 989 | } |
1017 | 990 | ||
1018 | void PlayListWidget::populateVideoView() { | 991 | void PlayListWidget::populateVideoView() { |
1019 | videoView->clear(); | 992 | videoView->clear(); |
1020 | StorageInfo storageInfo; | 993 | StorageInfo storageInfo; |
1021 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 994 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
@@ -1034,61 +1007,252 @@ void PlayListWidget::populateVideoView() { | |||
1034 | } | 1007 | } |
1035 | 1008 | ||
1036 | QListViewItem * newItem; | 1009 | QListViewItem * newItem; |
1037 | if ( QFile( Vdit.current()->file()).exists() ) { | 1010 | if ( QFile( Vdit.current()->file()).exists() ) { |
1038 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 1011 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
1039 | QString::number( QFile( Vdit.current()->file()).size() ), storage); | 1012 | QString::number( QFile( Vdit.current()->file()).size() ), storage); |
1040 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); | 1013 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); |
1041 | } | 1014 | } |
1042 | } | 1015 | } |
1043 | } | 1016 | } |
1044 | 1017 | ||
1045 | void PlayListWidget::openFile() { | 1018 | void PlayListWidget::openFile() { |
1019 | qDebug("<<<<<<<<<OPEN File"); | ||
1046 | QString filename, name; | 1020 | QString filename, name; |
1047 | InputDialog *fileDlg; | 1021 | InputDialog *fileDlg; |
1048 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 1022 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
1049 | fileDlg->exec(); | 1023 | fileDlg->exec(); |
1050 | if( fileDlg->result() == 1 ) { | 1024 | if( fileDlg->result() == 1 ) { |
1051 | filename = fileDlg->LineEdit1->text(); | 1025 | filename = fileDlg->text(); |
1052 | // http://205.188.234.129:8030 | ||
1053 | // http://66.28.68.70:8000 | ||
1054 | // filename.replace(QRegExp("%20")," "); | ||
1055 | qDebug("Selected filename is "+filename); | 1026 | qDebug("Selected filename is "+filename); |
1056 | if(filename.right(3) == "m3u") | 1027 | // Om3u *m3uList; |
1028 | DocLnk lnk; | ||
1029 | Config cfg( "OpiePlayer" ); | ||
1030 | cfg.setGroup("PlayList"); | ||
1031 | |||
1032 | if(filename.left(4) == "http") { | ||
1033 | QString m3uFile, m3uFilePath; | ||
1034 | if(filename.find(":",8,TRUE) != -1) { //found a port | ||
1035 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | ||
1036 | m3uFile = m3uFile.right( 7); | ||
1037 | } else if(filename.left(4) == "http"){ | ||
1038 | m3uFile=filename; | ||
1039 | m3uFile = m3uFile.right( m3uFile.length() - 7); | ||
1040 | } else{ | ||
1041 | m3uFile=filename; | ||
1042 | } | ||
1043 | |||
1044 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); | ||
1045 | lnk.setName( filename ); //sets name | ||
1046 | lnk.setFile( filename ); //sets file name | ||
1047 | lnk.setIcon("opieplayer2/musicfile"); | ||
1048 | d->selectedFiles->addToSelection( lnk ); | ||
1049 | writeCurrentM3u(); | ||
1050 | } | ||
1051 | else if( filename.right( 3) == "m3u" ) { | ||
1057 | readm3u( filename); | 1052 | readm3u( filename); |
1058 | else if(filename.right(3) == "pls") | 1053 | |
1054 | } else if( filename.right(3) == "pls" ) { | ||
1059 | readPls( filename); | 1055 | readPls( filename); |
1060 | else { | 1056 | } else { |
1057 | d->selectedFiles->addToSelection( DocLnk(filename) ); | ||
1058 | writeCurrentM3u(); | ||
1059 | } | ||
1060 | } | ||
1061 | |||
1062 | if( fileDlg ) { | ||
1063 | delete fileDlg; | ||
1064 | } | ||
1065 | } | ||
1066 | |||
1067 | |||
1068 | /* | ||
1069 | reads m3u and shows files/urls to playlist widget */ | ||
1070 | void PlayListWidget::readm3u( const QString &filename ) { | ||
1071 | qDebug( "read m3u filename " + filename ); | ||
1072 | |||
1073 | Om3u *m3uList; | ||
1074 | QString s, name; | ||
1075 | m3uList = new Om3u( filename, IO_ReadOnly ); | ||
1076 | m3uList->readM3u(); | ||
1061 | DocLnk lnk; | 1077 | DocLnk lnk; |
1078 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | ||
1079 | s = *it; | ||
1080 | // qDebug("reading "+ s); | ||
1081 | if(s.left(4)=="http") { | ||
1082 | lnk.setName( s ); //sets file name | ||
1083 | lnk.setIcon("opieplayer2/musicfile"); | ||
1084 | if(s.right(4) != '.' || s.right(5) != '.') | ||
1085 | lnk.setFile( s+"/"); //if url with no extension | ||
1086 | else | ||
1087 | lnk.setFile( s ); //sets file name | ||
1088 | |||
1089 | } else { | ||
1090 | // if( QFileInfo( s ).exists() ) { | ||
1091 | lnk.setName( QFileInfo(s).baseName()); | ||
1092 | // if(s.right(4) == '.') {//if regular file | ||
1093 | if(s.left(1) != "/") { | ||
1094 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); | ||
1095 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | ||
1096 | lnk.setIcon("SoundPlayer"); | ||
1097 | } else { | ||
1098 | // qDebug("set link2 "+s); | ||
1099 | lnk.setFile( s); | ||
1100 | lnk.setIcon("SoundPlayer"); | ||
1101 | } | ||
1102 | } | ||
1103 | d->selectedFiles->addToSelection( lnk ); | ||
1104 | } | ||
1105 | Config config( "OpiePlayer" ); | ||
1106 | config.setGroup( "PlayList" ); | ||
1107 | |||
1108 | config.writeEntry("CurrentPlaylist",filename); | ||
1109 | config.write(); | ||
1110 | currentPlayList=filename; | ||
1111 | |||
1112 | // m3uList->write(); | ||
1113 | m3uList->close(); | ||
1114 | if(m3uList) delete m3uList; | ||
1062 | 1115 | ||
1063 | lnk.setName(filename); //sets file name | 1116 | d->selectedFiles->setSelectedItem( s); |
1064 | if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3") | 1117 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
1065 | filename += "/"; | 1118 | |
1066 | lnk.setFile(filename); //sets File property | 1119 | } |
1067 | 1120 | ||
1121 | /* | ||
1122 | reads pls and adds files/urls to playlist */ | ||
1123 | void PlayListWidget::readPls( const QString &filename ) { | ||
1124 | |||
1125 | qDebug( "pls filename is " + filename ); | ||
1126 | Om3u *m3uList; | ||
1127 | QString s, name; | ||
1128 | m3uList = new Om3u( filename, IO_ReadOnly ); | ||
1129 | m3uList->readPls(); | ||
1130 | |||
1131 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | ||
1132 | s = *it; | ||
1133 | // s.replace( QRegExp( "%20" )," " ); | ||
1134 | DocLnk lnk( s ); | ||
1135 | QFileInfo f( s ); | ||
1136 | QString name = f.baseName(); | ||
1137 | |||
1138 | if( name.left( 4 ) == "http" ) { | ||
1139 | name = s.right( s.length() - 7); | ||
1140 | } else { | ||
1141 | name = s; | ||
1142 | } | ||
1143 | |||
1144 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | ||
1145 | |||
1146 | lnk.setName( name ); | ||
1147 | if( s.at( s.length() - 4) == '.') {// if this is probably a file | ||
1148 | lnk.setFile( s ); | ||
1149 | } else { //if its a url | ||
1150 | if( name.right( 1 ).find( '/' ) == -1) { | ||
1151 | s += "/"; | ||
1152 | } | ||
1153 | lnk.setFile( s ); | ||
1154 | } | ||
1068 | lnk.setType("audio/x-mpegurl"); | 1155 | lnk.setType("audio/x-mpegurl"); |
1069 | lnk.setExec("opieplayer"); | ||
1070 | lnk.setIcon("opieplayer/MPEGPlayer"); | ||
1071 | 1156 | ||
1072 | if(!lnk.writeLink()) | 1157 | lnk.writeLink(); |
1073 | qDebug("Writing doclink did not work"); | ||
1074 | d->selectedFiles->addToSelection( lnk); | 1158 | d->selectedFiles->addToSelection( lnk); |
1075 | // if(fileDlg2) | ||
1076 | // delete fileDlg2; | ||
1077 | } | 1159 | } |
1160 | |||
1161 | m3uList->close(); | ||
1162 | if(m3uList) delete m3uList; | ||
1078 | } | 1163 | } |
1079 | if(fileDlg) | 1164 | |
1080 | delete fileDlg; | 1165 | /* |
1166 | writes current playlist to current m3u file */ | ||
1167 | void PlayListWidget::writeCurrentM3u() { | ||
1168 | qDebug("writing to current m3u"); | ||
1169 | Config cfg( "OpiePlayer" ); | ||
1170 | cfg.setGroup("PlayList"); | ||
1171 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | ||
1172 | |||
1173 | if( d->selectedFiles->first()) { | ||
1174 | Om3u *m3uList; | ||
1175 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | ||
1176 | |||
1177 | do { | ||
1178 | qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); | ||
1179 | m3uList->add( d->selectedFiles->current()->file() ); | ||
1180 | } | ||
1181 | while ( d->selectedFiles->next() ); | ||
1182 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | ||
1183 | m3uList->write(); | ||
1184 | m3uList->close(); | ||
1185 | |||
1186 | if(m3uList) delete m3uList; | ||
1187 | } | ||
1188 | } | ||
1189 | |||
1190 | /* | ||
1191 | writes current playlist to m3u file */ | ||
1192 | void PlayListWidget::writem3u() { | ||
1193 | InputDialog *fileDlg; | ||
1194 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | ||
1195 | fileDlg->exec(); | ||
1196 | QString name, filename, list; | ||
1197 | Om3u *m3uList; | ||
1198 | |||
1199 | if( fileDlg->result() == 1 ) { | ||
1200 | name = fileDlg->text(); | ||
1201 | // qDebug( filename ); | ||
1202 | |||
1203 | if( name.left( 1) != "/" ) { | ||
1204 | filename = QPEApplication::documentDir() + "/" + name; | ||
1205 | } | ||
1206 | |||
1207 | if( name.right( 3 ) != "m3u" ) { | ||
1208 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; | ||
1209 | } | ||
1210 | |||
1211 | if( d->selectedFiles->first()) { | ||
1212 | m3uList = new Om3u(filename, IO_ReadWrite); | ||
1213 | |||
1214 | do { | ||
1215 | m3uList->add( d->selectedFiles->current()->file()); | ||
1216 | } | ||
1217 | while ( d->selectedFiles->next() ); | ||
1218 | // qDebug( list ); | ||
1219 | m3uList->write(); | ||
1220 | m3uList->close(); | ||
1221 | if(m3uList) delete m3uList; | ||
1222 | |||
1223 | if(fileDlg) delete fileDlg; | ||
1224 | |||
1225 | DocLnk lnk; | ||
1226 | lnk.setFile( filename); | ||
1227 | lnk.setIcon("opieplayer2/playlist2"); | ||
1228 | lnk.setName( name); //sets file name | ||
1229 | |||
1230 | // qDebug(filename); | ||
1231 | Config config( "OpiePlayer" ); | ||
1232 | config.setGroup( "PlayList" ); | ||
1233 | |||
1234 | config.writeEntry("CurrentPlaylist",filename); | ||
1235 | currentPlayList=filename; | ||
1236 | |||
1237 | if(!lnk.writeLink()) { | ||
1238 | qDebug("Writing doclink did not work"); | ||
1081 | } | 1239 | } |
1082 | 1240 | ||
1241 | setCaption(tr("OpiePlayer: ") + name); | ||
1242 | } | ||
1243 | } | ||
1244 | } | ||
1245 | |||
1246 | |||
1083 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | 1247 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) |
1084 | { | 1248 | { |
1085 | switch ( e->key() ) { | 1249 | switch ( e->key() ) { |
1086 | ////////////////////////////// Zaurus keys | 1250 | ////////////////////////////// Zaurus keys |
1087 | case Key_F9: //activity | 1251 | case Key_F9: //activity |
1088 | // if(audioUI->isHidden()) | 1252 | // if(audioUI->isHidden()) |
1089 | // audioUI->showMaximized(); | 1253 | // audioUI->showMaximized(); |
1090 | break; | 1254 | break; |
1091 | case Key_F10: //contacts | 1255 | case Key_F10: //contacts |
1092 | // if( videoUI->isHidden()) | 1256 | // if( videoUI->isHidden()) |
1093 | // videoUI->showMaximized(); | 1257 | // videoUI->showMaximized(); |
1094 | break; | 1258 | break; |
@@ -1132,25 +1296,25 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | |||
1132 | d->selectedFiles->first(); | 1296 | d->selectedFiles->first(); |
1133 | 1297 | ||
1134 | break; | 1298 | break; |
1135 | case Key_Up: | 1299 | case Key_Up: |
1136 | if ( !d->selectedFiles->prev() ) | 1300 | if ( !d->selectedFiles->prev() ) |
1137 | // d->selectedFiles->last(); | 1301 | // d->selectedFiles->last(); |
1138 | 1302 | ||
1139 | break; | 1303 | break; |
1140 | 1304 | ||
1141 | } | 1305 | } |
1142 | } | 1306 | } |
1143 | 1307 | ||
1144 | void PlayListWidget::keyPressEvent( QKeyEvent *e) | 1308 | void PlayListWidget::keyPressEvent( QKeyEvent *) |
1145 | { | 1309 | { |
1146 | // qDebug("Key press"); | 1310 | // qDebug("Key press"); |
1147 | // switch ( e->key() ) { | 1311 | // switch ( e->key() ) { |
1148 | // ////////////////////////////// Zaurus keys | 1312 | // ////////////////////////////// Zaurus keys |
1149 | // case Key_A: //add to playlist | 1313 | // case Key_A: //add to playlist |
1150 | // qDebug("Add"); | 1314 | // qDebug("Add"); |
1151 | // addSelected(); | 1315 | // addSelected(); |
1152 | // break; | 1316 | // break; |
1153 | // case Key_R: //remove from playlist | 1317 | // case Key_R: //remove from playlist |
1154 | // removeSelected(); | 1318 | // removeSelected(); |
1155 | // break; | 1319 | // break; |
1156 | // case Key_P: //play | 1320 | // case Key_P: //play |
@@ -1177,156 +1341,12 @@ void PlayListWidget::doUnblank() { | |||
1177 | // this crashes opieplayer with a segfault | 1341 | // this crashes opieplayer with a segfault |
1178 | // int fd; | 1342 | // int fd; |
1179 | // fd=open("/dev/fb0",O_RDWR); | 1343 | // fd=open("/dev/fb0",O_RDWR); |
1180 | qDebug("do unblanking"); | 1344 | qDebug("do unblanking"); |
1181 | if (fd != -1) { | 1345 | if (fd != -1) { |
1182 | ioctl(fd,FBIOBLANK,0); | 1346 | ioctl(fd,FBIOBLANK,0); |
1183 | close(fd); | 1347 | close(fd); |
1184 | } | 1348 | } |
1185 | QCopEnvelope h("QPE/System", "setBacklight(int)"); | 1349 | QCopEnvelope h("QPE/System", "setBacklight(int)"); |
1186 | h <<-3;// v[1]; // -3 Force on | 1350 | h <<-3;// v[1]; // -3 Force on |
1187 | } | 1351 | } |
1188 | 1352 | ||
1189 | void PlayListWidget::readm3u(const QString &filename) { | ||
1190 | |||
1191 | qDebug("m3u filename is "+filename); | ||
1192 | QFile f(filename); | ||
1193 | |||
1194 | if(f.open(IO_ReadOnly)) { | ||
1195 | QTextStream t(&f); | ||
1196 | QString s;//, first, second; | ||
1197 | int i=0; | ||
1198 | while ( !t.atEnd()) { | ||
1199 | // Lview->insertLine(t.readLine(),-1); | ||
1200 | s=t.readLine(); | ||
1201 | |||
1202 | if(s.find("#",0,TRUE) == -1) { | ||
1203 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat | ||
1204 | if(s.left(2) == "E:" || s.left(2) == "P:") { | ||
1205 | s=s.right(s.length()-2); | ||
1206 | DocLnk lnk( s ); | ||
1207 | QFileInfo f(s); | ||
1208 | QString name = f.baseName(); | ||
1209 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | ||
1210 | lnk.setName( name); | ||
1211 | s=s.replace( QRegExp("\\"),"/"); | ||
1212 | lnk.setFile( s); | ||
1213 | lnk.writeLink(); | ||
1214 | // lnk.setIcon(opieplayer/MPEGPlayer); | ||
1215 | qDebug("add "+name); | ||
1216 | d->selectedFiles->addToSelection( lnk); | ||
1217 | } else { // is url | ||
1218 | |||
1219 | s.replace(QRegExp("%20")," "); | ||
1220 | DocLnk lnk( s); | ||
1221 | QString name; | ||
1222 | if(name.left(4)=="http") | ||
1223 | name = s.right( s.length() - 7); | ||
1224 | else | ||
1225 | name=s; | ||
1226 | // name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | ||
1227 | lnk.setName(name); | ||
1228 | if(s.at(s.length()-4) == '.') | ||
1229 | lnk.setFile( s); | ||
1230 | else | ||
1231 | lnk.setFile( s+"/"); | ||
1232 | // lnk.setFile( filename); | ||
1233 | // lnk.setComment( s+"/"); | ||
1234 | lnk.setType("audio/x-mpegurl"); | ||
1235 | lnk.writeLink(); | ||
1236 | // lnk.setIcon( "opieplayer/MPEGPlayer"); | ||
1237 | // qDebug("add "+s); | ||
1238 | d->selectedFiles->addToSelection( lnk); | ||
1239 | } | ||
1240 | i++; | ||
1241 | } | ||
1242 | } | ||
1243 | } | ||
1244 | } | ||
1245 | f.close(); | ||
1246 | } | ||
1247 | |||
1248 | void PlayListWidget::writem3u() { | ||
1249 | |||
1250 | InputDialog *fileDlg; | ||
1251 | fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0); | ||
1252 | fileDlg->exec(); | ||
1253 | QString filename,list; | ||
1254 | if( fileDlg->result() == 1 ) { | ||
1255 | filename = fileDlg->LineEdit1->text(); | ||
1256 | qDebug(filename); | ||
1257 | int noOfFiles = 0; | ||
1258 | d->selectedFiles->first(); | ||
1259 | do { | ||
1260 | // we dont check for existance because of url's | ||
1261 | // qDebug(d->selectedFiles->current()->file()); | ||
1262 | list += d->selectedFiles->current()->file()+"\n"; | ||
1263 | noOfFiles++; | ||
1264 | } | ||
1265 | while ( d->selectedFiles->next() ); | ||
1266 | qDebug(list); | ||
1267 | if(filename.left(1) != "/") | ||
1268 | filename=QPEApplication::documentDir()+"/"+filename; | ||
1269 | if(filename.right(3) != "m3u") | ||
1270 | filename=filename+".m3u"; | ||
1271 | |||
1272 | QFile f(filename); | ||
1273 | f.open(IO_WriteOnly); | ||
1274 | f.writeBlock(list, list.length()); | ||
1275 | f.close(); | ||
1276 | } | ||
1277 | if(fileDlg) delete fileDlg; | ||
1278 | } | ||
1279 | |||
1280 | void PlayListWidget::readPls(const QString &filename) { | ||
1281 | |||
1282 | qDebug("pls filename is "+filename); | ||
1283 | QFile f(filename); | ||
1284 | |||
1285 | if(f.open(IO_ReadOnly)) { | ||
1286 | QTextStream t(&f); | ||
1287 | QString s;//, first, second; | ||
1288 | int i=0; | ||
1289 | while ( !t.atEnd()) { | ||
1290 | s=t.readLine(); | ||
1291 | if(s.left(4) == "File") { | ||
1292 | s=s.right(s.length() - 6); | ||
1293 | s.replace(QRegExp("%20")," "); | ||
1294 | qDebug("adding "+s+" to playlist"); | ||
1295 | // numberofentries=2 | ||
1296 | // File1=http | ||
1297 | // Title | ||
1298 | // Length | ||
1299 | // Version | ||
1300 | // File2=http | ||
1301 | |||
1302 | s=s.replace( QRegExp("\\"),"/"); | ||
1303 | DocLnk lnk( s ); | ||
1304 | QFileInfo f(s); | ||
1305 | QString name = f.baseName(); | ||
1306 | if(name.left(4)=="http") | ||
1307 | name = s.right( s.length() - 7); | ||
1308 | else | ||
1309 | name=s; | ||
1310 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | ||
1311 | // QFileInfo f(s); | ||
1312 | // QString name = f.baseName(); | ||
1313 | // name = name.left(name.length()-4); | ||
1314 | // name = name.right(name.findRev("/",0,TRUE)); | ||
1315 | lnk.setName( name); | ||
1316 | if(s.at(s.length()-4) == '.') // if this is probably a file | ||
1317 | lnk.setFile( s); | ||
1318 | else { //if its a url | ||
1319 | if( name.right(1).find('/') == -1) | ||
1320 | s+="/"; | ||
1321 | lnk.setFile( s); | ||
1322 | } | ||
1323 | lnk.setType("audio/x-mpegurl"); | ||
1324 | |||
1325 | qDebug("DocLnk add "+name); | ||
1326 | d->selectedFiles->addToSelection( lnk); | ||
1327 | } | ||
1328 | } | ||
1329 | i++; | ||
1330 | } | ||
1331 | } | ||
1332 | |||