コード例 #1
0
ファイル: trackmodelitem.cpp プロジェクト: Pritoj/tomahawk
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
ファイル: DynamicModel.cpp プロジェクト: ChrisOHu/tomahawk
void
DynamicModel::newTrackGenerated( const Tomahawk::query_ptr& query )
{
    if ( m_onDemandRunning )
    {
        bool isDuplicate = false;
        for ( int i = 0; i < m_deduper.size(); i++ )
        {
            if ( m_deduper[ i ].first == query->track() && m_deduper[ i ].second == query->artist() )
                isDuplicate = true;
        }
        if ( isDuplicate )
        {
            m_playlist->generator()->fetchNext();

            return;
        }
        else
        {
            m_deduper.append( QPair< QString, QString >( query->track(), query->artist() ) );
        }

        connect( query.data(), SIGNAL( resolvingFinished( bool ) ), this, SLOT( trackResolveFinished( bool ) ) );

        m_waitingFor << query.data();
        appendQuery( query );
    }
}
コード例 #3
0
ファイル: TreeModelItem.cpp プロジェクト: seezer/tomahawk
TreeModelItem::TreeModelItem( const Tomahawk::query_ptr& query, TreeModelItem* parent, int row )
    : QObject( parent )
    , m_query( query )
{
    this->parent = parent;
    fetchingMore = false;
    m_isPlaying = false;

    if ( parent )
    {
        if ( row < 0 )
        {
            parent->children.append( this );
            row = parent->children.count() - 1;
        }
        else
        {
            parent->children.insert( row, this );
        }

        this->model = parent->model;
    }

    toberemoved = false;
    onResultsChanged();

    connect( query.data(), SIGNAL( resultsAdded( QList<Tomahawk::result_ptr> ) ),
                             SLOT( onResultsChanged() ) );

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

    connect( query.data(), SIGNAL( resultsChanged() ),
                             SLOT( onResultsChanged() ) );
}
コード例 #4
0
ファイル: DynamicModel.cpp プロジェクト: euroelessar/tomahawk
void
DynamicModel::newTrackGenerated( const Tomahawk::query_ptr& query )
{
    if( m_onDemandRunning ) {
        connect( query.data(), SIGNAL( resolvingFinished( bool ) ), this, SLOT( trackResolveFinished( bool ) ) );

        m_waitingFor << query.data();
        append( query );
    }
}
コード例 #5
0
ファイル: AudioEngine.cpp プロジェクト: nowrep/tomahawk
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 );
    }
}
コード例 #6
0
void
PlaylistEntry::setQuery( const Tomahawk::query_ptr& q )
{
    Q_D( PlaylistEntry );
    d->query = q;

    connect( q.data(), SIGNAL( resolvingFinished( bool ) ), SLOT( onQueryResolved( bool ) ) );
}
コード例 #7
0
ファイル: PlayableItem.cpp プロジェクト: AndyCoder/tomahawk
PlayableItem::PlayableItem( const Tomahawk::query_ptr& query, PlayableItem* parent, int row )
    : QObject( parent )
    , m_query( query )
{
    init( parent, row );

    connect( query->track().data(), SIGNAL( socialActionsLoaded() ),
                                    SIGNAL( dataChanged() ) );

    connect( query->track().data(), SIGNAL( updated() ),
                                    SIGNAL( dataChanged() ) );

    connect( query.data(), SIGNAL( resultsChanged() ),
                             SLOT( onResultsChanged() ) );
}
コード例 #8
0
ファイル: sourcetreeview.cpp プロジェクト: hatstand/tomahawk
void
SourceTreeView::dropEvent( QDropEvent* event )
{
    bool accept = false;
    const QPoint pos = event->pos();
    const QModelIndex index = indexAt( pos );

    if ( event->mimeData()->hasFormat( "application/tomahawk.query.list" ) )
    {
        const QPoint pos = event->pos();
        const QModelIndex index = indexAt( pos );

        if ( index.isValid() )
        {
            if ( SourcesModel::indexType( index ) == SourcesModel::PlaylistSource )
            {
                playlist_ptr playlist = SourcesModel::indexToPlaylist( index );
                if ( !playlist.isNull() && playlist->author()->isLocal() )
                {
                    accept = true;
                    QByteArray itemData = event->mimeData()->data( "application/tomahawk.query.list" );
                    QDataStream stream( &itemData, QIODevice::ReadOnly );
                    QList<Tomahawk::query_ptr> queries;

                    while ( !stream.atEnd() )
                    {
                        qlonglong qptr;
                        stream >> qptr;

                        Tomahawk::query_ptr* query = reinterpret_cast<Tomahawk::query_ptr*>(qptr);
                        if ( query && !query->isNull() )
                        {
                            qDebug() << "Dropped query item:" << query->data()->artist() << "-" << query->data()->track();
                            queries << *query;
                        }
                    }

                    qDebug() << "on playlist:" << playlist->title() << playlist->guid();

                    SourceTreeItem* treeItem = SourcesModel::indexToTreeItem( index );
                    if ( treeItem )
                    {
                        QString rev = treeItem->currentlyLoadedPlaylistRevision( playlist->guid() );
                        playlist->addEntries( queries, rev );
                    }
                }
            }
        }
コード例 #9
0
ファイル: querylabel.cpp プロジェクト: LittleForker/tomahawk
void
QueryLabel::setQuery( const Tomahawk::query_ptr& query )
{
    if ( query.isNull() )
        return;

    setContentsMargins( BOXMARGIN * 2, BOXMARGIN / 2, BOXMARGIN * 2, BOXMARGIN / 2 );

    if ( m_query.isNull() || m_query.data() != query.data() )
    {
        m_query = query;
        m_result.clear();
        updateLabel();

        emit textChanged( text() );
        emit queryChanged( m_query );
    }
}