VirtualBox

Ignore:
Timestamp:
Feb 21, 2012 3:39:22 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
76368
Message:

FE/Qt: VM selector: Multi-selection mechanism cleanup.

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

Legend:

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

    r40196 r40202  
    273273    /* Show New Machine wizard: */
    274274    UINewVMWzd wizard(this);
    275     if (wizard.exec() == QDialog::Accepted)
    276     {
    277         /* Wait until the list is updated by OnMachineRegistered(): */
    278         const CMachine &machine = wizard.machine();
    279         QModelIndex index;
    280         while(!index.isValid())
    281         {
    282             qApp->processEvents();
    283             index = m_pVMModel->indexById(machine.GetId());
    284         }
    285         /* Choose newly created item: */
    286         m_pVMListView->setCurrentIndex(index);
    287     }
     275    wizard.exec();
    288276}
    289277
     
    326314                /* Register that machine: */
    327315                vbox.RegisterMachine(newMachine);
    328                 /* Wait until the list is updated by OnMachineRegistered(): */
    329                 QModelIndex index;
    330                 while(!index.isValid())
    331                 {
    332                     qApp->processEvents();
    333                     index = m_pVMModel->indexById(newMachine.GetId());
    334                 }
    335                 /* And choose added item: */
    336                 m_pVMListView->setCurrentIndex(index);
    337316            }
    338317            else
     
    1014993void UISelectorWindow::sltMachineRegistered(QString strMachineId, bool fRegistered)
    1015994{
     995    /* Add/remove VM: */
    1016996    if (fRegistered)
    1017997    {
    1018         CVirtualBox vbox = vboxGlobal().virtualBox();
    1019         CMachine m = vbox.FindMachine(strMachineId);
     998        CMachine m = vboxGlobal().virtualBox().FindMachine(strMachineId);
    1020999        if (!m.isNull())
    10211000        {
    10221001            m_pVMModel->addItem(m);
    1023             /* Make sure the description, ... pages are properly updated.
    1024              * Actually we haven't call the next method, but unfortunately Qt
    1025              * seems buggy if the new item is on the same position as the
    1026              * previous one. So go on the safe side and call this by our self. */
    1027             sltCurrentVMItemChanged();
     1002            int iRow = m_pVMModel->rowById(strMachineId);
     1003            m_pVMListView->ensureOneRowSelected(iRow);
    10281004        }
    10291005        /* m.isNull() is ok (theoretically, the machine could have been
     
    10351011        if (pItem)
    10361012        {
    1037             int iRow = m_pVMModel->rowById(pItem->id());
     1013            int iRow = m_pVMModel->rowById(strMachineId);
    10381014            m_pVMModel->removeItem(pItem);
    10391015            m_pVMListView->ensureOneRowSelected(iRow);
     
    10421018         * has been already removed) */
    10431019    }
     1020    /* Make sure all updated: */
     1021    sltCurrentVMItemChanged();
    10441022}
    10451023
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMListView.cpp

    r40196 r40202  
    77
    88/*
    9  * Copyright (C) 2006-2010 Oracle Corporation
     9 * Copyright (C) 2006-2012 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    394394{
    395395    setCurrentIndex(model()->index(row, 0));
     396    selectionModel()->select(currentIndex(), QItemSelectionModel::Current | QItemSelectionModel::ClearAndSelect);
    396397}
    397398
     
    417418     * or other than hinted row is selected: */
    418419    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);
    423     }
     420        selectItemByRow(aRowHint);
    424421}
    425422
     
    458455    /* If selection is empty => select 'current item': */
    459456    if (selectionModel()->selectedIndexes().isEmpty())
    460         selectionModel()->select(currentIndex(), QItemSelectionModel::SelectCurrent);
     457        selectionModel()->select(currentIndex(), QItemSelectionModel::Current | QItemSelectionModel::ClearAndSelect);
    461458
    462459    /* Ensure current index is visible: */
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