Changeset 85387 in vbox for trunk/src/VBox
- Timestamp:
- Jul 20, 2020 10:39:24 AM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 139412
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/cloud/profilemanager
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/cloud/profilemanager/UICloudProfileDetailsWidget.cpp
r83950 r85387 36 36 : QIWithRetranslateUI<QWidget>(pParent) 37 37 , m_enmEmbedding(enmEmbedding) 38 , m_pLabelName(0) 39 , m_pEditorName(0) 40 , m_pLabelTableWidget(0) 38 41 , m_pTableWidget(0) 39 42 , m_pButtonBox(0) 40 43 { 41 /* Prepare: */42 44 prepare(); 43 45 } -
trunk/src/VBox/Frontends/VirtualBox/src/cloud/profilemanager/UICloudProfileDetailsWidget.h
r85035 r85387 52 52 { 53 53 return true 54 && (m_u uid == other.m_uuid)54 && (m_uId == other.m_uId) 55 55 && (m_strShortName == other.m_strShortName) 56 56 && (m_strName == other.m_strName) … … 65 65 66 66 /** Holds the provider ID. */ 67 QUuid m_u uid;67 QUuid m_uId; 68 68 /** Holds the provider short name. */ 69 69 QString m_strShortName; … … 105 105 /** Holds the profile name. */ 106 106 QString m_strName; 107 /** Holds whether pro videris restricted. */107 /** Holds whether profile is restricted. */ 108 108 bool m_fRestricted; 109 109 … … 217 217 QTableWidget *m_pTableWidget; 218 218 219 /** Holds the serverbutton-box instance. */219 /** Holds the button-box instance. */ 220 220 QIDialogButtonBox *m_pButtonBox; 221 221 /** @} */ -
trunk/src/VBox/Frontends/VirtualBox/src/cloud/profilemanager/UICloudProfileManager.cpp
r85035 r85387 34 34 #include "UIMessageCenter.h" 35 35 #include "UIToolBar.h" 36 #ifdef VBOX_WS_MAC37 # include "UIWindowMenuManager.h"38 #endif39 36 40 37 /* COM includes: */ … … 47 44 enum CloudItemType 48 45 { 49 CloudItemType_Provider = QTreeWidgetItem::UserType + 1, 50 CloudItemType_Profile = QTreeWidgetItem::UserType + 2 46 CloudItemType_Invalid = 0, 47 CloudItemType_Provider = 1, 48 CloudItemType_Profile = 2 51 49 }; 52 50 Q_DECLARE_METATYPE(CloudItemType); … … 57 55 Data_ItemType = Qt::UserRole + 1, 58 56 Data_ProviderID = Qt::UserRole + 2, 57 Data_Definition = Qt::UserRole + 3, 59 58 }; 60 59 … … 119 118 /* Update item fields: */ 120 119 setText(Column_Name, m_strName); 121 setData(Column_Name, Data_ProviderID, m_uuid); 120 setData(Column_Name, Data_ProviderID, m_uId); 121 setData(Column_Name, Data_Definition, QVariant::fromValue(QString("/%1").arg(m_strShortName))); 122 122 setCheckState(Column_ListVMs, m_fRestricted ? Qt::Unchecked : Qt::Checked); 123 123 } … … 140 140 /* Update item fields: */ 141 141 setText(Column_Name, m_strName); 142 setData(Column_Name, Data_Definition, QVariant::fromValue(QString("/%1/%2").arg(m_strProviderShortName, m_strName))); 142 143 setCheckState(Column_ListVMs, m_fRestricted ? Qt::Unchecked : Qt::Checked); 143 144 } … … 158 159 , m_pDetailsWidget(0) 159 160 { 160 /* Prepare: */161 161 prepare(); 162 162 } … … 188 188 void UICloudProfileManagerWidget::sltResetCloudProfileDetailsChanges() 189 189 { 190 /* Just push the current 190 /* Just push the current-item data there again: */ 191 191 sltHandleCurrentItemChange(); 192 192 } … … 194 194 void UICloudProfileManagerWidget::sltApplyCloudProfileDetailsChanges() 195 195 { 196 /* I scan be that there is provider item, not profile item currently selected.196 /* It can be that there is provider item, not profile item currently selected. 197 197 * In such case we are not applying parameters, we are creating new one profile. */ 198 QTreeWidgetItem *pItem = m_pTreeWidget->currentItem(); 199 UIItemCloudProvider *pMaybeProviderItem = pItem && pItem->data(0, Data_ItemType).value<CloudItemType>() == CloudItemType_Provider 200 ? static_cast<UIItemCloudProvider*>(pItem) : 0; 198 QITreeWidgetItem *pItem = QITreeWidgetItem::toItem(m_pTreeWidget->currentItem()); 199 UIItemCloudProvider *pMaybeProviderItem = qobject_cast<UIItemCloudProvider*>(pItem); 201 200 if (pMaybeProviderItem) 202 201 return sltAddCloudProfile(); 203 202 204 203 /* Get profile item: */ 205 UIItemCloudProfile *pProfileItem = static_cast<UIItemCloudProfile*>(m_pTreeWidget->currentItem());204 UIItemCloudProfile *pProfileItem = qobject_cast<UIItemCloudProfile*>(pItem); 206 205 AssertMsgReturnVoid(pProfileItem, ("Current item must not be null!\n")); 207 206 … … 221 220 { 222 221 /* Get provider item: */ 223 UIItemCloudProvider *pProviderItem = static_cast<UIItemCloudProvider*>(pProfileItem->parentItem());222 UIItemCloudProvider *pProviderItem = qobject_cast<UIItemCloudProvider*>(pProfileItem->parentItem()); 224 223 /* Acquire provider ID: */ 225 224 const QUuid uId = pProviderItem->data(Column_Name, Data_ProviderID).toUuid(); … … 275 274 updateItemForCloudProfile(data, true, pProfileItem); 276 275 277 /* Make sure current 276 /* Make sure current-item fetched: */ 278 277 sltHandleCurrentItemChange(); 279 278 … … 295 294 { 296 295 /* Get provider item: */ 297 UIItemCloudProvider *pProviderItem = static_cast<UIItemCloudProvider*>(m_pTreeWidget->currentItem()); 296 QITreeWidgetItem *pItem = QITreeWidgetItem::toItem(m_pTreeWidget->currentItem()); 297 UIItemCloudProvider *pProviderItem = qobject_cast<UIItemCloudProvider*>(pItem); 298 298 AssertMsgReturnVoid(pProviderItem, ("Current item must not be null!\n")); 299 299 … … 378 378 { 379 379 /* Get provider item: */ 380 UIItemCloudProvider *pProviderItem = static_cast<UIItemCloudProvider*>(m_pTreeWidget->currentItem()); 380 QITreeWidgetItem *pItem = QITreeWidgetItem::toItem(m_pTreeWidget->currentItem()); 381 UIItemCloudProvider *pProviderItem = qobject_cast<UIItemCloudProvider*>(pItem); 381 382 AssertMsgReturnVoid(pProviderItem, ("Current item must not be null!\n")); 382 383 … … 424 425 { 425 426 /* Get profile item: */ 426 UIItemCloudProfile *pProfileItem = static_cast<UIItemCloudProfile*>(m_pTreeWidget->currentItem()); 427 QITreeWidgetItem *pItem = QITreeWidgetItem::toItem(m_pTreeWidget->currentItem()); 428 UIItemCloudProfile *pProfileItem = qobject_cast<UIItemCloudProfile*>(pItem); 427 429 AssertMsgReturnVoid(pProfileItem, ("Current item must not be null!\n")); 428 430 … … 445 447 { 446 448 /* Get provider item: */ 447 UIItemCloudProvider *pProviderItem = static_cast<UIItemCloudProvider*>(pProfileItem->parentItem());449 UIItemCloudProvider *pProviderItem = qobject_cast<UIItemCloudProvider*>(pProfileItem->parentItem()); 448 450 /* Acquire provider ID: */ 449 451 const QUuid uId = pProviderItem->data(Column_Name, Data_ProviderID).toUuid(); … … 513 515 void UICloudProfileManagerWidget::sltHandleCurrentItemChange() 514 516 { 515 /* Get items: */ 516 QTreeWidgetItem *pItem = m_pTreeWidget->currentItem(); 517 UIItemCloudProvider *pItemProvider = pItem && pItem->data(0, Data_ItemType).value<CloudItemType>() == CloudItemType_Provider 518 ? static_cast<UIItemCloudProvider*>(pItem) 519 : 0; 520 UIItemCloudProfile *pItemProfile = pItem && pItem->data(0, Data_ItemType).value<CloudItemType>() == CloudItemType_Profile 521 ? static_cast<UIItemCloudProfile*>(pItem) 522 : 0; 517 /* Check current-item type: */ 518 QITreeWidgetItem *pItem = QITreeWidgetItem::toItem(m_pTreeWidget->currentItem()); 519 UIItemCloudProvider *pItemProvider = qobject_cast<UIItemCloudProvider*>(pItem); 520 UIItemCloudProfile *pItemProfile = qobject_cast<UIItemCloudProfile*>(pItem); 523 521 524 522 /* Update actions availability: */ … … 541 539 void UICloudProfileManagerWidget::sltHandleContextMenuRequest(const QPoint &position) 542 540 { 543 /* Get items: */ 544 QTreeWidgetItem *pItem = m_pTreeWidget->itemAt(position); 545 UIItemCloudProvider *pItemProvider = pItem && pItem->data(0, Data_ItemType).value<CloudItemType>() == CloudItemType_Provider 546 ? static_cast<UIItemCloudProvider*>(pItem) 547 : 0; 548 UIItemCloudProfile *pItemProfile = pItem && pItem->data(0, Data_ItemType).value<CloudItemType>() == CloudItemType_Profile 549 ? static_cast<UIItemCloudProfile*>(pItem) 550 : 0; 541 /* Check clicked-item type: */ 542 QITreeWidgetItem *pItem = QITreeWidgetItem::toItem(m_pTreeWidget->itemAt(position)); 543 UIItemCloudProvider *pItemProvider = qobject_cast<UIItemCloudProvider*>(pItem); 544 UIItemCloudProfile *pItemProfile = qobject_cast<UIItemCloudProfile*>(pItem); 551 545 552 546 /* Compose temporary context-menu: */ … … 565 559 566 560 /* And show it: */ 567 menu.exec(m_pTreeWidget-> mapToGlobal(position));561 menu.exec(m_pTreeWidget->viewport()->mapToGlobal(position)); 568 562 } 569 563 570 564 void UICloudProfileManagerWidget::sltHandleItemChange(QTreeWidgetItem *pItem) 571 565 { 572 /* C ast pItem to QITreeWidgetItem: */566 /* Check item type: */ 573 567 QITreeWidgetItem *pChangedItem = QITreeWidgetItem::toItem(pItem); 574 AssertMsgReturnVoid(pChangedItem, ("Changed item must not be null!\n")); 568 UIItemCloudProvider *pProviderItem = qobject_cast<UIItemCloudProvider*>(pChangedItem); 569 UIItemCloudProfile *pProfileItem = qobject_cast<UIItemCloudProfile*>(pChangedItem); 575 570 576 571 /* Check whether item is of provider or profile type, then check whether it changed: */ 577 572 bool fChanged = false; 578 UIItemCloudProvider *pProviderItem = qobject_cast<UIItemCloudProvider*>(pChangedItem);579 UIItemCloudProfile *pProfileItem = qobject_cast<UIItemCloudProfile*>(pChangedItem);580 573 if (pProviderItem) 581 574 { … … 797 790 798 791 /* Make sure provider item is properly inserted: */ 799 UIItemCloudProvider *pItem = searchItem(providerData.m_u uid);792 UIItemCloudProvider *pItem = searchItem(providerData.m_uId); 800 793 801 794 /* Iterate through provider's profiles: */ … … 823 816 } 824 817 825 void UICloudProfileManagerWidget::loadCloudProvider(const CCloudProvider &comProvider, UIDataCloudProvider &data) 818 void UICloudProfileManagerWidget::loadCloudProvider(const CCloudProvider &comProvider, 819 UIDataCloudProvider &providerData) 826 820 { 827 821 /* Gather provider settings: */ 828 822 if (comProvider.isOk()) 829 data.m_uuid = comProvider.GetId();823 providerData.m_uId = comProvider.GetId(); 830 824 if (comProvider.isOk()) 831 data.m_strShortName = comProvider.GetShortName();825 providerData.m_strShortName = comProvider.GetShortName(); 832 826 if (comProvider.isOk()) 833 data.m_strName = comProvider.GetName();827 providerData.m_strName = comProvider.GetName(); 834 828 foreach (const QString &strSupportedPropertyName, comProvider.GetSupportedPropertyNames()) 835 data.m_propertyDescriptions[strSupportedPropertyName] = comProvider.GetPropertyDescription(strSupportedPropertyName);829 providerData.m_propertyDescriptions[strSupportedPropertyName] = comProvider.GetPropertyDescription(strSupportedPropertyName); 836 830 837 831 /* Show error message if necessary: */ … … 840 834 } 841 835 842 void UICloudProfileManagerWidget::loadCloudProfile(const CCloudProfile &comProfile, const UIDataCloudProvider &providerData, UIDataCloudProfile &profileData) 836 void UICloudProfileManagerWidget::loadCloudProfile(const CCloudProfile &comProfile, 837 const UIDataCloudProvider &providerData, 838 UIDataCloudProfile &profileData) 843 839 { 844 840 /* Gather provider settings: */ … … 874 870 } 875 871 876 UIItemCloudProvider *UICloudProfileManagerWidget::searchItem(const QUuid &u uid) const877 { 878 /* Iterate d through top-level items: */879 for (int i = 0; i < m_pTreeWidget-> topLevelItemCount(); ++i)880 if (m_pTreeWidget-> topLevelItem(i)->data(0, Data_ProviderID).toUuid() == uuid)881 return static_cast<UIItemCloudProvider*>(m_pTreeWidget->topLevelItem(i));872 UIItemCloudProvider *UICloudProfileManagerWidget::searchItem(const QUuid &uId) const 873 { 874 /* Iterate through tree-widget children: */ 875 for (int i = 0; i < m_pTreeWidget->childCount(); ++i) 876 if (m_pTreeWidget->childItem(i)->data(Column_Name, Data_ProviderID).toUuid() == uId) 877 return qobject_cast<UIItemCloudProvider*>(m_pTreeWidget->childItem(i)); 882 878 /* Null by default: */ 883 879 return 0; 884 880 } 885 881 886 void UICloudProfileManagerWidget::createItemForCloudProvider(const UIDataCloudProvider &data, bool fChooseItem) 882 void UICloudProfileManagerWidget::createItemForCloudProvider(const UIDataCloudProvider &providerData, 883 bool fChooseItem) 887 884 { 888 885 /* Create new provider item: */ … … 891 888 { 892 889 /* Configure item: */ 893 pItem->UIDataCloudProvider::operator=( data);890 pItem->UIDataCloudProvider::operator=(providerData); 894 891 pItem->updateFields(); 895 892 /* Add item to the tree: */ … … 901 898 } 902 899 903 void UICloudProfileManagerWidget::createItemForCloudProfile(QTreeWidgetItem *pParent, const UIDataCloudProfile &data, bool fChooseItem) 900 void UICloudProfileManagerWidget::createItemForCloudProfile(QTreeWidgetItem *pParent, 901 const UIDataCloudProfile &profileData, 902 bool fChooseItem) 904 903 { 905 904 /* Create new profile item: */ … … 908 907 { 909 908 /* Configure item: */ 910 pItem->UIDataCloudProfile::operator=( data);909 pItem->UIDataCloudProfile::operator=(profileData); 911 910 pItem->updateFields(); 912 911 /* Add item to the parent: */ … … 918 917 } 919 918 920 void UICloudProfileManagerWidget::updateItemForCloudProfile(const UIDataCloudProfile & data, bool fChooseItem, UIItemCloudProfile *pItem)919 void UICloudProfileManagerWidget::updateItemForCloudProfile(const UIDataCloudProfile &profileData, bool fChooseItem, UIItemCloudProfile *pItem) 921 920 { 922 921 /* Update passed item: */ … … 924 923 { 925 924 /* Configure item: */ 926 pItem->UIDataCloudProfile::operator=( data);925 pItem->UIDataCloudProfile::operator=(profileData); 927 926 pItem->updateFields(); 928 927 /* And choose it as current if necessary: */ … … 942 941 if ( pChangedItem 943 942 && 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 } 943 result << pChangedItem->data(Column_Name, Data_Definition).toString(); 959 944 960 945 /* Iterate through children recursively: */ -
trunk/src/VBox/Frontends/VirtualBox/src/cloud/profilemanager/UICloudProfileManager.h
r85035 r85387 95 95 /** @name Menu/action stuff. 96 96 * @{ */ 97 /** Handles command to createcloud profile. */97 /** Handles command to add cloud profile. */ 98 98 void sltAddCloudProfile(); 99 99 /** Handles command to import cloud profiles. */ … … 103 103 /** Handles command to make cloud profile details @a fVisible. */ 104 104 void sltToggleCloudProfileDetailsVisibility(bool fVisible); 105 /** Handles command to show cloud profile help. */105 /** Handles command to show cloud profile try page. */ 106 106 void sltShowCloudProfileTryPage(); 107 107 /** Handles command to show cloud profile help. */ … … 117 117 /** Handles tree-widget current item change. */ 118 118 void sltHandleCurrentItemChange(); 119 /** Handles context 119 /** Handles context-menu request for tree-widget @a position. */ 120 120 void sltHandleContextMenuRequest(const QPoint &position); 121 121 /** Handles tree-widget @a pItem change. */ … … 149 149 /** Loads cloud stuff. */ 150 150 void loadCloudStuff(); 151 /** Loads cloud @a comProvider data to passed @a data container. */ 152 void loadCloudProvider(const CCloudProvider &comProvider, UIDataCloudProvider &data); 151 /** Loads cloud @a comProvider data to passed @a providerData container. */ 152 void loadCloudProvider(const CCloudProvider &comProvider, 153 UIDataCloudProvider &providerData); 153 154 /** Loads cloud @a comProfile data to passed @a profileData container, using @a providerData as hint. */ 154 void loadCloudProfile(const CCloudProfile &comProfile, const UIDataCloudProvider &providerData, UIDataCloudProfile &profileData); 155 void loadCloudProfile(const CCloudProfile &comProfile, 156 const UIDataCloudProvider &providerData, 157 UIDataCloudProfile &profileData); 155 158 /** @} */ 156 159 157 160 /** @name Tree-widget stuff. 158 161 * @{ */ 159 /** Seearches a provider item with specified @a uuid. */ 160 UIItemCloudProvider *searchItem(const QUuid &uuid) const; 161 162 /** Creates a new tree-widget item on the basis of passed @a data, @a fChooseItem if requested. */ 163 void createItemForCloudProvider(const UIDataCloudProvider &data, bool fChooseItem); 164 165 /** Creates a new tree-widget item as a child of certain @a pParent, on the basis of passed @a data, @a fChooseItem if requested. */ 166 void createItemForCloudProfile(QTreeWidgetItem *pParent, const UIDataCloudProfile &data, bool fChooseItem); 167 /** Updates the passed tree-widget item on the basis of passed @a data, @a fChooseItem if requested. */ 168 void updateItemForCloudProfile(const UIDataCloudProfile &data, bool fChooseItem, UIItemCloudProfile *pItem); 162 /** Seearches a provider item with specified @a uId. */ 163 UIItemCloudProvider *searchItem(const QUuid &uId) const; 164 165 /** Creates a new tree-widget item 166 * on the basis of passed @a providerData, @a fChooseItem if requested. */ 167 void createItemForCloudProvider(const UIDataCloudProvider &providerData, bool fChooseItem); 168 169 /** Creates a new tree-widget item as a child of certain @a pParent, 170 * on the basis of passed @a profileData, @a fChooseItem if requested. */ 171 void createItemForCloudProfile(QTreeWidgetItem *pParent, const UIDataCloudProfile &profileData, bool fChooseItem); 172 /** Updates the passed tree-widget item on the basis of passed @a profileData, @a fChooseItem if requested. */ 173 void updateItemForCloudProfile(const UIDataCloudProfile &profileData, bool fChooseItem, UIItemCloudProfile *pItem); 169 174 170 175 /* Gathers a list of Cloud Profile Manager restrictions starting from @a pParentItem. */ … … 191 196 * @{ */ 192 197 /** Holds the tree-widget instance. */ 193 QITreeWidget *m_pTreeWidget;198 QITreeWidget *m_pTreeWidget; 194 199 /** Holds the details-widget instance. */ 195 200 UICloudProfileDetailsWidget *m_pDetailsWidget;
Note:
See TracChangeset
for help on using the changeset viewer.