Changeset 77750 in vbox for trunk/src/VBox
- Timestamp:
- Mar 18, 2019 11:51:29 AM (6 years ago)
- 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 580 580 void UIChooserModel::lookFor(const QString &strLookupSymbol) 581 581 { 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); 637 586 } 638 587 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserSearchWidget.cpp
r77723 r77750 50 50 return; 51 51 m_pLineEdit->setScroolToIndex(iScrollToIndex); 52 } 53 54 void UIChooserSearchWidget::appendToSearchString(const QString &strSearchText) 55 { 56 if (!m_pLineEdit) 57 return; 58 m_pLineEdit->setText(m_pLineEdit->text().append(strSearchText)); 52 59 } 53 60 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserSearchWidget.h
r77723 r77750 53 53 void setMatchCount(int iMatchCount); 54 54 void setScroolToIndex(int iScrollToIndex); 55 /** Appends the @a strSearchText to the current (if any) search text. */ 56 void appendToSearchString(const QString &strSearchText); 55 57 56 58 protected: -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserView.cpp
r77723 r77750 106 106 if (!m_pSearchWidget) 107 107 return; 108 m_pSearchWidget->setVisible(!m_pSearchWidget->isVisible()); 108 bool fVisible = m_pSearchWidget->isVisible(); 109 setSearchWidgetVisible(!fVisible); 110 } 111 112 void UIChooserView::setSearchWidgetVisible(bool fVisible) 113 { 114 if (!m_pSearchWidget) 115 return; 116 if (m_pSearchWidget->isVisible() == fVisible) 117 return; 118 m_pSearchWidget->setVisible(fVisible); 109 119 if (m_pSearchWidget->isVisible()) 110 120 updateSearchWidgetGeometry(); 121 122 UIChooserModel *pModel = m_pChooser->model(); 123 if (!pModel) 124 return; 125 pModel->resetSearch(); 111 126 } 112 127 … … 119 134 } 120 135 136 void UIChooserView::appendToSearchString(const QString &strSearchText) 137 { 138 if (m_pSearchWidget) 139 m_pSearchWidget->appendToSearchString(strSearchText); 140 } 141 121 142 void UIChooserView::sltMinimumWidthHintChanged(int iHint) 122 143 { … … 156 177 void UIChooserView::sltHandleSearchWidgetVisibilityToggle(bool fIsVisible) 157 178 { 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); 167 180 } 168 181 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserView.h
r77723 r77750 56 56 /** Shows/hides machine search widget. */ 57 57 void toggleSearchWidget(); 58 /** Shows/hides machine search widget. */ 59 void setSearchWidgetVisible(bool fVisible); 58 60 /** Updates the search widget's counts. */ 59 61 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); 60 64 /** @} */ 61 65
Note:
See TracChangeset
for help on using the changeset viewer.