void AtticaManager::uploadRating( const Content& c ) { m_resolverStates[ c.id() ].userRating = c.rating(); for ( int i = 0; i < m_resolvers.count(); i++ ) { if ( m_resolvers[ i ].id() == c.id() ) { Attica::Content atticaContent = m_resolvers[ i ]; atticaContent.setRating( c.rating() ); m_resolvers[ i ] = atticaContent; break; } } TomahawkSettings::instance()->setAtticaResolverStates( m_resolverStates ); PostJob* job = m_resolverProvider.voteForContent( c.id(), (uint)c.rating() ); connect( job, SIGNAL( finished( Attica::BaseJob* ) ), job, SLOT( deleteLater() ) ); job->start(); emit resolverStateChanged( c.id() ); }
QPixmap AtticaManager::iconForResolver( const Content& resolver ) { if ( !m_resolverStates[ resolver.id() ].pixmap ) return QPixmap(); return *m_resolverStates.value( resolver.id() ).pixmap; }
AtticaManager::ResolverState AtticaManager::resolverState ( const Content& resolver ) const { if ( !m_resolverStates.contains( resolver.id() ) ) { return AtticaManager::Uninstalled; } return m_resolverStates[ resolver.id() ].state; }
foreach ( Content resolver, m_resolvers ) { if ( !m_resolverStates.contains( resolver.id() ) ) m_resolverStates.insert( resolver.id(), Resolver() ); if ( !m_resolverStates.value( resolver.id() ).pixmap && !resolver.icons().isEmpty() && !resolver.icons().first().url().isEmpty() ) { QNetworkReply* fetch = Tomahawk::Utils::nam()->get( QNetworkRequest( resolver.icons().first().url() ) ); fetch->setProperty( "resolverId", resolver.id() ); connect( fetch, SIGNAL( finished() ), this, SLOT( resolverIconFetched() ) ); } }
bool AtticaManager::userHasRated( const Content& c ) const { return m_resolverStates[ c.id() ].userRating != -1; }