VirtualBox

Changeset 44009 in vbox for trunk


Ignore:
Timestamp:
Dec 3, 2012 1:42:58 PM (12 years ago)
Author:
vboxsync
Message:

FE/Qt: VM group UI: Details-view: Group-item cleanup (part 1).

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

Legend:

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

    r43989 r44009  
    5555}
    5656
    57 void UIGDetailsGroup::addItem(UIGDetailsItem *pItem)
    58 {
    59     switch (pItem->type())
    60     {
    61         case UIGDetailsItemType_Set: m_sets.append(pItem); break;
    62         default: AssertMsgFailed(("Invalid item type!")); break;
    63     }
    64 }
    65 
    66 void UIGDetailsGroup::removeItem(UIGDetailsItem *pItem)
    67 {
    68     switch (pItem->type())
    69     {
    70         case UIGDetailsItemType_Set: m_sets.removeAt(m_sets.indexOf(pItem)); break;
    71         default: AssertMsgFailed(("Invalid item type!")); break;
    72     }
    73 }
    74 
    75 QList<UIGDetailsItem*> UIGDetailsGroup::items(UIGDetailsItemType type /* = UIGDetailsItemType_Set */) const
    76 {
    77     switch (type)
    78     {
    79         case UIGDetailsItemType_Any: return items(UIGDetailsItemType_Set);
    80         case UIGDetailsItemType_Set: return m_sets;
    81         default: AssertMsgFailed(("Invalid item type!")); break;
    82     }
    83     return QList<UIGDetailsItem*>();
    84 }
    85 
    86 bool UIGDetailsGroup::hasItems(UIGDetailsItemType type /* = UIGDetailsItemType_Set */) const
    87 {
    88     switch (type)
    89     {
    90         case UIGDetailsItemType_Any: return hasItems(UIGDetailsItemType_Set);
    91         case UIGDetailsItemType_Set: return !m_sets.isEmpty();
    92         default: AssertMsgFailed(("Invalid item type!")); break;
    93     }
    94     return false;
    95 }
    96 
    97 void UIGDetailsGroup::clearItems(UIGDetailsItemType type /* = UIGDetailsItemType_Set */)
    98 {
    99     switch (type)
    100     {
    101         case UIGDetailsItemType_Any: clearItems(UIGDetailsItemType_Set); break;
    102         case UIGDetailsItemType_Set: while (!m_sets.isEmpty()) { delete m_sets.last(); } break;
    103         default: AssertMsgFailed(("Invalid item type!")); break;
    104     }
     57void UIGDetailsGroup::sltFirstStep(QString strGroupId)
     58{
     59    /* Clear step: */
     60    delete m_pStep;
     61    m_pStep = 0;
     62
     63    /* Was that a requested group? */
     64    if (strGroupId != m_strGroupId)
     65        return;
     66
     67    /* Prepare first set: */
     68    m_iStep = 0;
     69    prepareSet(strGroupId);
     70}
     71
     72void UIGDetailsGroup::sltNextStep(QString strGroupId)
     73{
     74    /* Clear step: */
     75    delete m_pStep;
     76    m_pStep = 0;
     77
     78    /* Was that a requested group? */
     79    if (strGroupId != m_strGroupId)
     80        return;
     81
     82    /* Prepare next set: */
     83    ++m_iStep;
     84    prepareSet(strGroupId);
    10585}
    10686
     
    11999}
    120100
    121 void UIGDetailsGroup::sltFirstStep(QString strGroupId)
    122 {
    123     /* Clear step: */
    124     delete m_pStep;
    125     m_pStep = 0;
    126 
    127     /* Was that a requested group? */
    128     if (strGroupId != m_strGroupId)
    129         return;
    130 
    131     /* Prepare first set: */
    132     m_iStep = 0;
    133     prepareSet(strGroupId);
    134 }
    135 
    136 void UIGDetailsGroup::sltNextStep(QString strGroupId)
    137 {
    138     /* Clear step: */
    139     delete m_pStep;
    140     m_pStep = 0;
    141 
    142     /* Was that a requested group? */
    143     if (strGroupId != m_strGroupId)
    144         return;
    145 
    146     /* Prepare next set: */
    147     ++m_iStep;
    148     prepareSet(strGroupId);
     101void UIGDetailsGroup::addItem(UIGDetailsItem *pItem)
     102{
     103    switch (pItem->type())
     104    {
     105        case UIGDetailsItemType_Set: m_items.append(pItem); break;
     106        default: AssertMsgFailed(("Invalid item type!")); break;
     107    }
     108}
     109
     110void UIGDetailsGroup::removeItem(UIGDetailsItem *pItem)
     111{
     112    switch (pItem->type())
     113    {
     114        case UIGDetailsItemType_Set: m_items.removeAt(m_items.indexOf(pItem)); break;
     115        default: AssertMsgFailed(("Invalid item type!")); break;
     116    }
     117}
     118
     119QList<UIGDetailsItem*> UIGDetailsGroup::items(UIGDetailsItemType type /* = UIGDetailsItemType_Set */) const
     120{
     121    switch (type)
     122    {
     123        case UIGDetailsItemType_Set: return m_items;
     124        case UIGDetailsItemType_Any: return items(UIGDetailsItemType_Set);
     125        default: AssertMsgFailed(("Invalid item type!")); break;
     126    }
     127    return QList<UIGDetailsItem*>();
     128}
     129
     130bool UIGDetailsGroup::hasItems(UIGDetailsItemType type /* = UIGDetailsItemType_Set */) const
     131{
     132    switch (type)
     133    {
     134        case UIGDetailsItemType_Set: return !m_items.isEmpty();
     135        case UIGDetailsItemType_Any: return hasItems(UIGDetailsItemType_Set);
     136        default: AssertMsgFailed(("Invalid item type!")); break;
     137    }
     138    return false;
     139}
     140
     141void UIGDetailsGroup::clearItems(UIGDetailsItemType type /* = UIGDetailsItemType_Set */)
     142{
     143    switch (type)
     144    {
     145        case UIGDetailsItemType_Set: while (!m_items.isEmpty()) { delete m_items.last(); } break;
     146        case UIGDetailsItemType_Any: clearItems(UIGDetailsItemType_Set); break;
     147        default: AssertMsgFailed(("Invalid item type!")); break;
     148    }
    149149}
    150150
     
    171171}
    172172
    173 void UIGDetailsGroup::prepareSets(const QList<UIVMItem*> &items)
    174 {
     173void UIGDetailsGroup::prepareSets(const QList<UIVMItem*> &machineItems)
     174{
     175    /* Remember new items: */
     176    m_machineItems = machineItems;
     177
    175178    /* Cleanup superflous sets: */
    176     while (m_sets.size() > items.size())
    177         delete m_sets.last();
    178 
    179     /* Remember new items: */
    180     m_items = items;
     179    while (m_items.size() > m_machineItems.size())
     180        delete m_items.last();
    181181
    182182    /* Update sets: */
     
    201201{
    202202    /* Step number feats the bounds: */
    203     if (m_iStep >= 0 && m_iStep < m_items.size())
     203    if (m_iStep >= 0 && m_iStep < m_machineItems.size())
    204204    {
    205205        /* Should we create set? */
    206206        UIGDetailsSet *pSet = 0;
    207         if (m_iStep > m_sets.size() - 1)
     207        if (m_iStep > m_items.size() - 1)
    208208            pSet = new UIGDetailsSet(this);
    209209        else
    210             pSet = m_sets.at(m_iStep)->toSet();
     210            pSet = m_items.at(m_iStep)->toSet();
    211211        /* Create prepare step: */
    212212        m_pStep = new UIPrepareStep(this, strGroupId);
     
    214214        connect(m_pStep, SIGNAL(sigStepDone(const QString&)), this, SLOT(sltNextStep(const QString&)), Qt::QueuedConnection);
    215215        /* Configure set: */
    216         pSet->configure(m_items[m_iStep], m_settings, m_items.size() == 1);
     216        pSet->configure(m_machineItems[m_iStep], m_settings, m_machineItems.size() == 1);
    217217    }
    218218    else
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsGroup.h

    r43989 r44009  
    5252    void stopPopulatingItems();
    5353
    54     /* API: Children stuff: */
    55     void addItem(UIGDetailsItem *pItem);
    56     void removeItem(UIGDetailsItem *pItem);
    57     QList<UIGDetailsItem*> items(UIGDetailsItemType type = UIGDetailsItemType_Set) const;
    58     bool hasItems(UIGDetailsItemType type = UIGDetailsItemType_Set) const;
    59     void clearItems(UIGDetailsItemType type = UIGDetailsItemType_Set);
    60 
    6154private slots:
    6255
     
    7871    QVariant data(int iKey) const;
    7972
     73    /* Hidden API: Children stuff: */
     74    void addItem(UIGDetailsItem *pItem);
     75    void removeItem(UIGDetailsItem *pItem);
     76    QList<UIGDetailsItem*> items(UIGDetailsItemType type = UIGDetailsItemType_Set) const;
     77    bool hasItems(UIGDetailsItemType type = UIGDetailsItemType_Set) const;
     78    void clearItems(UIGDetailsItemType type = UIGDetailsItemType_Set);
     79
    8080    /* Helpers: Prepare stuff: */
    8181    void loadSettings();
     
    9090
    9191    /* Variables: */
    92     QList<UIGDetailsItem*> m_sets;
    93     QList<UIVMItem*> m_items;
     92    QList<UIGDetailsItem*> m_items;
     93    QList<UIVMItem*> m_machineItems;
    9494    UIPrepareStep *m_pStep;
    9595    int m_iStep;
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