mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
* Moved cover / image retrieval into Artist & Album classes. Huge model / view cleanup.
This commit is contained in:
@@ -103,6 +103,8 @@ AudioControls::AudioControls( QWidget* parent )
|
|||||||
m_sliderTimeLine.setCurveShape( QTimeLine::LinearCurve );
|
m_sliderTimeLine.setCurveShape( QTimeLine::LinearCurve );
|
||||||
ui->seekSlider->setTimeLine( &m_sliderTimeLine );
|
ui->seekSlider->setTimeLine( &m_sliderTimeLine );
|
||||||
|
|
||||||
|
m_defaultCover = QPixmap( RESPATH "images/no-album-no-case.png" ).scaled( ui->coverImage->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
|
||||||
|
|
||||||
connect( &m_phononTickCheckTimer, SIGNAL( timeout() ), SLOT( phononTickCheckTimeout() ) );
|
connect( &m_phononTickCheckTimer, SIGNAL( timeout() ), SLOT( phononTickCheckTimeout() ) );
|
||||||
connect( &m_sliderTimeLine, SIGNAL( frameChanged( int ) ), ui->seekSlider, SLOT( setValue( int ) ) );
|
connect( &m_sliderTimeLine, SIGNAL( frameChanged( int ) ), ui->seekSlider, SLOT( setValue( int ) ) );
|
||||||
|
|
||||||
@@ -136,15 +138,6 @@ AudioControls::AudioControls( QWidget* parent )
|
|||||||
connect( AudioEngine::instance(), SIGNAL( timerMilliSeconds( qint64 ) ), SLOT( onPlaybackTimer( qint64 ) ) );
|
connect( AudioEngine::instance(), SIGNAL( timerMilliSeconds( qint64 ) ), SLOT( onPlaybackTimer( qint64 ) ) );
|
||||||
connect( AudioEngine::instance(), SIGNAL( volumeChanged( int ) ), SLOT( onVolumeChanged( int ) ) );
|
connect( AudioEngine::instance(), SIGNAL( volumeChanged( int ) ), SLOT( onVolumeChanged( int ) ) );
|
||||||
|
|
||||||
m_defaultCover = QPixmap( RESPATH "images/no-album-no-case.png" )
|
|
||||||
.scaled( ui->coverImage->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
|
|
||||||
|
|
||||||
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
|
|
||||||
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
|
||||||
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
|
|
||||||
|
|
||||||
connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
|
|
||||||
|
|
||||||
ui->buttonAreaLayout->setSpacing( 0 );
|
ui->buttonAreaLayout->setSpacing( 0 );
|
||||||
ui->stackedLayout->setSpacing( 0 );
|
ui->stackedLayout->setSpacing( 0 );
|
||||||
ui->stackedLayout->setContentsMargins( 0, 0, 0, 0 );
|
ui->stackedLayout->setContentsMargins( 0, 0, 0, 0 );
|
||||||
@@ -198,8 +191,6 @@ AudioControls::onVolumeChanged( int volume )
|
|||||||
void
|
void
|
||||||
AudioControls::onPlaybackStarted( const Tomahawk::result_ptr& result )
|
AudioControls::onPlaybackStarted( const Tomahawk::result_ptr& result )
|
||||||
{
|
{
|
||||||
tDebug( LOGEXTRA ) << Q_FUNC_INFO;
|
|
||||||
|
|
||||||
if ( result.isNull() )
|
if ( result.isNull() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -226,86 +217,62 @@ AudioControls::onPlaybackStarted( const Tomahawk::result_ptr& result )
|
|||||||
|
|
||||||
m_noTimeChange = false;
|
m_noTimeChange = false;
|
||||||
m_lastSliderCheck = 0;
|
m_lastSliderCheck = 0;
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoStringHash trackInfo;
|
|
||||||
trackInfo["artist"] = result->artist()->name();
|
|
||||||
trackInfo["album"] = result->album()->name();
|
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoRequestData requestData;
|
|
||||||
requestData.caller = s_acInfoIdentifier;
|
|
||||||
requestData.type = Tomahawk::InfoSystem::InfoAlbumCoverArt;
|
|
||||||
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo );
|
|
||||||
requestData.customData = QVariantMap();
|
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
AudioControls::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
|
|
||||||
{
|
|
||||||
if ( requestData.caller != s_acInfoIdentifier || requestData.type != Tomahawk::InfoSystem::InfoAlbumCoverArt )
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( m_currentTrack.isNull() )
|
|
||||||
{
|
|
||||||
tLog() << "Current track is null when trying to apply fetched cover art";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !output.canConvert< QVariantMap >() )
|
|
||||||
{
|
|
||||||
tDebug( LOGINFO ) << "Cannot convert fetched art from a QByteArray";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariantMap returnedData = output.value< QVariantMap >();
|
|
||||||
const QByteArray ba = returnedData["imgbytes"].toByteArray();
|
|
||||||
if ( ba.length() )
|
|
||||||
{
|
|
||||||
QPixmap pm;
|
|
||||||
pm.loadFromData( ba );
|
|
||||||
|
|
||||||
if ( pm.isNull() )
|
|
||||||
ui->coverImage->setPixmap( m_defaultCover );
|
|
||||||
else
|
|
||||||
ui->coverImage->setPixmap( pm.scaled( ui->coverImage->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
AudioControls::infoSystemFinished( QString target )
|
|
||||||
{
|
|
||||||
Q_UNUSED( target );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AudioControls::onPlaybackLoading( const Tomahawk::result_ptr& result )
|
AudioControls::onPlaybackLoading( const Tomahawk::result_ptr& result )
|
||||||
{
|
{
|
||||||
tDebug( LOGEXTRA ) << Q_FUNC_INFO;
|
if ( !m_currentTrack.isNull() )
|
||||||
|
{
|
||||||
|
disconnect( m_currentTrack->album().data(), SIGNAL( updated() ), this, SLOT( onAlbumCoverUpdated() ) );
|
||||||
|
disconnect( m_currentTrack.data(), SIGNAL( socialActionsLoaded() ), this, SLOT( socialActionsLoaded() ) );
|
||||||
|
}
|
||||||
|
|
||||||
m_currentTrack = result;
|
m_currentTrack = result;
|
||||||
|
connect( m_currentTrack->album().data(), SIGNAL( updated() ), SLOT( onAlbumCoverUpdated() ) );
|
||||||
|
connect( m_currentTrack.data(), SIGNAL( socialActionsLoaded() ), SLOT( socialActionsLoaded() ) );
|
||||||
|
|
||||||
ui->artistTrackLabel->setResult( result );
|
ui->artistTrackLabel->setResult( result );
|
||||||
ui->albumLabel->setResult( result );
|
ui->albumLabel->setResult( result );
|
||||||
ui->ownerLabel->setText( result->friendlySource() );
|
ui->ownerLabel->setText( result->friendlySource() );
|
||||||
ui->coverImage->setPixmap( m_defaultCover );
|
|
||||||
|
|
||||||
|
const QString duration = TomahawkUtils::timeToString( result.data()->duration() );
|
||||||
|
ui->timeLabel->setFixedWidth( ui->timeLabel->fontMetrics().width( QString( duration.length(), QChar( '0' ) ) ) );
|
||||||
ui->timeLabel->setText( TomahawkUtils::timeToString( 0 ) );
|
ui->timeLabel->setText( TomahawkUtils::timeToString( 0 ) );
|
||||||
ui->timeLeftLabel->setText( "-" + TomahawkUtils::timeToString( result.data()->duration() ) );
|
ui->timeLeftLabel->setFixedWidth( ui->timeLeftLabel->fontMetrics().width( QString( duration.length() + 1, QChar( '0' ) ) ) );
|
||||||
|
ui->timeLeftLabel->setText( "-" + duration );
|
||||||
|
|
||||||
ui->stackedLayout->setCurrentWidget( ui->pauseButton );
|
ui->stackedLayout->setCurrentWidget( ui->pauseButton );
|
||||||
|
|
||||||
ui->loveButton->setEnabled( true );
|
ui->loveButton->setEnabled( true );
|
||||||
ui->loveButton->setVisible( true );
|
ui->loveButton->setVisible( true );
|
||||||
|
|
||||||
|
setAlbumCover();
|
||||||
result->loadSocialActions();
|
result->loadSocialActions();
|
||||||
|
}
|
||||||
|
|
||||||
connect( result.data(), SIGNAL( socialActionsLoaded() ), SLOT( socialActionsLoaded() ) );
|
|
||||||
|
void
|
||||||
|
AudioControls::onAlbumCoverUpdated()
|
||||||
|
{
|
||||||
|
Album* album = qobject_cast< Album* >( sender() );
|
||||||
|
if ( !album || album != m_currentTrack->album().data() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
setAlbumCover();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AudioControls::setAlbumCover()
|
||||||
|
{
|
||||||
|
if ( !m_currentTrack->album()->cover().isNull() )
|
||||||
|
{
|
||||||
|
ui->coverImage->setPixmap( QPixmap::fromImage( m_currentTrack->album()->cover() ).scaled( ui->coverImage->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ui->coverImage->setPixmap( m_defaultCover );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -25,7 +25,6 @@
|
|||||||
|
|
||||||
#include "result.h"
|
#include "result.h"
|
||||||
#include "playlistinterface.h"
|
#include "playlistinterface.h"
|
||||||
#include "infosystem/infosystem.h"
|
|
||||||
#include "query.h"
|
#include "query.h"
|
||||||
|
|
||||||
class QDropEvent;
|
class QDropEvent;
|
||||||
@@ -80,14 +79,15 @@ private slots:
|
|||||||
void onTrackClicked();
|
void onTrackClicked();
|
||||||
void onLoveButtonClicked( bool );
|
void onLoveButtonClicked( bool );
|
||||||
|
|
||||||
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
void onAlbumCoverUpdated();
|
||||||
void infoSystemFinished( QString target );
|
|
||||||
|
|
||||||
void droppedTracks( QList<Tomahawk::query_ptr> );
|
void droppedTracks( QList<Tomahawk::query_ptr> );
|
||||||
|
|
||||||
void socialActionsLoaded();
|
void socialActionsLoaded();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void setAlbumCover();
|
||||||
|
|
||||||
Ui::AudioControls *ui;
|
Ui::AudioControls *ui;
|
||||||
|
|
||||||
QPixmap m_defaultCover;
|
QPixmap m_defaultCover;
|
||||||
|
@@ -345,6 +345,9 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Time</string>
|
<string>Time</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@@ -371,6 +374,9 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Time Left</string>
|
<string>Time Left</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@@ -29,8 +29,11 @@
|
|||||||
|
|
||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
Album::Album() {}
|
|
||||||
Album::~Album() {}
|
Album::~Album()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
album_ptr
|
album_ptr
|
||||||
Album::get( const Tomahawk::artist_ptr& artist, const QString& name, bool autoCreate )
|
Album::get( const Tomahawk::artist_ptr& artist, const QString& name, bool autoCreate )
|
||||||
@@ -68,15 +71,17 @@ Album::Album( unsigned int id, const QString& name, const Tomahawk::artist_ptr&
|
|||||||
, m_id( id )
|
, m_id( id )
|
||||||
, m_name( name )
|
, m_name( name )
|
||||||
, m_artist( artist )
|
, m_artist( artist )
|
||||||
|
, m_infoLoaded( false )
|
||||||
{
|
{
|
||||||
|
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
|
||||||
|
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
||||||
|
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Album::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks )
|
Album::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
|
|
||||||
Tomahawk::AlbumPlaylistInterface* api = dynamic_cast< Tomahawk::AlbumPlaylistInterface* >( playlistInterface().data() );
|
Tomahawk::AlbumPlaylistInterface* api = dynamic_cast< Tomahawk::AlbumPlaylistInterface* >( playlistInterface().data() );
|
||||||
if ( api )
|
if ( api )
|
||||||
api->addQueries( tracks );
|
api->addQueries( tracks );
|
||||||
@@ -92,6 +97,54 @@ Album::artist() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QImage
|
||||||
|
Album::cover() const
|
||||||
|
{
|
||||||
|
if ( !m_infoLoaded )
|
||||||
|
{
|
||||||
|
m_uuid = uuid();
|
||||||
|
|
||||||
|
Tomahawk::InfoSystem::InfoStringHash trackInfo;
|
||||||
|
trackInfo["artist"] = artist()->name();
|
||||||
|
trackInfo["album"] = name();
|
||||||
|
|
||||||
|
Tomahawk::InfoSystem::InfoRequestData requestData;
|
||||||
|
requestData.caller = m_uuid;
|
||||||
|
requestData.type = Tomahawk::InfoSystem::InfoAlbumCoverArt;
|
||||||
|
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo );
|
||||||
|
requestData.customData = QVariantMap();
|
||||||
|
|
||||||
|
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_cover;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Album::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
|
||||||
|
{
|
||||||
|
if ( requestData.caller != m_uuid ||
|
||||||
|
requestData.type != Tomahawk::InfoSystem::InfoAlbumCoverArt )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_infoLoaded = true;
|
||||||
|
if ( !output.isNull() && output.isValid() )
|
||||||
|
{
|
||||||
|
QVariantMap returnedData = output.value< QVariantMap >();
|
||||||
|
const QByteArray ba = returnedData["imgbytes"].toByteArray();
|
||||||
|
if ( ba.length() )
|
||||||
|
{
|
||||||
|
m_cover.loadFromData( ba );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
emit updated();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Tomahawk::playlistinterface_ptr
|
Tomahawk::playlistinterface_ptr
|
||||||
Album::playlistInterface()
|
Album::playlistInterface()
|
||||||
{
|
{
|
||||||
|
@@ -21,10 +21,12 @@
|
|||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtCore/QSharedPointer>
|
#include <QtCore/QSharedPointer>
|
||||||
|
#include <QImage>
|
||||||
|
|
||||||
#include "typedefs.h"
|
#include "typedefs.h"
|
||||||
#include "playlistinterface.h"
|
#include "playlistinterface.h"
|
||||||
#include "dllmacro.h"
|
#include "dllmacro.h"
|
||||||
|
#include "infosystem/infosystem.h"
|
||||||
|
|
||||||
namespace Tomahawk
|
namespace Tomahawk
|
||||||
{
|
{
|
||||||
@@ -43,23 +45,29 @@ public:
|
|||||||
unsigned int id() const { return m_id; }
|
unsigned int id() const { return m_id; }
|
||||||
QString name() const { return m_name; }
|
QString name() const { return m_name; }
|
||||||
artist_ptr artist() const;
|
artist_ptr artist() const;
|
||||||
|
QImage cover() const;
|
||||||
|
bool infoLoaded() const { return m_infoLoaded; }
|
||||||
|
|
||||||
Tomahawk::playlistinterface_ptr playlistInterface();
|
Tomahawk::playlistinterface_ptr playlistInterface();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void tracksAdded( const QList<Tomahawk::query_ptr>& tracks );
|
void tracksAdded( const QList<Tomahawk::query_ptr>& tracks );
|
||||||
|
void updated();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks );
|
void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks );
|
||||||
|
|
||||||
|
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY( Album )
|
Q_DISABLE_COPY( Album )
|
||||||
explicit Album();
|
|
||||||
|
|
||||||
unsigned int m_id;
|
unsigned int m_id;
|
||||||
QString m_name;
|
QString m_name;
|
||||||
|
|
||||||
artist_ptr m_artist;
|
artist_ptr m_artist;
|
||||||
|
QImage m_cover;
|
||||||
|
bool m_infoLoaded;
|
||||||
|
mutable QString m_uuid;
|
||||||
|
|
||||||
Tomahawk::playlistinterface_ptr m_playlistInterface;
|
Tomahawk::playlistinterface_ptr m_playlistInterface;
|
||||||
};
|
};
|
||||||
|
@@ -29,11 +29,6 @@
|
|||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
|
|
||||||
Artist::Artist()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Artist::~Artist()
|
Artist::~Artist()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -74,22 +69,73 @@ Artist::Artist( unsigned int id, const QString& name )
|
|||||||
: QObject()
|
: QObject()
|
||||||
, m_id( id )
|
, m_id( id )
|
||||||
, m_name( name )
|
, m_name( name )
|
||||||
|
, m_infoLoaded( false )
|
||||||
{
|
{
|
||||||
m_sortname = DatabaseImpl::sortname( name, true );
|
m_sortname = DatabaseImpl::sortname( name, true );
|
||||||
|
|
||||||
|
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
|
||||||
|
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
||||||
|
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Artist::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks )
|
Artist::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
|
|
||||||
Tomahawk::ArtistPlaylistInterface* api = dynamic_cast< Tomahawk::ArtistPlaylistInterface* >( playlistInterface().data() );
|
Tomahawk::ArtistPlaylistInterface* api = dynamic_cast< Tomahawk::ArtistPlaylistInterface* >( playlistInterface().data() );
|
||||||
if ( api )
|
if ( api )
|
||||||
api->addQueries( tracks );
|
api->addQueries( tracks );
|
||||||
emit tracksAdded( tracks );
|
emit tracksAdded( tracks );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QImage
|
||||||
|
Artist::cover() const
|
||||||
|
{
|
||||||
|
if ( !m_infoLoaded )
|
||||||
|
{
|
||||||
|
m_uuid = uuid();
|
||||||
|
|
||||||
|
Tomahawk::InfoSystem::InfoStringHash trackInfo;
|
||||||
|
trackInfo["artist"] = name();
|
||||||
|
|
||||||
|
Tomahawk::InfoSystem::InfoRequestData requestData;
|
||||||
|
requestData.caller = m_uuid;
|
||||||
|
requestData.type = Tomahawk::InfoSystem::InfoArtistImages;
|
||||||
|
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo );
|
||||||
|
requestData.customData = QVariantMap();
|
||||||
|
|
||||||
|
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_cover;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Artist::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
|
||||||
|
{
|
||||||
|
if ( requestData.caller != m_uuid ||
|
||||||
|
requestData.type != Tomahawk::InfoSystem::InfoArtistImages )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_infoLoaded = true;
|
||||||
|
if ( !output.isNull() && output.isValid() )
|
||||||
|
{
|
||||||
|
QVariantMap returnedData = output.value< QVariantMap >();
|
||||||
|
const QByteArray ba = returnedData["imgbytes"].toByteArray();
|
||||||
|
if ( ba.length() )
|
||||||
|
{
|
||||||
|
m_cover.loadFromData( ba );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
emit updated();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Tomahawk::playlistinterface_ptr
|
Tomahawk::playlistinterface_ptr
|
||||||
Artist::playlistInterface()
|
Artist::playlistInterface()
|
||||||
{
|
{
|
||||||
|
@@ -21,9 +21,11 @@
|
|||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtCore/QSharedPointer>
|
#include <QtCore/QSharedPointer>
|
||||||
|
#include <QImage>
|
||||||
|
|
||||||
#include "typedefs.h"
|
#include "typedefs.h"
|
||||||
#include "dllmacro.h"
|
#include "dllmacro.h"
|
||||||
|
#include "infosystem/infosystem.h"
|
||||||
|
|
||||||
namespace Tomahawk
|
namespace Tomahawk
|
||||||
{
|
{
|
||||||
@@ -35,29 +37,36 @@ Q_OBJECT
|
|||||||
public:
|
public:
|
||||||
static artist_ptr get( const QString& name, bool autoCreate = false );
|
static artist_ptr get( const QString& name, bool autoCreate = false );
|
||||||
static artist_ptr get( unsigned int id, const QString& name );
|
static artist_ptr get( unsigned int id, const QString& name );
|
||||||
explicit Artist( unsigned int id, const QString& name );
|
|
||||||
|
|
||||||
explicit Artist();
|
explicit Artist( unsigned int id, const QString& name );
|
||||||
virtual ~Artist();
|
virtual ~Artist();
|
||||||
|
|
||||||
unsigned int id() const { return m_id; }
|
unsigned int id() const { return m_id; }
|
||||||
QString name() const { return m_name; }
|
QString name() const { return m_name; }
|
||||||
QString sortname() const { return m_sortname; }
|
QString sortname() const { return m_sortname; }
|
||||||
|
QImage cover() const;
|
||||||
|
bool infoLoaded() const { return m_infoLoaded; }
|
||||||
|
|
||||||
Tomahawk::playlistinterface_ptr playlistInterface();
|
Tomahawk::playlistinterface_ptr playlistInterface();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void tracksAdded( const QList<Tomahawk::query_ptr>& tracks );
|
void tracksAdded( const QList<Tomahawk::query_ptr>& tracks );
|
||||||
|
void updated();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks );
|
void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks );
|
||||||
|
|
||||||
|
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY( Artist )
|
Q_DISABLE_COPY( Artist )
|
||||||
|
|
||||||
unsigned int m_id;
|
unsigned int m_id;
|
||||||
QString m_name;
|
QString m_name;
|
||||||
QString m_sortname;
|
QString m_sortname;
|
||||||
|
QImage m_cover;
|
||||||
|
bool m_infoLoaded;
|
||||||
|
mutable QString m_uuid;
|
||||||
|
|
||||||
Tomahawk::playlistinterface_ptr m_playlistInterface;
|
Tomahawk::playlistinterface_ptr m_playlistInterface;
|
||||||
};
|
};
|
||||||
|
@@ -29,7 +29,7 @@
|
|||||||
#include "network/servent.h"
|
#include "network/servent.h"
|
||||||
#include "utils/qnr_iodevicestream.h"
|
#include "utils/qnr_iodevicestream.h"
|
||||||
#include "headlesscheck.h"
|
#include "headlesscheck.h"
|
||||||
|
#include "infosystem/infosystem.h"
|
||||||
#include "album.h"
|
#include "album.h"
|
||||||
|
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
@@ -55,7 +55,6 @@ AudioEngine::AudioEngine()
|
|||||||
, m_timeElapsed( 0 )
|
, m_timeElapsed( 0 )
|
||||||
, m_expectStop( false )
|
, m_expectStop( false )
|
||||||
, m_waitingOnNewTrack( false )
|
, m_waitingOnNewTrack( false )
|
||||||
, m_infoSystemConnected( false )
|
|
||||||
, m_state( Stopped )
|
, m_state( Stopped )
|
||||||
{
|
{
|
||||||
s_instance = this;
|
s_instance = this;
|
||||||
@@ -73,7 +72,7 @@ AudioEngine::AudioEngine()
|
|||||||
connect( m_mediaObject, SIGNAL( tick( qint64 ) ), SLOT( timerTriggered( qint64 ) ) );
|
connect( m_mediaObject, SIGNAL( tick( qint64 ) ), SLOT( timerTriggered( qint64 ) ) );
|
||||||
connect( m_mediaObject, SIGNAL( aboutToFinish() ), SLOT( onAboutToFinish() ) );
|
connect( m_mediaObject, SIGNAL( aboutToFinish() ), SLOT( onAboutToFinish() ) );
|
||||||
|
|
||||||
connect( m_audioOutput, SIGNAL( volumeChanged( qreal ) ), this, SLOT( onVolumeChanged( qreal ) ) );
|
connect( m_audioOutput, SIGNAL( volumeChanged( qreal ) ), SLOT( onVolumeChanged( qreal ) ) );
|
||||||
|
|
||||||
onVolumeChanged( m_audioOutput->volume() );
|
onVolumeChanged( m_audioOutput->volume() );
|
||||||
|
|
||||||
@@ -324,63 +323,35 @@ AudioEngine::sendWaitingNotification() const
|
|||||||
void
|
void
|
||||||
AudioEngine::sendNowPlayingNotification()
|
AudioEngine::sendNowPlayingNotification()
|
||||||
{
|
{
|
||||||
tDebug( LOGEXTRA ) << Q_FUNC_INFO;
|
if ( m_currentTrack->album().isNull() || m_currentTrack->album()->infoLoaded() )
|
||||||
|
onNowPlayingInfoReady();
|
||||||
if ( ! m_infoSystemConnected )
|
else
|
||||||
{
|
{
|
||||||
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
|
connect( m_currentTrack->album().data(), SIGNAL( updated() ), SLOT( onNowPlayingInfoReady() ), Qt::UniqueConnection );
|
||||||
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
m_currentTrack->album()->cover();
|
||||||
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
|
|
||||||
|
|
||||||
connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
|
|
||||||
|
|
||||||
m_infoSystemConnected = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoStringHash trackInfo;
|
|
||||||
trackInfo["artist"] = m_currentTrack->album()->artist()->name();
|
|
||||||
trackInfo["album"] = m_currentTrack->album()->name();
|
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoRequestData requestData;
|
|
||||||
requestData.caller = s_aeInfoIdentifier;
|
|
||||||
requestData.type = Tomahawk::InfoSystem::InfoAlbumCoverArt;
|
|
||||||
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo );
|
|
||||||
requestData.customData = QVariantMap();
|
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AudioEngine::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
|
AudioEngine::onNowPlayingInfoReady()
|
||||||
{
|
{
|
||||||
if ( requestData.caller != s_aeInfoIdentifier ||
|
|
||||||
requestData.type != Tomahawk::InfoSystem::InfoAlbumCoverArt )
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( m_currentTrack.isNull() ||
|
if ( m_currentTrack.isNull() ||
|
||||||
m_currentTrack->track().isNull() ||
|
m_currentTrack->track().isNull() ||
|
||||||
m_currentTrack->artist().isNull() )
|
m_currentTrack->artist().isNull() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if ( !m_currentTrack->album().isNull() && sender() && m_currentTrack->album().data() != sender() )
|
||||||
|
return;
|
||||||
|
|
||||||
QVariantMap playInfo;
|
QVariantMap playInfo;
|
||||||
playInfo["message"] = tr( "Tomahawk is playing \"%1\" by %2%3." )
|
playInfo["message"] = tr( "Tomahawk is playing \"%1\" by %2%3." )
|
||||||
.arg( m_currentTrack->track() )
|
.arg( m_currentTrack->track() )
|
||||||
.arg( m_currentTrack->artist()->name() )
|
.arg( m_currentTrack->artist()->name() )
|
||||||
.arg( m_currentTrack->album().isNull() ? QString() : tr( " on album %1" ).arg( m_currentTrack->album()->name() ) );
|
.arg( m_currentTrack->album().isNull() ? QString() : QString( " %1" ).arg( tr( "on album %1" ).arg( m_currentTrack->album()->name() ) ) );
|
||||||
if ( !output.isNull() && output.isValid() )
|
|
||||||
{
|
if ( !m_currentTrack->album().isNull() )
|
||||||
QVariantMap returnedData = output.value< QVariantMap >();
|
playInfo["image"] = QVariant( QPixmap::fromImage( m_currentTrack->album()->cover() ) );
|
||||||
const QByteArray ba = returnedData["imgbytes"].toByteArray();
|
|
||||||
if ( ba.length() )
|
|
||||||
{
|
|
||||||
QPixmap pm;
|
|
||||||
pm.loadFromData( ba );
|
|
||||||
playInfo["image"] = QVariant( pm.toImage() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
|
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
|
||||||
s_aeInfoIdentifier, Tomahawk::InfoSystem::InfoNotifyUser,
|
s_aeInfoIdentifier, Tomahawk::InfoSystem::InfoNotifyUser,
|
||||||
@@ -388,13 +359,6 @@ AudioEngine::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
AudioEngine::infoSystemFinished( QString caller )
|
|
||||||
{
|
|
||||||
Q_UNUSED( caller );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
|
AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
|
||||||
{
|
{
|
||||||
@@ -578,7 +542,7 @@ AudioEngine::playItem( Tomahawk::playlistinterface_ptr playlist, const Tomahawk:
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AudioEngine::playlistNextTrackReady()
|
AudioEngine::onPlaylistNextTrackReady()
|
||||||
{
|
{
|
||||||
// If in real-time and you have a few seconds left, you're probably lagging -- finish it up
|
// If in real-time and you have a few seconds left, you're probably lagging -- finish it up
|
||||||
if ( m_playlist && m_playlist->latchMode() == PlaylistInterface::RealTime && ( m_waitingOnNewTrack || m_currentTrack.isNull() || m_currentTrack->id() == 0 || ( currentTrackTotalTime() - currentTime() > 6000 ) ) )
|
if ( m_playlist && m_playlist->latchMode() == PlaylistInterface::RealTime && ( m_waitingOnNewTrack || m_currentTrack.isNull() || m_currentTrack->id() == 0 || ( currentTrackTotalTime() - currentTime() > 6000 ) ) )
|
||||||
@@ -705,7 +669,7 @@ AudioEngine::setPlaylist( Tomahawk::playlistinterface_ptr playlist )
|
|||||||
m_playlist = playlist;
|
m_playlist = playlist;
|
||||||
|
|
||||||
if ( !m_playlist.isNull() && m_playlist.data() && m_playlist.data()->retryMode() == PlaylistInterface::Retry )
|
if ( !m_playlist.isNull() && m_playlist.data() && m_playlist.data()->retryMode() == PlaylistInterface::Retry )
|
||||||
connect( m_playlist.data(), SIGNAL( nextTrackReady() ), SLOT( playlistNextTrackReady() ) );
|
connect( m_playlist.data(), SIGNAL( nextTrackReady() ), SLOT( onPlaylistNextTrackReady() ) );
|
||||||
|
|
||||||
emit playlistChanged( playlist );
|
emit playlistChanged( playlist );
|
||||||
}
|
}
|
||||||
|
@@ -26,8 +26,6 @@
|
|||||||
#include <phonon/AudioOutput>
|
#include <phonon/AudioOutput>
|
||||||
#include <phonon/BackendCapabilities>
|
#include <phonon/BackendCapabilities>
|
||||||
|
|
||||||
#include "infosystem/infosystem.h"
|
|
||||||
|
|
||||||
#include "result.h"
|
#include "result.h"
|
||||||
#include "typedefs.h"
|
#include "typedefs.h"
|
||||||
#include "playlistinterface.h"
|
#include "playlistinterface.h"
|
||||||
@@ -87,18 +85,12 @@ public slots:
|
|||||||
void setVolume( int percentage );
|
void setVolume( int percentage );
|
||||||
void lowerVolume() { setVolume( volume() - AUDIO_VOLUME_STEP ); }
|
void lowerVolume() { setVolume( volume() - AUDIO_VOLUME_STEP ); }
|
||||||
void raiseVolume() { setVolume( volume() + AUDIO_VOLUME_STEP ); }
|
void raiseVolume() { setVolume( volume() + AUDIO_VOLUME_STEP ); }
|
||||||
void onVolumeChanged( qreal volume ) { emit volumeChanged( volume * 100 ); }
|
|
||||||
void mute();
|
void mute();
|
||||||
|
|
||||||
void playItem( Tomahawk::playlistinterface_ptr playlist, const Tomahawk::result_ptr& result );
|
void playItem( Tomahawk::playlistinterface_ptr playlist, const Tomahawk::result_ptr& result );
|
||||||
void setPlaylist( Tomahawk::playlistinterface_ptr playlist );
|
void setPlaylist( Tomahawk::playlistinterface_ptr playlist );
|
||||||
void setQueue( Tomahawk::playlistinterface_ptr queue ) { m_queue = queue; }
|
void setQueue( Tomahawk::playlistinterface_ptr queue ) { m_queue = queue; }
|
||||||
|
|
||||||
void playlistNextTrackReady();
|
|
||||||
|
|
||||||
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
|
||||||
void infoSystemFinished( QString caller );
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void loading( const Tomahawk::result_ptr& track );
|
void loading( const Tomahawk::result_ptr& track );
|
||||||
void started( const Tomahawk::result_ptr& track );
|
void started( const Tomahawk::result_ptr& track );
|
||||||
@@ -127,9 +119,12 @@ private slots:
|
|||||||
|
|
||||||
void onAboutToFinish();
|
void onAboutToFinish();
|
||||||
void onStateChanged( Phonon::State newState, Phonon::State oldState );
|
void onStateChanged( Phonon::State newState, Phonon::State oldState );
|
||||||
|
void onVolumeChanged( qreal volume ) { emit volumeChanged( volume * 100 ); }
|
||||||
void timerTriggered( qint64 time );
|
void timerTriggered( qint64 time );
|
||||||
|
|
||||||
void setCurrentTrack( const Tomahawk::result_ptr& result );
|
void setCurrentTrack( const Tomahawk::result_ptr& result );
|
||||||
|
void onNowPlayingInfoReady();
|
||||||
|
void onPlaylistNextTrackReady();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setState( AudioState state );
|
void setState( AudioState state );
|
||||||
@@ -154,7 +149,6 @@ private:
|
|||||||
unsigned int m_timeElapsed;
|
unsigned int m_timeElapsed;
|
||||||
bool m_expectStop;
|
bool m_expectStop;
|
||||||
bool m_waitingOnNewTrack;
|
bool m_waitingOnNewTrack;
|
||||||
bool m_infoSystemConnected;
|
|
||||||
|
|
||||||
mutable QStringList m_supportedMimeTypes;
|
mutable QStringList m_supportedMimeTypes;
|
||||||
AudioState m_state;
|
AudioState m_state;
|
||||||
|
@@ -74,6 +74,8 @@ AlbumItem::AlbumItem( const Tomahawk::album_ptr& album, AlbumItem* parent, int r
|
|||||||
}
|
}
|
||||||
|
|
||||||
toberemoved = false;
|
toberemoved = false;
|
||||||
|
|
||||||
|
connect( album.data(), SIGNAL( updated() ), SIGNAL( dataChanged() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -98,4 +100,6 @@ AlbumItem::AlbumItem( const Tomahawk::artist_ptr& artist, AlbumItem* parent, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
toberemoved = false;
|
toberemoved = false;
|
||||||
|
|
||||||
|
connect( artist.data(), SIGNAL( updated() ), SIGNAL( dataChanged() ) );
|
||||||
}
|
}
|
||||||
|
@@ -42,7 +42,6 @@ public:
|
|||||||
|
|
||||||
const Tomahawk::artist_ptr& artist() const { return m_artist; }
|
const Tomahawk::artist_ptr& artist() const { return m_artist; }
|
||||||
const Tomahawk::album_ptr& album() const { return m_album; }
|
const Tomahawk::album_ptr& album() const { return m_album; }
|
||||||
void setCover( const QPixmap& cover ) { this->cover = cover; emit dataChanged(); }
|
|
||||||
|
|
||||||
AlbumItem* parent;
|
AlbumItem* parent;
|
||||||
QList<AlbumItem*> children;
|
QList<AlbumItem*> children;
|
||||||
@@ -50,7 +49,6 @@ public:
|
|||||||
int childCount;
|
int childCount;
|
||||||
QPersistentModelIndex index;
|
QPersistentModelIndex index;
|
||||||
QAbstractItemModel* model;
|
QAbstractItemModel* model;
|
||||||
QPixmap cover;
|
|
||||||
bool toberemoved;
|
bool toberemoved;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@@ -89,7 +89,19 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
painter->drawLine( shadowRect.bottomLeft() + QPoint( 0, 4 ), shadowRect.bottomRight() + QPoint( 0, 4 ) );
|
painter->drawLine( shadowRect.bottomLeft() + QPoint( 0, 4 ), shadowRect.bottomRight() + QPoint( 0, 4 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap cover = item->cover.isNull() ? m_defaultCover : item->cover;
|
QPixmap cover;
|
||||||
|
if ( !item->album().isNull() )
|
||||||
|
{
|
||||||
|
cover = QPixmap::fromImage( item->album()->cover() );
|
||||||
|
}
|
||||||
|
else if ( !item->artist().isNull() )
|
||||||
|
{
|
||||||
|
cover = QPixmap::fromImage( item->artist()->cover() );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( cover.isNull() )
|
||||||
|
cover = m_defaultCover;
|
||||||
|
|
||||||
QRect r = option.rect.adjusted( 6, 5, -6, -41 );
|
QRect r = option.rect.adjusted( 6, 5, -6, -41 );
|
||||||
|
|
||||||
if ( option.state & QStyle::State_Selected )
|
if ( option.state & QStyle::State_Selected )
|
||||||
|
@@ -30,8 +30,6 @@
|
|||||||
#include "utils/tomahawkutils.h"
|
#include "utils/tomahawkutils.h"
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
|
|
||||||
static QString s_tmInfoIdentifier = QString( "ALBUMMODEL" );
|
|
||||||
|
|
||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
|
|
||||||
@@ -40,11 +38,6 @@ AlbumModel::AlbumModel( QObject* parent )
|
|||||||
, m_rootItem( new AlbumItem( 0, this ) )
|
, m_rootItem( new AlbumItem( 0, this ) )
|
||||||
, m_overwriteOnAdd( false )
|
, m_overwriteOnAdd( false )
|
||||||
{
|
{
|
||||||
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
|
|
||||||
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
|
||||||
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
|
|
||||||
|
|
||||||
connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -123,11 +116,6 @@ AlbumModel::data( const QModelIndex& index, int role ) const
|
|||||||
if ( !entry )
|
if ( !entry )
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
if ( role == Qt::DecorationRole )
|
|
||||||
{
|
|
||||||
return entry->cover;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( role != Qt::DisplayRole ) // && role != Qt::ToolTipRole )
|
if ( role != Qt::DisplayRole ) // && role != Qt::ToolTipRole )
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
@@ -187,8 +175,6 @@ AlbumModel::mimeTypes() const
|
|||||||
QMimeData*
|
QMimeData*
|
||||||
AlbumModel::mimeData( const QModelIndexList &indexes ) const
|
AlbumModel::mimeData( const QModelIndexList &indexes ) const
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
|
|
||||||
QByteArray queryData;
|
QByteArray queryData;
|
||||||
QDataStream queryStream( &queryData, QIODevice::WriteOnly );
|
QDataStream queryStream( &queryData, QIODevice::WriteOnly );
|
||||||
|
|
||||||
@@ -404,89 +390,6 @@ AlbumModel::clear()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
AlbumModel::getCover( const QModelIndex& index )
|
|
||||||
{
|
|
||||||
AlbumItem* item = itemFromIndex( index );
|
|
||||||
if ( !item || !item->cover.isNull() )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoStringHash trackInfo;
|
|
||||||
Tomahawk::InfoSystem::InfoRequestData requestData;
|
|
||||||
|
|
||||||
if ( !item->artist().isNull() )
|
|
||||||
{
|
|
||||||
requestData.type = Tomahawk::InfoSystem::InfoArtistImages;
|
|
||||||
|
|
||||||
trackInfo["artist"] = item->artist()->name();
|
|
||||||
}
|
|
||||||
else if ( !item->album().isNull() && !item->album()->artist().isNull() )
|
|
||||||
{
|
|
||||||
requestData.type = Tomahawk::InfoSystem::InfoAlbumCoverArt;
|
|
||||||
|
|
||||||
trackInfo["artist"] = item->album()->artist()->name();
|
|
||||||
trackInfo["album"] = item->album()->name();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_coverHash.insert( (qlonglong)item, index );
|
|
||||||
trackInfo["pptr"] = QString::number( (qlonglong)item );
|
|
||||||
|
|
||||||
requestData.caller = s_tmInfoIdentifier;
|
|
||||||
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo );
|
|
||||||
requestData.customData = QVariantMap();
|
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
AlbumModel::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
|
|
||||||
{
|
|
||||||
// qDebug() << Q_FUNC_INFO << " with caller " << requestData.caller;
|
|
||||||
|
|
||||||
if ( requestData.caller != s_tmInfoIdentifier ||
|
|
||||||
( requestData.type != Tomahawk::InfoSystem::InfoAlbumCoverArt && requestData.type != Tomahawk::InfoSystem::InfoArtistImages ) )
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !output.canConvert< QVariantMap >() )
|
|
||||||
{
|
|
||||||
qDebug() << "Cannot convert fetched art from a QByteArray";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoStringHash pptr = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >();
|
|
||||||
QVariantMap returnedData = output.value< QVariantMap >();
|
|
||||||
const QByteArray ba = returnedData["imgbytes"].toByteArray();
|
|
||||||
if ( ba.length() )
|
|
||||||
{
|
|
||||||
QPixmap pm;
|
|
||||||
pm.loadFromData( ba );
|
|
||||||
|
|
||||||
bool ok;
|
|
||||||
qlonglong p = pptr["pptr"].toLongLong( &ok );
|
|
||||||
AlbumItem* ai = itemFromIndex( m_coverHash.take( p ) );
|
|
||||||
if ( !ai )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ( !pm.isNull() )
|
|
||||||
ai->cover = pm;
|
|
||||||
|
|
||||||
if ( ai->index.isValid() )
|
|
||||||
emit dataChanged( ai->index, ai->index.sibling( ai->index.row(), columnCount( QModelIndex() ) - 1 ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
AlbumModel::infoSystemFinished( QString target )
|
|
||||||
{
|
|
||||||
Q_UNUSED( target );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AlbumModel::onDataChanged()
|
AlbumModel::onDataChanged()
|
||||||
{
|
{
|
||||||
|
@@ -25,7 +25,6 @@
|
|||||||
#include "album.h"
|
#include "album.h"
|
||||||
#include "playlistinterface.h"
|
#include "playlistinterface.h"
|
||||||
#include "database/databasecommand_allalbums.h"
|
#include "database/databasecommand_allalbums.h"
|
||||||
#include "infosystem/infosystem.h"
|
|
||||||
|
|
||||||
#include "dllmacro.h"
|
#include "dllmacro.h"
|
||||||
|
|
||||||
@@ -67,8 +66,6 @@ public:
|
|||||||
void addCollection( const Tomahawk::collection_ptr& collection, bool overwrite = false );
|
void addCollection( const Tomahawk::collection_ptr& collection, bool overwrite = false );
|
||||||
void addFilteredCollection( const Tomahawk::collection_ptr& collection, unsigned int amount, DatabaseCommand_AllAlbums::SortOrder order, bool overwrite = false );
|
void addFilteredCollection( const Tomahawk::collection_ptr& collection, unsigned int amount, DatabaseCommand_AllAlbums::SortOrder order, bool overwrite = false );
|
||||||
|
|
||||||
bool getCover( const QModelIndex& index );
|
|
||||||
|
|
||||||
virtual QString title() const { return m_title; }
|
virtual QString title() const { return m_title; }
|
||||||
virtual QString description() const { return m_description; }
|
virtual QString description() const { return m_description; }
|
||||||
virtual void setTitle( const QString& title ) { m_title = title; }
|
virtual void setTitle( const QString& title ) { m_title = title; }
|
||||||
@@ -106,9 +103,6 @@ private slots:
|
|||||||
void onSourceAdded( const Tomahawk::source_ptr& source );
|
void onSourceAdded( const Tomahawk::source_ptr& source );
|
||||||
void onCollectionChanged();
|
void onCollectionChanged();
|
||||||
|
|
||||||
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
|
||||||
void infoSystemFinished( QString target );
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPersistentModelIndex m_currentIndex;
|
QPersistentModelIndex m_currentIndex;
|
||||||
AlbumItem* m_rootItem;
|
AlbumItem* m_rootItem;
|
||||||
@@ -118,8 +112,6 @@ private:
|
|||||||
bool m_overwriteOnAdd;
|
bool m_overwriteOnAdd;
|
||||||
|
|
||||||
Tomahawk::collection_ptr m_collection;
|
Tomahawk::collection_ptr m_collection;
|
||||||
|
|
||||||
QHash<qlonglong, QPersistentModelIndex> m_coverHash;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ALBUMMODEL_H
|
#endif // ALBUMMODEL_H
|
||||||
|
@@ -63,12 +63,6 @@ AlbumView::AlbumView( QWidget* parent )
|
|||||||
setAutoFitItems( true );
|
setAutoFitItems( true );
|
||||||
setProxyModel( new AlbumProxyModel( this ) );
|
setProxyModel( new AlbumProxyModel( this ) );
|
||||||
|
|
||||||
m_timer.setInterval( SCROLL_TIMEOUT );
|
|
||||||
|
|
||||||
connect( verticalScrollBar(), SIGNAL( rangeChanged( int, int ) ), SLOT( onViewChanged() ) );
|
|
||||||
connect( verticalScrollBar(), SIGNAL( valueChanged( int ) ), SLOT( onViewChanged() ) );
|
|
||||||
connect( &m_timer, SIGNAL( timeout() ), SLOT( onScrollTimeout() ) );
|
|
||||||
|
|
||||||
connect( this, SIGNAL( doubleClicked( QModelIndex ) ), SLOT( onItemActivated( QModelIndex ) ) );
|
connect( this, SIGNAL( doubleClicked( QModelIndex ) ), SLOT( onItemActivated( QModelIndex ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,13 +106,10 @@ AlbumView::setAlbumModel( AlbumModel* model )
|
|||||||
}
|
}
|
||||||
|
|
||||||
connect( m_proxyModel, SIGNAL( filterChanged( QString ) ), SLOT( onFilterChanged( QString ) ) );
|
connect( m_proxyModel, SIGNAL( filterChanged( QString ) ), SLOT( onFilterChanged( QString ) ) );
|
||||||
connect( m_proxyModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( onViewChanged() ) );
|
|
||||||
|
|
||||||
connect( m_model, SIGNAL( itemCountChanged( unsigned int ) ), SLOT( onItemCountChanged( unsigned int ) ) );
|
connect( m_model, SIGNAL( itemCountChanged( unsigned int ) ), SLOT( onItemCountChanged( unsigned int ) ) );
|
||||||
connect( m_model, SIGNAL( loadingStarted() ), m_loadingSpinner, SLOT( fadeIn() ) );
|
connect( m_model, SIGNAL( loadingStarted() ), m_loadingSpinner, SLOT( fadeIn() ) );
|
||||||
connect( m_model, SIGNAL( loadingFinished() ), m_loadingSpinner, SLOT( fadeOut() ) );
|
connect( m_model, SIGNAL( loadingFinished() ), m_loadingSpinner, SLOT( fadeOut() ) );
|
||||||
|
|
||||||
onViewChanged(); // Fetch covers if albums were added to model before model was attached to view
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -139,16 +130,6 @@ AlbumView::onItemActivated( const QModelIndex& index )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
AlbumView::onViewChanged()
|
|
||||||
{
|
|
||||||
if ( m_timer.isActive() )
|
|
||||||
m_timer.stop();
|
|
||||||
|
|
||||||
m_timer.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AlbumView::onItemCountChanged( unsigned int items )
|
AlbumView::onItemCountChanged( unsigned int items )
|
||||||
{
|
{
|
||||||
@@ -166,45 +147,6 @@ AlbumView::onItemCountChanged( unsigned int items )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
AlbumView::onScrollTimeout()
|
|
||||||
{
|
|
||||||
if ( m_timer.isActive() )
|
|
||||||
m_timer.stop();
|
|
||||||
|
|
||||||
if ( !m_proxyModel->rowCount() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
QRect viewRect = viewport()->rect();
|
|
||||||
int rowHeight = m_proxyModel->data( QModelIndex(), Qt::SizeHintRole ).toSize().height();
|
|
||||||
viewRect.adjust( 0, -rowHeight, 0, rowHeight );
|
|
||||||
|
|
||||||
bool started = false;
|
|
||||||
bool done = false;
|
|
||||||
for ( int i = 0; i < m_proxyModel->rowCount(); i++ )
|
|
||||||
{
|
|
||||||
if ( started && done )
|
|
||||||
break;
|
|
||||||
|
|
||||||
for ( int j = 0; j < m_proxyModel->columnCount(); j++ )
|
|
||||||
{
|
|
||||||
QModelIndex idx = m_proxyModel->index( i, j );
|
|
||||||
if ( !viewRect.contains( visualRect( idx ) ) )
|
|
||||||
{
|
|
||||||
done = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
started = true;
|
|
||||||
done = false;
|
|
||||||
|
|
||||||
if ( !m_model->getCover( m_proxyModel->mapToSource( idx ) ) )
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AlbumView::paintEvent( QPaintEvent* event )
|
AlbumView::paintEvent( QPaintEvent* event )
|
||||||
{
|
{
|
||||||
|
@@ -76,9 +76,6 @@ private slots:
|
|||||||
|
|
||||||
void onFilterChanged( const QString& filter );
|
void onFilterChanged( const QString& filter );
|
||||||
|
|
||||||
void onViewChanged();
|
|
||||||
void onScrollTimeout();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AlbumModel* m_model;
|
AlbumModel* m_model;
|
||||||
AlbumProxyModel* m_proxyModel;
|
AlbumProxyModel* m_proxyModel;
|
||||||
@@ -88,8 +85,6 @@ private:
|
|||||||
|
|
||||||
bool m_inited;
|
bool m_inited;
|
||||||
bool m_autoFitItems;
|
bool m_autoFitItems;
|
||||||
|
|
||||||
QTimer m_timer;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ALBUMVIEW_H
|
#endif // ALBUMVIEW_H
|
||||||
|
@@ -80,12 +80,6 @@ ArtistView::ArtistView( QWidget* parent )
|
|||||||
setFont( f );
|
setFont( f );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_timer.setInterval( SCROLL_TIMEOUT );
|
|
||||||
|
|
||||||
connect( verticalScrollBar(), SIGNAL( rangeChanged( int, int ) ), SLOT( onViewChanged() ) );
|
|
||||||
connect( verticalScrollBar(), SIGNAL( valueChanged( int ) ), SLOT( onViewChanged() ) );
|
|
||||||
connect( &m_timer, SIGNAL( timeout() ), SLOT( onScrollTimeout() ) );
|
|
||||||
|
|
||||||
connect( this, SIGNAL( doubleClicked( QModelIndex ) ), SLOT( onItemActivated( QModelIndex ) ) );
|
connect( this, SIGNAL( doubleClicked( QModelIndex ) ), SLOT( onItemActivated( QModelIndex ) ) );
|
||||||
connect( this, SIGNAL( customContextMenuRequested( const QPoint& ) ), SLOT( onCustomContextMenu( const QPoint& ) ) );
|
connect( this, SIGNAL( customContextMenuRequested( const QPoint& ) ), SLOT( onCustomContextMenu( const QPoint& ) ) );
|
||||||
connect( m_contextMenu, SIGNAL( triggered( int ) ), SLOT( onMenuTriggered( int ) ) );
|
connect( m_contextMenu, SIGNAL( triggered( int ) ), SLOT( onMenuTriggered( int ) ) );
|
||||||
@@ -135,7 +129,6 @@ ArtistView::setTreeModel( TreeModel* model )
|
|||||||
|
|
||||||
connect( m_model, SIGNAL( itemCountChanged( unsigned int ) ), SLOT( onItemCountChanged( unsigned int ) ) );
|
connect( m_model, SIGNAL( itemCountChanged( unsigned int ) ), SLOT( onItemCountChanged( unsigned int ) ) );
|
||||||
connect( m_proxyModel, SIGNAL( filterChanged( QString ) ), SLOT( onFilterChanged( QString ) ) );
|
connect( m_proxyModel, SIGNAL( filterChanged( QString ) ), SLOT( onFilterChanged( QString ) ) );
|
||||||
connect( m_proxyModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( onViewChanged() ) );
|
|
||||||
|
|
||||||
guid(); // this will set the guid on the header
|
guid(); // this will set the guid on the header
|
||||||
|
|
||||||
@@ -307,45 +300,6 @@ ArtistView::startDrag( Qt::DropActions supportedActions )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ArtistView::onViewChanged()
|
|
||||||
{
|
|
||||||
if ( m_timer.isActive() )
|
|
||||||
m_timer.stop();
|
|
||||||
|
|
||||||
m_timer.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ArtistView::onScrollTimeout()
|
|
||||||
{
|
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
if ( m_timer.isActive() )
|
|
||||||
m_timer.stop();
|
|
||||||
|
|
||||||
QModelIndex left = indexAt( viewport()->rect().topLeft() );
|
|
||||||
while ( left.isValid() && left.parent().isValid() )
|
|
||||||
left = left.parent();
|
|
||||||
|
|
||||||
QModelIndex right = indexAt( viewport()->rect().bottomLeft() );
|
|
||||||
while ( right.isValid() && right.parent().isValid() )
|
|
||||||
right = right.parent();
|
|
||||||
|
|
||||||
int max = m_proxyModel->playlistInterface()->trackCount();
|
|
||||||
if ( right.isValid() )
|
|
||||||
max = right.row() + 1;
|
|
||||||
|
|
||||||
if ( !max )
|
|
||||||
return;
|
|
||||||
|
|
||||||
for ( int i = left.row(); i < max; i++ )
|
|
||||||
{
|
|
||||||
m_model->getCover( m_proxyModel->mapToSource( m_proxyModel->index( i, 0 ) ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ArtistView::onCustomContextMenu( const QPoint& pos )
|
ArtistView::onCustomContextMenu( const QPoint& pos )
|
||||||
{
|
{
|
||||||
|
@@ -95,8 +95,6 @@ private slots:
|
|||||||
void onItemCountChanged( unsigned int items );
|
void onItemCountChanged( unsigned int items );
|
||||||
void onFilterChanged( const QString& filter );
|
void onFilterChanged( const QString& filter );
|
||||||
void onFilteringStarted();
|
void onFilteringStarted();
|
||||||
void onViewChanged();
|
|
||||||
void onScrollTimeout();
|
|
||||||
|
|
||||||
void onCustomContextMenu( const QPoint& pos );
|
void onCustomContextMenu( const QPoint& pos );
|
||||||
void onMenuTriggered( int action );
|
void onMenuTriggered( int action );
|
||||||
@@ -115,7 +113,6 @@ private:
|
|||||||
Tomahawk::ContextMenu* m_contextMenu;
|
Tomahawk::ContextMenu* m_contextMenu;
|
||||||
|
|
||||||
bool m_showModes;
|
bool m_showModes;
|
||||||
QTimer m_timer;
|
|
||||||
mutable QString m_guid;
|
mutable QString m_guid;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -152,8 +152,17 @@ TreeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
QRect r = option.rect.adjusted( 4, 4, -option.rect.width() + option.rect.height() - 4, -4 );
|
QRect r = option.rect.adjusted( 4, 4, -option.rect.width() + option.rect.height() - 4, -4 );
|
||||||
// painter->drawPixmap( r, QPixmap( RESPATH "images/cover-shadow.png" ) );
|
// painter->drawPixmap( r, QPixmap( RESPATH "images/cover-shadow.png" ) );
|
||||||
|
|
||||||
|
QPixmap cover;
|
||||||
|
if ( !item->album().isNull() )
|
||||||
|
{
|
||||||
|
cover = QPixmap::fromImage( item->album()->cover() );
|
||||||
|
}
|
||||||
|
else if ( !item->artist().isNull() )
|
||||||
|
{
|
||||||
|
cover = QPixmap::fromImage( item->artist()->cover() );
|
||||||
|
}
|
||||||
|
|
||||||
QPixmap scover;
|
QPixmap scover;
|
||||||
QPixmap cover = item->cover;
|
|
||||||
if ( cover.isNull() )
|
if ( cover.isNull() )
|
||||||
{
|
{
|
||||||
if ( !item->artist().isNull() )
|
if ( !item->artist().isNull() )
|
||||||
|
@@ -47,8 +47,6 @@ TreeModel::TreeModel( QObject* parent )
|
|||||||
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
|
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
|
||||||
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
||||||
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
|
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
|
||||||
|
|
||||||
connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -89,40 +87,6 @@ TreeModel::collection() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TreeModel::getCover( const QModelIndex& index )
|
|
||||||
{
|
|
||||||
TreeModelItem* item = itemFromIndex( index );
|
|
||||||
if ( !item->cover.isNull() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoStringHash trackInfo;
|
|
||||||
Tomahawk::InfoSystem::InfoRequestData requestData;
|
|
||||||
|
|
||||||
if ( !item->artist().isNull() )
|
|
||||||
{
|
|
||||||
trackInfo["artist"] = item->artist()->name();
|
|
||||||
requestData.type = Tomahawk::InfoSystem::InfoArtistImages;
|
|
||||||
}
|
|
||||||
else if ( !item->album().isNull() )
|
|
||||||
{
|
|
||||||
trackInfo["artist"] = item->album()->artist()->name();
|
|
||||||
trackInfo["album"] = item->album()->name();
|
|
||||||
requestData.type = Tomahawk::InfoSystem::InfoAlbumCoverArt;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return;
|
|
||||||
|
|
||||||
trackInfo["pptr"] = QString::number( (qlonglong)item );
|
|
||||||
m_coverHash.insert( (qlonglong)item, index );
|
|
||||||
|
|
||||||
requestData.caller = m_infoId;
|
|
||||||
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo );
|
|
||||||
requestData.customData = QVariantMap();
|
|
||||||
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TreeModel::setCurrentItem( const QModelIndex& index )
|
TreeModel::setCurrentItem( const QModelIndex& index )
|
||||||
{
|
{
|
||||||
@@ -807,8 +771,6 @@ TreeModel::onAlbumsAdded( const QList<Tomahawk::album_ptr>& albums, const QModel
|
|||||||
albumitem = new TreeModelItem( album, parentItem );
|
albumitem = new TreeModelItem( album, parentItem );
|
||||||
albumitem->index = createIndex( parentItem->children.count() - 1, 0, albumitem );
|
albumitem->index = createIndex( parentItem->children.count() - 1, 0, albumitem );
|
||||||
connect( albumitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
|
connect( albumitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
|
||||||
|
|
||||||
getCover( albumitem->index );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
emit endInsertRows();
|
emit endInsertRows();
|
||||||
@@ -876,31 +838,6 @@ TreeModel::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QV
|
|||||||
|
|
||||||
switch ( requestData.type )
|
switch ( requestData.type )
|
||||||
{
|
{
|
||||||
case Tomahawk::InfoSystem::InfoAlbumCoverArt:
|
|
||||||
case Tomahawk::InfoSystem::InfoArtistImages:
|
|
||||||
{
|
|
||||||
Tomahawk::InfoSystem::InfoStringHash pptr = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >();
|
|
||||||
QVariantMap returnedData = output.value< QVariantMap >();
|
|
||||||
const QByteArray ba = returnedData["imgbytes"].toByteArray();
|
|
||||||
if ( ba.length() )
|
|
||||||
{
|
|
||||||
QPixmap pm;
|
|
||||||
pm.loadFromData( ba );
|
|
||||||
bool ok;
|
|
||||||
qlonglong p = pptr["pptr"].toLongLong( &ok );
|
|
||||||
TreeModelItem* ai = itemFromIndex( m_coverHash.take( p ) );
|
|
||||||
if ( !ai )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ( !pm.isNull() )
|
|
||||||
ai->cover = pm;
|
|
||||||
|
|
||||||
emit dataChanged( ai->index, ai->index.sibling( ai->index.row(), columnCount( QModelIndex() ) - 1 ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case Tomahawk::InfoSystem::InfoArtistReleases:
|
case Tomahawk::InfoSystem::InfoArtistReleases:
|
||||||
{
|
{
|
||||||
QVariantMap returnedData = output.value< QVariantMap >();
|
QVariantMap returnedData = output.value< QVariantMap >();
|
||||||
@@ -997,13 +934,6 @@ TreeModel::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QV
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TreeModel::infoSystemFinished( QString target )
|
|
||||||
{
|
|
||||||
Q_UNUSED( target );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TreeModel::onPlaybackStarted( const Tomahawk::result_ptr& result )
|
TreeModel::onPlaybackStarted( const Tomahawk::result_ptr& result )
|
||||||
{
|
{
|
||||||
|
@@ -97,8 +97,6 @@ public:
|
|||||||
void addAlbums( const Tomahawk::artist_ptr& artist, const QModelIndex& parent, bool autoRefetch = false );
|
void addAlbums( const Tomahawk::artist_ptr& artist, const QModelIndex& parent, bool autoRefetch = false );
|
||||||
void addTracks( const Tomahawk::album_ptr& album, const QModelIndex& parent, bool autoRefetch = false );
|
void addTracks( const Tomahawk::album_ptr& album, const QModelIndex& parent, bool autoRefetch = false );
|
||||||
|
|
||||||
void getCover( const QModelIndex& index );
|
|
||||||
|
|
||||||
ColumnStyle columnStyle() const { return m_columnStyle; }
|
ColumnStyle columnStyle() const { return m_columnStyle; }
|
||||||
void setColumnStyle( ColumnStyle style );
|
void setColumnStyle( ColumnStyle style );
|
||||||
|
|
||||||
@@ -150,7 +148,6 @@ private slots:
|
|||||||
void onTracksFound( const QList<Tomahawk::query_ptr>& tracks, const QVariant& variant );
|
void onTracksFound( const QList<Tomahawk::query_ptr>& tracks, const QVariant& variant );
|
||||||
|
|
||||||
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
||||||
void infoSystemFinished( QString target );
|
|
||||||
|
|
||||||
void onPlaybackStarted( const Tomahawk::result_ptr& result );
|
void onPlaybackStarted( const Tomahawk::result_ptr& result );
|
||||||
void onPlaybackStopped();
|
void onPlaybackStopped();
|
||||||
@@ -174,7 +171,6 @@ private:
|
|||||||
QList<Tomahawk::artist_ptr> m_artistsFilter;
|
QList<Tomahawk::artist_ptr> m_artistsFilter;
|
||||||
|
|
||||||
Tomahawk::collection_ptr m_collection;
|
Tomahawk::collection_ptr m_collection;
|
||||||
QHash<qlonglong, QPersistentModelIndex> m_coverHash;
|
|
||||||
QList<Tomahawk::InfoSystem::InfoStringHash> m_receivedInfoData;
|
QList<Tomahawk::InfoSystem::InfoStringHash> m_receivedInfoData;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -82,6 +82,8 @@ TreeModelItem::TreeModelItem( const Tomahawk::album_ptr& album, TreeModelItem* p
|
|||||||
}
|
}
|
||||||
|
|
||||||
toberemoved = false;
|
toberemoved = false;
|
||||||
|
|
||||||
|
connect( album.data(), SIGNAL( updated() ), SIGNAL( dataChanged() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -109,6 +111,8 @@ TreeModelItem::TreeModelItem( const Tomahawk::artist_ptr& artist, TreeModelItem*
|
|||||||
}
|
}
|
||||||
|
|
||||||
toberemoved = false;
|
toberemoved = false;
|
||||||
|
|
||||||
|
connect( artist.data(), SIGNAL( updated() ), SIGNAL( dataChanged() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -48,8 +48,6 @@ public:
|
|||||||
bool isPlaying() { return m_isPlaying; }
|
bool isPlaying() { return m_isPlaying; }
|
||||||
void setIsPlaying( bool b ) { m_isPlaying = b; emit dataChanged(); }
|
void setIsPlaying( bool b ) { m_isPlaying = b; emit dataChanged(); }
|
||||||
|
|
||||||
void setCover( const QPixmap& cover ) { this->cover = cover; emit dataChanged(); }
|
|
||||||
|
|
||||||
QString name() const;
|
QString name() const;
|
||||||
QString artistName() const;
|
QString artistName() const;
|
||||||
QString albumName() const;
|
QString albumName() const;
|
||||||
@@ -60,7 +58,6 @@ public:
|
|||||||
int childCount;
|
int childCount;
|
||||||
QPersistentModelIndex index;
|
QPersistentModelIndex index;
|
||||||
QAbstractItemModel* model;
|
QAbstractItemModel* model;
|
||||||
QPixmap cover;
|
|
||||||
|
|
||||||
bool toberemoved;
|
bool toberemoved;
|
||||||
bool fetchingMore;
|
bool fetchingMore;
|
||||||
|
@@ -87,8 +87,6 @@ AlbumInfoWidget::AlbumInfoWidget( const Tomahawk::album_ptr& album, ModelMode st
|
|||||||
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
||||||
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
|
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
|
||||||
|
|
||||||
connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
|
|
||||||
|
|
||||||
load( album );
|
load( album );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,6 +190,9 @@ AlbumInfoWidget::descriptionType()
|
|||||||
void
|
void
|
||||||
AlbumInfoWidget::load( const album_ptr& album )
|
AlbumInfoWidget::load( const album_ptr& album )
|
||||||
{
|
{
|
||||||
|
if ( !m_album.isNull() )
|
||||||
|
disconnect( m_album.data(), SIGNAL( updated() ), this, SLOT( onAlbumCoverUpdated() ) );
|
||||||
|
|
||||||
m_album = album;
|
m_album = album;
|
||||||
m_title = album->name();
|
m_title = album->name();
|
||||||
m_description = album->artist()->name();
|
m_description = album->artist()->name();
|
||||||
@@ -201,17 +202,8 @@ AlbumInfoWidget::load( const album_ptr& album )
|
|||||||
m_tracksModel->addTracks( album, QModelIndex(), true );
|
m_tracksModel->addTracks( album, QModelIndex(), true );
|
||||||
loadAlbums( true );
|
loadAlbums( true );
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoStringHash trackInfo;
|
connect( m_album.data(), SIGNAL( updated() ), SLOT( onAlbumCoverUpdated() ) );
|
||||||
trackInfo["artist"] = album->artist()->name();
|
onAlbumCoverUpdated();
|
||||||
trackInfo["album"] = album->name();
|
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoRequestData requestData;
|
|
||||||
requestData.caller = m_infoId;
|
|
||||||
requestData.type = Tomahawk::InfoSystem::InfoAlbumCoverArt;
|
|
||||||
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo );
|
|
||||||
requestData.customData = QVariantMap();
|
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -245,6 +237,17 @@ AlbumInfoWidget::loadAlbums( bool autoRefetch )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AlbumInfoWidget::onAlbumCoverUpdated()
|
||||||
|
{
|
||||||
|
if ( m_album->cover().isNull() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_pixmap = QPixmap::fromImage( m_album->cover() );
|
||||||
|
emit pixmapChanged( m_pixmap );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AlbumInfoWidget::gotAlbums( const QList<Tomahawk::album_ptr>& albums )
|
AlbumInfoWidget::gotAlbums( const QList<Tomahawk::album_ptr>& albums )
|
||||||
{
|
{
|
||||||
@@ -269,11 +272,6 @@ AlbumInfoWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDa
|
|||||||
|
|
||||||
if ( output.canConvert< QVariantMap >() )
|
if ( output.canConvert< QVariantMap >() )
|
||||||
{
|
{
|
||||||
if ( requestData.type == InfoSystem::InfoAlbumCoverArt && trackInfo["album"] != m_album->name() )
|
|
||||||
{
|
|
||||||
qDebug() << "Returned info was for:" << trackInfo["album"] << "- was looking for:" << m_album->name();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ( requestData.type == InfoSystem::InfoArtistReleases && trackInfo["artist"] != m_album->artist()->name() )
|
if ( requestData.type == InfoSystem::InfoArtistReleases && trackInfo["artist"] != m_album->artist()->name() )
|
||||||
{
|
{
|
||||||
qDebug() << "Returned info was for:" << trackInfo["artist"] << "- was looking for:" << m_album->artist()->name();
|
qDebug() << "Returned info was for:" << trackInfo["artist"] << "- was looking for:" << m_album->artist()->name();
|
||||||
@@ -284,18 +282,6 @@ AlbumInfoWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDa
|
|||||||
QVariantMap returnedData = output.value< QVariantMap >();
|
QVariantMap returnedData = output.value< QVariantMap >();
|
||||||
switch ( requestData.type )
|
switch ( requestData.type )
|
||||||
{
|
{
|
||||||
case Tomahawk::InfoSystem::InfoAlbumCoverArt:
|
|
||||||
{
|
|
||||||
const QByteArray ba = returnedData["imgbytes"].toByteArray();
|
|
||||||
if ( ba.length() )
|
|
||||||
{
|
|
||||||
m_pixmap.loadFromData( ba );
|
|
||||||
emit pixmapChanged( m_pixmap );
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case Tomahawk::InfoSystem::InfoArtistReleases:
|
case Tomahawk::InfoSystem::InfoArtistReleases:
|
||||||
{
|
{
|
||||||
QStringList albums = returnedData[ "albums" ].toStringList();
|
QStringList albums = returnedData[ "albums" ].toStringList();
|
||||||
@@ -335,13 +321,6 @@ AlbumInfoWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDa
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
AlbumInfoWidget::infoSystemFinished( QString target )
|
|
||||||
{
|
|
||||||
Q_UNUSED( target );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AlbumInfoWidget::changeEvent( QEvent* e )
|
AlbumInfoWidget::changeEvent( QEvent* e )
|
||||||
{
|
{
|
||||||
|
@@ -94,9 +94,9 @@ protected:
|
|||||||
private slots:
|
private slots:
|
||||||
void loadAlbums( bool autoRefetch = false );
|
void loadAlbums( bool autoRefetch = false );
|
||||||
void gotAlbums( const QList<Tomahawk::album_ptr>& albums );
|
void gotAlbums( const QList<Tomahawk::album_ptr>& albums );
|
||||||
|
void onAlbumCoverUpdated();
|
||||||
|
|
||||||
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
||||||
void infoSystemFinished( QString target );
|
|
||||||
|
|
||||||
void onModeToggle();
|
void onModeToggle();
|
||||||
void onAlbumsModeToggle();
|
void onAlbumsModeToggle();
|
||||||
|
@@ -89,8 +89,6 @@ ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget*
|
|||||||
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
||||||
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
|
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
|
||||||
|
|
||||||
connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
|
|
||||||
|
|
||||||
load( artist );
|
load( artist );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,6 +180,9 @@ ArtistInfoWidget::jumpToCurrentTrack()
|
|||||||
void
|
void
|
||||||
ArtistInfoWidget::load( const artist_ptr& artist )
|
ArtistInfoWidget::load( const artist_ptr& artist )
|
||||||
{
|
{
|
||||||
|
if ( !m_artist.isNull() )
|
||||||
|
disconnect( m_artist.data(), SIGNAL( updated() ), this, SLOT( onArtistImageUpdated() ) );
|
||||||
|
|
||||||
m_artist = artist;
|
m_artist = artist;
|
||||||
m_title = artist->name();
|
m_title = artist->name();
|
||||||
m_albumsModel->addAlbums( artist, QModelIndex(), true );
|
m_albumsModel->addAlbums( artist, QModelIndex(), true );
|
||||||
@@ -199,10 +200,6 @@ ArtistInfoWidget::load( const artist_ptr& artist )
|
|||||||
|
|
||||||
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( artistInfo );
|
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( artistInfo );
|
||||||
|
|
||||||
requestData.type = Tomahawk::InfoSystem::InfoArtistImages;
|
|
||||||
requestData.requestId = TomahawkUtils::infosystemRequestId();
|
|
||||||
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
|
|
||||||
|
|
||||||
requestData.type = Tomahawk::InfoSystem::InfoArtistSimilars;
|
requestData.type = Tomahawk::InfoSystem::InfoArtistSimilars;
|
||||||
requestData.requestId = TomahawkUtils::infosystemRequestId();
|
requestData.requestId = TomahawkUtils::infosystemRequestId();
|
||||||
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
|
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
|
||||||
@@ -210,6 +207,9 @@ ArtistInfoWidget::load( const artist_ptr& artist )
|
|||||||
requestData.type = Tomahawk::InfoSystem::InfoArtistSongs;
|
requestData.type = Tomahawk::InfoSystem::InfoArtistSongs;
|
||||||
requestData.requestId = TomahawkUtils::infosystemRequestId();
|
requestData.requestId = TomahawkUtils::infosystemRequestId();
|
||||||
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
|
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
|
||||||
|
|
||||||
|
connect( m_artist.data(), SIGNAL( updated() ), SLOT( onArtistImageUpdated() ) );
|
||||||
|
onArtistImageUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -264,22 +264,6 @@ ArtistInfoWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestD
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case InfoSystem::InfoArtistImages:
|
|
||||||
{
|
|
||||||
const QByteArray ba = returnedData["imgbytes"].toByteArray();
|
|
||||||
if ( ba.length() )
|
|
||||||
{
|
|
||||||
QPixmap pm;
|
|
||||||
pm.loadFromData( ba );
|
|
||||||
|
|
||||||
if ( !pm.isNull() )
|
|
||||||
m_pixmap = pm.scaledToHeight( 48, Qt::SmoothTransformation );
|
|
||||||
|
|
||||||
emit pixmapChanged( m_pixmap );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case InfoSystem::InfoArtistSimilars:
|
case InfoSystem::InfoArtistSimilars:
|
||||||
{
|
{
|
||||||
const QStringList artists = returnedData["artists"].toStringList();
|
const QStringList artists = returnedData["artists"].toStringList();
|
||||||
@@ -297,9 +281,13 @@ ArtistInfoWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestD
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ArtistInfoWidget::infoSystemFinished( QString target )
|
ArtistInfoWidget::onArtistImageUpdated()
|
||||||
{
|
{
|
||||||
Q_UNUSED( target );
|
if ( m_artist->cover().isNull() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_pixmap = QPixmap::fromImage( m_artist->cover() );
|
||||||
|
emit pixmapChanged( m_pixmap );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -93,7 +93,7 @@ private slots:
|
|||||||
void setMode( Tomahawk::ModelMode mode );
|
void setMode( Tomahawk::ModelMode mode );
|
||||||
|
|
||||||
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
||||||
void infoSystemFinished( QString target );
|
void onArtistImageUpdated();
|
||||||
|
|
||||||
void onModeToggle();
|
void onModeToggle();
|
||||||
void onLoadingStarted();
|
void onLoadingStarted();
|
||||||
|
Reference in New Issue
Block a user