VirtualBox

Changeset 50343 in vbox


Ignore:
Timestamp:
Feb 6, 2014 2:12:00 PM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: 4397: Medium Manager cleanup/rework (part 7): Few comments, doxies and variable-names.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.cpp

    r50340 r50343  
    146146
    147147
    148 /** Functor allowing to check if passed UIMediumItem is suitable by ID. */
     148/** Functor allowing to check if passed UIMediumItem is suitable by @a strID. */
    149149class CheckIfSuitableByID : public CheckIfSuitableBy
    150150{
    151151public:
    152     /** Constructor. */
     152    /** Constructor accepting @a strID to compare with. */
    153153    CheckIfSuitableByID(const QString &strID) : m_strID(strID) {}
    154154
    155155private:
    156     /** Determines whether passed UIMediumItem is suitable by ID. */
     156    /** Determines whether passed UIMediumItem is suitable by @a strID. */
    157157    bool isItSuitable(UIMediumItem *pItem) const { return pItem->id() == m_strID; }
    158     /** Holds the ID to compare to. */
     158    /** Holds the @a strID to compare to. */
    159159    QString m_strID;
    160160};
     
    164164{
    165165public:
    166     /** Constructor. */
     166    /** Constructor accepting @a state to compare with. */
    167167    CheckIfSuitableByState(KMediumState state) : m_state(state) {}
    168168
     
    175175
    176176
    177 /* Medium manager progress-bar: */
     177/** Medium manager progress-bar.
     178  * Reflects medium-enumeration progress, stays hidden otherwise. */
    178179class UIEnumerationProgressBar : public QWidget
    179180{
     
    182183public:
    183184
    184     /* Constructor: */
     185    /** Constructor on the basis of passed @a pParent. */
    185186    UIEnumerationProgressBar(QWidget *pParent)
    186187        : QWidget(pParent)
     
    190191    }
    191192
    192     /* API: Text stuff: */
    193     void setText(const QString &strText) { mText->setText(strText); }
    194 
    195     /* API: Value stuff: */
     193    /** Defines progress-bar label-text. */
     194    void setText(const QString &strText) { m_pLabel->setText(strText); }
     195
     196    /** Returns progress-bar current-value. */
    196197    int value() const { return m_pProgressBar->value(); }
     198    /** Defines progress-bar current-value. */
    197199    void setValue(int iValue) { m_pProgressBar->setValue(iValue); }
     200    /** Defines progress-bar maximum-value. */
    198201    void setMaximum(int iValue) { m_pProgressBar->setMaximum(iValue); }
    199202
    200203private:
    201204
    202     /* Helper: Prepare stuff: */
     205    /** Prepares progress-bar content. */
    203206    void prepare()
    204207    {
     
    209212            pLayout->setContentsMargins(0, 0, 0, 0);
    210213            /* Create label: */
    211             mText = new QLabel;
     214            m_pLabel = new QLabel;
    212215            /* Create progress-bar: */
    213216            m_pProgressBar = new QProgressBar;
     
    217220            }
    218221            /* Add widgets into layout: */
    219             pLayout->addWidget(mText);
     222            pLayout->addWidget(m_pLabel);
    220223            pLayout->addWidget(m_pProgressBar);
    221224        }
    222225    }
    223226
    224     /* Widgets: */
    225     QLabel *mText;
     227    /** Progress-bar label. */
     228    QLabel *m_pLabel;
     229    /** Progress-bar itself. */
    226230    QProgressBar *m_pProgressBar;
    227231};
     
    313317    updateTabIcons(pMediumItem, ItemAction_Removed);
    314318
    315     /* We need to silently delete item without selecting
     319    /* We need to silently delete medium-item without selecting
    316320     * the new one because of complex selection mechanism
    317321     * which could provoke a segfault choosing the new
     
    322326    pTree->blockSignals(false);
    323327
    324     /* Set new current-item: */
     328    /* Make sure current medium-item is selected: */
    325329    setCurrentItem(pTree, pTree->currentItem());
    326330}
     
    388392void UIMediumManager::sltCopyMedium()
    389393{
    390     /* Get current-item: */
     394    /* Get current medium-item: */
    391395    UIMediumItem *pMediumItem = currentMediumItem();
     396    AssertMsgReturnVoid(pMediumItem, ("Current item must not be null"));
     397    AssertReturnVoid(!pMediumItem->id().isNull());
    392398
    393399    /* Show Clone VD wizard: */
     
    403409void UIMediumManager::sltModifyMedium()
    404410{
    405     /* Get current-item: */
     411    /* Get current medium-item: */
    406412    UIMediumItem *pMediumItem = currentMediumItem();
     413    AssertMsgReturnVoid(pMediumItem, ("Current item must not be null"));
     414    AssertReturnVoid(!pMediumItem->id().isNull());
    407415
    408416    /* Show Modify VD dialog: */
     
    410418    if (pDialog->exec() == QDialog::Accepted)
    411419    {
    412         /* Safe spot because if dialog is deleted inside ::exec() =>
    413          * returned result will be QDialog::Rejected. */
     420        /* Update medium-item: */
    414421        pMediumItem->refreshAll();
    415         m_pTypePane->setText(pMediumItem->hardDiskType());
     422        /* Update HD information-panes: */
     423        updateInformationPanesHD();
    416424    }
    417425
     
    426434    UIMediumItem *pMediumItem = currentMediumItem();
    427435    AssertMsgReturnVoid(pMediumItem, ("Current item must not be null"));
     436    AssertReturnVoid(!pMediumItem->id().isNull());
    428437
    429438    /* Remember ID/type as they may get lost after the closure/deletion: */
     
    561570void UIMediumManager::sltHandleCurrentTabChanged()
    562571{
    563     /* Get current-tree: */
     572    /* Get current tree-widget: */
    564573    QTreeWidget *pTree = currentTreeWidget();
    565574
    566     /* If other tree was focused previously, moving focus to new tree: */
     575    /* If another tree-widget was focused before,
     576     * move focus to current tree-widget: */
    567577    if (qobject_cast<QTreeWidget*>(focusWidget()))
    568578        pTree->setFocus();
    569579
    570     /* Update current tree-item: */
     580    /* Make sure current medium-item is selected: */
    571581    sltHandleCurrentItemChanged(pTree->currentItem());
    572582}
     
    575585                                                  QTreeWidgetItem *pPrevItem /* = 0 */)
    576586{
    577     /* Get medium-item: */
     587    /* Get current medium-item: */
    578588    UIMediumItem *pMediumItem = toMediumItem(pItem);
    579589
    580     /* We have to make sure some item is always selected: */
     590    /* We have to make sure some medium-item is always selected: */
    581591    if (!pMediumItem && pPrevItem)
    582592    {
    583         /* If the new item is 0, set the old item again. */
     593        /* If new medium-item is 0, choose the old one again. */
    584594        UIMediumItem *pPrevMediumItem = toMediumItem(pPrevItem);
    585595        setCurrentItem(currentTreeWidget(), pPrevMediumItem);
    586596    }
    587597
     598    /* If item is set: */
    588599    if (pMediumItem)
    589600    {
    590601        /* Set the file for the proxy icon: */
    591602        setFileForProxyIcon(pMediumItem->location());
    592         /* Ensures current item visible every time we are switching page: */
     603        /* Make sure current medium-item visible: */
    593604        pMediumItem->treeWidget()->scrollToItem(pMediumItem, QAbstractItemView::EnsureVisible);
    594605    }
     
    603614void UIMediumManager::sltHandleDoubleClick()
    604615{
    605     /* Call for modify-action if hard-disk double-clicked: */
     616    /* Call for modify-action if hard-drive medium-item double-clicked: */
    606617    if (currentMediumType() == UIMediumType_HardDisk)
    607618        sltModifyMedium();
     
    610621void UIMediumManager::sltHandleContextMenuCall(const QPoint &position)
    611622{
    612     /* Get surrent widget/item: */
     623    /* Get corresponding widget/item: */
    613624    QTreeWidget *pTree = currentTreeWidget();
    614625    QTreeWidgetItem *pItem = pTree->itemAt(position);
     
    617628        /* Make sure the item is selected and current: */
    618629        setCurrentItem(pTree, pItem);
    619         /* Show context menu: */
     630        /* Show item context menu: */
    620631        m_pContextMenu->exec(pTree->viewport()->mapToGlobal(position));
    621632    }
     
    870881    /* Tab-widget created in .ui file. */
    871882    {
    872         /* Setup tab-widget: */
     883        /* Configure tab-widget: */
    873884        mTabWidget->setFocusPolicy(Qt::TabFocus);
    874885        mTabWidget->setTabIcon(HDTab, m_iconHD);
     
    896907    /* HD tree-widget created in .ui file. */
    897908    {
    898         /* Setup HD tree-widget: */
     909        /* Configure HD tree-widget: */
    899910        mTwHD->setColumnCount(3);
    900911        mTwHD->sortItems(0, Qt::AscendingOrder);
     
    921932    /* CD tree-widget created in .ui file. */
    922933    {
    923         /* Setup CD tree-widget: */
     934        /* Configure CD tree-widget: */
    924935        mTwCD->setColumnCount(2);
    925936        mTwCD->sortItems(0, Qt::AscendingOrder);
     
    945956    /* FD tree-widget created in .ui file. */
    946957    {
    947         /* Setup FD tree-widget: */
     958        /* Configure FD tree-widget: */
    948959        mTwFD->setColumnCount(2);
    949960        mTwFD->sortItems(0, Qt::AscendingOrder);
     
    9921003    m_pProgressBar = new UIEnumerationProgressBar(this);
    9931004    {
    994         /* Hidden by default: */
     1005        /* Configure progress-bar: */
    9951006        m_pProgressBar->hide();
    996         /* Integrate to the button-box: */
    9971007        mButtonBox->addExtraWidget(m_pProgressBar);
    9981008    }
     
    10231033    mTwFD->clear();
    10241034
    1025     /* Populate all medium-items: */
     1035    /* Create medium-items: */
    10261036    foreach (const QString &strMediumID, vboxGlobal().mediumIDs())
    10271037        sltHandleMediumCreated(strMediumID);
    10281038
    1029     /* Select first-item as current medium-item if nothing selected: */
     1039    /* Select first medium-item as current one if nothing selected: */
    10301040    if (!mediumItem(UIMediumType_HardDisk))
    10311041        if (QTreeWidgetItem *pItem = mTwHD->topLevelItem(0))
     
    10411051void UIMediumManager::updateActions()
    10421052{
    1043     /* Get current-item: */
    1044     UIMediumItem *pCurrentItem = currentMediumItem();
     1053    /* Get current medium-item: */
     1054    UIMediumItem *pMediumItem = currentMediumItem();
    10451055
    10461056    /* Calculate actions accessibility: */
    10471057    bool fNotInEnumeration = !vboxGlobal().isMediumEnumerationInProgress();
    10481058    bool fActionEnabledCopy = currentMediumType() == UIMediumType_HardDisk &&
    1049                               fNotInEnumeration && pCurrentItem && checkMediumFor(pCurrentItem, Action_Copy);
     1059                              fNotInEnumeration && pMediumItem && checkMediumFor(pMediumItem, Action_Copy);
    10501060    bool fActionEnabledModify = currentMediumType() == UIMediumType_HardDisk &&
    1051                                 fNotInEnumeration && pCurrentItem && checkMediumFor(pCurrentItem, Action_Modify);
    1052     bool fActionEnabledRemove = fNotInEnumeration && pCurrentItem && checkMediumFor(pCurrentItem, Action_Remove);
    1053     bool fActionEnabledRelease = fNotInEnumeration && pCurrentItem && checkMediumFor(pCurrentItem, Action_Release);
    1054 
    1055     /* Update actions: */
     1061                                fNotInEnumeration && pMediumItem && checkMediumFor(pMediumItem, Action_Modify);
     1062    bool fActionEnabledRemove = fNotInEnumeration && pMediumItem && checkMediumFor(pMediumItem, Action_Remove);
     1063    bool fActionEnabledRelease = fNotInEnumeration && pMediumItem && checkMediumFor(pMediumItem, Action_Release);
     1064
     1065    /* Apply actions accessibility: */
    10561066    m_pActionCopy->setEnabled(fActionEnabledCopy);
    10571067    m_pActionModify->setEnabled(fActionEnabledModify);
     
    11671177void UIMediumManager::updateInformationPanesHD()
    11681178{
    1169     /* Get current HD item: */
     1179    /* Get current hard-drive medium-item: */
    11701180    UIMediumItem *pCurrentItem = mediumItem(UIMediumType_HardDisk);
    11711181
     
    16691679    AssertReturn(!medium.medium().isNull(), 0);
    16701680
    1671     /* Search for medium-item: */
     1681    /* Search for existing medium-item: */
    16721682    UIMediumItem *pMediumItem = searchItem(pTree, CheckIfSuitableByID(medium.id()));
    16731683
     
    16831693            if (!pParentMediumItem)
    16841694            {
    1685                 /* Make sure such corresponding parent medium is already cached! */
     1695                /* Make sure corresponding parent medium is already cached! */
    16861696                UIMedium parentMedium = vboxGlobal().medium(medium.parentID());
    16871697                if (parentMedium.isNull())
     
    17061716    }
    17071717
    1708     /* Return medium-item: */
     1718    /* Return created medium-item: */
    17091719    return pMediumItem;
    17101720}
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