1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-11 00:24:12 +02:00

* Hide empty / 0 values for bitrate, year, age, filesize.

This commit is contained in:
Christian Muehlhaeuser
2011-11-08 19:03:00 +01:00
parent 1fc3c4c2f2
commit b537a237a8
3 changed files with 26 additions and 11 deletions

View File

@@ -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:

View File

@@ -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() );

View File

@@ -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;