- Timestamp:
- Apr 22, 2019 3:03:45 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIFormEditorWidget.cpp
r78249 r78250 57 57 /** Constructs null choice data. */ 58 58 ChoiceData() {} 59 /** Constructs choice data on the basis of passed @a choices and @a iSelectedChoice. */60 ChoiceData(const QVector<QString> & choices, int iSelectedChoice)61 : m_ choices(choices), m_iSelectedChoice(iSelectedChoice) {}59 /** Constructs choice data on the basis of passed @a values and @a iSelectedIndex. */ 60 ChoiceData(const QVector<QString> &values, int iSelectedIndex) 61 : m_values(values), m_iSelectedIndex(iSelectedIndex) {} 62 62 /** Constructs choice data on the basis of another @a choice data. */ 63 63 ChoiceData(const ChoiceData &choice) 64 : m_choices(choice.choices()), m_iSelectedChoice(choice.selectedChoice()) {} 65 66 /** Returns choice list. */ 67 QVector<QString> choices() const { return m_choices; } 68 /** Returns current selected choice. */ 69 int selectedChoice() const { return m_iSelectedChoice; } 64 : m_values(choice.values()), m_iSelectedIndex(choice.selectedIndex()) {} 65 66 /** Assigns values of @a other choice to this one. */ 67 ChoiceData &operator=(const ChoiceData &other) 68 { 69 m_values = other.values(); 70 m_iSelectedIndex = other.selectedIndex(); 71 return *this; 72 } 73 74 /** Returns values vector. */ 75 QVector<QString> values() const { return m_values; } 76 /** Returns selected index. */ 77 int selectedIndex() const { return m_iSelectedIndex; } 78 /** Returns selected value. */ 79 QString selectedValue() const 80 { 81 return m_iSelectedIndex >= 0 && m_iSelectedIndex < m_values.size() 82 ? m_values.at(m_iSelectedIndex) : QString(); 83 } 70 84 71 85 private: 72 86 73 /** Holds choice list. */74 QVector<QString> m_ choices;75 /** Holds current selected choice. */76 int m_iSelected Choice;87 /** Holds values vector. */ 88 QVector<QString> m_values; 89 /** Holds selected index. */ 90 int m_iSelectedIndex; 77 91 }; 78 92 Q_DECLARE_METATYPE(ChoiceData); … … 96 110 void setChoice(const ChoiceData &choice) 97 111 { 98 addItems(choice. choices().toList());99 setCurrentIndex(choice.selected Choice());112 addItems(choice.values().toList()); 113 setCurrentIndex(choice.selectedIndex()); 100 114 } 101 115 … … 415 429 { 416 430 /* Do nothing for empty choices: */ 417 if (choice.selected Choice() == -1)431 if (choice.selectedIndex() == -1) 418 432 return; 419 433 420 434 AssertReturnVoid(valueType() == KFormValueType_Choice); 421 435 CChoiceFormValue comValue(m_comValue); 422 CProgress comProgress = comValue.SetSelectedIndex(choice.selected Choice());436 CProgress comProgress = comValue.SetSelectedIndex(choice.selectedIndex()); 423 437 424 438 /* Show error message if necessary: */ … … 468 482 const int iSelectedIndex = comValue.GetSelectedIndex(); 469 483 m_choice = ChoiceData(values, iSelectedIndex); 470 m_cells[UIFormEditorDataType_Value]->setText( !m_choice.choices().isEmpty() 471 ? m_choice.choices().at(m_choice.selectedChoice()) 472 : QString()); 484 m_cells[UIFormEditorDataType_Value]->setText(m_choice.selectedValue()); 473 485 /// @todo check for errors 474 486 break;
Note:
See TracChangeset
for help on using the changeset viewer.