diff options
author | vboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f> | 2021-09-22 19:45:29 +0000 |
---|---|---|
committer | vboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f> | 2021-09-22 19:45:29 +0000 |
commit | 28ab1539266280884b079c8b8959be6358ad986f (patch) | |
tree | f819aa0e8c1f73181eb454e7fe6f4ee294e320fb | |
parent | c1a99e70600b51808527725f90e231d885bf6803 (diff) | |
download | VirtualBox-svn-28ab1539266280884b079c8b8959be6358ad986f.tar.gz |
FE/Qt: bugref:9996: A bit of refactoring for Add/New Cloud VM wizards; Parse full group name beforehand, it can be required for short wizard form.
git-svn-id: https://www.virtualbox.org/svn/vbox/trunk@91335 cfe28804-0f27-0410-a406-dd0f0b0b656f
10 files changed, 56 insertions, 58 deletions
diff --git a/src/VBox/Frontends/VirtualBox/src/wizards/addcloudvm/UIWizardAddCloudVM.cpp b/src/VBox/Frontends/VirtualBox/src/wizards/addcloudvm/UIWizardAddCloudVM.cpp index cfe53c82267..259f57da9b7 100644 --- a/src/VBox/Frontends/VirtualBox/src/wizards/addcloudvm/UIWizardAddCloudVM.cpp +++ b/src/VBox/Frontends/VirtualBox/src/wizards/addcloudvm/UIWizardAddCloudVM.cpp @@ -31,7 +31,6 @@ UIWizardAddCloudVM::UIWizardAddCloudVM(QWidget *pParent, const QString &strFullGroupName /* = QString() */) : UINativeWizard(pParent, WizardType_AddCloudVM, WizardMode_Auto) - , m_strFullGroupName(strFullGroupName) { #ifndef VBOX_WS_MAC /* Assign watermark: */ @@ -40,6 +39,15 @@ UIWizardAddCloudVM::UIWizardAddCloudVM(QWidget *pParent, /* Assign background image: */ setPixmapName(":/wizard_new_cloud_vm_bg.png"); #endif + + /* Parse passed full group name: */ + const QString strProviderShortName = strFullGroupName.section('/', 1, 1); + const QString strProfileName = strFullGroupName.section('/', 2, 2); + if (!strProviderShortName.isEmpty() && !strProfileName.isEmpty()) + { + m_strProviderShortName = strProviderShortName; + m_strProfileName = strProfileName; + } } bool UIWizardAddCloudVM::addCloudVMs() diff --git a/src/VBox/Frontends/VirtualBox/src/wizards/addcloudvm/UIWizardAddCloudVM.h b/src/VBox/Frontends/VirtualBox/src/wizards/addcloudvm/UIWizardAddCloudVM.h index d31c407271e..0d412715e20 100644 --- a/src/VBox/Frontends/VirtualBox/src/wizards/addcloudvm/UIWizardAddCloudVM.h +++ b/src/VBox/Frontends/VirtualBox/src/wizards/addcloudvm/UIWizardAddCloudVM.h @@ -39,9 +39,6 @@ public: * @param strFullGroupName Brings full group name (/provider/profile) to add VM to. */ UIWizardAddCloudVM(QWidget *pParent, const QString &strFullGroupName = QString()); - /** Returns full group name. */ - QString fullGroupName() const { return m_strFullGroupName; } - /** Defines @a strProviderShortName. */ void setProviderShortName(const QString &strProviderShortName) { m_strProviderShortName = strProviderShortName; } /** Returns provider short name. */ @@ -75,8 +72,6 @@ protected: private: - /** Holds the full group name (/provider/profile) to add VM to. */ - QString m_strFullGroupName; /** Holds the short provider name. */ QString m_strProviderShortName; /** Holds the profile name. */ diff --git a/src/VBox/Frontends/VirtualBox/src/wizards/addcloudvm/UIWizardAddCloudVMPageExpert.cpp b/src/VBox/Frontends/VirtualBox/src/wizards/addcloudvm/UIWizardAddCloudVMPageExpert.cpp index f6bcc9a4b87..eae5679e147 100644 --- a/src/VBox/Frontends/VirtualBox/src/wizards/addcloudvm/UIWizardAddCloudVMPageExpert.cpp +++ b/src/VBox/Frontends/VirtualBox/src/wizards/addcloudvm/UIWizardAddCloudVMPageExpert.cpp @@ -268,8 +268,7 @@ void UIWizardAddCloudVMPageExpert::updateProvider() { updateComboToolTip(m_pProviderComboBox); setProviderShortName(m_pProviderComboBox->currentData(ProviderData_ShortName).toString()); - CCloudProvider comCloudProvider = cloudProviderByShortName(providerShortName(), wizard()); - populateProfiles(m_pProfileComboBox, comCloudProvider); + populateProfiles(m_pProfileComboBox, providerShortName(), profileName()); updateProfile(); } diff --git a/src/VBox/Frontends/VirtualBox/src/wizards/addcloudvm/UIWizardAddCloudVMPageSource.cpp b/src/VBox/Frontends/VirtualBox/src/wizards/addcloudvm/UIWizardAddCloudVMPageSource.cpp index 41411102c7b..e684a08ea32 100644 --- a/src/VBox/Frontends/VirtualBox/src/wizards/addcloudvm/UIWizardAddCloudVMPageSource.cpp +++ b/src/VBox/Frontends/VirtualBox/src/wizards/addcloudvm/UIWizardAddCloudVMPageSource.cpp @@ -103,14 +103,18 @@ void UIWizardAddCloudVMPage1::populateProviders(QIComboBox *pCombo) pCombo->blockSignals(false); } -void UIWizardAddCloudVMPage1::populateProfiles(QIComboBox *pCombo, const CCloudProvider &comProvider) +void UIWizardAddCloudVMPage1::populateProfiles(QIComboBox *pCombo, + const QString &strProviderShortName, + const QString &strProfileName) { /* Sanity check: */ AssertPtrReturnVoid(pCombo); - AssertReturnVoid(comProvider.isNotNull()); /* We need top-level parent as well: */ QWidget *pParent = pCombo->window(); AssertPtrReturnVoid(pParent); + /* Acquire provider: */ + CCloudProvider comProvider = cloudProviderByShortName(strProviderShortName, pParent); + AssertReturnVoid(comProvider.isNotNull()); /* Block signals while updating: */ pCombo->blockSignals(true); @@ -119,16 +123,8 @@ void UIWizardAddCloudVMPage1::populateProfiles(QIComboBox *pCombo, const CCloudP QString strOldData; if (pCombo->currentIndex() != -1) strOldData = pCombo->itemData(pCombo->currentIndex(), ProfileData_Name).toString(); - else - { - /* Try to fetch "old" profile name from wizard full group name: */ - UIWizardAddCloudVM *pWizard = qobject_cast<UIWizardAddCloudVM*>(pParent); - AssertPtrReturnVoid(pWizard); - const QString strFullGroupName = pWizard->fullGroupName(); - const QString strProfileName = strFullGroupName.section('/', 2, 2); - if (!strProfileName.isEmpty()) - strOldData = strProfileName; - } + else if (!strProfileName.isEmpty()) + strOldData = strProfileName; /* Clear combo initially: */ pCombo->clear(); @@ -139,14 +135,14 @@ void UIWizardAddCloudVMPage1::populateProfiles(QIComboBox *pCombo, const CCloudP /* Skip if we have nothing to populate (wtf happened?): */ if (comProfile.isNull()) continue; - /* Acquire profile name: */ - QString strProfileName; - if (!cloudProfileName(comProfile, strProfileName, pParent)) + /* Acquire current profile name: */ + QString strCurrentProfileName; + if (!cloudProfileName(comProfile, strCurrentProfileName, pParent)) continue; /* Compose item, fill the data: */ - pCombo->addItem(strProfileName); - pCombo->setItemData(pCombo->count() - 1, strProfileName, ProfileData_Name); + pCombo->addItem(strCurrentProfileName); + pCombo->setItemData(pCombo->count() - 1, strCurrentProfileName, ProfileData_Name); } /* Set previous/default item if possible: */ @@ -524,8 +520,7 @@ void UIWizardAddCloudVMPageSource::updateProvider() { updateComboToolTip(m_pProviderComboBox); setProviderShortName(m_pProviderComboBox->currentData(ProviderData_ShortName).toString()); - CCloudProvider comCloudProvider = cloudProviderByShortName(providerShortName(), wizard()); - populateProfiles(m_pProfileComboBox, comCloudProvider); + populateProfiles(m_pProfileComboBox, providerShortName(), profileName()); updateProfile(); } diff --git a/src/VBox/Frontends/VirtualBox/src/wizards/addcloudvm/UIWizardAddCloudVMPageSource.h b/src/VBox/Frontends/VirtualBox/src/wizards/addcloudvm/UIWizardAddCloudVMPageSource.h index 1eea9c93ef9..5ebc464ff80 100644 --- a/src/VBox/Frontends/VirtualBox/src/wizards/addcloudvm/UIWizardAddCloudVMPageSource.h +++ b/src/VBox/Frontends/VirtualBox/src/wizards/addcloudvm/UIWizardAddCloudVMPageSource.h @@ -54,8 +54,10 @@ namespace UIWizardAddCloudVMPage1 { /** Populates @a pCombo with known providers. */ void populateProviders(QIComboBox *pCombo); - /** Populates @a pCombo with known profiles of @a comProvider specified. */ - void populateProfiles(QIComboBox *pCombo, const CCloudProvider &comProvider); + /** Populates @a pCombo with known profiles. + * @param strProviderShortName Brings the short name of provider profiles related to. + * @param strProfileName Brings the name of profile to be chosen by default. */ + void populateProfiles(QIComboBox *pCombo, const QString &strProviderShortName, const QString &strProfileName); /** Populates @a pList with profile instances available in @a comClient. */ void populateProfileInstances(QListWidget *pList, const CCloudClient &comClient); diff --git a/src/VBox/Frontends/VirtualBox/src/wizards/newcloudvm/UIWizardNewCloudVM.cpp b/src/VBox/Frontends/VirtualBox/src/wizards/newcloudvm/UIWizardNewCloudVM.cpp index d69a58cdffa..0650d42b9e3 100644 --- a/src/VBox/Frontends/VirtualBox/src/wizards/newcloudvm/UIWizardNewCloudVM.cpp +++ b/src/VBox/Frontends/VirtualBox/src/wizards/newcloudvm/UIWizardNewCloudVM.cpp @@ -39,7 +39,6 @@ UIWizardNewCloudVM::UIWizardNewCloudVM(QWidget *pParent, const CVirtualSystemDescription &comVSD /* = CVirtualSystemDescription() */, WizardMode enmMode /* = WizardMode_Auto */) : UINativeWizard(pParent, WizardType_NewCloudVM, enmMode) - , m_strFullGroupName(strFullGroupName) , m_comClient(comClient) , m_comVSD(comVSD) , m_fFullWizard(m_comClient.isNull() || m_comVSD.isNull()) @@ -52,6 +51,15 @@ UIWizardNewCloudVM::UIWizardNewCloudVM(QWidget *pParent, /* Assign background image: */ setPixmapName(":/wizard_new_cloud_vm_bg.png"); #endif + + /* Parse passed full group name: */ + const QString strProviderShortName = strFullGroupName.section('/', 1, 1); + const QString strProfileName = strFullGroupName.section('/', 2, 2); + if (!strProviderShortName.isEmpty() && !strProfileName.isEmpty()) + { + m_strProviderShortName = strProviderShortName; + m_strProfileName = strProfileName; + } } bool UIWizardNewCloudVM::createVSDForm() diff --git a/src/VBox/Frontends/VirtualBox/src/wizards/newcloudvm/UIWizardNewCloudVM.h b/src/VBox/Frontends/VirtualBox/src/wizards/newcloudvm/UIWizardNewCloudVM.h index de0d92836dc..c2d43210f15 100644 --- a/src/VBox/Frontends/VirtualBox/src/wizards/newcloudvm/UIWizardNewCloudVM.h +++ b/src/VBox/Frontends/VirtualBox/src/wizards/newcloudvm/UIWizardNewCloudVM.h @@ -50,9 +50,6 @@ public: /** Sets whether the final step is @a fPrevented. */ void setFinalStepPrevented(bool fPrevented) { m_fFinalStepPrevented = fPrevented; } - /** Returns full group name. */ - QString fullGroupName() const { return m_strFullGroupName; } - /** Defines @a strProviderShortName. */ void setProviderShortName(const QString &strProviderShortName) { m_strProviderShortName = strProviderShortName; } /** Returns provider short name. */ @@ -103,8 +100,6 @@ private slots: private: - /** Holds the full group name (/provider/profile) to add VM to. */ - QString m_strFullGroupName; /** Holds the short provider name. */ QString m_strProviderShortName; /** Holds the profile name. */ diff --git a/src/VBox/Frontends/VirtualBox/src/wizards/newcloudvm/UIWizardNewCloudVMPageExpert.cpp b/src/VBox/Frontends/VirtualBox/src/wizards/newcloudvm/UIWizardNewCloudVMPageExpert.cpp index 436c88700d4..d7e336d2723 100644 --- a/src/VBox/Frontends/VirtualBox/src/wizards/newcloudvm/UIWizardNewCloudVMPageExpert.cpp +++ b/src/VBox/Frontends/VirtualBox/src/wizards/newcloudvm/UIWizardNewCloudVMPageExpert.cpp @@ -409,8 +409,7 @@ void UIWizardNewCloudVMPageExpert::updateProvider() { updateComboToolTip(m_pProviderComboBox); setProviderShortName(m_pProviderComboBox->currentData(ProviderData_ShortName).toString()); - CCloudProvider comCloudProvider = cloudProviderByShortName(providerShortName(), wizard()); - populateProfiles(m_pProfileComboBox, comCloudProvider); + populateProfiles(m_pProfileComboBox, providerShortName(), profileName()); updateProfile(); } diff --git a/src/VBox/Frontends/VirtualBox/src/wizards/newcloudvm/UIWizardNewCloudVMPageSource.cpp b/src/VBox/Frontends/VirtualBox/src/wizards/newcloudvm/UIWizardNewCloudVMPageSource.cpp index 9cd907cc141..e7d51447444 100644 --- a/src/VBox/Frontends/VirtualBox/src/wizards/newcloudvm/UIWizardNewCloudVMPageSource.cpp +++ b/src/VBox/Frontends/VirtualBox/src/wizards/newcloudvm/UIWizardNewCloudVMPageSource.cpp @@ -106,14 +106,18 @@ void UIWizardNewCloudVMPage1::populateProviders(QIComboBox *pCombo) pCombo->blockSignals(false); } -void UIWizardNewCloudVMPage1::populateProfiles(QIComboBox *pCombo, const CCloudProvider &comProvider) +void UIWizardNewCloudVMPage1::populateProfiles(QIComboBox *pCombo, + const QString &strProviderShortName, + const QString &strProfileName) { /* Sanity check: */ AssertPtrReturnVoid(pCombo); - AssertReturnVoid(comProvider.isNotNull()); /* We need top-level parent as well: */ QWidget *pParent = pCombo->window(); AssertPtrReturnVoid(pParent); + /* Acquire provider: */ + CCloudProvider comProvider = cloudProviderByShortName(strProviderShortName, pParent); + AssertReturnVoid(comProvider.isNotNull()); /* Block signals while updating: */ pCombo->blockSignals(true); @@ -122,16 +126,8 @@ void UIWizardNewCloudVMPage1::populateProfiles(QIComboBox *pCombo, const CCloudP QString strOldData; if (pCombo->currentIndex() != -1) strOldData = pCombo->itemData(pCombo->currentIndex(), ProfileData_Name).toString(); - else - { - /* Try to fetch "old" profile name from wizard full group name: */ - UIWizardNewCloudVM *pWizard = qobject_cast<UIWizardNewCloudVM*>(pParent); - AssertPtrReturnVoid(pWizard); - const QString strFullGroupName = pWizard->fullGroupName(); - const QString strProfileName = strFullGroupName.section('/', 2, 2); - if (!strProfileName.isEmpty()) - strOldData = strProfileName; - } + else if (!strProfileName.isEmpty()) + strOldData = strProfileName; /* Clear combo initially: */ pCombo->clear(); @@ -142,14 +138,14 @@ void UIWizardNewCloudVMPage1::populateProfiles(QIComboBox *pCombo, const CCloudP /* Skip if we have nothing to populate (wtf happened?): */ if (comProfile.isNull()) continue; - /* Acquire profile name: */ - QString strProfileName; - if (!cloudProfileName(comProfile, strProfileName, pParent)) + /* Acquire current profile name: */ + QString strCurrentProfileName; + if (!cloudProfileName(comProfile, strCurrentProfileName, pParent)) continue; /* Compose item, fill the data: */ - pCombo->addItem(strProfileName); - pCombo->setItemData(pCombo->count() - 1, strProfileName, ProfileData_Name); + pCombo->addItem(strCurrentProfileName); + pCombo->setItemData(pCombo->count() - 1, strCurrentProfileName, ProfileData_Name); } /* Set previous/default item if possible: */ @@ -604,8 +600,7 @@ void UIWizardNewCloudVMPageSource::updateProvider() { updateComboToolTip(m_pProviderComboBox); setProviderShortName(m_pProviderComboBox->currentData(ProviderData_ShortName).toString()); - CCloudProvider comCloudProvider = cloudProviderByShortName(providerShortName(), wizard()); - populateProfiles(m_pProfileComboBox, comCloudProvider); + populateProfiles(m_pProfileComboBox, providerShortName(), profileName()); updateProfile(); } diff --git a/src/VBox/Frontends/VirtualBox/src/wizards/newcloudvm/UIWizardNewCloudVMPageSource.h b/src/VBox/Frontends/VirtualBox/src/wizards/newcloudvm/UIWizardNewCloudVMPageSource.h index 4d64b270cee..e4a50d20383 100644 --- a/src/VBox/Frontends/VirtualBox/src/wizards/newcloudvm/UIWizardNewCloudVMPageSource.h +++ b/src/VBox/Frontends/VirtualBox/src/wizards/newcloudvm/UIWizardNewCloudVMPageSource.h @@ -58,8 +58,10 @@ namespace UIWizardNewCloudVMPage1 { /** Populates @a pCombo with known providers. */ void populateProviders(QIComboBox *pCombo); - /** Populates @a pCombo with known profiles of @a comProvider specified. */ - void populateProfiles(QIComboBox *pCombo, const CCloudProvider &comProvider); + /** Populates @a pCombo with known profiles. + * @param strProviderShortName Brings the short name of provider profiles related to. + * @param strProfileName Brings the name of profile to be chosen by default. */ + void populateProfiles(QIComboBox *pCombo, const QString &strProviderShortName, const QString &strProfileName); /** Populates @a pList with source images from tab of @a pTabBar available in @a comClient. */ void populateSourceImages(QListWidget *pList, QTabBar *pTabBar, const CCloudClient &comClient); /** Populates @a comVSD with form property suitable for tab of @a pTabBar with @a strImageId value. */ |