VirtualBox

Changeset 43988 in vbox for trunk/src


Ignore:
Timestamp:
Nov 28, 2012 3:52:23 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
82363
Message:

FE/Qt: VM group UI: Details-view: Manual layout for group item.

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

Legend:

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

    r43987 r43988  
    1818 */
    1919
    20 /* Qt includes: */
    21 #include <QGraphicsLinearLayout>
    22 
    2320/* GUI includes: */
    2421#include "UIGDetailsGroup.h"
     
    3027UIGDetailsGroup::UIGDetailsGroup()
    3128    : UIGDetailsItem(0)
    32     , m_pMainLayout(0)
    33     , m_pLayout(0)
    3429    , m_pStep(0)
    3530    , m_iStep(0)
    3631{
    37     /* Prepare layout: */
    38     prepareLayout();
    39 
    4032    /* Prepare connections: */
    4133    connect(this, SIGNAL(sigStartFirstStep(QString)), this, SLOT(sltFirstStep(QString)), Qt::QueuedConnection);
     
    6759    switch (pItem->type())
    6860    {
    69         case UIGDetailsItemType_Set: m_sets.append(pItem); m_pLayout->addItem(pItem); break;
     61        case UIGDetailsItemType_Set: m_sets.append(pItem); break;
    7062        default: AssertMsgFailed(("Invalid item type!")); break;
    7163    }
     
    7668    switch (pItem->type())
    7769    {
    78         case UIGDetailsItemType_Set: m_sets.removeAt(m_sets.indexOf(pItem)); m_pLayout->removeItem(pItem); break;
     70        case UIGDetailsItemType_Set: m_sets.removeAt(m_sets.indexOf(pItem)); break;
    7971        default: AssertMsgFailed(("Invalid item type!")); break;
    8072    }
     
    125117    }
    126118    return QVariant();
    127 }
    128 
    129 void UIGDetailsGroup::updateLayout()
    130 {
    131     /* Update size-hints for all the items: */
    132     foreach (UIGDetailsItem *pItem, items())
    133         pItem->updateSizeHint();
    134     /* Update size-hint for this item: */
    135     updateSizeHint();
    136 
    137     /* Update layout finally: */
    138     m_pMainLayout->activate();
    139     m_pLayout->activate();
    140     foreach (UIGDetailsItem *pItem, items())
    141         pItem->updateLayout();
    142119}
    143120
     
    194171}
    195172
    196 void UIGDetailsGroup::prepareLayout()
    197 {
    198     /* Prepare variables: */
    199     int iMargin = data(GroupData_Margin).toInt();
    200     int iSpacing = data(GroupData_Spacing).toInt();
    201 
    202     /* Prepare layout: */
    203     m_pMainLayout = new QGraphicsLinearLayout(Qt::Vertical);
    204     m_pMainLayout->setContentsMargins(0, 0, 0, 0);
    205     m_pMainLayout->setSpacing(0);
    206     m_pLayout = new QGraphicsLinearLayout(Qt::Vertical);
    207     m_pLayout->setContentsMargins(iMargin, iMargin, iMargin, iMargin);
    208     m_pLayout->setSpacing(iSpacing);
    209     m_pMainLayout->addItem(m_pLayout);
    210     m_pMainLayout->addStretch();
    211     setLayout(m_pMainLayout);
    212 }
    213 
    214173void UIGDetailsGroup::prepareSets(const QList<UIVMItem*> &items)
    215174{
     
    264223}
    265224
     225int UIGDetailsGroup::minimumWidthHint() const
     226{
     227    /* Prepare variables: */
     228    int iMargin = data(GroupData_Margin).toInt();
     229    int iMinimumWidthHint = 0;
     230
     231    /* Take into account all the sets: */
     232    foreach (UIGDetailsItem *pItem, items())
     233        if (UIGDetailsSet *pSet = pItem->toSet())
     234            iMinimumWidthHint = qMax(iMinimumWidthHint, pSet->minimumWidthHint());
     235
     236    /* And two margins finally: */
     237    iMinimumWidthHint += 2 * iMargin;
     238
     239    /* Return value: */
     240    return iMinimumWidthHint;
     241}
     242
     243int UIGDetailsGroup::minimumHeightHint() const
     244{
     245    /* Prepare variables: */
     246    int iMargin = data(GroupData_Margin).toInt();
     247    int iSpacing = data(GroupData_Spacing).toInt();
     248    int iMinimumHeightHint = 0;
     249
     250    /* Take into account all the sets: */
     251    foreach (UIGDetailsItem *pItem, items())
     252        if (UIGDetailsSet *pSet = pItem->toSet())
     253            iMinimumHeightHint += (pSet->minimumHeightHint() + iSpacing);
     254
     255    /* Minus last spacing: */
     256    iMinimumHeightHint -= iSpacing;
     257
     258    /* And two margins finally: */
     259    iMinimumHeightHint += 2 * iMargin;
     260
     261    /* Return value: */
     262    return iMinimumHeightHint;
     263}
     264
     265QSizeF UIGDetailsGroup::sizeHint(Qt::SizeHint which, const QSizeF &constraint /* = QSizeF() */) const
     266{
     267    /* If Qt::MinimumSize requested: */
     268    if (which == Qt::MinimumSize || which == Qt::PreferredSize)
     269    {
     270        /* Return wrappers: */
     271        return QSizeF(minimumWidthHint(), minimumHeightHint());
     272    }
     273
     274    /* Call to base-class: */
     275    return UIGDetailsItem::sizeHint(which, constraint);
     276}
     277
     278void UIGDetailsGroup::updateLayout()
     279{
     280    /* Prepare variables: */
     281    int iMargin = data(GroupData_Margin).toInt();
     282    int iSpacing = data(GroupData_Spacing).toInt();
     283    int iMaximumWidth = (int)geometry().width() - 2 * iMargin;
     284    int iVerticalIndent = iMargin;
     285
     286    /* Layout all the sets: */
     287    foreach (UIGDetailsItem *pItem, items())
     288    {
     289        /* Get particular set: */
     290        UIGDetailsSet *pSet = pItem->toSet();
     291        /* Move set: */
     292        pItem->setPos(iMargin, iVerticalIndent);
     293        /* Resize set: */
     294        int iWidth = iMaximumWidth;
     295        pItem->resize(iWidth, pSet->minimumHeightHint());
     296        /* Layout set content: */
     297        pItem->updateLayout();
     298        /* Advance indent: */
     299        iVerticalIndent += (pSet->minimumHeightHint() + iSpacing);
     300    }
     301}
     302
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsGroup.h

    r42813 r43988  
    2424
    2525/* Forward declarations: */
    26 class QGraphicsLinearLayout;
    2726class UIVMItem;
    2827
     
    6059    void clearItems(UIGDetailsItemType type = UIGDetailsItemType_Set);
    6160
    62     /* API: Layout stuff: */
    63     void updateLayout();
    64 
    6561private slots:
    6662
     
    8480    /* Helpers: Prepare stuff: */
    8581    void loadSettings();
    86     void prepareLayout();
    8782    void prepareSets(const QList<UIVMItem*> &items);
    8883    void updateSets();
    8984    void prepareSet(QString strGroupId);
    9085
    91     /* Main variables: */
    92     QGraphicsLinearLayout *m_pMainLayout;
    93     QGraphicsLinearLayout *m_pLayout;
     86    /* Helpers: Layout stuff: */
     87    int minimumWidthHint() const;
     88    int minimumHeightHint() const;
     89    QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
     90    void updateLayout();
     91
     92    /* Variables: */
    9493    QList<UIGDetailsItem*> m_sets;
    95 
    96     /* Prepare variables: */
    9794    QList<UIVMItem*> m_items;
    9895    UIPrepareStep *m_pStep;
     
    10097    QString m_strGroupId;
    10198    QStringList m_settings;
     99
     100    /* Friends: */
     101    friend class UIGDetailsModel;
    102102};
    103103
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsSet.h

    r43987 r43988  
    117117    QString m_strSetId;
    118118    QStringList m_settings;
     119
     120    /* Friends: */
     121    friend class UIGDetailsGroup;
    119122};
    120123
Note: See TracChangeset for help on using the changeset viewer.

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