QGIS API Documentation 3.99.0-Master (21b3aa880ba)
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
25QgsProjectVersion::QgsProjectVersion( int major, int minor, int sub, const QString &name )
26 : mMajor( major )
27 , mMinor( minor )
28 , mSub( sub )
29 , mName( name )
30{
31}
32
34{
35 const QString pre = string.section( '-', 0, 0 );
36 const QStringList fileVersionParts = pre.section( '-', 0 ).split( '.' );
37
38 mMajor = fileVersionParts.at( 0 ).toInt();
39 if ( fileVersionParts.size() > 1 )
40 {
41 mMinor = fileVersionParts.at( 1 ).toInt();
42 }
43 if ( fileVersionParts.size() > 2 )
44 {
45 mSub = fileVersionParts.at( 2 ).toInt();
46 }
47 mName = string.section( '-', 1 );
48
49 QgsDebugMsgLevel( QStringLiteral( "Version is set to " ) + text(), 4 );
50}
51
53{
54 return ( ( mMajor == other.mMajor ) &&
55 ( mMinor == other.mMinor ) &&
56 ( mSub == other.mSub ) );
57}
58
60{
61 return ( ( mMajor != other.mMajor ) ||
62 ( mMinor != other.mMinor ) ||
63 ( mSub != other.mSub ) );
64}
65
67{
68 return ( *this == other ) || ( *this > other );
69}
70
72{
73 return ( ( mMajor > other.mMajor ) ||
74 ( ( mMajor == other.mMajor ) && ( mMinor > other.mMinor ) ) ||
75 ( ( mMajor == other.mMajor ) && ( mMinor == other.mMinor ) && ( mSub > other.mSub ) ) );
76}
77
79{
80 return other > *this;
81}
82
84{
85 return other >= *this;
86}
87
88
90{
91 if ( mName.isEmpty() )
92 {
93 return QStringLiteral( "%1.%2.%3" ).arg( mMajor ).arg( mMinor ).arg( mSub );
94 }
95 else
96 {
97 return QStringLiteral( "%1.%2.%3-%4" ).arg( mMajor ).arg( mMinor ).arg( mSub ).arg( mName );
98 }
99}
100
102{
103 return mMajor == 0 && mMinor == 0 && mSub == 0;
104}
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:61