QGIS API Documentation 4.1.0-Master (60fea48833c)
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
35{
36 const QString pre = string.section( '-', 0, 0 );
37 const QStringList fileVersionParts = pre.section( '-', 0 ).split( '.' );
38
39 mMajor = fileVersionParts.at( 0 ).toInt();
40 if ( fileVersionParts.size() > 1 )
41 {
42 mMinor = fileVersionParts.at( 1 ).toInt();
43 }
44 if ( fileVersionParts.size() > 2 )
45 {
46 mSub = fileVersionParts.at( 2 ).toInt();
47 }
48 mName = string.section( '-', 1 );
49
50 QgsDebugMsgLevel( u"Version is set to "_s + text(), 4 );
51}
52
54{
55 return ( ( mMajor == other.mMajor ) && ( mMinor == other.mMinor ) && ( mSub == other.mSub ) );
56}
57
59{
60 return ( ( mMajor != other.mMajor ) || ( mMinor != other.mMinor ) || ( mSub != other.mSub ) );
61}
62
64{
65 return ( *this == other ) || ( *this > other );
66}
67
69{
70 return ( ( mMajor > other.mMajor ) || ( ( mMajor == other.mMajor ) && ( mMinor > other.mMinor ) ) || ( ( mMajor == other.mMajor ) && ( mMinor == other.mMinor ) && ( mSub > other.mSub ) ) );
71}
72
74{
75 return other > *this;
76}
77
79{
80 return other >= *this;
81}
82
83
85{
86 if ( mName.isEmpty() )
87 {
88 return u"%1.%2.%3"_s.arg( mMajor ).arg( mMinor ).arg( mSub );
89 }
90 else
91 {
92 return u"%1.%2.%3-%4"_s.arg( mMajor ).arg( mMinor ).arg( mSub ).arg( mName );
93 }
94}
95
97{
98 return mMajor == 0 && mMinor == 0 && mSub == 0;
99}
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