VirtualBox

Ignore:
Timestamp:
Jun 24, 2024 2:23:44 PM (8 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
163616
Message:

FE/Qt: bugref:10681: UIFormEditorWidget: Moving the rest of table sub-class stuff from parent into appropriate place.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/cloud/machinesettings/UICloudMachineSettingsDialogPage.cpp

    r104273 r104998  
    120120        {
    121121            /* Push initial values to editor: */
    122             m_pFormEditor->setValues(initialValues);
     122            m_pFormEditor->setFormValues(initialValues);
    123123        }
    124124        /* If filter present: */
     
    133133                    filteredValues << comValue;
    134134            /* Push filtered values to editor: */
    135             m_pFormEditor->setValues(filteredValues);
     135            m_pFormEditor->setFormValues(filteredValues);
    136136        }
    137137    }
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIFormEditorWidget.cpp

    r104997 r104998  
    613613    virtual ~UIFormEditorView() RT_OVERRIDE;
    614614
     615protected:
     616
     617    /** Handles @a pEvent. */
     618    virtual bool event(QEvent *pEvent) RT_OVERRIDE;
     619
     620protected slots:
     621
     622    /** Handles rows being inserted.
     623      * @param  parent  Brings the parent under which new rows being inserted.
     624      * @param  iStart  Brings the starting position (inclusive).
     625      * @param  iStart  Brings the end position (inclusive). */
     626    virtual void rowsInserted(const QModelIndex &parent, int iStart, int iEnd) RT_OVERRIDE;
     627
    615628private:
    616629
     
    619632    /** Cleanups everything. */
    620633    void cleanup();
     634
     635    /** Adjusts table contents. */
     636    void adjust();
    621637
    622638    /** Holds the item editor factory instance. */
     
    15631579}
    15641580
     1581bool UIFormEditorView::event(QEvent *pEvent)
     1582{
     1583    /* Process different event-types: */
     1584    switch (pEvent->type())
     1585    {
     1586        /* Adjust table on show/resize events: */
     1587        case QEvent::Show:
     1588        case QEvent::Resize:
     1589        {
     1590            adjust();
     1591            break;
     1592        }
     1593        default:
     1594            break;
     1595    }
     1596
     1597    /* Call to base-class: */
     1598    return QITableView::event(pEvent);
     1599}
     1600
     1601void UIFormEditorView::rowsInserted(const QModelIndex &parent, int iStart, int iEnd)
     1602{
     1603    /* Call to base-class: */
     1604    QITableView::rowsInserted(parent, iStart, iEnd);
     1605
     1606    /* Adjust table on rows being inserted: */
     1607    adjust();
     1608}
     1609
    15651610void UIFormEditorView::prepare()
    15661611{
     
    16271672}
    16281673
     1674void UIFormEditorView::adjust()
     1675{
     1676    horizontalHeader()->setStretchLastSection(false);
     1677    /* If table is NOT empty: */
     1678    if (model()->rowCount())
     1679    {
     1680        /* Resize table to contents size-hint and emit a spare place for first column: */
     1681        resizeColumnsToContents();
     1682        const int iFullWidth = viewport()->width();
     1683        const int iNameWidth = horizontalHeader()->sectionSize(UIFormEditorDataType_Name);
     1684        const int iValueWidth = qMax(0, iFullWidth - iNameWidth);
     1685        horizontalHeader()->resizeSection(UIFormEditorDataType_Value, iValueWidth);
     1686    }
     1687    /* If table is empty: */
     1688    else
     1689    {
     1690        /* Resize table columns to be equal in size: */
     1691        const int iFullWidth = viewport()->width();
     1692        horizontalHeader()->resizeSection(UIFormEditorDataType_Name, iFullWidth / 2);
     1693        horizontalHeader()->resizeSection(UIFormEditorDataType_Value, iFullWidth / 2);
     1694    }
     1695    horizontalHeader()->setStretchLastSection(true);
     1696}
     1697
    16291698
    16301699/*********************************************************************************************************************************
     
    16681737{
    16691738    m_pTableModel->clearForm();
    1670     adjustTable();
    1671 }
    1672 
    1673 void UIFormEditorWidget::setValues(const QVector<CFormValue> &values)
     1739}
     1740
     1741void UIFormEditorWidget::setFormValues(const QVector<CFormValue> &values)
    16741742{
    16751743    m_pTableModel->setFormValues(values);
    1676     adjustTable();
    16771744}
    16781745
     
    16811748    AssertPtrReturnVoid(m_pTableModel);
    16821749    /// @todo add some check..
    1683     setValues(comForm.GetValues());
     1750    setFormValues(comForm.GetValues());
    16841751}
    16851752
     
    16881755    AssertPtrReturnVoid(m_pTableModel);
    16891756    /// @todo add some check..
    1690     setValues(comForm.GetValues());
     1757    setFormValues(comForm.GetValues());
    16911758}
    16921759
     
    16941761{
    16951762    m_pTableView->makeSureEditorDataCommitted();
    1696 }
    1697 
    1698 bool UIFormEditorWidget::eventFilter(QObject *pObject, QEvent *pEvent)
    1699 {
    1700     /* Process events for table only: */
    1701     if (pObject != m_pTableView)
    1702         return QWidget::eventFilter(pObject, pEvent);
    1703 
    1704     /* Process different event-types: */
    1705     switch (pEvent->type())
    1706     {
    1707         case QEvent::Show:
    1708         case QEvent::Resize:
    1709         {
    1710             /* Adjust table: */
    1711             adjustTable();
    1712             break;
    1713         }
    1714         default:
    1715             break;
    1716     }
    1717 
    1718     /* Call to base-class: */
    1719     return QWidget::eventFilter(pObject, pEvent);
    17201763}
    17211764
     
    17411784        {
    17421785            m_pTableView->setModel(pProxyModel);
    1743             m_pTableView->installEventFilter(this);
    17441786            pLayout->addWidget(m_pTableView);
    17451787        }
     
    17471789}
    17481790
    1749 void UIFormEditorWidget::adjustTable()
    1750 {
    1751     m_pTableView->horizontalHeader()->setStretchLastSection(false);
    1752     /* If table is NOT empty: */
    1753     if (m_pTableModel->rowCount())
    1754     {
    1755         /* Resize table to contents size-hint and emit a spare place for first column: */
    1756         m_pTableView->resizeColumnsToContents();
    1757         const int iFullWidth = m_pTableView->viewport()->width();
    1758         const int iNameWidth = m_pTableView->horizontalHeader()->sectionSize(UIFormEditorDataType_Name);
    1759         const int iValueWidth = qMax(0, iFullWidth - iNameWidth);
    1760         m_pTableView->horizontalHeader()->resizeSection(UIFormEditorDataType_Value, iValueWidth);
    1761     }
    1762     /* If table is empty: */
    1763     else
    1764     {
    1765         /* Resize table columns to be equal in size: */
    1766         const int iFullWidth = m_pTableView->viewport()->width();
    1767         m_pTableView->horizontalHeader()->resizeSection(UIFormEditorDataType_Name, iFullWidth / 2);
    1768         m_pTableView->horizontalHeader()->resizeSection(UIFormEditorDataType_Value, iFullWidth / 2);
    1769     }
    1770     m_pTableView->horizontalHeader()->setStretchLastSection(true);
    1771 }
    1772 
    17731791
    17741792#include "UIFormEditorWidget.moc"
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIFormEditorWidget.h

    r104997 r104998  
    7474    /** Clears form. */
    7575    void clearForm();
    76     /** Defines @a values to be edited. */
    77     void setValues(const QVector<CFormValue> &values);
     76    /** Defines form @a values to be edited. */
     77    void setFormValues(const QVector<CFormValue> &values);
    7878    /** Defines @a comForm to be edited. */
    7979    void setForm(const CForm &comForm);
     
    8484    void makeSureEditorDataCommitted();
    8585
    86 protected:
    87 
    88     /** Preprocesses any Qt @a pEvent for passed @a pObject. */
    89     virtual bool eventFilter(QObject *pObject, QEvent *pEvent) RT_OVERRIDE;
    90 
    9186private:
    9287
    9388    /** Prepares all. */
    9489    void prepare();
    95 
    96     /** Adjusts table column sizes. */
    97     void adjustTable();
    9890
    9991    /** Holds the notification-center reference. */
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