summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/playlistwidget.cpp
Side-by-side diff
Diffstat (limited to 'core/multimedia/opieplayer/playlistwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp553
1 files changed, 399 insertions, 154 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 969fc4b..4e1543e 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -22,2 +22,4 @@
#include <qpe/fileselector.h>
+#include <qpe/qpeapplication.h>
+
#include <qpe/applnk.h>
@@ -36,2 +38,6 @@
#include <qtoolbutton.h>
+#include <qtabwidget.h>
+#include <qlistview.h>
+#include <qpoint.h>
+#include <qtimer.h>
@@ -43,2 +49,5 @@
+#define BUTTONS_ON_TOOLBAR
+#define SIDE_BUTTONS
+#define CAN_SAVE_LOAD_PLAYLISTS
@@ -46,11 +55,8 @@ extern MediaPlayerState *mediaPlayerState;
+// class myFileSelector {
+// };
class PlayListWidgetPrivate {
public:
- QToolButton *tbPlay;
- QToolButton *tbFull;
- QToolButton *tbLoop;
- QToolButton *tbScale;
- QToolButton *tbShuffle;
-
+ QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove;
QFrame *playListFrame;
@@ -66,10 +72,10 @@ public:
ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
- : QToolButton( parent, name ) {
- setTextLabel( name );
- setPixmap( Resource::loadPixmap( icon ) );
- setAutoRaise( TRUE );
- setFocusPolicy( QWidget::NoFocus );
- setToggleButton( t );
- connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
- QPEMenuToolFocusManager::manager()->addWidget( this );
+ : QToolButton( parent, name ) {
+ setTextLabel( name );
+ setPixmap( Resource::loadPixmap( icon ) );
+ setAutoRaise( TRUE );
+ setFocusPolicy( QWidget::NoFocus );
+ setToggleButton( t );
+ connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
+ QPEMenuToolFocusManager::manager()->addWidget( this );
}
@@ -81,5 +87,5 @@ public:
MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot )
- : QAction( text, QString::null, 0, 0 ) {
- connect( this, SIGNAL( activated() ), handler, slot );
- addTo( parent );
+ : QAction( text, QString::null, 0, 0 ) {
+ connect( this, SIGNAL( activated() ), handler, slot );
+ addTo( parent );
}
@@ -94,2 +100,4 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
d->current = NULL;
+ menuTimer = new QTimer( this ,"menu timer"),
+ connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) );
@@ -97,3 +105,3 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
- setCaption( tr("MediaPlayer") );
+ setCaption( tr("OpiePlayer") );
setIcon( Resource::loadPixmap( "MPEGPlayer" ) );
@@ -112,67 +120,149 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
bar->setLabel( tr( "Play Operations" ) );
-#ifdef BUTTONS_ON_TOOLBAR
- d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", mediaPlayerState, SLOT(setPlaying(bool)), TRUE );
- d->tbShuffle = new ToolButton( bar, tr( "Randomize" ), "mpegplayer/shuffle", mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
-#endif
- d->tbLoop = new ToolButton( bar, tr( "Loop" ), "mpegplayer/loop", mediaPlayerState, SLOT(setLooping(bool)), TRUE );
- d->tbFull = new ToolButton( bar, tr( "Fullscreen" ), "fullscreen", mediaPlayerState, SLOT(setFullscreen(bool)), TRUE );
- d->tbScale = new ToolButton( bar, tr( "Scale" ), "mpegplayer/scale", mediaPlayerState, SLOT(setScaled(bool)), TRUE );
+ d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist",
+ this , SLOT(addSelected()) );
+ d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist",
+ this , SLOT(removeSelected()) );
+ d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play",
+ mediaPlayerState, SLOT(setPlaying(bool)), TRUE );
+
+ d->tbShuffle = new ToolButton( bar, tr( "Randomize" ), "mpegplayer/shuffle",
+ mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
+ d->tbLoop = new ToolButton( bar, tr( "Loop" ), "mpegplayer/loop",
+ mediaPlayerState, SLOT(setLooping(bool)), TRUE );
+
+// d->tbFull = new ToolButton( bar, tr( "Fullscreen" ), "fullscreen", mediaPlayerState, SLOT(setFullscreen(bool)), TRUE );
+// d->tbScale = new ToolButton( bar, tr( "Scale" ), "mpegplayer/scale", mediaPlayerState, SLOT(setScaled(bool)), TRUE );
QPopupMenu *pmPlayList = new QPopupMenu( this );
- menu->insertItem( tr( "PlayList" ), pmPlayList );
- new MenuItem( pmPlayList, tr( "Toggle PlayList" ), mediaPlayerState, SLOT( togglePlaylist() ) );
+ menu->insertItem( tr( "File" ), pmPlayList );
new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
- new MenuItem( pmPlayList, tr( "Add all music files" ), this, SLOT( addAllMusicToList() ) );
+ new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
-#ifdef CAN_SAVE_LOAD_PLAYLISTS
new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) );
-#endif
+
+ QPopupMenu *pmView = new QPopupMenu( this );
+ menu->insertItem( tr( "View" ), pmView );
+
+ fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0);
+ connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) );
+ fullScreenButton->addTo(pmView);
+ scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("mpegplayer/scale"), QString::null, 0, this, 0);
+ connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) );
+ scaleButton->addTo(pmView);
QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
+ QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
+// vbox4->setMargin(4);
+// libString = new QLabel( tr(" Media Library"), vbox4 );
+// libString->setBackgroundMode( QButton::PaletteButton );
+// libString->setFont( QFont( "Helvetica", 8, QFont::Bold ) );
+
+ QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
+
+ tabWidget = new QTabWidget( hbox6, "tabWidget" );
+ tabWidget->setTabShape(QTabWidget::Triangular);
+
+
+ QWidget *pTab;
+ pTab = new QWidget( tabWidget, "pTab" );
+ playlistView = new QListView( pTab, "Videoview" );
+ playlistView->setMinimumSize(236,260);
+ tabWidget->insertTab( pTab,"Playlist");
// Add the playlist area
- QVBox *vbox3 = new QVBox( vbox5 ); vbox3->setBackgroundMode( PaletteButton );
- d->playListFrame = vbox3;
- QLabel *plString = new QLabel( tr(" PlayList"), vbox3 );
- plString->setBackgroundMode( QButton::PaletteButton );
- plString->setFont( QFont( "Helvetica", 8, QFont::Bold ) );
+ 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 );
-
-#ifndef BUTTONS_ON_TOOLBAR
- d->tbPlay = new ToolButton( vbox1, tr( "Play" ), "mpegplayer/play", mediaPlayerState, SLOT(setPlaying(bool)), TRUE );
- QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
-#endif
- new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) );
- new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) );
- new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) );
- QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
-#ifndef BUTTONS_ON_TOOLBAR
- d->tbShuffle = new ToolButton( vbox1, tr( "Randomize" ), "mpegplayer/shuffle", mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
-#endif
+ d->selectedFiles = new PlayListSelection( hbox2);
+ QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton );
+
+ QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
+ new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) );
+ new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) );
+ new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/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( "Title",150);
+ audioView->addColumn("Size", 45);
+ audioView->addColumn("Media",35);
+ audioView->setColumnAlignment(1, Qt::AlignRight);
+ audioView->setColumnAlignment(2, Qt::AlignRight);
+ tabWidget->insertTab(aTab,"Audio");
+// audioView
+ Global::findDocuments(&files, "audio/*");
+ QListIterator<DocLnk> dit( files.children() );
+ QString storage;
+ for ( ; dit.current(); ++dit ) {
+ QListViewItem * newItem;
+ if(dit.current()->file().find("/mnt/cf") != -1 ) storage="CF";
+ else if(dit.current()->file().find("/mnt/card") != -1 ) storage="SD";
+ else storage="RAM";
+
+ newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage);
+ newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" ));
+ }
+// videowidget
+
+ QWidget *vTab;
+ vTab = new QWidget( tabWidget, "vTab" );
+ videoView = new QListView( vTab, "Videoview" );
+ videoView->setMinimumSize(233,260);
+
+ videoView->addColumn("Title",150);
+ videoView->addColumn("Size",45);
+ videoView->addColumn("Media",35);
+ videoView->setColumnAlignment(1, Qt::AlignRight);
+ videoView->setColumnAlignment(2, Qt::AlignRight);
+
+ tabWidget->insertTab( vTab,"Video");
+
+ Global::findDocuments(&vFiles, "video/*");
+ QListIterator<DocLnk> Vdit( vFiles.children() );
+ for ( ; Vdit.current(); ++Vdit ) {
+ if( Vdit.current()->file().find("/mnt/cf") != -1 ) storage="CF";
+ else if( Vdit.current()->file().find("/mnt/card") != -1 ) storage="SD";
+ else storage="RAM";
+ QListViewItem * newItem;
+ newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage);
+ newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" ));
+ }
+
+
+// d->tbPlay = new ToolButton( vbox1, tr( "Play" ), "mpegplayer/play", mediaPlayerState, SLOT(setPlaying(bool)), TRUE );
+// d->tbShuffle = new ToolButton( vbox1, tr( "Randomize" ), "mpegplayer/shuffle", mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
// add the library area
- QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
- QLabel *libString = new QLabel( tr(" Media Library"), vbox4 );
- libString->setBackgroundMode( QButton::PaletteButton );
- libString->setFont( QFont( "Helvetica", 8, QFont::Bold ) );
+// d->files->setBackgroundMode( PaletteButton );
+// QVBox *vbox7 = new QVBox( hbox6 ); vbox7->setBackgroundMode( PaletteButton );
- QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
- d->files = new FileSelector( "video/*;audio/*", hbox6, "Find Media Files", FALSE, FALSE );
- d->files->setBackgroundMode( PaletteButton );
- QVBox *vbox7 = new QVBox( hbox6 ); vbox7->setBackgroundMode( PaletteButton );
+// #ifdef SIDE_BUTTONS
+// QVBox *stretch3 = new QVBox( vbox1 ); stretch3->setBackgroundMode( PaletteButton ); // add stretch
+// #endif
+ QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold );
+
+// connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
+// connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
-#ifdef SIDE_BUTTONS
- new ToolButton( vbox7, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist", d->selectedFiles, SLOT(addSelected()) );
- new ToolButton( vbox7, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist", d->selectedFiles, SLOT(removeSelected()) );
- QVBox *stretch3 = new QVBox( vbox1 ); stretch3->setBackgroundMode( PaletteButton ); // add stretch
-#endif
+ connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
+ connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
- connect( d->files, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) );
+ connect( audioView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint&, int ) ),
+ this, SLOT( addToSelection( QListViewItem *, const QPoint&, int )) );
+ connect( videoView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint&, int ) ),
+ this, SLOT( addToSelection( QListViewItem *, const QPoint&, int )) );
+
+ connect( playlistView, SIGNAL( pressed( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
+ connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
+ // connect( d->files, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) );
+ // connect( d->files, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) );
connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
@@ -180,5 +270,7 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
- connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), d->tbFull, SLOT( setOn( bool ) ) );
- connect( mediaPlayerState, SIGNAL( scaledToggled( bool ) ), d->tbScale, SLOT( setOn( bool ) ) );
- connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), d->tbScale, SLOT( setEnabled( bool ) ) );
+
+// connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), fullScreenButton, SLOT( setOn( bool ) ) );
+// connect( mediaPlayerState, SIGNAL( scaledToggled( bool ) ), scaleButton, SLOT( setEnabled( bool ) ) );
+// connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), fullScreenButton, SLOT( setEnabled( bool ) ) );
+
connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
@@ -199,3 +291,3 @@ PlayListWidget::~PlayListWidget() {
if ( d->current )
- delete d->current;
+ delete d->current;
delete d;
@@ -205,2 +297,3 @@ PlayListWidget::~PlayListWidget() {
void PlayListWidget::initializeStates() {
+
d->tbPlay->setOn( mediaPlayerState->playing() );
@@ -208,6 +301,6 @@ void PlayListWidget::initializeStates() {
d->tbShuffle->setOn( mediaPlayerState->shuffled() );
- d->tbFull->setOn( mediaPlayerState->fullscreen() );
- d->tbScale->setOn( mediaPlayerState->scaled() );
- d->tbScale->setEnabled( mediaPlayerState->fullscreen() );
- setPlaylist( mediaPlayerState->playlist() );
+// d->tbFull->setOn( mediaPlayerState->fullscreen() );
+// d->tbScale->setOn( mediaPlayerState->scaled() );
+// d->tbScale->setEnabled( mediaPlayerState->fullscreen() );
+// setPlaylist( mediaPlayerState->playlist() );
}
@@ -221,7 +314,7 @@ void PlayListWidget::readConfig( Config& cfg ) {
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() )
+ QString entryName;
+ entryName.sprintf( "File%i", i + 1 );
+ QString linkFile = cfg.readEntry( entryName );
+ DocLnk lnk( linkFile );
+ if ( lnk.isValid() )
d->selectedFiles->addToSelection( lnk );
@@ -239,24 +332,24 @@ void PlayListWidget::writeConfig( Config& cfg ) const {
do {
- const DocLnk *lnk = d->selectedFiles->current();
- if ( lnk ) {
- QString entryName;
- entryName.sprintf( "File%i", noOfFiles + 1 );
- 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++;
- }
+ const DocLnk *lnk = d->selectedFiles->current();
+ if ( lnk ) {
+ QString entryName;
+ entryName.sprintf( "File%i", noOfFiles + 1 );
+ 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() );
@@ -268,3 +361,3 @@ void PlayListWidget::writeConfig( Config& cfg ) const {
void PlayListWidget::addToSelection( const DocLnk& lnk ) {
- d->setDocumentUsed = FALSE;
+ d->setDocumentUsed = FALSE;
if ( mediaPlayerState->playlist() )
@@ -272,3 +365,13 @@ void PlayListWidget::addToSelection( const DocLnk& lnk ) {
else
- mediaPlayerState->setPlaying( TRUE );
+ mediaPlayerState->setPlaying( TRUE );
+}
+
+
+void PlayListWidget::addToSelection( QListViewItem *it ,const QPoint & p, int index) {
+ qDebug("add");
+// d->selectedFiles->addToSelection( lnk );
+ // }
+// else
+// mediaPlayerState->setPlaying( TRUE );
+//
}
@@ -278,3 +381,3 @@ void PlayListWidget::clearList() {
while ( first() )
- d->selectedFiles->removeSelected();
+ d->selectedFiles->removeSelected();
}
@@ -311,12 +414,12 @@ void PlayListWidget::setDocument(const QString& fileref) {
if ( fileref.isNull() ) {
- QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) );
- return;
+ QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) );
+ return;
}
if ( mediaPlayerState->playlist() )
- addToSelection( DocLnk( fileref ) );
+ addToSelection( DocLnk( fileref ) );
else {
- d->setDocumentUsed = TRUE;
- if ( d->current )
- delete d->current;
- d->current = new DocLnk( fileref );
+ d->setDocumentUsed = TRUE;
+ if ( d->current )
+ delete d->current;
+ d->current = new DocLnk( fileref );
}
@@ -342,7 +445,7 @@ const DocLnk *PlayListWidget::current() {
if ( mediaPlayerState->playlist() )
- return d->selectedFiles->current();
+ return d->selectedFiles->current();
else if ( d->setDocumentUsed && d->current ) {
- return d->current;
+ return d->current;
} else
- return d->files->selected();
+ return d->files->selected();
}
@@ -352,25 +455,25 @@ 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() )
- d->selectedFiles->first();
- }
- if ( cur == current() )
- if ( !d->selectedFiles->next() )
- d->selectedFiles->first();
- return TRUE;
- } else {
- if ( !d->selectedFiles->prev() ) {
- if ( mediaPlayerState->looping() ) {
- return d->selectedFiles->last();
- } else {
- return FALSE;
- }
- }
- return TRUE;
- }
+ 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() )
+ d->selectedFiles->first();
+ }
+ if ( cur == current() )
+ if ( !d->selectedFiles->next() )
+ d->selectedFiles->first();
+ return TRUE;
+ } else {
+ if ( !d->selectedFiles->prev() ) {
+ if ( mediaPlayerState->looping() ) {
+ return d->selectedFiles->last();
+ } else {
+ return FALSE;
+ }
+ }
+ return TRUE;
+ }
} else {
- return mediaPlayerState->looping();
+ return mediaPlayerState->looping();
}
@@ -381,16 +484,16 @@ bool PlayListWidget::next() {
if ( mediaPlayerState->playlist() ) {
- if ( mediaPlayerState->shuffled() ) {
- return prev();
- } else {
- if ( !d->selectedFiles->next() ) {
- if ( mediaPlayerState->looping() ) {
- return d->selectedFiles->first();
- } else {
- return FALSE;
- }
- }
- return TRUE;
- }
+ if ( mediaPlayerState->shuffled() ) {
+ return prev();
+ } else {
+ if ( !d->selectedFiles->next() ) {
+ if ( mediaPlayerState->looping() ) {
+ return d->selectedFiles->first();
} else {
- return mediaPlayerState->looping();
+ return FALSE;
+ }
+ }
+ return TRUE;
+ }
+ } else {
+ return mediaPlayerState->looping();
}
@@ -401,5 +504,5 @@ bool PlayListWidget::first() {
if ( mediaPlayerState->playlist() )
- return d->selectedFiles->first();
+ return d->selectedFiles->first();
else
- return mediaPlayerState->looping();
+ return mediaPlayerState->looping();
}
@@ -409,5 +512,5 @@ bool PlayListWidget::last() {
if ( mediaPlayerState->playlist() )
- return d->selectedFiles->last();
+ return d->selectedFiles->last();
else
- return mediaPlayerState->looping();
+ return mediaPlayerState->looping();
}
@@ -435,5 +538,5 @@ void PlayListWidget::setPlaylist( bool shown ) {
if ( shown )
- d->playListFrame->show();
+ d->playListFrame->show();
else
- d->playListFrame->hide();
+ d->playListFrame->hide();
}
@@ -443,6 +546,148 @@ void PlayListWidget::setView( char view ) {
if ( view == 'l' )
- showMaximized();
+ showMaximized();
else
- hide();
+ hide();
+}
+
+void PlayListWidget::addSelected() {
+// QMessageBox::message("Note","Bozo the clown thinks\nthere's something actually here");
+ int tabPage=tabWidget->currentPageIndex();
+ switch (tabPage) {
+ case 0: //playlist
+ break;
+ case 1: { //audio
+ addToSelection( audioView->selectedItem() );
+ }
+ break;
+ case 2: { // video
+ addToSelection( videoView->selectedItem() );
+ }
+ break;
+ };
+}
+
+void PlayListWidget::removeSelected() {
+ d->selectedFiles->removeSelected( );
+}
+
+
+void PlayListWidget::playIt( QListViewItem *it) {
+ d->setDocumentUsed = FALSE;
+
+ if(it) {
+ qDebug("playit");
+ int tabPage=tabWidget->currentPageIndex();
+ switch (tabPage) {
+ case 1: {
+ DocLnkSet files;
+ QListIterator<DocLnk> dit( files.children() );
+ for ( ; dit.current(); ++dit ) {
+ if( dit.current()->name() == it->text(0)) {
+ setDocument( dit.current()->name());
+ }
+ }
+ }
+ break;
+ case 2: {
+ DocLnkSet vFiles;
+ QListIterator<DocLnk> dit( vFiles.children() );
+ for ( ; dit.current(); ++dit ) {
+ qDebug(dit.current()->name());
+ if( dit.current()->name() == it->text(0)) {
+ qDebug(it->text(0));
+ setDocument( dit.current()->name());
+ }
+ }
+ }
+ break;
+ };
+ }
+}
+
+void PlayListWidget::addToSelection( QListViewItem *it) {
+ d->setDocumentUsed = FALSE;
+
+ if(it) {
+ qDebug("add to selection");
+ int tabPage=tabWidget->currentPageIndex();
+ switch (tabPage) {
+ 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 ) {
+ qDebug(dit.current()->name());
+ if( dit.current()->name() == it->text(0)) {
+ d->selectedFiles->addToSelection( **dit );
+ }
+ }
+ }
+ break;
+ case 0:
+ break;
+ };
+ tabWidget->setCurrentPage(0);
+// mediaPlayerState->setPlaying( TRUE );
+ }
+}
+
+void PlayListWidget::tabChanged(QWidget *widg) {
+
+ int tabPage=tabWidget->currentPageIndex();
+ switch (tabPage) {
+ case 0:
+ {
+ d->tbRemoveFromList->setEnabled(TRUE);
+ d->tbAddToList->setEnabled(FALSE);
+ }
+ break;
+ case 1:
+ {
+ d->tbRemoveFromList->setEnabled(FALSE);
+ d->tbAddToList->setEnabled(TRUE);
+ }
+ break;
+ case 2:
+ {
+ d->tbRemoveFromList->setEnabled(FALSE);
+ d->tbAddToList->setEnabled(TRUE);
+ }
+ break;
+ };
+}
+
+void PlayListWidget::cancelMenuTimer() {
+ if( menuTimer->isActive() )
+ menuTimer->stop();
+}
+
+void PlayListWidget::showFileMenu() {
+
+}
+
+void PlayListWidget::contentsMousePressEvent( QMouseEvent * e )
+{
+// QListView::contentsMousePressEvent( e );
+ menuTimer->start( 750, TRUE );
+}
+
+
+void PlayListWidget::contentsMouseReleaseEvent( QMouseEvent * e )
+{
+// QListView::contentsMouseReleaseEvent( e );
+ menuTimer->stop();
}
+// void PlayListWidget::setFullScreen() {
+// mediaPlayerState->toggleFullscreen( );
+// }
+// void PlayListWidget::setScaled() {
+// mediaPlayerState->toggleScaled();
+// }