Changeset 78819 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- May 28, 2019 1:47:30 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
r78542 r78819 59 59 #include "CCloudProvider.h" 60 60 #include "CCloudProviderManager.h" 61 #include "CNATNetwork.h"62 61 #include "CDHCPServer.h" 63 62 #include "CNATEngine.h" 63 #include "CNATNetwork.h" 64 #include "CRangedIntegerFormValue.h" 64 65 #include "CSerialPort.h" 65 66 #include "CSharedFolder.h" … … 1750 1751 } 1751 1752 1753 void UIMessageCenter::cannotAssignFormValue(const CRangedIntegerFormValue &comValue, QWidget *pParent /* = 0 */) const 1754 { 1755 error(pParent, MessageType_Error, 1756 tr("Failed to assign form value."), 1757 UIErrorString::formatErrorInfo(comValue)); 1758 } 1759 1752 1760 void UIMessageCenter::cannotAssignFormValue(const CProgress &comProgress, QWidget *pParent /* = 0 */) const 1753 1761 { -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h
r78542 r78819 384 384 void cannotAssignFormValue(const CStringFormValue &comValue, QWidget *pParent = 0) const; 385 385 void cannotAssignFormValue(const CChoiceFormValue &comValue, QWidget *pParent = 0) const; 386 void cannotAssignFormValue(const CRangedIntegerFormValue &comValue, QWidget *pParent = 0) const; 386 387 void cannotAssignFormValue(const CProgress &comProgress, QWidget *pParent = 0) const; 387 388 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIFormEditorWidget.cpp
r78818 r78819 22 22 #include <QItemEditorFactory> 23 23 #include <QSortFilterProxyModel> 24 #include <QSpinBox> 24 25 #include <QStyledItemDelegate> 25 26 #include <QVBoxLayout> … … 34 35 #include "CChoiceFormValue.h" 35 36 #include "CFormValue.h" 37 #include "CRangedIntegerFormValue.h" 36 38 #include "CStringFormValue.h" 37 39 #include "CVirtualSystemDescriptionForm.h" … … 93 95 94 96 97 /** Class used to hold ranged-integer data. */ 98 class RangedIntegerData 99 { 100 public: 101 102 /** Constructs null ranged-integer data. */ 103 RangedIntegerData() {} 104 /** Constructs ranged-integer data on the basis of passed @a iMinimum, @a iMaximum and @a iInteger. */ 105 RangedIntegerData(int iMinimum, int iMaximum, int iInteger) 106 : m_iMinimum(iMinimum), m_iMaximum(iMaximum), m_iInteger(iInteger) {} 107 /** Constructs ranged-integer data on the basis of @a another ranged-integer data. */ 108 RangedIntegerData(const RangedIntegerData &another) 109 : m_iMinimum(another.minimum()), m_iMaximum(another.maximum()), m_iInteger(another.integer()) {} 110 111 /** Assigns values of @a another ranged-integer to this one. */ 112 RangedIntegerData &operator=(const RangedIntegerData &another) 113 { 114 m_iMinimum = another.minimum(); 115 m_iMaximum = another.maximum(); 116 m_iInteger = another.integer(); 117 return *this; 118 } 119 120 /** Returns minimum value. */ 121 int minimum() const { return m_iMinimum; } 122 /** Returns maximum value. */ 123 int maximum() const { return m_iMaximum; } 124 /** Returns current value. */ 125 int integer() const { return m_iInteger; } 126 127 private: 128 129 /** Holds minimum value. */ 130 int m_iMinimum; 131 /** Holds maximum value. */ 132 int m_iMaximum; 133 /** Holds current value. */ 134 int m_iInteger; 135 }; 136 Q_DECLARE_METATYPE(RangedIntegerData); 137 138 95 139 /** QComboBox extension used as ChoiceData editor. */ 96 140 class ChoiceEditor : public QComboBox … … 125 169 126 170 171 /** QSpinBox extension used as RangedIntegerData editor. */ 172 class RangedIntegerEditor : public QSpinBox 173 { 174 Q_OBJECT; 175 Q_PROPERTY(RangedIntegerData rangedInteger READ rangedInteger WRITE setRangedInteger USER true); 176 177 public: 178 179 /** Constructs RangedIntegerData editor passing @a pParent to the base-class. */ 180 RangedIntegerEditor(QWidget *pParent = 0) 181 : QSpinBox(pParent) {} 182 183 private: 184 185 /** Defines @a rangedInteger. */ 186 void setRangedInteger(const RangedIntegerData &rangedInteger) 187 { 188 setMinimum(rangedInteger.minimum()); 189 setMaximum(rangedInteger.maximum()); 190 setValue(rangedInteger.integer()); 191 } 192 193 /** Returns ranged-integer. */ 194 RangedIntegerData rangedInteger() const 195 { 196 return RangedIntegerData(minimum(), maximum(), value()); 197 } 198 }; 199 200 127 201 /** QITableViewCell extension used as Form Editor table-view cell. */ 128 202 class UIFormEditorCell : public QITableViewCell … … 186 260 void setChoice(const ChoiceData &choice); 187 261 262 /** Returns value cast to ranged-integer. */ 263 RangedIntegerData toRangedInteger() const; 264 /** Defines @a rangedInteger value. */ 265 void setRangedInteger(const RangedIntegerData &rangedInteger); 266 188 267 /** Updates value cells. */ 189 268 void updateValueCells(); … … 216 295 217 296 /** Holds cached bool value. */ 218 bool m_fBool;297 bool m_fBool; 219 298 /** Holds cached string value. */ 220 QString m_strString;299 QString m_strString; 221 300 /** Holds cached choice value. */ 222 ChoiceData m_choice; 301 ChoiceData m_choice; 302 /** Holds cached ranged-integer value. */ 303 RangedIntegerData m_rangedInteger; 223 304 224 305 /** Holds the cell instances. */ … … 338 419 , m_strString(QString()) 339 420 , m_choice(ChoiceData()) 421 , m_rangedInteger(RangedIntegerData()) 340 422 { 341 423 prepare(); … … 453 535 } 454 536 537 RangedIntegerData UIFormEditorRow::toRangedInteger() const 538 { 539 AssertReturn(valueType() == KFormValueType_RangedInteger, RangedIntegerData()); 540 return m_rangedInteger; 541 } 542 543 void UIFormEditorRow::setRangedInteger(const RangedIntegerData &rangedInteger) 544 { 545 AssertReturnVoid(valueType() == KFormValueType_RangedInteger); 546 CRangedIntegerFormValue comValue(m_comValue); 547 CProgress comProgress = comValue.SetInteger(rangedInteger.integer()); 548 549 /* Show error message if necessary: */ 550 if (!comValue.isOk()) 551 msgCenter().cannotAssignFormValue(comValue); 552 else 553 { 554 /* Show "Acquire export form" progress: */ 555 msgCenter().showModalProgressDialog(comProgress, UIFormEditorWidget::tr("Assign value..."), 556 ":/progress_reading_appliance_90px.png"); 557 558 /* Show error message if necessary: */ 559 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 560 msgCenter().cannotAssignFormValue(comProgress); 561 else 562 updateValueCells(); 563 } 564 } 565 455 566 void UIFormEditorRow::updateValueCells() 456 567 { … … 483 594 m_choice = ChoiceData(values, iSelectedIndex); 484 595 m_cells[UIFormEditorDataType_Value]->setText(m_choice.selectedValue()); 596 /// @todo check for errors 597 break; 598 } 599 case KFormValueType_RangedInteger: 600 { 601 CRangedIntegerFormValue comValue(m_comValue); 602 const int iMinimum = comValue.GetMinimum(); 603 const int iMaximum = comValue.GetMaximum(); 604 const int iInteger = comValue.GetInteger(); 605 m_rangedInteger = RangedIntegerData(iMinimum, iMaximum, iInteger); 606 m_cells[UIFormEditorDataType_Value]->setText(QString::number(m_rangedInteger.integer())); 485 607 /// @todo check for errors 486 608 break; … … 687 809 updateGeneration(); 688 810 return true; 811 case KFormValueType_RangedInteger: 812 m_dataList[index.row()]->setRangedInteger(value.value<RangedIntegerData>()); 813 emit dataChanged(index, index); 814 updateGeneration(); 815 return true; 689 816 default: 690 817 return false; … … 754 881 case KFormValueType_Choice: 755 882 return QVariant::fromValue(m_dataList[index.row()]->toChoice()); 883 case KFormValueType_RangedInteger: 884 return QVariant::fromValue(m_dataList[index.row()]->toRangedInteger()); 756 885 default: 757 886 return QVariant(); … … 943 1072 pNewItemEditorFactory->registerEditor((QVariant::Type)iChoiceId, pChoiceEditorItemCreator); 944 1073 1074 /* Register RangedIntegerEditor as the RangedIntegerData editor: */ 1075 int iRangedIntegerId = qRegisterMetaType<RangedIntegerData>(); 1076 QStandardItemEditorCreator<RangedIntegerEditor> *pRangedIntegerEditorItemCreator = new QStandardItemEditorCreator<RangedIntegerEditor>(); 1077 pNewItemEditorFactory->registerEditor((QVariant::Type)iRangedIntegerId, pRangedIntegerEditorItemCreator); 1078 945 1079 /* Set newly created item editor factory for table delegate: */ 946 1080 pStyledItemDelegate->setItemEditorFactory(pNewItemEditorFactory);
Note:
See TracChangeset
for help on using the changeset viewer.