summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-04-10 20:16:48 (UTC)
committer llornkcor <llornkcor>2002-04-10 20:16:48 (UTC)
commit5d7caf051fb1b46fc2ed7d2f71b03fdf3b42b3ac (patch) (unidiff)
treeaf7abddaeb16b6167d975968f62a521d8e6231dc
parent5cf7797af9fb965916f5017f84898516157c4620 (diff)
downloadopie-5d7caf051fb1b46fc2ed7d2f71b03fdf3b42b3ac.zip
opie-5d7caf051fb1b46fc2ed7d2f71b03fdf3b42b3ac.tar.gz
opie-5d7caf051fb1b46fc2ed7d2f71b03fdf3b42b3ac.tar.bz2
added ability to remember position in the playlist you were last at startup and when opening playlists
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/playlistselection.cpp12
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp12
2 files changed, 19 insertions, 5 deletions
diff --git a/core/multimedia/opieplayer/playlistselection.cpp b/core/multimedia/opieplayer/playlistselection.cpp
index 8f3711a..3c47256 100644
--- a/core/multimedia/opieplayer/playlistselection.cpp
+++ b/core/multimedia/opieplayer/playlistselection.cpp
@@ -189,15 +189,27 @@ void PlayListSelection::unSelect()
189} 189}
190 190
191void PlayListSelection::writeCurrent( Config& cfg ) { 191void PlayListSelection::writeCurrent( Config& cfg ) {
192 cfg.setGroup("PlayList"); 192 cfg.setGroup("PlayList");
193 QListViewItem *item = selectedItem(); 193 QListViewItem *item = selectedItem();
194 if ( item ) 194 if ( item )
195 cfg.writeEntry("current", item->text(0) ); 195 cfg.writeEntry("current", item->text(0) );
196 qDebug(item->text(0)); 196 qDebug(item->text(0));
197 197
198} 198}
199 199
200void PlayListSelection::setSelectedItem(const QString &strk ) { 200void PlayListSelection::setSelectedItem(const QString &strk ) {
201
202 unSelect();
203 QListViewItemIterator it( this );
204 for ( ; it.current(); ++it ) {
205// qDebug( it.current()->text(0));
206 if( strk == it.current()->text(0)) {
207// qDebug( "We have a match "+strk);
208 setSelected( it.current(), TRUE);
209 ensureItemVisible( it.current() );
210 return;
211 }
212 }
201// setSelected( item, TRUE ); 213// setSelected( item, TRUE );
202// ensureItemVisible( selectedItem() ); 214// ensureItemVisible( selectedItem() );
203} 215}
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 63df715..0764c01 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -310,57 +310,59 @@ PlayListWidget::~PlayListWidget() {
310 310
311 311
312void PlayListWidget::initializeStates() { 312void PlayListWidget::initializeStates() {
313 313
314 d->tbPlay->setOn( mediaPlayerState->playing() ); 314 d->tbPlay->setOn( mediaPlayerState->playing() );
315 d->tbLoop->setOn( mediaPlayerState->looping() ); 315 d->tbLoop->setOn( mediaPlayerState->looping() );
316 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 316 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
317// d->tbFull->setOn( mediaPlayerState->fullscreen() ); 317// d->tbFull->setOn( mediaPlayerState->fullscreen() );
318// d->tbScale->setOn( mediaPlayerState->scaled() ); 318// d->tbScale->setOn( mediaPlayerState->scaled() );
319// d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); 319// d->tbScale->setEnabled( mediaPlayerState->fullscreen() );
320// setPlaylist( mediaPlayerState->playlist() ); 320// setPlaylist( mediaPlayerState->playlist() );
321 setPlaylist( true); 321 setPlaylist( true);
322 d->selectedFiles->first(); 322// d->selectedFiles->first();
323
323} 324}
324 325
325 326
326void PlayListWidget::readConfig( Config& cfg ) { 327void PlayListWidget::readConfig( Config& cfg ) {
327 cfg.setGroup("PlayList"); 328 cfg.setGroup("PlayList");
328 QString currentString = cfg.readEntry("current", "" ); 329 QString currentString = cfg.readEntry("current", "" );
329 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 330 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
330 for ( int i = 0; i < noOfFiles; i++ ) { 331 for ( int i = 0; i < noOfFiles; i++ ) {
331 QString entryName; 332 QString entryName;
332 entryName.sprintf( "File%i", i + 1 ); 333 entryName.sprintf( "File%i", i + 1 );
333 QString linkFile = cfg.readEntry( entryName ); 334 QString linkFile = cfg.readEntry( entryName );
334 DocLnk lnk( linkFile ); 335 DocLnk lnk( linkFile );
335 if ( lnk.isValid() ) { 336 if ( lnk.isValid() ) {
336 d->selectedFiles->addToSelection( lnk ); 337 d->selectedFiles->addToSelection( lnk );
337 } 338 }
338 } 339 }
340 d->selectedFiles->setSelectedItem( currentString);
339// d->selectedFiles->setSelectedItem( (const QString &)currentString); 341// d->selectedFiles->setSelectedItem( (const QString &)currentString);
340} 342}
341 343
342 344
343void PlayListWidget::writeConfig( Config& cfg ) const { 345void PlayListWidget::writeConfig( Config& cfg ) const {
344 346
345 d->selectedFiles->writeCurrent( cfg); 347 d->selectedFiles->writeCurrent( cfg);
346 cfg.setGroup("PlayList"); 348 cfg.setGroup("PlayList");
347 int noOfFiles = 0; 349 int noOfFiles = 0;
348 d->selectedFiles->first(); 350 d->selectedFiles->first();
349 do { 351 do {
350 const DocLnk *lnk = d->selectedFiles->current(); 352 const DocLnk *lnk = d->selectedFiles->current();
351 if ( lnk ) { 353 if ( lnk ) {
352 QString entryName; 354 QString entryName;
353 entryName.sprintf( "File%i", noOfFiles + 1 ); 355 entryName.sprintf( "File%i", noOfFiles + 1 );
354 qDebug(entryName); 356// qDebug(entryName);
355 cfg.writeEntry( entryName, lnk->linkFile() ); 357 cfg.writeEntry( entryName, lnk->linkFile() );
356 // if this link does exist, add it so we have the file 358 // if this link does exist, add it so we have the file
357 // next time... 359 // next time...
358 if ( !QFile::exists( lnk->linkFile() ) ) { 360 if ( !QFile::exists( lnk->linkFile() ) ) {
359 // the way writing lnks doesn't really check for out 361 // the way writing lnks doesn't really check for out
360 // of disk space, but check it anyway. 362 // of disk space, but check it anyway.
361 if ( !lnk->writeLink() ) { 363 if ( !lnk->writeLink() ) {
362 QMessageBox::critical( 0, tr("Out of space"), 364 QMessageBox::critical( 0, tr("Out of space"),
363 tr( "There was a problem saving " 365 tr( "There was a problem saving "
364 "the playlist.\n" 366 "the playlist.\n"
365 "Your playlist " 367 "Your playlist "
366 "may be missing some entries\n" 368 "may be missing some entries\n"
@@ -464,25 +466,25 @@ const DocLnk *PlayListWidget::current() { // this is fugly
464// QListIterator<DocLnk> dit( files.children() ); 466// QListIterator<DocLnk> dit( files.children() );
465// for ( ; dit.current(); ++dit ) { 467// for ( ; dit.current(); ++dit ) {
466// if(dit.current()->linkFile() == setDocFileRef) { 468// if(dit.current()->linkFile() == setDocFileRef) {
467// qDebug(setDocFileRef); 469// qDebug(setDocFileRef);
468// return dit; 470// return dit;
469// } 471// }
470// } 472// }
471// } else 473// } else
472// qDebug("current"); 474// qDebug("current");
473// switch (tabWidget->currentPageIndex()) { 475// switch (tabWidget->currentPageIndex()) {
474// case 0: //playlist 476// case 0: //playlist
475// { 477// {
476 qDebug("playlist"); 478// qDebug("playlist");
477 if ( mediaPlayerState->playlist() ) { 479 if ( mediaPlayerState->playlist() ) {
478 return d->selectedFiles->current(); 480 return d->selectedFiles->current();
479 } 481 }
480 else if ( d->setDocumentUsed && d->current ) { 482 else if ( d->setDocumentUsed && d->current ) {
481 return d->current; 483 return d->current;
482 } else { 484 } else {
483 return d->files->selected(); 485 return d->files->selected();
484 } 486 }
485// } 487// }
486// break; 488// break;
487// case 1://audio 489// case 1://audio
488// { 490// {
@@ -600,25 +602,25 @@ void PlayListWidget::saveList() {
600// qDebug("same name so delete lnk"); 602// qDebug("same name so delete lnk");
601// QFile().remove(playLists->selected()->file()); 603// QFile().remove(playLists->selected()->file());
602// QFile().remove(playLists->selected()->linkFile()); 604// QFile().remove(playLists->selected()->linkFile());
603// playLists->reread(); 605// playLists->reread();
604// } 606// }
605// qDebug("new doclnk"); 607// qDebug("new doclnk");
606 DocLnk lnk; 608 DocLnk lnk;
607// lnk.setComment( ""); 609// lnk.setComment( "");
608 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property 610 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property
609 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D 611 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D
610 lnk.setIcon("mpegplayer/playlist2"); 612 lnk.setIcon("mpegplayer/playlist2");
611 lnk.setName( filename); //sets file name 613 lnk.setName( filename); //sets file name
612 qDebug(filename); 614// qDebug(filename);
613 if(!lnk.writeLink()) 615 if(!lnk.writeLink())
614 qDebug("Writing doclink did not work"); 616 qDebug("Writing doclink did not work");
615 } 617 }
616 Config config( "MediaPlayer" ); 618 Config config( "MediaPlayer" );
617 config.writeEntry("CurrentPlaylist",filename); 619 config.writeEntry("CurrentPlaylist",filename);
618 setCaption(tr("OpiePlayer: ")+filename); 620 setCaption(tr("OpiePlayer: ")+filename);
619 d->selectedFiles->first(); 621 d->selectedFiles->first();
620 if(fileDlg) 622 if(fileDlg)
621 delete fileDlg; 623 delete fileDlg;
622} 624}
623 625
624void PlayListWidget::loadList( const DocLnk & lnk) { 626void PlayListWidget::loadList( const DocLnk & lnk) {
@@ -877,25 +879,25 @@ void PlayListWidget::listDelete() {
877 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 879 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
878 switch ( tabWidget->currentPageIndex()) { 880 switch ( tabWidget->currentPageIndex()) {
879 case 0: 881 case 0:
880 break; 882 break;
881 case 1: 883 case 1:
882 { 884 {
883 file = audioView->selectedItem()->text(0); 885 file = audioView->selectedItem()->text(0);
884// Global::findDocuments(&files, "audio/*"); 886// Global::findDocuments(&files, "audio/*");
885// AppLnkSet appFiles; 887// AppLnkSet appFiles;
886 QListIterator<DocLnk> dit( files.children() ); 888 QListIterator<DocLnk> dit( files.children() );
887 for ( ; dit.current(); ++dit ) { 889 for ( ; dit.current(); ++dit ) {
888 if( dit.current()->name() == file) { 890 if( dit.current()->name() == file) {
889 qDebug(file); 891// qDebug(file);
890 LnkProperties prop( dit.current() ); 892 LnkProperties prop( dit.current() );
891// connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); 893// connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
892 prop.showMaximized(); 894 prop.showMaximized();
893 prop.exec(); 895 prop.exec();
894 } 896 }
895 } 897 }
896 populateAudioView(); 898 populateAudioView();
897 } 899 }
898 break; 900 break;
899 case 2: 901 case 2:
900 { 902 {
901// file = videoView->selectedItem()->text(0); 903// file = videoView->selectedItem()->text(0);