summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2005-03-06 04:52:03 (UTC)
committer llornkcor <llornkcor>2005-03-06 04:52:03 (UTC)
commitb9360499c5f84ab53e080861e0292a70e446f5e4 (patch) (side-by-side diff)
tree97cbc739073f03296bd9dc39b4ada35f1123baad
parent7e44f77d3749db2f43a1313d835a06684ecc1cd6 (diff)
downloadopie-b9360499c5f84ab53e080861e0292a70e446f5e4.zip
opie-b9360499c5f84ab53e080861e0292a70e446f5e4.tar.gz
opie-b9360499c5f84ab53e080861e0292a70e446f5e4.tar.bz2
patches from Paul, human readable sizes and play button #1216
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
@@ -78,7 +78,9 @@ void PlayListFileView::populateView()
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 ) );
@@ -92,4 +94,13 @@ void PlayListFileView::checkSelection()
}
+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
@@ -26,4 +26,5 @@ private slots:
private:
+ void fileSize(unsigned long size, QString &str);
QString m_mimeTypePattern;
QString m_itemPixmapName;
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
@@ -181,4 +181,36 @@ void PlayListWidget::initializeStates() {
}
+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() {
@@ -221,4 +253,5 @@ void PlayListWidget::clearList() {
cfg.writeEntry("CurrentPlaylist","default");
setCaption("OpiePlayer");
+ setButtons();
}
@@ -285,4 +318,6 @@ void PlayListWidget::addAllToList() {
writeCurrentM3u();
d->selectedFiles->first();
+
+ setButtons();
}
@@ -306,4 +341,6 @@ void PlayListWidget::addAllMusicToList() {
writeCurrentM3u();
d->selectedFiles->first();
+
+ setButtons();
}
@@ -325,4 +362,6 @@ void PlayListWidget::addAllVideoToList() {
writeCurrentM3u();
d->selectedFiles->first();
+
+ setButtons();
}
@@ -477,4 +516,5 @@ void PlayListWidget::removeSelected() {
d->selectedFiles->removeSelected( );
writeCurrentM3u();
+ setButtons();
}
@@ -511,6 +551,4 @@ void PlayListWidget::addToSelection( QListViewItem *it) {
void PlayListWidget::tabChanged(QWidget *) {
- d->tbPlay->setEnabled( true );
-
disconnect( audioView, SIGNAL( itemsSelected(bool) ),
d->tbPlay, SLOT( setEnabled(bool) ) );
@@ -526,8 +564,6 @@ void PlayListWidget::tabChanged(QWidget *) {
tbDeletePlaylist->hide();
}
- d->tbRemoveFromList->setEnabled(TRUE);
d->tbAddToList->setEnabled(FALSE);
- d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() );
}
break;
@@ -539,5 +575,4 @@ void PlayListWidget::tabChanged(QWidget *) {
tbDeletePlaylist->hide();
}
- d->tbRemoveFromList->setEnabled(FALSE);
d->tbAddToList->setEnabled(TRUE);
@@ -545,6 +580,4 @@ void PlayListWidget::tabChanged(QWidget *) {
d->tbPlay, SLOT( setEnabled(bool) ) );
- d->tbPlay->setEnabled( audioView->hasSelection() );
-
currentFileListView = audioView;
}
@@ -556,5 +589,4 @@ void PlayListWidget::tabChanged(QWidget *) {
tbDeletePlaylist->hide();
}
- d->tbRemoveFromList->setEnabled(FALSE);
d->tbAddToList->setEnabled(TRUE);
@@ -562,6 +594,4 @@ void PlayListWidget::tabChanged(QWidget *) {
d->tbPlay, SLOT( setEnabled(bool) ) );
- d->tbPlay->setEnabled( videoView->hasSelection() );
-
currentFileListView = videoView;
}
@@ -575,8 +605,9 @@ void PlayListWidget::tabChanged(QWidget *) {
d->tbAddToList->setEnabled(FALSE);
- d->tbPlay->setEnabled( false );
}
break;
};
+
+ setButtons();
}
@@ -711,4 +742,6 @@ void PlayListWidget::openFile() {
d->selectedFiles->setSelectedItem( lnk.name() );
}
+
+ setButtons();
}
@@ -780,4 +813,5 @@ void PlayListWidget::readListFromFile( const QString &filename ) {
setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
+ setButtons();
}
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
@@ -133,4 +133,5 @@ private slots:
private:
DocLnk addFileToPlaylist(const QString& directory, const QString& name);
+ void setButtons(void);
bool fromSetDocument;
bool insanityBool;