QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
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 <QString>
19#include <QStringList>
20
21#include "qgslogger.h"
22#include "qgsprojectversion.h"
23
24QgsProjectVersion::QgsProjectVersion( int major, int minor, int sub, const QString &name )
25 : mMajor( major )
26 , mMinor( minor )
27 , mSub( sub )
28 , mName( name )
29{
30}
31
33{
34 const QString pre = string.section( '-', 0, 0 );
35 const QStringList fileVersionParts = pre.section( '-', 0 ).split( '.' );
36
37 mMajor = fileVersionParts.at( 0 ).toInt();
38 if ( fileVersionParts.size() > 1 )
39 {
40 mMinor = fileVersionParts.at( 1 ).toInt();
41 }
42 if ( fileVersionParts.size() > 2 )
43 {
44 mSub = fileVersionParts.at( 2 ).toInt();
45 }
46 mName = string.section( '-', 1 );
47
48 QgsDebugMsgLevel( QStringLiteral( "Version is set to " ) + text(), 4 );
49}
50
52{
53 return ( ( mMajor == other.mMajor ) &&
54 ( mMinor == other.mMinor ) &&
55 ( mSub == other.mSub ) );
56}
57
59{
60 return ( ( mMajor != other.mMajor ) ||
61 ( mMinor != other.mMinor ) ||
62 ( mSub != other.mSub ) );
63}
64
66{
67 return ( *this == other ) || ( *this > other );
68}
69
71{
72 return ( ( mMajor > other.mMajor ) ||
73 ( ( mMajor == other.mMajor ) && ( mMinor > other.mMinor ) ) ||
74 ( ( mMajor == other.mMajor ) && ( mMinor == other.mMinor ) && ( mSub > other.mSub ) ) );
75}
76
78{
79 return other > *this;
80}
81
83{
84 return other >= *this;
85}
86
87
89{
90 if ( mName.isEmpty() )
91 {
92 return QStringLiteral( "%1.%2.%3" ).arg( mMajor ).arg( mMinor ).arg( mSub );
93 }
94 else
95 {
96 return QStringLiteral( "%1.%2.%3-%4" ).arg( mMajor ).arg( mMinor ).arg( mSub ).arg( mName );
97 }
98}
99
101{
102 return mMajor == 0 && mMinor == 0 && mSub == 0;
103}
A class to describe the version of a project.
bool operator>(const QgsProjectVersion &other) const
Boolean > operator.
bool operator!=(const QgsProjectVersion &other) const
Boolean not equal operator.
QString text() const
Returns a string representation of the version.
bool operator<(const QgsProjectVersion &other) const
Boolean < operator.
bool operator==(const QgsProjectVersion &other) const
Boolean equal operator.
bool operator>=(const QgsProjectVersion &other) const
Boolean >= operator.
bool operator<=(const QgsProjectVersion &other) const
Boolean <= operator.
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:39