Changeset 43604 in vbox
- Timestamp:
- Oct 10, 2012 4:19:53 PM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 81300
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItem.h
r43597 r43604 27 27 #include "QIWithRetranslateUI.h" 28 28 29 /* Other VBox includes: */ 30 #include <iprt/cdefs.h> 31 29 32 /* Forward declaration: */ 30 33 class UIGChooserModel; … … 43 46 UIGChooserItemType_Group = QGraphicsItem::UserType + 1, 44 47 UIGChooserItemType_Machine = QGraphicsItem::UserType + 2 48 }; 49 50 /* Item search flags: */ 51 enum UIGChooserItemSearchFlag 52 { 53 UIGChooserItemSearchFlag_Machine = RT_BIT(0), 54 UIGChooserItemSearchFlag_Group = RT_BIT(1), 55 UIGChooserItemSearchFlag_ExactName = RT_BIT(2) 45 56 }; 46 57 … … 94 105 virtual bool hasItems(UIGChooserItemType type = UIGChooserItemType_Any) const = 0; 95 106 virtual void clearItems(UIGChooserItemType type = UIGChooserItemType_Any) = 0; 107 virtual UIGChooserItem* searchForItem(const QString &strSearchTag, int iItemSearchFlags) = 0; 96 108 virtual UIGChooserItemMachine* firstMachineItem() = 0; 97 109 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemGroup.cpp
r43597 r43604 732 732 } 733 733 734 UIGChooserItem* UIGChooserItemGroup::searchForItem(const QString &strSearchTag, int iItemSearchFlags) 735 { 736 /* Are we searching among group-items? */ 737 if (iItemSearchFlags & UIGChooserItemSearchFlag_Group) 738 { 739 /* Are we searching by the exact name? */ 740 if (iItemSearchFlags & UIGChooserItemSearchFlag_ExactName) 741 { 742 /* Exact name matches? */ 743 if (name() == strSearchTag) 744 return this; 745 } 746 /* Are we searching by the few first symbols? */ 747 else 748 { 749 /* Name starts with passed symbols? */ 750 if (name().startsWith(strSearchTag, Qt::CaseInsensitive)) 751 return this; 752 } 753 } 754 755 /* Search among all the children, but machines first: */ 756 foreach (UIGChooserItem *pItem, items(UIGChooserItemType_Machine)) 757 if (UIGChooserItem *pFoundItem = pItem->searchForItem(strSearchTag, iItemSearchFlags)) 758 return pFoundItem; 759 foreach (UIGChooserItem *pItem, items(UIGChooserItemType_Group)) 760 if (UIGChooserItem *pFoundItem = pItem->searchForItem(strSearchTag, iItemSearchFlags)) 761 return pFoundItem; 762 763 /* Nothing found? */ 764 return 0; 765 } 766 734 767 UIGChooserItemMachine* UIGChooserItemGroup::firstMachineItem() 735 768 { -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemGroup.h
r43597 r43604 148 148 bool hasItems(UIGChooserItemType type = UIGChooserItemType_Any) const; 149 149 void clearItems(UIGChooserItemType type = UIGChooserItemType_Any); 150 UIGChooserItem* searchForItem(const QString &strSearchTag, int iItemSearchFlags); 150 151 UIGChooserItemMachine* firstMachineItem(); 151 152 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.cpp
r43598 r43604 360 360 } 361 361 362 UIGChooserItem* UIGChooserItemMachine::searchForItem(const QString &strSearchTag, int iItemSearchFlags) 363 { 364 /* Ignoring if we are not searching for the machine-item? */ 365 if (!(iItemSearchFlags & UIGChooserItemSearchFlag_Machine)) 366 return 0; 367 368 /* Are we searching by the exact name? */ 369 if (iItemSearchFlags & UIGChooserItemSearchFlag_ExactName) 370 { 371 /* Exact name doesn't match? */ 372 if (name() != strSearchTag) 373 return 0; 374 } 375 /* Are we searching by the few first symbols? */ 376 else 377 { 378 /* Name doesn't start with passed symbols? */ 379 if (!name().startsWith(strSearchTag, Qt::CaseInsensitive)) 380 return 0; 381 } 382 383 /* Returning this: */ 384 return this; 385 } 386 362 387 UIGChooserItemMachine* UIGChooserItemMachine::firstMachineItem() 363 388 { -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.h
r43597 r43604 23 23 #include "UIVMItem.h" 24 24 #include "UIGChooserItem.h" 25 26 /* Other VBox includes: */27 #include <iprt/cdefs.h>28 25 29 26 /* Forward declarations: */ … … 127 124 bool hasItems(UIGChooserItemType type) const; 128 125 void clearItems(UIGChooserItemType type); 126 UIGChooserItem* searchForItem(const QString &strSearchTag, int iItemSearchFlags); 129 127 UIGChooserItemMachine* firstMachineItem(); 130 128 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.cpp
r43598 r43604 296 296 { 297 297 /* Search for group-item with passed descriptor (name): */ 298 pItem = findGroupItem(strItemDescriptor, mainRoot()); 298 pItem = mainRoot()->searchForItem(strItemDescriptor, 299 UIGChooserItemSearchFlag_Group | 300 UIGChooserItemSearchFlag_ExactName); 299 301 } 300 302 /* Its a machine-item definition? */ … … 306 308 { 307 309 /* Search for machine-item with required name: */ 308 pItem = findMachineItem(machine.GetName(), mainRoot()); 310 pItem = mainRoot()->searchForItem(machine.GetName(), 311 UIGChooserItemSearchFlag_Machine | 312 UIGChooserItemSearchFlag_ExactName); 309 313 } 310 314 } … … 556 560 m_pLookupTimer->start(); 557 561 /* Look for item which is starting from the lookup-string: */ 558 UIGChooserItem *pItem = lookForItem(mainRoot(), m_strLookupString + strLookupSymbol); 562 UIGChooserItem *pItem = mainRoot()->searchForItem(m_strLookupString + strLookupSymbol, 563 UIGChooserItemSearchFlag_Machine | 564 UIGChooserItemSearchFlag_Group); 559 565 /* If item found: */ 560 566 if (pItem) … … 611 617 updateNavigation(); 612 618 updateLayout(); 613 setCurrentItem(findMachineItem(machine.GetName(), mainRoot())); 619 setCurrentItem(mainRoot()->searchForItem(machine.GetName(), 620 UIGChooserItemSearchFlag_Machine | 621 UIGChooserItemSearchFlag_ExactName)); 614 622 } 615 623 } … … 941 949 /* Select first of reloaded items: */ 942 950 if (!pSelectedItem) 943 pSelectedItem = findMachineItem(strMachineName, mainRoot()); 951 pSelectedItem = mainRoot()->searchForItem(strMachineName, 952 UIGChooserItemSearchFlag_Machine | 953 UIGChooserItemSearchFlag_ExactName); 944 954 } 945 955 } … … 1404 1414 } 1405 1415 1406 UIGChooserItem* UIGChooserModel::findGroupItem(const QString &strName, UIGChooserItem *pParent)1407 {1408 /* Search among all the group-items of passed parent: */1409 foreach (UIGChooserItem *pItem, pParent->items(UIGChooserItemType_Group))1410 if (pItem->name() == strName)1411 return pItem;1412 /* Recursively iterate into each the group-item of the passed parent: */1413 foreach (UIGChooserItem *pItem, pParent->items(UIGChooserItemType_Group))1414 if (UIGChooserItem *pGroupItem = findGroupItem(strName, pItem))1415 return pGroupItem;1416 /* Nothing found? */1417 return 0;1418 }1419 1420 1416 void UIGChooserModel::cleanupGroupTree(UIGChooserItem *pParent) 1421 1417 { … … 1433 1429 unindentRoot(); 1434 1430 } 1435 }1436 1437 UIGChooserItem* UIGChooserModel::findMachineItem(const QString &strName, UIGChooserItem *pParent)1438 {1439 /* Search among all the machine-items of passed parent: */1440 foreach (UIGChooserItem *pItem, pParent->items(UIGChooserItemType_Machine))1441 if (pItem->name() == strName)1442 return pItem;1443 /* Recursively iterate into each the group-item of the passed parent: */1444 foreach (UIGChooserItem *pItem, pParent->items(UIGChooserItemType_Group))1445 if (UIGChooserItem *pMachineItem = findMachineItem(strName, pItem))1446 return pMachineItem;1447 /* Nothing found? */1448 return 0;1449 1431 } 1450 1432 … … 1694 1676 } 1695 1677 1696 UIGChooserItem* UIGChooserModel::lookForItem(UIGChooserItem *pParent, const QString &strStartingFrom)1697 {1698 /* Search among the machines: */1699 foreach (UIGChooserItem *pItem, pParent->items(UIGChooserItemType_Machine))1700 if (pItem->name().startsWith(strStartingFrom, Qt::CaseInsensitive))1701 return pItem;1702 /* Search among the groups: */1703 foreach (UIGChooserItem *pItem, pParent->items(UIGChooserItemType_Group))1704 {1705 if (pItem->name().startsWith(strStartingFrom, Qt::CaseInsensitive))1706 return pItem;1707 if (UIGChooserItem *pResult = lookForItem(pItem, strStartingFrom))1708 return pResult;1709 }1710 /* Nothing found: */1711 return 0;1712 }1713 1714 1678 void UIGChooserModel::loadGroupTree() 1715 1679 { -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.h
r43598 r43604 245 245 246 246 /* Helper: Group-item stuff: */ 247 UIGChooserItem* findGroupItem(const QString &strName, UIGChooserItem *pParent);248 247 void cleanupGroupTree(UIGChooserItem *pGroupItem); 249 248 250 249 /* Helpers: Machine-item stuff: */ 251 UIGChooserItem* findMachineItem(const QString &strName, UIGChooserItem *pParent);252 250 void sortItems(UIGChooserItem *pParent); 253 251 void updateMachineItems(const QString &strId, UIGChooserItem *pParent); … … 262 260 /* Handler: Drag&drop event: */ 263 261 bool processDragMoveEvent(QGraphicsSceneDragDropEvent *pEvent); 264 265 /* Helper: Lookup stuff: */266 UIGChooserItem* lookForItem(UIGChooserItem *pParent, const QString &strStartingFrom);267 262 268 263 /* Helpers: Loading stuff: */
Note:
See TracChangeset
for help on using the changeset viewer.