diff --git a/src/libtomahawk/playlist/trackmodel.cpp b/src/libtomahawk/playlist/trackmodel.cpp index 57ec0ffe3..f67f27c74 100644 --- a/src/libtomahawk/playlist/trackmodel.cpp +++ b/src/libtomahawk/playlist/trackmodel.cpp @@ -185,18 +185,21 @@ TrackModel::data( const QModelIndex& index, int role ) const break; case Bitrate: - return query->results().first()->bitrate(); + if ( query->results().first()->bitrate() == 0 ) + return QString(); + else + return query->results().first()->bitrate(); break; case Age: - if ( query->results().first()->modificationTime() == 0 ) - return QString(); - else - return TomahawkUtils::ageToString( QDateTime::fromTime_t( query->results().first()->modificationTime() ) ); + return TomahawkUtils::ageToString( QDateTime::fromTime_t( query->results().first()->modificationTime() ) ); break; case Year: - return query->results().first()->year(); + if ( query->results().first()->year() == 0 ) + return QString(); + else + return query->results().first()->year(); break; case Filesize: diff --git a/src/libtomahawk/playlist/treemodel.cpp b/src/libtomahawk/playlist/treemodel.cpp index 3c9a445b0..7c3861a98 100644 --- a/src/libtomahawk/playlist/treemodel.cpp +++ b/src/libtomahawk/playlist/treemodel.cpp @@ -316,13 +316,19 @@ TreeModel::data( const QModelIndex& index, int role ) const return TomahawkUtils::timeToString( result->duration() ); case Bitrate: - return result->bitrate(); + if ( result->bitrate() == 0 ) + return QString(); + else + return result->bitrate(); case Age: return TomahawkUtils::ageToString( QDateTime::fromTime_t( result->modificationTime() ) ); case Year: - return result->year(); + if ( result->year() == 0 ) + return QString(); + else + return result->year(); case Filesize: return TomahawkUtils::filesizeToString( result->size() ); diff --git a/src/libtomahawk/utils/tomahawkutils.cpp b/src/libtomahawk/utils/tomahawkutils.cpp index c62a7d8e3..7f0b20fca 100644 --- a/src/libtomahawk/utils/tomahawkutils.cpp +++ b/src/libtomahawk/utils/tomahawkutils.cpp @@ -214,6 +214,9 @@ timeToString( int seconds ) QString ageToString( const QDateTime& time ) { + if ( time.toTime_t() == 0 ) + return QString(); + QDateTime now = QDateTime::currentDateTime(); int mins = time.secsTo( now ) / 60; @@ -276,6 +279,9 @@ ageToString( const QDateTime& time ) QString filesizeToString( unsigned int size ) { + if ( size == 0 ) + return QString(); + int kb = size / 1024; int mb = kb / 1024; @@ -556,7 +562,7 @@ proxyFactory( bool noMutexLocker ) // Don't lock if being called from nam() QMutex otherMutex; QMutexLocker locker( noMutexLocker ? &otherMutex : &s_namAccessMutex ); - + if ( s_threadProxyFactoryHash.contains( QThread::currentThread() ) ) return s_threadProxyFactoryHash[ QThread::currentThread() ]; @@ -606,7 +612,7 @@ setProxyFactory( NetworkProxyFactory* factory, bool noMutexLocker ) QNetworkAccessManager* -nam() +nam() { QMutexLocker locker( &s_namAccessMutex ); if ( s_threadNamHash.contains( QThread::currentThread() ) ) @@ -627,7 +633,7 @@ nam() newNam->setConfiguration( QNetworkConfiguration( mainNam->configuration() ) ); newNam->setNetworkAccessible( mainNam->networkAccessible() ); newNam->setProxyFactory( proxyFactory( true ) ); - + s_threadNamHash[ QThread::currentThread() ] = newNam; return newNam;