HistoryWidget::HistoryWidget( const source_ptr& source, QWidget* parent ) : FlexibleView( parent, m_header = new QWidget() ) { m_header->setMaximumHeight( 160 ); /* QCalendarWidget* m_calendarFrom = new QCalendarWidget(); QCalendarWidget* m_calendarTo = new QCalendarWidget(); m_calendarFrom->setGridVisible( false ); m_calendarTo->setGridVisible( false );*/ m_calendarFrom = new QDateEdit( QDate::currentDate() ); m_calendarTo = new QDateEdit( QDate::currentDate() ); m_calendarFrom->setDisplayFormat( "yyyy MMMM dd" ); m_calendarTo->setDisplayFormat( "yyyy MMMM dd" ); // setting an empty style-sheet prevents the QDateEdits from adopting their parent's QPalette QString calSheet = QString( "QDateEdit { }" ).arg( TomahawkStyle::PAGE_BACKGROUND.name() ); m_calendarFrom->setStyleSheet( calSheet ); m_calendarTo->setStyleSheet( calSheet ); QPalette pal = m_header->palette(); pal.setColor( QPalette::Foreground, Qt::white ); pal.setColor( QPalette::Text, Qt::white ); pal.setBrush( backgroundRole(), TomahawkStyle::PAGE_BACKGROUND ); m_header->setPalette( pal ); m_header->setAutoFillBackground( true ); QHBoxLayout* layout = new QHBoxLayout( m_header ); layout->addSpacerItem( new QSpacerItem( 1, 0, QSizePolicy::MinimumExpanding, QSizePolicy::Minimum ) ); layout->addWidget( new QLabel( tr( "From:" ) ) ); layout->addWidget( m_calendarFrom ); layout->addSpacerItem( new QSpacerItem( 16, 0, QSizePolicy::Fixed, QSizePolicy::Minimum ) ); layout->addWidget( new QLabel( tr( "To:" ) ) ); layout->addWidget( m_calendarTo ); layout->addSpacerItem( new QSpacerItem( 1, 0, QSizePolicy::MinimumExpanding, QSizePolicy::Minimum ) ); m_header->setLayout( layout ); setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::RecentlyPlayed ) ); m_model = new RecentlyPlayedModel( this ); m_model->setTitle( tr( "Recently Played Tracks" ) ); if ( source->isLocal() ) m_model->setDescription( tr( "Your recently played tracks" ) ); else m_model->setDescription( tr( "%1's recently played tracks" ).arg( source->friendlyName() ) ); PlaylistLargeItemDelegate* del = new PlaylistLargeItemDelegate( PlaylistLargeItemDelegate::RecentlyPlayed, trackView(), trackView()->proxyModel() ); trackView()->setItemDelegate( del ); setPlayableModel( m_model ); setEmptyTip( tr( "Sorry, we could not find any recent plays!" ) ); m_model->setSource( source ); setGuid( QString( "recentplays/%1" ).arg( source->nodeId() ) ); /* connect( m_calendarFrom, SIGNAL( clicked( QDate ) ), SLOT( onDateClicked( QDate ) ) ); connect( m_calendarTo, SIGNAL( clicked( QDate ) ), SLOT( onDateClicked( QDate ) ) );*/ connect( m_calendarFrom, SIGNAL( dateChanged( QDate ) ), SLOT( onDateClicked( QDate ) ) ); connect( m_calendarTo, SIGNAL( dateChanged( QDate ) ), SLOT( onDateClicked( QDate ) ) ); }
void LatchManager::latchRequest( const source_ptr& source ) { qDebug() << Q_FUNC_INFO; if ( isLatched( source ) ) return; m_state = Latching; m_waitingForLatch = source; AudioEngine::instance()->playItem( source->playlistInterface(), source->playlistInterface()->nextResult() ); }
Collection::Collection( const source_ptr& source, const QString& name, QObject* parent ) : QObject( parent ) , m_name( name ) , m_lastmodified( 0 ) , m_changed( false ) , m_source( source ) { qDebug() << Q_FUNC_INFO << name << source->friendlyName(); connect( source.data(), SIGNAL( synced() ), SLOT( onSynced() ) ); }
void Source::reportSocialAttributesChanged( DatabaseCommand_SocialAction* action ) { emit socialAttributesChanged(); if ( action->action() == "latchOn" ) { const source_ptr to = SourceList::instance()->get( action->comment() ); if ( !to.isNull() ) emit latchedOn( to ); } else if ( action->action() == "latchOff" ) { const source_ptr from = SourceList::instance()->get( action->comment() ); if ( !from.isNull() ) emit latchedOff( from ); } }
Collection::Collection( const source_ptr& source, const QString& name, QObject* parent ) : QObject( parent ) , m_name( name ) , m_lastmodified( 0 ) , m_isLoaded( false ) , m_source( source ) { qDebug() << Q_FUNC_INFO << name << source->friendlyName(); }
void SourceItem::latchedOff( const source_ptr& from, const source_ptr& to ) { if ( from->isLocal() && ( m_source == to || m_source == from ) ) { m_latchedOn = false; disconnect( m_latchedOnTo->playlistInterface().data(), SIGNAL( latchModeChanged( Tomahawk::PlaylistModes::LatchMode ) ) ); m_latchedOnTo.clear(); emit updated(); } }
bool SourcesModel::appendItem( const source_ptr& source ) { SourceTreeItem* item = new SourceTreeItem( source, this ); connect( item, SIGNAL( clicked( QModelIndex ) ), this, SIGNAL( clicked( QModelIndex ) ) ); // qDebug() << "Appending source item:" << item->source()->username(); invisibleRootItem()->appendRow( item->columns() ); if ( !source.isNull() ) { connect( source.data(), SIGNAL( offline() ), SLOT( onSourceChanged() ) ); connect( source.data(), SIGNAL( online() ), SLOT( onSourceChanged() ) ); connect( source.data(), SIGNAL( stats( QVariantMap ) ), SLOT( onSourceChanged() ) ); connect( source.data(), SIGNAL( playbackStarted( Tomahawk::query_ptr ) ), SLOT( onSourceChanged() ) ); connect( source.data(), SIGNAL( stateChanged() ), SLOT( onSourceChanged() ) ); } return true; // FIXME }
void SourceItem::latchedOn( const source_ptr& from, const source_ptr& to ) { if ( from->isLocal() && ( m_source == to || m_source == from ) ) { m_latchedOn = true; m_latchedOnTo = to; connect( m_latchedOnTo->playlistInterface().data(), SIGNAL( latchModeChanged( Tomahawk::PlaylistInterface::LatchMode ) ), SLOT( latchModeChanged( Tomahawk::PlaylistInterface::LatchMode ) ) ); emit updated(); } }
unsigned int Artist::playbackCount( const source_ptr& source ) { unsigned int count = 0; foreach ( const PlaybackLog& log, m_playbackHistory ) { if ( source.isNull() || log.source == source ) count++; } return count; }
HistoryWidget::HistoryWidget( const source_ptr& source, QWidget* parent ) : FlexibleView( parent ) { setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::RecentlyPlayed ) ); m_model = new RecentlyPlayedModel( this ); m_model->setTitle( tr( "Recently Played Tracks" ) ); if ( source->isLocal() ) m_model->setDescription( tr( "Your recently played tracks" ) ); else m_model->setDescription( tr( "%1's recently played tracks" ).arg( source->friendlyName() ) ); trackView()->setIndentation( 0 ); trackView()->setUniformRowHeights( false ); setPlayableModel( m_model ); setEmptyTip( tr( "Sorry, we could not find any recent plays!" ) ); m_model->setSource( source ); setGuid( QString( "recentplays/%1" ).arg( source->nodeId() ) ); }
unsigned int TrackData::playbackCount( const source_ptr& source ) { QMutexLocker locker( &s_memberMutex ); unsigned int count = 0; foreach ( const PlaybackLog& log, m_playbackHistory ) { if ( source.isNull() || log.source == source ) count++; } return count; }
RecentlyAddedModel::RecentlyAddedModel( const source_ptr& source, QObject* parent ) : TrackModel( parent ) , m_source( source ) , m_limit( LATEST_TRACK_ITEMS ) { if ( source.isNull() ) { connect( SourceList::instance(), SIGNAL( ready() ), SLOT( onSourcesReady() ) ); connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( onSourceAdded( Tomahawk::source_ptr ) ) ); } else { onSourceAdded( source ); loadHistory(); } }
DBSyncConnection::DBSyncConnection( Servent* s, source_ptr src ) : Connection( s ) , m_source( src ) , m_state( UNKNOWN ) { qDebug() << Q_FUNC_INFO << src->id() << thread(); connect( this, SIGNAL( stateChanged( DBSyncConnection::State, DBSyncConnection::State, QString ) ), m_source.data(), SLOT( onStateChanged( DBSyncConnection::State, DBSyncConnection::State, QString ) ) ); m_timer.setInterval( IDLE_TIMEOUT ); connect( &m_timer, SIGNAL( timeout() ), SLOT( idleTimeout() ) ); this->setMsgProcessorModeIn( MsgProcessor::PARSE_JSON | MsgProcessor::UNCOMPRESS_ALL ); // msgs are stored compressed in the db, so not typically needed here, but doesnt hurt: this->setMsgProcessorModeOut( MsgProcessor::COMPRESS_IF_LARGE ); }
DBSyncConnection::DBSyncConnection( Servent* s, const source_ptr& src ) : Connection( s ) , m_source( src ) , m_state( UNKNOWN ) { qDebug() << Q_FUNC_INFO << src->id() << thread(); connect( this, SIGNAL( stateChanged( DBSyncConnection::State, DBSyncConnection::State, QString ) ), m_source.data(), SLOT( onStateChanged( DBSyncConnection::State, DBSyncConnection::State, QString ) ) ); connect( m_source.data(), SIGNAL( commandsFinished() ), this, SLOT( lastOpApplied() ) ); this->setMsgProcessorModeIn( MsgProcessor::PARSE_JSON | MsgProcessor::UNCOMPRESS_ALL ); // msgs are stored compressed in the db, so not typically needed here, but doesnt hurt: this->setMsgProcessorModeOut( MsgProcessor::COMPRESS_IF_LARGE ); }
CustomPlaylistView::CustomPlaylistView( CustomPlaylistView::PlaylistType type, const source_ptr& s, QWidget* parent ) : PlaylistView ( parent ) , m_type( type ) , m_source( s ) , m_model( new PlaylistModel( this ) ) { // Generate the tracks, add them to the playlist m_model->setStyle( PlayableModel::Large ); setPlaylistModel( m_model ); generateTracks(); if ( m_type == SourceLovedTracks ) connect( m_source.data(), SIGNAL( socialAttributesChanged( QString ) ), this, SLOT( socialAttributesChanged( QString ) ) ); else if ( m_type == TopLovedTracks ) { connect( SourceList::instance()->getLocal().data(), SIGNAL( socialAttributesChanged( QString ) ), this, SLOT( socialAttributesChanged( QString ) ) ); foreach ( const source_ptr& s, SourceList::instance()->sources( true ) ) connect( s.data(), SIGNAL( socialAttributesChanged( QString ) ), this, SLOT( socialAttributesChanged( QString ) ) ); connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), this, SLOT( sourceAdded( Tomahawk::source_ptr ) ) ); }
CustomPlaylistView::CustomPlaylistView( CustomPlaylistView::PlaylistType type, const source_ptr& s, QWidget* parent ) : PlaylistView ( parent ) , m_type( type ) , m_source( s ) , m_model( new PlaylistModel( this ) ) { // Generate the tracks, add them to the playlist setFrameShape( QFrame::NoFrame ); setAttribute( Qt::WA_MacShowFocusRect, 0 ); setPlaylistModel( m_model ); generateTracks(); if ( m_type == SourceLovedTracks ) connect( m_source.data(), SIGNAL( socialAttributesChanged() ), this, SLOT( reload() ) ); else if ( m_type == AllLovedTracks ) { connect( SourceList::instance()->getLocal().data(), SIGNAL( socialAttributesChanged() ), this, SLOT( reload() ) ); foreach ( const source_ptr& s, SourceList::instance()->sources( true ) ) connect( s.data(), SIGNAL( socialAttributesChanged() ), this, SLOT( reload() ) ); connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), this, SLOT( sourceAdded( Tomahawk::source_ptr ) ) ); }
void LatchManager::playlistChanged( Tomahawk::playlistinterface_ptr ) { // If we were latched on and changed, send the listening along stop if ( m_latchedOnTo.isNull() ) { if ( m_waitingForLatch.isNull() ) return; // Neither latched on nor waiting to be latched on, no-op m_latchedOnTo = m_waitingForLatch; m_latchedInterface = m_waitingForLatch->playlistInterface(); m_waitingForLatch.clear(); m_state = Latched; DatabaseCommand_SocialAction* cmd = new DatabaseCommand_SocialAction(); cmd->setSource( SourceList::instance()->getLocal() ); cmd->setAction( "latchOn"); cmd->setComment( m_latchedOnTo->nodeId() ); cmd->setTimestamp( QDateTime::currentDateTime().toTime_t() ); Database::instance()->enqueue( Tomahawk::dbcmd_ptr( cmd ) ); QAction *latchOnAction = ActionCollection::instance()->getAction( "latchOn" ); latchOnAction->setText( tr( "&Catch Up" ) ); latchOnAction->setIcon( QIcon() ); // If not, then keep waiting return; } // We're current latched, and the user changed playlist, so stop SourcePlaylistInterface* origsourcepi = dynamic_cast< SourcePlaylistInterface* >( m_latchedInterface.data() ); Q_ASSERT( origsourcepi ); const source_ptr source = SourceList::instance()->get( origsourcepi->source()->id() ); DatabaseCommand_SocialAction* cmd = new DatabaseCommand_SocialAction(); cmd->setSource( SourceList::instance()->getLocal() ); cmd->setAction( "latchOff"); cmd->setComment( source->nodeId() ); cmd->setTimestamp( QDateTime::currentDateTime().toTime_t() ); Database::instance()->enqueue( Tomahawk::dbcmd_ptr( cmd ) ); if ( !m_waitingForLatch.isNull() && m_waitingForLatch != m_latchedOnTo ) { // We are asked to latch on immediately to another source m_latchedOnTo.clear(); m_latchedInterface.clear(); // call ourselves to hit the "create latch" condition playlistChanged( Tomahawk::playlistinterface_ptr() ); return; } m_latchedOnTo.clear(); m_waitingForLatch.clear(); m_latchedInterface.clear(); m_state = NotLatched; QAction *latchOnAction = ActionCollection::instance()->getAction( "latchOn" ); latchOnAction->setText( tr( "&Listen Along" ) ); latchOnAction->setIcon( QIcon( RESPATH "images/headphones-sidebar.png" ) ); }
DatabaseCollection::DatabaseCollection( const source_ptr& src, QObject* parent ) : Collection( src, QString( "dbcollection:%1" ).arg( src->nodeId() ), parent ) { }