- Timestamp:
- Dec 14, 2020 5:54:10 PM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/networkmanager
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/networkmanager/UINetworkManager.cpp
r87001 r87088 199 199 , m_pDetailsWidget(0) 200 200 { 201 /* Prepare: */202 201 prepare(); 203 uiCommon().setHelpKeyword(this, "networkingdetails");204 202 } 205 203 206 204 QMenu *UINetworkManagerWidget::menu() const 207 205 { 206 AssertPtrReturn(m_pActionPool, 0); 208 207 return m_pActionPool->action(UIActionIndexMN_M_NetworkWindow)->menu(); 209 208 } … … 223 222 224 223 /* Translate tree-widget: */ 225 const QStringList fields = QStringList() 226 << UINetworkManager::tr("Name") 227 << UINetworkManager::tr("IPv4 Address/Mask") 228 << UINetworkManager::tr("IPv6 Address/Mask") 229 << UINetworkManager::tr("DHCP Server"); 230 m_pTreeWidget->setHeaderLabels(fields); 224 if (m_pTreeWidget) 225 { 226 const QStringList fields = QStringList() 227 << UINetworkManager::tr("Name") 228 << UINetworkManager::tr("IPv4 Address/Mask") 229 << UINetworkManager::tr("IPv6 Address/Mask") 230 << UINetworkManager::tr("DHCP Server"); 231 m_pTreeWidget->setHeaderLabels(fields); 232 } 231 233 } 232 234 … … 251 253 void UINetworkManagerWidget::sltResetHostNetworkDetailsChanges() 252 254 { 253 /* Just push the current item data thereagain: */255 /* Just push current item data to details-widget again: */ 254 256 sltHandleCurrentItemChange(); 255 257 } … … 257 259 void UINetworkManagerWidget::sltApplyHostNetworkDetailsChanges() 258 260 { 261 /* Check tree-widget: */ 262 AssertMsgReturnVoid(m_pTreeWidget, ("Tree-widget isn't created!\n")); 263 259 264 /* Get network item: */ 260 265 UIItemHostNetwork *pItem = static_cast<UIItemHostNetwork*>(m_pTreeWidget->currentItem()); 261 266 AssertMsgReturnVoid(pItem, ("Current item must not be null!\n")); 267 268 /* Check details-widget: */ 269 AssertMsgReturnVoid(m_pDetailsWidget, ("Details-widget isn't created!\n")); 262 270 263 271 /* Get item data: */ … … 431 439 void UINetworkManagerWidget::sltRemoveHostNetwork() 432 440 { 441 /* Check tree-widget: */ 442 AssertMsgReturnVoid(m_pTreeWidget, ("Tree-widget isn't created!\n")); 443 433 444 /* Get network item: */ 434 445 UIItemHostNetwork *pItem = static_cast<UIItemHostNetwork*>(m_pTreeWidget->currentItem()); … … 514 525 gEDataManager->setHostNetworkManagerDetailsExpanded(fVisible); 515 526 /* Show/hide details area and Apply button: */ 516 m_pDetailsWidget->setVisible(fVisible); 517 /* Notify external lsiteners: */ 527 if (m_pDetailsWidget) 528 m_pDetailsWidget->setVisible(fVisible); 529 /* Notify external listeners: */ 518 530 emit sigHostNetworkDetailsVisibilityChanged(fVisible); 519 531 } … … 527 539 void UINetworkManagerWidget::sltAdjustTreeWidget() 528 540 { 529 /* Get the tree-widget abstract interface: */ 530 QAbstractItemView *pItemView = m_pTreeWidget; 531 /* Get the tree-widget header-view: */ 532 QHeaderView *pItemHeader = m_pTreeWidget->header(); 533 534 /* Calculate the total tree-widget width: */ 535 const int iTotal = m_pTreeWidget->viewport()->width(); 536 /* Look for a minimum width hints for non-important columns: */ 537 const int iMinWidth1 = qMax(pItemView->sizeHintForColumn(Column_IPv4), pItemHeader->sectionSizeHint(Column_IPv4)); 538 const int iMinWidth2 = qMax(pItemView->sizeHintForColumn(Column_IPv6), pItemHeader->sectionSizeHint(Column_IPv6)); 539 const int iMinWidth3 = qMax(pItemView->sizeHintForColumn(Column_DHCP), pItemHeader->sectionSizeHint(Column_DHCP)); 540 /* Propose suitable width hints for non-important columns: */ 541 const int iWidth1 = iMinWidth1 < iTotal / Column_Max ? iMinWidth1 : iTotal / Column_Max; 542 const int iWidth2 = iMinWidth2 < iTotal / Column_Max ? iMinWidth2 : iTotal / Column_Max; 543 const int iWidth3 = iMinWidth3 < iTotal / Column_Max ? iMinWidth3 : iTotal / Column_Max; 544 /* Apply the proposal: */ 545 m_pTreeWidget->setColumnWidth(Column_IPv4, iWidth1); 546 m_pTreeWidget->setColumnWidth(Column_IPv6, iWidth2); 547 m_pTreeWidget->setColumnWidth(Column_DHCP, iWidth3); 548 m_pTreeWidget->setColumnWidth(Column_Name, iTotal - iWidth1 - iWidth2 - iWidth3); 541 /* Check tree-widget: */ 542 if (m_pTreeWidget) 543 { 544 /* Get the tree-widget abstract interface: */ 545 QAbstractItemView *pItemView = m_pTreeWidget; 546 /* Get the tree-widget header-view: */ 547 QHeaderView *pItemHeader = m_pTreeWidget->header(); 548 549 /* Calculate the total tree-widget width: */ 550 const int iTotal = m_pTreeWidget->viewport()->width(); 551 /* Look for a minimum width hints for non-important columns: */ 552 const int iMinWidth1 = qMax(pItemView->sizeHintForColumn(Column_IPv4), pItemHeader->sectionSizeHint(Column_IPv4)); 553 const int iMinWidth2 = qMax(pItemView->sizeHintForColumn(Column_IPv6), pItemHeader->sectionSizeHint(Column_IPv6)); 554 const int iMinWidth3 = qMax(pItemView->sizeHintForColumn(Column_DHCP), pItemHeader->sectionSizeHint(Column_DHCP)); 555 /* Propose suitable width hints for non-important columns: */ 556 const int iWidth1 = iMinWidth1 < iTotal / Column_Max ? iMinWidth1 : iTotal / Column_Max; 557 const int iWidth2 = iMinWidth2 < iTotal / Column_Max ? iMinWidth2 : iTotal / Column_Max; 558 const int iWidth3 = iMinWidth3 < iTotal / Column_Max ? iMinWidth3 : iTotal / Column_Max; 559 /* Apply the proposal: */ 560 m_pTreeWidget->setColumnWidth(Column_IPv4, iWidth1); 561 m_pTreeWidget->setColumnWidth(Column_IPv6, iWidth2); 562 m_pTreeWidget->setColumnWidth(Column_DHCP, iWidth3); 563 m_pTreeWidget->setColumnWidth(Column_Name, iTotal - iWidth1 - iWidth2 - iWidth3); 564 } 549 565 } 550 566 … … 635 651 void UINetworkManagerWidget::sltHandleCurrentItemChange() 636 652 { 653 /* Check tree-widget: */ 654 AssertMsgReturnVoid(m_pTreeWidget, ("Tree-widget isn't created!\n")); 655 637 656 /* Get network item: */ 638 657 UIItemHostNetwork *pItem = static_cast<UIItemHostNetwork*>(m_pTreeWidget->currentItem()); … … 641 660 m_pActionPool->action(UIActionIndexMN_M_Network_S_Remove)->setEnabled(pItem); 642 661 m_pActionPool->action(UIActionIndexMN_M_Network_T_Details)->setEnabled(pItem); 662 663 /* Check details-widget: */ 664 AssertMsgReturnVoid(m_pDetailsWidget, ("Details-widget isn't created!\n")); 643 665 644 666 /* If there is an item => update details data: */ … … 655 677 void UINetworkManagerWidget::sltHandleContextMenuRequest(const QPoint &position) 656 678 { 679 /* Check tree-widget: */ 680 AssertMsgReturnVoid(m_pTreeWidget, ("Tree-widget isn't created!\n")); 681 657 682 /* Compose temporary context-menu: */ 658 683 QMenu menu; … … 673 698 void UINetworkManagerWidget::prepare() 674 699 { 675 /* Prepare actions: */ 700 /* Prepare self: */ 701 uiCommon().setHelpKeyword(this, "networkingdetails"); 702 703 /* Prepare stuff: */ 676 704 prepareActions(); 677 /* Prepare widgets: */678 705 prepareWidgets(); 679 706 … … 711 738 /* Create main-layout: */ 712 739 new QVBoxLayout(this); 713 AssertPtrReturnVoid(layout());740 if (layout()) 714 741 { 715 742 /* Configure layout: */ … … 735 762 /* Create toolbar: */ 736 763 m_pToolBar = new QIToolBar(parentWidget()); 737 AssertPtrReturnVoid(m_pToolBar);764 if (m_pToolBar) 738 765 { 739 766 /* Configure toolbar: */ … … 766 793 void UINetworkManagerWidget::prepareTreeWidget() 767 794 { 768 /* Create tree-widget: */ 769 m_pTreeWidget = new QITreeWidget; 770 AssertPtrReturnVoid(m_pTreeWidget); 771 { 772 /* Configure tree-widget: */ 795 /* Prepare tree-widget: */ 796 m_pTreeWidget = new QITreeWidget(this); 797 if (m_pTreeWidget) 798 { 773 799 m_pTreeWidget->setRootIsDecorated(false); 774 800 m_pTreeWidget->setAlternatingRowColors(true); … … 795 821 void UINetworkManagerWidget::prepareDetailsWidget() 796 822 { 797 /* Create details-widget: */ 798 m_pDetailsWidget = new UINetworkDetailsWidget(m_enmEmbedding); 799 AssertPtrReturnVoid(m_pDetailsWidget); 800 { 801 /* Configure details-widget: */ 823 /* Prepare details-widget: */ 824 m_pDetailsWidget = new UINetworkDetailsWidget(m_enmEmbedding, this); 825 if (m_pDetailsWidget) 826 { 802 827 m_pDetailsWidget->setVisible(false); 803 828 m_pDetailsWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); … … 817 842 { 818 843 /* Details action/widget: */ 819 m_pActionPool->action(UIActionIndexMN_M_Network_T_Details)->setChecked(gEDataManager->hostNetworkManagerDetailsExpanded()); 820 sltToggleHostNetworkDetailsVisibility(m_pActionPool->action(UIActionIndexMN_M_Network_T_Details)->isChecked()); 844 if (m_pActionPool) 845 { 846 m_pActionPool->action(UIActionIndexMN_M_Network_T_Details)->setChecked(gEDataManager->hostNetworkManagerDetailsExpanded()); 847 sltToggleHostNetworkDetailsVisibility(m_pActionPool->action(UIActionIndexMN_M_Network_T_Details)->isChecked()); 848 } 821 849 } 822 850 823 851 void UINetworkManagerWidget::loadHostNetworks() 824 852 { 853 /* Check tree-widget: */ 854 if (!m_pTreeWidget) 855 return; 856 825 857 /* Clear tree first of all: */ 826 858 m_pTreeWidget->clear(); … … 917 949 /* Create new item: */ 918 950 UIItemHostNetwork *pItem = new UIItemHostNetwork; 919 AssertPtrReturnVoid(pItem);951 if (pItem) 920 952 { 921 953 /* Configure item: */ … … 933 965 { 934 966 /* Update passed item: */ 935 AssertPtrReturnVoid(pItem);967 if (pItem) 936 968 { 937 969 /* Configure item: */ … … 1016 1048 void UINetworkManager::configureCentralWidget() 1017 1049 { 1018 /* Create widget: */1050 /* Prepare widget: */ 1019 1051 UINetworkManagerWidget *pWidget = new UINetworkManagerWidget(EmbedTo_Dialog, m_pActionPool, true, this); 1020 AssertPtrReturnVoid(pWidget); 1021 { 1022 /* Configure widget: */ 1052 if (pWidget) 1053 { 1023 1054 setWidget(pWidget); 1024 1055 setWidgetMenu(pWidget->menu()); -
trunk/src/VBox/Frontends/VirtualBox/src/networkmanager/UINetworkManager.h
r86997 r87088 61 61 * @param fShowToolbar Brings whether we should create/show toolbar. */ 62 62 UINetworkManagerWidget(EmbedTo enmEmbedding, UIActionPool *pActionPool, 63 63 bool fShowToolbar = true, QWidget *pParent = 0); 64 64 65 65 /** Returns the menu. */ … … 161 161 * @{ */ 162 162 /** Holds the widget embedding type. */ 163 const EmbedTo m_enmEmbedding;163 const EmbedTo m_enmEmbedding; 164 164 /** Holds the action-pool reference. */ 165 UIActionPool *m_pActionPool;165 UIActionPool *m_pActionPool; 166 166 /** Holds whether we should create/show toolbar. */ 167 const bool m_fShowToolbar;167 const bool m_fShowToolbar; 168 168 /** @} */ 169 169 … … 177 177 * @{ */ 178 178 /** Holds the tree-widget instance. */ 179 QITreeWidget *m_pTreeWidget;179 QITreeWidget *m_pTreeWidget; 180 180 /** Holds the details-widget instance. */ 181 181 UINetworkDetailsWidget *m_pDetailsWidget;
Note:
See TracChangeset
for help on using the changeset viewer.