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
@@ -77,9 +77,11 @@ void PlayListFileView::populateView()
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 ) );
}
@@ -91,5 +93,14 @@ 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
@@ -25,6 +25,7 @@ private slots:
void checkSelection();
private:
+ void fileSize(unsigned long size, QString &str);
QString m_mimeTypePattern;
QString m_itemPixmapName;
DocLnkSet m_files;
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
@@ -180,6 +180,38 @@ void PlayListWidget::initializeStates() {
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" );
@@ -220,6 +252,7 @@ void PlayListWidget::clearList() {
cfg.setGroup("PlayList");
cfg.writeEntry("CurrentPlaylist","default");
setCaption("OpiePlayer");
+ setButtons();
}
void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
@@ -284,6 +317,8 @@ void PlayListWidget::addAllToList() {
writeCurrentM3u();
d->selectedFiles->first();
+
+ setButtons();
}
@@ -305,6 +340,8 @@ void PlayListWidget::addAllMusicToList() {
tabWidget->setCurrentPage(0);
writeCurrentM3u();
d->selectedFiles->first();
+
+ setButtons();
}
@@ -324,6 +361,8 @@ void PlayListWidget::addAllVideoToList() {
tabWidget->setCurrentPage(0);
writeCurrentM3u();
d->selectedFiles->first();
+
+ setButtons();
}
@@ -476,6 +515,7 @@ void PlayListWidget::addSelected() {
void PlayListWidget::removeSelected() {
d->selectedFiles->removeSelected( );
writeCurrentM3u();
+ setButtons();
}
@@ -510,8 +550,6 @@ 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) ),
@@ -525,10 +563,8 @@ 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:
@@ -538,14 +574,11 @@ void PlayListWidget::tabChanged(QWidget *) {
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;
@@ -555,14 +588,11 @@ void PlayListWidget::tabChanged(QWidget *) {
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;
@@ -574,10 +604,11 @@ void PlayListWidget::tabChanged(QWidget *) {
playLists->reread();
d->tbAddToList->setEnabled(FALSE);
- d->tbPlay->setEnabled( false );
}
break;
};
+
+ setButtons();
}
@@ -710,6 +741,8 @@ void PlayListWidget::openFile() {
DocLnk lnk = addFileToPlaylist( str, info.baseName() );
d->selectedFiles->setSelectedItem( lnk.name() );
}
+
+ setButtons();
}
void PlayListWidget::openDirectory() {
@@ -779,6 +812,7 @@ void PlayListWidget::readListFromFile( const QString &filename ) {
d->selectedFiles->setSelectedItem( s);
setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
+ setButtons();
}
// writes current playlist to current m3u file */
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
@@ -132,6 +132,7 @@ private slots:
private:
DocLnk addFileToPlaylist(const QString& directory, const QString& name);
+ void setButtons(void);
bool fromSetDocument;
bool insanityBool;
QString setDocFileRef, currentPlayList;