summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistfileview.cpp13
-rw-r--r--noncore/multimedia/opieplayer2/playlistfileview.h1
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp56
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.h1
4 files changed, 59 insertions, 12 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistfileview.cpp b/noncore/multimedia/opieplayer2/playlistfileview.cpp
index 3ef4d03..3094876 100644
--- a/noncore/multimedia/opieplayer2/playlistfileview.cpp
+++ b/noncore/multimedia/opieplayer2/playlistfileview.cpp
@@ -74,22 +74,33 @@ void PlayListFileView::populateView()
QListViewItem *newItem;
if ( QFile::exists( dit.current()->file() ) ||
dit.current()->file().left( 4 ) == "http" ) {
unsigned long size = QFile( dit.current()->file() ).size();
+ QString sizestr;
+ fileSize(size, sizestr);
newItem = new QListViewItem( this, dit.current()->name(),
- QString::number( size ), "" /*storage*/,
+ sizestr, "" /*storage*/,
dit.current()->file() );
newItem->setPixmap( 0, Resource::loadPixmap( m_itemPixmapName ) );
}
}
}
void PlayListFileView::checkSelection()
{
emit itemsSelected( hasSelection() );
}
+void PlayListFileView::fileSize(unsigned long size, QString &str) {
+ if( size > 1048576 )
+ str.sprintf( "%.0fM", size / 1048576.0 );
+ else if( size > 1024 )
+ str.sprintf( "%.0fK", size / 1024.0 );
+ else
+ str.sprintf( "%d", size );
+}
+
/* vim: et sw=4 ts=4
*/
diff --git a/noncore/multimedia/opieplayer2/playlistfileview.h b/noncore/multimedia/opieplayer2/playlistfileview.h
index 5b15526..d92f258 100644
--- a/noncore/multimedia/opieplayer2/playlistfileview.h
+++ b/noncore/multimedia/opieplayer2/playlistfileview.h
@@ -22,12 +22,13 @@ signals:
void itemsSelected( bool selected );
private slots:
void checkSelection();
private:
+ void fileSize(unsigned long size, QString &str);
QString m_mimeTypePattern;
QString m_itemPixmapName;
DocLnkSet m_files;
bool m_scannedFiles;
bool m_viewPopulated;
};
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 5f4159c..83eb83b 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -177,12 +177,44 @@ void PlayListWidget::initializeStates() {
d->tbPlay->setOn( mediaPlayerState->isPlaying() );
d->tbLoop->setOn( mediaPlayerState->isLooping() );
d->tbShuffle->setOn( mediaPlayerState->isShuffled() );
d->playListFrame->show();
}
+void PlayListWidget::setButtons(void) {
+ bool hasitem;
+
+ switch ( currentTab() ) {
+ case CurrentPlayList:
+ {
+ hasitem = !d->selectedFiles->isEmpty();
+ d->tbPlay->setEnabled( hasitem );
+ d->tbRemoveFromList->setEnabled( hasitem );
+ }
+ break;
+ case AudioFiles:
+ {
+ d->tbPlay->setEnabled( audioView->hasSelection() );
+ d->tbRemoveFromList->setEnabled( false );
+ }
+ break;
+ case VideoFiles:
+ {
+ d->tbPlay->setEnabled( videoView->hasSelection() );
+ d->tbRemoveFromList->setEnabled( false );
+ }
+ break;
+ case PlayLists:
+ {
+ d->tbPlay->setEnabled( false );
+ d->tbRemoveFromList->setEnabled( false );
+ }
+ break;
+ };
+}
+
void PlayListWidget::writeDefaultPlaylist() {
Config config( "OpiePlayer" );
config.setGroup( "PlayList" );
QString filename=QPEApplication::documentDir() + "/default.m3u";
QString currentString = config.readEntry( "CurrentPlaylist", filename);
@@ -217,12 +249,13 @@ void PlayListWidget::clearList() {
d->selectedFiles->removeSelected();
}
Config cfg( "OpiePlayer" );
cfg.setGroup("PlayList");
cfg.writeEntry("CurrentPlaylist","default");
setCaption("OpiePlayer");
+ setButtons();
}
void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
switch (mouse) {
case LeftButton:
break;
@@ -281,12 +314,14 @@ void PlayListWidget::addAllToList() {
}
tabWidget->setCurrentPage(0);
writeCurrentM3u();
d->selectedFiles->first();
+
+ setButtons();
}
void PlayListWidget::addAllMusicToList() {
audioView->populateView();
@@ -302,12 +337,14 @@ void PlayListWidget::addAllMusicToList() {
d->selectedFiles->addToSelection( lnk);
}
tabWidget->setCurrentPage(0);
writeCurrentM3u();
d->selectedFiles->first();
+
+ setButtons();
}
void PlayListWidget::addAllVideoToList() {
videoView->populateView();
@@ -321,12 +358,14 @@ void PlayListWidget::addAllVideoToList() {
lnk.setFile( filename ); //sets file name
d->selectedFiles->addToSelection( lnk);
}
tabWidget->setCurrentPage(0);
writeCurrentM3u();
d->selectedFiles->first();
+
+ setButtons();
}
void PlayListWidget::setDocument( const QString& _fileref ) {
// odebug << "<<<<<<<<set document>>>>>>>>>> "+fileref << oendl;
QString fileref = _fileref;
@@ -473,12 +512,13 @@ void PlayListWidget::addSelected() {
}
void PlayListWidget::removeSelected() {
d->selectedFiles->removeSelected( );
writeCurrentM3u();
+ setButtons();
}
void PlayListWidget::playIt( QListViewItem *it) {
if(!it) return;
mediaPlayerState->setPlaying(FALSE);
@@ -507,14 +547,12 @@ void PlayListWidget::addToSelection( QListViewItem *it) {
}
}
void PlayListWidget::tabChanged(QWidget *) {
- d->tbPlay->setEnabled( true );
-
disconnect( audioView, SIGNAL( itemsSelected(bool) ),
d->tbPlay, SLOT( setEnabled(bool) ) );
disconnect( videoView, SIGNAL( itemsSelected(bool) ),
d->tbPlay, SLOT( setEnabled(bool) ) );
currentFileListView = 0;
@@ -522,65 +560,58 @@ void PlayListWidget::tabChanged(QWidget *) {
switch ( currentTab() ) {
case CurrentPlayList:
{
if( !tbDeletePlaylist->isHidden() ) {
tbDeletePlaylist->hide();
}
- d->tbRemoveFromList->setEnabled(TRUE);
d->tbAddToList->setEnabled(FALSE);
- d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() );
}
break;
case AudioFiles:
{
audioView->populateView();
if( !tbDeletePlaylist->isHidden() ) {
tbDeletePlaylist->hide();
}
- d->tbRemoveFromList->setEnabled(FALSE);
d->tbAddToList->setEnabled(TRUE);
connect( audioView, SIGNAL( itemsSelected(bool) ),
d->tbPlay, SLOT( setEnabled(bool) ) );
- d->tbPlay->setEnabled( audioView->hasSelection() );
-
currentFileListView = audioView;
}
break;
case VideoFiles:
{
videoView->populateView();
if( !tbDeletePlaylist->isHidden() ) {
tbDeletePlaylist->hide();
}
- d->tbRemoveFromList->setEnabled(FALSE);
d->tbAddToList->setEnabled(TRUE);
connect( videoView, SIGNAL( itemsSelected(bool) ),
d->tbPlay, SLOT( setEnabled(bool) ) );
- d->tbPlay->setEnabled( videoView->hasSelection() );
-
currentFileListView = videoView;
}
break;
case PlayLists:
{
if( tbDeletePlaylist->isHidden() ) {
tbDeletePlaylist->show();
}
playLists->reread();
d->tbAddToList->setEnabled(FALSE);
- d->tbPlay->setEnabled( false );
}
break;
};
+
+ setButtons();
}
void PlayListWidget::btnPlay(bool b) {
// mediaPlayerState->setPlaying(false);
mediaPlayerState->setPlaying(b);
@@ -707,12 +738,14 @@ void PlayListWidget::openFile() {
readListFromFile( str );
} else {
QFileInfo info( str );
DocLnk lnk = addFileToPlaylist( str, info.baseName() );
d->selectedFiles->setSelectedItem( lnk.name() );
}
+
+ setButtons();
}
void PlayListWidget::openDirectory() {
QString str = OFileDialog::getDirectory( OFileSelector::DirectorySelector,
QString::null, 0,
tr( "Add Files from Directory"));
@@ -776,12 +809,13 @@ void PlayListWidget::readListFromFile( const QString &filename ) {
m3uList->close();
delete m3uList;
d->selectedFiles->setSelectedItem( s);
setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
+ setButtons();
}
// writes current playlist to current m3u file */
void PlayListWidget::writeCurrentM3u() {
odebug << "writing to current m3u" << oendl;
Config cfg( "OpiePlayer" );
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h
index 1f5ba92..7db0029 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.h
+++ b/noncore/multimedia/opieplayer2/playlistwidget.h
@@ -129,12 +129,13 @@ private slots:
void viewPressed( int, QListViewItem *, const QPoint&, int);
void playlistViewPressed( int, QListViewItem *, const QPoint&, int);
void playSelected();
private:
DocLnk addFileToPlaylist(const QString& directory, const QString& name);
+ void setButtons(void);
bool fromSetDocument;
bool insanityBool;
QString setDocFileRef, currentPlayList;
int selected;
QListView *currentFileListView;