VirtualBox

Changeset 43590 in vbox for trunk


Ignore:
Timestamp:
Oct 10, 2012 1:13:15 PM (12 years ago)
Author:
vboxsync
Message:

FE/Qt: VM group feature UI: Few comments cleanup.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.cpp

    r43577 r43590  
    168168    int iViewportWidth = viewportSize.width() - 2 * iSceneMargin;
    169169    int iViewportHeight = viewportSize.height() - 2 * iSceneMargin;
    170     /* Set root item position: */
     170    /* Set root-item position: */
    171171    root()->setPos(iSceneMargin, iSceneMargin);
    172     /* Set root item size: */
     172    /* Set root-item size: */
    173173    root()->resize(iViewportWidth, iViewportHeight);
    174     /* Relayout root item: */
     174    /* Relayout root-item: */
    175175    root()->updateLayout();
    176     /* Make sure root is shown: */
     176    /* Make sure root-item is shown: */
    177177    root()->show();
    178178    /* Notify listener about root-item relayouted: */
     
    198198void UIGChooserModel::updateNavigation()
    199199{
    200     /* Recreate navigation list: */
    201200    clearNavigationList();
    202201    m_navigationList = createNavigationList(root());
     
    211210QList<UIVMItem*> UIGChooserModel::currentMachineItems() const
    212211{
    213     /* Populate list of selected machines: */
     212    /* Populate list of selected machine-items: */
    214213    QList<UIVMItem*> currentMachineItemList;
    215214    enumerateCurrentItems(currentItems(), currentMachineItemList);
     
    352351bool UIGChooserModel::isAllItemsOfOneGroupSelected() const
    353352{
    354     /* Make sure at least on item selected: */
     353    /* Make sure at least one item selected: */
    355354    if (currentItems().isEmpty())
    356355        return false;
     
    359358    UIGChooserItem *pFirstParent = currentItem()->parentItem();
    360359
    361     /* Make sure this parent is not main root item: */
     360    /* Make sure this parent is not main root-item: */
    362361    if (pFirstParent == mainRoot())
    363362        return false;
     
    400399    if (pOldFocusItem)
    401400        disconnect(pOldFocusItem, SIGNAL(destroyed(QObject*)), this, SLOT(sltFocusItemDestroyed()));
    402     /* Connect new focus item (if any): */
     401    /* Connect new focus-item (if any): */
    403402    if (m_pFocusItem)
    404403        connect(m_pFocusItem, SIGNAL(destroyed(QObject*)), this, SLOT(sltFocusItemDestroyed()));
     
    420419void UIGChooserModel::indentRoot(UIGChooserItem *pNewRootItem)
    421420{
    422     /* Do nothing is sliding already: */
     421    /* Do nothing if sliding already: */
    423422    if (m_fSliding)
    424423        return;
     
    453452void UIGChooserModel::unindentRoot()
    454453{
    455     /* Do nothing is sliding already: */
     454    /* Do nothing if sliding already: */
    456455    if (m_fSliding)
    457456        return;
     
    580579void UIGChooserModel::sltMachineStateChanged(QString strId, KMachineState)
    581580{
    582     /* Update machine items with passed id: */
     581    /* Update machine-items with passed id: */
    583582    updateMachineItems(strId, mainRoot());
    584583}
     
    586585void UIGChooserModel::sltMachineDataChanged(QString strId)
    587586{
    588     /* Update machine items with passed id: */
     587    /* Update machine-items with passed id: */
    589588    updateMachineItems(strId, mainRoot());
    590589}
     
    630629void UIGChooserModel::sltSessionStateChanged(QString strId, KSessionState)
    631630{
    632     /* Update machine items with passed id: */
     631    /* Update machine-items with passed id: */
    633632    updateMachineItems(strId, mainRoot());
    634633}
     
    636635void UIGChooserModel::sltSnapshotChanged(QString strId, QString)
    637636{
    638     /* Update machine items with passed id: */
     637    /* Update machine-items with passed id: */
    639638    updateMachineItems(strId, mainRoot());
    640639}
     
    764763{
    765764    /* Make sure focus item is of group type! */
    766     AssertMsg(focusItem()->type() == UIGChooserItemType_Group, ("This is not group item!"));
     765    AssertMsg(focusItem()->type() == UIGChooserItemType_Group, ("This is not group-item!"));
    767766
    768767    /* Check if we have collisions with our siblings: */
     
    913912void UIGChooserModel::sltRemoveCurrentlySelectedMachine()
    914913{
    915     /* Enumerate all the selected machine items: */
     914    /* Enumerate all the selected machine-items: */
    916915    QList<UIGChooserItem*> selectedMachineItemList = gatherMachineItems(currentItems());
    917     /* Enumerate all the existing machine items: */
     916    /* Enumerate all the existing machine-items: */
    918917    QList<UIGChooserItem*> existingMachineItemList = gatherMachineItems(mainRoot()->items());
    919918
     
    922921    QMap<QString, QString> namesMap;
    923922
    924     /* For each selected machine item: */
     923    /* For each selected machine-item: */
    925924    foreach (UIGChooserItem *pItem, selectedMachineItemList)
    926925    {
     
    10191018void UIGChooserModel::sltCurrentDragObjectDestroyed()
    10201019{
    1021     /* Reset drag tokens starting from the root item: */
    10221020    root()->resetDragToken();
    10231021}
     
    10831081void UIGChooserModel::prepareContextMenu()
    10841082{
    1085     /* Context menu for group: */
     1083    /* Context menu for group(s): */
    10861084    m_pContextMenuGroup = new QMenu;
    10871085    m_pContextMenuGroup->addAction(gActionPool->action(UIActionIndexSelector_Simple_Group_New));
     
    12621260        return QObject::eventFilter(pWatched, pEvent);
    12631261
    1264     /* Process only item is focused by model, not by scene: */
     1262    /* Process only item focused by model: */
    12651263    if (scene()->focusItem())
    12661264        return QObject::eventFilter(pWatched, pEvent);
     
    12811279        case QEvent::GraphicsSceneMouseDoubleClick:
    12821280            return m_pMouseHandler->handle(static_cast<QGraphicsSceneMouseEvent*>(pEvent), UIMouseEventType_DoubleClick);
    1283         /* Context menu: */
     1281        /* Context-menu handler: */
    12841282        case QEvent::GraphicsSceneContextMenu:
    12851283            return processContextMenuEvent(static_cast<QGraphicsSceneContextMenuEvent*>(pEvent));
    1286         /* Improvised scroll event: */
     1284        /* Drag&drop scroll-event handler: */
    12871285        case QEvent::GraphicsSceneDragMove:
    12881286            return processDragMoveEvent(static_cast<QGraphicsSceneDragDropEvent*>(pEvent));
     
    12981296    QList<UIGChooserItem*> navigationItems;
    12991297
    1300     /* Iterate over all the group items: */
     1298    /* Iterate over all the group-items: */
    13011299    foreach (UIGChooserItem *pGroupItem, pItem->items(UIGChooserItemType_Group))
    13021300    {
     
    13051303            navigationItems << createNavigationList(pGroupItem);
    13061304    }
    1307     /* Iterate over all the machine items: */
     1305    /* Iterate over all the machine-items: */
    13081306    foreach (UIGChooserItem *pMachineItem, pItem->items(UIGChooserItemType_Machine))
    13091307        navigationItems << pMachineItem;
     
    13181316    foreach (UIGChooserItem *pItem, list)
    13191317    {
    1320         /* If that is machine-item, just return it: */
     1318        /* If that is machine-item: */
    13211319        if (pItem->type() == UIGChooserItemType_Machine)
    13221320        {
     
    13741372void UIGChooserModel::clearRealFocus()
    13751373{
    1376     /* Set real focus to null: */
     1374    /* Set the real focus to null: */
    13771375    scene()->setFocusItem(0);
    13781376}
     
    14181416UIGChooserItem* UIGChooserModel::findGroupItem(const QString &strName, UIGChooserItem *pParent)
    14191417{
    1420     /* Search among all the group items of passed parent: */
     1418    /* Search among all the group-items of passed parent: */
    14211419    foreach (UIGChooserItem *pGroupItem, pParent->items(UIGChooserItemType_Group))
    14221420        if (pGroupItem->name() == strName)
    14231421            return pGroupItem;
    1424     /* Recursively iterate into each the group item of the passed parent: */
     1422    /* Recursively iterate into each the group-item of the passed parent: */
    14251423    foreach (UIGChooserItem *pGroupItem, pParent->items(UIGChooserItemType_Group))
    14261424        if (UIGChooserItem *pSubGroupItem = findGroupItem(strName, pGroupItem))
     
    14321430void UIGChooserModel::cleanupGroupTree(UIGChooserItem *pGroupItem)
    14331431{
    1434     /* Cleanup all the group items first: */
     1432    /* Cleanup all the group-items first: */
    14351433    foreach (UIGChooserItem *pSubGroupItem, pGroupItem->items(UIGChooserItemType_Group))
    14361434        cleanupGroupTree(pSubGroupItem);
     
    14401438        if (!pGroupItem->isRoot())
    14411439            delete pGroupItem;
    1442         /* Unindent root items: */
     1440        /* Unindent root-items: */
    14431441        else if (root() != mainRoot())
    14441442            unindentRoot();
     
    14481446UIGChooserItem* UIGChooserModel::findMachineItem(const QString &strName, UIGChooserItem *pParent)
    14491447{
    1450     /* Search among all the machine items of passed parent: */
     1448    /* Search among all the machine-items of passed parent: */
    14511449    foreach (UIGChooserItem *pMachineItem, pParent->items(UIGChooserItemType_Machine))
    14521450        if (pMachineItem->name() == strName)
    14531451            return pMachineItem;
    1454     /* Recursively iterate into each the group item of the passed parent: */
     1452    /* Recursively iterate into each the group-item of the passed parent: */
    14551453    foreach (UIGChooserItem *pGroupItem, pParent->items(UIGChooserItemType_Group))
    14561454        if (UIGChooserItem *pSubMachineItem = findMachineItem(strName, pGroupItem))
     
    15081506void UIGChooserModel::sortItems(UIGChooserItem *pParent, bool fRecursively /* = false */)
    15091507{
    1510     /* Sort group items: */
     1508    /* Sort group-items: */
    15111509    QMap<QString, UIGChooserItem*> sorter;
    15121510    foreach (UIGChooserItem *pItem, pParent->items(UIGChooserItemType_Group))
     
    15181516    pParent->setItems(sorter.values(), UIGChooserItemType_Group);
    15191517
    1520     /* Sort machine items: */
     1518    /* Sort machine-items: */
    15211519    sorter.clear();
    15221520    foreach (UIGChooserItem *pItem, pParent->items(UIGChooserItemType_Machine))
     
    15311529void UIGChooserModel::updateMachineItems(const QString &strId, UIGChooserItem *pParent)
    15321530{
    1533     /* For each group item in passed parent: */
     1531    /* For each group-item in passed parent: */
    15341532    foreach (UIGChooserItem *pItem, pParent->items(UIGChooserItemType_Group))
    15351533        updateMachineItems(strId, pItem->toGroupItem());
    1536     /* For each machine item in passed parent: */
     1534    /* For each machine-item in passed parent: */
    15371535    foreach (UIGChooserItem *pItem, pParent->items(UIGChooserItemType_Machine))
    15381536        if (UIGChooserItemMachine *pMachineItem = pItem->toMachineItem())
    15391537            if (pMachineItem->id() == strId)
    15401538            {
    1541                 /* Update machine item: */
     1539                /* Update machine-item: */
    15421540                pMachineItem->recache();
    15431541                pMachineItem->updateToolTip();
    15441542                pMachineItem->update();
    1545                 /* Update parent group item: */
     1543                /* Update parent group-item: */
    15461544                UIGChooserItemGroup *pParentGroupItem = pMachineItem->parentItem()->toGroupItem();
    15471545                pParentGroupItem->updateToolTip();
     
    15521550void UIGChooserModel::removeMachineItems(const QString &strId, UIGChooserItem *pParent)
    15531551{
    1554     /* For each group item in passed parent: */
     1552    /* For each group-item in passed parent: */
    15551553    foreach (UIGChooserItem *pItem, pParent->items(UIGChooserItemType_Group))
    15561554        removeMachineItems(strId, pItem->toGroupItem());
    1557     /* For each machine item in passed parent: */
     1555    /* For each machine-item in passed parent: */
    15581556    foreach (UIGChooserItem *pItem, pParent->items(UIGChooserItemType_Machine))
    15591557        if (pItem->toMachineItem()->id() == strId)
     
    15631561void UIGChooserModel::removeMachineItems(const QStringList &names, QList<UIGChooserItem*> &selectedItems)
    15641562{
    1565     /* Show machine items remove dialog: */
     1563    /* Show machine-items remove dialog: */
    15661564    int rc = msgCenter().confirmMachineItemRemoval(names);
    15671565    if (rc == QIMessageBox::Cancel)
     
    16471645                    case UIGChooserItemType_Group:
    16481646                    {
    1649                         /* Get group item: */
     1647                        /* Get group-item: */
    16501648                        UIGChooserItem *pGroupItem = qgraphicsitem_cast<UIGChooserItemGroup*>(pItem);
    16511649                        /* Make sure thats not root: */
    16521650                        if (pGroupItem->isRoot())
    16531651                            return false;
    1654                         /* Is this group item only the one selected? */
     1652                        /* Is this group-item only the one selected? */
    16551653                        if (currentItems().contains(pGroupItem) && currentItems().size() == 1)
    16561654                        {
     
    16821680                    case UIGChooserItemType_Group:
    16831681                    {
    1684                         /* Is this group item only the one selected? */
     1682                        /* Is this group-item only the one selected? */
    16851683                        if (currentItems().size() == 1)
    16861684                        {
     
    17401738    QGraphicsView *pView = scene()->views()[0];
    17411739
    1742     /* Check scroll area: */
     1740    /* Check scroll-area: */
    17431741    QPoint eventPoint = pView->mapFromGlobal(pEvent->screenPos());
    17441742    if ((eventPoint.y() < m_iScrollingTokenSize) ||
     
    18061804            if (strGroup.right(1) == "/")
    18071805                strGroup.truncate(strGroup.size() - 1);
    1808             /* Create machine item with found group item as parent: */
     1806            /* Create machine-item with found group-item as parent: */
    18091807            LogRel(("  Creating item for VM {%s}, group {%s}.\n", strName.toAscii().constData(),
    18101808                                                                  strGroup.toAscii().constData()));
     
    18191817        /* VM is accessible: */
    18201818        LogRel((" VM {%s} is inaccessible.\n", machine.GetId().toAscii().constData()));
    1821         /* Create machine item with main-root group item as parent: */
     1819        /* Create machine-item with main-root group-item as parent: */
    18221820        createMachineItem(machine, mainRoot());
    18231821    }
     
    18411839        /* Make sure first-suffix is NOT empty: */
    18421840        AssertMsg(!strFirstSuffix.isEmpty(), ("Invalid group name!"));
    1843         /* Trying to get group item among our children: */
     1841        /* Trying to get group-item among our children: */
    18441842        foreach (UIGChooserItem *pGroupItem, pParentItem->items(UIGChooserItemType_Group))
    18451843        {
     
    18611859                                    /* Should be new group opened when created? */
    18621860                                    fAllGroupsOpened || shouldBeGroupOpened(pParentItem, strSecondSubName),
    1863                                     /* Which position new group item should be placed in? */
     1861                                    /* Which position new group-item should be placed in? */
    18641862                                    getDesiredPosition(pParentItem, UIGChooserItemType_Group, strSecondSubName));
    18651863    return strSecondSuffix.isEmpty() ? pNewGroupItem : getGroupItem(strFirstSuffix, pNewGroupItem, fAllGroupsOpened);
     
    19901988    new UIGChooserItemMachine(/* Parent item and corresponding machine: */
    19911989                              pParentItem, machine,
    1992                               /* Which position new group item should be placed in? */
     1990                              /* Which position new group-item should be placed in? */
    19931991                              getDesiredPosition(pParentItem, UIGChooserItemType_Machine, machine.GetId()));
    19941992}
     
    20342032                                             UIGChooserItem *pParentGroup)
    20352033{
    2036     /* Iterate over all the machine items: */
     2034    /* Iterate over all the machine-items: */
    20372035    foreach (UIGChooserItem *pItem, pParentGroup->items(UIGChooserItemType_Machine))
    20382036        if (UIGChooserItemMachine *pMachineItem = pItem->toMachineItem())
    20392037            if (pMachineItem->accessible())
    20402038                groups[pMachineItem->id()] << fullName(pParentGroup);
    2041     /* Iterate over all the group items: */
     2039    /* Iterate over all the group-items: */
    20422040    foreach (UIGChooserItem *pItem, pParentGroup->items(UIGChooserItemType_Group))
    20432041        gatherGroupDefinitions(groups, pItem);
     
    20492047    /* Prepare extra-data key for current group: */
    20502048    QString strExtraDataKey = UIDefs::GUI_GroupDefinitions + fullName(pParentItem);
    2051     /* Iterate over all the group items: */
     2049    /* Iterate over all the group-items: */
    20522050    foreach (UIGChooserItem *pItem, pParentItem->items(UIGChooserItemType_Group))
    20532051    {
     
    20562054        gatherGroupOrders(groups, pItem);
    20572055    }
    2058     /* Iterate over all the machine items: */
     2056    /* Iterate over all the machine-items: */
    20592057    foreach (UIGChooserItem *pItem, pParentItem->items(UIGChooserItemType_Machine))
    20602058        groups[strExtraDataKey] << QString("m=%1").arg(pItem->toMachineItem()->id());
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette