Changeset 85035 in vbox
- Timestamp:
- Jul 1, 2020 4:45:17 PM (5 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r85013 r85035 928 928 # 929 929 VirtualBox_QT_MOCSRCS = \ 930 src/cloud/profilemanager/UICloudProfileManager.cpp \ 930 931 src/hostnetwork/UIHostNetworkManager.cpp \ 931 932 src/manager/UIWelcomePane.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/cloud/profilemanager/UICloudProfileDetailsWidget.h
r83950 r85035 45 45 /** Constructs data. */ 46 46 UIDataCloudProvider() 47 : m_ strName(QString())47 : m_fRestricted(false) 48 48 {} 49 49 … … 53 53 return true 54 54 && (m_uuid == other.m_uuid) 55 && (m_strShortName == other.m_strShortName) 55 56 && (m_strName == other.m_strName) 57 && (m_fRestricted == other.m_fRestricted) 56 58 ; 57 59 } … … 64 66 /** Holds the provider ID. */ 65 67 QUuid m_uuid; 68 /** Holds the provider short name. */ 69 QString m_strShortName; 66 70 /** Holds the provider name. */ 67 71 QString m_strName; 72 /** Holds whether provider is restricted. */ 73 bool m_fRestricted; 68 74 69 75 /** Holds the profile supported property descriptions. */ … … 76 82 /** Constructs data. */ 77 83 UIDataCloudProfile() 78 : m_ strName(QString())84 : m_fRestricted(false) 79 85 {} 80 86 … … 83 89 { 84 90 return true 91 && (m_strProviderShortName == other.m_strProviderShortName) 85 92 && (m_strName == other.m_strName) 93 && (m_fRestricted == other.m_fRestricted) 86 94 && (m_data == other.m_data) 87 95 ; … … 93 101 bool operator!=(const UIDataCloudProfile &other) const { return !equal(other); } 94 102 103 /** Holds the provider short name. */ 104 QString m_strProviderShortName; 95 105 /** Holds the profile name. */ 96 106 QString m_strName; 107 /** Holds whether provider is restricted. */ 108 bool m_fRestricted; 97 109 98 110 /** Holds the profile data. */ -
trunk/src/VBox/Frontends/VirtualBox/src/cloud/profilemanager/UICloudProfileManager.cpp
r85034 r85035 63 63 { 64 64 Column_Name, 65 Column_ListVMs, 65 66 Column_Max 66 67 }; … … 70 71 class UIItemCloudProvider : public QITreeWidgetItem, public UIDataCloudProvider 71 72 { 73 Q_OBJECT; 74 72 75 public: 73 76 … … 85 88 class UIItemCloudProfile : public QITreeWidgetItem, public UIDataCloudProfile 86 89 { 90 Q_OBJECT; 91 87 92 public: 88 93 … … 115 120 setText(Column_Name, m_strName); 116 121 setData(Column_Name, Data_ProviderID, m_uuid); 122 setCheckState(Column_ListVMs, m_fRestricted ? Qt::Unchecked : Qt::Checked); 117 123 } 118 124 … … 134 140 /* Update item fields: */ 135 141 setText(Column_Name, m_strName); 142 setCheckState(Column_ListVMs, m_fRestricted ? Qt::Unchecked : Qt::Checked); 136 143 } 137 144 … … 172 179 m_pToolBar->updateLayout(); 173 180 #endif 181 182 /* Translate tree-widget: */ 183 m_pTreeWidget->setHeaderLabels( QStringList() 184 << tr("Source") 185 << tr("List VMs")); 174 186 } 175 187 … … 491 503 } 492 504 505 void UICloudProfileManagerWidget::sltPerformTableAdjustment() 506 { 507 AssertPtrReturnVoid(m_pTreeWidget); 508 AssertPtrReturnVoid(m_pTreeWidget->header()); 509 AssertPtrReturnVoid(m_pTreeWidget->viewport()); 510 m_pTreeWidget->header()->resizeSection(0, m_pTreeWidget->viewport()->width() - m_pTreeWidget->header()->sectionSize(1)); 511 } 512 493 513 void UICloudProfileManagerWidget::sltHandleCurrentItemChange() 494 514 { … … 546 566 /* And show it: */ 547 567 menu.exec(m_pTreeWidget->mapToGlobal(position)); 568 } 569 570 void UICloudProfileManagerWidget::sltHandleItemChange(QTreeWidgetItem *pItem) 571 { 572 /* Cast pItem to QITreeWidgetItem: */ 573 QITreeWidgetItem *pChangedItem = QITreeWidgetItem::toItem(pItem); 574 AssertMsgReturnVoid(pChangedItem, ("Changed item must not be null!\n")); 575 576 /* Check whether item is of provider or profile type, then check whether it changed: */ 577 bool fChanged = false; 578 UIItemCloudProvider *pProviderItem = qobject_cast<UIItemCloudProvider*>(pChangedItem); 579 UIItemCloudProfile *pProfileItem = qobject_cast<UIItemCloudProfile*>(pChangedItem); 580 if (pProviderItem) 581 { 582 const UIDataCloudProvider oldData = *pProviderItem; 583 if ( (oldData.m_fRestricted && pProviderItem->checkState(Column_ListVMs) == Qt::Checked) 584 || (!oldData.m_fRestricted && pProviderItem->checkState(Column_ListVMs) == Qt::Unchecked)) 585 fChanged = true; 586 } 587 else if (pProfileItem) 588 { 589 const UIDataCloudProfile oldData = *pProfileItem; 590 if ( (oldData.m_fRestricted && pProfileItem->checkState(Column_ListVMs) == Qt::Checked) 591 || (!oldData.m_fRestricted && pProfileItem->checkState(Column_ListVMs) == Qt::Unchecked)) 592 fChanged = true; 593 } 594 595 /* Gather Cloud Profile Manager restrictions and save them to extra-data: */ 596 if (fChanged) 597 gEDataManager->setCloudProfileManagerRestrictions(gatherCloudProfileManagerRestrictions(m_pTreeWidget->invisibleRootItem())); 548 598 } 549 599 … … 644 694 { 645 695 /* Configure tree-widget: */ 646 m_pTreeWidget->header()-> hide();696 m_pTreeWidget->header()->setStretchLastSection(false); 647 697 m_pTreeWidget->setRootIsDecorated(false); 648 698 m_pTreeWidget->setAlternatingRowColors(true); … … 691 741 692 742 /* Tree-widget connections: */ 743 connect(m_pTreeWidget, &QITreeWidget::resized, 744 this, &UICloudProfileManagerWidget::sltPerformTableAdjustment, Qt::QueuedConnection); 745 connect(m_pTreeWidget->header(), &QHeaderView::sectionResized, 746 this, &UICloudProfileManagerWidget::sltPerformTableAdjustment, Qt::QueuedConnection); 693 747 connect(m_pTreeWidget, &QITreeWidget::currentItemChanged, 694 748 this, &UICloudProfileManagerWidget::sltHandleCurrentItemChange); … … 697 751 connect(m_pTreeWidget, &QITreeWidget::itemDoubleClicked, 698 752 m_pActionPool->action(UIActionIndexST_M_Cloud_T_Details), &QAction::setChecked); 753 connect(m_pTreeWidget, &QITreeWidget::itemChanged, 754 this, &UICloudProfileManagerWidget::sltHandleItemChange); 699 755 700 756 /* Details-widget connections: */ … … 705 761 connect(m_pDetailsWidget, &UICloudProfileDetailsWidget::sigDataChangeAccepted, 706 762 this, &UICloudProfileManagerWidget::sltApplyCloudProfileDetailsChanges); 763 764 /* Extra-data connections: */ 765 connect(gEDataManager, &UIExtraDataManager::sigCloudProfileManagerRestrictionChange, 766 this, &UICloudProfileManagerWidget::sltLoadCloudStuff); 707 767 } 708 768 … … 719 779 m_pTreeWidget->clear(); 720 780 781 /* Acquire cloud profile manager restrictions: */ 782 const QStringList restrictions = gEDataManager->cloudProfileManagerRestrictions(); 783 721 784 /* Iterate through existing providers: */ 722 785 foreach (const CCloudProvider &comCloudProvider, listCloudProviders()) … … 729 792 UIDataCloudProvider providerData; 730 793 loadCloudProvider(comCloudProvider, providerData); 794 const QString strProviderPath = QString("/%1").arg(providerData.m_strShortName); 795 providerData.m_fRestricted = restrictions.contains(strProviderPath); 731 796 createItemForCloudProvider(providerData, false); 732 797 … … 744 809 UIDataCloudProfile profileData; 745 810 loadCloudProfile(comCloudProfile, providerData, profileData); 811 const QString strProfilePath = QString("/%1/%2").arg(providerData.m_strShortName).arg(profileData.m_strName); 812 profileData.m_fRestricted = restrictions.contains(strProfilePath); 746 813 createItemForCloudProfile(pItem, profileData, false); 747 814 } … … 762 829 data.m_uuid = comProvider.GetId(); 763 830 if (comProvider.isOk()) 831 data.m_strShortName = comProvider.GetShortName(); 832 if (comProvider.isOk()) 764 833 data.m_strName = comProvider.GetName(); 765 834 foreach (const QString &strSupportedPropertyName, comProvider.GetSupportedPropertyNames()) … … 773 842 void UICloudProfileManagerWidget::loadCloudProfile(const CCloudProfile &comProfile, const UIDataCloudProvider &providerData, UIDataCloudProfile &profileData) 774 843 { 844 /* Gather provider settings: */ 845 profileData.m_strProviderShortName = providerData.m_strShortName; 846 775 847 /* Gather profile settings: */ 776 848 if (comProfile.isOk()) … … 858 930 m_pTreeWidget->setCurrentItem(pItem); 859 931 } 932 } 933 934 QStringList UICloudProfileManagerWidget::gatherCloudProfileManagerRestrictions(QTreeWidgetItem *pParentItem) 935 { 936 /* Prepare result: */ 937 QStringList result; 938 AssertPtrReturn(pParentItem, result); 939 940 /* Process unchecked QITreeWidgetItem(s) only: */ 941 QITreeWidgetItem *pChangedItem = QITreeWidgetItem::toItem(pParentItem); 942 if ( pChangedItem 943 && pChangedItem->checkState(Column_ListVMs) == Qt::Unchecked) 944 { 945 /* Check whether item is of provider or profile type: */ 946 UIItemCloudProvider *pProviderItem = qobject_cast<UIItemCloudProvider*>(pChangedItem); 947 UIItemCloudProfile *pProfileItem = qobject_cast<UIItemCloudProfile*>(pChangedItem); 948 if (pProviderItem) 949 { 950 const UIDataCloudProvider oldData = *pProviderItem; 951 result << QString("/%1").arg(oldData.m_strShortName); 952 } 953 else if (pProfileItem) 954 { 955 const UIDataCloudProfile oldData = *pProfileItem; 956 result << QString("/%1/%2").arg(oldData.m_strProviderShortName, oldData.m_strName); 957 } 958 } 959 960 /* Iterate through children recursively: */ 961 for (int i = 0; i < pParentItem->childCount(); ++i) 962 result << gatherCloudProfileManagerRestrictions(pParentItem->child(i)); 963 964 /* Return result: */ 965 return result; 860 966 } 861 967 … … 980 1086 return qobject_cast<UICloudProfileManagerWidget*>(QIManagerDialog::widget()); 981 1087 } 1088 1089 1090 #include "UICloudProfileManager.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/cloud/profilemanager/UICloudProfileManager.h
r85033 r85035 111 111 /** @name Tree-widget stuff. 112 112 * @{ */ 113 /** Handles request to load cloud stuff. */ 114 void sltLoadCloudStuff() { loadCloudStuff(); } 115 /** Adjusts tree-widget according content. */ 116 void sltPerformTableAdjustment(); 113 117 /** Handles tree-widget current item change. */ 114 118 void sltHandleCurrentItemChange(); 115 119 /** Handles context menu request for tree-widget @a position. */ 116 120 void sltHandleContextMenuRequest(const QPoint &position); 121 /** Handles tree-widget @a pItem change. */ 122 void sltHandleItemChange(QTreeWidgetItem *pItem); 117 123 /** @} */ 118 124 … … 161 167 /** Updates the passed tree-widget item on the basis of passed @a data, @a fChooseItem if requested. */ 162 168 void updateItemForCloudProfile(const UIDataCloudProfile &data, bool fChooseItem, UIItemCloudProfile *pItem); 169 170 /* Gathers a list of Cloud Profile Manager restrictions starting from @a pParentItem. */ 171 QStringList gatherCloudProfileManagerRestrictions(QTreeWidgetItem *pParentItem); 163 172 /** @} */ 164 173 -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.cpp
r84790 r85035 111 111 112 112 /* Cloud Profile Manager: */ 113 const char *UIExtraDataDefs::GUI_CloudProfileManager_Restrictions = "GUI/CloudProfileManager/Restrictions"; 113 114 const char *UIExtraDataDefs::GUI_CloudProfileManager_Details_Expanded = "GUI/CloudProfileManager/Details/Expanded"; 114 115 -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h
r84910 r85035 216 216 /** @name Cloud Profile Manager 217 217 * @{ */ 218 /** Holds Cloud Profile Manager restrictions. */ 219 SHARED_LIBRARY_STUFF extern const char *GUI_CloudProfileManager_Restrictions; 218 220 /** Holds whether Cloud Profile Manager details expanded. */ 219 221 SHARED_LIBRARY_STUFF extern const char *GUI_CloudProfileManager_Details_Expanded; -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp
r84990 r85035 1929 1929 << GUI_VirtualMediaManager_Details_Expanded 1930 1930 << GUI_HostNetworkManager_Details_Expanded 1931 << GUI_CloudProfileManager_Restrictions 1931 1932 << GUI_CloudProfileManager_Details_Expanded 1932 1933 << GUI_HideDescriptionForWizards … … 2974 2975 } 2975 2976 2977 QStringList UIExtraDataManager::cloudProfileManagerRestrictions() 2978 { 2979 return extraDataStringList(GUI_CloudProfileManager_Restrictions); 2980 } 2981 2982 void UIExtraDataManager::setCloudProfileManagerRestrictions(const QStringList &restrictions) 2983 { 2984 return setExtraDataStringList(GUI_CloudProfileManager_Restrictions, restrictions); 2985 } 2986 2976 2987 bool UIExtraDataManager::cloudProfileManagerDetailsExpanded() 2977 2988 { … … 4568 4579 else if (strKey == GUI_Input_HostKeyCombination) 4569 4580 emit sigRuntimeUIHostKeyCombinationChange(); 4581 /* Cloud Profile Manager restrictions changed: */ 4582 else if (strKey == GUI_CloudProfileManager_Restrictions) 4583 emit sigCloudProfileManagerRestrictionChange(); 4570 4584 /* Details categories: */ 4571 4585 else if (strKey == GUI_Details_Elements) -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h
r84990 r85035 75 75 /** Notifies about Runtime UI host-key combination change. */ 76 76 void sigRuntimeUIHostKeyCombinationChange(); 77 78 /** Notifies about Cloud Profile Manager restriction change. */ 79 void sigCloudProfileManagerRestrictionChange(); 77 80 78 81 /** Notifies about VirtualBox Manager / Details pane categories change. */ … … 405 408 /** @name Cloud Profile Manager 406 409 * @{ */ 410 /** Returns Cloud Profile Manager restrictions. */ 411 QStringList cloudProfileManagerRestrictions(); 412 /** Defines Cloud Profile Manager @a restrictions. */ 413 void setCloudProfileManagerRestrictions(const QStringList &restrictions); 414 407 415 /** Returns whether Cloud Profile Manager details expanded. */ 408 416 bool cloudProfileManagerDetailsExpanded();
Note:
See TracChangeset
for help on using the changeset viewer.