summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-04-10 20:16:48 (UTC)
committer llornkcor <llornkcor>2002-04-10 20:16:48 (UTC)
commit5d7caf051fb1b46fc2ed7d2f71b03fdf3b42b3ac (patch) (side-by-side diff)
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) (show 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
@@ -153,51 +153,63 @@ bool PlayListSelection::next() {
setSelected( item->itemBelow(), TRUE );
else
return FALSE;
ensureItemVisible( selectedItem() );
return TRUE;
}
bool PlayListSelection::first() {
QListViewItem *item = firstChild();
if ( item )
setSelected( item, TRUE );
else
return FALSE;
ensureItemVisible( selectedItem() );
return TRUE;
}
bool PlayListSelection::last() {
QListViewItem *prevItem = NULL;
QListViewItem *item = firstChild();
while ( ( item = item->nextSibling() ) )
prevItem = item;
if ( prevItem )
setSelected( prevItem, TRUE );
else
return FALSE;
ensureItemVisible( selectedItem() );
return TRUE;
}
void PlayListSelection::unSelect()
{
QListViewItem *item = selectedItem();
setSelected( currentItem(), FALSE);
}
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
@@ -274,129 +274,131 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
// connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) );
connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
// connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) );
setCentralWidget( vbox5 );
Config cfg( "MediaPlayer" );
readConfig( cfg );
QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
// qDebug("currentList is "+currentPlaylist);
loadList(DocLnk( currentPlaylist));
setCaption(tr("OpiePlayer: ")+ currentPlaylist );
initializeStates();
}
PlayListWidget::~PlayListWidget() {
Config cfg( "MediaPlayer" );
writeConfig( cfg );
if ( d->current )
delete d->current;
delete d;
}
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"
"the next time you start it." )
);
}
}
noOfFiles++;
}
}
while ( d->selectedFiles->next() );
cfg.writeEntry("NumberOfFiles", noOfFiles );
}
void PlayListWidget::addToSelection( const DocLnk& lnk ) {
// qDebug("add");
d->setDocumentUsed = FALSE;
if ( mediaPlayerState->playlist() )
d->selectedFiles->addToSelection( lnk );
else
mediaPlayerState->setPlaying( TRUE );
}
void PlayListWidget::clearList() {
while ( first() )
d->selectedFiles->removeSelected();
}
void PlayListWidget::addAllToList() {
DocLnkSet filesAll;
Global::findDocuments(&filesAll, "video/*;audio/*");
QListIterator<DocLnk> Adit( filesAll.children() );
for ( ; Adit.current(); ++Adit )
d->selectedFiles->addToSelection( **Adit );
}
@@ -428,97 +430,97 @@ void PlayListWidget::setDocument(const QString& fileref) {
clearList();
addToSelection( DocLnk( fileref ) );
d->setDocumentUsed = TRUE;
mediaPlayerState->setPlaying( FALSE );
qApp->processEvents();
mediaPlayerState->setPlaying( TRUE );
qApp->processEvents();
setCaption(tr("OpiePlayer"));
} else { //is playlist
clearList();
loadList(DocLnk(fileref));
d->selectedFiles->first();
}
}
void PlayListWidget::setActiveWindow() {
// When we get raised we need to ensure that it switches views
char origView = mediaPlayerState->view();
mediaPlayerState->setView( 'l' ); // invalidate
mediaPlayerState->setView( origView ); // now switch back
}
void PlayListWidget::useSelectedDocument() {
d->setDocumentUsed = FALSE;
}
const DocLnk *PlayListWidget::current() { // this is fugly
// if( fromSetDocument) {
// qDebug("from setDoc");
// DocLnkSet files;
// Global::findDocuments(&files, "video/*;audio/*");
// 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
// {
// qDebug("audioView");
// Global::findDocuments(&files, "audio/*");
// QListIterator<DocLnk> dit( files.children() );
// for ( ; dit.current(); ++dit ) {
// if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) {
// qDebug("here");
// insanityBool=TRUE;
// return dit;
// }
// }
// }
// break;
// case 2: // video
// {
// qDebug("videoView");
// Global::findDocuments(&vFiles, "video/*");
// QListIterator<DocLnk> Vdit( vFiles.children() );
// for ( ; Vdit.current(); ++Vdit ) {
// if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) {
// insanityBool=TRUE;
// return Vdit;
// }
// }
// }
// break;
// };
// return 0;
}
bool PlayListWidget::prev() {
if ( mediaPlayerState->playlist() ) {
if ( mediaPlayerState->shuffled() ) {
const DocLnk *cur = current();
int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
for ( int i = 0; i < j; i++ ) {
if ( !d->selectedFiles->next() )
@@ -564,97 +566,97 @@ bool PlayListWidget::next() {
}
bool PlayListWidget::first() {
if ( mediaPlayerState->playlist() )
return d->selectedFiles->first();
else
return mediaPlayerState->looping();
}
bool PlayListWidget::last() {
if ( mediaPlayerState->playlist() )
return d->selectedFiles->last();
else
return mediaPlayerState->looping();
}
void PlayListWidget::saveList() {
QString filename;
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0);
fileDlg->exec();
if( fileDlg->result() == 1 ) {
if ( d->current )
delete d->current;
filename = fileDlg->LineEdit1->text();//+".playlist";
// qDebug("saving playlist "+filename+".playlist");
Config cfg( filename +".playlist");
writeConfig( cfg );
// qDebug("same name so delete lnk??");
// if( playLists->selected()->name() == filename) {
// 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) {
QString name= lnk.name();
// qDebug("currentList is "+name);
if( name.length()>1) {
setCaption("OpiePlayer: "+name);
// qDebug("load list "+ name+".playlist");
clearList();
Config cfg( name+".playlist");
readConfig(cfg);
tabWidget->setCurrentPage(0);
Config config( "MediaPlayer" );
config.writeEntry("CurrentPlaylist", name);
// d->selectedFiles->first();
}
}
void PlayListWidget::setPlaylist( bool shown ) {
if ( shown )
d->playListFrame->show();
else
d->playListFrame->hide();
}
void PlayListWidget::setView( char view ) {
if ( view == 'l' )
showMaximized();
else
hide();
}
void PlayListWidget::addSelected() {
Config cfg( "MediaPlayer" );
cfg.setGroup("PlayList");
@@ -841,97 +843,97 @@ void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint&
m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
m.insertSeparator();
m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
m.exec( QCursor::pos() );
}
break;
};
}
void PlayListWidget::playSelected()
{
btnPlay( TRUE);
}
void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i)
{
switch (mouse) {
case 1:
break;
case 2:{
QPopupMenu m;
m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
// m.insertSeparator();
m.exec( QCursor::pos() );
}
break;
};
}
void PlayListWidget::listDelete() {
Config cfg( "MediaPlayer" );
cfg.setGroup("PlayList");
QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
QString file;
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);
// for ( int i = 0; i < noOfFiles; i++ ) {
// QString entryName;
// entryName.sprintf( "File%i", i + 1 );
// QString linkFile = cfg.readEntry( entryName );
// AppLnk lnk( AppLnk(linkFile));
// if( lnk.name() == file ) {
// LnkProperties prop( &lnk);
// // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
// prop.showMaximized();
// prop.exec();
// }
// }
}
break;
};
}
void PlayListWidget::populateAudioView() {
// if(files)
// files.~DocLnkSet();
StorageInfo storageInfo;
const QList<FileSystem> &fs = storageInfo.fileSystems();
Global::findDocuments(&files, "audio/*");
QListIterator<DocLnk> dit( files.children() );
QListIterator<FileSystem> it ( fs );
audioView->clear();
QString storage;
for ( ; dit.current(); ++dit ) {
for( ; it.current(); ++it ){
const QString name = (*it)->name();
const QString path = (*it)->path();
if(dit.current()->file().find(path) != -1 ) storage=name;
}
QListViewItem * newItem;