1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-17 19:37:09 +02:00

* Support showing tracks without an album tag in the TreeView.

This commit is contained in:
Christian Muehlhaeuser
2011-04-14 07:26:27 +02:00
parent f5219525b4
commit 3e05151008
4 changed files with 36 additions and 17 deletions

View File

@@ -44,10 +44,11 @@ DatabaseCommand_AllAlbums::execForArtist( DatabaseImpl* dbi )
QString sql = QString(
"SELECT DISTINCT album.id, album.name "
"FROM album, file, file_join "
"FROM file, file_join "
"LEFT OUTER JOIN album "
"ON file_join.album = album.id "
"WHERE file.id = file_join.file "
"AND file_join.album = album.id "
"AND album.artist = %1 "
"AND file_join.artist = %1 "
"%2 "
"%3 %4 %5"
).arg( m_artist->id() )
@@ -61,7 +62,14 @@ DatabaseCommand_AllAlbums::execForArtist( DatabaseImpl* dbi )
while( query.next() )
{
Tomahawk::album_ptr album = Tomahawk::Album::get( query.value( 0 ).toUInt(), query.value( 1 ).toString(), m_artist );
unsigned int albumId = query.value( 0 ).toUInt();
QString albumName;
if ( query.value( 0 ).isNull() )
{
albumName = tr( "Unknown" );
}
Tomahawk::album_ptr album = Tomahawk::Album::get( albumId, albumName, m_artist );
al << album;
}

View File

@@ -54,6 +54,12 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi )
if ( !m_collection.isNull() )
sourceToken = QString( "AND file.source %1" ).arg( m_collection->source()->isLocal() ? "IS NULL" : QString( "= %1" ).arg( m_collection->source()->id() ) );
if ( m_album && m_album->id() == 0 )
{
m_artist = m_album->artist().data();
m_album = 0;
}
QString sql = QString(
"SELECT file.id, artist.name, album.name, track.name, file.size, "
"file.duration, file.bitrate, file.url, file.source, file.mtime, file.mimetype, file_join.albumpos, artist.id, album.id, track.id "

View File

@@ -67,7 +67,6 @@ TreeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
else if ( !item->result().isNull() )
{
float opacity = item->result()->score();
opacity = qMax( (float)0.3, opacity );
QColor textColor = TomahawkUtils::alphaBlend( option.palette.color( QPalette::Foreground ), option.palette.color( QPalette::Background ), opacity );
@@ -77,9 +76,12 @@ TreeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
o.palette.setColor( QPalette::Text, textColor );
return QStyledItemDelegate::paint( painter, o, index );
}
else
return QStyledItemDelegate::paint( painter, option, index );
}
else
return;
if ( text.trimmed().isEmpty() )
text = tr( "Unknown" );
QStyleOptionViewItemV4 opt = option;
initStyleOption( &opt, QModelIndex() );

View File

@@ -96,8 +96,6 @@ TreeModel::canFetchMore( const QModelIndex& parent ) const
void
TreeModel::fetchMore( const QModelIndex& parent )
{
qDebug() << Q_FUNC_INFO;
TreeModelItem* parentItem = itemFromIndex( parent );
if ( !parentItem || parentItem->fetchingMore )
return;
@@ -105,16 +103,16 @@ TreeModel::fetchMore( const QModelIndex& parent )
parentItem->fetchingMore = true;
if ( !parentItem->artist().isNull() )
{
qDebug() << "Artist" << parentItem->artist()->name();
qDebug() << Q_FUNC_INFO << "Loading Artist:" << parentItem->artist()->name();
addAlbums( parentItem->artist(), parent );
}
else if ( !parentItem->album().isNull() )
{
qDebug() << "Artist" << parentItem->album()->name();
qDebug() << Q_FUNC_INFO << "Loading Album:" << parentItem->album()->name();
addTracks( parentItem->album(), parent );
}
else
qDebug() << "Something else";
Q_ASSERT( false );
}
@@ -183,8 +181,12 @@ TreeModel::data( const QModelIndex& index, int role ) const
{
return QSize( 128, 32 );
}
else if ( !entry->artist().isNull() )
{
return QSize( 128, 44 );
}
return QSize( 128, 44 );
return QSize( 128, 0 );
}
if ( role != Qt::DisplayRole ) // && role != Qt::ToolTipRole )
@@ -371,7 +373,6 @@ TreeModel::addTracks( const album_ptr& album, const QModelIndex& parent )
QList< QVariant > rows;
rows << parent.row();
rows << parent.parent().row();
cmd->setData( QVariant( rows ) );
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr>, QVariant ) ),
@@ -438,7 +439,6 @@ TreeModel::onArtistsAdded( const QList<Tomahawk::artist_ptr>& artists )
TreeModelItem* artistitem;
foreach( const artist_ptr& artist, artists )
{
qDebug() << artist->name();
artistitem = new TreeModelItem( artist, m_rootItem );
artistitem->cover = m_defaultCover;
artistitem->index = createIndex( m_rootItem->children.count() - 1, 0, artistitem );
@@ -470,7 +470,7 @@ TreeModel::onAlbumsAdded( const QList<Tomahawk::album_ptr>& albums, const QVaria
if ( crows.second > 0 )
emit beginInsertRows( parent, crows.first + 1, crows.second );
TreeModelItem* albumitem;
TreeModelItem* albumitem = 0;
foreach( const album_ptr& album, albums )
{
albumitem = new TreeModelItem( album, parentItem );
@@ -518,7 +518,7 @@ TreeModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const QVaria
if ( crows.second > 0 )
emit beginInsertRows( parent, crows.first + 1, crows.second );
TreeModelItem* item;
TreeModelItem* item = 0;
foreach( const query_ptr& query, tracks )
{
qDebug() << query->toString();
@@ -541,7 +541,9 @@ TreeModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const QVaria
void
TreeModel::infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomData customData )
{
Q_UNUSED( customData );
qDebug() << Q_FUNC_INFO;
if ( caller != s_tmInfoIdentifier || type != Tomahawk::InfoSystem::InfoAlbumCoverArt )
{
qDebug() << "Info of wrong type or not with our identifier";
@@ -578,6 +580,7 @@ TreeModel::infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType type,
void
TreeModel::infoSystemFinished( QString target )
{
Q_UNUSED( target );
qDebug() << Q_FUNC_INFO;
}