summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistfileview.cpp14
-rw-r--r--noncore/multimedia/opieplayer2/playlistfileview.h1
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp30
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.h3
4 files changed, 20 insertions, 28 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistfileview.cpp b/noncore/multimedia/opieplayer2/playlistfileview.cpp
index 0ed1061..cb16415 100644
--- a/noncore/multimedia/opieplayer2/playlistfileview.cpp
+++ b/noncore/multimedia/opieplayer2/playlistfileview.cpp
@@ -1,21 +1,22 @@
#include "playlistfileview.h"
#include <qfile.h>
#include <qpe/global.h>
#include <qpe/resource.h>
PlayListFileView::PlayListFileView( const QString &mimeTypePattern, const QString &itemPixmapName, QWidget *parent, const char *name )
- : PlayListView( parent, name ), m_mimeTypePattern( mimeTypePattern ), m_itemPixmapName( itemPixmapName ), m_scannedFiles( false )
+ : PlayListView( parent, name ), m_mimeTypePattern( mimeTypePattern ), m_itemPixmapName( itemPixmapName ), m_scannedFiles( false ),
+ m_viewPopulated( false )
{
addColumn( tr( "Title" ), 140);
addColumn( tr( "Size" ), -1 );
addColumn(tr( "Media" ), 0 );
addColumn(tr( "Path" ), -1 );
setColumnAlignment( 1, Qt::AlignRight );
setColumnAlignment( 2, Qt::AlignRight );
setAllColumnsShowFocus( TRUE );
setSorting( 3, TRUE );
setMultiSelection( TRUE );
setSelectionMode( QListView::Extended );
}
@@ -23,35 +24,46 @@ PlayListFileView::PlayListFileView( const QString &mimeTypePattern, const QStrin
PlayListFileView::~PlayListFileView()
{
}
void PlayListFileView::scanFiles()
{
m_files.detachChildren();
QListIterator<DocLnk> sdit( m_files.children() );
for ( ; sdit.current(); ++sdit )
delete sdit.current();
Global::findDocuments( &m_files, m_mimeTypePattern );
+
+ if ( m_viewPopulated ) {
+ m_viewPopulated = false;
+ populateView();
+ }
}
void PlayListFileView::populateView()
{
+ if ( m_viewPopulated )
+ return;
+
clear();
if( !m_scannedFiles ) {
+ m_viewPopulated = false; // avoid a recursion :)
scanFiles();
m_scannedFiles = true;
}
+ m_viewPopulated = true;
+
QString storage;
QListIterator<DocLnk> dit( m_files.children() );
for ( ; dit.current(); ++dit ) {
QListViewItem *newItem;
if ( QFile::exists( dit.current()->file() ) ||
dit.current()->file().left( 4 ) == "http" ) {
unsigned long size = QFile( dit.current()->file() ).size();
newItem = new QListViewItem( this, dit.current()->name(),
diff --git a/noncore/multimedia/opieplayer2/playlistfileview.h b/noncore/multimedia/opieplayer2/playlistfileview.h
index a00349e..448473e 100644
--- a/noncore/multimedia/opieplayer2/playlistfileview.h
+++ b/noncore/multimedia/opieplayer2/playlistfileview.h
@@ -17,17 +17,18 @@ public:
DocLnkSet &files() { return m_files; }
bool &scannedFiles() { return m_scannedFiles; }
public slots:
void scanFiles();
void populateView();
private:
QString m_mimeTypePattern;
QString m_itemPixmapName;
DocLnkSet m_files;
bool m_scannedFiles;
+ bool m_viewPopulated;
};
#endif // PLAYLISTFILEVIEW_H
/* vim: et sw=4 ts=4
*/
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 460a0bf..eb0606d 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -142,26 +142,24 @@ PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* par
connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ),
d->tbPlay, SLOT( setOn( bool ) ) );
connect( &mediaPlayerState, SIGNAL( loopingToggled( bool ) ),
d->tbLoop, SLOT( setOn( bool ) ) );
connect( &mediaPlayerState, SIGNAL( shuffledToggled( bool ) ),
d->tbShuffle, SLOT( setOn( bool ) ) );
connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ),
this, SLOT( playIt( QListViewItem *) ) );
connect ( gammaSlider, SIGNAL( valueChanged( int ) ),
&mediaPlayerState, SLOT( setVideoGamma( int ) ) );
// see which skins are installed
- audioPopulated=false;
- videoPopulated=false;
populateSkinsMenu();
initializeStates();
cfg.setGroup("PlayList");
QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
loadList(DocLnk( currentPlaylist ) );
}
PlayListWidget::~PlayListWidget() {
delete d;
}
@@ -245,41 +243,41 @@ void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoi
break;
}
}
void PlayListWidget::addAllToList() {
// QTime t;
// t.start();
if(!audioView->scannedFiles()) {
if(audioView->childCount() < 1)
- populateAudioView();
+ 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(!videoView->scannedFiles()) {
if(videoView->childCount() < 1)
- populateVideoView();
+ 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() )
@@ -305,25 +303,25 @@ void PlayListWidget::addAllToList() {
tabWidget->setCurrentPage(0);
writeCurrentM3u();
d->selectedFiles->first();
}
void PlayListWidget::addAllMusicToList() {
if(!audioView->scannedFiles()) {
if(audioView->childCount() < 1)
- populateAudioView();
+ 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);
}
@@ -338,25 +336,25 @@ void PlayListWidget::addAllMusicToList() {
}
*/
tabWidget->setCurrentPage(0);
writeCurrentM3u();
d->selectedFiles->first();
}
void PlayListWidget::addAllVideoToList() {
if(!videoView->scannedFiles()) {
if(videoView->childCount() < 1)
- populateVideoView();
+ 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);
}
@@ -563,38 +561,36 @@ void PlayListWidget::tabChanged(QWidget *) {
{
if( !tbDeletePlaylist->isHidden() ) {
tbDeletePlaylist->hide();
}
d->tbRemoveFromList->setEnabled(TRUE);
d->tbAddToList->setEnabled(FALSE);
d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() );
}
break;
case AudioFiles:
{
- // audioView->clear();
- if(!audioPopulated) populateAudioView();
+ audioView->populateView();
if( !tbDeletePlaylist->isHidden() ) {
tbDeletePlaylist->hide();
}
d->tbRemoveFromList->setEnabled(FALSE);
d->tbAddToList->setEnabled(TRUE);
}
break;
case VideoFiles:
{
- // videoView->clear();
- if(!videoPopulated) populateVideoView();
+ videoView->populateView();
if( !tbDeletePlaylist->isHidden() ) {
tbDeletePlaylist->hide();
}
d->tbRemoveFromList->setEnabled(FALSE);
d->tbAddToList->setEnabled(TRUE);
}
break;
case PlayLists:
{
if( tbDeletePlaylist->isHidden() ) {
tbDeletePlaylist->show();
}
@@ -627,42 +623,28 @@ void PlayListWidget::deletePlaylist() {
break;
};
}
void PlayListWidget::playSelected() {
btnPlay( TRUE);
}
void PlayListWidget::scanForAudio() {
audioView->scanFiles();
- audioView->scannedFiles() = true;
- populateAudioView();
}
void PlayListWidget::scanForVideo() {
videoView->scanFiles();
- videoView->scannedFiles() = true;
- populateVideoView();
-}
-
-void PlayListWidget::populateAudioView() {
- audioView->populateView();
- audioPopulated = true;
-}
-
-void PlayListWidget::populateVideoView() {
- videoView->populateView();
- videoPopulated=true;
}
QListView *PlayListWidget::currentFileListView() const
{
switch ( currentTab() ) {
case AudioFiles: return audioView;
case VideoFiles: return videoView;
default: assert( false );
}
return 0;
}
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h
index 58efd47..8c22f17 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.h
+++ b/noncore/multimedia/opieplayer2/playlistwidget.h
@@ -85,30 +85,27 @@ public slots:
bool next();
bool prev();
void writeDefaultPlaylist( );
QString currentFileListPathName() const;
protected:
void keyReleaseEvent( QKeyEvent *e);
signals:
void skinSelected();
private:
int defaultSkinIndex;
- bool 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();