ScrobblesListWidget::ScrobblesListWidget( QWidget* parent )
    :QListWidget( parent ), m_trackItem( 0 )
{
    setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );

#ifdef Q_OS_MAC
    connect( verticalScrollBar(), SIGNAL(valueChanged(int)), SLOT(scroll()) );
#endif

    setAttribute( Qt::WA_MacNoClickThrough );
    setAttribute( Qt::WA_MacShowFocusRect, false );

    setUniformItemSizes( false );
    setSortingEnabled( false );
    setSelectionMode( QAbstractItemView::NoSelection );
    setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );

    connect( qApp, SIGNAL( sessionChanged(unicorn::Session)), SLOT(onSessionChanged(unicorn::Session)));

    connect( &ScrobbleService::instance(), SIGNAL(scrobblesCached(QList<lastfm::Track>)), SLOT(onScrobblesSubmitted(QList<lastfm::Track>) ) );
    connect( &ScrobbleService::instance(), SIGNAL(scrobblesSubmitted(QList<lastfm::Track>)), SLOT(onScrobblesSubmitted(QList<lastfm::Track>) ) );

    connect( &ScrobbleService::instance(), SIGNAL(trackStarted(lastfm::Track,lastfm::Track)), SLOT(onTrackStarted(lastfm::Track,lastfm::Track)));
    connect( &ScrobbleService::instance(), SIGNAL(paused()), SLOT(onPaused()));
    connect( &ScrobbleService::instance(), SIGNAL(resumed()), SLOT(onResumed()));
    connect( &ScrobbleService::instance(), SIGNAL(stopped()), SLOT(onStopped()));

    onSessionChanged( aApp->currentSession() );
}
void
ScrobbleService::resetScrobbler()
{
/// audioscrobbler
    if( m_as )
        delete m_as;

    m_as = new Audioscrobbler( "ass" );
    connect( m_as, SIGNAL(scrobblesCached(QList<lastfm::Track>)), SIGNAL(scrobblesCached(QList<lastfm::Track>)));
    connect( m_as, SIGNAL(scrobblesSubmitted(QList<lastfm::Track>)), SIGNAL(scrobblesSubmitted(QList<lastfm::Track>)));

/// DeviceScrobbler
    if( m_deviceScrobbler )
        delete m_deviceScrobbler;

    m_deviceScrobbler = new DeviceScrobbler;
    connect( m_deviceScrobbler, SIGNAL(foundScrobbles( QList<lastfm::Track>, QString)), this, SIGNAL( foundIPodScrobbles(QList<lastfm::Track>, QString) ));
    connect( m_deviceScrobbler, SIGNAL(foundScrobbles( QList<lastfm::Track>, QString )), m_as, SLOT( cacheBatch( QList<lastfm::Track>, QString)));
    m_deviceScrobbler->checkCachedIPodScrobbles();
}
ProfileWidget::ProfileWidget(QWidget *parent)
    :QFrame(parent), ui( new Ui::ProfileWidget )
{
    ui->setupUi( this );

    connect( aApp, SIGNAL(sessionChanged(unicorn::Session*)), SLOT(onSessionChanged(unicorn::Session*)) );
    connect( aApp, SIGNAL(gotUserInfo(lastfm::User)), SLOT(onGotUserInfo(lastfm::User)) );

    connect( &ScrobbleService::instance(), SIGNAL(scrobblesCached(QList<lastfm::Track>)), SLOT(onScrobblesCached(QList<lastfm::Track>)));

    onSessionChanged( aApp->currentSession() );
}
ProfileWidget::ProfileWidget(QWidget *parent)
    :StylableWidget(parent)
{
    QVBoxLayout* layout = new QVBoxLayout( this );
    layout->setContentsMargins( 0, 0, 0, 0 );
    layout->setSpacing( 0 );

    connect( aApp, SIGNAL(sessionChanged(unicorn::Session*)), SLOT(onSessionChanged(unicorn::Session*)) );
    connect( aApp, SIGNAL(gotUserInfo(lastfm::User)), SLOT(onGotUserInfo(lastfm::User)) );

    connect( &ScrobbleService::instance(), SIGNAL(scrobblesCached(QList<lastfm::Track>)), SLOT(onScrobblesCached(QList<lastfm::Track>)));

    onSessionChanged( aApp->currentSession() );
}