~ubuntu-branches/ubuntu/trusty/qgis/trusty

« back to all changes in this revision

Viewing changes to src/core/qgsfield.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
1
/***************************************************************************
2
 
    qgsfield.cpp - Describes a field in a layer or table
3
 
     --------------------------------------
4
 
    Date                 : 01-Jan-2004
5
 
    Copyright            : (C) 2004 by Gary E.Sherman
6
 
    email                : sherman at mrcc.com
7
 
    
 
2
       qgsfield.cpp - Describes a field in a layer or table
 
3
        --------------------------------------
 
4
       Date                 : 01-Jan-2004
 
5
       Copyright            : (C) 2004 by Gary E.Sherman
 
6
       email                : sherman at mrcc.com
 
7
 
8
8
 ***************************************************************************
9
9
 *                                                                         *
10
10
 *   This program is free software; you can redistribute it and/or modify  *
13
13
 *   (at your option) any later version.                                   *
14
14
 *                                                                         *
15
15
 ***************************************************************************/
16
 
/* $Id: qgsfield.cpp 5501 2006-06-01 10:33:19Z g_j_m $ */
 
16
/* $Id$ */
17
17
 
18
 
#include <iostream>
19
18
#include "qgsfield.h"
20
19
 
21
 
#include <qstring.h>
22
 
#include <iostream>
23
 
 
24
 
static const char * const ident_ = 
25
 
   "$Id: qgsfield.cpp 5501 2006-06-01 10:33:19Z g_j_m $";
26
 
 
27
 
 
28
 
QgsField::QgsField(QString nam, QString typ, int len, int prec, bool num)
29
 
    :mName(nam), mType(typ), mLength(len), mPrecision(prec), mNumeric(num)
 
20
static const char * const ident_ =
 
21
  "$Id$";
 
22
 
 
23
/*
 
24
QgsField::QgsField(QString nam, QString typ, int len, int prec, bool num,
 
25
                   QString comment)
 
26
    :mName(nam), mType(typ), mLength(len), mPrecision(prec), mNumeric(num),
 
27
     mComment(comment)
30
28
{
31
29
  // This function used to lower case the field name since some stores
32
30
  // use upper case (eg. shapefiles), but that caused problems with
33
31
  // attribute actions getting confused between uppercase and
34
32
  // lowercase versions of the attribute names, so just leave the
35
33
  // names how they are now.
 
34
}*/
 
35
 
 
36
QgsField::QgsField( QString name, QVariant::Type type, QString typeName, int len, int prec, QString comment )
 
37
    : mName( name ), mType( type ), mTypeName( typeName ),
 
38
    mLength( len ), mPrecision( prec ), mComment( comment )
 
39
{
36
40
}
37
41
 
 
42
 
38
43
QgsField::~QgsField()
39
44
{
40
45
}
41
46
 
42
 
bool QgsField::operator==(const QgsField other) const
43
 
{
44
 
    return ((mName == other.mName) && (mType == other.mType)
45
 
            && (mLength == other.mLength) && (mPrecision == other.mPrecision));
46
 
}
47
 
 
48
 
bool QgsField::operator!=(const QgsField other) const
49
 
{
50
 
    return !(*this == other);
51
 
}
52
 
 
53
 
QString const & QgsField::name() const
 
47
bool QgsField::operator==( const QgsField& other ) const
 
48
{
 
49
  return (( mName == other.mName ) && ( mType == other.mType ) && ( mTypeName == other.mTypeName )
 
50
          && ( mLength == other.mLength ) && ( mPrecision == other.mPrecision ) );
 
51
}
 
52
 
 
53
const QString & QgsField::name() const
54
54
{
55
55
  return mName;
56
56
}
57
57
 
58
 
QString const & QgsField::type() const
 
58
QVariant::Type QgsField::type() const
59
59
{
60
60
  return mType;
61
61
}
62
62
 
 
63
const QString & QgsField::typeName() const
 
64
{
 
65
  return mTypeName;
 
66
}
 
67
 
63
68
int QgsField::length() const
64
69
{
65
70
  return mLength;
70
75
  return mPrecision;
71
76
}
72
77
 
73
 
bool QgsField::isNumeric() const
 
78
const QString & QgsField::comment() const
74
79
{
75
 
  return mNumeric;
 
80
  return mComment;
76
81
}
77
82
 
78
 
void QgsField::setName(QString const & nam)
 
83
void QgsField::setName( const QString & nam )
79
84
{
80
85
  mName = nam;
81
86
}
82
87
 
83
 
void QgsField::setType(QString const & typ)
84
 
{
85
 
  mType = typ;
86
 
}
87
 
void QgsField::setLength(int len)
 
88
void QgsField::setType( QVariant::Type type )
 
89
{
 
90
  mType = type;
 
91
}
 
92
 
 
93
void QgsField::setTypeName( const QString & typeName )
 
94
{
 
95
  mTypeName = typeName;
 
96
}
 
97
 
 
98
void QgsField::setLength( int len )
88
99
{
89
100
  mLength = len;
90
101
}
91
 
void QgsField::setPrecision(int prec)
 
102
void QgsField::setPrecision( int prec )
92
103
{
93
104
  mPrecision = prec;
94
105
}
95
 
void QgsField::setNumeric(bool num)
 
106
 
 
107
void QgsField::setComment( const QString & comment )
96
108
{
97
 
  mNumeric = num;
 
109
  mComment = comment;
98
110
}