VirtualBox

Ignore:
Timestamp:
Dec 3, 2012 3:10:03 PM (12 years ago)
Author:
vboxsync
Message:

FE/Qt: VM group UI: Reworking/cleanup details-view build mechanism.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsSet.cpp

    r44015 r44016  
    3333    : UIGDetailsItem(pParent)
    3434    , m_fFullSet(true)
    35     , m_pStep(0)
    36     , m_iStep(-1)
     35    , m_pBuildStep(0)
    3736    , m_iLastStepNumber(-1)
    3837{
     
    5655}
    5756
    58 void UIGDetailsSet::configure(UIVMItem *pItem, const QStringList &settings, bool fFullSet)
     57void UIGDetailsSet::buildSet(UIVMItem *pItem, bool fFullSet, const QStringList &settings)
    5958{
    6059    /* Remember passed arguments: */
     
    8281    }
    8382
    84     /* Create elements step-by-step: */
    85     prepareElements();
    86 }
    87 
    88 void UIGDetailsSet::sltFirstStep(QString strSetId)
    89 {
    90     /* Cleanup step: */
    91     delete m_pStep;
    92     m_pStep = 0;
     83    /* Start building set: */
     84    rebuildSet();
     85}
     86
     87void UIGDetailsSet::sltBuildStep(QString strStepId, int iStepNumber)
     88{
     89    /* Cleanup build-step: */
     90    delete m_pBuildStep;
     91    m_pBuildStep = 0;
    9392
    9493    /* Is step id valid? */
    95     if (strSetId != m_strSetId)
     94    if (strStepId != m_strSetId)
    9695        return;
    9796
    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    }
    124170}
    125171
     
    135181
    136182    /* Update appearance: */
    137     prepareElements();
     183    rebuildSet();
    138184}
    139185
     
    145191
    146192    /* Update appearance: */
    147     prepareElements();
     193    rebuildSet();
    148194}
    149195
     
    151197{
    152198    /* Update appearance: */
    153     prepareElements();
     199    rebuildSet();
    154200}
    155201
     
    271317{
    272318    /* 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);
    275320
    276321    /* Global-events connections: */
     
    474519}
    475520
    476 void UIGDetailsSet::prepareElements()
    477 {
    478     /* Cleanup step: */
    479     delete m_pStep;
    480     m_pStep = 0;
     521void UIGDetailsSet::rebuildSet()
     522{
     523    /* Cleanup build-step: */
     524    delete m_pBuildStep;
     525    m_pBuildStep = 0;
    481526
    482527    /* Generate new set-id: */
    483528    m_strSetId = QUuid::createUuid().toString();
    484529
    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);
    562532}
    563533
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette