QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
project
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
25
using namespace
Qt::StringLiterals;
26
27
QgsProjectVersion::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
QgsProjectVersion::QgsProjectVersion
(
const
QString &
string
)
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
53
bool
QgsProjectVersion::operator==
(
const
QgsProjectVersion
&other )
const
54
{
55
return
( ( mMajor == other.mMajor ) && ( mMinor == other.mMinor ) && ( mSub == other.mSub ) );
56
}
57
58
bool
QgsProjectVersion::operator!=
(
const
QgsProjectVersion
&other )
const
59
{
60
return
( ( mMajor != other.mMajor ) || ( mMinor != other.mMinor ) || ( mSub != other.mSub ) );
61
}
62
63
bool
QgsProjectVersion::operator>=
(
const
QgsProjectVersion
&other )
const
64
{
65
return
( *
this
== other ) || ( *
this
> other );
66
}
67
68
bool
QgsProjectVersion::operator>
(
const
QgsProjectVersion
&other )
const
69
{
70
return
( ( mMajor > other.mMajor ) || ( ( mMajor == other.mMajor ) && ( mMinor > other.mMinor ) ) || ( ( mMajor == other.mMajor ) && ( mMinor == other.mMinor ) && ( mSub > other.mSub ) ) );
71
}
72
73
bool
QgsProjectVersion::operator<
(
const
QgsProjectVersion
&other )
const
74
{
75
return
other > *
this
;
76
}
77
78
bool
QgsProjectVersion::operator<=
(
const
QgsProjectVersion
&other )
const
79
{
80
return
other >= *
this
;
81
}
82
83
84
QString
QgsProjectVersion::text
()
const
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
96
bool
QgsProjectVersion::isNull
()
const
97
{
98
return
mMajor == 0 && mMinor == 0 && mSub == 0;
99
}
QgsProjectVersion::operator>
bool operator>(const QgsProjectVersion &other) const
Definition
qgsprojectversion.cpp:68
QgsProjectVersion::operator!=
bool operator!=(const QgsProjectVersion &other) const
Definition
qgsprojectversion.cpp:58
QgsProjectVersion::text
QString text() const
Returns a string representation of the version.
Definition
qgsprojectversion.cpp:84
QgsProjectVersion::operator<
bool operator<(const QgsProjectVersion &other) const
Definition
qgsprojectversion.cpp:73
QgsProjectVersion::operator==
bool operator==(const QgsProjectVersion &other) const
Definition
qgsprojectversion.cpp:53
QgsProjectVersion::operator>=
bool operator>=(const QgsProjectVersion &other) const
Definition
qgsprojectversion.cpp:63
QgsProjectVersion::operator<=
bool operator<=(const QgsProjectVersion &other) const
Definition
qgsprojectversion.cpp:78
QgsProjectVersion::isNull
bool isNull() const
Returns true if this is a NULL project version.
Definition
qgsprojectversion.cpp:96
QgsProjectVersion::QgsProjectVersion
QgsProjectVersion()=default
Creates a new NULL version.
qgslogger.h
QgsDebugMsgLevel
#define QgsDebugMsgLevel(str, level)
Definition
qgslogger.h:80
qgsprojectversion.h
Generated on
for QGIS API Documentation by
1.17.0