VirtualBox

Changeset 42879 in vbox


Ignore:
Timestamp:
Aug 20, 2012 11:34:13 AM (12 years ago)
Author:
vboxsync
Message:

FE/Qt: 6234: Support for VM groups: Rework 'Ungroup' action to be less destructive.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp

    r42766 r42879  
    12451245}
    12461246
     1247void UIMessageCenter::notifyAboutCollisionOnGroupRemovingCantBeResolved(const QString &strName, const QString &strGroupName)
     1248{
     1249    message(&vboxGlobal().selectorWnd(),
     1250            Error,
     1251            tr("<p>You are trying to move machine <nobr><b>%1</b></nobr> "
     1252               "to group <nobr><b>%2</b></nobr> which already have sub-group <nobr><b>%1</b></nobr>.</p>"
     1253               "<p>Please resolve this name-conflict and try again.</p>")
     1254               .arg(strName, strGroupName),
     1255            0, /* auto-confirm id */
     1256            QIMessageBox::Ok | QIMessageBox::Default);
     1257}
     1258
     1259int UIMessageCenter::askAboutCollisionOnGroupRemoving(const QString &strName, const QString &strGroupName)
     1260{
     1261    return message(&vboxGlobal().selectorWnd(),
     1262                   Question,
     1263                   tr("<p>You are trying to move group <nobr><b>%1</b></nobr> "
     1264                      "to group <nobr><b>%2</b></nobr> which already have another item with the same name.</p>"
     1265                      "<p>Would you like to automatically rename it?</p>")
     1266                      .arg(strName, strGroupName),
     1267                   0, /* auto-confirm id */
     1268                   QIMessageBox::Ok,
     1269                   QIMessageBox::Cancel | QIMessageBox::Escape | QIMessageBox::Default,
     1270                   0,
     1271                   tr("Rename"));
     1272}
     1273
    12471274int UIMessageCenter::confirmMachineItemRemoval(const QStringList &names)
    12481275{
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h

    r42766 r42879  
    255255    int cannotEnterSeamlessMode();
    256256
     257    void notifyAboutCollisionOnGroupRemovingCantBeResolved(const QString &strName, const QString &strGroupName);
     258    int askAboutCollisionOnGroupRemoving(const QString &strName, const QString &strGroupName);
    257259    int confirmMachineItemRemoval(const QStringList &names);
    258260    int confirmMachineDeletion(const QList<CMachine> &machines);
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIActionPoolSelector.cpp

    r42850 r42879  
    258258                         ":/vm_delete_disabled_32px.png", ":/delete_dis_16px.png")
    259259    {
    260         setShortcut(gSS->keySequence(UISelectorShortcuts::BreakVMGroupShortcut));
    261         retranslateUi();
    262     }
    263 
    264 protected:
    265 
    266     void retranslateUi()
    267     {
    268         setText(QApplication::translate("UIActionPool", "&Break Group..."));
    269         setStatusTip(QApplication::translate("UIActionPool", "Break the selected virtual machine group"));
     260        setShortcut(gSS->keySequence(UISelectorShortcuts::AddVMGroupShortcut));
     261        retranslateUi();
     262    }
     263
     264protected:
     265
     266    void retranslateUi()
     267    {
     268        setText(QApplication::translate("UIActionPool", "&Ungroup..."));
     269        setStatusTip(QApplication::translate("UIActionPool", "Ungroup items of the selected virtual machine group"));
    270270    }
    271271};
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorShortcuts.cpp

    r42751 r42879  
    3636    m_Shortcuts[SettingsVMShortcut]          = UIKeySequence("SettingsVM",          "Ctrl+S");
    3737    m_Shortcuts[CloneVMShortcut]             = UIKeySequence("CloneVM",             "Ctrl+O");
    38     m_Shortcuts[BreakVMGroupShortcut]        = UIKeySequence("BreakVMGroup",        "Ctrl+B");
    3938    m_Shortcuts[RemoveVMShortcut]            = UIKeySequence("RemoveVM",            "Ctrl+R");
    4039    m_Shortcuts[RenameVMGroupShortcut]       = UIKeySequence("RenameVMGroup",       "Ctrl+M");
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorShortcuts.h

    r42751 r42879  
    3838        SettingsVMShortcut,
    3939        CloneVMShortcut,
    40         BreakVMGroupShortcut,
    4140        RemoveVMShortcut,
    4241        RenameVMGroupShortcut,
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemGroup.cpp

    r42873 r42879  
    166166{
    167167    return m_strName;
     168}
     169
     170void UIGChooserItemGroup::setName(const QString &strName)
     171{
     172    m_strName = strName;
    168173}
    169174
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemGroup.h

    r42795 r42879  
    6464    /* API: Basic stuff: */
    6565    QString name() const;
     66    void setName(const QString &strName);
    6667    bool closed() const;
    6768    bool opened() const;
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.cpp

    r42862 r42879  
    689689    AssertMsg(focusItem()->type() == UIGChooserItemType_Group, ("This is not group item!"));
    690690
    691     /* Compose focus group name: */
    692     QString strFocusGroupName = fullName(focusItem());
    693     /* Enumerate all the unique sub-machine-items recursively: */
    694     QList<UIVMItem*> items;
    695     enumerateCurrentItems(focusItem()->items(), items);
    696     /* Enumerate all the machine groups recursively: */
    697     QMap<QString, QStringList> groupMap;
    698     gatherGroupTree(groupMap, mainRoot());
    699 
    700     /* For each the sub-machine-item: */
    701     foreach (UIVMItem *pItem, items)
    702     {
    703         /* Get machine groups: */
    704         QStringList groups = groupMap.value(pItem->id());
    705         /* For each the machine group: */
    706         bool fUniqueMachine = true;
    707         foreach (const QString &strGroupName, groups)
    708         {
    709             /* Check if this item is unique: */
    710             if (strGroupName != strFocusGroupName &&
    711                 !strGroupName.startsWith(strFocusGroupName + "/"))
     691    /* Check if we have collisions with our siblings: */
     692    UIGChooserItem *pFocusItem = focusItem();
     693    UIGChooserItem *pParentItem = pFocusItem->parentItem();
     694    QList<UIGChooserItem*> siblings = pParentItem->items();
     695    QList<UIGChooserItem*> toBeRenamed;
     696    QList<UIGChooserItem*> toBeRemoved;
     697    foreach (UIGChooserItem *pItem, pFocusItem->items())
     698    {
     699        QString strItemName = pItem->name();
     700        UIGChooserItem *pCollisionSibling = 0;
     701        foreach (UIGChooserItem *pSibling, siblings)
     702            if (pSibling != pFocusItem && pSibling->name() == strItemName)
     703                pCollisionSibling = pSibling;
     704        if (pCollisionSibling)
     705        {
     706            if (pItem->type() == UIGChooserItemType_Machine)
    712707            {
    713                 fUniqueMachine = false;
     708                if (pCollisionSibling->type() == UIGChooserItemType_Machine)
     709                    toBeRemoved << pItem;
     710                else if (pCollisionSibling->type() == UIGChooserItemType_Group)
     711                {
     712                    msgCenter().notifyAboutCollisionOnGroupRemovingCantBeResolved(strItemName, pParentItem->name());
     713                    return;
     714                }
     715            }
     716            else if (pItem->type() == UIGChooserItemType_Group)
     717            {
     718                if (msgCenter().askAboutCollisionOnGroupRemoving(strItemName, pParentItem->name()) == QIMessageBox::Ok)
     719                    toBeRenamed << pItem;
     720                else
     721                    return;
     722            }
     723        }
     724    }
     725
     726    /* Copy all the children into our parent: */
     727    foreach (UIGChooserItem *pItem, pFocusItem->items())
     728    {
     729        if (toBeRemoved.contains(pItem))
     730            continue;
     731        switch (pItem->type())
     732        {
     733            case UIGChooserItemType_Group:
     734            {
     735                UIGChooserItemGroup *pGroupItem = new UIGChooserItemGroup(pParentItem, pItem->toGroupItem());
     736                if (toBeRenamed.contains(pItem))
     737                    pGroupItem->setName(uniqueGroupName(pParentItem));
    714738                break;
    715739            }
    716         }
    717         /* Add unique item into root: */
    718         if (fUniqueMachine)
    719             createMachineItem(pItem->machine(), mainRoot());
     740            case UIGChooserItemType_Machine:
     741            {
     742                new UIGChooserItemMachine(pParentItem, pItem->toMachineItem());
     743                break;
     744            }
     745        }
    720746    }
    721747
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