VirtualBox

Ignore:
Timestamp:
Oct 21, 2020 2:21:40 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9653: VirtualBox Manager: Chooser pane: A shortcuts to call for profile and fake node search to make corresponding functions reusable.

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

Legend:

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

    r86664 r86665  
    718718{
    719719    /* Search for profile node: */
    720     const QString strProfileNodeName = QString("/%1/%2").arg(strProviderShortName, strProfileName);
    721     QList<UIChooserNode*> profileNodes;
    722     invisibleRoot()->searchForNodes(strProfileNodeName, UIChooserItemSearchFlag_CloudProfile | UIChooserItemSearchFlag_ExactId, profileNodes);
    723     UIChooserNode *pProfileNode = profileNodes.value(0);
     720    UIChooserNode *pProfileNode = searchProfileNode(strProviderShortName, strProfileName);
    724721    if (!pProfileNode)
    725722        return;
     
    738735{
    739736    /* Search for profile node: */
    740     const QString strProfileNodeName = QString("/%1/%2").arg(strProviderShortName, strProfileName);
    741     QList<UIChooserNode*> profileNodes;
    742     invisibleRoot()->searchForNodes(strProfileNodeName, UIChooserItemSearchFlag_CloudProfile | UIChooserItemSearchFlag_ExactId, profileNodes);
    743     UIChooserNode *pProfileNode = profileNodes.value(0);
     737    UIChooserNode *pProfileNode = searchProfileNode(strProviderShortName, strProfileName);
    744738    if (!pProfileNode)
    745739        return;
     
    759753{
    760754    /* Search for profile node: */
    761     const QString strProfileNodeName = QString("/%1/%2").arg(strProviderShortName, strProfileName);
    762     QList<UIChooserNode*> profileNodes;
    763     invisibleRoot()->searchForNodes(strProfileNodeName, UIChooserItemSearchFlag_CloudProfile | UIChooserItemSearchFlag_ExactId, profileNodes);
    764     UIChooserNode *pProfileNode = profileNodes.value(0);
     755    UIChooserNode *pProfileNode = searchProfileNode(strProviderShortName, strProfileName);
    765756    if (!pProfileNode)
    766757        return;
    767758
    768759    /* Add new machine-item: */
    769     addCloudMachineIntoTheTree(strProfileNodeName, comMachine, true /* make it visible? */);
    770 
    771     /* Search for possible fake node: */
    772     QList<UIChooserNode*> fakeNodes;
    773     pProfileNode->searchForNodes(QUuid().toString(), UIChooserItemSearchFlag_Machine | UIChooserItemSearchFlag_ExactId, fakeNodes);
     760    const QString strGroup = QString("/%1/%2").arg(strProviderShortName, strProfileName);
     761    addCloudMachineIntoTheTree(strGroup, comMachine, true /* make it visible? */);
     762
    774763    /* Delete fake node if present: */
    775     delete fakeNodes.value(0);
     764    delete searchFakeNode(pProfileNode);
    776765}
    777766
     
    781770{
    782771    /* Search for profile node: */
    783     const QString strProfileNodeName = QString("/%1/%2").arg(strProviderShortName, strProfileName);
    784     QList<UIChooserNode*> profileNodes;
    785     invisibleRoot()->searchForNodes(strProfileNodeName, UIChooserItemSearchFlag_CloudProfile | UIChooserItemSearchFlag_ExactId, profileNodes);
    786     UIChooserNode *pProfileNode = profileNodes.value(0);
     772    UIChooserNode *pProfileNode = searchProfileNode(strProviderShortName, strProfileName);
    787773    if (!pProfileNode)
    788774        return;
    789775
    790776    /* Add new machine-items: */
     777    const QString strGroup = QString("/%1/%2").arg(strProviderShortName, strProfileName);
    791778    foreach (const CCloudMachine &comMachine, machines)
    792         addCloudMachineIntoTheTree(strProfileNodeName, comMachine, false /* make it visible? */);
    793 
    794     /* Search for possible fake node: */
    795     QList<UIChooserNode*> fakeNodes;
    796     pProfileNode->searchForNodes(QUuid().toString(), UIChooserItemSearchFlag_Machine | UIChooserItemSearchFlag_ExactId, fakeNodes);
     779        addCloudMachineIntoTheTree(strGroup, comMachine, false /* make it visible? */);
     780
    797781    /* Delete fake node if present: */
    798     delete fakeNodes.value(0);
     782    delete searchFakeNode(pProfileNode);
    799783}
    800784
     
    807791    UITaskCloudListMachines *pAcquiringTask = qobject_cast<UITaskCloudListMachines*>(pTask);
    808792    AssertPtrReturnVoid(pAcquiringTask);
     793    const QString strProviderShortName = pAcquiringTask->providerShortName();
     794    const QString strProfileName = pAcquiringTask->profileName();
    809795
    810796    /* Search for profile node: */
    811     const QString strProfileNodeName = QString("/%1/%2").arg(pAcquiringTask->providerShortName(), pAcquiringTask->profileName());
    812     QList<UIChooserNode*> profileNodes;
    813     invisibleRoot()->searchForNodes(strProfileNodeName, UIChooserItemSearchFlag_CloudProfile | UIChooserItemSearchFlag_ExactId, profileNodes);
    814     UIChooserNode *pProfileNode = profileNodes.value(0);
     797    UIChooserNode *pProfileNode = searchProfileNode(strProviderShortName, strProfileName);
    815798    if (!pProfileNode)
    816799        return;
     
    847830    /* Remove unregistered cloud VM nodes: */
    848831    if (!unregisteredIDs.isEmpty())
    849         sltCloudMachinesUnregistered(pAcquiringTask->providerShortName(), pAcquiringTask->profileName(), unregisteredIDs.toList());
     832        sltCloudMachinesUnregistered(strProviderShortName, strProfileName, unregisteredIDs.toList());
    850833    /* Add registered cloud VM nodes: */
    851834    if (!registeredMachines.isEmpty())
    852         sltCloudMachinesRegistered(pAcquiringTask->providerShortName(), pAcquiringTask->profileName(), registeredMachines);
     835        sltCloudMachinesRegistered(strProviderShortName, strProfileName, registeredMachines);
    853836
    854837    /* Remove cloud account key from the list of keys currently being updated: */
    855     const UICloudAccountKey accountKey = qMakePair(pAcquiringTask->providerShortName(), pAcquiringTask->profileName());
     838    const UICloudAccountKey accountKey = qMakePair(strProviderShortName, strProfileName);
    856839    removeCloudAccountKey(accountKey);
    857840}
     
    16191602}
    16201603
     1604UIChooserNode *UIChooserAbstractModel::searchProfileNode(const QString &strProviderShortName, const QString &strProfileName)
     1605{
     1606    /* Compose profile node ID: */
     1607    const QString strProfileNodeId = QString("/%1/%2").arg(strProviderShortName, strProfileName);
     1608
     1609    /* Search for a list of nodes matching required ID: */
     1610    QList<UIChooserNode*> profileNodes;
     1611    invisibleRoot()->searchForNodes(strProfileNodeId, UIChooserItemSearchFlag_CloudProfile | UIChooserItemSearchFlag_ExactId, profileNodes);
     1612
     1613    /* Return 1st node if any: */
     1614    return profileNodes.value(0);
     1615}
     1616
     1617UIChooserNode *UIChooserAbstractModel::searchFakeNode(UIChooserNode *pProfileNode)
     1618{
     1619    /* Search for a list of nodes matching null ID: */
     1620    QList<UIChooserNode*> fakeNodes;
     1621    pProfileNode->searchForNodes(QUuid().toString(), UIChooserItemSearchFlag_Machine | UIChooserItemSearchFlag_ExactId, fakeNodes);
     1622
     1623    /* Return 1st node if any: */
     1624    return fakeNodes.value(0);
     1625}
     1626
    16211627
    16221628#include "UIChooserAbstractModel.moc"
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.h

    r86664 r86665  
    308308    /** @} */
    309309
     310    /** @name Cloud stuff.
     311      * @{ */
     312        /** Searches for profile node with passed @a strProviderShortName and @a strProfileName. */
     313        UIChooserNode *searchProfileNode(const QString &strProviderShortName, const QString &strProfileName);
     314        /** Searches for fake node under passed @a pProfileNode. */
     315        UIChooserNode *searchFakeNode(UIChooserNode *pProfileNode);
     316    /** @} */
     317
    310318    /** @name General stuff.
    311319      * @{ */
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