VirtualBox

Ignore:
Timestamp:
Jan 17, 2024 6:12:12 PM (11 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10513: VM settings / Storage page: More cleanup, mostly sanity checks; Removing some excessive stuff which can be done easier.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIStorageSettingsEditor.cpp

    r102935 r102936  
    717717    /** Sorts the contents of model by @a iColumn and @a enmOrder. */
    718718    void sort(int iColumn = 0, Qt::SortOrder enmOrder = Qt::AscendingOrder);
    719     /** Returns attachment index by specified @a controllerIndex and @a attachmentStorageSlot. */
    720     QModelIndex attachmentBySlot(QModelIndex controllerIndex, StorageSlot attachmentStorageSlot);
    721719
    722720    /** Returns chipset type. */
     
    26412639}
    26422640
    2643 QModelIndex StorageModel::attachmentBySlot(QModelIndex controllerIndex, StorageSlot attachmentStorageSlot)
    2644 {
    2645     /* Check what parent model index is valid, set and of 'controller' type: */
    2646     AssertMsg(controllerIndex.isValid(), ("Controller index should be valid!\n"));
    2647     AbstractItem *pParentItem = static_cast<AbstractItem*>(controllerIndex.internalPointer());
    2648     AssertMsg(pParentItem, ("Parent item should be set!\n"));
    2649     AssertMsg(pParentItem->rtti() == AbstractItem::Type_ControllerItem, ("Parent item should be of 'controller' type!\n"));
    2650     NOREF(pParentItem);
    2651 
    2652     /* Search for suitable attachment one by one: */
    2653     for (int i = 0; i < rowCount(controllerIndex); ++i)
    2654     {
    2655         QModelIndex curAttachmentIndex = index(i, 0, controllerIndex);
    2656         StorageSlot curAttachmentStorageSlot = data(curAttachmentIndex, R_AttSlot).value<StorageSlot>();
    2657         if (curAttachmentStorageSlot ==  attachmentStorageSlot)
    2658             return curAttachmentIndex;
    2659     }
    2660     return QModelIndex();
    2661 }
    2662 
    26632641KChipsetType StorageModel::chipsetType() const
    26642642{
     
    34663444void UIStorageSettingsEditor::sltRemoveController()
    34673445{
     3446    /* Acquire current index: */
    34683447    AssertPtrReturnVoid(m_pTreeViewStorage);
    34693448    const QModelIndex index = m_pTreeViewStorage->currentIndex();
     
    34803459void UIStorageSettingsEditor::sltAddAttachment()
    34813460{
     3461    /* Acquire current index: */
    34823462    AssertPtrReturnVoid(m_pTreeViewStorage);
    34833463    const QModelIndex index = m_pTreeViewStorage->currentIndex();
     
    35373517void UIStorageSettingsEditor::sltRemoveAttachment()
    35383518{
     3519    /* Acquire model, current index and it's parent index: */
    35393520    AssertPtrReturnVoid(m_pTreeViewStorage);
    35403521    const QModelIndex index = m_pTreeViewStorage->currentIndex();
     
    37353716void UIStorageSettingsEditor::sltSetInformation()
    37363717{
     3718    /* Acquire current index: */
    37373719    AssertPtrReturnVoid(m_pTreeViewStorage);
    37383720    const QModelIndex index = m_pTreeViewStorage->currentIndex();
     
    37733755                StorageSlot attachmentStorageSlot = gpConverter->fromString<StorageSlot>(m_pComboSlot->currentText());
    37743756                m_pModelStorage->setData(index, QVariant::fromValue(attachmentStorageSlot), StorageModel::R_AttSlot);
    3775                 QModelIndex theSameIndexAtNewPosition = m_pModelStorage->attachmentBySlot(controllerIndex, attachmentStorageSlot);
    3776                 AssertMsg(theSameIndexAtNewPosition.isValid(), ("Current attachment disappears!\n"));
    3777                 m_pTreeViewStorage->setCurrentIndex(theSameIndexAtNewPosition);
     3757                for (int iAttachmentIndex = 0; iAttachmentIndex < m_pModelStorage->rowCount(controllerIndex); ++iAttachmentIndex)
     3758                {
     3759                    QModelIndex enumeratedIndex = m_pModelStorage->index(iAttachmentIndex, 0, controllerIndex);
     3760                    StorageSlot enumeratedStorageSlot = m_pModelStorage->data(enumeratedIndex, StorageModel::R_AttSlot).value<StorageSlot>();
     3761                    if (enumeratedStorageSlot == attachmentStorageSlot)
     3762                    {
     3763                        m_pTreeViewStorage->setCurrentIndex(enumeratedIndex);
     3764                        break;
     3765                    }
     3766                }
    37783767            }
    37793768            /* Setting attachment medium: */
     
    39393928void UIStorageSettingsEditor::sltUpdateActionStates()
    39403929{
     3930    /* Acquire current index: */
    39413931    AssertPtrReturnVoid(m_pTreeViewStorage);
    39423932    const QModelIndex index = m_pTreeViewStorage->currentIndex();
     
    39913981void UIStorageSettingsEditor::sltHandleRowInsertion(const QModelIndex &parentIndex, int iPosition)
    39923982{
    3993     AssertPtrReturnVoid(m_pModelStorage);
     3983    /* Acquire current index: */
    39943984    AssertPtrReturnVoid(m_pTreeViewStorage);
    39953985    const QModelIndex index = m_pModelStorage->index(iPosition, 0, parentIndex);
     
    43494339
    43504340    /* Check what item we are hovering currently: */
     4341    AssertPtrReturnVoid(m_pTreeViewStorage);
    43514342    QModelIndex index = m_pTreeViewStorage->indexAt(pEvent->position().toPoint());
    43524343    /* And make sure this is controller item, we are supporting dropping for this kind only: */
     4344    AssertPtrReturnVoid(m_pModelStorage);
    43534345    if (   !m_pModelStorage->data(index, StorageModel::R_IsController).toBool()
    43544346        || m_pModelStorage->data(index, StorageModel::R_ItemId).toString() == strControllerId)
     
    43764368
    43774369    /* Check what item we are hovering currently: */
     4370    AssertPtrReturnVoid(m_pTreeViewStorage);
    43784371    QModelIndex index = m_pTreeViewStorage->indexAt(pEvent->position().toPoint());
    43794372    /* And make sure this is controller item, we are supporting dropping for this kind only: */
     4373    AssertPtrReturnVoid(m_pModelStorage);
    43804374    if (m_pModelStorage->data(index, StorageModel::R_IsController).toBool())
    43814375    {
     
    50865080#ifdef RT_STRICT
    50875081    AssertPtrReturnVoid(m_pTreeViewStorage);
     5082    AssertPtrReturnVoid(m_pModelStorage);
    50885083    const QModelIndex index = m_pTreeViewStorage->currentIndex();
    50895084    switch (enmBus)
     
    51285123void UIStorageSettingsEditor::addAttachmentWrapper(KDeviceType enmDeviceType)
    51295124{
     5125    /* Acquire current index: */
    51305126    AssertPtrReturnVoid(m_pTreeViewStorage);
    51315127    const QModelIndex index = m_pTreeViewStorage->currentIndex();
     5128    AssertPtrReturnVoid(m_pModelStorage);
    51325129    Assert(m_pModelStorage->data(index, StorageModel::R_IsController).toBool());
    51335130    Assert(m_pModelStorage->data(index, StorageModel::R_IsMoreAttachmentsPossible).toBool());
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