summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-05-31 00:24:18 (UTC)
committer llornkcor <llornkcor>2002-05-31 00:24:18 (UTC)
commit294fecd1c15c4940bdab8566e5afaee9f305abb6 (patch) (side-by-side diff)
tree47860d13c0aeffb0b9afad96d669d8935769fe7a
parent706841997a5d466f3b873ed79102e4abe0d745ae (diff)
downloadopie-294fecd1c15c4940bdab8566e5afaee9f305abb6.zip
opie-294fecd1c15c4940bdab8566e5afaee9f305abb6.tar.gz
opie-294fecd1c15c4940bdab8566e5afaee9f305abb6.tar.bz2
sped up startup time, and fixed segfault on exit
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/multimedia/opieplayer/mediaplayer.h2
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp68
-rw-r--r--core/multimedia/opieplayer/playlistwidget.h3
3 files changed, 52 insertions, 21 deletions
diff --git a/core/multimedia/opieplayer/mediaplayer.h b/core/multimedia/opieplayer/mediaplayer.h
index cf9daea..8f9a0ee 100644
--- a/core/multimedia/opieplayer/mediaplayer.h
+++ b/core/multimedia/opieplayer/mediaplayer.h
@@ -41,19 +41,19 @@ private slots:
void play();
void next();
void prev();
void startIncreasingVolume();
void startDecreasingVolume();
void stopChangingVolume();
+ void cleanUp();
protected:
void timerEvent( QTimerEvent *e );
void keyReleaseEvent( QKeyEvent *e);
void doBlank();
void doUnblank();
- void cleanUp();
private:
int volumeDirection;
const DocLnk *currentFile;
};
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 7a79be1..78c2822 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -29,13 +29,12 @@
#include <qpe/storage.h>
#include <qpe/applnk.h>
#include <qpe/config.h>
#include <qpe/global.h>
#include <qpe/resource.h>
-
#include <qaction.h>
#include <qcursor.h>
#include <qimage.h>
#include <qfile.h>
#include <qdir.h>
#include <qlayout.h>
@@ -128,12 +127,14 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
d = new PlayListWidgetPrivate;
d->setDocumentUsed = FALSE;
d->current = NULL;
fromSetDocument = FALSE;
insanityBool=FALSE;
+ audioScan = FALSE;
+ videoScan = FALSE;
// menuTimer = new QTimer( this ,"menu timer"),
// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) );
setBackgroundMode( PaletteButton );
setCaption( tr("OpiePlayer") );
@@ -178,12 +179,15 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
// pmPlayList->insertSeparator(-1);
new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
pmPlayList->insertSeparator(-1);
new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
+ pmPlayList->insertSeparator(-1);
+ new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) );
+ new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) );
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()) );
@@ -251,13 +255,13 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
connect( audioView, SIGNAL( returnPressed( QListViewItem *)),
this,SLOT( playIt( QListViewItem *)) );
// audioView
- populateAudioView();
+// populateAudioView();
// videowidget
QWidget *vTab;
vTab = new QWidget( tabWidget, "vTab" );
videoView = new QListView( vTab, "Videoview" );
videoView->setMinimumSize(233,260);
@@ -276,25 +280,24 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
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 *)) );
tabWidget->insertTab( vTab,tr("Video"));
-populateVideoView();
+// populateVideoView();
//playlists list
QWidget *LTab;
LTab = new QWidget( tabWidget, "LTab" );
playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy
- playLists->setMinimumSize(233,260);;
+ 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 *)) );
@@ -430,14 +433,12 @@ void PlayListWidget::addAllToList() {
for ( ; Adit.current(); ++Adit )
d->selectedFiles->addToSelection( **Adit );
}
void PlayListWidget::addAllMusicToList() {
-// DocLnkSet files;
-// Global::findDocuments(&files, "audio/*");
QListIterator<DocLnk> dit( files.children() );
for ( ; dit.current(); ++dit )
d->selectedFiles->addToSelection( **dit );
}
@@ -524,13 +525,12 @@ const DocLnk *PlayListWidget::current() { // this is fugly
}
}
break;
case 1://audio
{
qDebug("audioView");
-// Global::findDocuments(&files, "audio/*");
QListIterator<DocLnk> dit( files.children() );
for ( ; dit.current(); ++dit ) {
if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) {
qDebug("here");
insanityBool=TRUE;
return dit;
@@ -538,13 +538,12 @@ const DocLnk *PlayListWidget::current() { // this is fugly
}
}
break;
case 2: // video
{
qDebug("videoView");
-// Global::findDocuments(&vFiles, "video/*");
QListIterator<DocLnk> Vdit( vFiles.children() );
for ( ; Vdit.current(); ++Vdit ) {
if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) {
insanityBool=TRUE;
return Vdit;
}
@@ -800,20 +799,25 @@ void PlayListWidget::tabChanged(QWidget *widg) {
d->tbRemoveFromList->setEnabled(TRUE);
d->tbAddToList->setEnabled(FALSE);
}
break;
case 1:
{
+ audioView->clear();
+ populateAudioView();
+
if( !tbDeletePlaylist->isHidden())
tbDeletePlaylist->hide();
d->tbRemoveFromList->setEnabled(FALSE);
d->tbAddToList->setEnabled(TRUE);
}
break;
case 2:
{
+ videoView->clear();
+ populateVideoView();
if( !tbDeletePlaylist->isHidden())
tbDeletePlaylist->hide();
d->tbRemoveFromList->setEnabled(FALSE);
d->tbAddToList->setEnabled(TRUE);
}
break;
@@ -824,14 +828,12 @@ void PlayListWidget::tabChanged(QWidget *widg) {
playLists->reread();
}
break;
};
}
-
-
void PlayListWidget::btnPlay(bool b) {
// mediaPlayerState->setPlaying(b);
switch ( tabWidget->currentPageIndex()) {
case 0:
{
@@ -877,13 +879,12 @@ void PlayListWidget::deletePlaylist() {
QFile().remove(playLists->selected()->linkFile());
playLists->reread();
break;
case 1: // Cancel
break;
};
-
}
void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i)
{
switch (mouse) {
case 1:
@@ -971,44 +972,69 @@ void PlayListWidget::listDelete() {
// }
}
break;
};
}
+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/*");
+ audioScan = TRUE;
+}
+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/*");
+ videoScan = TRUE;
+}
+
void PlayListWidget::populateAudioView() {
-// if(files)
-// files.~DocLnkSet();
+
+ audioView->clear();
StorageInfo storageInfo;
const QList<FileSystem> &fs = storageInfo.fileSystems();
+ if(!audioScan) scanForAudio();
- Global::findDocuments(&files, "audio/*");
QListIterator<DocLnk> dit( files.children() );
QListIterator<FileSystem> it ( fs );
- audioView->clear();
+
QString storage;
for ( ; dit.current(); ++dit ) {
for( ; it.current(); ++it ){
const QString name = (*it)->name();
const QString path = (*it)->path();
if(dit.current()->file().find(path) != -1 ) storage=name;
}
QListViewItem * newItem;
if ( QFile( dit.current()->file()).exists() ) {
- newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage);
+// qDebug(dit.current()->name());
+ newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
+ QString::number( QFile( dit.current()->file()).size() ), storage);
newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" ));
}
}
}
void PlayListWidget::populateVideoView() {
+ videoView->clear();
StorageInfo storageInfo;
const QList<FileSystem> &fs = storageInfo.fileSystems();
- Global::findDocuments(&vFiles, "video/*");
+ if(!videoScan ) scanForVideo();
+
QListIterator<DocLnk> Vdit( vFiles.children() );
QListIterator<FileSystem> it ( fs );
videoView->clear();
QString storage;
for ( ; Vdit.current(); ++Vdit ) {
for( ; it.current(); ++it ){
@@ -1016,13 +1042,14 @@ void PlayListWidget::populateVideoView() {
const QString path = (*it)->path();
if( Vdit.current()->file().find(path) != -1 ) storage=name;
}
QListViewItem * newItem;
if ( QFile( Vdit.current()->file()).exists() ) {
- newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage);
+ newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
+ QString::number( QFile( Vdit.current()->file()).size() ), storage);
newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" ));
}
}
}
void PlayListWidget::openFile() {
@@ -1092,13 +1119,13 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
// case Key_P: //play
// qDebug("Play");
// playSelected();
// break;
case Key_Space:
qDebug("Play");
- playSelected();
+// playSelected(); puh
break;
case Key_1:
tabWidget->setCurrentPage(0);
break;
case Key_2:
tabWidget->setCurrentPage(1);
@@ -1230,6 +1257,7 @@ void PlayListWidget::readPls(const QString &filename) {
// qDebug("add "+name);
// d->selectedFiles->addToSelection( lnk);
}
i++;
}
}
+
diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h
index 778e3ee..6569f35 100644
--- a/core/multimedia/opieplayer/playlistwidget.h
+++ b/core/multimedia/opieplayer/playlistwidget.h
@@ -68,12 +68,13 @@ public slots:
protected:
/* void contentsMousePressEvent( QMouseEvent * e ); */
/* void contentsMouseReleaseEvent( QMouseEvent * e ); */
void keyReleaseEvent( QKeyEvent *e);
void keyPressEvent( QKeyEvent *e);
private:
+ bool audioScan, videoScan;
void doBlank();
void doUnblank();
void readm3u(const QString &);
void writem3u(const QString &);
void readPls(const QString &);
@@ -82,12 +83,14 @@ private:
void readConfig( Config& cfg );
void writeConfig( Config& cfg ) const;
PlayListWidgetPrivate *d; // Private implementation data
void populateAudioView();
void populateVideoView();
private slots:
+ 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 setActiveWindow(); // need to handle this to show the right view
void setPlaylist( bool ); // Show/Hide the playlist