4 files changed, 40 insertions, 74 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistfileview.cpp b/noncore/multimedia/opieplayer2/playlistfileview.cpp index 1e2ef89..0ed1061 100644 --- a/noncore/multimedia/opieplayer2/playlistfileview.cpp +++ b/noncore/multimedia/opieplayer2/playlistfileview.cpp | |||
@@ -1,36 +1,66 @@ | |||
1 | 1 | ||
2 | #include "playlistfileview.h" | 2 | #include "playlistfileview.h" |
3 | 3 | ||
4 | #include <qfile.h> | ||
4 | #include <qpe/global.h> | 5 | #include <qpe/global.h> |
6 | #include <qpe/resource.h> | ||
5 | 7 | ||
6 | PlayListFileView::PlayListFileView( const QString &mimeTypePattern, QWidget *parent, const char *name ) | 8 | PlayListFileView::PlayListFileView( const QString &mimeTypePattern, const QString &itemPixmapName, QWidget *parent, const char *name ) |
7 | : PlayListView( parent, name ), m_mimeTypePattern( mimeTypePattern ), m_scannedFiles( false ) | 9 | : PlayListView( parent, name ), m_mimeTypePattern( mimeTypePattern ), m_itemPixmapName( itemPixmapName ), m_scannedFiles( false ) |
8 | { | 10 | { |
9 | addColumn( tr( "Title" ), 140); | 11 | addColumn( tr( "Title" ), 140); |
10 | addColumn( tr( "Size" ), -1 ); | 12 | addColumn( tr( "Size" ), -1 ); |
11 | addColumn(tr( "Media" ), 0 ); | 13 | addColumn(tr( "Media" ), 0 ); |
12 | addColumn(tr( "Path" ), -1 ); | 14 | addColumn(tr( "Path" ), -1 ); |
13 | setColumnAlignment( 1, Qt::AlignRight ); | 15 | setColumnAlignment( 1, Qt::AlignRight ); |
14 | setColumnAlignment( 2, Qt::AlignRight ); | 16 | setColumnAlignment( 2, Qt::AlignRight ); |
15 | setAllColumnsShowFocus( TRUE ); | 17 | setAllColumnsShowFocus( TRUE ); |
16 | setSorting( 3, TRUE ); | 18 | setSorting( 3, TRUE ); |
17 | setMultiSelection( TRUE ); | 19 | setMultiSelection( TRUE ); |
18 | setSelectionMode( QListView::Extended ); | 20 | setSelectionMode( QListView::Extended ); |
19 | } | 21 | } |
20 | 22 | ||
21 | PlayListFileView::~PlayListFileView() | 23 | PlayListFileView::~PlayListFileView() |
22 | { | 24 | { |
23 | } | 25 | } |
24 | 26 | ||
25 | void PlayListFileView::scanFiles() | 27 | void PlayListFileView::scanFiles() |
26 | { | 28 | { |
27 | m_files.detachChildren(); | 29 | m_files.detachChildren(); |
28 | QListIterator<DocLnk> sdit( m_files.children() ); | 30 | QListIterator<DocLnk> sdit( m_files.children() ); |
29 | for ( ; sdit.current(); ++sdit ) | 31 | for ( ; sdit.current(); ++sdit ) |
30 | delete sdit.current(); | 32 | delete sdit.current(); |
31 | 33 | ||
32 | Global::findDocuments( &m_files, m_mimeTypePattern ); | 34 | Global::findDocuments( &m_files, m_mimeTypePattern ); |
33 | } | 35 | } |
34 | 36 | ||
37 | void PlayListFileView::populateView() | ||
38 | { | ||
39 | clear(); | ||
40 | |||
41 | if( !m_scannedFiles ) { | ||
42 | scanFiles(); | ||
43 | m_scannedFiles = true; | ||
44 | } | ||
45 | |||
46 | QString storage; | ||
47 | QListIterator<DocLnk> dit( m_files.children() ); | ||
48 | for ( ; dit.current(); ++dit ) { | ||
49 | |||
50 | QListViewItem *newItem; | ||
51 | |||
52 | if ( QFile::exists( dit.current()->file() ) || | ||
53 | dit.current()->file().left( 4 ) == "http" ) { | ||
54 | |||
55 | unsigned long size = QFile( dit.current()->file() ).size(); | ||
56 | |||
57 | newItem = new QListViewItem( this, dit.current()->name(), | ||
58 | QString::number( size ), "" /*storage*/, | ||
59 | dit.current()->file() ); | ||
60 | newItem->setPixmap( 0, Resource::loadPixmap( m_itemPixmapName ) ); | ||
61 | } | ||
62 | } | ||
63 | } | ||
64 | |||
35 | /* vim: et sw=4 ts=4 | 65 | /* vim: et sw=4 ts=4 |
36 | */ | 66 | */ |
diff --git a/noncore/multimedia/opieplayer2/playlistfileview.h b/noncore/multimedia/opieplayer2/playlistfileview.h index 4e17966..a00349e 100644 --- a/noncore/multimedia/opieplayer2/playlistfileview.h +++ b/noncore/multimedia/opieplayer2/playlistfileview.h | |||
@@ -1,31 +1,33 @@ | |||
1 | #ifndef PLAYLISTFILEVIEW_H | 1 | #ifndef PLAYLISTFILEVIEW_H |
2 | #define PLAYLISTFILEVIEW_H | 2 | #define PLAYLISTFILEVIEW_H |
3 | 3 | ||
4 | #include "playlistview.h" | 4 | #include "playlistview.h" |
5 | 5 | ||
6 | #include <qpe/applnk.h> | 6 | #include <qpe/applnk.h> |
7 | 7 | ||
8 | class PlayListFileView : public PlayListView | 8 | class PlayListFileView : public PlayListView |
9 | { | 9 | { |
10 | Q_OBJECT | 10 | Q_OBJECT |
11 | public: | 11 | public: |
12 | PlayListFileView( const QString &mimeTypePattern, QWidget *parent, const char *name = 0 ); | 12 | PlayListFileView( const QString &mimeTypePattern, const QString &itemPixmapName, QWidget *parent, const char *name = 0 ); |
13 | virtual ~PlayListFileView(); | 13 | virtual ~PlayListFileView(); |
14 | 14 | ||
15 | // both temporarily accessible that way until the caller code has | 15 | // both temporarily accessible that way until the caller code has |
16 | // been migrated into this class | 16 | // been migrated into this class |
17 | DocLnkSet &files() { return m_files; } | 17 | DocLnkSet &files() { return m_files; } |
18 | bool &scannedFiles() { return m_scannedFiles; } | 18 | bool &scannedFiles() { return m_scannedFiles; } |
19 | 19 | ||
20 | public slots: | 20 | public slots: |
21 | void scanFiles(); | 21 | void scanFiles(); |
22 | void populateView(); | ||
22 | 23 | ||
23 | private: | 24 | private: |
24 | QString m_mimeTypePattern; | 25 | QString m_mimeTypePattern; |
26 | QString m_itemPixmapName; | ||
25 | DocLnkSet m_files; | 27 | DocLnkSet m_files; |
26 | bool m_scannedFiles; | 28 | bool m_scannedFiles; |
27 | }; | 29 | }; |
28 | 30 | ||
29 | #endif // PLAYLISTFILEVIEW_H | 31 | #endif // PLAYLISTFILEVIEW_H |
30 | /* vim: et sw=4 ts=4 | 32 | /* vim: et sw=4 ts=4 |
31 | */ | 33 | */ |
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 12b8a71..460a0bf 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -626,120 +626,54 @@ void PlayListWidget::deletePlaylist() { | |||
626 | case 1: // Cancel | 626 | case 1: // Cancel |
627 | break; | 627 | break; |
628 | }; | 628 | }; |
629 | } | 629 | } |
630 | 630 | ||
631 | 631 | ||
632 | void PlayListWidget::playSelected() { | 632 | void PlayListWidget::playSelected() { |
633 | btnPlay( TRUE); | 633 | btnPlay( TRUE); |
634 | } | 634 | } |
635 | 635 | ||
636 | 636 | ||
637 | void PlayListWidget::scanForAudio() { | 637 | void PlayListWidget::scanForAudio() { |
638 | audioView->scanFiles(); | 638 | audioView->scanFiles(); |
639 | audioView->scannedFiles() = true; | 639 | audioView->scannedFiles() = true; |
640 | populateAudioView(); | 640 | populateAudioView(); |
641 | } | 641 | } |
642 | 642 | ||
643 | void PlayListWidget::scanForVideo() { | 643 | void PlayListWidget::scanForVideo() { |
644 | videoView->scanFiles(); | 644 | videoView->scanFiles(); |
645 | videoView->scannedFiles() = true; | 645 | videoView->scannedFiles() = true; |
646 | populateVideoView(); | 646 | populateVideoView(); |
647 | } | 647 | } |
648 | 648 | ||
649 | void PlayListWidget::populateAudioView() { | 649 | void PlayListWidget::populateAudioView() { |
650 | audioView->clear(); | 650 | audioView->populateView(); |
651 | StorageInfo storageInfo; | 651 | audioPopulated = true; |
652 | // const QList<FileSystem> &fs = storageInfo.fileSystems(); | ||
653 | if(!audioView->scannedFiles()) { | ||
654 | scanForAudio(); | ||
655 | } | ||
656 | |||
657 | QListIterator<DocLnk> dit( audioView->files().children() ); | ||
658 | // QListIterator<FileSystem> it ( fs ); | ||
659 | audioView->clear(); | ||
660 | |||
661 | QString storage; | ||
662 | for ( ; dit.current(); ++dit ) { | ||
663 | // // for( ; it.current(); ++it ){ | ||
664 | // const QString name = (*dit)->name(); | ||
665 | // const QString path = (*dit)->path(); | ||
666 | // if(dit.current()->file().find(path) != -1 ) { | ||
667 | // storage = name; | ||
668 | // // } | ||
669 | // } | ||
670 | |||
671 | QListViewItem * newItem; | ||
672 | if ( QFile( dit.current()->file()).exists() || | ||
673 | dit.current()->file().left(4) == "http" ) { | ||
674 | long size; | ||
675 | if( dit.current()->file().left(4) == "http" ) | ||
676 | size=0; | ||
677 | else | ||
678 | size = QFile( dit.current()->file() ).size(); | ||
679 | |||
680 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | ||
681 | QString::number(size ), "" /*storage*/, | ||
682 | dit.current()->file() ); | ||
683 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); | ||
684 | // qDebug("<<<< "+dit.current()->file()); | ||
685 | } | ||
686 | } | ||
687 | audioPopulated=true; | ||
688 | } | 652 | } |
689 | 653 | ||
690 | |||
691 | void PlayListWidget::populateVideoView() { | 654 | void PlayListWidget::populateVideoView() { |
692 | videoView->clear(); | 655 | videoView->populateView(); |
693 | StorageInfo storageInfo; | ||
694 | // const QList<FileSystem> &fs = storageInfo.fileSystems(); | ||
695 | |||
696 | if(!videoView->scannedFiles()) { | ||
697 | scanForVideo(); | ||
698 | } | ||
699 | |||
700 | QListIterator<DocLnk> Vdit( videoView->files().children() ); | ||
701 | // QListIterator<FileSystem> it ( fs ); | ||
702 | videoView->clear(); | ||
703 | QString storage, pathName; | ||
704 | for ( ; Vdit.current(); ++Vdit ) { | ||
705 | // // for( ; it.current(); ++it ) { | ||
706 | // const QString name = (*Vdit)->name(); | ||
707 | // const QString path = (*Vdit)->path(); | ||
708 | // if( Vdit.current()->file().find(path) != -1 ) { | ||
709 | // storage=name; | ||
710 | // pathName=path; | ||
711 | // // } | ||
712 | // } | ||
713 | |||
714 | QListViewItem * newItem; | ||
715 | if ( QFile( Vdit.current()->file() ).exists() ) { | ||
716 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | ||
717 | QString::number( QFile( Vdit.current()->file() ).size() ), | ||
718 | ""/*storage*/, Vdit.current()->file()); | ||
719 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); | ||
720 | } | ||
721 | } | ||
722 | videoPopulated=true; | 656 | videoPopulated=true; |
723 | } | 657 | } |
724 | 658 | ||
725 | QListView *PlayListWidget::currentFileListView() const | 659 | QListView *PlayListWidget::currentFileListView() const |
726 | { | 660 | { |
727 | switch ( currentTab() ) { | 661 | switch ( currentTab() ) { |
728 | case AudioFiles: return audioView; | 662 | case AudioFiles: return audioView; |
729 | case VideoFiles: return videoView; | 663 | case VideoFiles: return videoView; |
730 | default: assert( false ); | 664 | default: assert( false ); |
731 | } | 665 | } |
732 | return 0; | 666 | return 0; |
733 | } | 667 | } |
734 | 668 | ||
735 | bool PlayListWidget::inFileListMode() const | 669 | bool PlayListWidget::inFileListMode() const |
736 | { | 670 | { |
737 | TabType tab = currentTab(); | 671 | TabType tab = currentTab(); |
738 | return tab == AudioFiles || tab == VideoFiles; | 672 | return tab == AudioFiles || tab == VideoFiles; |
739 | } | 673 | } |
740 | 674 | ||
741 | void PlayListWidget::openFile() { | 675 | void PlayListWidget::openFile() { |
742 | // http://66.28.164.33:2080 | 676 | // http://66.28.164.33:2080 |
743 | // http://somafm.com/star0242.m3u | 677 | // http://somafm.com/star0242.m3u |
744 | QString filename, name; | 678 | QString filename, name; |
745 | InputDialog *fileDlg; | 679 | InputDialog *fileDlg; |
diff --git a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp index a219cfd..7f851bd 100644 --- a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp | |||
@@ -130,61 +130,61 @@ PlayListWidgetGui::PlayListWidgetGui( MediaPlayerState &_mediaPlayerState, QWidg | |||
130 | QGridLayout *Playout = new QGridLayout( pTab ); | 130 | QGridLayout *Playout = new QGridLayout( pTab ); |
131 | Playout->setSpacing( 2); | 131 | Playout->setSpacing( 2); |
132 | Playout->setMargin( 2); | 132 | Playout->setMargin( 2); |
133 | 133 | ||
134 | // Add the playlist area | 134 | // Add the playlist area |
135 | QVBox *vbox3 = new QVBox( pTab ); | 135 | QVBox *vbox3 = new QVBox( pTab ); |
136 | d->playListFrame = vbox3; | 136 | d->playListFrame = vbox3; |
137 | 137 | ||
138 | QHBox *hbox2 = new QHBox( vbox3 ); | 138 | QHBox *hbox2 = new QHBox( vbox3 ); |
139 | d->selectedFiles = new PlayListSelection( hbox2 ); | 139 | d->selectedFiles = new PlayListSelection( hbox2 ); |
140 | 140 | ||
141 | vbox1 = new QVBox( hbox2 ); | 141 | vbox1 = new QVBox( hbox2 ); |
142 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(), QPEApplication::RightOnHold ); | 142 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(), QPEApplication::RightOnHold ); |
143 | QVBox *stretch1 = new QVBox( vbox1 ); // add stretch | 143 | QVBox *stretch1 = new QVBox( vbox1 ); // add stretch |
144 | 144 | ||
145 | Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 ); | 145 | Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 ); |
146 | 146 | ||
147 | QWidget *aTab; | 147 | QWidget *aTab; |
148 | aTab = new QWidget( tabWidget, "aTab" ); | 148 | aTab = new QWidget( tabWidget, "aTab" ); |
149 | 149 | ||
150 | QGridLayout *Alayout = new QGridLayout( aTab ); | 150 | QGridLayout *Alayout = new QGridLayout( aTab ); |
151 | Alayout->setSpacing( 2 ); | 151 | Alayout->setSpacing( 2 ); |
152 | Alayout->setMargin( 2 ); | 152 | Alayout->setMargin( 2 ); |
153 | // no m3u's here please | 153 | // no m3u's here please |
154 | audioView = new PlayListFileView( "audio/mpeg;audio/x-wav;audio/x-ogg", aTab, "Audioview" ); | 154 | audioView = new PlayListFileView( "audio/mpeg;audio/x-wav;audio/x-ogg", "opieplayer2/musicfile", aTab, "Audioview" ); |
155 | Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 ); | 155 | Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 ); |
156 | tabWidget->insertTab( aTab, tr( "Audio" ) ); | 156 | tabWidget->insertTab( aTab, tr( "Audio" ) ); |
157 | 157 | ||
158 | QPEApplication::setStylusOperation( audioView->viewport(), QPEApplication::RightOnHold ); | 158 | QPEApplication::setStylusOperation( audioView->viewport(), QPEApplication::RightOnHold ); |
159 | 159 | ||
160 | QWidget *vTab; | 160 | QWidget *vTab; |
161 | vTab = new QWidget( tabWidget, "vTab" ); | 161 | vTab = new QWidget( tabWidget, "vTab" ); |
162 | 162 | ||
163 | QGridLayout *Vlayout = new QGridLayout( vTab ); | 163 | QGridLayout *Vlayout = new QGridLayout( vTab ); |
164 | Vlayout->setSpacing( 2 ); | 164 | Vlayout->setSpacing( 2 ); |
165 | Vlayout->setMargin( 2 ); | 165 | Vlayout->setMargin( 2 ); |
166 | videoView = new PlayListFileView( "video/*", vTab, "Videoview" ); | 166 | videoView = new PlayListFileView( "video/*", "opieplayer2/videofile", vTab, "Videoview" ); |
167 | Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 ); | 167 | Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 ); |
168 | 168 | ||
169 | QPEApplication::setStylusOperation( videoView->viewport(), QPEApplication::RightOnHold ); | 169 | QPEApplication::setStylusOperation( videoView->viewport(), QPEApplication::RightOnHold ); |
170 | 170 | ||
171 | tabWidget->insertTab( vTab, tr( "Video" ) ); | 171 | tabWidget->insertTab( vTab, tr( "Video" ) ); |
172 | 172 | ||
173 | //playlists list | 173 | //playlists list |
174 | QWidget *LTab; | 174 | QWidget *LTab; |
175 | LTab = new QWidget( tabWidget, "LTab" ); | 175 | LTab = new QWidget( tabWidget, "LTab" ); |
176 | QGridLayout *Llayout = new QGridLayout( LTab ); | 176 | QGridLayout *Llayout = new QGridLayout( LTab ); |
177 | Llayout->setSpacing( 2 ); | 177 | Llayout->setSpacing( 2 ); |
178 | Llayout->setMargin( 2 ); | 178 | Llayout->setMargin( 2 ); |
179 | 179 | ||
180 | playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE ); | 180 | playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE ); |
181 | Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 ); | 181 | Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 ); |
182 | 182 | ||
183 | tabWidget->insertTab( LTab, tr( "Lists" ) ); | 183 | tabWidget->insertTab( LTab, tr( "Lists" ) ); |
184 | 184 | ||
185 | setCentralWidget( vbox5 ); | 185 | setCentralWidget( vbox5 ); |
186 | } | 186 | } |
187 | 187 | ||
188 | 188 | ||
189 | 189 | ||
190 | PlayListWidgetGui::~PlayListWidgetGui() { | 190 | PlayListWidgetGui::~PlayListWidgetGui() { |