VirtualBox

Changeset 77750 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Mar 18, 2019 11:51:29 AM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9378. Handling showing/hiding serch widget a bit better.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp

    r77748 r77750  
    580580void UIChooserModel::lookFor(const QString &strLookupSymbol)
    581581{
    582     /* Restart timer to reset lookup-string: */
    583     m_pLookupTimer->start();
    584 
    585     /* Prepare item: */
    586     UIChooserItem *pItem = 0;
    587 
    588     /* We are starting to look from the current position: */
    589     int iCurrentIndex = navigationList().indexOf(currentItem());
    590 
    591     /* Are we looking for the 1. same symbol or for the 2. composed word? */
    592     const QString strLookupString = m_strLookupString.isEmpty() || m_strLookupString == strLookupSymbol ?
    593                                     strLookupSymbol : m_strLookupString + strLookupSymbol;
    594     /* Are we looking from the 1. subsequent position or from the 2. same one? */
    595     const int     iFirstIndex     = m_strLookupString.isEmpty() || m_strLookupString == strLookupSymbol ?
    596                                     iCurrentIndex + 1 : iCurrentIndex;
    597 
    598     /* If first position feats the bounds: */
    599     if (iFirstIndex < navigationList().size())
    600     {
    601         /* We have to look starting from the first position: */
    602         for (int iIndex = iFirstIndex; iIndex < navigationList().size(); ++iIndex)
    603         {
    604             UIChooserItem *pIteratedItem = navigationList().at(iIndex);
    605             if (pIteratedItem->name().startsWith(strLookupString, Qt::CaseInsensitive))
    606             {
    607                 pItem = pIteratedItem;
    608                 break;
    609             }
    610         }
    611     }
    612 
    613     /* If the item was not found: */
    614     if (!pItem && iFirstIndex > 0)
    615     {
    616         /* We have to try to look from the beginning of the list: */
    617         for (int iIndex = 0; iIndex < iFirstIndex; ++iIndex)
    618         {
    619             UIChooserItem *pIteratedItem = navigationList().at(iIndex);
    620             if (pIteratedItem->name().startsWith(strLookupString, Qt::CaseInsensitive))
    621             {
    622                 pItem = pIteratedItem;
    623                 break;
    624             }
    625         }
    626     }
    627 
    628     /* If that item was found: */
    629     if (pItem)
    630     {
    631         /* Choose it: */
    632         pItem->makeSureItsVisible();
    633         setCurrentItem(pItem);
    634         /* Append lookup symbol: */
    635         if (m_strLookupString != strLookupSymbol)
    636             m_strLookupString += strLookupSymbol;
     582    if (view())
     583    {
     584        view()->setSearchWidgetVisible(true);
     585        view()->appendToSearchString(strLookupSymbol);
    637586    }
    638587}
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserSearchWidget.cpp

    r77723 r77750  
    5050        return;
    5151    m_pLineEdit->setScroolToIndex(iScrollToIndex);
     52}
     53
     54void UIChooserSearchWidget::appendToSearchString(const QString &strSearchText)
     55{
     56    if (!m_pLineEdit)
     57        return;
     58    m_pLineEdit->setText(m_pLineEdit->text().append(strSearchText));
    5259}
    5360
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserSearchWidget.h

    r77723 r77750  
    5353    void setMatchCount(int iMatchCount);
    5454    void setScroolToIndex(int iScrollToIndex);
     55    /** Appends the @a strSearchText to the current (if any) search text. */
     56    void appendToSearchString(const QString &strSearchText);
    5557
    5658protected:
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserView.cpp

    r77723 r77750  
    106106    if (!m_pSearchWidget)
    107107        return;
    108     m_pSearchWidget->setVisible(!m_pSearchWidget->isVisible());
     108    bool fVisible = m_pSearchWidget->isVisible();
     109    setSearchWidgetVisible(!fVisible);
     110}
     111
     112void UIChooserView::setSearchWidgetVisible(bool fVisible)
     113{
     114    if (!m_pSearchWidget)
     115        return;
     116    if (m_pSearchWidget->isVisible() == fVisible)
     117        return;
     118    m_pSearchWidget->setVisible(fVisible);
    109119    if (m_pSearchWidget->isVisible())
    110120        updateSearchWidgetGeometry();
     121
     122    UIChooserModel *pModel =  m_pChooser->model();
     123    if (!pModel)
     124        return;
     125    pModel->resetSearch();
    111126}
    112127
     
    119134}
    120135
     136void UIChooserView::appendToSearchString(const QString &strSearchText)
     137{
     138    if (m_pSearchWidget)
     139        m_pSearchWidget->appendToSearchString(strSearchText);
     140}
     141
    121142void UIChooserView::sltMinimumWidthHintChanged(int iHint)
    122143{
     
    156177void UIChooserView::sltHandleSearchWidgetVisibilityToggle(bool fIsVisible)
    157178{
    158     if (!m_pSearchWidget)
    159         return;
    160     if (m_pSearchWidget->isVisible() == fIsVisible)
    161         return;
    162     m_pSearchWidget->setVisible(fIsVisible);
    163     UIChooserModel *pModel =  m_pChooser->model();
    164     if (!pModel)
    165         return;
    166     pModel->resetSearch();
     179    setSearchWidgetVisible(fIsVisible);
    167180}
    168181
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserView.h

    r77723 r77750  
    5656        /** Shows/hides machine search widget. */
    5757        void toggleSearchWidget();
     58        /** Shows/hides machine search widget. */
     59        void setSearchWidgetVisible(bool fVisible);
    5860        /** Updates the search widget's counts. */
    5961        void setSearchResultsCount(int iTotalMacthCount, int iCurrentlyScrolledItemIndex);
     62        /** Forwards @a strSearchText to the search widget which in turn appends it to the current (if any) search term. */
     63        void appendToSearchString(const QString &strSearchText);
    6064    /** @} */
    6165
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