Changeset 44016 in vbox for trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsSet.cpp
- Timestamp:
- Dec 3, 2012 3:10:03 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsSet.cpp
r44015 r44016 33 33 : UIGDetailsItem(pParent) 34 34 , m_fFullSet(true) 35 , m_pStep(0) 36 , m_iStep(-1) 35 , m_pBuildStep(0) 37 36 , m_iLastStepNumber(-1) 38 37 { … … 56 55 } 57 56 58 void UIGDetailsSet:: configure(UIVMItem *pItem, const QStringList &settings, bool fFullSet)57 void UIGDetailsSet::buildSet(UIVMItem *pItem, bool fFullSet, const QStringList &settings) 59 58 { 60 59 /* Remember passed arguments: */ … … 82 81 } 83 82 84 /* Create elements step-by-step: */85 prepareElements();86 } 87 88 void UIGDetailsSet::slt FirstStep(QString strSetId)89 { 90 /* Cleanup step: */91 delete m_p Step;92 m_p Step = 0;83 /* Start building set: */ 84 rebuildSet(); 85 } 86 87 void UIGDetailsSet::sltBuildStep(QString strStepId, int iStepNumber) 88 { 89 /* Cleanup build-step: */ 90 delete m_pBuildStep; 91 m_pBuildStep = 0; 93 92 94 93 /* Is step id valid? */ 95 if (strS etId != m_strSetId)94 if (strStepId != m_strSetId) 96 95 return; 97 96 98 /* Prepare first element: */ 99 m_iStep = DetailsElementType_General; 100 prepareElement(strSetId); 101 } 102 103 void UIGDetailsSet::sltNextStep(QString strSetId) 104 { 105 /* Clear step: */ 106 delete m_pStep; 107 m_pStep = 0; 108 109 /* Was that a requested set? */ 110 if (strSetId != m_strSetId) 111 return; 112 113 /* Prepare next element: */ 114 ++m_iStep; 115 prepareElement(strSetId); 116 } 117 118 void UIGDetailsSet::sltSetPrepared() 119 { 120 /* Reset step index: */ 121 m_iStep = -1; 122 /* Notify parent group: */ 123 emit sigSetCreationDone(); 97 /* Step number feats the bounds: */ 98 if (iStepNumber >= 0 && iStepNumber <= m_iLastStepNumber) 99 { 100 /* Load details settings: */ 101 DetailsElementType elementType = (DetailsElementType)iStepNumber; 102 QString strElementTypeOpened = gpConverter->toInternalString(elementType); 103 QString strElementTypeClosed = strElementTypeOpened + "Closed"; 104 /* Should the element be visible? */ 105 bool fVisible = m_settings.contains(strElementTypeOpened) || m_settings.contains(strElementTypeClosed); 106 /* Should the element be opened? */ 107 bool fOpen = m_settings.contains(strElementTypeOpened); 108 109 /* Check if element is present already: */ 110 UIGDetailsElement *pElement = element(elementType); 111 if (pElement && fOpen) 112 pElement->open(false); 113 /* Create element if necessary: */ 114 bool fJustCreated = false; 115 if (!pElement) 116 { 117 fJustCreated = true; 118 pElement = createElement(elementType, fOpen); 119 } 120 121 /* Show element if necessary: */ 122 if (fVisible && !pElement->isVisible()) 123 { 124 /* Show the element: */ 125 pElement->show(); 126 /* Update layout: */ 127 model()->updateLayout(); 128 } 129 /* Hide element if necessary: */ 130 else if (!fVisible && pElement->isVisible()) 131 { 132 /* Hide the element: */ 133 pElement->hide(); 134 /* Update layout: */ 135 model()->updateLayout(); 136 } 137 /* Update model if necessary: */ 138 else if (fJustCreated) 139 model()->updateLayout(); 140 141 /* For visible element: */ 142 if (pElement->isVisible()) 143 { 144 /* Create next build-step: */ 145 m_pBuildStep = new UIBuildStep(this, strStepId, iStepNumber + 1); 146 connect(pElement, SIGNAL(sigBuildDone()), m_pBuildStep, SLOT(sltStepDone()), Qt::QueuedConnection); 147 connect(m_pBuildStep, SIGNAL(sigStepDone(QString, int)), this, SLOT(sltBuildStep(QString, int)), Qt::QueuedConnection); 148 149 /* Build element: */ 150 pElement->updateAppearance(); 151 } 152 /* For invisible element: */ 153 else 154 { 155 /* Just build next step: */ 156 sltBuildStep(strStepId, iStepNumber + 1); 157 } 158 } 159 /* Step number out of bounds: */ 160 else 161 { 162 /* Update model: */ 163 model()->updateLayout(); 164 /* Repaint all the items: */ 165 foreach (UIGDetailsItem *pItem, items()) 166 pItem->update(); 167 /* Notify group about build done: */ 168 emit sigBuildDone(); 169 } 124 170 } 125 171 … … 135 181 136 182 /* Update appearance: */ 137 prepareElements();183 rebuildSet(); 138 184 } 139 185 … … 145 191 146 192 /* Update appearance: */ 147 prepareElements();193 rebuildSet(); 148 194 } 149 195 … … 151 197 { 152 198 /* Update appearance: */ 153 prepareElements();199 rebuildSet(); 154 200 } 155 201 … … 271 317 { 272 318 /* Build connections: */ 273 connect(this, SIGNAL(sigStartFirstStep(QString)), this, SLOT(sltFirstStep(QString)), Qt::QueuedConnection); 274 connect(this, SIGNAL(sigSetPrepared()), this, SLOT(sltSetPrepared()), Qt::QueuedConnection); 319 connect(this, SIGNAL(sigBuildStep(QString, int)), this, SLOT(sltBuildStep(QString, int)), Qt::QueuedConnection); 275 320 276 321 /* Global-events connections: */ … … 474 519 } 475 520 476 void UIGDetailsSet:: prepareElements()477 { 478 /* Cleanup step: */479 delete m_p Step;480 m_p Step = 0;521 void UIGDetailsSet::rebuildSet() 522 { 523 /* Cleanup build-step: */ 524 delete m_pBuildStep; 525 m_pBuildStep = 0; 481 526 482 527 /* Generate new set-id: */ 483 528 m_strSetId = QUuid::createUuid().toString(); 484 529 485 /* Request to prepare first step: */ 486 emit sigStartFirstStep(m_strSetId); 487 } 488 489 void UIGDetailsSet::prepareElement(QString strSetId) 490 { 491 /* Step number feats the bounds: */ 492 if (m_iStep <= m_iLastStepNumber) 493 { 494 /* Load details settings: */ 495 DetailsElementType elementType = (DetailsElementType)m_iStep; 496 QString strElementTypeOpened = gpConverter->toInternalString(elementType); 497 QString strElementTypeClosed = strElementTypeOpened + "Closed"; 498 /* Should be element visible? */ 499 bool fVisible = m_settings.contains(strElementTypeOpened) || m_settings.contains(strElementTypeClosed); 500 /* Should be element opened? */ 501 bool fOpen = m_settings.contains(strElementTypeOpened); 502 503 /* Check if element is present already: */ 504 UIGDetailsElement *pElement = element(elementType); 505 if (pElement && fOpen) 506 pElement->open(false); 507 /* Create element if necessary: */ 508 bool fJustCreated = false; 509 if (!pElement) 510 { 511 fJustCreated = true; 512 pElement = createElement(elementType, fOpen); 513 } 514 515 /* Show element if necessary: */ 516 if (fVisible && !pElement->isVisible()) 517 { 518 /* Show the element: */ 519 pElement->show(); 520 /* Update layout: */ 521 model()->updateLayout(); 522 } 523 /* Hide element if necessary: */ 524 else if (!fVisible && pElement->isVisible()) 525 { 526 /* Hide the element: */ 527 pElement->hide(); 528 /* Update layout: */ 529 model()->updateLayout(); 530 } 531 /* Update model if necessary: */ 532 else if (fJustCreated) 533 model()->updateLayout(); 534 535 /* For visible element: */ 536 if (pElement->isVisible()) 537 { 538 /* Create prepare step: */ 539 m_pStep = new UIPrepareStep(this, strSetId); 540 connect(pElement, SIGNAL(sigElementUpdateDone()), m_pStep, SLOT(sltStepDone()), Qt::QueuedConnection); 541 connect(m_pStep, SIGNAL(sigStepDone(const QString&)), this, SLOT(sltNextStep(const QString&)), Qt::QueuedConnection); 542 543 /* Update element: */ 544 pElement->updateAppearance(); 545 } 546 /* For invisible element: */ 547 else 548 { 549 /* Just go to the next step: */ 550 sltNextStep(strSetId); 551 } 552 } 553 /* Step number out of bounds: */ 554 else 555 { 556 /* Mark whole set prepared: */ 557 model()->updateLayout(); 558 foreach (UIGDetailsItem *pElement, items()) 559 pElement->update(); 560 emit sigSetPrepared(); 561 } 530 /* Request to build first step: */ 531 emit sigBuildStep(m_strSetId, DetailsElementType_General); 562 532 } 563 533
Note:
See TracChangeset
for help on using the changeset viewer.