Diffstat (limited to 'noncore/multimedia/opieplayer2/playlistfileview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistfileview.cpp | 13 |
1 files changed, 12 insertions, 1 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 @@ -72,24 +72,35 @@ void PlayListFileView::populateView() 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(); + 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 */ |