VirtualBox

Changeset 84400 in vbox for trunk/src


Ignore:
Timestamp:
May 20, 2020 1:44:57 PM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: ​bugref:9653: VirtualBox Manager: Chooser pane: Shortcut for groupType inside item as well; Adding a bit of assertion paranoia here and there across related stuff.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.cpp

    r84378 r84400  
    650650        AssertMsg(!strFirstSuffix.isEmpty(), ("Invalid group name!"));
    651651        /* Trying to get group node among our children: */
    652         foreach (UIChooserNode *pGroupNode, pParentNode->nodes(UIChooserNodeType_Group))
     652        foreach (UIChooserNode *pNode, pParentNode->nodes(UIChooserNodeType_Group))
    653653        {
    654             if (   pGroupNode->toGroupNode()->groupType() == UIChooserNodeGroupType_Local
    655                 && pGroupNode->name() == strSecondSubName)
     654            AssertPtrReturn(pNode, 0);
     655            UIChooserNodeGroup *pGroupNode = pNode->toGroupNode();
     656            AssertPtrReturn(pGroupNode, 0);
     657            if (   pGroupNode->groupType() == UIChooserNodeGroupType_Local
     658                && pNode->name() == strSecondSubName)
    656659            {
    657                 UIChooserNode *pFoundNode = getLocalGroupNode(strFirstSuffix, pGroupNode, fAllGroupsOpened);
     660                UIChooserNode *pFoundNode = getLocalGroupNode(strFirstSuffix, pNode, fAllGroupsOpened);
    658661                if (UIChooserNodeGroup *pFoundGroupNode = pFoundNode->toGroupNode())
    659662                    if (fAllGroupsOpened && pFoundGroupNode->isClosed())
     
    692695        AssertMsg(!strFirstSuffix.isEmpty(), ("Invalid group name!"));
    693696        /* Trying to get group node among our children: */
    694         foreach (UIChooserNode *pGroupNode, pParentNode->nodes(UIChooserNodeType_Group))
     697        foreach (UIChooserNode *pNode, pParentNode->nodes(UIChooserNodeType_Group))
    695698        {
    696             if (   pGroupNode->toGroupNode()->groupType() != UIChooserNodeGroupType_Local
    697                 && pGroupNode->name() == strSecondSubName)
     699            AssertPtrReturn(pNode, 0);
     700            UIChooserNodeGroup *pGroupNode = pNode->toGroupNode();
     701            AssertPtrReturn(pGroupNode, 0);
     702            if (   (   pGroupNode->groupType() == UIChooserNodeGroupType_Provider
     703                    || pGroupNode->groupType() == UIChooserNodeGroupType_Profile)
     704                && pNode->name() == strSecondSubName)
    698705            {
    699                 UIChooserNode *pFoundNode = getCloudGroupNode(strFirstSuffix, pGroupNode, fAllGroupsOpened);
     706                UIChooserNode *pFoundNode = getCloudGroupNode(strFirstSuffix, pNode, fAllGroupsOpened);
    700707                if (UIChooserNodeGroup *pFoundGroupNode = pFoundNode->toGroupNode())
    701708                    if (fAllGroupsOpened && pFoundGroupNode->isClosed())
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserDefs.h

    r84371 r84400  
    4242enum UIChooserNodeGroupType
    4343{
     44    UIChooserNodeGroupType_Invalid,
    4445    UIChooserNodeGroupType_Local,
    4546    UIChooserNodeGroupType_Provider,
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGroup.cpp

    r84371 r84400  
    9393{
    9494    return node() ? node()->toGroupNode() : 0;
     95}
     96
     97UIChooserNodeGroupType UIChooserItemGroup::groupType() const
     98{
     99    return nodeToGroupType() ? nodeToGroupType()->groupType() : UIChooserNodeGroupType_Invalid;
    95100}
    96101
     
    493498    /* Are we searching among group-items? */
    494499    if (   (   iItemSearchFlags & UIChooserItemSearchFlag_LocalGroup
    495             && nodeToGroupType()->groupType() == UIChooserNodeGroupType_Local)
     500            && groupType() == UIChooserNodeGroupType_Local)
    496501        || (   iItemSearchFlags & UIChooserItemSearchFlag_CloudProvider
    497             && nodeToGroupType()->groupType() == UIChooserNodeGroupType_Provider)
     502            && groupType() == UIChooserNodeGroupType_Provider)
    498503        || (   iItemSearchFlags & UIChooserItemSearchFlag_CloudProfile
    499             && nodeToGroupType()->groupType() == UIChooserNodeGroupType_Profile))
     504            && groupType() == UIChooserNodeGroupType_Profile))
    500505    {
    501506        /* Are we searching by the exact ID? */
     
    703708
    704709        /* For local items: */
    705         if (   nodeToGroupType()->groupType() == UIChooserNodeGroupType_Local
    706             && pGroupItem->nodeToGroupType()->groupType() == UIChooserNodeGroupType_Local)
     710        if (   groupType() == UIChooserNodeGroupType_Local
     711            && pGroupItem->groupType() == UIChooserNodeGroupType_Local)
    707712        {
    708713            /* Make sure passed machine isn't immutable within own group: */
     
    727732        /* For cloud items: */
    728733        else
    729         if (   nodeToGroupType()->groupType() == UIChooserNodeGroupType_Provider
    730             && pGroupItem->nodeToGroupType()->groupType() == UIChooserNodeGroupType_Profile)
     734        if (   groupType() == UIChooserNodeGroupType_Provider
     735            && pGroupItem->groupType() == UIChooserNodeGroupType_Profile)
    731736        {
    732737            /* Make sure passed item is ours: */
     
    745750
    746751        /* For local items: */
    747         if (   nodeToGroupType()->groupType() == UIChooserNodeGroupType_Local
     752        if (   groupType() == UIChooserNodeGroupType_Local
    748753            && pMachineItem->cacheType() == UIVirtualMachineItemType_Local)
    749754        {
     
    770775        /* For cloud items: */
    771776        else
    772         if (   nodeToGroupType()->groupType() == UIChooserNodeGroupType_Profile
     777        if (   groupType() == UIChooserNodeGroupType_Profile
    773778            && pMachineItem->cacheType() == UIVirtualMachineItemType_CloudReal)
    774779        {
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGroup.h

    r83924 r84400  
    7373        /** Returns group node reference. */
    7474        UIChooserNodeGroup *nodeToGroupType() const;
     75
     76        /** Returns group node type. */
     77        UIChooserNodeGroupType groupType() const;
    7578
    7679        /** Returns whether group is closed. */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp

    r84378 r84400  
    362362{
    363363    return    isSingleGroupSelected()
    364            && firstSelectedItem()->node()->toGroupNode()->groupType() == UIChooserNodeGroupType_Local;
     364           && firstSelectedItem()->toGroupItem()->groupType() == UIChooserNodeGroupType_Local;
    365365}
    366366
     
    368368{
    369369    return    isSingleGroupSelected()
    370            && firstSelectedItem()->node()->toGroupNode()->groupType() == UIChooserNodeGroupType_Profile;
     370           && firstSelectedItem()->toGroupItem()->groupType() == UIChooserNodeGroupType_Profile;
    371371}
    372372
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserNodeGroup.cpp

    r84378 r84400  
    120120            strNodePrefix = UIChooserAbstractModel::definitionOption(UIChooserAbstractModel::NodeDef_GroupPrefixProfile);
    121121            break;
     122        default:
     123            AssertFailedReturn(QString());
    122124    }
    123125    const QString strNodeOptionOpened = UIChooserAbstractModel::definitionOption(UIChooserAbstractModel::NodeDef_GroupOptionOpened);
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