- Timestamp:
- Sep 6, 2018 10:21:53 AM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager/details
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsGroup.cpp
r74109 r74110 129 129 } 130 130 131 void UIDetailsGroup::sltBuildStep(QString strStepId, int iStepNumber)132 {133 /* Cleanup build-step: */134 delete m_pBuildStep;135 m_pBuildStep = 0;136 137 /* Is step id valid? */138 if (strStepId != m_strGroupId)139 return;140 141 /* Step number feats the bounds: */142 if (iStepNumber >= 0 && iStepNumber < m_machineItems.size())143 {144 /* Should we create a new set for this step? */145 UIDetailsSet *pSet = 0;146 if (iStepNumber > m_items.size() - 1)147 pSet = new UIDetailsSet(this);148 /* Or use existing? */149 else150 pSet = m_items.at(iStepNumber)->toSet();151 152 /* Create next build-step: */153 m_pBuildStep = new UIPrepareStep(this, pSet, strStepId, iStepNumber + 1);154 155 /* Build set: */156 pSet->buildSet(m_machineItems[iStepNumber], m_machineItems.size() == 1, model()->settings());157 }158 else159 {160 /* Notify listener about build done: */161 emit sigBuildDone();162 }163 }164 165 void UIDetailsGroup::paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOptions, QWidget *)166 {167 /* Paint background: */168 paintBackground(pPainter, pOptions);169 }170 171 void UIDetailsGroup::addItem(UIDetailsItem *pItem)172 {173 switch (pItem->type())174 {175 case UIDetailsItemType_Set: m_items.append(pItem); break;176 default: AssertMsgFailed(("Invalid item type!")); break;177 }178 }179 180 void UIDetailsGroup::removeItem(UIDetailsItem *pItem)181 {182 switch (pItem->type())183 {184 case UIDetailsItemType_Set: m_items.removeAt(m_items.indexOf(pItem)); break;185 default: AssertMsgFailed(("Invalid item type!")); break;186 }187 }188 189 bool UIDetailsGroup::hasItems(UIDetailsItemType enmType /* = UIDetailsItemType_Set */) const190 {191 switch (enmType)192 {193 case UIDetailsItemType_Set: return !m_items.isEmpty();194 case UIDetailsItemType_Any: return hasItems(UIDetailsItemType_Set);195 default: AssertMsgFailed(("Invalid item type!")); break;196 }197 return false;198 }199 200 void UIDetailsGroup::clearItems(UIDetailsItemType enmType /* = UIDetailsItemType_Set */)201 {202 switch (enmType)203 {204 case UIDetailsItemType_Set: while (!m_items.isEmpty()) { delete m_items.last(); } break;205 case UIDetailsItemType_Any: clearItems(UIDetailsItemType_Set); break;206 default: AssertMsgFailed(("Invalid item type!")); break;207 }208 }209 210 void UIDetailsGroup::updateGeometry()211 {212 /* Call to base class: */213 UIDetailsItem::updateGeometry();214 215 /* Group-item should notify details-view if minimum-width-hint was changed: */216 int iMinimumWidthHint = minimumWidthHint();217 if (m_iPreviousMinimumWidthHint != iMinimumWidthHint)218 {219 /* Save new minimum-width-hint, notify listener: */220 m_iPreviousMinimumWidthHint = iMinimumWidthHint;221 emit sigMinimumWidthHintChanged(m_iPreviousMinimumWidthHint);222 }223 /* Group-item should notify details-view if minimum-height-hint was changed: */224 int iMinimumHeightHint = minimumHeightHint();225 if (m_iPreviousMinimumHeightHint != iMinimumHeightHint)226 {227 /* Save new minimum-height-hint, notify listener: */228 m_iPreviousMinimumHeightHint = iMinimumHeightHint;229 emit sigMinimumHeightHintChanged(m_iPreviousMinimumHeightHint);230 }231 }232 233 131 int UIDetailsGroup::minimumWidthHint() const 234 132 { … … 291 189 } 292 190 191 void UIDetailsGroup::sltBuildStep(QString strStepId, int iStepNumber) 192 { 193 /* Cleanup build-step: */ 194 delete m_pBuildStep; 195 m_pBuildStep = 0; 196 197 /* Is step id valid? */ 198 if (strStepId != m_strGroupId) 199 return; 200 201 /* Step number feats the bounds: */ 202 if (iStepNumber >= 0 && iStepNumber < m_machineItems.size()) 203 { 204 /* Should we create a new set for this step? */ 205 UIDetailsSet *pSet = 0; 206 if (iStepNumber > m_items.size() - 1) 207 pSet = new UIDetailsSet(this); 208 /* Or use existing? */ 209 else 210 pSet = m_items.at(iStepNumber)->toSet(); 211 212 /* Create next build-step: */ 213 m_pBuildStep = new UIPrepareStep(this, pSet, strStepId, iStepNumber + 1); 214 215 /* Build set: */ 216 pSet->buildSet(m_machineItems[iStepNumber], m_machineItems.size() == 1, model()->settings()); 217 } 218 else 219 { 220 /* Notify listener about build done: */ 221 emit sigBuildDone(); 222 } 223 } 224 225 void UIDetailsGroup::paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOptions, QWidget *) 226 { 227 /* Paint background: */ 228 paintBackground(pPainter, pOptions); 229 } 230 231 void UIDetailsGroup::addItem(UIDetailsItem *pItem) 232 { 233 switch (pItem->type()) 234 { 235 case UIDetailsItemType_Set: m_items.append(pItem); break; 236 default: AssertMsgFailed(("Invalid item type!")); break; 237 } 238 } 239 240 void UIDetailsGroup::removeItem(UIDetailsItem *pItem) 241 { 242 switch (pItem->type()) 243 { 244 case UIDetailsItemType_Set: m_items.removeAt(m_items.indexOf(pItem)); break; 245 default: AssertMsgFailed(("Invalid item type!")); break; 246 } 247 } 248 249 bool UIDetailsGroup::hasItems(UIDetailsItemType enmType /* = UIDetailsItemType_Set */) const 250 { 251 switch (enmType) 252 { 253 case UIDetailsItemType_Set: return !m_items.isEmpty(); 254 case UIDetailsItemType_Any: return hasItems(UIDetailsItemType_Set); 255 default: AssertMsgFailed(("Invalid item type!")); break; 256 } 257 return false; 258 } 259 260 void UIDetailsGroup::clearItems(UIDetailsItemType enmType /* = UIDetailsItemType_Set */) 261 { 262 switch (enmType) 263 { 264 case UIDetailsItemType_Set: while (!m_items.isEmpty()) { delete m_items.last(); } break; 265 case UIDetailsItemType_Any: clearItems(UIDetailsItemType_Set); break; 266 default: AssertMsgFailed(("Invalid item type!")); break; 267 } 268 } 269 270 void UIDetailsGroup::updateGeometry() 271 { 272 /* Call to base class: */ 273 UIDetailsItem::updateGeometry(); 274 275 /* Group-item should notify details-view if minimum-width-hint was changed: */ 276 int iMinimumWidthHint = minimumWidthHint(); 277 if (m_iPreviousMinimumWidthHint != iMinimumWidthHint) 278 { 279 /* Save new minimum-width-hint, notify listener: */ 280 m_iPreviousMinimumWidthHint = iMinimumWidthHint; 281 emit sigMinimumWidthHintChanged(m_iPreviousMinimumWidthHint); 282 } 283 /* Group-item should notify details-view if minimum-height-hint was changed: */ 284 int iMinimumHeightHint = minimumHeightHint(); 285 if (m_iPreviousMinimumHeightHint != iMinimumHeightHint) 286 { 287 /* Save new minimum-height-hint, notify listener: */ 288 m_iPreviousMinimumHeightHint = iMinimumHeightHint; 289 emit sigMinimumHeightHintChanged(m_iPreviousMinimumHeightHint); 290 } 291 } 292 293 293 void UIDetailsGroup::prepareConnections() 294 294 { -
trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsGroup.h
r74109 r74110 71 71 /** Updates layout. */ 72 72 virtual void updateLayout() /* override */; 73 74 /** Returns minimum width-hint. */ 75 virtual int minimumWidthHint() const /* override */; 76 /** Returns minimum height-hint. */ 77 virtual int minimumHeightHint() const /* override */; 73 78 /** @} */ 74 79 … … 117 122 /** Updates geometry. */ 118 123 virtual void updateGeometry() /* override */; 119 120 /** Returns minimum width-hint. */121 virtual int minimumWidthHint() const /* override */;122 /** Returns minimum height-hint. */123 virtual int minimumHeightHint() const /* override */;124 124 /** @} */ 125 125 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsModel.cpp
r74049 r74110 96 96 { 97 97 /* Prepare variables: */ 98 int iSceneMargin = data(DetailsModelData_Margin).toInt(); 99 QSize viewportSize = paintDevice()->viewport()->size(); 100 int iViewportWidth = viewportSize.width() - 2 * iSceneMargin; 101 int iViewportHeight = viewportSize.height() - 2 * iSceneMargin; 98 const int iSceneMargin = data(DetailsModelData_Margin).toInt(); 99 const QSize viewportSize = paintDevice()->viewport()->size(); 100 const int iViewportWidth = viewportSize.width() - 2 * iSceneMargin; 102 101 103 102 /* Move root: */ 104 103 m_pRoot->setPos(iSceneMargin, iSceneMargin); 105 104 /* Resize root: */ 106 m_pRoot->resize(iViewportWidth, iViewportHeight);105 m_pRoot->resize(iViewportWidth, m_pRoot->minimumHeightHint()); 107 106 /* Layout root content: */ 108 107 m_pRoot->updateLayout();
Note:
See TracChangeset
for help on using the changeset viewer.