VirtualBox

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


Ignore:
Timestamp:
Sep 27, 2012 7:18:12 AM (12 years ago)
Author:
vboxsync
Message:

FE/Qt: VM group feature: Make sure grouping is disabled if all the chosen items are full children list of one group already.

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

Legend:

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

    r43424 r43444  
    796796
    797797    /* Determine which menu to show: */
    798     m_pGroupMenuAction->setVisible(m_pChooser->singleGroupSelected());
    799     m_pMachineMenuAction->setVisible(!m_pChooser->singleGroupSelected());
     798    m_pGroupMenuAction->setVisible(m_pChooser->isSingleGroupSelected());
     799    m_pMachineMenuAction->setVisible(!m_pChooser->isSingleGroupSelected());
    800800    if (m_pGroupMenuAction->isVisible())
    801801    {
     
    832832            /* Always hide snapshots-view if
    833833             * single group or more than one machine is selected: */
    834             if (currentItems().size() > 1 || m_pChooser->singleGroupSelected())
     834            if (currentItems().size() > 1 || m_pChooser->isSingleGroupSelected())
    835835                m_pVMDesktop->lockSnapshots();
    836836        }
     
    16781678        {
    16791679            return !m_pChooser->isGroupSavingInProgress() &&
    1680                    m_pChooser->singleGroupSelected();
     1680                   m_pChooser->isSingleGroupSelected();
    16811681        }
    16821682        case UIActionIndexSelector_Simple_Machine_Settings:
     
    17011701        {
    17021702            return !m_pChooser->isGroupSavingInProgress() &&
     1703                   !m_pChooser->isAllItemsOfOneGroupSelected() &&
    17031704                   isItemsPoweredOff(items);
    17041705        }
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooser.cpp

    r43005 r43444  
    9595}
    9696
    97 bool UIGChooser::singleGroupSelected() const
     97bool UIGChooser::isSingleGroupSelected() const
    9898{
    99     return m_pChooserModel->singleGroupSelected();
     99    return m_pChooserModel->isSingleGroupSelected();
     100}
     101
     102bool UIGChooser::isAllItemsOfOneGroupSelected() const
     103{
     104    return m_pChooserModel->isAllItemsOfOneGroupSelected();
    100105}
    101106
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooser.h

    r43005 r43444  
    6363    UIVMItem* currentItem() const;
    6464    QList<UIVMItem*> currentItems() const;
    65     bool singleGroupSelected() const;
     65    bool isSingleGroupSelected() const;
     66    bool isAllItemsOfOneGroupSelected() const;
    6667
    6768    /* API: Status bar stuff: */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.cpp

    r43424 r43444  
    346346}
    347347
    348 bool UIGChooserModel::singleGroupSelected() const
     348bool UIGChooserModel::isSingleGroupSelected() const
    349349{
    350350    return selectionList().size() == 1 &&
    351351           selectionList().first()->type() == UIGChooserItemType_Group;
     352}
     353
     354bool UIGChooserModel::isAllItemsOfOneGroupSelected() const
     355{
     356    /* Make sure at least on item selected: */
     357    if (selectionList().isEmpty())
     358        return false;
     359
     360    /* Determine the parent group of the first item: */
     361    UIGChooserItem *pFirstParent = selectionList().first()->parentItem();
     362
     363    /* Make sure this parent is not main root item: */
     364    if (pFirstParent == mainRoot())
     365        return false;
     366
     367    /* Enumerate selected set: */
     368    QSet<UIGChooserItem*> selectedSet;
     369    foreach (UIGChooserItem *pSelectedItem, selectionList())
     370        selectedSet << pSelectedItem;
     371
     372    /* Enumerate first parent children set: */
     373    QSet<UIGChooserItem*> firstParentSet;
     374    foreach (UIGChooserItem *pSelectedItem, pFirstParent->items())
     375        firstParentSet << pSelectedItem;
     376
     377    /* Check if both sets contains the same: */
     378    return selectedSet == firstParentSet;
    352379}
    353380
     
    885912
    886913    /* Only for single selected group: */
    887     if (!singleGroupSelected())
     914    if (!isSingleGroupSelected())
    888915        return;
    889916
     
    895922{
    896923    UIGChooserItem *pGroup = 0;
    897     if (singleGroupSelected())
     924    if (isSingleGroupSelected())
    898925        pGroup = selectionList().first();
    899926    else if (!selectionList().isEmpty())
     
    10031030void UIGChooserModel::sltSortGroup()
    10041031{
    1005     if (singleGroupSelected())
     1032    if (isSingleGroupSelected())
    10061033        sortItems(selectionList().first());
    10071034}
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.h

    r43155 r43444  
    118118    void setCurrentItemDefinition(const QString &strDefinition);
    119119    QString currentItemDefinition() const;
    120     bool singleGroupSelected() const;
     120    bool isSingleGroupSelected() const;
     121    bool isAllItemsOfOneGroupSelected() const;
    121122
    122123    /* API: Focus item 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