当前位置: 首页>>代码示例>>C++>>正文


C++ PlayableItem类代码示例

本文整理汇总了C++中PlayableItem的典型用法代码示例。如果您正苦于以下问题:C++ PlayableItem类的具体用法?C++ PlayableItem怎么用?C++ PlayableItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PlayableItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: indexAt

void
TreeView::updateHoverIndex( const QPoint& pos )
{
    QModelIndex idx = indexAt( pos );

    if ( idx != m_hoveredIndex )
    {
        m_hoveredIndex = idx;
        repaint();
    }

    if ( !m_model || m_proxyModel->style() != PlayableProxyModel::Collection )
        return;

    PlayableItem* item = proxyModel()->itemFromIndex( proxyModel()->mapToSource( idx ) );
    if ( idx.column() == 0 && !item->query().isNull() )
    {
        if ( pos.x() > header()->sectionViewportPosition( idx.column() ) + header()->sectionSize( idx.column() ) - 16 &&
             pos.x() < header()->sectionViewportPosition( idx.column() ) + header()->sectionSize( idx.column() ) )
        {
            setCursor( Qt::PointingHandCursor );
            return;
        }
    }

    if ( cursor().shape() != Qt::ArrowCursor )
        setCursor( Qt::ArrowCursor );
}
开发者ID:mokerjoke,项目名称:tomahawk,代码行数:28,代码来源:TreeView.cpp

示例2: if

QWidget*
PlaylistItemDelegate::createEditor( QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index ) const
{
    PlayableItem* item = m_model->itemFromIndex( m_model->mapToSource( index ) );
    Q_ASSERT( item );

    if ( index.column() == PlayableModel::Download && item->result() &&
         !DownloadManager::instance()->localFileForDownload( item->result()->downloadFormats().first().url.toString() ).isEmpty() )
    {
        QDesktopServices::openUrl( QUrl::fromLocalFile( QFileInfo( DownloadManager::instance()->localFileForDownload( item->result()->downloadFormats().first().url.toString() ) ).absolutePath() ) );
    }
    else if ( index.column() == PlayableModel::Download && item->result() && item->result()->downloadJob() && item->result()->downloadJob()->state() == DownloadJob::Finished )
    {
        QDesktopServices::openUrl( QUrl::fromLocalFile( QFileInfo( item->result()->downloadJob()->localFile() ).absolutePath() ) );
    }
    else if ( index.column() == PlayableModel::Download && item->result() &&
              !item->result()->downloadFormats().isEmpty() && !item->result()->downloadJob() )
    {
        QStringList formats;
        foreach ( const DownloadFormat& format, item->result()->downloadFormats() )
        {
            formats << tr( "Download %1" ).arg( format.extension );
        }

        DropDownButton* editor = new DropDownButton( parent );
        editor->addItems( formats );

        NewClosure( editor, SIGNAL( clicked() ),
                    const_cast<PlaylistItemDelegate*>(this), SLOT( addDownloadJob( const QModelIndex&, QWidget* ) ), index, (QWidget*)editor );

        NewClosure( editor, SIGNAL( activated( int ) ),
                    const_cast<PlaylistItemDelegate*>(this), SLOT( addDownloadJob( const QModelIndex&, QWidget* ) ), index, (QWidget*)editor );
        return editor;
    }
开发者ID:dophinlife,项目名称:tomahawk,代码行数:34,代码来源:PlaylistItemDelegate.cpp

示例3: QModelIndex

void
DynamicWidget::steeringChanged()
{
    // When steering changes, toss all the tracks that are upcoming, and re-fetch.
    // We have to find the currently playing item
    QModelIndex playing;
    for ( int i = 0; i < m_view->proxyModel()->rowCount( QModelIndex() ); ++i )
    {
        const QModelIndex  cur = m_view->proxyModel()->index( i, 0, QModelIndex() );
        PlayableItem* item = m_view->proxyModel()->itemFromIndex( m_view->proxyModel()->mapToSource( cur ) );
        if ( item && item->isPlaying() )
        {
            playing = cur;
            break;
        }
    }
    if ( !playing.isValid() )
        return;

    const int upcoming = m_view->proxyModel()->rowCount( QModelIndex() ) - 1 - playing.row();
    tDebug() << "Removing tracks after current in station, found" << upcoming;

    QModelIndexList toRemove;
    for ( int i = playing.row() + 1; i < m_view->proxyModel()->rowCount( QModelIndex() ); i++ )
    {
        toRemove << m_view->proxyModel()->index( i, 0, QModelIndex() );
    }

    m_view->proxyModel()->removeIndexes( toRemove );

    m_playlist->generator()->fetchNext();
}
开发者ID:AndyCoder,项目名称:tomahawk,代码行数:32,代码来源:DynamicWidget.cpp

示例4: connect

void
TreeProxyModel::onRowsInserted( const QModelIndex& parent, int /* start */, int /* end */ )
{
    if ( m_filter.isEmpty() )
        return;
    if ( sender() != m_model )
        return;

    PlayableItem* pi = m_model->itemFromIndex( m_model->index( parent.row(), 0, parent.parent() ) );
    if ( pi->artist().isNull() )
        return;

    Tomahawk::AlbumsRequest* cmd = 0;
    if ( !m_model->collection().isNull() )
        cmd = m_model->collection()->requestAlbums( pi->artist() );
    else
        cmd = new Tomahawk::DatabaseCommand_AllAlbums( Tomahawk::collection_ptr(), pi->artist() );

    cmd->setFilter( m_filter );

    connect( dynamic_cast< QObject* >( cmd ), SIGNAL( albums( QList<Tomahawk::album_ptr> ) ),
             SLOT( onFilterAlbums( QList<Tomahawk::album_ptr> ) ) );

    cmd->enqueue();
}
开发者ID:JessicaWhite17,项目名称:tomahawk,代码行数:25,代码来源:TreeProxyModel.cpp

示例5:

void
GridView::currentChanged( const QModelIndex& current, const QModelIndex& previous )
{
    QListView::currentChanged( current, previous );

    PlayableItem* item = m_model->itemFromIndex( m_proxyModel->mapToSource( current ) );
    if ( item )
    {
        if ( !item->album().isNull() )
            ViewManager::instance()->context()->setAlbum( item->album() );
    }
}
开发者ID:AltarBeastiful,项目名称:tomahawk,代码行数:12,代码来源:GridView.cpp

示例6: result_ptr

Tomahawk::result_ptr
PlayableProxyModelPlaylistInterface::resultAt( qint64 index ) const
{
    if ( m_proxyModel.isNull() )
        return result_ptr();

    PlayableItem* item = reinterpret_cast<PlayableItem*>( (void*)index );
    if ( item && item->result() )
        return item->result();

    return result_ptr();
}
开发者ID:AndyCoder,项目名称:tomahawk,代码行数:12,代码来源:PlayableProxyModelPlaylistInterface.cpp

示例7: result_ptr

Tomahawk::result_ptr
PlayableProxyModelPlaylistInterface::currentItem() const
{
    if ( m_proxyModel.isNull() )
        return Tomahawk::result_ptr();

    PlayableProxyModel* proxyModel = m_proxyModel.data();

    PlayableItem* item = proxyModel->itemFromIndex( proxyModel->mapToSource( proxyModel->currentIndex() ) );
    if ( item && !item->query().isNull() && item->query()->playable() )
        return item->query()->results().at( 0 );
    return Tomahawk::result_ptr();
}
开发者ID:creichert,项目名称:tomahawk,代码行数:13,代码来源:PlayableProxyModelPlaylistInterface.cpp

示例8: QModelIndex

void
CollectionViewPage::onDownloadAll()
{
    for ( int i = 0; i < m_flatModel->rowCount( QModelIndex() ); i++ )
    {
        PlayableItem* item = m_flatModel->itemFromIndex( m_flatModel->index( i, 0, QModelIndex() ) );
        if ( !item )
            continue;

        if ( !item->result()->downloadFormats().isEmpty() )
            DownloadManager::instance()->addJob( item->result()->toDownloadJob( item->result()->downloadFormats().first() ) );
    }
}
开发者ID:pmpontes,项目名称:tomahawk,代码行数:13,代码来源:CollectionViewPage.cpp

示例9: Q_D

void
PlaylistModel::insertEntries( const QList< Tomahawk::plentry_ptr >& entries, int row, const QModelIndex& parent, const QList< Tomahawk::PlaybackLog >& logs )
{
    Q_D( PlaylistModel );
    if ( !entries.count() )
    {
        emit itemCountChanged( rowCount( QModelIndex() ) );
        finishLoading();
        return;
    }

    int c = row;
    QPair< int, int > crows;
    crows.first = c;
    crows.second = c + entries.count() - 1;

    if ( !d->isLoading )
    {
        d->savedInsertPos = row;
        d->savedInsertTracks = entries;
    }

    emit beginInsertRows( parent, crows.first, crows.second );

    QList< Tomahawk::query_ptr > queries;
    int i = 0;
    PlayableItem* plitem;
    foreach( const plentry_ptr& entry, entries )
    {
        PlayableItem* pItem = itemFromIndex( parent );
        plitem = new PlayableItem( entry, pItem, row + i );
        plitem->index = createIndex( row + i, 0, plitem );

        if ( logs.count() > i )
            plitem->setPlaybackLog( logs.at( i ) );

        i++;

        if ( entry->query()->id() == currentItemUuid() )
            setCurrentIndex( plitem->index );

        if ( !entry->query()->resolvingFinished() && !entry->query()->playable() )
        {
            queries << entry->query();
            d->waitingForResolved.append( entry->query().data() );
            connect( entry->query().data(), SIGNAL( playableStateChanged( bool ) ),
                     SLOT( onQueryBecamePlayable( bool ) ),
                     Qt::UniqueConnection );
            connect( entry->query().data(), SIGNAL( resolvingFinished( bool ) ),
                     SLOT( trackResolved( bool ) ) );
        }
开发者ID:hatchetindustries,项目名称:tomahawk,代码行数:51,代码来源:PlaylistModel.cpp

示例10:

void
TrackView::currentChanged( const QModelIndex& current, const QModelIndex& previous )
{
    QTreeView::currentChanged( current, previous );

    if ( !m_updateContextView )
        return;

    PlayableItem* item = m_model->itemFromIndex( m_proxyModel->mapToSource( current ) );
    if ( item )
    {
        ViewManager::instance()->context()->setQuery( item->query() );
    }
}
开发者ID:Erreur32,项目名称:tomahawk,代码行数:14,代码来源:TrackView.cpp

示例11: NewClosure

void
TrackView::startAutoPlay( const QModelIndex& index )
{
    if ( tryToPlayItem( index ) )
        return;

    // item isn't playable but still resolving
    PlayableItem* item = m_model->itemFromIndex( m_proxyModel->mapToSource( index ) );
    if ( item && !item->query().isNull() && !item->query()->resolvingFinished() )
    {
        m_autoPlaying = item->query(); // So we can kill it if user starts autoplaying this playlist again
        NewClosure( item->query().data(), SIGNAL( resolvingFinished( bool ) ), this, SLOT( autoPlayResolveFinished( Tomahawk::query_ptr, int ) ),
                    item->query(), index.row() );
        return;
    }
开发者ID:barovski,项目名称:tomahawk,代码行数:15,代码来源:TrackView.cpp

示例12: querySelected

void
TrackView::currentChanged( const QModelIndex& current, const QModelIndex& previous )
{
    QTreeView::currentChanged( current, previous );

    PlayableItem* item = m_model->itemFromIndex( m_proxyModel->mapToSource( current ) );
    if ( item && item->query() )
    {
        emit querySelected( item->query() );
    }
    else
    {
        emit querySelected( query_ptr() );
    }
}
开发者ID:RahulKondi,项目名称:tomahawk,代码行数:15,代码来源:TrackView.cpp

示例13: index

void
QueueProxyModel::onPlaybackStarted( const Tomahawk::result_ptr& result )
{
    for ( int i = 0; i < rowCount(); i++ )
    {
        QModelIndex idx = index( i, 0 );
        PlayableItem* item = itemFromIndex( mapToSource( idx ) );
        if ( item && item->query() && ( item->query()->results().contains( result ) ||
                                        item->query()->track()->equals( result->track() ) ) )
        {
            removeIndex( idx );
            if ( !rowCount() )
                ViewManager::instance()->hideQueue();
        }
    }
}
开发者ID:AltarBeastiful,项目名称:tomahawk,代码行数:16,代码来源:QueueProxyModel.cpp

示例14: clearButtons

void
GridItemDelegate::onPlayClicked( const QPersistentModelIndex& index )
{
    QPoint pos = m_playButton[ index ]->pos();
    clearButtons();

    AnimatedSpinner* spinner = new AnimatedSpinner( m_view );
    spinner->setAutoCenter( false );
    spinner->fadeIn();
    spinner->move( pos );
    spinner->setFocusPolicy( Qt::NoFocus );
    spinner->installEventFilter( this );

    m_spinner[ index ] = spinner;

    PlayableItem* item = m_model->sourceModel()->itemFromIndex( m_model->mapToSource( index ) );

    NewClosure(  AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ),
                const_cast<GridItemDelegate*>(this), SLOT( onPlaybackStarted( QPersistentModelIndex ) ), QPersistentModelIndex( index ) );

    if ( item )
    {
        if ( !item->query().isNull() )
            AudioEngine::instance()->playItem( m_model->playlistInterface(), item->query() );
        else if ( !item->album().isNull() )
            AudioEngine::instance()->playItem( item->album() );
        else if ( !item->artist().isNull() )
            AudioEngine::instance()->playItem( item->artist() );
    }
}
开发者ID:ChrisOHu,项目名称:tomahawk,代码行数:30,代码来源:GridItemDelegate.cpp

示例15:

QList< Tomahawk::query_ptr >
PlayableProxyModelPlaylistInterface::tracks()
{
    if ( m_proxyModel.isNull() )
        return QList< Tomahawk::query_ptr >();

    PlayableProxyModel* proxyModel = m_proxyModel.data();
    QList<Tomahawk::query_ptr> queries;

    for ( int i = 0; i < proxyModel->rowCount( QModelIndex() ); i++ )
    {
        PlayableItem* item = proxyModel->itemFromIndex( proxyModel->mapToSource( proxyModel->index( i, 0 ) ) );
        if ( item )
            queries << item->query();
    }

    return queries;
}
开发者ID:creichert,项目名称:tomahawk,代码行数:18,代码来源:PlayableProxyModelPlaylistInterface.cpp


注:本文中的PlayableItem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。