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 ) ) ); }
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() ) ); }
DatabaseCollection::DatabaseCollection( const source_ptr& src, QObject* parent ) : Collection( src, QString( "dbcollection:%1" ).arg( src->nodeId() ), parent ) { }
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" ) ); }