MCPcopy Create free account
hub / github.com/altairwei/WizNotePlus / compareVersion

Method compareVersion

src/WizUpgrade.cpp:116–144  ·  view source on GitHub ↗

* @brief Compare two version numbers version1 and version2. * * @param v1 Version string, such as "2.8.1", only three parts are allowed. * @param v2 Version string, such as "2.7.3", only three parts are allowed.. * @return int If version1 > version2 return 1; if version1 < version2 return -1;otherwise return 0. */

Source from the content-addressed store, hash-verified

114 * @return int If version1 > version2 return 1; if version1 < version2 return -1;otherwise return 0.
115 */
116int WizUpgradeChecker::compareVersion(const QString &v1, const QString &v2)
117{
118 QStringList v1Parts = v1.split(".");
119 int v1Major = v1Parts.at(0).toInt();
120 int v1Minor = v1Parts.at(1).toInt();
121 int v1Patch = v1Parts.at(2).toInt();
122
123 QStringList v2Parts = v2.split(".");
124 int v2Major = v2Parts.at(0).toInt();
125 int v2Minor = v2Parts.at(1).toInt();
126 int v2Patch = v2Parts.at(2).toInt();
127
128 if (v1Major > v2Major)
129 return 1;
130 else if (v1Major < v2Major)
131 return -1;
132
133 if (v1Minor > v2Minor)
134 return 1;
135 else if (v1Minor < v2Minor)
136 return -1;
137
138 if (v1Patch > v2Patch)
139 return 1;
140 else if (v1Patch < v2Patch)
141 return -1;
142 else
143 return 0;
144}
145
146/**
147 * @brief Compare two developing stage stage1 and stage2.

Callers 2

tFunction · 0.80
checkCompareVersionMethod · 0.80

Calls

no outgoing calls

Tested by 1

checkCompareVersionMethod · 0.64