VirtualBox

儲存庫 vbox 的更動 43593


忽略:
時間撮記:
2012-10-10 下午01:36:39 (12 年 以前)
作者:
vboxsync
訊息:

FE/Qt: VM group feature UI: Group/machine item handling cleanup (part 3).

位置:
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser
檔案:
修改 2 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.cpp

    r43592 r43593  
    693693}
    694694
     695void UIGChooserModel::sltEditGroupName()
     696{
     697    /* Check if action is enabled: */
     698    if (!gActionPool->action(UIActionIndexSelector_Simple_Group_Rename)->isEnabled())
     699        return;
     700
     701    /* Only for single selected group: */
     702    if (!isSingleGroupSelected())
     703        return;
     704
     705    /* Start editing group name: */
     706    currentItem()->startEditing();
     707}
     708
     709void UIGChooserModel::sltSortGroup()
     710{
     711    /* Check if action is enabled: */
     712    if (!gActionPool->action(UIActionIndexSelector_Simple_Group_Sort)->isEnabled())
     713        return;
     714
     715    /* Only for single selected group: */
     716    if (!isSingleGroupSelected())
     717        return;
     718
     719    /* Sorting group: */
     720    sortItems(currentItem());
     721}
     722
     723void UIGChooserModel::sltUngroupSelectedGroup()
     724{
     725    /* Check if action is enabled: */
     726    if (!gActionPool->action(UIActionIndexSelector_Simple_Group_Remove)->isEnabled())
     727        return;
     728
     729    /* Make sure focus item is of group type! */
     730    AssertMsg(focusItem()->type() == UIGChooserItemType_Group, ("This is not group-item!"));
     731
     732    /* Check if we have collisions with our siblings: */
     733    UIGChooserItem *pFocusItem = focusItem();
     734    UIGChooserItem *pParentItem = pFocusItem->parentItem();
     735    QList<UIGChooserItem*> siblings = pParentItem->items();
     736    QList<UIGChooserItem*> toBeRenamed;
     737    QList<UIGChooserItem*> toBeRemoved;
     738    foreach (UIGChooserItem *pItem, pFocusItem->items())
     739    {
     740        QString strItemName = pItem->name();
     741        UIGChooserItem *pCollisionSibling = 0;
     742        foreach (UIGChooserItem *pSibling, siblings)
     743            if (pSibling != pFocusItem && pSibling->name() == strItemName)
     744                pCollisionSibling = pSibling;
     745        if (pCollisionSibling)
     746        {
     747            if (pItem->type() == UIGChooserItemType_Machine)
     748            {
     749                if (pCollisionSibling->type() == UIGChooserItemType_Machine)
     750                    toBeRemoved << pItem;
     751                else if (pCollisionSibling->type() == UIGChooserItemType_Group)
     752                {
     753                    msgCenter().notifyAboutCollisionOnGroupRemovingCantBeResolved(strItemName, pParentItem->name());
     754                    return;
     755                }
     756            }
     757            else if (pItem->type() == UIGChooserItemType_Group)
     758            {
     759                if (msgCenter().askAboutCollisionOnGroupRemoving(strItemName, pParentItem->name()) == QIMessageBox::Ok)
     760                    toBeRenamed << pItem;
     761                else
     762                    return;
     763            }
     764        }
     765    }
     766
     767    /* Copy all the children into our parent: */
     768    foreach (UIGChooserItem *pItem, pFocusItem->items())
     769    {
     770        if (toBeRemoved.contains(pItem))
     771            continue;
     772        switch (pItem->type())
     773        {
     774            case UIGChooserItemType_Group:
     775            {
     776                UIGChooserItemGroup *pGroupItem = new UIGChooserItemGroup(pParentItem, pItem->toGroupItem());
     777                if (toBeRenamed.contains(pItem))
     778                    pGroupItem->setName(uniqueGroupName(pParentItem));
     779                break;
     780            }
     781            case UIGChooserItemType_Machine:
     782            {
     783                new UIGChooserItemMachine(pParentItem, pItem->toMachineItem());
     784                break;
     785            }
     786        }
     787    }
     788
     789    /* Delete focus group: */
     790    delete focusItem();
     791
     792    /* And update model: */
     793    updateNavigation();
     794    updateLayout();
     795    setCurrentItem(navigationList().first());
     796    saveGroupSettings();
     797}
     798
     799void UIGChooserModel::sltCreateNewMachine()
     800{
     801    /* Check if action is enabled: */
     802    if (!gActionPool->action(UIActionIndexSelector_Simple_Machine_New)->isEnabled())
     803        return;
     804
     805    /* Choose the parent: */
     806    UIGChooserItem *pGroup = 0;
     807    if (isSingleGroupSelected())
     808        pGroup = currentItem();
     809    else if (!currentItems().isEmpty())
     810        pGroup = currentItem()->parentItem();
     811    QString strGroupName;
     812    if (pGroup)
     813        strGroupName = fullName(pGroup);
     814
     815    /* Start the new vm wizard: */
     816    UISafePointerWizard pWizard = new UIWizardNewVM(&vboxGlobal().selectorWnd(), strGroupName);
     817    pWizard->prepare();
     818    pWizard->exec();
     819    if (pWizard)
     820        delete pWizard;
     821}
     822
    695823void UIGChooserModel::sltGroupSelectedMachines()
    696824{
     825    /* Check if action is enabled: */
     826    if (!gActionPool->action(UIActionIndexSelector_Simple_Machine_AddGroup)->isEnabled())
     827        return;
     828
    697829    /* Create new group in the current root: */
    698830    UIGChooserItemGroup *pNewGroupItem = new UIGChooserItemGroup(root(), uniqueGroupName(root()), true);
     
    740872}
    741873
    742 void UIGChooserModel::sltEditGroupName()
    743 {
    744     /* Check if action is enabled: */
    745     if (!gActionPool->action(UIActionIndexSelector_Simple_Group_Rename)->isEnabled())
    746         return;
    747 
    748     /* Only for single selected group: */
    749     if (!isSingleGroupSelected())
    750         return;
    751 
    752     /* Start editing group name: */
    753     currentItem()->startEditing();
    754 }
    755 
    756 void UIGChooserModel::sltSortGroup()
    757 {
    758     /* Only for single selected group: */
    759     if (!isSingleGroupSelected())
    760         return;
    761 
    762     /* Sorting group: */
    763     sortItems(currentItem());
    764 }
    765 
    766 void UIGChooserModel::sltUngroupSelectedGroup()
    767 {
    768     /* Make sure focus item is of group type! */
    769     AssertMsg(focusItem()->type() == UIGChooserItemType_Group, ("This is not group-item!"));
    770 
    771     /* Check if we have collisions with our siblings: */
    772     UIGChooserItem *pFocusItem = focusItem();
    773     UIGChooserItem *pParentItem = pFocusItem->parentItem();
    774     QList<UIGChooserItem*> siblings = pParentItem->items();
    775     QList<UIGChooserItem*> toBeRenamed;
    776     QList<UIGChooserItem*> toBeRemoved;
    777     foreach (UIGChooserItem *pItem, pFocusItem->items())
    778     {
    779         QString strItemName = pItem->name();
    780         UIGChooserItem *pCollisionSibling = 0;
    781         foreach (UIGChooserItem *pSibling, siblings)
    782             if (pSibling != pFocusItem && pSibling->name() == strItemName)
    783                 pCollisionSibling = pSibling;
    784         if (pCollisionSibling)
    785         {
    786             if (pItem->type() == UIGChooserItemType_Machine)
    787             {
    788                 if (pCollisionSibling->type() == UIGChooserItemType_Machine)
    789                     toBeRemoved << pItem;
    790                 else if (pCollisionSibling->type() == UIGChooserItemType_Group)
    791                 {
    792                     msgCenter().notifyAboutCollisionOnGroupRemovingCantBeResolved(strItemName, pParentItem->name());
    793                     return;
    794                 }
    795             }
    796             else if (pItem->type() == UIGChooserItemType_Group)
    797             {
    798                 if (msgCenter().askAboutCollisionOnGroupRemoving(strItemName, pParentItem->name()) == QIMessageBox::Ok)
    799                     toBeRenamed << pItem;
    800                 else
    801                     return;
    802             }
    803         }
    804     }
    805 
    806     /* Copy all the children into our parent: */
    807     foreach (UIGChooserItem *pItem, pFocusItem->items())
    808     {
    809         if (toBeRemoved.contains(pItem))
    810             continue;
    811         switch (pItem->type())
    812         {
    813             case UIGChooserItemType_Group:
    814             {
    815                 UIGChooserItemGroup *pGroupItem = new UIGChooserItemGroup(pParentItem, pItem->toGroupItem());
    816                 if (toBeRenamed.contains(pItem))
    817                     pGroupItem->setName(uniqueGroupName(pParentItem));
    818                 break;
    819             }
    820             case UIGChooserItemType_Machine:
    821             {
    822                 new UIGChooserItemMachine(pParentItem, pItem->toMachineItem());
    823                 break;
    824             }
    825         }
    826     }
    827 
    828     /* Delete focus group: */
    829     delete focusItem();
    830 
    831     /* And update model: */
    832     updateNavigation();
    833     updateLayout();
    834     setCurrentItem(navigationList().first());
    835     saveGroupSettings();
    836 }
    837 
    838 void UIGChooserModel::sltCreateNewMachine()
    839 {
    840     UIGChooserItem *pGroup = 0;
    841     if (isSingleGroupSelected())
    842         pGroup = currentItem();
    843     else if (!currentItems().isEmpty())
    844         pGroup = currentItem()->parentItem();
    845     QString strGroupName;
    846     if (pGroup)
    847         strGroupName = fullName(pGroup);
    848     UISafePointerWizard pWizard = new UIWizardNewVM(&vboxGlobal().selectorWnd(), strGroupName);
    849     pWizard->prepare();
    850     pWizard->exec();
    851     if (pWizard)
    852         delete pWizard;
    853 }
    854 
    855874void UIGChooserModel::sltReloadMachine(const QString &strId)
    856875{
     
    877896void UIGChooserModel::sltSortParentGroup()
    878897{
     898    /* Check if action is enabled: */
     899    if (!gActionPool->action(UIActionIndexSelector_Simple_Machine_SortParent)->isEnabled())
     900        return;
     901
    879902    /* Only if some item selected: */
    880903    if (!currentItem())
     
    887910void UIGChooserModel::sltPerformRefreshAction()
    888911{
     912    /* Check if action is enabled: */
     913    if (!gActionPool->action(UIActionIndexSelector_Simple_Common_Refresh)->isEnabled())
     914        return;
     915
    889916    /* Gather list of chosen inaccessible VMs: */
    890917    QList<UIGChooserItem*> inaccessibleItems;
     
    920947void UIGChooserModel::sltRemoveSelectedMachine()
    921948{
     949    /* Check if action is enabled: */
     950    if (!gActionPool->action(UIActionIndexSelector_Simple_Machine_Remove)->isEnabled())
     951        return;
     952
    922953    /* Enumerate all the selected machine-items: */
    923954    QList<UIGChooserItem*> selectedMachineItemList = gatherMachineItems(currentItems());
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.h

    r43592 r43593  
    175175
    176176    /* Handlers: Group-item stuff: */
    177     void sltGroupSelectedMachines();
    178177    void sltEditGroupName();
    179178    void sltSortGroup();
     
    182181    /* Handlers: Machine-item stuff: */
    183182    void sltCreateNewMachine();
     183    void sltGroupSelectedMachines();
    184184    void sltReloadMachine(const QString &strId);
    185185    void sltSortParentGroup();
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette