-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 172 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.h | 36 |
2 files changed, 131 insertions, 77 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index db6533a..3b8f6d7 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -15,16 +15,19 @@ | |||
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 | 20 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 |
21 | #define QTOPIA_INTERNAL_FSLP | ||
22 | |||
21 | #include <qpe/qpemenubar.h> | 23 | #include <qpe/qpemenubar.h> |
22 | #include <qpe/qpetoolbar.h> | 24 | #include <qpe/qpetoolbar.h> |
23 | #include <qpe/fileselector.h> | 25 | #include <qpe/fileselector.h> |
24 | #include <qpe/qpeapplication.h> | 26 | #include <qpe/qpeapplication.h> |
27 | #include <qpe/lnkproperties.h> | ||
25 | 28 | ||
26 | #include <qpe/applnk.h> | 29 | #include <qpe/applnk.h> |
27 | #include <qpe/config.h> | 30 | #include <qpe/config.h> |
28 | #include <qpe/global.h> | 31 | #include <qpe/global.h> |
29 | #include <qpe/resource.h> | 32 | #include <qpe/resource.h> |
30 | #include <qaction.h> | 33 | #include <qaction.h> |
@@ -204,79 +207,53 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
204 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 207 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
205 | 208 | ||
206 | QWidget *aTab; | 209 | QWidget *aTab; |
207 | aTab = new QWidget( tabWidget, "aTab" ); | 210 | aTab = new QWidget( tabWidget, "aTab" ); |
208 | audioView = new QListView( aTab, "Audioview" ); | 211 | audioView = new QListView( aTab, "Audioview" ); |
209 | audioView->setMinimumSize(233,260); | 212 | audioView->setMinimumSize(233,260); |
210 | audioView->addColumn( "Title",140); | 213 | audioView->addColumn( tr("Title"),140); |
211 | audioView->addColumn("Size", -1); | 214 | audioView->addColumn(tr("Size"), -1); |
212 | audioView->addColumn("Media",-1); | 215 | audioView->addColumn(tr("Media"),-1); |
213 | audioView->setColumnAlignment(1, Qt::AlignRight); | 216 | audioView->setColumnAlignment(1, Qt::AlignRight); |
214 | audioView->setColumnAlignment(2, Qt::AlignRight); | 217 | audioView->setColumnAlignment(2, Qt::AlignRight); |
215 | audioView->setAllColumnsShowFocus(TRUE); | 218 | audioView->setAllColumnsShowFocus(TRUE); |
216 | tabWidget->insertTab(aTab,"Audio"); | 219 | tabWidget->insertTab(aTab,tr("Audio")); |
217 | 220 | ||
218 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); | 221 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); |
219 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 222 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
220 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 223 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
221 | 224 | ||
222 | 225 | ||
223 | // audioView | 226 | // audioView |
224 | Global::findDocuments(&files, "audio/*"); | 227 | populateAudioView(); |
225 | QListIterator<DocLnk> dit( files.children() ); | ||
226 | QString storage; | ||
227 | for ( ; dit.current(); ++dit ) { | ||
228 | QListViewItem * newItem; | ||
229 | if(dit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; | ||
230 | else if(dit.current()->file().find("/mnt/hda") != -1 ) storage="CF"; | ||
231 | else if(dit.current()->file().find("/mnt/card") != -1 ) storage="SD"; | ||
232 | else storage="RAM"; | ||
233 | if ( QFile( dit.current()->file()).exists() ) { | ||
234 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); | ||
235 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" )); | ||
236 | } | ||
237 | } | ||
238 | // videowidget | 228 | // videowidget |
239 | 229 | ||
240 | QWidget *vTab; | 230 | QWidget *vTab; |
241 | vTab = new QWidget( tabWidget, "vTab" ); | 231 | vTab = new QWidget( tabWidget, "vTab" ); |
242 | videoView = new QListView( vTab, "Videoview" ); | 232 | videoView = new QListView( vTab, "Videoview" ); |
243 | videoView->setMinimumSize(233,260); | 233 | videoView->setMinimumSize(233,260); |
244 | 234 | ||
245 | videoView->addColumn("Title",140); | 235 | videoView->addColumn(tr("Title"),140); |
246 | videoView->addColumn("Size",-1); | 236 | videoView->addColumn(tr("Size"),-1); |
247 | videoView->addColumn("Media",-1); | 237 | videoView->addColumn(tr("Media"),-1); |
248 | videoView->setColumnAlignment(1, Qt::AlignRight); | 238 | videoView->setColumnAlignment(1, Qt::AlignRight); |
249 | videoView->setColumnAlignment(2, Qt::AlignRight); | 239 | videoView->setColumnAlignment(2, Qt::AlignRight); |
250 | videoView->setAllColumnsShowFocus(TRUE); | 240 | videoView->setAllColumnsShowFocus(TRUE); |
251 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | 241 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); |
252 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 242 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
253 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 243 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
254 | 244 | ||
255 | tabWidget->insertTab( vTab,"Video"); | 245 | tabWidget->insertTab( vTab,tr("Video")); |
256 | 246 | ||
257 | Global::findDocuments(&vFiles, "video/*"); | ||
258 | QListIterator<DocLnk> Vdit( vFiles.children() ); | ||
259 | for ( ; Vdit.current(); ++Vdit ) { | ||
260 | if( Vdit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; | ||
261 | else if( Vdit.current()->file().find("/mnt/hda") != -1 ) storage="CF"; | ||
262 | else if( Vdit.current()->file().find("/mnt/card") != -1 ) storage="SD"; | ||
263 | else storage="RAM"; | ||
264 | QListViewItem * newItem; | ||
265 | if ( QFile( Vdit.current()->file()).exists() ) { | ||
266 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); | ||
267 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); | ||
268 | } | ||
269 | } | ||
270 | 247 | ||
271 | //playlists list | 248 | //playlists list |
272 | QWidget *LTab; | 249 | QWidget *LTab; |
273 | LTab = new QWidget( tabWidget, "LTab" ); | 250 | LTab = new QWidget( tabWidget, "LTab" ); |
274 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy | 251 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy |
275 | playLists->setMinimumSize(233,260);; | 252 | playLists->setMinimumSize(233,260);; |
276 | tabWidget->insertTab(LTab,"Lists"); | 253 | tabWidget->insertTab(LTab,tr("Lists")); |
277 | 254 | ||
278 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 255 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
279 | // connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); | 256 | // connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); |
280 | 257 | ||
281 | 258 | ||
282 | // add the library area | 259 | // add the library area |
@@ -305,13 +282,13 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
305 | 282 | ||
306 | Config cfg( "MediaPlayer" ); | 283 | Config cfg( "MediaPlayer" ); |
307 | readConfig( cfg ); | 284 | readConfig( cfg ); |
308 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 285 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
309 | // qDebug("currentList is "+currentPlaylist); | 286 | // qDebug("currentList is "+currentPlaylist); |
310 | loadList(DocLnk( currentPlaylist)); | 287 | loadList(DocLnk( currentPlaylist)); |
311 | setCaption("OpiePlayer: "+ currentPlaylist ); | 288 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); |
312 | 289 | ||
313 | initializeStates(); | 290 | initializeStates(); |
314 | } | 291 | } |
315 | 292 | ||
316 | 293 | ||
317 | PlayListWidget::~PlayListWidget() { | 294 | PlayListWidget::~PlayListWidget() { |
@@ -447,13 +424,13 @@ void PlayListWidget::setDocument(const QString& fileref) { | |||
447 | addToSelection( DocLnk( fileref ) ); | 424 | addToSelection( DocLnk( fileref ) ); |
448 | d->setDocumentUsed = TRUE; | 425 | d->setDocumentUsed = TRUE; |
449 | mediaPlayerState->setPlaying( FALSE ); | 426 | mediaPlayerState->setPlaying( FALSE ); |
450 | qApp->processEvents(); | 427 | qApp->processEvents(); |
451 | mediaPlayerState->setPlaying( TRUE ); | 428 | mediaPlayerState->setPlaying( TRUE ); |
452 | qApp->processEvents(); | 429 | qApp->processEvents(); |
453 | setCaption("OpiePlayer"); | 430 | setCaption(tr("OpiePlayer")); |
454 | 431 | ||
455 | } else { //is playlist | 432 | } else { //is playlist |
456 | clearList(); | 433 | clearList(); |
457 | loadList(DocLnk(fileref)); | 434 | loadList(DocLnk(fileref)); |
458 | d->selectedFiles->first(); | 435 | d->selectedFiles->first(); |
459 | } | 436 | } |
@@ -490,13 +467,13 @@ const DocLnk *PlayListWidget::current() { // this is fugly | |||
490 | // qDebug("current"); | 467 | // qDebug("current"); |
491 | // switch (tabWidget->currentPageIndex()) { | 468 | // switch (tabWidget->currentPageIndex()) { |
492 | // case 0: //playlist | 469 | // case 0: //playlist |
493 | // { | 470 | // { |
494 | qDebug("playlist"); | 471 | qDebug("playlist"); |
495 | if ( mediaPlayerState->playlist() ) { | 472 | if ( mediaPlayerState->playlist() ) { |
496 | return d->selectedFiles->current(); | 473 | return d->selectedFiles->current(); |
497 | } | 474 | } |
498 | else if ( d->setDocumentUsed && d->current ) { | 475 | else if ( d->setDocumentUsed && d->current ) { |
499 | return d->current; | 476 | return d->current; |
500 | } else { | 477 | } else { |
501 | return d->files->selected(); | 478 | return d->files->selected(); |
502 | } | 479 | } |
@@ -599,13 +576,13 @@ bool PlayListWidget::last() { | |||
599 | 576 | ||
600 | 577 | ||
601 | void PlayListWidget::saveList() { | 578 | void PlayListWidget::saveList() { |
602 | 579 | ||
603 | QString filename; | 580 | QString filename; |
604 | InputDialog *fileDlg; | 581 | InputDialog *fileDlg; |
605 | fileDlg = new InputDialog(this,"Save Playlist",TRUE, 0); | 582 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); |
606 | fileDlg->exec(); | 583 | fileDlg->exec(); |
607 | if( fileDlg->result() == 1 ) { | 584 | if( fileDlg->result() == 1 ) { |
608 | if ( d->current ) | 585 | if ( d->current ) |
609 | delete d->current; | 586 | delete d->current; |
610 | filename = fileDlg->LineEdit1->text();//+".playlist"; | 587 | filename = fileDlg->LineEdit1->text();//+".playlist"; |
611 | // qDebug("saving playlist "+filename+".playlist"); | 588 | // qDebug("saving playlist "+filename+".playlist"); |
@@ -626,13 +603,13 @@ void PlayListWidget::saveList() { | |||
626 | lnk.setName( filename); //sets file name | 603 | lnk.setName( filename); //sets file name |
627 | if(!lnk.writeLink()) | 604 | if(!lnk.writeLink()) |
628 | qDebug("Writing doclink did not work"); | 605 | qDebug("Writing doclink did not work"); |
629 | } | 606 | } |
630 | Config config( "MediaPlayer" ); | 607 | Config config( "MediaPlayer" ); |
631 | config.writeEntry("CurrentPlaylist",filename); | 608 | config.writeEntry("CurrentPlaylist",filename); |
632 | setCaption("OpiePlayer: "+filename); | 609 | setCaption(tr("OpiePlayer: ")+filename); |
633 | d->selectedFiles->first(); | 610 | d->selectedFiles->first(); |
634 | if(fileDlg) | 611 | if(fileDlg) |
635 | delete fileDlg; | 612 | delete fileDlg; |
636 | } | 613 | } |
637 | 614 | ||
638 | void PlayListWidget::loadList( const DocLnk & lnk) { | 615 | void PlayListWidget::loadList( const DocLnk & lnk) { |
@@ -678,13 +655,13 @@ void PlayListWidget::addSelected() { | |||
678 | case 1: { //audio | 655 | case 1: { //audio |
679 | for ( int i = 0; i < noOfFiles; i++ ) { | 656 | for ( int i = 0; i < noOfFiles; i++ ) { |
680 | QString entryName; | 657 | QString entryName; |
681 | entryName.sprintf( "File%i", i + 1 ); | 658 | entryName.sprintf( "File%i", i + 1 ); |
682 | QString linkFile = cfg.readEntry( entryName ); | 659 | QString linkFile = cfg.readEntry( entryName ); |
683 | if( DocLnk( linkFile).name() == audioView->selectedItem()->text(0) ) { | 660 | if( DocLnk( linkFile).name() == audioView->selectedItem()->text(0) ) { |
684 | int result= QMessageBox::warning(this,"OpiePlayer", | 661 | int result= QMessageBox::warning(this,tr("OpiePlayer"), |
685 | tr("This is all ready in your playlist.\nContinue?"), | 662 | tr("This is all ready in your playlist.\nContinue?"), |
686 | tr("Yes"),tr("No"),0,0,1); | 663 | tr("Yes"),tr("No"),0,0,1); |
687 | if (result !=0) | 664 | if (result !=0) |
688 | return; | 665 | return; |
689 | } | 666 | } |
690 | } | 667 | } |
@@ -695,13 +672,13 @@ void PlayListWidget::addSelected() { | |||
695 | case 2: { // video | 672 | case 2: { // video |
696 | for ( int i = 0; i < noOfFiles; i++ ) { | 673 | for ( int i = 0; i < noOfFiles; i++ ) { |
697 | QString entryName; | 674 | QString entryName; |
698 | entryName.sprintf( "File%i", i + 1 ); | 675 | entryName.sprintf( "File%i", i + 1 ); |
699 | QString linkFile = cfg.readEntry( entryName ); | 676 | QString linkFile = cfg.readEntry( entryName ); |
700 | if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { | 677 | if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { |
701 | int result= QMessageBox::warning(this,"OpiePlayer", | 678 | int result= QMessageBox::warning(this,tr("OpiePlayer"), |
702 | tr("This is all ready in your playlist.\nContinue?"), | 679 | tr("This is all ready in your playlist.\nContinue?"), |
703 | tr("Yes"),tr("No"),0,0,1); | 680 | tr("Yes"),tr("No"),0,0,1); |
704 | if (result !=0) | 681 | if (result !=0) |
705 | return; | 682 | return; |
706 | } | 683 | } |
707 | } | 684 | } |
@@ -713,51 +690,44 @@ void PlayListWidget::addSelected() { | |||
713 | } | 690 | } |
714 | 691 | ||
715 | void PlayListWidget::removeSelected() { | 692 | void PlayListWidget::removeSelected() { |
716 | d->selectedFiles->removeSelected( ); | 693 | d->selectedFiles->removeSelected( ); |
717 | } | 694 | } |
718 | 695 | ||
719 | |||
720 | void PlayListWidget::playIt( QListViewItem *it) { | 696 | void PlayListWidget::playIt( QListViewItem *it) { |
721 | // d->setDocumentUsed = FALSE; | 697 | // d->setDocumentUsed = FALSE; |
722 | mediaPlayerState->setPlaying(TRUE); | 698 | mediaPlayerState->setPlaying(TRUE); |
723 | } | 699 | } |
724 | 700 | ||
725 | void PlayListWidget::addToSelection( QListViewItem *it) { | 701 | void PlayListWidget::addToSelection( QListViewItem *it) { |
726 | d->setDocumentUsed = FALSE; | 702 | d->setDocumentUsed = FALSE; |
727 | 703 | ||
728 | if(it) { | 704 | if(it) { |
729 | // qDebug("add to selection"); | ||
730 | switch (tabWidget->currentPageIndex()) { | 705 | switch (tabWidget->currentPageIndex()) { |
731 | case 1: { | 706 | case 1: { |
732 | // qDebug("case 1"); | ||
733 | QListIterator<DocLnk> dit( files.children() ); | 707 | QListIterator<DocLnk> dit( files.children() ); |
734 | for ( ; dit.current(); ++dit ) { | 708 | for ( ; dit.current(); ++dit ) { |
735 | // qDebug(dit.current()->name()); | ||
736 | if( dit.current()->name() == it->text(0)) { | 709 | if( dit.current()->name() == it->text(0)) { |
737 | d->selectedFiles->addToSelection( **dit ); | 710 | d->selectedFiles->addToSelection( **dit ); |
738 | } | 711 | } |
739 | } | 712 | } |
740 | } | 713 | } |
741 | break; | 714 | break; |
742 | case 2: { | 715 | case 2: { |
743 | // qDebug("case 2"); | ||
744 | QListIterator<DocLnk> dit( vFiles.children() ); | 716 | QListIterator<DocLnk> dit( vFiles.children() ); |
745 | for ( ; dit.current(); ++dit ) { | 717 | for ( ; dit.current(); ++dit ) { |
746 | // qDebug(dit.current()->name()); | ||
747 | if( dit.current()->name() == it->text(0)) { | 718 | if( dit.current()->name() == it->text(0)) { |
748 | d->selectedFiles->addToSelection( **dit ); | 719 | d->selectedFiles->addToSelection( **dit ); |
749 | } | 720 | } |
750 | } | 721 | } |
751 | } | 722 | } |
752 | break; | 723 | break; |
753 | case 0: | 724 | case 0: |
754 | break; | 725 | break; |
755 | }; | 726 | }; |
756 | tabWidget->setCurrentPage(0); | 727 | tabWidget->setCurrentPage(0); |
757 | // mediaPlayerState->setPlaying( TRUE ); | ||
758 | } | 728 | } |
759 | } | 729 | } |
760 | 730 | ||
761 | void PlayListWidget::tabChanged(QWidget *widg) { | 731 | void PlayListWidget::tabChanged(QWidget *widg) { |
762 | 732 | ||
763 | switch ( tabWidget->currentPageIndex()) { | 733 | switch ( tabWidget->currentPageIndex()) { |
@@ -793,15 +763,15 @@ void PlayListWidget::tabChanged(QWidget *widg) { | |||
793 | } | 763 | } |
794 | break; | 764 | break; |
795 | }; | 765 | }; |
796 | } | 766 | } |
797 | 767 | ||
798 | 768 | ||
799 | /* | 769 | |
800 | play button is pressed*/ | ||
801 | void PlayListWidget::btnPlay(bool b) { | 770 | void PlayListWidget::btnPlay(bool b) { |
771 | |||
802 | // mediaPlayerState->setPlaying(b); | 772 | // mediaPlayerState->setPlaying(b); |
803 | switch ( tabWidget->currentPageIndex()) { | 773 | switch ( tabWidget->currentPageIndex()) { |
804 | case 0: | 774 | case 0: |
805 | { | 775 | { |
806 | mediaPlayerState->setPlaying(b); | 776 | mediaPlayerState->setPlaying(b); |
807 | } | 777 | } |
@@ -810,32 +780,28 @@ void PlayListWidget::btnPlay(bool b) { | |||
810 | { | 780 | { |
811 | addToSelection( audioView->selectedItem() ); | 781 | addToSelection( audioView->selectedItem() ); |
812 | mediaPlayerState->setPlaying(b); | 782 | mediaPlayerState->setPlaying(b); |
813 | // qApp->processEvents(); | 783 | // qApp->processEvents(); |
814 | d->selectedFiles->removeSelected( ); | 784 | d->selectedFiles->removeSelected( ); |
815 | tabWidget->setCurrentPage(1); | 785 | tabWidget->setCurrentPage(1); |
816 | d->selectedFiles->unSelect(); | 786 | d->selectedFiles->unSelect(); |
817 | // mediaPlayerState->setPlaying(FALSE); | 787 | // mediaPlayerState->setPlaying(FALSE); |
818 | } | 788 | } |
819 | break; | 789 | break; |
820 | case 2: | 790 | case 2: |
821 | { | 791 | { |
822 | addToSelection( videoView->selectedItem() ); | 792 | addToSelection( videoView->selectedItem() ); |
823 | mediaPlayerState->setPlaying(b); | 793 | mediaPlayerState->setPlaying(b); |
824 | qApp->processEvents(); | 794 | qApp->processEvents(); |
825 | d->selectedFiles->removeSelected( ); | 795 | d->selectedFiles->removeSelected( ); |
826 | tabWidget->setCurrentPage(2); | 796 | tabWidget->setCurrentPage(2); |
827 | d->selectedFiles->unSelect(); | 797 | d->selectedFiles->unSelect(); |
828 | // mediaPlayerState->setPlaying(FALSE); | 798 | // mediaPlayerState->setPlaying(FALSE); |
829 | } | 799 | } |
830 | break; | 800 | break; |
831 | }; | 801 | }; |
832 | |||
833 | |||
834 | |||
835 | |||
836 | } | 802 | } |
837 | 803 | ||
838 | void PlayListWidget::deletePlaylist() { | 804 | void PlayListWidget::deletePlaylist() { |
839 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 805 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
840 | (tr("You really want to delete\nthis playlist?")), | 806 | (tr("You really want to delete\nthis playlist?")), |
841 | (tr("Yes")), (tr("No")), 0 )){ | 807 | (tr("Yes")), (tr("No")), 0 )){ |
@@ -856,19 +822,18 @@ void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& | |||
856 | case 1: | 822 | case 1: |
857 | break; | 823 | break; |
858 | case 2:{ | 824 | case 2:{ |
859 | QPopupMenu m; | 825 | QPopupMenu m; |
860 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 826 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
861 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 827 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
862 | // m.insertSeparator(); | 828 | m.insertSeparator(); |
863 | // m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 829 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
864 | m.exec( QCursor::pos() ); | 830 | m.exec( QCursor::pos() ); |
865 | } | 831 | } |
866 | break; | 832 | break; |
867 | }; | 833 | }; |
868 | |||
869 | } | 834 | } |
870 | 835 | ||
871 | void PlayListWidget::playSelected() | 836 | void PlayListWidget::playSelected() |
872 | { | 837 | { |
873 | btnPlay( TRUE); | 838 | btnPlay( TRUE); |
874 | } | 839 | } |
@@ -886,6 +851,91 @@ void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const | |||
886 | m.exec( QCursor::pos() ); | 851 | m.exec( QCursor::pos() ); |
887 | } | 852 | } |
888 | break; | 853 | break; |
889 | }; | 854 | }; |
890 | 855 | ||
891 | } | 856 | } |
857 | |||
858 | void PlayListWidget::listDelete() { | ||
859 | Config cfg( "MediaPlayer" ); | ||
860 | cfg.setGroup("PlayList"); | ||
861 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | ||
862 | QString file; | ||
863 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | ||
864 | switch ( tabWidget->currentPageIndex()) { | ||
865 | case 0: | ||
866 | break; | ||
867 | case 1: | ||
868 | { | ||
869 | file = audioView->selectedItem()->text(0); | ||
870 | // Global::findDocuments(&files, "audio/*"); | ||
871 | // AppLnkSet appFiles; | ||
872 | QListIterator<DocLnk> dit( files.children() ); | ||
873 | for ( ; dit.current(); ++dit ) { | ||
874 | if( dit.current()->name() == file) { | ||
875 | qDebug(file); | ||
876 | LnkProperties prop( dit.current() ); | ||
877 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | ||
878 | prop.showMaximized(); | ||
879 | prop.exec(); | ||
880 | } | ||
881 | } | ||
882 | populateAudioView(); | ||
883 | } | ||
884 | break; | ||
885 | case 2: | ||
886 | { | ||
887 | // file = videoView->selectedItem()->text(0); | ||
888 | // for ( int i = 0; i < noOfFiles; i++ ) { | ||
889 | // QString entryName; | ||
890 | // entryName.sprintf( "File%i", i + 1 ); | ||
891 | // QString linkFile = cfg.readEntry( entryName ); | ||
892 | // AppLnk lnk( AppLnk(linkFile)); | ||
893 | // if( lnk.name() == file ) { | ||
894 | // LnkProperties prop( &lnk); | ||
895 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | ||
896 | // prop.showMaximized(); | ||
897 | // prop.exec(); | ||
898 | // } | ||
899 | // } | ||
900 | } | ||
901 | break; | ||
902 | }; | ||
903 | } | ||
904 | |||
905 | void PlayListWidget::populateAudioView() { | ||
906 | // if(files) | ||
907 | // files.~DocLnkSet(); | ||
908 | Global::findDocuments(&files, "audio/*"); | ||
909 | QListIterator<DocLnk> dit( files.children() ); | ||
910 | audioView->clear(); | ||
911 | QString storage; | ||
912 | for ( ; dit.current(); ++dit ) { | ||
913 | QListViewItem * newItem; | ||
914 | if(dit.current()->file().find("/mnt/cf") != -1 ) storage=tr("CF"); | ||
915 | else if(dit.current()->file().find("/mnt/hda") != -1 ) storage=tr("CF"); | ||
916 | else if(dit.current()->file().find("/mnt/card") != -1 ) storage=tr("SD"); | ||
917 | else storage=tr("RAM"); | ||
918 | if ( QFile( dit.current()->file()).exists() ) { | ||
919 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); | ||
920 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" )); | ||
921 | } | ||
922 | } | ||
923 | } | ||
924 | |||
925 | void PlayListWidget::populateVideoView() { | ||
926 | Global::findDocuments(&vFiles, "video/*"); | ||
927 | QListIterator<DocLnk> Vdit( vFiles.children() ); | ||
928 | videoView->clear(); | ||
929 | QString storage; | ||
930 | for ( ; Vdit.current(); ++Vdit ) { | ||
931 | if( Vdit.current()->file().find("/mnt/cf") != -1 ) storage=tr("CF"); | ||
932 | else if( Vdit.current()->file().find("/mnt/hda") != -1 ) storage=tr("CF"); | ||
933 | else if( Vdit.current()->file().find("/mnt/card") != -1 ) storage=tr("SD"); | ||
934 | else storage=tr("RAM"); | ||
935 | QListViewItem * newItem; | ||
936 | if ( QFile( Vdit.current()->file()).exists() ) { | ||
937 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); | ||
938 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); | ||
939 | } | ||
940 | } | ||
941 | } | ||
diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h index 10a42df..186ca1b 100644 --- a/core/multimedia/opieplayer/playlistwidget.h +++ b/core/multimedia/opieplayer/playlistwidget.h | |||
@@ -55,12 +55,30 @@ public: | |||
55 | const DocLnk *current(); | 55 | const DocLnk *current(); |
56 | void useSelectedDocument(); | 56 | void useSelectedDocument(); |
57 | /* QTimer * menuTimer; */ | 57 | /* QTimer * menuTimer; */ |
58 | FileSelector* playLists; | 58 | FileSelector* playLists; |
59 | QPushButton *tbDeletePlaylist; | 59 | QPushButton *tbDeletePlaylist; |
60 | public slots: | 60 | public slots: |
61 | bool first(); | ||
62 | bool last(); | ||
63 | bool next(); | ||
64 | bool prev(); | ||
65 | /* void setFullScreen(); */ | ||
66 | /* void setScaled(); */ | ||
67 | protected: | ||
68 | /* void contentsMousePressEvent( QMouseEvent * e ); */ | ||
69 | /* void contentsMouseReleaseEvent( QMouseEvent * e ); */ | ||
70 | |||
71 | private: | ||
72 | void initializeStates(); | ||
73 | void readConfig( Config& cfg ); | ||
74 | void writeConfig( Config& cfg ) const; | ||
75 | PlayListWidgetPrivate *d; // Private implementation data | ||
76 | void populateAudioView(); | ||
77 | void populateVideoView(); | ||
78 | private slots: | ||
61 | void setDocument( const QString& fileref ); | 79 | void setDocument( const QString& fileref ); |
62 | void addToSelection( const DocLnk& ); // Add a media file to the playlist | 80 | void addToSelection( const DocLnk& ); // Add a media file to the playlist |
63 | void addToSelection( QListViewItem* ); // Add a media file to the playlist | 81 | void addToSelection( QListViewItem* ); // Add a media file to the playlist |
64 | void setActiveWindow(); // need to handle this to show the right view | 82 | void setActiveWindow(); // need to handle this to show the right view |
65 | void setPlaylist( bool ); // Show/Hide the playlist | 83 | void setPlaylist( bool ); // Show/Hide the playlist |
66 | void setView( char ); | 84 | void setView( char ); |
@@ -71,34 +89,20 @@ public slots: | |||
71 | void saveList(); // Save the playlist | 89 | void saveList(); // Save the playlist |
72 | void loadList( const DocLnk &); // Load a playlist | 90 | void loadList( const DocLnk &); // Load a playlist |
73 | void playIt( QListViewItem *); | 91 | void playIt( QListViewItem *); |
74 | 92 | ||
75 | void btnPlay(bool); | 93 | void btnPlay(bool); |
76 | void deletePlaylist(); | 94 | void deletePlaylist(); |
77 | bool first(); | ||
78 | bool last(); | ||
79 | bool next(); | ||
80 | bool prev(); | ||
81 | void addSelected(); | 95 | void addSelected(); |
82 | void removeSelected(); | 96 | void removeSelected(); |
83 | void tabChanged(QWidget*); | 97 | void tabChanged(QWidget*); |
84 | void viewPressed( int, QListViewItem *, const QPoint&, int); | 98 | void viewPressed( int, QListViewItem *, const QPoint&, int); |
85 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); | 99 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); |
86 | void playSelected(); | 100 | void playSelected(); |
87 | /* void setFullScreen(); */ | 101 | void listDelete(); |
88 | /* void setScaled(); */ | 102 | |
89 | protected: | ||
90 | /* void contentsMousePressEvent( QMouseEvent * e ); */ | ||
91 | /* void contentsMouseReleaseEvent( QMouseEvent * e ); */ | ||
92 | |||
93 | private: | ||
94 | void initializeStates(); | ||
95 | void readConfig( Config& cfg ); | ||
96 | void writeConfig( Config& cfg ) const; | ||
97 | PlayListWidgetPrivate *d; // Private implementation data | ||
98 | |||
99 | protected slots: | 103 | protected slots: |
100 | /* void cancelMenuTimer(); */ | 104 | /* void cancelMenuTimer(); */ |
101 | /* void showFileMenu(); */ | 105 | /* void showFileMenu(); */ |
102 | 106 | ||
103 | 107 | ||
104 | }; | 108 | }; |