VirtualBox

Changeset 83698 in vbox


Ignore:
Timestamp:
Apr 15, 2020 12:06:02 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
137204
Message:

FE/Qt: bugref:9653: VirtualBox Manager: Chooser pane: Cleanup for adding/removing node/item codeflow.

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

Legend:

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

    r83691 r83698  
    117117
    118118                /* Add machine into tree: */
    119                 addMachineIntoTheTree(comMachine);
     119                addLocalMachineIntoTheTree(comMachine);
    120120            }
    121121        }
     
    375375}
    376376
    377 void UIChooserAbstractModel::sltMachineRegistered(const QUuid &uMachineId, const bool fRegistered)
     377void UIChooserAbstractModel::sltLocalMachineRegistered(const QUuid &uMachineId, const bool fRegistered)
    378378{
    379379    /* Existing VM unregistered? */
     
    393393            /* Add new machine-item: */
    394394            const CMachine comMachine = uiCommon().virtualBox().FindMachine(uMachineId.toString());
    395             addMachineIntoTheTree(comMachine, true /* make it visible */);
     395            addLocalMachineIntoTheTree(comMachine, true /* make it visible */);
    396396        }
    397397    }
     
    422422        /* Add new machine-item: */
    423423        const CMachine comMachine = uiCommon().virtualBox().FindMachine(uMachineId.toString());
    424         addMachineIntoTheTree(comMachine, true /* make it visible */);
     424        addLocalMachineIntoTheTree(comMachine, true /* make it visible */);
    425425    }
    426426}
     
    525525            this, &UIChooserAbstractModel::sltMachineDataChanged);
    526526    connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigMachineRegistered,
    527             this, &UIChooserAbstractModel::sltMachineRegistered);
     527            this, &UIChooserAbstractModel::sltLocalMachineRegistered);
    528528    connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigSessionStateChange,
    529529            this, &UIChooserAbstractModel::sltSessionStateChanged);
     
    543543}
    544544
    545 void UIChooserAbstractModel::addMachineIntoTheTree(const CMachine &comMachine, bool fMakeItVisible /* = false */)
     545void UIChooserAbstractModel::addLocalMachineIntoTheTree(const CMachine &comMachine,
     546                                                        bool fMakeItVisible /* = false */)
    546547{
    547548    /* Make sure passed VM is not NULL: */
    548549    if (comMachine.isNull())
    549         LogRelFlow(("UIChooserModel: ERROR: Passed VM is NULL!\n"));
     550        LogRelFlow(("UIChooserModel: ERROR: Passed local VM is NULL!\n"));
    550551    AssertReturnVoid(!comMachine.isNull());
    551552
    552553    /* Which VM we are loading: */
    553     LogRelFlow(("UIChooserModel: Loading VM with ID={%s}...\n", toOldStyleUuid(comMachine.GetId()).toUtf8().constData()));
     554    const QUuid uMachineId = comMachine.GetId();
     555    LogRelFlow(("UIChooserModel: Loading local VM with ID={%s}...\n",
     556                toOldStyleUuid(uMachineId).toUtf8().constData()));
    554557    /* Is that machine accessible? */
    555558    if (comMachine.GetAccessible())
    556559    {
    557         /* VM is accessible: */
     560        /* Acquire VM name: */
    558561        const QString strName = comMachine.GetName();
    559         LogRelFlow(("UIChooserModel:  VM {%s} is accessible.\n", strName.toUtf8().constData()));
     562        LogRelFlow(("UIChooserModel:  Local VM {%s} is accessible.\n", strName.toUtf8().constData()));
    560563        /* Which groups passed machine attached to? */
    561564        const QVector<QString> groups = comMachine.GetGroups();
    562565        const QStringList groupList = groups.toList();
    563566        const QString strGroups = groupList.join(", ");
    564         LogRelFlow(("UIChooserModel:  VM {%s} has groups: {%s}.\n", strName.toUtf8().constData(),
    565                                                                     strGroups.toUtf8().constData()));
     567        LogRelFlow(("UIChooserModel:  Local VM {%s} has groups: {%s}.\n",
     568                    strName.toUtf8().constData(), strGroups.toUtf8().constData()));
    566569        foreach (QString strGroup, groups)
    567570        {
     
    570573                strGroup.truncate(strGroup.size() - 1);
    571574            /* Create machine-item with found group-item as parent: */
    572             LogRelFlow(("UIChooserModel:   Creating item for VM {%s} in group {%s}.\n", strName.toUtf8().constData(),
    573                                                                                         strGroup.toUtf8().constData()));
    574             createMachineNode(getGroupNode(strGroup, invisibleRoot(), fMakeItVisible), comMachine);
     575            LogRelFlow(("UIChooserModel:   Creating node for local VM {%s} in group {%s}.\n",
     576                        strName.toUtf8().constData(), strGroup.toUtf8().constData()));
     577            createLocalMachineNode(getLocalGroupNode(strGroup, invisibleRoot(), fMakeItVisible), comMachine);
    575578        }
    576579        /* Update group definitions: */
    577         m_groups[toOldStyleUuid(comMachine.GetId())] = groupList;
     580        m_groups[toOldStyleUuid(uMachineId)] = groupList;
    578581    }
    579582    /* Inaccessible machine: */
     
    581584    {
    582585        /* VM is accessible: */
    583         LogRelFlow(("UIChooserModel:  VM {%s} is inaccessible.\n", toOldStyleUuid(comMachine.GetId()).toUtf8().constData()));
     586        LogRelFlow(("UIChooserModel:  Local VM {%s} is inaccessible.\n",
     587                    toOldStyleUuid(uMachineId).toUtf8().constData()));
    584588        /* Create machine-item with main-root group-item as parent: */
    585         createMachineNode(invisibleRoot(), comMachine);
    586     }
    587 }
    588 
    589 UIChooserNode *UIChooserAbstractModel::getGroupNode(const QString &strName, UIChooserNode *pParentNode, bool fAllGroupsOpened)
     589        createLocalMachineNode(invisibleRoot(), comMachine);
     590    }
     591}
     592
     593UIChooserNode *UIChooserAbstractModel::getLocalGroupNode(const QString &strName, UIChooserNode *pParentNode, bool fAllGroupsOpened)
    590594{
    591595    /* Check passed stuff: */
     
    607611        foreach (UIChooserNode *pGroupNode, pParentNode->nodes(UIChooserNodeType_Group))
    608612        {
    609             if (pGroupNode->name() == strSecondSubName)
     613            if (   pGroupNode->toGroupNode()->groupType() == UIChooserNodeGroupType_Local
     614                && pGroupNode->name() == strSecondSubName)
    610615            {
    611                 UIChooserNode *pFoundNode = getGroupNode(strFirstSuffix, pGroupNode, fAllGroupsOpened);
     616                UIChooserNode *pFoundNode = getLocalGroupNode(strFirstSuffix, pGroupNode, fAllGroupsOpened);
    612617                if (UIChooserNodeGroup *pFoundGroupNode = pFoundNode->toGroupNode())
    613618                    if (fAllGroupsOpened && pFoundGroupNode->isClosed())
     
    626631                               UIChooserNodeGroupType_Local,
    627632                               fAllGroupsOpened || shouldGroupNodeBeOpened(pParentNode, strSecondSubName));
    628     return strSecondSuffix.isEmpty() ? pNewGroupNode : getGroupNode(strFirstSuffix, pNewGroupNode, fAllGroupsOpened);
     633    return strSecondSuffix.isEmpty() ? pNewGroupNode : getLocalGroupNode(strFirstSuffix, pNewGroupNode, fAllGroupsOpened);
    629634}
    630635
     
    787792}
    788793
    789 void UIChooserAbstractModel::createMachineNode(UIChooserNode *pParentNode, const CMachine &comMachine)
     794void UIChooserAbstractModel::createLocalMachineNode(UIChooserNode *pParentNode, const CMachine &comMachine)
    790795{
    791796    /* Create machine node: */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.h

    r83689 r83698  
    132132        /** Handles machine data change for machine with certain @a uMachineId. */
    133133        virtual void sltMachineDataChanged(const QUuid &uMachineId);
    134         /** Handles machine registering/unregistering for machine with certain @a uMachineId. */
    135         virtual void sltMachineRegistered(const QUuid &uMachineId, const bool fRegistered);
     134        /** Handles local machine registering/unregistering for machine with certain @a uMachineId. */
     135        virtual void sltLocalMachineRegistered(const QUuid &uMachineId, const bool fRegistered);
    136136        /** Handles session @a enmState change for machine with certain @a uMachineId. */
    137137        virtual void sltSessionStateChanged(const QUuid &uMachineId, const KSessionState enmState);
     
    174174    /** @name Children stuff.
    175175      * @{ */
    176         /** Adds machine item based on certain @a comMachine and optionally @a fMakeItVisible. */
    177         void addMachineIntoTheTree(const CMachine &comMachine, bool fMakeItVisible = false);
    178         /** Acquires group node, creates one if necessary.
     176        /** Adds local machine item based on certain @a comMachine and optionally @a fMakeItVisible. */
     177        void addLocalMachineIntoTheTree(const CMachine &comMachine, bool fMakeItVisible = false);
     178
     179        /** Acquires local group node, creates one if necessary.
    179180          * @param  strName           Brings the name of group we looking for.
    180181          * @param  pParentNode       Brings the parent we starting to look for a group from.
    181182          * @param  fAllGroupsOpened  Brings whether we should open all the groups till the required one. */
    182         UIChooserNode *getGroupNode(const QString &strName, UIChooserNode *pParentNode, bool fAllGroupsOpened);
     183        UIChooserNode *getLocalGroupNode(const QString &strName, UIChooserNode *pParentNode, bool fAllGroupsOpened);
     184
    183185        /** Returns whether group node with certain @a strName should be opened, searching starting from the passed @a pParentItem. */
    184186        bool shouldGroupNodeBeOpened(UIChooserNode *pParentNode, const QString &strName);
     
    195197        int getDefinedNodePosition(UIChooserNode *pParentNode, UIChooserNodeType enmType, const QString &strName);
    196198
    197         /** Creates machine node based on certain @a comMachine as a child of specified @a pParentNode. */
    198         void createMachineNode(UIChooserNode *pParentNode, const CMachine &comMachine);
     199        /** Creates local machine node based on certain @a comMachine as a child of specified @a pParentNode. */
     200        void createLocalMachineNode(UIChooserNode *pParentNode, const CMachine &comMachine);
    199201    /** @} */
    200202
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp

    r83691 r83698  
    653653}
    654654
    655 void UIChooserModel::sltMachineRegistered(const QUuid &uId, const bool fRegistered)
     655void UIChooserModel::sltLocalMachineRegistered(const QUuid &uId, const bool fRegistered)
    656656{
    657657    /* Call to base-class: */
    658     UIChooserAbstractModel::sltMachineRegistered(uId, fRegistered);
     658    UIChooserAbstractModel::sltLocalMachineRegistered(uId, fRegistered);
    659659
    660660    /* Existing VM unregistered? */
     
    689689
    690690            /* Select newly added item: */
    691             CMachine comMachine = uiCommon().virtualBox().FindMachine(uId.toString());
    692             setSelectedItem(root()->searchForItem(comMachine.GetName(),
    693                                                  UIChooserItemSearchFlag_Machine |
    694                                                  UIChooserItemSearchFlag_ExactName));
     691            setSelectedItem(root()->searchForItem(uId.toString(),
     692                                                  UIChooserItemSearchFlag_Machine |
     693                                                  UIChooserItemSearchFlag_ExactId));
    695694        }
    696695    }
     
    11671166    /* If we have something local to unregister: */
    11681167    if (!localMachinesToUnregister.isEmpty())
    1169         unregisterMachines(localMachinesToUnregister);
     1168        unregisterLocalMachines(localMachinesToUnregister);
    11701169}
    11711170
     
    16341633}
    16351634
    1636 void UIChooserModel::unregisterMachines(const QList<CMachine> &machines)
     1635void UIChooserModel::unregisterLocalMachines(const QList<CMachine> &machines)
    16371636{
    16381637    /* Confirm machine removal: */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.h

    r83683 r83698  
    247247    /** @name Main event handling stuff.
    248248      * @{ */
    249         /** Handles machine registering/unregistering for machine with certain @a uId. */
    250         virtual void sltMachineRegistered(const QUuid &uId, const bool fRegistered) /* override */;
     249        /** Handles local machine registering/unregistering for machine with certain @a uId. */
     250        virtual void sltLocalMachineRegistered(const QUuid &uId, const bool fRegistered) /* override */;
    251251    /** @} */
    252252
     
    363363        /** Removes machine @a items. */
    364364        void removeItems(const QList<UIChooserItem*> &items);
    365         /** Unregisters a list of virtual @a machines. */
    366         void unregisterMachines(const QList<CMachine> &machines);
     365        /** Unregisters a list of local virtual @a machines. */
     366        void unregisterLocalMachines(const QList<CMachine> &machines);
    367367
    368368        /** Processes drag move @a pEvent. */
Note: See TracChangeset for help on using the changeset viewer.

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