Changeset 94738 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Apr 28, 2022 5:13:37 PM (3 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/networking/UIUpdateDefs.cpp
r94733 r94738 70 70 , m_enmUpdateChannel(KUpdateChannel_Stable) 71 71 { 72 decode();73 }74 75 VBoxUpdateData::VBoxUpdateData(UpdatePeriodType enmUpdatePeriod, KUpdateChannel enmUpdateChannel)76 : m_strData(QString())77 , m_enmUpdatePeriod(enmUpdatePeriod)78 , m_enmUpdateChannel(enmUpdateChannel)79 {80 encode();81 }82 83 bool VBoxUpdateData::isNoNeedToCheck() const84 {85 /* No need to check if Period == Never: */86 return m_enmUpdatePeriod == UpdatePeriodType_Never;87 }88 89 bool VBoxUpdateData::isNeedToCheck() const90 {91 /* Return 'false' if there is no need to check: */92 if (isNoNeedToCheck())93 return false;94 95 /* Return 'true' if date of next check is today or missed: */96 if (QDate::currentDate() >= m_date)97 return true;98 99 /* Return 'true' if saved version value is NOT valid or NOT equal to current: */100 if (!version().isValid() || version() != UIVersion(uiCommon().vboxVersionStringNormalized()))101 return true;102 103 /* Return 'false' in all other cases: */104 return false;105 }106 107 QString VBoxUpdateData::data() const108 {109 return m_strData;110 }111 112 UpdatePeriodType VBoxUpdateData::updatePeriod() const113 {114 return m_enmUpdatePeriod;115 }116 117 QString VBoxUpdateData::date() const118 {119 return isNoNeedToCheck() ? QCoreApplication::translate("UIUpdateManager", "Never")120 : QLocale::system().toString(m_date, QLocale::ShortFormat);121 }122 123 QDate VBoxUpdateData::internalDate() const124 {125 return m_date;126 }127 128 KUpdateChannel VBoxUpdateData::updateChannel() const129 {130 return m_enmUpdateChannel;131 }132 133 QString VBoxUpdateData::updateChannelName() const134 {135 return updateChannelToInternalString(m_enmUpdateChannel);136 }137 138 UIVersion VBoxUpdateData::version() const139 {140 return m_version;141 }142 143 bool VBoxUpdateData::isEqual(const VBoxUpdateData &another) const144 {145 return true146 && (m_strData == another.data())147 && (m_enmUpdatePeriod == another.updatePeriod())148 && (m_date == another.internalDate())149 && (m_enmUpdateChannel == another.updateChannel())150 && (m_version == another.version())151 ;152 }153 154 bool VBoxUpdateData::operator==(const VBoxUpdateData &another) const155 {156 return isEqual(another);157 }158 159 bool VBoxUpdateData::operator!=(const VBoxUpdateData &another) const160 {161 return !isEqual(another);162 }163 164 /* static */165 QString VBoxUpdateData::updateChannelToInternalString(KUpdateChannel enmUpdateChannel)166 {167 switch (enmUpdateChannel)168 {169 case KUpdateChannel_WithTesting: return "withtesting";170 case KUpdateChannel_WithBetas: return "withbetas";171 case KUpdateChannel_All: return "allrelease";172 default: return "stable";173 }174 }175 176 /* static */177 KUpdateChannel VBoxUpdateData::updateChannelFromInternalString(const QString &strUpdateChannel)178 {179 QMap<QString, KUpdateChannel> pairs;180 pairs["withtesting"] = KUpdateChannel_WithTesting;181 pairs["withbetas"] = KUpdateChannel_WithBetas;182 pairs["allrelease"] = KUpdateChannel_All;183 return pairs.value(strUpdateChannel, KUpdateChannel_Stable);184 }185 186 void VBoxUpdateData::decode()187 {188 72 /* Parse standard values: */ 189 73 if (m_strData == "never") … … 228 112 } 229 113 230 void VBoxUpdateData::encode() 114 VBoxUpdateData::VBoxUpdateData(UpdatePeriodType enmUpdatePeriod, KUpdateChannel enmUpdateChannel) 115 : m_strData(QString()) 116 , m_enmUpdatePeriod(enmUpdatePeriod) 117 , m_enmUpdateChannel(enmUpdateChannel) 231 118 { 232 119 /* Encode standard values: */ … … 263 150 } 264 151 152 bool VBoxUpdateData::isNoNeedToCheck() const 153 { 154 /* No need to check if Period == Never: */ 155 return m_enmUpdatePeriod == UpdatePeriodType_Never; 156 } 157 158 bool VBoxUpdateData::isNeedToCheck() const 159 { 160 /* Return 'false' if there is no need to check: */ 161 if (isNoNeedToCheck()) 162 return false; 163 164 /* Return 'true' if date of next check is today or missed: */ 165 if (QDate::currentDate() >= m_date) 166 return true; 167 168 /* Return 'true' if saved version value is NOT valid or NOT equal to current: */ 169 if (!version().isValid() || version() != UIVersion(uiCommon().vboxVersionStringNormalized())) 170 return true; 171 172 /* Return 'false' in all other cases: */ 173 return false; 174 } 175 176 QString VBoxUpdateData::data() const 177 { 178 return m_strData; 179 } 180 181 UpdatePeriodType VBoxUpdateData::updatePeriod() const 182 { 183 return m_enmUpdatePeriod; 184 } 185 186 QDate VBoxUpdateData::date() const 187 { 188 return m_date; 189 } 190 191 QString VBoxUpdateData::dateToString() const 192 { 193 return isNoNeedToCheck() ? QCoreApplication::translate("UIUpdateManager", "Never") 194 : QLocale::system().toString(m_date, QLocale::ShortFormat); 195 } 196 197 KUpdateChannel VBoxUpdateData::updateChannel() const 198 { 199 return m_enmUpdateChannel; 200 } 201 202 QString VBoxUpdateData::updateChannelName() const 203 { 204 return updateChannelToInternalString(m_enmUpdateChannel); 205 } 206 207 UIVersion VBoxUpdateData::version() const 208 { 209 return m_version; 210 } 211 212 bool VBoxUpdateData::isEqual(const VBoxUpdateData &another) const 213 { 214 return true 215 && (m_strData == another.data()) 216 && (m_enmUpdatePeriod == another.updatePeriod()) 217 && (m_date == another.date()) 218 && (m_enmUpdateChannel == another.updateChannel()) 219 && (m_version == another.version()) 220 ; 221 } 222 223 bool VBoxUpdateData::operator==(const VBoxUpdateData &another) const 224 { 225 return isEqual(another); 226 } 227 228 bool VBoxUpdateData::operator!=(const VBoxUpdateData &another) const 229 { 230 return !isEqual(another); 231 } 232 233 /* static */ 234 QString VBoxUpdateData::updateChannelToInternalString(KUpdateChannel enmUpdateChannel) 235 { 236 switch (enmUpdateChannel) 237 { 238 case KUpdateChannel_WithTesting: return "withtesting"; 239 case KUpdateChannel_WithBetas: return "withbetas"; 240 case KUpdateChannel_All: return "allrelease"; 241 default: return "stable"; 242 } 243 } 244 245 /* static */ 246 KUpdateChannel VBoxUpdateData::updateChannelFromInternalString(const QString &strUpdateChannel) 247 { 248 QMap<QString, KUpdateChannel> pairs; 249 pairs["withtesting"] = KUpdateChannel_WithTesting; 250 pairs["withbetas"] = KUpdateChannel_WithBetas; 251 pairs["allrelease"] = KUpdateChannel_All; 252 return pairs.value(strUpdateChannel, KUpdateChannel_Stable); 253 } -
trunk/src/VBox/Frontends/VirtualBox/src/networking/UIUpdateDefs.h
r94733 r94738 96 96 UpdatePeriodType updatePeriod() const; 97 97 /** Returns update date. */ 98 Q Stringdate() const;99 /** Returns internal update date. */100 Q Date internalDate() const;98 QDate date() const; 99 /** Returns update date as string. */ 100 QString dateToString() const; 101 101 /** Returns update channel. */ 102 102 KUpdateChannel updateChannel() const; … … 124 124 private: 125 125 126 /** Decodes data. */127 void decode();128 /** Encodes data. */129 void encode();130 131 126 /** Holds the populated list of update period options. */ 132 static VBoxUpdateDayList 127 static VBoxUpdateDayList s_days; 133 128 134 129 /** Holds the update data. */ 135 QString 130 QString m_strData; 136 131 /** Holds the update period. */ 137 UpdatePeriodType m_enmUpdatePeriod;132 UpdatePeriodType m_enmUpdatePeriod; 138 133 /** Holds the update date. */ 139 QDate 134 QDate m_date; 140 135 /** Holds the update channel. */ 141 KUpdateChannel 136 KUpdateChannel m_enmUpdateChannel; 142 137 /** Holds the update version. */ 143 UIVersion 138 UIVersion m_version; 144 139 }; 145 140 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIUpdateSettingsEditor.cpp
r94733 r94738 141 141 { 142 142 if (m_pFieldUpdateDate) 143 m_pFieldUpdateDate->setText(VBoxUpdateData(updatePeriod(), updateChannel()).date ());143 m_pFieldUpdateDate->setText(VBoxUpdateData(updatePeriod(), updateChannel()).dateToString()); 144 144 } 145 145
Note:
See TracChangeset
for help on using the changeset viewer.