Changeset 94733 in vbox
- Timestamp:
- Apr 28, 2022 12:24:47 PM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 151113
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/networking/UIUpdateDefs.cpp
r94725 r94733 27 27 28 28 /* static: */ 29 VBoxUpdateDayList VBoxUpdateData:: m_dayList= VBoxUpdateDayList();29 VBoxUpdateDayList VBoxUpdateData::s_days = VBoxUpdateDayList(); 30 30 31 31 /* static */ … … 33 33 { 34 34 /* Clear list initially: */ 35 m_dayList.clear();35 s_days.clear(); 36 36 37 37 // WORKAROUND: … … 40 40 41 41 /* Separately retranslate each day: */ 42 m_dayList << VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "1 day"),"1 d");43 m_dayList << VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "2 days"),"2 d");44 m_dayList << VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "3 days"),"3 d");45 m_dayList << VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "4 days"),"4 d");46 m_dayList << VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "5 days"),"5 d");47 m_dayList << VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "6 days"),"6 d");42 s_days << VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "1 day"), "1 d"); 43 s_days << VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "2 days"), "2 d"); 44 s_days << VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "3 days"), "3 d"); 45 s_days << VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "4 days"), "4 d"); 46 s_days << VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "5 days"), "5 d"); 47 s_days << VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "6 days"), "6 d"); 48 48 49 49 /* Separately retranslate each week: */ 50 m_dayList<< VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "1 week"), "1 w");51 m_dayList<< VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "2 weeks"), "2 w");52 m_dayList<< VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "3 weeks"), "3 w");50 s_days << VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "1 week"), "1 w"); 51 s_days << VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "2 weeks"), "2 w"); 52 s_days << VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "3 weeks"), "3 w"); 53 53 54 54 /* Separately retranslate each month: */ 55 m_dayList<< VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "1 month"), "1 m");55 s_days << VBoxUpdateDay(QCoreApplication::translate("UIUpdateManager", "1 month"), "1 m"); 56 56 } 57 57 … … 60 60 { 61 61 QStringList result; 62 for (int i = 0; i < m_dayList.size(); ++i)63 result << m_dayList.at(i).val;62 foreach (const VBoxUpdateDay &day, s_days) 63 result << day.val; 64 64 return result; 65 65 } … … 67 67 VBoxUpdateData::VBoxUpdateData(const QString &strData) 68 68 : m_strData(strData) 69 , m_enm PeriodIndex(Period1Day)69 , m_enmUpdatePeriod(UpdatePeriodType_1Day) 70 70 , m_enmUpdateChannel(KUpdateChannel_Stable) 71 71 { … … 73 73 } 74 74 75 VBoxUpdateData::VBoxUpdateData( PeriodType enmPeriodIndex, KUpdateChannel enmUpdateChannel)75 VBoxUpdateData::VBoxUpdateData(UpdatePeriodType enmUpdatePeriod, KUpdateChannel enmUpdateChannel) 76 76 : m_strData(QString()) 77 , m_enm PeriodIndex(enmPeriodIndex)77 , m_enmUpdatePeriod(enmUpdatePeriod) 78 78 , m_enmUpdateChannel(enmUpdateChannel) 79 79 { … … 84 84 { 85 85 /* No need to check if Period == Never: */ 86 return m_enm PeriodIndex == PeriodNever;86 return m_enmUpdatePeriod == UpdatePeriodType_Never; 87 87 } 88 88 … … 110 110 } 111 111 112 VBoxUpdateData::PeriodType VBoxUpdateData::periodIndex() const113 { 114 return m_enm PeriodIndex;112 UpdatePeriodType VBoxUpdateData::updatePeriod() const 113 { 114 return m_enmUpdatePeriod; 115 115 } 116 116 … … 145 145 return true 146 146 && (m_strData == another.data()) 147 && (m_enm PeriodIndex == another.periodIndex())147 && (m_enmUpdatePeriod == another.updatePeriod()) 148 148 && (m_date == another.internalDate()) 149 149 && (m_enmUpdateChannel == another.updateChannel()) … … 188 188 /* Parse standard values: */ 189 189 if (m_strData == "never") 190 m_enm PeriodIndex = PeriodNever;190 m_enmUpdatePeriod = UpdatePeriodType_Never; 191 191 /* Parse other values: */ 192 192 else … … 201 201 if (parser.size() > 0) 202 202 { 203 if ( m_dayList.isEmpty())203 if (s_days.isEmpty()) 204 204 populate(); 205 PeriodType index = (PeriodType)m_dayList.indexOf(VBoxUpdateDay(QString(), parser.at(0)));206 m_enm PeriodIndex = index == PeriodUndefined ? Period1Day : index;205 const UpdatePeriodType enmUpdatePeriod = (UpdatePeriodType)s_days.indexOf(VBoxUpdateDay(QString(), parser.at(0))); 206 m_enmUpdatePeriod = enmUpdatePeriod == UpdatePeriodType_Never ? UpdatePeriodType_1Day : enmUpdatePeriod; 207 207 } 208 208 … … 231 231 { 232 232 /* Encode standard values: */ 233 if (m_enm PeriodIndex == PeriodNever)233 if (m_enmUpdatePeriod == UpdatePeriodType_Never) 234 234 m_strData = "never"; 235 235 /* Encode other values: */ … … 237 237 { 238 238 /* Encode 'period' value: */ 239 if ( m_dayList.isEmpty())239 if (s_days.isEmpty()) 240 240 populate(); 241 QString remindPeriod = m_dayList[m_enmPeriodIndex].key;241 QString remindPeriod = s_days.at(m_enmUpdatePeriod).key; 242 242 243 243 /* Encode 'date' value: */ -
trunk/src/VBox/Frontends/VirtualBox/src/networking/UIUpdateDefs.h
r94725 r94733 33 33 34 34 35 /** Structure to store retranslated reminder values. */ 35 /** Update period types. */ 36 enum UpdatePeriodType 37 { 38 UpdatePeriodType_Never = -1, 39 UpdatePeriodType_1Day = 0, 40 UpdatePeriodType_2Days = 1, 41 UpdatePeriodType_3Days = 2, 42 UpdatePeriodType_4Days = 3, 43 UpdatePeriodType_5Days = 4, 44 UpdatePeriodType_6Days = 5, 45 UpdatePeriodType_1Week = 6, 46 UpdatePeriodType_2Weeks = 7, 47 UpdatePeriodType_3Weeks = 8, 48 UpdatePeriodType_1Month = 9 49 }; 50 51 52 /** Structure to store retranslated period type values. */ 36 53 struct VBoxUpdateDay 37 54 { 38 55 VBoxUpdateDay(const QString &strVal, const QString &strKey) 39 : val(strVal), key(strKey) {} 56 : val(strVal) 57 , key(strKey) 58 {} 40 59 41 bool operator==(const VBoxUpdateDay &other) const { return val == other.val || key == other.key; } 60 bool operator==(const VBoxUpdateDay &other) const 61 { 62 return val == other.val 63 || key == other.key; 64 } 42 65 43 QString val;44 QString key;66 QString val; 67 QString key; 45 68 }; 46 69 typedef QList<VBoxUpdateDay> VBoxUpdateDayList; … … 52 75 public: 53 76 54 /** Period types. */55 enum PeriodType56 {57 PeriodNever = -2,58 PeriodUndefined = -1,59 Period1Day = 0,60 Period2Days = 1,61 Period3Days = 2,62 Period4Days = 3,63 Period5Days = 4,64 Period6Days = 5,65 Period1Week = 6,66 Period2Weeks = 7,67 Period3Weeks = 8,68 Period1Month = 969 };70 71 77 /** Populates a set of update options. */ 72 78 static void populate(); … … 76 82 /** Constructs update description on the basis of passed @a strData. */ 77 83 VBoxUpdateData(const QString &strData = QString()); 78 /** Constructs update description on the basis of passed @a enm PeriodIndexand @a enmUpdateChannel. */79 VBoxUpdateData( PeriodType enmPeriodIndex, KUpdateChannel enmUpdateChannel);84 /** Constructs update description on the basis of passed @a enmUpdatePeriod and @a enmUpdateChannel. */ 85 VBoxUpdateData(UpdatePeriodType enmUpdatePeriod, KUpdateChannel enmUpdateChannel); 80 86 81 87 /** Returns whether there is no need to check. */ … … 83 89 /** Returns whether there is really need to check. */ 84 90 bool isNeedToCheck() const; 91 85 92 /** Returns update data. */ 86 93 QString data() const; 87 /** Returns period index. */ 88 PeriodType periodIndex() const; 94 95 /** Returns update period. */ 96 UpdatePeriodType updatePeriod() const; 89 97 /** Returns update date. */ 90 98 QString date() const; … … 121 129 void encode(); 122 130 123 /** Holds the populated list of update options. */124 static VBoxUpdateDayList m_dayList;131 /** Holds the populated list of update period options. */ 132 static VBoxUpdateDayList s_days; 125 133 126 134 /** Holds the update data. */ 127 QString m_strData;128 /** Holds the update period index. */129 PeriodType m_enmPeriodIndex;135 QString m_strData; 136 /** Holds the update period. */ 137 UpdatePeriodType m_enmUpdatePeriod; 130 138 /** Holds the update date. */ 131 QDate m_date;139 QDate m_date; 132 140 /** Holds the update channel. */ 133 KUpdateChannel m_enmUpdateChannel;141 KUpdateChannel m_enmUpdateChannel; 134 142 /** Holds the update version. */ 135 UIVersion m_version;143 UIVersion m_version; 136 144 }; 137 145 -
trunk/src/VBox/Frontends/VirtualBox/src/networking/UIUpdateManager.cpp
r94725 r94733 364 364 VBoxUpdateData currentData(gEDataManager->applicationUpdateData()); 365 365 /* Encode/save new update data: */ 366 VBoxUpdateData newData(currentData. periodIndex(), currentData.updateChannel());366 VBoxUpdateData newData(currentData.updatePeriod(), currentData.updateChannel()); 367 367 gEDataManager->setApplicationUpdateData(newData.data()); 368 368 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIUpdateSettingsEditor.cpp
r94725 r94733 57 57 { 58 58 if (m_pComboUpdatePeriod) 59 m_pComboUpdatePeriod->setCurrentIndex(m_guiValue. periodIndex());59 m_pComboUpdatePeriod->setCurrentIndex(m_guiValue.updatePeriod()); 60 60 if (m_mapRadioButtons.value(m_guiValue.updateChannel())) 61 61 m_mapRadioButtons.value(m_guiValue.updateChannel())->setChecked(true); … … 69 69 VBoxUpdateData UIUpdateSettingsEditor::value() const 70 70 { 71 return m_pCheckBox ? VBoxUpdateData( periodType(), updateChannel()) : m_guiValue;71 return m_pCheckBox ? VBoxUpdateData(updatePeriod(), updateChannel()) : m_guiValue; 72 72 } 73 73 … … 141 141 { 142 142 if (m_pFieldUpdateDate) 143 m_pFieldUpdateDate->setText(VBoxUpdateData( periodType(), updateChannel()).date());143 m_pFieldUpdateDate->setText(VBoxUpdateData(updatePeriod(), updateChannel()).date()); 144 144 } 145 145 … … 265 265 } 266 266 267 VBoxUpdateData::PeriodType UIUpdateSettingsEditor::periodType() const 268 { 269 const VBoxUpdateData::PeriodType enmResult = m_pCheckBox && m_pCheckBox->isChecked() && m_pComboUpdatePeriod 270 ? (VBoxUpdateData::PeriodType)m_pComboUpdatePeriod->currentIndex() 271 : VBoxUpdateData::PeriodNever; 272 return enmResult == VBoxUpdateData::PeriodUndefined ? VBoxUpdateData::Period1Day : enmResult; 267 UpdatePeriodType UIUpdateSettingsEditor::updatePeriod() const 268 { 269 return m_pCheckBox && m_pCheckBox->isChecked() && m_pComboUpdatePeriod 270 ? (UpdatePeriodType)m_pComboUpdatePeriod->currentIndex() 271 : UpdatePeriodType_Never; 273 272 } 274 273 … … 276 275 { 277 276 QAbstractButton *pCheckedButton = m_pRadioButtonGroup ? m_pRadioButtonGroup->checkedButton() : 0; 278 return m_mapRadioButtons.key(pCheckedButton, KUpdateChannel_Stable);279 } 277 return m_mapRadioButtons.key(pCheckedButton, m_guiValue.updateChannel()); 278 } -
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIUpdateSettingsEditor.h
r94725 r94733 72 72 void prepareConnections(); 73 73 74 /** Returns period type. */75 VBoxUpdateData::PeriodType periodType() const;74 /** Returns update period. */ 75 UpdatePeriodType updatePeriod() const; 76 76 /** Returns update channel. */ 77 77 KUpdateChannel updateChannel() const;
Note:
See TracChangeset
for help on using the changeset viewer.