summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp25
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.h4
2 files changed, 11 insertions, 18 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index a8429e3..fd256b7 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -529,153 +529,150 @@ void PlayListWidget::setPlaylist( bool shown ) {
529 d->playListFrame->show(); 529 d->playListFrame->show();
530 } else { 530 } else {
531 d->playListFrame->hide(); 531 d->playListFrame->hide();
532 } 532 }
533} 533}
534 534
535 535
536void PlayListWidget::addSelected() { 536void PlayListWidget::addSelected() {
537 assert( inFileListMode() ); 537 assert( inFileListMode() );
538 538
539 QListView *fileListView = currentFileListView(); 539 QListView *fileListView = currentFileListView();
540 QListViewItemIterator it( fileListView ); 540 QListViewItemIterator it( fileListView );
541 for ( ; it.current(); ++it ) 541 for ( ; it.current(); ++it )
542 if ( it.current()->isSelected() ) { 542 if ( it.current()->isSelected() ) {
543 QString filename = it.current()->text(3); 543 QString filename = it.current()->text(3);
544 544
545 DocLnk lnk; 545 DocLnk lnk;
546 lnk.setName( QFileInfo( filename ).baseName() ); //sets name 546 lnk.setName( QFileInfo( filename ).baseName() ); //sets name
547 lnk.setFile( filename ); //sets file name 547 lnk.setFile( filename ); //sets file name
548 548
549 d->selectedFiles->addToSelection( lnk ); 549 d->selectedFiles->addToSelection( lnk );
550 } 550 }
551 551
552 fileListView->clearSelection(); 552 fileListView->clearSelection();
553 553
554 tabWidget->setCurrentPage( 0 ); 554 tabWidget->setCurrentPage( 0 );
555 writeCurrentM3u(); 555 writeCurrentM3u();
556} 556}
557 557
558 558
559void PlayListWidget::removeSelected() { 559void PlayListWidget::removeSelected() {
560 d->selectedFiles->removeSelected( ); 560 d->selectedFiles->removeSelected( );
561 writeCurrentM3u(); 561 writeCurrentM3u();
562} 562}
563 563
564 564
565void PlayListWidget::playIt( QListViewItem *it) { 565void PlayListWidget::playIt( QListViewItem *it) {
566 if(!it) return; 566 if(!it) return;
567 mediaPlayerState->setPlaying(FALSE); 567 mediaPlayerState->setPlaying(FALSE);
568 mediaPlayerState->setPlaying(TRUE); 568 mediaPlayerState->setPlaying(TRUE);
569 d->selectedFiles->unSelect(); 569 d->selectedFiles->unSelect();
570} 570}
571 571
572 572
573void PlayListWidget::addToSelection( QListViewItem *it) { 573void PlayListWidget::addToSelection( QListViewItem *it) {
574 d->setDocumentUsed = FALSE; 574 d->setDocumentUsed = FALSE;
575 575
576 if(it) { 576 if(it) {
577 switch ( whichList()) { 577 if ( currentTab() == CurrentPlayList )
578 case 0: //playlist 578 return;
579 return;
580 break;
581 };
582 // case 1: { 579 // case 1: {
583 DocLnk lnk; 580 DocLnk lnk;
584 QString filename; 581 QString filename;
585 582
586 filename=it->text(3); 583 filename=it->text(3);
587 lnk.setName( QFileInfo(filename).baseName() ); //sets name 584 lnk.setName( QFileInfo(filename).baseName() ); //sets name
588 lnk.setFile( filename ); //sets file name 585 lnk.setFile( filename ); //sets file name
589 d->selectedFiles->addToSelection( lnk); 586 d->selectedFiles->addToSelection( lnk);
590 587
591 writeCurrentM3u(); 588 writeCurrentM3u();
592 tabWidget->setCurrentPage(0); 589 tabWidget->setCurrentPage(0);
593 590
594 } 591 }
595} 592}
596 593
597 594
598void PlayListWidget::tabChanged(QWidget *) { 595void PlayListWidget::tabChanged(QWidget *) {
599 596
600 switch ( whichList()) { 597 switch ( currentTab() ) {
601 case 0: 598 case CurrentPlayList:
602 { 599 {
603 if( !tbDeletePlaylist->isHidden() ) { 600 if( !tbDeletePlaylist->isHidden() ) {
604 tbDeletePlaylist->hide(); 601 tbDeletePlaylist->hide();
605 } 602 }
606 d->tbRemoveFromList->setEnabled(TRUE); 603 d->tbRemoveFromList->setEnabled(TRUE);
607 d->tbAddToList->setEnabled(FALSE); 604 d->tbAddToList->setEnabled(FALSE);
608 } 605 }
609 break; 606 break;
610 case 1: 607 case AudioFiles:
611 { 608 {
612 // audioView->clear(); 609 // audioView->clear();
613 if(!audioPopulated) populateAudioView(); 610 if(!audioPopulated) populateAudioView();
614 611
615 if( !tbDeletePlaylist->isHidden() ) { 612 if( !tbDeletePlaylist->isHidden() ) {
616 tbDeletePlaylist->hide(); 613 tbDeletePlaylist->hide();
617 } 614 }
618 d->tbRemoveFromList->setEnabled(FALSE); 615 d->tbRemoveFromList->setEnabled(FALSE);
619 d->tbAddToList->setEnabled(TRUE); 616 d->tbAddToList->setEnabled(TRUE);
620 } 617 }
621 break; 618 break;
622 case 2: 619 case VideoFiles:
623 { 620 {
624 // videoView->clear(); 621 // videoView->clear();
625 if(!videoPopulated) populateVideoView(); 622 if(!videoPopulated) populateVideoView();
626 if( !tbDeletePlaylist->isHidden() ) { 623 if( !tbDeletePlaylist->isHidden() ) {
627 tbDeletePlaylist->hide(); 624 tbDeletePlaylist->hide();
628 } 625 }
629 d->tbRemoveFromList->setEnabled(FALSE); 626 d->tbRemoveFromList->setEnabled(FALSE);
630 d->tbAddToList->setEnabled(TRUE); 627 d->tbAddToList->setEnabled(TRUE);
631 } 628 }
632 break; 629 break;
633 case 3: 630 case PlayLists:
634 { 631 {
635 if( tbDeletePlaylist->isHidden() ) { 632 if( tbDeletePlaylist->isHidden() ) {
636 tbDeletePlaylist->show(); 633 tbDeletePlaylist->show();
637 } 634 }
638 playLists->reread(); 635 playLists->reread();
639 d->tbAddToList->setEnabled(FALSE); 636 d->tbAddToList->setEnabled(FALSE);
640 } 637 }
641 break; 638 break;
642 }; 639 };
643} 640}
644 641
645 642
646void PlayListWidget::btnPlay(bool b) { 643void PlayListWidget::btnPlay(bool b) {
647// mediaPlayerState->setPlaying(false); 644// mediaPlayerState->setPlaying(false);
648 mediaPlayerState->setPlaying(b); 645 mediaPlayerState->setPlaying(b);
649 insanityBool=FALSE; 646 insanityBool=FALSE;
650} 647}
651 648
652void PlayListWidget::deletePlaylist() { 649void PlayListWidget::deletePlaylist() {
653 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 650 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
654 (tr("You really want to delete\nthis playlist?")), 651 (tr("You really want to delete\nthis playlist?")),
655 (tr("Yes")), (tr("No")), 0 )){ 652 (tr("Yes")), (tr("No")), 0 )){
656 case 0: // Yes clicked, 653 case 0: // Yes clicked,
657 QFile().remove(playLists->selectedDocument().file()); 654 QFile().remove(playLists->selectedDocument().file());
658 QFile().remove(playLists->selectedDocument().linkFile()); 655 QFile().remove(playLists->selectedDocument().linkFile());
659 playLists->reread(); 656 playLists->reread();
660 break; 657 break;
661 case 1: // Cancel 658 case 1: // Cancel
662 break; 659 break;
663 }; 660 };
664} 661}
665 662
666 663
667void PlayListWidget::playSelected() { 664void PlayListWidget::playSelected() {
668 btnPlay( TRUE); 665 btnPlay( TRUE);
669} 666}
670 667
671 668
672void PlayListWidget::scanForAudio() { 669void PlayListWidget::scanForAudio() {
673// qDebug("scan for audio"); 670// qDebug("scan for audio");
674 files.detachChildren(); 671 files.detachChildren();
675 QListIterator<DocLnk> sdit( files.children() ); 672 QListIterator<DocLnk> sdit( files.children() );
676 for ( ; sdit.current(); ++sdit ) { 673 for ( ; sdit.current(); ++sdit ) {
677 delete sdit.current(); 674 delete sdit.current();
678 } 675 }
679// Global::findDocuments( &files, "audio/*"); 676// Global::findDocuments( &files, "audio/*");
680 Global::findDocuments( &files, audioMimes); 677 Global::findDocuments( &files, audioMimes);
681 audioScan = true; 678 audioScan = true;
@@ -1088,66 +1085,62 @@ void PlayListWidget::pmViewActivated(int index) {
1088 } 1085 }
1089 break; 1086 break;
1090 }; 1087 };
1091} 1088}
1092 1089
1093void PlayListWidget::populateSkinsMenu() { 1090void PlayListWidget::populateSkinsMenu() {
1094 int item = 0; 1091 int item = 0;
1095 defaultSkinIndex = 0; 1092 defaultSkinIndex = 0;
1096 QString skinName; 1093 QString skinName;
1097 Config cfg( "OpiePlayer" ); 1094 Config cfg( "OpiePlayer" );
1098 cfg.setGroup("Options" ); 1095 cfg.setGroup("Options" );
1099 QString skin = cfg.readEntry( "Skin", "default" ); 1096 QString skin = cfg.readEntry( "Skin", "default" );
1100 1097
1101 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); 1098 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" );
1102 skinsDir.setFilter( QDir::Dirs ); 1099 skinsDir.setFilter( QDir::Dirs );
1103 skinsDir.setSorting(QDir::Name ); 1100 skinsDir.setSorting(QDir::Name );
1104 const QFileInfoList *skinslist = skinsDir.entryInfoList(); 1101 const QFileInfoList *skinslist = skinsDir.entryInfoList();
1105 QFileInfoListIterator it( *skinslist ); 1102 QFileInfoListIterator it( *skinslist );
1106 QFileInfo *fi; 1103 QFileInfo *fi;
1107 while ( ( fi = it.current() ) ) { 1104 while ( ( fi = it.current() ) ) {
1108 skinName = fi->fileName(); 1105 skinName = fi->fileName();
1109// qDebug( fi->fileName() ); 1106// qDebug( fi->fileName() );
1110 if( skinName != "." && skinName != ".." && skinName !="CVS" ) { 1107 if( skinName != "." && skinName != ".." && skinName !="CVS" ) {
1111 item = skinsMenu->insertItem( fi->fileName() ) ; 1108 item = skinsMenu->insertItem( fi->fileName() ) ;
1112 } 1109 }
1113 if( skinName == "default" ) { 1110 if( skinName == "default" ) {
1114 defaultSkinIndex = item; 1111 defaultSkinIndex = item;
1115 } 1112 }
1116 if( skinName == skin ) { 1113 if( skinName == skin ) {
1117 skinsMenu->setItemChecked( item, TRUE ); 1114 skinsMenu->setItemChecked( item, TRUE );
1118 } 1115 }
1119 ++it; 1116 ++it;
1120 } 1117 }
1121} 1118}
1122 1119
1123void PlayListWidget::skinsMenuActivated( int item ) { 1120void PlayListWidget::skinsMenuActivated( int item ) {
1124 for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { 1121 for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) {
1125 skinsMenu->setItemChecked( i, FALSE ); 1122 skinsMenu->setItemChecked( i, FALSE );
1126 } 1123 }
1127 skinsMenu->setItemChecked( item, TRUE ); 1124 skinsMenu->setItemChecked( item, TRUE );
1128 1125
1129 Config cfg( "OpiePlayer" ); 1126 Config cfg( "OpiePlayer" );
1130 cfg.setGroup("Options"); 1127 cfg.setGroup("Options");
1131 cfg.writeEntry("Skin", skinsMenu->text( item ) ); 1128 cfg.writeEntry("Skin", skinsMenu->text( item ) );
1132 QMessageBox::warning( this, tr( "OpiePlayer" ), 1129 QMessageBox::warning( this, tr( "OpiePlayer" ),
1133 tr( "You must <b>restart</b> Opieplayer<br>to see your changes." ) ); 1130 tr( "You must <b>restart</b> Opieplayer<br>to see your changes." ) );
1134} 1131}
1135 1132
1136int PlayListWidget::whichList() const {
1137 return tabWidget->currentPageIndex();
1138}
1139
1140PlayListWidget::TabType PlayListWidget::currentTab() const 1133PlayListWidget::TabType PlayListWidget::currentTab() const
1141{ 1134{
1142 static const TabType indexToTabType[ NumTabTypes ] = 1135 static const TabType indexToTabType[ TabTypeCount ] =
1143 { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; 1136 { CurrentPlayList, AudioFiles, VideoFiles, PlayLists };
1144 1137
1145 int index = tabWidget->currentPageIndex(); 1138 int index = tabWidget->currentPageIndex();
1146 assert( index < NumTabTypes && index >= 0 ); 1139 assert( index < TabTypeCount && index >= 0 );
1147 1140
1148 return indexToTabType[ index ]; 1141 return indexToTabType[ index ];
1149} 1142}
1150 1143
1151QString PlayListWidget::currentFileListPathName() const { 1144QString PlayListWidget::currentFileListPathName() const {
1152 return currentFileListView()->currentItem()->text( 3 ); 1145 return currentFileListView()->currentItem()->text( 3 );
1153} 1146}
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h
index 238a75c..2e2ff89 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.h
+++ b/noncore/multimedia/opieplayer2/playlistwidget.h
@@ -10,110 +10,110 @@
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef PLAY_LIST_WIDGET_H 34#ifndef PLAY_LIST_WIDGET_H
35#define PLAY_LIST_WIDGET_H 35#define PLAY_LIST_WIDGET_H
36 36
37#include <qmainwindow.h> 37#include <qmainwindow.h>
38#include <qpe/applnk.h> 38#include <qpe/applnk.h>
39#include <qtabwidget.h> 39#include <qtabwidget.h>
40#include <qpe/fileselector.h> 40#include <qpe/fileselector.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qpopupmenu.h> 42#include <qpopupmenu.h>
43 43
44#include "playlistwidgetgui.h" 44#include "playlistwidgetgui.h"
45 45
46 46
47//class PlayListWidgetPrivate; 47//class PlayListWidgetPrivate;
48class Config; 48class Config;
49class QListViewItem; 49class QListViewItem;
50class QListView; 50class QListView;
51class QPoint; 51class QPoint;
52class QAction; 52class QAction;
53class QLabel; 53class QLabel;
54 54
55class PlayListWidget : public PlayListWidgetGui { 55class PlayListWidget : public PlayListWidgetGui {
56 Q_OBJECT 56 Q_OBJECT
57public: 57public:
58 enum TabType { CurrentPlayList, AudioFiles, VideoFiles, PlayLists, NumTabTypes = 4 }; 58 enum TabType { CurrentPlayList, AudioFiles, VideoFiles, PlayLists };
59 enum { TabTypeCount = 4 };
59 60
60 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); 61 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 );
61 ~PlayListWidget(); 62 ~PlayListWidget();
62 DocLnkSet files; 63 DocLnkSet files;
63 DocLnkSet vFiles; 64 DocLnkSet vFiles;
64 bool fromSetDocument; 65 bool fromSetDocument;
65 bool insanityBool; 66 bool insanityBool;
66 QString setDocFileRef, currentPlayList; 67 QString setDocFileRef, currentPlayList;
67 // retrieve the current playlist entry (media file link) 68 // retrieve the current playlist entry (media file link)
68 const DocLnk *current(); 69 const DocLnk *current();
69 void useSelectedDocument(); 70 void useSelectedDocument();
70 int selected; 71 int selected;
71 int whichList() const;
72 TabType currentTab() const; 72 TabType currentTab() const;
73 73
74public slots: 74public slots:
75 bool first(); 75 bool first();
76 bool last(); 76 bool last();
77 bool next(); 77 bool next();
78 bool prev(); 78 bool prev();
79 void writeDefaultPlaylist( ); 79 void writeDefaultPlaylist( );
80 QString currentFileListPathName() const; 80 QString currentFileListPathName() const;
81protected: 81protected:
82 void keyReleaseEvent( QKeyEvent *e); 82 void keyReleaseEvent( QKeyEvent *e);
83 83
84private: 84private:
85 int defaultSkinIndex; 85 int defaultSkinIndex;
86 bool audioScan, videoScan, audioPopulated, videoPopulated; 86 bool audioScan, videoScan, audioPopulated, videoPopulated;
87 void readm3u(const QString &); 87 void readm3u(const QString &);
88 void readPls(const QString &); 88 void readPls(const QString &);
89 void initializeStates(); 89 void initializeStates();
90 void populateAudioView(); 90 void populateAudioView();
91 void populateVideoView(); 91 void populateVideoView();
92 92
93 QListView *currentFileListView() const; 93 QListView *currentFileListView() const;
94 94
95 bool inFileListMode() const; 95 bool inFileListMode() const;
96 96
97private slots: 97private slots:
98 void populateSkinsMenu(); 98 void populateSkinsMenu();
99 void skinsMenuActivated(int); 99 void skinsMenuActivated(int);
100 void pmViewActivated(int); 100 void pmViewActivated(int);
101 void writem3u(); 101 void writem3u();
102 void writeCurrentM3u(); 102 void writeCurrentM3u();
103 void scanForAudio(); 103 void scanForAudio();
104 void scanForVideo(); 104 void scanForVideo();
105 void openFile(); 105 void openFile();
106 void setDocument( const QString& fileref ); 106 void setDocument( const QString& fileref );
107 void addToSelection( const DocLnk& ); // Add a media file to the playlist 107 void addToSelection( const DocLnk& ); // Add a media file to the playlist
108 void addToSelection( QListViewItem* ); // Add a media file to the playlist 108 void addToSelection( QListViewItem* ); // Add a media file to the playlist
109 void setPlaylist( bool ); // Show/Hide the playlist 109 void setPlaylist( bool ); // Show/Hide the playlist
110 void clearList(); 110 void clearList();
111 void addAllToList(); 111 void addAllToList();
112 void addAllMusicToList(); 112 void addAllMusicToList();
113 void addAllVideoToList(); 113 void addAllVideoToList();
114 void saveList(); // Save the playlist 114 void saveList(); // Save the playlist
115 void loadList( const DocLnk &); // Load a playlist 115 void loadList( const DocLnk &); // Load a playlist
116 void playIt( QListViewItem *); 116 void playIt( QListViewItem *);
117 void btnPlay(bool); 117 void btnPlay(bool);
118 void deletePlaylist(); 118 void deletePlaylist();
119 void addSelected(); 119 void addSelected();