File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -43,6 +43,9 @@ Version::Version(QString str) : m_string(std::move(str))
4343
4444bool Version::operator <(const Version& other) const
4545{
46+ // prefer x.y.z over x.y
47+ if (versionDigitsNumber () == 3 && other.versionDigitsNumber () == 2 ) return false ;
48+
4649 VERSION_OPERATOR (sec1 < sec2)
4750
4851 return false ;
@@ -57,6 +60,24 @@ bool Version::operator!=(const Version& other) const
5760{
5861 return !operator ==(other);
5962}
63+
64+ int Version::versionDigitsNumber () const
65+ {
66+ int num = 0 ;
67+ for (const auto & sec : m_sections) {
68+ if (!sec.isPreRelease () && !sec.isAppendix ()) {
69+ if (sec.m_fullString == sec.m_stringPart ) {
70+ continue ;
71+ }
72+ ++num;
73+ }
74+ else {
75+ break ;
76+ }
77+ }
78+ return num;
79+ }
80+
6081bool Version::operator <=(const Version& other) const
6182{
6283 return *this < other || *this == other;
Original file line number Diff line number Diff line change @@ -61,6 +61,8 @@ class Version {
6161 friend QDebug operator <<(QDebug debug, const Version& v);
6262
6363 private:
64+ int versionDigitsNumber () const ;
65+
6466 struct Section {
6567 explicit Section (QString fullString) : m_fullString(std::move(fullString))
6668 {
You can’t perform that action at this time.
0 commit comments