VirtualBox

Changeset 43155 in vbox


Ignore:
Timestamp:
Sep 3, 2012 8:54:57 PM (12 years ago)
Author:
vboxsync
Message:

FE/Qt: VM selector UI: Implement refresh-VM functionality.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/selector
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp

    r43005 r43155  
    707707}
    708708
    709 void UISelectorWindow::sltPerformRefreshAction()
    710 {
    711     /* Get selected items: */
    712     QList<UIVMItem*> items = currentItems();
    713     AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n"));
    714 
    715     // TODO: Notify selector-model to refresh selected items!
    716 
    717     /* Refresh details: */
    718     sltCurrentVMItemChanged();
    719 }
    720 
    721709void UISelectorWindow::sltShowLogDialog()
    722710{
     
    14051393    connect(m_pAction_Common_Reset, SIGNAL(triggered()), this, SLOT(sltPerformResetAction()));
    14061394    connect(m_pAction_Common_Discard, SIGNAL(triggered()), this, SLOT(sltPerformDiscardAction()));
    1407     connect(m_pAction_Common_Refresh, SIGNAL(triggered()), this, SLOT(sltPerformRefreshAction()));
    14081395    connect(m_pAction_Common_ShowInFileManager, SIGNAL(triggered()), this, SLOT(sltShowMachineInFileManager()));
    14091396    connect(m_pAction_Common_CreateShortcut, SIGNAL(triggered()), this, SLOT(sltPerformCreateShortcutAction()));
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.h

    r42853 r43155  
    9696    void sltPerformACPIShutdownAction();
    9797    void sltPerformPowerOffAction();
    98     void sltPerformRefreshAction();
    9998    void sltShowLogDialog();
    10099    void sltShowMachineInFileManager();
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.cpp

    r43007 r43155  
    964964}
    965965
     966void UIGChooserModel::sltPerformRefreshAction()
     967{
     968    /* Gather list of chosen inaccessible VMs: */
     969    QList<UIGChooserItem*> inaccessibleItems;
     970    enumerateInaccessibleItems(selectionList(), inaccessibleItems);
     971
     972    /* For each inaccessible item: */
     973    UIGChooserItem *pSelectedItem = 0;
     974    foreach (UIGChooserItem *pItem, inaccessibleItems)
     975        if (UIGChooserItemMachine *pMachineItem = pItem->toMachineItem())
     976        {
     977            /* Recache: */
     978            pMachineItem->recache();
     979            /* Become accessible? */
     980            if (pMachineItem->accessible())
     981            {
     982                /* Machine name: */
     983                QString strMachineName = pMachineItem->name();
     984                /* We should reload this machine: */
     985                sltReloadMachine(pMachineItem->id());
     986                /* Select first of reloaded items: */
     987                if (!pSelectedItem)
     988                    pSelectedItem = findMachineItem(strMachineName, mainRoot());
     989            }
     990        }
     991    /* Some item to be selected? */
     992    if (pSelectedItem)
     993    {
     994        pSelectedItem->makeSureItsVisible();
     995        setCurrentItem(pSelectedItem);
     996    }
     997}
     998
    966999void UIGChooserModel::sltSortParentGroup()
    9671000{
     
    11101143    connect(gActionPool->action(UIActionIndexSelector_Simple_Machine_AddGroup), SIGNAL(triggered()),
    11111144            this, SLOT(sltAddGroupBasedOnChosenItems()));
     1145    connect(gActionPool->action(UIActionIndexSelector_Simple_Common_Refresh), SIGNAL(triggered()),
     1146            this, SLOT(sltPerformRefreshAction()));
    11121147    connect(gActionPool->action(UIActionIndexSelector_Simple_Machine_SortParent), SIGNAL(triggered()),
    11131148            this, SLOT(sltSortParentGroup()));
     
    19231958}
    19241959
     1960void UIGChooserModel::enumerateInaccessibleItems(const QList<UIGChooserItem*> &il, QList<UIGChooserItem*> &ol) const
     1961{
     1962    /* Enumerate all the passed items: */
     1963    foreach (UIGChooserItem *pItem, il)
     1964    {
     1965        /* If item is inaccessible machine: */
     1966        if (pItem->type() == UIGChooserItemType_Machine)
     1967        {
     1968            if (UIGChooserItemMachine *pMachineItem = pItem->toMachineItem())
     1969                if (!pMachineItem->accessible() && !contains(ol, pItem))
     1970                    ol << pMachineItem;
     1971        }
     1972        /* If item is group: */
     1973        else if (pItem->type() == UIGChooserItemType_Group)
     1974        {
     1975            /* Enumerate all the machine items recursively: */
     1976            enumerateInaccessibleItems(pItem->items(UIGChooserItemType_Machine), ol);
     1977            /* Enumerate all the group items recursively: */
     1978            enumerateInaccessibleItems(pItem->items(UIGChooserItemType_Group), ol);
     1979        }
     1980    }
     1981}
     1982
     1983bool UIGChooserModel::contains(const QList<UIGChooserItem*> &il, UIGChooserItem *pLookupItem) const
     1984{
     1985    /* We assume passed list contains only machine items: */
     1986    foreach (UIGChooserItem *pItem, il)
     1987        if (UIGChooserItemMachine *pMachineItem = pItem->toMachineItem())
     1988            if (pMachineItem->id() == pLookupItem->toMachineItem()->id())
     1989                return true;
     1990    return false;
     1991}
     1992
    19251993void UIGChooserModel::sortItems(UIGChooserItem *pParent, bool fRecursively /* = false */)
    19261994{
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.h

    r43007 r43155  
    206206    void sltSlidingComplete();
    207207
     208    /* Handler: Refresh stuff: */
     209    void sltPerformRefreshAction();
     210
    208211    /* Handlers: Sorting stuff: */
    209212    void sltSortParentGroup();
     
    304307    void removeMachineItems(const QStringList &names, QList<UIGChooserItem*> &selectedItems);
    305308    void unregisterMachines(const QStringList &ids);
     309
     310    /* Helper: Refresh stuff: */
     311    void enumerateInaccessibleItems(const QList<UIGChooserItem*> &il, QList<UIGChooserItem*> &ol) const;
     312    bool contains(const QList<UIGChooserItem*> &il, UIGChooserItem *pLookupItem) const;
    306313
    307314    /* Helper: Sorting stuff: */
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