Changeset 43617 in vbox
- Timestamp:
- Oct 11, 2012 12:59:41 PM (12 years ago)
- 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
r43615 r43617 91 91 virtual void hide(); 92 92 virtual void startEditing() = 0; 93 virtual void updateToolTip() = 0; 93 94 virtual QString name() const = 0; 94 95 virtual QString definition() const = 0; … … 105 106 virtual bool hasItems(UIGChooserItemType type = UIGChooserItemType_Any) const = 0; 106 107 virtual void clearItems(UIGChooserItemType type = UIGChooserItemType_Any) = 0; 108 virtual void updateAll(const QString &strId) = 0; 107 109 virtual UIGChooserItem* searchForItem(const QString &strSearchTag, int iItemSearchFlags) = 0; 108 110 virtual UIGChooserItemMachine* firstMachineItem() = 0; -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemGroup.cpp
r43615 r43617 244 244 return true; 245 245 return false; 246 }247 248 void UIGChooserItemGroup::updateToolTip()249 {250 /* Prepare variables: */251 QStringList toolTipInfo;252 253 /* Should we add name? */254 if (!name().isEmpty())255 {256 /* Template: */257 QString strTemplateForName = tr("<b>%1</b>", "Group item tool-tip / Group name");258 259 /* Append value: */260 toolTipInfo << strTemplateForName.arg(name());261 }262 263 /* Should we add group info? */264 if (!items(UIGChooserItemType_Group).isEmpty())265 {266 /* Template: */267 QString strGroupCount = tr("%n group(s)", "Group item tool-tip / Group info", items(UIGChooserItemType_Group).size());268 269 /* Append value: */270 QString strValue = tr("<nobr>%1</nobr>", "Group item tool-tip / Group info wrapper").arg(strGroupCount);271 toolTipInfo << strValue;272 }273 274 /* Should we add machine info? */275 if (!items(UIGChooserItemType_Machine).isEmpty())276 {277 /* Check if 'this' group contains started VMs: */278 int iCountOfStartedMachineItems = 0;279 foreach (UIGChooserItem *pItem, items(UIGChooserItemType_Machine))280 if (UIVMItem::isItemStarted(pItem->toMachineItem()))281 ++iCountOfStartedMachineItems;282 /* Template: */283 QString strMachineCount = tr("%n machine(s)", "Group item tool-tip / Machine info", items(UIGChooserItemType_Machine).size());284 QString strStartedMachineCount = tr("(%n running)", "Group item tool-tip / Running machine info", iCountOfStartedMachineItems);285 286 /* Append value: */287 QString strValue = !iCountOfStartedMachineItems ?288 tr("<nobr>%1</nobr>", "Group item tool-tip / Machine info wrapper").arg(strMachineCount) :289 tr("<nobr>%1 %2</nobr>", "Group item tool-tip / Machine info wrapper, including running").arg(strMachineCount).arg(strStartedMachineCount);290 toolTipInfo << strValue;291 }292 293 /* Set tool-tip: */294 setToolTip(toolTipInfo.join("<br>"));295 246 } 296 247 … … 602 553 } 603 554 555 void UIGChooserItemGroup::updateToolTip() 556 { 557 /* Prepare variables: */ 558 QStringList toolTipInfo; 559 560 /* Should we add name? */ 561 if (!name().isEmpty()) 562 { 563 /* Template: */ 564 QString strTemplateForName = tr("<b>%1</b>", "Group item tool-tip / Group name"); 565 566 /* Append value: */ 567 toolTipInfo << strTemplateForName.arg(name()); 568 } 569 570 /* Should we add group info? */ 571 if (!items(UIGChooserItemType_Group).isEmpty()) 572 { 573 /* Template: */ 574 QString strGroupCount = tr("%n group(s)", "Group item tool-tip / Group info", items(UIGChooserItemType_Group).size()); 575 576 /* Append value: */ 577 QString strValue = tr("<nobr>%1</nobr>", "Group item tool-tip / Group info wrapper").arg(strGroupCount); 578 toolTipInfo << strValue; 579 } 580 581 /* Should we add machine info? */ 582 if (!items(UIGChooserItemType_Machine).isEmpty()) 583 { 584 /* Check if 'this' group contains started VMs: */ 585 int iCountOfStartedMachineItems = 0; 586 foreach (UIGChooserItem *pItem, items(UIGChooserItemType_Machine)) 587 if (UIVMItem::isItemStarted(pItem->toMachineItem())) 588 ++iCountOfStartedMachineItems; 589 /* Template: */ 590 QString strMachineCount = tr("%n machine(s)", "Group item tool-tip / Machine info", items(UIGChooserItemType_Machine).size()); 591 QString strStartedMachineCount = tr("(%n running)", "Group item tool-tip / Running machine info", iCountOfStartedMachineItems); 592 593 /* Append value: */ 594 QString strValue = !iCountOfStartedMachineItems ? 595 tr("<nobr>%1</nobr>", "Group item tool-tip / Machine info wrapper").arg(strMachineCount) : 596 tr("<nobr>%1 %2</nobr>", "Group item tool-tip / Machine info wrapper, including running").arg(strMachineCount).arg(strStartedMachineCount); 597 toolTipInfo << strValue; 598 } 599 600 /* Set tool-tip: */ 601 setToolTip(toolTipInfo.join("<br>")); 602 } 603 604 604 void UIGChooserItemGroup::addItem(UIGChooserItem *pItem, int iPosition) 605 605 { … … 730 730 731 731 updateToolTip(); 732 } 733 734 void UIGChooserItemGroup::updateAll(const QString &strId) 735 { 736 /* Update all the items: */ 737 foreach (UIGChooserItem *pItem, items()) 738 pItem->updateAll(strId); 732 739 } 733 740 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemGroup.h
r43615 r43617 78 78 bool contains(const QString &strId, bool fRecursively = false) const; 79 79 bool isContainsLockedMachine(); 80 81 /* API: Update stuff: */82 void updateToolTip();83 80 84 81 private slots: … … 139 136 void hide(); 140 137 void startEditing(); 138 void updateToolTip(); 141 139 bool isMainRoot() const { return m_fMainRoot; } 142 140 … … 148 146 bool hasItems(UIGChooserItemType type = UIGChooserItemType_Any) const; 149 147 void clearItems(UIGChooserItemType type = UIGChooserItemType_Any); 148 void updateAll(const QString &strId); 150 149 UIGChooserItem* searchForItem(const QString &strSearchTag, int iItemSearchFlags); 151 150 UIGChooserItemMachine* firstMachineItem(); -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.cpp
r43615 r43617 148 148 } 149 149 150 void UIGChooserItemMachine::updateToolTip()151 {152 setToolTip(toolTipText());153 }154 155 150 /* static */ 156 151 void UIGChooserItemMachine::enumerateMachineItems(const QList<UIGChooserItem*> &il, … … 328 323 } 329 324 325 void UIGChooserItemMachine::updateToolTip() 326 { 327 setToolTip(toolTipText()); 328 } 329 330 330 void UIGChooserItemMachine::addItem(UIGChooserItem*, int) 331 331 { … … 358 358 { 359 359 AssertMsgFailed(("Machine graphics item do NOT support children!")); 360 } 361 362 void UIGChooserItemMachine::updateAll(const QString &strId) 363 { 364 /* Skip wrong id: */ 365 if (id() != strId) 366 return; 367 368 /* Update this machine-item: */ 369 recache(); 370 updateToolTip(); 371 update(); 372 373 /* Update parent group-item: */ 374 parentItem()->updateToolTip(); 375 parentItem()->update(); 360 376 } 361 377 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.h
r43615 r43617 61 61 bool isLockedMachine() const; 62 62 63 /* API: Update stuff: */64 void updateToolTip();65 66 63 /* API: Machine-item enumeration stuff: */ 67 64 static void enumerateMachineItems(const QList<UIGChooserItem*> &il, … … 116 113 /* Helpers: Basic stuff: */ 117 114 void startEditing(); 115 void updateToolTip(); 118 116 119 117 /* Helpers: Children stuff: */ … … 124 122 bool hasItems(UIGChooserItemType type) const; 125 123 void clearItems(UIGChooserItemType type); 124 void updateAll(const QString &strId); 126 125 UIGChooserItem* searchForItem(const QString &strSearchTag, int iItemSearchFlags); 127 126 UIGChooserItemMachine* firstMachineItem(); -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.cpp
r43616 r43617 588 588 { 589 589 /* Update machine-items with passed id: */ 590 updateMachineItems(strId, mainRoot());590 mainRoot()->updateAll(strId); 591 591 } 592 592 … … 594 594 { 595 595 /* Update machine-items with passed id: */ 596 updateMachineItems(strId, mainRoot());596 mainRoot()->updateAll(strId); 597 597 } 598 598 … … 640 640 { 641 641 /* Update machine-items with passed id: */ 642 updateMachineItems(strId, mainRoot());642 mainRoot()->updateAll(strId); 643 643 } 644 644 … … 646 646 { 647 647 /* Update machine-items with passed id: */ 648 updateMachineItems(strId, mainRoot());648 mainRoot()->updateAll(strId); 649 649 } 650 650 … … 1418 1418 unindentRoot(); 1419 1419 } 1420 }1421 1422 void UIGChooserModel::updateMachineItems(const QString &strId, UIGChooserItem *pParent)1423 {1424 /* For each group-item in passed parent: */1425 foreach (UIGChooserItem *pItem, pParent->items(UIGChooserItemType_Group))1426 updateMachineItems(strId, pItem->toGroupItem());1427 /* For each machine-item in passed parent: */1428 foreach (UIGChooserItem *pItem, pParent->items(UIGChooserItemType_Machine))1429 if (UIGChooserItemMachine *pMachineItem = pItem->toMachineItem())1430 if (pMachineItem->id() == strId)1431 {1432 /* Update machine-item: */1433 pMachineItem->recache();1434 pMachineItem->updateToolTip();1435 pMachineItem->update();1436 /* Update parent group-item: */1437 UIGChooserItemGroup *pParentGroupItem = pMachineItem->parentItem()->toGroupItem();1438 pParentGroupItem->updateToolTip();1439 pParentGroupItem->update();1440 }1441 1420 } 1442 1421 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.h
r43616 r43617 247 247 248 248 /* Helpers: Machine-item stuff: */ 249 void updateMachineItems(const QString &strId, UIGChooserItem *pParent);250 249 void removeMachineItems(const QString &strId, UIGChooserItem *pParent); 251 250 void removeItems(const QList<UIGChooserItem*> &itemsToRemove);
Note:
See TracChangeset
for help on using the changeset viewer.