- Timestamp:
- Jan 18, 2024 6:43:05 PM (11 months ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/settings/editors
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIStorageSettingsEditor.cpp
r102951 r102958 3173 3173 } 3174 3174 3175 /* Choose first controller as current: */ 3176 AssertPtrReturnVoid(m_pTreeViewStorage); 3177 const QAbstractItemModel *pModel = m_pTreeViewStorage->model(); 3178 AssertPtrReturnVoid(pModel); 3179 const QModelIndex rootIndex = pModel->index(0, 0); 3180 if (pModel->rowCount(rootIndex) > 0) 3181 m_pTreeViewStorage->setCurrentIndex(pModel->index(0, 0, rootIndex)); 3175 /* Update root and current indexes: */ 3176 updateRootAndCurrentIndexes(); 3182 3177 3183 3178 /* Fetch recent information: */ … … 3327 3322 } 3328 3323 3324 void UIStorageSettingsEditor::handleFilterChange() 3325 { 3326 /* First of all we could remap view's root to 3327 * something more appropriate to current mode. 3328 * In Basic mode we no need controllers. */ 3329 updateRootAndCurrentIndexes(); 3330 3331 /* Update action visibility. In Basic mode 3332 * we no need controller actions as well. */ 3333 m_pActionAddController->setVisible(m_fInExpertMode); 3334 m_pActionRemoveController->setVisible(m_fInExpertMode); 3335 3336 /* We should also redraw branches if any: */ 3337 update(); 3338 } 3339 3329 3340 void UIStorageSettingsEditor::sltHandleMediumEnumerated(const QUuid &uMediumId) 3330 3341 { … … 4104 4115 void UIStorageSettingsEditor::sltHandleDrawItemBranches(QPainter *pPainter, const QRect &rect, const QModelIndex &index) 4105 4116 { 4117 /* Do nothing for Basic experience mode: */ 4118 if (!m_fInExpertMode) 4119 return; 4120 4106 4121 /* Acquire model: */ 4107 4122 AssertPtrReturnVoid(m_pTreeViewStorage); … … 5120 5135 } 5121 5136 5137 void UIStorageSettingsEditor::updateRootAndCurrentIndexes() 5138 { 5139 /* Acquire model: */ 5140 AssertPtrReturnVoid(m_pTreeViewStorage); 5141 const QAbstractItemModel *pModel = m_pTreeViewStorage->model(); 5142 AssertPtrReturnVoid(pModel); 5143 5144 /* What indexes we wish to make current/root of the view? */ 5145 QModelIndex currentIndex; 5146 QModelIndex rootIndex; 5147 5148 /* Select the model's root index. 5149 * It contains all the controllers we have: */ 5150 currentIndex = pModel->index(0, 0); 5151 /* Map the view to this selection: */ 5152 rootIndex = currentIndex; 5153 /* But if we have at least one controller: */ 5154 if (pModel->rowCount(currentIndex) > 0) 5155 { 5156 /* Why not select it as well? 5157 * It contains all the attachments we have (there): */ 5158 currentIndex = pModel->index(0, 0, currentIndex); 5159 /* For Basic experience mode: */ 5160 if (!m_fInExpertMode) 5161 { 5162 /* Map the view to this selection: */ 5163 rootIndex = currentIndex; 5164 /* But if we have at least one attachment: */ 5165 if (pModel->rowCount(currentIndex) > 0) 5166 { 5167 /* Why not select it as well? 5168 * It's useful for Basic experience mode: */ 5169 currentIndex = pModel->index(0, 0, currentIndex); 5170 } 5171 } 5172 } 5173 5174 /* Use the indexes we found: */ 5175 m_pTreeViewStorage->setRootIndex(rootIndex); 5176 m_pTreeViewStorage->setCurrentIndex(currentIndex); 5177 } 5178 5122 5179 void UIStorageSettingsEditor::addControllerWrapper(const QString &strName, KStorageBus enmBus, KStorageControllerType enmType) 5123 5180 { -
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIStorageSettingsEditor.h
r101868 r102958 223 223 /** Handles show @a pEvent. */ 224 224 virtual void showEvent(QShowEvent *pEvent) RT_OVERRIDE; 225 226 /** Handles filter change. */ 227 virtual void handleFilterChange() RT_OVERRIDE; 225 228 226 229 private slots: … … 343 346 /** Cleanups all. */ 344 347 void cleanup(); 348 349 /** Updates root and current index most suitable for this editor. */ 350 void updateRootAndCurrentIndexes(); 345 351 346 352 /** Adds controller with @a strName, @a enmBus and @a enmType. */
Note:
See TracChangeset
for help on using the changeset viewer.