예제 #1
0
void
TrackModelItem::setupItem( const Tomahawk::query_ptr& query, TrackModelItem* parent, int row )
{
    this->parent = parent;
    if ( parent )
    {
        if ( row < 0 )
        {
            parent->children.append( this );
            row = parent->children.count() - 1;
        }
        else
        {
            parent->children.insert( row, this );
        }

        this->model = parent->model;
    }

    m_isPlaying = false;
    toberemoved = false;
    m_query = query;
    if ( !query->numResults() )
    {
        connect( query.data(), SIGNAL( resultsAdded( QList<Tomahawk::result_ptr> ) ),
                               SIGNAL( dataChanged() ) );

        connect( query.data(), SIGNAL( resultsRemoved( Tomahawk::result_ptr ) ),
                               SIGNAL( dataChanged() ) );

        connect( query.data(), SIGNAL( resultsChanged() ),
                               SIGNAL( dataChanged() ) );
    }
}
예제 #2
0
void
AudioEngine::playItem( Tomahawk::playlistinterface_ptr playlist, const Tomahawk::query_ptr& query )
{
    if ( query->resolvingFinished() )
    {
        if ( query->numResults() && query->results().first()->isOnline() )
        {
            playItem( playlist, query->results().first() );
            return;
        }

        JobStatusView::instance()->model()->addJob(
            new ErrorStatusMessage( tr( "Sorry, Tomahawk couldn't find the track '%1' by %2" ).arg( query->track() ).arg( query->artist() ), 15 ) );

        if ( isStopped() )
            emit stopped(); // we do this so the original caller knows we couldn't find this track
    }
    else
    {
        Pipeline::instance()->resolve( query );

        NewClosure( query.data(), SIGNAL( resolvingFinished( bool ) ),
                    const_cast<AudioEngine*>(this), SLOT( playItem( Tomahawk::playlistinterface_ptr, Tomahawk::query_ptr ) ), playlist, query );
    }
}
예제 #3
0
void
ColumnViewPreviewWidget::setQuery( const Tomahawk::query_ptr& query )
{
    if ( !m_query.isNull() )
    {
        disconnect( m_query->track().data(), SIGNAL( updated() ), this, SLOT( onCoverUpdated() ) );
    }

    m_query = query;
    connect( m_query->track().data(), SIGNAL( updated() ), SLOT( onCoverUpdated() ) );

    onCoverUpdated();
    m_cover->setQuery( query );

    setVisible( true );

    m_trackLabel->setText( query->track()->track() );
    m_artistLabel->setArtist( query->track()->artistPtr() );
    m_artistLabel->setMinimumWidth( qMin( m_artistLabel->fontMetrics().width( query->track()->artist() ) +
                                          m_artistLabel->contentsMargins().left() +
                                          m_artistLabel->contentsMargins().right() +
                                          2 * m_artistLabel->lineWidth(),
                                          width() ) );
    m_artistLabel->setElideMode( Qt::ElideRight );
    m_composerValue->setText( query->track()->composer() );

    m_composerValue->setVisible( !query->track()->composerPtr().isNull() );
    m_composerLabel->setVisible( !query->track()->composerPtr().isNull() );

    if ( query->numResults() )
    {
        m_yearValue->setText( QString::number( query->track()->year() ) );
        m_bitrateValue->setText( tr( "%1 kbps" ).arg( query->results().first()->bitrate() ) );
        m_durationValue->setText( TomahawkUtils::timeToString( query->track()->duration() ) );
        m_ageValue->setText( TomahawkUtils::ageToString( QDateTime::fromTime_t( query->results().first()->modificationTime() ) ) );

        m_yearValue->setVisible( query->track()->year() > 0 );
        m_yearLabel->setVisible( query->track()->year() > 0 );
        m_bitrateLabel->setVisible( query->results().first()->bitrate() > 0 );
        m_bitrateValue->setVisible( query->results().first()->bitrate() > 0 );
        m_durationLabel->setVisible( query->track()->duration() > 0 );
        m_durationValue->setVisible( query->track()->duration() > 0 );
        m_ageLabel->setVisible( query->results().first()->modificationTime() > 0 );
        m_ageValue->setVisible( query->results().first()->modificationTime() > 0 );
    }
    else
    {
        m_yearLabel->setVisible( false );
        m_yearValue->setVisible( false );
        m_bitrateLabel->setVisible( false );
        m_bitrateValue->setVisible( false );
        m_durationLabel->setVisible( false );
        m_durationValue->setVisible( false );
        m_ageLabel->setVisible( false );
        m_ageValue->setVisible( false );
    }

    setMinimumHeight( sizeHint().height() );
}
예제 #4
0
void
MetadataEditor::loadQuery( const Tomahawk::query_ptr& query )
{
    if ( query.isNull() )
        return;

    if ( query->numResults() )
    {
        loadResult( query->results().first() );
        return;
    }

    m_result = Tomahawk::result_ptr();
    m_query = query;
    setEditable( false );

    setTitle( query->track()->track() );
    setArtist( query->track()->artist() );
    setAlbum( query->track()->album() );
    setAlbumPos( query->track()->albumpos() );
    setDuration( query->track()->duration() );
    setYear( 0 );
    setBitrate( 0 );

    setFileName( QString() );
    setFileSize( 0 );

    setWindowTitle( query->track()->track() );

    if ( m_interface )
    {
        m_index = m_interface->indexOfQuery( query );

        if ( m_index >= 0 )
            enablePushButtons();
    }
}