Changeset 77683 in vbox for trunk/src/VBox
- Timestamp:
- Mar 13, 2019 4:22:23 PM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp
r77677 r77683 452 452 } 453 453 454 void UIChooserModel::performSearch(const QString &strSearchTerm, int iItemSearchFlags) 455 { 456 if (!m_pInvisibleRootNode || strSearchTerm.isEmpty()) 457 return; 458 459 QList<UIChooserNode*> matchedItems; 460 m_pInvisibleRootNode->searchForNodes(strSearchTerm, iItemSearchFlags, matchedItems); 461 } 462 454 463 UIChooserNode *UIChooserModel::invisibleRoot() const 455 464 { … … 779 788 } 780 789 781 void UIChooserModel::slt MachineSearch()790 void UIChooserModel::sltShowHideSearchWidget() 782 791 { 783 792 UIChooserView *pChooserView = qobject_cast<UIChooserView*>(scene()->views()[0]); … … 1411 1420 this, SLOT(sltSortGroup())); 1412 1421 connect(actionPool()->action(UIActionIndexST_M_Machine_S_Search), SIGNAL(triggered()), 1413 this, SLOT(slt MachineSearch()));1422 this, SLOT(sltShowHideSearchWidget())); 1414 1423 1415 1424 /* Setup group saving connections: */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.h
r77677 r77683 187 187 /** @} */ 188 188 189 /** @name Virtual Machine/Group search stuff. 190 * @{ */ 191 /** Performs a search starting from the m_pInvisibleRootNode. */ 192 void performSearch(const QString &strSearchTerm, int iItemSearchFlags); 193 /** @} */ 194 189 195 /** @name Children stuff. 190 196 * @{ */ … … 277 283 /** Handles group sort request. */ 278 284 void sltSortGroup(); 279 /** Handles machine search request. */280 void slt MachineSearch();285 /** Handles machine search widget show/hide request. */ 286 void sltShowHideSearchWidget(); 281 287 /** Handles group destroy request. */ 282 288 void sltUngroupSelectedGroup(); -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserNode.h
r77638 r77683 107 107 UIChooserItem *item() const { return m_pItem.data(); } 108 108 109 /** Performs search wrt. @a strSearchTerm and @a iItemSearchFlags and updates @a matchedItems. */ 110 virtual void searchForNodes(const QString &strSearchTerm, int iItemSearchFlags, QList<UIChooserNode*> &matchedItems) = 0; 111 109 112 protected: 110 113 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserNodeGlobal.cpp
r77639 r77683 115 115 } 116 116 117 void UIChooserNodeGlobal::searchForNodes(const QString &strSearchTerm, int iItemSearchFlags, QList<UIChooserNode*> &matchedItems) 118 { 119 if (!(iItemSearchFlags & UIChooserItemSearchFlag_Global)) 120 return; 121 if (iItemSearchFlags & UIChooserItemSearchFlag_ExactName) 122 { 123 if (name() == strSearchTerm) 124 matchedItems << this; 125 } 126 else 127 { 128 if (name().contains(strSearchTerm, Qt::CaseInsensitive)) 129 matchedItems << this; 130 } 131 } 132 117 133 void UIChooserNodeGlobal::retranslateUi() 118 134 { -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserNodeGlobal.h
r77639 r77683 80 80 virtual int positionOf(UIChooserNode *pNode) /* override */; 81 81 82 /** Updates the @a matchedItems wrt. @strSearchTerm and @a iItemSearchFlags. */ 83 virtual void searchForNodes(const QString &strSearchTerm, int iItemSearchFlags, QList<UIChooserNode*> &matchedItems) /* override */; 84 82 85 protected: 83 86 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserNodeGroup.cpp
r77639 r77683 188 188 } 189 189 190 191 void UIChooserNodeGroup::searchForNodes(const QString &strSearchTerm, int iItemSearchFlags, QList<UIChooserNode*> &matchedItems) 192 { 193 194 if (iItemSearchFlags & UIChooserItemSearchFlag_Group) 195 { 196 if (iItemSearchFlags & UIChooserItemSearchFlag_ExactName) 197 { 198 if (name() == strSearchTerm) 199 matchedItems << this; 200 } 201 else 202 { 203 if (name().contains(strSearchTerm, Qt::CaseInsensitive)) 204 matchedItems << this; 205 } 206 } 207 208 foreach (UIChooserNode* pNode, m_nodesGroup) 209 pNode->searchForNodes(strSearchTerm, iItemSearchFlags, matchedItems); 210 211 foreach (UIChooserNode* pNode, m_nodesGlobal) 212 pNode->searchForNodes(strSearchTerm, iItemSearchFlags, matchedItems); 213 214 foreach (UIChooserNode* pNode, m_nodesMachine) 215 pNode->searchForNodes(strSearchTerm, iItemSearchFlags, matchedItems); 216 217 } 218 219 190 220 void UIChooserNodeGroup::retranslateUi() 191 221 { -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserNodeGroup.h
r77639 r77683 95 95 void close() { m_fOpened = false; } 96 96 97 98 /** Recursively searches for a children wrt. @a strSearchTerm and @a iItemSearchFlags and updates the @a matchedItems. */ 99 virtual void searchForNodes(const QString &strSearchTerm, int iItemSearchFlags, QList<UIChooserNode*> &matchedItems) /* override */; 100 97 101 protected: 98 102 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserNodeMachine.cpp
r77639 r77683 131 131 } 132 132 133 void UIChooserNodeMachine::searchForNodes(const QString &strSearchTerm, int iItemSearchFlags, 134 QList<UIChooserNode*> &matchedItems) 135 { 136 if (!(iItemSearchFlags & UIChooserItemSearchFlag_Machine)) 137 return; 138 if (iItemSearchFlags & UIChooserItemSearchFlag_ExactName) 139 { 140 if (name() == strSearchTerm) 141 matchedItems << this; 142 return; 143 } 144 if (name().contains(strSearchTerm, Qt::CaseInsensitive)) 145 matchedItems << this; 146 } 147 133 148 void UIChooserNodeMachine::retranslateUi() 134 149 { -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserNodeMachine.h
r77639 r77683 81 81 virtual int positionOf(UIChooserNode *pNode) /* override */; 82 82 83 virtual void searchForNodes(const QString &strSearchTerm, int iItemSearchFlags, QList<UIChooserNode*> &matchedItems) /* override */; 84 83 85 protected: 84 86 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserSearchWidget.cpp
r77677 r77683 21 21 /* GUI includes: */ 22 22 #include "QILineEdit.h" 23 #include "UIChooserDefs.h" 23 24 #include "UIChooserSearchWidget.h" 24 25 … … 54 55 { 55 56 connect(m_pLineEdit, &QILineEdit::textEdited, 56 this, &UIChooserSearchWidget::s igSearchTermChanged);57 this, &UIChooserSearchWidget::sltHandleSearchTermChange); 57 58 } 58 59 } … … 68 69 { 69 70 } 71 72 void UIChooserSearchWidget::sltHandleSearchTermChange(const QString &strSearchTerm) 73 { 74 emit sigRedoSearch(strSearchTerm, UIChooserItemSearchFlag_Machine); 75 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserSearchWidget.h
r77677 r77683 39 39 signals: 40 40 41 void sig SearchTermChanged(const QString &strSearchTerm);41 void sigRedoSearch(const QString &strSearchTerm, int iItemSearchFlags); 42 42 43 43 public: … … 54 54 private slots: 55 55 56 void sltHandleSearchTermChange(const QString &strSearchTerm); 57 56 58 private: 57 59 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserView.cpp
r77677 r77683 127 127 } 128 128 129 void UIChooserView::sltRedoSearch(const QString &strSearchTerm, int iItemSearchFlags) 130 { 131 if (!m_pChooser) 132 return; 133 134 UIChooserModel *pModel = m_pChooser->model(); 135 if (!pModel) 136 return; 137 138 pModel->performSearch(strSearchTerm, iItemSearchFlags); 139 140 } 141 129 142 void UIChooserView::retranslateUi() 130 143 { … … 138 151 { 139 152 /* Install Chooser-view accessibility interface factory: */ 140 QAccessible::installFactory(UIAccessibilityInterfaceForUIChooserView::pFactory);153 QAccessible::installFactory(UIAccessibilityInterfaceForUIChooserView::pFactory); 141 154 142 155 /* Prepare palette: */ … … 155 168 m_pSearchWidget = new UIChooserSearchWidget(this); 156 169 m_pSearchWidget->hide(); 170 connect(m_pSearchWidget, &UIChooserSearchWidget::sigRedoSearch, 171 this, &UIChooserView::sltRedoSearch); 157 172 158 173 /* Update scene-rect: */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserView.h
r77677 r77683 73 73 /** @} */ 74 74 75 private slots: 76 77 void sltRedoSearch(const QString &strSearchTerm, int iItemSearchFlags); 78 75 79 private: 76 80
Note:
See TracChangeset
for help on using the changeset viewer.