VirtualBox

Changeset 100960 in vbox


Ignore:
Timestamp:
Aug 23, 2023 5:15:29 PM (14 months ago)
Author:
vboxsync
Message:

FE/Qt: UISettingsDialog: Cleanup for settings selector stuff; A bit of excessive methods which were never used; Some stuff related to wrong names and comments.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/settings
Files:
3 edited

Legend:

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

    r100959 r100960  
    625625
    626626    /* Prepare classical tree-view selector: */
    627     m_pSelector = new UISettingsSelectorTreeView(centralWidget());
     627    m_pSelector = new UISettingsSelectorTreeWidget(centralWidget());
    628628    if (m_pSelector)
    629629    {
     
    657657    /* Configure selector created above: */
    658658    if (m_pSelector)
    659         connect(m_pSelector, &UISettingsSelectorTreeView::sigCategoryChanged,
     659        connect(m_pSelector, &UISettingsSelectorTreeWidget::sigCategoryChanged,
    660660                this, &UISettingsDialog::sltCategoryChanged);
    661661}
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsSelector.cpp

    r98103 r100960  
    254254}
    255255
    256 QList<QWidget*> UISettingsSelector::rootPages() const
    257 {
    258     QList<QWidget*> list;
    259     foreach (UISelectorItem *pItem, m_list)
    260         if (pItem->page())
    261             list << pItem->page();
    262     return list;
    263 }
    264 
    265256UISelectorItem *UISettingsSelector::findItem(int iID) const
    266257{
     
    301292
    302293/*********************************************************************************************************************************
    303 *   Class UISettingsSelectorTreeView implementation.                                                                             *
     294*   Class UISettingsSelectorTreeWidget implementation.                                                                           *
    304295*********************************************************************************************************************************/
    305296
    306 UISettingsSelectorTreeView::UISettingsSelectorTreeView(QWidget *pParent /* = 0 */)
     297UISettingsSelectorTreeWidget::UISettingsSelectorTreeWidget(QWidget *pParent /* = 0 */)
    307298    : UISettingsSelector(pParent)
    308299    , m_pTreeWidget(0)
     
    332323    /* Setup connections: */
    333324    connect(m_pTreeWidget, &QITreeWidget::currentItemChanged,
    334             this, &UISettingsSelectorTreeView::sltSettingsGroupChanged);
    335 }
    336 
    337 UISettingsSelectorTreeView::~UISettingsSelectorTreeView()
     325            this, &UISettingsSelectorTreeWidget::sltSettingsGroupChanged);
     326}
     327
     328UISettingsSelectorTreeWidget::~UISettingsSelectorTreeWidget()
    338329{
    339330    /* Cleanup the tree-widget: */
     
    342333}
    343334
    344 QWidget *UISettingsSelectorTreeView::widget() const
     335QWidget *UISettingsSelectorTreeWidget::widget() const
    345336{
    346337    return m_pTreeWidget;
    347338}
    348339
    349 QWidget *UISettingsSelectorTreeView::addItem(const QString & /* strBigIcon */,
    350                                              const QString &strMediumIcon ,
    351                                              const QString & /* strSmallIcon */,
    352                                              int iID,
    353                                              const QString &strLink,
    354                                              UISettingsPage *pPage /* = 0 */,
    355                                              int iParentID /* = -1 */)
     340QWidget *UISettingsSelectorTreeWidget::addItem(const QString & /* strBigIcon */,
     341                                               const QString &strMediumIcon ,
     342                                               const QString & /* strSmallIcon */,
     343                                               int iID,
     344                                               const QString &strLink,
     345                                               UISettingsPage *pPage /* = 0 */,
     346                                               int iParentID /* = -1 */)
    356347{
    357348    QWidget *pResult = 0;
     
    374365}
    375366
    376 void UISettingsSelectorTreeView::setItemText(int iID, const QString &strText)
     367void UISettingsSelectorTreeWidget::setItemText(int iID, const QString &strText)
    377368{
    378369    UISettingsSelector::setItemText(iID, strText);
     
    382373}
    383374
    384 QString UISettingsSelectorTreeView::itemText(int iID) const
     375QString UISettingsSelectorTreeWidget::itemText(int iID) const
    385376{
    386377    return pagePath(idToString(iID));
    387378}
    388379
    389 int UISettingsSelectorTreeView::currentId() const
     380int UISettingsSelectorTreeWidget::currentId() const
    390381{
    391382    int iID = -1;
     
    396387}
    397388
    398 int UISettingsSelectorTreeView::linkToId(const QString &strLink) const
     389int UISettingsSelectorTreeWidget::linkToId(const QString &strLink) const
    399390{
    400391    int iID = -1;
     
    405396}
    406397
    407 void UISettingsSelectorTreeView::selectById(int iID)
     398void UISettingsSelectorTreeWidget::selectById(int iID)
    408399{
    409400    QTreeWidgetItem *pItem = findItem(m_pTreeWidget, idToString(iID), TreeWidgetSection_Id);
     
    412403}
    413404
    414 void UISettingsSelectorTreeView::setVisibleById(int iID, bool fVisible)
    415 {
    416     QTreeWidgetItem *pItem = findItem(m_pTreeWidget, idToString(iID), TreeWidgetSection_Id);
    417     if (pItem)
    418         pItem->setHidden(!fVisible);
    419 }
    420 
    421 void UISettingsSelectorTreeView::polish()
     405void UISettingsSelectorTreeWidget::polish()
    422406{
    423407    /* Get recommended size hint: */
     
    444428}
    445429
    446 void UISettingsSelectorTreeView::sltSettingsGroupChanged(QTreeWidgetItem *pItem,
     430void UISettingsSelectorTreeWidget::sltSettingsGroupChanged(QTreeWidgetItem *pItem,
    447431                                                         QTreeWidgetItem * /* pPrevItem */)
    448432{
     
    455439}
    456440
    457 void UISettingsSelectorTreeView::clear()
     441void UISettingsSelectorTreeWidget::clear()
    458442{
    459443    m_pTreeWidget->clear();
    460444}
    461445
    462 QString UISettingsSelectorTreeView::pagePath(const QString &strMatch) const
     446QString UISettingsSelectorTreeWidget::pagePath(const QString &strMatch) const
    463447{
    464448    const QTreeWidgetItem *pTreeItem =
     
    469453}
    470454
    471 QTreeWidgetItem *UISettingsSelectorTreeView::findItem(QTreeWidget *pView,
    472                                                       const QString &strMatch,
    473                                                       int iColumn) const
     455QTreeWidgetItem *UISettingsSelectorTreeWidget::findItem(QTreeWidget *pView,
     456                                                        const QString &strMatch,
     457                                                        int iColumn) const
    474458{
    475459    QList<QTreeWidgetItem*> list =
     
    479463}
    480464
    481 QString UISettingsSelectorTreeView::idToString(int iID) const
     465QString UISettingsSelectorTreeWidget::idToString(int iID) const
    482466{
    483467    return QString("%1").arg(iID, 2, 10, QLatin1Char('0'));
     
    485469
    486470/* static */
    487 QString UISettingsSelectorTreeView::path(const QTreeWidgetItem *pItem)
     471QString UISettingsSelectorTreeWidget::path(const QTreeWidgetItem *pItem)
    488472{
    489473    static QString strSep = ": ";
     
    657641}
    658642
    659 QWidget *UISettingsSelectorToolBar::rootPage(int iID) const
    660 {
    661     QWidget *pPage = 0;
    662     if (const UISelectorActionItem *pItem = findActionItem(iID))
    663     {
    664         if (pItem->parentID() > -1)
    665             pPage = rootPage(pItem->parentID());
    666         else if (pItem->page())
    667             pPage = pItem->page();
    668         else
    669             pPage = pItem->tabWidget();
    670     }
    671     return pPage;
    672 }
    673 
    674643void UISettingsSelectorToolBar::selectById(int iID)
    675644{
     
    690659            pItem->action()->trigger();
    691660    }
    692 }
    693 
    694 void UISettingsSelectorToolBar::setVisibleById(int iID, bool fVisible)
    695 {
    696     const UISelectorActionItem *pItem = findActionItem(iID);
    697 
    698     if (pItem)
    699     {
    700         pItem->action()->setVisible(fVisible);
    701         if (pItem->parentID() > -1 &&
    702             pItem->page())
    703         {
    704             const UISelectorActionItem *pParent = findActionItem(pItem->parentID());
    705             if (pParent &&
    706                 pParent->tabWidget())
    707             {
    708                 if (fVisible &&
    709                     pParent->tabWidget()->indexOf(pItem->page()) == -1)
    710                     pParent->tabWidget()->addTab(pItem->page(), pItem->text());
    711                 else if (!fVisible &&
    712                          pParent->tabWidget()->indexOf(pItem->page()) > -1)
    713                     pParent->tabWidget()->removeTab(
    714                         pParent->tabWidget()->indexOf(pItem->page()));
    715             }
    716         }
    717     }
    718 
    719 }
    720 
    721 QList<QWidget*> UISettingsSelectorToolBar::rootPages() const
    722 {
    723     QList<QWidget*> list;
    724     foreach (UISelectorItem *pItem, m_list)
    725     {
    726         const UISelectorActionItem *pActionItem = static_cast<UISelectorActionItem*>(pItem);
    727         if (pActionItem->parentID() == -1 &&
    728             pActionItem->page())
    729             list << pActionItem->page();
    730         else if (pActionItem->tabWidget())
    731             list << pActionItem->tabWidget();
    732     }
    733     return list;
    734661}
    735662
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsSelector.h

    r98103 r100960  
    9898    /** Returns the section page for passed @a iID. */
    9999    virtual QWidget *idToPage(int iID) const;
    100     /** Returns the section root-page for passed @a iID. */
    101     virtual QWidget *rootPage(int iID) const { return idToPage(iID); }
    102100
    103101    /** Make the section with @a iID current. */
     
    106104    virtual void selectByLink(const QString &strLink) { selectById(linkToId(strLink)); }
    107105
    108     /** Make the section with @a iID @a fVisible. */
    109     virtual void setVisibleById(int iID, bool fVisible) = 0;
    110 
    111106    /** Returns the list of all selector pages. */
    112107    virtual QList<UISettingsPage*> settingPages() const;
    113     /** Returns the list of all root pages. */
    114     virtual QList<QWidget*> rootPages() const;
    115108
    116109    /** Performs selector polishing. */
     
    140133  * with the means to switch between settings pages.
    141134  * This one represented as tree-widget. */
    142 class SHARED_LIBRARY_STUFF UISettingsSelectorTreeView : public UISettingsSelector
     135class SHARED_LIBRARY_STUFF UISettingsSelectorTreeWidget : public UISettingsSelector
    143136{
    144137    Q_OBJECT;
     
    147140
    148141    /** Constructs settings selector passing @a pParent to the base-class. */
    149     UISettingsSelectorTreeView(QWidget *pParent = 0);
     142    UISettingsSelectorTreeWidget(QWidget *pParent = 0);
    150143    /** Destructs settings selector. */
    151     virtual ~UISettingsSelectorTreeView() RT_OVERRIDE;
     144    virtual ~UISettingsSelectorTreeWidget() RT_OVERRIDE;
    152145
    153146    /** Returns the widget selector operates on. */
     
    179172    virtual void selectById(int iID) RT_OVERRIDE;
    180173
    181     /** Make the section with @a iID @a fVisible. */
    182     virtual void setVisibleById(int iID, bool fVisible) RT_OVERRIDE;
    183 
    184174    /** Performs selector polishing. */
    185175    virtual void polish() RT_OVERRIDE;
     
    212202/** UISettingsSelector subclass providing settings dialog
    213203  * with the means to switch between settings pages.
    214   * This one represented as tab-widget. */
     204  * This one represented as tool-bar. */
    215205class SHARED_LIBRARY_STUFF UISettingsSelectorToolBar : public UISettingsSelector
    216206{
     
    251241    /** Returns the section page for passed @a iID. */
    252242    virtual QWidget *idToPage(int iID) const RT_OVERRIDE;
    253     /** Returns the section root-page for passed @a iID. */
    254     virtual QWidget *rootPage(int iID) const RT_OVERRIDE;
    255243
    256244    /** Make the section with @a iID current. */
    257245    virtual void selectById(int iID) RT_OVERRIDE;
    258 
    259     /** Make the section with @a iID @a fVisible. */
    260     virtual void setVisibleById(int iID, bool fVisible) RT_OVERRIDE;
    261 
    262     /** Returns the list of all root pages. */
    263     virtual QList<QWidget*> rootPages() const RT_OVERRIDE;
    264246
    265247    /** Returns minimum selector width. */
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