1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-18 23:09:42 +01:00

Fixed bug with null discnumbers and added discnumbers to view.

Fix bug in the taghandlers where a discnumber polluted null entries in
the database.
Also made the tree model so that the discnumber appears before the track
number if it's defined.
This commit is contained in:
Teo Mrnjavac 2011-11-18 15:53:27 +01:00 committed by Dominik Schmidt
parent 4e59f1dc12
commit 47e9f27199
4 changed files with 16 additions and 4 deletions

View File

@ -271,6 +271,12 @@ TreeModel::data( const QModelIndex& index, int role ) const
else if ( !entry->result().isNull() )
{
const result_ptr& result = entry->result();
unsigned int discnumber = 0;
if( !entry->query().isNull() )
discnumber = entry->query()->discnumber();
if( discnumber == 0 )
discnumber = result->discnumber();
unsigned int albumpos = 0;
if ( !entry->query().isNull() )
albumpos = entry->query()->albumpos();
@ -280,8 +286,9 @@ TreeModel::data( const QModelIndex& index, int role ) const
switch( index.column() )
{
case Name:
return QString( "%1%2" ).arg( albumpos > 0 ? QString( "%1. ").arg( albumpos ) : QString() )
.arg( result->track() );
return QString( "%1%2%3" ).arg( discnumber > 0 ? QString( "%1." ).arg( discnumber ) : QString() )
.arg( albumpos > 0 ? QString( "%1. ").arg( albumpos ) : QString() )
.arg( result->track() );
case Duration:
return TomahawkUtils::timeToString( result->duration() );
@ -310,6 +317,9 @@ TreeModel::data( const QModelIndex& index, int role ) const
case AlbumPosition:
return result->albumpos();
case Composer:
return result->composer()->name();
default:
return QVariant();
}

View File

@ -50,7 +50,8 @@ public:
Year,
Filesize,
Origin,
AlbumPosition
AlbumPosition,
Composer
};
enum ColumnStyle

View File

@ -116,6 +116,7 @@ Query::init()
m_playable = false;
m_duration = -1;
m_albumpos = 0;
m_discnumber = 0;
updateSortNames();
}

View File

@ -57,7 +57,7 @@ public:
//TODO: add support for writing those 3 items with TagLib's addField/setField
protected:
Tag( TagLib::Tag *tag ) : m_tag( tag ) {}
Tag( TagLib::Tag *tag ) : m_tag( tag ), m_discNumber( 0 ) {}
unsigned int processDiscNumber( const QString & ) const;