- Timestamp:
- Apr 17, 2019 5:31:19 PM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp
r78166 r78177 53 53 54 54 /* COM includes: */ 55 #include "CBooleanFormValue.h" 56 #include "CChoiceFormValue.h" 55 57 #include "CCloudClient.h" 56 58 #include "CCloudProfile.h" … … 64 66 #include "CSnapshot.h" 65 67 #include "CStorageController.h" 68 #include "CStringFormValue.h" 66 69 #include "CConsole.h" 67 70 #include "CMachine.h" … … 1689 1692 } 1690 1693 1694 void UIMessageCenter::cannotAssignFormValue(const CBooleanFormValue &comValue, QWidget *pParent /* = 0 */) const 1695 { 1696 error(pParent, MessageType_Error, 1697 tr("Failed to assign form value."), 1698 UIErrorString::formatErrorInfo(comValue)); 1699 } 1700 1701 void UIMessageCenter::cannotAssignFormValue(const CStringFormValue &comValue, QWidget *pParent /* = 0 */) const 1702 { 1703 error(pParent, MessageType_Error, 1704 tr("Failed to assign form value."), 1705 UIErrorString::formatErrorInfo(comValue)); 1706 } 1707 1708 void UIMessageCenter::cannotAssignFormValue(const CChoiceFormValue &comValue, QWidget *pParent /* = 0 */) const 1709 { 1710 error(pParent, MessageType_Error, 1711 tr("Failed to assign form value."), 1712 UIErrorString::formatErrorInfo(comValue)); 1713 } 1714 1715 void UIMessageCenter::cannotAssignFormValue(const CProgress &comProgress, QWidget *pParent /* = 0 */) const 1716 { 1717 error(pParent, MessageType_Error, 1718 tr("Failed to assign form value."), 1719 UIErrorString::formatErrorInfo(comProgress)); 1720 } 1721 1691 1722 bool UIMessageCenter::confirmHardDisklessMachine(QWidget *pParent /* = 0*/) const 1692 1723 { -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h
r78166 r78177 376 376 bool confirmCloudProfileRemoval(const QString &strName, QWidget *pParent = 0) const; 377 377 bool confirmCloudProfilesImport(QWidget *pParent = 0) const; 378 void cannotAssignFormValue(const CBooleanFormValue &comValue, QWidget *pParent = 0) const; 379 void cannotAssignFormValue(const CStringFormValue &comValue, QWidget *pParent = 0) const; 380 void cannotAssignFormValue(const CChoiceFormValue &comValue, QWidget *pParent = 0) const; 381 void cannotAssignFormValue(const CProgress &comProgress, QWidget *pParent = 0) const; 378 382 379 383 /* API: Wizards warnings: */ -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIFormEditorWidget.cpp
r78173 r78177 152 152 /** Returns value cast to bool. */ 153 153 bool toBool() const; 154 /** Defines @a fBool value. */ 155 void setBool(bool fBool); 154 156 155 157 /** Returns value cast to string. */ 156 158 QString toString() const; 159 /** Defines @a strString value. */ 160 void setString(const QString &strString); 157 161 158 162 /** Returns value cast to choice. */ 159 163 ChoiceData toChoice() const; 164 /** Defines @a choice value. */ 165 void setChoice(ChoiceData choice); 160 166 161 167 protected: … … 298 304 } 299 305 306 void UIFormEditorRow::setBool(bool fBool) 307 { 308 AssertReturnVoid(valueType() == KFormValueType_Boolean); 309 CBooleanFormValue comValue(m_comValue); 310 CProgress comProgress = comValue.SetSelected(fBool); 311 312 /* Show error message if necessary: */ 313 if (!comValue.isOk()) 314 msgCenter().cannotAssignFormValue(comValue); 315 else 316 { 317 /* Show "Acquire export form" progress: */ 318 msgCenter().showModalProgressDialog(comProgress, UIFormEditorWidget::tr("Assign value..."), 319 ":/progress_reading_appliance_90px.png"); 320 321 /* Show error message if necessary: */ 322 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 323 msgCenter().cannotAssignFormValue(comProgress); 324 else 325 updateValueCells(); 326 } 327 } 328 300 329 QString UIFormEditorRow::toString() const 301 330 { … … 305 334 } 306 335 336 void UIFormEditorRow::setString(const QString &strString) 337 { 338 AssertReturnVoid(valueType() == KFormValueType_String); 339 CStringFormValue comValue(m_comValue); 340 CProgress comProgress = comValue.SetString(strString); 341 342 /* Show error message if necessary: */ 343 if (!comValue.isOk()) 344 msgCenter().cannotAssignFormValue(comValue); 345 else 346 { 347 /* Show "Acquire export form" progress: */ 348 msgCenter().showModalProgressDialog(comProgress, UIFormEditorWidget::tr("Assign value..."), 349 ":/progress_reading_appliance_90px.png"); 350 351 /* Show error message if necessary: */ 352 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 353 msgCenter().cannotAssignFormValue(comProgress); 354 else 355 updateValueCells(); 356 } 357 } 358 307 359 ChoiceData UIFormEditorRow::toChoice() const 308 360 { … … 310 362 CChoiceFormValue comValue(m_comValue); 311 363 return ChoiceData(comValue.GetValues(), comValue.GetSelectedIndex()); 364 } 365 366 void UIFormEditorRow::setChoice(ChoiceData choice) 367 { 368 AssertReturnVoid(valueType() == KFormValueType_Choice); 369 CChoiceFormValue comValue(m_comValue); 370 CProgress comProgress = comValue.SetSelectedIndex(choice.selectedChoice()); 371 372 /* Show error message if necessary: */ 373 if (!comValue.isOk()) 374 msgCenter().cannotAssignFormValue(comValue); 375 else 376 { 377 /* Show "Acquire export form" progress: */ 378 msgCenter().showModalProgressDialog(comProgress, UIFormEditorWidget::tr("Assign value..."), 379 ":/progress_reading_appliance_90px.png"); 380 381 /* Show error message if necessary: */ 382 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 383 msgCenter().cannotAssignFormValue(comProgress); 384 else 385 updateValueCells(); 386 } 312 387 } 313 388 … … 472 547 bool UIFormEditorModel::setData(const QModelIndex &index, const QVariant &value, int iRole /* = Qt::EditRole */) 473 548 { 474 Q_UNUSED(value);475 476 549 /* Check index validness: */ 477 if (!index.isValid() || iRole != Qt::EditRole)550 if (!index.isValid()) 478 551 return false; 479 /* Return wrong value: */ 480 return false; 552 /* Switch for different roles: */ 553 switch (iRole) 554 { 555 /* Checkstate role: */ 556 case Qt::CheckStateRole: 557 { 558 /* Switch for different columns: */ 559 switch (index.column()) 560 { 561 case UIFormEditorDataType_Value: 562 { 563 if (m_dataList[index.row()]->valueType() == KFormValueType_Boolean) 564 { 565 const Qt::CheckState enmCheckState = static_cast<Qt::CheckState>(value.toInt()); 566 m_dataList[index.row()]->setBool(enmCheckState == Qt::Checked); 567 emit dataChanged(index, index); 568 return true; 569 } 570 else 571 return false; 572 } 573 default: 574 return false; 575 } 576 } 577 /* Edit role: */ 578 case Qt::EditRole: 579 { 580 /* Switch for different columns: */ 581 switch (index.column()) 582 { 583 case UIFormEditorDataType_Value: 584 { 585 switch (m_dataList[index.row()]->valueType()) 586 { 587 case KFormValueType_String: 588 m_dataList[index.row()]->setString(value.toString()); 589 emit dataChanged(index, index); 590 return true; 591 case KFormValueType_Choice: 592 m_dataList[index.row()]->setChoice(value.value<ChoiceData>()); 593 emit dataChanged(index, index); 594 return true; 595 default: 596 return false; 597 } 598 } 599 default: 600 return false; 601 } 602 } 603 default: 604 return false; 605 } 481 606 } 482 607
Note:
See TracChangeset
for help on using the changeset viewer.