~ubuntu-branches/ubuntu/wily/qgis/wily

« back to all changes in this revision

Viewing changes to src/core/qgsprojectversion.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Johan Van de Wauw
  • Date: 2010-07-11 20:23:24 UTC
  • mfrom: (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100711202324-5ktghxa7hracohmr
Tags: 1.4.0+12730-3ubuntu1
* Merge from Debian unstable (LP: #540941).
* Fix compilation issues with QT 4.7
* Add build-depends on libqt4-webkit-dev 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
24
QgsProjectVersion::QgsProjectVersion( int major, int minor, int sub, QString name )
 
25
{
 
26
  mMajor = major;
 
27
  mMinor = minor;
 
28
  mSub   = sub;
 
29
  mName  = name;
 
30
}
 
31
 
 
32
QgsProjectVersion::QgsProjectVersion( QString string )
 
33
{
 
34
  QString pre = string.section( '-', 0, 0 );
 
35
 
 
36
  QStringList fileVersionParts = pre.section( "-", 0 ).split( "." );
 
37
 
 
38
  mMinor = 0;
 
39
  mSub   = 0;
 
40
  mName  = "";
 
41
  mMajor = fileVersionParts.at( 0 ).toInt();
 
42
 
 
43
  if ( fileVersionParts.size() > 1 )
 
44
  {
 
45
    mMinor = fileVersionParts.at( 1 ).toInt();
 
46
  }
 
47
  if ( fileVersionParts.size() > 2 )
 
48
  {
 
49
    mSub   = fileVersionParts.at( 2 ).toInt();
 
50
  }
 
51
  mName  = string.section( '-', 1 );
 
52
 
 
53
  QgsDebugMsg( QString( "Version is set to " ) + text() );
 
54
 
 
55
}
 
56
 
 
57
/*! Boolean equal operator
 
58
 */
 
59
bool QgsProjectVersion::operator==( const QgsProjectVersion &other )
 
60
{
 
61
  return (( mMajor == other.mMajor ) &&
 
62
          ( mMinor == other.mMinor ) &&
 
63
          ( mSub == other.mSub ) );
 
64
}
 
65
 
 
66
/*! Boolean >= operator
 
67
 */
 
68
bool QgsProjectVersion::operator>=( const QgsProjectVersion &other )
 
69
{
 
70
  return (( mMajor >= other.mMajor ) ||
 
71
          (( mMajor == other.mMajor ) && ( mMinor >= other.mMinor ) ) ||
 
72
          (( mMajor == other.mMajor ) && ( mMinor == other.mMinor ) && ( mSub >= other.mSub ) ) );
 
73
}
 
74
 
 
75
/*! Boolean > operator
 
76
 */
 
77
bool QgsProjectVersion::operator>( const QgsProjectVersion &other )
 
78
{
 
79
  return (( mMajor > other.mMajor ) ||
 
80
          (( mMajor == other.mMajor ) && ( mMinor > other.mMinor ) ) ||
 
81
          (( mMajor == other.mMajor ) && ( mMinor == other.mMinor ) && ( mSub > other.mSub ) ) );
 
82
}
 
83
 
 
84
QString QgsProjectVersion::text()
 
85
{
 
86
  if ( mName.isNull() )
 
87
  {
 
88
    return QString( "%1.%2.%3" ).arg( mMajor ).arg( mMinor ).arg( mSub );
 
89
  }
 
90
  else
 
91
  {
 
92
    return QString( "%1.%2.%3-%4" ).arg( mMajor ).arg( mMinor ).arg( mSub ).arg( mName );
 
93
  }
 
94
}