QGIS API Documentation 3.99.0-Master (d270888f95f)
Loading...
Searching...
No Matches
qgsprojectversion.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsprojectfile.h - description
3 -------------------
4 begin : Sun 15 dec 2007
5 copyright : (C) 2007 by Magnus Homann
6 email : magnus at homann.se
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#include "qgsprojectversion.h"
19
20#include "qgslogger.h"
21
22#include <QString>
23#include <QStringList>
24
25using namespace Qt::StringLiterals;
26
27QgsProjectVersion::QgsProjectVersion( int major, int minor, int sub, const QString &name )
28 : mMajor( major )
29 , mMinor( minor )
30 , mSub( sub )
31 , mName( name )
32{
33}
34
36{
37 const QString pre = string.section( '-', 0, 0 );
38 const QStringList fileVersionParts = pre.section( '-', 0 ).split( '.' );
39
40 mMajor = fileVersionParts.at( 0 ).toInt();
41 if ( fileVersionParts.size() > 1 )
42 {
43 mMinor = fileVersionParts.at( 1 ).toInt();
44 }
45 if ( fileVersionParts.size() > 2 )
46 {
47 mSub = fileVersionParts.at( 2 ).toInt();
48 }
49 mName = string.section( '-', 1 );
50
51 QgsDebugMsgLevel( u"Version is set to "_s + text(), 4 );
52}
53
55{
56 return ( ( mMajor == other.mMajor ) &&
57 ( mMinor == other.mMinor ) &&
58 ( mSub == other.mSub ) );
59}
60
62{
63 return ( ( mMajor != other.mMajor ) ||
64 ( mMinor != other.mMinor ) ||
65 ( mSub != other.mSub ) );
66}
67
69{
70 return ( *this == other ) || ( *this > other );
71}
72
74{
75 return ( ( mMajor > other.mMajor ) ||
76 ( ( mMajor == other.mMajor ) && ( mMinor > other.mMinor ) ) ||
77 ( ( mMajor == other.mMajor ) && ( mMinor == other.mMinor ) && ( mSub > other.mSub ) ) );
78}
79
81{
82 return other > *this;
83}
84
86{
87 return other >= *this;
88}
89
90
92{
93 if ( mName.isEmpty() )
94 {
95 return u"%1.%2.%3"_s.arg( mMajor ).arg( mMinor ).arg( mSub );
96 }
97 else
98 {
99 return u"%1.%2.%3-%4"_s.arg( mMajor ).arg( mMinor ).arg( mSub ).arg( mName );
100 }
101}
102
104{
105 return mMajor == 0 && mMinor == 0 && mSub == 0;
106}
bool operator>(const QgsProjectVersion &other) const
bool operator!=(const QgsProjectVersion &other) const
QString text() const
Returns a string representation of the version.
bool operator<(const QgsProjectVersion &other) const
bool operator==(const QgsProjectVersion &other) const
bool operator>=(const QgsProjectVersion &other) const
bool operator<=(const QgsProjectVersion &other) const
bool isNull() const
Returns true if this is a NULL project version.
QgsProjectVersion()=default
Creates a new NULL version.
#define QgsDebugMsgLevel(str, level)
Definition qgslogger.h:63