summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-12-11 23:35:31 (UTC)
committer harlekin <harlekin>2002-12-11 23:35:31 (UTC)
commita1ff0243520fca8406d90b0875ef141b7555d748 (patch) (side-by-side diff)
tree739fb7fbd60e1e19eb017e28afea3b8c6efd918b
parentd4a0626f01fae21ed19d0eea88d8eca1935c6bc8 (diff)
downloadopie-a1ff0243520fca8406d90b0875ef141b7555d748.zip
opie-a1ff0243520fca8406d90b0875ef141b7555d748.tar.gz
opie-a1ff0243520fca8406d90b0875ef141b7555d748.tar.bz2
buttons centered again
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp58
1 files changed, 29 insertions, 29 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index c35e03d..a65495e 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -35,100 +35,100 @@
#include <qpe/qpeapplication.h>
#include <qpe/storage.h>
#include <qpe/mimetype.h>
#include <qpe/global.h>
#include <qpe/resource.h>
#include <qdatetime.h>
#include <qdir.h>
#include <qmessagebox.h>
#include <qregexp.h>
#include <qtextstream.h>
#include "playlistselection.h"
#include "playlistwidget.h"
#include "mediaplayerstate.h"
#include "inputDialog.h"
#include "om3u.h"
#include "playlistfileview.h"
//only needed for the random play
#include <stdlib.h>
#include <assert.h>
PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name )
- : PlayListWidgetGui( mediaPlayerState, parent, name ) , currentFileListView( 0 )
+ : PlayListWidgetGui( mediaPlayerState, parent, name ) , currentFileListView( 0 )
{
d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ),
"opieplayer2/add_to_playlist",
this , SLOT(addSelected() ) );
d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ),
"opieplayer2/remove_from_playlist",
this , SLOT(removeSelected() ) );
d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play",
this , SLOT( btnPlay( bool) ), TRUE );
d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle",
&mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE );
d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop",
&mediaPlayerState, SLOT( setLooping( bool ) ), TRUE );
(void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
(void)new MenuItem( pmPlayList, tr( "Add all audio files" ),
this, SLOT( addAllMusicToList() ) );
(void)new MenuItem( pmPlayList, tr( "Add all video files" ),
this, SLOT( addAllVideoToList() ) );
(void)new MenuItem( pmPlayList, tr( "Add all files" ),
this, SLOT( addAllToList() ) );
pmPlayList->insertSeparator(-1);
// (void)new MenuItem( pmPlayList, tr( "Save PlayList" ),
// this, SLOT( saveList() ) );
(void)new MenuItem( pmPlayList, tr( "Save Playlist" ),
this, SLOT(writem3u() ) );
pmPlayList->insertSeparator(-1);
(void)new MenuItem( pmPlayList, tr( "Open File or URL" ),
this,SLOT( openFile() ) );
pmPlayList->insertSeparator(-1);
(void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ),
audioView, SLOT( scanFiles() ) );
(void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ),
videoView, SLOT( scanFiles() ) );
pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"),
&mediaPlayerState, SLOT( toggleFullscreen() ) );
Config cfg( "OpiePlayer" );
bool b= cfg.readBoolEntry("FullScreen", 0);
mediaPlayerState.setFullscreen( b );
pmView->setItemChecked( -16, b );
- (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up",
+ (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up",
d->selectedFiles, SLOT(moveSelectedUp() ) );
- (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut",
+ (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut",
d->selectedFiles, SLOT(removeSelected() ) );
(void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down",
d->selectedFiles, SLOT(moveSelectedDown() ) );
- // QVBox *stretch2 = new QVBox( vbox1 );
+ QVBox *stretch2 = new QVBox( vbox1 );
connect( tbDeletePlaylist, ( SIGNAL( released() ) ),
SLOT( deletePlaylist() ) );
connect( pmView, SIGNAL( activated( int ) ),
this, SLOT( pmViewActivated( int ) ) );
connect( skinsMenu, SIGNAL( activated( int ) ) ,
this, SLOT( skinsMenuActivated( int ) ) );
connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ),
this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) );
connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ),
this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) );
connect( audioView, SIGNAL( returnPressed( QListViewItem *) ),
this,SLOT( playIt( QListViewItem *) ) );
connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ),
this, SLOT( addToSelection( QListViewItem *) ) );
connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ),
this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) );
connect( videoView, SIGNAL( returnPressed( QListViewItem *) ),
this,SLOT( playIt( QListViewItem *) ) );
connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ),
this, SLOT( addToSelection( QListViewItem *) ) );
connect( playLists, SIGNAL( fileSelected( const DocLnk &) ),
this, SLOT( loadList( const DocLnk & ) ) );
connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ),
@@ -167,60 +167,60 @@ void PlayListWidget::initializeStates() {
d->tbShuffle->setOn( mediaPlayerState.isShuffled() );
d->playListFrame->show();
}
void PlayListWidget::writeDefaultPlaylist() {
Config config( "OpiePlayer" );
config.setGroup( "PlayList" );
QString filename=QPEApplication::documentDir() + "/default.m3u";
QString currentString = config.readEntry( "CurrentPlaylist", filename);
if( currentString == filename) {
Om3u *m3uList;
// qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>");
if( d->selectedFiles->first() ) {
m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate);
do {
// qDebug(d->selectedFiles->current()->file());
m3uList->add( d->selectedFiles->current()->file() );
}
while ( d->selectedFiles->next() );
m3uList->write();
m3uList->close();
delete m3uList;
-
+
}
}
}
void PlayListWidget::addToSelection( const DocLnk& lnk ) {
d->setDocumentUsed = FALSE;
if( QFileInfo( lnk.file() ).exists() ||
lnk.file().left(4) == "http" ) {
d->selectedFiles->addToSelection( lnk );
}
-// writeCurrentM3u();
+// writeCurrentM3u();
}
void PlayListWidget::clearList() {
while ( first() ) {
d->selectedFiles->removeSelected();
}
Config cfg( "OpiePlayer" );
cfg.setGroup("PlayList");
cfg.writeEntry("CurrentPlaylist","default");
setCaption("OpiePlayer");
}
void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
switch (mouse) {
case LeftButton:
break;
case RightButton:
{
QPopupMenu m;
m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
m.exec( QCursor::pos() );
}
@@ -240,172 +240,172 @@ void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoi
m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
m.exec( QCursor::pos() );
}
break;
}
}
void PlayListWidget::addAllToList() {
// QTime t;
// t.start();
audioView->populateView();
QListViewItemIterator audioIt( audioView );
DocLnk lnk;
QString filename;
// iterate through all items of the listview
for ( ; audioIt.current(); ++audioIt ) {
filename = audioIt.current()->text(3);
lnk.setName( QFileInfo(filename).baseName() ); //sets name
lnk.setFile( filename ); //sets file name
d->selectedFiles->addToSelection( lnk);
- }
+ }
videoView->populateView();
QListViewItemIterator videoIt( videoView );
for ( ; videoIt.current(); ++videoIt ) {
filename = videoIt.current()->text(3);
lnk.setName( QFileInfo(filename).baseName() ); //sets name
lnk.setFile( filename ); //sets file name
d->selectedFiles->addToSelection( lnk);
- }
+ }
// d->selectedFiles->addToSelection( );
// if ( it.current()->isSelected() )
// lst->append( audioIt.current() );
// }
-
+
// if(!audioScan)
// scanForAudio();
-// if(!videoScan)
+// if(!videoScan)
// scanForVideo();
// DocLnkSet filesAll;
// Global::findDocuments(&filesAll, "video/*;"+audioMimes);
// QListIterator<DocLnk> Adit( filesAll.children() );
// for ( ; Adit.current(); ++Adit ) {
// if( QFileInfo( Adit.current()->file() ).exists() ) {
// d->selectedFiles->addToSelection( **Adit );
// }
// }
// qDebug("elapsed time %d", t.elapsed() );
tabWidget->setCurrentPage(0);
-
+
writeCurrentM3u();
d->selectedFiles->first();
}
void PlayListWidget::addAllMusicToList() {
audioView->populateView();
QListViewItemIterator audioIt( audioView );
DocLnk lnk;
QString filename;
// iterate through all items of the listview
for ( ; audioIt.current(); ++audioIt ) {
filename = audioIt.current()->text(3);
lnk.setName( QFileInfo(filename).baseName() ); //sets name
lnk.setFile( filename ); //sets file name
d->selectedFiles->addToSelection( lnk);
- }
+ }
/* if(!audioScan)
scanForAudio();
QListIterator<DocLnk> dit( files.children() );
for ( ; dit.current(); ++dit ) {
if( QFileInfo(dit.current()->file() ).exists() ) {
d->selectedFiles->addToSelection( **dit );
}
}
*/
tabWidget->setCurrentPage(0);
writeCurrentM3u();
d->selectedFiles->first();
}
void PlayListWidget::addAllVideoToList() {
videoView->populateView();
QListViewItemIterator videoIt( videoView );
DocLnk lnk;
QString filename;
for ( ; videoIt.current(); ++videoIt ) {
filename = videoIt.current()->text(3);
lnk.setName( QFileInfo(filename).baseName() ); //sets name
lnk.setFile( filename ); //sets file name
d->selectedFiles->addToSelection( lnk);
- }
+ }
/* if(!videoScan)
scanForVideo();
QListIterator<DocLnk> dit( vFiles.children() );
for ( ; dit.current(); ++dit ) {
if( QFileInfo( dit.current()->file() ).exists() ) {
d->selectedFiles->addToSelection( **dit );
}
}
-*/
+*/
tabWidget->setCurrentPage(0);
- writeCurrentM3u();
+ writeCurrentM3u();
d->selectedFiles->first();
}
void PlayListWidget::setDocument( const QString& fileref ) {
// qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref );
fromSetDocument = TRUE;
if ( fileref.isNull() ) {
QMessageBox::warning( this, tr( "Invalid File" ),
tr( "There was a problem in getting the file." ) );
return;
}
clearList();
if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u
readm3u( fileref );
} else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) {
readm3u( DocLnk( fileref).file() );
} else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls
readPls( fileref );
} else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) {
readPls( DocLnk( fileref).file() );
} else {
clearList();
addToSelection( DocLnk( fileref ) );
- writeCurrentM3u();
-
+ writeCurrentM3u();
+
d->setDocumentUsed = TRUE;
mediaPlayerState.setPlaying( FALSE );
mediaPlayerState.setPlaying( TRUE );
}
}
void PlayListWidget::useSelectedDocument() {
d->setDocumentUsed = FALSE;
}
const DocLnk *PlayListWidget::current() const { // this is fugly
assert( currentTab() == CurrentPlayList );
const DocLnk *lnk = d->selectedFiles->current();
if ( !lnk ) {
d->selectedFiles->first();
lnk = d->selectedFiles->current();
}
assert( lnk );
return lnk;
}
@@ -484,78 +484,78 @@ void PlayListWidget::loadList( const DocLnk & lnk) {
void PlayListWidget::addSelected() {
assert( inFileListMode() );
QListViewItemIterator it( currentFileListView );
for ( ; it.current(); ++it )
if ( it.current()->isSelected() ) {
QString filename = it.current()->text(3);
DocLnk lnk;
lnk.setName( QFileInfo( filename ).baseName() ); //sets name
lnk.setFile( filename ); //sets file name
d->selectedFiles->addToSelection( lnk );
}
currentFileListView->clearSelection();
// tabWidget->setCurrentPage( 0 );
writeCurrentM3u();
}
void PlayListWidget::removeSelected() {
d->selectedFiles->removeSelected( );
- writeCurrentM3u();
+ writeCurrentM3u();
}
void PlayListWidget::playIt( QListViewItem *it) {
if(!it) return;
mediaPlayerState.setPlaying(FALSE);
mediaPlayerState.setPlaying(TRUE);
d->selectedFiles->unSelect();
}
void PlayListWidget::addToSelection( QListViewItem *it) {
d->setDocumentUsed = FALSE;
if(it) {
if ( currentTab() == CurrentPlayList )
return;
// case 1: {
DocLnk lnk;
QString filename;
filename=it->text(3);
lnk.setName( QFileInfo(filename).baseName() ); //sets name
lnk.setFile( filename ); //sets file name
d->selectedFiles->addToSelection( lnk);
-
- writeCurrentM3u();
+
+ writeCurrentM3u();
// tabWidget->setCurrentPage(0);
-
+
}
}
void PlayListWidget::tabChanged(QWidget *) {
d->tbPlay->setEnabled( true );
disconnect( audioView, SIGNAL( itemsSelected( bool ) ),
d->tbPlay, SLOT( setEnabled( bool ) ) );
disconnect( videoView, SIGNAL( itemsSelected( bool ) ),
d->tbPlay, SLOT( setEnabled( bool ) ) );
currentFileListView = 0;
switch ( currentTab() ) {
case CurrentPlayList:
{
if( !tbDeletePlaylist->isHidden() ) {
tbDeletePlaylist->hide();
}
d->tbRemoveFromList->setEnabled(TRUE);
d->tbAddToList->setEnabled(FALSE);
@@ -672,102 +672,102 @@ void PlayListWidget::openFile() {
// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile);
lnk.setName( filename ); //sets name
lnk.setFile( filename ); //sets file name
// lnk.setIcon("opieplayer2/musicfile");
d->selectedFiles->addToSelection( lnk );
writeCurrentM3u();
d->selectedFiles->setSelectedItem( lnk.name());
}
else if( filename.right( 3) == "m3u" ) {
readm3u( filename );
} else if( filename.right(3) == "pls" ) {
readPls( filename );
} else {
lnk.setName( QFileInfo(filename).baseName() ); //sets name
lnk.setFile( filename ); //sets file name
d->selectedFiles->addToSelection( lnk);
writeCurrentM3u();
d->selectedFiles->setSelectedItem( lnk.name());
}
}
-
+
delete fileDlg;
}
/*
reads m3u and shows files/urls to playlist widget */
-void PlayListWidget::readm3u( const QString &filename ) {
+void PlayListWidget::readm3u( const QString &filename ) {
qDebug( "read m3u filename " + filename );
Om3u *m3uList;
QString s, name;
m3uList = new Om3u( filename, IO_ReadOnly );
m3uList->readM3u();
DocLnk lnk;
for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
s = *it;
// qDebug("reading "+ s);
if(s.left(4)=="http") {
lnk.setName( s ); //sets file name
lnk.setIcon("opieplayer2/musicfile");
lnk.setFile( s ); //sets file name
-
+
} else {
// if( QFileInfo( s ).exists() ) {
lnk.setName( QFileInfo(s).baseName());
// if(s.right(4) == '.') {//if regular file
- if(s.left(1) != "/") {
+ if(s.left(1) != "/") {
// qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s);
lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
// lnk.setIcon(MimeType(s).pixmap() );
// lnk.setIcon("SoundPlayer");
} else {
// qDebug("set link2 "+s);
lnk.setFile( s);
// lnk.setIcon(MimeType(s).pixmap() );
// lnk.setIcon("SoundPlayer");
}
}
d->selectedFiles->addToSelection( lnk );
}
Config config( "OpiePlayer" );
config.setGroup( "PlayList" );
config.writeEntry("CurrentPlaylist",filename);
config.write();
currentPlayList=filename;
// m3uList->write();
m3uList->close();
delete m3uList;
d->selectedFiles->setSelectedItem( s);
setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
-
+
}
/*
reads pls and adds files/urls to playlist */
void PlayListWidget::readPls( const QString &filename ) {
qDebug( "pls filename is " + filename );
Om3u *m3uList;
QString s, name;
m3uList = new Om3u( filename, IO_ReadOnly );
m3uList->readPls();
for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
s = *it;
// s.replace( QRegExp( "%20" )," " );
DocLnk lnk( s );
QFileInfo f( s );
QString name = f.baseName();
if( name.left( 4 ) == "http" ) {
name = s.right( s.length() - 7);
} else {
name = s;
}
@@ -794,95 +794,95 @@ void PlayListWidget::readPls( const QString &filename ) {
}
/*
writes current playlist to current m3u file */
void PlayListWidget::writeCurrentM3u() {
qDebug("writing to current m3u");
Config cfg( "OpiePlayer" );
cfg.setGroup("PlayList");
QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
Om3u *m3uList;
m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
if( d->selectedFiles->first()) {
do {
// qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file());
m3uList->add( d->selectedFiles->current()->file() );
}
while ( d->selectedFiles->next() );
// qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
m3uList->write();
m3uList->close();
}
delete m3uList;
-
+
}
/*
writes current playlist to m3u file */
void PlayListWidget::writem3u() {
InputDialog *fileDlg;
fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
fileDlg->exec();
QString name, filename, list;
Om3u *m3uList;
if( fileDlg->result() == 1 ) {
name = fileDlg->text();
// qDebug( filename );
if( name.left( 1) != "/" ) {
filename = QPEApplication::documentDir() + "/" + name;
}
if( name.right( 3 ) != "m3u" ) {
filename = QPEApplication::documentDir() + "/" +name+".m3u";
}
if( d->selectedFiles->first()) {
m3uList = new Om3u(filename, IO_ReadWrite);
do {
m3uList->add( d->selectedFiles->current()->file());
}
while ( d->selectedFiles->next() );
// qDebug( list );
m3uList->write();
m3uList->close();
delete m3uList;
-
+
delete fileDlg;
DocLnk lnk;
lnk.setFile( filename);
lnk.setIcon("opieplayer2/playlist2");
lnk.setName( name); //sets file name
// qDebug(filename);
Config config( "OpiePlayer" );
config.setGroup( "PlayList" );
-
+
config.writeEntry("CurrentPlaylist",filename);
currentPlayList=filename;
if(!lnk.writeLink()) {
qDebug("Writing doclink did not work");
}
setCaption(tr("OpiePlayer: ") + name);
}
}
}
void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) {
switch ( e->key() ) {
////////////////////////////// Zaurus keys
case Key_F9: //activity
// if(audioUI->isHidden())
// audioUI->showMaximized();
break;
case Key_F10: //contacts
// if( videoUI->isHidden())
// videoUI->showMaximized();
break;
case Key_F11: //menu