- Timestamp:
- Oct 10, 2012 1:13:15 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.cpp
r43577 r43590 168 168 int iViewportWidth = viewportSize.width() - 2 * iSceneMargin; 169 169 int iViewportHeight = viewportSize.height() - 2 * iSceneMargin; 170 /* Set root 170 /* Set root-item position: */ 171 171 root()->setPos(iSceneMargin, iSceneMargin); 172 /* Set root 172 /* Set root-item size: */ 173 173 root()->resize(iViewportWidth, iViewportHeight); 174 /* Relayout root 174 /* Relayout root-item: */ 175 175 root()->updateLayout(); 176 /* Make sure root is shown: */176 /* Make sure root-item is shown: */ 177 177 root()->show(); 178 178 /* Notify listener about root-item relayouted: */ … … 198 198 void UIGChooserModel::updateNavigation() 199 199 { 200 /* Recreate navigation list: */201 200 clearNavigationList(); 202 201 m_navigationList = createNavigationList(root()); … … 211 210 QList<UIVMItem*> UIGChooserModel::currentMachineItems() const 212 211 { 213 /* Populate list of selected machine s: */212 /* Populate list of selected machine-items: */ 214 213 QList<UIVMItem*> currentMachineItemList; 215 214 enumerateCurrentItems(currentItems(), currentMachineItemList); … … 352 351 bool UIGChooserModel::isAllItemsOfOneGroupSelected() const 353 352 { 354 /* Make sure at least on item selected: */353 /* Make sure at least one item selected: */ 355 354 if (currentItems().isEmpty()) 356 355 return false; … … 359 358 UIGChooserItem *pFirstParent = currentItem()->parentItem(); 360 359 361 /* Make sure this parent is not main root 360 /* Make sure this parent is not main root-item: */ 362 361 if (pFirstParent == mainRoot()) 363 362 return false; … … 400 399 if (pOldFocusItem) 401 400 disconnect(pOldFocusItem, SIGNAL(destroyed(QObject*)), this, SLOT(sltFocusItemDestroyed())); 402 /* Connect new focus 401 /* Connect new focus-item (if any): */ 403 402 if (m_pFocusItem) 404 403 connect(m_pFocusItem, SIGNAL(destroyed(QObject*)), this, SLOT(sltFocusItemDestroyed())); … … 420 419 void UIGChooserModel::indentRoot(UIGChooserItem *pNewRootItem) 421 420 { 422 /* Do nothing i ssliding already: */421 /* Do nothing if sliding already: */ 423 422 if (m_fSliding) 424 423 return; … … 453 452 void UIGChooserModel::unindentRoot() 454 453 { 455 /* Do nothing i ssliding already: */454 /* Do nothing if sliding already: */ 456 455 if (m_fSliding) 457 456 return; … … 580 579 void UIGChooserModel::sltMachineStateChanged(QString strId, KMachineState) 581 580 { 582 /* Update machine 581 /* Update machine-items with passed id: */ 583 582 updateMachineItems(strId, mainRoot()); 584 583 } … … 586 585 void UIGChooserModel::sltMachineDataChanged(QString strId) 587 586 { 588 /* Update machine 587 /* Update machine-items with passed id: */ 589 588 updateMachineItems(strId, mainRoot()); 590 589 } … … 630 629 void UIGChooserModel::sltSessionStateChanged(QString strId, KSessionState) 631 630 { 632 /* Update machine 631 /* Update machine-items with passed id: */ 633 632 updateMachineItems(strId, mainRoot()); 634 633 } … … 636 635 void UIGChooserModel::sltSnapshotChanged(QString strId, QString) 637 636 { 638 /* Update machine 637 /* Update machine-items with passed id: */ 639 638 updateMachineItems(strId, mainRoot()); 640 639 } … … 764 763 { 765 764 /* Make sure focus item is of group type! */ 766 AssertMsg(focusItem()->type() == UIGChooserItemType_Group, ("This is not group 765 AssertMsg(focusItem()->type() == UIGChooserItemType_Group, ("This is not group-item!")); 767 766 768 767 /* Check if we have collisions with our siblings: */ … … 913 912 void UIGChooserModel::sltRemoveCurrentlySelectedMachine() 914 913 { 915 /* Enumerate all the selected machine 914 /* Enumerate all the selected machine-items: */ 916 915 QList<UIGChooserItem*> selectedMachineItemList = gatherMachineItems(currentItems()); 917 /* Enumerate all the existing machine 916 /* Enumerate all the existing machine-items: */ 918 917 QList<UIGChooserItem*> existingMachineItemList = gatherMachineItems(mainRoot()->items()); 919 918 … … 922 921 QMap<QString, QString> namesMap; 923 922 924 /* For each selected machine 923 /* For each selected machine-item: */ 925 924 foreach (UIGChooserItem *pItem, selectedMachineItemList) 926 925 { … … 1019 1018 void UIGChooserModel::sltCurrentDragObjectDestroyed() 1020 1019 { 1021 /* Reset drag tokens starting from the root item: */1022 1020 root()->resetDragToken(); 1023 1021 } … … 1083 1081 void UIGChooserModel::prepareContextMenu() 1084 1082 { 1085 /* Context menu for group : */1083 /* Context menu for group(s): */ 1086 1084 m_pContextMenuGroup = new QMenu; 1087 1085 m_pContextMenuGroup->addAction(gActionPool->action(UIActionIndexSelector_Simple_Group_New)); … … 1262 1260 return QObject::eventFilter(pWatched, pEvent); 1263 1261 1264 /* Process only item is focused by model, not by scene: */1262 /* Process only item focused by model: */ 1265 1263 if (scene()->focusItem()) 1266 1264 return QObject::eventFilter(pWatched, pEvent); … … 1281 1279 case QEvent::GraphicsSceneMouseDoubleClick: 1282 1280 return m_pMouseHandler->handle(static_cast<QGraphicsSceneMouseEvent*>(pEvent), UIMouseEventType_DoubleClick); 1283 /* Context menu: */1281 /* Context-menu handler: */ 1284 1282 case QEvent::GraphicsSceneContextMenu: 1285 1283 return processContextMenuEvent(static_cast<QGraphicsSceneContextMenuEvent*>(pEvent)); 1286 /* Improvised scroll event: */1284 /* Drag&drop scroll-event handler: */ 1287 1285 case QEvent::GraphicsSceneDragMove: 1288 1286 return processDragMoveEvent(static_cast<QGraphicsSceneDragDropEvent*>(pEvent)); … … 1298 1296 QList<UIGChooserItem*> navigationItems; 1299 1297 1300 /* Iterate over all the group 1298 /* Iterate over all the group-items: */ 1301 1299 foreach (UIGChooserItem *pGroupItem, pItem->items(UIGChooserItemType_Group)) 1302 1300 { … … 1305 1303 navigationItems << createNavigationList(pGroupItem); 1306 1304 } 1307 /* Iterate over all the machine 1305 /* Iterate over all the machine-items: */ 1308 1306 foreach (UIGChooserItem *pMachineItem, pItem->items(UIGChooserItemType_Machine)) 1309 1307 navigationItems << pMachineItem; … … 1318 1316 foreach (UIGChooserItem *pItem, list) 1319 1317 { 1320 /* If that is machine-item , just return it: */1318 /* If that is machine-item: */ 1321 1319 if (pItem->type() == UIGChooserItemType_Machine) 1322 1320 { … … 1374 1372 void UIGChooserModel::clearRealFocus() 1375 1373 { 1376 /* Set real focus to null: */1374 /* Set the real focus to null: */ 1377 1375 scene()->setFocusItem(0); 1378 1376 } … … 1418 1416 UIGChooserItem* UIGChooserModel::findGroupItem(const QString &strName, UIGChooserItem *pParent) 1419 1417 { 1420 /* Search among all the group 1418 /* Search among all the group-items of passed parent: */ 1421 1419 foreach (UIGChooserItem *pGroupItem, pParent->items(UIGChooserItemType_Group)) 1422 1420 if (pGroupItem->name() == strName) 1423 1421 return pGroupItem; 1424 /* Recursively iterate into each the group 1422 /* Recursively iterate into each the group-item of the passed parent: */ 1425 1423 foreach (UIGChooserItem *pGroupItem, pParent->items(UIGChooserItemType_Group)) 1426 1424 if (UIGChooserItem *pSubGroupItem = findGroupItem(strName, pGroupItem)) … … 1432 1430 void UIGChooserModel::cleanupGroupTree(UIGChooserItem *pGroupItem) 1433 1431 { 1434 /* Cleanup all the group 1432 /* Cleanup all the group-items first: */ 1435 1433 foreach (UIGChooserItem *pSubGroupItem, pGroupItem->items(UIGChooserItemType_Group)) 1436 1434 cleanupGroupTree(pSubGroupItem); … … 1440 1438 if (!pGroupItem->isRoot()) 1441 1439 delete pGroupItem; 1442 /* Unindent root 1440 /* Unindent root-items: */ 1443 1441 else if (root() != mainRoot()) 1444 1442 unindentRoot(); … … 1448 1446 UIGChooserItem* UIGChooserModel::findMachineItem(const QString &strName, UIGChooserItem *pParent) 1449 1447 { 1450 /* Search among all the machine 1448 /* Search among all the machine-items of passed parent: */ 1451 1449 foreach (UIGChooserItem *pMachineItem, pParent->items(UIGChooserItemType_Machine)) 1452 1450 if (pMachineItem->name() == strName) 1453 1451 return pMachineItem; 1454 /* Recursively iterate into each the group 1452 /* Recursively iterate into each the group-item of the passed parent: */ 1455 1453 foreach (UIGChooserItem *pGroupItem, pParent->items(UIGChooserItemType_Group)) 1456 1454 if (UIGChooserItem *pSubMachineItem = findMachineItem(strName, pGroupItem)) … … 1508 1506 void UIGChooserModel::sortItems(UIGChooserItem *pParent, bool fRecursively /* = false */) 1509 1507 { 1510 /* Sort group 1508 /* Sort group-items: */ 1511 1509 QMap<QString, UIGChooserItem*> sorter; 1512 1510 foreach (UIGChooserItem *pItem, pParent->items(UIGChooserItemType_Group)) … … 1518 1516 pParent->setItems(sorter.values(), UIGChooserItemType_Group); 1519 1517 1520 /* Sort machine 1518 /* Sort machine-items: */ 1521 1519 sorter.clear(); 1522 1520 foreach (UIGChooserItem *pItem, pParent->items(UIGChooserItemType_Machine)) … … 1531 1529 void UIGChooserModel::updateMachineItems(const QString &strId, UIGChooserItem *pParent) 1532 1530 { 1533 /* For each group 1531 /* For each group-item in passed parent: */ 1534 1532 foreach (UIGChooserItem *pItem, pParent->items(UIGChooserItemType_Group)) 1535 1533 updateMachineItems(strId, pItem->toGroupItem()); 1536 /* For each machine 1534 /* For each machine-item in passed parent: */ 1537 1535 foreach (UIGChooserItem *pItem, pParent->items(UIGChooserItemType_Machine)) 1538 1536 if (UIGChooserItemMachine *pMachineItem = pItem->toMachineItem()) 1539 1537 if (pMachineItem->id() == strId) 1540 1538 { 1541 /* Update machine 1539 /* Update machine-item: */ 1542 1540 pMachineItem->recache(); 1543 1541 pMachineItem->updateToolTip(); 1544 1542 pMachineItem->update(); 1545 /* Update parent group 1543 /* Update parent group-item: */ 1546 1544 UIGChooserItemGroup *pParentGroupItem = pMachineItem->parentItem()->toGroupItem(); 1547 1545 pParentGroupItem->updateToolTip(); … … 1552 1550 void UIGChooserModel::removeMachineItems(const QString &strId, UIGChooserItem *pParent) 1553 1551 { 1554 /* For each group 1552 /* For each group-item in passed parent: */ 1555 1553 foreach (UIGChooserItem *pItem, pParent->items(UIGChooserItemType_Group)) 1556 1554 removeMachineItems(strId, pItem->toGroupItem()); 1557 /* For each machine 1555 /* For each machine-item in passed parent: */ 1558 1556 foreach (UIGChooserItem *pItem, pParent->items(UIGChooserItemType_Machine)) 1559 1557 if (pItem->toMachineItem()->id() == strId) … … 1563 1561 void UIGChooserModel::removeMachineItems(const QStringList &names, QList<UIGChooserItem*> &selectedItems) 1564 1562 { 1565 /* Show machine 1563 /* Show machine-items remove dialog: */ 1566 1564 int rc = msgCenter().confirmMachineItemRemoval(names); 1567 1565 if (rc == QIMessageBox::Cancel) … … 1647 1645 case UIGChooserItemType_Group: 1648 1646 { 1649 /* Get group 1647 /* Get group-item: */ 1650 1648 UIGChooserItem *pGroupItem = qgraphicsitem_cast<UIGChooserItemGroup*>(pItem); 1651 1649 /* Make sure thats not root: */ 1652 1650 if (pGroupItem->isRoot()) 1653 1651 return false; 1654 /* Is this group 1652 /* Is this group-item only the one selected? */ 1655 1653 if (currentItems().contains(pGroupItem) && currentItems().size() == 1) 1656 1654 { … … 1682 1680 case UIGChooserItemType_Group: 1683 1681 { 1684 /* Is this group 1682 /* Is this group-item only the one selected? */ 1685 1683 if (currentItems().size() == 1) 1686 1684 { … … 1740 1738 QGraphicsView *pView = scene()->views()[0]; 1741 1739 1742 /* Check scroll 1740 /* Check scroll-area: */ 1743 1741 QPoint eventPoint = pView->mapFromGlobal(pEvent->screenPos()); 1744 1742 if ((eventPoint.y() < m_iScrollingTokenSize) || … … 1806 1804 if (strGroup.right(1) == "/") 1807 1805 strGroup.truncate(strGroup.size() - 1); 1808 /* Create machine item with found groupitem as parent: */1806 /* Create machine-item with found group-item as parent: */ 1809 1807 LogRel((" Creating item for VM {%s}, group {%s}.\n", strName.toAscii().constData(), 1810 1808 strGroup.toAscii().constData())); … … 1819 1817 /* VM is accessible: */ 1820 1818 LogRel((" VM {%s} is inaccessible.\n", machine.GetId().toAscii().constData())); 1821 /* Create machine item with main-root groupitem as parent: */1819 /* Create machine-item with main-root group-item as parent: */ 1822 1820 createMachineItem(machine, mainRoot()); 1823 1821 } … … 1841 1839 /* Make sure first-suffix is NOT empty: */ 1842 1840 AssertMsg(!strFirstSuffix.isEmpty(), ("Invalid group name!")); 1843 /* Trying to get group 1841 /* Trying to get group-item among our children: */ 1844 1842 foreach (UIGChooserItem *pGroupItem, pParentItem->items(UIGChooserItemType_Group)) 1845 1843 { … … 1861 1859 /* Should be new group opened when created? */ 1862 1860 fAllGroupsOpened || shouldBeGroupOpened(pParentItem, strSecondSubName), 1863 /* Which position new group 1861 /* Which position new group-item should be placed in? */ 1864 1862 getDesiredPosition(pParentItem, UIGChooserItemType_Group, strSecondSubName)); 1865 1863 return strSecondSuffix.isEmpty() ? pNewGroupItem : getGroupItem(strFirstSuffix, pNewGroupItem, fAllGroupsOpened); … … 1990 1988 new UIGChooserItemMachine(/* Parent item and corresponding machine: */ 1991 1989 pParentItem, machine, 1992 /* Which position new group 1990 /* Which position new group-item should be placed in? */ 1993 1991 getDesiredPosition(pParentItem, UIGChooserItemType_Machine, machine.GetId())); 1994 1992 } … … 2034 2032 UIGChooserItem *pParentGroup) 2035 2033 { 2036 /* Iterate over all the machine 2034 /* Iterate over all the machine-items: */ 2037 2035 foreach (UIGChooserItem *pItem, pParentGroup->items(UIGChooserItemType_Machine)) 2038 2036 if (UIGChooserItemMachine *pMachineItem = pItem->toMachineItem()) 2039 2037 if (pMachineItem->accessible()) 2040 2038 groups[pMachineItem->id()] << fullName(pParentGroup); 2041 /* Iterate over all the group 2039 /* Iterate over all the group-items: */ 2042 2040 foreach (UIGChooserItem *pItem, pParentGroup->items(UIGChooserItemType_Group)) 2043 2041 gatherGroupDefinitions(groups, pItem); … … 2049 2047 /* Prepare extra-data key for current group: */ 2050 2048 QString strExtraDataKey = UIDefs::GUI_GroupDefinitions + fullName(pParentItem); 2051 /* Iterate over all the group 2049 /* Iterate over all the group-items: */ 2052 2050 foreach (UIGChooserItem *pItem, pParentItem->items(UIGChooserItemType_Group)) 2053 2051 { … … 2056 2054 gatherGroupOrders(groups, pItem); 2057 2055 } 2058 /* Iterate over all the machine 2056 /* Iterate over all the machine-items: */ 2059 2057 foreach (UIGChooserItem *pItem, pParentItem->items(UIGChooserItemType_Machine)) 2060 2058 groups[strExtraDataKey] << QString("m=%1").arg(pItem->toMachineItem()->id());
Note:
See TracChangeset
for help on using the changeset viewer.