VirtualBox

Changeset 77933 in vbox for trunk


Ignore:
Timestamp:
Mar 28, 2019 12:30:56 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9241: VirtualBox Manager: Chooser pane: Rename current-item(s) to selected-item(s) and focus-item to current-item afterwards as this stuff was initially named wrong.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooser.cpp

    r77228 r77933  
    5151UIVirtualMachineItem *UIChooser::currentItem() const
    5252{
    53     return m_pChooserModel->currentMachineItem();
     53    return m_pChooserModel->firstSelectedMachineItem();
    5454}
    5555
    5656QList<UIVirtualMachineItem*> UIChooser::currentItems() const
    5757{
    58     return m_pChooserModel->currentMachineItems();
     58    return m_pChooserModel->selectedMachineItems();
    5959}
    6060
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooser.h

    r77315 r77933  
    8989    /** @} */
    9090
    91     /** @name Current item stuff.
     91    /** @name Current-item stuff.
    9292      * @{ */
    93         /** Returns current item. */
     93        /** Returns current-item. */
    9494        UIVirtualMachineItem *currentItem() const;
    95         /** Returns a list of current items. */
     95        /** Returns a list of current-items. */
    9696        QList<UIVirtualMachineItem*> currentItems() const;
    9797
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserHandlerKeyboard.cpp

    r77919 r77933  
    8787#endif /* !VBOX_WS_MAC */
    8888            {
    89                 /* Determine focus item position: */
    90                 int iPosition = model()->navigationList().indexOf(model()->focusItem());
     89                /* Determine current-item position: */
     90                int iPosition = model()->navigationList().indexOf(model()->currentItem());
    9191                /* Determine 'previous' item: */
    9292                UIChooserItem *pPreviousItem = 0;
     
    103103                    pPreviousItem->makeSureItsVisible();
    104104                    /* Calculate positions: */
    105                     UIChooserItem *pFirstItem = model()->currentItem();
     105                    UIChooserItem *pFirstItem = model()->firstSelectedItem();
    106106                    int iFirstPosition = model()->navigationList().indexOf(pFirstItem);
    107107                    int iPreviousPosition = model()->navigationList().indexOf(pPreviousItem);
     
    114114                        for (int i = iFirstPosition; i >= iPreviousPosition; --i)
    115115                            items << model()->navigationList().at(i);
    116                     /* Set that list as current: */
    117                     model()->setCurrentItems(items);
    118                     /* Move focus to 'previous' item: */
    119                     model()->setFocusItem(pPreviousItem);
     116                    /* Set that list as selected: */
     117                    model()->setSelectedItems(items);
     118                    /* Make 'previous' item current one: */
     119                    model()->setCurrentItem(pPreviousItem);
    120120                    /* Filter-out this event: */
    121121                    return true;
     
    130130#endif /* !VBOX_WS_MAC */
    131131            {
    132                 /* Determine focus item position: */
    133                 int iPosition = model()->navigationList().indexOf(model()->focusItem());
     132                /* Determine current-item position: */
     133                int iPosition = model()->navigationList().indexOf(model()->currentItem());
    134134                /* Determine 'previous' item: */
    135135                UIChooserItem *pPreviousItem = 0;
     
    145145                    /* Make sure 'previous' item is visible: */
    146146                    pPreviousItem->makeSureItsVisible();
    147                     /* Make 'previous' item the current one: */
    148                     model()->setCurrentItem(pPreviousItem);
     147                    /* Make 'previous' item the only selected: */
     148                    model()->setSelectedItem(pPreviousItem);
    149149                    /* Filter-out this event: */
    150150                    return true;
     
    180180#endif /* !VBOX_WS_MAC */
    181181            {
    182                 /* Determine focus item position: */
    183                 int iPosition = model()->navigationList().indexOf(model()->focusItem());
     182                /* Determine current-item position: */
     183                int iPosition = model()->navigationList().indexOf(model()->currentItem());
    184184                /* Determine 'next' item: */
    185185                UIChooserItem *pNextItem = 0;
     
    196196                    pNextItem->makeSureItsVisible();
    197197                    /* Calculate positions: */
    198                     UIChooserItem *pFirstItem = model()->currentItem();
     198                    UIChooserItem *pFirstItem = model()->firstSelectedItem();
    199199                    int iFirstPosition = model()->navigationList().indexOf(pFirstItem);
    200200                    int iNextPosition = model()->navigationList().indexOf(pNextItem);
     
    207207                        for (int i = iFirstPosition; i >= iNextPosition; --i)
    208208                            items << model()->navigationList().at(i);
    209                     /* Set that list as current: */
    210                     model()->setCurrentItems(items);
    211                     /* Move focus to 'next' item: */
    212                     model()->setFocusItem(pNextItem);
     209                    /* Set that list as selected: */
     210                    model()->setSelectedItems(items);
     211                    /* Make 'next' item current one: */
     212                    model()->setCurrentItem(pNextItem);
    213213                    /* Filter-out this event: */
    214214                    return true;
     
    223223#endif /* !VBOX_WS_MAC */
    224224            {
    225                 /* Determine focus item position: */
    226                 int iPosition = model()->navigationList().indexOf(model()->focusItem());
     225                /* Determine current-item position: */
     226                int iPosition = model()->navigationList().indexOf(model()->currentItem());
    227227                /* Determine 'next' item: */
    228228                UIChooserItem *pNextItem = 0;
     
    238238                    /* Make sure 'next' item is visible: */
    239239                    pNextItem->makeSureItsVisible();
    240                     /* Make 'next' item the current one: */
    241                     model()->setCurrentItem(pNextItem);
     240                    /* Make 'next' item the only selected one: */
     241                    model()->setSelectedItem(pNextItem);
    242242                    /* Filter-out this event: */
    243243                    return true;
     
    251251        {
    252252            /* If this item is of group type: */
    253             if (model()->focusItem()->type() == UIChooserItemType_Group)
    254             {
    255                 /* Start embedded editing focus item: */
     253            if (model()->currentItem()->type() == UIChooserItemType_Group)
     254            {
     255                /* Start embedded editing of current-item: */
    256256                model()->startEditingGroupItemName();
    257257                /* Filter that event out: */
     
    265265        {
    266266            /* If this item is of group or machine type: */
    267             if (   model()->focusItem()->type() == UIChooserItemType_Group
    268                 || model()->focusItem()->type() == UIChooserItemType_Machine)
     267            if (   model()->currentItem()->type() == UIChooserItemType_Group
     268                || model()->currentItem()->type() == UIChooserItemType_Machine)
    269269            {
    270270                /* Activate item: */
     
    278278        case Qt::Key_Space:
    279279        {
    280             /* If there is a focus item: */
    281             if (UIChooserItem *pFocusItem = model()->focusItem())
     280            /* If there is a current-item: */
     281            if (UIChooserItem *pCurrentItem = model()->currentItem())
    282282            {
    283283                /* Of the group type: */
    284                 if (pFocusItem->type() == UIChooserItemType_Group)
     284                if (pCurrentItem->type() == UIChooserItemType_Group)
    285285                {
    286286                    /* Toggle that group: */
    287                     UIChooserItemGroup *pGroupItem = pFocusItem->toGroupItem();
     287                    UIChooserItemGroup *pGroupItem = pCurrentItem->toGroupItem();
    288288                    if (pGroupItem->isClosed())
    289289                        pGroupItem->open();
     
    324324void UIChooserHandlerKeyboard::shift(UIItemShiftDirection enmDirection, UIItemShiftType enmShiftType) const
    325325{
    326     /* Get focus-node and its parent: */
    327     UIChooserNode *pFocusNode = model()->focusItem()->node();
    328     UIChooserNode *pParentNode = pFocusNode->parentNode();
    329     /* Get focus-node position: */
    330     const int iFocusNodePosition = pFocusNode->position();
     326    /* Get current-node and its parent: */
     327    UIChooserNode *pCurrentNode = model()->currentItem()->node();
     328    UIChooserNode *pParentNode = pCurrentNode->parentNode();
     329    /* Get current-node position: */
     330    const int iCurrentNodePosition = pCurrentNode->position();
    331331
    332332    /* Calculate new position: */
    333     int iNewFocusNodePosition = -1;
     333    int iNewCurrentNodePosition = -1;
    334334    switch (enmDirection)
    335335    {
    336336        case UIItemShiftDirection_Up:
    337337        {
    338             if (iFocusNodePosition > 0)
     338            if (iCurrentNodePosition > 0)
    339339                switch (enmShiftType)
    340340                {
    341                     case UIItemShiftSize_Item: iNewFocusNodePosition = iFocusNodePosition - 1; break;
    342                     case UIItemShiftSize_Full: iNewFocusNodePosition = 0; break;
     341                    case UIItemShiftSize_Item: iNewCurrentNodePosition = iCurrentNodePosition - 1; break;
     342                    case UIItemShiftSize_Full: iNewCurrentNodePosition = 0; break;
    343343                    default: break;
    344344                }
     
    347347        case UIItemShiftDirection_Down:
    348348        {
    349             if (iFocusNodePosition < pParentNode->nodes(pFocusNode->type()).size() - 1)
     349            if (iCurrentNodePosition < pParentNode->nodes(pCurrentNode->type()).size() - 1)
    350350                switch (enmShiftType)
    351351                {
    352                     case UIItemShiftSize_Item: iNewFocusNodePosition = iFocusNodePosition + 2; break;
    353                     case UIItemShiftSize_Full: iNewFocusNodePosition = pParentNode->nodes(pFocusNode->type()).size();  break;
     352                    case UIItemShiftSize_Item: iNewCurrentNodePosition = iCurrentNodePosition + 2; break;
     353                    case UIItemShiftSize_Full: iNewCurrentNodePosition = pParentNode->nodes(pCurrentNode->type()).size();  break;
    354354                    default: break;
    355355                }
     
    360360    }
    361361    /* Filter out invalid requests: */
    362     if (iNewFocusNodePosition == -1)
     362    if (iNewCurrentNodePosition == -1)
    363363        return;
    364364
    365365    /* Create shifted node/item: */
    366366    UIChooserItem *pShiftedItem = 0;
    367     switch (pFocusNode->type())
     367    switch (pCurrentNode->type())
    368368    {
    369369        case UIChooserItemType_Group:
    370370        {
    371             UIChooserNodeGroup *pNewNode = new UIChooserNodeGroup(pParentNode, pFocusNode->toGroupNode(), iNewFocusNodePosition);
     371            UIChooserNodeGroup *pNewNode = new UIChooserNodeGroup(pParentNode, pCurrentNode->toGroupNode(), iNewCurrentNodePosition);
    372372            pShiftedItem = new UIChooserItemGroup(pParentNode->item(), pNewNode);
    373373            break;
     
    375375        case UIChooserItemType_Machine:
    376376        {
    377             UIChooserNodeMachine *pNewNode = new UIChooserNodeMachine(pParentNode, pFocusNode->toMachineNode(), iNewFocusNodePosition);
     377            UIChooserNodeMachine *pNewNode = new UIChooserNodeMachine(pParentNode, pCurrentNode->toMachineNode(), iNewCurrentNodePosition);
    378378            pShiftedItem = new UIChooserItemMachine(pParentNode->item(), pNewNode);
    379379            break;
     
    384384
    385385    /* Delete old node/item: */
    386     delete pFocusNode;
     386    delete pCurrentNode;
    387387
    388388    /* Update model: */
     
    390390    model()->updateNavigation();
    391391    model()->updateLayout();
    392     model()->setCurrentItem(pShiftedItem);
     392    model()->setSelectedItem(pShiftedItem);
    393393    model()->saveGroupSettings();
    394394}
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserHandlerMouse.cpp

    r77430 r77933  
    7373                    const QPoint itemCursorPos = pGlobalItem->mapFromScene(scenePos).toPoint();
    7474                    if (   pGlobalItem->isToolButtonArea(itemCursorPos)
    75                         && (   model()->currentItem() == pGlobalItem
     75                        && (   model()->firstSelectedItem() == pGlobalItem
    7676                            || pGlobalItem->isHovered()))
    7777                    {
    7878                        model()->handleToolButtonClick(pGlobalItem);
    79                         if (model()->currentItem() != pGlobalItem)
     79                        if (model()->firstSelectedItem() != pGlobalItem)
    8080                            pClickedItem = pGlobalItem;
    8181                    }
    8282                    else
    8383                    if (   pGlobalItem->isPinButtonArea(itemCursorPos)
    84                         && (   model()->currentItem() == pGlobalItem
     84                        && (   model()->firstSelectedItem() == pGlobalItem
    8585                            || pGlobalItem->isHovered()))
    8686                        model()->handlePinButtonClick(pGlobalItem);
     
    9393                    const QPoint itemCursorPos = pMachineItem->mapFromScene(scenePos).toPoint();
    9494                    if (   pMachineItem->isToolButtonArea(itemCursorPos)
    95                         && (   model()->currentItem() == pMachineItem
     95                        && (   model()->firstSelectedItem() == pMachineItem
    9696                            || pMachineItem->isHovered()))
    9797                    {
    9898                        model()->handleToolButtonClick(pMachineItem);
    99                         if (model()->currentItem() != pMachineItem)
     99                        if (model()->firstSelectedItem() != pMachineItem)
    100100                            pClickedItem = pMachineItem;
    101101                    }
     
    110110                    {
    111111                        /* Calculate positions: */
    112                         UIChooserItem *pFirstItem = model()->currentItem();
     112                        UIChooserItem *pFirstItem = model()->firstSelectedItem();
    113113                        int iFirstPosition = model()->navigationList().indexOf(pFirstItem);
    114114                        int iClickedPosition = model()->navigationList().indexOf(pClickedItem);
     
    121121                            for (int i = iFirstPosition; i >= iClickedPosition; --i)
    122122                                items << model()->navigationList().at(i);
    123                         /* Set that list as current: */
    124                         model()->setCurrentItems(items);
    125                         /* Move focus to clicked item: */
    126                         model()->setFocusItem(pClickedItem);
     123                        /* Make that list selected: */
     124                        model()->setSelectedItems(items);
     125                        /* Make clicked item current one: */
     126                        model()->setCurrentItem(pClickedItem);
    127127                    }
    128128                    /* Was 'control' modifier pressed? */
     
    130130                    {
    131131                        /* Invert selection state for clicked item: */
    132                         if (model()->currentItems().contains(pClickedItem))
    133                             model()->removeFromCurrentItems(pClickedItem);
     132                        if (model()->selectedItems().contains(pClickedItem))
     133                            model()->removeFromSelectedItems(pClickedItem);
    134134                        else
    135                             model()->addToCurrentItems(pClickedItem);
    136                         /* Move focus to clicked item: */
    137                         model()->setFocusItem(pClickedItem);
     135                            model()->addToSelectedItems(pClickedItem);
     136                        /* Make clicked item current one: */
     137                        model()->setCurrentItem(pClickedItem);
    138138                        model()->makeSureSomeItemIsSelected();
    139139                    }
     
    141141                    else if (pEvent->modifiers() == Qt::NoModifier)
    142142                    {
    143                         /* Make clicked item the current one: */
    144                         model()->setCurrentItem(pClickedItem);
     143                        /* Make clicked item the only selected one: */
     144                        model()->setSelectedItem(pClickedItem);
    145145                    }
    146146                }
     
    165165                {
    166166                    /* Select clicked item if not selected yet: */
    167                     if (!model()->currentItems().contains(pClickedItem))
    168                         model()->setCurrentItem(pClickedItem);
     167                    if (!model()->selectedItems().contains(pClickedItem))
     168                        model()->setSelectedItem(pClickedItem);
    169169                }
    170170                break;
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItem.cpp

    r77829 r77933  
    186186        state.selectable = true;
    187187
    188         /* Compose the state of current item: */
    189         if (item() && item() == item()->model()->currentItem())
     188        /* Compose the state of first selected-item: */
     189        if (item() && item() == item()->model()->firstSelectedItem())
    190190        {
    191191            state.active = true;
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGlobal.cpp

    r77847 r77933  
    367367void UIChooserItemGlobal::cleanup()
    368368{
    369     /* If that item is focused: */
    370     if (model()->focusItem() == this)
    371     {
    372         /* Unset the focus: */
    373         model()->setFocusItem(0);
     369    /* If that item is current: */
     370    if (model()->currentItem() == this)
     371    {
     372        /* Unset current-item: */
     373        model()->setCurrentItem(0);
    374374    }
    375375    /* If that item is in selection list: */
    376     if (model()->currentItems().contains(this))
     376    if (model()->selectedItems().contains(this))
    377377    {
    378378        /* Remove item from the selection list: */
    379         model()->removeFromCurrentItems(this);
     379        model()->removeFromSelectedItems(this);
    380380    }
    381381    /* If that item is in navigation list: */
     
    556556    const QPalette pal = palette();
    557557
    558     /* Selection background: */
    559     if (model()->currentItems().contains(unconst(this)))
     558    /* Selected-item background: */
     559    if (model()->selectedItems().contains(unconst(this)))
    560560    {
    561561        /* Prepare color: */
     
    578578#endif
    579579            animationColor2.setAlpha(0);
    580             /* Draw hovering animated gradient: */
     580            /* Draw hovered-item animated gradient: */
    581581            QRect animatedRect = rectangle;
    582582            animatedRect.setWidth(animatedRect.height());
     
    593593        }
    594594    }
    595     /* Hovering background: */
     595    /* Hovered-item background: */
    596596    else if (isHovered())
    597597    {
     
    613613#endif
    614614        animationColor2.setAlpha(0);
    615         /* Draw hovering animated gradient: */
     615        /* Draw hovered-item animated gradient: */
    616616        QRect animatedRect = rectangle;
    617617        animatedRect.setWidth(animatedRect.height());
     
    652652void UIChooserItemGlobal::paintFrame(QPainter *pPainter, const QRect &rectangle) const
    653653{
    654     /* Only chosen and/or hovered item should have a frame: */
    655     if (!model()->currentItems().contains(unconst(this)) && !isHovered())
     654    /* Only selected and/or hovered item should have a frame: */
     655    if (!model()->selectedItems().contains(unconst(this)) && !isHovered())
    656656        return;
    657657
     
    663663    QColor strokeColor;
    664664
    665     /* Selection frame: */
    666     if (model()->currentItems().contains(unconst(this)))
     665    /* Selected-item frame: */
     666    if (model()->selectedItems().contains(unconst(this)))
    667667        strokeColor = pal.color(QPalette::Active, QPalette::Highlight).lighter(m_iHighlightLightnessMin - 40);
    668     /* Hovering frame: */
     668    /* Hovered-item frame: */
    669669    else if (isHovered())
    670670        strokeColor = pal.color(QPalette::Active, QPalette::Highlight).lighter(m_iHoverLightnessMin - 50);
     
    697697    const int iButtonMargin = data(GlobalItemData_ButtonMargin).toInt();
    698698
    699     /* Selected item foreground: */
    700     if (model()->currentItems().contains(unconst(this)))
     699    /* Selected-item foreground: */
     700    if (model()->selectedItems().contains(unconst(this)))
    701701    {
    702702        const QPalette pal = palette();
     
    765765
    766766    /* Paint right column: */
    767     if (   model()->currentItem() == this
     767    if (   model()->firstSelectedItem() == this
    768768        || isHovered())
    769769    {
     
    800800
    801801    /* Paint right column: */
    802     if (   model()->currentItem() == this
     802    if (   model()->firstSelectedItem() == this
    803803        || isHovered())
    804804    {
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGroup.cpp

    r77923 r77933  
    836836                pModel->updateNavigation();
    837837                pModel->updateLayout();
    838                 pModel->setCurrentItem(pNewGroupItem);
     838                pModel->setSelectedItem(pNewGroupItem);
    839839                pModel->saveGroupSettings();
    840840                break;
     
    890890                pModel->updateNavigation();
    891891                pModel->updateLayout();
    892                 pModel->setCurrentItem(pNewMachineItem);
     892                pModel->setSelectedItem(pNewMachineItem);
    893893                pModel->saveGroupSettings();
    894894                break;
     
    12041204    while (!m_machineItems.isEmpty()) { delete m_machineItems.last(); }
    12051205
    1206     /* If that item is focused: */
    1207     if (model()->focusItem() == this)
    1208     {
    1209         /* Unset the focus: */
    1210         model()->setFocusItem(0);
     1206    /* If that item is current: */
     1207    if (model()->currentItem() == this)
     1208    {
     1209        /* Unset current-item: */
     1210        model()->setCurrentItem(0);
    12111211    }
    12121212    /* If that item is in selection list: */
    1213     if (model()->currentItems().contains(this))
     1213    if (model()->selectedItems().contains(this))
    12141214    {
    12151215        /* Remove item from the selection list: */
    1216         model()->removeFromCurrentItems(this);
     1216        model()->removeFromSelectedItems(this);
    12171217    }
    12181218    /* If that item is in navigation list: */
     
    16091609    const QPalette pal = palette();
    16101610    const QColor headerColor = pal.color(QPalette::Active,
    1611                                          model()->currentItems().contains(this) ?
     1611                                         model()->selectedItems().contains(this) ?
    16121612                                         QPalette::Highlight : QPalette::Midlight);
    16131613
     
    17061706    const QPalette pal = palette();
    17071707    const QColor strokeColor = pal.color(QPalette::Active,
    1708                                          model()->currentItems().contains(this) ?
     1708                                         model()->selectedItems().contains(this) ?
    17091709                                         QPalette::Highlight : QPalette::Midlight).darker(headerDarkness() + 10);
    17101710
     
    17451745    /* Configure painter color: */
    17461746    pPainter->setPen(palette().color(QPalette::Active,
    1747                                      model()->currentItems().contains(this) ?
     1747                                     model()->selectedItems().contains(this) ?
    17481748                                     QPalette::HighlightedText : QPalette::ButtonText));
    17491749
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemMachine.cpp

    r77890 r77933  
    415415                UIChooserNode *pNode = pCastedMime->item()->node();
    416416
    417                 /* Group passed item with current item into the new group: */
     417                /* Group passed item with current-item into the new group: */
    418418                UIChooserNodeGroup *pNewGroupNode = new UIChooserNodeGroup(parentItem()->node(),
    419419                                                                           false /* favorite */,
     
    444444                pModel->updateNavigation();
    445445                pModel->updateLayout();
    446                 pModel->setCurrentItem(pNewGroupItem);
     446                pModel->setSelectedItem(pNewGroupItem);
    447447                pModel->saveGroupSettings();
    448448                break;
     
    531531void UIChooserItemMachine::cleanup()
    532532{
    533     /* If that item is focused: */
    534     if (model()->focusItem() == this)
    535     {
    536         /* Unset the focus: */
    537         model()->setFocusItem(0);
     533    /* If that item is current: */
     534    if (model()->currentItem() == this)
     535    {
     536        /* Unset current-item: */
     537        model()->setCurrentItem(0);
    538538    }
    539539    /* If that item is in selection list: */
    540     if (model()->currentItems().contains(this))
     540    if (model()->selectedItems().contains(this))
    541541    {
    542542        /* Remove item from the selection list: */
    543         model()->removeFromCurrentItems(this);
     543        model()->removeFromSelectedItems(this);
    544544    }
    545545    /* If that item is in navigation list: */
     
    667667    iFirstRowMaximumWidth -= m_pixmapSize.width(); /* left pixmap width */
    668668    iFirstRowMaximumWidth -= iMajorSpacing; /* spacing between left pixmap and name(s) */
    669     if (   model()->currentItem() == this
     669    if (   model()->firstSelectedItem() == this
    670670        || isHovered())
    671671    {
     
    834834    const QPalette pal = palette();
    835835
    836     /* Selection background: */
    837     if (model()->currentItems().contains(unconst(this)))
     836    /* Selected-item background: */
     837    if (model()->selectedItems().contains(unconst(this)))
    838838    {
    839839        /* Prepare color: */
     
    856856#endif
    857857            animationColor2.setAlpha(0);
    858             /* Draw hovering animated gradient: */
     858            /* Draw hovered-item animated gradient: */
    859859            QRect animatedRect = rectangle;
    860860            animatedRect.setWidth(animatedRect.height());
     
    871871        }
    872872    }
    873     /* Hovering background: */
     873    /* Hovered-item background: */
    874874    else if (isHovered())
    875875    {
     
    891891#endif
    892892        animationColor2.setAlpha(0);
    893         /* Draw hovering animated gradient: */
     893        /* Draw hovered-item animated gradient: */
    894894        QRect animatedRect = rectangle;
    895895        animatedRect.setWidth(animatedRect.height());
     
    928928        if (dragTokenPlace() == UIChooserItemDragToken_Up)
    929929        {
    930             /* Selection background: */
    931             if (model()->currentItems().contains(unconst(this)))
     930            /* Selected-item background: */
     931            if (model()->selectedItems().contains(unconst(this)))
    932932            {
    933933                QColor backgroundColor = pal.color(QPalette::Active, QPalette::Highlight);
     
    949949        else if (dragTokenPlace() == UIChooserItemDragToken_Down)
    950950        {
    951             /* Selection background: */
    952             if (model()->currentItems().contains(unconst(this)))
     951            /* Selected-item background: */
     952            if (model()->selectedItems().contains(unconst(this)))
    953953            {
    954954                QColor backgroundColor = pal.color(QPalette::Active, QPalette::Highlight);
     
    986986    QColor strokeColor;
    987987
    988     /* Selection frame: */
    989     if (model()->currentItems().contains(unconst(this)))
     988    /* Selected-item frame: */
     989    if (model()->selectedItems().contains(unconst(this)))
    990990        strokeColor = pal.color(QPalette::Active, QPalette::Highlight).lighter(m_iHighlightLightnessMin - 40);
    991     /* Hovering frame: */
     991    /* Hovered-item frame: */
    992992    else if (isHovered())
    993993        strokeColor = pal.color(QPalette::Active, QPalette::Highlight).lighter(m_iHoverLightnessMin - 50);
     
    10251025
    10261026    /* Selected or hovered item foreground: */
    1027     if (model()->currentItems().contains(unconst(this)) || isHovered())
     1027    if (model()->selectedItems().contains(unconst(this)) || isHovered())
    10281028    {
    10291029        /* Prepare color: */
     
    11631163
    11641164    /* Paint right column: */
    1165     if (   model()->currentItem() == this
     1165    if (   model()->firstSelectedItem() == this
    11661166        || isHovered())
    11671167    {
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp

    r77923 r77933  
    8585    updateLayout();
    8686
    87     /* Load last selected item: */
     87    /* Load last selected-item: */
    8888    loadLastSelectedItem();
    8989}
     
    9191void UIChooserModel::deinit()
    9292{
    93     /* Save last selected item: */
     93    /* Save last selected-item: */
    9494    saveLastSelectedItem();
    9595
    96     /* Unset current items: */
    97     unsetCurrentItems();
     96    /* Clear list of selected-items: */
     97    clearSelectedItems();
    9898
    9999    /* Call to base-class: */
     
    158158}
    159159
    160 void UIChooserModel::setCurrentItems(const QList<UIChooserItem*> &items)
     160void UIChooserModel::setSelectedItems(const QList<UIChooserItem*> &items)
    161161{
    162162    /* Is there something changed? */
    163     if (m_currentItems == items)
    164         return;
    165 
    166     /* Remember old current-item list: */
    167     const QList<UIChooserItem*> oldCurrentItems = m_currentItems;
    168 
    169     /* Clear current current-item list: */
    170     m_currentItems.clear();
     163    if (m_selectedItems == items)
     164        return;
     165
     166    /* Remember old selected-item list: */
     167    const QList<UIChooserItem*> oldCurrentItems = m_selectedItems;
     168
     169    /* Clear current selected-item list: */
     170    m_selectedItems.clear();
    171171
    172172    /* Iterate over all the passed items: */
    173173    foreach (UIChooserItem *pItem, items)
    174174    {
    175         /* Add item to current list if navigation list contains it: */
     175        /* Add item to current selected-item list if navigation list contains it: */
    176176        if (pItem && navigationList().contains(pItem))
    177             m_currentItems << pItem;
     177            m_selectedItems << pItem;
    178178        else
    179179            AssertMsgFailed(("Passed item is not in navigation list!"));
     
    181181
    182182    /* Is there something really changed? */
    183     if (oldCurrentItems == m_currentItems)
     183    if (oldCurrentItems == m_selectedItems)
    184184        return;
    185185
     
    188188        pItem->update();
    189189    /* Update all the new items (they are selected now): */
    190     foreach (UIChooserItem *pItem, m_currentItems)
     190    foreach (UIChooserItem *pItem, m_selectedItems)
    191191        pItem->update();
    192192
     
    195195}
    196196
    197 void UIChooserModel::setCurrentItem(UIChooserItem *pItem)
     197void UIChooserModel::setSelectedItem(UIChooserItem *pItem)
    198198{
    199199    /* Call for wrapper above: */
     
    201201    if (pItem)
    202202        items << pItem;
    203     setCurrentItems(items);
    204 
    205     /* Move focus to current-item: */
    206     setFocusItem(currentItem());
    207 }
    208 
    209 void UIChooserModel::setCurrentItem(const QString &strDefinition)
     203    setSelectedItems(items);
     204
     205    /* Make selected-item current one as well: */
     206    setCurrentItem(firstSelectedItem());
     207}
     208
     209void UIChooserModel::setSelectedItem(const QString &strDefinition)
    210210{
    211211    /* Ignore if empty definition passed: */
     
    244244
    245245    /* Call for wrapper above: */
    246     setCurrentItem(pItem);
    247 }
    248 
    249 void UIChooserModel::unsetCurrentItems()
     246    setSelectedItem(pItem);
     247}
     248
     249void UIChooserModel::clearSelectedItems()
    250250{
    251251    /* Call for wrapper above: */
    252     setCurrentItem(0);
    253 }
    254 
    255 void UIChooserModel::addToCurrentItems(UIChooserItem *pItem)
     252    setSelectedItem(0);
     253}
     254
     255void UIChooserModel::addToSelectedItems(UIChooserItem *pItem)
    256256{
    257257    /* Call for wrapper above: */
    258     setCurrentItems(QList<UIChooserItem*>(m_currentItems) << pItem);
    259 }
    260 
    261 void UIChooserModel::removeFromCurrentItems(UIChooserItem *pItem)
     258    setSelectedItems(QList<UIChooserItem*>(m_selectedItems) << pItem);
     259}
     260
     261void UIChooserModel::removeFromSelectedItems(UIChooserItem *pItem)
    262262{
    263263    /* Prepare filtered list: */
    264     QList<UIChooserItem*> list(m_currentItems);
     264    QList<UIChooserItem*> list(m_selectedItems);
    265265    list.removeAll(pItem);
    266266    /* Call for wrapper above: */
    267     setCurrentItems(list);
    268 }
    269 
    270 UIChooserItem *UIChooserModel::currentItem() const
    271 {
    272     /* Return first of current items, if any: */
    273     return currentItems().isEmpty() ? 0 : currentItems().first();
    274 }
    275 
    276 const QList<UIChooserItem*> &UIChooserModel::currentItems() const
    277 {
    278     return m_currentItems;
    279 }
    280 
    281 UIVirtualMachineItem *UIChooserModel::currentMachineItem() const
    282 {
    283     /* Return first machine-item of the current-item: */
    284     return   currentItem() && currentItem()->firstMachineItem() && currentItem()->firstMachineItem()->node()
    285            ? currentItem()->firstMachineItem()->node()->toMachineNode()
     267    setSelectedItems(list);
     268}
     269
     270UIChooserItem *UIChooserModel::firstSelectedItem() const
     271{
     272    /* Return first of selected-items, if any: */
     273    return selectedItems().isEmpty() ? 0 : selectedItems().first();
     274}
     275
     276const QList<UIChooserItem*> &UIChooserModel::selectedItems() const
     277{
     278    return m_selectedItems;
     279}
     280
     281UIVirtualMachineItem *UIChooserModel::firstSelectedMachineItem() const
     282{
     283    /* Return first machine-item of the selected-item: */
     284    return   firstSelectedItem() && firstSelectedItem()->firstMachineItem() && firstSelectedItem()->firstMachineItem()->node()
     285           ? firstSelectedItem()->firstMachineItem()->node()->toMachineNode()
    286286           : 0;
    287287}
    288288
    289 QList<UIVirtualMachineItem*> UIChooserModel::currentMachineItems() const
    290 {
    291     /* Gather list of current unique machine-items: */
     289QList<UIVirtualMachineItem*> UIChooserModel::selectedMachineItems() const
     290{
     291    /* Gather list of selected unique machine-items: */
    292292    QList<UIChooserItemMachine*> currentMachineItemList;
    293     UIChooserItemMachine::enumerateMachineItems(currentItems(), currentMachineItemList,
     293    UIChooserItemMachine::enumerateMachineItems(selectedItems(), currentMachineItemList,
    294294                                                UIChooserItemMachineEnumerationFlag_Unique);
    295295
     
    303303bool UIChooserModel::isGroupItemSelected() const
    304304{
    305     return currentItem() && currentItem()->type() == UIChooserItemType_Group;
     305    return firstSelectedItem() && firstSelectedItem()->type() == UIChooserItemType_Group;
    306306}
    307307
    308308bool UIChooserModel::isGlobalItemSelected() const
    309309{
    310     return currentItem() && currentItem()->type() == UIChooserItemType_Global;
     310    return firstSelectedItem() && firstSelectedItem()->type() == UIChooserItemType_Global;
    311311}
    312312
    313313bool UIChooserModel::isMachineItemSelected() const
    314314{
    315     return currentItem() && currentItem()->type() == UIChooserItemType_Machine;
     315    return firstSelectedItem() && firstSelectedItem()->type() == UIChooserItemType_Machine;
    316316}
    317317
    318318bool UIChooserModel::isSingleGroupSelected() const
    319319{
    320     return    currentItems().size() == 1
    321            && currentItem()->type() == UIChooserItemType_Group;
     320    return    selectedItems().size() == 1
     321           && firstSelectedItem()->type() == UIChooserItemType_Group;
    322322}
    323323
     
    325325{
    326326    /* Make sure at least one item selected: */
    327     if (currentItems().isEmpty())
     327    if (selectedItems().isEmpty())
    328328        return false;
    329329
    330330    /* Determine the parent group of the first item: */
    331     UIChooserItem *pFirstParent = currentItem()->parentItem();
     331    UIChooserItem *pFirstParent = firstSelectedItem()->parentItem();
    332332
    333333    /* Make sure this parent is not main root-item: */
     
    335335        return false;
    336336
    337     /* Enumerate current-item set: */
     337    /* Enumerate selected-item set: */
    338338    QSet<UIChooserItem*> currentItemSet;
    339     foreach (UIChooserItem *pCurrentItem, currentItems())
     339    foreach (UIChooserItem *pCurrentItem, selectedItems())
    340340        currentItemSet << pCurrentItem;
    341341
     
    351351UIChooserItem *UIChooserModel::findClosestUnselectedItem() const
    352352{
    353     /* Take the focus item (if any) as a starting point
    354      * and find the closest non-selected item. */
    355     UIChooserItem *pItem = focusItem();
     353    /* Take the current-item (if any) as a starting point
     354     * and find the closest non-selected-item. */
     355    UIChooserItem *pItem = currentItem();
    356356    if (!pItem)
    357         pItem = currentItem();
     357        pItem = firstSelectedItem();
    358358    if (pItem)
    359359    {
     
    365365            {
    366366                pItem = navigationList().at(idxBefore);
    367                 if (!currentItems().contains(pItem) && pItem->type() == UIChooserItemType_Machine)
     367                if (!selectedItems().contains(pItem) && pItem->type() == UIChooserItemType_Machine)
    368368                    return pItem;
    369369                --idxBefore;
     
    372372            {
    373373                pItem = navigationList().at(idxAfter);
    374                 if (!currentItems().contains(pItem) && pItem->type() == UIChooserItemType_Machine)
     374                if (!selectedItems().contains(pItem) && pItem->type() == UIChooserItemType_Machine)
    375375                    return pItem;
    376376                ++idxAfter;
     
    384384{
    385385    /* Make sure selection list is never empty if at
    386      * least one item (for example 'focus') present: */
    387     if (!currentItem() && focusItem())
    388         setCurrentItem(focusItem());
    389 }
    390 
    391 void UIChooserModel::setFocusItem(UIChooserItem *pItem)
     386     * least one item (for example 'current') present: */
     387    if (!firstSelectedItem() && currentItem())
     388        setSelectedItem(currentItem());
     389}
     390
     391void UIChooserModel::setCurrentItem(UIChooserItem *pItem)
    392392{
    393393    /* Make sure real focus unset: */
     
    395395
    396396    /* Is there something changed? */
    397     if (m_pFocusItem == pItem)
    398         return;
    399 
    400     /* Remember old focus-item: */
    401     UIChooserItem *pOldFocusItem = m_pFocusItem;
    402 
    403     /* Set new focus-item: */
    404     m_pFocusItem = pItem;
    405 
    406     /* Disconnect old focus-item (if any): */
    407     if (pOldFocusItem)
    408         disconnect(pOldFocusItem, SIGNAL(destroyed(QObject*)), this, SLOT(sltFocusItemDestroyed()));
    409     /* Connect new focus-item (if any): */
    410     if (m_pFocusItem)
    411         connect(m_pFocusItem, SIGNAL(destroyed(QObject*)), this, SLOT(sltFocusItemDestroyed()));
     397    if (m_pCurrentItem == pItem)
     398        return;
     399
     400    /* Remember old current-item: */
     401    UIChooserItem *pOldCurrentItem = m_pCurrentItem;
     402
     403    /* Set new current-item: */
     404    m_pCurrentItem = pItem;
     405
     406    /* Disconnect old current-item (if any): */
     407    if (pOldCurrentItem)
     408        disconnect(pOldCurrentItem, SIGNAL(destroyed(QObject*)), this, SLOT(sltCurrentItemDestroyed()));
     409    /* Connect new current-item (if any): */
     410    if (m_pCurrentItem)
     411        connect(m_pCurrentItem, SIGNAL(destroyed(QObject*)), this, SLOT(sltCurrentItemDestroyed()));
    412412
    413413    /* If dialog is visible and item exists => make it visible as well: */
     
    417417}
    418418
    419 UIChooserItem *UIChooserModel::focusItem() const
    420 {
    421     return m_pFocusItem;
     419UIChooserItem *UIChooserModel::currentItem() const
     420{
     421    return m_pCurrentItem;
    422422}
    423423
     
    523523        {
    524524            pItem->makeSureItsVisible();
    525             setCurrentItem(pItem);
     525            setSelectedItem(pItem);
    526526        }
    527527    }
     
    668668        updateLayout();
    669669
     670        /* Make sure selected-item present, if possible: */
     671        if (!firstSelectedItem() && !navigationList().isEmpty())
     672            setSelectedItem(navigationList().first());
    670673        /* Make sure current-item present, if possible: */
    671         if (!currentItem() && !navigationList().isEmpty())
    672             setCurrentItem(navigationList().first());
    673         /* Make sure focus-item present, if possible: */
    674         else if (!focusItem() && currentItem())
    675             setFocusItem(currentItem());
    676         /* Notify about current-item change: */
     674        else if (!currentItem() && firstSelectedItem())
     675            setCurrentItem(firstSelectedItem());
     676        /* Notify about selected-item change: */
    677677        emit sigSelectionChanged();
    678678    }
     
    688688            updateLayout();
    689689
    690             /* Choose newly added item: */
     690            /* Select newly added item: */
    691691            CMachine comMachine = vboxGlobal().virtualBox().FindMachine(uId.toString());
    692             setCurrentItem(root()->searchForItem(comMachine.GetName(),
     692            setSelectedItem(root()->searchForItem(comMachine.GetName(),
    693693                                                 UIChooserItemSearchFlag_Machine |
    694694                                                 UIChooserItemSearchFlag_ExactName));
     
    710710        updateLayout();
    711711
    712         /* Choose newly added item: */
     712        /* Select newly added item: */
    713713        CMachine comMachine = vboxGlobal().virtualBox().FindMachine(uId.toString());
    714         setCurrentItem(root()->searchForItem(comMachine.GetName(),
     714        setSelectedItem(root()->searchForItem(comMachine.GetName(),
    715715                                             UIChooserItemSearchFlag_Machine |
    716716                                             UIChooserItemSearchFlag_ExactName));
     
    719719    {
    720720        /* Make sure at least one item selected after that: */
    721         if (!currentItem() && !navigationList().isEmpty())
    722             setCurrentItem(navigationList().first());
     721        if (!firstSelectedItem() && !navigationList().isEmpty())
     722            setSelectedItem(navigationList().first());
    723723    }
    724724
     
    727727}
    728728
    729 void UIChooserModel::sltFocusItemDestroyed()
    730 {
    731     AssertMsgFailed(("Focus item destroyed!"));
     729void UIChooserModel::sltCurrentItemDestroyed()
     730{
     731    AssertMsgFailed(("Current-item destroyed!"));
    732732}
    733733
     
    742742
    743743    /* Start editing group name: */
    744     currentItem()->startEditing();
     744    firstSelectedItem()->startEditing();
    745745}
    746746
     
    755755
    756756    /* Sort nodes: */
    757     currentItem()->node()->sortNodes();
     757    firstSelectedItem()->node()->sortNodes();
    758758
    759759    /* Rebuild tree for main root: */
     
    769769        return;
    770770
    771     /* Make sure focus item is of group type! */
    772     AssertMsg(focusItem()->type() == UIChooserItemType_Group, ("This is not group-item!"));
     771    /* Make sure current-item is of group type! */
     772    AssertMsg(currentItem()->type() == UIChooserItemType_Group, ("This is not group-item!"));
    773773
    774774    /* Check if we have collisions with our siblings: */
    775     UIChooserItem *pFocusItem = focusItem();
    776     UIChooserNode *pFocusNode = pFocusItem->node();
    777     UIChooserItem *pParentItem = pFocusItem->parentItem();
     775    UIChooserItem *pCurrentItem = currentItem();
     776    UIChooserNode *pCurrentNode = pCurrentItem->node();
     777    UIChooserItem *pParentItem = pCurrentItem->parentItem();
    778778    UIChooserNode *pParentNode = pParentItem->node();
    779779    QList<UIChooserNode*> siblings = pParentNode->nodes();
    780780    QList<UIChooserNode*> toBeRenamed;
    781781    QList<UIChooserNode*> toBeRemoved;
    782     foreach (UIChooserNode *pNode, pFocusNode->nodes())
     782    foreach (UIChooserNode *pNode, pCurrentNode->nodes())
    783783    {
    784784        QString strItemName = pNode->name();
    785785        UIChooserNode *pCollisionSibling = 0;
    786786        foreach (UIChooserNode *pSibling, siblings)
    787             if (pSibling != pFocusNode && pSibling->name() == strItemName)
     787            if (pSibling != pCurrentNode && pSibling->name() == strItemName)
    788788                pCollisionSibling = pSibling;
    789789        if (pCollisionSibling)
     
    811811    /* Copy all the children into our parent: */
    812812    QList<UIChooserItem*> copiedItems;
    813     foreach (UIChooserNode *pNode, pFocusNode->nodes())
     813    foreach (UIChooserNode *pNode, pCurrentNode->nodes())
    814814    {
    815815        if (toBeRemoved.contains(pNode))
     
    842842    }
    843843
    844     /* Delete focus group: */
    845     delete pFocusNode;
     844    /* Delete current group: */
     845    delete pCurrentNode;
    846846
    847847    /* Notify about selection invalidated: */
     
    853853    if (!copiedItems.isEmpty())
    854854    {
    855         setCurrentItems(copiedItems);
    856         setFocusItem(currentItem());
     855        setSelectedItems(copiedItems);
     856        setCurrentItem(firstSelectedItem());
    857857    }
    858858    else
    859         setCurrentItem(navigationList().first());
     859        setSelectedItem(navigationList().first());
    860860    saveGroupSettings();
    861861}
     
    867867        return;
    868868
    869     /* Choose the parent: */
     869    /* Select the parent: */
    870870    UIChooserItem *pGroup = 0;
    871871    if (isSingleGroupSelected())
    872         pGroup = currentItem();
    873     else if (!currentItems().isEmpty())
    874         pGroup = currentItem()->parentItem();
     872        pGroup = firstSelectedItem();
     873    else if (!selectedItems().isEmpty())
     874        pGroup = firstSelectedItem()->parentItem();
    875875    QString strGroupName;
    876876    if (pGroup)
     
    913913    UIChooserItemGroup *pNewGroupItem = new UIChooserItemGroup(root(), pNewGroupNode);
    914914
    915     /* Enumerate all the currently chosen items: */
     915    /* Enumerate all the currently selected-items: */
    916916    QStringList busyGroupNames;
    917917    QStringList busyMachineNames;
    918     QList<UIChooserItem*> selectedItems = currentItems();
    919     foreach (UIChooserItem *pItem, selectedItems)
     918    foreach (UIChooserItem *pItem, selectedItems())
    920919    {
    921920        /* For each of known types: */
     
    959958    updateNavigation();
    960959    updateLayout();
    961     setCurrentItem(pNewGroupItem);
     960    setSelectedItem(pNewGroupItem);
    962961    saveGroupSettings();
    963962}
     
    970969
    971970    /* Only if some item selected: */
    972     if (!currentItem())
     971    if (!firstSelectedItem())
    973972        return;
    974973
    975974    /* Sort nodes: */
    976     currentItem()->parentItem()->node()->sortNodes();
     975    firstSelectedItem()->parentItem()->node()->sortNodes();
    977976
    978977    /* Rebuild tree for main root: */
     
    990989    /* Gather list of current unique inaccessible machine-items: */
    991990    QList<UIChooserItemMachine*> inaccessibleMachineItemList;
    992     UIChooserItemMachine::enumerateMachineItems(currentItems(), inaccessibleMachineItemList,
     991    UIChooserItemMachine::enumerateMachineItems(selectedItems(), inaccessibleMachineItemList,
    993992                                                UIChooserItemMachineEnumerationFlag_Unique |
    994993                                                UIChooserItemMachineEnumerationFlag_Inaccessible);
     
    10191018    {
    10201019        pSelectedItem->makeSureItsVisible();
    1021         setCurrentItem(pSelectedItem);
     1020        setSelectedItem(pSelectedItem);
    10221021    }
    10231022}
     
    10311030    /* Enumerate all the selected machine-items: */
    10321031    QList<UIChooserItemMachine*> selectedMachineItemList;
    1033     UIChooserItemMachine::enumerateMachineItems(currentItems(), selectedMachineItemList);
     1032    UIChooserItemMachine::enumerateMachineItems(selectedItems(), selectedMachineItemList);
    10341033    /* Enumerate all the existing machine-items: */
    10351034    QList<UIChooserItemMachine*> existingMachineItemList;
     
    10681067        /* If selected copy count equal to existing copy count,
    10691068         * we will propose ro unregister machine fully else
    1070          * we will just propose to remove selected items: */
     1069         * we will just propose to remove selected-items: */
    10711070        bool fVerdict = iSelectedCopyCount == iExistingCopyCount;
    10721071        verdicts.insert(uId, fVerdict);
     
    12981297void UIChooserModel::loadLastSelectedItem()
    12991298{
    1300     /* Load last selected item (choose first if unable to load): */
    1301     setCurrentItem(gEDataManager->selectorWindowLastItemChosen());
    1302     if (!currentItem() && !navigationList().isEmpty())
    1303         setCurrentItem(navigationList().first());
     1299    /* Load last selected-item (choose first if unable to load): */
     1300    setSelectedItem(gEDataManager->selectorWindowLastItemChosen());
     1301    if (!firstSelectedItem() && !navigationList().isEmpty())
     1302        setSelectedItem(navigationList().first());
    13041303}
    13051304
    13061305void UIChooserModel::saveLastSelectedItem()
    13071306{
    1308     /* Save last selected item: */
    1309     gEDataManager->setSelectorWindowLastItemChosen(currentItem() ? currentItem()->definition() : QString());
     1307    /* Save last selected-item: */
     1308    gEDataManager->setSelectorWindowLastItemChosen(firstSelectedItem() ? firstSelectedItem()->definition() : QString());
    13101309}
    13111310
     
    13681367                            return false;
    13691368                        /* Is this group-item only the one selected? */
    1370                         if (currentItems().contains(pGroupItem) && currentItems().size() == 1)
     1369                        if (selectedItems().contains(pGroupItem) && selectedItems().size() == 1)
    13711370                        {
    13721371                            /* Group context menu in that case: */
     
    13901389        case QGraphicsSceneContextMenuEvent::Keyboard:
    13911390        {
    1392             /* Get first selected item: */
    1393             if (UIChooserItem *pItem = currentItem())
     1391            /* Get first selected-item: */
     1392            if (UIChooserItem *pItem = firstSelectedItem())
    13941393            {
    13951394                /* If this item of known type? */
     
    14051404                    {
    14061405                        /* Is this group-item only the one selected? */
    1407                         if (currentItems().size() == 1)
     1406                        if (selectedItems().size() == 1)
    14081407                        {
    14091408                            /* Group context menu in that case: */
     
    15191518    updateLayout();
    15201519    if (!navigationList().isEmpty())
    1521         setCurrentItem(navigationList().first());
     1520        setSelectedItem(navigationList().first());
    15221521    else
    1523         unsetCurrentItems();
     1522        clearSelectedItems();
    15241523    saveGroupSettings();
    15251524}
     
    15431542
    15441543    /* Change selection to some close by item: */
    1545     setCurrentItem(findClosestUnselectedItem());
    1546 
    1547     /* For every selected item: */
     1544    setSelectedItem(findClosestUnselectedItem());
     1545
     1546    /* For every selected-item: */
    15481547    for (int iMachineIndex = 0; iMachineIndex < machines.size(); ++iMachineIndex)
    15491548    {
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.h

    r77919 r77933  
    120120    /** @name Selection stuff.
    121121      * @{ */
    122         /** Sets a list of current @a items. */
    123         void setCurrentItems(const QList<UIChooserItem*> &items);
    124         /** Defines current @a pItem. */
    125         void setCurrentItem(UIChooserItem *pItem);
    126         /** Defines current item by @a definition. */
    127         void setCurrentItem(const QString &strDefinition);
    128         /** Unsets all current items. */
    129         void unsetCurrentItems();
    130 
    131         /** Adds @a pItem to list of current. */
    132         void addToCurrentItems(UIChooserItem *pItem);
    133         /** Removes @a pItem from list of current. */
    134         void removeFromCurrentItems(UIChooserItem *pItem);
    135 
    136         /** Returns current item. */
    137         UIChooserItem *currentItem() const;
    138         /** Returns a list of current items. */
    139         const QList<UIChooserItem*> &currentItems() const;
    140 
    141         /** Returns current machine item. */
    142         UIVirtualMachineItem *currentMachineItem() const;
    143         /** Returns a list of current machine items. */
    144         QList<UIVirtualMachineItem*> currentMachineItems() const;
     122        /** Sets a list of selected @a items. */
     123        void setSelectedItems(const QList<UIChooserItem*> &items);
     124        /** Defines selected @a pItem. */
     125        void setSelectedItem(UIChooserItem *pItem);
     126        /** Defines selected-item by @a definition. */
     127        void setSelectedItem(const QString &strDefinition);
     128        /** Clear selected-items list. */
     129        void clearSelectedItems();
     130
     131        /** Adds @a pItem to list of selected. */
     132        void addToSelectedItems(UIChooserItem *pItem);
     133        /** Removes @a pItem from list of selected. */
     134        void removeFromSelectedItems(UIChooserItem *pItem);
     135
     136        /** Returns first selected-item. */
     137        UIChooserItem *firstSelectedItem() const;
     138        /** Returns a list of selected-items. */
     139        const QList<UIChooserItem*> &selectedItems() const;
     140
     141        /** Returns first selected machine item. */
     142        UIVirtualMachineItem *firstSelectedMachineItem() const;
     143        /** Returns a list of selected machine items. */
     144        QList<UIVirtualMachineItem*> selectedMachineItems() const;
    145145
    146146        /** Returns whether group item is selected. */
     
    156156        bool isAllItemsOfOneGroupSelected() const;
    157157
    158         /** Finds closest non-selected item. */
     158        /** Finds closest non-selected-item. */
    159159        UIChooserItem *findClosestUnselectedItem() const;
    160160
     
    162162        void makeSureSomeItemIsSelected();
    163163
    164         /** Defines focus @a pItem. */
    165         void setFocusItem(UIChooserItem *pItem);
    166         /** Returns focus item. */
    167         UIChooserItem *focusItem() const;
     164        /** Defines current @a pItem. */
     165        void setCurrentItem(UIChooserItem *pItem);
     166        /** Returns current-item. */
     167        UIChooserItem *currentItem() const;
    168168    /** @} */
    169169
     
    252252    /** @name Selection stuff.
    253253      * @{ */
    254         /** Handles focus item destruction. */
    255         void sltFocusItemDestroyed();
     254        /** Handles current-item destruction. */
     255        void sltCurrentItemDestroyed();
    256256    /** @} */
    257257
     
    299299        /** Prepares connections. */
    300300        void prepareConnections();
    301         /** Loads last selected items. */
     301        /** Loads last selected-items. */
    302302        void loadLastSelectedItem();
    303303
    304         /** Saves last selected items. */
     304        /** Saves last selected-items. */
    305305        void saveLastSelectedItem();
    306306        /** Cleanups connections. */
     
    373373    /** @name Selection stuff.
    374374      * @{ */
    375         /** Holds the focus item reference. */
    376         QPointer<UIChooserItem>  m_pFocusItem;
     375        /** Holds the current-item reference. */
     376        QPointer<UIChooserItem>  m_pCurrentItem;
    377377    /** @} */
    378378
     
    392392        /** Holds the navigation list. */
    393393        QList<UIChooserItem*>  m_navigationList;
    394         QList<UIChooserItem*>  m_currentItems;
     394        /** Holds the selected-items. */
     395        QList<UIChooserItem*>  m_selectedItems;
    395396
    396397        /** Holds the current drag object instance. */
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