20 #include <QtCore/qmath.h>
25 : mName( nam ), mType( typ ), mLength( len ), mPrecision( prec ), mNumeric( num )
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 )
49 return (( mName == other.mName ) && ( mType == other.mType )
50 && ( mLength == other.mLength ) && ( mPrecision == other.mPrecision ) );
55 return !( *
this == other );
123 return settings.value(
"qgis/nullValue",
"NULL" ).toString();
126 if ( mType == QVariant::Double && mPrecision > 0 )
127 return QString::number( v.toDouble(),
'f', mPrecision );
140 if ( mType == QVariant::Int && v.toInt() != v.toLongLong() )
142 v = QVariant( mType );
146 if ( !v.convert( mType ) )
148 v = QVariant( mType );
152 if ( mType == QVariant::Double && mPrecision > 0 )
154 double s = qPow( 10, mPrecision );
155 double d = v.toDouble() * s;
156 v = QVariant(( d < 0 ? ceil( d - 0.5 ) : floor( d + 0.5 ) ) / s );
160 if ( mType == QVariant::String && mLength > 0 && v.toString().length() > mLength )
162 v = v.toString().left( mLength );
203 if ( !
exists( fieldIdx ) )
212 for (
int i = 0; i < other.
count(); ++i )
220 if ( !
exists( fieldIdx ) )
223 return mFields[fieldIdx].origin;
229 for (
int i = 0; i <
mFields.count(); ++i )
230 lst.append(
mFields[i].field );
236 for (
int idx = 0; idx <
count(); ++idx )
238 if ( QString::compare(
mFields[idx].
field.
name(), fieldName, Qt::CaseInsensitive ) == 0 )
249 for (
int i = 0; i <
mFields.count(); ++i )