author | llornkcor <llornkcor> | 2002-09-05 00:30:37 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-09-05 00:30:37 (UTC) |
commit | fd3239820e471044bf279a2964702573572859d6 (patch) (unidiff) | |
tree | e18b8ccd8cf76fced4395950c27563f2251017be | |
parent | 3f2a74813b552c6f7a4450ec6294bbbcc5b811c5 (diff) | |
download | opie-fd3239820e471044bf279a2964702573572859d6.zip opie-fd3239820e471044bf279a2964702573572859d6.tar.gz opie-fd3239820e471044bf279a2964702573572859d6.tar.bz2 |
remove unneeded code
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 133 |
1 files changed, 55 insertions, 78 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 15c70c3..2b58402 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -104,662 +104,639 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
104 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), | 104 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), |
105 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 105 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
106 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), | 106 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), |
107 | this,SLOT( playIt( QListViewItem *) ) ); | 107 | this,SLOT( playIt( QListViewItem *) ) ); |
108 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 108 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
109 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 109 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), |
110 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); | 110 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); |
111 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), | 111 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), |
112 | this,SLOT( playIt( QListViewItem *) ) ); | 112 | this,SLOT( playIt( QListViewItem *) ) ); |
113 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 113 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
114 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 114 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
115 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), this, SLOT( tabChanged( QWidget* ) ) ); | 115 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), this, SLOT( tabChanged( QWidget* ) ) ); |
116 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 116 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
117 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 117 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
118 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 118 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
119 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 119 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
120 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 120 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
121 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), mediaPlayerState, SLOT( setVideoGamma( int ) ) ); | 121 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), mediaPlayerState, SLOT( setVideoGamma( int ) ) ); |
122 | 122 | ||
123 | readConfig( cfg ); | 123 | readConfig( cfg ); |
124 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "" ); | 124 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "" ); |
125 | loadList(DocLnk( currentPlaylist ) ); | 125 | loadList(DocLnk( currentPlaylist ) ); |
126 | setCaption( tr( "OpiePlayer: " ) + currentPlaylist ); | 126 | setCaption( tr( "OpiePlayer: " ) + currentPlaylist ); |
127 | 127 | ||
128 | // see which skins are installed | 128 | // see which skins are installed |
129 | videoScan=FALSE; | 129 | videoScan=FALSE; |
130 | audioScan=FALSE; | 130 | audioScan=FALSE; |
131 | populateSkinsMenu(); | 131 | populateSkinsMenu(); |
132 | initializeStates(); | 132 | initializeStates(); |
133 | } | 133 | } |
134 | 134 | ||
135 | 135 | ||
136 | PlayListWidget::~PlayListWidget() { | 136 | PlayListWidget::~PlayListWidget() { |
137 | // WTF?!@?! | 137 | // WTF?!@?! |
138 | 138 | ||
139 | if ( d->current ) { | 139 | if ( d->current ) { |
140 | delete d->current; | 140 | delete d->current; |
141 | } | 141 | } |
142 | delete d; | 142 | delete d; |
143 | } | 143 | } |
144 | 144 | ||
145 | 145 | ||
146 | void PlayListWidget::initializeStates() { | 146 | void PlayListWidget::initializeStates() { |
147 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 147 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
148 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 148 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
149 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 149 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
150 | setPlaylist( true ); | 150 | setPlaylist( true ); |
151 | } | 151 | } |
152 | 152 | ||
153 | 153 | ||
154 | void PlayListWidget::readConfig( Config& cfg ) { | 154 | void PlayListWidget::readConfig( Config& cfg ) { |
155 | cfg.setGroup( "PlayList" ); | 155 | cfg.setGroup( "PlayList" ); |
156 | QString currentString = cfg.readEntry( "current", "" ); | 156 | QString currentString = cfg.readEntry( "current", "" ); |
157 | int noOfFiles = cfg.readNumEntry( "NumberOfFiles", 0 ); | 157 | int noOfFiles = cfg.readNumEntry( "NumberOfFiles", 0 ); |
158 | for ( int i = 0; i < noOfFiles; i++ ) { | 158 | for ( int i = 0; i < noOfFiles; i++ ) { |
159 | QString entryName; | 159 | QString entryName; |
160 | entryName.sprintf( "File%i", i + 1 ); | 160 | entryName.sprintf( "File%i", i + 1 ); |
161 | QString linkFile = cfg.readEntry( entryName ); | 161 | QString linkFile = cfg.readEntry( entryName ); |
162 | if( QFileInfo( linkFile ).exists() ) { | 162 | if( QFileInfo( linkFile ).exists() ) { |
163 | DocLnk lnk( linkFile ); | 163 | DocLnk lnk( linkFile ); |
164 | if ( QFileInfo( lnk.file() ).exists() || linkFile.find( "http" , 0, TRUE) != -1) { | 164 | if ( QFileInfo( lnk.file() ).exists() || linkFile.find( "http" , 0, TRUE) != -1) { |
165 | d->selectedFiles->addToSelection( lnk ); | 165 | d->selectedFiles->addToSelection( lnk ); |
166 | } | 166 | } |
167 | } | 167 | } |
168 | } | 168 | } |
169 | d->selectedFiles->setSelectedItem( currentString ); | 169 | d->selectedFiles->setSelectedItem( currentString ); |
170 | } | 170 | } |
171 | 171 | ||
172 | 172 | ||
173 | void PlayListWidget::writeConfig( Config& cfg ) const { | 173 | void PlayListWidget::writeConfig( Config& cfg ) const { |
174 | d->selectedFiles->writeCurrent( cfg ); | 174 | d->selectedFiles->writeCurrent( cfg ); |
175 | cfg.setGroup( "PlayList" ); | 175 | cfg.setGroup( "PlayList" ); |
176 | int noOfFiles = 0; | 176 | int noOfFiles = 0; |
177 | d->selectedFiles->first(); | 177 | d->selectedFiles->first(); |
178 | do { | 178 | do { |
179 | const DocLnk *lnk = d->selectedFiles->current(); | 179 | const DocLnk *lnk = d->selectedFiles->current(); |
180 | if ( lnk ) { | 180 | if ( lnk ) { |
181 | QString entryName; | 181 | QString entryName; |
182 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 182 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
183 | cfg.writeEntry( entryName, lnk->linkFile() ); | 183 | cfg.writeEntry( entryName, lnk->linkFile() ); |
184 | // if this link does exist, add it so we have the file | 184 | // if this link does exist, add it so we have the file |
185 | // next time... | 185 | // next time... |
186 | if ( !QFile::exists( lnk->linkFile() ) ) { | 186 | if ( !QFile::exists( lnk->linkFile() ) ) { |
187 | // the way writing lnks doesn't really check for out | 187 | // the way writing lnks doesn't really check for out |
188 | // of disk space, but check it anyway. | 188 | // of disk space, but check it anyway. |
189 | if ( !lnk->writeLink() ) { | 189 | if ( !lnk->writeLink() ) { |
190 | QMessageBox::critical( 0, tr("Out of space"), | 190 | QMessageBox::critical( 0, tr("Out of space"), |
191 | tr( "There was a problem saving " | 191 | tr( "There was a problem saving " |
192 | "the playlist.\n" | 192 | "the playlist.\n" |
193 | "Your playlist " | 193 | "Your playlist " |
194 | "may be missing some entries\n" | 194 | "may be missing some entries\n" |
195 | "the next time you start it." ) | 195 | "the next time you start it." ) |
196 | ); | 196 | ); |
197 | } | 197 | } |
198 | } | 198 | } |
199 | noOfFiles++; | 199 | noOfFiles++; |
200 | } | 200 | } |
201 | } | 201 | } |
202 | while ( d->selectedFiles->next() ); | 202 | while ( d->selectedFiles->next() ); |
203 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 203 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
204 | } | 204 | } |
205 | 205 | ||
206 | 206 | ||
207 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 207 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
208 | d->setDocumentUsed = FALSE; | 208 | d->setDocumentUsed = FALSE; |
209 | if ( mediaPlayerState->playlist() ) { | 209 | if ( mediaPlayerState->playlist() ) { |
210 | if( QFileInfo( lnk.file() ).exists() || lnk.file().left(4) == "http" ) | 210 | if( QFileInfo( lnk.file() ).exists() || lnk.file().left(4) == "http" ) |
211 | d->selectedFiles->addToSelection( lnk ); | 211 | d->selectedFiles->addToSelection( lnk ); |
212 | } | 212 | } |
213 | else | 213 | else |
214 | mediaPlayerState->setPlaying( TRUE ); | 214 | mediaPlayerState->setPlaying( TRUE ); |
215 | } | 215 | } |
216 | 216 | ||
217 | 217 | ||
218 | void PlayListWidget::clearList() { | 218 | void PlayListWidget::clearList() { |
219 | while ( first() ) { | 219 | while ( first() ) { |
220 | d->selectedFiles->removeSelected(); | 220 | d->selectedFiles->removeSelected(); |
221 | } | 221 | } |
222 | } | 222 | } |
223 | 223 | ||
224 | 224 | ||
225 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 225 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
226 | switch (mouse) { | 226 | switch (mouse) { |
227 | case 1: | 227 | case 1: |
228 | break; | 228 | break; |
229 | case 2: | 229 | case 2: |
230 | { | 230 | { |
231 | QPopupMenu m; | 231 | QPopupMenu m; |
232 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 232 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
233 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 233 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
234 | m.exec( QCursor::pos() ); | 234 | m.exec( QCursor::pos() ); |
235 | } | 235 | } |
236 | break; | 236 | break; |
237 | } | 237 | } |
238 | } | 238 | } |
239 | 239 | ||
240 | 240 | ||
241 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 241 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
242 | switch (mouse) { | 242 | switch (mouse) { |
243 | case 1: | 243 | case 1: |
244 | break; | 244 | break; |
245 | case 2: | 245 | case 2: |
246 | { | 246 | { |
247 | QPopupMenu m; | 247 | QPopupMenu m; |
248 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 248 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
249 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 249 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
250 | m.exec( QCursor::pos() ); | 250 | m.exec( QCursor::pos() ); |
251 | } | 251 | } |
252 | break; | 252 | break; |
253 | } | 253 | } |
254 | } | 254 | } |
255 | 255 | ||
256 | 256 | ||
257 | void PlayListWidget::addAllToList() { | 257 | void PlayListWidget::addAllToList() { |
258 | DocLnkSet filesAll; | 258 | DocLnkSet filesAll; |
259 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 259 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
260 | QListIterator<DocLnk> Adit( filesAll.children() ); | 260 | QListIterator<DocLnk> Adit( filesAll.children() ); |
261 | for ( ; Adit.current(); ++Adit ) { | 261 | for ( ; Adit.current(); ++Adit ) { |
262 | if( QFileInfo( Adit.current()->file() ).exists() ) { | 262 | if( QFileInfo( Adit.current()->file() ).exists() ) { |
263 | d->selectedFiles->addToSelection( **Adit ); | 263 | d->selectedFiles->addToSelection( **Adit ); |
264 | } | 264 | } |
265 | } | 265 | } |
266 | } | 266 | } |
267 | 267 | ||
268 | 268 | ||
269 | void PlayListWidget::addAllMusicToList() { | 269 | void PlayListWidget::addAllMusicToList() { |
270 | QListIterator<DocLnk> dit( files.children() ); | 270 | QListIterator<DocLnk> dit( files.children() ); |
271 | for ( ; dit.current(); ++dit ) { | 271 | for ( ; dit.current(); ++dit ) { |
272 | if( QFileInfo(dit.current()->file() ).exists() ) { | 272 | if( QFileInfo(dit.current()->file() ).exists() ) { |
273 | d->selectedFiles->addToSelection( **dit ); | 273 | d->selectedFiles->addToSelection( **dit ); |
274 | } | 274 | } |
275 | } | 275 | } |
276 | } | 276 | } |
277 | 277 | ||
278 | 278 | ||
279 | void PlayListWidget::addAllVideoToList() { | 279 | void PlayListWidget::addAllVideoToList() { |
280 | QListIterator<DocLnk> dit( vFiles.children() ); | 280 | QListIterator<DocLnk> dit( vFiles.children() ); |
281 | for ( ; dit.current(); ++dit ) { | 281 | for ( ; dit.current(); ++dit ) { |
282 | if( QFileInfo( dit.current()->file() ).exists() ) { | 282 | if( QFileInfo( dit.current()->file() ).exists() ) { |
283 | d->selectedFiles->addToSelection( **dit ); | 283 | d->selectedFiles->addToSelection( **dit ); |
284 | } | 284 | } |
285 | } | 285 | } |
286 | } | 286 | } |
287 | 287 | ||
288 | 288 | ||
289 | void PlayListWidget::setDocument( const QString& fileref ) { | 289 | void PlayListWidget::setDocument( const QString& fileref ) { |
290 | //qDebug( fileref ); | 290 | //qDebug( fileref ); |
291 | fromSetDocument = TRUE; | 291 | fromSetDocument = TRUE; |
292 | if ( fileref.isNull() ) { | 292 | if ( fileref.isNull() ) { |
293 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 293 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
294 | return; | 294 | return; |
295 | } | 295 | } |
296 | 296 | ||
297 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u | 297 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u |
298 | readm3u( fileref ); | 298 | readm3u( fileref ); |
299 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls | 299 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls |
300 | readPls( fileref ); | 300 | readPls( fileref ); |
301 | } else if( fileref.find( "playlist", 0, TRUE) != -1 ) {//is playlist | 301 | } else if( fileref.find( "playlist", 0, TRUE) != -1 ) {//is playlist |
302 | clearList(); | 302 | clearList(); |
303 | loadList( DocLnk( fileref ) ); | 303 | loadList( DocLnk( fileref ) ); |
304 | d->selectedFiles->first(); | 304 | d->selectedFiles->first(); |
305 | } else { | 305 | } else { |
306 | clearList(); | 306 | clearList(); |
307 | addToSelection( DocLnk( fileref ) ); | 307 | addToSelection( DocLnk( fileref ) ); |
308 | d->setDocumentUsed = TRUE; | 308 | d->setDocumentUsed = TRUE; |
309 | mediaPlayerState->setPlaying( FALSE ); | 309 | mediaPlayerState->setPlaying( FALSE ); |
310 | qApp->processEvents(); | 310 | qApp->processEvents(); |
311 | mediaPlayerState->setPlaying( TRUE ); | 311 | mediaPlayerState->setPlaying( TRUE ); |
312 | qApp->processEvents(); | 312 | qApp->processEvents(); |
313 | setCaption( tr("OpiePlayer") ); | 313 | setCaption( tr("OpiePlayer") ); |
314 | } | 314 | } |
315 | } | 315 | } |
316 | 316 | ||
317 | 317 | ||
318 | void PlayListWidget::useSelectedDocument() { | 318 | void PlayListWidget::useSelectedDocument() { |
319 | d->setDocumentUsed = FALSE; | 319 | d->setDocumentUsed = FALSE; |
320 | } | 320 | } |
321 | 321 | ||
322 | 322 | ||
323 | const DocLnk *PlayListWidget::current() { // this is fugly | 323 | const DocLnk *PlayListWidget::current() { // this is fugly |
324 | switch ( whichList() ) { | 324 | switch ( whichList() ) { |
325 | case 0: //playlist | 325 | case 0: //playlist |
326 | { | 326 | { |
327 | // qDebug("playlist"); | 327 | // qDebug("playlist"); |
328 | if ( mediaPlayerState->playlist() ) { | 328 | if ( mediaPlayerState->playlist() ) { |
329 | return d->selectedFiles->current(); | 329 | return d->selectedFiles->current(); |
330 | } else if ( d->setDocumentUsed && d->current ) { | 330 | } else if ( d->setDocumentUsed && d->current ) { |
331 | return d->current; | 331 | return d->current; |
332 | } else { | 332 | } else { |
333 | return d->files->selected(); | 333 | return d->files->selected(); |
334 | } | 334 | } |
335 | } | 335 | } |
336 | break; | 336 | break; |
337 | case 1://audio | ||
338 | { | ||
339 | // qDebug("audioView"); | ||
340 | QListIterator<DocLnk> dit( files.children() ); | ||
341 | for ( ; dit.current(); ++dit ) { | ||
342 | if( dit.current()->name() == audioView->currentItem()->text( 0 ) && !insanityBool ) { | ||
343 | insanityBool = TRUE; | ||
344 | return dit; | ||
345 | } | ||
346 | } | ||
347 | } | ||
348 | break; | ||
349 | case 2: // video | ||
350 | { | ||
351 | // qDebug("videoView"); | ||
352 | QListIterator<DocLnk> Vdit( vFiles.children() ); | ||
353 | for ( ; Vdit.current(); ++Vdit ) { | ||
354 | if( Vdit.current()->name() == videoView->currentItem()->text( 0 ) && !insanityBool) { | ||
355 | insanityBool = TRUE; | ||
356 | return Vdit; | ||
357 | } | ||
358 | } | ||
359 | } | ||
360 | break; | ||
361 | }; | 337 | }; |
362 | return 0; | 338 | return 0; |
363 | } | 339 | } |
364 | 340 | ||
365 | 341 | ||
366 | bool PlayListWidget::prev() { | 342 | bool PlayListWidget::prev() { |
367 | if ( mediaPlayerState->playlist() ) { | 343 | if ( mediaPlayerState->playlist() ) { |
368 | if ( mediaPlayerState->shuffled() ) { | 344 | if ( mediaPlayerState->shuffled() ) { |
369 | const DocLnk *cur = current(); | 345 | const DocLnk *cur = current(); |
370 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 346 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
371 | for ( int i = 0; i < j; i++ ) { | 347 | for ( int i = 0; i < j; i++ ) { |
372 | if ( !d->selectedFiles->next() ) | 348 | if ( !d->selectedFiles->next() ) |
373 | d->selectedFiles->first(); | 349 | d->selectedFiles->first(); |
374 | } | 350 | } |
375 | if ( cur == current() ) | 351 | if ( cur == current() ) |
376 | if ( !d->selectedFiles->next() ) { | 352 | if ( !d->selectedFiles->next() ) { |
377 | d->selectedFiles->first(); | 353 | d->selectedFiles->first(); |
378 | } | 354 | } |
379 | return TRUE; | 355 | return TRUE; |
380 | } else { | 356 | } else { |
381 | if ( !d->selectedFiles->prev() ) { | 357 | if ( !d->selectedFiles->prev() ) { |
382 | if ( mediaPlayerState->looping() ) { | 358 | if ( mediaPlayerState->looping() ) { |
383 | return d->selectedFiles->last(); | 359 | return d->selectedFiles->last(); |
384 | } else { | 360 | } else { |
385 | return FALSE; | 361 | return FALSE; |
386 | } | 362 | } |
387 | } | 363 | } |
388 | return TRUE; | 364 | return TRUE; |
389 | } | 365 | } |
390 | } else { | 366 | } else { |
391 | return mediaPlayerState->looping(); | 367 | return mediaPlayerState->looping(); |
392 | } | 368 | } |
393 | } | 369 | } |
394 | 370 | ||
395 | 371 | ||
396 | bool PlayListWidget::next() { | 372 | bool PlayListWidget::next() { |
397 | qDebug("<<<<<<<<<<<<next()"); | 373 | qDebug("<<<<<<<<<<<<next()"); |
398 | if ( mediaPlayerState->playlist() ) { | 374 | if ( mediaPlayerState->playlist() ) { |
399 | if ( mediaPlayerState->shuffled() ) { | 375 | if ( mediaPlayerState->shuffled() ) { |
400 | return prev(); | 376 | return prev(); |
401 | } else { | 377 | } else { |
402 | if ( !d->selectedFiles->next() ) { | 378 | if ( !d->selectedFiles->next() ) { |
403 | if ( mediaPlayerState->looping() ) { | 379 | if ( mediaPlayerState->looping() ) { |
404 | return d->selectedFiles->first(); | 380 | return d->selectedFiles->first(); |
405 | } else { | 381 | } else { |
406 | return FALSE; | 382 | return FALSE; |
407 | } | 383 | } |
408 | } | 384 | } |
409 | return TRUE; | 385 | return TRUE; |
410 | } | 386 | } |
411 | } else { | 387 | } else { |
412 | return mediaPlayerState->looping(); | 388 | return mediaPlayerState->looping(); |
413 | } | 389 | } |
414 | } | 390 | } |
415 | 391 | ||
416 | 392 | ||
417 | bool PlayListWidget::first() { | 393 | bool PlayListWidget::first() { |
418 | if ( mediaPlayerState->playlist() ) | 394 | if ( mediaPlayerState->playlist() ) |
419 | return d->selectedFiles->first(); | 395 | return d->selectedFiles->first(); |
420 | else | 396 | else |
421 | return mediaPlayerState->looping(); | 397 | return mediaPlayerState->looping(); |
422 | } | 398 | } |
423 | 399 | ||
424 | 400 | ||
425 | bool PlayListWidget::last() { | 401 | bool PlayListWidget::last() { |
426 | if ( mediaPlayerState->playlist() ) | 402 | if ( mediaPlayerState->playlist() ) |
427 | return d->selectedFiles->last(); | 403 | return d->selectedFiles->last(); |
428 | else | 404 | else |
429 | return mediaPlayerState->looping(); | 405 | return mediaPlayerState->looping(); |
430 | } | 406 | } |
431 | 407 | ||
432 | 408 | ||
433 | void PlayListWidget::saveList() { | 409 | void PlayListWidget::saveList() { |
434 | 410 | ||
435 | QString filename; | 411 | QString filename; |
436 | InputDialog *fileDlg = 0l; | 412 | InputDialog *fileDlg = 0l; |
437 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); | 413 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); |
438 | fileDlg->exec(); | 414 | fileDlg->exec(); |
439 | if( fileDlg->result() == 1 ) { | 415 | if( fileDlg->result() == 1 ) { |
440 | if ( d->current ) | 416 | if ( d->current ) |
441 | delete d->current; | 417 | delete d->current; |
442 | filename = fileDlg->text();//+".playlist"; | 418 | filename = fileDlg->text();//+".playlist"; |
443 | // qDebug("saving playlist "+filename+".playlist"); | 419 | // qDebug("saving playlist "+filename+".playlist"); |
444 | Config cfg( filename +".playlist"); | 420 | Config cfg( filename +".playlist"); |
445 | writeConfig( cfg ); | 421 | writeConfig( cfg ); |
446 | 422 | ||
447 | DocLnk lnk; | 423 | DocLnk lnk; |
448 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property | 424 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property |
449 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | 425 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D |
450 | lnk.setIcon("opieplayer2/playlist2"); | 426 | lnk.setIcon("opieplayer2/playlist2"); |
451 | lnk.setName( filename); //sets file name | 427 | lnk.setName( filename); //sets file name |
452 | // qDebug(filename); | 428 | // qDebug(filename); |
453 | if(!lnk.writeLink()) { | 429 | if(!lnk.writeLink()) { |
454 | qDebug("Writing doclink did not work"); | 430 | qDebug("Writing doclink did not work"); |
455 | } | 431 | } |
456 | } | 432 | } |
457 | Config config( "OpiePlayer" ); | 433 | Config config( "OpiePlayer" ); |
458 | config.writeEntry("CurrentPlaylist",filename); | 434 | config.writeEntry("CurrentPlaylist",filename); |
459 | setCaption(tr("OpiePlayer: ")+filename); | 435 | setCaption(tr("OpiePlayer: ")+filename); |
460 | d->selectedFiles->first(); | 436 | d->selectedFiles->first(); |
461 | if(fileDlg) { | 437 | if(fileDlg) { |
462 | delete fileDlg; | 438 | delete fileDlg; |
463 | } | 439 | } |
464 | } | 440 | } |
465 | 441 | ||
466 | void PlayListWidget::loadList( const DocLnk & lnk) { | 442 | void PlayListWidget::loadList( const DocLnk & lnk) { |
467 | QString name= lnk.name(); | 443 | QString name= lnk.name(); |
468 | // qDebug("currentList is "+name); | 444 | // qDebug("currentList is "+name); |
469 | if( name.length()>1) { | 445 | if( name.length()>1) { |
470 | setCaption("OpiePlayer: "+name); | 446 | setCaption("OpiePlayer: "+name); |
471 | // qDebug("load list "+ name+".playlist"); | 447 | // qDebug("load list "+ name+".playlist"); |
472 | clearList(); | 448 | clearList(); |
473 | Config cfg( name+".playlist"); | 449 | Config cfg( name+".playlist"); |
474 | readConfig(cfg); | 450 | readConfig(cfg); |
475 | 451 | ||
476 | tabWidget->setCurrentPage(0); | 452 | tabWidget->setCurrentPage(0); |
477 | 453 | ||
478 | Config config( "OpiePlayer" ); | 454 | Config config( "OpiePlayer" ); |
479 | config.writeEntry("CurrentPlaylist", name); | 455 | config.writeEntry("CurrentPlaylist", name); |
480 | // d->selectedFiles->first(); | 456 | // d->selectedFiles->first(); |
481 | } | 457 | } |
482 | } | 458 | } |
483 | 459 | ||
484 | 460 | ||
485 | void PlayListWidget::setPlaylist( bool shown ) { | 461 | void PlayListWidget::setPlaylist( bool shown ) { |
486 | if ( shown ) { | 462 | if ( shown ) { |
487 | d->playListFrame->show(); | 463 | d->playListFrame->show(); |
488 | } else { | 464 | } else { |
489 | d->playListFrame->hide(); | 465 | d->playListFrame->hide(); |
490 | } | 466 | } |
491 | } | 467 | } |
492 | 468 | ||
493 | 469 | ||
494 | void PlayListWidget::addSelected() { | 470 | void PlayListWidget::addSelected() { |
495 | 471 | ||
496 | Config cfg( "OpiePlayer" ); | 472 | Config cfg( "OpiePlayer" ); |
497 | cfg.setGroup("PlayList"); | 473 | cfg.setGroup("PlayList"); |
498 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 474 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
499 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 475 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
500 | 476 | ||
501 | switch (whichList()) { | 477 | switch (whichList()) { |
502 | case 0: //playlist | 478 | case 0: //playlist |
503 | break; | 479 | break; |
504 | case 1: { //audio | 480 | case 1: { //audio |
505 | QListViewItemIterator it( audioView ); | 481 | QListViewItemIterator it( audioView ); |
506 | // iterate through all items of the listview | 482 | // iterate through all items of the listview |
507 | for ( ; it.current(); ++it ) { | 483 | for ( ; it.current(); ++it ) { |
508 | if ( it.current()->isSelected() ) { | 484 | if ( it.current()->isSelected() ) { |
509 | QListIterator<DocLnk> dit( files.children() ); | 485 | QListIterator<DocLnk> dit( files.children() ); |
510 | for ( ; dit.current(); ++dit ) { | 486 | for ( ; dit.current(); ++dit ) { |
511 | if( dit.current()->name() == it.current()->text(0) ) { | 487 | if( dit.current()->name() == it.current()->text(0) ) { |
512 | if(QFileInfo( dit.current()->file()).exists()) | 488 | if(QFileInfo( dit.current()->file()).exists()) |
513 | d->selectedFiles->addToSelection( **dit ); | 489 | d->selectedFiles->addToSelection( **dit ); |
514 | } | 490 | } |
515 | } | 491 | } |
516 | audioView->setSelected( it.current(),FALSE); | 492 | audioView->setSelected( it.current(),FALSE); |
517 | } | 493 | } |
518 | } | 494 | } |
519 | tabWidget->setCurrentPage(0); | 495 | tabWidget->setCurrentPage(0); |
520 | } | 496 | } |
521 | break; | 497 | break; |
522 | case 2: { // video | 498 | case 2: { // video |
523 | QListViewItemIterator it( videoView ); | 499 | QListViewItemIterator it( videoView ); |
524 | // iterate through all items of the listview | 500 | // iterate through all items of the listview |
525 | for ( ; it.current(); ++it ) { | 501 | for ( ; it.current(); ++it ) { |
526 | if ( it.current()->isSelected() ) { | 502 | if ( it.current()->isSelected() ) { |
527 | QListIterator<DocLnk> dit( vFiles.children() ); | 503 | QListIterator<DocLnk> dit( vFiles.children() ); |
528 | for ( ; dit.current(); ++dit ) { | 504 | for ( ; dit.current(); ++dit ) { |
529 | if( dit.current()->name() == it.current()->text(0) ) { | 505 | if( dit.current()->name() == it.current()->text(0) ) { |
530 | if(QFileInfo( dit.current()->file()).exists()) | 506 | if(QFileInfo( dit.current()->file()).exists()) |
531 | d->selectedFiles->addToSelection( **dit ); | 507 | d->selectedFiles->addToSelection( **dit ); |
532 | } | 508 | } |
533 | } | 509 | } |
534 | videoView->setSelected( it.current(),FALSE); | 510 | videoView->setSelected( it.current(),FALSE); |
535 | } | 511 | } |
536 | } | 512 | } |
537 | tabWidget->setCurrentPage(0); | 513 | tabWidget->setCurrentPage(0); |
538 | } | 514 | } |
539 | break; | 515 | break; |
540 | }; | 516 | }; |
541 | } | 517 | } |
542 | 518 | ||
543 | 519 | ||
544 | void PlayListWidget::removeSelected() { | 520 | void PlayListWidget::removeSelected() { |
545 | d->selectedFiles->removeSelected( ); | 521 | d->selectedFiles->removeSelected( ); |
546 | } | 522 | } |
547 | 523 | ||
548 | 524 | ||
549 | void PlayListWidget::playIt( QListViewItem *it) { | 525 | void PlayListWidget::playIt( QListViewItem *it) { |
550 | if(!it) return; | 526 | if(!it) return; |
551 | mediaPlayerState->setPlaying(FALSE); | 527 | mediaPlayerState->setPlaying(FALSE); |
552 | mediaPlayerState->setPlaying(TRUE); | 528 | mediaPlayerState->setPlaying(TRUE); |
553 | d->selectedFiles->unSelect(); | 529 | d->selectedFiles->unSelect(); |
554 | } | 530 | } |
555 | 531 | ||
556 | 532 | ||
557 | void PlayListWidget::addToSelection( QListViewItem *it) { | 533 | void PlayListWidget::addToSelection( QListViewItem *it) { |
558 | d->setDocumentUsed = FALSE; | 534 | d->setDocumentUsed = FALSE; |
559 | 535 | ||
560 | if(it) { | 536 | if(it) { |
561 | switch ( whichList()) { | 537 | switch ( whichList()) { |
562 | case 1: { | 538 | case 1: { |
563 | QListIterator<DocLnk> dit( files.children() ); | 539 | QListIterator<DocLnk> dit( files.children() ); |
564 | for ( ; dit.current(); ++dit ) { | 540 | for ( ; dit.current(); ++dit ) { |
565 | if( dit.current()->name() == it->text(0)) { | 541 | if( dit.current()->name() == it->text(0)) { |
566 | if(QFileInfo( dit.current()->file()).exists()) | 542 | if(QFileInfo( dit.current()->file()).exists()) |
567 | d->selectedFiles->addToSelection( **dit ); | 543 | d->selectedFiles->addToSelection( **dit ); |
568 | } | 544 | } |
569 | } | 545 | } |
570 | } | 546 | } |
571 | break; | 547 | break; |
572 | case 2: { | 548 | case 2: { |
573 | QListIterator<DocLnk> dit( vFiles.children() ); | 549 | QListIterator<DocLnk> dit( vFiles.children() ); |
574 | for ( ; dit.current(); ++dit ) { | 550 | for ( ; dit.current(); ++dit ) { |
575 | if( dit.current()->name() == it->text(0)) { | 551 | if( dit.current()->name() == it->text(0)) { |
576 | if(QFileInfo( dit.current()->file()).exists()) | 552 | if(QFileInfo( dit.current()->file()).exists()) |
577 | d->selectedFiles->addToSelection( **dit ); | 553 | d->selectedFiles->addToSelection( **dit ); |
578 | } | 554 | } |
579 | } | 555 | } |
580 | } | 556 | } |
581 | break; | 557 | break; |
582 | case 0: | 558 | case 0: |
583 | break; | 559 | break; |
584 | }; | 560 | }; |
585 | tabWidget->setCurrentPage(0); | 561 | tabWidget->setCurrentPage(0); |
586 | } | 562 | } |
587 | } | 563 | } |
588 | 564 | ||
589 | 565 | ||
590 | void PlayListWidget::tabChanged(QWidget *) { | 566 | void PlayListWidget::tabChanged(QWidget *) { |
591 | 567 | ||
592 | switch ( whichList()) { | 568 | switch ( whichList()) { |
593 | case 0: | 569 | case 0: |
594 | { | 570 | { |
595 | if( !tbDeletePlaylist->isHidden() ) { | 571 | if( !tbDeletePlaylist->isHidden() ) { |
596 | tbDeletePlaylist->hide(); | 572 | tbDeletePlaylist->hide(); |
597 | } | 573 | } |
598 | d->tbRemoveFromList->setEnabled(TRUE); | 574 | d->tbRemoveFromList->setEnabled(TRUE); |
599 | d->tbAddToList->setEnabled(FALSE); | 575 | d->tbAddToList->setEnabled(FALSE); |
600 | } | 576 | } |
601 | break; | 577 | break; |
602 | case 1: | 578 | case 1: |
603 | { | 579 | { |
604 | audioView->clear(); | 580 | audioView->clear(); |
605 | populateAudioView(); | 581 | populateAudioView(); |
606 | 582 | ||
607 | if( !tbDeletePlaylist->isHidden() ) { | 583 | if( !tbDeletePlaylist->isHidden() ) { |
608 | tbDeletePlaylist->hide(); | 584 | tbDeletePlaylist->hide(); |
609 | } | 585 | } |
610 | d->tbRemoveFromList->setEnabled(FALSE); | 586 | d->tbRemoveFromList->setEnabled(FALSE); |
611 | d->tbAddToList->setEnabled(TRUE); | 587 | d->tbAddToList->setEnabled(TRUE); |
612 | } | 588 | } |
613 | break; | 589 | break; |
614 | case 2: | 590 | case 2: |
615 | { | 591 | { |
616 | videoView->clear(); | 592 | videoView->clear(); |
617 | populateVideoView(); | 593 | populateVideoView(); |
618 | if( !tbDeletePlaylist->isHidden() ) { | 594 | if( !tbDeletePlaylist->isHidden() ) { |
619 | tbDeletePlaylist->hide(); | 595 | tbDeletePlaylist->hide(); |
620 | } | 596 | } |
621 | d->tbRemoveFromList->setEnabled(FALSE); | 597 | d->tbRemoveFromList->setEnabled(FALSE); |
622 | d->tbAddToList->setEnabled(TRUE); | 598 | d->tbAddToList->setEnabled(TRUE); |
623 | } | 599 | } |
624 | break; | 600 | break; |
625 | case 3: | 601 | case 3: |
626 | { | 602 | { |
627 | if( tbDeletePlaylist->isHidden() ) { | 603 | if( tbDeletePlaylist->isHidden() ) { |
628 | tbDeletePlaylist->show(); | 604 | tbDeletePlaylist->show(); |
629 | } | 605 | } |
630 | playLists->reread(); | 606 | playLists->reread(); |
631 | } | 607 | } |
632 | break; | 608 | break; |
633 | }; | 609 | }; |
634 | } | 610 | } |
635 | 611 | ||
636 | 612 | ||
637 | void PlayListWidget::btnPlay(bool b) { | 613 | void PlayListWidget::btnPlay(bool b) { |
614 | // mediaPlayerState->setPlaying(false); | ||
638 | mediaPlayerState->setPlaying(b); | 615 | mediaPlayerState->setPlaying(b); |
639 | qApp->processEvents(); | 616 | qApp->processEvents(); |
640 | insanityBool=FALSE; | 617 | insanityBool=FALSE; |
641 | // switch ( whichList()) { | 618 | // switch ( whichList()) { |
642 | // case 0: | 619 | // case 0: |
643 | // { | 620 | // { |
644 | // mediaPlayerState->setPlaying(b); | 621 | // mediaPlayerState->setPlaying(b); |
645 | // } | 622 | // } |
646 | // break; | 623 | // break; |
647 | // case 1: | 624 | // case 1: |
648 | // { | 625 | // { |
649 | // mediaPlayerState->setPlaying(b); | 626 | // mediaPlayerState->setPlaying(b); |
650 | // qApp->processEvents(); | 627 | // qApp->processEvents(); |
651 | // insanityBool=FALSE; | 628 | // insanityBool=FALSE; |
652 | // }// audioView->clearSelection(); | 629 | // }// audioView->clearSelection(); |
653 | // break; | 630 | // break; |
654 | // case 2: | 631 | // case 2: |
655 | // { | 632 | // { |
656 | // // addToSelection( videoView->currentItem() ); | 633 | // // addToSelection( videoView->currentItem() ); |
657 | // mediaPlayerState->setPlaying(b); | 634 | // mediaPlayerState->setPlaying(b); |
658 | // qApp->processEvents(); | 635 | // qApp->processEvents(); |
659 | // // d->selectedFiles->removeSelected( ); | 636 | // // d->selectedFiles->removeSelected( ); |
660 | // // tabWidget->setCurrentPage(2); | 637 | // // tabWidget->setCurrentPage(2); |
661 | // // d->selectedFiles->unSelect(); | 638 | // // d->selectedFiles->unSelect(); |
662 | // insanityBool=FALSE; | 639 | // insanityBool=FALSE; |
663 | // }// videoView->clearSelection(); | 640 | // }// videoView->clearSelection(); |
664 | // break; | 641 | // break; |
665 | // }; | 642 | // }; |
666 | 643 | ||
667 | } | 644 | } |
668 | 645 | ||
669 | void PlayListWidget::deletePlaylist() { | 646 | void PlayListWidget::deletePlaylist() { |
670 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 647 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
671 | (tr("You really want to delete\nthis playlist?")), | 648 | (tr("You really want to delete\nthis playlist?")), |
672 | (tr("Yes")), (tr("No")), 0 )){ | 649 | (tr("Yes")), (tr("No")), 0 )){ |
673 | case 0: // Yes clicked, | 650 | case 0: // Yes clicked, |
674 | QFile().remove(playLists->selected()->file()); | 651 | QFile().remove(playLists->selected()->file()); |
675 | QFile().remove(playLists->selected()->linkFile()); | 652 | QFile().remove(playLists->selected()->linkFile()); |
676 | playLists->reread(); | 653 | playLists->reread(); |
677 | break; | 654 | break; |
678 | case 1: // Cancel | 655 | case 1: // Cancel |
679 | break; | 656 | break; |
680 | }; | 657 | }; |
681 | } | 658 | } |
682 | 659 | ||
683 | 660 | ||
684 | void PlayListWidget::playSelected() { | 661 | void PlayListWidget::playSelected() { |
685 | btnPlay( TRUE); | 662 | btnPlay( TRUE); |
686 | } | 663 | } |
687 | 664 | ||
688 | 665 | ||
689 | void PlayListWidget::scanForAudio() { | 666 | void PlayListWidget::scanForAudio() { |
690 | // qDebug("scan for audio"); | 667 | // qDebug("scan for audio"); |
691 | files.detachChildren(); | 668 | files.detachChildren(); |
692 | QListIterator<DocLnk> sdit( files.children() ); | 669 | QListIterator<DocLnk> sdit( files.children() ); |
693 | for ( ; sdit.current(); ++sdit ) { | 670 | for ( ; sdit.current(); ++sdit ) { |
694 | delete sdit.current(); | 671 | delete sdit.current(); |
695 | } | 672 | } |
696 | Global::findDocuments(&files, "audio/*"); | 673 | Global::findDocuments(&files, "audio/*"); |
697 | audioScan = TRUE; | 674 | audioScan = TRUE; |
698 | } | 675 | } |
699 | 676 | ||
700 | void PlayListWidget::scanForVideo() { | 677 | void PlayListWidget::scanForVideo() { |
701 | // qDebug("scan for video"); | 678 | // qDebug("scan for video"); |
702 | vFiles.detachChildren(); | 679 | vFiles.detachChildren(); |
703 | QListIterator<DocLnk> sdit( vFiles.children() ); | 680 | QListIterator<DocLnk> sdit( vFiles.children() ); |
704 | for ( ; sdit.current(); ++sdit ) { | 681 | for ( ; sdit.current(); ++sdit ) { |
705 | delete sdit.current(); | 682 | delete sdit.current(); |
706 | } | 683 | } |
707 | Global::findDocuments(&vFiles, "video/*"); | 684 | Global::findDocuments(&vFiles, "video/*"); |
708 | videoScan = TRUE; | 685 | videoScan = TRUE; |
709 | } | 686 | } |
710 | 687 | ||
711 | void PlayListWidget::populateAudioView() { | 688 | void PlayListWidget::populateAudioView() { |
712 | audioView->clear(); | 689 | audioView->clear(); |
713 | StorageInfo storageInfo; | 690 | StorageInfo storageInfo; |
714 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 691 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
715 | if(!audioScan) { | 692 | if(!audioScan) { |
716 | scanForAudio(); | 693 | scanForAudio(); |
717 | } | 694 | } |
718 | 695 | ||
719 | QListIterator<DocLnk> dit( files.children() ); | 696 | QListIterator<DocLnk> dit( files.children() ); |
720 | QListIterator<FileSystem> it ( fs ); | 697 | QListIterator<FileSystem> it ( fs ); |
721 | 698 | ||
722 | QString storage; | 699 | QString storage; |
723 | for ( ; dit.current(); ++dit ) { | 700 | for ( ; dit.current(); ++dit ) { |
724 | for( ; it.current(); ++it ){ | 701 | for( ; it.current(); ++it ){ |
725 | const QString name = (*it)->name(); | 702 | const QString name = (*it)->name(); |
726 | const QString path = (*it)->path(); | 703 | const QString path = (*it)->path(); |
727 | if(dit.current()->file().find(path) != -1 ) { | 704 | if(dit.current()->file().find(path) != -1 ) { |
728 | storage = name; | 705 | storage = name; |
729 | } | 706 | } |
730 | } | 707 | } |
731 | 708 | ||
732 | QListViewItem * newItem; | 709 | QListViewItem * newItem; |
733 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { | 710 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { |
734 | long size; | 711 | long size; |
735 | if( dit.current()->file().left(4) == "http" ) | 712 | if( dit.current()->file().left(4) == "http" ) |
736 | size=0; | 713 | size=0; |
737 | else | 714 | else |
738 | size = QFile( dit.current()->file() ).size(); | 715 | size = QFile( dit.current()->file() ).size(); |
739 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 716 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
740 | QString::number(size ), storage, dit.current()->file()); | 717 | QString::number(size ), storage, dit.current()->file()); |
741 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); | 718 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); |
742 | } | 719 | } |
743 | } | 720 | } |
744 | } | 721 | } |
745 | 722 | ||
746 | 723 | ||
747 | void PlayListWidget::populateVideoView() { | 724 | void PlayListWidget::populateVideoView() { |
748 | videoView->clear(); | 725 | videoView->clear(); |
749 | StorageInfo storageInfo; | 726 | StorageInfo storageInfo; |
750 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 727 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
751 | 728 | ||
752 | if(!videoScan ) { | 729 | if(!videoScan ) { |
753 | scanForVideo(); | 730 | scanForVideo(); |
754 | } | 731 | } |
755 | 732 | ||
756 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 733 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
757 | QListIterator<FileSystem> it ( fs ); | 734 | QListIterator<FileSystem> it ( fs ); |
758 | videoView->clear(); | 735 | videoView->clear(); |
759 | QString storage, pathName; | 736 | QString storage, pathName; |
760 | for ( ; Vdit.current(); ++Vdit ) { | 737 | for ( ; Vdit.current(); ++Vdit ) { |
761 | for( ; it.current(); ++it ) { | 738 | for( ; it.current(); ++it ) { |
762 | const QString name = (*it)->name(); | 739 | const QString name = (*it)->name(); |
763 | const QString path = (*it)->path(); | 740 | const QString path = (*it)->path(); |
764 | if( Vdit.current()->file().find(path) != -1 ) { | 741 | if( Vdit.current()->file().find(path) != -1 ) { |
765 | storage=name; | 742 | storage=name; |
@@ -915,168 +892,168 @@ void PlayListWidget::readm3u( const QString &filename ) { | |||
915 | } | 892 | } |
916 | i++; | 893 | i++; |
917 | } | 894 | } |
918 | } | 895 | } |
919 | } | 896 | } |
920 | } | 897 | } |
921 | f.close(); | 898 | f.close(); |
922 | } | 899 | } |
923 | 900 | ||
924 | void PlayListWidget::writem3u() { | 901 | void PlayListWidget::writem3u() { |
925 | InputDialog *fileDlg; | 902 | InputDialog *fileDlg; |
926 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 903 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
927 | fileDlg->exec(); | 904 | fileDlg->exec(); |
928 | QString filename, list; | 905 | QString filename, list; |
929 | if( fileDlg->result() == 1 ) { | 906 | if( fileDlg->result() == 1 ) { |
930 | filename = fileDlg->text(); | 907 | filename = fileDlg->text(); |
931 | qDebug( filename ); | 908 | qDebug( filename ); |
932 | int noOfFiles = 0; | 909 | int noOfFiles = 0; |
933 | d->selectedFiles->first(); | 910 | d->selectedFiles->first(); |
934 | do { | 911 | do { |
935 | // we dont check for existance because of url's | 912 | // we dont check for existance because of url's |
936 | // qDebug(d->selectedFiles->current()->file()); | 913 | // qDebug(d->selectedFiles->current()->file()); |
937 | 914 | ||
938 | // so maybe we should do some net checking to ,-) | 915 | // so maybe we should do some net checking to ,-) |
939 | // no, cause it takes to long... | 916 | // no, cause it takes to long... |
940 | 917 | ||
941 | list += d->selectedFiles->current()->file() + "\n"; | 918 | list += d->selectedFiles->current()->file() + "\n"; |
942 | noOfFiles++; | 919 | noOfFiles++; |
943 | } | 920 | } |
944 | while ( d->selectedFiles->next() ); | 921 | while ( d->selectedFiles->next() ); |
945 | qDebug( list ); | 922 | qDebug( list ); |
946 | if( filename.left( 1) != "/" ) { | 923 | if( filename.left( 1) != "/" ) { |
947 | filename=QPEApplication::documentDir() + "/" + filename; | 924 | filename=QPEApplication::documentDir() + "/" + filename; |
948 | } | 925 | } |
949 | if( filename.right( 3 ) != "m3u" ) { | 926 | if( filename.right( 3 ) != "m3u" ) { |
950 | filename=filename+".m3u"; | 927 | filename=filename+".m3u"; |
951 | } | 928 | } |
952 | QFile f( filename ); | 929 | QFile f( filename ); |
953 | f.open( IO_WriteOnly ); | 930 | f.open( IO_WriteOnly ); |
954 | f.writeBlock( list, list.length() ); | 931 | f.writeBlock( list, list.length() ); |
955 | f.close(); | 932 | f.close(); |
956 | } | 933 | } |
957 | if( fileDlg ) { | 934 | if( fileDlg ) { |
958 | delete fileDlg; | 935 | delete fileDlg; |
959 | } | 936 | } |
960 | } | 937 | } |
961 | 938 | ||
962 | void PlayListWidget::readPls( const QString &filename ) { | 939 | void PlayListWidget::readPls( const QString &filename ) { |
963 | 940 | ||
964 | qDebug( "pls filename is " + filename ); | 941 | qDebug( "pls filename is " + filename ); |
965 | QFile f( filename ); | 942 | QFile f( filename ); |
966 | 943 | ||
967 | if( f.open( IO_ReadOnly ) ) { | 944 | if( f.open( IO_ReadOnly ) ) { |
968 | QTextStream t( &f ); | 945 | QTextStream t( &f ); |
969 | QString s;//, first, second; | 946 | QString s;//, first, second; |
970 | int i = 0; | 947 | int i = 0; |
971 | while ( !t.atEnd() ) { | 948 | while ( !t.atEnd() ) { |
972 | s = t.readLine(); | 949 | s = t.readLine(); |
973 | if( s.left(4) == "File" ) { | 950 | if( s.left(4) == "File" ) { |
974 | s = s.right( s.length() - 6 ); | 951 | s = s.right( s.length() - 6 ); |
975 | s.replace( QRegExp( "%20" )," "); | 952 | s.replace( QRegExp( "%20" )," "); |
976 | qDebug( "adding " + s + " to playlist" ); | 953 | qDebug( "adding " + s + " to playlist" ); |
977 | // numberofentries=2 | 954 | // numberofentries=2 |
978 | // File1=http | 955 | // File1=http |
979 | // Title | 956 | // Title |
980 | // Length | 957 | // Length |
981 | // Version | 958 | // Version |
982 | // File2=http | 959 | // File2=http |
983 | s = s.replace( QRegExp( "\\" ), "/" ); | 960 | s = s.replace( QRegExp( "\\" ), "/" ); |
984 | DocLnk lnk( s ); | 961 | DocLnk lnk( s ); |
985 | QFileInfo f( s ); | 962 | QFileInfo f( s ); |
986 | QString name = f.baseName(); | 963 | QString name = f.baseName(); |
987 | if( name.left( 4 ) == "http" ) { | 964 | if( name.left( 4 ) == "http" ) { |
988 | name = s.right( s.length() - 7); | 965 | name = s.right( s.length() - 7); |
989 | } else { | 966 | } else { |
990 | name = s; | 967 | name = s; |
991 | } | 968 | } |
992 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 969 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
993 | lnk.setName( name ); | 970 | lnk.setName( name ); |
994 | if( s.at( s.length() - 4) == '.') // if this is probably a file | 971 | if( s.at( s.length() - 4) == '.') // if this is probably a file |
995 | lnk.setFile( s ); | 972 | lnk.setFile( s ); |
996 | else { //if its a url | 973 | else { //if its a url |
997 | if( name.right( 1 ).find( '/' ) == -1) { | 974 | if( name.right( 1 ).find( '/' ) == -1) { |
998 | s += "/"; | 975 | s += "/"; |
999 | } | 976 | } |
1000 | lnk.setFile( s ); | 977 | lnk.setFile( s ); |
1001 | } | 978 | } |
1002 | lnk.setType( "audio/x-mpegurl" ); | 979 | lnk.setType( "audio/x-mpegurl" ); |
1003 | 980 | ||
1004 | //qDebug("DocLnk add "+name); | 981 | //qDebug("DocLnk add "+name); |
1005 | d->selectedFiles->addToSelection( lnk ); | 982 | d->selectedFiles->addToSelection( lnk ); |
1006 | } | 983 | } |
1007 | } | 984 | } |
1008 | i++; | 985 | i++; |
1009 | } | 986 | } |
1010 | } | 987 | } |
1011 | 988 | ||
1012 | void PlayListWidget::pmViewActivated(int index) { | 989 | void PlayListWidget::pmViewActivated(int index) { |
1013 | // qDebug("%d", index); | 990 | // qDebug("%d", index); |
1014 | switch(index) { | 991 | switch(index) { |
1015 | case -16: | 992 | case -16: |
1016 | { | 993 | { |
1017 | mediaPlayerState->toggleFullscreen(); | 994 | mediaPlayerState->toggleFullscreen(); |
1018 | bool b=mediaPlayerState->fullscreen(); | 995 | bool b=mediaPlayerState->fullscreen(); |
1019 | pmView->setItemChecked( index, b); | 996 | pmView->setItemChecked( index, b); |
1020 | Config cfg( "OpiePlayer" ); | 997 | Config cfg( "OpiePlayer" ); |
1021 | cfg.writeEntry( "FullScreen", b ); | 998 | cfg.writeEntry( "FullScreen", b ); |
1022 | } | 999 | } |
1023 | break; | 1000 | break; |
1024 | }; | 1001 | }; |
1025 | } | 1002 | } |
1026 | 1003 | ||
1027 | void PlayListWidget::populateSkinsMenu() { | 1004 | void PlayListWidget::populateSkinsMenu() { |
1028 | int item = 0; | 1005 | int item = 0; |
1029 | defaultSkinIndex = 0; | 1006 | defaultSkinIndex = 0; |
1030 | QString skinName; | 1007 | QString skinName; |
1031 | Config cfg( "OpiePlayer" ); | 1008 | Config cfg( "OpiePlayer" ); |
1032 | cfg.setGroup("Options" ); | 1009 | cfg.setGroup("Options" ); |
1033 | QString skin = cfg.readEntry( "Skin", "default" ); | 1010 | QString skin = cfg.readEntry( "Skin", "default" ); |
1034 | 1011 | ||
1035 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 1012 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
1036 | skinsDir.setFilter( QDir::Dirs ); | 1013 | skinsDir.setFilter( QDir::Dirs ); |
1037 | skinsDir.setSorting(QDir::Name ); | 1014 | skinsDir.setSorting(QDir::Name ); |
1038 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 1015 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
1039 | QFileInfoListIterator it( *skinslist ); | 1016 | QFileInfoListIterator it( *skinslist ); |
1040 | QFileInfo *fi; | 1017 | QFileInfo *fi; |
1041 | while ( ( fi = it.current() ) ) { | 1018 | while ( ( fi = it.current() ) ) { |
1042 | skinName = fi->fileName(); | 1019 | skinName = fi->fileName(); |
1043 | qDebug( fi->fileName() ); | 1020 | // qDebug( fi->fileName() ); |
1044 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 1021 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
1045 | item = skinsMenu->insertItem( fi->fileName() ) ; | 1022 | item = skinsMenu->insertItem( fi->fileName() ) ; |
1046 | } | 1023 | } |
1047 | if( skinName == "default" ) { | 1024 | if( skinName == "default" ) { |
1048 | defaultSkinIndex = item; | 1025 | defaultSkinIndex = item; |
1049 | } | 1026 | } |
1050 | if( skinName == skin ) { | 1027 | if( skinName == skin ) { |
1051 | skinsMenu->setItemChecked( item, TRUE ); | 1028 | skinsMenu->setItemChecked( item, TRUE ); |
1052 | } | 1029 | } |
1053 | ++it; | 1030 | ++it; |
1054 | } | 1031 | } |
1055 | } | 1032 | } |
1056 | 1033 | ||
1057 | void PlayListWidget::skinsMenuActivated( int item ) { | 1034 | void PlayListWidget::skinsMenuActivated( int item ) { |
1058 | for( uint i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { | 1035 | for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { |
1059 | skinsMenu->setItemChecked( i, FALSE ); | 1036 | skinsMenu->setItemChecked( i, FALSE ); |
1060 | } | 1037 | } |
1061 | skinsMenu->setItemChecked( item, TRUE ); | 1038 | skinsMenu->setItemChecked( item, TRUE ); |
1062 | 1039 | ||
1063 | Config cfg( "OpiePlayer" ); | 1040 | Config cfg( "OpiePlayer" ); |
1064 | cfg.setGroup("Options"); | 1041 | cfg.setGroup("Options"); |
1065 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 1042 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
1066 | } | 1043 | } |
1067 | 1044 | ||
1068 | int PlayListWidget::whichList() { | 1045 | int PlayListWidget::whichList() { |
1069 | return tabWidget->currentPageIndex(); | 1046 | return tabWidget->currentPageIndex(); |
1070 | } | 1047 | } |
1071 | 1048 | ||
1072 | QString PlayListWidget::currentFileListPathName() { | 1049 | QString PlayListWidget::currentFileListPathName() { |
1073 | switch (whichList()) { | 1050 | switch (whichList()) { |
1074 | case 1: | 1051 | case 1: |
1075 | return audioView->currentItem()->text(3); | 1052 | return audioView->currentItem()->text(3); |
1076 | break; | 1053 | break; |
1077 | case 2: | 1054 | case 2: |
1078 | return videoView->currentItem()->text(3); | 1055 | return videoView->currentItem()->text(3); |
1079 | break; | 1056 | break; |
1080 | }; | 1057 | }; |
1081 | return ""; | 1058 | return ""; |
1082 | } | 1059 | } |