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


C++ QTimeLine::deleteLater方法代码示例

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


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

示例1: updateIndex

bool
GridItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index )
{
    Q_UNUSED( model );
    Q_UNUSED( option );

    if ( event->type() != QEvent::MouseButtonRelease &&
         event->type() != QEvent::MouseMove &&
         event->type() != QEvent::MouseButtonPress &&
         event->type() != QEvent::Leave )
        return false;

    const QMouseEvent* ev = static_cast< QMouseEvent* >( event );
    bool hoveringArtist = false;
    bool hoveringAlbum = false;
    bool hoveringBuyButton = false;
    if ( m_artistNameRects.contains( index ) )
    {
        const QRect artistNameRect = m_artistNameRects[ index ];
        hoveringArtist = artistNameRect.contains( ev->pos() );
    }
    if ( m_albumNameRects.contains( index ) )
    {
        const QRect albumNameRect = m_albumNameRects[ index ];
        hoveringAlbum = albumNameRect.contains( ev->pos() );
    }
    if ( m_buyButtonRects.contains( index ) )
    {
        const QRect buyButtonRect = m_buyButtonRects[ index ];
        hoveringBuyButton = buyButtonRect.contains( ev->pos() );
    }

    QRect coverRect = m_view->visualRect( index );
    coverRect.setHeight( coverRect.width() );
    const bool hoveringCover = coverRect.contains( ev->pos() );

    if ( event->type() == QEvent::MouseMove )
    {
        if ( hoveringArtist || hoveringAlbum || hoveringBuyButton )
            m_view->setCursor( Qt::PointingHandCursor );
        else
            m_view->setCursor( Qt::ArrowCursor );

        foreach ( const QModelIndex& idx, m_hoverControls.keys() )
        {
            if ( index != idx )
                m_hoverControls.take( idx )->deleteLater();
        }

        if ( hoveringCover && !m_hoverControls.contains( index ) && !m_spinner.contains( index ) )
        {
            foreach ( HoverControls* control, m_hoverControls )
                control->deleteLater();
            m_hoverControls.clear();

            QRect cRect = option.rect;
            cRect.setHeight( cRect.width() );

            HoverControls* controls = new HoverControls( m_view );
            controls->setFixedSize( m_margin * 2, m_margin + m_margin / 4 );
            controls->move( cRect.center() - QPoint( controls->width() / 2 -1, controls->height() / 2 -1 ) );
            controls->setContentsMargins( 0, 0, 0, 0 );
            controls->setFocusPolicy( Qt::NoFocus );
            controls->installEventFilter( this );
            controls->show();

            NewClosure( controls, SIGNAL( play() ),
                        const_cast<GridItemDelegate*>(this), SLOT( onPlayClicked( QPersistentModelIndex ) ), QPersistentModelIndex( index ) );

            m_hoverControls[ index ] = controls;
        }

        if ( m_hoveringOverArtist != index || ( !hoveringArtist && m_hoveringOverArtist.isValid() ) )
        {
            emit updateIndex( m_hoveringOverArtist );

            if ( hoveringArtist )
                m_hoveringOverArtist = index;
            else
                m_hoveringOverArtist = QPersistentModelIndex();

            emit updateIndex( index );
        }
        if ( m_hoveringOverAlbum != index || ( !hoveringAlbum && m_hoveringOverAlbum.isValid() ) )
        {
            emit updateIndex( m_hoveringOverAlbum );

            if ( hoveringAlbum )
                m_hoveringOverAlbum = index;
            else
                m_hoveringOverAlbum = QPersistentModelIndex();

            emit updateIndex( index );
        }
        if ( m_hoveringOverBuyButton != index || ( !hoveringBuyButton && m_hoveringOverBuyButton.isValid() ) )
        {
            emit updateIndex( m_hoveringOverBuyButton );

            if ( hoveringBuyButton )
                m_hoveringOverBuyButton = index;
//.........这里部分代码省略.........
开发者ID:AshotN,项目名称:tomahawk,代码行数:101,代码来源:GridItemDelegate.cpp


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