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


C++ SourceTreeItem类代码示例

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


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

示例1: iconRect

void
SourceDelegate::paintDecorations( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
{
    SourcesModel::RowType type = static_cast< SourcesModel::RowType >( index.data( SourcesModel::SourceTreeItemTypeRole ).toInt() );
    SourceTreeItem* item = index.data( SourcesModel::SourceTreeItemRole ).value< SourceTreeItem* >();

    // Paint the speaker icon next to the currently-playing playlist
    const bool playable = ( type == SourcesModel::StaticPlaylist ||
        type == SourcesModel::AutomaticPlaylist ||
        type == SourcesModel::Station ||
        type == SourcesModel::TemporaryPage ||
        type == SourcesModel::LovedTracksPage ||
        type == SourcesModel::Collection ||
        type == SourcesModel::GenericPage );
    const bool playing = ( AudioEngine::instance()->isPlaying() || AudioEngine::instance()->isPaused() );

    if ( playable && playing && item->isBeingPlayed() )
    {
        const int iconW = option.rect.height() - m_margin / 4;
        const QRect iconRect( m_margin / 4, option.rect.y() + m_margin / 8, iconW, iconW );
        const QPixmap speaker = TomahawkUtils::defaultPixmap( TomahawkUtils::NowPlayingSpeakerDark, TomahawkUtils::Original, iconRect.size() );

        painter->drawPixmap( iconRect, speaker );
    }
}
开发者ID:AshotN,项目名称:tomahawk,代码行数:25,代码来源:SourceDelegate.cpp

示例2: rowCount

bool
SourcesModel::removeItem( const source_ptr& source )
{
//    qDebug() << "Removing source item from SourceTree:" << source->username();

    QModelIndex idx;
    int rows = rowCount();
    for ( int row = 0; row < rows; row++ )
    {
        QModelIndex idx = index( row, 0 );
        SourceTreeItem* item = indexToTreeItem( idx );
        if ( item )
        {
            if ( item->source() == source )
            {
                qDebug() << "Found removed source item:" << item->source()->userName();
                invisibleRootItem()->removeRow( row );

                onItemOffline( idx );

                delete item;
                return true;
            }
        }
    }

    return false;
}
开发者ID:tiegz,项目名称:tomahawk,代码行数:28,代码来源:sourcesmodel.cpp

示例3: qDebug

void
SourcesModel::onItemOffline( const QModelIndex& idx )
{
    qDebug() << Q_FUNC_INFO;

    SourceTreeItem* item = indexToTreeItem( idx );
    if ( item )
        item->onOffline();
}
开发者ID:tiegz,项目名称:tomahawk,代码行数:9,代码来源:sourcesmodel.cpp

示例4:

void
SourceTreeView::onItemActivated( const QModelIndex& index )
{
    if ( !index.isValid() || !index.flags().testFlag( Qt::ItemIsEnabled ) )
        return;

    SourceTreeItem* item = itemFromIndex< SourceTreeItem >( index );
    item->activate();
}
开发者ID:ubertaco,项目名称:tomahawk,代码行数:9,代码来源:sourcetreeview.cpp

示例5: sourceModel

bool
SourcesProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const
{
    if ( !m_filtered )
        return true;
    
    SourceTreeItem* sti = m_model->indexToTreeItem( sourceModel()->index( sourceRow, 0, sourceParent ) );
    if ( sti )
    {
        if ( sti->source().isNull() || sti->source()->isOnline() )
            return true;
    }

    return false;
}
开发者ID:LittleForker,项目名称:tomahawk,代码行数:15,代码来源:sourcesproxymodel.cpp

示例6: QModelIndex

QModelIndex
SourcesModel::parent( const QModelIndex& child ) const
{
    if( !child.isValid() )
    {
        return QModelIndex();
    }

    SourceTreeItem* node = itemFromIndex( child );
    SourceTreeItem* parent = node->parent();
    if( parent == m_rootItem )
        return QModelIndex();

    return createIndex( rowForItem( parent ), 0, parent );
}
开发者ID:ralepinski,项目名称:tomahawk,代码行数:15,代码来源:sourcesmodel.cpp

示例7: indexAt

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 );
                    }
                }
            }
        }
开发者ID:hatstand,项目名称:tomahawk,代码行数:48,代码来源:sourcetreeview.cpp

示例8: index

QModelIndex
SourcesModel::collectionToIndex( const Tomahawk::collection_ptr& collection )
{
    for ( int i = 0; i < rowCount(); i++ )
    {
        QModelIndex idx = index( i, 0 );
        SourcesModel::SourceType type = SourcesModel::indexType( idx );
        if ( type == SourcesModel::CollectionSource )
        {
            SourceTreeItem* sti = SourcesModel::indexToTreeItem( idx );
            if ( sti && !sti->source().isNull() && sti->source()->collection().data() == collection.data() )
                return idx;
        }
    }

    return QModelIndex();
}
开发者ID:tiegz,项目名称:tomahawk,代码行数:17,代码来源:sourcesmodel.cpp

示例9: if

bool
SourcesModel::dropMimeData( const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent )
{
    SourceTreeItem* item = 0;
//    qDebug() << "Got mime data dropped:" << row << column << parent << itemFromIndex( parent )->text();
    if( row == -1 && column == -1 )
        item = itemFromIndex( parent );
    else if( column == 0 )
        item = itemFromIndex( index( row, column, parent ) );
    else if( column == -1 ) // column is -1, that means the drop is happening "below" the indices. that means we actually want the one before it
        item = itemFromIndex( index( row - 1, 0, parent ) );

    Q_ASSERT( item );

//    qDebug() << "Dropping on:" << item->text();
    return item->dropMimeData( data, action );
}
开发者ID:ralepinski,项目名称:tomahawk,代码行数:17,代码来源:sourcesmodel.cpp

示例10: qDebug

void
SourceTreeView::onItemActivated( const QModelIndex& index )
{
    if ( !index.isValid() )
        return;

    SourcesModel::SourceType type = SourcesModel::indexType( index );
    if ( type == SourcesModel::CollectionSource )
    {
        SourceTreeItem* item = SourcesModel::indexToTreeItem( index );
        if ( item )
        {
            if ( item->source().isNull() )
            {
                PlaylistManager::instance()->showSuperCollection();
            }
            else
            {
                qDebug() << "SourceTreeItem toggled:" << item->source()->userName();

                PlaylistManager::instance()->show( item->source()->collection() );
            }
        }
    }
    else if ( type == SourcesModel::PlaylistSource )
    {
        playlist_ptr playlist = SourcesModel::indexToPlaylist( index );
        if ( !playlist.isNull() )
        {
            qDebug() << "Playlist activated:" << playlist->title();

            PlaylistManager::instance()->show( playlist );
        }
    }
    else if ( type == SourcesModel::DynamicPlaylistSource )
    {
        dynplaylist_ptr playlist = SourcesModel::indexToDynamicPlaylist( index );
        if ( !playlist.isNull() )
        {
            qDebug() << "Dynamic Playlist activated:" << playlist->title();

            PlaylistManager::instance()->show( playlist );
        }
    }
}
开发者ID:hatstand,项目名称:tomahawk,代码行数:45,代码来源:sourcetreeview.cpp

示例11: SourceTreeItem

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
}
开发者ID:tiegz,项目名称:tomahawk,代码行数:20,代码来源:sourcesmodel.cpp

示例12: sender

void
SourcesModel::onSourceChanged()
{
    Source* src = qobject_cast< Source* >( sender() );
    
    for ( int i = 0; i < rowCount(); i++ )
    {
        QModelIndex idx = index( i, 0 );

        if ( indexType( idx ) == CollectionSource )
        {
            SourceTreeItem* sti = indexToTreeItem( idx );
            if ( sti )
            {
                if ( sti->source().data() == src )
                {
                    emit dataChanged( idx, idx );
                }
            }
        }
    }
}
开发者ID:tiegz,项目名称:tomahawk,代码行数:22,代码来源:sourcesmodel.cpp

示例13: switch

bool
SourceDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index )
{
    QMouseEvent* mEvent = 0;
    switch ( event->type() )
    {
//        case QEvent::MouseTrackingChange:
        case QEvent::MouseButtonDblClick:
        case QEvent::MouseButtonPress:
        case QEvent::MouseButtonRelease:
        case QEvent::MouseMove:
            mEvent = static_cast< QMouseEvent* >( event );
        default:
            break;
    }

    bool hoveringTrack = false;
    if ( m_trackRects.contains( index ) && mEvent )
    {
        const QRect trackRect = m_trackRects[ index ];
        hoveringTrack = trackRect.contains( mEvent->pos() );

        if ( hoveringTrack )
        {
            if ( m_trackHovered != index )
            {
                m_trackHovered = index;
                QMetaObject::invokeMethod( m_parent, "update", Qt::QueuedConnection, Q_ARG( QModelIndex, index ) );
            }
        }
    }
    if ( !hoveringTrack )
    {
        if ( m_trackHovered.isValid() )
            QMetaObject::invokeMethod( m_parent, "update", Qt::QueuedConnection, Q_ARG( QModelIndex, m_trackHovered ) );

        m_trackHovered = QPersistentModelIndex();
    }

    bool lockRectContainsClick = false, headphonesRectContainsClick = false;
    if ( m_headphoneRects.contains( index ) && mEvent )
    {
        const QRect headphoneRect = m_headphoneRects[ index ];
        headphonesRectContainsClick = headphoneRect.contains( mEvent->pos() );
    }
    if ( m_lockRects.contains( index ) && mEvent )
    {
        const QRect lockRect = m_lockRects[ index ];
        lockRectContainsClick = lockRect.contains( mEvent->pos() );
    }

    if ( event->type() == QEvent::MouseMove )
    {
        if ( hoveringTrack || lockRectContainsClick || headphonesRectContainsClick )
            m_parent->setCursor( Qt::PointingHandCursor );
        else
            m_parent->setCursor( Qt::ArrowCursor );
    }

    if ( event->type() == QEvent::MouseButtonRelease || event->type() == QEvent::MouseButtonPress )
    {
        SourcesModel::RowType type = static_cast< SourcesModel::RowType >( index.data( SourcesModel::SourceTreeItemTypeRole ).toInt() );
        if ( type == SourcesModel::TemporaryPage || type == SourcesModel::DeletablePage || type == SourcesModel::RemovablePage )
        {
            SourceTreeItem* gpi = index.data( SourcesModel::SourceTreeItemRole ).value< SourceTreeItem* >();
            Q_ASSERT( gpi );

            QStyleOptionViewItemV4 o = option;
            initStyleOption( &o, index );
            const int padding = m_margin / 8;
            const QRect r( o.rect.right() - padding - m_iconHeight, padding + o.rect.y(), m_iconHeight, m_iconHeight );

            if ( r.contains( mEvent->pos() ) )
            {
                if ( event->type() == QEvent::MouseButtonRelease && mEvent->button() == Qt::LeftButton )
                {
                    gpi->removeFromList();

                    // Send a new mouse event to the view, since if the mouse is now over another item's delete area we want it to show up
                    QMouseEvent* ev = new QMouseEvent( QEvent::MouseMove, m_parent->viewport()->mapFromGlobal( QCursor::pos() ), Qt::NoButton, Qt::NoButton, Qt::NoModifier );
                    QApplication::postEvent( m_parent->viewport(), ev );
                }

                return true;
            }
        }
        else if ( type == SourcesModel::Source )
        {
            SourceItem* colItem = qobject_cast< SourceItem* >( index.data( SourcesModel::SourceTreeItemRole ).value< SourceTreeItem* >() );
            Q_ASSERT( colItem );

            if ( hoveringTrack && colItem->source() && colItem->source()->currentTrack() )
            {
                if ( event->type() == QEvent::MouseButtonRelease && mEvent->button() == Qt::LeftButton )
                {
                    ViewManager::instance()->show( colItem->source()->currentTrack() );
                    return true;
                }
                else if ( event->type() == QEvent::MouseButtonPress && mEvent->button() == Qt::RightButton )
                {
//.........这里部分代码省略.........
开发者ID:AshotN,项目名称:tomahawk,代码行数:101,代码来源:SourceDelegate.cpp

示例14: itemFromIndex

bool
SourcesModel::setData( const QModelIndex& index, const QVariant& value, int role )
{
    SourceTreeItem* item = itemFromIndex( index );
    return item->setData( value, role );
}
开发者ID:ralepinski,项目名称:tomahawk,代码行数:6,代码来源:sourcesmodel.cpp


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