- Timestamp:
- Aug 15, 2012 9:08:59 PM (12 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserHandlerKeyboard.cpp
r42830 r42832 316 316 case Qt::Key_Space: 317 317 { 318 /* If model is performing lookup: */ 319 if (model()->isPerformingLookup()) 320 { 321 /* Continue lookup: */ 322 QString strText = pEvent->text(); 323 if (!strText.isEmpty()) 324 model()->lookFor(strText); 325 } 318 326 /* If there is a focus item: */ 319 if (UIGChooserItem *pFocusItem = model()->focusItem())327 else if (UIGChooserItem *pFocusItem = model()->focusItem()) 320 328 { 321 329 /* Of the group type: */ … … 336 344 } 337 345 default: 346 { 347 /* Start lookup: */ 348 QString strText = pEvent->text(); 349 if (!strText.isEmpty()) 350 model()->lookFor(strText); 338 351 break; 352 } 339 353 } 340 354 /* Pass all other events: */ -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItem.cpp
r42734 r42832 165 165 /* And make sure its opened: */ 166 166 if (pParentItem->closed()) 167 pParentItem->open( );167 pParentItem->open(false); 168 168 } 169 169 } -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.cpp
r42830 r42832 62 62 , m_pContextMenuGroup(0) 63 63 , m_pContextMenuMachine(0) 64 , m_pLookupTimer(0) 64 65 { 65 66 /* Prepare scene: */ … … 69 70 prepareRoot(); 70 71 72 /* Prepare lookup: */ 73 prepareLookup(); 74 71 75 /* Prepare context-menu: */ 72 76 prepareContextMenu(); … … 83 87 /* Prepare context-menu: */ 84 88 cleanupContextMenu(); 89 90 /* Cleanup lookup: */ 91 cleanupLookup(); 85 92 86 93 /* Cleanup root: */ … … 515 522 { 516 523 return UIGroupsSavingThread::instance(); 524 } 525 526 void UIGChooserModel::lookFor(const QString &strLookupSymbol) 527 { 528 /* Restart timer to reset lookup-string: */ 529 m_pLookupTimer->start(); 530 /* Look for item which is starting from the lookup-string: */ 531 UIGChooserItem *pItem = lookForItem(mainRoot(), m_strLookupString + strLookupSymbol); 532 /* If item found: */ 533 if (pItem) 534 { 535 /* Choose it: */ 536 pItem->makeSureItsVisible(); 537 setCurrentItem(pItem); 538 /* Append lookup symbol: */ 539 m_strLookupString += strLookupSymbol; 540 } 541 } 542 543 bool UIGChooserModel::isPerformingLookup() const 544 { 545 return m_pLookupTimer->isActive(); 517 546 } 518 547 … … 890 919 } 891 920 921 void UIGChooserModel::sltEraseLookupTimer() 922 { 923 m_pLookupTimer->stop(); 924 m_strLookupString = QString(); 925 } 926 892 927 QVariant UIGChooserModel::data(int iKey) const 893 928 { … … 909 944 { 910 945 m_rootStack << new UIGChooserItemGroup(scene()); 946 } 947 948 void UIGChooserModel::prepareLookup() 949 { 950 m_pLookupTimer = new QTimer(this); 951 m_pLookupTimer->setInterval(1000); 952 m_pLookupTimer->setSingleShot(true); 953 connect(m_pLookupTimer, SIGNAL(timeout()), this, SLOT(sltEraseLookupTimer())); 911 954 } 912 955 … … 1018 1061 delete m_pContextMenuMachine; 1019 1062 m_pContextMenuMachine = 0; 1063 } 1064 1065 void UIGChooserModel::cleanupLookup() 1066 { 1067 delete m_pLookupTimer; 1068 m_pLookupTimer = 0; 1020 1069 } 1021 1070 … … 1776 1825 } 1777 1826 1827 UIGChooserItem* UIGChooserModel::lookForItem(UIGChooserItem *pParent, const QString &strStartingFrom) 1828 { 1829 /* Search among the machines: */ 1830 foreach (UIGChooserItem *pItem, pParent->items(UIGChooserItemType_Machine)) 1831 if (pItem->name().startsWith(strStartingFrom, Qt::CaseInsensitive)) 1832 return pItem; 1833 /* Search among the groups: */ 1834 foreach (UIGChooserItem *pItem, pParent->items(UIGChooserItemType_Group)) 1835 { 1836 if (pItem->name().startsWith(strStartingFrom, Qt::CaseInsensitive)) 1837 return pItem; 1838 if (UIGChooserItem *pResult = lookForItem(pItem, strStartingFrom)) 1839 return pResult; 1840 } 1841 /* Nothing found: */ 1842 return 0; 1843 } 1844 1778 1845 /* static */ 1779 1846 UIGroupsSavingThread* UIGroupsSavingThread::m_spInstance = 0; -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.h
r42830 r42832 44 44 class UIGChooserHandlerMouse; 45 45 class UIGChooserHandlerKeyboard; 46 class QTimer; 46 47 47 48 /* Context-menu type: */ … … 156 157 bool isGroupSavingInProgress() const; 157 158 159 /* API: Lookup stuff: */ 160 void lookFor(const QString &strLookupSymbol); 161 bool isPerformingLookup() const; 162 158 163 private slots: 159 164 … … 204 209 void sltGroupSavingComplete(); 205 210 211 /* Handler: Lookup stuff: */ 212 void sltEraseLookupTimer(); 213 206 214 private: 207 215 … … 219 227 void prepareScene(); 220 228 void prepareRoot(); 229 void prepareLookup(); 221 230 void prepareContextMenu(); 222 231 void prepareHandlers(); … … 227 236 void cleanupHandlers(); 228 237 void cleanupContextMenu(); 238 void cleanupLookup(); 229 239 void cleanupRoot(); 230 240 void cleanupScene(); … … 293 303 /* Helper: Group saving stuff: */ 294 304 void makeSureGroupSavingIsFinished(); 305 306 /* Helper: Lookup stuff: */ 307 UIGChooserItem* lookForItem(UIGChooserItem *pParent, const QString &strStartingFrom); 295 308 296 309 /* Variables: */ … … 314 327 QMenu *m_pContextMenuGroup; 315 328 QMenu *m_pContextMenuMachine; 329 330 /* Variables: Lookup stuff: */ 331 QTimer *m_pLookupTimer; 332 QString m_strLookupString; 316 333 }; 317 334
Note:
See TracChangeset
for help on using the changeset viewer.