Changeset 99664 in vbox
- Timestamp:
- May 8, 2023 10:48:06 AM (19 months ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.cpp
r98938 r99664 70 70 #include "CNetworkAdapter.h" 71 71 #include "CRangedIntegerFormValue.h" 72 #include "CRangedInteger64FormValue.h" 72 73 #include "CRecordingSettings.h" 73 74 #include "CStringFormValue.h" … … 4235 4236 } 4236 4237 4238 UINotificationProgressVsdFormValueSet::UINotificationProgressVsdFormValueSet(const CRangedInteger64FormValue &comValue, 4239 qlonglong iInteger64) 4240 : m_enmType(KFormValueType_RangedInteger64) 4241 , m_comValue(comValue) 4242 , m_iInteger64(iInteger64) 4243 { 4244 } 4245 4237 4246 QString UINotificationProgressVsdFormValueSet::name() const 4238 4247 { … … 4249 4258 case KFormValueType_Choice: return UINotificationProgress::tr("<b>Value:</b> %1").arg(m_iChoice); 4250 4259 case KFormValueType_RangedInteger: return UINotificationProgress::tr("<b>Value:</b> %1").arg(m_iInteger); 4260 case KFormValueType_RangedInteger64: return UINotificationProgress::tr("<b>Value:</b> %1").arg(m_iInteger64); 4251 4261 default: break; 4252 4262 } … … 4299 4309 break; 4300 4310 } 4311 case KFormValueType_RangedInteger64: 4312 { 4313 /* Set value: */ 4314 CRangedInteger64FormValue comValue(m_comValue); 4315 comProgress = comValue.SetInteger(m_iInteger64); 4316 /* Store COM result: */ 4317 comResult = comValue; 4318 break; 4319 } 4301 4320 default: 4302 4321 break; -
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.h
r98938 r99664 2566 2566 UINotificationProgressVsdFormValueSet(const CRangedIntegerFormValue &comValue, int iInteger); 2567 2567 2568 /** Constructs virtual system description form value set notification-progress. 2569 * @param comValue Brings our value being set. 2570 * @param iInteger64 Brings the value our value being set to. */ 2571 UINotificationProgressVsdFormValueSet(const CRangedInteger64FormValue &comValue, qlonglong iInteger64); 2572 2568 2573 protected: 2569 2574 … … 2584 2589 2585 2590 /** Holds the bool value. */ 2586 bool m_fBool;2591 bool m_fBool; 2587 2592 /** Holds the string value. */ 2588 QString m_strString;2593 QString m_strString; 2589 2594 /** Holds the choice value. */ 2590 int m_iChoice;2595 int m_iChoice; 2591 2596 /** Holds the integer value. */ 2592 int m_iInteger; 2597 int m_iInteger; 2598 /** Holds the integer64 value. */ 2599 qlonglong m_iInteger64; 2593 2600 }; 2594 2601 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIFormEditorWidget.cpp
r98103 r99664 31 31 #include <QHeaderView> 32 32 #include <QItemEditorFactory> 33 #include <QLineEdit> 33 34 #include <QPointer> 34 35 #include <QPushButton> … … 54 55 #include "CFormValue.h" 55 56 #include "CRangedIntegerFormValue.h" 57 #include "CRangedInteger64FormValue.h" 56 58 #include "CStringFormValue.h" 59 #include "CSystemProperties.h" 57 60 #include "CVirtualSystemDescriptionForm.h" 58 61 59 62 /* VirtualBox interface declarations: */ 60 63 #include <VBox/com/VirtualBox.h> 64 65 /* External includes: */ 66 #include <math.h> 61 67 62 68 … … 205 211 206 212 213 /** Class used to hold ranged-integer64 data. */ 214 class RangedInteger64Data 215 { 216 public: 217 218 /** Constructs null ranged-integer64 data. */ 219 RangedInteger64Data() 220 : m_iMinimum(-1), m_iMaximum(-1) 221 , m_iInteger(-1), m_strSuffix(QString()) {} 222 /** Constructs ranged-integer64 data on the basis of passed @a iMinimum, @a iMaximum, @a iInteger and @a strSuffix. */ 223 RangedInteger64Data(qlonglong iMinimum, qlonglong iMaximum, qlonglong iInteger, const QString strSuffix) 224 : m_iMinimum(iMinimum), m_iMaximum(iMaximum) 225 , m_iInteger(iInteger), m_strSuffix(strSuffix) {} 226 /** Constructs ranged-integer64 data on the basis of @a another ranged-integer data. */ 227 RangedInteger64Data(const RangedInteger64Data &another) 228 : m_iMinimum(another.minimum()), m_iMaximum(another.maximum()) 229 , m_iInteger(another.integer()), m_strSuffix(another.suffix()) {} 230 231 /** Assigns values of @a another ranged-integer to this one. */ 232 RangedInteger64Data &operator=(const RangedInteger64Data &another) 233 { 234 m_iMinimum = another.minimum(); 235 m_iMaximum = another.maximum(); 236 m_iInteger = another.integer(); 237 m_strSuffix = another.suffix(); 238 return *this; 239 } 240 241 /** Returns minimum value. */ 242 qlonglong minimum() const { return m_iMinimum; } 243 /** Returns maximum value. */ 244 qlonglong maximum() const { return m_iMaximum; } 245 /** Returns current value. */ 246 qlonglong integer() const { return m_iInteger; } 247 /** Returns suffix value. */ 248 QString suffix() const { return m_strSuffix; } 249 250 private: 251 252 /** Holds minimum value. */ 253 qlonglong m_iMinimum; 254 /** Holds maximum value. */ 255 qlonglong m_iMaximum; 256 /** Holds current value. */ 257 qlonglong m_iInteger; 258 /** Holds suffix value. */ 259 QString m_strSuffix; 260 }; 261 Q_DECLARE_METATYPE(RangedInteger64Data); 262 263 207 264 /** QWidget extension used as dummy TextData editor. 208 265 * It's not actually an editor, but Edit... button instead which opens … … 297 354 /** Holds the unchanged suffix. */ 298 355 QString m_strSuffix; 356 }; 357 358 359 /** QLineEdit extension used as RangedInteger64Data editor. */ 360 class RangedInteger64Editor : public QLineEdit 361 { 362 Q_OBJECT; 363 Q_PROPERTY(RangedInteger64Data rangedInteger64 READ rangedInteger64 WRITE setRangedInteger64 USER true); 364 365 public: 366 367 /** Constructs RangedInteger64Data editor passing @a pParent to the base-class. */ 368 RangedInteger64Editor(QWidget *pParent = 0); 369 370 private: 371 372 /** Defines @a rangedInteger. */ 373 void setRangedInteger64(const RangedInteger64Data &rangedInteger64); 374 /** Returns ranged-integer. */ 375 RangedInteger64Data rangedInteger64() const; 376 377 /** Holds the minimum guest RAM in MBs. */ 378 qlonglong m_iMinimumGuestRAM; 379 /** Holds the maximum value. */ 380 qlonglong m_iMaximumGuestRAM; 381 382 /** Holds the minimum value. */ 383 qlonglong m_iMinimum; 384 /** Holds the maximum value. */ 385 qlonglong m_iMaximum; 386 /** Holds the unchanged suffix. */ 387 QString m_strSuffix; 299 388 }; 300 389 … … 375 464 void setRangedInteger(const RangedIntegerData &rangedInteger); 376 465 466 /** Returns value cast to ranged-integer64. */ 467 RangedInteger64Data toRangedInteger64() const; 468 /** Defines @a rangedInteger64 value. */ 469 void setRangedInteger64(const RangedInteger64Data &rangedInteger64); 470 377 471 /** Updates value cells. */ 378 472 void updateValueCells(); … … 408 502 409 503 /** Holds cached bool value. */ 410 bool m_fBool;504 bool m_fBool; 411 505 /** Holds whether cached string value is multiline. */ 412 bool m_fMultilineString;506 bool m_fMultilineString; 413 507 /** Holds cached text value. */ 414 TextData m_text;508 TextData m_text; 415 509 /** Holds cached string value. */ 416 QString m_strString;510 QString m_strString; 417 511 /** Holds cached choice value. */ 418 ChoiceData m_choice;512 ChoiceData m_choice; 419 513 /** Holds cached ranged-integer value. */ 420 RangedIntegerData m_rangedInteger; 514 RangedIntegerData m_rangedInteger; 515 /** Holds cached ranged-integer64 value. */ 516 RangedInteger64Data m_rangedInteger64; 421 517 422 518 /** Holds the cell instances. */ … … 671 767 { 672 768 return RangedIntegerData(minimum(), maximum(), value(), m_strSuffix); 769 } 770 771 772 /********************************************************************************************************************************* 773 * Class RangedInteger64Editor implementation. * 774 *********************************************************************************************************************************/ 775 776 RangedInteger64Editor::RangedInteger64Editor(QWidget *pParent /* = 0 */) 777 : QLineEdit(pParent) 778 , m_iMinimumGuestRAM(0) 779 , m_iMaximumGuestRAM(0) 780 , m_iMinimum(0) 781 , m_iMaximum(0) 782 { 783 /* Acquire min/max amount of RAM guest in theory could have: */ 784 CSystemProperties comProps = uiCommon().virtualBox().GetSystemProperties(); 785 if (comProps.isOk()) 786 { 787 m_iMinimumGuestRAM = comProps.GetMinGuestRAM(); 788 m_iMaximumGuestRAM = comProps.GetMaxGuestRAM(); 789 } 790 } 791 792 void RangedInteger64Editor::setRangedInteger64(const RangedInteger64Data &rangedInteger64) 793 { 794 /* Parse incoming rangedInteger64: */ 795 m_iMinimum = rangedInteger64.minimum(); 796 m_iMaximum = rangedInteger64.maximum(); 797 m_strSuffix = rangedInteger64.suffix(); 798 const qlonglong iValue = rangedInteger64.integer(); 799 800 /* Acquire effective values: */ 801 qlonglong iMinEffective = 0; 802 qlonglong iMaxEffective = 0; 803 qlonglong iValueEffective = 0; 804 /* We wish to represent bytes as megabytes: */ 805 if (m_strSuffix == "B") 806 { 807 iMinEffective = m_iMinimum / _1M; 808 iMaxEffective = m_iMaximum / _1M; 809 iValueEffective = iValue / _1M; 810 } 811 /* For now we will keep all the other suffixes untouched: */ 812 else 813 { 814 iMinEffective = m_iMinimum; 815 iMaxEffective = m_iMaximum; 816 iValueEffective = iValue; 817 } 818 819 /* Make sure minimum, maximum and actual values are within the bounds: */ 820 iMinEffective = qMax(iMinEffective, m_iMinimumGuestRAM); 821 iMaxEffective = qMin(iMaxEffective, m_iMaximumGuestRAM); 822 iValueEffective = qMax(iValueEffective, m_iMinimumGuestRAM); 823 iValueEffective = qMin(iValueEffective, m_iMaximumGuestRAM); 824 825 /* Finally assign validator bounds and actual value: */ 826 setValidator(new QIntValidator((int)iMinEffective, (int)iMaxEffective, this)); 827 setText(QString::number(iValueEffective)); 828 } 829 830 RangedInteger64Data RangedInteger64Editor::rangedInteger64() const 831 { 832 const qlonglong iValueEffective = locale().toLongLong(text()); 833 834 /* Acquire literal value: */ 835 qlonglong iValue = 0; 836 /* We should bring megabytes back to bytes: */ 837 if (m_strSuffix == "B") 838 iValue = iValueEffective * _1M; 839 /* For now we will keep all the other suffixes untouched: */ 840 else 841 iValue = iValueEffective; 842 return RangedInteger64Data(m_iMinimum, m_iMaximum, iValue, m_strSuffix); 673 843 } 674 844 … … 701 871 , m_choice(ChoiceData()) 702 872 , m_rangedInteger(RangedIntegerData()) 873 , m_rangedInteger64(RangedInteger64Data()) 703 874 { 704 875 prepare(); … … 824 995 UINotificationProgressVsdFormValueSet *pNotification = new UINotificationProgressVsdFormValueSet(comValue, 825 996 rangedInteger.integer()); 997 UINotificationCenter *pCenter = m_pFormEditorWidget->notificationCenter() 998 ? m_pFormEditorWidget->notificationCenter() : gpNotificationCenter; 999 pCenter->handleNow(pNotification); 1000 updateValueCells(); 1001 } 1002 1003 RangedInteger64Data UIFormEditorRow::toRangedInteger64() const 1004 { 1005 AssertReturn(valueType() == KFormValueType_RangedInteger64, RangedInteger64Data()); 1006 return m_rangedInteger64; 1007 } 1008 1009 void UIFormEditorRow::setRangedInteger64(const RangedInteger64Data &rangedInteger64) 1010 { 1011 AssertReturnVoid(valueType() == KFormValueType_RangedInteger64); 1012 CRangedInteger64FormValue comValue(m_comValue); 1013 UINotificationProgressVsdFormValueSet *pNotification = new UINotificationProgressVsdFormValueSet(comValue, 1014 rangedInteger64.integer()); 826 1015 UINotificationCenter *pCenter = m_pFormEditorWidget->notificationCenter() 827 1016 ? m_pFormEditorWidget->notificationCenter() : gpNotificationCenter; … … 876 1065 const QString strSuffix = comValue.GetSuffix(); 877 1066 m_rangedInteger = RangedIntegerData(iMinimum, iMaximum, iInteger, strSuffix); 878 m_cells[UIFormEditorDataType_Value]->setText( m_rangedInteger.suffix().isEmpty() 879 ? QString::number(m_rangedInteger.integer()) 880 : QString("%1 %2").arg(m_rangedInteger.integer()) 881 .arg(m_rangedInteger.suffix())); 1067 m_cells[UIFormEditorDataType_Value]->setText( strSuffix.isEmpty() 1068 ? QString::number(iInteger) 1069 : QString("%1 %2").arg(iInteger) 1070 .arg(strSuffix)); 1071 /// @todo check for errors 1072 break; 1073 } 1074 case KFormValueType_RangedInteger64: 1075 { 1076 CRangedInteger64FormValue comValue(m_comValue); 1077 const qlonglong iMinimum = comValue.GetMinimum(); 1078 const qlonglong iMaximum = comValue.GetMaximum(); 1079 const qlonglong iInteger = comValue.GetInteger(); 1080 const QString strSuffix = comValue.GetSuffix(); 1081 m_rangedInteger64 = RangedInteger64Data(iMinimum, iMaximum, iInteger, strSuffix); 1082 /* Display suffix and effective value can be different: */ 1083 QString strEffectiveSuffix = strSuffix; 1084 QString strEffectiveValue; 1085 if (strSuffix.isEmpty()) 1086 strEffectiveValue = QString::number(iInteger); 1087 else if (strSuffix != "B") 1088 strEffectiveValue = QString("%1 %2").arg(iInteger).arg(strEffectiveSuffix); 1089 else 1090 { 1091 /* We wish to convert bytes to megabytes: */ 1092 strEffectiveSuffix = "MB"; 1093 strEffectiveValue = QString("%1 %2").arg(iInteger / _1M).arg(strEffectiveSuffix); 1094 } 1095 m_cells[UIFormEditorDataType_Value]->setText(strEffectiveValue); 882 1096 /// @todo check for errors 883 1097 break; … … 1108 1322 { 1109 1323 m_dataList[index.row()]->setRangedInteger(value.value<RangedIntegerData>()); 1324 emit dataChanged(index, index); 1325 updateGeneration(); 1326 return true; 1327 } 1328 case KFormValueType_RangedInteger64: 1329 { 1330 m_dataList[index.row()]->setRangedInteger64(value.value<RangedInteger64Data>()); 1110 1331 emit dataChanged(index, index); 1111 1332 updateGeneration(); … … 1200 1421 case KFormValueType_RangedInteger: 1201 1422 return QVariant::fromValue(m_dataList[index.row()]->toRangedInteger()); 1423 case KFormValueType_RangedInteger64: 1424 return QVariant::fromValue(m_dataList[index.row()]->toRangedInteger64()); 1202 1425 default: 1203 1426 return QVariant(); … … 1539 1762 m_pItemEditorFactory->registerEditor((QVariant::Type)iRangedIntegerId, pRangedIntegerEditorItemCreator); 1540 1763 1764 /* Register RangedInteger64Editor as the RangedInteger64Data editor: */ 1765 int iRangedInteger64Id = qRegisterMetaType<RangedInteger64Data>(); 1766 QStandardItemEditorCreator<RangedInteger64Editor> *pRangedInteger64EditorItemCreator = new QStandardItemEditorCreator<RangedInteger64Editor>(); 1767 m_pItemEditorFactory->registerEditor((QVariant::Type)iRangedInteger64Id, pRangedInteger64EditorItemCreator); 1768 1541 1769 /* Set newly created item editor factory for table delegate: */ 1542 1770 pStyledItemDelegate->setItemEditorFactory(m_pItemEditorFactory);
Note:
See TracChangeset
for help on using the changeset viewer.