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


C++ QPtrListIterator::toFirst方法代码示例

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


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

示例1: Draw

void UIListBtnType::Draw(QPainter *p, int order, int context, bool active_on)
{
    if (!m_visible || hidden)
        return;

    if (!m_initialized)
        Init();

    if (m_order != order)
        return;

    if (m_context != -1 && m_context != context)
        return;

    //  Put something on the LCD device (if one exists)
    if (class LCD *lcddev = LCD::Get())
    {
        if (m_active)
        {
            // add max of lcd height menu items either side of the selected item
            // let the lcdserver figure out which ones to display

            QPtrList<LCDMenuItem> menuItems;
            menuItems.setAutoDelete(true);

            QPtrListIterator<UIListBtnTypeItem> it = (*m_selIterator);
            uint count = 0;

            // move back up the list a little
            while (it.current() && count < lcddev->getLCDHeight())
            {
                --it;
                ++count;
            }

            if (!it.current())
                it.toFirst();
            count = 0;
            while (it.current() && count < lcddev->getLCDHeight() * 2)
            {
                UIListBtnTypeItem *curItem = it.current();
                QString msg = curItem->text();
                bool selected;
                CHECKED_STATE checkState = NOTCHECKABLE;
                if (curItem->checkable())
                {
                    if (curItem->state() == UIListBtnTypeItem::HalfChecked || 
                        curItem->state() == UIListBtnTypeItem::FullChecked)
                        checkState = CHECKED;
                    else
                        checkState = UNCHECKED;
                }

                if (curItem == m_selItem)
                    selected = true;
                else
                    selected = false;

                menuItems.append(new LCDMenuItem(selected, checkState, msg));
                ++it;
                ++count;
            }

            QString title = "";

            if (m_parentListTree && m_parentListTree->getDepth() > 0)
                title = "<< ";
            else
                title = "   ";

            if ((m_selItem && m_selItem->getDrawArrow()) || m_showArrow)
                title += " >>";
            else
                title += "   ";

            if (!menuItems.isEmpty())
            {
                lcddev->switchToMenu(&menuItems, title);
            }
        }
    }

    fontProp* font = m_active ? m_fontActive : m_fontInactive;

    if (!active_on)
    {
        font = m_fontInactive;
    }
    
    p->setFont(font->face);
    p->setPen(font->color);

    int x = m_rect.x() + m_xdrawoffset;

    int y = m_rect.y();
    QPtrListIterator<UIListBtnTypeItem> it = (*m_topIterator);
    while (it.current() && 
           (y - m_rect.y()) <= (m_contentsRect.height() - m_itemHeight)) 
    {
        if (active_on && it.current()->getOverrideInactive())
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例2: incSearchNext

bool UIListBtnType::incSearchNext(void)
{
    if (!m_selItem)
    {
        return false;
    }

    //
    //  Move the active node to the node whose string value
    //  starts or contains the search text
    //

    QPtrListIterator<UIListBtnTypeItem> it = (*m_selIterator);
    ++it;

    while (it.current())
    {
        if (m_bIncSearchContains)
        {
            if (it.current()->text().find(m_incSearch, 0, false) != -1)
                break;
        }
        else
        {
            if (it.current()->text().startsWith(m_incSearch, false))
                break;
        }

        ++it;
    }

    // if it is NULL, we reached the end of the list. wrap to the
    // beginning and try again
    if (!it.current())
    {
        it.toFirst();

        while (it.current())
        {
            // we're back at the current_node, which means there are no
            // matching nodes
            if (it.current() == m_selItem)
            {
                break;
            }

            if (m_bIncSearchContains)
            {
                if (it.current()->text().find(m_incSearch, 0, false) != -1)
                    break;
            }
            else
            {
                if (it.current()->text().startsWith(m_incSearch, false))
                    break;
            }

            ++it;
        }
    }

    if (it.current())
    {
        SetItemCurrent(it.current());
        return true;
    }

    return false;
}
开发者ID:,项目名称:,代码行数:69,代码来源:


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