VirtualBox

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


Ignore:
Timestamp:
Jan 3, 2018 6:05:20 PM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: Don't jump to the top of the VM list after deletion, pick something close by.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.cpp

    r69500 r70452  
    349349    /* Call for wrapper above: */
    350350    setCurrentItems(list);
     351}
     352
     353UIGChooserItem* UIGChooserModel::findClosestUnselectedItem() const
     354{
     355    /*
     356     * Take the focus item (if any) as a starting point and find
     357     * the closest non-selected item
     358     */
     359    UIGChooserItem *pItem = focusItem();
     360    if (!pItem)
     361        pItem = currentItem();
     362    if (pItem)
     363    {
     364        int idxBefore = navigationList().indexOf(pItem) - 1;
     365        int idxAfter  = idxBefore + 2;
     366        while(idxBefore >= 0 || idxAfter < navigationList().size())
     367        {
     368            if (idxBefore >= 0)
     369            {
     370                pItem = navigationList().at(idxBefore);
     371                if (!currentItems().contains(pItem))
     372                    return pItem;
     373                idxBefore--;
     374            }
     375            if (idxAfter < navigationList().size())
     376            {
     377                pItem = navigationList().at(idxAfter);
     378                if (!currentItems().contains(pItem))
     379                    return pItem;
     380                idxAfter++;
     381            }
     382        }
     383    }
     384    return 0;
    351385}
    352386
     
    15271561        return;
    15281562
    1529     /* Unset current item(s): */
    1530     unsetCurrentItem();
     1563    /* Change selection to some close by item: */
     1564    setCurrentItem(findClosestUnselectedItem());
    15311565
    15321566    /* For every selected item: */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.h

    r69500 r70452  
    120120    void addToCurrentItems(UIGChooserItem *pItem);
    121121    void removeFromCurrentItems(UIGChooserItem *pItem);
     122    UIGChooserItem* findClosestUnselectedItem() const;
    122123    void makeSureSomeItemIsSelected();
    123124    void notifyCurrentItemChanged();
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