VirtualBox

Changeset 44016 in vbox for trunk


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.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.h

    r43989 r44016  
    5050signals:
    5151
    52     /* Notifier: Prepare stuff: */
    53     void sigElementUpdateDone();
     52    /* Notifier: Build stuff: */
     53    void sigBuildDone();
    5454
    5555    /* Notifiers: Hover stuff: */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElements.cpp

    r43984 r44016  
    7979        setText(newText);
    8080    cleanupThread();
    81     emit sigElementUpdateDone();
     81    emit sigBuildDone();
    8282}
    8383
     
    232232{
    233233    m_pPreview->setMachine(machine());
    234     emit sigElementUpdateDone();
     234    emit sigBuildDone();
    235235}
    236236
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsGroup.cpp

    r44012 r44016  
    2727UIGDetailsGroup::UIGDetailsGroup()
    2828    : UIGDetailsItem(0)
    29     , m_pStep(0)
    30     , m_iStep(0)
     29    , m_pBuildStep(0)
    3130{
    3231    /* Prepare connections: */
     
    4039}
    4140
    42 void UIGDetailsGroup::setItems(const QList<UIVMItem*> &machineItems)
     41void UIGDetailsGroup::buildGroup(const QList<UIVMItem*> &machineItems)
    4342{
    4443    /* Remember passed machine-items: */
     
    4948        delete m_items.last();
    5049
    51     /* Update items: */
    52     updateItems();
    53 }
    54 
    55 void UIGDetailsGroup::updateItems()
     50    /* Start building group: */
     51    rebuildGroup();
     52}
     53
     54void UIGDetailsGroup::rebuildGroup()
    5655{
    5756    /* Load settings: */
    5857    loadSettings();
    5958
    60     /* Cleanup step: */
    61     delete m_pStep;
    62     m_pStep = 0;
     59    /* Cleanup build-step: */
     60    delete m_pBuildStep;
     61    m_pBuildStep = 0;
    6362
    6463    /* Generate new group-id: */
    6564    m_strGroupId = QUuid::createUuid().toString();
    6665
    67     /* Request to prepare first set: */
    68     emit sigStartFirstStep(m_strGroupId);
    69 }
    70 
    71 void UIGDetailsGroup::stopPopulatingItems()
     66    /* Request to build first step: */
     67    emit sigBuildStep(m_strGroupId, 0);
     68}
     69
     70void UIGDetailsGroup::stopBuildingGroup()
    7271{
    7372    /* Generate new group-id: */
     
    7574}
    7675
    77 void UIGDetailsGroup::sltFirstStep(QString strGroupId)
    78 {
    79     /* Cleanup step: */
    80     delete m_pStep;
    81     m_pStep = 0;
     76void UIGDetailsGroup::sltBuildStep(QString strStepId, int iStepNumber)
     77{
     78    /* Cleanup build-step: */
     79    delete m_pBuildStep;
     80    m_pBuildStep = 0;
    8281
    8382    /* Is step id valid? */
    84     if (strGroupId != m_strGroupId)
     83    if (strStepId != m_strGroupId)
    8584        return;
    8685
    87     /* Prepare first set: */
    88     m_iStep = 0;
    89     prepareSet(strGroupId);
    90 }
    91 
    92 void UIGDetailsGroup::sltNextStep(QString strGroupId)
    93 {
    94     /* Cleanup step: */
    95     delete m_pStep;
    96     m_pStep = 0;
    97 
    98     /* Is step id valid? */
    99     if (strGroupId != m_strGroupId)
    100         return;
    101 
    102     /* Prepare next set: */
    103     ++m_iStep;
    104     prepareSet(strGroupId);
     86    /* Step number feats the bounds: */
     87    if (iStepNumber >= 0 && iStepNumber < m_machineItems.size())
     88    {
     89        /* Should we create a new set for this step? */
     90        UIGDetailsSet *pSet = 0;
     91        if (iStepNumber > m_items.size() - 1)
     92            pSet = new UIGDetailsSet(this);
     93        /* Or use existing? */
     94        else
     95            pSet = m_items.at(iStepNumber)->toSet();
     96
     97        /* Create next build-step: */
     98        m_pBuildStep = new UIBuildStep(this, strStepId, iStepNumber + 1);
     99        connect(pSet, SIGNAL(sigBuildDone()), m_pBuildStep, SLOT(sltStepDone()), Qt::QueuedConnection);
     100        connect(m_pBuildStep, SIGNAL(sigStepDone(QString, int)), this, SLOT(sltBuildStep(QString, int)), Qt::QueuedConnection);
     101
     102        /* Build set: */
     103        pSet->buildSet(m_machineItems[iStepNumber], m_machineItems.size() == 1, m_settings);
     104    }
     105    else
     106    {
     107        /* Update model: */
     108        model()->updateLayout();
     109    }
    105110}
    106111
     
    171176void UIGDetailsGroup::prepareConnections()
    172177{
    173     connect(this, SIGNAL(sigStartFirstStep(QString)), this, SLOT(sltFirstStep(QString)), Qt::QueuedConnection);
     178    connect(this, SIGNAL(sigBuildStep(QString, int)), this, SLOT(sltBuildStep(QString, int)), Qt::QueuedConnection);
    174179}
    175180
     
    196201}
    197202
    198 void UIGDetailsGroup::prepareSet(QString strGroupId)
    199 {
    200     /* Step number feats the bounds: */
    201     if (m_iStep >= 0 && m_iStep < m_machineItems.size())
    202     {
    203         /* Should we create set? */
    204         UIGDetailsSet *pSet = 0;
    205         if (m_iStep > m_items.size() - 1)
    206             pSet = new UIGDetailsSet(this);
    207         else
    208             pSet = m_items.at(m_iStep)->toSet();
    209         /* Create prepare step: */
    210         m_pStep = new UIPrepareStep(this, strGroupId);
    211         connect(pSet, SIGNAL(sigSetCreationDone()), m_pStep, SLOT(sltStepDone()), Qt::QueuedConnection);
    212         connect(m_pStep, SIGNAL(sigStepDone(const QString&)), this, SLOT(sltNextStep(const QString&)), Qt::QueuedConnection);
    213         /* Configure set: */
    214         pSet->configure(m_machineItems[m_iStep], m_settings, m_machineItems.size() == 1);
    215     }
    216     else
    217     {
    218         /* Update model after group update: */
    219         model()->updateLayout();
    220     }
    221 }
    222 
    223203int UIGDetailsGroup::minimumWidthHint() const
    224204{
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsGroup.h

    r44011 r44016  
    3434signals:
    3535
    36     /* Notifier: Prepare stuff: */
    37     void sigStartFirstStep(QString strGroupId);
     36    /* Notifier: Build stuff: */
     37    void sigBuildStep(QString strStepId, int iStepNumber);
    3838
    3939public:
     
    4747    ~UIGDetailsGroup();
    4848
    49     /* API: Prepare stuff: */
    50     void setItems(const QList<UIVMItem*> &machineItems);
    51     void updateItems();
    52     void stopPopulatingItems();
     49    /* API: Build stuff: */
     50    void buildGroup(const QList<UIVMItem*> &machineItems);
     51    void rebuildGroup();
     52    void stopBuildingGroup();
    5353
    5454private slots:
    5555
    56     /* Handlers: Prepare stuff: */
    57     void sltFirstStep(QString strGroupId);
    58     void sltNextStep(QString strGroupId);
     56    /* Handler: Build stuff: */
     57    void sltBuildStep(QString strStepId, int iStepNumber);
    5958
    6059private:
     
    8180    void prepareConnections();
    8281    void loadSettings();
    83     void prepareSet(QString strGroupId);
    8482
    8583    /* Helpers: Layout stuff: */
     
    9189    QList<UIGDetailsItem*> m_items;
    9290    QList<UIVMItem*> m_machineItems;
    93     UIPrepareStep *m_pStep;
    94     int m_iStep;
     91    UIBuildStep *m_pBuildStep;
    9592    QString m_strGroupId;
    9693    QStringList m_settings;
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsItem.cpp

    r43989 r44016  
    144144}
    145145
    146 UIPrepareStep::UIPrepareStep(QObject *pParent, const QString &strStepId /* = QString() */)
     146UIBuildStep::UIBuildStep(QObject *pParent, const QString &strStepId, int iStepNumber)
    147147    : QObject(pParent)
    148148    , m_strStepId(strStepId)
     149    , m_iStepNumber(iStepNumber)
    149150{
    150151}
    151152
    152 void UIPrepareStep::sltStepDone()
     153void UIBuildStep::sltStepDone()
    153154{
    154     emit sigStepDone(m_strStepId);
     155    emit sigStepDone(m_strStepId, m_iStepNumber);
    155156}
    156157
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsItem.h

    r43989 r44016  
    9191};
    9292
    93 /* Allows to prepare item synchronously: */
    94 class UIPrepareStep : public QObject
     93/* Allows to build item content synchronously: */
     94class UIBuildStep : public QObject
    9595{
    9696    Q_OBJECT;
     
    9898signals:
    9999
    100     /* Notifier: Prepare stuff: */
    101     void sigStepDone(QString strStepId);
     100    /* Notifier: Build stuff: */
     101    void sigStepDone(QString strStepId, int iStepNumber);
    102102
    103103public:
    104104
    105105    /* Constructor: */
    106     UIPrepareStep(QObject *pParent, const QString &strStepId = QString());
     106    UIBuildStep(QObject *pParent, const QString &strStepId, int iStepNumber);
    107107
    108108private slots:
    109109
    110     /* Handlers: Prepare stuff: */
     110    /* Handler: Build stuff: */
    111111    void sltStepDone();
    112112
     
    115115    /* Variables: */
    116116    QString m_strStepId;
     117    int m_iStepNumber;
    117118};
    118119
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsModel.cpp

    r43990 r44016  
    9393void UIGDetailsModel::setItems(const QList<UIVMItem*> &items)
    9494{
    95     m_pRoot->setItems(items);
     95    m_pRoot->buildGroup(items);
    9696}
    9797
     
    196196    }
    197197    vboxGlobal().virtualBox().SetExtraDataStringList(GUI_DetailsPageBoxes, detailsSettings);
    198     m_pRoot->updateItems();
     198    m_pRoot->rebuildGroup();
    199199}
    200200
    201201void UIGDetailsModel::sltHandleSlidingStarted()
    202202{
    203     m_pRoot->stopPopulatingItems();
     203    m_pRoot->stopBuildingGroup();
    204204}
    205205
    206206void UIGDetailsModel::sltHandleToggleStarted()
    207207{
    208     m_pRoot->stopPopulatingItems();
     208    m_pRoot->stopBuildingGroup();
    209209}
    210210
    211211void UIGDetailsModel::sltHandleToggleFinished()
    212212{
    213     m_pRoot->updateItems();
     213    m_pRoot->rebuildGroup();
    214214}
    215215
  • 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
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsSet.h

    r44015 r44016  
    3939signals:
    4040
    41     /* Notifiers: Prepare stuff: */
    42     void sigStartFirstStep(QString strSetId);
    43     void sigSetPrepared();
    44     void sigSetCreationDone();
     41    /* Notifiers: Build stuff: */
     42    void sigBuildStep(QString strSetId, int iStepNumber);
     43    void sigBuildDone();
    4544
    4645public:
     
    5453    ~UIGDetailsSet();
    5554
    56     /* API: Configure stuff: */
    57     void configure(UIVMItem *pItem, const QStringList &settings, bool fFullSet);
     55    /* API: Build stuff: */
     56    void buildSet(UIVMItem *pItem, bool fFullSet, const QStringList &settings);
    5857
    5958    /* API: Machine stuff: */
     
    6261private slots:
    6362
    64     /* Handlers: Prepare stuff: */
    65     void sltFirstStep(QString strSetId);
    66     void sltNextStep(QString strSetId);
    67     void sltSetPrepared();
     63    /* Handler: Build stuff: */
     64    void sltBuildStep(QString strStepId, int iStepNumber);
    6865
    6966    /* Handlers: Global event stuff: */
     
    104101    void updateLayout();
    105102
    106     /* Helpers: Prepare stuff: */
    107     void prepareElements();
    108     void prepareElement(QString strSetId);
     103    /* Helpers: Build stuff: */
     104    void rebuildSet();
    109105    UIGDetailsElement* createElement(DetailsElementType elementType, bool fOpen);
    110106
     
    115111    /* Prepare variables: */
    116112    bool m_fFullSet;
    117     UIPrepareStep *m_pStep;
    118     int m_iStep;
     113    UIBuildStep *m_pBuildStep;
    119114    int m_iLastStepNumber;
    120115    QString m_strSetId;
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