summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-04-21 15:49:37 (UTC)
committer llornkcor <llornkcor>2002-04-21 15:49:37 (UTC)
commitd7ff40e1530a1aab578a3d3c3126c4367cf3e898 (patch) (side-by-side diff)
treec581ad533a4cbb7a0fbbcaa9f624ae8f9475adde
parenta588c90b0191e837b472dcaa76a5dedc289a5b10 (diff)
downloadopie-d7ff40e1530a1aab578a3d3c3126c4367cf3e898.zip
opie-d7ff40e1530a1aab578a3d3c3126c4367cf3e898.tar.gz
opie-d7ff40e1530a1aab578a3d3c3126c4367cf3e898.tar.bz2
added multiselect to playlist
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/libmad/libmadplugin.cpp14
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp78
2 files changed, 55 insertions, 37 deletions
diff --git a/core/multimedia/opieplayer/libmad/libmadplugin.cpp b/core/multimedia/opieplayer/libmad/libmadplugin.cpp
index 6793773..7de4282 100644
--- a/core/multimedia/opieplayer/libmad/libmadplugin.cpp
+++ b/core/multimedia/opieplayer/libmad/libmadplugin.cpp
@@ -505,70 +505,70 @@ bool LibMadPlugin::isOpen() {
debugMsg( "LibMadPlugin::isOpen" );
return ( d->input.fd != 0 );
}
int LibMadPlugin::audioStreams() {
debugMsg( "LibMadPlugin::audioStreams" );
return 1;
}
int LibMadPlugin::audioChannels( int ) {
debugMsg( "LibMadPlugin::audioChannels" );
/*
long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 );
qDebug( "LibMadPlugin::audioChannels: %i", d->frame.header.mode > 0 ? 2 : 1 );
return d->frame.header.mode > 0 ? 2 : 1;
*/
return 2;
}
int LibMadPlugin::audioFrequency( int ) {
debugMsg( "LibMadPlugin::audioFrequency" );
long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 );
qDebug( "LibMadPlugin::audioFrequency: %i", d->frame.header.samplerate );
return d->frame.header.samplerate;
}
int LibMadPlugin::audioSamples( int ) {
debugMsg( "LibMadPlugin::audioSamples" );
-/*
- long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 );
- mad_header_decode( (struct mad_header *)&d->frame.header, &d->stream );
- qDebug( "LibMadPlugin::audioSamples: %i*%i", d->frame.header.duration.seconds, d->frame.header.samplerate );
- return d->frame.header.duration.seconds * d->frame.header.samplerate;
-*/
+
+ // long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 );
+// mad_header_decode( (struct mad_header *)&d->frame.header, &d->stream );
+// qDebug( "LibMadPlugin::audioSamples: %i*%i", d->frame.header.duration.seconds, d->frame.header.samplerate );
+// return d->frame.header.duration.seconds * d->frame.header.samplerate;
+
return 10000000;
}
bool LibMadPlugin::audioSetSample( long, int ) {
debugMsg( "LibMadPlugin::audioSetSample" );
return FALSE;
}
long LibMadPlugin::audioGetSample( int ) {
debugMsg( "LibMadPlugin::audioGetSample" );
return 0;
}
/*
bool LibMadPlugin::audioReadSamples( short *, int, long, int ) {
debugMsg( "LibMadPlugin::audioReadSamples" );
return FALSE;
}
bool LibMadPlugin::audioReReadSamples( short *, int, long, int ) {
debugMsg( "LibMadPlugin::audioReReadSamples" );
return FALSE;
}
*/
bool LibMadPlugin::read() {
debugMsg( "LibMadPlugin::read" );
int len;
@@ -753,65 +753,65 @@ bool LibMadPlugin::audioReadSamples( short *output, int /*channels*/, long sampl
// else
return FALSE;
}
needInput = FALSE;
if ( decode( output, samples, samplesMade ) )
return TRUE;
else
needInput = TRUE;
}
while ( ( samplesMade < samples ) && ( !d->input.eof ) );
/*
static bool firstTimeThru = TRUE;
if ( firstTimeThru ) {
firstTimeThru = FALSE;
decode( output, samples, samplesMade );
return FALSE;
} else
*/
return FALSE;
}
double LibMadPlugin::getTime() {
debugMsg( "LibMadPlugin::getTime" );
return 0.0;
}
void LibMadPlugin::printID3Tags() {
- debugMsg( "LibMadPlugin::printID3Tags" );
+ qDebug( "LibMadPlugin::printID3Tags" );
char id3v1[128 + 1];
if ( ::lseek( d->input.fd, -128, SEEK_END ) == -1 ) {
qDebug( "error seeking to id3 tags" );
return;
}
if ( ::read( d->input.fd, id3v1, 128 ) != 128 ) {
qDebug( "error reading in id3 tags" );
return;
}
if ( ::strncmp( (const char *)id3v1, "TAG", 3 ) != 0 ) {
debugMsg( "sorry, no id3 tags" );
} else {
int len[5] = { 30, 30, 30, 4, 30 };
QString label[5] = { tr( "Title" ), tr( "Artist" ), tr( "Album" ), tr( "Year" ), tr( "Comment" ) };
char *ptr = id3v1 + 3, *ptr2 = ptr + len[0];
qDebug( "ID3 tags in file:" );
info = "";
for ( int i = 0; i < 5; ptr += len[i], i++, ptr2 += len[i] ) {
char push = *ptr2;
*ptr2 = '\0';
char *ptr3 = ptr2;
while ( ptr3-1 >= ptr && isspace(ptr3[-1]) ) ptr3--;
char push2 = *ptr3; *ptr3 = '\0';
if ( strcmp( ptr, "" ) )
info += ( i != 0 ? ", " : "" ) + label[i] + ": " + ptr;
//qDebug( info.latin1() );
*ptr3 = push2;
*ptr2 = push;
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index ff156f8..7c76400 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -192,91 +192,92 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
// Add the playlist area
QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
d->playListFrame = vbox3;
d->playListFrame ->setMinimumSize(235,260);
QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton );
d->selectedFiles = new PlayListSelection( hbox2);
QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton );
QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold);
connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) );
QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) );
new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) );
new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) );
QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
QWidget *aTab;
aTab = new QWidget( tabWidget, "aTab" );
audioView = new QListView( aTab, "Audioview" );
audioView->setMinimumSize(233,260);
audioView->addColumn( tr("Title"),140);
audioView->addColumn(tr("Size"), -1);
audioView->addColumn(tr("Media"),-1);
audioView->setColumnAlignment(1, Qt::AlignRight);
audioView->setColumnAlignment(2, Qt::AlignRight);
audioView->setAllColumnsShowFocus(TRUE);
-// audioView->setMultiSelection( TRUE );
-// audioView->setSelectionMode( QListView::Extended);
+
+ audioView->setMultiSelection( TRUE );
+ audioView->setSelectionMode( QListView::Extended);
tabWidget->insertTab(aTab,tr("Audio"));
QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold);
connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
// audioView
populateAudioView();
// videowidget
QWidget *vTab;
vTab = new QWidget( tabWidget, "vTab" );
videoView = new QListView( vTab, "Videoview" );
videoView->setMinimumSize(233,260);
videoView->addColumn(tr("Title"),140);
videoView->addColumn(tr("Size"),-1);
videoView->addColumn(tr("Media"),-1);
videoView->setColumnAlignment(1, Qt::AlignRight);
videoView->setColumnAlignment(2, Qt::AlignRight);
videoView->setAllColumnsShowFocus(TRUE);
-// videoView->setMultiSelection( TRUE );
-// videoView->setSelectionMode( QListView::Extended);
+ videoView->setMultiSelection( TRUE );
+ videoView->setSelectionMode( QListView::Extended);
QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold);
connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
tabWidget->insertTab( vTab,tr("Video"));
populateVideoView();
//playlists list
QWidget *LTab;
LTab = new QWidget( tabWidget, "LTab" );
playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy
playLists->setMinimumSize(233,260);;
tabWidget->insertTab(LTab,tr("Lists"));
connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
// connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) );
// add the library area
// connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)),
// this, SLOT( fauxPlay( QListViewItem *) ) );
// connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)),
// this, SLOT( fauxPlay( QListViewItem *)) );
// connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) );
// 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 *) ) );
@@ -651,95 +652,112 @@ void PlayListWidget::loadList( const DocLnk & lnk) {
Config config( "OpiePlayer" );
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( "OpiePlayer" );
cfg.setGroup("PlayList");
QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
switch (tabWidget->currentPageIndex()) {
case 0: //playlist
break;
case 1: { //audio
- for ( int i = 0; i < noOfFiles; i++ ) {
- QString entryName;
- entryName.sprintf( "File%i", i + 1 );
- QString linkFile = cfg.readEntry( entryName );
- if( DocLnk( linkFile).name() == audioView->selectedItem()->text(0) ) {
- int result= QMessageBox::warning(this,tr("OpiePlayer"),
- tr("This is all ready in your playlist.\nContinue?"),
- tr("Yes"),tr("No"),0,0,1);
- if (result !=0)
- return;
- }
+// QString entryName;
+// entryName.sprintf( "File%i", i + 1 );
+// QString linkFile = cfg.readEntry( entryName );
+ QListViewItemIterator it( audioView );
+ // iterate through all items of the listview
+ for ( ; it.current(); ++it ) {
+ if ( it.current()->isSelected() ) {
+ QListIterator<DocLnk> dit( files.children() );
+ for ( ; dit.current(); ++dit ) {
+ if( dit.current()->name() == it.current()->text(0) ) {
+ d->selectedFiles->addToSelection( **dit );
+ }
+ }
+ audioView->setSelected( it.current(),FALSE);
+ }
}
- addToSelection( audioView->selectedItem() );
- tabWidget->setCurrentPage(1);
+ tabWidget->setCurrentPage(0);
}
break;
case 2: { // video
- for ( int i = 0; i < noOfFiles; i++ ) {
- QString entryName;
- entryName.sprintf( "File%i", i + 1 );
- QString linkFile = cfg.readEntry( entryName );
- if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) {
- int result= QMessageBox::warning(this,tr("OpiePlayer"),
- tr("This is all ready in your playlist.\nContinue?"),
- tr("Yes"),tr("No"),0,0,1);
- if (result !=0)
- return;
- }
+ QListViewItemIterator it( videoView );
+ // iterate through all items of the listview
+ for ( ; it.current(); ++it ) {
+ if ( it.current()->isSelected() ) {
+ QListIterator<DocLnk> dit( vFiles.children() );
+ for ( ; dit.current(); ++dit ) {
+ if( dit.current()->name() == it.current()->text(0) ) {
+ d->selectedFiles->addToSelection( **dit );
+ }
+ }
+
+ videoView->setSelected( it.current(),FALSE);
+ }
}
- addToSelection( videoView->selectedItem() );
- tabWidget->setCurrentPage(2);
+// for ( int i = 0; i < noOfFiles; i++ ) {
+// QString entryName;
+// entryName.sprintf( "File%i", i + 1 );
+// QString linkFile = cfg.readEntry( entryName );
+// if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) {
+// int result= QMessageBox::warning(this,tr("OpiePlayer"),
+// tr("This is all ready in your playlist.\nContinue?"),
+// tr("Yes"),tr("No"),0,0,1);
+// if (result !=0)
+// return;
+// }
+// }
+// addToSelection( videoView->selectedItem() );
+ tabWidget->setCurrentPage(0);
}
break;
};
}
void PlayListWidget::removeSelected() {
d->selectedFiles->removeSelected( );
}
void PlayListWidget::playIt( QListViewItem *it) {
// d->setDocumentUsed = FALSE;
mediaPlayerState->setPlaying(TRUE);
}
void PlayListWidget::addToSelection( QListViewItem *it) {
d->setDocumentUsed = FALSE;
if(it) {
switch (tabWidget->currentPageIndex()) {
case 1: {
QListIterator<DocLnk> dit( files.children() );
for ( ; dit.current(); ++dit ) {
if( dit.current()->name() == it->text(0)) {
d->selectedFiles->addToSelection( **dit );
}
}
}
break;
case 2: {
QListIterator<DocLnk> dit( vFiles.children() );
for ( ; dit.current(); ++dit ) {
if( dit.current()->name() == it->text(0)) {