Changeset 78143 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Apr 16, 2019 11:49:44 AM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIFormEditorWidget.cpp
r78131 r78143 18 18 /* Qt includes: */ 19 19 #include <QComboBox> 20 #include <QEvent> 20 21 #include <QHeaderView> 21 22 #include <QItemEditorFactory> … … 563 564 /// @todo add some check.. 564 565 m_pTableModel->setFormValues(comForm.GetValues()); 566 adjustTable(); 567 } 568 569 bool UIFormEditorWidget::eventFilter(QObject *pObject, QEvent *pEvent) 570 { 571 /* Process events for table only: */ 572 if (pObject != m_pTableView) 573 return QWidget::eventFilter(pObject, pEvent); 574 575 /* Process different event-types: */ 576 switch (pEvent->type()) 577 { 578 case QEvent::Show: 579 case QEvent::Resize: 580 { 581 /* Adjust table: */ 582 adjustTable(); 583 break; 584 } 585 default: 586 break; 587 } 588 589 /* Call to base-class: */ 590 return QWidget::eventFilter(pObject, pEvent); 565 591 } 566 592 … … 571 597 if (pLayout) 572 598 { 599 pLayout->setContentsMargins(0, 0, 0, 0); 600 573 601 /* Create view: */ 574 602 m_pTableView = new UIFormEditorView(this); … … 579 607 m_pTableView->verticalHeader()->setDefaultSectionSize((int)(m_pTableView->verticalHeader()->minimumSectionSize() * 1.33)); 580 608 m_pTableView->setSelectionMode(QAbstractItemView::SingleSelection); 609 m_pTableView->installEventFilter(this); 581 610 582 611 /* Create model: */ … … 614 643 } 615 644 645 void UIFormEditorWidget::adjustTable() 646 { 647 m_pTableView->horizontalHeader()->setStretchLastSection(false); 648 /* If table is NOT empty: */ 649 if (m_pTableModel->rowCount()) 650 { 651 /* Resize table to contents size-hint and emit a spare place for first column: */ 652 m_pTableView->resizeColumnsToContents(); 653 const int iFullWidth = m_pTableView->viewport()->width(); 654 const int iNameWidth = m_pTableView->horizontalHeader()->sectionSize(UIFormEditorDataType_Name); 655 const int iValueWidth = qMax(0, iFullWidth - iNameWidth); 656 m_pTableView->horizontalHeader()->resizeSection(UIFormEditorDataType_Value, iValueWidth); 657 } 658 /* If table is empty: */ 659 else 660 { 661 /* Resize table columns to be equal in size: */ 662 const int iFullWidth = m_pTableView->viewport()->width(); 663 m_pTableView->horizontalHeader()->resizeSection(UIFormEditorDataType_Name, iFullWidth / 2); 664 m_pTableView->horizontalHeader()->resizeSection(UIFormEditorDataType_Value, iFullWidth / 2); 665 } 666 m_pTableView->horizontalHeader()->setStretchLastSection(true); 667 } 668 616 669 617 670 #include "UIFormEditorWidget.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIFormEditorWidget.h
r78131 r78143 70 70 void setVirtualSystemDescriptionForm(const CVirtualSystemDescriptionForm &comForm); 71 71 72 protected: 73 74 /** Preprocesses any Qt @a pEvent for passed @a pObject. */ 75 virtual bool eventFilter(QObject *pObject, QEvent *pEvent) /* override */; 76 72 77 private: 73 78 74 79 /** Prepares all. */ 75 80 void prepare(); 81 82 /** Adjusts table column sizes. */ 83 void adjustTable(); 76 84 77 85 /** Holds the table-view instance. */
Note:
See TracChangeset
for help on using the changeset viewer.