Changeset 102936 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Jan 17, 2024 6:12:12 PM (11 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIStorageSettingsEditor.cpp
r102935 r102936 717 717 /** Sorts the contents of model by @a iColumn and @a enmOrder. */ 718 718 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);721 719 722 720 /** Returns chipset type. */ … … 2641 2639 } 2642 2640 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 2663 2641 KChipsetType StorageModel::chipsetType() const 2664 2642 { … … 3466 3444 void UIStorageSettingsEditor::sltRemoveController() 3467 3445 { 3446 /* Acquire current index: */ 3468 3447 AssertPtrReturnVoid(m_pTreeViewStorage); 3469 3448 const QModelIndex index = m_pTreeViewStorage->currentIndex(); … … 3480 3459 void UIStorageSettingsEditor::sltAddAttachment() 3481 3460 { 3461 /* Acquire current index: */ 3482 3462 AssertPtrReturnVoid(m_pTreeViewStorage); 3483 3463 const QModelIndex index = m_pTreeViewStorage->currentIndex(); … … 3537 3517 void UIStorageSettingsEditor::sltRemoveAttachment() 3538 3518 { 3519 /* Acquire model, current index and it's parent index: */ 3539 3520 AssertPtrReturnVoid(m_pTreeViewStorage); 3540 3521 const QModelIndex index = m_pTreeViewStorage->currentIndex(); … … 3735 3716 void UIStorageSettingsEditor::sltSetInformation() 3736 3717 { 3718 /* Acquire current index: */ 3737 3719 AssertPtrReturnVoid(m_pTreeViewStorage); 3738 3720 const QModelIndex index = m_pTreeViewStorage->currentIndex(); … … 3773 3755 StorageSlot attachmentStorageSlot = gpConverter->fromString<StorageSlot>(m_pComboSlot->currentText()); 3774 3756 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 } 3778 3767 } 3779 3768 /* Setting attachment medium: */ … … 3939 3928 void UIStorageSettingsEditor::sltUpdateActionStates() 3940 3929 { 3930 /* Acquire current index: */ 3941 3931 AssertPtrReturnVoid(m_pTreeViewStorage); 3942 3932 const QModelIndex index = m_pTreeViewStorage->currentIndex(); … … 3991 3981 void UIStorageSettingsEditor::sltHandleRowInsertion(const QModelIndex &parentIndex, int iPosition) 3992 3982 { 3993 AssertPtrReturnVoid(m_pModelStorage);3983 /* Acquire current index: */ 3994 3984 AssertPtrReturnVoid(m_pTreeViewStorage); 3995 3985 const QModelIndex index = m_pModelStorage->index(iPosition, 0, parentIndex); … … 4349 4339 4350 4340 /* Check what item we are hovering currently: */ 4341 AssertPtrReturnVoid(m_pTreeViewStorage); 4351 4342 QModelIndex index = m_pTreeViewStorage->indexAt(pEvent->position().toPoint()); 4352 4343 /* And make sure this is controller item, we are supporting dropping for this kind only: */ 4344 AssertPtrReturnVoid(m_pModelStorage); 4353 4345 if ( !m_pModelStorage->data(index, StorageModel::R_IsController).toBool() 4354 4346 || m_pModelStorage->data(index, StorageModel::R_ItemId).toString() == strControllerId) … … 4376 4368 4377 4369 /* Check what item we are hovering currently: */ 4370 AssertPtrReturnVoid(m_pTreeViewStorage); 4378 4371 QModelIndex index = m_pTreeViewStorage->indexAt(pEvent->position().toPoint()); 4379 4372 /* And make sure this is controller item, we are supporting dropping for this kind only: */ 4373 AssertPtrReturnVoid(m_pModelStorage); 4380 4374 if (m_pModelStorage->data(index, StorageModel::R_IsController).toBool()) 4381 4375 { … … 5086 5080 #ifdef RT_STRICT 5087 5081 AssertPtrReturnVoid(m_pTreeViewStorage); 5082 AssertPtrReturnVoid(m_pModelStorage); 5088 5083 const QModelIndex index = m_pTreeViewStorage->currentIndex(); 5089 5084 switch (enmBus) … … 5128 5123 void UIStorageSettingsEditor::addAttachmentWrapper(KDeviceType enmDeviceType) 5129 5124 { 5125 /* Acquire current index: */ 5130 5126 AssertPtrReturnVoid(m_pTreeViewStorage); 5131 5127 const QModelIndex index = m_pTreeViewStorage->currentIndex(); 5128 AssertPtrReturnVoid(m_pModelStorage); 5132 5129 Assert(m_pModelStorage->data(index, StorageModel::R_IsController).toBool()); 5133 5130 Assert(m_pModelStorage->data(index, StorageModel::R_IsMoreAttachmentsPossible).toBool());
Note:
See TracChangeset
for help on using the changeset viewer.