VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/globals/UIVersion.cpp@ 82781

Last change on this file since 82781 was 78655, checked in by vboxsync, 5 years ago

FE/Qt: bugref:9470: UIVersion fix for trunk to ease the GA downloading testing.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
1/* $Id: UIVersion.cpp 78655 2019-05-22 10:55:02Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIVersion class implementation.
4 */
5
6/*
7 * Copyright (C) 2006-2019 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18/* Qt includes: */
19#include <QStringList>
20
21/* GUI includes: */
22#include "UIVersion.h"
23
24/* Other VBox includes: */
25#include <iprt/string.h>
26
27
28UIVersion::UIVersion()
29 : m_x(-1)
30 , m_y(-1)
31 , m_z(-1)
32{
33}
34
35UIVersion::UIVersion(const QString &strFullVersionInfo)
36 : m_x(-1)
37 , m_y(-1)
38 , m_z(-1)
39{
40 const QStringList fullVersionInfo = strFullVersionInfo.split('_');
41 if (fullVersionInfo.size() > 0)
42 {
43 const QStringList versionIndexes = fullVersionInfo.at(0).split('.');
44 if (versionIndexes.size() > 0)
45 m_x = versionIndexes[0].toInt();
46 if (versionIndexes.size() > 1)
47 m_y = versionIndexes[1].toInt();
48 if (versionIndexes.size() > 2)
49 m_z = versionIndexes[2].toInt();
50 }
51 if (fullVersionInfo.size() > 1)
52 m_strPostfix = fullVersionInfo.at(1);
53}
54
55UIVersion &UIVersion::operator=(const UIVersion &another)
56{
57 m_x = another.x();
58 m_y = another.y();
59 m_z = another.z();
60 m_strPostfix = another.postfix();
61 return *this;
62}
63
64bool UIVersion::isValid() const
65{
66 return (m_x != -1)
67 && (m_y != -1)
68 && (m_z != -1);
69}
70
71bool UIVersion::equal(const UIVersion &other) const
72{
73 return (m_x == other.m_x)
74 && (m_y == other.m_y)
75 && (m_z == other.m_z)
76 && (m_strPostfix == other.m_strPostfix);
77}
78
79bool UIVersion::operator<(const UIVersion &other) const
80{
81 return RTStrVersionCompare(toString().toUtf8().constData(), other.toString().toUtf8().constData()) < 0;
82}
83
84bool UIVersion::operator<=(const UIVersion &other) const
85{
86 return RTStrVersionCompare(toString().toUtf8().constData(), other.toString().toUtf8().constData()) <= 0;
87}
88
89bool UIVersion::operator>(const UIVersion &other) const
90{
91 return RTStrVersionCompare(toString().toUtf8().constData(), other.toString().toUtf8().constData()) > 0;
92}
93
94bool UIVersion::operator>=(const UIVersion &other) const
95{
96 return RTStrVersionCompare(toString().toUtf8().constData(), other.toString().toUtf8().constData()) >= 0;
97}
98
99QString UIVersion::toString() const
100{
101 return m_strPostfix.isEmpty() ? QString("%1.%2.%3").arg(m_x).arg(m_y).arg(m_z)
102 : QString("%1.%2.%3_%4").arg(m_x).arg(m_y).arg(m_z).arg(m_strPostfix);
103}
104
105UIVersion UIVersion::effectiveReleasedVersion() const
106{
107 /* First, we just copy the current one: */
108 UIVersion version = *this;
109
110 /* If this version being developed: */
111 if (version.z() % 2 == 1)
112 {
113 /* If this version being developed on release branch (we guess the right one): */
114 if (version.z() < 97)
115 version.setZ(version.z() - 1);
116 /* If this version being developed on trunk (we use hardcoded one for now): */
117 else
118 version.setZ(8); /* Current .z for 6.0.z */
119 }
120
121 /* Finally, we just return that we have: */
122 return version;
123}
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use