- Timestamp:
- Oct 9, 2023 10:12:12 AM (19 months ago)
- svn:sync-xref-src-repo-rev:
- 159413
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsSelector.cpp ¶
r101391 r101392 321 321 { 322 322 QWidget *pResult = 0; 323 if (pPage != 0) 324 { 323 if (pPage) 324 { 325 /* Adjust page a bit: */ 326 pPage->setContentsMargins(0, 0, 0, 0); 327 if (pPage->layout()) 328 pPage->layout()->setContentsMargins(0, 0, 0, 0); 329 pResult = pPage; 330 331 /* Add selector-item object: */ 325 332 const QIcon icon = UIIconPool::iconSet(strMediumIcon); 326 327 333 UISelectorItem *pItem = new UISelectorItem(icon, iID, strLink, pPage, iParentID); 328 m_list.append(pItem);329 330 QTreeWidgetItem *pTwItem = new QITreeWidgetItem(m_pTreeWidget, QStringList() << QString("") 331 << idToString(iID)332 << strLink);333 pTwItem->setIcon(TreeWidgetSection_Category, pItem->icon());334 pPage->setContentsMargins(0, 0, 0, 0);335 pPage->layout()->setContentsMargins(0, 0, 0, 0);336 pResult = pPage;334 if (pItem) 335 m_list.append(pItem); 336 337 /* Add tree-widget item: */ 338 QITreeWidgetItem *pTwItem = new QITreeWidgetItem(m_pTreeWidget, QStringList() << QString("") 339 << idToString(iID) 340 << strLink); 341 if (pTwItem) 342 pTwItem->setIcon(TreeWidgetSection_Category, pItem->icon()); 337 343 } 338 344 return pResult; … … 341 347 void UISettingsSelectorTreeWidget::setItemText(int iID, const QString &strText) 342 348 { 349 /* Call to base-class: */ 343 350 UISettingsSelector::setItemText(iID, strText); 351 352 /* Look for the tree-widget item to assign the text: */ 344 353 QTreeWidgetItem *pItem = findItem(m_pTreeWidget, idToString(iID), TreeWidgetSection_Id); 345 354 if (pItem) … … 380 389 { 381 390 /* Get recommended size hint: */ 382 const QStyle *pStyle = QApplication::style(); 383 const int iIconMetric = pStyle->pixelMetric(QStyle::PM_SmallIconSize); 384 int iItemWidth = static_cast<QAbstractItemView*>(m_pTreeWidget)->sizeHintForColumn(TreeWidgetSection_Category); 385 int iItemHeight = qMax((int)(iIconMetric * 1.5) /* icon height */, 386 m_pTreeWidget->fontMetrics().height() /* text height */); 387 /* Add some margin to every item in the tree: */ 388 iItemHeight += 4 /* margin itself */ * 2 /* margin count */; 391 const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize); 392 const int iItemWidth = static_cast<QAbstractItemView*>(m_pTreeWidget)->sizeHintForColumn(TreeWidgetSection_Category); 393 const int iItemHeight = qMax((int)(iIconMetric * 1.5) /* icon height */, 394 m_pTreeWidget->fontMetrics().height() /* text height */) 395 + 4 /* margin itself */ * 2 /* margin count */; 396 389 397 /* Set final size hint for items: */ 390 398 m_pTreeWidget->setSizeHintForItems(QSize(iItemWidth , iItemHeight)); … … 392 400 /* Adjust selector width/height: */ 393 401 m_pTreeWidget->setFixedWidth(iItemWidth + 2 * m_pTreeWidget->frameWidth()); 394 m_pTreeWidget->setMinimumHeight( m_pTreeWidget->topLevelItemCount() * iItemHeight +395 1 /* margin itself */ * 2 /* margin count */);402 m_pTreeWidget->setMinimumHeight( m_pTreeWidget->topLevelItemCount() * iItemHeight 403 + 1 /* margin itself */ * 2 /* margin count */); 396 404 397 405 /* Sort selector by the id column: */ … … 402 410 } 403 411 404 void UISettingsSelectorTreeWidget::sltSettingsGroupChanged(QTreeWidgetItem *pItem, 405 QTreeWidgetItem * /* pPrevItem */) 412 void UISettingsSelectorTreeWidget::sltSettingsGroupChanged(QTreeWidgetItem *pItem, QTreeWidgetItem * /* pPrevItem */) 406 413 { 407 414 if (pItem) … … 443 450 QString UISettingsSelectorTreeWidget::pagePath(const QString &strMatch) const 444 451 { 445 const QTreeWidgetItem *pTreeItem = 446 findItem(m_pTreeWidget, 447 strMatch, 448 TreeWidgetSection_Id); 452 const QTreeWidgetItem *pTreeItem = findItem(m_pTreeWidget, strMatch, TreeWidgetSection_Id); 449 453 return path(pTreeItem); 450 454 } 451 455 452 QTreeWidgetItem *UISettingsSelectorTreeWidget::findItem(QTreeWidget *pView, 453 const QString &strMatch, 454 int iColumn) const 455 { 456 QList<QTreeWidgetItem*> list = 457 pView->findItems(strMatch, Qt::MatchExactly, iColumn); 458 459 return list.count() ? list[0] : 0; 456 QTreeWidgetItem *UISettingsSelectorTreeWidget::findItem(QTreeWidget *pView, const QString &strMatch, int iColumn) const 457 { 458 const QList<QTreeWidgetItem*> list = pView->findItems(strMatch, Qt::MatchExactly, iColumn); 459 return list.count() ? list.first() : 0; 460 460 } 461 461
Note:
See TracChangeset
for help on using the changeset viewer.