VirtualBox

Changeset 84567 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
May 27, 2020 2:41:06 PM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9653: VirtualBox Manager: Chooser pane: When unregistering some VM we should choose non-selected item only when unregistration event came, not instantly when user commanded to remove VM; First of all, this is required to handle removal initiated from other side, like VBoxManage; Besides that, there is a significant pause in-between otherwise.

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

Legend:

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

    r84565 r84567  
    437437}
    438438
     439void UIChooserModel::makeSureNoItemWithCertainIdIsSelected(const QUuid &uId)
     440{
     441    /* Look for all nodes with passed uId: */
     442    QList<UIChooserNode*> matchedNodes;
     443    invisibleRoot()->searchForNodes(uId.toString(),
     444                                    UIChooserItemSearchFlag_Machine |
     445                                    UIChooserItemSearchFlag_ExactId,
     446                                    matchedNodes);
     447
     448    /* Compose a set of items with passed uId: */
     449    QSet<UIChooserItem*> matchedItems;
     450    foreach (UIChooserNode *pNode, matchedNodes)
     451        if (pNode && pNode->item())
     452            matchedItems << pNode->item();
     453
     454    /* If we have at least one of those items currently selected: */
     455    if (selectedItems().toSet().intersects(matchedItems))
     456        setSelectedItem(findClosestUnselectedItem());
     457}
     458
    439459void UIChooserModel::setCurrentItem(UIChooserItem *pItem)
    440460{
     
    10491069void UIChooserModel::sltLocalMachineRegistered(const QUuid &uId, const bool fRegistered)
    10501070{
     1071    /* Make sure no item with passed uId is selected: */
     1072    if (!fRegistered)
     1073        makeSureNoItemWithCertainIdIsSelected(uId);
     1074
    10511075    /* Call to base-class: */
    10521076    UIChooserAbstractModel::sltLocalMachineRegistered(uId, fRegistered);
     
    10781102                                               const QUuid &uId, const bool fRegistered)
    10791103{
     1104    /* Make sure no item with passed uId is selected: */
     1105    if (!fRegistered)
     1106        makeSureNoItemWithCertainIdIsSelected(uId);
     1107
    10801108    /* Call to base-class: */
    10811109    UIChooserAbstractModel::sltCloudMachineRegistered(strProviderName, strProfileName, uId, fRegistered);
     
    15981626        return;
    15991627
    1600     /* Change selection to some close by item: */
    1601     setSelectedItem(findClosestUnselectedItem());
    1602 
    16031628    /* For every selected machine: */
    16041629    foreach (CMachine comMachine, machines)
     
    16531678    if (iResultCode == AlertButton_Cancel)
    16541679        return;
    1655 
    1656     /* Change selection to some close by item: */
    1657     setSelectedItem(findClosestUnselectedItem());
    16581680
    16591681    /* For every selected machine: */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.h

    r84542 r84567  
    180180        /** Finds closest non-selected-item. */
    181181        UIChooserItem *findClosestUnselectedItem() const;
     182        /** Makes sure selection doesn't contain item with certain @a uId. */
     183        void makeSureNoItemWithCertainIdIsSelected(const QUuid &uId);
    182184
    183185        /** Defines current @a pItem. */
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