VirtualBox

Changeset 102958 in vbox for trunk/src


Ignore:
Timestamp:
Jan 18, 2024 6:43:05 PM (11 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10513: VM settings / Storage page: Simplify for Basic experience mode; Hiding controller items and actions.

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  
    31733173    }
    31743174
    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();
    31823177
    31833178    /* Fetch recent information: */
     
    33273322}
    33283323
     3324void 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
    33293340void UIStorageSettingsEditor::sltHandleMediumEnumerated(const QUuid &uMediumId)
    33303341{
     
    41044115void UIStorageSettingsEditor::sltHandleDrawItemBranches(QPainter *pPainter, const QRect &rect, const QModelIndex &index)
    41054116{
     4117    /* Do nothing for Basic experience mode:  */
     4118    if (!m_fInExpertMode)
     4119        return;
     4120
    41064121    /* Acquire model: */
    41074122    AssertPtrReturnVoid(m_pTreeViewStorage);
     
    51205135}
    51215136
     5137void 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
    51225179void UIStorageSettingsEditor::addControllerWrapper(const QString &strName, KStorageBus enmBus, KStorageControllerType enmType)
    51235180{
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIStorageSettingsEditor.h

    r101868 r102958  
    223223    /** Handles show @a pEvent. */
    224224    virtual void showEvent(QShowEvent *pEvent) RT_OVERRIDE;
     225
     226    /** Handles filter change. */
     227    virtual void handleFilterChange() RT_OVERRIDE;
    225228
    226229private slots:
     
    343346    /** Cleanups all. */
    344347    void cleanup();
     348
     349    /** Updates root and current index most suitable for this editor. */
     350    void updateRootAndCurrentIndexes();
    345351
    346352    /** Adds controller with @a strName, @a enmBus and @a enmType. */
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