Changeset 43989 in vbox
- Timestamp:
- Nov 28, 2012 4:20:48 PM (12 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.cpp
r43987 r43989 92 92 } 93 93 94 int UIGDetailsElement::minimumWidthHint() const95 {96 /* Prepare variables: */97 int iMargin = data(ElementData_Margin).toInt();98 int iProposedWidth = 0;99 100 /* Maximum width: */101 iProposedWidth = qMax(m_iMinimumHeaderWidth, m_iMinimumTextWidth);102 103 /* And 4 margins: 2 left and 2 right: */104 iProposedWidth += 4 * iMargin;105 106 /* Return result: */107 return iProposedWidth;108 }109 110 int UIGDetailsElement::minimumHeightHint() const111 {112 return minimumHeightHint(m_fClosed);113 }114 115 94 void UIGDetailsElement::updateHoverAccessibility() 116 95 { … … 352 331 } 353 332 354 int UIGDetailsElement::minimum HeightHint(bool fClosed) const333 int UIGDetailsElement::minimumWidthHint() const 355 334 { 356 335 /* Prepare variables: */ 357 336 int iMargin = data(ElementData_Margin).toInt(); 358 int iProposedHeight = 0; 337 int iMinimumWidthHint = 0; 338 339 /* Maximum width: */ 340 iMinimumWidthHint = qMax(m_iMinimumHeaderWidth, m_iMinimumTextWidth); 341 342 /* And 4 margins: 2 left and 2 right: */ 343 iMinimumWidthHint += 4 * iMargin; 344 345 /* Return result: */ 346 return iMinimumWidthHint; 347 } 348 349 int UIGDetailsElement::minimumHeightHint(bool fClosed) const 350 { 351 /* Prepare variables: */ 352 int iMargin = data(ElementData_Margin).toInt(); 353 int iMinimumHeightHint = 0; 359 354 360 355 /* Two margins: */ 361 i ProposedHeight += 2 * iMargin;356 iMinimumHeightHint += 2 * iMargin; 362 357 363 358 /* Header height: */ 364 i ProposedHeight += m_iMinimumHeaderHeight;359 iMinimumHeightHint += m_iMinimumHeaderHeight; 365 360 366 361 /* Element is opened? */ … … 369 364 /* Add text height: */ 370 365 if (!m_text.isEmpty()) 371 i ProposedHeight += 2 * iMargin + m_iMinimumTextHeight;366 iMinimumHeightHint += 2 * iMargin + m_iMinimumTextHeight; 372 367 } 373 368 374 369 /* Additional height during animation: */ 375 370 if (m_fAnimationRunning) 376 i ProposedHeight += m_iAdditionalHeight;371 iMinimumHeightHint += m_iAdditionalHeight; 377 372 378 373 /* Return value: */ 379 return iProposedHeight; 380 } 381 382 QSizeF UIGDetailsElement::sizeHint(Qt::SizeHint which, const QSizeF &constraint /* = QSizeF() */) const 383 { 384 /* If Qt::MinimumSize requested: */ 385 if (which == Qt::MinimumSize || which == Qt::PreferredSize) 386 { 387 /* Return wrappers: */ 388 return QSizeF(minimumWidthHint(), minimumHeightHint()); 389 } 390 391 /* Call to base-class: */ 392 return UIGDetailsItem::sizeHint(which, constraint); 374 return iMinimumHeightHint; 375 } 376 377 int UIGDetailsElement::minimumHeightHint() const 378 { 379 return minimumHeightHint(m_fClosed); 393 380 } 394 381 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.h
r43987 r43989 83 83 void open(bool fAnimated = true); 84 84 85 /* API: Layout stuff: */86 virtual int minimumWidthHint() const;87 virtual int minimumHeightHint() const;88 89 85 /* API: Update stuff: */ 90 86 void updateHoverAccessibility(); … … 137 133 int minimumHeaderWidth() const { return m_iMinimumHeaderWidth; } 138 134 int minimumHeaderHeight() const { return m_iMinimumHeaderHeight; } 135 int minimumWidthHint() const; 139 136 virtual int minimumHeightHint(bool fClosed) const; 140 QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;137 int minimumHeightHint() const; 141 138 void updateLayout(); 142 139 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsGroup.cpp
r43988 r43989 231 231 /* Take into account all the sets: */ 232 232 foreach (UIGDetailsItem *pItem, items()) 233 if (UIGDetailsSet *pSet = pItem->toSet()) 234 iMinimumWidthHint = qMax(iMinimumWidthHint, pSet->minimumWidthHint()); 233 iMinimumWidthHint = qMax(iMinimumWidthHint, pItem->minimumWidthHint()); 235 234 236 235 /* And two margins finally: */ 237 236 iMinimumWidthHint += 2 * iMargin; 238 237 239 /* Return value: */238 /* Return result: */ 240 239 return iMinimumWidthHint; 241 240 } … … 250 249 /* Take into account all the sets: */ 251 250 foreach (UIGDetailsItem *pItem, items()) 252 if (UIGDetailsSet *pSet = pItem->toSet()) 253 iMinimumHeightHint += (pSet->minimumHeightHint() + iSpacing); 251 iMinimumHeightHint += (pItem->minimumHeightHint() + iSpacing); 254 252 255 253 /* Minus last spacing: */ … … 259 257 iMinimumHeightHint += 2 * iMargin; 260 258 261 /* Return value: */259 /* Return result: */ 262 260 return iMinimumHeightHint; 263 261 } 264 262 265 QSizeF UIGDetailsGroup::sizeHint(Qt::SizeHint which, const QSizeF &constraint /* = QSizeF() */) const266 {267 /* If Qt::MinimumSize requested: */268 if (which == Qt::MinimumSize || which == Qt::PreferredSize)269 {270 /* Return wrappers: */271 return QSizeF(minimumWidthHint(), minimumHeightHint());272 }273 274 /* Call to base-class: */275 return UIGDetailsItem::sizeHint(which, constraint);276 }277 278 263 void UIGDetailsGroup::updateLayout() 279 264 { 265 /* Update size-hints for all the items: */ 266 foreach (UIGDetailsItem *pItem, items()) 267 pItem->updateSizeHint(); 268 /* Update size-hint for this item: */ 269 updateSizeHint(); 270 280 271 /* Prepare variables: */ 281 272 int iMargin = data(GroupData_Margin).toInt(); … … 287 278 foreach (UIGDetailsItem *pItem, items()) 288 279 { 289 /* Get particular set: */290 UIGDetailsSet *pSet = pItem->toSet();291 280 /* Move set: */ 292 281 pItem->setPos(iMargin, iVerticalIndent); 293 282 /* Resize set: */ 294 283 int iWidth = iMaximumWidth; 295 pItem->resize(iWidth, p Set->minimumHeightHint());284 pItem->resize(iWidth, pItem->minimumHeightHint()); 296 285 /* Layout set content: */ 297 286 pItem->updateLayout(); 298 287 /* Advance indent: */ 299 iVerticalIndent += (p Set->minimumHeightHint() + iSpacing);300 } 301 } 302 288 iVerticalIndent += (pItem->minimumHeightHint() + iSpacing); 289 } 290 } 291 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsGroup.h
r43988 r43989 87 87 int minimumWidthHint() const; 88 88 int minimumHeightHint() const; 89 QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;90 89 void updateLayout(); 91 90 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsItem.cpp
r43982 r43989 87 87 } 88 88 89 QSizeF UIGDetailsItem::sizeHint(Qt::SizeHint which, const QSizeF &constraint /* = QSizeF() */) const 90 { 91 /* If Qt::MinimumSize or Qt::PreferredSize requested: */ 92 if (which == Qt::MinimumSize || which == Qt::PreferredSize) 93 /* Return wrappers: */ 94 return QSizeF(minimumWidthHint(), minimumHeightHint()); 95 /* Call to base-class: */ 96 return QIGraphicsWidget::sizeHint(which, constraint); 97 } 98 89 99 /* static */ 90 100 void UIGDetailsItem::configurePainterShape(QPainter *pPainter, -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsItem.h
r43885 r43989 72 72 /* API: Layout stuff: */ 73 73 void updateSizeHint(); 74 virtual int minimumWidthHint() const = 0; 75 virtual int minimumHeightHint() const = 0; 76 QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const; 74 77 virtual void updateLayout() = 0; 75 78 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsSet.cpp
r43987 r43989 260 260 int iMargin = data(SetData_Margin).toInt(); 261 261 int iSpacing = data(SetData_Spacing).toInt(); 262 int i ProposedWidth= 0;263 264 /* Layout all the elements: */262 int iMinimumWidthHint = 0; 263 264 /* Take into account all the elements: */ 265 265 foreach (UIGDetailsItem *pItem, items()) 266 266 { 267 /* Get particular element: */ 267 /* Skip hidden: */ 268 if (!pItem->isVisible()) 269 continue; 270 271 /* For each particular element: */ 268 272 UIGDetailsElement *pElement = pItem->toElement(); 269 if (!pElement->isVisible())270 continue;271 272 /* For each particular element: */273 273 switch (pElement->elementType()) 274 274 { … … 287 287 case DetailsElementType_Description: 288 288 { 289 i ProposedWidth = qMax(iProposedWidth, pElement->minimumWidthHint());289 iMinimumWidthHint = qMax(iMinimumWidthHint, pItem->minimumWidthHint()); 290 290 break; 291 291 } 292 292 case DetailsElementType_Preview: 293 293 { 294 UIGDetails Element *pGeneralElement= element(DetailsElementType_General);295 UIGDetails Element *pSystemElement= element(DetailsElementType_System);296 int iGeneralElementWidth = pGeneral Element ? pGeneralElement->minimumWidthHint() : 0;297 int iSystemElementWidth = pSystem Element ? pSystemElement->minimumWidthHint() : 0;294 UIGDetailsItem *pGeneralItem = element(DetailsElementType_General); 295 UIGDetailsItem *pSystemItem = element(DetailsElementType_System); 296 int iGeneralElementWidth = pGeneralItem ? pGeneralItem->minimumWidthHint() : 0; 297 int iSystemElementWidth = pSystemItem ? pSystemItem->minimumWidthHint() : 0; 298 298 int iFirstColumnWidth = qMax(iGeneralElementWidth, iSystemElementWidth); 299 i ProposedWidth = qMax(iProposedWidth, iFirstColumnWidth + iSpacing + pElement->minimumWidthHint());299 iMinimumWidthHint = qMax(iMinimumWidthHint, iFirstColumnWidth + iSpacing + pItem->minimumWidthHint()); 300 300 break; 301 301 } … … 303 303 } 304 304 305 /* Two margins finally: */306 i ProposedWidth+= 2 * iMargin;305 /* And two margins finally: */ 306 iMinimumWidthHint += 2 * iMargin; 307 307 308 308 /* Return result: */ 309 return i ProposedWidth;309 return iMinimumWidthHint; 310 310 } 311 311 … … 315 315 int iMargin = data(SetData_Margin).toInt(); 316 316 int iSpacing = data(SetData_Spacing).toInt(); 317 int i ProposedHeight = 0;318 319 /* Layout all the elements: */317 int iMinimumHeightHint = 0; 318 319 /* Take into account all the elements: */ 320 320 foreach (UIGDetailsItem *pItem, items()) 321 321 { 322 /* Get particular element: */ 322 /* Skip hidden: */ 323 if (!pItem->isVisible()) 324 continue; 325 326 /* For each particular element: */ 323 327 UIGDetailsElement *pElement = pItem->toElement(); 324 if (!pElement->isVisible())325 continue;326 327 /* For each particular element: */328 328 switch (pElement->elementType()) 329 329 { … … 342 342 case DetailsElementType_Description: 343 343 { 344 i ProposedHeight += (pElement->minimumHeightHint() + iSpacing);344 iMinimumHeightHint += (pItem->minimumHeightHint() + iSpacing); 345 345 break; 346 346 } 347 347 case DetailsElementType_Preview: 348 348 { 349 i ProposedHeight = qMax(iProposedHeight, pElement->minimumHeightHint() + iSpacing);349 iMinimumHeightHint = qMax(iMinimumHeightHint, pItem->minimumHeightHint() + iSpacing); 350 350 break; 351 351 } … … 354 354 355 355 /* Minus last spacing: */ 356 i ProposedHeight -= iSpacing;357 358 /* Two margins finally: */359 i ProposedHeight += 2 * iMargin;356 iMinimumHeightHint -= iSpacing; 357 358 /* And two margins finally: */ 359 iMinimumHeightHint += 2 * iMargin; 360 360 361 361 /* Return result: */ 362 return iProposedHeight; 363 } 364 365 QSizeF UIGDetailsSet::sizeHint(Qt::SizeHint which, const QSizeF &constraint /* = QSizeF() */) const 366 { 367 /* If Qt::MinimumSize requested: */ 368 if (which == Qt::MinimumSize || which == Qt::PreferredSize) 369 { 370 /* Return wrappers: */ 371 return QSizeF(minimumWidthHint(), minimumHeightHint()); 372 } 373 374 /* Call to base-class: */ 375 return UIGDetailsItem::sizeHint(which, constraint); 362 return iMinimumHeightHint; 376 363 } 377 364 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsSet.h
r43988 r43989 98 98 int minimumWidthHint() const; 99 99 int minimumHeightHint() const; 100 QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;101 100 void updateLayout(); 102 101 … … 117 116 QString m_strSetId; 118 117 QStringList m_settings; 119 120 /* Friends: */121 friend class UIGDetailsGroup;122 118 }; 123 119
Note:
See TracChangeset
for help on using the changeset viewer.