VirtualBox

Changeset 43776 in vbox for trunk


Ignore:
Timestamp:
Oct 30, 2012 12:31:49 PM (12 years ago)
Author:
vboxsync
Message:

FE/Qt: VM group UI: Group-item code reordering, comments cleanup (part 1).

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemGroup.cpp

    r43620 r43776  
    248248bool UIGChooserItemGroup::isContainsLockedMachine()
    249249{
    250     /* For each machine item: */
     250    /* For each machine-item: */
    251251    foreach (UIGChooserItem *pItem, items(UIGChooserItemType_Machine))
    252252        if (pItem->toMachineItem()->isLockedMachine())
    253253            return true;
    254     /* For each group item: */
     254    /* For each group-item: */
    255255    foreach (UIGChooserItem *pItem, items(UIGChooserItemType_Group))
    256256        if (pItem->toGroupItem()->isContainsLockedMachine())
     
    518518}
    519519
     520void UIGChooserItemGroup::prepare()
     521{
     522    /* Non root item only: */
     523    if (!isRoot())
     524    {
     525        /* Setup toggle-button: */
     526        m_pToggleButton = new UIGraphicsRotatorButton(this, "additionalHeight", opened());
     527        connect(m_pToggleButton, SIGNAL(sigRotationStart()), this, SLOT(sltGroupToggleStart()));
     528        connect(m_pToggleButton, SIGNAL(sigRotationFinish(bool)), this, SLOT(sltGroupToggleFinish(bool)));
     529        m_pToggleButton->hide();
     530
     531        /* Setup enter-button: */
     532        m_pEnterButton = new UIGraphicsButton(this, UIGraphicsButtonType_DirectArrow);
     533        connect(m_pEnterButton, SIGNAL(sigButtonClicked()), this, SLOT(sltIndentRoot()));
     534        m_pEnterButton->hide();
     535
     536        /* Setup name-editor: */
     537        m_pNameEditorWidget = new UIGroupRenameEditor(m_strName, this);
     538        m_pNameEditorWidget->setFont(data(GroupItemData_NameFont).value<QFont>());
     539        connect(m_pNameEditorWidget, SIGNAL(sigEditingFinished()), this, SLOT(sltNameEditingFinished()));
     540        m_pNameEditor = new QGraphicsProxyWidget(this);
     541        m_pNameEditor->setWidget(m_pNameEditorWidget);
     542        m_pNameEditor->hide();
     543    }
     544    /* Root item but non main: */
     545    if (!isMainRoot())
     546    {
     547        /* Setup exit-button: */
     548        m_pExitButton = new UIGraphicsButton(this, UIGraphicsButtonType_DirectArrow);
     549        connect(m_pExitButton, SIGNAL(sigButtonClicked()), this, SLOT(sltUnindentRoot()));
     550        QSizeF sh = m_pExitButton->minimumSizeHint();
     551        m_pExitButton->setTransformOriginPoint(sh.width() / 2, sh.height() / 2);
     552        m_pExitButton->setRotation(180);
     553        m_pExitButton->hide();
     554    }
     555}
     556
     557/* static */
     558void UIGChooserItemGroup::copyContent(UIGChooserItemGroup *pFrom, UIGChooserItemGroup *pTo)
     559{
     560    /* Copy group items: */
     561    foreach (UIGChooserItem *pGroupItem, pFrom->items(UIGChooserItemType_Group))
     562        new UIGChooserItemGroup(pTo, pGroupItem->toGroupItem());
     563    /* Copy machine items: */
     564    foreach (UIGChooserItem *pMachineItem, pFrom->items(UIGChooserItemType_Machine))
     565        new UIGChooserItemMachine(pTo, pMachineItem->toMachineItem());
     566}
     567
    520568void UIGChooserItemGroup::retranslateUi()
    521569{
     
    622670        case UIGChooserItemType_Group:
    623671        {
    624             AssertMsg(!m_groupItems.contains(pItem), ("Group item already added!"));
     672            AssertMsg(!m_groupItems.contains(pItem), ("Group-item already added!"));
    625673            if (iPosition < 0 || iPosition >= m_groupItems.size())
    626674                m_groupItems.append(pItem);
     
    632680        case UIGChooserItemType_Machine:
    633681        {
    634             AssertMsg(!m_machineItems.contains(pItem), ("Machine item already added!"));
     682            AssertMsg(!m_machineItems.contains(pItem), ("Machine-item already added!"));
    635683            if (iPosition < 0 || iPosition >= m_machineItems.size())
    636684                m_machineItems.append(pItem);
     
    657705        case UIGChooserItemType_Group:
    658706        {
    659             AssertMsg(m_groupItems.contains(pItem), ("Group item was not found!"));
     707            AssertMsg(m_groupItems.contains(pItem), ("Group-item was not found!"));
    660708            scene()->removeItem(pItem);
    661709            m_groupItems.removeAt(m_groupItems.indexOf(pItem));
     
    664712        case UIGChooserItemType_Machine:
    665713        {
    666             AssertMsg(m_machineItems.contains(pItem), ("Machine item was not found!"));
     714            AssertMsg(m_machineItems.contains(pItem), ("Machine-item was not found!"));
    667715            scene()->removeItem(pItem);
    668716            m_machineItems.removeAt(m_machineItems.indexOf(pItem));
     
    9631011    int iProposedWidth = 0;
    9641012
    965     /* Simple group item have 2 margins - left and right: */
     1013    /* Simple group-item have 2 margins - left and right: */
    9661014    iProposedWidth += 2 * iHorizontalMargin;
    9671015    /* And full header width to take into account: */
     
    9951043    int iProposedHeight = 0;
    9961044
    997     /* Simple group item have 2 margins - top and bottom: */
     1045    /* Simple group-item have 2 margins - top and bottom: */
    9981046    iProposedHeight += 2 * iVerticalMargin;
    9991047    /* And full header height to take into account: */
     
    10461094    /* Else call to base-class: */
    10471095    return UIGChooserItem::sizeHint(which, constraint);
     1096}
     1097
     1098void UIGChooserItemGroup::updateToggleButtonToolTip()
     1099{
     1100    /* Is toggle-button created? */
     1101    if (!m_pToggleButton)
     1102        return;
     1103
     1104    /* Update toggle-button tool-tip: */
     1105    m_pToggleButton->setToolTip(opened() ? tr("Collapse group") : tr("Expand group"));
    10481106}
    10491107
     
    10741132    if (pMimeData->hasFormat(UIGChooserItemGroup::className()))
    10751133    {
    1076         /* Get passed group item: */
     1134        /* Get passed group-item: */
    10771135        const UIGChooserItemMimeData *pCastedMimeData = qobject_cast<const UIGChooserItemMimeData*>(pMimeData);
    10781136        AssertMsg(pCastedMimeData, ("Can't cast passed mime-data to UIGChooserItemMimeData!"));
     
    10971155    else if (pMimeData->hasFormat(UIGChooserItemMachine::className()))
    10981156    {
    1099         /* Get passed machine item: */
     1157        /* Get passed machine-item: */
    11001158        const UIGChooserItemMimeData *pCastedMimeData = qobject_cast<const UIGChooserItemMimeData*>(pMimeData);
    11011159        AssertMsg(pCastedMimeData, ("Can't cast passed mime-data to UIGChooserItemMimeData!"));
     
    11381196                UIGChooserModel *pModel = model();
    11391197
    1140                 /* Get passed group item: */
     1198                /* Get passed group-item: */
    11411199                const UIGChooserItemMimeData *pCastedMime = qobject_cast<const UIGChooserItemMimeData*>(pMime);
    11421200                AssertMsg(pCastedMime, ("Can't cast passed mime-data to UIGChooserItemMimeData!"));
     
    12101268                }
    12111269
    1212                 /* Copy passed machine item into this group: */
     1270                /* Copy passed machine-item into this group: */
    12131271                UIGChooserItem *pNewMachineItem = new UIGChooserItemMachine(this, pItem->toMachineItem(), iPosition);
    12141272                if (closed())
     
    15811639}
    15821640
    1583 void UIGChooserItemGroup::prepare()
    1584 {
    1585     /* Non root item only: */
    1586     if (!isRoot())
    1587     {
    1588         /* Setup toggle-button: */
    1589         m_pToggleButton = new UIGraphicsRotatorButton(this, "additionalHeight", opened());
    1590         connect(m_pToggleButton, SIGNAL(sigRotationStart()), this, SLOT(sltGroupToggleStart()));
    1591         connect(m_pToggleButton, SIGNAL(sigRotationFinish(bool)), this, SLOT(sltGroupToggleFinish(bool)));
    1592         m_pToggleButton->hide();
    1593 
    1594         /* Setup enter-button: */
    1595         m_pEnterButton = new UIGraphicsButton(this, UIGraphicsButtonType_DirectArrow);
    1596         connect(m_pEnterButton, SIGNAL(sigButtonClicked()), this, SLOT(sltIndentRoot()));
    1597         m_pEnterButton->hide();
    1598 
    1599         /* Setup name-editor: */
    1600         m_pNameEditorWidget = new UIGroupRenameEditor(m_strName, this);
    1601         m_pNameEditorWidget->setFont(data(GroupItemData_NameFont).value<QFont>());
    1602         connect(m_pNameEditorWidget, SIGNAL(sigEditingFinished()), this, SLOT(sltNameEditingFinished()));
    1603         m_pNameEditor = new QGraphicsProxyWidget(this);
    1604         m_pNameEditor->setWidget(m_pNameEditorWidget);
    1605         m_pNameEditor->hide();
    1606     }
    1607     /* Root item but non main: */
    1608     if (!isMainRoot())
    1609     {
    1610         /* Setup exit-button: */
    1611         m_pExitButton = new UIGraphicsButton(this, UIGraphicsButtonType_DirectArrow);
    1612         connect(m_pExitButton, SIGNAL(sigButtonClicked()), this, SLOT(sltUnindentRoot()));
    1613         QSizeF sh = m_pExitButton->minimumSizeHint();
    1614         m_pExitButton->setTransformOriginPoint(sh.width() / 2, sh.height() / 2);
    1615         m_pExitButton->setRotation(180);
    1616         m_pExitButton->hide();
    1617     }
    1618 }
    1619 
    1620 /* static */
    1621 void UIGChooserItemGroup::copyContent(UIGChooserItemGroup *pFrom, UIGChooserItemGroup *pTo)
    1622 {
    1623     /* Copy group items: */
    1624     foreach (UIGChooserItem *pGroupItem, pFrom->items(UIGChooserItemType_Group))
    1625         new UIGChooserItemGroup(pTo, pGroupItem->toGroupItem());
    1626     /* Copy machine items: */
    1627     foreach (UIGChooserItem *pMachineItem, pFrom->items(UIGChooserItemType_Machine))
    1628         new UIGChooserItemMachine(pTo, pMachineItem->toMachineItem());
    1629 }
    1630 
    1631 void UIGChooserItemGroup::updateToggleButtonToolTip()
    1632 {
    1633     /* Is toggle-button created? */
    1634     if (!m_pToggleButton)
    1635         return;
    1636 
    1637     /* Update toggle-button tool-tip: */
    1638     m_pToggleButton->setToolTip(opened() ? tr("Collapse group") : tr("Expand group"));
    1639 }
    1640 
    16411641UIGroupRenameEditor::UIGroupRenameEditor(const QString &strName, UIGChooserItem *pParent)
    16421642    : m_pParent(pParent)
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemGroup.h

    r43620 r43776  
    2828/* Forward declarations: */
    2929class QGraphicsScene;
     30class QGraphicsProxyWidget;
     31class QLineEdit;
    3032class UIGraphicsButton;
    3133class UIGraphicsRotatorButton;
    32 class QLineEdit;
    33 class QGraphicsProxyWidget;
    3434class UIGroupRenameEditor;
    3535
    36 /* Graphics group item
     36/* Graphics group-item
    3737 * for graphics selector model/view architecture: */
    3838class UIGChooserItemGroup : public UIGChooserItem
     
    6161                        bool fMainRoot);
    6262    UIGChooserItemGroup(UIGChooserItem *pParent, const QString &strName,
    63                         bool fOpened  = false , int iPosition  = -1 );
     63                        bool fOpened = false, int iPosition  = -1);
    6464    UIGChooserItemGroup(UIGChooserItem *pParent, UIGChooserItemGroup *pCopyFrom,
    65                         int iPosition  = -1 );
     65                        int iPosition = -1);
    6666    ~UIGChooserItemGroup();
    6767
     
    8282private slots:
    8383
    84     /* Handler: Group name editing: */
     84    /* Handler: Name editing stuff: */
    8585    void sltNameEditingFinished();
    8686
    87     /* Handler: Collapse/expand stuff: */
     87    /* Handler: Toggle stuff: */
    8888    void sltGroupToggleStart();
    8989    void sltGroupToggleFinish(bool fToggled);
    9090
    91     /* Handler: Indent root stuff: */
     91    /* Handlers: Indent root stuff: */
    9292    void sltIndentRoot();
    9393    void sltUnindentRoot();
     
    130130    QVariant data(int iKey) const;
    131131
     132    /* Helpers: Prepare stuff: */
     133    void prepare();
     134    static void copyContent(UIGChooserItemGroup *pFrom, UIGChooserItemGroup *pTo);
     135
    132136    /* Helper: Translate stuff: */
    133137    void retranslateUi();
     
    162166    QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
    163167
    164     /* Helpers: Drag and drop stuff: */
     168    /* Helper: Collapse/expand stuff: */
     169    void updateToggleButtonToolTip();
     170
     171    /* Helpers: Drag&drop stuff: */
    165172    QPixmap toPixmap();
    166173    bool isDropAllowed(QGraphicsSceneDragDropEvent *pEvent, DragToken where) const;
     
    169176    QMimeData* createMimeData();
    170177
    171     /* Event handlers: */
     178    /* Helper: Event handling stuff: */
    172179    void hoverMoveEvent(QGraphicsSceneHoverEvent *pEvent);
    173180
     
    184191    int additionalHeight() const;
    185192
    186     /* Helpers: Prepare stuff: */
    187     void prepare();
    188     static void copyContent(UIGChooserItemGroup *pFrom, UIGChooserItemGroup *pTo);
    189 
    190193    /* Helper: Color stuff: */
    191194    int blackoutDarkness() const { return m_iBlackoutDarkness; }
    192 
    193     /* Helper: Collapse/expand stuff: */
    194     void updateToggleButtonToolTip();
    195195
    196196    /* Variables: */
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