mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-20 15:59:42 +01:00
* Make use of new Track class / api.
This commit is contained in:
parent
f0fdb47f4e
commit
77fe7bc334
@ -235,7 +235,7 @@ AudioControls::onPlaybackStarted( const Tomahawk::result_ptr& result )
|
||||
qint64 duration = AudioEngine::instance()->currentTrackTotalTime();
|
||||
|
||||
if ( duration == -1 )
|
||||
duration = result.data()->duration() * 1000;
|
||||
duration = result.data()->track()->duration() * 1000;
|
||||
|
||||
ui->seekSlider->setRange( 0, duration );
|
||||
ui->seekSlider->setValue( 0 );
|
||||
@ -263,18 +263,18 @@ AudioControls::onPlaybackLoading( const Tomahawk::result_ptr& result )
|
||||
{
|
||||
if ( !m_currentTrack.isNull() )
|
||||
{
|
||||
disconnect( m_currentTrack->toQuery().data(), SIGNAL( updated() ), this, SLOT( onCoverUpdated() ) );
|
||||
disconnect( m_currentTrack->toQuery().data(), SIGNAL( socialActionsLoaded() ), this, SLOT( onSocialActionsLoaded() ) );
|
||||
disconnect( m_currentTrack->track().data(), SIGNAL( updated() ), this, SLOT( onCoverUpdated() ) );
|
||||
disconnect( m_currentTrack->track().data(), SIGNAL( socialActionsLoaded() ), this, SLOT( onSocialActionsLoaded() ) );
|
||||
}
|
||||
|
||||
m_currentTrack = result;
|
||||
connect( m_currentTrack->toQuery().data(), SIGNAL( updated() ), SLOT( onCoverUpdated() ) );
|
||||
connect( m_currentTrack->toQuery().data(), SIGNAL( socialActionsLoaded() ), SLOT( onSocialActionsLoaded() ) );
|
||||
connect( m_currentTrack->track().data(), SIGNAL( updated() ), SLOT( onCoverUpdated() ) );
|
||||
connect( m_currentTrack->track().data(), SIGNAL( socialActionsLoaded() ), SLOT( onSocialActionsLoaded() ) );
|
||||
|
||||
ui->artistTrackLabel->setResult( result );
|
||||
ui->albumLabel->setResult( result );
|
||||
|
||||
const QString duration = TomahawkUtils::timeToString( result.data()->duration() );
|
||||
const QString duration = TomahawkUtils::timeToString( result.data()->track()->duration() );
|
||||
ui->timeLabel->setFixedWidth( ui->timeLabel->fontMetrics().width( QString( duration.length(), QChar( '0' ) ) ) );
|
||||
ui->timeLabel->setText( TomahawkUtils::timeToString( 0 ) );
|
||||
ui->timeLeftLabel->setFixedWidth( ui->timeLeftLabel->fontMetrics().width( QString( duration.length() + 1, QChar( '0' ) ) ) );
|
||||
@ -340,10 +340,10 @@ AudioControls::onCoverUpdated()
|
||||
void
|
||||
AudioControls::setCover()
|
||||
{
|
||||
if ( !m_currentTrack->toQuery()->cover( ui->coverImage->size() ).isNull() )
|
||||
if ( !m_currentTrack->track()->cover( ui->coverImage->size() ).isNull() )
|
||||
{
|
||||
QPixmap cover;
|
||||
cover = m_currentTrack->toQuery()->cover( ui->coverImage->size() );
|
||||
cover = m_currentTrack->track()->cover( ui->coverImage->size() );
|
||||
ui->coverImage->setPixmap( TomahawkUtils::createRoundedImage( cover, QSize( 0, 0 ) ), false );
|
||||
}
|
||||
else
|
||||
@ -384,7 +384,7 @@ AudioControls::onInfoSystemPushTypesUpdated( InfoSystem::InfoTypeSet supportedTy
|
||||
void
|
||||
AudioControls::setSocialActions()
|
||||
{
|
||||
if ( m_currentTrack->toQuery()->loved() )
|
||||
if ( m_currentTrack->track()->loved() )
|
||||
{
|
||||
ui->loveButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::Loved, TomahawkUtils::Original, QSize( 20, 20 ) ) );
|
||||
ui->loveButton->setChecked( true );
|
||||
@ -479,7 +479,7 @@ AudioControls::onPlaybackTimer( qint64 msElapsed )
|
||||
if ( seconds != m_lastTextSecondShown )
|
||||
{
|
||||
ui->timeLabel->setText( TomahawkUtils::timeToString( seconds ) );
|
||||
ui->timeLeftLabel->setText( "-" + TomahawkUtils::timeToString( m_currentTrack->duration() - seconds ) );
|
||||
ui->timeLeftLabel->setText( "-" + TomahawkUtils::timeToString( m_currentTrack->track()->duration() - seconds ) );
|
||||
m_lastTextSecondShown = seconds;
|
||||
}
|
||||
|
||||
@ -656,14 +656,14 @@ AudioControls::onShuffleClicked()
|
||||
void
|
||||
AudioControls::onArtistClicked()
|
||||
{
|
||||
ViewManager::instance()->show( m_currentTrack->artist() );
|
||||
ViewManager::instance()->show( m_currentTrack->track()->artistPtr() );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AudioControls::onAlbumClicked()
|
||||
{
|
||||
ViewManager::instance()->show( m_currentTrack->album() );
|
||||
ViewManager::instance()->show( m_currentTrack->track()->albumPtr() );
|
||||
}
|
||||
|
||||
|
||||
@ -742,13 +742,13 @@ AudioControls::onLoveButtonClicked( bool checked )
|
||||
{
|
||||
ui->loveButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::Loved, TomahawkUtils::Original, QSize( 20, 20 ) ) );
|
||||
|
||||
m_currentTrack->toQuery()->setLoved( true );
|
||||
m_currentTrack->track()->setLoved( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->loveButton->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::NotLoved, TomahawkUtils::Original, QSize( 20, 20 ) ) );
|
||||
|
||||
m_currentTrack->toQuery()->setLoved( false );
|
||||
m_currentTrack->track()->setLoved( false );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,11 +81,11 @@ Scrobbler::trackStarted( const Tomahawk::result_ptr& track )
|
||||
}
|
||||
|
||||
Tomahawk::InfoSystem::InfoStringHash trackInfo;
|
||||
trackInfo["title"] = track->track();
|
||||
trackInfo["artist"] = track->artist()->name();
|
||||
trackInfo["album"] = track->album()->name();
|
||||
trackInfo["duration"] = QString::number( track->duration() );
|
||||
trackInfo["albumpos"] = QString::number( track->albumpos() );
|
||||
trackInfo["title"] = track->track()->track();
|
||||
trackInfo["artist"] = track->track()->artist();
|
||||
trackInfo["album"] = track->track()->album();
|
||||
trackInfo["duration"] = QString::number( track->track()->duration() );
|
||||
trackInfo["albumpos"] = QString::number( track->track()->albumpos() );
|
||||
|
||||
QVariantMap playInfo;
|
||||
playInfo["trackinfo"] = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo );
|
||||
@ -99,10 +99,10 @@ Scrobbler::trackStarted( const Tomahawk::result_ptr& track )
|
||||
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo( pushData );
|
||||
|
||||
// liblastfm forces 0-length tracks to scrobble after 4 minutes, stupid.
|
||||
if ( track->duration() == 0 )
|
||||
if ( track->track()->duration() == 0 )
|
||||
m_scrobblePoint = lastfm::ScrobblePoint( 30 );
|
||||
else
|
||||
m_scrobblePoint = lastfm::ScrobblePoint( track->duration() / 2 );
|
||||
m_scrobblePoint = lastfm::ScrobblePoint( track->track()->duration() / 2 );
|
||||
}
|
||||
|
||||
|
||||
|
@ -62,7 +62,7 @@ SocialWidget::SocialWidget( QWidget* parent )
|
||||
|
||||
|
||||
m_timer.setSingleShot( true );
|
||||
connect( &m_timer, SIGNAL( timeout() ), this, SLOT( hide() ) );
|
||||
connect( &m_timer, SIGNAL( timeout() ), SLOT( hide() ) );
|
||||
|
||||
ui->charsLeftLabel->setForegroundRole( QPalette::Text );
|
||||
ui->charsLeftLabel->setStyleSheet( "text: black" );
|
||||
@ -109,7 +109,7 @@ SocialWidget::show( int timeoutSecs )
|
||||
if ( !isEnabled() )
|
||||
return;
|
||||
|
||||
if( timeoutSecs > 0 )
|
||||
if ( timeoutSecs > 0 )
|
||||
m_timer.start( timeoutSecs * 1000 );
|
||||
|
||||
QWidget::show();
|
||||
@ -145,9 +145,9 @@ SocialWidget::paintEvent( QPaintEvent* event )
|
||||
|
||||
QRect r = contentsRect();
|
||||
outline.addRoundedRect( r, TomahawkUtils::POPUP_ROUNDING_RADIUS, TomahawkUtils::POPUP_ROUNDING_RADIUS );
|
||||
outline.moveTo( r.right() - ARROW_HEIGHT * 2, r.bottom()+1 );
|
||||
outline.lineTo( r.right() - ARROW_HEIGHT * 3, r.bottom()+1 + ARROW_HEIGHT );
|
||||
outline.lineTo( r.right() - ARROW_HEIGHT * 4, r.bottom()+1 );
|
||||
outline.moveTo( r.right() - ARROW_HEIGHT * 2, r.bottom() + 1 );
|
||||
outline.lineTo( r.right() - ARROW_HEIGHT * 3, r.bottom() + 1 + ARROW_HEIGHT );
|
||||
outline.lineTo( r.right() - ARROW_HEIGHT * 4, r.bottom() + 1 );
|
||||
|
||||
TomahawkUtils::drawCompositedPopup( this,
|
||||
outline,
|
||||
@ -163,10 +163,10 @@ SocialWidget::onShortLinkReady( const QUrl& longUrl, const QUrl& shortUrl, const
|
||||
Q_UNUSED( longUrl );
|
||||
Q_UNUSED( callbackObj );
|
||||
|
||||
if ( m_query->album().isEmpty() )
|
||||
ui->textEdit->setText( tr( "Listening to \"%1\" by %2. %3" ).arg( m_query->track() ).arg( m_query->artist() ).arg( shortUrl.toString() ) );
|
||||
if ( m_query->track()->album().isEmpty() )
|
||||
ui->textEdit->setText( tr( "Listening to \"%1\" by %2. %3" ).arg( m_query->track()->track() ).arg( m_query->track()->artist() ).arg( shortUrl.toString() ) );
|
||||
else
|
||||
ui->textEdit->setText( tr( "Listening to \"%1\" by %2 on \"%3\". %4" ).arg( m_query->track() ).arg( m_query->artist() ).arg( m_query->album() ).arg( shortUrl.toString() ) );
|
||||
ui->textEdit->setText( tr( "Listening to \"%1\" by %2 on \"%3\". %4" ).arg( m_query->track()->track() ).arg( m_query->track()->artist() ).arg( m_query->track()->album() ).arg( shortUrl.toString() ) );
|
||||
}
|
||||
|
||||
|
||||
@ -174,7 +174,7 @@ void
|
||||
SocialWidget::setQuery( const Tomahawk::query_ptr& query )
|
||||
{
|
||||
m_query = query;
|
||||
ui->coverImage->setPixmap( TomahawkUtils::addDropShadow( query->cover( ui->coverImage->size() ), ui->coverImage->size() ) );
|
||||
ui->coverImage->setPixmap( TomahawkUtils::addDropShadow( query->track()->cover( ui->coverImage->size() ), ui->coverImage->size() ) );
|
||||
onShortLinkReady( QString(), QString(), QVariant() );
|
||||
onChanged();
|
||||
|
||||
@ -200,9 +200,9 @@ SocialWidget::accept()
|
||||
QVariantMap shareInfo;
|
||||
Tomahawk::InfoSystem::InfoStringHash trackInfo;
|
||||
|
||||
trackInfo["title"] = m_query->track();
|
||||
trackInfo["artist"] = m_query->artist();
|
||||
trackInfo["album"] = m_query->album();
|
||||
trackInfo["title"] = m_query->track()->track();
|
||||
trackInfo["artist"] = m_query->track()->artist();
|
||||
trackInfo["album"] = m_query->track()->album();
|
||||
|
||||
shareInfo["trackinfo"] = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo );
|
||||
shareInfo["message"] = ui->textEdit->toPlainText();
|
||||
|
@ -155,14 +155,14 @@ TomahawkTrayIcon::setResult( const Tomahawk::result_ptr& result )
|
||||
{
|
||||
if ( m_currentTrack )
|
||||
{
|
||||
disconnect( m_currentTrack->toQuery().data(), SIGNAL( socialActionsLoaded() ), this, SLOT( onSocialActionsLoaded() ) );
|
||||
disconnect( m_currentTrack->track().data(), SIGNAL( socialActionsLoaded() ), this, SLOT( onSocialActionsLoaded() ) );
|
||||
}
|
||||
|
||||
m_currentTrack = result;
|
||||
refreshToolTip();
|
||||
|
||||
if ( result )
|
||||
connect( result->toQuery().data(), SIGNAL( socialActionsLoaded() ), SLOT( onSocialActionsLoaded() ), Qt::UniqueConnection );
|
||||
connect( result->track().data(), SIGNAL( socialActionsLoaded() ), SLOT( onSocialActionsLoaded() ), Qt::UniqueConnection );
|
||||
|
||||
onSocialActionsLoaded();
|
||||
onStopContinueAfterTrackChanged();
|
||||
@ -172,7 +172,7 @@ TomahawkTrayIcon::setResult( const Tomahawk::result_ptr& result )
|
||||
void
|
||||
TomahawkTrayIcon::onStopContinueAfterTrackChanged()
|
||||
{
|
||||
if ( m_currentTrack && m_currentTrack->toQuery()->equals( AudioEngine::instance()->stopAfterTrack() ) )
|
||||
if ( m_currentTrack && AudioEngine::instance()->stopAfterTrack() && m_currentTrack->track()->equals( AudioEngine::instance()->stopAfterTrack()->track() ) )
|
||||
m_stopContinueAfterTrackAction->setText( tr( "&Continue Playback after current Track" ) );
|
||||
else
|
||||
m_stopContinueAfterTrackAction->setText( tr( "&Stop Playback after current Track" ) );
|
||||
@ -191,7 +191,7 @@ TomahawkTrayIcon::refreshToolTip()
|
||||
QString tip;
|
||||
if ( !m_currentTrack.isNull() )
|
||||
{
|
||||
tip = m_currentTrack->artist()->name() + " " + QChar( 8211 ) /*en dash*/ + " " + m_currentTrack->track();
|
||||
tip = m_currentTrack->track()->artist() + " " + QChar( 8211 ) /*en dash*/ + " " + m_currentTrack->track()->track();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -294,7 +294,7 @@ TomahawkTrayIcon::loveTrackTriggered()
|
||||
if ( !m_currentTrack )
|
||||
return;
|
||||
|
||||
m_currentTrack->toQuery()->setLoved( !m_currentTrack->toQuery()->loved() );
|
||||
m_currentTrack->track()->setLoved( !m_currentTrack->track()->loved() );
|
||||
}
|
||||
|
||||
|
||||
@ -304,7 +304,7 @@ TomahawkTrayIcon::stopContinueAfterTrackActionTriggered()
|
||||
if ( !m_currentTrack )
|
||||
return;
|
||||
|
||||
if ( !m_currentTrack->toQuery()->equals( AudioEngine::instance()->stopAfterTrack() ) )
|
||||
if ( !AudioEngine::instance()->stopAfterTrack() || !m_currentTrack->track()->equals( AudioEngine::instance()->stopAfterTrack()->track() ) )
|
||||
AudioEngine::instance()->setStopAfterTrack( m_currentTrack->toQuery() );
|
||||
else
|
||||
AudioEngine::instance()->setStopAfterTrack( Tomahawk::query_ptr() );
|
||||
@ -320,7 +320,7 @@ TomahawkTrayIcon::onSocialActionsLoaded()
|
||||
if ( !m_currentTrack )
|
||||
return;
|
||||
|
||||
if ( m_currentTrack->toQuery()->loved() )
|
||||
if ( m_currentTrack->track()->loved() )
|
||||
{
|
||||
m_loveTrackAction->setText( tr( "Un-&Love" ) );
|
||||
m_loveTrackAction->setIcon( QIcon( RESPATH "images/not-loved.svg" ) );
|
||||
|
@ -709,7 +709,7 @@ TomahawkWindow::winEvent( MSG* msg, long* result )
|
||||
tLog() << TB_PRESSED << "Love";
|
||||
if ( !AudioEngine::instance()->currentTrack().isNull() )
|
||||
{
|
||||
AudioEngine::instance()->currentTrack()->toQuery()->setLoved( !AudioEngine::instance()->currentTrack()->toQuery()->loved() );
|
||||
AudioEngine::instance()->currentTrack()->track()->setLoved( !AudioEngine::instance()->currentTrack()->track()->loved() );
|
||||
updateWindowsLoveButton();
|
||||
}
|
||||
break;
|
||||
@ -756,7 +756,7 @@ TomahawkWindow::audioStateChanged( AudioState newState, AudioState oldState )
|
||||
{
|
||||
if ( !AudioEngine::instance()->currentTrack().isNull() )
|
||||
{
|
||||
disconnect( AudioEngine::instance()->currentTrack()->toQuery().data(), SIGNAL( socialActionsLoaded() ), this, SLOT( updateWindowsLoveButton() ) );
|
||||
disconnect( AudioEngine::instance()->currentTrack()->track().data(), SIGNAL( socialActionsLoaded() ), this, SLOT( updateWindowsLoveButton() ) );
|
||||
}
|
||||
|
||||
m_thumbButtons[TP_PLAY_PAUSE].hIcon = thumbIcon(TomahawkUtils::PlayButton);
|
||||
@ -785,7 +785,7 @@ TomahawkWindow::updateWindowsLoveButton()
|
||||
#ifdef HAVE_THUMBBUTTON
|
||||
if ( m_taskbarList == 0 )
|
||||
return;
|
||||
if ( !AudioEngine::instance()->currentTrack().isNull() && AudioEngine::instance()->currentTrack()->toQuery()->loved() )
|
||||
if ( !AudioEngine::instance()->currentTrack().isNull() && AudioEngine::instance()->currentTrack()->track()->loved() )
|
||||
{
|
||||
m_thumbButtons[TP_LOVE].hIcon = thumbIcon(TomahawkUtils::Loved);
|
||||
m_thumbButtons[TP_LOVE].szTip[ tr( "Unlove" ).toWCharArray( m_thumbButtons[TP_LOVE].szTip ) ] = 0;
|
||||
@ -1129,7 +1129,7 @@ TomahawkWindow::audioStarted()
|
||||
ActionCollection::instance()->getAction( "stop" )->setEnabled( true );
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
connect( AudioEngine::instance()->currentTrack()->toQuery().data(), SIGNAL( socialActionsLoaded() ), SLOT( updateWindowsLoveButton() ) );
|
||||
connect( AudioEngine::instance()->currentTrack()->track().data(), SIGNAL( socialActionsLoaded() ), SLOT( updateWindowsLoveButton() ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1138,7 +1138,7 @@ void
|
||||
TomahawkWindow::audioFinished()
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
disconnect( AudioEngine::instance()->currentTrack()->toQuery().data(), SIGNAL( socialActionsLoaded() ), this, SLOT( updateWindowsLoveButton() ) );
|
||||
disconnect( AudioEngine::instance()->currentTrack()->track().data(), SIGNAL( socialActionsLoaded() ), this, SLOT( updateWindowsLoveButton() ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1179,7 +1179,7 @@ TomahawkWindow::setWindowTitle( const QString& title )
|
||||
QMainWindow::setWindowTitle( title );
|
||||
else
|
||||
{
|
||||
QString s = tr( "%1 by %2", "track, artist name" ).arg( m_currentTrack->track(), m_currentTrack->artist()->name() );
|
||||
QString s = tr( "%1 by %2", "track, artist name" ).arg( m_currentTrack->track()->track(), m_currentTrack->track()->artist() );
|
||||
QMainWindow::setWindowTitle( tr( "%1 - %2", "current track, some window title" ).arg( s, title ) );
|
||||
}
|
||||
}
|
||||
|
@ -267,16 +267,16 @@ MprisPlugin::metadata() const
|
||||
if ( track )
|
||||
{
|
||||
metadataMap.insert( "mpris:trackid", QVariant::fromValue(QDBusObjectPath(QString( "/track/" ) + track->id().replace( "-", "" ))) );
|
||||
metadataMap.insert( "mpris:length", static_cast<qlonglong>(track->duration()) * 1000000 );
|
||||
metadataMap.insert( "xesam:album", track->album()->name() );
|
||||
metadataMap.insert( "xesam:artist", QStringList( track->artist()->name() ) );
|
||||
metadataMap.insert( "xesam:title", track->track() );
|
||||
metadataMap.insert( "mpris:length", static_cast<qlonglong>(track->track()->duration()) * 1000000 );
|
||||
metadataMap.insert( "xesam:album", track->track()->album() );
|
||||
metadataMap.insert( "xesam:artist", QStringList( track->track()->artist() ) );
|
||||
metadataMap.insert( "xesam:title", track->track()->track() );
|
||||
|
||||
// Only return art if tempfile exists, and if its name contains the same "artist_album_tomahawk_cover.png"
|
||||
if ( !m_coverTempFile.isEmpty() )
|
||||
{
|
||||
QFile coverFile( m_coverTempFile );
|
||||
if ( coverFile.exists() && coverFile.fileName().contains( track->artist()->name() + "_" + track->album()->name() + "_tomahawk_cover.png" ) )
|
||||
if ( coverFile.exists() && coverFile.fileName().contains( track->track()->artist() + "_" + track->track()->album() + "_tomahawk_cover.png" ) )
|
||||
metadataMap.insert( "mpris:artUrl", QString( QUrl::fromLocalFile( m_coverTempFile ).toEncoded() ) );
|
||||
}
|
||||
}
|
||||
|
@ -191,12 +191,10 @@ AlbumPlaylistInterface::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData re
|
||||
|
||||
foreach ( const QString& trackName, tracks )
|
||||
{
|
||||
query_ptr query = Query::get( inputInfo[ "artist" ], trackName, inputInfo[ "album" ] );
|
||||
if ( query.isNull() )
|
||||
continue;
|
||||
|
||||
query->setAlbumPos( trackNo++ );
|
||||
ql << query;
|
||||
track_ptr track = Track::get( inputInfo[ "artist" ], trackName, inputInfo[ "album" ], 0, QString(), trackNo++ );
|
||||
query_ptr query = Query::get( track );
|
||||
if ( query )
|
||||
ql << query;
|
||||
}
|
||||
Pipeline::instance()->resolve( ql );
|
||||
|
||||
|
@ -155,9 +155,10 @@ ArtistPlaylistInterface::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData r
|
||||
|
||||
foreach ( const QString& trackName, tracks )
|
||||
{
|
||||
query_ptr query = Query::get( inputInfo[ "artist" ], trackName, inputInfo[ "album" ] );
|
||||
query->setAlbumPos( trackNo++ );
|
||||
ql << query;
|
||||
track_ptr track = Track::get( inputInfo[ "artist" ], trackName, inputInfo[ "album" ], 0, QString(), trackNo++ );
|
||||
query_ptr query = Query::get( track );
|
||||
if ( query )
|
||||
ql << query;
|
||||
}
|
||||
Pipeline::instance()->resolve( ql );
|
||||
|
||||
|
@ -133,7 +133,7 @@ ContextMenu::setQueries( const QList<Tomahawk::query_ptr>& queries )
|
||||
m_loveAction = addAction( tr( "&Love" ) );
|
||||
m_sigmap->setMapping( m_loveAction, ActionLove );
|
||||
|
||||
connect( queries.first().data(), SIGNAL( socialActionsLoaded() ), SLOT( onSocialActionsLoaded() ) );
|
||||
connect( queries.first()->track().data(), SIGNAL( socialActionsLoaded() ), SLOT( onSocialActionsLoaded() ) );
|
||||
onSocialActionsLoaded();
|
||||
}
|
||||
|
||||
@ -142,15 +142,15 @@ ContextMenu::setQueries( const QList<Tomahawk::query_ptr>& queries )
|
||||
if ( m_supportedActions & ActionPage && itemCount() == 1 )
|
||||
{
|
||||
// Ampersands need to be escaped as they indicate a keyboard shortcut
|
||||
const QString track = m_queries.first()->track().replace( QString( "&" ), QString( "&&" ) );
|
||||
const QString track = m_queries.first()->track()->track().replace( QString( "&" ), QString( "&&" ) );
|
||||
m_sigmap->setMapping( addAction( ImageRegistry::instance()->icon( RESPATH "images/track-icon.svg" ),
|
||||
tr( "&Go to \"%1\"" ).arg( track ) ), ActionTrackPage );
|
||||
if ( !m_queries.first()->album().isEmpty() ) {
|
||||
const QString album = m_queries.first()->album().replace( QString( "&" ), QString( "&&" ) );
|
||||
if ( !m_queries.first()->track()->album().isEmpty() ) {
|
||||
const QString album = m_queries.first()->track()->album().replace( QString( "&" ), QString( "&&" ) );
|
||||
m_sigmap->setMapping( addAction( ImageRegistry::instance()->icon( RESPATH "images/album-icon.svg" ),
|
||||
tr( "Go to \"%1\"" ).arg( album ) ), ActionAlbumPage );
|
||||
}
|
||||
const QString artist = m_queries.first()->artist().replace( QString( "&" ), QString( "&&" ) );
|
||||
const QString artist = m_queries.first()->track()->artist().replace( QString( "&" ), QString( "&&" ) );
|
||||
m_sigmap->setMapping( addAction( ImageRegistry::instance()->icon( RESPATH "images/artist-icon.svg" ),
|
||||
tr( "Go to \"%1\"" ).arg( artist ) ), ActionArtistPage );
|
||||
}
|
||||
@ -302,7 +302,7 @@ ContextMenu::onTriggered( int action )
|
||||
break;
|
||||
|
||||
case ActionLove:
|
||||
m_queries.first()->setLoved( !m_queries.first()->loved() );
|
||||
m_queries.first()->track()->setLoved( !m_queries.first()->track()->loved() );
|
||||
break;
|
||||
|
||||
case ActionStopAfter:
|
||||
@ -322,6 +322,8 @@ ContextMenu::onTriggered( int action )
|
||||
default:
|
||||
emit triggered( action );
|
||||
}
|
||||
|
||||
clear();
|
||||
}
|
||||
|
||||
|
||||
@ -375,14 +377,13 @@ ContextMenu::openPage( MenuActions action )
|
||||
}
|
||||
else
|
||||
{
|
||||
const Tomahawk::artist_ptr artist = Artist::get( m_queries.first()->artist(), false );
|
||||
if ( action == ActionArtistPage )
|
||||
{
|
||||
ViewManager::instance()->show( artist );
|
||||
ViewManager::instance()->show( m_queries.first()->track()->artistPtr() );
|
||||
}
|
||||
else if ( action == ActionAlbumPage )
|
||||
{
|
||||
ViewManager::instance()->show( Album::get( artist, m_queries.first()->album(), false ) );
|
||||
ViewManager::instance()->show( m_queries.first()->track()->albumPtr() );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -410,7 +411,7 @@ ContextMenu::onSocialActionsLoaded()
|
||||
if ( m_queries.isEmpty() || m_queries.first().isNull() )
|
||||
return;
|
||||
|
||||
if ( m_loveAction && m_queries.first()->loved() )
|
||||
if ( m_loveAction && m_queries.first()->track()->loved() )
|
||||
{
|
||||
m_loveAction->setText( tr( "Un-&Love" ) );
|
||||
m_loveAction->setIcon( ImageRegistry::instance()->icon( RESPATH "images/not-loved.svg" ) );
|
||||
|
@ -360,15 +360,15 @@ DropJob::tracksFromQueryList( const QMimeData* data )
|
||||
|
||||
if ( m_top10 )
|
||||
{
|
||||
queries << getTopTen( query->data()->artist() );
|
||||
queries << getTopTen( query->data()->track()->artist() );
|
||||
}
|
||||
else if ( m_getWholeArtists )
|
||||
{
|
||||
queries << getArtist( query->data()->artist() );
|
||||
queries << getArtist( query->data()->track()->artist() );
|
||||
}
|
||||
else if ( m_getWholeAlbums )
|
||||
{
|
||||
queries << getAlbum( query->data()->artist(), query->data()->album() );
|
||||
queries << getAlbum( query->data()->track()->artist(), query->data()->track()->album() );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -396,24 +396,23 @@ DropJob::tracksFromResultList( const QMimeData* data )
|
||||
result_ptr* result = reinterpret_cast<result_ptr*>(qptr);
|
||||
if ( result && !result->isNull() )
|
||||
{
|
||||
tDebug() << "Dropped result item:" << result->data()->artist()->name() << "-" << result->data()->track();
|
||||
query_ptr q = result->data()->toQuery();
|
||||
tDebug() << "Dropped result item:" << result->data()->track()->artist() << "-" << result->data()->track()->track();
|
||||
|
||||
if ( m_top10 )
|
||||
{
|
||||
getTopTen( q->artist() );
|
||||
getTopTen( result->data()->track()->artist() );
|
||||
}
|
||||
else if ( m_getWholeArtists )
|
||||
{
|
||||
queries << getArtist( q->artist() );
|
||||
queries << getArtist( result->data()->track()->artist() );
|
||||
}
|
||||
else if ( m_getWholeAlbums )
|
||||
{
|
||||
queries << getAlbum( q->artist(), q->album() );
|
||||
queries << getAlbum( result->data()->track()->artist(), result->data()->track()->album() );
|
||||
}
|
||||
else
|
||||
{
|
||||
queries << q;
|
||||
queries << result->data()->toQuery();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -488,7 +487,7 @@ DropJob::tracksFromMixedData( const QMimeData *data )
|
||||
QDataStream singleStream( &singleData, QIODevice::WriteOnly );
|
||||
|
||||
QMimeData singleMimeData;
|
||||
if ( mimeType == "application/tomahawk.query.list" )
|
||||
if ( mimeType == "application/tomahawk.query.list" )
|
||||
{
|
||||
qlonglong query;
|
||||
stream >> query;
|
||||
@ -798,7 +797,7 @@ void
|
||||
DropJob::onTracksAdded( const QList<Tomahawk::query_ptr>& tracksList )
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO << tracksList.count();
|
||||
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
/* if ( results.isEmpty() )
|
||||
{
|
||||
@ -842,7 +841,7 @@ DropJob::removeDuplicates()
|
||||
m_resultList.removeOne( item );
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
foreach( const Tomahawk::query_ptr &tmpItem, list )
|
||||
{
|
||||
if ( tmpItem.isNull() )
|
||||
@ -850,10 +849,10 @@ DropJob::removeDuplicates()
|
||||
list.removeOne( tmpItem );
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( item->album() == tmpItem->album()
|
||||
&& item->artist() == tmpItem->artist()
|
||||
&& item->track() == tmpItem->track() )
|
||||
|
||||
if ( item->track()->album() == tmpItem->track()->album()
|
||||
&& item->track()->artist() == tmpItem->track()->artist()
|
||||
&& item->track()->track() == tmpItem->track()->track() )
|
||||
{
|
||||
if ( item->playable() && !tmpItem->playable() )
|
||||
list.replace( list.indexOf( tmpItem ), item );
|
||||
@ -882,7 +881,7 @@ DropJob::removeRemoteSources()
|
||||
m_resultList.removeOne( item );
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
bool hasLocalSource = false;
|
||||
foreach ( const Tomahawk::result_ptr& result, item->results() )
|
||||
{
|
||||
|
@ -328,9 +328,7 @@ EchonestCatalogSynchronizer::loadedResults( const QList<result_ptr>& results )
|
||||
|
||||
qDebug() << "Metadata for item:" << result->fileId();
|
||||
|
||||
const QString artist = result->artist().isNull() ? QString() : result->artist()->name();
|
||||
const QString album = result->album().isNull() ? QString() : result->album()->name();
|
||||
rawTracks << ( QStringList() << QString::number( result->fileId() ) << result->track() << artist << album );
|
||||
rawTracks << ( QStringList() << QString::number( result->fileId() ) << result->track()->track() << result->track()->artist() << result->track()->album() );
|
||||
}
|
||||
rawTracksAdd( rawTracks );
|
||||
}
|
||||
|
@ -89,9 +89,9 @@ GlobalActionManager::~GlobalActionManager()
|
||||
QUrl
|
||||
GlobalActionManager::openLinkFromQuery( const query_ptr& query ) const
|
||||
{
|
||||
QString title = query->displayQuery()->track();
|
||||
QString artist = query->displayQuery()->artist();
|
||||
QString album = query->displayQuery()->album();
|
||||
QString title = query->track()->track();
|
||||
QString artist = query->track()->artist();
|
||||
QString album = query->track()->album();
|
||||
|
||||
return openLink( title, artist, album );
|
||||
}
|
||||
@ -178,9 +178,9 @@ GlobalActionManager::getShortLink( const playlist_ptr& pl )
|
||||
continue;
|
||||
|
||||
QVariantMap track;
|
||||
track[ "title" ] = pl->query()->track();
|
||||
track[ "creator" ] = pl->query()->artist();
|
||||
track[ "album" ] = pl->query()->album();
|
||||
track[ "title" ] = pl->query()->track()->track();
|
||||
track[ "creator" ] = pl->query()->track()->artist();
|
||||
track[ "album" ] = pl->query()->track()->album();
|
||||
|
||||
tracks << track;
|
||||
}
|
||||
@ -1341,7 +1341,7 @@ GlobalActionManager::doBookmark( const playlist_ptr& pl, const query_ptr& q )
|
||||
plentry_ptr e( new PlaylistEntry );
|
||||
e->setGuid( uuid() );
|
||||
|
||||
e->setDuration( q->displayQuery()->duration() );
|
||||
e->setDuration( q->track()->duration() );
|
||||
e->setLastmodified( 0 );
|
||||
QString annotation = "";
|
||||
if ( !q->property( "annotation" ).toString().isEmpty() )
|
||||
|
@ -44,8 +44,15 @@
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
PlaylistEntry::PlaylistEntry() {}
|
||||
PlaylistEntry::~PlaylistEntry() {}
|
||||
PlaylistEntry::PlaylistEntry()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
PlaylistEntry::~PlaylistEntry()
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO << m_query->toString();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
@ -179,7 +186,7 @@ Playlist::create( const source_ptr& author,
|
||||
{
|
||||
plentry_ptr p( new PlaylistEntry );
|
||||
p->setGuid( uuid() );
|
||||
p->setDuration( query->duration() );
|
||||
p->setDuration( query->track()->duration() );
|
||||
p->setLastmodified( 0 );
|
||||
p->setAnnotation( query->property( "annotation" ).toString() );
|
||||
p->setQuery( query );
|
||||
@ -435,7 +442,7 @@ Playlist::createNewRevision( const QString& newrev, const QString& oldrev, const
|
||||
qDebug() << "Inserting ordered GUIDs:";
|
||||
foreach( const plentry_ptr& p, entries )
|
||||
{
|
||||
qDebug() << p->guid() << p->query()->track() << p->query()->artist();
|
||||
qDebug() << p->guid() << p->query()->track()->toString();
|
||||
orderedguids << p->guid();
|
||||
}
|
||||
|
||||
@ -558,11 +565,10 @@ Playlist::setNewRevision( const QString& rev,
|
||||
QMap<QString, plentry_ptr> entriesmap;
|
||||
foreach ( const plentry_ptr& p, m_entries )
|
||||
{
|
||||
qDebug() << p->guid() << p->query()->track() << p->query()->artist();
|
||||
tDebug() << p->guid() << p->query()->toString();
|
||||
entriesmap.insert( p->guid(), p );
|
||||
}
|
||||
|
||||
|
||||
// re-build m_entries from neworderedguids. plentries come either from the old m_entries OR addedmap.
|
||||
m_entries.clear();
|
||||
|
||||
@ -705,7 +711,7 @@ Playlist::entriesFromQueries( const QList<Tomahawk::query_ptr>& queries, bool cl
|
||||
plentry_ptr e( new PlaylistEntry() );
|
||||
e->setGuid( uuid() );
|
||||
|
||||
e->setDuration( query->displayQuery()->duration() );
|
||||
e->setDuration( query->track()->duration() );
|
||||
e->setLastmodified( 0 );
|
||||
QString annotation = "";
|
||||
if ( !query->property( "annotation" ).toString().isEmpty() )
|
||||
|
@ -950,7 +950,7 @@ SpotifyAccount::resolverMessage( const QString &msgType, const QVariantMap &msg
|
||||
QList<query_ptr> qs = SpotifyPlaylistUpdater::variantToQueries( tracksList );
|
||||
foreach ( const query_ptr& query, qs )
|
||||
{
|
||||
query->setLoved( love );
|
||||
query->track()->setLoved( love );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -533,7 +533,7 @@ SpotifyPlaylistUpdater::spotifyTracksMoved( const QVariantList& tracks, const QS
|
||||
{
|
||||
qDebug() << "Adding moved track to playlist at pos (end:" << (iter == entries.end());
|
||||
if ( iter != entries.end() )
|
||||
qDebug() << (*iter)->query()->track() << (*iter)->query()->artist();
|
||||
qDebug() << (*iter)->query()->queryTrack()->toString();
|
||||
iter = entries.insert( iter, toMove.takeLast() );
|
||||
}
|
||||
|
||||
@ -661,7 +661,7 @@ SpotifyPlaylistUpdater::onTracksInsertedReturn( const QString& msgType, const QV
|
||||
continue;
|
||||
}
|
||||
|
||||
qDebug() << "Setting annotation for track:" << m_waitingForIds[ pos ]->query()->track() << m_waitingForIds[ pos ]->query()->artist() << trackIdsInserted.at( i ).toString();
|
||||
qDebug() << "Setting annotation for track:" << m_waitingForIds[ pos ]->query()->queryTrack()->toString() << trackIdsInserted.at( i ).toString();
|
||||
m_waitingForIds[ pos ]->setAnnotation( trackIdsInserted.at( i ).toString() );
|
||||
changed << m_waitingForIds[ pos ];
|
||||
}
|
||||
@ -723,9 +723,9 @@ SpotifyPlaylistUpdater::tomahawkTracksMoved( const QList< plentry_ptr >& tracks,
|
||||
}
|
||||
|
||||
qDebug() << Q_FUNC_INFO << "Got tracks moved at position:" << position;
|
||||
foreach ( const plentry_ptr ple, tracks )
|
||||
foreach ( const plentry_ptr& ple, tracks )
|
||||
{
|
||||
qDebug() << ple->query()->track() << ple->query()->artist();
|
||||
qDebug() << ple->query()->queryTrack()->toString();
|
||||
}
|
||||
|
||||
qDebug() << Q_FUNC_INFO << "updating spotify resolver with moved tracks to:" << position;
|
||||
@ -780,9 +780,9 @@ QVariant
|
||||
SpotifyPlaylistUpdater::queryToVariant( const query_ptr& query )
|
||||
{
|
||||
QVariantMap m;
|
||||
m[ "track" ] = query->track();
|
||||
m[ "artist" ] = query->artist();
|
||||
m[ "album" ] = query->album();
|
||||
m[ "track" ] = query->queryTrack()->track();
|
||||
m[ "artist" ] = query->queryTrack()->artist();
|
||||
m[ "album" ] = query->queryTrack()->album();
|
||||
|
||||
if ( !query->property( "annotation" ).isNull() )
|
||||
m[ "id" ] = query->property( "annotation" );
|
||||
|
@ -191,7 +191,7 @@ AudioEngine::stop( AudioErrorCode errorCode )
|
||||
if ( !m_playlist.isNull() )
|
||||
m_playlist.data()->reset();
|
||||
if ( !m_currentTrack.isNull() )
|
||||
emit timerPercentage( ( (double)m_timeElapsed / (double)m_currentTrack->duration() ) * 100.0 );
|
||||
emit timerPercentage( ( (double)m_timeElapsed / (double)m_currentTrack->track()->duration() ) * 100.0 );
|
||||
|
||||
setCurrentTrack( Tomahawk::result_ptr() );
|
||||
|
||||
@ -365,14 +365,14 @@ AudioEngine::sendNowPlayingNotification( const Tomahawk::InfoSystem::InfoType ty
|
||||
return;
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
if ( m_currentTrack->toQuery()->coverLoaded() )
|
||||
if ( m_currentTrack->track()->coverLoaded() )
|
||||
{
|
||||
onNowPlayingInfoReady( type );
|
||||
}
|
||||
else
|
||||
{
|
||||
NewClosure( m_currentTrack->toQuery().data(), SIGNAL( coverChanged() ), const_cast< AudioEngine* >( this ), SLOT( sendNowPlayingNotification( const Tomahawk::InfoSystem::InfoType ) ), type );
|
||||
m_currentTrack->toQuery()->cover( QSize( 0, 0 ), true );
|
||||
NewClosure( m_currentTrack->track().data(), SIGNAL( coverChanged() ), const_cast< AudioEngine* >( this ), SLOT( sendNowPlayingNotification( const Tomahawk::InfoSystem::InfoType ) ), type );
|
||||
m_currentTrack->track()->cover( QSize( 0, 0 ), true );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -382,20 +382,20 @@ void
|
||||
AudioEngine::onNowPlayingInfoReady( const Tomahawk::InfoSystem::InfoType type )
|
||||
{
|
||||
if ( m_currentTrack.isNull() ||
|
||||
m_currentTrack->track().isNull() ||
|
||||
m_currentTrack->artist().isNull() )
|
||||
m_currentTrack->track()->artist().isEmpty() )
|
||||
return;
|
||||
|
||||
QVariantMap playInfo;
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
QImage cover;
|
||||
cover = m_currentTrack->toQuery()->cover( QSize( 0, 0 ) ).toImage();
|
||||
cover = m_currentTrack->track()->cover( QSize( 0, 0 ) ).toImage();
|
||||
if ( !cover.isNull() )
|
||||
{
|
||||
playInfo["cover"] = cover;
|
||||
|
||||
QTemporaryFile* coverTempFile = new QTemporaryFile( QDir::toNativeSeparators( QDir::tempPath() + "/" + m_currentTrack->artist()->name() + "_" + m_currentTrack->album()->name() + "_tomahawk_cover.png" ) );
|
||||
//FIXME!
|
||||
QTemporaryFile* coverTempFile = new QTemporaryFile( QDir::toNativeSeparators( QDir::tempPath() + "/" + m_currentTrack->track()->artist() + "_" + m_currentTrack->track()->album() + "_tomahawk_cover.png" ) );
|
||||
if ( !coverTempFile->open() )
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO << "WARNING: could not write temporary file for cover art!";
|
||||
@ -419,11 +419,11 @@ AudioEngine::onNowPlayingInfoReady( const Tomahawk::InfoSystem::InfoType type )
|
||||
#endif
|
||||
|
||||
Tomahawk::InfoSystem::InfoStringHash trackInfo;
|
||||
trackInfo["title"] = m_currentTrack->track();
|
||||
trackInfo["artist"] = m_currentTrack->artist()->name();
|
||||
trackInfo["album"] = m_currentTrack->album()->name();
|
||||
trackInfo["duration"] = QString::number( m_currentTrack->duration() );
|
||||
trackInfo["albumpos"] = QString::number( m_currentTrack->albumpos() );
|
||||
trackInfo["title"] = m_currentTrack->track()->track();
|
||||
trackInfo["artist"] = m_currentTrack->track()->artist();
|
||||
trackInfo["album"] = m_currentTrack->track()->album();
|
||||
trackInfo["duration"] = QString::number( m_currentTrack->track()->duration() );
|
||||
trackInfo["albumpos"] = QString::number( m_currentTrack->track()->albumpos() );
|
||||
|
||||
playInfo["trackinfo"] = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo );
|
||||
playInfo["private"] = TomahawkSettings::instance()->privateListeningMode();
|
||||
@ -525,7 +525,7 @@ AudioEngine::performLoadTrack( const Tomahawk::result_ptr& result, QSharedPointe
|
||||
|
||||
if ( TomahawkSettings::instance()->privateListeningMode() != TomahawkSettings::FullyPrivate )
|
||||
{
|
||||
DatabaseCommand_LogPlayback* cmd = new DatabaseCommand_LogPlayback( m_currentTrack, DatabaseCommand_LogPlayback::Started );
|
||||
DatabaseCommand_LogPlayback* cmd = new DatabaseCommand_LogPlayback( m_currentTrack->track(), DatabaseCommand_LogPlayback::Started );
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
|
||||
}
|
||||
|
||||
@ -576,9 +576,9 @@ AudioEngine::loadNextTrack()
|
||||
|
||||
Tomahawk::result_ptr result;
|
||||
|
||||
if ( !m_stopAfterTrack.isNull() && !m_currentTrack.isNull() )
|
||||
if ( m_stopAfterTrack && m_currentTrack )
|
||||
{
|
||||
if ( m_stopAfterTrack->equals( m_currentTrack->toQuery() ) )
|
||||
if ( m_stopAfterTrack->track()->equals( m_currentTrack->track() ) )
|
||||
{
|
||||
m_stopAfterTrack.clear();
|
||||
stop();
|
||||
@ -661,7 +661,7 @@ AudioEngine::playItem( Tomahawk::playlistinterface_ptr playlist, const Tomahawk:
|
||||
}
|
||||
|
||||
JobStatusView::instance()->model()->addJob(
|
||||
new ErrorStatusMessage( tr( "Sorry, Tomahawk couldn't find the track '%1' by %2" ).arg( query->track() ).arg( query->artist() ), 15 ) );
|
||||
new ErrorStatusMessage( tr( "Sorry, Tomahawk couldn't find the track '%1' by %2" ).arg( query->queryTrack()->track() ).arg( query->queryTrack()->artist() ), 15 ) );
|
||||
|
||||
if ( isStopped() )
|
||||
emit stopped(); // we do this so the original caller knows we couldn't find this track
|
||||
@ -814,7 +814,7 @@ AudioEngine::onStateChanged( Phonon::State newState, Phonon::State oldState )
|
||||
{
|
||||
if ( m_mediaObject && m_currentTrack )
|
||||
{
|
||||
qint64 duration = m_mediaObject->totalTime() > 0 ? m_mediaObject->totalTime() : m_currentTrack->duration() * 1000;
|
||||
qint64 duration = m_mediaObject->totalTime() > 0 ? m_mediaObject->totalTime() : m_currentTrack->track()->duration() * 1000;
|
||||
stopped = ( duration - 1000 < m_mediaObject->currentTime() );
|
||||
}
|
||||
else
|
||||
@ -876,13 +876,13 @@ AudioEngine::timerTriggered( qint64 time )
|
||||
|
||||
if ( !m_currentTrack.isNull() )
|
||||
{
|
||||
if ( m_currentTrack->duration() == 0 )
|
||||
if ( m_currentTrack->track()->duration() == 0 )
|
||||
{
|
||||
emit timerPercentage( 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
emit timerPercentage( ( (double)m_timeElapsed / (double)m_currentTrack->duration() ) * 100.0 );
|
||||
emit timerPercentage( ( (double)m_timeElapsed / (double)m_currentTrack->track()->duration() ) * 100.0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -993,7 +993,7 @@ AudioEngine::setCurrentTrack( const Tomahawk::result_ptr& result )
|
||||
{
|
||||
if ( m_state != Error && TomahawkSettings::instance()->privateListeningMode() == TomahawkSettings::PublicListening )
|
||||
{
|
||||
DatabaseCommand_LogPlayback* cmd = new DatabaseCommand_LogPlayback( m_currentTrack, DatabaseCommand_LogPlayback::Finished, m_timeElapsed );
|
||||
DatabaseCommand_LogPlayback* cmd = new DatabaseCommand_LogPlayback( m_currentTrack->track(), DatabaseCommand_LogPlayback::Finished, m_timeElapsed );
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
|
||||
}
|
||||
|
||||
|
@ -270,7 +270,7 @@ ContextWidget::setQuery( const Tomahawk::query_ptr& query, bool force )
|
||||
{
|
||||
if ( query.isNull() )
|
||||
return;
|
||||
if ( !force && !m_query.isNull() && query->artist() == m_query->artist() )
|
||||
if ( !force && !m_query.isNull() && query->track()->artist() == m_query->track()->artist() )
|
||||
return;
|
||||
|
||||
m_query = query;
|
||||
|
@ -83,7 +83,7 @@ RelatedArtistsContext::setQuery( const Tomahawk::query_ptr& query )
|
||||
if ( query.isNull() )
|
||||
return;
|
||||
|
||||
setArtist( Artist::get( query->artist(), false ) );
|
||||
setArtist( query->track()->artistPtr() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -91,7 +91,7 @@ TopTracksContext::setQuery( const Tomahawk::query_ptr& query )
|
||||
if ( query.isNull() )
|
||||
return;
|
||||
|
||||
setArtist( Artist::get( query->artist(), false ) );
|
||||
setArtist( query->track()->artistPtr() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -53,7 +53,7 @@ WikipediaContext::setQuery( const Tomahawk::query_ptr& query )
|
||||
if ( query.isNull() )
|
||||
return;
|
||||
|
||||
setArtist( Artist::get( query->artist(), false ) );
|
||||
setArtist( query->track()->artistPtr() );
|
||||
}
|
||||
|
||||
|
||||
@ -87,5 +87,5 @@ LastfmContext::setQuery( const Tomahawk::query_ptr& query )
|
||||
if ( query.isNull() )
|
||||
return;
|
||||
|
||||
setArtist( Artist::get( query->artist(), false ) );
|
||||
setArtist( query->track()->artistPtr() );
|
||||
}
|
||||
|
@ -123,22 +123,15 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi )
|
||||
|
||||
Tomahawk::result_ptr result = Tomahawk::Result::get( url );
|
||||
Tomahawk::query_ptr qry = Tomahawk::Query::get( artist, track, album );
|
||||
Tomahawk::artist_ptr artistptr = Tomahawk::Artist::get( query.value( 14 ).toUInt(), artist );
|
||||
Tomahawk::artist_ptr composerptr = Tomahawk::Artist::get( query.value( 17 ).toUInt(), composer );
|
||||
Tomahawk::album_ptr albumptr = Tomahawk::Album::get( query.value( 15 ).toUInt(), album, artistptr );
|
||||
|
||||
Tomahawk::track_ptr t = Tomahawk::Track::get( artist, track, album, query.value( 6 ).toUInt(), composer, query.value( 13 ).toUInt(), query.value( 12 ).toUInt() );
|
||||
result->setTrack( t );
|
||||
|
||||
result->setTrackId( query.value( 16 ).toUInt() );
|
||||
result->setArtist( artistptr );
|
||||
result->setAlbum( albumptr );
|
||||
result->setTrack( query.value( 3 ).toString() );
|
||||
result->setComposer( composerptr );
|
||||
result->setSize( query.value( 5 ).toUInt() );
|
||||
result->setDuration( query.value( 6 ).toUInt() );
|
||||
result->setBitrate( query.value( 7 ).toUInt() );
|
||||
result->setModificationTime( query.value( 10 ).toUInt() );
|
||||
result->setMimetype( query.value( 11 ).toString() );
|
||||
result->setDiscNumber( query.value( 12 ).toUInt() );
|
||||
result->setAlbumPos( query.value( 13 ).toUInt() );
|
||||
result->setScore( 1.0 );
|
||||
result->setCollection( s->dbCollection() );
|
||||
|
||||
|
@ -81,7 +81,7 @@ DatabaseCommand_Resolve::resolve( DatabaseImpl* lib )
|
||||
|
||||
if ( tracks.length() == 0 )
|
||||
{
|
||||
qDebug() << "No candidates found in first pass, aborting resolve" << m_query->artist() << m_query->track();
|
||||
qDebug() << "No candidates found in first pass, aborting resolve" << m_query->queryTrack()->toString();
|
||||
emit results( m_query->id(), res );
|
||||
return;
|
||||
}
|
||||
@ -142,32 +142,23 @@ DatabaseCommand_Resolve::resolve( DatabaseImpl* lib )
|
||||
url = QString( "servent://%1\t%2" ).arg( s->nodeId() ).arg( url );
|
||||
}
|
||||
|
||||
bool cached = Tomahawk::Result::isCached( url );
|
||||
Tomahawk::result_ptr result = Tomahawk::Result::get( url );
|
||||
if ( cached )
|
||||
if ( result->isValid() )
|
||||
{
|
||||
qDebug() << "Result already cached:" << result->toString();
|
||||
tDebug( LOGVERBOSE ) << "Result already cached:" << result->toString();
|
||||
res << result;
|
||||
continue;
|
||||
}
|
||||
|
||||
Tomahawk::artist_ptr artist = Tomahawk::Artist::get( files_query.value( 18 ).toUInt(), files_query.value( 12 ).toString() );
|
||||
Tomahawk::album_ptr album = Tomahawk::Album::get( files_query.value( 19 ).toUInt(), files_query.value( 13 ).toString(), artist );
|
||||
Tomahawk::artist_ptr composer = Tomahawk::Artist::get( files_query.value( 20 ).toUInt(), files_query.value( 15 ).toString() );
|
||||
track_ptr track = Track::get( files_query.value( 12 ).toString(), files_query.value( 14 ).toString(), files_query.value( 13 ).toString(), files_query.value( 5 ).toUInt(), files_query.value( 15 ).toString(), files_query.value( 17 ).toUInt(), files_query.value( 11 ).toUInt() );
|
||||
result->setTrack( track );
|
||||
|
||||
result->setModificationTime( files_query.value( 1 ).toUInt() );
|
||||
result->setSize( files_query.value( 2 ).toUInt() );
|
||||
result->setMimetype( files_query.value( 4 ).toString() );
|
||||
result->setDuration( files_query.value( 5 ).toUInt() );
|
||||
result->setBitrate( files_query.value( 6 ).toUInt() );
|
||||
result->setArtist( artist );
|
||||
result->setComposer( composer );
|
||||
result->setAlbum( album );
|
||||
result->setDiscNumber( files_query.value( 11 ).toUInt() );
|
||||
result->setTrack( files_query.value( 14 ).toString() );
|
||||
result->setRID( uuid() );
|
||||
result->setAlbumPos( files_query.value( 17 ).toUInt() );
|
||||
result->setTrackId( files_query.value( 9 ).toUInt() );
|
||||
result->setRID( uuid() );
|
||||
|
||||
TomahawkSqlQuery attrQuery = lib->newquery();
|
||||
QVariantMap attr;
|
||||
@ -290,22 +281,14 @@ DatabaseCommand_Resolve::fullTextResolve( DatabaseImpl* lib )
|
||||
continue;
|
||||
}
|
||||
|
||||
Tomahawk::artist_ptr artist = Tomahawk::Artist::get( files_query.value( 18 ).toUInt(), files_query.value( 12 ).toString() );
|
||||
Tomahawk::album_ptr album = Tomahawk::Album::get( files_query.value( 19 ).toUInt(), files_query.value( 13 ).toString(), artist );
|
||||
Tomahawk::artist_ptr composer = Tomahawk::Artist::get( files_query.value( 20 ).toUInt(), files_query.value( 15 ).toString() );
|
||||
track_ptr track = Track::get( files_query.value( 12 ).toString(), files_query.value( 14 ).toString(), files_query.value( 13 ).toString(), files_query.value( 5 ).toUInt(), files_query.value( 15 ).toString(), files_query.value( 17 ).toUInt(), files_query.value( 11 ).toUInt() );
|
||||
result->setTrack( track );
|
||||
|
||||
result->setModificationTime( files_query.value( 1 ).toUInt() );
|
||||
result->setSize( files_query.value( 2 ).toUInt() );
|
||||
result->setMimetype( files_query.value( 4 ).toString() );
|
||||
result->setDuration( files_query.value( 5 ).toUInt() );
|
||||
result->setBitrate( files_query.value( 6 ).toUInt() );
|
||||
result->setArtist( artist );
|
||||
result->setComposer( composer );
|
||||
result->setAlbum( album );
|
||||
result->setDiscNumber( files_query.value( 11 ).toUInt() );
|
||||
result->setTrack( files_query.value( 14 ).toString() );
|
||||
result->setRID( uuid() );
|
||||
result->setAlbumPos( files_query.value( 17 ).toUInt() );
|
||||
result->setTrackId( files_query.value( 9 ).toUInt() );
|
||||
|
||||
for ( int k = 0; k < trackPairs.count(); k++ )
|
||||
|
@ -170,9 +170,9 @@ DatabaseCommand_SetPlaylistRevision::exec( DatabaseImpl* lib )
|
||||
if ( !e->isValid() )
|
||||
continue;
|
||||
|
||||
adde.bindValue( 0, e->query()->track() );
|
||||
adde.bindValue( 1, e->query()->artist() );
|
||||
adde.bindValue( 2, e->query()->album() );
|
||||
adde.bindValue( 0, e->query()->queryTrack()->track() );
|
||||
adde.bindValue( 1, e->query()->queryTrack()->artist() );
|
||||
adde.bindValue( 2, e->query()->queryTrack()->album() );
|
||||
adde.bindValue( 3, e->annotation() );
|
||||
adde.bindValue( 4, (int) e->duration() );
|
||||
adde.bindValue( 5, e->lastmodified() );
|
||||
@ -203,9 +203,9 @@ DatabaseCommand_SetPlaylistRevision::exec( DatabaseImpl* lib )
|
||||
|
||||
adde.bindValue( 0, e->guid() );
|
||||
adde.bindValue( 1, m_playlistguid );
|
||||
adde.bindValue( 2, e->query()->track() );
|
||||
adde.bindValue( 3, e->query()->artist() );
|
||||
adde.bindValue( 4, e->query()->album() );
|
||||
adde.bindValue( 2, e->query()->queryTrack()->track() );
|
||||
adde.bindValue( 3, e->query()->queryTrack()->artist() );
|
||||
adde.bindValue( 4, e->query()->queryTrack()->album() );
|
||||
adde.bindValue( 5, e->annotation() );
|
||||
adde.bindValue( 6, (int) e->duration() );
|
||||
adde.bindValue( 7, e->lastmodified() );
|
||||
|
@ -297,19 +297,14 @@ DatabaseImpl::file( int fid )
|
||||
}
|
||||
|
||||
r = Tomahawk::Result::get( url );
|
||||
Tomahawk::artist_ptr artist = Tomahawk::Artist::get( query.value( 7 ).toUInt(), query.value( 11 ).toString() );
|
||||
Tomahawk::album_ptr album = Tomahawk::Album::get( query.value( 8 ).toUInt(), query.value( 12 ).toString(), artist );
|
||||
Tomahawk::artist_ptr composer = Tomahawk::Artist::get( query.value( 10 ).toUInt(), query.value( 14 ).toString() );
|
||||
|
||||
Tomahawk::track_ptr track = Tomahawk::Track::get( query.value( 11 ).toString(), query.value( 13 ).toString(), query.value( 12 ).toString(), query.value( 5 ).toUInt(), query.value( 14 ).toString() );
|
||||
r->setTrack( track );
|
||||
|
||||
r->setModificationTime( query.value( 1 ).toUInt() );
|
||||
r->setSize( query.value( 2 ).toUInt() );
|
||||
r->setMimetype( query.value( 4 ).toString() );
|
||||
r->setDuration( query.value( 5 ).toUInt() );
|
||||
r->setBitrate( query.value( 6 ).toUInt() );
|
||||
r->setArtist( artist );
|
||||
r->setAlbum( album );
|
||||
r->setComposer( composer );
|
||||
r->setTrack( query.value( 13 ).toString() );
|
||||
r->setTrackId( query.value( 9 ).toUInt() );
|
||||
r->setCollection( s->dbCollection() );
|
||||
r->setScore( 1.0 );
|
||||
@ -626,13 +621,12 @@ DatabaseImpl::resultFromHint( const Tomahawk::query_ptr& origquery )
|
||||
res = Tomahawk::Result::get( url );
|
||||
res->setRID( uuid() );
|
||||
res->setScore( 1.0 );
|
||||
res->setArtist( Tomahawk::Artist::get( artistId( origquery->artist(), false ), origquery->artist() ) );
|
||||
res->setAlbum( Tomahawk::Album::get( albumId( res->artist()->id(), origquery->album(), false ), origquery->album(), res->artist() ) );
|
||||
res->setTrack( origquery->track() );
|
||||
res->setDuration( origquery->duration() );
|
||||
const QUrl u = QUrl::fromUserInput( url );
|
||||
res->setFriendlySource( u.host() );
|
||||
|
||||
Tomahawk::track_ptr track = Tomahawk::Track::get( origquery->queryTrack()->artist(), origquery->queryTrack()->track(), origquery->queryTrack()->album(), origquery->queryTrack()->duration() );
|
||||
res->setTrack( track );
|
||||
|
||||
return res;
|
||||
}
|
||||
else
|
||||
@ -695,22 +689,15 @@ DatabaseImpl::resultFromHint( const Tomahawk::query_ptr& origquery )
|
||||
}
|
||||
|
||||
res = Tomahawk::Result::get( url );
|
||||
Tomahawk::artist_ptr artist = Tomahawk::Artist::get( query.value( 18 ).toUInt(), query.value( 11 ).toString() );
|
||||
Tomahawk::album_ptr album = Tomahawk::Album::get( query.value( 19 ).toUInt(), query.value( 12 ).toString(), artist );
|
||||
Tomahawk::artist_ptr composer = Tomahawk::Artist::get( query.value( 20 ).toUInt(), query.value( 14 ).toString() );
|
||||
|
||||
Tomahawk::track_ptr track = Tomahawk::Track::get( query.value( 11 ).toString(), query.value( 13 ).toString(), query.value( 12 ).toString(), query.value( 5 ).toInt(), query.value( 14 ).toString(), query.value( 16 ).toUInt(), query.value( 17 ).toUInt() );
|
||||
res->setTrack( track );
|
||||
|
||||
res->setModificationTime( query.value( 1 ).toUInt() );
|
||||
res->setSize( query.value( 2 ).toUInt() );
|
||||
res->setMimetype( query.value( 4 ).toString() );
|
||||
res->setDuration( query.value( 5 ).toInt() );
|
||||
res->setBitrate( query.value( 6 ).toInt() );
|
||||
res->setArtist( artist );
|
||||
res->setAlbum( album );
|
||||
res->setComposer( composer );
|
||||
res->setScore( 1.0 );
|
||||
res->setTrack( query.value( 13 ).toString() );
|
||||
res->setAlbumPos( query.value( 16 ).toUInt() );
|
||||
res->setDiscNumber( query.value( 17 ).toUInt() );
|
||||
res->setRID( uuid() );
|
||||
res->setTrackId( query.value( 9 ).toUInt() );
|
||||
res->setCollection( s->dbCollection() );
|
||||
|
@ -256,8 +256,8 @@ FuzzyIndex::search( const Tomahawk::query_ptr& query )
|
||||
}
|
||||
else
|
||||
{
|
||||
QString track = QString::fromWCharArray( parser.escape( DatabaseImpl::sortname( query->track() ).toStdWString().c_str() ) );
|
||||
QString artist = QString::fromWCharArray( parser.escape( DatabaseImpl::sortname( query->artist() ).toStdWString().c_str() ) );
|
||||
QString track = QString::fromWCharArray( parser.escape( DatabaseImpl::sortname( query->queryTrack()->track() ).toStdWString().c_str() ) );
|
||||
QString artist = QString::fromWCharArray( parser.escape( DatabaseImpl::sortname( query->queryTrack()->artist() ).toStdWString().c_str() ) );
|
||||
// QString album = QString::fromWCharArray( parser.escape( query->album().toStdWString().c_str() ) );
|
||||
|
||||
Term* term = _CLNEW Term( _T( "track" ), track.toStdWString().c_str() );
|
||||
|
@ -95,35 +95,35 @@ MetadataEditor::writeMetadata( bool closeDlg )
|
||||
TagLib::FileRef f( encodedName );
|
||||
Tomahawk::Tag* tag = Tomahawk::Tag::fromFile( f );
|
||||
|
||||
if ( title() != m_result->track() )
|
||||
if ( title() != m_result->track()->track() )
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO << "Track changed" << title() << m_result->track();
|
||||
|
||||
tag->setTitle( title() );
|
||||
m_result->setTrack( title() );
|
||||
m_result->track()->setTrack( title() );
|
||||
|
||||
changed = true;
|
||||
}
|
||||
|
||||
Tomahawk::artist_ptr newArtist = Tomahawk::Artist::get( artist(), true );
|
||||
if ( newArtist != m_result->artist() )
|
||||
if ( newArtist != m_result->track()->artistPtr() )
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO << "Artist changed" << artist() << m_result->artist();
|
||||
tDebug() << Q_FUNC_INFO << "Artist changed" << artist() << m_result->track()->artist();
|
||||
|
||||
tag->setArtist( artist() );
|
||||
m_result->setArtist( newArtist );
|
||||
m_result->track()->setArtist( artist() );
|
||||
|
||||
changed = true;
|
||||
}
|
||||
|
||||
Tomahawk::album_ptr newAlbum = Tomahawk::Album::get( newArtist, album(), true );
|
||||
if ( newAlbum != m_result->album() )
|
||||
if ( newAlbum != m_result->track()->albumPtr() )
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO << "Album changed" << album() << newAlbum->id() << m_result->album()->name() << m_result->album()->id() << newAlbum.data() << m_result->album().data();
|
||||
if ( newAlbum->id() != m_result->album()->id() )
|
||||
tDebug() << Q_FUNC_INFO << "Album changed" << album() << newAlbum->id() << m_result->track()->album() << m_result->track()->albumPtr()->id() << newAlbum.data() << m_result->track()->albumPtr().data();
|
||||
if ( newAlbum->id() != m_result->track()->albumPtr()->id() )
|
||||
{
|
||||
tag->setAlbum( album() );
|
||||
m_result->setAlbum( newAlbum );
|
||||
m_result->track()->setAlbum( album() );
|
||||
|
||||
changed = true;
|
||||
}
|
||||
@ -132,10 +132,10 @@ MetadataEditor::writeMetadata( bool closeDlg )
|
||||
}
|
||||
|
||||
// FIXME: Ugly workaround for the min value of 0
|
||||
if ( albumPos() != 0 && albumPos() != (int)m_result->albumpos() )
|
||||
if ( albumPos() != 0 && albumPos() != (int)m_result->track()->albumpos() )
|
||||
{
|
||||
tag->setTrack( albumPos() );
|
||||
m_result->setAlbumPos( albumPos() );
|
||||
//FIXME:m_result->track()->setAlbumPos( albumPos() );
|
||||
|
||||
tDebug() << Q_FUNC_INFO << "Albumpos changed";
|
||||
changed = true;
|
||||
@ -158,8 +158,7 @@ MetadataEditor::writeMetadata( bool closeDlg )
|
||||
m_editFiles.append( fileName );
|
||||
m_result->doneEditing();
|
||||
|
||||
tDebug() << Q_FUNC_INFO << m_result->toString();
|
||||
tDebug() << Q_FUNC_INFO << m_result->toQuery()->toString();
|
||||
tDebug() << Q_FUNC_INFO << m_result->toString() << m_result->track()->toString();
|
||||
}
|
||||
}
|
||||
|
||||
@ -189,18 +188,18 @@ MetadataEditor::loadQuery( const Tomahawk::query_ptr& query )
|
||||
m_query = query;
|
||||
setEditable( false );
|
||||
|
||||
setTitle( query->displayQuery()->track() );
|
||||
setArtist( query->displayQuery()->artist() );
|
||||
setAlbum( query->displayQuery()->album() );
|
||||
setAlbumPos( query->displayQuery()->albumpos() );
|
||||
setDuration( query->displayQuery()->duration() );
|
||||
setTitle( query->track()->track() );
|
||||
setArtist( query->track()->artist() );
|
||||
setAlbum( query->track()->album() );
|
||||
setAlbumPos( query->track()->albumpos() );
|
||||
setDuration( query->track()->duration() );
|
||||
setYear( 0 );
|
||||
setBitrate( 0 );
|
||||
|
||||
setFileName( QString() );
|
||||
setFileSize( 0 );
|
||||
|
||||
setWindowTitle( query->track() );
|
||||
setWindowTitle( query->track()->track() );
|
||||
|
||||
if ( m_interface )
|
||||
{
|
||||
@ -221,11 +220,11 @@ MetadataEditor::loadResult( const Tomahawk::result_ptr& result )
|
||||
m_result = result;
|
||||
setEditable( result->collection() && result->collection()->source()->isLocal() );
|
||||
|
||||
setTitle( result->track() );
|
||||
setArtist( result->artist()->name() );
|
||||
setAlbum( result->album()->name() );
|
||||
setAlbumPos( result->albumpos() );
|
||||
setDuration( result->duration() );
|
||||
setTitle( result->track()->track() );
|
||||
setArtist( result->track()->artist() );
|
||||
setAlbum( result->track()->album() );
|
||||
setAlbumPos( result->track()->albumpos() );
|
||||
setDuration( result->track()->duration() );
|
||||
setYear( result->year() );
|
||||
setBitrate( result->bitrate() );
|
||||
|
||||
@ -236,7 +235,7 @@ MetadataEditor::loadResult( const Tomahawk::result_ptr& result )
|
||||
setFileSize( TomahawkUtils::filesizeToString( fi.size() ) );
|
||||
}
|
||||
|
||||
setWindowTitle( result->track() );
|
||||
setWindowTitle( result->track()->track() );
|
||||
|
||||
if ( m_interface )
|
||||
{
|
||||
|
@ -81,10 +81,8 @@ PipelineStatusItem::resolving( const Tomahawk::query_ptr& query )
|
||||
if ( query->isFullTextQuery() )
|
||||
m_latestQuery = query->fullTextQuery();
|
||||
else
|
||||
m_latestQuery = QString( "%1 - %2" ).arg( query->artist() ).arg( query->track() );
|
||||
m_latestQuery = QString( "%1 - %2" ).arg( query->queryTrack()->artist() ).arg( query->queryTrack()->track() );
|
||||
|
||||
if ( m_latestQuery.isEmpty() )
|
||||
qDebug() << "EMPTY STRING IN STATUS ITEM:" << query->fullTextQuery() << query->track() << query->artist() << query->album();
|
||||
Q_ASSERT( !m_latestQuery.isEmpty() );
|
||||
|
||||
emit statusChanged();
|
||||
|
@ -62,9 +62,9 @@ TransferStatusItem::mainText() const
|
||||
return QString();
|
||||
|
||||
if ( m_stream.data()->source().isNull() && !m_stream.data()->track().isNull() )
|
||||
return QString( "%1" ).arg( QString( "%1 - %2" ).arg( m_stream.data()->track()->artist()->name() ).arg( m_stream.data()->track()->track() ) );
|
||||
return QString( "%1" ).arg( QString( "%1 - %2" ).arg( m_stream.data()->track()->track()->artist() ).arg( m_stream.data()->track()->track()->track() ) );
|
||||
else if ( !m_stream.data()->source().isNull() && !m_stream.data()->track().isNull() )
|
||||
return QString( "%1 %2 %3" ).arg( QString( "%1 - %2" ).arg( m_stream.data()->track()->artist()->name() ).arg( m_stream.data()->track()->track() ) )
|
||||
return QString( "%1 %2 %3" ).arg( QString( "%1 - %2" ).arg( m_stream.data()->track()->track()->artist() ).arg( m_stream.data()->track()->track()->track() ) )
|
||||
.arg( m_stream.data()->type() == StreamConnection::RECEIVING ? tr( "from", "streaming artist - track from friend" ) : tr( "to", "streaming artist - track to friend" ) )
|
||||
.arg( m_stream.data()->source()->friendlyName() );
|
||||
else
|
||||
|
@ -86,11 +86,7 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
||||
if ( m_view->header()->visualIndex( index.column() ) > 0 )
|
||||
return;
|
||||
|
||||
const query_ptr q = item->query()->displayQuery();
|
||||
const QString artist = q->artist();
|
||||
const QString album = q->album();
|
||||
const QString track = q->track();
|
||||
int duration = q->duration();
|
||||
const track_ptr track = item->query()->track();
|
||||
QString lowerText;
|
||||
|
||||
painter->save();
|
||||
@ -125,7 +121,7 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
||||
painter->drawText( figureRect, QString::number( index.row() + 1 ), QTextOption( Qt::AlignCenter ) );
|
||||
|
||||
r.adjust( figureRect.width() + 12, 0, 0, 0 );
|
||||
QRect rightRect = r.adjusted( r.width() - smallBoldFontMetrics.width( TomahawkUtils::timeToString( duration ) ), 0, 0, 0 );
|
||||
QRect rightRect = r.adjusted( r.width() - smallBoldFontMetrics.width( TomahawkUtils::timeToString( track->duration() ) ), 0, 0, 0 );
|
||||
QRect leftRect = r.adjusted( 0, 0, -( rightRect.width() + 8 ), 0 );
|
||||
|
||||
const int sourceIconSize = r.height();
|
||||
@ -140,24 +136,24 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
||||
rightRect.moveLeft( rightRect.left() - infoIcon.width() - 8 );
|
||||
leftRect.adjust( 0, 0, -( infoIcon.width() + 8 ), 0 );
|
||||
}
|
||||
else if ( q->numResults() && !q->results().first()->sourceIcon( TomahawkUtils::RoundedCorners, QSize( sourceIconSize, sourceIconSize ) ).isNull() )
|
||||
else if ( item->query()->numResults() && !item->query()->results().first()->sourceIcon( TomahawkUtils::RoundedCorners, QSize( sourceIconSize, sourceIconSize ) ).isNull() )
|
||||
{
|
||||
const QPixmap sourceIcon = q->results().first()->sourceIcon( TomahawkUtils::RoundedCorners, QSize( sourceIconSize, sourceIconSize ) );
|
||||
const QPixmap sourceIcon = item->query()->results().first()->sourceIcon( TomahawkUtils::RoundedCorners, QSize( sourceIconSize, sourceIconSize ) );
|
||||
painter->setOpacity( 0.8 );
|
||||
painter->drawPixmap( QRect( rightRect.right() - sourceIconSize, r.center().y() - sourceIconSize / 2, sourceIcon.width(), sourceIcon.height() ), sourceIcon );
|
||||
painter->setOpacity( 1.0 );
|
||||
rightRect.moveLeft( rightRect.left() - sourceIcon.width() - 8 );
|
||||
}
|
||||
|
||||
QString text = painter->fontMetrics().elidedText( track, Qt::ElideRight, leftRect.width() );
|
||||
QString text = painter->fontMetrics().elidedText( track->track(), Qt::ElideRight, leftRect.width() );
|
||||
painter->setPen( opt.palette.text().color() );
|
||||
painter->drawText( leftRect, text, m_centerOption );
|
||||
|
||||
if ( duration > 0 )
|
||||
if ( track->duration() > 0 )
|
||||
{
|
||||
painter->setPen( opt.palette.text().color() );
|
||||
painter->setFont( smallBoldFont );
|
||||
painter->drawText( rightRect, TomahawkUtils::timeToString( duration ), m_centerRightOption );
|
||||
painter->drawText( rightRect, TomahawkUtils::timeToString( track->duration() ), m_centerRightOption );
|
||||
}
|
||||
}
|
||||
painter->restore();
|
||||
|
@ -102,8 +102,8 @@ GridItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
||||
}
|
||||
else if ( !item->query().isNull() )
|
||||
{
|
||||
top = item->query()->track();
|
||||
bottom = item->query()->artist();
|
||||
top = item->query()->track()->track();
|
||||
bottom = item->query()->track()->artist();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -381,9 +381,9 @@ GridItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const Q
|
||||
if ( !item )
|
||||
return false;
|
||||
|
||||
if ( !item->query().isNull() )
|
||||
ViewManager::instance()->show( Tomahawk::Artist::get( item->query()->artist() ) );
|
||||
else if ( !item->album().isNull() && !item->album()->artist().isNull() )
|
||||
if ( item->query() )
|
||||
ViewManager::instance()->show( item->query()->track()->artistPtr() );
|
||||
else if ( item->album() && item->album()->artist() )
|
||||
ViewManager::instance()->show( item->album()->artist() );
|
||||
|
||||
event->accept();
|
||||
|
@ -157,13 +157,9 @@ PlayableProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourcePa
|
||||
|
||||
if ( pi->query() )
|
||||
{
|
||||
const Tomahawk::query_ptr& q = pi->query()->displayQuery();
|
||||
if ( q.isNull() ) // uh oh? filter out invalid queries i guess
|
||||
return false;
|
||||
|
||||
Tomahawk::result_ptr r;
|
||||
if ( q->numResults() )
|
||||
r = q->results().first();
|
||||
if ( pi->query()->numResults() )
|
||||
r = pi->query()->results().first();
|
||||
|
||||
if ( !m_showOfflineResults && ( r.isNull() || !r->isOnline() ) )
|
||||
return false;
|
||||
@ -175,9 +171,9 @@ PlayableProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourcePa
|
||||
foreach( QString s, sl )
|
||||
{
|
||||
s = s.toLower();
|
||||
if ( !q->artist().toLower().contains( s ) &&
|
||||
!q->album().toLower().contains( s ) &&
|
||||
!q->track().toLower().contains( s ) )
|
||||
if ( !pi->query()->track()->artist().toLower().contains( s ) &&
|
||||
!pi->query()->track()->album().toLower().contains( s ) &&
|
||||
!pi->query()->track()->track().toLower().contains( s ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -298,19 +294,21 @@ PlayableProxyModel::setMaxVisibleItems( int items )
|
||||
bool
|
||||
PlayableProxyModel::lessThan( int column, const Tomahawk::query_ptr& q1, const Tomahawk::query_ptr& q2 ) const
|
||||
{
|
||||
const QString artist1 = q1->artistSortname();
|
||||
const QString artist2 = q2->artistSortname();
|
||||
const QString album1 = q1->albumSortname();
|
||||
const QString album2 = q2->albumSortname();
|
||||
const QString track1 = q1->trackSortname();
|
||||
const QString track2 = q2->trackSortname();
|
||||
const QString composer1 = q1->composerSortname();
|
||||
const QString composer2 = q2->composerSortname();
|
||||
const unsigned int albumpos1 = q1->albumpos();
|
||||
const unsigned int albumpos2 = q2->albumpos();
|
||||
const unsigned int discnumber1 = q1->discnumber();
|
||||
const unsigned int discnumber2 = q2->discnumber();
|
||||
unsigned int duration1 = q1->duration(), duration2 = q2->duration();
|
||||
const Tomahawk::track_ptr& t1 = q1->track();
|
||||
const Tomahawk::track_ptr& t2 = q2->track();
|
||||
const QString artist1 = t1->artistSortname();
|
||||
const QString artist2 = t2->artistSortname();
|
||||
const QString album1 = t1->albumSortname();
|
||||
const QString album2 = t2->albumSortname();
|
||||
const QString track1 = t1->trackSortname();
|
||||
const QString track2 = t2->trackSortname();
|
||||
const QString composer1 = t1->composerSortname();
|
||||
const QString composer2 = t2->composerSortname();
|
||||
const unsigned int albumpos1 = t1->albumpos();
|
||||
const unsigned int albumpos2 = t2->albumpos();
|
||||
const unsigned int discnumber1 = t1->discnumber();
|
||||
const unsigned int discnumber2 = t2->discnumber();
|
||||
unsigned int duration1 = t1->duration(), duration2 = t2->duration();
|
||||
unsigned int bitrate1 = 0, bitrate2 = 0;
|
||||
unsigned int mtime1 = 0, mtime2 = 0;
|
||||
unsigned int size1 = 0, size2 = 0;
|
||||
@ -324,7 +322,7 @@ PlayableProxyModel::lessThan( int column, const Tomahawk::query_ptr& q1, const T
|
||||
{
|
||||
const Tomahawk::result_ptr& r = q1->results().at( 0 );
|
||||
bitrate1 = r->bitrate();
|
||||
duration1 = r->duration();
|
||||
duration1 = r->track()->duration();
|
||||
mtime1 = r->modificationTime();
|
||||
size1 = r->size();
|
||||
year1 = r->year();
|
||||
@ -336,7 +334,7 @@ PlayableProxyModel::lessThan( int column, const Tomahawk::query_ptr& q1, const T
|
||||
{
|
||||
const Tomahawk::result_ptr& r = q2->results().at( 0 );
|
||||
bitrate2 = r->bitrate();
|
||||
duration2 = r->duration();
|
||||
duration2 = r->track()->duration();
|
||||
mtime2 = r->modificationTime();
|
||||
size2 = r->size();
|
||||
year2 = r->year();
|
||||
@ -475,8 +473,8 @@ PlayableProxyModel::lessThan( int column, const Tomahawk::query_ptr& q1, const T
|
||||
}
|
||||
}
|
||||
|
||||
const QString& lefts = q1->track();
|
||||
const QString& rights = q2->track();
|
||||
const QString& lefts = t1->track();
|
||||
const QString& rights = t2->track();
|
||||
if ( lefts == rights )
|
||||
return id1 < id2;
|
||||
|
||||
@ -497,9 +495,7 @@ PlayableProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right
|
||||
|
||||
if ( p1->query() && p2->query() )
|
||||
{
|
||||
const Tomahawk::query_ptr& q1 = p1->query()->displayQuery();
|
||||
const Tomahawk::query_ptr& q2 = p2->query()->displayQuery();
|
||||
return lessThan( left.column(), q1, q2 );
|
||||
return lessThan( left.column(), p1->query(), p2->query() );
|
||||
}
|
||||
|
||||
return QString::localeAwareCompare( sourceModel()->data( left ).toString(), sourceModel()->data( right ).toString() ) < 0;
|
||||
@ -611,12 +607,12 @@ PlayableProxyModel::updateDetailedInfo( const QModelIndex& index )
|
||||
|
||||
if ( style() == PlayableProxyModel::Short || style() == PlayableProxyModel::Large )
|
||||
{
|
||||
item->query()->displayQuery()->cover( QSize( 0, 0 ) );
|
||||
item->query()->track()->cover( QSize( 0, 0 ) );
|
||||
}
|
||||
|
||||
if ( style() == PlayableProxyModel::Large )
|
||||
{
|
||||
item->query()->loadSocialActions();
|
||||
item->query()->track()->loadSocialActions();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,10 +111,7 @@ PlaylistChartItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem&
|
||||
if ( m_view->header()->visualIndex( index.column() ) > 0 )
|
||||
return;
|
||||
|
||||
const query_ptr q = item->query()->displayQuery();
|
||||
unsigned int duration = q->duration();
|
||||
QString artist = q->artist();
|
||||
QString track = q->track();
|
||||
const track_ptr track = item->query()->track();
|
||||
QPixmap avatar;
|
||||
QString upperText, lowerText;
|
||||
|
||||
@ -192,7 +189,7 @@ PlaylistChartItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem&
|
||||
painter->drawPixmap( pixmapRect, pixmap );
|
||||
|
||||
r.adjust( pixmapRect.width() + figureRect.width() + 18, 1, -28, 0 );
|
||||
QRect rightRect = r.adjusted( r.width() - durationFontMetrics.width( TomahawkUtils::timeToString( duration ) ), 0, 0, 0 );
|
||||
QRect rightRect = r.adjusted( r.width() - durationFontMetrics.width( TomahawkUtils::timeToString( track->duration() ) ), 0, 0, 0 );
|
||||
QRect leftRect = r.adjusted( 0, 0, -( rightRect.width() + 8 ), 0 );
|
||||
|
||||
/* const int sourceIconSize = r.height();
|
||||
@ -217,18 +214,18 @@ PlaylistChartItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem&
|
||||
}*/
|
||||
|
||||
painter->setFont( boldFont );
|
||||
QString text = painter->fontMetrics().elidedText( track, Qt::ElideRight, leftRect.width() );
|
||||
QString text = painter->fontMetrics().elidedText( track->track(), Qt::ElideRight, leftRect.width() );
|
||||
painter->drawText( leftRect, text, m_topOption );
|
||||
|
||||
painter->setFont( smallBoldFont );
|
||||
text = painter->fontMetrics().elidedText( artist, Qt::ElideRight, leftRect.width() );
|
||||
text = painter->fontMetrics().elidedText( track->artist(), Qt::ElideRight, leftRect.width() );
|
||||
painter->drawText( index.row() >= 10 ? leftRect : leftRect.adjusted( 0, painter->fontMetrics().height() + 6, 0, 0 ), text, index.row() >= 10 ? m_bottomOption : m_topOption );
|
||||
|
||||
if ( duration > 0 )
|
||||
if ( track->duration() > 0 )
|
||||
{
|
||||
painter->setPen( opt.palette.text().color() );
|
||||
painter->setFont( durationFont );
|
||||
painter->drawText( rightRect, TomahawkUtils::timeToString( duration ), m_centerRightOption );
|
||||
painter->drawText( rightRect, TomahawkUtils::timeToString( track->duration() ), m_centerRightOption );
|
||||
}
|
||||
}
|
||||
painter->restore();
|
||||
|
@ -129,27 +129,24 @@ PlaylistItemDelegate::paintShort( QPainter* painter, const QStyleOptionViewItem&
|
||||
if ( m_view->header()->visualIndex( index.column() ) > 0 )
|
||||
return;
|
||||
|
||||
const query_ptr q = item->query()->displayQuery();
|
||||
QString artist = q->artist();
|
||||
QString track = q->track();
|
||||
const track_ptr track = item->query()->track();
|
||||
QPixmap pixmap;
|
||||
QString upperText, lowerText;
|
||||
source_ptr source = item->query()->playedBy().first;
|
||||
|
||||
if ( source.isNull() )
|
||||
if ( !item->playbackLog().source )
|
||||
{
|
||||
upperText = track;
|
||||
lowerText = artist;
|
||||
upperText = track->track();
|
||||
lowerText = track->artist();
|
||||
}
|
||||
else
|
||||
{
|
||||
upperText = QString( "%1 - %2" ).arg( artist ).arg( track );
|
||||
QString playtime = TomahawkUtils::ageToString( QDateTime::fromTime_t( item->query()->playedBy().second ), true );
|
||||
upperText = QString( "%1 - %2" ).arg( track->artist() ).arg( track->track() );
|
||||
QString playtime = TomahawkUtils::ageToString( QDateTime::fromTime_t( item->playbackLog().timestamp ), true );
|
||||
|
||||
if ( source == SourceList::instance()->getLocal() )
|
||||
if ( item->playbackLog().source->isLocal() )
|
||||
lowerText = QString( tr( "played %1 by you" ) ).arg( playtime );
|
||||
else
|
||||
lowerText = QString( tr( "played %1 by %2" ) ).arg( playtime ).arg( source->friendlyName() );
|
||||
lowerText = QString( tr( "played %1 by %2" ) ).arg( playtime ).arg( item->playbackLog().source->friendlyName() );
|
||||
}
|
||||
|
||||
painter->save();
|
||||
@ -172,11 +169,11 @@ PlaylistItemDelegate::paintShort( QPainter* painter, const QStyleOptionViewItem&
|
||||
|
||||
if ( useAvatars )
|
||||
{
|
||||
if ( !source.isNull() )
|
||||
pixmap = source->avatar( TomahawkUtils::RoundedCorners, ir.size() );
|
||||
if ( item->playbackLog().source )
|
||||
pixmap = item->playbackLog().source->avatar( TomahawkUtils::RoundedCorners, ir.size() );
|
||||
}
|
||||
else
|
||||
pixmap = item->query()->cover( ir.size(), false );
|
||||
pixmap = item->query()->track()->cover( ir.size(), false );
|
||||
|
||||
if ( pixmap.isNull() )
|
||||
{
|
||||
@ -340,7 +337,7 @@ PlaylistItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, con
|
||||
if ( m_model->style() != PlayableProxyModel::Detailed )
|
||||
{
|
||||
if ( item->query() )
|
||||
ViewManager::instance()->show( item->query()->displayQuery() );
|
||||
ViewManager::instance()->show( item->query()->track()->toQuery() );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -348,20 +345,19 @@ PlaylistItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, con
|
||||
{
|
||||
case PlayableModel::Artist:
|
||||
{
|
||||
ViewManager::instance()->show( Artist::get( item->query()->displayQuery()->artist() ) );
|
||||
ViewManager::instance()->show( item->query()->track()->artistPtr() );
|
||||
break;
|
||||
}
|
||||
|
||||
case PlayableModel::Album:
|
||||
{
|
||||
artist_ptr artist = Artist::get( item->query()->displayQuery()->artist() );
|
||||
ViewManager::instance()->show( Album::get( artist, item->query()->displayQuery()->album() ) );
|
||||
ViewManager::instance()->show( item->query()->track()->albumPtr() );
|
||||
break;
|
||||
}
|
||||
|
||||
case PlayableModel::Track:
|
||||
{
|
||||
ViewManager::instance()->show( item->query()->displayQuery() );
|
||||
ViewManager::instance()->show( item->query()->track()->toQuery() );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -116,23 +116,18 @@ PlaylistLargeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem&
|
||||
if ( m_view->header()->visualIndex( index.column() ) > 0 )
|
||||
return;
|
||||
|
||||
const query_ptr q = item->query()->displayQuery();
|
||||
const QString artist = q->artist();
|
||||
const QString album = q->album();
|
||||
const QString track = q->track();
|
||||
int duration = q->duration();
|
||||
const track_ptr track = item->query()->track();
|
||||
QString lowerText;
|
||||
|
||||
QSize avatarSize( 32, 32 );
|
||||
source_ptr source = item->query()->playedBy().first;
|
||||
if ( m_mode == RecentlyPlayed && !source.isNull() )
|
||||
if ( m_mode == RecentlyPlayed && item->playbackLog().source )
|
||||
{
|
||||
QString playtime = TomahawkUtils::ageToString( QDateTime::fromTime_t( item->query()->playedBy().second ), true );
|
||||
QString playtime = TomahawkUtils::ageToString( QDateTime::fromTime_t( item->playbackLog().timestamp ), true );
|
||||
|
||||
if ( source == SourceList::instance()->getLocal() )
|
||||
if ( item->playbackLog().source->isLocal() )
|
||||
lowerText = QString( tr( "played %1 by you", "e.g. played 3 hours ago by you" ) ).arg( playtime );
|
||||
else
|
||||
lowerText = QString( tr( "played %1 by %2", "e.g. played 3 hours ago by SomeSource" ) ).arg( playtime ).arg( source->friendlyName() );
|
||||
lowerText = QString( tr( "played %1 by %2", "e.g. played 3 hours ago by SomeSource" ) ).arg( playtime ).arg( item->playbackLog().source->friendlyName() );
|
||||
}
|
||||
|
||||
if ( m_mode == LatestAdditions && item->query()->numResults() )
|
||||
@ -143,9 +138,9 @@ PlaylistLargeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem&
|
||||
}
|
||||
|
||||
if ( m_mode == LovedTracks )
|
||||
lowerText = item->query()->socialActionDescription( "Love", Query::Detailed );
|
||||
lowerText = item->query()->queryTrack()->socialActionDescription( "Love", Track::Detailed );
|
||||
if ( m_mode == Inbox )
|
||||
lowerText = item->query()->socialActionDescription( "Inbox", Query::Detailed );
|
||||
lowerText = item->query()->queryTrack()->socialActionDescription( "Inbox", Track::Detailed );
|
||||
|
||||
painter->save();
|
||||
{
|
||||
@ -192,7 +187,7 @@ PlaylistLargeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem&
|
||||
smallFont.setPointSize( TomahawkUtils::defaultFontSize() - 1 );
|
||||
|
||||
r.adjust( pixmapRect.width() + 12, 1, - 16, 0 );
|
||||
QRect rightRect = r.adjusted( r.width() - smallBoldFontMetrics.width( TomahawkUtils::timeToString( duration ) ), 0, 0, 0 );
|
||||
QRect rightRect = r.adjusted( r.width() - smallBoldFontMetrics.width( TomahawkUtils::timeToString( track->duration() ) ), 0, 0, 0 );
|
||||
QRect leftRect = r.adjusted( 0, 0, -( rightRect.width() + 8 ), 0 );
|
||||
|
||||
const int sourceIconSize = avatarRect.width() - 6;
|
||||
@ -207,9 +202,9 @@ PlaylistLargeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem&
|
||||
rightRect.moveLeft( rightRect.left() - infoIcon.width() - 8 );
|
||||
leftRect.adjust( 0, 0, -( infoIcon.width() + 8 ), 0 );
|
||||
}
|
||||
else if ( q->numResults() && !q->results().first()->sourceIcon( TomahawkUtils::RoundedCorners, QSize( sourceIconSize, sourceIconSize ) ).isNull() )
|
||||
else if ( item->query()->numResults() && !item->query()->results().first()->sourceIcon( TomahawkUtils::RoundedCorners, QSize( sourceIconSize, sourceIconSize ) ).isNull() )
|
||||
{
|
||||
const QPixmap sourceIcon = q->results().first()->sourceIcon( TomahawkUtils::RoundedCorners, QSize( sourceIconSize, sourceIconSize ) );
|
||||
const QPixmap sourceIcon = item->query()->results().first()->sourceIcon( TomahawkUtils::RoundedCorners, QSize( sourceIconSize, sourceIconSize ) );
|
||||
painter->setOpacity( 0.8 );
|
||||
painter->drawPixmap( QRect( rightRect.right() - sourceIconSize, r.center().y() - sourceIconSize / 2, sourceIcon.width(), sourceIcon.height() ), sourceIcon );
|
||||
painter->setOpacity( 1.0 );
|
||||
@ -219,15 +214,15 @@ PlaylistLargeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem&
|
||||
}
|
||||
|
||||
painter->setFont( boldFont );
|
||||
QString text = painter->fontMetrics().elidedText( track, Qt::ElideRight, leftRect.width() );
|
||||
QString text = painter->fontMetrics().elidedText( track->track(), Qt::ElideRight, leftRect.width() );
|
||||
painter->drawText( leftRect, text, m_topOption );
|
||||
|
||||
painter->setFont( smallFont );
|
||||
QTextDocument textDoc;
|
||||
if ( album.isEmpty() )
|
||||
textDoc.setHtml( tr( "by <b>%1</b>", "e.g. by SomeArtist" ).arg( artist ) );
|
||||
if ( track->album().isEmpty() )
|
||||
textDoc.setHtml( tr( "by <b>%1</b>", "e.g. by SomeArtist" ).arg( track->artist() ) );
|
||||
else
|
||||
textDoc.setHtml( tr( "by <b>%1</b> on <b>%2</b>", "e.g. by SomeArtist on SomeAlbum" ).arg( artist ).arg( album ) );
|
||||
textDoc.setHtml( tr( "by <b>%1</b> on <b>%2</b>", "e.g. by SomeArtist on SomeAlbum" ).arg( track->artist() ).arg( track->album() ) );
|
||||
textDoc.setDocumentMargin( 0 );
|
||||
textDoc.setDefaultFont( painter->font() );
|
||||
textDoc.setDefaultTextOption( m_topOption );
|
||||
@ -244,15 +239,15 @@ PlaylistLargeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem&
|
||||
textDoc.setDefaultTextOption( m_bottomOption );
|
||||
|
||||
if ( textDoc.idealWidth() > leftRect.width() )
|
||||
textDoc.setHtml( item->query()->socialActionDescription( "Love", Query::Short ) );
|
||||
textDoc.setHtml( item->query()->queryTrack()->socialActionDescription( "Love", Track::Short ) );
|
||||
|
||||
drawRichText( painter, opt, leftRect, Qt::AlignBottom, textDoc );
|
||||
|
||||
if ( duration > 0 )
|
||||
if ( track->duration() > 0 )
|
||||
{
|
||||
painter->setPen( opt.palette.text().color() );
|
||||
painter->setFont( smallBoldFont );
|
||||
painter->drawText( rightRect, TomahawkUtils::timeToString( duration ), m_centerRightOption );
|
||||
painter->drawText( rightRect, TomahawkUtils::timeToString( track->duration() ), m_centerRightOption );
|
||||
}
|
||||
}
|
||||
painter->restore();
|
||||
|
@ -67,7 +67,7 @@ QueueProxyModel::onPlaybackStarted( const Tomahawk::result_ptr& result )
|
||||
QModelIndex idx = index( i, 0 );
|
||||
PlayableItem* item = itemFromIndex( mapToSource( idx ) );
|
||||
if ( item && item->query() && ( item->query()->results().contains( result ) ||
|
||||
item->query()->equals( result->toQuery() ) ) )
|
||||
item->query()->track()->equals( result->track() ) ) )
|
||||
{
|
||||
removeIndex( idx );
|
||||
if ( !rowCount() )
|
||||
|
@ -291,7 +291,7 @@ TreeItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const Q
|
||||
|
||||
if ( item->query() )
|
||||
{
|
||||
ViewManager::instance()->show( item->query()->displayQuery() );
|
||||
ViewManager::instance()->show( item->query()->track()->toQuery() );
|
||||
}
|
||||
else if ( item->artist() )
|
||||
{
|
||||
|
@ -433,7 +433,7 @@ TreeModel::indexFromAlbum( const Tomahawk::album_ptr& album ) const
|
||||
QModelIndex
|
||||
TreeModel::indexFromResult( const Tomahawk::result_ptr& result ) const
|
||||
{
|
||||
QModelIndex albumIdx = indexFromAlbum( result->album() );
|
||||
QModelIndex albumIdx = indexFromAlbum( result->track()->albumPtr() );
|
||||
for ( int i = 0; i < rowCount( albumIdx ); i++ )
|
||||
{
|
||||
QModelIndex idx = index( i, 0, albumIdx );
|
||||
@ -453,15 +453,12 @@ TreeModel::indexFromResult( const Tomahawk::result_ptr& result ) const
|
||||
QModelIndex
|
||||
TreeModel::indexFromQuery( const Tomahawk::query_ptr& query ) const
|
||||
{
|
||||
Tomahawk::artist_ptr artist = Artist::get( query->artist(), false );
|
||||
Tomahawk::album_ptr album = Album::get( artist, query->album(), false );
|
||||
|
||||
QModelIndex albumIdx = indexFromAlbum( album );
|
||||
QModelIndex albumIdx = indexFromAlbum( query->queryTrack()->albumPtr() );
|
||||
for ( int i = 0; i < rowCount( albumIdx ); i++ )
|
||||
{
|
||||
QModelIndex idx = index( i, 0, albumIdx );
|
||||
PlayableItem* item = itemFromIndex( idx );
|
||||
if ( item && item->result() && item->result()->toQuery()->equals( query ) )
|
||||
if ( item && item->result() && item->result()->track()->equals( query->track() ) )
|
||||
{
|
||||
return idx;
|
||||
}
|
||||
@ -475,7 +472,7 @@ TreeModel::indexFromQuery( const Tomahawk::query_ptr& query ) const
|
||||
PlayableItem*
|
||||
TreeModel::itemFromResult( const Tomahawk::result_ptr& result ) const
|
||||
{
|
||||
QModelIndex albumIdx = indexFromAlbum( result->album() );
|
||||
QModelIndex albumIdx = indexFromAlbum( result->track()->albumPtr() );
|
||||
for ( int i = 0; i < rowCount( albumIdx ); i++ )
|
||||
{
|
||||
QModelIndex idx = index( i, 0, albumIdx );
|
||||
|
@ -200,8 +200,8 @@ TreeProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent
|
||||
if ( cachedQuery.isNull() )
|
||||
continue;
|
||||
|
||||
if ( cachedQuery->track() == item->query()->track() &&
|
||||
( cachedQuery->albumpos() == item->query()->albumpos() || cachedQuery->albumpos() == 0 ) )
|
||||
if ( cachedQuery->track()->track() == item->query()->track()->track() &&
|
||||
( cachedQuery->track()->albumpos() == item->query()->track()->albumpos() || cachedQuery->track()->albumpos() == 0 ) )
|
||||
{
|
||||
return ( cachedQuery.data() == item->query().data() );
|
||||
}
|
||||
@ -216,7 +216,7 @@ TreeProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent
|
||||
|
||||
if ( ti && ti->name() == item->name() && !ti->query().isNull() )
|
||||
{
|
||||
if ( ti->query()->albumpos() == item->query()->albumpos() || ti->query()->albumpos() == 0 || item->query()->albumpos() == 0 )
|
||||
if ( ti->query()->track()->albumpos() == item->query()->track()->albumpos() || ti->query()->track()->albumpos() == 0 || item->query()->track()->albumpos() == 0 )
|
||||
{
|
||||
if ( item->result().isNull() )
|
||||
return false;
|
||||
@ -286,27 +286,27 @@ TreeProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) co
|
||||
unsigned int discnumber2 = 0;
|
||||
if ( !p1->query().isNull() )
|
||||
{
|
||||
albumpos1 = p1->query()->albumpos();
|
||||
discnumber1 = p1->query()->discnumber();
|
||||
albumpos1 = p1->query()->track()->albumpos();
|
||||
discnumber1 = p1->query()->track()->discnumber();
|
||||
}
|
||||
if ( !p2->query().isNull() )
|
||||
{
|
||||
albumpos2 = p2->query()->albumpos();
|
||||
discnumber2 = p2->query()->discnumber();
|
||||
albumpos2 = p2->query()->track()->albumpos();
|
||||
discnumber2 = p2->query()->track()->discnumber();
|
||||
}
|
||||
if ( !p1->result().isNull() )
|
||||
{
|
||||
if ( albumpos1 == 0 )
|
||||
albumpos1 = p1->result()->albumpos();
|
||||
albumpos1 = p1->result()->track()->albumpos();
|
||||
if ( discnumber1 == 0 )
|
||||
discnumber1 = p1->result()->discnumber();
|
||||
discnumber1 = p1->result()->track()->discnumber();
|
||||
}
|
||||
if ( !p2->result().isNull() )
|
||||
{
|
||||
if ( albumpos2 == 0 )
|
||||
albumpos2 = p2->result()->albumpos();
|
||||
albumpos2 = p2->result()->track()->albumpos();
|
||||
if ( discnumber2 == 0 )
|
||||
discnumber2 = p2->result()->discnumber();
|
||||
discnumber2 = p2->result()->track()->discnumber();
|
||||
}
|
||||
discnumber1 = qMax( 1, (int)discnumber1 );
|
||||
discnumber2 = qMax( 1, (int)discnumber2 );
|
||||
@ -346,11 +346,11 @@ TreeProxyModel::textForItem( PlayableItem* item ) const
|
||||
}
|
||||
else if ( !item->result().isNull() )
|
||||
{
|
||||
return DatabaseImpl::sortname( item->result()->track() );
|
||||
return item->result()->track()->trackSortname();
|
||||
}
|
||||
else if ( !item->query().isNull() )
|
||||
{
|
||||
return item->query()->track();
|
||||
return item->query()->track()->track();
|
||||
}
|
||||
|
||||
return QString();
|
||||
|
@ -104,7 +104,7 @@ DynamicModel::newTrackGenerated( const Tomahawk::query_ptr& query )
|
||||
bool isDuplicate = false;
|
||||
for ( int i = 0; i < m_deduper.size(); i++ )
|
||||
{
|
||||
if ( m_deduper[ i ].first == query->track() && m_deduper[ i ].second == query->artist() )
|
||||
if ( m_deduper[ i ].first == query->track()->track() && m_deduper[ i ].second == query->track()->artist() )
|
||||
isDuplicate = true;
|
||||
}
|
||||
if ( isDuplicate )
|
||||
@ -115,7 +115,7 @@ DynamicModel::newTrackGenerated( const Tomahawk::query_ptr& query )
|
||||
}
|
||||
else
|
||||
{
|
||||
m_deduper.append( QPair< QString, QString >( query->track(), query->artist() ) );
|
||||
m_deduper.append( QPair< QString, QString >( query->track()->track(), query->track()->artist() ) );
|
||||
}
|
||||
|
||||
connect( query.data(), SIGNAL( resolvingFinished( bool ) ), this, SLOT( trackResolveFinished( bool ) ) );
|
||||
@ -154,13 +154,13 @@ DynamicModel::trackResolveFinished( bool success )
|
||||
|
||||
Query* q = qobject_cast<Query*>( sender() );
|
||||
|
||||
tDebug() << "Got resolveFinished in DynamicModel" << q->track() << q->artist();
|
||||
tDebug() << "Got resolveFinished in DynamicModel" << q->track()->toString();
|
||||
if ( !m_waitingFor.contains( q ) )
|
||||
return;
|
||||
|
||||
if ( !q->playable() )
|
||||
{
|
||||
tDebug() << "Got not playable or resolved track:" << q->track() << q->artist() << m_lastResolvedRow << m_currentAttempts;
|
||||
tDebug() << "Got not playable or resolved track:" << q->track()->toString() << m_lastResolvedRow << m_currentAttempts;
|
||||
m_currentAttempts++;
|
||||
|
||||
int curAttempts = m_startingAfterFailed ? m_currentAttempts - 20 : m_currentAttempts; // if we just failed, m_currentAttempts includes those failures
|
||||
@ -174,7 +174,7 @@ DynamicModel::trackResolveFinished( bool success )
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Got successful resolved track:" << q->track() << q->artist() << m_lastResolvedRow << m_currentAttempts;
|
||||
qDebug() << "Got successful resolved track:" << q->track()->toString() << m_lastResolvedRow << m_currentAttempts;
|
||||
|
||||
if ( m_currentAttempts > 0 ) {
|
||||
qDebug() << "EMITTING AN ASK FOR COLLAPSE:" << m_lastResolvedRow << m_currentAttempts;
|
||||
@ -251,7 +251,7 @@ DynamicModel::filteringTrackResolved( bool successful )
|
||||
Q_ASSERT( q );
|
||||
|
||||
// if meantime the user began the station, abort
|
||||
qDebug() << "Got filtering resolved finished for track, was it successful?:" << q->track() << q->artist() << successful << q->playable();
|
||||
qDebug() << "Got filtering resolved finished for track, was it successful?:" << q->track()->toString() << successful << q->playable();
|
||||
if ( m_onDemandRunning )
|
||||
{
|
||||
m_toResolveList.clear();
|
||||
@ -294,7 +294,7 @@ DynamicModel::filteringTrackResolved( bool successful )
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Got unsuccessful resolve request for this track" << realptr->track() << realptr->artist();
|
||||
qDebug() << "Got unsuccessful resolve request for this track" << realptr->track()->toString();
|
||||
}
|
||||
|
||||
if ( m_toResolveList.isEmpty() && rowCount( QModelIndex() ) == 0 ) // we failed
|
||||
@ -309,7 +309,7 @@ DynamicModel::addToPlaylist( const QList< query_ptr >& entries, bool clearFirst
|
||||
clear();
|
||||
|
||||
foreach ( const query_ptr& q, entries )
|
||||
m_deduper.append( QPair< QString, QString >( q->track(), q->artist() ) );
|
||||
m_deduper.append( QPair< QString, QString >( q->track()->track(), q->track()->artist() ) );
|
||||
|
||||
if ( m_playlist->author()->isLocal() && m_playlist->mode() == Static )
|
||||
{
|
||||
|
@ -686,9 +686,9 @@ QtScriptResolver::resolve( const Tomahawk::query_ptr& query )
|
||||
{
|
||||
eval = QString( RESOLVER_LEGACY_CODE2 "resolver.resolve( '%1', '%2', '%3', '%4' );" )
|
||||
.arg( query->id().replace( "'", "\\'" ) )
|
||||
.arg( query->artist().replace( "'", "\\'" ) )
|
||||
.arg( query->album().replace( "'", "\\'" ) )
|
||||
.arg( query->track().replace( "'", "\\'" ) );
|
||||
.arg( query->queryTrack()->artist().replace( "'", "\\'" ) )
|
||||
.arg( query->queryTrack()->album().replace( "'", "\\'" ) )
|
||||
.arg( query->queryTrack()->track().replace( "'", "\\'" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -736,12 +736,16 @@ QtScriptResolver::parseResultVariantList( const QVariantList& reslist )
|
||||
if ( m.value( "preview" ).toBool() == true )
|
||||
continue;
|
||||
|
||||
unsigned int duration = m.value( "duration", 0 ).toUInt();
|
||||
if ( duration <= 0 && m.contains( "durationString" ) )
|
||||
{
|
||||
QTime time = QTime::fromString( m.value( "durationString" ).toString(), "hh:mm:ss" );
|
||||
duration = time.secsTo( QTime( 0, 0 ) ) * -1;
|
||||
}
|
||||
|
||||
Tomahawk::result_ptr rp = Tomahawk::Result::get( m.value( "url" ).toString() );
|
||||
Tomahawk::artist_ptr ap = Tomahawk::Artist::get( m.value( "artist" ).toString(), false );
|
||||
rp->setArtist( ap );
|
||||
rp->setAlbum( Tomahawk::Album::get( ap, m.value( "album" ).toString(), false ) );
|
||||
rp->setTrack( m.value( "track" ).toString() );
|
||||
rp->setAlbumPos( m.value( "albumpos" ).toUInt() );
|
||||
Tomahawk::track_ptr track = Tomahawk::Track::get( m.value( "artist" ).toString(), m.value( "track" ).toString(), m.value( "album" ).toString(), duration, QString(), m.value( "albumpos" ).toUInt(), m.value( "discnumber" ).toUInt() );
|
||||
|
||||
rp->setBitrate( m.value( "bitrate" ).toUInt() );
|
||||
rp->setSize( m.value( "size" ).toUInt() );
|
||||
rp->setRID( uuid() );
|
||||
@ -749,7 +753,6 @@ QtScriptResolver::parseResultVariantList( const QVariantList& reslist )
|
||||
rp->setPurchaseUrl( m.value( "purchaseUrl" ).toString() );
|
||||
rp->setLinkUrl( m.value( "linkUrl" ).toString() );
|
||||
rp->setScore( m.value( "score" ).toFloat() );
|
||||
rp->setDiscNumber( m.value( "discnumber" ).toUInt() );
|
||||
|
||||
if ( m.contains( "year" ) )
|
||||
{
|
||||
@ -758,13 +761,6 @@ QtScriptResolver::parseResultVariantList( const QVariantList& reslist )
|
||||
rp->setAttributes( attr );
|
||||
}
|
||||
|
||||
rp->setDuration( m.value( "duration", 0 ).toUInt() );
|
||||
if ( rp->duration() <= 0 && m.contains( "durationString" ) )
|
||||
{
|
||||
QTime time = QTime::fromString( m.value( "durationString" ).toString(), "hh:mm:ss" );
|
||||
rp->setDuration( time.secsTo( QTime( 0, 0 ) ) * -1 );
|
||||
}
|
||||
|
||||
rp->setMimetype( m.value( "mimetype" ).toString() );
|
||||
if ( rp->mimetype().isEmpty() )
|
||||
{
|
||||
@ -772,6 +768,7 @@ QtScriptResolver::parseResultVariantList( const QVariantList& reslist )
|
||||
Q_ASSERT( !rp->mimetype().isEmpty() );
|
||||
}
|
||||
|
||||
rp->setTrack( track );
|
||||
rp->setResolvedBy( this );
|
||||
results << rp;
|
||||
}
|
||||
|
@ -278,12 +278,9 @@ ScriptResolver::handleMsg( const QByteArray& msg )
|
||||
continue;
|
||||
|
||||
Tomahawk::result_ptr rp = Tomahawk::Result::get( m.value( "url" ).toString() );
|
||||
Tomahawk::artist_ptr ap = Tomahawk::Artist::get( m.value( "artist" ).toString(), false );
|
||||
rp->setArtist( ap );
|
||||
rp->setAlbum( Tomahawk::Album::get( ap, m.value( "album" ).toString(), false ) );
|
||||
rp->setAlbumPos( m.value( "albumpos" ).toUInt() );
|
||||
rp->setTrack( m.value( "track" ).toString() );
|
||||
rp->setDuration( m.value( "duration" ).toUInt() );
|
||||
Tomahawk::track_ptr track = Tomahawk::Track::get( m.value( "artist" ).toString(), m.value( "track" ).toString(), m.value( "album" ).toString(), m.value( "duration" ).toUInt(), QString(), m.value( "albumpos" ).toUInt(), m.value( "discnumber" ).toUInt() );
|
||||
rp->setTrack( track );
|
||||
|
||||
rp->setBitrate( m.value( "bitrate" ).toUInt() );
|
||||
rp->setSize( m.value( "size" ).toUInt() );
|
||||
rp->setRID( uuid() );
|
||||
@ -291,7 +288,6 @@ ScriptResolver::handleMsg( const QByteArray& msg )
|
||||
rp->setPurchaseUrl( m.value( "purchaseUrl" ).toString() );
|
||||
rp->setLinkUrl( m.value( "linkUrl" ).toString() );
|
||||
rp->setYear( m.value( "year").toUInt() );
|
||||
rp->setDiscNumber( m.value( "discnumber" ).toUInt() );
|
||||
|
||||
rp->setMimetype( m.value( "mimetype" ).toString() );
|
||||
if ( rp->mimetype().isEmpty() )
|
||||
@ -355,14 +351,14 @@ ScriptResolver::resolve( const Tomahawk::query_ptr& query )
|
||||
if ( query->isFullTextQuery() )
|
||||
{
|
||||
m.insert( "fulltext", query->fullTextQuery() );
|
||||
m.insert( "artist", query->artist() );
|
||||
m.insert( "artist", query->queryTrack()->artist() );
|
||||
m.insert( "track", query->fullTextQuery() );
|
||||
m.insert( "qid", query->id() );
|
||||
}
|
||||
else
|
||||
{
|
||||
m.insert( "artist", query->artist() );
|
||||
m.insert( "track", query->track() );
|
||||
m.insert( "artist", query->queryTrack()->artist() );
|
||||
m.insert( "track", query->queryTrack()->track() );
|
||||
m.insert( "qid", query->id() );
|
||||
|
||||
if ( !query->resultHint().isEmpty() )
|
||||
|
@ -178,11 +178,11 @@ JSPFLoader::gotBody()
|
||||
continue;
|
||||
}
|
||||
|
||||
query_ptr q = Tomahawk::Query::get( artist, track, album, uuid() );
|
||||
if ( q.isNull() )
|
||||
track_ptr t = Tomahawk::Track::get( artist, track, album, duration.toInt() / 1000 );
|
||||
query_ptr q = Tomahawk::Query::get( t );
|
||||
if ( !q )
|
||||
continue;
|
||||
|
||||
q->setDuration( duration.toInt() / 1000 );
|
||||
if ( !url.isEmpty() )
|
||||
{
|
||||
q->setResultHint( url );
|
||||
|
@ -85,12 +85,11 @@ PixmapDelegateFader::PixmapDelegateFader( const query_ptr& track, const QSize& s
|
||||
{
|
||||
if ( !m_track.isNull() )
|
||||
{
|
||||
connect( m_track.data(), SIGNAL( updated() ), SLOT( trackChanged() ) );
|
||||
connect( m_track.data(), SIGNAL( resultsChanged() ), SLOT( trackChanged() ) );
|
||||
connect( m_track->displayQuery().data(), SIGNAL( updated() ), SLOT( trackChanged() ) );
|
||||
connect( m_track->displayQuery().data(), SIGNAL( coverChanged() ), SLOT( trackChanged() ) );
|
||||
connect( m_track->track().data(), SIGNAL( updated() ), SLOT( trackChanged() ) );
|
||||
connect( m_track->track().data(), SIGNAL( coverChanged() ), SLOT( trackChanged() ) );
|
||||
|
||||
m_currentReference = TomahawkUtils::createRoundedImage( m_track->displayQuery()->cover( size, forceLoad ), QSize( 0, 0 ), m_mode == TomahawkUtils::Grid ? 0.00 : 0.20 );
|
||||
m_currentReference = TomahawkUtils::createRoundedImage( m_track->track()->cover( size, forceLoad ), QSize( 0, 0 ), m_mode == TomahawkUtils::Grid ? 0.00 : 0.20 );
|
||||
}
|
||||
|
||||
init();
|
||||
@ -151,7 +150,7 @@ PixmapDelegateFader::setSize( const QSize& size )
|
||||
else if ( !m_artist.isNull() )
|
||||
m_currentReference = TomahawkUtils::createRoundedImage( m_artist->cover( m_size ), QSize( 0, 0 ), m_mode == TomahawkUtils::Grid ? 0.00 : 0.20 );
|
||||
else if ( !m_track.isNull() )
|
||||
m_currentReference = TomahawkUtils::createRoundedImage( m_track->displayQuery()->cover( m_size ), QSize( 0, 0 ), m_mode == TomahawkUtils::Grid ? 0.00 : 0.20 );
|
||||
m_currentReference = TomahawkUtils::createRoundedImage( m_track->track()->cover( m_size ), QSize( 0, 0 ), m_mode == TomahawkUtils::Grid ? 0.00 : 0.20 );
|
||||
}
|
||||
|
||||
emit repaintRequest();
|
||||
@ -184,9 +183,9 @@ PixmapDelegateFader::trackChanged()
|
||||
if ( m_track.isNull() )
|
||||
return;
|
||||
|
||||
connect( m_track->displayQuery().data(), SIGNAL( updated() ), SLOT( trackChanged() ), Qt::UniqueConnection );
|
||||
connect( m_track->displayQuery().data(), SIGNAL( coverChanged() ), SLOT( trackChanged() ), Qt::UniqueConnection );
|
||||
QMetaObject::invokeMethod( this, "setPixmap", Qt::QueuedConnection, Q_ARG( QPixmap, m_track->displayQuery()->cover( m_size ) ) );
|
||||
connect( m_track->track().data(), SIGNAL( updated() ), SLOT( trackChanged() ), Qt::UniqueConnection );
|
||||
connect( m_track->track().data(), SIGNAL( coverChanged() ), SLOT( trackChanged() ), Qt::UniqueConnection );
|
||||
QMetaObject::invokeMethod( this, "setPixmap", Qt::QueuedConnection, Q_ARG( QPixmap, m_track->track()->cover( m_size ) ) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -702,9 +702,9 @@ mergePlaylistChanges( const QList< Tomahawk::query_ptr >& orig, const QList< Tom
|
||||
{
|
||||
foreach ( const Tomahawk::query_ptr& oldq, orig )
|
||||
{
|
||||
if ( newquery->track() == oldq->track() &&
|
||||
newquery->artist() == oldq->artist() &&
|
||||
newquery->album() == oldq->album() )
|
||||
if ( newquery->queryTrack()->track() == oldq->queryTrack()->track() &&
|
||||
newquery->queryTrack()->artist() == oldq->queryTrack()->artist() &&
|
||||
newquery->queryTrack()->album() == oldq->queryTrack()->album() )
|
||||
{
|
||||
sameCount++;
|
||||
if ( tosave.contains( newquery ) )
|
||||
|
@ -66,9 +66,9 @@ XSPFGenerator::generate()
|
||||
foreach ( const plentry_ptr& q, m_playlist->entries() )
|
||||
{
|
||||
w.writeStartElement( "track" );
|
||||
w.writeTextElement( "title", q->query()->track() );
|
||||
w.writeTextElement( "creator", q->query()->artist() );
|
||||
w.writeTextElement( "album", q->query()->album() );
|
||||
w.writeTextElement( "title", q->query()->queryTrack()->track() );
|
||||
w.writeTextElement( "creator", q->query()->queryTrack()->artist() );
|
||||
w.writeTextElement( "album", q->query()->queryTrack()->album() );
|
||||
w.writeEndElement();
|
||||
}
|
||||
w.writeEndDocument(); // will close all open elements
|
||||
|
@ -249,11 +249,11 @@ XSPFLoader::gotBody()
|
||||
continue;
|
||||
}
|
||||
|
||||
query_ptr q = Tomahawk::Query::get( artist, track, album, uuid(), false );
|
||||
track_ptr t = Tomahawk::Track::get( artist, track, album, duration.toInt() / 1000 );
|
||||
query_ptr q = Tomahawk::Query::get( t );
|
||||
if ( q.isNull() )
|
||||
continue;
|
||||
|
||||
q->setDuration( duration.toInt() / 1000 );
|
||||
if ( !url.isEmpty() )
|
||||
{
|
||||
q->setResultHint( url );
|
||||
|
@ -116,7 +116,7 @@ void
|
||||
PlayableCover::mouseReleaseEvent( QMouseEvent* event )
|
||||
{
|
||||
QLabel::mouseReleaseEvent( event );
|
||||
|
||||
|
||||
foreach ( const QRect& rect, m_itemRects )
|
||||
{
|
||||
if ( rect.contains( event->pos() ) )
|
||||
@ -126,8 +126,8 @@ PlayableCover::mouseReleaseEvent( QMouseEvent* event )
|
||||
else if ( m_album )
|
||||
ViewManager::instance()->show( m_album->artist() );
|
||||
else if ( m_query )
|
||||
ViewManager::instance()->show( Tomahawk::Artist::get( m_query->artist() ) );
|
||||
|
||||
ViewManager::instance()->show( m_query->queryTrack()->artistPtr() );
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -145,7 +145,7 @@ PlayableCover::contextMenuEvent( QContextMenuEvent* event )
|
||||
m_contextMenu->setAlbum( m_album );
|
||||
else
|
||||
m_contextMenu->setQuery( m_query );
|
||||
|
||||
|
||||
m_contextMenu->exec( event->globalPos() );
|
||||
}
|
||||
|
||||
@ -175,10 +175,10 @@ PlayableCover::paintEvent( QPaintEvent* event )
|
||||
buffer.fill( Qt::transparent );
|
||||
QPainter bufpainter( &buffer );
|
||||
bufpainter.setRenderHint( QPainter::Antialiasing );
|
||||
|
||||
|
||||
QTextOption to;
|
||||
to.setWrapMode( QTextOption::NoWrap );
|
||||
|
||||
|
||||
QColor c1;
|
||||
c1.setRgb( 0, 0, 0 );
|
||||
c1.setAlphaF( 0.00 );
|
||||
@ -205,34 +205,34 @@ PlayableCover::paintEvent( QPaintEvent* event )
|
||||
}
|
||||
else if ( m_query )
|
||||
{
|
||||
top = m_query->track();
|
||||
bottom = m_query->artist();
|
||||
top = m_query->queryTrack()->track();
|
||||
bottom = m_query->queryTrack()->artist();
|
||||
}
|
||||
|
||||
int bottomHeight = QFontMetrics( font ).boundingRect( bottom ).height();
|
||||
int topHeight = QFontMetrics( boldFont ).boundingRect( top ).height();
|
||||
int frameHeight = bottomHeight + topHeight + 4;
|
||||
|
||||
|
||||
QRect gradientRect = r.adjusted( 0, r.height() - frameHeight * 3, 0, 0 );
|
||||
QLinearGradient gradient( QPointF( 0, 0 ), QPointF( 0, 1 ) );
|
||||
gradient.setCoordinateMode( QGradient::ObjectBoundingMode );
|
||||
gradient.setColorAt( 0.0, c1 );
|
||||
gradient.setColorAt( 0.6, c2 );
|
||||
gradient.setColorAt( 1.0, c2 );
|
||||
|
||||
|
||||
bufpainter.save();
|
||||
bufpainter.setPen( Qt::transparent );
|
||||
bufpainter.setBrush( gradient );
|
||||
bufpainter.drawRect( gradientRect );
|
||||
bufpainter.restore();
|
||||
|
||||
|
||||
bufpainter.setPen( Qt::white );
|
||||
|
||||
|
||||
QRect textRect = r.adjusted( 8, r.height() - frameHeight - 16, -8, -16 );
|
||||
bool oneLiner = false;
|
||||
if ( bottom.isEmpty() )
|
||||
oneLiner = true;
|
||||
|
||||
|
||||
bufpainter.setFont( boldFont );
|
||||
if ( oneLiner )
|
||||
{
|
||||
@ -244,7 +244,7 @@ PlayableCover::paintEvent( QPaintEvent* event )
|
||||
f.setPointSizeF( f.pointSizeF() - 0.2 );
|
||||
bufpainter.setFont( f );
|
||||
}
|
||||
|
||||
|
||||
to.setAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
|
||||
text = bufpainter.fontMetrics().elidedText( top, Qt::ElideRight, textRect.width() - 3 );
|
||||
bufpainter.drawText( textRect, text, to );
|
||||
@ -256,7 +256,7 @@ PlayableCover::paintEvent( QPaintEvent* event )
|
||||
to.setAlignment( Qt::AlignHCenter | Qt::AlignTop );
|
||||
text = bufpainter.fontMetrics().elidedText( top, Qt::ElideRight, textRect.width() - 3 );
|
||||
bufpainter.drawText( textRect, text, to );
|
||||
|
||||
|
||||
bufpainter.setFont( font );
|
||||
|
||||
QRect r = textRect;
|
||||
@ -275,7 +275,7 @@ PlayableCover::paintEvent( QPaintEvent* event )
|
||||
TomahawkUtils::drawQueryBackground( &bufpainter, r );
|
||||
bufpainter.setPen( TomahawkUtils::Colors::SELECTION_FOREGROUND );
|
||||
}
|
||||
|
||||
|
||||
to.setAlignment( Qt::AlignHCenter | Qt::AlignBottom );
|
||||
bufpainter.drawText( textRect.adjusted( 5, -1, -5, -1 ), text, to );
|
||||
}
|
||||
|
@ -109,30 +109,30 @@ QueryLabel::text() const
|
||||
{
|
||||
if ( m_type & Artist )
|
||||
{
|
||||
text += m_result->artist()->name();
|
||||
text += m_result->track()->artist();
|
||||
}
|
||||
if ( m_type & Album && !m_result->album()->name().isEmpty() )
|
||||
if ( m_type & Album && !m_result->track()->album().isEmpty() )
|
||||
{
|
||||
smartAppend( text, m_result->album()->name() );
|
||||
smartAppend( text, m_result->track()->album() );
|
||||
}
|
||||
if ( m_type & Track )
|
||||
{
|
||||
smartAppend( text, m_result->track() );
|
||||
smartAppend( text, m_result->track()->track() );
|
||||
}
|
||||
}
|
||||
else if ( !m_query.isNull() )
|
||||
{
|
||||
if ( m_type & Artist )
|
||||
{
|
||||
text += m_query->artist();
|
||||
text += m_query->track()->artist();
|
||||
}
|
||||
if ( m_type & Album && !m_query->album().isEmpty() )
|
||||
if ( m_type & Album && !m_query->track()->album().isEmpty() )
|
||||
{
|
||||
smartAppend( text, m_query->album() );
|
||||
smartAppend( text, m_query->track()->album() );
|
||||
}
|
||||
if ( m_type & Track )
|
||||
{
|
||||
smartAppend( text, m_query->track() );
|
||||
smartAppend( text, m_query->track()->track() );
|
||||
}
|
||||
}
|
||||
else if ( !m_artist.isNull() )
|
||||
@ -155,9 +155,9 @@ QueryLabel::track() const
|
||||
return QString();
|
||||
|
||||
if ( !m_result.isNull() )
|
||||
return m_result->track();
|
||||
return m_result->track()->track();
|
||||
else
|
||||
return m_query->track();
|
||||
return m_query->track()->track();
|
||||
}
|
||||
|
||||
|
||||
@ -183,8 +183,8 @@ void
|
||||
QueryLabel::onResultChanged()
|
||||
{
|
||||
m_query = m_result->toQuery();
|
||||
m_artist = m_result->artist();
|
||||
m_album = m_result->album();
|
||||
m_artist = m_result->track()->artistPtr();
|
||||
m_album = m_result->track()->albumPtr();
|
||||
|
||||
updateLabel();
|
||||
|
||||
@ -225,8 +225,8 @@ QueryLabel::setQuery( const Tomahawk::query_ptr& query )
|
||||
if ( m_query.isNull() || m_query.data() != query.data() )
|
||||
{
|
||||
m_query = query;
|
||||
m_artist = Artist::get( query->artist() );
|
||||
m_album = Album::get( m_artist, query->album() );
|
||||
m_artist = Artist::get( query->track()->artist() );
|
||||
m_album = Album::get( m_artist, query->track()->album() );
|
||||
m_result.clear();
|
||||
|
||||
updateLabel();
|
||||
|
@ -65,7 +65,7 @@ RecentPlaylistsModel::onRefresh()
|
||||
m_timer->stop();
|
||||
|
||||
emit loadingStarted();
|
||||
|
||||
|
||||
DatabaseCommand_LoadAllSortedPlaylists* cmd = new DatabaseCommand_LoadAllSortedPlaylists( source_ptr() );
|
||||
cmd->setLimit( 15 );
|
||||
cmd->setSortOrder( DatabaseCommand_LoadAllPlaylists::ModificationTime );
|
||||
@ -145,8 +145,8 @@ RecentPlaylistsModel::data( const QModelIndex& index, int role ) const
|
||||
|
||||
foreach( const Tomahawk::plentry_ptr& entry, pl->entries() )
|
||||
{
|
||||
if ( !artists.contains( entry->query()->artist() ) )
|
||||
artists << entry->query()->artist();
|
||||
if ( !artists.contains( entry->query()->track()->artist() ) )
|
||||
artists << entry->query()->track()->artist();
|
||||
}
|
||||
|
||||
m_artists[pl] = artists.join( ", " );
|
||||
|
@ -109,8 +109,8 @@ RecentlyPlayedPlaylistsModel::data( const QModelIndex& index, int role ) const
|
||||
|
||||
foreach( const Tomahawk::plentry_ptr& entry, pl->entries() )
|
||||
{
|
||||
if ( !artists.contains( entry->query()->artist() ) )
|
||||
artists << entry->query()->artist();
|
||||
if ( !artists.contains( entry->query()->track()->artist() ) )
|
||||
artists << entry->query()->track()->artist();
|
||||
}
|
||||
|
||||
m_artists[pl] = artists.join( ", " );
|
||||
|
@ -132,8 +132,8 @@ SearchWidget::onResultsFound( const QList<Tomahawk::result_ptr>& results )
|
||||
|
||||
m_resultsModel->appendQuery( q );
|
||||
|
||||
artists << result->artist();
|
||||
albums << result->album();
|
||||
artists << result->track()->artistPtr();
|
||||
albums << result->track()->albumPtr();
|
||||
}
|
||||
|
||||
onArtistsFound( artists );
|
||||
|
@ -84,7 +84,7 @@ TrackInfoWidget::TrackInfoWidget( const Tomahawk::query_ptr& query, QWidget* par
|
||||
m_pixmap = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultTrackImage, TomahawkUtils::Original, QSize( 48, 48 ) );
|
||||
ui->cover->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultTrackImage, TomahawkUtils::Grid, ui->cover->size() ) );
|
||||
ui->cover->setShowText( true );
|
||||
|
||||
|
||||
m_scrollArea = new QScrollArea();
|
||||
m_scrollArea->setWidgetResizable( true );
|
||||
m_scrollArea->setWidget( widget );
|
||||
@ -156,28 +156,28 @@ void
|
||||
TrackInfoWidget::load( const query_ptr& query )
|
||||
{
|
||||
m_query = query;
|
||||
m_artist = Artist::get( m_query->artist() );
|
||||
m_title = QString( "%1 - %2" ).arg( query->artist() ).arg( query->track() );
|
||||
m_artist = Artist::get( m_query->track()->artist() );
|
||||
m_title = QString( "%1 - %2" ).arg( query->track()->artist() ).arg( query->track()->track() );
|
||||
|
||||
if ( !m_query.isNull() )
|
||||
{
|
||||
disconnect( m_query.data(), SIGNAL( lyricsLoaded() ), this, SLOT( onLyricsLoaded() ) );
|
||||
disconnect( m_query.data(), SIGNAL( similarTracksLoaded() ), this, SLOT( onSimilarTracksLoaded() ) );
|
||||
disconnect( m_query.data(), SIGNAL( statsLoaded() ), this, SLOT( onStatsLoaded() ) );
|
||||
disconnect( m_query.data(), SIGNAL( updated() ), this, SLOT( onCoverUpdated() ) );
|
||||
disconnect( m_query->track().data(), SIGNAL( lyricsLoaded() ), this, SLOT( onLyricsLoaded() ) );
|
||||
disconnect( m_query->track().data(), SIGNAL( similarTracksLoaded() ), this, SLOT( onSimilarTracksLoaded() ) );
|
||||
disconnect( m_query->track().data(), SIGNAL( statsLoaded() ), this, SLOT( onStatsLoaded() ) );
|
||||
disconnect( m_query->track().data(), SIGNAL( updated() ), this, SLOT( onCoverUpdated() ) );
|
||||
disconnect( m_artist.data(), SIGNAL( statsLoaded() ), this, SLOT( onStatsLoaded() ) );
|
||||
disconnect( m_artist.data(), SIGNAL( similarArtistsLoaded() ), this, SLOT( onSimilarArtistsLoaded() ) );
|
||||
}
|
||||
|
||||
connect( m_artist.data(), SIGNAL( similarArtistsLoaded() ), SLOT( onSimilarArtistsLoaded() ) );
|
||||
connect( m_artist.data(), SIGNAL( statsLoaded() ), SLOT( onStatsLoaded() ) );
|
||||
connect( m_query.data(), SIGNAL( lyricsLoaded() ), SLOT( onLyricsLoaded() ) );
|
||||
connect( m_query.data(), SIGNAL( similarTracksLoaded() ), SLOT( onSimilarTracksLoaded() ) );
|
||||
connect( m_query.data(), SIGNAL( updated() ), SLOT( onCoverUpdated() ) );
|
||||
connect( m_query.data(), SIGNAL( statsLoaded() ), SLOT( onStatsLoaded() ) );
|
||||
connect( m_query->track().data(), SIGNAL( lyricsLoaded() ), SLOT( onLyricsLoaded() ) );
|
||||
connect( m_query->track().data(), SIGNAL( similarTracksLoaded() ), SLOT( onSimilarTracksLoaded() ) );
|
||||
connect( m_query->track().data(), SIGNAL( updated() ), SLOT( onCoverUpdated() ) );
|
||||
connect( m_query->track().data(), SIGNAL( statsLoaded() ), SLOT( onStatsLoaded() ) );
|
||||
|
||||
m_artist->loadStats();
|
||||
m_query->loadStats();
|
||||
m_query->track()->loadStats();
|
||||
// m_query->lyrics();
|
||||
onCoverUpdated();
|
||||
|
||||
@ -186,7 +186,7 @@ TrackInfoWidget::load( const query_ptr& query )
|
||||
m_relatedTracksModel->clear();
|
||||
m_relatedTracksModel->startLoading();
|
||||
|
||||
if ( !m_query->similarTracks().isEmpty() )
|
||||
if ( !m_query->track()->similarTracks().isEmpty() )
|
||||
onSimilarTracksLoaded();
|
||||
}
|
||||
|
||||
@ -194,10 +194,10 @@ TrackInfoWidget::load( const query_ptr& query )
|
||||
void
|
||||
TrackInfoWidget::onCoverUpdated()
|
||||
{
|
||||
if ( m_query->cover( QSize( 0, 0 ) ).isNull() )
|
||||
if ( m_query->track()->cover( QSize( 0, 0 ) ).isNull() )
|
||||
return;
|
||||
|
||||
m_pixmap = m_query->cover( ui->cover->size() );
|
||||
m_pixmap = m_query->track()->cover( ui->cover->size() );
|
||||
ui->cover->setPixmap( TomahawkUtils::createRoundedImage( m_pixmap, QSize( 0, 0 ) ) );
|
||||
}
|
||||
|
||||
@ -205,8 +205,8 @@ TrackInfoWidget::onCoverUpdated()
|
||||
void
|
||||
TrackInfoWidget::onStatsLoaded()
|
||||
{
|
||||
QList< Tomahawk::PlaybackLog > history = m_query->playbackHistory( SourceList::instance()->getLocal() );
|
||||
const unsigned int trackCounter = m_query->playbackCount( SourceList::instance()->getLocal() );
|
||||
QList< Tomahawk::PlaybackLog > history = m_query->track()->playbackHistory( SourceList::instance()->getLocal() );
|
||||
const unsigned int trackCounter = m_query->track()->playbackCount( SourceList::instance()->getLocal() );
|
||||
const unsigned int artistCounter = m_artist->playbackCount( SourceList::instance()->getLocal() );
|
||||
|
||||
QString stats;
|
||||
@ -242,7 +242,7 @@ TrackInfoWidget::onSimilarArtistsLoaded()
|
||||
void
|
||||
TrackInfoWidget::onSimilarTracksLoaded()
|
||||
{
|
||||
m_relatedTracksModel->appendQueries( m_query->similarTracks() );
|
||||
m_relatedTracksModel->appendQueries( m_query->track()->similarTracks() );
|
||||
m_relatedTracksModel->finishLoading();
|
||||
}
|
||||
|
||||
@ -250,22 +250,21 @@ TrackInfoWidget::onSimilarTracksLoaded()
|
||||
void
|
||||
TrackInfoWidget::onLyricsLoaded()
|
||||
{
|
||||
ui->lyricsView->setHtml( m_query->lyrics().join( "<br/>" ) );
|
||||
ui->lyricsView->setHtml( m_query->track()->lyrics().join( "<br/>" ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TrackInfoWidget::onArtistClicked()
|
||||
{
|
||||
ViewManager::instance()->show( Artist::get( m_query->artist(), false ) );
|
||||
ViewManager::instance()->show( m_query->track()->artistPtr() );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TrackInfoWidget::onAlbumClicked()
|
||||
{
|
||||
artist_ptr artist = Artist::get( m_query->artist(), false );
|
||||
ViewManager::instance()->show( Album::get( artist, m_query->album(), false ) );
|
||||
ViewManager::instance()->show( m_query->track()->albumPtr() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -289,7 +289,7 @@ CategoryAddItem::parsedDroppedTracks( const QList< query_ptr >& tracks )
|
||||
{
|
||||
// seed the playlist with these song or artist filters
|
||||
QString name;
|
||||
name = tracks.isEmpty() ? tr( "New Station" ) : tr( "%1 Station" ).arg( tracks.first()->track() );
|
||||
name = tracks.isEmpty() ? tr( "New Station" ) : tr( "%1 Station" ).arg( tracks.first()->track()->track() );
|
||||
|
||||
dynplaylist_ptr newpl = DynamicPlaylist::create( SourceList::instance()->getLocal(), uuid(), name, "", SourceList::instance()->getLocal()->friendlyName(), OnDemand, false );
|
||||
newpl->setMode( OnDemand );
|
||||
@ -299,7 +299,7 @@ CategoryAddItem::parsedDroppedTracks( const QList< query_ptr >& tracks )
|
||||
foreach ( const Tomahawk::query_ptr& q, tracks )
|
||||
{
|
||||
dyncontrol_ptr c = newpl->generator()->createControl( "Song" );
|
||||
c->setInput( QString( "%1 %2" ).arg( q->track() ).arg( q->artist() ) );
|
||||
c->setInput( QString( "%1 %2" ).arg( q->track()->track() ).arg( q->track()->artist() ) );
|
||||
controls << c;
|
||||
}
|
||||
|
||||
|
@ -166,5 +166,5 @@ void
|
||||
LovedTracksItem::loveDroppedTracks( QList< Tomahawk::query_ptr > qrys )
|
||||
{
|
||||
foreach( Tomahawk::query_ptr qry, qrys )
|
||||
qry->setLoved( true );
|
||||
qry->track()->setLoved( true );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user