summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-02 15:00:35 (UTC)
committer simon <simon>2002-12-02 15:00:35 (UTC)
commit77147a2001cf991e3581bcb2401143e20a3973d4 (patch) (side-by-side diff)
tree2f42819217f97431082a54459d6a7cfe76ea5702
parentf90e42128a496a0fb5a67c3148c30ef46092624b (diff)
downloadopie-77147a2001cf991e3581bcb2401143e20a3973d4.zip
opie-77147a2001cf991e3581bcb2401143e20a3973d4.tar.gz
opie-77147a2001cf991e3581bcb2401143e20a3973d4.tar.bz2
- simplified addSelected
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp58
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.h2
2 files changed, 24 insertions, 36 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 92da73b..c9ae225 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -513,87 +513,67 @@ bool PlayListWidget::last() {
void PlayListWidget::loadList( const DocLnk & lnk) {
QString name = lnk.name();
// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name);
if( name.length()>0) {
setCaption("OpiePlayer: "+name);
// qDebug("<<<<<<<<<<<<load list "+ lnk.file());
clearList();
readm3u(lnk.file());
tabWidget->setCurrentPage(0);
}
}
void PlayListWidget::setPlaylist( bool shown ) {
if ( shown ) {
d->playListFrame->show();
} else {
d->playListFrame->hide();
}
}
void PlayListWidget::addSelected() {
- qDebug("addSelected");
- DocLnk lnk;
- QString filename;
- switch (whichList()) {
+ assert( inFileListMode() );
- case 0: //playlist
- return;
- break;
- case 1: { //audio
- QListViewItemIterator it( audioView );
- for ( ; it.current(); ++it ) {
+ QListView *fileListView = currentFileListView();
+ QListViewItemIterator it( fileListView );
+ for ( ; it.current(); ++it )
if ( it.current()->isSelected() ) {
- filename=it.current()->text(3);
- lnk.setName( QFileInfo(filename).baseName() ); //sets name
- lnk.setFile( filename ); //sets file name
- d->selectedFiles->addToSelection( lnk);
-
- }
- }
- audioView->clearSelection();
- }
- break;
-
- case 2: { // video
- QListViewItemIterator it( videoView );
- for ( ; it.current(); ++it ) {
- if ( it.current()->isSelected() ) {
- filename=it.current()->text(3);
- lnk.setName( QFileInfo(filename).baseName() ); //sets name
- lnk.setFile( filename ); //sets file name
- d->selectedFiles->addToSelection( lnk);
+ 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 );
}
- }
- videoView->clearSelection();
- }
- break;
- };
- tabWidget->setCurrentPage(0);
- writeCurrentM3u();
+
+ fileListView->clearSelection();
+
+ tabWidget->setCurrentPage( 0 );
+ writeCurrentM3u();
}
void PlayListWidget::removeSelected() {
d->selectedFiles->removeSelected( );
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) {
switch ( whichList()) {
case 0: //playlist
return;
@@ -778,48 +758,54 @@ void PlayListWidget::populateVideoView() {
// // }
// }
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 ) {
filename = fileDlg->text();
qDebug( "Selected filename is " + filename );
// Om3u *m3uList;
DocLnk lnk;
Config cfg( "OpiePlayer" );
cfg.setGroup("PlayList");
if(filename.left(4) == "http") {
QString m3uFile, m3uFilePath;
if(filename.find(":",8,TRUE) != -1) { //found a port
m3uFile = filename.left( filename.find( ":",8,TRUE));
m3uFile = m3uFile.right( 7);
} else if(filename.left(4) == "http"){
m3uFile=filename;
m3uFile = m3uFile.right( m3uFile.length() - 7);
} else{
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h
index a608eae..238a75c 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.h
+++ b/noncore/multimedia/opieplayer2/playlistwidget.h
@@ -71,48 +71,50 @@ public:
int whichList() const;
TabType currentTab() const;
public slots:
bool first();
bool last();
bool next();
bool prev();
void writeDefaultPlaylist( );
QString currentFileListPathName() const;
protected:
void keyReleaseEvent( QKeyEvent *e);
private:
int defaultSkinIndex;
bool audioScan, videoScan, audioPopulated, videoPopulated;
void readm3u(const QString &);
void readPls(const QString &);
void initializeStates();
void populateAudioView();
void populateVideoView();
QListView *currentFileListView() const;
+ bool inFileListMode() const;
+
private slots:
void populateSkinsMenu();
void skinsMenuActivated(int);
void pmViewActivated(int);
void writem3u();
void writeCurrentM3u();
void scanForAudio();
void scanForVideo();
void openFile();
void setDocument( const QString& fileref );
void addToSelection( const DocLnk& ); // Add a media file to the playlist
void addToSelection( QListViewItem* ); // Add a media file to the playlist
void setPlaylist( bool ); // Show/Hide the playlist
void clearList();
void addAllToList();
void addAllMusicToList();
void addAllVideoToList();
void saveList(); // Save the playlist
void loadList( const DocLnk &); // Load a playlist
void playIt( QListViewItem *);
void btnPlay(bool);
void deletePlaylist();
void addSelected();
void removeSelected();