Changeset 100960 in vbox
- Timestamp:
- Aug 23, 2023 5:15:29 PM (14 months ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/settings
- Files:
-
- 3 edited
-
UISettingsDialog.cpp (modified) (2 diffs)
-
UISettingsSelector.cpp (modified) (16 diffs)
-
UISettingsSelector.h (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialog.cpp
r100959 r100960 625 625 626 626 /* Prepare classical tree-view selector: */ 627 m_pSelector = new UISettingsSelectorTree View(centralWidget());627 m_pSelector = new UISettingsSelectorTreeWidget(centralWidget()); 628 628 if (m_pSelector) 629 629 { … … 657 657 /* Configure selector created above: */ 658 658 if (m_pSelector) 659 connect(m_pSelector, &UISettingsSelectorTree View::sigCategoryChanged,659 connect(m_pSelector, &UISettingsSelectorTreeWidget::sigCategoryChanged, 660 660 this, &UISettingsDialog::sltCategoryChanged); 661 661 } -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsSelector.cpp
r98103 r100960 254 254 } 255 255 256 QList<QWidget*> UISettingsSelector::rootPages() const257 {258 QList<QWidget*> list;259 foreach (UISelectorItem *pItem, m_list)260 if (pItem->page())261 list << pItem->page();262 return list;263 }264 265 256 UISelectorItem *UISettingsSelector::findItem(int iID) const 266 257 { … … 301 292 302 293 /********************************************************************************************************************************* 303 * Class UISettingsSelectorTree View implementation.*294 * Class UISettingsSelectorTreeWidget implementation. * 304 295 *********************************************************************************************************************************/ 305 296 306 UISettingsSelectorTree View::UISettingsSelectorTreeView(QWidget *pParent /* = 0 */)297 UISettingsSelectorTreeWidget::UISettingsSelectorTreeWidget(QWidget *pParent /* = 0 */) 307 298 : UISettingsSelector(pParent) 308 299 , m_pTreeWidget(0) … … 332 323 /* Setup connections: */ 333 324 connect(m_pTreeWidget, &QITreeWidget::currentItemChanged, 334 this, &UISettingsSelectorTree View::sltSettingsGroupChanged);335 } 336 337 UISettingsSelectorTree View::~UISettingsSelectorTreeView()325 this, &UISettingsSelectorTreeWidget::sltSettingsGroupChanged); 326 } 327 328 UISettingsSelectorTreeWidget::~UISettingsSelectorTreeWidget() 338 329 { 339 330 /* Cleanup the tree-widget: */ … … 342 333 } 343 334 344 QWidget *UISettingsSelectorTree View::widget() const335 QWidget *UISettingsSelectorTreeWidget::widget() const 345 336 { 346 337 return m_pTreeWidget; 347 338 } 348 339 349 QWidget *UISettingsSelectorTree View::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 */)340 QWidget *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 */) 356 347 { 357 348 QWidget *pResult = 0; … … 374 365 } 375 366 376 void UISettingsSelectorTree View::setItemText(int iID, const QString &strText)367 void UISettingsSelectorTreeWidget::setItemText(int iID, const QString &strText) 377 368 { 378 369 UISettingsSelector::setItemText(iID, strText); … … 382 373 } 383 374 384 QString UISettingsSelectorTree View::itemText(int iID) const375 QString UISettingsSelectorTreeWidget::itemText(int iID) const 385 376 { 386 377 return pagePath(idToString(iID)); 387 378 } 388 379 389 int UISettingsSelectorTree View::currentId() const380 int UISettingsSelectorTreeWidget::currentId() const 390 381 { 391 382 int iID = -1; … … 396 387 } 397 388 398 int UISettingsSelectorTree View::linkToId(const QString &strLink) const389 int UISettingsSelectorTreeWidget::linkToId(const QString &strLink) const 399 390 { 400 391 int iID = -1; … … 405 396 } 406 397 407 void UISettingsSelectorTree View::selectById(int iID)398 void UISettingsSelectorTreeWidget::selectById(int iID) 408 399 { 409 400 QTreeWidgetItem *pItem = findItem(m_pTreeWidget, idToString(iID), TreeWidgetSection_Id); … … 412 403 } 413 404 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() 405 void UISettingsSelectorTreeWidget::polish() 422 406 { 423 407 /* Get recommended size hint: */ … … 444 428 } 445 429 446 void UISettingsSelectorTree View::sltSettingsGroupChanged(QTreeWidgetItem *pItem,430 void UISettingsSelectorTreeWidget::sltSettingsGroupChanged(QTreeWidgetItem *pItem, 447 431 QTreeWidgetItem * /* pPrevItem */) 448 432 { … … 455 439 } 456 440 457 void UISettingsSelectorTree View::clear()441 void UISettingsSelectorTreeWidget::clear() 458 442 { 459 443 m_pTreeWidget->clear(); 460 444 } 461 445 462 QString UISettingsSelectorTree View::pagePath(const QString &strMatch) const446 QString UISettingsSelectorTreeWidget::pagePath(const QString &strMatch) const 463 447 { 464 448 const QTreeWidgetItem *pTreeItem = … … 469 453 } 470 454 471 QTreeWidgetItem *UISettingsSelectorTree View::findItem(QTreeWidget *pView,472 const QString &strMatch,473 int iColumn) const455 QTreeWidgetItem *UISettingsSelectorTreeWidget::findItem(QTreeWidget *pView, 456 const QString &strMatch, 457 int iColumn) const 474 458 { 475 459 QList<QTreeWidgetItem*> list = … … 479 463 } 480 464 481 QString UISettingsSelectorTree View::idToString(int iID) const465 QString UISettingsSelectorTreeWidget::idToString(int iID) const 482 466 { 483 467 return QString("%1").arg(iID, 2, 10, QLatin1Char('0')); … … 485 469 486 470 /* static */ 487 QString UISettingsSelectorTree View::path(const QTreeWidgetItem *pItem)471 QString UISettingsSelectorTreeWidget::path(const QTreeWidgetItem *pItem) 488 472 { 489 473 static QString strSep = ": "; … … 657 641 } 658 642 659 QWidget *UISettingsSelectorToolBar::rootPage(int iID) const660 {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 else669 pPage = pItem->tabWidget();670 }671 return pPage;672 }673 674 643 void UISettingsSelectorToolBar::selectById(int iID) 675 644 { … … 690 659 pItem->action()->trigger(); 691 660 } 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() const722 {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;734 661 } 735 662 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsSelector.h
r98103 r100960 98 98 /** Returns the section page for passed @a iID. */ 99 99 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); }102 100 103 101 /** Make the section with @a iID current. */ … … 106 104 virtual void selectByLink(const QString &strLink) { selectById(linkToId(strLink)); } 107 105 108 /** Make the section with @a iID @a fVisible. */109 virtual void setVisibleById(int iID, bool fVisible) = 0;110 111 106 /** Returns the list of all selector pages. */ 112 107 virtual QList<UISettingsPage*> settingPages() const; 113 /** Returns the list of all root pages. */114 virtual QList<QWidget*> rootPages() const;115 108 116 109 /** Performs selector polishing. */ … … 140 133 * with the means to switch between settings pages. 141 134 * This one represented as tree-widget. */ 142 class SHARED_LIBRARY_STUFF UISettingsSelectorTree View: public UISettingsSelector135 class SHARED_LIBRARY_STUFF UISettingsSelectorTreeWidget : public UISettingsSelector 143 136 { 144 137 Q_OBJECT; … … 147 140 148 141 /** Constructs settings selector passing @a pParent to the base-class. */ 149 UISettingsSelectorTree View(QWidget *pParent = 0);142 UISettingsSelectorTreeWidget(QWidget *pParent = 0); 150 143 /** Destructs settings selector. */ 151 virtual ~UISettingsSelectorTree View() RT_OVERRIDE;144 virtual ~UISettingsSelectorTreeWidget() RT_OVERRIDE; 152 145 153 146 /** Returns the widget selector operates on. */ … … 179 172 virtual void selectById(int iID) RT_OVERRIDE; 180 173 181 /** Make the section with @a iID @a fVisible. */182 virtual void setVisibleById(int iID, bool fVisible) RT_OVERRIDE;183 184 174 /** Performs selector polishing. */ 185 175 virtual void polish() RT_OVERRIDE; … … 212 202 /** UISettingsSelector subclass providing settings dialog 213 203 * with the means to switch between settings pages. 214 * This one represented as t ab-widget. */204 * This one represented as tool-bar. */ 215 205 class SHARED_LIBRARY_STUFF UISettingsSelectorToolBar : public UISettingsSelector 216 206 { … … 251 241 /** Returns the section page for passed @a iID. */ 252 242 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;255 243 256 244 /** Make the section with @a iID current. */ 257 245 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;264 246 265 247 /** Returns minimum selector width. */
Note:
See TracChangeset
for help on using the changeset viewer.

