mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-20 07:49:42 +01:00
* Use new DbCmd interfaces.
This commit is contained in:
parent
0bde2a5521
commit
e905a4b617
@ -181,10 +181,7 @@ PlaylistInterface::filterTracks( const QList<Tomahawk::query_ptr>& queries )
|
||||
|
||||
if ( picked )
|
||||
{
|
||||
query_ptr q = Query::get( q1->artist(), q1->track(), q1->album(), uuid(), false );
|
||||
q->setAlbumPos( q1->results().first()->albumpos() );
|
||||
q->setDiscNumber( q1->discnumber() );
|
||||
result << q;
|
||||
result << q1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -222,7 +219,7 @@ PlaylistInterface::onItemsChanged()
|
||||
Tomahawk::result_ptr nextResult = siblingResult( 1, m_currentIndex );
|
||||
|
||||
{
|
||||
bool avail = prevResult && prevResult->toQuery()->playable();
|
||||
bool avail = prevResult && prevResult->playable();
|
||||
if ( avail != m_prevAvail )
|
||||
{
|
||||
m_prevAvail = avail;
|
||||
@ -231,7 +228,7 @@ PlaylistInterface::onItemsChanged()
|
||||
}
|
||||
|
||||
{
|
||||
bool avail = nextResult && nextResult->toQuery()->playable();
|
||||
bool avail = nextResult && nextResult->playable();
|
||||
if ( avail != m_nextAvail )
|
||||
{
|
||||
m_nextAvail = avail;
|
||||
|
@ -152,13 +152,13 @@ LastFmConfig::onHistoryLoaded()
|
||||
foreach ( lastfm::XmlQuery e, lfm.children( "track" ) )
|
||||
{
|
||||
// tDebug() << "Found:" << e.children( "artist" ).first()["name"].text() << e["name"].text() << e["date"].attribute( "uts" ).toUInt();
|
||||
Tomahawk::query_ptr query = Tomahawk::Query::get( e.children( "artist" ).first()["name"].text(), e["name"].text(), QString(), QString(), false );
|
||||
if ( query.isNull() )
|
||||
Tomahawk::track_ptr track = Tomahawk::Track::get( e.children( "artist" ).first()["name"].text(), e["name"].text(), QString() );
|
||||
if ( !track )
|
||||
continue;
|
||||
|
||||
m_lastTimeStamp = e["date"].attribute( "uts" ).toUInt();
|
||||
|
||||
DatabaseCommand_LogPlayback* cmd = new DatabaseCommand_LogPlayback( query, DatabaseCommand_LogPlayback::Finished, m_lastTimeStamp );
|
||||
DatabaseCommand_LogPlayback* cmd = new DatabaseCommand_LogPlayback( track, DatabaseCommand_LogPlayback::Finished, 0, m_lastTimeStamp );
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
|
||||
}
|
||||
|
||||
@ -296,12 +296,12 @@ LastFmConfig::onLovedFinished( QNetworkReply* reply )
|
||||
m_ui->progressBar->setValue( thisPage );
|
||||
foreach ( lastfm::XmlQuery e, loved.children( "track" ) )
|
||||
{
|
||||
tDebug() << "Found:" << e.children( "artist" ).first()["name"].text() << e["name"].text() << e["date"].attribute( "uts" ).toUInt();
|
||||
Tomahawk::query_ptr query = Tomahawk::Query::get( e.children( "artist" ).first()["name"].text(), e["name"].text(), QString(), QString(), false );
|
||||
if ( query.isNull() )
|
||||
tDebug() << "Found:" << e.children( "artist" ).first()["name"].text() << e["name"].text() << e["date"].attribute( "uts" ).toUInt();
|
||||
Tomahawk::track_ptr track = Tomahawk::Track::get( e.children( "artist" ).first()["name"].text(), e["name"].text(), QString() );
|
||||
if ( track.isNull() )
|
||||
continue;
|
||||
|
||||
m_lastfmLoved.insert( query );
|
||||
m_lastfmLoved.insert( track );
|
||||
}
|
||||
|
||||
if ( thisPage == m_totalLovedPages )
|
||||
@ -335,7 +335,8 @@ LastFmConfig::onLovedFinished( QNetworkReply* reply )
|
||||
}
|
||||
|
||||
|
||||
bool trackEquality( const Tomahawk::query_ptr& first, const Tomahawk::query_ptr& second )
|
||||
bool
|
||||
trackEquality( const Tomahawk::track_ptr& first, const Tomahawk::track_ptr& second )
|
||||
{
|
||||
qDebug() << "Comparing:" << first->track() << second->track();
|
||||
qDebug() << "==========" << first->artist() << second->artist();
|
||||
@ -357,15 +358,15 @@ LastFmConfig::localLovedLoaded( DatabaseCommand_LoadSocialActions::TrackActions
|
||||
void
|
||||
LastFmConfig::syncLoved()
|
||||
{
|
||||
QSet< Tomahawk::query_ptr > localToLove, lastFmToLove, lastFmToUnlove;
|
||||
QSet< Tomahawk::track_ptr > localToLove, lastFmToLove, lastFmToUnlove;
|
||||
|
||||
const QSet< Tomahawk::query_ptr > myLoved = m_localLoved.keys().toSet();
|
||||
const QSet< Tomahawk::track_ptr > myLoved = m_localLoved.keys().toSet();
|
||||
|
||||
m_ui->progressBar->setValue( m_ui->progressBar->value() + 1 );
|
||||
|
||||
foreach ( const Tomahawk::query_ptr& lastfmLoved, m_lastfmLoved )
|
||||
foreach ( const Tomahawk::track_ptr& lastfmLoved, m_lastfmLoved )
|
||||
{
|
||||
QSet< Tomahawk::query_ptr >::const_iterator iter = std::find_if( myLoved.begin(), myLoved.end(), boost::bind( &trackEquality, _1, boost::ref( lastfmLoved ) ) );
|
||||
QSet< Tomahawk::track_ptr >::const_iterator iter = std::find_if( myLoved.begin(), myLoved.end(), boost::bind( &trackEquality, _1, boost::ref( lastfmLoved ) ) );
|
||||
if ( iter == myLoved.constEnd() )
|
||||
{
|
||||
// qDebug() << "Found last.fm loved track that we didn't have loved locally:" << lastfmLoved->track() << lastfmLoved->artist();
|
||||
@ -373,10 +374,10 @@ LastFmConfig::syncLoved()
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( const Tomahawk::query_ptr& localLoved, myLoved )
|
||||
foreach ( const Tomahawk::track_ptr& localLoved, myLoved )
|
||||
{
|
||||
qDebug() << "CHECKING FOR LOCAL LOVED ON LAST.FM TOO:" << m_localLoved[ localLoved ].value.toString() << localLoved->track() << localLoved->artist();
|
||||
QSet< Tomahawk::query_ptr >::const_iterator iter = std::find_if( m_lastfmLoved.begin(), m_lastfmLoved.end(), boost::bind( &trackEquality, _1, boost::ref( localLoved ) ) );
|
||||
QSet< Tomahawk::track_ptr >::const_iterator iter = std::find_if( m_lastfmLoved.begin(), m_lastfmLoved.end(), boost::bind( &trackEquality, _1, boost::ref( localLoved ) ) );
|
||||
|
||||
qDebug() << "Result:" << (iter == m_lastfmLoved.constEnd());
|
||||
// If we unloved it locally, but it's still loved on last.fm, unlove it
|
||||
@ -391,7 +392,7 @@ LastFmConfig::syncLoved()
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( const Tomahawk::query_ptr& track, localToLove )
|
||||
foreach ( const Tomahawk::track_ptr& track, localToLove )
|
||||
{
|
||||
// Don't use the infosystem as we don't want to tweet a few hundred times :)
|
||||
DatabaseCommand_SocialAction* cmd = new DatabaseCommand_SocialAction( track, QString( "Love" ), QString( "true" ) );
|
||||
@ -400,7 +401,7 @@ LastFmConfig::syncLoved()
|
||||
|
||||
lastFmToLove.unite( lastFmToUnlove );
|
||||
|
||||
foreach ( const Tomahawk::query_ptr& track, lastFmToLove )
|
||||
foreach ( const Tomahawk::track_ptr& track, lastFmToLove )
|
||||
{
|
||||
lastfm::MutableTrack lfmTrack;
|
||||
lfmTrack.stamp();
|
||||
|
@ -19,7 +19,7 @@
|
||||
#ifndef LASTFMCONFIG_H
|
||||
#define LASTFMCONFIG_H
|
||||
|
||||
#include "Query.h"
|
||||
#include "Track.h"
|
||||
#include "accounts/AccountConfigWidget.h"
|
||||
#include "database/DatabaseCommand_LoadSocialActions.h"
|
||||
|
||||
@ -74,7 +74,7 @@ private:
|
||||
|
||||
int m_totalLovedPages;
|
||||
bool m_doneFetchingLoved, m_doneFetchingLocal;
|
||||
QSet< Tomahawk::query_ptr > m_lastfmLoved;
|
||||
QSet< Tomahawk::track_ptr > m_lastfmLoved;
|
||||
DatabaseCommand_LoadSocialActions::TrackActions m_localLoved;
|
||||
};
|
||||
|
||||
|
@ -86,11 +86,11 @@ PlayableItem::PlayableItem( const Tomahawk::query_ptr& query, PlayableItem* pare
|
||||
{
|
||||
init( parent, row );
|
||||
|
||||
connect( query.data(), SIGNAL( socialActionsLoaded() ),
|
||||
SIGNAL( dataChanged() ) );
|
||||
connect( query->track().data(), SIGNAL( socialActionsLoaded() ),
|
||||
SIGNAL( dataChanged() ) );
|
||||
|
||||
connect( query.data(), SIGNAL( updated() ),
|
||||
SIGNAL( dataChanged() ) );
|
||||
connect( query->track().data(), SIGNAL( updated() ),
|
||||
SIGNAL( dataChanged() ) );
|
||||
|
||||
connect( query.data(), SIGNAL( resultsChanged() ),
|
||||
SLOT( onResultsChanged() ) );
|
||||
@ -104,11 +104,11 @@ PlayableItem::PlayableItem( const Tomahawk::plentry_ptr& entry, PlayableItem* pa
|
||||
m_query = entry->query();
|
||||
init( parent, row );
|
||||
|
||||
connect( m_query.data(), SIGNAL( socialActionsLoaded() ),
|
||||
SIGNAL( dataChanged() ) );
|
||||
connect( m_query->track().data(), SIGNAL( socialActionsLoaded() ),
|
||||
SIGNAL( dataChanged() ) );
|
||||
|
||||
connect( m_query.data(), SIGNAL( updated() ),
|
||||
SIGNAL( dataChanged() ) );
|
||||
connect( m_query->track().data(), SIGNAL( updated() ),
|
||||
SIGNAL( dataChanged() ) );
|
||||
|
||||
connect( m_query.data(), SIGNAL( resultsChanged() ),
|
||||
SLOT( onResultsChanged() ) );
|
||||
@ -167,11 +167,11 @@ PlayableItem::name() const
|
||||
}
|
||||
else if ( !m_result.isNull() )
|
||||
{
|
||||
return m_result->track();
|
||||
return m_result->track()->track();
|
||||
}
|
||||
else if ( !m_query.isNull() )
|
||||
{
|
||||
return m_query->track();
|
||||
return m_query->track()->track();
|
||||
}
|
||||
|
||||
Q_ASSERT( false );
|
||||
@ -184,11 +184,11 @@ PlayableItem::artistName() const
|
||||
{
|
||||
if ( !m_result.isNull() )
|
||||
{
|
||||
return m_result->artist()->name();
|
||||
return m_result->track()->artist();
|
||||
}
|
||||
else if ( !m_query.isNull() )
|
||||
{
|
||||
return m_query->artist();
|
||||
return m_query->track()->artist();
|
||||
}
|
||||
|
||||
return QString();
|
||||
@ -198,13 +198,13 @@ PlayableItem::artistName() const
|
||||
QString
|
||||
PlayableItem::albumName() const
|
||||
{
|
||||
if ( !m_result.isNull() && !m_result->album().isNull() )
|
||||
if ( !m_result.isNull() )
|
||||
{
|
||||
return m_result->album()->name();
|
||||
return m_result->track()->album();
|
||||
}
|
||||
else if ( !m_query.isNull() )
|
||||
{
|
||||
return m_query->album();
|
||||
return m_query->track()->album();
|
||||
}
|
||||
|
||||
return QString();
|
||||
@ -222,3 +222,17 @@ PlayableItem::result() const
|
||||
|
||||
return m_result;
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::PlaybackLog
|
||||
PlayableItem::playbackLog() const
|
||||
{
|
||||
return m_playbackLog;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlayableItem::setPlaybackLog( const Tomahawk::PlaybackLog& log )
|
||||
{
|
||||
m_playbackLog = log;
|
||||
}
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <QPersistentModelIndex>
|
||||
#include <QPixmap>
|
||||
|
||||
#include "Track.h"
|
||||
#include "Typedefs.h"
|
||||
#include "DllMacro.h"
|
||||
|
||||
@ -47,6 +48,9 @@ public:
|
||||
const Tomahawk::plentry_ptr& entry() const { return m_entry; }
|
||||
const Tomahawk::result_ptr& result() const;
|
||||
|
||||
Tomahawk::PlaybackLog playbackLog() const;
|
||||
void setPlaybackLog( const Tomahawk::PlaybackLog& log );
|
||||
|
||||
PlayableItem* parent() const { return m_parent; }
|
||||
|
||||
bool isPlaying() const { return m_isPlaying; }
|
||||
@ -81,6 +85,8 @@ private:
|
||||
PlayableItem* m_parent;
|
||||
bool m_fetchingMore;
|
||||
bool m_isPlaying;
|
||||
|
||||
Tomahawk::PlaybackLog m_playbackLog;
|
||||
};
|
||||
|
||||
#endif // PLAYABLEITEM_H
|
||||
|
@ -570,7 +570,7 @@ SourceItem::collectionClicked( const Tomahawk::collection_ptr& collection )
|
||||
|
||||
ViewPage*
|
||||
SourceItem::getCollectionPage( const Tomahawk::collection_ptr& collection ) const
|
||||
{
|
||||
{
|
||||
return m_collectionPages[ collection ];
|
||||
}
|
||||
|
||||
@ -685,8 +685,7 @@ SourceItem::onTracksDropped( const QList< query_ptr >& queries )
|
||||
{
|
||||
foreach ( const query_ptr& query, queries )
|
||||
{
|
||||
DatabaseCommand_ShareTrack* cmd =
|
||||
new DatabaseCommand_ShareTrack( query, m_source->nodeId() );
|
||||
DatabaseCommand_ShareTrack* cmd = new DatabaseCommand_ShareTrack( query->track(), m_source->nodeId() );
|
||||
|
||||
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user