VirtualBox

Ignore:
Timestamp:
Feb 21, 2012 12:48:56 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
76361
Message:

FE/Qt: VM Selector: More predictable VM-list behavior on removing VM-items from VM-list.

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

Legend:

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

    r39932 r40196  
    10371037            int iRow = m_pVMModel->rowById(pItem->id());
    10381038            m_pVMModel->removeItem(pItem);
    1039             m_pVMListView->ensureSomeRowSelected(iRow);
     1039            m_pVMListView->ensureOneRowSelected(iRow);
    10401040        }
    10411041        /* item = 0 is ok (if we originated this event then the item
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMListView.cpp

    r39238 r40196  
    406406}
    407407
    408 void UIVMListView::ensureSomeRowSelected(int aRowHint)
    409 {
    410     UIVMItem *item = currentItem();
    411     if (!item)
    412     {
    413         aRowHint = qBound(0, aRowHint, model()->rowCount() - 1);
    414         selectItemByRow(aRowHint);
    415         item = currentItem();
    416         if (!item)
    417             selectItemByRow(0);
     408void UIVMListView::ensureOneRowSelected(int aRowHint)
     409{
     410    /* Calculate nearest index row: */
     411    aRowHint = qBound(0, aRowHint, model()->rowCount() - 1);
     412
     413    /* Get current selection: */
     414    QModelIndexList selectedIndexes = selectionModel()->selectedIndexes();
     415
     416    /* If there are less/more selected items than necessary
     417     * or other than hinted row is selected: */
     418    if (selectedIndexes.size() != 1 || selectedIndexes[0].row() != aRowHint)
     419    {
     420        /* Make sure that only necessary item is selected: */
     421        setCurrentIndex(model()->index(aRowHint, 0));
     422        selectionModel()->select(currentIndex(), QItemSelectionModel::Current | QItemSelectionModel::ClearAndSelect);
    418423    }
    419424}
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMListView.h

    r39238 r40196  
    9898    void selectItemByRow(int row);
    9999    void selectItemById(const QString &aID);
    100     void ensureSomeRowSelected(int aRowHint);
     100    void ensureOneRowSelected(int aRowHint);
    101101    UIVMItem* currentItem() const;
    102102    QList<UIVMItem*> currentItems() const;
Note: See TracChangeset for help on using the changeset viewer.

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