mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-18 11:51:44 +02:00
* Support showing tracks without an album tag in the TreeView.
This commit is contained in:
@@ -44,10 +44,11 @@ DatabaseCommand_AllAlbums::execForArtist( DatabaseImpl* dbi )
|
|||||||
|
|
||||||
QString sql = QString(
|
QString sql = QString(
|
||||||
"SELECT DISTINCT album.id, album.name "
|
"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 "
|
"WHERE file.id = file_join.file "
|
||||||
"AND file_join.album = album.id "
|
"AND file_join.artist = %1 "
|
||||||
"AND album.artist = %1 "
|
|
||||||
"%2 "
|
"%2 "
|
||||||
"%3 %4 %5"
|
"%3 %4 %5"
|
||||||
).arg( m_artist->id() )
|
).arg( m_artist->id() )
|
||||||
@@ -61,7 +62,14 @@ DatabaseCommand_AllAlbums::execForArtist( DatabaseImpl* dbi )
|
|||||||
|
|
||||||
while( query.next() )
|
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;
|
al << album;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -54,6 +54,12 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi )
|
|||||||
if ( !m_collection.isNull() )
|
if ( !m_collection.isNull() )
|
||||||
sourceToken = QString( "AND file.source %1" ).arg( m_collection->source()->isLocal() ? "IS NULL" : QString( "= %1" ).arg( m_collection->source()->id() ) );
|
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(
|
QString sql = QString(
|
||||||
"SELECT file.id, artist.name, album.name, track.name, file.size, "
|
"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 "
|
"file.duration, file.bitrate, file.url, file.source, file.mtime, file.mimetype, file_join.albumpos, artist.id, album.id, track.id "
|
||||||
|
@@ -67,7 +67,6 @@ TreeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
else if ( !item->result().isNull() )
|
else if ( !item->result().isNull() )
|
||||||
{
|
{
|
||||||
float opacity = item->result()->score();
|
float opacity = item->result()->score();
|
||||||
|
|
||||||
opacity = qMax( (float)0.3, opacity );
|
opacity = qMax( (float)0.3, opacity );
|
||||||
QColor textColor = TomahawkUtils::alphaBlend( option.palette.color( QPalette::Foreground ), option.palette.color( QPalette::Background ), 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 );
|
o.palette.setColor( QPalette::Text, textColor );
|
||||||
return QStyledItemDelegate::paint( painter, o, index );
|
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;
|
QStyleOptionViewItemV4 opt = option;
|
||||||
initStyleOption( &opt, QModelIndex() );
|
initStyleOption( &opt, QModelIndex() );
|
||||||
|
@@ -96,8 +96,6 @@ TreeModel::canFetchMore( const QModelIndex& parent ) const
|
|||||||
void
|
void
|
||||||
TreeModel::fetchMore( const QModelIndex& parent )
|
TreeModel::fetchMore( const QModelIndex& parent )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
|
|
||||||
TreeModelItem* parentItem = itemFromIndex( parent );
|
TreeModelItem* parentItem = itemFromIndex( parent );
|
||||||
if ( !parentItem || parentItem->fetchingMore )
|
if ( !parentItem || parentItem->fetchingMore )
|
||||||
return;
|
return;
|
||||||
@@ -105,16 +103,16 @@ TreeModel::fetchMore( const QModelIndex& parent )
|
|||||||
parentItem->fetchingMore = true;
|
parentItem->fetchingMore = true;
|
||||||
if ( !parentItem->artist().isNull() )
|
if ( !parentItem->artist().isNull() )
|
||||||
{
|
{
|
||||||
qDebug() << "Artist" << parentItem->artist()->name();
|
qDebug() << Q_FUNC_INFO << "Loading Artist:" << parentItem->artist()->name();
|
||||||
addAlbums( parentItem->artist(), parent );
|
addAlbums( parentItem->artist(), parent );
|
||||||
}
|
}
|
||||||
else if ( !parentItem->album().isNull() )
|
else if ( !parentItem->album().isNull() )
|
||||||
{
|
{
|
||||||
qDebug() << "Artist" << parentItem->album()->name();
|
qDebug() << Q_FUNC_INFO << "Loading Album:" << parentItem->album()->name();
|
||||||
addTracks( parentItem->album(), parent );
|
addTracks( parentItem->album(), parent );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
qDebug() << "Something else";
|
Q_ASSERT( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -183,8 +181,12 @@ TreeModel::data( const QModelIndex& index, int role ) const
|
|||||||
{
|
{
|
||||||
return QSize( 128, 32 );
|
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 )
|
if ( role != Qt::DisplayRole ) // && role != Qt::ToolTipRole )
|
||||||
@@ -371,7 +373,6 @@ TreeModel::addTracks( const album_ptr& album, const QModelIndex& parent )
|
|||||||
QList< QVariant > rows;
|
QList< QVariant > rows;
|
||||||
rows << parent.row();
|
rows << parent.row();
|
||||||
rows << parent.parent().row();
|
rows << parent.parent().row();
|
||||||
|
|
||||||
cmd->setData( QVariant( rows ) );
|
cmd->setData( QVariant( rows ) );
|
||||||
|
|
||||||
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr>, QVariant ) ),
|
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr>, QVariant ) ),
|
||||||
@@ -438,7 +439,6 @@ TreeModel::onArtistsAdded( const QList<Tomahawk::artist_ptr>& artists )
|
|||||||
TreeModelItem* artistitem;
|
TreeModelItem* artistitem;
|
||||||
foreach( const artist_ptr& artist, artists )
|
foreach( const artist_ptr& artist, artists )
|
||||||
{
|
{
|
||||||
qDebug() << artist->name();
|
|
||||||
artistitem = new TreeModelItem( artist, m_rootItem );
|
artistitem = new TreeModelItem( artist, m_rootItem );
|
||||||
artistitem->cover = m_defaultCover;
|
artistitem->cover = m_defaultCover;
|
||||||
artistitem->index = createIndex( m_rootItem->children.count() - 1, 0, artistitem );
|
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 )
|
if ( crows.second > 0 )
|
||||||
emit beginInsertRows( parent, crows.first + 1, crows.second );
|
emit beginInsertRows( parent, crows.first + 1, crows.second );
|
||||||
|
|
||||||
TreeModelItem* albumitem;
|
TreeModelItem* albumitem = 0;
|
||||||
foreach( const album_ptr& album, albums )
|
foreach( const album_ptr& album, albums )
|
||||||
{
|
{
|
||||||
albumitem = new TreeModelItem( album, parentItem );
|
albumitem = new TreeModelItem( album, parentItem );
|
||||||
@@ -518,7 +518,7 @@ TreeModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const QVaria
|
|||||||
if ( crows.second > 0 )
|
if ( crows.second > 0 )
|
||||||
emit beginInsertRows( parent, crows.first + 1, crows.second );
|
emit beginInsertRows( parent, crows.first + 1, crows.second );
|
||||||
|
|
||||||
TreeModelItem* item;
|
TreeModelItem* item = 0;
|
||||||
foreach( const query_ptr& query, tracks )
|
foreach( const query_ptr& query, tracks )
|
||||||
{
|
{
|
||||||
qDebug() << query->toString();
|
qDebug() << query->toString();
|
||||||
@@ -541,7 +541,9 @@ TreeModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const QVaria
|
|||||||
void
|
void
|
||||||
TreeModel::infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomData customData )
|
TreeModel::infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomData customData )
|
||||||
{
|
{
|
||||||
|
Q_UNUSED( customData );
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
|
||||||
if ( caller != s_tmInfoIdentifier || type != Tomahawk::InfoSystem::InfoAlbumCoverArt )
|
if ( caller != s_tmInfoIdentifier || type != Tomahawk::InfoSystem::InfoAlbumCoverArt )
|
||||||
{
|
{
|
||||||
qDebug() << "Info of wrong type or not with our identifier";
|
qDebug() << "Info of wrong type or not with our identifier";
|
||||||
@@ -578,6 +580,7 @@ TreeModel::infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType type,
|
|||||||
void
|
void
|
||||||
TreeModel::infoSystemFinished( QString target )
|
TreeModel::infoSystemFinished( QString target )
|
||||||
{
|
{
|
||||||
|
Q_UNUSED( target );
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user