author | llornkcor <llornkcor> | 2002-10-09 23:36:52 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-10-09 23:36:52 (UTC) |
commit | 4c7d8f663ee98751da0f8264ea1d49799463f0bf (patch) (unidiff) | |
tree | b2fd7207dd9b59643b144aca03098e7b10550c5c | |
parent | d624bf47913f76c881f28c6498cec4ad3c007a9b (diff) | |
download | opie-4c7d8f663ee98751da0f8264ea1d49799463f0bf.zip opie-4c7d8f663ee98751da0f8264ea1d49799463f0bf.tar.gz opie-4c7d8f663ee98751da0f8264ea1d49799463f0bf.tar.bz2 |
remove op2 crash feature when cancelling playlist save
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index d53c423..e28efd0 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -136,918 +136,919 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
136 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), | 136 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), |
137 | this, SLOT( loadList( const DocLnk & ) ) ); | 137 | this, SLOT( loadList( const DocLnk & ) ) ); |
138 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), | 138 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), |
139 | this, SLOT( tabChanged( QWidget* ) ) ); | 139 | this, SLOT( tabChanged( QWidget* ) ) ); |
140 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), | 140 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), |
141 | d->tbPlay, SLOT( setOn( bool ) ) ); | 141 | d->tbPlay, SLOT( setOn( bool ) ) ); |
142 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), | 142 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), |
143 | d->tbLoop, SLOT( setOn( bool ) ) ); | 143 | d->tbLoop, SLOT( setOn( bool ) ) ); |
144 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), | 144 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), |
145 | d->tbShuffle, SLOT( setOn( bool ) ) ); | 145 | d->tbShuffle, SLOT( setOn( bool ) ) ); |
146 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), | 146 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), |
147 | this, SLOT( setPlaylist( bool ) ) ); | 147 | this, SLOT( setPlaylist( bool ) ) ); |
148 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), | 148 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), |
149 | this, SLOT( playIt( QListViewItem *) ) ); | 149 | this, SLOT( playIt( QListViewItem *) ) ); |
150 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), | 150 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), |
151 | mediaPlayerState, SLOT( setVideoGamma( int ) ) ); | 151 | mediaPlayerState, SLOT( setVideoGamma( int ) ) ); |
152 | 152 | ||
153 | // see which skins are installed | 153 | // see which skins are installed |
154 | videoScan=FALSE; | 154 | videoScan=FALSE; |
155 | audioScan=FALSE; | 155 | audioScan=FALSE; |
156 | populateSkinsMenu(); | 156 | populateSkinsMenu(); |
157 | initializeStates(); | 157 | initializeStates(); |
158 | 158 | ||
159 | cfg.setGroup("PlayList"); | 159 | cfg.setGroup("PlayList"); |
160 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "" ); | 160 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "" ); |
161 | loadList(DocLnk( currentPlaylist ) ); | 161 | loadList(DocLnk( currentPlaylist ) ); |
162 | setCaption( tr( "OpiePlayer: " ) + currentPlaylist ); | 162 | setCaption( tr( "OpiePlayer: " ) + currentPlaylist ); |
163 | } | 163 | } |
164 | 164 | ||
165 | 165 | ||
166 | PlayListWidget::~PlayListWidget() { | 166 | PlayListWidget::~PlayListWidget() { |
167 | if ( d->current ) { | 167 | if ( d->current ) { |
168 | delete d->current; | 168 | delete d->current; |
169 | } | 169 | } |
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->playing() ); | 175 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
176 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 176 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
177 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 177 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
178 | setPlaylist( true ); | 178 | setPlaylist( true ); |
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 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 190 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
191 | d->selectedFiles->first(); | 191 | d->selectedFiles->first(); |
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 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 204 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
205 | d->setDocumentUsed = FALSE; | 205 | d->setDocumentUsed = FALSE; |
206 | if ( mediaPlayerState->playlist() ) { | 206 | if ( mediaPlayerState->playlist() ) { |
207 | if( QFileInfo( lnk.file() ).exists() || | 207 | if( QFileInfo( lnk.file() ).exists() || |
208 | lnk.file().left(4) == "http" ) | 208 | lnk.file().left(4) == "http" ) |
209 | d->selectedFiles->addToSelection( lnk ); | 209 | d->selectedFiles->addToSelection( lnk ); |
210 | // writeCurrentM3u(); | 210 | // writeCurrentM3u(); |
211 | } | 211 | } |
212 | else | 212 | else |
213 | mediaPlayerState->setPlaying( TRUE ); | 213 | mediaPlayerState->setPlaying( TRUE ); |
214 | } | 214 | } |
215 | 215 | ||
216 | 216 | ||
217 | void PlayListWidget::clearList() { | 217 | void PlayListWidget::clearList() { |
218 | while ( first() ) { | 218 | while ( first() ) { |
219 | d->selectedFiles->removeSelected(); | 219 | d->selectedFiles->removeSelected(); |
220 | } | 220 | } |
221 | } | 221 | } |
222 | 222 | ||
223 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 223 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
224 | switch (mouse) { | 224 | switch (mouse) { |
225 | case 1: | 225 | case 1: |
226 | break; | 226 | break; |
227 | case 2: | 227 | case 2: |
228 | { | 228 | { |
229 | QPopupMenu m; | 229 | QPopupMenu m; |
230 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 230 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
231 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 231 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
232 | m.exec( QCursor::pos() ); | 232 | m.exec( QCursor::pos() ); |
233 | } | 233 | } |
234 | break; | 234 | break; |
235 | } | 235 | } |
236 | } | 236 | } |
237 | 237 | ||
238 | 238 | ||
239 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 239 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
240 | switch (mouse) { | 240 | switch (mouse) { |
241 | case 1: | 241 | case 1: |
242 | break; | 242 | break; |
243 | case 2: | 243 | case 2: |
244 | { | 244 | { |
245 | QPopupMenu m; | 245 | QPopupMenu m; |
246 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 246 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
247 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 247 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
248 | m.exec( QCursor::pos() ); | 248 | m.exec( QCursor::pos() ); |
249 | } | 249 | } |
250 | break; | 250 | break; |
251 | } | 251 | } |
252 | } | 252 | } |
253 | 253 | ||
254 | 254 | ||
255 | void PlayListWidget::addAllToList() { | 255 | void PlayListWidget::addAllToList() { |
256 | DocLnkSet filesAll; | 256 | DocLnkSet filesAll; |
257 | Global::findDocuments(&filesAll, "video/*;"+audioMimes); | 257 | Global::findDocuments(&filesAll, "video/*;"+audioMimes); |
258 | QListIterator<DocLnk> Adit( filesAll.children() ); | 258 | QListIterator<DocLnk> Adit( filesAll.children() ); |
259 | for ( ; Adit.current(); ++Adit ) { | 259 | for ( ; Adit.current(); ++Adit ) { |
260 | if( QFileInfo( Adit.current()->file() ).exists() ) { | 260 | if( QFileInfo( Adit.current()->file() ).exists() ) { |
261 | d->selectedFiles->addToSelection( **Adit ); | 261 | d->selectedFiles->addToSelection( **Adit ); |
262 | } | 262 | } |
263 | } | 263 | } |
264 | writeCurrentM3u(); | 264 | writeCurrentM3u(); |
265 | } | 265 | } |
266 | 266 | ||
267 | 267 | ||
268 | void PlayListWidget::addAllMusicToList() { | 268 | void PlayListWidget::addAllMusicToList() { |
269 | if(!audioScan) | 269 | if(!audioScan) |
270 | scanForAudio(); | 270 | scanForAudio(); |
271 | QListIterator<DocLnk> dit( files.children() ); | 271 | QListIterator<DocLnk> dit( files.children() ); |
272 | for ( ; dit.current(); ++dit ) { | 272 | for ( ; dit.current(); ++dit ) { |
273 | if( QFileInfo(dit.current()->file() ).exists() ) { | 273 | if( QFileInfo(dit.current()->file() ).exists() ) { |
274 | d->selectedFiles->addToSelection( **dit ); | 274 | d->selectedFiles->addToSelection( **dit ); |
275 | } | 275 | } |
276 | } | 276 | } |
277 | writeCurrentM3u(); | 277 | writeCurrentM3u(); |
278 | } | 278 | } |
279 | 279 | ||
280 | 280 | ||
281 | void PlayListWidget::addAllVideoToList() { | 281 | void PlayListWidget::addAllVideoToList() { |
282 | if(!videoScan) | 282 | if(!videoScan) |
283 | scanForVideo(); | 283 | scanForVideo(); |
284 | QListIterator<DocLnk> dit( vFiles.children() ); | 284 | QListIterator<DocLnk> dit( vFiles.children() ); |
285 | for ( ; dit.current(); ++dit ) { | 285 | for ( ; dit.current(); ++dit ) { |
286 | if( QFileInfo( dit.current()->file() ).exists() ) { | 286 | if( QFileInfo( dit.current()->file() ).exists() ) { |
287 | d->selectedFiles->addToSelection( **dit ); | 287 | d->selectedFiles->addToSelection( **dit ); |
288 | } | 288 | } |
289 | } | 289 | } |
290 | writeCurrentM3u(); | 290 | writeCurrentM3u(); |
291 | } | 291 | } |
292 | 292 | ||
293 | 293 | ||
294 | void PlayListWidget::setDocument( const QString& fileref ) { | 294 | void PlayListWidget::setDocument( const QString& fileref ) { |
295 | qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); | 295 | qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); |
296 | fromSetDocument = TRUE; | 296 | fromSetDocument = TRUE; |
297 | if ( fileref.isNull() ) { | 297 | if ( fileref.isNull() ) { |
298 | QMessageBox::critical( 0, tr( "Invalid File" ), | 298 | QMessageBox::critical( 0, tr( "Invalid File" ), |
299 | tr( "There was a problem in getting the file." ) ); | 299 | tr( "There was a problem in getting the file." ) ); |
300 | return; | 300 | return; |
301 | } | 301 | } |
302 | 302 | ||
303 | clearList(); | 303 | clearList(); |
304 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u | 304 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u |
305 | readm3u( fileref ); | 305 | readm3u( fileref ); |
306 | } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { | 306 | } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { |
307 | readm3u( DocLnk( fileref).file() ); | 307 | readm3u( DocLnk( fileref).file() ); |
308 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls | 308 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls |
309 | readPls( fileref ); | 309 | readPls( fileref ); |
310 | } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { | 310 | } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { |
311 | readPls( DocLnk( fileref).file() ); | 311 | readPls( DocLnk( fileref).file() ); |
312 | } else { | 312 | } else { |
313 | clearList(); | 313 | clearList(); |
314 | addToSelection( DocLnk( fileref ) ); | 314 | addToSelection( DocLnk( fileref ) ); |
315 | writeCurrentM3u(); | 315 | writeCurrentM3u(); |
316 | 316 | ||
317 | d->setDocumentUsed = TRUE; | 317 | d->setDocumentUsed = TRUE; |
318 | mediaPlayerState->setPlaying( FALSE ); | 318 | mediaPlayerState->setPlaying( FALSE ); |
319 | mediaPlayerState->setPlaying( TRUE ); | 319 | mediaPlayerState->setPlaying( TRUE ); |
320 | } | 320 | } |
321 | } | 321 | } |
322 | 322 | ||
323 | 323 | ||
324 | void PlayListWidget::useSelectedDocument() { | 324 | void PlayListWidget::useSelectedDocument() { |
325 | d->setDocumentUsed = FALSE; | 325 | d->setDocumentUsed = FALSE; |
326 | } | 326 | } |
327 | 327 | ||
328 | 328 | ||
329 | const DocLnk *PlayListWidget::current() { // this is fugly | 329 | const DocLnk *PlayListWidget::current() { // this is fugly |
330 | switch ( whichList() ) { | 330 | switch ( whichList() ) { |
331 | case 0: //playlist | 331 | case 0: //playlist |
332 | { | 332 | { |
333 | // qDebug("playlist"); | 333 | // qDebug("playlist"); |
334 | if ( mediaPlayerState->playlist() ) { | 334 | if ( mediaPlayerState->playlist() ) { |
335 | return d->selectedFiles->current(); | 335 | return d->selectedFiles->current(); |
336 | } else if ( d->setDocumentUsed && d->current ) { | 336 | } else if ( d->setDocumentUsed && d->current ) { |
337 | return d->current; | 337 | return d->current; |
338 | } else { | 338 | } else { |
339 | return &(d->files->selectedDocument()); | 339 | return &(d->files->selectedDocument()); |
340 | } | 340 | } |
341 | } | 341 | } |
342 | break; | 342 | break; |
343 | }; | 343 | }; |
344 | return 0; | 344 | return 0; |
345 | } | 345 | } |
346 | 346 | ||
347 | 347 | ||
348 | bool PlayListWidget::prev() { | 348 | bool PlayListWidget::prev() { |
349 | if ( mediaPlayerState->playlist() ) { | 349 | if ( mediaPlayerState->playlist() ) { |
350 | if ( mediaPlayerState->shuffled() ) { | 350 | if ( mediaPlayerState->shuffled() ) { |
351 | const DocLnk *cur = current(); | 351 | const DocLnk *cur = current(); |
352 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 352 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
353 | for ( int i = 0; i < j; i++ ) { | 353 | for ( int i = 0; i < j; i++ ) { |
354 | if ( !d->selectedFiles->next() ) | 354 | if ( !d->selectedFiles->next() ) |
355 | d->selectedFiles->first(); | 355 | d->selectedFiles->first(); |
356 | } | 356 | } |
357 | if ( cur == current() ) | 357 | if ( cur == current() ) |
358 | if ( !d->selectedFiles->next() ) { | 358 | if ( !d->selectedFiles->next() ) { |
359 | d->selectedFiles->first(); | 359 | d->selectedFiles->first(); |
360 | } | 360 | } |
361 | return TRUE; | 361 | return TRUE; |
362 | } else { | 362 | } else { |
363 | if ( !d->selectedFiles->prev() ) { | 363 | if ( !d->selectedFiles->prev() ) { |
364 | if ( mediaPlayerState->looping() ) { | 364 | if ( mediaPlayerState->looping() ) { |
365 | return d->selectedFiles->last(); | 365 | return d->selectedFiles->last(); |
366 | } else { | 366 | } else { |
367 | return FALSE; | 367 | return FALSE; |
368 | } | 368 | } |
369 | } | 369 | } |
370 | return TRUE; | 370 | return TRUE; |
371 | } | 371 | } |
372 | } else { | 372 | } else { |
373 | return mediaPlayerState->looping(); | 373 | return mediaPlayerState->looping(); |
374 | } | 374 | } |
375 | } | 375 | } |
376 | 376 | ||
377 | 377 | ||
378 | bool PlayListWidget::next() { | 378 | bool PlayListWidget::next() { |
379 | //qDebug("<<<<<<<<<<<<next()"); | 379 | //qDebug("<<<<<<<<<<<<next()"); |
380 | if ( mediaPlayerState->playlist() ) { | 380 | if ( mediaPlayerState->playlist() ) { |
381 | if ( mediaPlayerState->shuffled() ) { | 381 | if ( mediaPlayerState->shuffled() ) { |
382 | return prev(); | 382 | return prev(); |
383 | } else { | 383 | } else { |
384 | if ( !d->selectedFiles->next() ) { | 384 | if ( !d->selectedFiles->next() ) { |
385 | if ( mediaPlayerState->looping() ) { | 385 | if ( mediaPlayerState->looping() ) { |
386 | return d->selectedFiles->first(); | 386 | return d->selectedFiles->first(); |
387 | } else { | 387 | } else { |
388 | return FALSE; | 388 | return FALSE; |
389 | } | 389 | } |
390 | } | 390 | } |
391 | return TRUE; | 391 | return TRUE; |
392 | } | 392 | } |
393 | } else { | 393 | } else { |
394 | return mediaPlayerState->looping(); | 394 | return mediaPlayerState->looping(); |
395 | } | 395 | } |
396 | } | 396 | } |
397 | 397 | ||
398 | 398 | ||
399 | bool PlayListWidget::first() { | 399 | bool PlayListWidget::first() { |
400 | if ( mediaPlayerState->playlist() ) | 400 | if ( mediaPlayerState->playlist() ) |
401 | return d->selectedFiles->first(); | 401 | return d->selectedFiles->first(); |
402 | else | 402 | else |
403 | return mediaPlayerState->looping(); | 403 | return mediaPlayerState->looping(); |
404 | } | 404 | } |
405 | 405 | ||
406 | 406 | ||
407 | bool PlayListWidget::last() { | 407 | bool PlayListWidget::last() { |
408 | if ( mediaPlayerState->playlist() ) | 408 | if ( mediaPlayerState->playlist() ) |
409 | return d->selectedFiles->last(); | 409 | return d->selectedFiles->last(); |
410 | else | 410 | else |
411 | return mediaPlayerState->looping(); | 411 | return mediaPlayerState->looping(); |
412 | } | 412 | } |
413 | 413 | ||
414 | 414 | ||
415 | void PlayListWidget::saveList() { | 415 | void PlayListWidget::saveList() { |
416 | writem3u(); | 416 | writem3u(); |
417 | } | 417 | } |
418 | 418 | ||
419 | 419 | ||
420 | void PlayListWidget::loadList( const DocLnk & lnk) { | 420 | void PlayListWidget::loadList( const DocLnk & lnk) { |
421 | QString name = lnk.name(); | 421 | QString name = lnk.name(); |
422 | qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); | 422 | qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); |
423 | 423 | ||
424 | if( name.length()>0) { | 424 | if( name.length()>0) { |
425 | setCaption("OpiePlayer: "+name); | 425 | setCaption("OpiePlayer: "+name); |
426 | qDebug("<<<<<<<<<<<<load list "+ lnk.file()); | 426 | qDebug("<<<<<<<<<<<<load list "+ lnk.file()); |
427 | clearList(); | 427 | clearList(); |
428 | readm3u(lnk.file()); | 428 | readm3u(lnk.file()); |
429 | tabWidget->setCurrentPage(0); | 429 | tabWidget->setCurrentPage(0); |
430 | } | 430 | } |
431 | } | 431 | } |
432 | 432 | ||
433 | 433 | ||
434 | void PlayListWidget::setPlaylist( bool shown ) { | 434 | void PlayListWidget::setPlaylist( bool shown ) { |
435 | if ( shown ) { | 435 | if ( shown ) { |
436 | d->playListFrame->show(); | 436 | d->playListFrame->show(); |
437 | } else { | 437 | } else { |
438 | d->playListFrame->hide(); | 438 | d->playListFrame->hide(); |
439 | } | 439 | } |
440 | } | 440 | } |
441 | 441 | ||
442 | 442 | ||
443 | void PlayListWidget::addSelected() { | 443 | void PlayListWidget::addSelected() { |
444 | qDebug("addSelected"); | 444 | qDebug("addSelected"); |
445 | switch (whichList()) { | 445 | switch (whichList()) { |
446 | case 0: //playlist | 446 | case 0: //playlist |
447 | break; | 447 | break; |
448 | case 1: { //audio | 448 | case 1: { //audio |
449 | QListViewItemIterator it( audioView ); | 449 | QListViewItemIterator it( audioView ); |
450 | // iterate through all items of the listview | 450 | // iterate through all items of the listview |
451 | for ( ; it.current(); ++it ) { | 451 | for ( ; it.current(); ++it ) { |
452 | if ( it.current()->isSelected() ) { | 452 | if ( it.current()->isSelected() ) { |
453 | QListIterator<DocLnk> dit( files.children() ); | 453 | QListIterator<DocLnk> dit( files.children() ); |
454 | for ( ; dit.current(); ++dit ) { | 454 | for ( ; dit.current(); ++dit ) { |
455 | if( dit.current()->name() == it.current()->text(0) ) { | 455 | if( dit.current()->name() == it.current()->text(0) ) { |
456 | if( QFileInfo( dit.current()->file()).exists()) { | 456 | if( QFileInfo( dit.current()->file()).exists()) { |
457 | d->selectedFiles->addToSelection( **dit ); | 457 | d->selectedFiles->addToSelection( **dit ); |
458 | audioView->setSelected( it.current(),FALSE); | 458 | audioView->setSelected( it.current(),FALSE); |
459 | } | 459 | } |
460 | } | 460 | } |
461 | } | 461 | } |
462 | } | 462 | } |
463 | } | 463 | } |
464 | tabWidget->setCurrentPage(0); | 464 | tabWidget->setCurrentPage(0); |
465 | writeCurrentM3u(); | 465 | writeCurrentM3u(); |
466 | } | 466 | } |
467 | break; | 467 | break; |
468 | case 2: { // video | 468 | case 2: { // video |
469 | QListViewItemIterator it( videoView ); | 469 | QListViewItemIterator it( videoView ); |
470 | // iterate through all items of the listview | 470 | // iterate through all items of the listview |
471 | for ( ; it.current(); ++it ) { | 471 | for ( ; it.current(); ++it ) { |
472 | if ( it.current()->isSelected() ) { | 472 | if ( it.current()->isSelected() ) { |
473 | QListIterator<DocLnk> dit( vFiles.children() ); | 473 | QListIterator<DocLnk> dit( vFiles.children() ); |
474 | for ( ; dit.current(); ++dit ) { | 474 | for ( ; dit.current(); ++dit ) { |
475 | if( dit.current()->name() == it.current()->text(0) ) { | 475 | if( dit.current()->name() == it.current()->text(0) ) { |
476 | if(QFileInfo( dit.current()->file()).exists()) { | 476 | if(QFileInfo( dit.current()->file()).exists()) { |
477 | d->selectedFiles->addToSelection( **dit ); | 477 | d->selectedFiles->addToSelection( **dit ); |
478 | videoView->setSelected( it.current(),FALSE); | 478 | videoView->setSelected( it.current(),FALSE); |
479 | } | 479 | } |
480 | } | 480 | } |
481 | } | 481 | } |
482 | } | 482 | } |
483 | } | 483 | } |
484 | tabWidget->setCurrentPage(0); | 484 | tabWidget->setCurrentPage(0); |
485 | writeCurrentM3u(); | 485 | writeCurrentM3u(); |
486 | } | 486 | } |
487 | break; | 487 | break; |
488 | }; | 488 | }; |
489 | } | 489 | } |
490 | 490 | ||
491 | 491 | ||
492 | void PlayListWidget::removeSelected() { | 492 | void PlayListWidget::removeSelected() { |
493 | d->selectedFiles->removeSelected( ); | 493 | d->selectedFiles->removeSelected( ); |
494 | writeCurrentM3u(); | 494 | writeCurrentM3u(); |
495 | } | 495 | } |
496 | 496 | ||
497 | 497 | ||
498 | void PlayListWidget::playIt( QListViewItem *it) { | 498 | void PlayListWidget::playIt( QListViewItem *it) { |
499 | if(!it) return; | 499 | if(!it) return; |
500 | mediaPlayerState->setPlaying(FALSE); | 500 | mediaPlayerState->setPlaying(FALSE); |
501 | mediaPlayerState->setPlaying(TRUE); | 501 | mediaPlayerState->setPlaying(TRUE); |
502 | d->selectedFiles->unSelect(); | 502 | d->selectedFiles->unSelect(); |
503 | } | 503 | } |
504 | 504 | ||
505 | 505 | ||
506 | void PlayListWidget::addToSelection( QListViewItem *it) { | 506 | void PlayListWidget::addToSelection( QListViewItem *it) { |
507 | d->setDocumentUsed = FALSE; | 507 | d->setDocumentUsed = FALSE; |
508 | 508 | ||
509 | if(it) { | 509 | if(it) { |
510 | switch ( whichList()) { | 510 | switch ( whichList()) { |
511 | case 1: { | 511 | case 1: { |
512 | QListIterator<DocLnk> dit( files.children() ); | 512 | QListIterator<DocLnk> dit( files.children() ); |
513 | for ( ; dit.current(); ++dit ) { | 513 | for ( ; dit.current(); ++dit ) { |
514 | if( dit.current()->name() == it->text(0)) { | 514 | if( dit.current()->name() == it->text(0)) { |
515 | if(QFileInfo( dit.current()->file()).exists()) | 515 | if(QFileInfo( dit.current()->file()).exists()) |
516 | d->selectedFiles->addToSelection( **dit ); | 516 | d->selectedFiles->addToSelection( **dit ); |
517 | } | 517 | } |
518 | } | 518 | } |
519 | writeCurrentM3u(); | 519 | writeCurrentM3u(); |
520 | } | 520 | } |
521 | break; | 521 | break; |
522 | case 2: { | 522 | case 2: { |
523 | QListIterator<DocLnk> dit( vFiles.children() ); | 523 | QListIterator<DocLnk> dit( vFiles.children() ); |
524 | for ( ; dit.current(); ++dit ) { | 524 | for ( ; dit.current(); ++dit ) { |
525 | if( dit.current()->name() == it->text(0)) { | 525 | if( dit.current()->name() == it->text(0)) { |
526 | if( QFileInfo( dit.current()->file()).exists() ) | 526 | if( QFileInfo( dit.current()->file()).exists() ) |
527 | d->selectedFiles->addToSelection( **dit ); | 527 | d->selectedFiles->addToSelection( **dit ); |
528 | } | 528 | } |
529 | } | 529 | } |
530 | writeCurrentM3u(); | 530 | writeCurrentM3u(); |
531 | 531 | ||
532 | } | 532 | } |
533 | break; | 533 | break; |
534 | case 0: | 534 | case 0: |
535 | break; | 535 | break; |
536 | }; | 536 | }; |
537 | tabWidget->setCurrentPage(0); | 537 | tabWidget->setCurrentPage(0); |
538 | } | 538 | } |
539 | } | 539 | } |
540 | 540 | ||
541 | 541 | ||
542 | void PlayListWidget::tabChanged(QWidget *) { | 542 | void PlayListWidget::tabChanged(QWidget *) { |
543 | 543 | ||
544 | switch ( whichList()) { | 544 | switch ( whichList()) { |
545 | case 0: | 545 | case 0: |
546 | { | 546 | { |
547 | if( !tbDeletePlaylist->isHidden() ) { | 547 | if( !tbDeletePlaylist->isHidden() ) { |
548 | tbDeletePlaylist->hide(); | 548 | tbDeletePlaylist->hide(); |
549 | } | 549 | } |
550 | d->tbRemoveFromList->setEnabled(TRUE); | 550 | d->tbRemoveFromList->setEnabled(TRUE); |
551 | d->tbAddToList->setEnabled(FALSE); | 551 | d->tbAddToList->setEnabled(FALSE); |
552 | } | 552 | } |
553 | break; | 553 | break; |
554 | case 1: | 554 | case 1: |
555 | { | 555 | { |
556 | audioView->clear(); | 556 | audioView->clear(); |
557 | populateAudioView(); | 557 | populateAudioView(); |
558 | 558 | ||
559 | if( !tbDeletePlaylist->isHidden() ) { | 559 | if( !tbDeletePlaylist->isHidden() ) { |
560 | tbDeletePlaylist->hide(); | 560 | tbDeletePlaylist->hide(); |
561 | } | 561 | } |
562 | d->tbRemoveFromList->setEnabled(FALSE); | 562 | d->tbRemoveFromList->setEnabled(FALSE); |
563 | d->tbAddToList->setEnabled(TRUE); | 563 | d->tbAddToList->setEnabled(TRUE); |
564 | } | 564 | } |
565 | break; | 565 | break; |
566 | case 2: | 566 | case 2: |
567 | { | 567 | { |
568 | videoView->clear(); | 568 | videoView->clear(); |
569 | populateVideoView(); | 569 | populateVideoView(); |
570 | if( !tbDeletePlaylist->isHidden() ) { | 570 | if( !tbDeletePlaylist->isHidden() ) { |
571 | tbDeletePlaylist->hide(); | 571 | tbDeletePlaylist->hide(); |
572 | } | 572 | } |
573 | d->tbRemoveFromList->setEnabled(FALSE); | 573 | d->tbRemoveFromList->setEnabled(FALSE); |
574 | d->tbAddToList->setEnabled(TRUE); | 574 | d->tbAddToList->setEnabled(TRUE); |
575 | } | 575 | } |
576 | break; | 576 | break; |
577 | case 3: | 577 | case 3: |
578 | { | 578 | { |
579 | if( tbDeletePlaylist->isHidden() ) { | 579 | if( tbDeletePlaylist->isHidden() ) { |
580 | tbDeletePlaylist->show(); | 580 | tbDeletePlaylist->show(); |
581 | } | 581 | } |
582 | playLists->reread(); | 582 | playLists->reread(); |
583 | } | 583 | } |
584 | break; | 584 | break; |
585 | }; | 585 | }; |
586 | } | 586 | } |
587 | 587 | ||
588 | 588 | ||
589 | void PlayListWidget::btnPlay(bool b) { | 589 | void PlayListWidget::btnPlay(bool b) { |
590 | // mediaPlayerState->setPlaying(false); | 590 | // mediaPlayerState->setPlaying(false); |
591 | mediaPlayerState->setPlaying(b); | 591 | mediaPlayerState->setPlaying(b); |
592 | insanityBool=FALSE; | 592 | insanityBool=FALSE; |
593 | } | 593 | } |
594 | 594 | ||
595 | void PlayListWidget::deletePlaylist() { | 595 | void PlayListWidget::deletePlaylist() { |
596 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 596 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
597 | (tr("You really want to delete\nthis playlist?")), | 597 | (tr("You really want to delete\nthis playlist?")), |
598 | (tr("Yes")), (tr("No")), 0 )){ | 598 | (tr("Yes")), (tr("No")), 0 )){ |
599 | case 0: // Yes clicked, | 599 | case 0: // Yes clicked, |
600 | QFile().remove(playLists->selectedDocument().file()); | 600 | QFile().remove(playLists->selectedDocument().file()); |
601 | QFile().remove(playLists->selectedDocument().linkFile()); | 601 | QFile().remove(playLists->selectedDocument().linkFile()); |
602 | playLists->reread(); | 602 | playLists->reread(); |
603 | break; | 603 | break; |
604 | case 1: // Cancel | 604 | case 1: // Cancel |
605 | break; | 605 | break; |
606 | }; | 606 | }; |
607 | } | 607 | } |
608 | 608 | ||
609 | 609 | ||
610 | void PlayListWidget::playSelected() { | 610 | void PlayListWidget::playSelected() { |
611 | btnPlay( TRUE); | 611 | btnPlay( TRUE); |
612 | } | 612 | } |
613 | 613 | ||
614 | 614 | ||
615 | void PlayListWidget::scanForAudio() { | 615 | void PlayListWidget::scanForAudio() { |
616 | // qDebug("scan for audio"); | 616 | // qDebug("scan for audio"); |
617 | files.detachChildren(); | 617 | files.detachChildren(); |
618 | QListIterator<DocLnk> sdit( files.children() ); | 618 | QListIterator<DocLnk> sdit( files.children() ); |
619 | for ( ; sdit.current(); ++sdit ) { | 619 | for ( ; sdit.current(); ++sdit ) { |
620 | delete sdit.current(); | 620 | delete sdit.current(); |
621 | } | 621 | } |
622 | // Global::findDocuments( &files, "audio/*"); | 622 | // Global::findDocuments( &files, "audio/*"); |
623 | Global::findDocuments( &files, audioMimes); | 623 | Global::findDocuments( &files, audioMimes); |
624 | audioScan = TRUE; | 624 | audioScan = TRUE; |
625 | } | 625 | } |
626 | 626 | ||
627 | void PlayListWidget::scanForVideo() { | 627 | void PlayListWidget::scanForVideo() { |
628 | // qDebug("scan for video"); | 628 | // qDebug("scan for video"); |
629 | vFiles.detachChildren(); | 629 | vFiles.detachChildren(); |
630 | QListIterator<DocLnk> sdit( vFiles.children() ); | 630 | QListIterator<DocLnk> sdit( vFiles.children() ); |
631 | for ( ; sdit.current(); ++sdit ) { | 631 | for ( ; sdit.current(); ++sdit ) { |
632 | delete sdit.current(); | 632 | delete sdit.current(); |
633 | } | 633 | } |
634 | Global::findDocuments(&vFiles, "video/*"); | 634 | Global::findDocuments(&vFiles, "video/*"); |
635 | videoScan = TRUE; | 635 | videoScan = TRUE; |
636 | } | 636 | } |
637 | 637 | ||
638 | void PlayListWidget::populateAudioView() { | 638 | void PlayListWidget::populateAudioView() { |
639 | audioView->clear(); | 639 | audioView->clear(); |
640 | StorageInfo storageInfo; | 640 | StorageInfo storageInfo; |
641 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 641 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
642 | if(!audioScan) { | 642 | if(!audioScan) { |
643 | scanForAudio(); | 643 | scanForAudio(); |
644 | } | 644 | } |
645 | 645 | ||
646 | QListIterator<DocLnk> dit( files.children() ); | 646 | QListIterator<DocLnk> dit( files.children() ); |
647 | QListIterator<FileSystem> it ( fs ); | 647 | QListIterator<FileSystem> it ( fs ); |
648 | 648 | ||
649 | QString storage; | 649 | QString storage; |
650 | for ( ; dit.current(); ++dit ) { | 650 | for ( ; dit.current(); ++dit ) { |
651 | for( ; it.current(); ++it ){ | 651 | for( ; it.current(); ++it ){ |
652 | const QString name = (*it)->name(); | 652 | const QString name = (*it)->name(); |
653 | const QString path = (*it)->path(); | 653 | const QString path = (*it)->path(); |
654 | if(dit.current()->file().find(path) != -1 ) { | 654 | if(dit.current()->file().find(path) != -1 ) { |
655 | storage = name; | 655 | storage = name; |
656 | } | 656 | } |
657 | } | 657 | } |
658 | 658 | ||
659 | QListViewItem * newItem; | 659 | QListViewItem * newItem; |
660 | if ( QFile( dit.current()->file()).exists() || | 660 | if ( QFile( dit.current()->file()).exists() || |
661 | dit.current()->file().left(4) == "http" ) { | 661 | dit.current()->file().left(4) == "http" ) { |
662 | long size; | 662 | long size; |
663 | if( dit.current()->file().left(4) == "http" ) | 663 | if( dit.current()->file().left(4) == "http" ) |
664 | size=0; | 664 | size=0; |
665 | else | 665 | else |
666 | size = QFile( dit.current()->file() ).size(); | 666 | size = QFile( dit.current()->file() ).size(); |
667 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 667 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
668 | QString::number(size ), storage, dit.current()->file()); | 668 | QString::number(size ), storage, dit.current()->file()); |
669 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); | 669 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); |
670 | } | 670 | } |
671 | } | 671 | } |
672 | } | 672 | } |
673 | 673 | ||
674 | 674 | ||
675 | void PlayListWidget::populateVideoView() { | 675 | void PlayListWidget::populateVideoView() { |
676 | videoView->clear(); | 676 | videoView->clear(); |
677 | StorageInfo storageInfo; | 677 | StorageInfo storageInfo; |
678 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 678 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
679 | 679 | ||
680 | if(!videoScan ) { | 680 | if(!videoScan ) { |
681 | scanForVideo(); | 681 | scanForVideo(); |
682 | } | 682 | } |
683 | 683 | ||
684 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 684 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
685 | QListIterator<FileSystem> it ( fs ); | 685 | QListIterator<FileSystem> it ( fs ); |
686 | videoView->clear(); | 686 | videoView->clear(); |
687 | QString storage, pathName; | 687 | QString storage, pathName; |
688 | for ( ; Vdit.current(); ++Vdit ) { | 688 | for ( ; Vdit.current(); ++Vdit ) { |
689 | for( ; it.current(); ++it ) { | 689 | for( ; it.current(); ++it ) { |
690 | const QString name = (*it)->name(); | 690 | const QString name = (*it)->name(); |
691 | const QString path = (*it)->path(); | 691 | const QString path = (*it)->path(); |
692 | if( Vdit.current()->file().find(path) != -1 ) { | 692 | if( Vdit.current()->file().find(path) != -1 ) { |
693 | storage=name; | 693 | storage=name; |
694 | pathName=path; | 694 | pathName=path; |
695 | } | 695 | } |
696 | } | 696 | } |
697 | 697 | ||
698 | QListViewItem * newItem; | 698 | QListViewItem * newItem; |
699 | if ( QFile( Vdit.current()->file() ).exists() ) { | 699 | if ( QFile( Vdit.current()->file() ).exists() ) { |
700 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 700 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
701 | QString::number( QFile( Vdit.current()->file() ).size() ), | 701 | QString::number( QFile( Vdit.current()->file() ).size() ), |
702 | storage, Vdit.current()->file()); | 702 | storage, Vdit.current()->file()); |
703 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); | 703 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); |
704 | } | 704 | } |
705 | } | 705 | } |
706 | } | 706 | } |
707 | 707 | ||
708 | 708 | ||
709 | void PlayListWidget::openFile() { | 709 | void PlayListWidget::openFile() { |
710 | QString filename, name; | 710 | QString filename, name; |
711 | InputDialog *fileDlg; | 711 | InputDialog *fileDlg; |
712 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 712 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
713 | fileDlg->exec(); | 713 | fileDlg->exec(); |
714 | if( fileDlg->result() == 1 ) { | 714 | if( fileDlg->result() == 1 ) { |
715 | filename = fileDlg->text(); | 715 | filename = fileDlg->text(); |
716 | qDebug( "Selected filename is " + filename ); | 716 | qDebug( "Selected filename is " + filename ); |
717 | Om3u *m3uList; | 717 | Om3u *m3uList; |
718 | DocLnk lnk; | 718 | DocLnk lnk; |
719 | Config cfg( "OpiePlayer" ); | 719 | Config cfg( "OpiePlayer" ); |
720 | cfg.setGroup("PlayList"); | 720 | cfg.setGroup("PlayList"); |
721 | 721 | ||
722 | if(filename.left(4) == "http") { | 722 | if(filename.left(4) == "http") { |
723 | QString m3uFile, m3uFilePath; | 723 | QString m3uFile, m3uFilePath; |
724 | if(filename.find(":",8,TRUE) != -1) { //found a port | 724 | if(filename.find(":",8,TRUE) != -1) { //found a port |
725 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 725 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
726 | m3uFile = m3uFile.right( 7); | 726 | m3uFile = m3uFile.right( 7); |
727 | } else if(filename.left(4) == "http"){ | 727 | } else if(filename.left(4) == "http"){ |
728 | m3uFile=filename; | 728 | m3uFile=filename; |
729 | m3uFile = m3uFile.right( m3uFile.length() - 7); | 729 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
730 | } else{ | 730 | } else{ |
731 | m3uFile=filename; | 731 | m3uFile=filename; |
732 | } | 732 | } |
733 | 733 | ||
734 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); | 734 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); |
735 | lnk.setName( filename ); //sets name | 735 | lnk.setName( filename ); //sets name |
736 | lnk.setFile( filename ); //sets file name | 736 | lnk.setFile( filename ); //sets file name |
737 | lnk.setIcon("opieplayer2/musicfile"); | 737 | lnk.setIcon("opieplayer2/musicfile"); |
738 | d->selectedFiles->addToSelection( lnk ); | 738 | d->selectedFiles->addToSelection( lnk ); |
739 | writeCurrentM3u(); | 739 | writeCurrentM3u(); |
740 | } | 740 | } |
741 | else if( filename.right( 3) == "m3u" ) { | 741 | else if( filename.right( 3) == "m3u" ) { |
742 | readm3u( filename ); | 742 | readm3u( filename ); |
743 | 743 | ||
744 | } else if( filename.right(3) == "pls" ) { | 744 | } else if( filename.right(3) == "pls" ) { |
745 | readPls( filename ); | 745 | readPls( filename ); |
746 | } else { | 746 | } else { |
747 | d->selectedFiles->addToSelection( DocLnk(filename) ); | 747 | d->selectedFiles->addToSelection( DocLnk(filename) ); |
748 | writeCurrentM3u(); | 748 | writeCurrentM3u(); |
749 | } | 749 | } |
750 | } | 750 | } |
751 | 751 | ||
752 | if( fileDlg ) { | 752 | if( fileDlg ) { |
753 | delete fileDlg; | 753 | delete fileDlg; |
754 | } | 754 | } |
755 | } | 755 | } |
756 | 756 | ||
757 | /* | 757 | /* |
758 | reads m3u and shows files/urls to playlist widget */ | 758 | reads m3u and shows files/urls to playlist widget */ |
759 | void PlayListWidget::readm3u( const QString &filename ) { | 759 | void PlayListWidget::readm3u( const QString &filename ) { |
760 | qDebug( "read m3u filename " + filename ); | 760 | qDebug( "read m3u filename " + filename ); |
761 | 761 | ||
762 | Om3u *m3uList; | 762 | Om3u *m3uList; |
763 | QString s, name; | 763 | QString s, name; |
764 | m3uList = new Om3u( filename, IO_ReadOnly ); | 764 | m3uList = new Om3u( filename, IO_ReadOnly ); |
765 | m3uList->readM3u(); | 765 | m3uList->readM3u(); |
766 | DocLnk lnk; | 766 | DocLnk lnk; |
767 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 767 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
768 | s = *it; | 768 | s = *it; |
769 | // s.replace( QRegExp( "%20" )," " ); | 769 | // s.replace( QRegExp( "%20" )," " ); |
770 | // qDebug("reading "+ s); | 770 | // qDebug("reading "+ s); |
771 | if(s.left(4)=="http") { | 771 | if(s.left(4)=="http") { |
772 | lnk.setName( s ); //sets file name | 772 | lnk.setName( s ); //sets file name |
773 | lnk.setFile( s ); //sets file name | 773 | lnk.setFile( s ); //sets file name |
774 | lnk.setIcon("opieplayer2/musicfile"); | 774 | lnk.setIcon("opieplayer2/musicfile"); |
775 | } | 775 | } |
776 | else { | 776 | else { |
777 | if( QFileInfo( s ).exists() ) { | 777 | if( QFileInfo( s ).exists() ) { |
778 | lnk.setName( QFileInfo(s).baseName()); | 778 | lnk.setName( QFileInfo(s).baseName()); |
779 | // qDebug("set link "+s); | 779 | // qDebug("set link "+s); |
780 | if(s.at(s.length()-4) == '.') //if regular file | 780 | if(s.at(s.length()-4) == '.') //if regular file |
781 | lnk.setFile( s); | 781 | lnk.setFile( s); |
782 | else | 782 | else |
783 | lnk.setFile( s+"/"); //if url with no extension | 783 | lnk.setFile( s+"/"); //if url with no extension |
784 | } | 784 | } |
785 | } | 785 | } |
786 | d->selectedFiles->addToSelection( lnk ); | 786 | d->selectedFiles->addToSelection( lnk ); |
787 | } | 787 | } |
788 | Config config( "OpiePlayer" ); | 788 | Config config( "OpiePlayer" ); |
789 | config.setGroup( "PlayList" ); | 789 | config.setGroup( "PlayList" ); |
790 | 790 | ||
791 | config.writeEntry("CurrentPlaylist",filename); | 791 | config.writeEntry("CurrentPlaylist",filename); |
792 | config.write(); | 792 | config.write(); |
793 | currentPlayList=filename; | 793 | currentPlayList=filename; |
794 | 794 | ||
795 | // m3uList->write(); | 795 | // m3uList->write(); |
796 | m3uList->close(); | 796 | m3uList->close(); |
797 | if(m3uList) delete m3uList; | 797 | if(m3uList) delete m3uList; |
798 | 798 | ||
799 | d->selectedFiles->setSelectedItem( s); | 799 | d->selectedFiles->setSelectedItem( s); |
800 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 800 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
801 | 801 | ||
802 | } | 802 | } |
803 | 803 | ||
804 | /* | 804 | /* |
805 | reads pls and adds files/urls to playlist */ | 805 | reads pls and adds files/urls to playlist */ |
806 | void PlayListWidget::readPls( const QString &filename ) { | 806 | void PlayListWidget::readPls( const QString &filename ) { |
807 | 807 | ||
808 | qDebug( "pls filename is " + filename ); | 808 | qDebug( "pls filename is " + filename ); |
809 | Om3u *m3uList; | 809 | Om3u *m3uList; |
810 | QString s, name; | 810 | QString s, name; |
811 | m3uList = new Om3u( filename, IO_ReadOnly ); | 811 | m3uList = new Om3u( filename, IO_ReadOnly ); |
812 | m3uList->readPls(); | 812 | m3uList->readPls(); |
813 | 813 | ||
814 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 814 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
815 | s = *it; | 815 | s = *it; |
816 | // s.replace( QRegExp( "%20" )," " ); | 816 | // s.replace( QRegExp( "%20" )," " ); |
817 | DocLnk lnk( s ); | 817 | DocLnk lnk( s ); |
818 | QFileInfo f( s ); | 818 | QFileInfo f( s ); |
819 | QString name = f.baseName(); | 819 | QString name = f.baseName(); |
820 | 820 | ||
821 | if( name.left( 4 ) == "http" ) { | 821 | if( name.left( 4 ) == "http" ) { |
822 | name = s.right( s.length() - 7); | 822 | name = s.right( s.length() - 7); |
823 | } else { | 823 | } else { |
824 | name = s; | 824 | name = s; |
825 | } | 825 | } |
826 | 826 | ||
827 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 827 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
828 | 828 | ||
829 | lnk.setName( name ); | 829 | lnk.setName( name ); |
830 | if( s.at( s.length() - 4) == '.') {// if this is probably a file | 830 | if( s.at( s.length() - 4) == '.') {// if this is probably a file |
831 | lnk.setFile( s ); | 831 | lnk.setFile( s ); |
832 | } else { //if its a url | 832 | } else { //if its a url |
833 | if( name.right( 1 ).find( '/' ) == -1) { | 833 | if( name.right( 1 ).find( '/' ) == -1) { |
834 | s += "/"; | 834 | s += "/"; |
835 | } | 835 | } |
836 | lnk.setFile( s ); | 836 | lnk.setFile( s ); |
837 | } | 837 | } |
838 | lnk.setType( "audio/x-mpegurl" ); | 838 | lnk.setType( "audio/x-mpegurl" ); |
839 | 839 | ||
840 | lnk.writeLink(); | 840 | lnk.writeLink(); |
841 | d->selectedFiles->addToSelection( lnk ); | 841 | d->selectedFiles->addToSelection( lnk ); |
842 | } | 842 | } |
843 | 843 | ||
844 | m3uList->close(); | 844 | m3uList->close(); |
845 | if(m3uList) delete m3uList; | 845 | if(m3uList) delete m3uList; |
846 | } | 846 | } |
847 | 847 | ||
848 | /* | 848 | /* |
849 | writes current playlist to current m3u file */ | 849 | writes current playlist to current m3u file */ |
850 | void PlayListWidget::writeCurrentM3u() { | 850 | void PlayListWidget::writeCurrentM3u() { |
851 | qDebug("writing to current m3u"); | 851 | qDebug("writing to current m3u"); |
852 | Config cfg( "OpiePlayer" ); | 852 | Config cfg( "OpiePlayer" ); |
853 | cfg.setGroup("PlayList"); | 853 | cfg.setGroup("PlayList"); |
854 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 854 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
855 | 855 | ||
856 | Om3u *m3uList; | 856 | Om3u *m3uList; |
857 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 857 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
858 | d->selectedFiles->first(); | 858 | d->selectedFiles->first(); |
859 | qDebug( d->selectedFiles->current()->file()); | 859 | qDebug( d->selectedFiles->current()->file()); |
860 | do { | 860 | do { |
861 | qDebug( d->selectedFiles->current()->file()); | 861 | qDebug( d->selectedFiles->current()->file()); |
862 | m3uList->add( d->selectedFiles->current()->file() ); | 862 | m3uList->add( d->selectedFiles->current()->file() ); |
863 | } | 863 | } |
864 | while ( d->selectedFiles->next() ); | 864 | while ( d->selectedFiles->next() ); |
865 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 865 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
866 | m3uList->write(); | 866 | m3uList->write(); |
867 | m3uList->close(); | 867 | m3uList->close(); |
868 | 868 | ||
869 | if(m3uList) delete m3uList; | 869 | if(m3uList) delete m3uList; |
870 | } | 870 | } |
871 | 871 | ||
872 | /* | 872 | /* |
873 | writes current playlist to m3u file */ | 873 | writes current playlist to m3u file */ |
874 | void PlayListWidget::writem3u() { | 874 | void PlayListWidget::writem3u() { |
875 | InputDialog *fileDlg; | 875 | InputDialog *fileDlg; |
876 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 876 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
877 | fileDlg->exec(); | 877 | fileDlg->exec(); |
878 | QString name, filename, list; | 878 | QString name, filename, list; |
879 | Om3u *m3uList; | 879 | Om3u *m3uList; |
880 | 880 | ||
881 | if( fileDlg->result() == 1 ) { | 881 | if( fileDlg->result() == 1 ) { |
882 | name = fileDlg->text(); | 882 | name = fileDlg->text(); |
883 | // qDebug( filename ); | 883 | // qDebug( filename ); |
884 | 884 | ||
885 | if( name.left( 1) != "/" ) { | 885 | if( name.left( 1) != "/" ) { |
886 | filename = QPEApplication::documentDir() + "/" + name; | 886 | filename = QPEApplication::documentDir() + "/" + name; |
887 | } | 887 | } |
888 | 888 | ||
889 | if( name.right( 3 ) != "m3u" ) { | 889 | if( name.right( 3 ) != "m3u" ) { |
890 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; | 890 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; |
891 | } | 891 | } |
892 | 892 | ||
893 | m3uList = new Om3u(filename, IO_ReadWrite); | 893 | m3uList = new Om3u(filename, IO_ReadWrite); |
894 | 894 | ||
895 | d->selectedFiles->first(); | 895 | d->selectedFiles->first(); |
896 | 896 | ||
897 | do { | 897 | do { |
898 | m3uList->add( d->selectedFiles->current()->file()); | 898 | m3uList->add( d->selectedFiles->current()->file()); |
899 | } | 899 | } |
900 | while ( d->selectedFiles->next() ); | 900 | while ( d->selectedFiles->next() ); |
901 | // qDebug( list ); | 901 | // qDebug( list ); |
902 | m3uList->write(); | 902 | m3uList->write(); |
903 | m3uList->close(); | 903 | m3uList->close(); |
904 | |||
905 | } | ||
906 | if(m3uList) delete m3uList; | 904 | if(m3uList) delete m3uList; |
905 | |||
907 | if(fileDlg) delete fileDlg; | 906 | if(fileDlg) delete fileDlg; |
908 | 907 | ||
909 | DocLnk lnk; | 908 | DocLnk lnk; |
910 | lnk.setFile( filename); | 909 | lnk.setFile( filename); |
911 | lnk.setIcon("opieplayer2/playlist2"); | 910 | lnk.setIcon("opieplayer2/playlist2"); |
912 | lnk.setName( name); //sets file name | 911 | lnk.setName( name); //sets file name |
913 | 912 | ||
914 | // qDebug(filename); | 913 | // qDebug(filename); |
915 | Config config( "OpiePlayer" ); | 914 | Config config( "OpiePlayer" ); |
916 | config.setGroup( "PlayList" ); | 915 | config.setGroup( "PlayList" ); |
917 | 916 | ||
918 | config.writeEntry("CurrentPlaylist",filename); | 917 | config.writeEntry("CurrentPlaylist",filename); |
919 | currentPlayList=filename; | 918 | currentPlayList=filename; |
920 | 919 | ||
921 | if(!lnk.writeLink()) { | 920 | if(!lnk.writeLink()) { |
922 | qDebug("Writing doclink did not work"); | 921 | qDebug("Writing doclink did not work"); |
923 | } | 922 | } |
924 | 923 | ||
925 | setCaption(tr("OpiePlayer: ") + name); | 924 | setCaption(tr("OpiePlayer: ") + name); |
925 | } | ||
926 | |||
926 | } | 927 | } |
927 | 928 | ||
928 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | 929 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { |
929 | switch ( e->key() ) { | 930 | switch ( e->key() ) { |
930 | ////////////////////////////// Zaurus keys | 931 | ////////////////////////////// Zaurus keys |
931 | case Key_F9: //activity | 932 | case Key_F9: //activity |
932 | // if(audioUI->isHidden()) | 933 | // if(audioUI->isHidden()) |
933 | // audioUI->showMaximized(); | 934 | // audioUI->showMaximized(); |
934 | break; | 935 | break; |
935 | case Key_F10: //contacts | 936 | case Key_F10: //contacts |
936 | // if( videoUI->isHidden()) | 937 | // if( videoUI->isHidden()) |
937 | // videoUI->showMaximized(); | 938 | // videoUI->showMaximized(); |
938 | break; | 939 | break; |
939 | case Key_F11: //menu | 940 | case Key_F11: //menu |
940 | break; | 941 | break; |
941 | case Key_F12: //home | 942 | case Key_F12: //home |
942 | // doBlank(); | 943 | // doBlank(); |
943 | break; | 944 | break; |
944 | case Key_F13: //mail | 945 | case Key_F13: //mail |
945 | // doUnblank(); | 946 | // doUnblank(); |
946 | break; | 947 | break; |
947 | case Key_Q: //add to playlist | 948 | case Key_Q: //add to playlist |
948 | addSelected(); | 949 | addSelected(); |
949 | break; | 950 | break; |
950 | case Key_R: //remove from playlist | 951 | case Key_R: //remove from playlist |
951 | removeSelected(); | 952 | removeSelected(); |
952 | break; | 953 | break; |
953 | // case Key_P: //play | 954 | // case Key_P: //play |
954 | // qDebug("Play"); | 955 | // qDebug("Play"); |
955 | // playSelected(); | 956 | // playSelected(); |
956 | // break; | 957 | // break; |
957 | case Key_Space: | 958 | case Key_Space: |
958 | // playSelected(); puh | 959 | // playSelected(); puh |
959 | break; | 960 | break; |
960 | case Key_1: | 961 | case Key_1: |
961 | tabWidget->setCurrentPage( 0 ); | 962 | tabWidget->setCurrentPage( 0 ); |
962 | break; | 963 | break; |
963 | case Key_2: | 964 | case Key_2: |
964 | tabWidget->setCurrentPage( 1 ); | 965 | tabWidget->setCurrentPage( 1 ); |
965 | break; | 966 | break; |
966 | case Key_3: | 967 | case Key_3: |
967 | tabWidget->setCurrentPage( 2 ); | 968 | tabWidget->setCurrentPage( 2 ); |
968 | break; | 969 | break; |
969 | case Key_4: | 970 | case Key_4: |
970 | tabWidget->setCurrentPage( 3 ); | 971 | tabWidget->setCurrentPage( 3 ); |
971 | break; | 972 | break; |
972 | case Key_Down: | 973 | case Key_Down: |
973 | if ( !d->selectedFiles->next() ) | 974 | if ( !d->selectedFiles->next() ) |
974 | d->selectedFiles->first(); | 975 | d->selectedFiles->first(); |
975 | break; | 976 | break; |
976 | case Key_Up: | 977 | case Key_Up: |
977 | if ( !d->selectedFiles->prev() ) | 978 | if ( !d->selectedFiles->prev() ) |
978 | // d->selectedFiles->last(); | 979 | // d->selectedFiles->last(); |
979 | break; | 980 | break; |
980 | } | 981 | } |
981 | } | 982 | } |
982 | 983 | ||
983 | void PlayListWidget::pmViewActivated(int index) { | 984 | void PlayListWidget::pmViewActivated(int index) { |
984 | // qDebug("%d", index); | 985 | // qDebug("%d", index); |
985 | switch(index) { | 986 | switch(index) { |
986 | case -16: | 987 | case -16: |
987 | { | 988 | { |
988 | mediaPlayerState->toggleFullscreen(); | 989 | mediaPlayerState->toggleFullscreen(); |
989 | bool b=mediaPlayerState->fullscreen(); | 990 | bool b=mediaPlayerState->fullscreen(); |
990 | pmView->setItemChecked( index, b); | 991 | pmView->setItemChecked( index, b); |
991 | Config cfg( "OpiePlayer" ); | 992 | Config cfg( "OpiePlayer" ); |
992 | cfg.writeEntry( "FullScreen", b ); | 993 | cfg.writeEntry( "FullScreen", b ); |
993 | } | 994 | } |
994 | break; | 995 | break; |
995 | }; | 996 | }; |
996 | } | 997 | } |
997 | 998 | ||
998 | void PlayListWidget::populateSkinsMenu() { | 999 | void PlayListWidget::populateSkinsMenu() { |
999 | int item = 0; | 1000 | int item = 0; |
1000 | defaultSkinIndex = 0; | 1001 | defaultSkinIndex = 0; |
1001 | QString skinName; | 1002 | QString skinName; |
1002 | Config cfg( "OpiePlayer" ); | 1003 | Config cfg( "OpiePlayer" ); |
1003 | cfg.setGroup("Options" ); | 1004 | cfg.setGroup("Options" ); |
1004 | QString skin = cfg.readEntry( "Skin", "default" ); | 1005 | QString skin = cfg.readEntry( "Skin", "default" ); |
1005 | 1006 | ||
1006 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 1007 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
1007 | skinsDir.setFilter( QDir::Dirs ); | 1008 | skinsDir.setFilter( QDir::Dirs ); |
1008 | skinsDir.setSorting(QDir::Name ); | 1009 | skinsDir.setSorting(QDir::Name ); |
1009 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 1010 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
1010 | QFileInfoListIterator it( *skinslist ); | 1011 | QFileInfoListIterator it( *skinslist ); |
1011 | QFileInfo *fi; | 1012 | QFileInfo *fi; |
1012 | while ( ( fi = it.current() ) ) { | 1013 | while ( ( fi = it.current() ) ) { |
1013 | skinName = fi->fileName(); | 1014 | skinName = fi->fileName(); |
1014 | // qDebug( fi->fileName() ); | 1015 | // qDebug( fi->fileName() ); |
1015 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 1016 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
1016 | item = skinsMenu->insertItem( fi->fileName() ) ; | 1017 | item = skinsMenu->insertItem( fi->fileName() ) ; |
1017 | } | 1018 | } |
1018 | if( skinName == "default" ) { | 1019 | if( skinName == "default" ) { |
1019 | defaultSkinIndex = item; | 1020 | defaultSkinIndex = item; |
1020 | } | 1021 | } |
1021 | if( skinName == skin ) { | 1022 | if( skinName == skin ) { |
1022 | skinsMenu->setItemChecked( item, TRUE ); | 1023 | skinsMenu->setItemChecked( item, TRUE ); |
1023 | } | 1024 | } |
1024 | ++it; | 1025 | ++it; |
1025 | } | 1026 | } |
1026 | } | 1027 | } |
1027 | 1028 | ||
1028 | void PlayListWidget::skinsMenuActivated( int item ) { | 1029 | void PlayListWidget::skinsMenuActivated( int item ) { |
1029 | for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { | 1030 | for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { |
1030 | skinsMenu->setItemChecked( i, FALSE ); | 1031 | skinsMenu->setItemChecked( i, FALSE ); |
1031 | } | 1032 | } |
1032 | skinsMenu->setItemChecked( item, TRUE ); | 1033 | skinsMenu->setItemChecked( item, TRUE ); |
1033 | 1034 | ||
1034 | Config cfg( "OpiePlayer" ); | 1035 | Config cfg( "OpiePlayer" ); |
1035 | cfg.setGroup("Options"); | 1036 | cfg.setGroup("Options"); |
1036 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 1037 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
1037 | } | 1038 | } |
1038 | 1039 | ||
1039 | int PlayListWidget::whichList() { | 1040 | int PlayListWidget::whichList() { |
1040 | return tabWidget->currentPageIndex(); | 1041 | return tabWidget->currentPageIndex(); |
1041 | } | 1042 | } |
1042 | 1043 | ||
1043 | QString PlayListWidget::currentFileListPathName() { | 1044 | QString PlayListWidget::currentFileListPathName() { |
1044 | switch (whichList()) { | 1045 | switch (whichList()) { |
1045 | case 1: | 1046 | case 1: |
1046 | return audioView->currentItem()->text(3); | 1047 | return audioView->currentItem()->text(3); |
1047 | break; | 1048 | break; |
1048 | case 2: | 1049 | case 2: |
1049 | return videoView->currentItem()->text(3); | 1050 | return videoView->currentItem()->text(3); |
1050 | break; | 1051 | break; |
1051 | }; | 1052 | }; |
1052 | return ""; | 1053 | return ""; |
1053 | } | 1054 | } |