VirtualBox

Changeset 86605 in vbox


Ignore:
Timestamp:
Oct 16, 2020 1:40:05 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9653: VirtualBox Manager: Small code reordering for Chooser pane.

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

    r86573 r86605  
    636636}
    637637
    638 void UIChooserAbstractModel::sltCloudMachineRegistered(const QString &strProviderShortName, const QString &strProfileName,
    639                                                        const CCloudMachine &comMachine, bool fSelect)
    640 {
    641     /* Search for profile node: */
    642     const QString strProfileNodeName = QString("/%1/%2").arg(strProviderShortName, strProfileName);
    643     QList<UIChooserNode*> profileNodes;
    644     invisibleRoot()->searchForNodes(strProfileNodeName, UIChooserItemSearchFlag_CloudProfile | UIChooserItemSearchFlag_ExactId, profileNodes);
    645     AssertReturnVoid(!profileNodes.isEmpty());
    646     UIChooserNode *pProfileNode = profileNodes.first();
    647     AssertPtrReturnVoid(pProfileNode);
    648 
    649     /* Add new machine-item: */
    650     addCloudMachineIntoTheTree(strProfileNodeName, comMachine, fSelect);
    651 
    652     /* Search for possible fake node: */
    653     QList<UIChooserNode*> fakeNodes;
    654     pProfileNode->searchForNodes(QUuid().toString(), UIChooserItemSearchFlag_Machine | UIChooserItemSearchFlag_ExactId, fakeNodes);
    655     /* Delete fake node if present: */
    656     delete fakeNodes.value(0);
    657 }
    658 
    659 void UIChooserAbstractModel::sltCloudMachineRegistrationChanged(const QString &strProviderShortName, const QString &strProfileName,
    660                                                                 const QUuid &uMachineId, const bool fRegistered)
    661 {
    662     /* Search for profile node: */
    663     const QString strProfileNodeName = QString("/%1/%2").arg(strProviderShortName, strProfileName);
    664     QList<UIChooserNode*> profileNodes;
    665     invisibleRoot()->searchForNodes(strProfileNodeName, UIChooserItemSearchFlag_CloudProfile | UIChooserItemSearchFlag_ExactId, profileNodes);
    666     AssertReturnVoid(!profileNodes.isEmpty());
    667     UIChooserNode *pProfileNode = profileNodes.first();
    668     AssertPtrReturnVoid(pProfileNode);
    669 
    670     /* Existing VM unregistered? */
    671     if (!fRegistered)
    672     {
    673         /* Remove machine-items with passed id: */
    674         pProfileNode->removeAllNodes(uMachineId);
    675 
    676         /* If there are no items left: */
    677         if (pProfileNode->nodes(UIChooserNodeType_Machine).isEmpty())
    678         {
    679             /* Add fake cloud VM item: */
    680             new UIChooserNodeMachine(pProfileNode /* parent */,
    681                                      0 /* position */,
    682                                      UIFakeCloudVirtualMachineItemState_Done);
    683         }
    684     }
    685     /* New VM registered? */
    686     else
    687     {
    688         /* Add new machine-item: */
    689         const CCloudMachine comMachine = cloudMachineById(strProviderShortName, strProfileName, uMachineId);
    690         addCloudMachineIntoTheTree(strProfileNodeName, comMachine, true /* make it visible */);
    691 
    692         /* Search for possible fake node: */
    693         QList<UIChooserNode*> fakeNodes;
    694         pProfileNode->searchForNodes(QUuid().toString(), UIChooserItemSearchFlag_Machine | UIChooserItemSearchFlag_ExactId, fakeNodes);
    695         /* Delete fake node if present: */
    696         delete fakeNodes.value(0);
    697     }
    698 }
    699 
    700638void UIChooserAbstractModel::sltSessionStateChanged(const QUuid &uMachineId, const KSessionState)
    701639{
     
    751689    saveGroupSettings();
    752690    saveGroupDefinitions();
     691}
     692
     693void UIChooserAbstractModel::sltCloudMachineRegistered(const QString &strProviderShortName, const QString &strProfileName,
     694                                                       const CCloudMachine &comMachine, bool fSelect)
     695{
     696    /* Search for profile node: */
     697    const QString strProfileNodeName = QString("/%1/%2").arg(strProviderShortName, strProfileName);
     698    QList<UIChooserNode*> profileNodes;
     699    invisibleRoot()->searchForNodes(strProfileNodeName, UIChooserItemSearchFlag_CloudProfile | UIChooserItemSearchFlag_ExactId, profileNodes);
     700    AssertReturnVoid(!profileNodes.isEmpty());
     701    UIChooserNode *pProfileNode = profileNodes.first();
     702    AssertPtrReturnVoid(pProfileNode);
     703
     704    /* Add new machine-item: */
     705    addCloudMachineIntoTheTree(strProfileNodeName, comMachine, fSelect);
     706
     707    /* Search for possible fake node: */
     708    QList<UIChooserNode*> fakeNodes;
     709    pProfileNode->searchForNodes(QUuid().toString(), UIChooserItemSearchFlag_Machine | UIChooserItemSearchFlag_ExactId, fakeNodes);
     710    /* Delete fake node if present: */
     711    delete fakeNodes.value(0);
     712}
     713
     714void UIChooserAbstractModel::sltCloudMachineRegistrationChanged(const QString &strProviderShortName, const QString &strProfileName,
     715                                                                const QUuid &uMachineId, const bool fRegistered)
     716{
     717    /* Search for profile node: */
     718    const QString strProfileNodeName = QString("/%1/%2").arg(strProviderShortName, strProfileName);
     719    QList<UIChooserNode*> profileNodes;
     720    invisibleRoot()->searchForNodes(strProfileNodeName, UIChooserItemSearchFlag_CloudProfile | UIChooserItemSearchFlag_ExactId, profileNodes);
     721    AssertReturnVoid(!profileNodes.isEmpty());
     722    UIChooserNode *pProfileNode = profileNodes.first();
     723    AssertPtrReturnVoid(pProfileNode);
     724
     725    /* Existing VM unregistered? */
     726    if (!fRegistered)
     727    {
     728        /* Remove machine-items with passed id: */
     729        pProfileNode->removeAllNodes(uMachineId);
     730
     731        /* If there are no items left: */
     732        if (pProfileNode->nodes(UIChooserNodeType_Machine).isEmpty())
     733        {
     734            /* Add fake cloud VM item: */
     735            new UIChooserNodeMachine(pProfileNode /* parent */,
     736                                     0 /* position */,
     737                                     UIFakeCloudVirtualMachineItemState_Done);
     738        }
     739    }
     740    /* New VM registered? */
     741    else
     742    {
     743        /* Add new machine-item: */
     744        const CCloudMachine comMachine = cloudMachineById(strProviderShortName, strProfileName, uMachineId);
     745        addCloudMachineIntoTheTree(strProfileNodeName, comMachine, true /* make it visible */);
     746
     747        /* Search for possible fake node: */
     748        QList<UIChooserNode*> fakeNodes;
     749        pProfileNode->searchForNodes(QUuid().toString(), UIChooserItemSearchFlag_Machine | UIChooserItemSearchFlag_ExactId, fakeNodes);
     750        /* Delete fake node if present: */
     751        delete fakeNodes.value(0);
     752    }
    753753}
    754754
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.h

    r86573 r86605  
    145145        /** Handles local machine registering/unregistering for machine with certain @a uMachineId. */
    146146        virtual void sltLocalMachineRegistrationChanged(const QUuid &uMachineId, const bool fRegistered);
     147
     148        /** Handles session @a enmState change for machine with certain @a uMachineId. */
     149        virtual void sltSessionStateChanged(const QUuid &uMachineId, const KSessionState enmState);
     150
     151        /** Handles snapshot change for machine/snapshot with certain @a uMachineId / @a uSnapshotId. */
     152        virtual void sltSnapshotChanged(const QUuid &uMachineId, const QUuid &uSnapshotId);
     153
     154        /** Handles event about cloud provider with @a uProviderId being uninstalled. */
     155        virtual void sltHandleCloudProviderUninstall(const QUuid &uProviderId);
     156    /** @} */
     157
     158    /** @name Children stuff.
     159      * @{ */
     160        /** Handles reload machine with certain @a uMachineId request. */
     161        virtual void sltReloadMachine(const QUuid &uMachineId);
     162    /** @} */
     163
     164    /** @name Cloud stuff.
     165      * @{ */
    147166        /** Handles cloud machine registering for @a comMachine.
    148167          * @param  strProviderShortName  Brings provider short name.
     
    156175        virtual void sltCloudMachineRegistrationChanged(const QString &strProviderShortName, const QString &strProfileName,
    157176                                                        const QUuid &uMachineId, const bool fRegistered);
    158         /** Handles session @a enmState change for machine with certain @a uMachineId. */
    159         virtual void sltSessionStateChanged(const QUuid &uMachineId, const KSessionState enmState);
    160         /** Handles snapshot change for machine/snapshot with certain @a uMachineId / @a uSnapshotId. */
    161         virtual void sltSnapshotChanged(const QUuid &uMachineId, const QUuid &uSnapshotId);
    162         /** Handles event about cloud provider with @a uProviderId being uninstalled. */
    163         virtual void sltHandleCloudProviderUninstall(const QUuid &uProviderId);
    164     /** @} */
    165 
    166     /** @name Children stuff.
    167       * @{ */
    168         /** Handles reload machine with certain @a uMachineId request. */
    169         virtual void sltReloadMachine(const QUuid &uMachineId);
    170     /** @} */
    171 
    172     /** @name Cloud stuff.
    173       * @{ */
     177
    174178        /** Handles list cloud machines task complete signal. */
    175179        virtual void sltHandleCloudListMachinesTaskComplete(UITask *pTask);
     180
    176181        /** Handles Cloud Profile Manager cumulative change. */
    177182        virtual void sltHandleCloudProfileManagerCumulativeChange();
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp

    r86573 r86605  
    11111111}
    11121112
    1113 void UIChooserModel::sltCloudMachineRegistered(const QString &strProviderShortName, const QString &strProfileName,
    1114                                                const CCloudMachine &comMachine, bool fSelect)
    1115 {
     1113void UIChooserModel::sltHandleCloudProviderUninstall(const QUuid &uProviderId)
     1114{
     1115    /* Search for selected cloud machine items: */
     1116    foreach (UIVirtualMachineItem *pItem, selectedMachineItems())
     1117    {
     1118        /* Skip unrelated nodes: */
     1119        AssertPtrReturnVoid(pItem);
     1120        UIVirtualMachineItemCloud *pCloudItem = pItem->toCloud();
     1121        if (!pCloudItem)
     1122            continue;
     1123
     1124        /* Wait for cloud machine refresh task to complete: */
     1125        pCloudItem->waitForAsyncInfoUpdateFinished();
     1126    }
     1127
    11161128    /* Call to base-class: */
    1117     UIChooserAbstractModel::sltCloudMachineRegistered(strProviderShortName, strProfileName, comMachine, fSelect);
    1118 
    1119     /* Rebuild tree for main root: */
    1120     buildTreeForMainRoot(false /* preserve selection */);
    1121 
    1122     /* Select newly added item: */
    1123     if (fSelect)
    1124     {
    1125         QUuid uMachineId;
    1126         if (cloudMachineId(comMachine, uMachineId))
    1127             setSelectedItem(root()->searchForItem(uMachineId.toString(),
    1128                                                   UIChooserItemSearchFlag_Machine |
    1129                                                   UIChooserItemSearchFlag_ExactId));
    1130     }
    1131 }
    1132 
    1133 void UIChooserModel::sltCloudMachineRegistrationChanged(const QString &strProviderShortName, const QString &strProfileName,
    1134                                                         const QUuid &uMachineId, const bool fRegistered)
    1135 {
    1136     /* Existing VM unregistered => make sure no item with passed uMachineId is selected: */
    1137     if (!fRegistered)
    1138         makeSureNoItemWithCertainIdSelected(uMachineId);
    1139 
     1129    UIChooserAbstractModel::sltHandleCloudProviderUninstall(uProviderId);
     1130
     1131    /* Notify about selection invalidated: */
     1132    emit sigSelectionInvalidated();
     1133}
     1134
     1135void UIChooserModel::sltReloadMachine(const QUuid &uMachineId)
     1136{
    11401137    /* Call to base-class: */
    1141     UIChooserAbstractModel::sltCloudMachineRegistrationChanged(strProviderShortName, strProfileName, uMachineId, fRegistered);
    1142 
    1143     /* Existing VM unregistered? */
    1144     if (!fRegistered)
    1145     {
    1146         /* Rebuild tree for main root: */
    1147         buildTreeForMainRoot(true /* preserve selection */);
    1148     }
    1149     /* New VM registered? */
    1150     else
     1138    UIChooserAbstractModel::sltReloadMachine(uMachineId);
     1139
     1140    /* Should we show this VM? */
     1141    if (gEDataManager->showMachineInVirtualBoxManagerChooser(uMachineId))
    11511142    {
    11521143        /* Rebuild tree for main root: */
     
    11571148                                              UIChooserItemSearchFlag_ExactId));
    11581149    }
    1159 }
    1160 
    1161 void UIChooserModel::sltHandleCloudProviderUninstall(const QUuid &uProviderId)
    1162 {
    1163     /* Search for selected cloud machine items: */
    1164     foreach (UIVirtualMachineItem *pItem, selectedMachineItems())
    1165     {
    1166         /* Skip unrelated nodes: */
    1167         AssertPtrReturnVoid(pItem);
    1168         UIVirtualMachineItemCloud *pCloudItem = pItem->toCloud();
    1169         if (!pCloudItem)
    1170             continue;
    1171 
    1172         /* Wait for cloud machine refresh task to complete: */
    1173         pCloudItem->waitForAsyncInfoUpdateFinished();
    1174     }
    1175 
     1150    makeSureAtLeastOneItemSelected();
     1151
     1152    /* Notify listeners about selection change: */
     1153    emit sigSelectionChanged();
     1154}
     1155
     1156void UIChooserModel::sltCloudMachineRegistered(const QString &strProviderShortName, const QString &strProfileName,
     1157                                               const CCloudMachine &comMachine, bool fSelect)
     1158{
    11761159    /* Call to base-class: */
    1177     UIChooserAbstractModel::sltHandleCloudProviderUninstall(uProviderId);
    1178 
    1179     /* Notify about selection invalidated: */
    1180     emit sigSelectionInvalidated();
    1181 }
    1182 
    1183 void UIChooserModel::sltReloadMachine(const QUuid &uMachineId)
    1184 {
     1160    UIChooserAbstractModel::sltCloudMachineRegistered(strProviderShortName, strProfileName, comMachine, fSelect);
     1161
     1162    /* Rebuild tree for main root: */
     1163    buildTreeForMainRoot(false /* preserve selection */);
     1164
     1165    /* Select newly added item: */
     1166    if (fSelect)
     1167    {
     1168        QUuid uMachineId;
     1169        if (cloudMachineId(comMachine, uMachineId))
     1170            setSelectedItem(root()->searchForItem(uMachineId.toString(),
     1171                                                  UIChooserItemSearchFlag_Machine |
     1172                                                  UIChooserItemSearchFlag_ExactId));
     1173    }
     1174}
     1175
     1176void UIChooserModel::sltCloudMachineRegistrationChanged(const QString &strProviderShortName, const QString &strProfileName,
     1177                                                        const QUuid &uMachineId, const bool fRegistered)
     1178{
     1179    /* Existing VM unregistered => make sure no item with passed uMachineId is selected: */
     1180    if (!fRegistered)
     1181        makeSureNoItemWithCertainIdSelected(uMachineId);
     1182
    11851183    /* Call to base-class: */
    1186     UIChooserAbstractModel::sltReloadMachine(uMachineId);
    1187 
    1188     /* Should we show this VM? */
    1189     if (gEDataManager->showMachineInVirtualBoxManagerChooser(uMachineId))
     1184    UIChooserAbstractModel::sltCloudMachineRegistrationChanged(strProviderShortName, strProfileName, uMachineId, fRegistered);
     1185
     1186    /* Existing VM unregistered? */
     1187    if (!fRegistered)
     1188    {
     1189        /* Rebuild tree for main root: */
     1190        buildTreeForMainRoot(true /* preserve selection */);
     1191    }
     1192    /* New VM registered? */
     1193    else
    11901194    {
    11911195        /* Rebuild tree for main root: */
     
    11961200                                              UIChooserItemSearchFlag_ExactId));
    11971201    }
    1198     makeSureAtLeastOneItemSelected();
    1199 
    1200     /* Notify listeners about selection change: */
    1201     emit sigSelectionChanged();
    12021202}
    12031203
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.h

    r86573 r86605  
    263263        /** Handles local machine registering/unregistering for machine with certain @a uMachineId. */
    264264        virtual void sltLocalMachineRegistrationChanged(const QUuid &uMachineId, const bool fRegistered) /* override */;
     265
     266        /** Handles event about cloud provider with @a uProviderId being uninstalled. */
     267        virtual void sltHandleCloudProviderUninstall(const QUuid &uProviderId) /* override */;
     268    /** @} */
     269
     270    /** @name Children stuff.
     271      * @{ */
     272        /** Handles reload machine with certain @a uMachineId request. */
     273        virtual void sltReloadMachine(const QUuid &uMachineId) /* override */;
     274    /** @} */
     275
     276    /** @name Cloud stuff.
     277      * @{ */
    265278        /** Handles cloud machine registering for @a comMachine.
    266279          * @param  strProviderShortName  Brings provider short name.
     
    274287        virtual void sltCloudMachineRegistrationChanged(const QString &strProviderShortName, const QString &strProfileName,
    275288                                                        const QUuid &uMachineId, const bool fRegistered) /* override */;
    276         /** Handles event about cloud provider with @a uProviderId being uninstalled. */
    277         virtual void sltHandleCloudProviderUninstall(const QUuid &uProviderId) /* override */;
    278     /** @} */
    279 
    280     /** @name Children stuff.
    281       * @{ */
    282         /** Handles reload machine with certain @a uMachineId request. */
    283         virtual void sltReloadMachine(const QUuid &uMachineId) /* override */;
    284     /** @} */
    285 
    286     /** @name Cloud stuff.
    287       * @{ */
     289
    288290        /** Handles list cloud machines task complete signal. */
    289291        virtual void sltHandleCloudListMachinesTaskComplete(UITask *pTask) /* override */;
     292
    290293        /** Handles Cloud Profile Manager cumulative changes. */
    291294        virtual void sltHandleCloudProfileManagerCumulativeChange() /* override */;
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