Changeset 86696 in vbox
- Timestamp:
- Oct 23, 2020 5:31:51 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 141079
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/cloud/profilemanager/UICloudProfileManager.cpp
r86692 r86696 252 252 void UICloudProfileManagerWidget::sltApplyCloudProfileDetailsChanges() 253 253 { 254 /* It can be that th ereis provider item, not profile item currently selected.254 /* It can be that this is provider item, not profile item currently selected. 255 255 * In such case we are not applying parameters, we are creating new one profile. */ 256 256 QITreeWidgetItem *pItem = QITreeWidgetItem::toItem(m_pTreeWidget->currentItem()); … … 261 261 /* Get profile item: */ 262 262 UIItemCloudProfile *pProfileItem = qobject_cast<UIItemCloudProfile*>(pItem); 263 AssertMsgReturnVoid(pProfileItem, ("Current item must not be null!\n")); 264 265 /* Get item data: */ 266 UIDataCloudProfile oldData = *pProfileItem; 267 UIDataCloudProfile newData = m_pDetailsWidget->data(); 268 269 /* Get VirtualBox for further activities: */ 270 const CVirtualBox comVBox = uiCommon().virtualBox(); 271 272 /* Get CloudProviderManager for further activities: */ 273 CCloudProviderManager comCloudProviderManager = comVBox.GetCloudProviderManager(); 274 /* Show error message if necessary: */ 275 if (!comVBox.isOk()) 276 msgCenter().cannotAcquireCloudProviderManager(comVBox, this); 277 else 278 { 279 /* Get provider item: */ 280 UIItemCloudProvider *pProviderItem = qobject_cast<UIItemCloudProvider*>(pProfileItem->parentItem()); 281 /* Acquire provider short name: */ 282 const QString strShortName = pProviderItem->data(Column_Name, Data_ProviderShortName).toString(); 283 284 /* Look for corresponding provider: */ 285 CCloudProvider comCloudProvider = comCloudProviderManager.GetProviderByShortName(strShortName); 286 /* Show error message if necessary: */ 287 if (!comCloudProviderManager.isOk()) 288 msgCenter().cannotAcquireCloudProviderManagerParameter(comCloudProviderManager, this); 289 else 263 AssertPtrReturnVoid(pProfileItem); 264 /* Get provider item: */ 265 UIItemCloudProvider *pProviderItem = qobject_cast<UIItemCloudProvider*>(pProfileItem->parentItem()); 266 AssertPtrReturnVoid(pProviderItem); 267 268 /* Acquire provider short name: */ 269 const QString strShortName = pProviderItem->data(Column_Name, Data_ProviderShortName).toString(); 270 271 /* Look for corresponding provider: */ 272 CCloudProvider comCloudProvider = cloudProviderByShortName(strShortName, this); 273 if (comCloudProvider.isNotNull()) 274 { 275 /* Get old/new data: */ 276 UIDataCloudProfile oldData = *pProfileItem; 277 UIDataCloudProfile newData = m_pDetailsWidget->data(); 278 279 /* Look for corresponding profile: */ 280 CCloudProfile comCloudProfile = cloudProfileByName(strShortName, oldData.m_strName, this); 281 if (comCloudProfile.isNotNull()) 290 282 { 291 /* Look for corresponding profile: */ 292 CCloudProfile comCloudProfile = comCloudProvider.GetProfileByName(oldData.m_strName); 283 /* Set profile name, if necessary: */ 284 if (newData.m_strName != oldData.m_strName) 285 comCloudProfile.SetName(newData.m_strName); 293 286 /* Show error message if necessary: */ 294 if (!comCloudPro vider.isOk())295 msgCenter().cannot FindCloudProfile(comCloudProvider, oldData.m_strName, this);287 if (!comCloudProfile.isOk()) 288 msgCenter().cannotAssignCloudProfileParameter(comCloudProfile, this); 296 289 else 297 290 { 298 /* Set profile name, if necessary: */ 299 if (newData.m_strName != oldData.m_strName) 300 comCloudProfile.SetName(newData.m_strName); 301 /* Show error message if necessary: */ 302 if (!comCloudProfile.isOk()) 303 msgCenter().cannotAssignCloudProfileParameter(comCloudProfile, this); 304 else 291 /* Iterate through old/new data: */ 292 foreach (const QString &strKey, oldData.m_data.keys()) 305 293 { 306 /* Iterate through old/new data: */ 307 foreach (const QString &strKey, oldData.m_data.keys()) 294 /* Get values: */ 295 const QString strOldValue = oldData.m_data.value(strKey).first; 296 const QString strNewValue = newData.m_data.value(strKey).first; 297 if (strNewValue != strOldValue) 308 298 { 309 /* Get values: */310 co nst QString strOldValue = oldData.m_data.value(strKey).first;311 const QString strNewValue = newData.m_data.value(strKey).first;312 if ( strNewValue != strOldValue)299 /* Apply property: */ 300 comCloudProfile.SetProperty(strKey, strNewValue); 301 /* Show error message if necessary: */ 302 if (!comCloudProfile.isOk()) 313 303 { 314 /* Apply property: */ 315 comCloudProfile.SetProperty(strKey, strNewValue); 316 /* Show error message if necessary: */ 317 if (!comCloudProfile.isOk()) 318 { 319 msgCenter().cannotAssignCloudProfileParameter(comCloudProfile, this); 320 break; 321 } 304 msgCenter().cannotAssignCloudProfileParameter(comCloudProfile, this); 305 break; 322 306 } 323 307 } 324 308 } 325 326 /* If profile is Ok finally: */ 327 if (comCloudProfile.isOk())328 {329 /* Save profile changes: */330 comCloudProvider.SaveProfiles();331 /* Show error message if necessary: */332 if (!comCloudProvider.isOk())333 msgCenter().cannotSaveCloudProfiles(comCloudProvider, this);334 }309 } 310 311 /* If profile is Ok finally: */ 312 if (comCloudProfile.isOk()) 313 { 314 /* Save profile changes: */ 315 comCloudProvider.SaveProfiles(); 316 /* Show error message if necessary: */ 317 if (!comCloudProvider.isOk()) 318 msgCenter().cannotSaveCloudProfiles(comCloudProvider, this); 335 319 } 336 320 } … … 343 327 QITreeWidgetItem *pItem = QITreeWidgetItem::toItem(m_pTreeWidget->currentItem()); 344 328 UIItemCloudProvider *pProviderItem = qobject_cast<UIItemCloudProvider*>(pItem); 345 Assert MsgReturnVoid(pProviderItem, ("Current item must not be null!\n"));329 AssertPtrReturnVoid(pProviderItem); 346 330 347 331 /* Acquire profile name if not proposed by details widget: */ … … 366 350 } 367 351 368 /* Get VirtualBox for further activities: */ 369 const CVirtualBox comVBox = uiCommon().virtualBox(); 370 371 /* Get CloudProviderManager for further activities: */ 372 CCloudProviderManager comCloudProviderManager = comVBox.GetCloudProviderManager(); 373 /* Show error message if necessary: */ 374 if (!comVBox.isOk()) 375 msgCenter().cannotAcquireCloudProviderManager(comVBox, this); 376 else 377 { 378 /* Acquire provider short name: */ 379 const QString strShortName = pProviderItem->data(Column_Name, Data_ProviderShortName).toString(); 380 381 /* Look for corresponding provider: */ 382 CCloudProvider comCloudProvider = comCloudProviderManager.GetProviderByShortName(strShortName); 352 /* Acquire provider short name: */ 353 const QString strShortName = pProviderItem->data(Column_Name, Data_ProviderShortName).toString(); 354 355 /* Look for corresponding provider: */ 356 CCloudProvider comCloudProvider = cloudProviderByShortName(strShortName, this); 357 if (comCloudProvider.isNotNull()) 358 { 359 /* Create new profile: */ 360 const QVector<QString> keys = pProviderItem->m_propertyDescriptions.keys().toVector(); 361 const QVector<QString> values(keys.size()); 362 comCloudProvider.CreateProfile(strProfileName, keys, values); 383 363 /* Show error message if necessary: */ 384 if (!comCloudProvider Manager.isOk())385 msgCenter().cannot AcquireCloudProviderManagerParameter(comCloudProviderManager, this);364 if (!comCloudProvider.isOk()) 365 msgCenter().cannotCreateCloudProfile(comCloudProvider, this); 386 366 else 387 367 { 388 /* Create new profile: */ 389 const QVector<QString> keys = pProviderItem->m_propertyDescriptions.keys().toVector(); 390 const QVector<QString> values(keys.size()); 391 comCloudProvider.CreateProfile(strProfileName, keys, values); 368 /* Save profile changes: */ 369 comCloudProvider.SaveProfiles(); 392 370 /* Show error message if necessary: */ 393 371 if (!comCloudProvider.isOk()) 394 msgCenter().cannotCreateCloudProfile(comCloudProvider, this); 395 else 396 { 397 /* Save profile changes: */ 398 comCloudProvider.SaveProfiles(); 399 /* Show error message if necessary: */ 400 if (!comCloudProvider.isOk()) 401 msgCenter().cannotSaveCloudProfiles(comCloudProvider, this); 402 } 372 msgCenter().cannotSaveCloudProfiles(comCloudProvider, this); 403 373 } 404 374 } … … 410 380 QITreeWidgetItem *pItem = QITreeWidgetItem::toItem(m_pTreeWidget->currentItem()); 411 381 UIItemCloudProvider *pProviderItem = qobject_cast<UIItemCloudProvider*>(pItem); 412 Assert MsgReturnVoid(pProviderItem, ("Current item must not be null!\n"));382 AssertPtrReturnVoid(pProviderItem); 413 383 414 384 /* If there are profiles exist => confirm cloud profile import. */ … … 417 387 return; 418 388 419 /* Get VirtualBox for further activities: */ 420 const CVirtualBox comVBox = uiCommon().virtualBox(); 421 422 /* Get CloudProviderManager for further activities: */ 423 CCloudProviderManager comCloudProviderManager = comVBox.GetCloudProviderManager(); 424 /* Show error message if necessary: */ 425 if (!comVBox.isOk()) 426 msgCenter().cannotAcquireCloudProviderManager(comVBox, this); 427 else 428 { 429 /* Acquire provider short name: */ 430 const QString strShortName = pProviderItem->data(Column_Name, Data_ProviderShortName).toString(); 431 432 /* Look for corresponding provider: */ 433 CCloudProvider comCloudProvider = comCloudProviderManager.GetProviderByShortName(strShortName); 389 /* Acquire provider short name: */ 390 const QString strShortName = pProviderItem->data(Column_Name, Data_ProviderShortName).toString(); 391 392 /* Look for corresponding provider: */ 393 CCloudProvider comCloudProvider = cloudProviderByShortName(strShortName, this); 394 if (comCloudProvider.isNotNull()) 395 { 396 /* Import profiles: */ 397 comCloudProvider.ImportProfiles(); 434 398 /* Show error message if necessary: */ 435 if (!comCloudProviderManager.isOk()) 436 msgCenter().cannotAcquireCloudProviderManagerParameter(comCloudProviderManager, this); 437 else 438 { 439 /* Import profiles: */ 440 comCloudProvider.ImportProfiles(); 441 442 /* Show error message if necessary: */ 443 if (!comCloudProvider.isOk()) 444 msgCenter().cannotImportCloudProfiles(comCloudProvider, this); 445 } 399 if (!comCloudProvider.isOk()) 400 msgCenter().cannotImportCloudProfiles(comCloudProvider, this); 446 401 } 447 402 } … … 452 407 QITreeWidgetItem *pItem = QITreeWidgetItem::toItem(m_pTreeWidget->currentItem()); 453 408 UIItemCloudProfile *pProfileItem = qobject_cast<UIItemCloudProfile*>(pItem); 454 AssertMsgReturnVoid(pProfileItem, ("Current item must not be null!\n")); 455 456 /* Get profile name: */ 457 const QString strProfileName(pProfileItem->name()); 409 AssertPtrReturnVoid(pProfileItem); 410 /* Get provider item: */ 411 UIItemCloudProvider *pProviderItem = qobject_cast<UIItemCloudProvider*>(pProfileItem->parentItem()); 412 AssertPtrReturnVoid(pProviderItem); 413 414 /* Acquire profile name: */ 415 const QString strProfileName = pProfileItem->name(); 458 416 459 417 /* Confirm cloud profile removal: */ … … 461 419 return; 462 420 463 /* Get VirtualBox for further activities: */ 464 const CVirtualBox comVBox = uiCommon().virtualBox(); 465 466 /* Get CloudProviderManager for further activities: */ 467 CCloudProviderManager comCloudProviderManager = comVBox.GetCloudProviderManager(); 468 /* Show error message if necessary: */ 469 if (!comVBox.isOk()) 470 msgCenter().cannotAcquireCloudProviderManager(comVBox, this); 471 else 472 { 473 /* Get provider item: */ 474 UIItemCloudProvider *pProviderItem = qobject_cast<UIItemCloudProvider*>(pProfileItem->parentItem()); 475 /* Acquire provider short name: */ 476 const QString strShortName = pProviderItem->data(Column_Name, Data_ProviderShortName).toString(); 477 478 /* Look for corresponding provider: */ 479 CCloudProvider comCloudProvider = comCloudProviderManager.GetProviderByShortName(strShortName); 480 /* Show error message if necessary: */ 481 if (!comCloudProviderManager.isOk()) 482 msgCenter().cannotAcquireCloudProviderManagerParameter(comCloudProviderManager, this); 483 else 421 /* Acquire provider short name: */ 422 const QString strShortName = pProviderItem->data(Column_Name, Data_ProviderShortName).toString(); 423 424 /* Look for corresponding provider: */ 425 CCloudProvider comCloudProvider = cloudProviderByShortName(strShortName, this); 426 if (comCloudProvider.isNotNull()) 427 { 428 /* Look for corresponding profile: */ 429 CCloudProfile comCloudProfile = cloudProfileByName(strShortName, strProfileName, this); 430 if (comCloudProfile.isNotNull()) 484 431 { 485 /* Look for correspondingprofile: */486 CCloudProfile comCloudProfile = comCloudProvider.GetProfileByName(strProfileName);432 /* Remove current profile: */ 433 comCloudProfile.Remove(); 487 434 /* Show error message if necessary: */ 488 if (!comCloudPro vider.isOk())489 msgCenter().cannot FindCloudProfile(comCloudProvider, strProfileName, this);435 if (!comCloudProfile.isOk()) 436 msgCenter().cannotRemoveCloudProfile(comCloudProfile, this); 490 437 else 491 438 { 492 /* Remove current profile: */493 comCloudProfile.Remove();494 /* Show error message if necessary: */495 if (!comCloudProfile.isOk())496 msgCenter().cannotRemoveCloudProfile(comCloudProfile, this);497 498 439 /* Save profile changes: */ 499 440 comCloudProvider.SaveProfiles(); … … 855 796 /* Gather provider settings: */ 856 797 if (comProvider.isOk()) 857 providerData.m_uId = comProvider.GetId();798 cloudProviderId(comProvider, providerData.m_uId, this); 858 799 if (comProvider.isOk()) 859 providerData.m_strShortName = comProvider.GetShortName();800 cloudProviderShortName(comProvider, providerData.m_strShortName); 860 801 if (comProvider.isOk()) 861 providerData.m_strName = comProvider.GetName(); 862 const QString strProviderPath = UIItemCloudProvider::definition(providerData.m_strShortName); 863 providerData.m_fRestricted = restrictions.contains(strProviderPath); 802 cloudProviderName(comProvider, providerData.m_strName); 803 providerData.m_fRestricted = restrictions.contains(UIItemCloudProvider::definition(providerData.m_strShortName)); 864 804 foreach (const QString &strSupportedPropertyName, comProvider.GetSupportedPropertyNames()) 865 805 providerData.m_propertyDescriptions[strSupportedPropertyName] = comProvider.GetPropertyDescription(strSupportedPropertyName); 866 867 /* Show error message if necessary: */868 if (!comProvider.isOk())869 msgCenter().cannotAcquireCloudProviderParameter(comProvider, this);870 806 } 871 807 … … 880 816 /* Gather profile settings: */ 881 817 if (comProfile.isOk()) 882 profileData.m_strName = comProfile.GetName(); 883 const QString strProfilePath = UIItemCloudProfile::definition(providerData.m_strShortName, profileData.m_strName); 884 profileData.m_fRestricted = restrictions.contains(strProfilePath); 885 818 cloudProfileName(comProfile, profileData.m_strName); 819 profileData.m_fRestricted = restrictions.contains(UIItemCloudProfile::definition(providerData.m_strShortName, profileData.m_strName)); 886 820 if (comProfile.isOk()) 887 821 { 888 /* Acquire properties: */889 822 QVector<QString> keys; 890 823 QVector<QString> values; 891 QVector<QString> descriptions; 892 values = comProfile.GetProperties(QString(), keys); 893 894 /* Sync sizes: */ 895 values.resize(keys.size()); 896 descriptions.resize(keys.size()); 897 898 if (comProfile.isOk()) 899 { 900 /* Enumerate all the keys: */ 824 if (cloudProfileProperties(comProfile, keys, values)) 901 825 for (int i = 0; i < keys.size(); ++i) 902 826 profileData.m_data[keys.at(i)] = qMakePair(values.at(i), providerData.m_propertyDescriptions.value(keys.at(i))); 903 } 904 } 905 906 /* Show error message if necessary: */ 907 if (!comProfile.isOk()) 908 msgCenter().cannotAcquireCloudProfileParameter(comProfile, this); 827 } 909 828 } 910 829
Note:
See TracChangeset
for help on using the changeset viewer.