6 files changed, 37 insertions, 28 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistfileview.cpp b/noncore/multimedia/opieplayer2/playlistfileview.cpp index c4f93e7..2726296 100644 --- a/noncore/multimedia/opieplayer2/playlistfileview.cpp +++ b/noncore/multimedia/opieplayer2/playlistfileview.cpp | |||
@@ -1,24 +1,36 @@ | |||
1 | 1 | ||
2 | #include "playlistfileview.h" | 2 | #include "playlistfileview.h" |
3 | 3 | ||
4 | PlayListFileView::PlayListFileView( QWidget *parent, const char *name ) | 4 | #include <qpe/global.h> |
5 | : PlayListView( parent, name ) | 5 | |
6 | PlayListFileView::PlayListFileView( const QString &mimeTypePattern, QWidget *parent, const char *name ) | ||
7 | : PlayListView( parent, name ), m_mimeTypePattern( mimeTypePattern ) | ||
6 | { | 8 | { |
7 | addColumn( tr( "Title" ), 140); | 9 | addColumn( tr( "Title" ), 140); |
8 | addColumn( tr( "Size" ), -1 ); | 10 | addColumn( tr( "Size" ), -1 ); |
9 | addColumn(tr( "Media" ), 0 ); | 11 | addColumn(tr( "Media" ), 0 ); |
10 | addColumn(tr( "Path" ), -1 ); | 12 | addColumn(tr( "Path" ), -1 ); |
11 | setColumnAlignment( 1, Qt::AlignRight ); | 13 | setColumnAlignment( 1, Qt::AlignRight ); |
12 | setColumnAlignment( 2, Qt::AlignRight ); | 14 | setColumnAlignment( 2, Qt::AlignRight ); |
13 | setAllColumnsShowFocus( TRUE ); | 15 | setAllColumnsShowFocus( TRUE ); |
14 | setSorting( 3, TRUE ); | 16 | setSorting( 3, TRUE ); |
15 | setMultiSelection( TRUE ); | 17 | setMultiSelection( TRUE ); |
16 | setSelectionMode( QListView::Extended ); | 18 | setSelectionMode( QListView::Extended ); |
17 | } | 19 | } |
18 | 20 | ||
19 | PlayListFileView::~PlayListFileView() | 21 | PlayListFileView::~PlayListFileView() |
20 | { | 22 | { |
21 | } | 23 | } |
22 | 24 | ||
25 | void PlayListFileView::scanFiles() | ||
26 | { | ||
27 | m_files.detachChildren(); | ||
28 | QListIterator<DocLnk> sdit( m_files.children() ); | ||
29 | for ( ; sdit.current(); ++sdit ) | ||
30 | delete sdit.current(); | ||
31 | |||
32 | Global::findDocuments( &m_files, m_mimeTypePattern ); | ||
33 | } | ||
34 | |||
23 | /* vim: et sw=4 ts=4 | 35 | /* vim: et sw=4 ts=4 |
24 | */ | 36 | */ |
diff --git a/noncore/multimedia/opieplayer2/playlistfileview.h b/noncore/multimedia/opieplayer2/playlistfileview.h index eef4bd1..08db929 100644 --- a/noncore/multimedia/opieplayer2/playlistfileview.h +++ b/noncore/multimedia/opieplayer2/playlistfileview.h | |||
@@ -1,16 +1,27 @@ | |||
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> | ||
7 | |||
6 | class PlayListFileView : public PlayListView | 8 | class PlayListFileView : public PlayListView |
7 | { | 9 | { |
8 | Q_OBJECT | 10 | Q_OBJECT |
9 | public: | 11 | public: |
10 | PlayListFileView( QWidget *parent, const char *name = 0 ); | 12 | PlayListFileView( const QString &mimeTypePattern, QWidget *parent, const char *name = 0 ); |
11 | virtual ~PlayListFileView(); | 13 | virtual ~PlayListFileView(); |
14 | |||
15 | DocLnkSet &files() { return m_files; } | ||
16 | |||
17 | public slots: | ||
18 | void scanFiles(); | ||
19 | |||
20 | private: | ||
21 | QString m_mimeTypePattern; | ||
22 | DocLnkSet m_files; | ||
12 | }; | 23 | }; |
13 | 24 | ||
14 | #endif // PLAYLISTFILEVIEW_H | 25 | #endif // PLAYLISTFILEVIEW_H |
15 | /* vim: et sw=4 ts=4 | 26 | /* vim: et sw=4 ts=4 |
16 | */ | 27 | */ |
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 6bda71e..93e7919 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -1,1130 +1,1115 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
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 | #include <qpe/qpetoolbar.h> | 34 | #include <qpe/qpetoolbar.h> |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | #include <qpe/storage.h> | 36 | #include <qpe/storage.h> |
37 | #include <qpe/mimetype.h> | 37 | #include <qpe/mimetype.h> |
38 | #include <qpe/global.h> | 38 | #include <qpe/global.h> |
39 | #include <qpe/resource.h> | 39 | #include <qpe/resource.h> |
40 | 40 | ||
41 | #include <qdatetime.h> | 41 | #include <qdatetime.h> |
42 | #include <qdir.h> | 42 | #include <qdir.h> |
43 | #include <qmessagebox.h> | 43 | #include <qmessagebox.h> |
44 | #include <qregexp.h> | 44 | #include <qregexp.h> |
45 | #include <qtextstream.h> | 45 | #include <qtextstream.h> |
46 | 46 | ||
47 | #include "playlistselection.h" | 47 | #include "playlistselection.h" |
48 | #include "playlistwidget.h" | 48 | #include "playlistwidget.h" |
49 | #include "mediaplayerstate.h" | 49 | #include "mediaplayerstate.h" |
50 | #include "inputDialog.h" | 50 | #include "inputDialog.h" |
51 | #include "om3u.h" | 51 | #include "om3u.h" |
52 | #include "playlistfileview.h" | ||
52 | 53 | ||
53 | //only needed for the random play | 54 | //only needed for the random play |
54 | #include <stdlib.h> | 55 | #include <stdlib.h> |
55 | #include <assert.h> | 56 | #include <assert.h> |
56 | 57 | ||
57 | #include "audiowidget.h" | 58 | #include "audiowidget.h" |
58 | #include "videowidget.h" | 59 | #include "videowidget.h" |
59 | 60 | ||
60 | extern MediaPlayerState *mediaPlayerState; | 61 | extern MediaPlayerState *mediaPlayerState; |
61 | // extern AudioWidget *audioUI; | 62 | // extern AudioWidget *audioUI; |
62 | // extern VideoWidget *videoUI; | 63 | // extern VideoWidget *videoUI; |
63 | 64 | ||
64 | QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg"; | ||
65 | // no m3u's here please | ||
66 | |||
67 | PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) | 65 | PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) |
68 | : PlayListWidgetGui( mediaPlayerState, parent, name ) { | 66 | : PlayListWidgetGui( mediaPlayerState, parent, name ) { |
69 | 67 | ||
70 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), | 68 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), |
71 | "opieplayer2/add_to_playlist", | 69 | "opieplayer2/add_to_playlist", |
72 | this , SLOT(addSelected() ) ); | 70 | this , SLOT(addSelected() ) ); |
73 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), | 71 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), |
74 | "opieplayer2/remove_from_playlist", | 72 | "opieplayer2/remove_from_playlist", |
75 | this , SLOT(removeSelected() ) ); | 73 | this , SLOT(removeSelected() ) ); |
76 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", | 74 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", |
77 | this , SLOT( btnPlay( bool) ), TRUE ); | 75 | this , SLOT( btnPlay( bool) ), TRUE ); |
78 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", | 76 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", |
79 | &mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); | 77 | &mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); |
80 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", | 78 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", |
81 | &mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); | 79 | &mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); |
82 | 80 | ||
83 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 81 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
84 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), | 82 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), |
85 | this, SLOT( addAllMusicToList() ) ); | 83 | this, SLOT( addAllMusicToList() ) ); |
86 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), | 84 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), |
87 | this, SLOT( addAllVideoToList() ) ); | 85 | this, SLOT( addAllVideoToList() ) ); |
88 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), | 86 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), |
89 | this, SLOT( addAllToList() ) ); | 87 | this, SLOT( addAllToList() ) ); |
90 | pmPlayList->insertSeparator(-1); | 88 | pmPlayList->insertSeparator(-1); |
91 | // (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), | 89 | // (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), |
92 | // this, SLOT( saveList() ) ); | 90 | // this, SLOT( saveList() ) ); |
93 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), | 91 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), |
94 | this, SLOT(writem3u() ) ); | 92 | this, SLOT(writem3u() ) ); |
95 | pmPlayList->insertSeparator(-1); | 93 | pmPlayList->insertSeparator(-1); |
96 | (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), | 94 | (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), |
97 | this,SLOT( openFile() ) ); | 95 | this,SLOT( openFile() ) ); |
98 | pmPlayList->insertSeparator(-1); | 96 | pmPlayList->insertSeparator(-1); |
99 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), | 97 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), |
100 | this,SLOT( scanForAudio() ) ); | 98 | this,SLOT( scanForAudio() ) ); |
101 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), | 99 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), |
102 | this,SLOT( scanForVideo() ) ); | 100 | this,SLOT( scanForVideo() ) ); |
103 | 101 | ||
104 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), | 102 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), |
105 | &mediaPlayerState, SLOT( toggleFullscreen() ) ); | 103 | &mediaPlayerState, SLOT( toggleFullscreen() ) ); |
106 | 104 | ||
107 | Config cfg( "OpiePlayer" ); | 105 | Config cfg( "OpiePlayer" ); |
108 | bool b= cfg.readBoolEntry("FullScreen", 0); | 106 | bool b= cfg.readBoolEntry("FullScreen", 0); |
109 | mediaPlayerState.setFullscreen( b ); | 107 | mediaPlayerState.setFullscreen( b ); |
110 | pmView->setItemChecked( -16, b ); | 108 | pmView->setItemChecked( -16, b ); |
111 | 109 | ||
112 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", | 110 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", |
113 | d->selectedFiles, SLOT(moveSelectedUp() ) ); | 111 | d->selectedFiles, SLOT(moveSelectedUp() ) ); |
114 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", | 112 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", |
115 | d->selectedFiles, SLOT(removeSelected() ) ); | 113 | d->selectedFiles, SLOT(removeSelected() ) ); |
116 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", | 114 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", |
117 | d->selectedFiles, SLOT(moveSelectedDown() ) ); | 115 | d->selectedFiles, SLOT(moveSelectedDown() ) ); |
118 | // QVBox *stretch2 = new QVBox( vbox1 ); | 116 | // QVBox *stretch2 = new QVBox( vbox1 ); |
119 | 117 | ||
120 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), | 118 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), |
121 | SLOT( deletePlaylist() ) ); | 119 | SLOT( deletePlaylist() ) ); |
122 | connect( pmView, SIGNAL( activated( int ) ), | 120 | connect( pmView, SIGNAL( activated( int ) ), |
123 | this, SLOT( pmViewActivated( int ) ) ); | 121 | this, SLOT( pmViewActivated( int ) ) ); |
124 | connect( skinsMenu, SIGNAL( activated( int ) ) , | 122 | connect( skinsMenu, SIGNAL( activated( int ) ) , |
125 | this, SLOT( skinsMenuActivated( int ) ) ); | 123 | this, SLOT( skinsMenuActivated( int ) ) ); |
126 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 124 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), |
127 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 125 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
128 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), | 126 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), |
129 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 127 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
130 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), | 128 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), |
131 | this,SLOT( playIt( QListViewItem *) ) ); | 129 | this,SLOT( playIt( QListViewItem *) ) ); |
132 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), | 130 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), |
133 | this, SLOT( addToSelection( QListViewItem *) ) ); | 131 | this, SLOT( addToSelection( QListViewItem *) ) ); |
134 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 132 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), |
135 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); | 133 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); |
136 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), | 134 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), |
137 | this,SLOT( playIt( QListViewItem *) ) ); | 135 | this,SLOT( playIt( QListViewItem *) ) ); |
138 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), | 136 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), |
139 | this, SLOT( addToSelection( QListViewItem *) ) ); | 137 | this, SLOT( addToSelection( QListViewItem *) ) ); |
140 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), | 138 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), |
141 | this, SLOT( loadList( const DocLnk & ) ) ); | 139 | this, SLOT( loadList( const DocLnk & ) ) ); |
142 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), | 140 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), |
143 | this, SLOT( tabChanged( QWidget* ) ) ); | 141 | this, SLOT( tabChanged( QWidget* ) ) ); |
144 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), | 142 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), |
145 | d->tbPlay, SLOT( setOn( bool ) ) ); | 143 | d->tbPlay, SLOT( setOn( bool ) ) ); |
146 | connect( &mediaPlayerState, SIGNAL( loopingToggled( bool ) ), | 144 | connect( &mediaPlayerState, SIGNAL( loopingToggled( bool ) ), |
147 | d->tbLoop, SLOT( setOn( bool ) ) ); | 145 | d->tbLoop, SLOT( setOn( bool ) ) ); |
148 | connect( &mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), | 146 | connect( &mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), |
149 | d->tbShuffle, SLOT( setOn( bool ) ) ); | 147 | d->tbShuffle, SLOT( setOn( bool ) ) ); |
150 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), | 148 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), |
151 | this, SLOT( playIt( QListViewItem *) ) ); | 149 | this, SLOT( playIt( QListViewItem *) ) ); |
152 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), | 150 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), |
153 | &mediaPlayerState, SLOT( setVideoGamma( int ) ) ); | 151 | &mediaPlayerState, SLOT( setVideoGamma( int ) ) ); |
154 | 152 | ||
155 | // see which skins are installed | 153 | // see which skins are installed |
156 | videoScan=false; | 154 | videoScan=false; |
157 | audioScan=false; | 155 | audioScan=false; |
158 | audioPopulated=false; | 156 | audioPopulated=false; |
159 | videoPopulated=false; | 157 | videoPopulated=false; |
160 | populateSkinsMenu(); | 158 | populateSkinsMenu(); |
161 | initializeStates(); | 159 | initializeStates(); |
162 | 160 | ||
163 | cfg.setGroup("PlayList"); | 161 | cfg.setGroup("PlayList"); |
164 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); | 162 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); |
165 | loadList(DocLnk( currentPlaylist ) ); | 163 | loadList(DocLnk( currentPlaylist ) ); |
166 | } | 164 | } |
167 | 165 | ||
168 | 166 | ||
169 | PlayListWidget::~PlayListWidget() { | 167 | PlayListWidget::~PlayListWidget() { |
170 | delete d; | 168 | delete d; |
171 | } | 169 | } |
172 | 170 | ||
173 | 171 | ||
174 | void PlayListWidget::initializeStates() { | 172 | void PlayListWidget::initializeStates() { |
175 | d->tbPlay->setOn( mediaPlayerState.isPlaying() ); | 173 | d->tbPlay->setOn( mediaPlayerState.isPlaying() ); |
176 | d->tbLoop->setOn( mediaPlayerState.isLooping() ); | 174 | d->tbLoop->setOn( mediaPlayerState.isLooping() ); |
177 | d->tbShuffle->setOn( mediaPlayerState.isShuffled() ); | 175 | d->tbShuffle->setOn( mediaPlayerState.isShuffled() ); |
178 | d->playListFrame->show(); | 176 | d->playListFrame->show(); |
179 | } | 177 | } |
180 | 178 | ||
181 | void PlayListWidget::writeDefaultPlaylist() { | 179 | void PlayListWidget::writeDefaultPlaylist() { |
182 | 180 | ||
183 | Config config( "OpiePlayer" ); | 181 | Config config( "OpiePlayer" ); |
184 | config.setGroup( "PlayList" ); | 182 | config.setGroup( "PlayList" ); |
185 | QString filename=QPEApplication::documentDir() + "/default.m3u"; | 183 | QString filename=QPEApplication::documentDir() + "/default.m3u"; |
186 | QString currentString = config.readEntry( "CurrentPlaylist", filename); | 184 | QString currentString = config.readEntry( "CurrentPlaylist", filename); |
187 | if( currentString == filename) { | 185 | if( currentString == filename) { |
188 | Om3u *m3uList; | 186 | Om3u *m3uList; |
189 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); | 187 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); |
190 | if( d->selectedFiles->first() ) { | 188 | if( d->selectedFiles->first() ) { |
191 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 189 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
192 | do { | 190 | do { |
193 | // qDebug(d->selectedFiles->current()->file()); | 191 | // qDebug(d->selectedFiles->current()->file()); |
194 | m3uList->add( d->selectedFiles->current()->file() ); | 192 | m3uList->add( d->selectedFiles->current()->file() ); |
195 | } | 193 | } |
196 | while ( d->selectedFiles->next() ); | 194 | while ( d->selectedFiles->next() ); |
197 | 195 | ||
198 | m3uList->write(); | 196 | m3uList->write(); |
199 | m3uList->close(); | 197 | m3uList->close(); |
200 | if(m3uList) delete m3uList; | 198 | if(m3uList) delete m3uList; |
201 | 199 | ||
202 | } | 200 | } |
203 | } | 201 | } |
204 | } | 202 | } |
205 | 203 | ||
206 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 204 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
207 | d->setDocumentUsed = FALSE; | 205 | d->setDocumentUsed = FALSE; |
208 | if( QFileInfo( lnk.file() ).exists() || | 206 | if( QFileInfo( lnk.file() ).exists() || |
209 | lnk.file().left(4) == "http" ) { | 207 | lnk.file().left(4) == "http" ) { |
210 | d->selectedFiles->addToSelection( lnk ); | 208 | d->selectedFiles->addToSelection( lnk ); |
211 | } | 209 | } |
212 | // writeCurrentM3u(); | 210 | // writeCurrentM3u(); |
213 | } | 211 | } |
214 | 212 | ||
215 | 213 | ||
216 | void PlayListWidget::clearList() { | 214 | void PlayListWidget::clearList() { |
217 | while ( first() ) { | 215 | while ( first() ) { |
218 | d->selectedFiles->removeSelected(); | 216 | d->selectedFiles->removeSelected(); |
219 | } | 217 | } |
220 | } | 218 | } |
221 | 219 | ||
222 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 220 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
223 | switch (mouse) { | 221 | switch (mouse) { |
224 | case 1: | 222 | case 1: |
225 | break; | 223 | break; |
226 | case 2: | 224 | case 2: |
227 | { | 225 | { |
228 | QPopupMenu m; | 226 | QPopupMenu m; |
229 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 227 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
230 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 228 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
231 | m.exec( QCursor::pos() ); | 229 | m.exec( QCursor::pos() ); |
232 | } | 230 | } |
233 | break; | 231 | break; |
234 | } | 232 | } |
235 | } | 233 | } |
236 | 234 | ||
237 | 235 | ||
238 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 236 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
239 | switch (mouse) { | 237 | switch (mouse) { |
240 | case 1: | 238 | case 1: |
241 | break; | 239 | break; |
242 | case 2: | 240 | case 2: |
243 | { | 241 | { |
244 | QPopupMenu m; | 242 | QPopupMenu m; |
245 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 243 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
246 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 244 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
247 | m.exec( QCursor::pos() ); | 245 | m.exec( QCursor::pos() ); |
248 | } | 246 | } |
249 | break; | 247 | break; |
250 | } | 248 | } |
251 | } | 249 | } |
252 | 250 | ||
253 | 251 | ||
254 | void PlayListWidget::addAllToList() { | 252 | void PlayListWidget::addAllToList() { |
255 | 253 | ||
256 | // QTime t; | 254 | // QTime t; |
257 | // t.start(); | 255 | // t.start(); |
258 | 256 | ||
259 | if(!audioScan) { | 257 | if(!audioScan) { |
260 | if(audioView->childCount() < 1) | 258 | if(audioView->childCount() < 1) |
261 | populateAudioView(); | 259 | populateAudioView(); |
262 | } | 260 | } |
263 | 261 | ||
264 | QListViewItemIterator audioIt( audioView ); | 262 | QListViewItemIterator audioIt( audioView ); |
265 | DocLnk lnk; | 263 | DocLnk lnk; |
266 | QString filename; | 264 | QString filename; |
267 | // iterate through all items of the listview | 265 | // iterate through all items of the listview |
268 | for ( ; audioIt.current(); ++audioIt ) { | 266 | for ( ; audioIt.current(); ++audioIt ) { |
269 | filename = audioIt.current()->text(3); | 267 | filename = audioIt.current()->text(3); |
270 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 268 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
271 | lnk.setFile( filename ); //sets file name | 269 | lnk.setFile( filename ); //sets file name |
272 | d->selectedFiles->addToSelection( lnk); | 270 | d->selectedFiles->addToSelection( lnk); |
273 | } | 271 | } |
274 | 272 | ||
275 | if(!videoScan) { | 273 | if(!videoScan) { |
276 | if(videoView->childCount() < 1) | 274 | if(videoView->childCount() < 1) |
277 | populateVideoView(); | 275 | populateVideoView(); |
278 | } | 276 | } |
279 | 277 | ||
280 | QListViewItemIterator videoIt( videoView ); | 278 | QListViewItemIterator videoIt( videoView ); |
281 | for ( ; videoIt.current(); ++videoIt ) { | 279 | for ( ; videoIt.current(); ++videoIt ) { |
282 | filename = videoIt.current()->text(3); | 280 | filename = videoIt.current()->text(3); |
283 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 281 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
284 | lnk.setFile( filename ); //sets file name | 282 | lnk.setFile( filename ); //sets file name |
285 | d->selectedFiles->addToSelection( lnk); | 283 | d->selectedFiles->addToSelection( lnk); |
286 | } | 284 | } |
287 | 285 | ||
288 | // d->selectedFiles->addToSelection( ); | 286 | // d->selectedFiles->addToSelection( ); |
289 | // if ( it.current()->isSelected() ) | 287 | // if ( it.current()->isSelected() ) |
290 | // lst->append( audioIt.current() ); | 288 | // lst->append( audioIt.current() ); |
291 | // } | 289 | // } |
292 | 290 | ||
293 | 291 | ||
294 | // if(!audioScan) | 292 | // if(!audioScan) |
295 | // scanForAudio(); | 293 | // scanForAudio(); |
296 | // if(!videoScan) | 294 | // if(!videoScan) |
297 | // scanForVideo(); | 295 | // scanForVideo(); |
298 | 296 | ||
299 | // DocLnkSet filesAll; | 297 | // DocLnkSet filesAll; |
300 | // Global::findDocuments(&filesAll, "video/*;"+audioMimes); | 298 | // Global::findDocuments(&filesAll, "video/*;"+audioMimes); |
301 | // QListIterator<DocLnk> Adit( filesAll.children() ); | 299 | // QListIterator<DocLnk> Adit( filesAll.children() ); |
302 | // for ( ; Adit.current(); ++Adit ) { | 300 | // for ( ; Adit.current(); ++Adit ) { |
303 | // if( QFileInfo( Adit.current()->file() ).exists() ) { | 301 | // if( QFileInfo( Adit.current()->file() ).exists() ) { |
304 | // d->selectedFiles->addToSelection( **Adit ); | 302 | // d->selectedFiles->addToSelection( **Adit ); |
305 | // } | 303 | // } |
306 | // } | 304 | // } |
307 | 305 | ||
308 | // qDebug("elapsed time %d", t.elapsed() ); | 306 | // qDebug("elapsed time %d", t.elapsed() ); |
309 | 307 | ||
310 | tabWidget->setCurrentPage(0); | 308 | tabWidget->setCurrentPage(0); |
311 | 309 | ||
312 | writeCurrentM3u(); | 310 | writeCurrentM3u(); |
313 | d->selectedFiles->first(); | 311 | d->selectedFiles->first(); |
314 | } | 312 | } |
315 | 313 | ||
316 | 314 | ||
317 | void PlayListWidget::addAllMusicToList() { | 315 | void PlayListWidget::addAllMusicToList() { |
318 | 316 | ||
319 | if(!audioScan) { | 317 | if(!audioScan) { |
320 | if(audioView->childCount() < 1) | 318 | if(audioView->childCount() < 1) |
321 | populateAudioView(); | 319 | populateAudioView(); |
322 | } | 320 | } |
323 | 321 | ||
324 | QListViewItemIterator audioIt( audioView ); | 322 | QListViewItemIterator audioIt( audioView ); |
325 | DocLnk lnk; | 323 | DocLnk lnk; |
326 | QString filename; | 324 | QString filename; |
327 | // iterate through all items of the listview | 325 | // iterate through all items of the listview |
328 | for ( ; audioIt.current(); ++audioIt ) { | 326 | for ( ; audioIt.current(); ++audioIt ) { |
329 | filename = audioIt.current()->text(3); | 327 | filename = audioIt.current()->text(3); |
330 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 328 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
331 | lnk.setFile( filename ); //sets file name | 329 | lnk.setFile( filename ); //sets file name |
332 | d->selectedFiles->addToSelection( lnk); | 330 | d->selectedFiles->addToSelection( lnk); |
333 | } | 331 | } |
334 | 332 | ||
335 | /* if(!audioScan) | 333 | /* if(!audioScan) |
336 | scanForAudio(); | 334 | scanForAudio(); |
337 | QListIterator<DocLnk> dit( files.children() ); | 335 | QListIterator<DocLnk> dit( files.children() ); |
338 | for ( ; dit.current(); ++dit ) { | 336 | for ( ; dit.current(); ++dit ) { |
339 | if( QFileInfo(dit.current()->file() ).exists() ) { | 337 | if( QFileInfo(dit.current()->file() ).exists() ) { |
340 | d->selectedFiles->addToSelection( **dit ); | 338 | d->selectedFiles->addToSelection( **dit ); |
341 | } | 339 | } |
342 | } | 340 | } |
343 | */ | 341 | */ |
344 | tabWidget->setCurrentPage(0); | 342 | tabWidget->setCurrentPage(0); |
345 | writeCurrentM3u(); | 343 | writeCurrentM3u(); |
346 | d->selectedFiles->first(); | 344 | d->selectedFiles->first(); |
347 | } | 345 | } |
348 | 346 | ||
349 | 347 | ||
350 | void PlayListWidget::addAllVideoToList() { | 348 | void PlayListWidget::addAllVideoToList() { |
351 | 349 | ||
352 | if(!videoScan) { | 350 | if(!videoScan) { |
353 | if(videoView->childCount() < 1) | 351 | if(videoView->childCount() < 1) |
354 | populateVideoView(); | 352 | populateVideoView(); |
355 | } | 353 | } |
356 | 354 | ||
357 | QListViewItemIterator videoIt( videoView ); | 355 | QListViewItemIterator videoIt( videoView ); |
358 | DocLnk lnk; | 356 | DocLnk lnk; |
359 | QString filename; | 357 | QString filename; |
360 | for ( ; videoIt.current(); ++videoIt ) { | 358 | for ( ; videoIt.current(); ++videoIt ) { |
361 | filename = videoIt.current()->text(3); | 359 | filename = videoIt.current()->text(3); |
362 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 360 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
363 | lnk.setFile( filename ); //sets file name | 361 | lnk.setFile( filename ); //sets file name |
364 | d->selectedFiles->addToSelection( lnk); | 362 | d->selectedFiles->addToSelection( lnk); |
365 | } | 363 | } |
366 | 364 | ||
367 | 365 | ||
368 | /* if(!videoScan) | 366 | /* if(!videoScan) |
369 | scanForVideo(); | 367 | scanForVideo(); |
370 | QListIterator<DocLnk> dit( vFiles.children() ); | 368 | QListIterator<DocLnk> dit( vFiles.children() ); |
371 | for ( ; dit.current(); ++dit ) { | 369 | for ( ; dit.current(); ++dit ) { |
372 | if( QFileInfo( dit.current()->file() ).exists() ) { | 370 | if( QFileInfo( dit.current()->file() ).exists() ) { |
373 | d->selectedFiles->addToSelection( **dit ); | 371 | d->selectedFiles->addToSelection( **dit ); |
374 | } | 372 | } |
375 | } | 373 | } |
376 | */ | 374 | */ |
377 | tabWidget->setCurrentPage(0); | 375 | tabWidget->setCurrentPage(0); |
378 | writeCurrentM3u(); | 376 | writeCurrentM3u(); |
379 | d->selectedFiles->first(); | 377 | d->selectedFiles->first(); |
380 | } | 378 | } |
381 | 379 | ||
382 | 380 | ||
383 | void PlayListWidget::setDocument( const QString& fileref ) { | 381 | void PlayListWidget::setDocument( const QString& fileref ) { |
384 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); | 382 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); |
385 | fromSetDocument = TRUE; | 383 | fromSetDocument = TRUE; |
386 | if ( fileref.isNull() ) { | 384 | if ( fileref.isNull() ) { |
387 | QMessageBox::warning( this, tr( "Invalid File" ), | 385 | QMessageBox::warning( this, tr( "Invalid File" ), |
388 | tr( "There was a problem in getting the file." ) ); | 386 | tr( "There was a problem in getting the file." ) ); |
389 | return; | 387 | return; |
390 | } | 388 | } |
391 | 389 | ||
392 | clearList(); | 390 | clearList(); |
393 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u | 391 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u |
394 | readm3u( fileref ); | 392 | readm3u( fileref ); |
395 | } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { | 393 | } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { |
396 | readm3u( DocLnk( fileref).file() ); | 394 | readm3u( DocLnk( fileref).file() ); |
397 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls | 395 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls |
398 | readPls( fileref ); | 396 | readPls( fileref ); |
399 | } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { | 397 | } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { |
400 | readPls( DocLnk( fileref).file() ); | 398 | readPls( DocLnk( fileref).file() ); |
401 | } else { | 399 | } else { |
402 | clearList(); | 400 | clearList(); |
403 | addToSelection( DocLnk( fileref ) ); | 401 | addToSelection( DocLnk( fileref ) ); |
404 | writeCurrentM3u(); | 402 | writeCurrentM3u(); |
405 | 403 | ||
406 | d->setDocumentUsed = TRUE; | 404 | d->setDocumentUsed = TRUE; |
407 | mediaPlayerState.setPlaying( FALSE ); | 405 | mediaPlayerState.setPlaying( FALSE ); |
408 | mediaPlayerState.setPlaying( TRUE ); | 406 | mediaPlayerState.setPlaying( TRUE ); |
409 | } | 407 | } |
410 | } | 408 | } |
411 | 409 | ||
412 | 410 | ||
413 | void PlayListWidget::useSelectedDocument() { | 411 | void PlayListWidget::useSelectedDocument() { |
414 | d->setDocumentUsed = FALSE; | 412 | d->setDocumentUsed = FALSE; |
415 | } | 413 | } |
416 | 414 | ||
417 | 415 | ||
418 | const DocLnk *PlayListWidget::current() const { // this is fugly | 416 | const DocLnk *PlayListWidget::current() const { // this is fugly |
419 | assert( currentTab() == CurrentPlayList ); | 417 | assert( currentTab() == CurrentPlayList ); |
420 | 418 | ||
421 | const DocLnk *lnk = d->selectedFiles->current(); | 419 | const DocLnk *lnk = d->selectedFiles->current(); |
422 | if ( !lnk ) { | 420 | if ( !lnk ) { |
423 | d->selectedFiles->first(); | 421 | d->selectedFiles->first(); |
424 | lnk = d->selectedFiles->current(); | 422 | lnk = d->selectedFiles->current(); |
425 | } | 423 | } |
426 | assert( lnk ); | 424 | assert( lnk ); |
427 | return lnk; | 425 | return lnk; |
428 | } | 426 | } |
429 | 427 | ||
430 | 428 | ||
431 | bool PlayListWidget::prev() { | 429 | bool PlayListWidget::prev() { |
432 | if ( mediaPlayerState.isShuffled() ) { | 430 | if ( mediaPlayerState.isShuffled() ) { |
433 | const DocLnk *cur = current(); | 431 | const DocLnk *cur = current(); |
434 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 432 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
435 | for ( int i = 0; i < j; i++ ) { | 433 | for ( int i = 0; i < j; i++ ) { |
436 | if ( !d->selectedFiles->next() ) | 434 | if ( !d->selectedFiles->next() ) |
437 | d->selectedFiles->first(); | 435 | d->selectedFiles->first(); |
438 | } | 436 | } |
439 | if ( cur == current() ) | 437 | if ( cur == current() ) |
440 | if ( !d->selectedFiles->next() ) { | 438 | if ( !d->selectedFiles->next() ) { |
441 | d->selectedFiles->first(); | 439 | d->selectedFiles->first(); |
442 | } | 440 | } |
443 | return TRUE; | 441 | return TRUE; |
444 | } else { | 442 | } else { |
445 | if ( !d->selectedFiles->prev() ) { | 443 | if ( !d->selectedFiles->prev() ) { |
446 | if ( mediaPlayerState.isLooping() ) { | 444 | if ( mediaPlayerState.isLooping() ) { |
447 | return d->selectedFiles->last(); | 445 | return d->selectedFiles->last(); |
448 | } else { | 446 | } else { |
449 | return FALSE; | 447 | return FALSE; |
450 | } | 448 | } |
451 | } | 449 | } |
452 | return TRUE; | 450 | return TRUE; |
453 | } | 451 | } |
454 | } | 452 | } |
455 | 453 | ||
456 | 454 | ||
457 | bool PlayListWidget::next() { | 455 | bool PlayListWidget::next() { |
458 | //qDebug("<<<<<<<<<<<<next()"); | 456 | //qDebug("<<<<<<<<<<<<next()"); |
459 | if ( mediaPlayerState.isShuffled() ) { | 457 | if ( mediaPlayerState.isShuffled() ) { |
460 | return prev(); | 458 | return prev(); |
461 | } else { | 459 | } else { |
462 | if ( !d->selectedFiles->next() ) { | 460 | if ( !d->selectedFiles->next() ) { |
463 | if ( mediaPlayerState.isLooping() ) { | 461 | if ( mediaPlayerState.isLooping() ) { |
464 | return d->selectedFiles->first(); | 462 | return d->selectedFiles->first(); |
465 | } else { | 463 | } else { |
466 | return FALSE; | 464 | return FALSE; |
467 | } | 465 | } |
468 | } | 466 | } |
469 | return TRUE; | 467 | return TRUE; |
470 | } | 468 | } |
471 | } | 469 | } |
472 | 470 | ||
473 | 471 | ||
474 | bool PlayListWidget::first() { | 472 | bool PlayListWidget::first() { |
475 | return d->selectedFiles->first(); | 473 | return d->selectedFiles->first(); |
476 | } | 474 | } |
477 | 475 | ||
478 | 476 | ||
479 | bool PlayListWidget::last() { | 477 | bool PlayListWidget::last() { |
480 | return d->selectedFiles->last(); | 478 | return d->selectedFiles->last(); |
481 | } | 479 | } |
482 | 480 | ||
483 | 481 | ||
484 | void PlayListWidget::saveList() { | 482 | void PlayListWidget::saveList() { |
485 | writem3u(); | 483 | writem3u(); |
486 | } | 484 | } |
487 | 485 | ||
488 | 486 | ||
489 | void PlayListWidget::loadList( const DocLnk & lnk) { | 487 | void PlayListWidget::loadList( const DocLnk & lnk) { |
490 | QString name = lnk.name(); | 488 | QString name = lnk.name(); |
491 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); | 489 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); |
492 | 490 | ||
493 | if( name.length()>0) { | 491 | if( name.length()>0) { |
494 | setCaption("OpiePlayer: "+name); | 492 | setCaption("OpiePlayer: "+name); |
495 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); | 493 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); |
496 | clearList(); | 494 | clearList(); |
497 | readm3u(lnk.file()); | 495 | readm3u(lnk.file()); |
498 | tabWidget->setCurrentPage(0); | 496 | tabWidget->setCurrentPage(0); |
499 | } | 497 | } |
500 | } | 498 | } |
501 | 499 | ||
502 | void PlayListWidget::addSelected() { | 500 | void PlayListWidget::addSelected() { |
503 | assert( inFileListMode() ); | 501 | assert( inFileListMode() ); |
504 | 502 | ||
505 | QListView *fileListView = currentFileListView(); | 503 | QListView *fileListView = currentFileListView(); |
506 | QListViewItemIterator it( fileListView ); | 504 | QListViewItemIterator it( fileListView ); |
507 | for ( ; it.current(); ++it ) | 505 | for ( ; it.current(); ++it ) |
508 | if ( it.current()->isSelected() ) { | 506 | if ( it.current()->isSelected() ) { |
509 | QString filename = it.current()->text(3); | 507 | QString filename = it.current()->text(3); |
510 | 508 | ||
511 | DocLnk lnk; | 509 | DocLnk lnk; |
512 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name | 510 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name |
513 | lnk.setFile( filename ); //sets file name | 511 | lnk.setFile( filename ); //sets file name |
514 | 512 | ||
515 | d->selectedFiles->addToSelection( lnk ); | 513 | d->selectedFiles->addToSelection( lnk ); |
516 | } | 514 | } |
517 | 515 | ||
518 | fileListView->clearSelection(); | 516 | fileListView->clearSelection(); |
519 | 517 | ||
520 | tabWidget->setCurrentPage( 0 ); | 518 | tabWidget->setCurrentPage( 0 ); |
521 | writeCurrentM3u(); | 519 | writeCurrentM3u(); |
522 | } | 520 | } |
523 | 521 | ||
524 | 522 | ||
525 | void PlayListWidget::removeSelected() { | 523 | void PlayListWidget::removeSelected() { |
526 | d->selectedFiles->removeSelected( ); | 524 | d->selectedFiles->removeSelected( ); |
527 | writeCurrentM3u(); | 525 | writeCurrentM3u(); |
528 | } | 526 | } |
529 | 527 | ||
530 | 528 | ||
531 | void PlayListWidget::playIt( QListViewItem *it) { | 529 | void PlayListWidget::playIt( QListViewItem *it) { |
532 | if(!it) return; | 530 | if(!it) return; |
533 | mediaPlayerState.setPlaying(FALSE); | 531 | mediaPlayerState.setPlaying(FALSE); |
534 | mediaPlayerState.setPlaying(TRUE); | 532 | mediaPlayerState.setPlaying(TRUE); |
535 | d->selectedFiles->unSelect(); | 533 | d->selectedFiles->unSelect(); |
536 | } | 534 | } |
537 | 535 | ||
538 | 536 | ||
539 | void PlayListWidget::addToSelection( QListViewItem *it) { | 537 | void PlayListWidget::addToSelection( QListViewItem *it) { |
540 | d->setDocumentUsed = FALSE; | 538 | d->setDocumentUsed = FALSE; |
541 | 539 | ||
542 | if(it) { | 540 | if(it) { |
543 | if ( currentTab() == CurrentPlayList ) | 541 | if ( currentTab() == CurrentPlayList ) |
544 | return; | 542 | return; |
545 | // case 1: { | 543 | // case 1: { |
546 | DocLnk lnk; | 544 | DocLnk lnk; |
547 | QString filename; | 545 | QString filename; |
548 | 546 | ||
549 | filename=it->text(3); | 547 | filename=it->text(3); |
550 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 548 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
551 | lnk.setFile( filename ); //sets file name | 549 | lnk.setFile( filename ); //sets file name |
552 | d->selectedFiles->addToSelection( lnk); | 550 | d->selectedFiles->addToSelection( lnk); |
553 | 551 | ||
554 | writeCurrentM3u(); | 552 | writeCurrentM3u(); |
555 | tabWidget->setCurrentPage(0); | 553 | tabWidget->setCurrentPage(0); |
556 | 554 | ||
557 | } | 555 | } |
558 | } | 556 | } |
559 | 557 | ||
560 | 558 | ||
561 | void PlayListWidget::tabChanged(QWidget *) { | 559 | void PlayListWidget::tabChanged(QWidget *) { |
562 | 560 | ||
563 | d->tbPlay->setEnabled( true ); | 561 | d->tbPlay->setEnabled( true ); |
564 | 562 | ||
565 | switch ( currentTab() ) { | 563 | switch ( currentTab() ) { |
566 | case CurrentPlayList: | 564 | case CurrentPlayList: |
567 | { | 565 | { |
568 | if( !tbDeletePlaylist->isHidden() ) { | 566 | if( !tbDeletePlaylist->isHidden() ) { |
569 | tbDeletePlaylist->hide(); | 567 | tbDeletePlaylist->hide(); |
570 | } | 568 | } |
571 | d->tbRemoveFromList->setEnabled(TRUE); | 569 | d->tbRemoveFromList->setEnabled(TRUE); |
572 | d->tbAddToList->setEnabled(FALSE); | 570 | d->tbAddToList->setEnabled(FALSE); |
573 | 571 | ||
574 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); | 572 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); |
575 | } | 573 | } |
576 | break; | 574 | break; |
577 | case AudioFiles: | 575 | case AudioFiles: |
578 | { | 576 | { |
579 | // audioView->clear(); | 577 | // audioView->clear(); |
580 | if(!audioPopulated) populateAudioView(); | 578 | if(!audioPopulated) populateAudioView(); |
581 | 579 | ||
582 | if( !tbDeletePlaylist->isHidden() ) { | 580 | if( !tbDeletePlaylist->isHidden() ) { |
583 | tbDeletePlaylist->hide(); | 581 | tbDeletePlaylist->hide(); |
584 | } | 582 | } |
585 | d->tbRemoveFromList->setEnabled(FALSE); | 583 | d->tbRemoveFromList->setEnabled(FALSE); |
586 | d->tbAddToList->setEnabled(TRUE); | 584 | d->tbAddToList->setEnabled(TRUE); |
587 | } | 585 | } |
588 | break; | 586 | break; |
589 | case VideoFiles: | 587 | case VideoFiles: |
590 | { | 588 | { |
591 | // videoView->clear(); | 589 | // videoView->clear(); |
592 | if(!videoPopulated) populateVideoView(); | 590 | if(!videoPopulated) populateVideoView(); |
593 | if( !tbDeletePlaylist->isHidden() ) { | 591 | if( !tbDeletePlaylist->isHidden() ) { |
594 | tbDeletePlaylist->hide(); | 592 | tbDeletePlaylist->hide(); |
595 | } | 593 | } |
596 | d->tbRemoveFromList->setEnabled(FALSE); | 594 | d->tbRemoveFromList->setEnabled(FALSE); |
597 | d->tbAddToList->setEnabled(TRUE); | 595 | d->tbAddToList->setEnabled(TRUE); |
598 | } | 596 | } |
599 | break; | 597 | break; |
600 | case PlayLists: | 598 | case PlayLists: |
601 | { | 599 | { |
602 | if( tbDeletePlaylist->isHidden() ) { | 600 | if( tbDeletePlaylist->isHidden() ) { |
603 | tbDeletePlaylist->show(); | 601 | tbDeletePlaylist->show(); |
604 | } | 602 | } |
605 | playLists->reread(); | 603 | playLists->reread(); |
606 | d->tbAddToList->setEnabled(FALSE); | 604 | d->tbAddToList->setEnabled(FALSE); |
607 | 605 | ||
608 | d->tbPlay->setEnabled( false ); | 606 | d->tbPlay->setEnabled( false ); |
609 | } | 607 | } |
610 | break; | 608 | break; |
611 | }; | 609 | }; |
612 | } | 610 | } |
613 | 611 | ||
614 | 612 | ||
615 | void PlayListWidget::btnPlay(bool b) { | 613 | void PlayListWidget::btnPlay(bool b) { |
616 | // mediaPlayerState->setPlaying(false); | 614 | // mediaPlayerState->setPlaying(false); |
617 | mediaPlayerState.setPlaying(b); | 615 | mediaPlayerState.setPlaying(b); |
618 | insanityBool=FALSE; | 616 | insanityBool=FALSE; |
619 | } | 617 | } |
620 | 618 | ||
621 | void PlayListWidget::deletePlaylist() { | 619 | void PlayListWidget::deletePlaylist() { |
622 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 620 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
623 | (tr("You really want to delete\nthis playlist?")), | 621 | (tr("You really want to delete\nthis playlist?")), |
624 | (tr("Yes")), (tr("No")), 0 )){ | 622 | (tr("Yes")), (tr("No")), 0 )){ |
625 | case 0: // Yes clicked, | 623 | case 0: // Yes clicked, |
626 | QFile().remove(playLists->selectedDocument().file()); | 624 | QFile().remove(playLists->selectedDocument().file()); |
627 | QFile().remove(playLists->selectedDocument().linkFile()); | 625 | QFile().remove(playLists->selectedDocument().linkFile()); |
628 | playLists->reread(); | 626 | playLists->reread(); |
629 | break; | 627 | break; |
630 | case 1: // Cancel | 628 | case 1: // Cancel |
631 | break; | 629 | break; |
632 | }; | 630 | }; |
633 | } | 631 | } |
634 | 632 | ||
635 | 633 | ||
636 | void PlayListWidget::playSelected() { | 634 | void PlayListWidget::playSelected() { |
637 | btnPlay( TRUE); | 635 | btnPlay( TRUE); |
638 | } | 636 | } |
639 | 637 | ||
640 | 638 | ||
641 | void PlayListWidget::scanForAudio() { | 639 | void PlayListWidget::scanForAudio() { |
642 | // qDebug("scan for audio"); | 640 | audioView->scanFiles(); |
643 | files.detachChildren(); | ||
644 | QListIterator<DocLnk> sdit( files.children() ); | ||
645 | for ( ; sdit.current(); ++sdit ) { | ||
646 | delete sdit.current(); | ||
647 | } | ||
648 | // Global::findDocuments( &files, "audio/*"); | ||
649 | Global::findDocuments( &files, audioMimes); | ||
650 | audioScan = true; | 641 | audioScan = true; |
651 | populateAudioView(); | 642 | populateAudioView(); |
652 | } | 643 | } |
653 | 644 | ||
654 | void PlayListWidget::scanForVideo() { | 645 | void PlayListWidget::scanForVideo() { |
655 | // qDebug("scan for video"); | 646 | videoView->scanFiles(); |
656 | vFiles.detachChildren(); | ||
657 | QListIterator<DocLnk> sdit( vFiles.children() ); | ||
658 | for ( ; sdit.current(); ++sdit ) { | ||
659 | delete sdit.current(); | ||
660 | } | ||
661 | Global::findDocuments(&vFiles, "video/*"); | ||
662 | videoScan = true; | 647 | videoScan = true; |
663 | populateVideoView(); | 648 | populateVideoView(); |
664 | } | 649 | } |
665 | 650 | ||
666 | void PlayListWidget::populateAudioView() { | 651 | void PlayListWidget::populateAudioView() { |
667 | audioView->clear(); | 652 | audioView->clear(); |
668 | StorageInfo storageInfo; | 653 | StorageInfo storageInfo; |
669 | // const QList<FileSystem> &fs = storageInfo.fileSystems(); | 654 | // const QList<FileSystem> &fs = storageInfo.fileSystems(); |
670 | if(!audioScan) { | 655 | if(!audioScan) { |
671 | scanForAudio(); | 656 | scanForAudio(); |
672 | } | 657 | } |
673 | 658 | ||
674 | QListIterator<DocLnk> dit( files.children() ); | 659 | QListIterator<DocLnk> dit( audioView->files().children() ); |
675 | // QListIterator<FileSystem> it ( fs ); | 660 | // QListIterator<FileSystem> it ( fs ); |
676 | audioView->clear(); | 661 | audioView->clear(); |
677 | 662 | ||
678 | QString storage; | 663 | QString storage; |
679 | for ( ; dit.current(); ++dit ) { | 664 | for ( ; dit.current(); ++dit ) { |
680 | // // for( ; it.current(); ++it ){ | 665 | // // for( ; it.current(); ++it ){ |
681 | // const QString name = (*dit)->name(); | 666 | // const QString name = (*dit)->name(); |
682 | // const QString path = (*dit)->path(); | 667 | // const QString path = (*dit)->path(); |
683 | // if(dit.current()->file().find(path) != -1 ) { | 668 | // if(dit.current()->file().find(path) != -1 ) { |
684 | // storage = name; | 669 | // storage = name; |
685 | // // } | 670 | // // } |
686 | // } | 671 | // } |
687 | 672 | ||
688 | QListViewItem * newItem; | 673 | QListViewItem * newItem; |
689 | if ( QFile( dit.current()->file()).exists() || | 674 | if ( QFile( dit.current()->file()).exists() || |
690 | dit.current()->file().left(4) == "http" ) { | 675 | dit.current()->file().left(4) == "http" ) { |
691 | long size; | 676 | long size; |
692 | if( dit.current()->file().left(4) == "http" ) | 677 | if( dit.current()->file().left(4) == "http" ) |
693 | size=0; | 678 | size=0; |
694 | else | 679 | else |
695 | size = QFile( dit.current()->file() ).size(); | 680 | size = QFile( dit.current()->file() ).size(); |
696 | 681 | ||
697 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 682 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
698 | QString::number(size ), "" /*storage*/, | 683 | QString::number(size ), "" /*storage*/, |
699 | dit.current()->file() ); | 684 | dit.current()->file() ); |
700 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); | 685 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); |
701 | // qDebug("<<<< "+dit.current()->file()); | 686 | // qDebug("<<<< "+dit.current()->file()); |
702 | } | 687 | } |
703 | } | 688 | } |
704 | audioPopulated=true; | 689 | audioPopulated=true; |
705 | } | 690 | } |
706 | 691 | ||
707 | 692 | ||
708 | void PlayListWidget::populateVideoView() { | 693 | void PlayListWidget::populateVideoView() { |
709 | videoView->clear(); | 694 | videoView->clear(); |
710 | StorageInfo storageInfo; | 695 | StorageInfo storageInfo; |
711 | // const QList<FileSystem> &fs = storageInfo.fileSystems(); | 696 | // const QList<FileSystem> &fs = storageInfo.fileSystems(); |
712 | 697 | ||
713 | if(!videoScan ) { | 698 | if(!videoScan ) { |
714 | scanForVideo(); | 699 | scanForVideo(); |
715 | } | 700 | } |
716 | 701 | ||
717 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 702 | QListIterator<DocLnk> Vdit( videoView->files().children() ); |
718 | // QListIterator<FileSystem> it ( fs ); | 703 | // QListIterator<FileSystem> it ( fs ); |
719 | videoView->clear(); | 704 | videoView->clear(); |
720 | QString storage, pathName; | 705 | QString storage, pathName; |
721 | for ( ; Vdit.current(); ++Vdit ) { | 706 | for ( ; Vdit.current(); ++Vdit ) { |
722 | // // for( ; it.current(); ++it ) { | 707 | // // for( ; it.current(); ++it ) { |
723 | // const QString name = (*Vdit)->name(); | 708 | // const QString name = (*Vdit)->name(); |
724 | // const QString path = (*Vdit)->path(); | 709 | // const QString path = (*Vdit)->path(); |
725 | // if( Vdit.current()->file().find(path) != -1 ) { | 710 | // if( Vdit.current()->file().find(path) != -1 ) { |
726 | // storage=name; | 711 | // storage=name; |
727 | // pathName=path; | 712 | // pathName=path; |
728 | // // } | 713 | // // } |
729 | // } | 714 | // } |
730 | 715 | ||
731 | QListViewItem * newItem; | 716 | QListViewItem * newItem; |
732 | if ( QFile( Vdit.current()->file() ).exists() ) { | 717 | if ( QFile( Vdit.current()->file() ).exists() ) { |
733 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 718 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
734 | QString::number( QFile( Vdit.current()->file() ).size() ), | 719 | QString::number( QFile( Vdit.current()->file() ).size() ), |
735 | ""/*storage*/, Vdit.current()->file()); | 720 | ""/*storage*/, Vdit.current()->file()); |
736 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); | 721 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); |
737 | } | 722 | } |
738 | } | 723 | } |
739 | videoPopulated=true; | 724 | videoPopulated=true; |
740 | } | 725 | } |
741 | 726 | ||
742 | QListView *PlayListWidget::currentFileListView() const | 727 | QListView *PlayListWidget::currentFileListView() const |
743 | { | 728 | { |
744 | switch ( currentTab() ) { | 729 | switch ( currentTab() ) { |
745 | case AudioFiles: return audioView; | 730 | case AudioFiles: return audioView; |
746 | case VideoFiles: return videoView; | 731 | case VideoFiles: return videoView; |
747 | default: assert( false ); | 732 | default: assert( false ); |
748 | } | 733 | } |
749 | return 0; | 734 | return 0; |
750 | } | 735 | } |
751 | 736 | ||
752 | bool PlayListWidget::inFileListMode() const | 737 | bool PlayListWidget::inFileListMode() const |
753 | { | 738 | { |
754 | TabType tab = currentTab(); | 739 | TabType tab = currentTab(); |
755 | return tab == AudioFiles || tab == VideoFiles; | 740 | return tab == AudioFiles || tab == VideoFiles; |
756 | } | 741 | } |
757 | 742 | ||
758 | void PlayListWidget::openFile() { | 743 | void PlayListWidget::openFile() { |
759 | // http://66.28.164.33:2080 | 744 | // http://66.28.164.33:2080 |
760 | // http://somafm.com/star0242.m3u | 745 | // http://somafm.com/star0242.m3u |
761 | QString filename, name; | 746 | QString filename, name; |
762 | InputDialog *fileDlg; | 747 | InputDialog *fileDlg; |
763 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 748 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
764 | fileDlg->exec(); | 749 | fileDlg->exec(); |
765 | if( fileDlg->result() == 1 ) { | 750 | if( fileDlg->result() == 1 ) { |
766 | filename = fileDlg->text(); | 751 | filename = fileDlg->text(); |
767 | qDebug( "Selected filename is " + filename ); | 752 | qDebug( "Selected filename is " + filename ); |
768 | // Om3u *m3uList; | 753 | // Om3u *m3uList; |
769 | DocLnk lnk; | 754 | DocLnk lnk; |
770 | Config cfg( "OpiePlayer" ); | 755 | Config cfg( "OpiePlayer" ); |
771 | cfg.setGroup("PlayList"); | 756 | cfg.setGroup("PlayList"); |
772 | 757 | ||
773 | if(filename.left(4) == "http") { | 758 | if(filename.left(4) == "http") { |
774 | QString m3uFile, m3uFilePath; | 759 | QString m3uFile, m3uFilePath; |
775 | if(filename.find(":",8,TRUE) != -1) { //found a port | 760 | if(filename.find(":",8,TRUE) != -1) { //found a port |
776 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 761 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
777 | m3uFile = m3uFile.right( 7); | 762 | m3uFile = m3uFile.right( 7); |
778 | } else if(filename.left(4) == "http"){ | 763 | } else if(filename.left(4) == "http"){ |
779 | m3uFile=filename; | 764 | m3uFile=filename; |
780 | m3uFile = m3uFile.right( m3uFile.length() - 7); | 765 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
781 | } else{ | 766 | } else{ |
782 | m3uFile=filename; | 767 | m3uFile=filename; |
783 | } | 768 | } |
784 | 769 | ||
785 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); | 770 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); |
786 | lnk.setName( filename ); //sets name | 771 | lnk.setName( filename ); //sets name |
787 | lnk.setFile( filename ); //sets file name | 772 | lnk.setFile( filename ); //sets file name |
788 | 773 | ||
789 | // lnk.setIcon("opieplayer2/musicfile"); | 774 | // lnk.setIcon("opieplayer2/musicfile"); |
790 | 775 | ||
791 | d->selectedFiles->addToSelection( lnk ); | 776 | d->selectedFiles->addToSelection( lnk ); |
792 | writeCurrentM3u(); | 777 | writeCurrentM3u(); |
793 | d->selectedFiles->setSelectedItem( lnk.name()); | 778 | d->selectedFiles->setSelectedItem( lnk.name()); |
794 | } | 779 | } |
795 | else if( filename.right( 3) == "m3u" ) { | 780 | else if( filename.right( 3) == "m3u" ) { |
796 | readm3u( filename ); | 781 | readm3u( filename ); |
797 | 782 | ||
798 | } else if( filename.right(3) == "pls" ) { | 783 | } else if( filename.right(3) == "pls" ) { |
799 | readPls( filename ); | 784 | readPls( filename ); |
800 | } else { | 785 | } else { |
801 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 786 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
802 | lnk.setFile( filename ); //sets file name | 787 | lnk.setFile( filename ); //sets file name |
803 | d->selectedFiles->addToSelection( lnk); | 788 | d->selectedFiles->addToSelection( lnk); |
804 | writeCurrentM3u(); | 789 | writeCurrentM3u(); |
805 | d->selectedFiles->setSelectedItem( lnk.name()); | 790 | d->selectedFiles->setSelectedItem( lnk.name()); |
806 | } | 791 | } |
807 | } | 792 | } |
808 | 793 | ||
809 | if( fileDlg ) { | 794 | if( fileDlg ) { |
810 | delete fileDlg; | 795 | delete fileDlg; |
811 | } | 796 | } |
812 | } | 797 | } |
813 | 798 | ||
814 | /* | 799 | /* |
815 | reads m3u and shows files/urls to playlist widget */ | 800 | reads m3u and shows files/urls to playlist widget */ |
816 | void PlayListWidget::readm3u( const QString &filename ) { | 801 | void PlayListWidget::readm3u( const QString &filename ) { |
817 | qDebug( "read m3u filename " + filename ); | 802 | qDebug( "read m3u filename " + filename ); |
818 | 803 | ||
819 | Om3u *m3uList; | 804 | Om3u *m3uList; |
820 | QString s, name; | 805 | QString s, name; |
821 | m3uList = new Om3u( filename, IO_ReadOnly ); | 806 | m3uList = new Om3u( filename, IO_ReadOnly ); |
822 | m3uList->readM3u(); | 807 | m3uList->readM3u(); |
823 | DocLnk lnk; | 808 | DocLnk lnk; |
824 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 809 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
825 | s = *it; | 810 | s = *it; |
826 | // qDebug("reading "+ s); | 811 | // qDebug("reading "+ s); |
827 | if(s.left(4)=="http") { | 812 | if(s.left(4)=="http") { |
828 | lnk.setName( s ); //sets file name | 813 | lnk.setName( s ); //sets file name |
829 | lnk.setIcon("opieplayer2/musicfile"); | 814 | lnk.setIcon("opieplayer2/musicfile"); |
830 | lnk.setFile( s ); //sets file name | 815 | lnk.setFile( s ); //sets file name |
831 | 816 | ||
832 | } else { | 817 | } else { |
833 | // if( QFileInfo( s ).exists() ) { | 818 | // if( QFileInfo( s ).exists() ) { |
834 | lnk.setName( QFileInfo(s).baseName()); | 819 | lnk.setName( QFileInfo(s).baseName()); |
835 | // if(s.right(4) == '.') {//if regular file | 820 | // if(s.right(4) == '.') {//if regular file |
836 | if(s.left(1) != "/") { | 821 | if(s.left(1) != "/") { |
837 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); | 822 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); |
838 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 823 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
839 | // lnk.setIcon(MimeType(s).pixmap() ); | 824 | // lnk.setIcon(MimeType(s).pixmap() ); |
840 | // lnk.setIcon("SoundPlayer"); | 825 | // lnk.setIcon("SoundPlayer"); |
841 | } else { | 826 | } else { |
842 | // qDebug("set link2 "+s); | 827 | // qDebug("set link2 "+s); |
843 | lnk.setFile( s); | 828 | lnk.setFile( s); |
844 | // lnk.setIcon(MimeType(s).pixmap() ); | 829 | // lnk.setIcon(MimeType(s).pixmap() ); |
845 | // lnk.setIcon("SoundPlayer"); | 830 | // lnk.setIcon("SoundPlayer"); |
846 | } | 831 | } |
847 | } | 832 | } |
848 | d->selectedFiles->addToSelection( lnk ); | 833 | d->selectedFiles->addToSelection( lnk ); |
849 | } | 834 | } |
850 | Config config( "OpiePlayer" ); | 835 | Config config( "OpiePlayer" ); |
851 | config.setGroup( "PlayList" ); | 836 | config.setGroup( "PlayList" ); |
852 | 837 | ||
853 | config.writeEntry("CurrentPlaylist",filename); | 838 | config.writeEntry("CurrentPlaylist",filename); |
854 | config.write(); | 839 | config.write(); |
855 | currentPlayList=filename; | 840 | currentPlayList=filename; |
856 | 841 | ||
857 | // m3uList->write(); | 842 | // m3uList->write(); |
858 | m3uList->close(); | 843 | m3uList->close(); |
859 | if(m3uList) delete m3uList; | 844 | if(m3uList) delete m3uList; |
860 | 845 | ||
861 | d->selectedFiles->setSelectedItem( s); | 846 | d->selectedFiles->setSelectedItem( s); |
862 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 847 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
863 | 848 | ||
864 | } | 849 | } |
865 | 850 | ||
866 | /* | 851 | /* |
867 | reads pls and adds files/urls to playlist */ | 852 | reads pls and adds files/urls to playlist */ |
868 | void PlayListWidget::readPls( const QString &filename ) { | 853 | void PlayListWidget::readPls( const QString &filename ) { |
869 | 854 | ||
870 | qDebug( "pls filename is " + filename ); | 855 | qDebug( "pls filename is " + filename ); |
871 | Om3u *m3uList; | 856 | Om3u *m3uList; |
872 | QString s, name; | 857 | QString s, name; |
873 | m3uList = new Om3u( filename, IO_ReadOnly ); | 858 | m3uList = new Om3u( filename, IO_ReadOnly ); |
874 | m3uList->readPls(); | 859 | m3uList->readPls(); |
875 | 860 | ||
876 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 861 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
877 | s = *it; | 862 | s = *it; |
878 | // s.replace( QRegExp( "%20" )," " ); | 863 | // s.replace( QRegExp( "%20" )," " ); |
879 | DocLnk lnk( s ); | 864 | DocLnk lnk( s ); |
880 | QFileInfo f( s ); | 865 | QFileInfo f( s ); |
881 | QString name = f.baseName(); | 866 | QString name = f.baseName(); |
882 | 867 | ||
883 | if( name.left( 4 ) == "http" ) { | 868 | if( name.left( 4 ) == "http" ) { |
884 | name = s.right( s.length() - 7); | 869 | name = s.right( s.length() - 7); |
885 | } else { | 870 | } else { |
886 | name = s; | 871 | name = s; |
887 | } | 872 | } |
888 | 873 | ||
889 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 874 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
890 | 875 | ||
891 | lnk.setName( name ); | 876 | lnk.setName( name ); |
892 | if( s.at( s.length() - 4) == '.') {// if this is probably a file | 877 | if( s.at( s.length() - 4) == '.') {// if this is probably a file |
893 | lnk.setFile( s ); | 878 | lnk.setFile( s ); |
894 | } else { //if its a url | 879 | } else { //if its a url |
895 | // if( name.right( 1 ).find( '/' ) == -1) { | 880 | // if( name.right( 1 ).find( '/' ) == -1) { |
896 | // s += "/"; | 881 | // s += "/"; |
897 | // } | 882 | // } |
898 | lnk.setFile( s ); | 883 | lnk.setFile( s ); |
899 | } | 884 | } |
900 | lnk.setType( "audio/x-mpegurl" ); | 885 | lnk.setType( "audio/x-mpegurl" ); |
901 | 886 | ||
902 | lnk.writeLink(); | 887 | lnk.writeLink(); |
903 | d->selectedFiles->addToSelection( lnk ); | 888 | d->selectedFiles->addToSelection( lnk ); |
904 | } | 889 | } |
905 | 890 | ||
906 | m3uList->close(); | 891 | m3uList->close(); |
907 | if(m3uList) delete m3uList; | 892 | if(m3uList) delete m3uList; |
908 | } | 893 | } |
909 | 894 | ||
910 | /* | 895 | /* |
911 | writes current playlist to current m3u file */ | 896 | writes current playlist to current m3u file */ |
912 | void PlayListWidget::writeCurrentM3u() { | 897 | void PlayListWidget::writeCurrentM3u() { |
913 | qDebug("writing to current m3u"); | 898 | qDebug("writing to current m3u"); |
914 | Config cfg( "OpiePlayer" ); | 899 | Config cfg( "OpiePlayer" ); |
915 | cfg.setGroup("PlayList"); | 900 | cfg.setGroup("PlayList"); |
916 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 901 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
917 | 902 | ||
918 | Om3u *m3uList; | 903 | Om3u *m3uList; |
919 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 904 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
920 | if( d->selectedFiles->first()) { | 905 | if( d->selectedFiles->first()) { |
921 | 906 | ||
922 | do { | 907 | do { |
923 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); | 908 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); |
924 | m3uList->add( d->selectedFiles->current()->file() ); | 909 | m3uList->add( d->selectedFiles->current()->file() ); |
925 | } | 910 | } |
926 | while ( d->selectedFiles->next() ); | 911 | while ( d->selectedFiles->next() ); |
927 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 912 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
928 | m3uList->write(); | 913 | m3uList->write(); |
929 | m3uList->close(); | 914 | m3uList->close(); |
930 | 915 | ||
931 | if(m3uList) delete m3uList; | 916 | if(m3uList) delete m3uList; |
932 | } | 917 | } |
933 | 918 | ||
934 | } | 919 | } |
935 | 920 | ||
936 | /* | 921 | /* |
937 | writes current playlist to m3u file */ | 922 | writes current playlist to m3u file */ |
938 | void PlayListWidget::writem3u() { | 923 | void PlayListWidget::writem3u() { |
939 | InputDialog *fileDlg; | 924 | InputDialog *fileDlg; |
940 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 925 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
941 | fileDlg->exec(); | 926 | fileDlg->exec(); |
942 | QString name, filename, list; | 927 | QString name, filename, list; |
943 | Om3u *m3uList; | 928 | Om3u *m3uList; |
944 | 929 | ||
945 | if( fileDlg->result() == 1 ) { | 930 | if( fileDlg->result() == 1 ) { |
946 | name = fileDlg->text(); | 931 | name = fileDlg->text(); |
947 | // qDebug( filename ); | 932 | // qDebug( filename ); |
948 | 933 | ||
949 | if( name.left( 1) != "/" ) { | 934 | if( name.left( 1) != "/" ) { |
950 | filename = QPEApplication::documentDir() + "/" + name; | 935 | filename = QPEApplication::documentDir() + "/" + name; |
951 | } | 936 | } |
952 | 937 | ||
953 | if( name.right( 3 ) != "m3u" ) { | 938 | if( name.right( 3 ) != "m3u" ) { |
954 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; | 939 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; |
955 | } | 940 | } |
956 | 941 | ||
957 | if( d->selectedFiles->first()) { | 942 | if( d->selectedFiles->first()) { |
958 | m3uList = new Om3u(filename, IO_ReadWrite); | 943 | m3uList = new Om3u(filename, IO_ReadWrite); |
959 | 944 | ||
960 | do { | 945 | do { |
961 | m3uList->add( d->selectedFiles->current()->file()); | 946 | m3uList->add( d->selectedFiles->current()->file()); |
962 | } | 947 | } |
963 | while ( d->selectedFiles->next() ); | 948 | while ( d->selectedFiles->next() ); |
964 | // qDebug( list ); | 949 | // qDebug( list ); |
965 | m3uList->write(); | 950 | m3uList->write(); |
966 | m3uList->close(); | 951 | m3uList->close(); |
967 | if(m3uList) delete m3uList; | 952 | if(m3uList) delete m3uList; |
968 | 953 | ||
969 | if(fileDlg) delete fileDlg; | 954 | if(fileDlg) delete fileDlg; |
970 | 955 | ||
971 | DocLnk lnk; | 956 | DocLnk lnk; |
972 | lnk.setFile( filename); | 957 | lnk.setFile( filename); |
973 | lnk.setIcon("opieplayer2/playlist2"); | 958 | lnk.setIcon("opieplayer2/playlist2"); |
974 | lnk.setName( name); //sets file name | 959 | lnk.setName( name); //sets file name |
975 | 960 | ||
976 | // qDebug(filename); | 961 | // qDebug(filename); |
977 | Config config( "OpiePlayer" ); | 962 | Config config( "OpiePlayer" ); |
978 | config.setGroup( "PlayList" ); | 963 | config.setGroup( "PlayList" ); |
979 | 964 | ||
980 | config.writeEntry("CurrentPlaylist",filename); | 965 | config.writeEntry("CurrentPlaylist",filename); |
981 | currentPlayList=filename; | 966 | currentPlayList=filename; |
982 | 967 | ||
983 | if(!lnk.writeLink()) { | 968 | if(!lnk.writeLink()) { |
984 | qDebug("Writing doclink did not work"); | 969 | qDebug("Writing doclink did not work"); |
985 | } | 970 | } |
986 | 971 | ||
987 | setCaption(tr("OpiePlayer: ") + name); | 972 | setCaption(tr("OpiePlayer: ") + name); |
988 | } | 973 | } |
989 | } | 974 | } |
990 | } | 975 | } |
991 | 976 | ||
992 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | 977 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { |
993 | switch ( e->key() ) { | 978 | switch ( e->key() ) { |
994 | ////////////////////////////// Zaurus keys | 979 | ////////////////////////////// Zaurus keys |
995 | case Key_F9: //activity | 980 | case Key_F9: //activity |
996 | // if(audioUI->isHidden()) | 981 | // if(audioUI->isHidden()) |
997 | // audioUI->showMaximized(); | 982 | // audioUI->showMaximized(); |
998 | break; | 983 | break; |
999 | case Key_F10: //contacts | 984 | case Key_F10: //contacts |
1000 | // if( videoUI->isHidden()) | 985 | // if( videoUI->isHidden()) |
1001 | // videoUI->showMaximized(); | 986 | // videoUI->showMaximized(); |
1002 | break; | 987 | break; |
1003 | case Key_F11: //menu | 988 | case Key_F11: //menu |
1004 | break; | 989 | break; |
1005 | case Key_F12: //home | 990 | case Key_F12: //home |
1006 | // doBlank(); | 991 | // doBlank(); |
1007 | break; | 992 | break; |
1008 | case Key_F13: //mail | 993 | case Key_F13: //mail |
1009 | // doUnblank(); | 994 | // doUnblank(); |
1010 | break; | 995 | break; |
1011 | case Key_Q: //add to playlist | 996 | case Key_Q: //add to playlist |
1012 | addSelected(); | 997 | addSelected(); |
1013 | break; | 998 | break; |
1014 | case Key_R: //remove from playlist | 999 | case Key_R: //remove from playlist |
1015 | removeSelected(); | 1000 | removeSelected(); |
1016 | break; | 1001 | break; |
1017 | // case Key_P: //play | 1002 | // case Key_P: //play |
1018 | // qDebug("Play"); | 1003 | // qDebug("Play"); |
1019 | // playSelected(); | 1004 | // playSelected(); |
1020 | // break; | 1005 | // break; |
1021 | case Key_Space: | 1006 | case Key_Space: |
1022 | // playSelected(); puh | 1007 | // playSelected(); puh |
1023 | break; | 1008 | break; |
1024 | case Key_1: | 1009 | case Key_1: |
1025 | tabWidget->setCurrentPage( 0 ); | 1010 | tabWidget->setCurrentPage( 0 ); |
1026 | break; | 1011 | break; |
1027 | case Key_2: | 1012 | case Key_2: |
1028 | tabWidget->setCurrentPage( 1 ); | 1013 | tabWidget->setCurrentPage( 1 ); |
1029 | break; | 1014 | break; |
1030 | case Key_3: | 1015 | case Key_3: |
1031 | tabWidget->setCurrentPage( 2 ); | 1016 | tabWidget->setCurrentPage( 2 ); |
1032 | break; | 1017 | break; |
1033 | case Key_4: | 1018 | case Key_4: |
1034 | tabWidget->setCurrentPage( 3 ); | 1019 | tabWidget->setCurrentPage( 3 ); |
1035 | break; | 1020 | break; |
1036 | case Key_Down: | 1021 | case Key_Down: |
1037 | if ( !d->selectedFiles->next() ) | 1022 | if ( !d->selectedFiles->next() ) |
1038 | d->selectedFiles->first(); | 1023 | d->selectedFiles->first(); |
1039 | break; | 1024 | break; |
1040 | case Key_Up: | 1025 | case Key_Up: |
1041 | if ( !d->selectedFiles->prev() ) | 1026 | if ( !d->selectedFiles->prev() ) |
1042 | // d->selectedFiles->last(); | 1027 | // d->selectedFiles->last(); |
1043 | break; | 1028 | break; |
1044 | } | 1029 | } |
1045 | } | 1030 | } |
1046 | 1031 | ||
1047 | void PlayListWidget::pmViewActivated(int index) { | 1032 | void PlayListWidget::pmViewActivated(int index) { |
1048 | // qDebug("%d", index); | 1033 | // qDebug("%d", index); |
1049 | switch(index) { | 1034 | switch(index) { |
1050 | case -16: | 1035 | case -16: |
1051 | { | 1036 | { |
1052 | mediaPlayerState.toggleFullscreen(); | 1037 | mediaPlayerState.toggleFullscreen(); |
1053 | bool b=mediaPlayerState.isFullscreen(); | 1038 | bool b=mediaPlayerState.isFullscreen(); |
1054 | pmView->setItemChecked( index, b); | 1039 | pmView->setItemChecked( index, b); |
1055 | Config cfg( "OpiePlayer" ); | 1040 | Config cfg( "OpiePlayer" ); |
1056 | cfg.writeEntry( "FullScreen", b ); | 1041 | cfg.writeEntry( "FullScreen", b ); |
1057 | } | 1042 | } |
1058 | break; | 1043 | break; |
1059 | }; | 1044 | }; |
1060 | } | 1045 | } |
1061 | 1046 | ||
1062 | void PlayListWidget::populateSkinsMenu() { | 1047 | void PlayListWidget::populateSkinsMenu() { |
1063 | int item = 0; | 1048 | int item = 0; |
1064 | defaultSkinIndex = 0; | 1049 | defaultSkinIndex = 0; |
1065 | QString skinName; | 1050 | QString skinName; |
1066 | Config cfg( "OpiePlayer" ); | 1051 | Config cfg( "OpiePlayer" ); |
1067 | cfg.setGroup("Options" ); | 1052 | cfg.setGroup("Options" ); |
1068 | QString skin = cfg.readEntry( "Skin", "default" ); | 1053 | QString skin = cfg.readEntry( "Skin", "default" ); |
1069 | 1054 | ||
1070 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 1055 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
1071 | skinsDir.setFilter( QDir::Dirs ); | 1056 | skinsDir.setFilter( QDir::Dirs ); |
1072 | skinsDir.setSorting(QDir::Name ); | 1057 | skinsDir.setSorting(QDir::Name ); |
1073 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 1058 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
1074 | QFileInfoListIterator it( *skinslist ); | 1059 | QFileInfoListIterator it( *skinslist ); |
1075 | QFileInfo *fi; | 1060 | QFileInfo *fi; |
1076 | while ( ( fi = it.current() ) ) { | 1061 | while ( ( fi = it.current() ) ) { |
1077 | skinName = fi->fileName(); | 1062 | skinName = fi->fileName(); |
1078 | // qDebug( fi->fileName() ); | 1063 | // qDebug( fi->fileName() ); |
1079 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 1064 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
1080 | item = skinsMenu->insertItem( fi->fileName() ) ; | 1065 | item = skinsMenu->insertItem( fi->fileName() ) ; |
1081 | } | 1066 | } |
1082 | if( skinName == "default" ) { | 1067 | if( skinName == "default" ) { |
1083 | defaultSkinIndex = item; | 1068 | defaultSkinIndex = item; |
1084 | } | 1069 | } |
1085 | if( skinName == skin ) { | 1070 | if( skinName == skin ) { |
1086 | skinsMenu->setItemChecked( item, TRUE ); | 1071 | skinsMenu->setItemChecked( item, TRUE ); |
1087 | } | 1072 | } |
1088 | ++it; | 1073 | ++it; |
1089 | } | 1074 | } |
1090 | } | 1075 | } |
1091 | 1076 | ||
1092 | void PlayListWidget::skinsMenuActivated( int item ) { | 1077 | void PlayListWidget::skinsMenuActivated( int item ) { |
1093 | for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { | 1078 | for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { |
1094 | skinsMenu->setItemChecked( i, FALSE ); | 1079 | skinsMenu->setItemChecked( i, FALSE ); |
1095 | } | 1080 | } |
1096 | skinsMenu->setItemChecked( item, TRUE ); | 1081 | skinsMenu->setItemChecked( item, TRUE ); |
1097 | 1082 | ||
1098 | { | 1083 | { |
1099 | Config cfg( "OpiePlayer" ); | 1084 | Config cfg( "OpiePlayer" ); |
1100 | cfg.setGroup("Options"); | 1085 | cfg.setGroup("Options"); |
1101 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 1086 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
1102 | } | 1087 | } |
1103 | 1088 | ||
1104 | emit skinSelected(); | 1089 | emit skinSelected(); |
1105 | } | 1090 | } |
1106 | 1091 | ||
1107 | PlayListWidget::TabType PlayListWidget::currentTab() const | 1092 | PlayListWidget::TabType PlayListWidget::currentTab() const |
1108 | { | 1093 | { |
1109 | static const TabType indexToTabType[ TabTypeCount ] = | 1094 | static const TabType indexToTabType[ TabTypeCount ] = |
1110 | { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; | 1095 | { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; |
1111 | 1096 | ||
1112 | int index = tabWidget->currentPageIndex(); | 1097 | int index = tabWidget->currentPageIndex(); |
1113 | assert( index < TabTypeCount && index >= 0 ); | 1098 | assert( index < TabTypeCount && index >= 0 ); |
1114 | 1099 | ||
1115 | return indexToTabType[ index ]; | 1100 | return indexToTabType[ index ]; |
1116 | } | 1101 | } |
1117 | 1102 | ||
1118 | PlayListWidget::Entry PlayListWidget::currentEntry() const | 1103 | PlayListWidget::Entry PlayListWidget::currentEntry() const |
1119 | { | 1104 | { |
1120 | if ( currentTab() == CurrentPlayList ) { | 1105 | if ( currentTab() == CurrentPlayList ) { |
1121 | const DocLnk *lnk = current(); | 1106 | const DocLnk *lnk = current(); |
1122 | return Entry( lnk->name(), lnk->file() ); | 1107 | return Entry( lnk->name(), lnk->file() ); |
1123 | } | 1108 | } |
1124 | 1109 | ||
1125 | return Entry( currentFileListPathName() ); | 1110 | return Entry( currentFileListPathName() ); |
1126 | } | 1111 | } |
1127 | 1112 | ||
1128 | QString PlayListWidget::currentFileListPathName() const { | 1113 | QString PlayListWidget::currentFileListPathName() const { |
1129 | return currentFileListView()->currentItem()->text( 3 ); | 1114 | return currentFileListView()->currentItem()->text( 3 ); |
1130 | } | 1115 | } |
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h index 62d78a2..e81ef3c 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.h +++ b/noncore/multimedia/opieplayer2/playlistwidget.h | |||
@@ -1,146 +1,144 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
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; |
48 | class Config; | 48 | class Config; |
49 | class QListViewItem; | 49 | class QListViewItem; |
50 | class QListView; | 50 | class QListView; |
51 | class QPoint; | 51 | class QPoint; |
52 | class QAction; | 52 | class QAction; |
53 | class QLabel; | 53 | class QLabel; |
54 | 54 | ||
55 | class PlayListWidget : public PlayListWidgetGui { | 55 | class PlayListWidget : public PlayListWidgetGui { |
56 | Q_OBJECT | 56 | Q_OBJECT |
57 | public: | 57 | public: |
58 | enum TabType { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; | 58 | enum TabType { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; |
59 | enum { TabTypeCount = 4 }; | 59 | enum { TabTypeCount = 4 }; |
60 | 60 | ||
61 | struct Entry | 61 | struct Entry |
62 | { | 62 | { |
63 | Entry( const QString &_name, const QString &_fileName ) | 63 | Entry( const QString &_name, const QString &_fileName ) |
64 | : name( _name ), file( _fileName ) {} | 64 | : name( _name ), file( _fileName ) {} |
65 | Entry( const QString &_fileName ) | 65 | Entry( const QString &_fileName ) |
66 | : name( _fileName ), file( _fileName ) {} | 66 | : name( _fileName ), file( _fileName ) {} |
67 | 67 | ||
68 | QString name; | 68 | QString name; |
69 | QString file; | 69 | QString file; |
70 | }; | 70 | }; |
71 | 71 | ||
72 | PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); | 72 | PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); |
73 | ~PlayListWidget(); | 73 | ~PlayListWidget(); |
74 | 74 | ||
75 | // retrieve the current playlist entry (media file link) | 75 | // retrieve the current playlist entry (media file link) |
76 | const DocLnk *current() const; | 76 | const DocLnk *current() const; |
77 | void useSelectedDocument(); | 77 | void useSelectedDocument(); |
78 | TabType currentTab() const; | 78 | TabType currentTab() const; |
79 | 79 | ||
80 | Entry currentEntry() const; | 80 | Entry currentEntry() const; |
81 | 81 | ||
82 | public slots: | 82 | public slots: |
83 | bool first(); | 83 | bool first(); |
84 | bool last(); | 84 | bool last(); |
85 | bool next(); | 85 | bool next(); |
86 | bool prev(); | 86 | bool prev(); |
87 | void writeDefaultPlaylist( ); | 87 | void writeDefaultPlaylist( ); |
88 | QString currentFileListPathName() const; | 88 | QString currentFileListPathName() const; |
89 | protected: | 89 | protected: |
90 | void keyReleaseEvent( QKeyEvent *e); | 90 | void keyReleaseEvent( QKeyEvent *e); |
91 | 91 | ||
92 | signals: | 92 | signals: |
93 | void skinSelected(); | 93 | void skinSelected(); |
94 | 94 | ||
95 | private: | 95 | private: |
96 | int defaultSkinIndex; | 96 | int defaultSkinIndex; |
97 | bool audioScan, videoScan, audioPopulated, videoPopulated; | 97 | bool audioScan, videoScan, audioPopulated, videoPopulated; |
98 | void readm3u(const QString &); | 98 | void readm3u(const QString &); |
99 | void readPls(const QString &); | 99 | void readPls(const QString &); |
100 | void initializeStates(); | 100 | void initializeStates(); |
101 | void populateAudioView(); | 101 | void populateAudioView(); |
102 | void populateVideoView(); | 102 | void populateVideoView(); |
103 | 103 | ||
104 | QListView *currentFileListView() const; | 104 | QListView *currentFileListView() const; |
105 | 105 | ||
106 | bool inFileListMode() const; | 106 | bool inFileListMode() const; |
107 | 107 | ||
108 | private slots: | 108 | private slots: |
109 | void populateSkinsMenu(); | 109 | void populateSkinsMenu(); |
110 | void skinsMenuActivated(int); | 110 | void skinsMenuActivated(int); |
111 | void pmViewActivated(int); | 111 | void pmViewActivated(int); |
112 | void writem3u(); | 112 | void writem3u(); |
113 | void writeCurrentM3u(); | 113 | void writeCurrentM3u(); |
114 | void scanForAudio(); | 114 | void scanForAudio(); |
115 | void scanForVideo(); | 115 | void scanForVideo(); |
116 | void openFile(); | 116 | void openFile(); |
117 | void setDocument( const QString& fileref ); | 117 | void setDocument( const QString& fileref ); |
118 | void addToSelection( const DocLnk& ); // Add a media file to the playlist | 118 | void addToSelection( const DocLnk& ); // Add a media file to the playlist |
119 | void addToSelection( QListViewItem* ); // Add a media file to the playlist | 119 | void addToSelection( QListViewItem* ); // Add a media file to the playlist |
120 | void clearList(); | 120 | void clearList(); |
121 | void addAllToList(); | 121 | void addAllToList(); |
122 | void addAllMusicToList(); | 122 | void addAllMusicToList(); |
123 | void addAllVideoToList(); | 123 | void addAllVideoToList(); |
124 | void saveList(); // Save the playlist | 124 | void saveList(); // Save the playlist |
125 | void loadList( const DocLnk &); // Load a playlist | 125 | void loadList( const DocLnk &); // Load a playlist |
126 | void playIt( QListViewItem *); | 126 | void playIt( QListViewItem *); |
127 | void btnPlay(bool); | 127 | void btnPlay(bool); |
128 | void deletePlaylist(); | 128 | void deletePlaylist(); |
129 | void addSelected(); | 129 | void addSelected(); |
130 | void removeSelected(); | 130 | void removeSelected(); |
131 | void tabChanged(QWidget*); | 131 | void tabChanged(QWidget*); |
132 | void viewPressed( int, QListViewItem *, const QPoint&, int); | 132 | void viewPressed( int, QListViewItem *, const QPoint&, int); |
133 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); | 133 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); |
134 | void playSelected(); | 134 | void playSelected(); |
135 | 135 | ||
136 | private: | 136 | private: |
137 | DocLnkSet files; | ||
138 | DocLnkSet vFiles; | ||
139 | bool fromSetDocument; | 137 | bool fromSetDocument; |
140 | bool insanityBool; | 138 | bool insanityBool; |
141 | QString setDocFileRef, currentPlayList; | 139 | QString setDocFileRef, currentPlayList; |
142 | int selected; | 140 | int selected; |
143 | }; | 141 | }; |
144 | 142 | ||
145 | #endif // PLAY_LIST_WIDGET_H | 143 | #endif // PLAY_LIST_WIDGET_H |
146 | 144 | ||
diff --git a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp index cfca5e3..a219cfd 100644 --- a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp | |||
@@ -1,207 +1,208 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
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 | #include <qpe/qpemenubar.h> | 34 | #include <qpe/qpemenubar.h> |
35 | #include <qpe/qpetoolbar.h> | 35 | #include <qpe/qpetoolbar.h> |
36 | #include <qpe/fileselector.h> | 36 | #include <qpe/fileselector.h> |
37 | #include <qpe/qpeapplication.h> | 37 | #include <qpe/qpeapplication.h> |
38 | #include <qpe/storage.h> | 38 | #include <qpe/storage.h> |
39 | #include <qpe/mimetype.h> | 39 | #include <qpe/mimetype.h> |
40 | #include <qpe/config.h> | 40 | #include <qpe/config.h> |
41 | #include <qpe/global.h> | 41 | #include <qpe/global.h> |
42 | #include <qpe/resource.h> | 42 | #include <qpe/resource.h> |
43 | 43 | ||
44 | #include <qpopupmenu.h> | 44 | #include <qpopupmenu.h> |
45 | #include <qaction.h> | 45 | #include <qaction.h> |
46 | #include <qcursor.h> | 46 | #include <qcursor.h> |
47 | #include <qdir.h> | 47 | #include <qdir.h> |
48 | #include <qlayout.h> | 48 | #include <qlayout.h> |
49 | 49 | ||
50 | #include "playlistselection.h" | 50 | #include "playlistselection.h" |
51 | #include "playlistwidget.h" | 51 | #include "playlistwidget.h" |
52 | #include "mediaplayerstate.h" | 52 | #include "mediaplayerstate.h" |
53 | #include "inputDialog.h" | 53 | #include "inputDialog.h" |
54 | #include "playlistfileview.h" | 54 | #include "playlistfileview.h" |
55 | 55 | ||
56 | //only needed for the random play | 56 | //only needed for the random play |
57 | #include <stdlib.h> | 57 | #include <stdlib.h> |
58 | 58 | ||
59 | #include "audiowidget.h" | 59 | #include "audiowidget.h" |
60 | #include "videowidget.h" | 60 | #include "videowidget.h" |
61 | #include "mediaplayerstate.h" | 61 | #include "mediaplayerstate.h" |
62 | 62 | ||
63 | PlayListWidgetGui::PlayListWidgetGui( MediaPlayerState &_mediaPlayerState, QWidget* parent, const char* name ) | 63 | PlayListWidgetGui::PlayListWidgetGui( MediaPlayerState &_mediaPlayerState, QWidget* parent, const char* name ) |
64 | : QMainWindow( parent, name ), mediaPlayerState( _mediaPlayerState ) { | 64 | : QMainWindow( parent, name ), mediaPlayerState( _mediaPlayerState ) { |
65 | 65 | ||
66 | d = new PlayListWidgetPrivate; | 66 | d = new PlayListWidgetPrivate; |
67 | d->setDocumentUsed = FALSE; | 67 | d->setDocumentUsed = FALSE; |
68 | 68 | ||
69 | setBackgroundMode( PaletteButton ); | 69 | setBackgroundMode( PaletteButton ); |
70 | setToolBarsMovable( FALSE ); | 70 | setToolBarsMovable( FALSE ); |
71 | 71 | ||
72 | // Create Toolbar | 72 | // Create Toolbar |
73 | QPEToolBar *toolbar = new QPEToolBar( this ); | 73 | QPEToolBar *toolbar = new QPEToolBar( this ); |
74 | toolbar->setHorizontalStretchable( TRUE ); | 74 | toolbar->setHorizontalStretchable( TRUE ); |
75 | 75 | ||
76 | // Create Menubar | 76 | // Create Menubar |
77 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); | 77 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); |
78 | menu->setMargin( 0 ); | 78 | menu->setMargin( 0 ); |
79 | 79 | ||
80 | bar = new QPEToolBar( this ); | 80 | bar = new QPEToolBar( this ); |
81 | bar->setLabel( tr( "Play Operations" ) ); | 81 | bar->setLabel( tr( "Play Operations" ) ); |
82 | 82 | ||
83 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet( "trash" ), "", bar, "close" ); | 83 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet( "trash" ), "", bar, "close" ); |
84 | tbDeletePlaylist->setFlat( TRUE ); | 84 | tbDeletePlaylist->setFlat( TRUE ); |
85 | tbDeletePlaylist->setFixedSize( 20, 20 ); | 85 | tbDeletePlaylist->setFixedSize( 20, 20 ); |
86 | 86 | ||
87 | tbDeletePlaylist->hide(); | 87 | tbDeletePlaylist->hide(); |
88 | 88 | ||
89 | pmPlayList = new QPopupMenu( this ); | 89 | pmPlayList = new QPopupMenu( this ); |
90 | menu->insertItem( tr( "File" ), pmPlayList ); | 90 | menu->insertItem( tr( "File" ), pmPlayList ); |
91 | 91 | ||
92 | pmView = new QPopupMenu( this ); | 92 | pmView = new QPopupMenu( this ); |
93 | menu->insertItem( tr( "View" ), pmView ); | 93 | menu->insertItem( tr( "View" ), pmView ); |
94 | pmView->isCheckable(); | 94 | pmView->isCheckable(); |
95 | 95 | ||
96 | skinsMenu = new QPopupMenu( this ); | 96 | skinsMenu = new QPopupMenu( this ); |
97 | pmView->insertItem( tr( "Skins" ), skinsMenu ); | 97 | pmView->insertItem( tr( "Skins" ), skinsMenu ); |
98 | skinsMenu->isCheckable(); | 98 | skinsMenu->isCheckable(); |
99 | 99 | ||
100 | gammaMenu = new QPopupMenu( this ); | 100 | gammaMenu = new QPopupMenu( this ); |
101 | pmView->insertItem( tr( "Gamma (Video)" ), gammaMenu ); | 101 | pmView->insertItem( tr( "Gamma (Video)" ), gammaMenu ); |
102 | 102 | ||
103 | gammaSlider = new QSlider( QSlider::Vertical, gammaMenu ); | 103 | gammaSlider = new QSlider( QSlider::Vertical, gammaMenu ); |
104 | gammaSlider->setRange( -40, 40 ); | 104 | gammaSlider->setRange( -40, 40 ); |
105 | gammaSlider->setTickmarks( QSlider::Left ); | 105 | gammaSlider->setTickmarks( QSlider::Left ); |
106 | gammaSlider->setTickInterval( 20 ); | 106 | gammaSlider->setTickInterval( 20 ); |
107 | gammaSlider->setFocusPolicy( QWidget::StrongFocus ); | 107 | gammaSlider->setFocusPolicy( QWidget::StrongFocus ); |
108 | gammaSlider->setValue( 0 ); | 108 | gammaSlider->setValue( 0 ); |
109 | gammaSlider->setMinimumHeight( 50 ); | 109 | gammaSlider->setMinimumHeight( 50 ); |
110 | 110 | ||
111 | gammaLCD = new QLCDNumber( 3, gammaMenu ); | 111 | gammaLCD = new QLCDNumber( 3, gammaMenu ); |
112 | gammaLCD-> setFrameShape ( QFrame::NoFrame ); | 112 | gammaLCD-> setFrameShape ( QFrame::NoFrame ); |
113 | gammaLCD-> setSegmentStyle ( QLCDNumber::Flat ); | 113 | gammaLCD-> setSegmentStyle ( QLCDNumber::Flat ); |
114 | 114 | ||
115 | gammaMenu->insertItem( gammaSlider ); | 115 | gammaMenu->insertItem( gammaSlider ); |
116 | gammaMenu->insertItem( gammaLCD ); | 116 | gammaMenu->insertItem( gammaLCD ); |
117 | 117 | ||
118 | connect( gammaSlider, SIGNAL( valueChanged( int ) ), gammaLCD, SLOT( display( int ) ) ); | 118 | connect( gammaSlider, SIGNAL( valueChanged( int ) ), gammaLCD, SLOT( display( int ) ) ); |
119 | 119 | ||
120 | vbox5 = new QVBox( this ); | 120 | vbox5 = new QVBox( this ); |
121 | QVBox *vbox4 = new QVBox( vbox5 ); | 121 | QVBox *vbox4 = new QVBox( vbox5 ); |
122 | QHBox *hbox6 = new QHBox( vbox4 ); | 122 | QHBox *hbox6 = new QHBox( vbox4 ); |
123 | 123 | ||
124 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 124 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
125 | 125 | ||
126 | QWidget *pTab; | 126 | QWidget *pTab; |
127 | pTab = new QWidget( tabWidget, "pTab" ); | 127 | pTab = new QWidget( tabWidget, "pTab" ); |
128 | tabWidget->insertTab( pTab, "Playlist"); | 128 | tabWidget->insertTab( pTab, "Playlist"); |
129 | 129 | ||
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 | audioView = new PlayListFileView( aTab, "Audioview" ); | 153 | // no m3u's here please |
154 | audioView = new PlayListFileView( "audio/mpeg;audio/x-wav;audio/x-ogg", aTab, "Audioview" ); | ||
154 | Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 ); | 155 | Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 ); |
155 | tabWidget->insertTab( aTab, tr( "Audio" ) ); | 156 | tabWidget->insertTab( aTab, tr( "Audio" ) ); |
156 | 157 | ||
157 | QPEApplication::setStylusOperation( audioView->viewport(), QPEApplication::RightOnHold ); | 158 | QPEApplication::setStylusOperation( audioView->viewport(), QPEApplication::RightOnHold ); |
158 | 159 | ||
159 | QWidget *vTab; | 160 | QWidget *vTab; |
160 | vTab = new QWidget( tabWidget, "vTab" ); | 161 | vTab = new QWidget( tabWidget, "vTab" ); |
161 | 162 | ||
162 | QGridLayout *Vlayout = new QGridLayout( vTab ); | 163 | QGridLayout *Vlayout = new QGridLayout( vTab ); |
163 | Vlayout->setSpacing( 2 ); | 164 | Vlayout->setSpacing( 2 ); |
164 | Vlayout->setMargin( 2 ); | 165 | Vlayout->setMargin( 2 ); |
165 | videoView = new PlayListFileView( vTab, "Videoview" ); | 166 | videoView = new PlayListFileView( "video/*", vTab, "Videoview" ); |
166 | Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 ); | 167 | Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 ); |
167 | 168 | ||
168 | QPEApplication::setStylusOperation( videoView->viewport(), QPEApplication::RightOnHold ); | 169 | QPEApplication::setStylusOperation( videoView->viewport(), QPEApplication::RightOnHold ); |
169 | 170 | ||
170 | tabWidget->insertTab( vTab, tr( "Video" ) ); | 171 | tabWidget->insertTab( vTab, tr( "Video" ) ); |
171 | 172 | ||
172 | //playlists list | 173 | //playlists list |
173 | QWidget *LTab; | 174 | QWidget *LTab; |
174 | LTab = new QWidget( tabWidget, "LTab" ); | 175 | LTab = new QWidget( tabWidget, "LTab" ); |
175 | QGridLayout *Llayout = new QGridLayout( LTab ); | 176 | QGridLayout *Llayout = new QGridLayout( LTab ); |
176 | Llayout->setSpacing( 2 ); | 177 | Llayout->setSpacing( 2 ); |
177 | Llayout->setMargin( 2 ); | 178 | Llayout->setMargin( 2 ); |
178 | 179 | ||
179 | 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 ); |
180 | Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 ); | 181 | Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 ); |
181 | 182 | ||
182 | tabWidget->insertTab( LTab, tr( "Lists" ) ); | 183 | tabWidget->insertTab( LTab, tr( "Lists" ) ); |
183 | 184 | ||
184 | setCentralWidget( vbox5 ); | 185 | setCentralWidget( vbox5 ); |
185 | } | 186 | } |
186 | 187 | ||
187 | 188 | ||
188 | 189 | ||
189 | PlayListWidgetGui::~PlayListWidgetGui() { | 190 | PlayListWidgetGui::~PlayListWidgetGui() { |
190 | } | 191 | } |
191 | 192 | ||
192 | void PlayListWidgetGui::setView( char view ) { | 193 | void PlayListWidgetGui::setView( char view ) { |
193 | if ( view == 'l' ) | 194 | if ( view == 'l' ) |
194 | showMaximized(); | 195 | showMaximized(); |
195 | else | 196 | else |
196 | hide(); | 197 | hide(); |
197 | } | 198 | } |
198 | 199 | ||
199 | 200 | ||
200 | void PlayListWidgetGui::setActiveWindow() { | 201 | void PlayListWidgetGui::setActiveWindow() { |
201 | // qDebug("SETTING active window"); | 202 | // qDebug("SETTING active window"); |
202 | // When we get raised we need to ensure that it switches views | 203 | // When we get raised we need to ensure that it switches views |
203 | MediaPlayerState::DisplayType origDisplayType = mediaPlayerState.displayType(); | 204 | MediaPlayerState::DisplayType origDisplayType = mediaPlayerState.displayType(); |
204 | mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); // invalidate | 205 | mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); // invalidate |
205 | mediaPlayerState.setDisplayType( origDisplayType ); // now switch back | 206 | mediaPlayerState.setDisplayType( origDisplayType ); // now switch back |
206 | } | 207 | } |
207 | 208 | ||
diff --git a/noncore/multimedia/opieplayer2/playlistwidgetgui.h b/noncore/multimedia/opieplayer2/playlistwidgetgui.h index 9b5252a..0d8af43 100644 --- a/noncore/multimedia/opieplayer2/playlistwidgetgui.h +++ b/noncore/multimedia/opieplayer2/playlistwidgetgui.h | |||
@@ -1,130 +1,132 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
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_GUI_H | 34 | #ifndef PLAY_LIST_WIDGET_GUI_H |
35 | #define PLAY_LIST_WIDGET_GUI_H | 35 | #define PLAY_LIST_WIDGET_GUI_H |
36 | 36 | ||
37 | #include <qmainwindow.h> | 37 | #include <qmainwindow.h> |
38 | #include <qpe/applnk.h> | 38 | #include <qpe/applnk.h> |
39 | #include <qpe/resource.h> | 39 | #include <qpe/resource.h> |
40 | #include <qpe/qpemenubar.h> | 40 | #include <qpe/qpemenubar.h> |
41 | 41 | ||
42 | #include <qtabwidget.h> | 42 | #include <qtabwidget.h> |
43 | #include <qpe/fileselector.h> | 43 | #include <qpe/fileselector.h> |
44 | #include <qpushbutton.h> | 44 | #include <qpushbutton.h> |
45 | #include <qpopupmenu.h> | 45 | #include <qpopupmenu.h> |
46 | #include <qaction.h> | 46 | #include <qaction.h> |
47 | #include <qslider.h> | 47 | #include <qslider.h> |
48 | #include <qlcdnumber.h> | 48 | #include <qlcdnumber.h> |
49 | 49 | ||
50 | class PlayListWidgetPrivate; | 50 | class PlayListWidgetPrivate; |
51 | class PlayListSelection; | 51 | class PlayListSelection; |
52 | class MediaPlayerState; | 52 | class MediaPlayerState; |
53 | class PlayListFileView; | ||
53 | 54 | ||
54 | class Config; | 55 | class Config; |
55 | class QPEToolBar; | 56 | class QPEToolBar; |
56 | class QListViewItem; | 57 | class QListViewItem; |
57 | class QListView; | 58 | class QListView; |
58 | class QPoint; | 59 | class QPoint; |
59 | class QAction; | 60 | class QAction; |
60 | class QLabel; | 61 | class QLabel; |
61 | 62 | ||
62 | class PlayListWidgetPrivate { | 63 | class PlayListWidgetPrivate { |
63 | public: | 64 | public: |
64 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; | 65 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; |
65 | QFrame *playListFrame; | 66 | QFrame *playListFrame; |
66 | PlayListSelection *selectedFiles; | 67 | PlayListSelection *selectedFiles; |
67 | bool setDocumentUsed; | 68 | bool setDocumentUsed; |
68 | }; | 69 | }; |
69 | 70 | ||
70 | 71 | ||
71 | class ToolButton : public QToolButton { | 72 | class ToolButton : public QToolButton { |
72 | public: | 73 | public: |
73 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 74 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
74 | : QToolButton( parent, name ) { | 75 | : QToolButton( parent, name ) { |
75 | setTextLabel( name ); | 76 | setTextLabel( name ); |
76 | setPixmap( Resource::loadPixmap( icon ) ); | 77 | setPixmap( Resource::loadPixmap( icon ) ); |
77 | setAutoRaise( TRUE ); | 78 | setAutoRaise( TRUE ); |
78 | setFocusPolicy( QWidget::NoFocus ); | 79 | setFocusPolicy( QWidget::NoFocus ); |
79 | setToggleButton( t ); | 80 | setToggleButton( t ); |
80 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 81 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
81 | QPEMenuToolFocusManager::manager()->addWidget( this ); | 82 | QPEMenuToolFocusManager::manager()->addWidget( this ); |
82 | } | 83 | } |
83 | }; | 84 | }; |
84 | 85 | ||
85 | 86 | ||
86 | class MenuItem : public QAction { | 87 | class MenuItem : public QAction { |
87 | 88 | ||
88 | public: | 89 | public: |
89 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | 90 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) |
90 | : QAction( text, QString::null, 0, 0 ) { | 91 | : QAction( text, QString::null, 0, 0 ) { |
91 | connect( this, SIGNAL( activated() ), handler, slot ); | 92 | connect( this, SIGNAL( activated() ), handler, slot ); |
92 | addTo( parent ); | 93 | addTo( parent ); |
93 | } | 94 | } |
94 | }; | 95 | }; |
95 | 96 | ||
96 | class PlayListWidgetGui : public QMainWindow { | 97 | class PlayListWidgetGui : public QMainWindow { |
97 | Q_OBJECT | 98 | Q_OBJECT |
98 | public: | 99 | public: |
99 | PlayListWidgetGui( MediaPlayerState &_mediaPlayerState, QWidget* parent=0, const char* name=0 ); | 100 | PlayListWidgetGui( MediaPlayerState &_mediaPlayerState, QWidget* parent=0, const char* name=0 ); |
100 | ~PlayListWidgetGui(); | 101 | ~PlayListWidgetGui(); |
101 | 102 | ||
102 | protected: | 103 | protected: |
103 | QTabWidget * tabWidget; | 104 | QTabWidget * tabWidget; |
104 | QListView *audioView, *videoView, *playlistView; | 105 | PlayListFileView *audioView, *videoView; |
106 | QListView *playlistView; | ||
105 | QLabel *libString; | 107 | QLabel *libString; |
106 | QPopupMenu *pmView ; | 108 | QPopupMenu *pmView ; |
107 | QPopupMenu *gammaMenu; | 109 | QPopupMenu *gammaMenu; |
108 | QSlider *gammaSlider; | 110 | QSlider *gammaSlider; |
109 | QLCDNumber *gammaLCD; | 111 | QLCDNumber *gammaLCD; |
110 | bool fromSetDocument; | 112 | bool fromSetDocument; |
111 | bool insanityBool; | 113 | bool insanityBool; |
112 | QString setDocFileRef; | 114 | QString setDocFileRef; |
113 | // retrieve the current playlist entry (media file link) | 115 | // retrieve the current playlist entry (media file link) |
114 | QPushButton *tbDeletePlaylist; | 116 | QPushButton *tbDeletePlaylist; |
115 | int selected; | 117 | int selected; |
116 | QPopupMenu *pmPlayList; | 118 | QPopupMenu *pmPlayList; |
117 | FileSelector* playLists; | 119 | FileSelector* playLists; |
118 | QPopupMenu *skinsMenu; | 120 | QPopupMenu *skinsMenu; |
119 | PlayListWidgetPrivate *d; // Private implementation data | 121 | PlayListWidgetPrivate *d; // Private implementation data |
120 | QVBox *vbox1; | 122 | QVBox *vbox1; |
121 | QVBox *vbox5; | 123 | QVBox *vbox5; |
122 | QPEToolBar *bar; | 124 | QPEToolBar *bar; |
123 | void setActiveWindow(); // need to handle this to show the right view | 125 | void setActiveWindow(); // need to handle this to show the right view |
124 | void setView( char ); | 126 | void setView( char ); |
125 | 127 | ||
126 | MediaPlayerState &mediaPlayerState; | 128 | MediaPlayerState &mediaPlayerState; |
127 | }; | 129 | }; |
128 | 130 | ||
129 | #endif | 131 | #endif |
130 | 132 | ||