summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/playlistwidget.cpp
authorsimon <simon>2002-12-04 10:52:00 (UTC)
committer simon <simon>2002-12-04 10:52:00 (UTC)
commit63541c46776721ef5ae63903e5b40838c1c49a43 (patch) (side-by-side diff)
treee9beaf0d1340b32a7fffdce8e6dad7b0cbc54866 /noncore/multimedia/opieplayer2/playlistwidget.cpp
parentd000538b68b3411a409e829c4e68f42f9646b940 (diff)
downloadopie-63541c46776721ef5ae63903e5b40838c1c49a43.zip
opie-63541c46776721ef5ae63903e5b40838c1c49a43.tar.gz
opie-63541c46776721ef5ae63903e5b40838c1c49a43.tar.bz2
- merged scanForVideo and scanForAudio into a common scanFiles method in
the PlayListFileView. less duplicated code :)
Diffstat (limited to 'noncore/multimedia/opieplayer2/playlistwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp25
1 files changed, 5 insertions, 20 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 6bda71e..93e7919 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -4,111 +4,109 @@
              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <qpe/qpetoolbar.h>
#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>
#include "audiowidget.h"
#include "videowidget.h"
extern MediaPlayerState *mediaPlayerState;
// extern AudioWidget *audioUI;
// extern VideoWidget *videoUI;
-QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg";
-// no m3u's here please
-
PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name )
: PlayListWidgetGui( mediaPlayerState, parent, name ) {
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" ),
this,SLOT( scanForAudio() ) );
(void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ),
this,SLOT( scanForVideo() ) );
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",
d->selectedFiles, SLOT(moveSelectedUp() ) );
(void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut",
@@ -594,172 +592,159 @@ void PlayListWidget::tabChanged(QWidget *) {
tbDeletePlaylist->hide();
}
d->tbRemoveFromList->setEnabled(FALSE);
d->tbAddToList->setEnabled(TRUE);
}
break;
case PlayLists:
{
if( tbDeletePlaylist->isHidden() ) {
tbDeletePlaylist->show();
}
playLists->reread();
d->tbAddToList->setEnabled(FALSE);
d->tbPlay->setEnabled( false );
}
break;
};
}
void PlayListWidget::btnPlay(bool b) {
// mediaPlayerState->setPlaying(false);
mediaPlayerState.setPlaying(b);
insanityBool=FALSE;
}
void PlayListWidget::deletePlaylist() {
switch( QMessageBox::information( this, (tr("Remove Playlist?")),
(tr("You really want to delete\nthis playlist?")),
(tr("Yes")), (tr("No")), 0 )){
case 0: // Yes clicked,
QFile().remove(playLists->selectedDocument().file());
QFile().remove(playLists->selectedDocument().linkFile());
playLists->reread();
break;
case 1: // Cancel
break;
};
}
void PlayListWidget::playSelected() {
btnPlay( TRUE);
}
void PlayListWidget::scanForAudio() {
-// qDebug("scan for audio");
- files.detachChildren();
- QListIterator<DocLnk> sdit( files.children() );
- for ( ; sdit.current(); ++sdit ) {
- delete sdit.current();
- }
-// Global::findDocuments( &files, "audio/*");
- Global::findDocuments( &files, audioMimes);
+ audioView->scanFiles();
audioScan = true;
populateAudioView();
}
void PlayListWidget::scanForVideo() {
-// qDebug("scan for video");
- vFiles.detachChildren();
- QListIterator<DocLnk> sdit( vFiles.children() );
- for ( ; sdit.current(); ++sdit ) {
- delete sdit.current();
- }
- Global::findDocuments(&vFiles, "video/*");
+ videoView->scanFiles();
videoScan = true;
populateVideoView();
}
void PlayListWidget::populateAudioView() {
audioView->clear();
StorageInfo storageInfo;
// const QList<FileSystem> &fs = storageInfo.fileSystems();
if(!audioScan) {
scanForAudio();
}
- QListIterator<DocLnk> dit( files.children() );
+ QListIterator<DocLnk> dit( audioView->files().children() );
// QListIterator<FileSystem> it ( fs );
audioView->clear();
QString storage;
for ( ; dit.current(); ++dit ) {
// // for( ; it.current(); ++it ){
// const QString name = (*dit)->name();
// const QString path = (*dit)->path();
// if(dit.current()->file().find(path) != -1 ) {
// storage = name;
// // }
// }
QListViewItem * newItem;
if ( QFile( dit.current()->file()).exists() ||
dit.current()->file().left(4) == "http" ) {
long size;
if( dit.current()->file().left(4) == "http" )
size=0;
else
size = QFile( dit.current()->file() ).size();
newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
QString::number(size ), "" /*storage*/,
dit.current()->file() );
newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) );
// qDebug("<<<< "+dit.current()->file());
}
}
audioPopulated=true;
}
void PlayListWidget::populateVideoView() {
videoView->clear();
StorageInfo storageInfo;
// const QList<FileSystem> &fs = storageInfo.fileSystems();
if(!videoScan ) {
scanForVideo();
}
- QListIterator<DocLnk> Vdit( vFiles.children() );
+ QListIterator<DocLnk> Vdit( videoView->files().children() );
// QListIterator<FileSystem> it ( fs );
videoView->clear();
QString storage, pathName;
for ( ; Vdit.current(); ++Vdit ) {
// // for( ; it.current(); ++it ) {
// const QString name = (*Vdit)->name();
// const QString path = (*Vdit)->path();
// if( Vdit.current()->file().find(path) != -1 ) {
// storage=name;
// pathName=path;
// // }
// }
QListViewItem * newItem;
if ( QFile( Vdit.current()->file() ).exists() ) {
newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
QString::number( QFile( Vdit.current()->file() ).size() ),
""/*storage*/, Vdit.current()->file());
newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) );
}
}
videoPopulated=true;
}
QListView *PlayListWidget::currentFileListView() const
{
switch ( currentTab() ) {
case AudioFiles: return audioView;
case VideoFiles: return videoView;
default: assert( false );
}
return 0;
}
bool PlayListWidget::inFileListMode() const
{
TabType tab = currentTab();
return tab == AudioFiles || tab == VideoFiles;
}
void PlayListWidget::openFile() {
// http://66.28.164.33:2080
// http://somafm.com/star0242.m3u
QString filename, name;
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
fileDlg->exec();
if( fileDlg->result() == 1 ) {