summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp30
1 files changed, 22 insertions, 8 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 19c8056..3c5734e 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -186,1039 +186,1053 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
186 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 186 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
187 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 187 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
188 pmPlayList->insertSeparator(-1); 188 pmPlayList->insertSeparator(-1);
189 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 189 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
190 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); 190 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
191 pmPlayList->insertSeparator(-1); 191 pmPlayList->insertSeparator(-1);
192 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); 192 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) );
193 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); 193 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) );
194 194
195 QPopupMenu *pmView = new QPopupMenu( this ); 195 QPopupMenu *pmView = new QPopupMenu( this );
196 menu->insertItem( tr( "View" ), pmView ); 196 menu->insertItem( tr( "View" ), pmView );
197 197
198 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); 198 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0);
199 fullScreenButton->addTo(pmView); 199 fullScreenButton->addTo(pmView);
200 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); 200 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0);
201 scaleButton->addTo(pmView); 201 scaleButton->addTo(pmView);
202 202
203 203
204 skinsMenu = new QPopupMenu( this ); 204 skinsMenu = new QPopupMenu( this );
205 menu->insertItem( tr( "Skins" ), skinsMenu ); 205 menu->insertItem( tr( "Skins" ), skinsMenu );
206 skinsMenu->isCheckable(); 206 skinsMenu->isCheckable();
207 connect( skinsMenu, SIGNAL( activated( int ) ) , 207 connect( skinsMenu, SIGNAL( activated( int ) ) ,
208 this, SLOT( skinsMenuActivated( int ) ) ); 208 this, SLOT( skinsMenuActivated( int ) ) );
209 populateSkinsMenu(); 209 populateSkinsMenu();
210 210
211 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); 211 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
212 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); 212 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
213 213
214 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); 214 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
215 215
216 tabWidget = new QTabWidget( hbox6, "tabWidget" ); 216 tabWidget = new QTabWidget( hbox6, "tabWidget" );
217 tabWidget->setTabShape(QTabWidget::Triangular); 217 tabWidget->setTabShape(QTabWidget::Triangular);
218 218
219 QWidget *pTab; 219 QWidget *pTab;
220 pTab = new QWidget( tabWidget, "pTab" ); 220 pTab = new QWidget( tabWidget, "pTab" );
221// playlistView = new QListView( pTab, "playlistview" ); 221// playlistView = new QListView( pTab, "playlistview" );
222// playlistView->setMinimumSize(236,260); 222// playlistView->setMinimumSize(236,260);
223 tabWidget->insertTab( pTab,"Playlist"); 223 tabWidget->insertTab( pTab,"Playlist");
224 224
225 225
226 // Add the playlist area 226 // Add the playlist area
227 227
228 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); 228 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
229 d->playListFrame = vbox3; 229 d->playListFrame = vbox3;
230 d->playListFrame ->setMinimumSize(235,260); 230 d->playListFrame ->setMinimumSize(235,260);
231 231
232 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); 232 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton );
233 233
234 d->selectedFiles = new PlayListSelection( hbox2); 234 d->selectedFiles = new PlayListSelection( hbox2);
235 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); 235 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton );
236 236
237 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); 237 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold);
238 238
239 239
240 240
241 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch 241 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
242 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); 242 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) );
243 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); 243 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) );
244 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); 244 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) );
245 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch 245 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
246 246
247 QWidget *aTab; 247 QWidget *aTab;
248 aTab = new QWidget( tabWidget, "aTab" ); 248 aTab = new QWidget( tabWidget, "aTab" );
249 audioView = new QListView( aTab, "Audioview" ); 249 audioView = new QListView( aTab, "Audioview" );
250 audioView->setMinimumSize(233,260); 250 audioView->setMinimumSize(233,260);
251 audioView->addColumn( tr("Title"),140); 251 audioView->addColumn( tr("Title"),140);
252 audioView->addColumn(tr("Size"), -1); 252 audioView->addColumn(tr("Size"), -1);
253 audioView->addColumn(tr("Media"),-1); 253 audioView->addColumn(tr("Media"),-1);
254 audioView->addColumn( tr( "Path" ), 0 ); 254 audioView->addColumn( tr( "Path" ), 0 );
255 255
256 audioView->setColumnAlignment(1, Qt::AlignRight); 256 audioView->setColumnAlignment(1, Qt::AlignRight);
257 audioView->setColumnAlignment(2, Qt::AlignRight); 257 audioView->setColumnAlignment(2, Qt::AlignRight);
258 audioView->setAllColumnsShowFocus(TRUE); 258 audioView->setAllColumnsShowFocus(TRUE);
259 259
260 audioView->setMultiSelection( TRUE ); 260 audioView->setMultiSelection( TRUE );
261 audioView->setSelectionMode( QListView::Extended); 261 audioView->setSelectionMode( QListView::Extended);
262 audioView->setSorting( 3, TRUE ); 262 audioView->setSorting( 3, TRUE );
263 263
264 tabWidget->insertTab(aTab,tr("Audio")); 264 tabWidget->insertTab(aTab,tr("Audio"));
265 265
266 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); 266 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold);
267 267
268// audioView 268// audioView
269// populateAudioView(); 269// populateAudioView();
270// videowidget 270// videowidget
271 271
272 QWidget *vTab; 272 QWidget *vTab;
273 vTab = new QWidget( tabWidget, "vTab" ); 273 vTab = new QWidget( tabWidget, "vTab" );
274 videoView = new QListView( vTab, "Videoview" ); 274 videoView = new QListView( vTab, "Videoview" );
275 videoView->setMinimumSize(233,260); 275 videoView->setMinimumSize(233,260);
276 276
277 videoView->addColumn(tr("Title"),140); 277 videoView->addColumn(tr("Title"),140);
278 videoView->addColumn(tr("Size"),-1); 278 videoView->addColumn(tr("Size"),-1);
279 videoView->addColumn(tr("Media"),-1); 279 videoView->addColumn(tr("Media"),-1);
280 videoView->addColumn(tr( "Path" ), 0 ); 280 videoView->addColumn(tr( "Path" ), 0 );
281 videoView->setColumnAlignment(1, Qt::AlignRight); 281 videoView->setColumnAlignment(1, Qt::AlignRight);
282 videoView->setColumnAlignment(2, Qt::AlignRight); 282 videoView->setColumnAlignment(2, Qt::AlignRight);
283 videoView->setAllColumnsShowFocus(TRUE); 283 videoView->setAllColumnsShowFocus(TRUE);
284 videoView->setMultiSelection( TRUE ); 284 videoView->setMultiSelection( TRUE );
285 videoView->setSelectionMode( QListView::Extended); 285 videoView->setSelectionMode( QListView::Extended);
286 286
287 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); 287 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold);
288 288
289 tabWidget->insertTab( vTab,tr("Video")); 289 tabWidget->insertTab( vTab,tr("Video"));
290 290
291 QWidget *LTab; 291 QWidget *LTab;
292 LTab = new QWidget( tabWidget, "LTab" ); 292 LTab = new QWidget( tabWidget, "LTab" );
293 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy 293 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy
294 playLists->setMinimumSize(233,260); 294 playLists->setMinimumSize(233,260);
295 tabWidget->insertTab(LTab,tr("Lists")); 295 tabWidget->insertTab(LTab,tr("Lists"));
296 296
297 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); 297 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist()));
298 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); 298 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) );
299 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); 299 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) );
300 300
301 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 301 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
302 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); 302 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) );
303 303
304 304
305///audioView 305///audioView
306 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 306 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
307 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 307 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
308 308
309 connect( audioView, SIGNAL( returnPressed( QListViewItem *)), 309 connect( audioView, SIGNAL( returnPressed( QListViewItem *)),
310 this,SLOT( playIt( QListViewItem *)) ); 310 this,SLOT( playIt( QListViewItem *)) );
311 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 311 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
312 312
313 313
314//videoView 314//videoView
315 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 315 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
316 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 316 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
317 connect( videoView, SIGNAL( returnPressed( QListViewItem *)), 317 connect( videoView, SIGNAL( returnPressed( QListViewItem *)),
318 this,SLOT( playIt( QListViewItem *)) ); 318 this,SLOT( playIt( QListViewItem *)) );
319 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 319 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
320 320
321 321
322//playlists 322//playlists
323 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); 323 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
324 324
325 325
326 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); 326 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
327 327
328// connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); 328// connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
329 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); 329 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
330 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); 330 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
331 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); 331 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
332 332
333 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 333 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
334 334
335 setCentralWidget( vbox5 ); 335 setCentralWidget( vbox5 );
336 336
337 Config cfg( "OpiePlayer" ); 337 Config cfg( "OpiePlayer" );
338 readConfig( cfg ); 338 readConfig( cfg );
339 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); 339 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
340 loadList(DocLnk( currentPlaylist)); 340 loadList(DocLnk( currentPlaylist));
341 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlaylist))); 341 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlaylist)));
342 342
343 initializeStates(); 343 initializeStates();
344} 344}
345 345
346 346
347PlayListWidget::~PlayListWidget() { 347PlayListWidget::~PlayListWidget() {
348 Config cfg( "OpiePlayer" ); 348 Config cfg( "OpiePlayer" );
349 writeConfig( cfg ); 349 writeConfig( cfg );
350 350
351 if ( d->current ) 351 if ( d->current )
352 delete d->current; 352 delete d->current;
353 delete d; 353 delete d;
354} 354}
355 355
356 356
357void PlayListWidget::initializeStates() { 357void PlayListWidget::initializeStates() {
358 358
359 d->tbPlay->setOn( mediaPlayerState->playing() ); 359 d->tbPlay->setOn( mediaPlayerState->playing() );
360 d->tbLoop->setOn( mediaPlayerState->looping() ); 360 d->tbLoop->setOn( mediaPlayerState->looping() );
361 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 361 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
362 setPlaylist( true); 362 setPlaylist( true);
363} 363}
364 364
365 365
366void PlayListWidget::readConfig( Config& cfg ) { 366void PlayListWidget::readConfig( Config& cfg ) {
367 cfg.setGroup("PlayList"); 367 cfg.setGroup("PlayList");
368 QString currentString = cfg.readEntry("current", "" ); 368 QString currentString = cfg.readEntry("current", "" );
369 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 369 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
370 for ( int i = 0; i < noOfFiles; i++ ) { 370 for ( int i = 0; i < noOfFiles; i++ ) {
371 QString entryName; 371 QString entryName;
372 entryName.sprintf( "File%i", i + 1 ); 372 entryName.sprintf( "File%i", i + 1 );
373 QString linkFile = cfg.readEntry( entryName ); 373 QString linkFile = cfg.readEntry( entryName );
374 DocLnk lnk( linkFile ); 374 DocLnk lnk( linkFile );
375 if ( lnk.isValid() ) { 375 if ( lnk.isValid() ) {
376 d->selectedFiles->addToSelection( lnk ); 376 d->selectedFiles->addToSelection( lnk );
377 } 377 }
378 } 378 }
379 d->selectedFiles->setSelectedItem( currentString); 379 d->selectedFiles->setSelectedItem( currentString);
380} 380}
381 381
382 382
383void PlayListWidget::writeConfig( Config& cfg ) const { 383void PlayListWidget::writeConfig( Config& cfg ) const {
384 384
385 d->selectedFiles->writeCurrent( cfg); 385 d->selectedFiles->writeCurrent( cfg);
386 cfg.setGroup("PlayList"); 386 cfg.setGroup("PlayList");
387 int noOfFiles = 0; 387 int noOfFiles = 0;
388 d->selectedFiles->first(); 388 d->selectedFiles->first();
389 do { 389 do {
390 const DocLnk *lnk = d->selectedFiles->current(); 390 const DocLnk *lnk = d->selectedFiles->current();
391 if ( lnk ) { 391 if ( lnk ) {
392 QString entryName; 392 QString entryName;
393 entryName.sprintf( "File%i", noOfFiles + 1 ); 393 entryName.sprintf( "File%i", noOfFiles + 1 );
394// qDebug(entryName); 394// qDebug(entryName);
395 cfg.writeEntry( entryName, lnk->linkFile() ); 395 cfg.writeEntry( entryName, lnk->linkFile() );
396 // if this link does exist, add it so we have the file 396 // if this link does exist, add it so we have the file
397 // next time... 397 // next time...
398 if ( !QFile::exists( lnk->linkFile() ) ) { 398 if ( !QFile::exists( lnk->linkFile() ) ) {
399 // the way writing lnks doesn't really check for out 399 // the way writing lnks doesn't really check for out
400 // of disk space, but check it anyway. 400 // of disk space, but check it anyway.
401 if ( !lnk->writeLink() ) { 401 if ( !lnk->writeLink() ) {
402 QMessageBox::critical( 0, tr("Out of space"), 402 QMessageBox::critical( 0, tr("Out of space"),
403 tr( "There was a problem saving " 403 tr( "There was a problem saving "
404 "the playlist.\n" 404 "the playlist.\n"
405 "Your playlist " 405 "Your playlist "
406 "may be missing some entries\n" 406 "may be missing some entries\n"
407 "the next time you start it." ) 407 "the next time you start it." )
408 ); 408 );
409 } 409 }
410 } 410 }
411 noOfFiles++; 411 noOfFiles++;
412 } 412 }
413 } 413 }
414 while ( d->selectedFiles->next() ); 414 while ( d->selectedFiles->next() );
415 cfg.writeEntry("NumberOfFiles", noOfFiles ); 415 cfg.writeEntry("NumberOfFiles", noOfFiles );
416} 416}
417 417
418 418
419void PlayListWidget::addToSelection( const DocLnk& lnk ) { 419void PlayListWidget::addToSelection( const DocLnk& lnk ) {
420 d->setDocumentUsed = false; 420 d->setDocumentUsed = false;
421 if ( mediaPlayerState->playlist() ) { 421 if ( mediaPlayerState->playlist() ) {
422 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) 422 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" )
423 d->selectedFiles->addToSelection( lnk ); 423 d->selectedFiles->addToSelection( lnk );
424 } 424 }
425 else 425 else
426 mediaPlayerState->setPlaying( true); 426 mediaPlayerState->setPlaying( true);
427} 427}
428 428
429 429
430void PlayListWidget::clearList() { 430void PlayListWidget::clearList() {
431 while ( first() ) 431 while ( first() )
432 d->selectedFiles->removeSelected(); 432 d->selectedFiles->removeSelected();
433} 433}
434 434
435 435
436void PlayListWidget::addAllToList() { 436void PlayListWidget::addAllToList() {
437 DocLnkSet filesAll; 437 DocLnkSet filesAll;
438 Global::findDocuments(&filesAll, "video/*;audio/*"); 438 Global::findDocuments(&filesAll, "video/*;audio/*");
439 QListIterator<DocLnk> Adit( filesAll.children() ); 439 QListIterator<DocLnk> Adit( filesAll.children() );
440 for ( ; Adit.current(); ++Adit ) 440 for ( ; Adit.current(); ++Adit )
441 if(QFileInfo(Adit.current()->file()).exists()) 441 if(QFileInfo(Adit.current()->file()).exists())
442 d->selectedFiles->addToSelection( **Adit ); 442 d->selectedFiles->addToSelection( **Adit );
443 tabWidget->setCurrentPage(0); 443 tabWidget->setCurrentPage(0);
444 444
445 writeCurrentM3u(); 445 writeCurrentM3u();
446 d->selectedFiles->first(); 446 d->selectedFiles->first();
447} 447}
448 448
449 449
450void PlayListWidget::addAllMusicToList() { 450void PlayListWidget::addAllMusicToList() {
451 QListIterator<DocLnk> dit( files.children() ); 451 QListIterator<DocLnk> dit( files.children() );
452 for ( ; dit.current(); ++dit ) 452 for ( ; dit.current(); ++dit )
453 if(QFileInfo(dit.current()->file()).exists()) 453 if(QFileInfo(dit.current()->file()).exists())
454 d->selectedFiles->addToSelection( **dit ); 454 d->selectedFiles->addToSelection( **dit );
455 tabWidget->setCurrentPage(0); 455 tabWidget->setCurrentPage(0);
456 456
457 writeCurrentM3u(); 457 writeCurrentM3u();
458 d->selectedFiles->first(); 458 d->selectedFiles->first();
459} 459}
460 460
461 461
462void PlayListWidget::addAllVideoToList() { 462void PlayListWidget::addAllVideoToList() {
463 QListIterator<DocLnk> dit( vFiles.children() ); 463 QListIterator<DocLnk> dit( vFiles.children() );
464 for ( ; dit.current(); ++dit ) 464 for ( ; dit.current(); ++dit )
465 if(QFileInfo( dit.current()->file()).exists()) 465 if(QFileInfo( dit.current()->file()).exists())
466 d->selectedFiles->addToSelection( **dit ); 466 d->selectedFiles->addToSelection( **dit );
467 tabWidget->setCurrentPage(0); 467 tabWidget->setCurrentPage(0);
468 468
469 writeCurrentM3u(); 469 writeCurrentM3u();
470 d->selectedFiles->first(); 470 d->selectedFiles->first();
471} 471}
472 472
473 473
474void PlayListWidget::setDocument(const QString& fileref) { 474void PlayListWidget::setDocument(const QString& fileref) {
475 qDebug(fileref); 475 qDebug(fileref);
476 fromSetDocument = TRUE; 476 fromSetDocument = TRUE;
477 QFileInfo fileInfo(fileref); 477 QFileInfo fileInfo(fileref);
478 if ( !fileInfo.exists() ) { 478 if ( !fileInfo.exists() ) {
479 QMessageBox::critical( 0, tr( "Invalid File" ), 479 QMessageBox::critical( 0, tr( "Invalid File" ),
480 tr( "There was a problem in getting the file." ) ); 480 tr( "There was a problem in getting the file." ) );
481 return; 481 return;
482 } 482 }
483// qDebug("setDocument "+fileref); 483// qDebug("setDocument "+fileref);
484 QString extension = fileInfo.extension(false); 484 QString extension = fileInfo.extension(false);
485 if( extension.find( "m3u", 0, false) != -1) { //is m3u 485 if( extension.find( "m3u", 0, false) != -1) { //is m3u
486 readm3u( fileref); 486 readm3u( fileref);
487 } 487 }
488 else if( extension.find( "pls", 0, false) != -1 ) { //is pls 488 else if( extension.find( "pls", 0, false) != -1 ) { //is pls
489 readPls( fileref); 489 readPls( fileref);
490 } 490 }
491 else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist 491 else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist
492 clearList(); 492 clearList();
493 DocLnk lnk; 493 DocLnk lnk;
494 lnk.setName( fileInfo.baseName() ); //sets name 494 lnk.setName( fileInfo.baseName() ); //sets name
495 lnk.setFile( fileref ); //sets file name 495 lnk.setFile( fileref ); //sets file name
496 //addToSelection( lnk ); 496 //addToSelection( lnk );
497 497
498 loadList( lnk); 498 loadList( lnk);
499 d->selectedFiles->first(); 499 d->selectedFiles->first();
500 } else { 500 } else {
501 clearList(); 501 clearList();
502 DocLnk lnk; 502 DocLnk lnk;
503 lnk.setName( fileInfo.baseName() ); //sets name 503 lnk.setName( fileInfo.baseName() ); //sets name
504 lnk.setFile( fileref ); //sets file name 504 lnk.setFile( fileref ); //sets file name
505 addToSelection( lnk ); 505 addToSelection( lnk );
506// addToSelection( DocLnk( fileref ) ); 506// addToSelection( DocLnk( fileref ) );
507 d->setDocumentUsed = TRUE; 507 d->setDocumentUsed = TRUE;
508 mediaPlayerState->setPlaying( FALSE ); 508 mediaPlayerState->setPlaying( FALSE );
509 qApp->processEvents(); 509 qApp->processEvents();
510 mediaPlayerState->setPlaying( TRUE ); 510 mediaPlayerState->setPlaying( TRUE );
511 qApp->processEvents(); 511 qApp->processEvents();
512 setCaption(tr("OpiePlayer")); 512 setCaption(tr("OpiePlayer"));
513 } 513 }
514} 514}
515 515
516 516
517void PlayListWidget::setActiveWindow() { 517void PlayListWidget::setActiveWindow() {
518 qDebug("SETTING active window"); 518 qDebug("SETTING active window");
519 519
520 // When we get raised we need to ensure that it switches views 520 // When we get raised we need to ensure that it switches views
521 char origView = mediaPlayerState->view(); 521 char origView = mediaPlayerState->view();
522 mediaPlayerState->setView( 'l' ); // invalidate 522 mediaPlayerState->setView( 'l' ); // invalidate
523 mediaPlayerState->setView( origView ); // now switch back 523 mediaPlayerState->setView( origView ); // now switch back
524} 524}
525 525
526 526
527void PlayListWidget::useSelectedDocument() { 527void PlayListWidget::useSelectedDocument() {
528 d->setDocumentUsed = FALSE; 528 d->setDocumentUsed = FALSE;
529} 529}
530 530
531 531
532const DocLnk *PlayListWidget::current() { // this is fugly 532const DocLnk *PlayListWidget::current() { // this is fugly
533 533
534// if( fromSetDocument) { 534// if( fromSetDocument) {
535// qDebug("from setDoc"); 535// qDebug("from setDoc");
536// DocLnkSet files; 536// DocLnkSet files;
537// Global::findDocuments(&files, "video/*;audio/*"); 537// Global::findDocuments(&files, "video/*;audio/*");
538// QListIterator<DocLnk> dit( files.children() ); 538// QListIterator<DocLnk> dit( files.children() );
539// for ( ; dit.current(); ++dit ) { 539// for ( ; dit.current(); ++dit ) {
540// if(dit.current()->linkFile() == setDocFileRef) { 540// if(dit.current()->linkFile() == setDocFileRef) {
541// qDebug(setDocFileRef); 541// qDebug(setDocFileRef);
542// return dit; 542// return dit;
543// } 543// }
544// } 544// }
545// } else 545// } else
546 546
547 qDebug("current"); 547 qDebug("current");
548 548
549 switch (tabWidget->currentPageIndex()) { 549 switch (tabWidget->currentPageIndex()) {
550 case 0: //playlist 550 case 0: //playlist
551 { 551 {
552 qDebug("playlist"); 552 qDebug("playlist");
553 if ( mediaPlayerState->playlist() ) { 553 if ( mediaPlayerState->playlist() ) {
554 return d->selectedFiles->current(); 554 return d->selectedFiles->current();
555 } 555 }
556 else if ( d->setDocumentUsed && d->current ) { 556 else if ( d->setDocumentUsed && d->current ) {
557 return d->current; 557 return d->current;
558 } else { 558 } else {
559 return &(d->files->selectedDocument()); 559 return &(d->files->selectedDocument());
560 } 560 }
561 } 561 }
562 break; 562 break;
563 case 1://audio 563 case 1://audio
564 { 564 {
565 qDebug("audioView"); 565 qDebug("audioView");
566 QListIterator<DocLnk> dit( files.children() ); 566 QListIterator<DocLnk> dit( files.children() );
567 for ( ; dit.current(); ++dit ) { 567 for ( ; dit.current(); ++dit ) {
568 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { 568 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) {
569 qDebug("here"); 569 qDebug("here");
570 insanityBool=TRUE; 570 insanityBool=TRUE;
571 return dit; 571 return dit;
572 } 572 }
573 } 573 }
574 } 574 }
575 break; 575 break;
576 case 2: // video 576 case 2: // video
577 { 577 {
578 qDebug("videoView"); 578 qDebug("videoView");
579 QListIterator<DocLnk> Vdit( vFiles.children() ); 579 QListIterator<DocLnk> Vdit( vFiles.children() );
580 for ( ; Vdit.current(); ++Vdit ) { 580 for ( ; Vdit.current(); ++Vdit ) {
581 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { 581 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) {
582 insanityBool=TRUE; 582 insanityBool=TRUE;
583 return Vdit; 583 return Vdit;
584 } 584 }
585 } 585 }
586 } 586 }
587 break; 587 break;
588 }; 588 };
589 return 0; 589 return 0;
590} 590}
591 591
592bool PlayListWidget::prev() { 592bool PlayListWidget::prev() {
593 if ( mediaPlayerState->playlist() ) { 593 if ( mediaPlayerState->playlist() ) {
594 if ( mediaPlayerState->shuffled() ) { 594 if ( mediaPlayerState->shuffled() ) {
595 const DocLnk *cur = current(); 595 const DocLnk *cur = current();
596 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 596 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
597 for ( int i = 0; i < j; i++ ) { 597 for ( int i = 0; i < j; i++ ) {
598 if ( !d->selectedFiles->next() ) 598 if ( !d->selectedFiles->next() )
599 d->selectedFiles->first(); 599 d->selectedFiles->first();
600 } 600 }
601 if ( cur == current() ) 601 if ( cur == current() )
602 if ( !d->selectedFiles->next() ) 602 if ( !d->selectedFiles->next() )
603 d->selectedFiles->first(); 603 d->selectedFiles->first();
604 return TRUE; 604 return TRUE;
605 } else { 605 } else {
606 if ( !d->selectedFiles->prev() ) { 606 if ( !d->selectedFiles->prev() ) {
607 if ( mediaPlayerState->looping() ) { 607 if ( mediaPlayerState->looping() ) {
608 return d->selectedFiles->last(); 608 return d->selectedFiles->last();
609 } else { 609 } else {
610 return FALSE; 610 return FALSE;
611 } 611 }
612 } 612 }
613 return TRUE; 613 return TRUE;
614 } 614 }
615 } else { 615 } else {
616 return mediaPlayerState->looping(); 616 return mediaPlayerState->looping();
617 } 617 }
618} 618}
619 619
620 620
621bool PlayListWidget::next() { 621bool PlayListWidget::next() {
622 if ( mediaPlayerState->playlist() ) { 622 if ( mediaPlayerState->playlist() ) {
623 if ( mediaPlayerState->shuffled() ) { 623 if ( mediaPlayerState->shuffled() ) {
624 return prev(); 624 return prev();
625 } else { 625 } else {
626 if ( !d->selectedFiles->next() ) { 626 if ( !d->selectedFiles->next() ) {
627 if ( mediaPlayerState->looping() ) { 627 if ( mediaPlayerState->looping() ) {
628 return d->selectedFiles->first(); 628 return d->selectedFiles->first();
629 } else { 629 } else {
630 return FALSE; 630 return FALSE;
631 } 631 }
632 } 632 }
633 return TRUE; 633 return TRUE;
634 } 634 }
635 } else { 635 } else {
636 return mediaPlayerState->looping(); 636 return mediaPlayerState->looping();
637 } 637 }
638} 638}
639 639
640 640
641bool PlayListWidget::first() { 641bool PlayListWidget::first() {
642 if ( mediaPlayerState->playlist() ) 642 if ( mediaPlayerState->playlist() )
643 return d->selectedFiles->first(); 643 return d->selectedFiles->first();
644 else 644 else
645 return mediaPlayerState->looping(); 645 return mediaPlayerState->looping();
646} 646}
647 647
648 648
649bool PlayListWidget::last() { 649bool PlayListWidget::last() {
650 if ( mediaPlayerState->playlist() ) 650 if ( mediaPlayerState->playlist() )
651 return d->selectedFiles->last(); 651 return d->selectedFiles->last();
652 else 652 else
653 return mediaPlayerState->looping(); 653 return mediaPlayerState->looping();
654} 654}
655 655
656 656
657void PlayListWidget::saveList() { 657void PlayListWidget::saveList() {
658 writem3u(); 658 writem3u();
659} 659}
660 660
661void PlayListWidget::loadList( const DocLnk & lnk) { 661void PlayListWidget::loadList( const DocLnk & lnk) {
662 QString name = lnk.name(); 662 QString name = lnk.name();
663// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); 663// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name);
664 664
665 if( name.length()>0) { 665 if( name.length()>0) {
666 setCaption("OpiePlayer: "+name); 666 setCaption("OpiePlayer: "+name);
667// qDebug("<<<<<<<<<<<<load list "+ lnk.file()); 667// qDebug("<<<<<<<<<<<<load list "+ lnk.file());
668 clearList(); 668 clearList();
669 readm3u(lnk.file()); 669 readm3u(lnk.file());
670 tabWidget->setCurrentPage(0); 670 tabWidget->setCurrentPage(0);
671 } 671 }
672} 672}
673 673
674void PlayListWidget::setPlaylist( bool shown ) { 674void PlayListWidget::setPlaylist( bool shown ) {
675 if ( shown ) 675 if ( shown )
676 d->playListFrame->show(); 676 d->playListFrame->show();
677 else 677 else
678 d->playListFrame->hide(); 678 d->playListFrame->hide();
679} 679}
680 680
681void PlayListWidget::setView( char view ) { 681void PlayListWidget::setView( char view ) {
682 if ( view == 'l' ) 682 if ( view == 'l' )
683 showMaximized(); 683 showMaximized();
684 else 684 else
685 hide(); 685 hide();
686} 686}
687 687
688void PlayListWidget::addSelected() { 688void PlayListWidget::addSelected() {
689 qDebug("addSelected"); 689 qDebug("addSelected");
690 DocLnk lnk; 690 DocLnk lnk;
691 QString filename; 691 QString filename;
692 switch (tabWidget->currentPageIndex()) { 692 switch (tabWidget->currentPageIndex()) {
693 693
694 case 0: //playlist 694 case 0: //playlist
695 return; 695 return;
696 break; 696 break;
697 case 1: { //audio 697 case 1: { //audio
698 filename=audioView->currentItem()->text(3); 698 QListViewItemIterator it( audioView );
699 // d->selectedFiles->next(); 699 for ( ; it.current(); ++it ) {
700 if ( it.current()->isSelected() ) {
701 filename = it.current()->text(3);
702 lnk.setName( QFileInfo(filename).baseName() ); //sets name
703 lnk.setFile( filename ); //sets file name
704 d->selectedFiles->addToSelection( lnk);
705 }
706 }
707 audioView->clearSelection();
708 // d->selectedFiles->next();
700 } 709 }
701 break; 710 break;
702 711
703 case 2: { // video 712 case 2: { // video
704 filename=videoView->currentItem()->text(3); 713 QListViewItemIterator it( videoView );
705 // tabWidget->setCurrentPage(0); 714 for ( ; it.current(); ++it ) {
706 715 if ( it.current()->isSelected() ) {
716
717 filename = it.current()->text(3);
718 lnk.setName( QFileInfo(filename).baseName() ); //sets name
719 lnk.setFile( filename ); //sets file name
720 d->selectedFiles->addToSelection( lnk);
721 }
722 }
723 videoView->clearSelection();
707 } 724 }
708 break; 725 break;
709 }; 726 };
710 lnk.setName( fullBaseName ( QFileInfo(filename))); //sets name
711 lnk.setFile( filename ); //sets file name
712 d->selectedFiles->addToSelection( lnk);
713 tabWidget->setCurrentPage(0); 727 tabWidget->setCurrentPage(0);
714 writeCurrentM3u(); 728 writeCurrentM3u();
715 729
716} 730}
717 731
718void PlayListWidget::removeSelected() { 732void PlayListWidget::removeSelected() {
719 d->selectedFiles->removeSelected( ); 733 d->selectedFiles->removeSelected( );
720} 734}
721 735
722void PlayListWidget::playIt( QListViewItem *) { 736void PlayListWidget::playIt( QListViewItem *) {
723// d->setDocumentUsed = FALSE; 737// d->setDocumentUsed = FALSE;
724// mediaPlayerState->curPosition =0; 738// mediaPlayerState->curPosition =0;
725 qDebug("playIt"); 739 qDebug("playIt");
726 mediaPlayerState->setPlaying(FALSE); 740 mediaPlayerState->setPlaying(FALSE);
727 mediaPlayerState->setPlaying(TRUE); 741 mediaPlayerState->setPlaying(TRUE);
728 d->selectedFiles->unSelect(); 742 d->selectedFiles->unSelect();
729} 743}
730 744
731void PlayListWidget::addToSelection( QListViewItem *it) { 745void PlayListWidget::addToSelection( QListViewItem *it) {
732 d->setDocumentUsed = FALSE; 746 d->setDocumentUsed = FALSE;
733 747
734 if(it) { 748 if(it) {
735 switch ( tabWidget->currentPageIndex()) { 749 switch ( tabWidget->currentPageIndex()) {
736 case 0: //playlist 750 case 0: //playlist
737 return; 751 return;
738 break; 752 break;
739 }; 753 };
740 // case 1: { 754 // case 1: {
741 DocLnk lnk; 755 DocLnk lnk;
742 QString filename; 756 QString filename;
743 757
744 filename=it->text(3); 758 filename=it->text(3);
745 lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name 759 lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name
746 lnk.setFile( filename ); //sets file name 760 lnk.setFile( filename ); //sets file name
747 d->selectedFiles->addToSelection( lnk); 761 d->selectedFiles->addToSelection( lnk);
748 762
749 writeCurrentM3u(); 763 writeCurrentM3u();
750 tabWidget->setCurrentPage(0); 764 tabWidget->setCurrentPage(0);
751 765
752 } 766 }
753} 767}
754 768
755void PlayListWidget::tabChanged(QWidget *) { 769void PlayListWidget::tabChanged(QWidget *) {
756 770
757 switch ( tabWidget->currentPageIndex()) { 771 switch ( tabWidget->currentPageIndex()) {
758 case 0: 772 case 0:
759 { 773 {
760 if( !tbDeletePlaylist->isHidden()) 774 if( !tbDeletePlaylist->isHidden())
761 tbDeletePlaylist->hide(); 775 tbDeletePlaylist->hide();
762 d->tbRemoveFromList->setEnabled(TRUE); 776 d->tbRemoveFromList->setEnabled(TRUE);
763 d->tbAddToList->setEnabled(FALSE); 777 d->tbAddToList->setEnabled(FALSE);
764 } 778 }
765 break; 779 break;
766 case 1: 780 case 1:
767 { 781 {
768 audioView->clear(); 782 audioView->clear();
769 populateAudioView(); 783 populateAudioView();
770 784
771 if( !tbDeletePlaylist->isHidden()) 785 if( !tbDeletePlaylist->isHidden())
772 tbDeletePlaylist->hide(); 786 tbDeletePlaylist->hide();
773 d->tbRemoveFromList->setEnabled(FALSE); 787 d->tbRemoveFromList->setEnabled(FALSE);
774 d->tbAddToList->setEnabled(TRUE); 788 d->tbAddToList->setEnabled(TRUE);
775 } 789 }
776 break; 790 break;
777 case 2: 791 case 2:
778 { 792 {
779 videoView->clear(); 793 videoView->clear();
780 populateVideoView(); 794 populateVideoView();
781 if( !tbDeletePlaylist->isHidden()) 795 if( !tbDeletePlaylist->isHidden())
782 tbDeletePlaylist->hide(); 796 tbDeletePlaylist->hide();
783 d->tbRemoveFromList->setEnabled(FALSE); 797 d->tbRemoveFromList->setEnabled(FALSE);
784 d->tbAddToList->setEnabled(TRUE); 798 d->tbAddToList->setEnabled(TRUE);
785 } 799 }
786 break; 800 break;
787 case 3: 801 case 3:
788 { 802 {
789 if( tbDeletePlaylist->isHidden()) 803 if( tbDeletePlaylist->isHidden())
790 tbDeletePlaylist->show(); 804 tbDeletePlaylist->show();
791 playLists->reread(); 805 playLists->reread();
792 } 806 }
793 break; 807 break;
794 }; 808 };
795} 809}
796 810
797void PlayListWidget::btnPlay(bool b) { 811void PlayListWidget::btnPlay(bool b) {
798 qDebug("<<<<<<<<<<<<<<<BtnPlay"); 812 qDebug("<<<<<<<<<<<<<<<BtnPlay");
799// mediaPlayerState->setPlaying(b); 813// mediaPlayerState->setPlaying(b);
800 switch ( tabWidget->currentPageIndex()) { 814 switch ( tabWidget->currentPageIndex()) {
801 case 0: 815 case 0:
802 { 816 {
803 qDebug("1"); 817 qDebug("1");
804// if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 818// if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1
805// if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { 819// if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) {
806// QMessageBox::message("Note","You are trying to play\na malformed url."); 820// QMessageBox::message("Note","You are trying to play\na malformed url.");
807// } else { 821// } else {
808 mediaPlayerState->setPlaying(b); 822 mediaPlayerState->setPlaying(b);
809 insanityBool=FALSE; 823 insanityBool=FALSE;
810 qDebug("insanity"); 824 qDebug("insanity");
811// } 825// }
812 } 826 }
813 break; 827 break;
814 case 1: 828 case 1:
815 { 829 {
816 qDebug("2"); 830 qDebug("2");
817// d->selectedFiles->unSelect(); 831// d->selectedFiles->unSelect();
818 addToSelection( audioView->currentItem() ); 832 addToSelection( audioView->currentItem() );
819 mediaPlayerState->setPlaying(true); 833 mediaPlayerState->setPlaying(true);
820 d->selectedFiles->removeSelected( ); 834 d->selectedFiles->removeSelected( );
821 d->selectedFiles->unSelect(); 835 d->selectedFiles->unSelect();
822 tabWidget->setCurrentPage(1); 836 tabWidget->setCurrentPage(1);
823 insanityBool=FALSE; 837 insanityBool=FALSE;
824 }// audioView->clearSelection(); 838 }// audioView->clearSelection();
825 break; 839 break;
826 case 2: 840 case 2:
827 { 841 {
828 qDebug("3"); 842 qDebug("3");
829 843
830 addToSelection( videoView->currentItem() ); 844 addToSelection( videoView->currentItem() );
831 mediaPlayerState->setPlaying(true); 845 mediaPlayerState->setPlaying(true);
832// qApp->processEvents(); 846// qApp->processEvents();
833 d->selectedFiles->removeSelected( ); 847 d->selectedFiles->removeSelected( );
834 d->selectedFiles->unSelect(); 848 d->selectedFiles->unSelect();
835 tabWidget->setCurrentPage(2); 849 tabWidget->setCurrentPage(2);
836 insanityBool=FALSE; 850 insanityBool=FALSE;
837 }// videoView->clearSelection(); 851 }// videoView->clearSelection();
838 break; 852 break;
839 }; 853 };
840 854
841} 855}
842 856
843void PlayListWidget::deletePlaylist() { 857void PlayListWidget::deletePlaylist() {
844 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 858 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
845 (tr("You really want to delete\nthis playlist?")), 859 (tr("You really want to delete\nthis playlist?")),
846 (tr("Yes")), (tr("No")), 0 )){ 860 (tr("Yes")), (tr("No")), 0 )){
847 case 0: // Yes clicked, 861 case 0: // Yes clicked,
848 QFile().remove(playLists->selectedDocument().file()); 862 QFile().remove(playLists->selectedDocument().file());
849 QFile().remove(playLists->selectedDocument().linkFile()); 863 QFile().remove(playLists->selectedDocument().linkFile());
850 playLists->reread(); 864 playLists->reread();
851 break; 865 break;
852 case 1: // Cancel 866 case 1: // Cancel
853 break; 867 break;
854 }; 868 };
855} 869}
856 870
857void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int ) 871void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int )
858{ 872{
859 switch (mouse) { 873 switch (mouse) {
860 case 1: 874 case 1:
861 break; 875 break;
862 case 2:{ 876 case 2:{
863 877
864 QPopupMenu m; 878 QPopupMenu m;
865 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 879 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
866 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 880 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
867 m.insertSeparator(); 881 m.insertSeparator();
868 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) 882 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() )
869 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 883 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
870 884
871 m.exec( QCursor::pos() ); 885 m.exec( QCursor::pos() );
872 } 886 }
873 break; 887 break;
874 }; 888 };
875} 889}
876 890
877void PlayListWidget::playSelected() 891void PlayListWidget::playSelected()
878{ 892{
879 qDebug("playSelected"); 893 qDebug("playSelected");
880 btnPlay( true); 894 btnPlay( true);
881// d->selectedFiles->unSelect(); 895// d->selectedFiles->unSelect();
882} 896}
883 897
884void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) 898void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int)
885{ 899{
886 switch (mouse) { 900 switch (mouse) {
887 case 1: 901 case 1:
888 902
889 break; 903 break;
890 case 2:{ 904 case 2:{
891 QPopupMenu m; 905 QPopupMenu m;
892 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 906 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
893 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 907 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
894// m.insertSeparator(); 908// m.insertSeparator();
895// m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 909// m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
896 m.exec( QCursor::pos() ); 910 m.exec( QCursor::pos() );
897 } 911 }
898 break; 912 break;
899 }; 913 };
900 914
901} 915}
902 916
903void PlayListWidget::listDelete() { 917void PlayListWidget::listDelete() {
904 Config cfg( "OpiePlayer" ); 918 Config cfg( "OpiePlayer" );
905 cfg.setGroup("PlayList"); 919 cfg.setGroup("PlayList");
906 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 920 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
907 QString file; 921 QString file;
908// int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 922// int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
909 switch ( tabWidget->currentPageIndex()) { 923 switch ( tabWidget->currentPageIndex()) {
910 case 0: 924 case 0:
911 break; 925 break;
912 case 1: 926 case 1:
913 { 927 {
914 file = audioView->currentItem()->text(0); 928 file = audioView->currentItem()->text(0);
915 QListIterator<DocLnk> Pdit( files.children() ); 929 QListIterator<DocLnk> Pdit( files.children() );
916 for ( ; Pdit.current(); ++Pdit ) { 930 for ( ; Pdit.current(); ++Pdit ) {
917 if( Pdit.current()->name() == file) { 931 if( Pdit.current()->name() == file) {
918 LnkProperties prop( Pdit.current() ); 932 LnkProperties prop( Pdit.current() );
919 prop.showMaximized(); 933 prop.showMaximized();
920 prop.exec(); 934 prop.exec();
921 } 935 }
922 } 936 }
923 populateAudioView(); 937 populateAudioView();
924 } 938 }
925 break; 939 break;
926 case 2: 940 case 2:
927 { 941 {
928// file = videoView->selectedItem()->text(0); 942// file = videoView->selectedItem()->text(0);
929// for ( int i = 0; i < noOfFiles; i++ ) { 943// for ( int i = 0; i < noOfFiles; i++ ) {
930// QString entryName; 944// QString entryName;
931// entryName.sprintf( "File%i", i + 1 ); 945// entryName.sprintf( "File%i", i + 1 );
932// QString linkFile = cfg.readEntry( entryName ); 946// QString linkFile = cfg.readEntry( entryName );
933// AppLnk lnk( AppLnk(linkFile)); 947// AppLnk lnk( AppLnk(linkFile));
934// if( lnk.name() == file ) { 948// if( lnk.name() == file ) {
935// LnkProperties prop( &lnk); 949// LnkProperties prop( &lnk);
936// // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); 950// // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
937// prop.showMaximized(); 951// prop.showMaximized();
938// prop.exec(); 952// prop.exec();
939// } 953// }
940// } 954// }
941 } 955 }
942 break; 956 break;
943 }; 957 };
944} 958}
945 959
946void PlayListWidget::scanForAudio() { 960void PlayListWidget::scanForAudio() {
947// qDebug("scan for audio"); 961// qDebug("scan for audio");
948 files.detachChildren(); 962 files.detachChildren();
949 QListIterator<DocLnk> sdit( files.children() ); 963 QListIterator<DocLnk> sdit( files.children() );
950 for ( ; sdit.current(); ++sdit ) { 964 for ( ; sdit.current(); ++sdit ) {
951 delete sdit.current(); 965 delete sdit.current();
952 } 966 }
953 Global::findDocuments( &files, audioMimes); 967 Global::findDocuments( &files, audioMimes);
954 audioScan = true; 968 audioScan = true;
955} 969}
956void PlayListWidget::scanForVideo() { 970void PlayListWidget::scanForVideo() {
957// qDebug("scan for video"); 971// qDebug("scan for video");
958 vFiles.detachChildren(); 972 vFiles.detachChildren();
959 QListIterator<DocLnk> sdit( vFiles.children() ); 973 QListIterator<DocLnk> sdit( vFiles.children() );
960 for ( ; sdit.current(); ++sdit ) { 974 for ( ; sdit.current(); ++sdit ) {
961 delete sdit.current(); 975 delete sdit.current();
962 } 976 }
963 Global::findDocuments(&vFiles, "video/*"); 977 Global::findDocuments(&vFiles, "video/*");
964 videoScan = true; 978 videoScan = true;
965} 979}
966 980
967void PlayListWidget::populateAudioView() { 981void PlayListWidget::populateAudioView() {
968 982
969 audioView->clear(); 983 audioView->clear();
970 StorageInfo storageInfo; 984 StorageInfo storageInfo;
971 const QList<FileSystem> &fs = storageInfo.fileSystems(); 985 const QList<FileSystem> &fs = storageInfo.fileSystems();
972 if(!audioScan) scanForAudio(); 986 if(!audioScan) scanForAudio();
973 987
974 QListIterator<DocLnk> dit( files.children() ); 988 QListIterator<DocLnk> dit( files.children() );
975 QListIterator<FileSystem> it ( fs ); 989 QListIterator<FileSystem> it ( fs );
976 990
977 QString storage; 991 QString storage;
978 for ( ; dit.current(); ++dit ) { 992 for ( ; dit.current(); ++dit ) {
979 for( ; it.current(); ++it ){ 993 for( ; it.current(); ++it ){
980 const QString name = (*it)->name(); 994 const QString name = (*it)->name();
981 const QString path = (*it)->path(); 995 const QString path = (*it)->path();
982 if(dit.current()->file().find(path) != -1 ) storage=name; 996 if(dit.current()->file().find(path) != -1 ) storage=name;
983 } 997 }
984 998
985 QListViewItem * newItem; 999 QListViewItem * newItem;
986 if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { 1000 if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) {
987 long size; 1001 long size;
988 if( dit.current()->file().left(4) == "http" ) 1002 if( dit.current()->file().left(4) == "http" )
989 size=0; 1003 size=0;
990 else 1004 else
991 size = QFile( dit.current()->file() ).size(); 1005 size = QFile( dit.current()->file() ).size();
992// qDebug(dit.current()->name()); 1006// qDebug(dit.current()->name());
993 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), 1007 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
994 QString::number(size ), storage, dit.current()->file()); 1008 QString::number(size ), storage, dit.current()->file());
995 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); 1009 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" ));
996 } 1010 }
997 } 1011 }
998 1012
999} 1013}
1000 1014
1001void PlayListWidget::populateVideoView() { 1015void PlayListWidget::populateVideoView() {
1002 videoView->clear(); 1016 videoView->clear();
1003 StorageInfo storageInfo; 1017 StorageInfo storageInfo;
1004 const QList<FileSystem> &fs = storageInfo.fileSystems(); 1018 const QList<FileSystem> &fs = storageInfo.fileSystems();
1005 1019
1006 if(!videoScan ) scanForVideo(); 1020 if(!videoScan ) scanForVideo();
1007 1021
1008 QListIterator<DocLnk> Vdit( vFiles.children() ); 1022 QListIterator<DocLnk> Vdit( vFiles.children() );
1009 QListIterator<FileSystem> it ( fs ); 1023 QListIterator<FileSystem> it ( fs );
1010 videoView->clear(); 1024 videoView->clear();
1011 QString storage; 1025 QString storage;
1012 for ( ; Vdit.current(); ++Vdit ) { 1026 for ( ; Vdit.current(); ++Vdit ) {
1013 for( ; it.current(); ++it ){ 1027 for( ; it.current(); ++it ){
1014 const QString name = (*it)->name(); 1028 const QString name = (*it)->name();
1015 const QString path = (*it)->path(); 1029 const QString path = (*it)->path();
1016 if( Vdit.current()->file().find(path) != -1 ) storage=name; 1030 if( Vdit.current()->file().find(path) != -1 ) storage=name;
1017 } 1031 }
1018 1032
1019 QListViewItem * newItem; 1033 QListViewItem * newItem;
1020 if ( QFile( Vdit.current()->file()).exists() ) { 1034 if ( QFile( Vdit.current()->file()).exists() ) {
1021 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 1035 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
1022 QString::number( QFile( Vdit.current()->file() ).size() ), 1036 QString::number( QFile( Vdit.current()->file() ).size() ),
1023 storage, Vdit.current()->file()); 1037 storage, Vdit.current()->file());
1024 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); 1038 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" ));
1025 } 1039 }
1026 } 1040 }
1027} 1041}
1028 1042
1029void PlayListWidget::openFile() { 1043void PlayListWidget::openFile() {
1030 qDebug("<<<<<<<<<OPEN File"); 1044 qDebug("<<<<<<<<<OPEN File");
1031 QString filename, name; 1045 QString filename, name;
1032 InputDialog *fileDlg; 1046 InputDialog *fileDlg;
1033 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 1047 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
1034 fileDlg->exec(); 1048 fileDlg->exec();
1035 if( fileDlg->result() == 1 ) { 1049 if( fileDlg->result() == 1 ) {
1036 filename = fileDlg->text(); 1050 filename = fileDlg->text();
1037 qDebug( "Selected filename is " + filename ); 1051 qDebug( "Selected filename is " + filename );
1038// Om3u *m3uList; 1052// Om3u *m3uList;
1039 DocLnk lnk; 1053 DocLnk lnk;
1040 Config cfg( "OpiePlayer" ); 1054 Config cfg( "OpiePlayer" );
1041 cfg.setGroup("PlayList"); 1055 cfg.setGroup("PlayList");
1042 1056
1043 if(filename.left(4) == "http") { 1057 if(filename.left(4) == "http") {
1044 QString m3uFile, m3uFilePath; 1058 QString m3uFile, m3uFilePath;
1045 if(filename.find(":",8,TRUE) != -1) { //found a port 1059 if(filename.find(":",8,TRUE) != -1) { //found a port
1046 m3uFile = filename.left( filename.find( ":",8,TRUE)); 1060 m3uFile = filename.left( filename.find( ":",8,TRUE));
1047 m3uFile = m3uFile.right( 7); 1061 m3uFile = m3uFile.right( 7);
1048 } else if(filename.left(4) == "http"){ 1062 } else if(filename.left(4) == "http"){
1049 m3uFile=filename; 1063 m3uFile=filename;
1050 m3uFile = m3uFile.right( m3uFile.length() - 7); 1064 m3uFile = m3uFile.right( m3uFile.length() - 7);
1051 } else{ 1065 } else{
1052 m3uFile=filename; 1066 m3uFile=filename;
1053 } 1067 }
1054 1068
1055// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); 1069// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile);
1056 lnk.setName( filename ); //sets name 1070 lnk.setName( filename ); //sets name
1057 lnk.setFile( filename ); //sets file name 1071 lnk.setFile( filename ); //sets file name
1058 lnk.setIcon("opieplayer2/musicfile"); 1072 lnk.setIcon("opieplayer2/musicfile");
1059 d->selectedFiles->addToSelection( lnk ); 1073 d->selectedFiles->addToSelection( lnk );
1060 writeCurrentM3u(); 1074 writeCurrentM3u();
1061 } 1075 }
1062 else if( filename.right( 3) == "m3u" ) { 1076 else if( filename.right( 3) == "m3u" ) {
1063 readm3u( filename ); 1077 readm3u( filename );
1064 1078
1065 } else if( filename.right(3) == "pls" ) { 1079 } else if( filename.right(3) == "pls" ) {
1066 readPls( filename ); 1080 readPls( filename );
1067 } else { 1081 } else {
1068 lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name 1082 lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name
1069 lnk.setFile( filename ); //sets file name 1083 lnk.setFile( filename ); //sets file name
1070 d->selectedFiles->addToSelection( lnk); 1084 d->selectedFiles->addToSelection( lnk);
1071 writeCurrentM3u(); 1085 writeCurrentM3u();
1072 } 1086 }
1073 } 1087 }
1074 1088
1075 if( fileDlg ) { 1089 if( fileDlg ) {
1076 delete fileDlg; 1090 delete fileDlg;
1077 } 1091 }
1078} 1092}
1079 1093
1080 1094
1081/* 1095/*
1082reads m3u and shows files/urls to playlist widget */ 1096reads m3u and shows files/urls to playlist widget */
1083void PlayListWidget::readm3u( const QString &filename ) { 1097void PlayListWidget::readm3u( const QString &filename ) {
1084 qDebug( "read m3u filename " + filename ); 1098 qDebug( "read m3u filename " + filename );
1085 1099
1086 Om3u *m3uList; 1100 Om3u *m3uList;
1087 QString s, name; 1101 QString s, name;
1088 m3uList = new Om3u( filename, IO_ReadOnly ); 1102 m3uList = new Om3u( filename, IO_ReadOnly );
1089 m3uList->readM3u(); 1103 m3uList->readM3u();
1090 DocLnk lnk; 1104 DocLnk lnk;
1091 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 1105 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
1092 s = *it; 1106 s = *it;
1093// qDebug("reading "+ s); 1107// qDebug("reading "+ s);
1094 if(s.left(4)=="http") { 1108 if(s.left(4)=="http") {
1095 lnk.setName( s ); //sets file name 1109 lnk.setName( s ); //sets file name
1096 lnk.setIcon("opieplayer2/musicfile"); 1110 lnk.setIcon("opieplayer2/musicfile");
1097 if(s.right(4) != '.' || s.right(5) != '.') 1111 if(s.right(4) != '.' || s.right(5) != '.')
1098 lnk.setFile( s+"/"); //if url with no extension 1112 lnk.setFile( s+"/"); //if url with no extension
1099 else 1113 else
1100 lnk.setFile( s ); //sets file name 1114 lnk.setFile( s ); //sets file name
1101 1115
1102 } else { 1116 } else {
1103 // if( QFileInfo( s ).exists() ) { 1117 // if( QFileInfo( s ).exists() ) {
1104 lnk.setName( fullBaseName ( QFileInfo(s))); 1118 lnk.setName( fullBaseName ( QFileInfo(s)));
1105 // if(s.right(4) == '.') {//if regular file 1119 // if(s.right(4) == '.') {//if regular file
1106 if(s.left(1) != "/") { 1120 if(s.left(1) != "/") {
1107 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); 1121 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s);
1108 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); 1122 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
1109 lnk.setIcon("SoundPlayer"); 1123 lnk.setIcon("SoundPlayer");
1110 } else { 1124 } else {
1111 // qDebug("set link2 "+s); 1125 // qDebug("set link2 "+s);
1112 lnk.setFile( s); 1126 lnk.setFile( s);
1113 lnk.setIcon("SoundPlayer"); 1127 lnk.setIcon("SoundPlayer");
1114 } 1128 }
1115 } 1129 }
1116 d->selectedFiles->addToSelection( lnk ); 1130 d->selectedFiles->addToSelection( lnk );
1117 } 1131 }
1118 Config config( "OpiePlayer" ); 1132 Config config( "OpiePlayer" );
1119 config.setGroup( "PlayList" ); 1133 config.setGroup( "PlayList" );
1120 1134
1121 config.writeEntry("CurrentPlaylist",filename); 1135 config.writeEntry("CurrentPlaylist",filename);
1122 config.write(); 1136 config.write();
1123 currentPlayList=filename; 1137 currentPlayList=filename;
1124 1138
1125// m3uList->write(); 1139// m3uList->write();
1126 m3uList->close(); 1140 m3uList->close();
1127 if(m3uList) delete m3uList; 1141 if(m3uList) delete m3uList;
1128 1142
1129 d->selectedFiles->setSelectedItem( s); 1143 d->selectedFiles->setSelectedItem( s);
1130 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename))); 1144 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename)));
1131 1145
1132} 1146}
1133 1147
1134/* 1148/*
1135reads pls and adds files/urls to playlist */ 1149reads pls and adds files/urls to playlist */
1136void PlayListWidget::readPls( const QString &filename ) { 1150void PlayListWidget::readPls( const QString &filename ) {
1137 1151
1138 qDebug( "pls filename is " + filename ); 1152 qDebug( "pls filename is " + filename );
1139 Om3u *m3uList; 1153 Om3u *m3uList;
1140 QString s, name; 1154 QString s, name;
1141 m3uList = new Om3u( filename, IO_ReadOnly ); 1155 m3uList = new Om3u( filename, IO_ReadOnly );
1142 m3uList->readPls(); 1156 m3uList->readPls();
1143 1157
1144 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 1158 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
1145 s = *it; 1159 s = *it;
1146 // s.replace( QRegExp( "%20" )," " ); 1160 // s.replace( QRegExp( "%20" )," " );
1147 DocLnk lnk( s ); 1161 DocLnk lnk( s );
1148 QFileInfo f( s ); 1162 QFileInfo f( s );
1149 QString name = fullBaseName ( f); 1163 QString name = fullBaseName ( f);
1150 1164
1151 if( name.left( 4 ) == "http" ) { 1165 if( name.left( 4 ) == "http" ) {
1152 name = s.right( s.length() - 7); 1166 name = s.right( s.length() - 7);
1153 } else { 1167 } else {
1154 name = s; 1168 name = s;
1155 } 1169 }
1156 1170
1157 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 1171 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
1158 1172
1159 lnk.setName( name ); 1173 lnk.setName( name );
1160 if( s.at( s.length() - 4) == '.') {// if this is probably a file 1174 if( s.at( s.length() - 4) == '.') {// if this is probably a file
1161 lnk.setFile( s ); 1175 lnk.setFile( s );
1162 } else { //if its a url 1176 } else { //if its a url
1163 if( name.right( 1 ).find( '/' ) == -1) { 1177 if( name.right( 1 ).find( '/' ) == -1) {
1164 s += "/"; 1178 s += "/";
1165 } 1179 }
1166 lnk.setFile( s ); 1180 lnk.setFile( s );
1167 } 1181 }
1168 lnk.setType( "audio/x-mpegurl" ); 1182 lnk.setType( "audio/x-mpegurl" );
1169 1183
1170 lnk.writeLink(); 1184 lnk.writeLink();
1171 d->selectedFiles->addToSelection( lnk ); 1185 d->selectedFiles->addToSelection( lnk );
1172 } 1186 }
1173 1187
1174 m3uList->close(); 1188 m3uList->close();
1175 if(m3uList) delete m3uList; 1189 if(m3uList) delete m3uList;
1176} 1190}
1177 1191
1178/* 1192/*
1179 writes current playlist to current m3u file */ 1193 writes current playlist to current m3u file */
1180void PlayListWidget::writeCurrentM3u() { 1194void PlayListWidget::writeCurrentM3u() {
1181 qDebug("writing to current m3u"); 1195 qDebug("writing to current m3u");
1182 Config cfg( "OpiePlayer" ); 1196 Config cfg( "OpiePlayer" );
1183 cfg.setGroup("PlayList"); 1197 cfg.setGroup("PlayList");
1184 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 1198 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
1185 Om3u *m3uList; 1199 Om3u *m3uList;
1186 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); 1200 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
1187 1201
1188 if( d->selectedFiles->first()) { 1202 if( d->selectedFiles->first()) {
1189 do { 1203 do {
1190 qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); 1204 qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file());
1191 m3uList->add( d->selectedFiles->current()->file() ); 1205 m3uList->add( d->selectedFiles->current()->file() );
1192 } 1206 }
1193 while ( d->selectedFiles->next() ); 1207 while ( d->selectedFiles->next() );
1194 qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); 1208 qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
1195 m3uList->write(); 1209 m3uList->write();
1196 m3uList->close(); 1210 m3uList->close();
1197 1211
1198 if(m3uList) delete m3uList; 1212 if(m3uList) delete m3uList;
1199 } 1213 }
1200} 1214}
1201 1215
1202 /* 1216 /*
1203 writes current playlist to m3u file */ 1217 writes current playlist to m3u file */
1204void PlayListWidget::writem3u() { 1218void PlayListWidget::writem3u() {
1205 InputDialog *fileDlg; 1219 InputDialog *fileDlg;
1206 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 1220 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
1207 fileDlg->exec(); 1221 fileDlg->exec();
1208 QString name, filename, list; 1222 QString name, filename, list;
1209 Om3u *m3uList; 1223 Om3u *m3uList;
1210 1224
1211 if( fileDlg->result() == 1 ) { 1225 if( fileDlg->result() == 1 ) {
1212 name = fileDlg->text(); 1226 name = fileDlg->text();
1213// qDebug( filename ); 1227// qDebug( filename );
1214 if( name.find("/",0,true) != -1) {// assume they specify a file path 1228 if( name.find("/",0,true) != -1) {// assume they specify a file path
1215 filename = name; 1229 filename = name;
1216 name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); 1230 name = name.right(name.length()- name.findRev("/",-1,true) - 1 );
1217 } 1231 }
1218 else //otherwise dump it somewhere noticable 1232 else //otherwise dump it somewhere noticable
1219 filename = QPEApplication::documentDir() + "/" + name; 1233 filename = QPEApplication::documentDir() + "/" + name;
1220 1234
1221 if( filename.right( 3 ) != "m3u" ) //needs filename extension 1235 if( filename.right( 3 ) != "m3u" ) //needs filename extension
1222 filename += ".m3u"; 1236 filename += ".m3u";
1223 1237
1224 if( d->selectedFiles->first()) { 1238 if( d->selectedFiles->first()) {