author | llornkcor <llornkcor> | 2002-04-10 20:16:48 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-10 20:16:48 (UTC) |
commit | 5d7caf051fb1b46fc2ed7d2f71b03fdf3b42b3ac (patch) (side-by-side diff) | |
tree | af7abddaeb16b6167d975968f62a521d8e6231dc | |
parent | 5cf7797af9fb965916f5017f84898516157c4620 (diff) | |
download | opie-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
-rw-r--r-- | core/multimedia/opieplayer/playlistselection.cpp | 12 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 12 |
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() } void PlayListSelection::writeCurrent( Config& cfg ) { cfg.setGroup("PlayList"); QListViewItem *item = selectedItem(); if ( item ) cfg.writeEntry("current", item->text(0) ); qDebug(item->text(0)); } void PlayListSelection::setSelectedItem(const QString &strk ) { + + unSelect(); + QListViewItemIterator it( this ); + for ( ; it.current(); ++it ) { +// qDebug( it.current()->text(0)); + if( strk == it.current()->text(0)) { +// qDebug( "We have a match "+strk); + setSelected( it.current(), TRUE); + ensureItemVisible( it.current() ); + return; + } + } // setSelected( item, TRUE ); // ensureItemVisible( selectedItem() ); } 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() { void PlayListWidget::initializeStates() { d->tbPlay->setOn( mediaPlayerState->playing() ); d->tbLoop->setOn( mediaPlayerState->looping() ); d->tbShuffle->setOn( mediaPlayerState->shuffled() ); // d->tbFull->setOn( mediaPlayerState->fullscreen() ); // d->tbScale->setOn( mediaPlayerState->scaled() ); // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); // setPlaylist( mediaPlayerState->playlist() ); setPlaylist( true); - d->selectedFiles->first(); +// d->selectedFiles->first(); + } void PlayListWidget::readConfig( Config& cfg ) { cfg.setGroup("PlayList"); QString currentString = cfg.readEntry("current", "" ); int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); for ( int i = 0; i < noOfFiles; i++ ) { QString entryName; entryName.sprintf( "File%i", i + 1 ); QString linkFile = cfg.readEntry( entryName ); DocLnk lnk( linkFile ); if ( lnk.isValid() ) { d->selectedFiles->addToSelection( lnk ); } } + d->selectedFiles->setSelectedItem( currentString); // d->selectedFiles->setSelectedItem( (const QString &)currentString); } void PlayListWidget::writeConfig( Config& cfg ) const { d->selectedFiles->writeCurrent( cfg); cfg.setGroup("PlayList"); int noOfFiles = 0; d->selectedFiles->first(); do { const DocLnk *lnk = d->selectedFiles->current(); if ( lnk ) { QString entryName; entryName.sprintf( "File%i", noOfFiles + 1 ); - qDebug(entryName); +// qDebug(entryName); cfg.writeEntry( entryName, lnk->linkFile() ); // if this link does exist, add it so we have the file // next time... if ( !QFile::exists( lnk->linkFile() ) ) { // the way writing lnks doesn't really check for out // of disk space, but check it anyway. if ( !lnk->writeLink() ) { QMessageBox::critical( 0, tr("Out of space"), tr( "There was a problem saving " "the playlist.\n" "Your playlist " "may be missing some entries\n" @@ -464,25 +466,25 @@ const DocLnk *PlayListWidget::current() { // this is fugly // QListIterator<DocLnk> dit( files.children() ); // for ( ; dit.current(); ++dit ) { // if(dit.current()->linkFile() == setDocFileRef) { // qDebug(setDocFileRef); // return dit; // } // } // } else // qDebug("current"); // switch (tabWidget->currentPageIndex()) { // case 0: //playlist // { - qDebug("playlist"); +// qDebug("playlist"); if ( mediaPlayerState->playlist() ) { return d->selectedFiles->current(); } else if ( d->setDocumentUsed && d->current ) { return d->current; } else { return d->files->selected(); } // } // break; // case 1://audio // { @@ -600,25 +602,25 @@ void PlayListWidget::saveList() { // qDebug("same name so delete lnk"); // QFile().remove(playLists->selected()->file()); // QFile().remove(playLists->selected()->linkFile()); // playLists->reread(); // } // qDebug("new doclnk"); DocLnk lnk; // lnk.setComment( ""); lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D lnk.setIcon("mpegplayer/playlist2"); lnk.setName( filename); //sets file name - qDebug(filename); +// qDebug(filename); if(!lnk.writeLink()) qDebug("Writing doclink did not work"); } Config config( "MediaPlayer" ); config.writeEntry("CurrentPlaylist",filename); setCaption(tr("OpiePlayer: ")+filename); d->selectedFiles->first(); if(fileDlg) delete fileDlg; } void PlayListWidget::loadList( const DocLnk & lnk) { @@ -877,25 +879,25 @@ void PlayListWidget::listDelete() { int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); switch ( tabWidget->currentPageIndex()) { case 0: break; case 1: { file = audioView->selectedItem()->text(0); // Global::findDocuments(&files, "audio/*"); // AppLnkSet appFiles; QListIterator<DocLnk> dit( files.children() ); for ( ; dit.current(); ++dit ) { if( dit.current()->name() == file) { - qDebug(file); +// qDebug(file); LnkProperties prop( dit.current() ); // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); prop.showMaximized(); prop.exec(); } } populateAudioView(); } break; case 2: { // file = videoView->selectedItem()->text(0); |