1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-07-31 11:20:22 +02: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() ) else if ( !entry->result().isNull() )
{ {
const result_ptr& result = entry->result(); 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; unsigned int albumpos = 0;
if ( !entry->query().isNull() ) if ( !entry->query().isNull() )
albumpos = entry->query()->albumpos(); albumpos = entry->query()->albumpos();
@@ -280,8 +286,9 @@ TreeModel::data( const QModelIndex& index, int role ) const
switch( index.column() ) switch( index.column() )
{ {
case Name: case Name:
return QString( "%1%2" ).arg( albumpos > 0 ? QString( "%1. ").arg( albumpos ) : QString() ) return QString( "%1%2%3" ).arg( discnumber > 0 ? QString( "%1." ).arg( discnumber ) : QString() )
.arg( result->track() ); .arg( albumpos > 0 ? QString( "%1. ").arg( albumpos ) : QString() )
.arg( result->track() );
case Duration: case Duration:
return TomahawkUtils::timeToString( result->duration() ); return TomahawkUtils::timeToString( result->duration() );
@@ -310,6 +317,9 @@ TreeModel::data( const QModelIndex& index, int role ) const
case AlbumPosition: case AlbumPosition:
return result->albumpos(); return result->albumpos();
case Composer:
return result->composer()->name();
default: default:
return QVariant(); return QVariant();
} }

View File

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

View File

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

View File

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