-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayerstate.cpp | 3 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayerstate.h | 1 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 92 |
3 files changed, 35 insertions, 61 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp index 43040c2..586870c 100644 --- a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp | |||
@@ -1,261 +1,258 @@ | |||
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 | // this file is based on work by trolltech | 34 | // this file is based on work by trolltech |
35 | 35 | ||
36 | #include <qpe/qpeapplication.h> | 36 | #include <qpe/qpeapplication.h> |
37 | #include <qpe/qlibrary.h> | 37 | #include <qpe/qlibrary.h> |
38 | #include <qpe/config.h> | 38 | #include <qpe/config.h> |
39 | #include <qvaluelist.h> | 39 | #include <qvaluelist.h> |
40 | #include <qobject.h> | 40 | #include <qobject.h> |
41 | #include <qdir.h> | 41 | #include <qdir.h> |
42 | #include "mediaplayerstate.h" | 42 | #include "mediaplayerstate.h" |
43 | 43 | ||
44 | 44 | ||
45 | 45 | ||
46 | //#define MediaPlayerDebug(x) qDebug x | 46 | //#define MediaPlayerDebug(x) qDebug x |
47 | #define MediaPlayerDebug(x) | 47 | #define MediaPlayerDebug(x) |
48 | 48 | ||
49 | 49 | ||
50 | MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) | 50 | MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) |
51 | : QObject( parent, name ) { | 51 | : QObject( parent, name ) { |
52 | Config cfg( "OpiePlayer" ); | 52 | Config cfg( "OpiePlayer" ); |
53 | readConfig( cfg ); | 53 | readConfig( cfg ); |
54 | streaming = false; | 54 | streaming = false; |
55 | seekable = true; | 55 | seekable = true; |
56 | } | 56 | } |
57 | 57 | ||
58 | 58 | ||
59 | MediaPlayerState::~MediaPlayerState() { | 59 | MediaPlayerState::~MediaPlayerState() { |
60 | } | 60 | } |
61 | 61 | ||
62 | 62 | ||
63 | void MediaPlayerState::readConfig( Config& cfg ) { | 63 | void MediaPlayerState::readConfig( Config& cfg ) { |
64 | cfg.setGroup("Options"); | 64 | cfg.setGroup("Options"); |
65 | fullscreen = cfg.readBoolEntry( "FullScreen" ); | 65 | fullscreen = cfg.readBoolEntry( "FullScreen" ); |
66 | scaled = cfg.readBoolEntry( "Scaling" ); | 66 | scaled = cfg.readBoolEntry( "Scaling" ); |
67 | looping = cfg.readBoolEntry( "Looping" ); | 67 | looping = cfg.readBoolEntry( "Looping" ); |
68 | shuffled = cfg.readBoolEntry( "Shuffle" ); | 68 | shuffled = cfg.readBoolEntry( "Shuffle" ); |
69 | usePlaylist = cfg.readBoolEntry( "UsePlayList" ); | ||
70 | videoGamma = cfg.readNumEntry( "VideoGamma" ); | 69 | videoGamma = cfg.readNumEntry( "VideoGamma" ); |
71 | usePlaylist = TRUE; | ||
72 | playing = FALSE; | 70 | playing = FALSE; |
73 | streaming = FALSE; | 71 | streaming = FALSE; |
74 | paused = FALSE; | 72 | paused = FALSE; |
75 | curPosition = 0; | 73 | curPosition = 0; |
76 | curLength = 0; | 74 | curLength = 0; |
77 | curView = 'l'; | 75 | curView = 'l'; |
78 | } | 76 | } |
79 | 77 | ||
80 | 78 | ||
81 | void MediaPlayerState::writeConfig( Config& cfg ) const { | 79 | void MediaPlayerState::writeConfig( Config& cfg ) const { |
82 | cfg.setGroup( "Options" ); | 80 | cfg.setGroup( "Options" ); |
83 | cfg.writeEntry( "FullScreen", fullscreen ); | 81 | cfg.writeEntry( "FullScreen", fullscreen ); |
84 | cfg.writeEntry( "Scaling", scaled ); | 82 | cfg.writeEntry( "Scaling", scaled ); |
85 | cfg.writeEntry( "Looping", looping ); | 83 | cfg.writeEntry( "Looping", looping ); |
86 | cfg.writeEntry( "Shuffle", shuffled ); | 84 | cfg.writeEntry( "Shuffle", shuffled ); |
87 | cfg.writeEntry( "UsePlayList", usePlaylist ); | ||
88 | cfg.writeEntry( "VideoGamma", videoGamma ); | 85 | cfg.writeEntry( "VideoGamma", videoGamma ); |
89 | } | 86 | } |
90 | 87 | ||
91 | // slots | 88 | // slots |
92 | void MediaPlayerState::setIsStreaming( bool b ) { | 89 | void MediaPlayerState::setIsStreaming( bool b ) { |
93 | streaming = b; | 90 | streaming = b; |
94 | } | 91 | } |
95 | 92 | ||
96 | void MediaPlayerState::setIsSeekable( bool b ) { | 93 | void MediaPlayerState::setIsSeekable( bool b ) { |
97 | seekable = b; | 94 | seekable = b; |
98 | emit isSeekableToggled(b); | 95 | emit isSeekableToggled(b); |
99 | } | 96 | } |
100 | 97 | ||
101 | 98 | ||
102 | void MediaPlayerState::setFullscreen( bool b ) { | 99 | void MediaPlayerState::setFullscreen( bool b ) { |
103 | if ( fullscreen == b ) { | 100 | if ( fullscreen == b ) { |
104 | return; | 101 | return; |
105 | } | 102 | } |
106 | fullscreen = b; | 103 | fullscreen = b; |
107 | emit fullscreenToggled(b); | 104 | emit fullscreenToggled(b); |
108 | } | 105 | } |
109 | 106 | ||
110 | 107 | ||
111 | void MediaPlayerState::setBlanked( bool b ) { | 108 | void MediaPlayerState::setBlanked( bool b ) { |
112 | if ( blanked == b ) { | 109 | if ( blanked == b ) { |
113 | return; | 110 | return; |
114 | } | 111 | } |
115 | blanked = b; | 112 | blanked = b; |
116 | emit blankToggled(b); | 113 | emit blankToggled(b); |
117 | } | 114 | } |
118 | 115 | ||
119 | 116 | ||
120 | void MediaPlayerState::setScaled( bool b ) { | 117 | void MediaPlayerState::setScaled( bool b ) { |
121 | if ( scaled == b ) { | 118 | if ( scaled == b ) { |
122 | return; | 119 | return; |
123 | } | 120 | } |
124 | scaled = b; | 121 | scaled = b; |
125 | emit scaledToggled(b); | 122 | emit scaledToggled(b); |
126 | } | 123 | } |
127 | 124 | ||
128 | void MediaPlayerState::setLooping( bool b ) { | 125 | void MediaPlayerState::setLooping( bool b ) { |
129 | if ( looping == b ) { | 126 | if ( looping == b ) { |
130 | return; | 127 | return; |
131 | } | 128 | } |
132 | looping = b; | 129 | looping = b; |
133 | emit loopingToggled(b); | 130 | emit loopingToggled(b); |
134 | } | 131 | } |
135 | 132 | ||
136 | void MediaPlayerState::setShuffled( bool b ) { | 133 | void MediaPlayerState::setShuffled( bool b ) { |
137 | if ( shuffled == b ) { | 134 | if ( shuffled == b ) { |
138 | return; | 135 | return; |
139 | } | 136 | } |
140 | shuffled = b; | 137 | shuffled = b; |
141 | emit shuffledToggled(b); | 138 | emit shuffledToggled(b); |
142 | } | 139 | } |
143 | 140 | ||
144 | void MediaPlayerState::setPaused( bool b ) { | 141 | void MediaPlayerState::setPaused( bool b ) { |
145 | if ( paused == b ) { | 142 | if ( paused == b ) { |
146 | paused = FALSE; | 143 | paused = FALSE; |
147 | emit pausedToggled(FALSE); | 144 | emit pausedToggled(FALSE); |
148 | return; | 145 | return; |
149 | } | 146 | } |
150 | paused = b; | 147 | paused = b; |
151 | emit pausedToggled(b); | 148 | emit pausedToggled(b); |
152 | } | 149 | } |
153 | 150 | ||
154 | void MediaPlayerState::setPlaying( bool b ) { | 151 | void MediaPlayerState::setPlaying( bool b ) { |
155 | if ( playing == b ) { | 152 | if ( playing == b ) { |
156 | return; | 153 | return; |
157 | } | 154 | } |
158 | playing = b; | 155 | playing = b; |
159 | stopped = !b; | 156 | stopped = !b; |
160 | emit playingToggled(b); | 157 | emit playingToggled(b); |
161 | } | 158 | } |
162 | 159 | ||
163 | void MediaPlayerState::setStopped( bool b ) { | 160 | void MediaPlayerState::setStopped( bool b ) { |
164 | if ( stopped == b ) { | 161 | if ( stopped == b ) { |
165 | return; | 162 | return; |
166 | } | 163 | } |
167 | stopped = b; | 164 | stopped = b; |
168 | emit stopToggled(b); | 165 | emit stopToggled(b); |
169 | } | 166 | } |
170 | 167 | ||
171 | void MediaPlayerState::setPosition( long p ) { | 168 | void MediaPlayerState::setPosition( long p ) { |
172 | if ( curPosition == p ) { | 169 | if ( curPosition == p ) { |
173 | return; | 170 | return; |
174 | } | 171 | } |
175 | curPosition = p; | 172 | curPosition = p; |
176 | emit positionChanged(p); | 173 | emit positionChanged(p); |
177 | } | 174 | } |
178 | 175 | ||
179 | void MediaPlayerState::updatePosition( long p ){ | 176 | void MediaPlayerState::updatePosition( long p ){ |
180 | if ( curPosition == p ) { | 177 | if ( curPosition == p ) { |
181 | return; | 178 | return; |
182 | } | 179 | } |
183 | curPosition = p; | 180 | curPosition = p; |
184 | emit positionUpdated(p); | 181 | emit positionUpdated(p); |
185 | } | 182 | } |
186 | 183 | ||
187 | void MediaPlayerState::setVideoGamma( int v ){ | 184 | void MediaPlayerState::setVideoGamma( int v ){ |
188 | if ( videoGamma == v ) { | 185 | if ( videoGamma == v ) { |
189 | return; | 186 | return; |
190 | } | 187 | } |
191 | videoGamma = v; | 188 | videoGamma = v; |
192 | emit videoGammaChanged( v ); | 189 | emit videoGammaChanged( v ); |
193 | } | 190 | } |
194 | 191 | ||
195 | void MediaPlayerState::setLength( long l ) { | 192 | void MediaPlayerState::setLength( long l ) { |
196 | if ( curLength == l ) { | 193 | if ( curLength == l ) { |
197 | return; | 194 | return; |
198 | } | 195 | } |
199 | curLength = l; | 196 | curLength = l; |
200 | emit lengthChanged(l); | 197 | emit lengthChanged(l); |
201 | } | 198 | } |
202 | 199 | ||
203 | void MediaPlayerState::setView( char v ) { | 200 | void MediaPlayerState::setView( char v ) { |
204 | if ( curView == v ) { | 201 | if ( curView == v ) { |
205 | return; | 202 | return; |
206 | } | 203 | } |
207 | curView = v; | 204 | curView = v; |
208 | emit viewChanged(v); | 205 | emit viewChanged(v); |
209 | } | 206 | } |
210 | 207 | ||
211 | void MediaPlayerState::setPrev(){ | 208 | void MediaPlayerState::setPrev(){ |
212 | emit prev(); | 209 | emit prev(); |
213 | } | 210 | } |
214 | 211 | ||
215 | void MediaPlayerState::setNext() { | 212 | void MediaPlayerState::setNext() { |
216 | emit next(); | 213 | emit next(); |
217 | } | 214 | } |
218 | 215 | ||
219 | void MediaPlayerState::setList() { | 216 | void MediaPlayerState::setList() { |
220 | setPlaying( FALSE ); | 217 | setPlaying( FALSE ); |
221 | setView('l'); | 218 | setView('l'); |
222 | } | 219 | } |
223 | 220 | ||
224 | void MediaPlayerState::setVideo() { | 221 | void MediaPlayerState::setVideo() { |
225 | setView('v'); | 222 | setView('v'); |
226 | } | 223 | } |
227 | 224 | ||
228 | void MediaPlayerState::setAudio() { | 225 | void MediaPlayerState::setAudio() { |
229 | setView('a'); | 226 | setView('a'); |
230 | } | 227 | } |
231 | 228 | ||
232 | void MediaPlayerState::toggleFullscreen() { | 229 | void MediaPlayerState::toggleFullscreen() { |
233 | setFullscreen( !fullscreen ); | 230 | setFullscreen( !fullscreen ); |
234 | } | 231 | } |
235 | 232 | ||
236 | void MediaPlayerState::toggleScaled() { | 233 | void MediaPlayerState::toggleScaled() { |
237 | setScaled( !scaled); | 234 | setScaled( !scaled); |
238 | } | 235 | } |
239 | 236 | ||
240 | void MediaPlayerState::toggleLooping() { | 237 | void MediaPlayerState::toggleLooping() { |
241 | setLooping( !looping); | 238 | setLooping( !looping); |
242 | } | 239 | } |
243 | 240 | ||
244 | void MediaPlayerState::toggleShuffled() { | 241 | void MediaPlayerState::toggleShuffled() { |
245 | setShuffled( !shuffled); | 242 | setShuffled( !shuffled); |
246 | } | 243 | } |
247 | 244 | ||
248 | void MediaPlayerState::togglePaused() { | 245 | void MediaPlayerState::togglePaused() { |
249 | setPaused( !paused); | 246 | setPaused( !paused); |
250 | } | 247 | } |
251 | 248 | ||
252 | void MediaPlayerState::togglePlaying() { | 249 | void MediaPlayerState::togglePlaying() { |
253 | setPlaying( !playing); | 250 | setPlaying( !playing); |
254 | } | 251 | } |
255 | 252 | ||
256 | void MediaPlayerState::toggleBlank() { | 253 | void MediaPlayerState::toggleBlank() { |
257 | setBlanked( !blanked); | 254 | setBlanked( !blanked); |
258 | } | 255 | } |
259 | 256 | ||
260 | 257 | ||
261 | 258 | ||
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.h b/noncore/multimedia/opieplayer2/mediaplayerstate.h index 7a80ad8..fc4e6cb 100644 --- a/noncore/multimedia/opieplayer2/mediaplayerstate.h +++ b/noncore/multimedia/opieplayer2/mediaplayerstate.h | |||
@@ -1,140 +1,139 @@ | |||
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 | // this file is based on work by trolltech | 34 | // this file is based on work by trolltech |
35 | 35 | ||
36 | #ifndef MEDIA_PLAYER_STATE_H | 36 | #ifndef MEDIA_PLAYER_STATE_H |
37 | #define MEDIA_PLAYER_STATE_H | 37 | #define MEDIA_PLAYER_STATE_H |
38 | 38 | ||
39 | 39 | ||
40 | #include <qobject.h> | 40 | #include <qobject.h> |
41 | 41 | ||
42 | 42 | ||
43 | class MediaPlayerDecoder; | 43 | class MediaPlayerDecoder; |
44 | class Config; | 44 | class Config; |
45 | 45 | ||
46 | 46 | ||
47 | class MediaPlayerState : public QObject { | 47 | class MediaPlayerState : public QObject { |
48 | Q_OBJECT | 48 | Q_OBJECT |
49 | public: | 49 | public: |
50 | MediaPlayerState( QObject *parent, const char *name ); | 50 | MediaPlayerState( QObject *parent, const char *name ); |
51 | ~MediaPlayerState(); | 51 | ~MediaPlayerState(); |
52 | 52 | ||
53 | bool isStreaming() const { return streaming; } | 53 | bool isStreaming() const { return streaming; } |
54 | bool isSeekable() const { return seekable; } | 54 | bool isSeekable() const { return seekable; } |
55 | bool isFullscreen() const { return fullscreen; } | 55 | bool isFullscreen() const { return fullscreen; } |
56 | bool isScaled() const { return scaled; } | 56 | bool isScaled() const { return scaled; } |
57 | bool isLooping() const { return looping; } | 57 | bool isLooping() const { return looping; } |
58 | bool isShuffled() const { return shuffled; } | 58 | bool isShuffled() const { return shuffled; } |
59 | bool isUsingPlaylist() const { return usePlaylist; } | ||
60 | bool isPaused() const { return paused; } | 59 | bool isPaused() const { return paused; } |
61 | bool isPlaying() const { return playing; } | 60 | bool isPlaying() const { return playing; } |
62 | bool isStopped() const { return stopped; } | 61 | bool isStopped() const { return stopped; } |
63 | long position() const { return curPosition; } | 62 | long position() const { return curPosition; } |
64 | long length() const { return curLength; } | 63 | long length() const { return curLength; } |
65 | char view() const { return curView; } | 64 | char view() const { return curView; } |
66 | 65 | ||
67 | public slots: | 66 | public slots: |
68 | void setIsStreaming( bool b ); | 67 | void setIsStreaming( bool b ); |
69 | void setIsSeekable( bool b ); | 68 | void setIsSeekable( bool b ); |
70 | void setFullscreen( bool b ); | 69 | void setFullscreen( bool b ); |
71 | void setScaled( bool b ); | 70 | void setScaled( bool b ); |
72 | void setLooping( bool b ); | 71 | void setLooping( bool b ); |
73 | void setShuffled( bool b ); | 72 | void setShuffled( bool b ); |
74 | void setPaused( bool b ); | 73 | void setPaused( bool b ); |
75 | void setPlaying( bool b ); | 74 | void setPlaying( bool b ); |
76 | void setStopped( bool b ); | 75 | void setStopped( bool b ); |
77 | void setPosition( long p ); | 76 | void setPosition( long p ); |
78 | void updatePosition( long p ); | 77 | void updatePosition( long p ); |
79 | void setLength( long l ); | 78 | void setLength( long l ); |
80 | void setView( char v ); | 79 | void setView( char v ); |
81 | void setBlanked( bool b ); | 80 | void setBlanked( bool b ); |
82 | void setVideoGamma( int v ); | 81 | void setVideoGamma( int v ); |
83 | 82 | ||
84 | void setPrev(); | 83 | void setPrev(); |
85 | void setNext(); | 84 | void setNext(); |
86 | void setList(); | 85 | void setList(); |
87 | void setVideo(); | 86 | void setVideo(); |
88 | void setAudio(); | 87 | void setAudio(); |
89 | 88 | ||
90 | void toggleFullscreen(); | 89 | void toggleFullscreen(); |
91 | void toggleScaled(); | 90 | void toggleScaled(); |
92 | void toggleLooping(); | 91 | void toggleLooping(); |
93 | void toggleShuffled(); | 92 | void toggleShuffled(); |
94 | void togglePaused(); | 93 | void togglePaused(); |
95 | void togglePlaying(); | 94 | void togglePlaying(); |
96 | void toggleBlank(); | 95 | void toggleBlank(); |
97 | void writeConfig( Config& cfg ) const; | 96 | void writeConfig( Config& cfg ) const; |
98 | 97 | ||
99 | 98 | ||
100 | signals: | 99 | signals: |
101 | void fullscreenToggled( bool ); | 100 | void fullscreenToggled( bool ); |
102 | void scaledToggled( bool ); | 101 | void scaledToggled( bool ); |
103 | void loopingToggled( bool ); | 102 | void loopingToggled( bool ); |
104 | void shuffledToggled( bool ); | 103 | void shuffledToggled( bool ); |
105 | void pausedToggled( bool ); | 104 | void pausedToggled( bool ); |
106 | void playingToggled( bool ); | 105 | void playingToggled( bool ); |
107 | void stopToggled( bool ); | 106 | void stopToggled( bool ); |
108 | void positionChanged( long ); // When the slider is moved | 107 | void positionChanged( long ); // When the slider is moved |
109 | void positionUpdated( long ); // When the media file progresses | 108 | void positionUpdated( long ); // When the media file progresses |
110 | void lengthChanged( long ); | 109 | void lengthChanged( long ); |
111 | void viewChanged( char ); | 110 | void viewChanged( char ); |
112 | void isSeekableToggled( bool ); | 111 | void isSeekableToggled( bool ); |
113 | void blankToggled( bool ); | 112 | void blankToggled( bool ); |
114 | void videoGammaChanged( int ); | 113 | void videoGammaChanged( int ); |
115 | void prev(); | 114 | void prev(); |
116 | void next(); | 115 | void next(); |
117 | 116 | ||
118 | private: | 117 | private: |
119 | bool streaming : 1; | 118 | bool streaming : 1; |
120 | bool seekable : 1; | 119 | bool seekable : 1; |
121 | bool fullscreen: 1; | 120 | bool fullscreen: 1; |
122 | bool scaled : 1; | 121 | bool scaled : 1; |
123 | bool blanked : 1; | 122 | bool blanked : 1; |
124 | bool looping : 1; | 123 | bool looping : 1; |
125 | bool shuffled : 1; | 124 | bool shuffled : 1; |
126 | bool usePlaylist : 1; | 125 | bool usePlaylist : 1; |
127 | bool paused : 1; | 126 | bool paused : 1; |
128 | bool playing : 1; | 127 | bool playing : 1; |
129 | bool stopped : 1; | 128 | bool stopped : 1; |
130 | long curPosition; | 129 | long curPosition; |
131 | long curLength; | 130 | long curLength; |
132 | char curView; | 131 | char curView; |
133 | int videoGamma; | 132 | int videoGamma; |
134 | void readConfig( Config& cfg ); | 133 | void readConfig( Config& cfg ); |
135 | 134 | ||
136 | }; | 135 | }; |
137 | 136 | ||
138 | 137 | ||
139 | #endif // MEDIA_PLAYER_STATE_H | 138 | #endif // MEDIA_PLAYER_STATE_H |
140 | 139 | ||
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 5b277cc..f53def6 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -1,880 +1,858 @@ | |||
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 | 52 | ||
53 | //only needed for the random play | 53 | //only needed for the random play |
54 | #include <stdlib.h> | 54 | #include <stdlib.h> |
55 | #include <assert.h> | 55 | #include <assert.h> |
56 | 56 | ||
57 | #include "audiowidget.h" | 57 | #include "audiowidget.h" |
58 | #include "videowidget.h" | 58 | #include "videowidget.h" |
59 | 59 | ||
60 | extern MediaPlayerState *mediaPlayerState; | 60 | extern MediaPlayerState *mediaPlayerState; |
61 | // extern AudioWidget *audioUI; | 61 | // extern AudioWidget *audioUI; |
62 | // extern VideoWidget *videoUI; | 62 | // extern VideoWidget *videoUI; |
63 | 63 | ||
64 | QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg"; | 64 | QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg"; |
65 | // no m3u's here please | 65 | // no m3u's here please |
66 | 66 | ||
67 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 67 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
68 | : PlayListWidgetGui( parent, name, fl ) { | 68 | : PlayListWidgetGui( parent, name, fl ) { |
69 | 69 | ||
70 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), | 70 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), |
71 | "opieplayer2/add_to_playlist", | 71 | "opieplayer2/add_to_playlist", |
72 | this , SLOT(addSelected() ) ); | 72 | this , SLOT(addSelected() ) ); |
73 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), | 73 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), |
74 | "opieplayer2/remove_from_playlist", | 74 | "opieplayer2/remove_from_playlist", |
75 | this , SLOT(removeSelected() ) ); | 75 | this , SLOT(removeSelected() ) ); |
76 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", | 76 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", |
77 | this , SLOT( btnPlay( bool) ), TRUE ); | 77 | this , SLOT( btnPlay( bool) ), TRUE ); |
78 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", | 78 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", |
79 | mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); | 79 | mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); |
80 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", | 80 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", |
81 | mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); | 81 | mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); |
82 | 82 | ||
83 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 83 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
84 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), | 84 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), |
85 | this, SLOT( addAllMusicToList() ) ); | 85 | this, SLOT( addAllMusicToList() ) ); |
86 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), | 86 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), |
87 | this, SLOT( addAllVideoToList() ) ); | 87 | this, SLOT( addAllVideoToList() ) ); |
88 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), | 88 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), |
89 | this, SLOT( addAllToList() ) ); | 89 | this, SLOT( addAllToList() ) ); |
90 | pmPlayList->insertSeparator(-1); | 90 | pmPlayList->insertSeparator(-1); |
91 | // (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), | 91 | // (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), |
92 | // this, SLOT( saveList() ) ); | 92 | // this, SLOT( saveList() ) ); |
93 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), | 93 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), |
94 | this, SLOT(writem3u() ) ); | 94 | this, SLOT(writem3u() ) ); |
95 | pmPlayList->insertSeparator(-1); | 95 | pmPlayList->insertSeparator(-1); |
96 | (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), | 96 | (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), |
97 | this,SLOT( openFile() ) ); | 97 | this,SLOT( openFile() ) ); |
98 | pmPlayList->insertSeparator(-1); | 98 | pmPlayList->insertSeparator(-1); |
99 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), | 99 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), |
100 | this,SLOT( scanForAudio() ) ); | 100 | this,SLOT( scanForAudio() ) ); |
101 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), | 101 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), |
102 | this,SLOT( scanForVideo() ) ); | 102 | this,SLOT( scanForVideo() ) ); |
103 | 103 | ||
104 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), | 104 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), |
105 | mediaPlayerState, SLOT( toggleFullscreen() ) ); | 105 | mediaPlayerState, SLOT( toggleFullscreen() ) ); |
106 | 106 | ||
107 | Config cfg( "OpiePlayer" ); | 107 | Config cfg( "OpiePlayer" ); |
108 | bool b= cfg.readBoolEntry("FullScreen", 0); | 108 | bool b= cfg.readBoolEntry("FullScreen", 0); |
109 | mediaPlayerState->setFullscreen( b ); | 109 | mediaPlayerState->setFullscreen( b ); |
110 | pmView->setItemChecked( -16, b ); | 110 | pmView->setItemChecked( -16, b ); |
111 | 111 | ||
112 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", | 112 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", |
113 | d->selectedFiles, SLOT(moveSelectedUp() ) ); | 113 | d->selectedFiles, SLOT(moveSelectedUp() ) ); |
114 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", | 114 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", |
115 | d->selectedFiles, SLOT(removeSelected() ) ); | 115 | d->selectedFiles, SLOT(removeSelected() ) ); |
116 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", | 116 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", |
117 | d->selectedFiles, SLOT(moveSelectedDown() ) ); | 117 | d->selectedFiles, SLOT(moveSelectedDown() ) ); |
118 | // QVBox *stretch2 = new QVBox( vbox1 ); | 118 | // QVBox *stretch2 = new QVBox( vbox1 ); |
119 | 119 | ||
120 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), | 120 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), |
121 | SLOT( deletePlaylist() ) ); | 121 | SLOT( deletePlaylist() ) ); |
122 | connect( pmView, SIGNAL( activated( int ) ), | 122 | connect( pmView, SIGNAL( activated( int ) ), |
123 | this, SLOT( pmViewActivated( int ) ) ); | 123 | this, SLOT( pmViewActivated( int ) ) ); |
124 | connect( skinsMenu, SIGNAL( activated( int ) ) , | 124 | connect( skinsMenu, SIGNAL( activated( int ) ) , |
125 | this, SLOT( skinsMenuActivated( int ) ) ); | 125 | this, SLOT( skinsMenuActivated( int ) ) ); |
126 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 126 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), |
127 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 127 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
128 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), | 128 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), |
129 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 129 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
130 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), | 130 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), |
131 | this,SLOT( playIt( QListViewItem *) ) ); | 131 | this,SLOT( playIt( QListViewItem *) ) ); |
132 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), | 132 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), |
133 | this, SLOT( addToSelection( QListViewItem *) ) ); | 133 | this, SLOT( addToSelection( QListViewItem *) ) ); |
134 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 134 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), |
135 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); | 135 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); |
136 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), | 136 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), |
137 | this,SLOT( playIt( QListViewItem *) ) ); | 137 | this,SLOT( playIt( QListViewItem *) ) ); |
138 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), | 138 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), |
139 | this, SLOT( addToSelection( QListViewItem *) ) ); | 139 | this, SLOT( addToSelection( QListViewItem *) ) ); |
140 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), | 140 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), |
141 | this, SLOT( loadList( const DocLnk & ) ) ); | 141 | this, SLOT( loadList( const DocLnk & ) ) ); |
142 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), | 142 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), |
143 | this, SLOT( tabChanged( QWidget* ) ) ); | 143 | this, SLOT( tabChanged( QWidget* ) ) ); |
144 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), | 144 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), |
145 | d->tbPlay, SLOT( setOn( bool ) ) ); | 145 | d->tbPlay, SLOT( setOn( bool ) ) ); |
146 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), | 146 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), |
147 | d->tbLoop, SLOT( setOn( bool ) ) ); | 147 | d->tbLoop, SLOT( setOn( bool ) ) ); |
148 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), | 148 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), |
149 | d->tbShuffle, SLOT( setOn( bool ) ) ); | 149 | d->tbShuffle, SLOT( setOn( bool ) ) ); |
150 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), | 150 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), |
151 | this, SLOT( playIt( QListViewItem *) ) ); | 151 | this, SLOT( playIt( QListViewItem *) ) ); |
152 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), | 152 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), |
153 | mediaPlayerState, SLOT( setVideoGamma( int ) ) ); | 153 | mediaPlayerState, SLOT( setVideoGamma( int ) ) ); |
154 | 154 | ||
155 | // see which skins are installed | 155 | // see which skins are installed |
156 | videoScan=false; | 156 | videoScan=false; |
157 | audioScan=false; | 157 | audioScan=false; |
158 | audioPopulated=false; | 158 | audioPopulated=false; |
159 | videoPopulated=false; | 159 | videoPopulated=false; |
160 | populateSkinsMenu(); | 160 | populateSkinsMenu(); |
161 | initializeStates(); | 161 | initializeStates(); |
162 | 162 | ||
163 | cfg.setGroup("PlayList"); | 163 | cfg.setGroup("PlayList"); |
164 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); | 164 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); |
165 | loadList(DocLnk( currentPlaylist ) ); | 165 | loadList(DocLnk( currentPlaylist ) ); |
166 | } | 166 | } |
167 | 167 | ||
168 | 168 | ||
169 | PlayListWidget::~PlayListWidget() { | 169 | PlayListWidget::~PlayListWidget() { |
170 | delete d; | 170 | delete d; |
171 | } | 171 | } |
172 | 172 | ||
173 | 173 | ||
174 | void PlayListWidget::initializeStates() { | 174 | void PlayListWidget::initializeStates() { |
175 | d->tbPlay->setOn( mediaPlayerState->isPlaying() ); | 175 | d->tbPlay->setOn( mediaPlayerState->isPlaying() ); |
176 | d->tbLoop->setOn( mediaPlayerState->isLooping() ); | 176 | d->tbLoop->setOn( mediaPlayerState->isLooping() ); |
177 | d->tbShuffle->setOn( mediaPlayerState->isShuffled() ); | 177 | d->tbShuffle->setOn( mediaPlayerState->isShuffled() ); |
178 | d->playListFrame->show(); | 178 | d->playListFrame->show(); |
179 | } | 179 | } |
180 | 180 | ||
181 | void PlayListWidget::writeDefaultPlaylist() { | 181 | void PlayListWidget::writeDefaultPlaylist() { |
182 | 182 | ||
183 | Config config( "OpiePlayer" ); | 183 | Config config( "OpiePlayer" ); |
184 | config.setGroup( "PlayList" ); | 184 | config.setGroup( "PlayList" ); |
185 | QString filename=QPEApplication::documentDir() + "/default.m3u"; | 185 | QString filename=QPEApplication::documentDir() + "/default.m3u"; |
186 | QString currentString = config.readEntry( "CurrentPlaylist", filename); | 186 | QString currentString = config.readEntry( "CurrentPlaylist", filename); |
187 | if( currentString == filename) { | 187 | if( currentString == filename) { |
188 | Om3u *m3uList; | 188 | Om3u *m3uList; |
189 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); | 189 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); |
190 | if( d->selectedFiles->first() ) { | 190 | if( d->selectedFiles->first() ) { |
191 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 191 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
192 | do { | 192 | do { |
193 | // qDebug(d->selectedFiles->current()->file()); | 193 | // qDebug(d->selectedFiles->current()->file()); |
194 | m3uList->add( d->selectedFiles->current()->file() ); | 194 | m3uList->add( d->selectedFiles->current()->file() ); |
195 | } | 195 | } |
196 | while ( d->selectedFiles->next() ); | 196 | while ( d->selectedFiles->next() ); |
197 | 197 | ||
198 | m3uList->write(); | 198 | m3uList->write(); |
199 | m3uList->close(); | 199 | m3uList->close(); |
200 | if(m3uList) delete m3uList; | 200 | if(m3uList) delete m3uList; |
201 | 201 | ||
202 | } | 202 | } |
203 | } | 203 | } |
204 | } | 204 | } |
205 | 205 | ||
206 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 206 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
207 | d->setDocumentUsed = FALSE; | 207 | d->setDocumentUsed = FALSE; |
208 | if ( mediaPlayerState->isUsingPlaylist() ) { | 208 | if( QFileInfo( lnk.file() ).exists() || |
209 | if( QFileInfo( lnk.file() ).exists() || | 209 | lnk.file().left(4) == "http" ) { |
210 | lnk.file().left(4) == "http" ) { | 210 | d->selectedFiles->addToSelection( lnk ); |
211 | d->selectedFiles->addToSelection( lnk ); | ||
212 | } | ||
213 | // writeCurrentM3u(); | ||
214 | } | 211 | } |
215 | else | 212 | // writeCurrentM3u(); |
216 | mediaPlayerState->setPlaying( TRUE ); | ||
217 | } | 213 | } |
218 | 214 | ||
219 | 215 | ||
220 | void PlayListWidget::clearList() { | 216 | void PlayListWidget::clearList() { |
221 | while ( first() ) { | 217 | while ( first() ) { |
222 | d->selectedFiles->removeSelected(); | 218 | d->selectedFiles->removeSelected(); |
223 | } | 219 | } |
224 | } | 220 | } |
225 | 221 | ||
226 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 222 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
227 | switch (mouse) { | 223 | switch (mouse) { |
228 | case 1: | 224 | case 1: |
229 | break; | 225 | break; |
230 | case 2: | 226 | case 2: |
231 | { | 227 | { |
232 | QPopupMenu m; | 228 | QPopupMenu m; |
233 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 229 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
234 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 230 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
235 | m.exec( QCursor::pos() ); | 231 | m.exec( QCursor::pos() ); |
236 | } | 232 | } |
237 | break; | 233 | break; |
238 | } | 234 | } |
239 | } | 235 | } |
240 | 236 | ||
241 | 237 | ||
242 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 238 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
243 | switch (mouse) { | 239 | switch (mouse) { |
244 | case 1: | 240 | case 1: |
245 | break; | 241 | break; |
246 | case 2: | 242 | case 2: |
247 | { | 243 | { |
248 | QPopupMenu m; | 244 | QPopupMenu m; |
249 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 245 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
250 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 246 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
251 | m.exec( QCursor::pos() ); | 247 | m.exec( QCursor::pos() ); |
252 | } | 248 | } |
253 | break; | 249 | break; |
254 | } | 250 | } |
255 | } | 251 | } |
256 | 252 | ||
257 | 253 | ||
258 | void PlayListWidget::addAllToList() { | 254 | void PlayListWidget::addAllToList() { |
259 | 255 | ||
260 | // QTime t; | 256 | // QTime t; |
261 | // t.start(); | 257 | // t.start(); |
262 | 258 | ||
263 | if(!audioScan) { | 259 | if(!audioScan) { |
264 | if(audioView->childCount() < 1) | 260 | if(audioView->childCount() < 1) |
265 | populateAudioView(); | 261 | populateAudioView(); |
266 | } | 262 | } |
267 | 263 | ||
268 | QListViewItemIterator audioIt( audioView ); | 264 | QListViewItemIterator audioIt( audioView ); |
269 | DocLnk lnk; | 265 | DocLnk lnk; |
270 | QString filename; | 266 | QString filename; |
271 | // iterate through all items of the listview | 267 | // iterate through all items of the listview |
272 | for ( ; audioIt.current(); ++audioIt ) { | 268 | for ( ; audioIt.current(); ++audioIt ) { |
273 | filename = audioIt.current()->text(3); | 269 | filename = audioIt.current()->text(3); |
274 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 270 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
275 | lnk.setFile( filename ); //sets file name | 271 | lnk.setFile( filename ); //sets file name |
276 | d->selectedFiles->addToSelection( lnk); | 272 | d->selectedFiles->addToSelection( lnk); |
277 | } | 273 | } |
278 | 274 | ||
279 | if(!videoScan) { | 275 | if(!videoScan) { |
280 | if(videoView->childCount() < 1) | 276 | if(videoView->childCount() < 1) |
281 | populateVideoView(); | 277 | populateVideoView(); |
282 | } | 278 | } |
283 | 279 | ||
284 | QListViewItemIterator videoIt( videoView ); | 280 | QListViewItemIterator videoIt( videoView ); |
285 | for ( ; videoIt.current(); ++videoIt ) { | 281 | for ( ; videoIt.current(); ++videoIt ) { |
286 | filename = videoIt.current()->text(3); | 282 | filename = videoIt.current()->text(3); |
287 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 283 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
288 | lnk.setFile( filename ); //sets file name | 284 | lnk.setFile( filename ); //sets file name |
289 | d->selectedFiles->addToSelection( lnk); | 285 | d->selectedFiles->addToSelection( lnk); |
290 | } | 286 | } |
291 | 287 | ||
292 | // d->selectedFiles->addToSelection( ); | 288 | // d->selectedFiles->addToSelection( ); |
293 | // if ( it.current()->isSelected() ) | 289 | // if ( it.current()->isSelected() ) |
294 | // lst->append( audioIt.current() ); | 290 | // lst->append( audioIt.current() ); |
295 | // } | 291 | // } |
296 | 292 | ||
297 | 293 | ||
298 | // if(!audioScan) | 294 | // if(!audioScan) |
299 | // scanForAudio(); | 295 | // scanForAudio(); |
300 | // if(!videoScan) | 296 | // if(!videoScan) |
301 | // scanForVideo(); | 297 | // scanForVideo(); |
302 | 298 | ||
303 | // DocLnkSet filesAll; | 299 | // DocLnkSet filesAll; |
304 | // Global::findDocuments(&filesAll, "video/*;"+audioMimes); | 300 | // Global::findDocuments(&filesAll, "video/*;"+audioMimes); |
305 | // QListIterator<DocLnk> Adit( filesAll.children() ); | 301 | // QListIterator<DocLnk> Adit( filesAll.children() ); |
306 | // for ( ; Adit.current(); ++Adit ) { | 302 | // for ( ; Adit.current(); ++Adit ) { |
307 | // if( QFileInfo( Adit.current()->file() ).exists() ) { | 303 | // if( QFileInfo( Adit.current()->file() ).exists() ) { |
308 | // d->selectedFiles->addToSelection( **Adit ); | 304 | // d->selectedFiles->addToSelection( **Adit ); |
309 | // } | 305 | // } |
310 | // } | 306 | // } |
311 | 307 | ||
312 | // qDebug("elapsed time %d", t.elapsed() ); | 308 | // qDebug("elapsed time %d", t.elapsed() ); |
313 | 309 | ||
314 | tabWidget->setCurrentPage(0); | 310 | tabWidget->setCurrentPage(0); |
315 | 311 | ||
316 | writeCurrentM3u(); | 312 | writeCurrentM3u(); |
317 | d->selectedFiles->first(); | 313 | d->selectedFiles->first(); |
318 | } | 314 | } |
319 | 315 | ||
320 | 316 | ||
321 | void PlayListWidget::addAllMusicToList() { | 317 | void PlayListWidget::addAllMusicToList() { |
322 | 318 | ||
323 | if(!audioScan) { | 319 | if(!audioScan) { |
324 | if(audioView->childCount() < 1) | 320 | if(audioView->childCount() < 1) |
325 | populateAudioView(); | 321 | populateAudioView(); |
326 | } | 322 | } |
327 | 323 | ||
328 | QListViewItemIterator audioIt( audioView ); | 324 | QListViewItemIterator audioIt( audioView ); |
329 | DocLnk lnk; | 325 | DocLnk lnk; |
330 | QString filename; | 326 | QString filename; |
331 | // iterate through all items of the listview | 327 | // iterate through all items of the listview |
332 | for ( ; audioIt.current(); ++audioIt ) { | 328 | for ( ; audioIt.current(); ++audioIt ) { |
333 | filename = audioIt.current()->text(3); | 329 | filename = audioIt.current()->text(3); |
334 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 330 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
335 | lnk.setFile( filename ); //sets file name | 331 | lnk.setFile( filename ); //sets file name |
336 | d->selectedFiles->addToSelection( lnk); | 332 | d->selectedFiles->addToSelection( lnk); |
337 | } | 333 | } |
338 | 334 | ||
339 | /* if(!audioScan) | 335 | /* if(!audioScan) |
340 | scanForAudio(); | 336 | scanForAudio(); |
341 | QListIterator<DocLnk> dit( files.children() ); | 337 | QListIterator<DocLnk> dit( files.children() ); |
342 | for ( ; dit.current(); ++dit ) { | 338 | for ( ; dit.current(); ++dit ) { |
343 | if( QFileInfo(dit.current()->file() ).exists() ) { | 339 | if( QFileInfo(dit.current()->file() ).exists() ) { |
344 | d->selectedFiles->addToSelection( **dit ); | 340 | d->selectedFiles->addToSelection( **dit ); |
345 | } | 341 | } |
346 | } | 342 | } |
347 | */ | 343 | */ |
348 | tabWidget->setCurrentPage(0); | 344 | tabWidget->setCurrentPage(0); |
349 | writeCurrentM3u(); | 345 | writeCurrentM3u(); |
350 | d->selectedFiles->first(); | 346 | d->selectedFiles->first(); |
351 | } | 347 | } |
352 | 348 | ||
353 | 349 | ||
354 | void PlayListWidget::addAllVideoToList() { | 350 | void PlayListWidget::addAllVideoToList() { |
355 | 351 | ||
356 | if(!videoScan) { | 352 | if(!videoScan) { |
357 | if(videoView->childCount() < 1) | 353 | if(videoView->childCount() < 1) |
358 | populateVideoView(); | 354 | populateVideoView(); |
359 | } | 355 | } |
360 | 356 | ||
361 | QListViewItemIterator videoIt( videoView ); | 357 | QListViewItemIterator videoIt( videoView ); |
362 | DocLnk lnk; | 358 | DocLnk lnk; |
363 | QString filename; | 359 | QString filename; |
364 | for ( ; videoIt.current(); ++videoIt ) { | 360 | for ( ; videoIt.current(); ++videoIt ) { |
365 | filename = videoIt.current()->text(3); | 361 | filename = videoIt.current()->text(3); |
366 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 362 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
367 | lnk.setFile( filename ); //sets file name | 363 | lnk.setFile( filename ); //sets file name |
368 | d->selectedFiles->addToSelection( lnk); | 364 | d->selectedFiles->addToSelection( lnk); |
369 | } | 365 | } |
370 | 366 | ||
371 | 367 | ||
372 | /* if(!videoScan) | 368 | /* if(!videoScan) |
373 | scanForVideo(); | 369 | scanForVideo(); |
374 | QListIterator<DocLnk> dit( vFiles.children() ); | 370 | QListIterator<DocLnk> dit( vFiles.children() ); |
375 | for ( ; dit.current(); ++dit ) { | 371 | for ( ; dit.current(); ++dit ) { |
376 | if( QFileInfo( dit.current()->file() ).exists() ) { | 372 | if( QFileInfo( dit.current()->file() ).exists() ) { |
377 | d->selectedFiles->addToSelection( **dit ); | 373 | d->selectedFiles->addToSelection( **dit ); |
378 | } | 374 | } |
379 | } | 375 | } |
380 | */ | 376 | */ |
381 | tabWidget->setCurrentPage(0); | 377 | tabWidget->setCurrentPage(0); |
382 | writeCurrentM3u(); | 378 | writeCurrentM3u(); |
383 | d->selectedFiles->first(); | 379 | d->selectedFiles->first(); |
384 | } | 380 | } |
385 | 381 | ||
386 | 382 | ||
387 | void PlayListWidget::setDocument( const QString& fileref ) { | 383 | void PlayListWidget::setDocument( const QString& fileref ) { |
388 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); | 384 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); |
389 | fromSetDocument = TRUE; | 385 | fromSetDocument = TRUE; |
390 | if ( fileref.isNull() ) { | 386 | if ( fileref.isNull() ) { |
391 | QMessageBox::warning( this, tr( "Invalid File" ), | 387 | QMessageBox::warning( this, tr( "Invalid File" ), |
392 | tr( "There was a problem in getting the file." ) ); | 388 | tr( "There was a problem in getting the file." ) ); |
393 | return; | 389 | return; |
394 | } | 390 | } |
395 | 391 | ||
396 | clearList(); | 392 | clearList(); |
397 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u | 393 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u |
398 | readm3u( fileref ); | 394 | readm3u( fileref ); |
399 | } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { | 395 | } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { |
400 | readm3u( DocLnk( fileref).file() ); | 396 | readm3u( DocLnk( fileref).file() ); |
401 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls | 397 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls |
402 | readPls( fileref ); | 398 | readPls( fileref ); |
403 | } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { | 399 | } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { |
404 | readPls( DocLnk( fileref).file() ); | 400 | readPls( DocLnk( fileref).file() ); |
405 | } else { | 401 | } else { |
406 | clearList(); | 402 | clearList(); |
407 | addToSelection( DocLnk( fileref ) ); | 403 | addToSelection( DocLnk( fileref ) ); |
408 | writeCurrentM3u(); | 404 | writeCurrentM3u(); |
409 | 405 | ||
410 | d->setDocumentUsed = TRUE; | 406 | d->setDocumentUsed = TRUE; |
411 | mediaPlayerState->setPlaying( FALSE ); | 407 | mediaPlayerState->setPlaying( FALSE ); |
412 | mediaPlayerState->setPlaying( TRUE ); | 408 | mediaPlayerState->setPlaying( TRUE ); |
413 | } | 409 | } |
414 | } | 410 | } |
415 | 411 | ||
416 | 412 | ||
417 | void PlayListWidget::useSelectedDocument() { | 413 | void PlayListWidget::useSelectedDocument() { |
418 | d->setDocumentUsed = FALSE; | 414 | d->setDocumentUsed = FALSE; |
419 | } | 415 | } |
420 | 416 | ||
421 | 417 | ||
422 | const DocLnk *PlayListWidget::current() const { // this is fugly | 418 | const DocLnk *PlayListWidget::current() const { // this is fugly |
423 | assert( currentTab() == CurrentPlayList ); | 419 | assert( currentTab() == CurrentPlayList ); |
424 | 420 | ||
425 | // qDebug("playlist"); | 421 | return d->selectedFiles->current(); |
426 | if ( mediaPlayerState->isUsingPlaylist() ) | ||
427 | return d->selectedFiles->current(); | ||
428 | |||
429 | assert( false ); | ||
430 | } | 422 | } |
431 | 423 | ||
432 | 424 | ||
433 | bool PlayListWidget::prev() { | 425 | bool PlayListWidget::prev() { |
434 | if ( mediaPlayerState->isUsingPlaylist() ) { | 426 | if ( mediaPlayerState->isShuffled() ) { |
435 | if ( mediaPlayerState->isShuffled() ) { | 427 | const DocLnk *cur = current(); |
436 | const DocLnk *cur = current(); | 428 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
437 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 429 | for ( int i = 0; i < j; i++ ) { |
438 | for ( int i = 0; i < j; i++ ) { | 430 | if ( !d->selectedFiles->next() ) |
439 | if ( !d->selectedFiles->next() ) | 431 | d->selectedFiles->first(); |
440 | d->selectedFiles->first(); | 432 | } |
433 | if ( cur == current() ) | ||
434 | if ( !d->selectedFiles->next() ) { | ||
435 | d->selectedFiles->first(); | ||
441 | } | 436 | } |
442 | if ( cur == current() ) | 437 | return TRUE; |
443 | if ( !d->selectedFiles->next() ) { | 438 | } else { |
444 | d->selectedFiles->first(); | 439 | if ( !d->selectedFiles->prev() ) { |
445 | } | 440 | if ( mediaPlayerState->isLooping() ) { |
446 | return TRUE; | 441 | return d->selectedFiles->last(); |
447 | } else { | 442 | } else { |
448 | if ( !d->selectedFiles->prev() ) { | 443 | return FALSE; |
449 | if ( mediaPlayerState->isLooping() ) { | ||
450 | return d->selectedFiles->last(); | ||
451 | } else { | ||
452 | return FALSE; | ||
453 | } | ||
454 | } | 444 | } |
455 | return TRUE; | ||
456 | } | 445 | } |
457 | } else { | 446 | return TRUE; |
458 | return mediaPlayerState->isLooping(); | 447 | } |
459 | } | ||
460 | } | 448 | } |
461 | 449 | ||
462 | 450 | ||
463 | bool PlayListWidget::next() { | 451 | bool PlayListWidget::next() { |
464 | //qDebug("<<<<<<<<<<<<next()"); | 452 | //qDebug("<<<<<<<<<<<<next()"); |
465 | if ( mediaPlayerState->isUsingPlaylist() ) { | 453 | if ( mediaPlayerState->isShuffled() ) { |
466 | if ( mediaPlayerState->isShuffled() ) { | 454 | return prev(); |
467 | return prev(); | 455 | } else { |
468 | } else { | 456 | if ( !d->selectedFiles->next() ) { |
469 | if ( !d->selectedFiles->next() ) { | 457 | if ( mediaPlayerState->isLooping() ) { |
470 | if ( mediaPlayerState->isLooping() ) { | 458 | return d->selectedFiles->first(); |
471 | return d->selectedFiles->first(); | 459 | } else { |
472 | } else { | 460 | return FALSE; |
473 | return FALSE; | ||
474 | } | ||
475 | } | 461 | } |
476 | return TRUE; | ||
477 | } | 462 | } |
478 | } else { | 463 | return TRUE; |
479 | return mediaPlayerState->isLooping(); | ||
480 | } | 464 | } |
481 | } | 465 | } |
482 | 466 | ||
483 | 467 | ||
484 | bool PlayListWidget::first() { | 468 | bool PlayListWidget::first() { |
485 | if ( mediaPlayerState->isUsingPlaylist() ) | 469 | return d->selectedFiles->first(); |
486 | return d->selectedFiles->first(); | ||
487 | else | ||
488 | return mediaPlayerState->isLooping(); | ||
489 | } | 470 | } |
490 | 471 | ||
491 | 472 | ||
492 | bool PlayListWidget::last() { | 473 | bool PlayListWidget::last() { |
493 | if ( mediaPlayerState->isUsingPlaylist() ) | 474 | return d->selectedFiles->last(); |
494 | return d->selectedFiles->last(); | ||
495 | else | ||
496 | return mediaPlayerState->isLooping(); | ||
497 | } | 475 | } |
498 | 476 | ||
499 | 477 | ||
500 | void PlayListWidget::saveList() { | 478 | void PlayListWidget::saveList() { |
501 | writem3u(); | 479 | writem3u(); |
502 | } | 480 | } |
503 | 481 | ||
504 | 482 | ||
505 | void PlayListWidget::loadList( const DocLnk & lnk) { | 483 | void PlayListWidget::loadList( const DocLnk & lnk) { |
506 | QString name = lnk.name(); | 484 | QString name = lnk.name(); |
507 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); | 485 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); |
508 | 486 | ||
509 | if( name.length()>0) { | 487 | if( name.length()>0) { |
510 | setCaption("OpiePlayer: "+name); | 488 | setCaption("OpiePlayer: "+name); |
511 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); | 489 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); |
512 | clearList(); | 490 | clearList(); |
513 | readm3u(lnk.file()); | 491 | readm3u(lnk.file()); |
514 | tabWidget->setCurrentPage(0); | 492 | tabWidget->setCurrentPage(0); |
515 | } | 493 | } |
516 | } | 494 | } |
517 | 495 | ||
518 | void PlayListWidget::addSelected() { | 496 | void PlayListWidget::addSelected() { |
519 | assert( inFileListMode() ); | 497 | assert( inFileListMode() ); |
520 | 498 | ||
521 | QListView *fileListView = currentFileListView(); | 499 | QListView *fileListView = currentFileListView(); |
522 | QListViewItemIterator it( fileListView ); | 500 | QListViewItemIterator it( fileListView ); |
523 | for ( ; it.current(); ++it ) | 501 | for ( ; it.current(); ++it ) |
524 | if ( it.current()->isSelected() ) { | 502 | if ( it.current()->isSelected() ) { |
525 | QString filename = it.current()->text(3); | 503 | QString filename = it.current()->text(3); |
526 | 504 | ||
527 | DocLnk lnk; | 505 | DocLnk lnk; |
528 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name | 506 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name |
529 | lnk.setFile( filename ); //sets file name | 507 | lnk.setFile( filename ); //sets file name |
530 | 508 | ||
531 | d->selectedFiles->addToSelection( lnk ); | 509 | d->selectedFiles->addToSelection( lnk ); |
532 | } | 510 | } |
533 | 511 | ||
534 | fileListView->clearSelection(); | 512 | fileListView->clearSelection(); |
535 | 513 | ||
536 | tabWidget->setCurrentPage( 0 ); | 514 | tabWidget->setCurrentPage( 0 ); |
537 | writeCurrentM3u(); | 515 | writeCurrentM3u(); |
538 | } | 516 | } |
539 | 517 | ||
540 | 518 | ||
541 | void PlayListWidget::removeSelected() { | 519 | void PlayListWidget::removeSelected() { |
542 | d->selectedFiles->removeSelected( ); | 520 | d->selectedFiles->removeSelected( ); |
543 | writeCurrentM3u(); | 521 | writeCurrentM3u(); |
544 | } | 522 | } |
545 | 523 | ||
546 | 524 | ||
547 | void PlayListWidget::playIt( QListViewItem *it) { | 525 | void PlayListWidget::playIt( QListViewItem *it) { |
548 | if(!it) return; | 526 | if(!it) return; |
549 | mediaPlayerState->setPlaying(FALSE); | 527 | mediaPlayerState->setPlaying(FALSE); |
550 | mediaPlayerState->setPlaying(TRUE); | 528 | mediaPlayerState->setPlaying(TRUE); |
551 | d->selectedFiles->unSelect(); | 529 | d->selectedFiles->unSelect(); |
552 | } | 530 | } |
553 | 531 | ||
554 | 532 | ||
555 | void PlayListWidget::addToSelection( QListViewItem *it) { | 533 | void PlayListWidget::addToSelection( QListViewItem *it) { |
556 | d->setDocumentUsed = FALSE; | 534 | d->setDocumentUsed = FALSE; |
557 | 535 | ||
558 | if(it) { | 536 | if(it) { |
559 | if ( currentTab() == CurrentPlayList ) | 537 | if ( currentTab() == CurrentPlayList ) |
560 | return; | 538 | return; |
561 | // case 1: { | 539 | // case 1: { |
562 | DocLnk lnk; | 540 | DocLnk lnk; |
563 | QString filename; | 541 | QString filename; |
564 | 542 | ||
565 | filename=it->text(3); | 543 | filename=it->text(3); |
566 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 544 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
567 | lnk.setFile( filename ); //sets file name | 545 | lnk.setFile( filename ); //sets file name |
568 | d->selectedFiles->addToSelection( lnk); | 546 | d->selectedFiles->addToSelection( lnk); |
569 | 547 | ||
570 | writeCurrentM3u(); | 548 | writeCurrentM3u(); |
571 | tabWidget->setCurrentPage(0); | 549 | tabWidget->setCurrentPage(0); |
572 | 550 | ||
573 | } | 551 | } |
574 | } | 552 | } |
575 | 553 | ||
576 | 554 | ||
577 | void PlayListWidget::tabChanged(QWidget *) { | 555 | void PlayListWidget::tabChanged(QWidget *) { |
578 | 556 | ||
579 | d->tbPlay->setEnabled( true ); | 557 | d->tbPlay->setEnabled( true ); |
580 | 558 | ||
581 | switch ( currentTab() ) { | 559 | switch ( currentTab() ) { |
582 | case CurrentPlayList: | 560 | case CurrentPlayList: |
583 | { | 561 | { |
584 | if( !tbDeletePlaylist->isHidden() ) { | 562 | if( !tbDeletePlaylist->isHidden() ) { |
585 | tbDeletePlaylist->hide(); | 563 | tbDeletePlaylist->hide(); |
586 | } | 564 | } |
587 | d->tbRemoveFromList->setEnabled(TRUE); | 565 | d->tbRemoveFromList->setEnabled(TRUE); |
588 | d->tbAddToList->setEnabled(FALSE); | 566 | d->tbAddToList->setEnabled(FALSE); |
589 | } | 567 | } |
590 | break; | 568 | break; |
591 | case AudioFiles: | 569 | case AudioFiles: |
592 | { | 570 | { |
593 | // audioView->clear(); | 571 | // audioView->clear(); |
594 | if(!audioPopulated) populateAudioView(); | 572 | if(!audioPopulated) populateAudioView(); |
595 | 573 | ||
596 | if( !tbDeletePlaylist->isHidden() ) { | 574 | if( !tbDeletePlaylist->isHidden() ) { |
597 | tbDeletePlaylist->hide(); | 575 | tbDeletePlaylist->hide(); |
598 | } | 576 | } |
599 | d->tbRemoveFromList->setEnabled(FALSE); | 577 | d->tbRemoveFromList->setEnabled(FALSE); |
600 | d->tbAddToList->setEnabled(TRUE); | 578 | d->tbAddToList->setEnabled(TRUE); |
601 | } | 579 | } |
602 | break; | 580 | break; |
603 | case VideoFiles: | 581 | case VideoFiles: |
604 | { | 582 | { |
605 | // videoView->clear(); | 583 | // videoView->clear(); |
606 | if(!videoPopulated) populateVideoView(); | 584 | if(!videoPopulated) populateVideoView(); |
607 | if( !tbDeletePlaylist->isHidden() ) { | 585 | if( !tbDeletePlaylist->isHidden() ) { |
608 | tbDeletePlaylist->hide(); | 586 | tbDeletePlaylist->hide(); |
609 | } | 587 | } |
610 | d->tbRemoveFromList->setEnabled(FALSE); | 588 | d->tbRemoveFromList->setEnabled(FALSE); |
611 | d->tbAddToList->setEnabled(TRUE); | 589 | d->tbAddToList->setEnabled(TRUE); |
612 | } | 590 | } |
613 | break; | 591 | break; |
614 | case PlayLists: | 592 | case PlayLists: |
615 | { | 593 | { |
616 | if( tbDeletePlaylist->isHidden() ) { | 594 | if( tbDeletePlaylist->isHidden() ) { |
617 | tbDeletePlaylist->show(); | 595 | tbDeletePlaylist->show(); |
618 | } | 596 | } |
619 | playLists->reread(); | 597 | playLists->reread(); |
620 | d->tbAddToList->setEnabled(FALSE); | 598 | d->tbAddToList->setEnabled(FALSE); |
621 | 599 | ||
622 | d->tbPlay->setEnabled( false ); | 600 | d->tbPlay->setEnabled( false ); |
623 | } | 601 | } |
624 | break; | 602 | break; |
625 | }; | 603 | }; |
626 | } | 604 | } |
627 | 605 | ||
628 | 606 | ||
629 | void PlayListWidget::btnPlay(bool b) { | 607 | void PlayListWidget::btnPlay(bool b) { |
630 | // mediaPlayerState->setPlaying(false); | 608 | // mediaPlayerState->setPlaying(false); |
631 | mediaPlayerState->setPlaying(b); | 609 | mediaPlayerState->setPlaying(b); |
632 | insanityBool=FALSE; | 610 | insanityBool=FALSE; |
633 | } | 611 | } |
634 | 612 | ||
635 | void PlayListWidget::deletePlaylist() { | 613 | void PlayListWidget::deletePlaylist() { |
636 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 614 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
637 | (tr("You really want to delete\nthis playlist?")), | 615 | (tr("You really want to delete\nthis playlist?")), |
638 | (tr("Yes")), (tr("No")), 0 )){ | 616 | (tr("Yes")), (tr("No")), 0 )){ |
639 | case 0: // Yes clicked, | 617 | case 0: // Yes clicked, |
640 | QFile().remove(playLists->selectedDocument().file()); | 618 | QFile().remove(playLists->selectedDocument().file()); |
641 | QFile().remove(playLists->selectedDocument().linkFile()); | 619 | QFile().remove(playLists->selectedDocument().linkFile()); |
642 | playLists->reread(); | 620 | playLists->reread(); |
643 | break; | 621 | break; |
644 | case 1: // Cancel | 622 | case 1: // Cancel |
645 | break; | 623 | break; |
646 | }; | 624 | }; |
647 | } | 625 | } |
648 | 626 | ||
649 | 627 | ||
650 | void PlayListWidget::playSelected() { | 628 | void PlayListWidget::playSelected() { |
651 | btnPlay( TRUE); | 629 | btnPlay( TRUE); |
652 | } | 630 | } |
653 | 631 | ||
654 | 632 | ||
655 | void PlayListWidget::scanForAudio() { | 633 | void PlayListWidget::scanForAudio() { |
656 | // qDebug("scan for audio"); | 634 | // qDebug("scan for audio"); |
657 | files.detachChildren(); | 635 | files.detachChildren(); |
658 | QListIterator<DocLnk> sdit( files.children() ); | 636 | QListIterator<DocLnk> sdit( files.children() ); |
659 | for ( ; sdit.current(); ++sdit ) { | 637 | for ( ; sdit.current(); ++sdit ) { |
660 | delete sdit.current(); | 638 | delete sdit.current(); |
661 | } | 639 | } |
662 | // Global::findDocuments( &files, "audio/*"); | 640 | // Global::findDocuments( &files, "audio/*"); |
663 | Global::findDocuments( &files, audioMimes); | 641 | Global::findDocuments( &files, audioMimes); |
664 | audioScan = true; | 642 | audioScan = true; |
665 | populateAudioView(); | 643 | populateAudioView(); |
666 | } | 644 | } |
667 | 645 | ||
668 | void PlayListWidget::scanForVideo() { | 646 | void PlayListWidget::scanForVideo() { |
669 | // qDebug("scan for video"); | 647 | // qDebug("scan for video"); |
670 | vFiles.detachChildren(); | 648 | vFiles.detachChildren(); |
671 | QListIterator<DocLnk> sdit( vFiles.children() ); | 649 | QListIterator<DocLnk> sdit( vFiles.children() ); |
672 | for ( ; sdit.current(); ++sdit ) { | 650 | for ( ; sdit.current(); ++sdit ) { |
673 | delete sdit.current(); | 651 | delete sdit.current(); |
674 | } | 652 | } |
675 | Global::findDocuments(&vFiles, "video/*"); | 653 | Global::findDocuments(&vFiles, "video/*"); |
676 | videoScan = true; | 654 | videoScan = true; |
677 | populateVideoView(); | 655 | populateVideoView(); |
678 | } | 656 | } |
679 | 657 | ||
680 | void PlayListWidget::populateAudioView() { | 658 | void PlayListWidget::populateAudioView() { |
681 | audioView->clear(); | 659 | audioView->clear(); |
682 | StorageInfo storageInfo; | 660 | StorageInfo storageInfo; |
683 | // const QList<FileSystem> &fs = storageInfo.fileSystems(); | 661 | // const QList<FileSystem> &fs = storageInfo.fileSystems(); |
684 | if(!audioScan) { | 662 | if(!audioScan) { |
685 | scanForAudio(); | 663 | scanForAudio(); |
686 | } | 664 | } |
687 | 665 | ||
688 | QListIterator<DocLnk> dit( files.children() ); | 666 | QListIterator<DocLnk> dit( files.children() ); |
689 | // QListIterator<FileSystem> it ( fs ); | 667 | // QListIterator<FileSystem> it ( fs ); |
690 | audioView->clear(); | 668 | audioView->clear(); |
691 | 669 | ||
692 | QString storage; | 670 | QString storage; |
693 | for ( ; dit.current(); ++dit ) { | 671 | for ( ; dit.current(); ++dit ) { |
694 | // // for( ; it.current(); ++it ){ | 672 | // // for( ; it.current(); ++it ){ |
695 | // const QString name = (*dit)->name(); | 673 | // const QString name = (*dit)->name(); |
696 | // const QString path = (*dit)->path(); | 674 | // const QString path = (*dit)->path(); |
697 | // if(dit.current()->file().find(path) != -1 ) { | 675 | // if(dit.current()->file().find(path) != -1 ) { |
698 | // storage = name; | 676 | // storage = name; |
699 | // // } | 677 | // // } |
700 | // } | 678 | // } |
701 | 679 | ||
702 | QListViewItem * newItem; | 680 | QListViewItem * newItem; |
703 | if ( QFile( dit.current()->file()).exists() || | 681 | if ( QFile( dit.current()->file()).exists() || |
704 | dit.current()->file().left(4) == "http" ) { | 682 | dit.current()->file().left(4) == "http" ) { |
705 | long size; | 683 | long size; |
706 | if( dit.current()->file().left(4) == "http" ) | 684 | if( dit.current()->file().left(4) == "http" ) |
707 | size=0; | 685 | size=0; |
708 | else | 686 | else |
709 | size = QFile( dit.current()->file() ).size(); | 687 | size = QFile( dit.current()->file() ).size(); |
710 | 688 | ||
711 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 689 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
712 | QString::number(size ), "" /*storage*/, | 690 | QString::number(size ), "" /*storage*/, |
713 | dit.current()->file() ); | 691 | dit.current()->file() ); |
714 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); | 692 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); |
715 | // qDebug("<<<< "+dit.current()->file()); | 693 | // qDebug("<<<< "+dit.current()->file()); |
716 | } | 694 | } |
717 | } | 695 | } |
718 | audioPopulated=true; | 696 | audioPopulated=true; |
719 | } | 697 | } |
720 | 698 | ||
721 | 699 | ||
722 | void PlayListWidget::populateVideoView() { | 700 | void PlayListWidget::populateVideoView() { |
723 | videoView->clear(); | 701 | videoView->clear(); |
724 | StorageInfo storageInfo; | 702 | StorageInfo storageInfo; |
725 | // const QList<FileSystem> &fs = storageInfo.fileSystems(); | 703 | // const QList<FileSystem> &fs = storageInfo.fileSystems(); |
726 | 704 | ||
727 | if(!videoScan ) { | 705 | if(!videoScan ) { |
728 | scanForVideo(); | 706 | scanForVideo(); |
729 | } | 707 | } |
730 | 708 | ||
731 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 709 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
732 | // QListIterator<FileSystem> it ( fs ); | 710 | // QListIterator<FileSystem> it ( fs ); |
733 | videoView->clear(); | 711 | videoView->clear(); |
734 | QString storage, pathName; | 712 | QString storage, pathName; |
735 | for ( ; Vdit.current(); ++Vdit ) { | 713 | for ( ; Vdit.current(); ++Vdit ) { |
736 | // // for( ; it.current(); ++it ) { | 714 | // // for( ; it.current(); ++it ) { |
737 | // const QString name = (*Vdit)->name(); | 715 | // const QString name = (*Vdit)->name(); |
738 | // const QString path = (*Vdit)->path(); | 716 | // const QString path = (*Vdit)->path(); |
739 | // if( Vdit.current()->file().find(path) != -1 ) { | 717 | // if( Vdit.current()->file().find(path) != -1 ) { |
740 | // storage=name; | 718 | // storage=name; |
741 | // pathName=path; | 719 | // pathName=path; |
742 | // // } | 720 | // // } |
743 | // } | 721 | // } |
744 | 722 | ||
745 | QListViewItem * newItem; | 723 | QListViewItem * newItem; |
746 | if ( QFile( Vdit.current()->file() ).exists() ) { | 724 | if ( QFile( Vdit.current()->file() ).exists() ) { |
747 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 725 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
748 | QString::number( QFile( Vdit.current()->file() ).size() ), | 726 | QString::number( QFile( Vdit.current()->file() ).size() ), |
749 | ""/*storage*/, Vdit.current()->file()); | 727 | ""/*storage*/, Vdit.current()->file()); |
750 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); | 728 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); |
751 | } | 729 | } |
752 | } | 730 | } |
753 | videoPopulated=true; | 731 | videoPopulated=true; |
754 | } | 732 | } |
755 | 733 | ||
756 | QListView *PlayListWidget::currentFileListView() const | 734 | QListView *PlayListWidget::currentFileListView() const |
757 | { | 735 | { |
758 | switch ( currentTab() ) { | 736 | switch ( currentTab() ) { |
759 | case AudioFiles: return audioView; | 737 | case AudioFiles: return audioView; |
760 | case VideoFiles: return videoView; | 738 | case VideoFiles: return videoView; |
761 | default: assert( false ); | 739 | default: assert( false ); |
762 | } | 740 | } |
763 | return 0; | 741 | return 0; |
764 | } | 742 | } |
765 | 743 | ||
766 | bool PlayListWidget::inFileListMode() const | 744 | bool PlayListWidget::inFileListMode() const |
767 | { | 745 | { |
768 | TabType tab = currentTab(); | 746 | TabType tab = currentTab(); |
769 | return tab == AudioFiles || tab == VideoFiles; | 747 | return tab == AudioFiles || tab == VideoFiles; |
770 | } | 748 | } |
771 | 749 | ||
772 | void PlayListWidget::openFile() { | 750 | void PlayListWidget::openFile() { |
773 | // http://66.28.164.33:2080 | 751 | // http://66.28.164.33:2080 |
774 | // http://somafm.com/star0242.m3u | 752 | // http://somafm.com/star0242.m3u |
775 | QString filename, name; | 753 | QString filename, name; |
776 | InputDialog *fileDlg; | 754 | InputDialog *fileDlg; |
777 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 755 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
778 | fileDlg->exec(); | 756 | fileDlg->exec(); |
779 | if( fileDlg->result() == 1 ) { | 757 | if( fileDlg->result() == 1 ) { |
780 | filename = fileDlg->text(); | 758 | filename = fileDlg->text(); |
781 | qDebug( "Selected filename is " + filename ); | 759 | qDebug( "Selected filename is " + filename ); |
782 | // Om3u *m3uList; | 760 | // Om3u *m3uList; |
783 | DocLnk lnk; | 761 | DocLnk lnk; |
784 | Config cfg( "OpiePlayer" ); | 762 | Config cfg( "OpiePlayer" ); |
785 | cfg.setGroup("PlayList"); | 763 | cfg.setGroup("PlayList"); |
786 | 764 | ||
787 | if(filename.left(4) == "http") { | 765 | if(filename.left(4) == "http") { |
788 | QString m3uFile, m3uFilePath; | 766 | QString m3uFile, m3uFilePath; |
789 | if(filename.find(":",8,TRUE) != -1) { //found a port | 767 | if(filename.find(":",8,TRUE) != -1) { //found a port |
790 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 768 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
791 | m3uFile = m3uFile.right( 7); | 769 | m3uFile = m3uFile.right( 7); |
792 | } else if(filename.left(4) == "http"){ | 770 | } else if(filename.left(4) == "http"){ |
793 | m3uFile=filename; | 771 | m3uFile=filename; |
794 | m3uFile = m3uFile.right( m3uFile.length() - 7); | 772 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
795 | } else{ | 773 | } else{ |
796 | m3uFile=filename; | 774 | m3uFile=filename; |
797 | } | 775 | } |
798 | 776 | ||
799 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); | 777 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); |
800 | lnk.setName( filename ); //sets name | 778 | lnk.setName( filename ); //sets name |
801 | lnk.setFile( filename ); //sets file name | 779 | lnk.setFile( filename ); //sets file name |
802 | 780 | ||
803 | // lnk.setIcon("opieplayer2/musicfile"); | 781 | // lnk.setIcon("opieplayer2/musicfile"); |
804 | 782 | ||
805 | d->selectedFiles->addToSelection( lnk ); | 783 | d->selectedFiles->addToSelection( lnk ); |
806 | writeCurrentM3u(); | 784 | writeCurrentM3u(); |
807 | d->selectedFiles->setSelectedItem( lnk.name()); | 785 | d->selectedFiles->setSelectedItem( lnk.name()); |
808 | } | 786 | } |
809 | else if( filename.right( 3) == "m3u" ) { | 787 | else if( filename.right( 3) == "m3u" ) { |
810 | readm3u( filename ); | 788 | readm3u( filename ); |
811 | 789 | ||
812 | } else if( filename.right(3) == "pls" ) { | 790 | } else if( filename.right(3) == "pls" ) { |
813 | readPls( filename ); | 791 | readPls( filename ); |
814 | } else { | 792 | } else { |
815 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 793 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
816 | lnk.setFile( filename ); //sets file name | 794 | lnk.setFile( filename ); //sets file name |
817 | d->selectedFiles->addToSelection( lnk); | 795 | d->selectedFiles->addToSelection( lnk); |
818 | writeCurrentM3u(); | 796 | writeCurrentM3u(); |
819 | d->selectedFiles->setSelectedItem( lnk.name()); | 797 | d->selectedFiles->setSelectedItem( lnk.name()); |
820 | } | 798 | } |
821 | } | 799 | } |
822 | 800 | ||
823 | if( fileDlg ) { | 801 | if( fileDlg ) { |
824 | delete fileDlg; | 802 | delete fileDlg; |
825 | } | 803 | } |
826 | } | 804 | } |
827 | 805 | ||
828 | /* | 806 | /* |
829 | reads m3u and shows files/urls to playlist widget */ | 807 | reads m3u and shows files/urls to playlist widget */ |
830 | void PlayListWidget::readm3u( const QString &filename ) { | 808 | void PlayListWidget::readm3u( const QString &filename ) { |
831 | qDebug( "read m3u filename " + filename ); | 809 | qDebug( "read m3u filename " + filename ); |
832 | 810 | ||
833 | Om3u *m3uList; | 811 | Om3u *m3uList; |
834 | QString s, name; | 812 | QString s, name; |
835 | m3uList = new Om3u( filename, IO_ReadOnly ); | 813 | m3uList = new Om3u( filename, IO_ReadOnly ); |
836 | m3uList->readM3u(); | 814 | m3uList->readM3u(); |
837 | DocLnk lnk; | 815 | DocLnk lnk; |
838 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 816 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
839 | s = *it; | 817 | s = *it; |
840 | // qDebug("reading "+ s); | 818 | // qDebug("reading "+ s); |
841 | if(s.left(4)=="http") { | 819 | if(s.left(4)=="http") { |
842 | lnk.setName( s ); //sets file name | 820 | lnk.setName( s ); //sets file name |
843 | lnk.setIcon("opieplayer2/musicfile"); | 821 | lnk.setIcon("opieplayer2/musicfile"); |
844 | lnk.setFile( s ); //sets file name | 822 | lnk.setFile( s ); //sets file name |
845 | 823 | ||
846 | } else { | 824 | } else { |
847 | // if( QFileInfo( s ).exists() ) { | 825 | // if( QFileInfo( s ).exists() ) { |
848 | lnk.setName( QFileInfo(s).baseName()); | 826 | lnk.setName( QFileInfo(s).baseName()); |
849 | // if(s.right(4) == '.') {//if regular file | 827 | // if(s.right(4) == '.') {//if regular file |
850 | if(s.left(1) != "/") { | 828 | if(s.left(1) != "/") { |
851 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); | 829 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); |
852 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 830 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
853 | // lnk.setIcon(MimeType(s).pixmap() ); | 831 | // lnk.setIcon(MimeType(s).pixmap() ); |
854 | // lnk.setIcon("SoundPlayer"); | 832 | // lnk.setIcon("SoundPlayer"); |
855 | } else { | 833 | } else { |
856 | // qDebug("set link2 "+s); | 834 | // qDebug("set link2 "+s); |
857 | lnk.setFile( s); | 835 | lnk.setFile( s); |
858 | // lnk.setIcon(MimeType(s).pixmap() ); | 836 | // lnk.setIcon(MimeType(s).pixmap() ); |
859 | // lnk.setIcon("SoundPlayer"); | 837 | // lnk.setIcon("SoundPlayer"); |
860 | } | 838 | } |
861 | } | 839 | } |
862 | d->selectedFiles->addToSelection( lnk ); | 840 | d->selectedFiles->addToSelection( lnk ); |
863 | } | 841 | } |
864 | Config config( "OpiePlayer" ); | 842 | Config config( "OpiePlayer" ); |
865 | config.setGroup( "PlayList" ); | 843 | config.setGroup( "PlayList" ); |
866 | 844 | ||
867 | config.writeEntry("CurrentPlaylist",filename); | 845 | config.writeEntry("CurrentPlaylist",filename); |
868 | config.write(); | 846 | config.write(); |
869 | currentPlayList=filename; | 847 | currentPlayList=filename; |
870 | 848 | ||
871 | // m3uList->write(); | 849 | // m3uList->write(); |
872 | m3uList->close(); | 850 | m3uList->close(); |
873 | if(m3uList) delete m3uList; | 851 | if(m3uList) delete m3uList; |
874 | 852 | ||
875 | d->selectedFiles->setSelectedItem( s); | 853 | d->selectedFiles->setSelectedItem( s); |
876 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 854 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
877 | 855 | ||
878 | } | 856 | } |
879 | 857 | ||
880 | /* | 858 | /* |