- Timestamp:
- Jun 23, 2011 12:26:14 PM (13 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QITreeWidget.cpp
r28800 r37610 28 28 : QTreeWidget (aParent) 29 29 { 30 } 31 32 void QITreeWidget::setSizeHintForItems(const QSize &sizeHint) 33 { 34 for (int i = 0; i < topLevelItemCount(); ++i) 35 topLevelItem(i)->setSizeHint(0, sizeHint); 30 36 } 31 37 … … 60 66 } 61 67 62 void QITreeWidget::addTopBottomMarginToItems (int aMargin)63 {64 for (int i = 0; i < topLevelItemCount(); ++ i)65 {66 QTreeWidgetItem *item = topLevelItem (i);67 QSize s = item->sizeHint (0);68 item->setSizeHint (0, QSize (s.width(), s.height() + 2 * aMargin));69 }70 }71 -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QITreeWidget.h
r28800 r37610 34 34 QITreeWidget (QWidget *aParent = 0); 35 35 36 void addTopBottomMarginToItems (int aMargin);36 void setSizeHintForItems(const QSize &sizeHint); 37 37 38 38 signals: -
trunk/src/VBox/Frontends/VirtualBox/src/settings/VBoxSettingsSelector.cpp
r32814 r37610 285 285 void VBoxSettingsTreeViewSelector::polish() 286 286 { 287 mTwSelector->setFixedWidth (static_cast<QAbstractItemView*> (mTwSelector) 288 ->sizeHintForColumn (treeWidget_Category) + 2 * mTwSelector->frameWidth()); 289 290 /* Sort selector by the id column */ 291 mTwSelector->sortItems (treeWidget_Id, Qt::AscendingOrder); 292 mTwSelector->resizeColumnToContents (treeWidget_Category); 293 294 /* Add some margin to every item in the tree */ 295 mTwSelector->addTopBottomMarginToItems (12); 287 /* Get recommended size hint: */ 288 int iItemWidth = static_cast<QAbstractItemView*>(mTwSelector)->sizeHintForColumn(treeWidget_Category); 289 int iItemHeight = qMax(16 /* icon height */, mTwSelector->fontMetrics().height() /* text height */); 290 /* Add some margin to every item in the tree: */ 291 iItemHeight += 4 /* margin itself */ * 2 /* margin count */; 292 /* Set final size hint for items: */ 293 mTwSelector->setSizeHintForItems(QSize(iItemWidth , iItemHeight)); 294 295 /* Fix selector width to minimum possible: */ 296 mTwSelector->setFixedWidth(iItemWidth + 2 * mTwSelector->frameWidth()); 297 298 /* Sort selector by the id column: */ 299 mTwSelector->sortItems(treeWidget_Id, Qt::AscendingOrder); 300 301 /* Resize column(s) to content: */ 302 mTwSelector->resizeColumnToContents(treeWidget_Category); 296 303 } 297 304
Note:
See TracChangeset
for help on using the changeset viewer.