VirtualBox

Changeset 77013 in vbox


Ignore:
Timestamp:
Jan 28, 2019 8:24:12 AM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: Some modifications to UIMediumSearchWidget.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/medium
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSearchWidget.cpp

    r77009 r77013  
    155155    if (!m_matchedItemList.isEmpty())
    156156    {
    157         m_iScrollToIndex = 0;
    158         pTreeWidget->scrollTo(pTreeWidget->itemIndex(m_matchedItemList[m_iScrollToIndex]), QAbstractItemView::PositionAtCenter);
     157        m_iScrollToIndex = -1;
     158        goToNextPrevious(true);
    159159    }
    160160}
     
    195195        font.setBold(fMark);
    196196        pMediumItem->setFont(0, font);
    197     }
     197
     198        if (!fMark)
     199            setUnderlineItemText(pMediumItem, false);
     200    }
     201}
     202
     203void UIMediumSearchWidget::setUnderlineItemText(QTreeWidgetItem* pItem, bool fUnderline)
     204{
     205    if (!pItem)
     206        return;
     207    QFont font = pItem->font(0);
     208    font.setUnderline(fUnderline);
     209    pItem->setFont(0, font);
     210}
     211
     212void UIMediumSearchWidget::goToNextPrevious(bool fNext)
     213{
     214    if (!m_pTreeWidget || m_matchedItemList.isEmpty())
     215        return;
     216
     217    if (m_iScrollToIndex >= 0 && m_iScrollToIndex < m_matchedItemList.size())
     218        setUnderlineItemText(m_matchedItemList[m_iScrollToIndex], false);
     219
     220    if (fNext)
     221        ++m_iScrollToIndex;
     222    else
     223        --m_iScrollToIndex;
     224
     225    if (m_iScrollToIndex >= m_matchedItemList.size())
     226        m_iScrollToIndex = 0;
     227    if (m_iScrollToIndex < 0)
     228        m_iScrollToIndex = m_matchedItemList.size() - 1;
     229
     230    setUnderlineItemText(m_matchedItemList[m_iScrollToIndex], true);
     231    m_pTreeWidget->scrollTo(m_pTreeWidget->itemIndex(m_matchedItemList[m_iScrollToIndex]), QAbstractItemView::PositionAtCenter);
     232
    198233}
    199234
    200235void UIMediumSearchWidget::sltShowNextMatchingItem()
    201236{
    202     if (!m_pTreeWidget)
    203         return;
    204     if (++m_iScrollToIndex >= m_matchedItemList.size())
    205         m_iScrollToIndex = 0;
    206     if (!m_matchedItemList[m_iScrollToIndex])
    207         return;
    208     m_pTreeWidget->scrollTo(m_pTreeWidget->itemIndex(m_matchedItemList[m_iScrollToIndex]), QAbstractItemView::PositionAtCenter);
     237    if (m_matchedItemList.isEmpty())
     238        return;
     239    goToNextPrevious(true);
    209240}
    210241
    211242void UIMediumSearchWidget::sltShowPreviousMatchingItem()
    212243{
    213     if (!m_pTreeWidget)
    214         return;
    215     if (--m_iScrollToIndex <= 0)
    216         m_iScrollToIndex = m_matchedItemList.size() - 1;
    217     if (!m_matchedItemList[m_iScrollToIndex])
    218         return;
    219     m_pTreeWidget->scrollTo(m_pTreeWidget->itemIndex(m_matchedItemList[m_iScrollToIndex]), QAbstractItemView::PositionAtCenter);
    220 
    221 }
     244    goToNextPrevious(false);
     245}
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSearchWidget.h

    r77006 r77013  
    7676    void    prepareWidgets();
    7777    void    markUnmarkItems(QList<QTreeWidgetItem*> &itemList, bool fMark);
    78 
     78    void    setUnderlineItemText(QTreeWidgetItem* pItem, bool fUnderline);
     79    /** Increases (or decreases if @p fNext is false) the m_iScrollToIndex and
     80     *  takes care of the necessary decoration changes to mark the current item. */
     81    void    goToNextPrevious(bool fNext);
    7982    QIComboBox       *m_pSearchComboxBox;
    8083    QLineEdit        *m_pSearchTermLineEdit;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette