Changeset 104998 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Jun 24, 2024 2:23:44 PM (8 months ago)
- svn:sync-xref-src-repo-rev:
- 163616
- 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 120 120 { 121 121 /* Push initial values to editor: */ 122 m_pFormEditor->set Values(initialValues);122 m_pFormEditor->setFormValues(initialValues); 123 123 } 124 124 /* If filter present: */ … … 133 133 filteredValues << comValue; 134 134 /* Push filtered values to editor: */ 135 m_pFormEditor->set Values(filteredValues);135 m_pFormEditor->setFormValues(filteredValues); 136 136 } 137 137 } -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIFormEditorWidget.cpp
r104997 r104998 613 613 virtual ~UIFormEditorView() RT_OVERRIDE; 614 614 615 protected: 616 617 /** Handles @a pEvent. */ 618 virtual bool event(QEvent *pEvent) RT_OVERRIDE; 619 620 protected 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 615 628 private: 616 629 … … 619 632 /** Cleanups everything. */ 620 633 void cleanup(); 634 635 /** Adjusts table contents. */ 636 void adjust(); 621 637 622 638 /** Holds the item editor factory instance. */ … … 1563 1579 } 1564 1580 1581 bool 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 1601 void 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 1565 1610 void UIFormEditorView::prepare() 1566 1611 { … … 1627 1672 } 1628 1673 1674 void 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 1629 1698 1630 1699 /********************************************************************************************************************************* … … 1668 1737 { 1669 1738 m_pTableModel->clearForm(); 1670 adjustTable(); 1671 } 1672 1673 void UIFormEditorWidget::setValues(const QVector<CFormValue> &values) 1739 } 1740 1741 void UIFormEditorWidget::setFormValues(const QVector<CFormValue> &values) 1674 1742 { 1675 1743 m_pTableModel->setFormValues(values); 1676 adjustTable();1677 1744 } 1678 1745 … … 1681 1748 AssertPtrReturnVoid(m_pTableModel); 1682 1749 /// @todo add some check.. 1683 set Values(comForm.GetValues());1750 setFormValues(comForm.GetValues()); 1684 1751 } 1685 1752 … … 1688 1755 AssertPtrReturnVoid(m_pTableModel); 1689 1756 /// @todo add some check.. 1690 set Values(comForm.GetValues());1757 setFormValues(comForm.GetValues()); 1691 1758 } 1692 1759 … … 1694 1761 { 1695 1762 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);1720 1763 } 1721 1764 … … 1741 1784 { 1742 1785 m_pTableView->setModel(pProxyModel); 1743 m_pTableView->installEventFilter(this);1744 1786 pLayout->addWidget(m_pTableView); 1745 1787 } … … 1747 1789 } 1748 1790 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 else1764 {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 1773 1791 1774 1792 #include "UIFormEditorWidget.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIFormEditorWidget.h
r104997 r104998 74 74 /** Clears form. */ 75 75 void clearForm(); 76 /** Defines @a values to be edited. */77 void set Values(const QVector<CFormValue> &values);76 /** Defines form @a values to be edited. */ 77 void setFormValues(const QVector<CFormValue> &values); 78 78 /** Defines @a comForm to be edited. */ 79 79 void setForm(const CForm &comForm); … … 84 84 void makeSureEditorDataCommitted(); 85 85 86 protected:87 88 /** Preprocesses any Qt @a pEvent for passed @a pObject. */89 virtual bool eventFilter(QObject *pObject, QEvent *pEvent) RT_OVERRIDE;90 91 86 private: 92 87 93 88 /** Prepares all. */ 94 89 void prepare(); 95 96 /** Adjusts table column sizes. */97 void adjustTable();98 90 99 91 /** Holds the notification-center reference. */
Note:
See TracChangeset
for help on using the changeset viewer.