QgsVectorDataProvider API cleanup

This commit is contained in:
Matthias Kuhn 2016-10-21 12:49:45 +02:00
parent ec25df1565
commit 1445647065
22 changed files with 346 additions and 234 deletions

View File

@ -224,16 +224,24 @@ should now call QgsCoordinateReferenceSystem::invalidateCache() and QgsCoordinat
\subsection qgis_api_break_3_0_DataProviders Data Providers
<ul>
<li>Many methods in QgsDataProvider, QgsVectorDataProvider and QgsRasterDataProvider have been made const-correct.
This has no effect on PyQGIS code, but c++ code implementing third-party providers will need to update the
signatures of these methods to match. Affected methods are:
<ul>
<li>QgsDataProvider: crs(), extent(), isValid(), supportsSubsetString(), subsetString()</li>
<li>QgsVectorDataProvider: getFeatures(), minimumValue(), maximumValue(), uniqueValues(), enumValues(), defaultValue(),
attributeIndexes(), pkAttributeIndexes(), isSaveAndLoadStyleToDBSupported()</li>
<li>QgsRasterInterface: extent()</li>
</ul
</li>
<li>Many methods in QgsDataProvider, QgsVectorDataProvider and QgsRasterDataProvider have been made const-correct.
This has no effect on PyQGIS code, but c++ code implementing third-party providers will need to update the
signatures of these methods to match. Affected methods are:
<ul>
<li>QgsDataProvider: crs(), extent(), isValid(), supportsSubsetString(), subsetString()</li>
<li>QgsVectorDataProvider: getFeatures(), minimumValue(), maximumValue(), uniqueValues(), enumValues(), defaultValue(),
attributeIndexes(), pkAttributeIndexes(), isSaveAndLoadStyleToDBSupported()</li>
<li>QgsRasterInterface: extent()</li>
</ul>
</li>
<li>Many protected member variables have been wrapped in setter/getter methods.
This should generally only affect 3rd party providers
<ul>
<li>mCacheMinMaxDirty: use clearMinMaxCache()</li>
<li>mNativeTypes: use setNativeTypes()</li>
<li>mAttrPalIndexName: overwrite palAttributeIndexNames()</li>
</ul>
</li>
</ul>
\subsection qgis_api_break_3_0_Qgis Qgis

View File

@ -343,7 +343,6 @@ class QgsVectorDataProvider : QgsDataProvider
*/
QStringList errors() const;
/**
* It returns false by default.
* Must be implemented by providers that support saving and loading styles to db returning true
@ -381,24 +380,57 @@ class QgsVectorDataProvider : QgsDataProvider
virtual QList<QgsRelation> discoverRelations( const QgsVectorLayer* self, const QList<QgsVectorLayer*>& layers ) const;
signals:
/** Signals an error in this provider */
void raiseError( const QString& msg );
/**
* Signals an error in this provider
*
* @note Added const in QGIS 3.0
*/
void raiseError( const QString& msg ) const;
protected:
/**
* Invalidates the min/max cache. This will force the provider to recalculate the
* cache the next time it is requested.
*/
void clearMinMaxCache();
//! Populates the cache of minimum and maximum attribute values.
/**
* Populates the cache of minimum and maximum attribute values.
*/
void fillMinMaxCache() const;
/**
* Raises an error message from the provider.
* Push a notification about errors that happened in this providers scope.
* Errors should be translated strings that require the users immediate
* attention.
*
* For general debug information use QgsMessageLog::logMessage() instead.
*
* @note Added in QGIS 3.0
*/
void pushError( const QString& msg ) const;
/** Converts the geometry to the provider type if possible / necessary
@return the converted geometry or nullptr if no conversion was necessary or possible*/
/**
* Converts the geometry to the provider type if possible / necessary
* @return the converted geometry or nullptr if no conversion was necessary or possible
*/
QgsGeometry* convertToProviderType( const QgsGeometry& geom ) const /Factory/;
/**
* Set the list of native types supported by this provider.
* Usually done in the constructor.
*
* @note Added in QGIS 3.0
*/
void setNativeTypes(const QList<QgsVectorDataProvider::NativeType>& nativeTypes);
/**
* Get this providers encoding
*
* @note Added in QGIS 3.0
*/
QTextCodec* textEncoding() const;
};
QFlags<QgsVectorDataProvider::Capability> operator|(QgsVectorDataProvider::Capability f1, QFlags<QgsVectorDataProvider::Capability> f2);

View File

@ -19,7 +19,6 @@
#include "qgslogger.h"
#include "qgsmapcanvas.h"
#include "qgsrubberband.h"
#include "qgsvectordataprovider.h"
#include "qgsvectorlayer.h"
#include "qgstolerance.h"
#include "qgisapp.h"

View File

@ -19,7 +19,6 @@
#include "qgslogger.h"
#include "qgsmapcanvas.h"
#include "qgsrubberband.h"
#include "qgsvectordataprovider.h"
#include "qgsvectorlayer.h"
#include "qgstolerance.h"
#include "qgsvertexmarker.h"

View File

@ -36,7 +36,6 @@
QgsVectorDataProvider::QgsVectorDataProvider( const QString& uri )
: QgsDataProvider( uri )
, mCacheMinMaxDirty( true )
, mAttrPalIndexName( QgsAttrPalIndexNameHash() )
{
QSettings settings;
setEncoding( settings.value( "/UI/encoding", "System" ).toString() );
@ -280,35 +279,45 @@ QgsAttributeList QgsVectorDataProvider::attributeIndexes() const
return fields().allAttributesList();
}
QgsAttributeList QgsVectorDataProvider::pkAttributeIndexes() const
{
return QgsAttributeList();
}
const QList< QgsVectorDataProvider::NativeType > &QgsVectorDataProvider::nativeTypes() const
{
return mNativeTypes;
}
QgsAttrPalIndexNameHash QgsVectorDataProvider::palAttributeIndexNames() const
{
return QgsAttrPalIndexNameHash();
}
bool QgsVectorDataProvider::supportedType( const QgsField &field ) const
{
int i;
QgsDebugMsgLevel( QString( "field name = %1 type = %2 length = %3 precision = %4" )
.arg( field.name(),
QVariant::typeToName( field.type() ) )
.arg( field.length() )
.arg( field.precision() ), 2 );
for ( i = 0; i < mNativeTypes.size(); i++ )
Q_FOREACH ( const NativeType& nativeType, mNativeTypes )
{
QgsDebugMsgLevel( QString( "native field type = %1 min length = %2 max length = %3 min precision = %4 max precision = %5" )
.arg( QVariant::typeToName( mNativeTypes[i].mType ) )
.arg( mNativeTypes[i].mMinLen )
.arg( mNativeTypes[i].mMaxLen )
.arg( mNativeTypes[i].mMinPrec )
.arg( mNativeTypes[i].mMaxPrec ), 2 );
.arg( QVariant::typeToName( nativeType.mType ) )
.arg( nativeType.mMinLen )
.arg( nativeType.mMaxLen )
.arg( nativeType.mMinPrec )
.arg( nativeType.mMaxPrec ), 2 );
if ( field.type() != mNativeTypes[i].mType )
if ( field.type() != nativeType.mType )
continue;
if ( field.length() == -1 )
{
// source length unlimited
if ( mNativeTypes[i].mMinLen > -1 || mNativeTypes[i].mMaxLen > -1 )
if ( nativeType.mMinLen > -1 || nativeType.mMaxLen > -1 )
{
// destination limited
continue;
@ -317,8 +326,8 @@ bool QgsVectorDataProvider::supportedType( const QgsField &field ) const
else
{
// source length limited
if ( mNativeTypes[i].mMinLen > -1 && mNativeTypes[i].mMaxLen > -1 &&
( field.length() < mNativeTypes[i].mMinLen || field.length() > mNativeTypes[i].mMaxLen ) )
if ( nativeType.mMinLen > -1 && nativeType.mMaxLen > -1 &&
( field.length() < nativeType.mMinLen || field.length() > nativeType.mMaxLen ) )
{
// source length exceeds destination limits
continue;
@ -328,7 +337,7 @@ bool QgsVectorDataProvider::supportedType( const QgsField &field ) const
if ( field.precision() == -1 )
{
// source precision unlimited / n/a
if ( mNativeTypes[i].mMinPrec > -1 || mNativeTypes[i].mMaxPrec > -1 )
if ( nativeType.mMinPrec > -1 || nativeType.mMaxPrec > -1 )
{
// destination limited
continue;
@ -337,8 +346,8 @@ bool QgsVectorDataProvider::supportedType( const QgsField &field ) const
else
{
// source precision unlimited / n/a
if ( mNativeTypes[i].mMinPrec > -1 && mNativeTypes[i].mMaxPrec > -1 &&
( field.precision() < mNativeTypes[i].mMinPrec || field.precision() > mNativeTypes[i].mMaxPrec ) )
if ( nativeType.mMinPrec > -1 && nativeType.mMaxPrec > -1 &&
( field.precision() < nativeType.mMinPrec || field.precision() > nativeType.mMaxPrec ) )
{
// source precision exceeds destination limits
continue;
@ -523,6 +532,16 @@ QVariant QgsVectorDataProvider::convertValue( QVariant::Type type, const QString
return v;
}
QgsTransaction* QgsVectorDataProvider::transaction() const
{
return nullptr;
}
void QgsVectorDataProvider::forceReload()
{
emit dataChanged();
}
static bool _compareEncodings( const QString& s1, const QString& s2 )
{
return s1.toLower() < s2.toLower();
@ -606,6 +625,11 @@ QStringList QgsVectorDataProvider::errors() const
return mErrors;
}
bool QgsVectorDataProvider::isSaveAndLoadStyleToDBSupported() const
{
return false;
}
void QgsVectorDataProvider::pushError( const QString& msg ) const
{
QgsDebugMsg( msg );
@ -717,6 +741,16 @@ QgsGeometry* QgsVectorDataProvider::convertToProviderType( const QgsGeometry& ge
return nullptr;
}
void QgsVectorDataProvider::setNativeTypes( const QList<NativeType>& nativeTypes )
{
mNativeTypes = nativeTypes;
}
QTextCodec* QgsVectorDataProvider::textEncoding() const
{
return mEncoding;
}
QStringList QgsVectorDataProvider::smEncodings;
QList<QgsRelation> QgsVectorDataProvider::discoverRelations( const QgsVectorLayer*, const QList<QgsVectorLayer*>& ) const

View File

@ -339,12 +339,12 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
/**
* Return list of indexes of fields that make up the primary key
*/
virtual QgsAttributeList pkAttributeIndexes() const { return QgsAttributeList(); }
virtual QgsAttributeList pkAttributeIndexes() const;
/**
* Return list of indexes to names for QgsPalLabeling fix
*/
virtual QgsAttrPalIndexNameHash palAttributeIndexNames() const { return mAttrPalIndexName; }
virtual QgsAttrPalIndexNameHash palAttributeIndexNames() const;
/**
* check if provider supports type of field
@ -403,19 +403,18 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
*/
QStringList errors() const;
/**
* It returns false by default.
* Must be implemented by providers that support saving and loading styles to db returning true
*/
virtual bool isSaveAndLoadStyleToDBSupported() const { return false; }
virtual bool isSaveAndLoadStyleToDBSupported() const;
static QVariant convertValue( QVariant::Type type, const QString& value );
/**
* Returns the transaction this data provider is included in, if any.
*/
virtual QgsTransaction* transaction() const { return nullptr; }
virtual QgsTransaction* transaction() const;
/**
* Forces a reload of the underlying datasource if the provider implements this
@ -424,10 +423,7 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
* This forces QGIS to reopen a file or connection.
* This can be required if the underlying file is replaced.
*/
virtual void forceReload()
{
emit dataChanged();
}
virtual void forceReload();
/**
* Get the list of layer ids on which this layer depends. This in particular determines the order of layer loading.
@ -444,15 +440,58 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
virtual QList<QgsRelation> discoverRelations( const QgsVectorLayer* self, const QList<QgsVectorLayer*>& layers ) const;
signals:
/** Signals an error in this provider */
/**
* Signals an error in this provider
*
* @note Added const in QGIS 3.0
*/
void raiseError( const QString& msg ) const;
protected:
/**
* Invalidates the min/max cache. This will force the provider to recalculate the
* cache the next time it is requested.
*/
void clearMinMaxCache();
//! Populates the cache of minimum and maximum attribute values.
/**
* Populates the cache of minimum and maximum attribute values.
*/
void fillMinMaxCache() const;
/**
* Push a notification about errors that happened in this providers scope.
* Errors should be translated strings that require the users immediate
* attention.
*
* For general debug information use QgsMessageLog::logMessage() instead.
*
* @note Added in QGIS 3.0
*/
void pushError( const QString& msg ) const;
/**
* Converts the geometry to the provider type if possible / necessary
* @return the converted geometry or nullptr if no conversion was necessary or possible
*/
QgsGeometry* convertToProviderType( const QgsGeometry& geom ) const;
/**
* Set the list of native types supported by this provider.
* Usually done in the constructor.
*
* @note Added in QGIS 3.0
*/
void setNativeTypes( const QList<NativeType>& nativeTypes );
/**
* Get this providers encoding
*
* @note Added in QGIS 3.0
*/
QTextCodec* textEncoding() const;
private:
mutable bool mCacheMinMaxDirty;
mutable QMap<int, QVariant> mCacheMinValues, mCacheMaxValues;
@ -465,19 +504,6 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
/** The names of the providers native types*/
QList< NativeType > mNativeTypes;
/**
* Raises an error message from the provider.
*/
void pushError( const QString& msg ) const;
/** Old-style mapping of index to name for QgsPalLabeling fix */
QgsAttrPalIndexNameHash mAttrPalIndexName;
/** Converts the geometry to the provider type if possible / necessary
@return the converted geometry or nullptr if no conversion was necessary or possible*/
QgsGeometry* convertToProviderType( const QgsGeometry& geom ) const;
private:
/** Old notation **/
QMap<QString, QVariant::Type> mOldTypeList;

View File

@ -110,30 +110,30 @@ QgsDb2Provider::QgsDb2Provider( QString uri )
}
//fill type names into sets
mNativeTypes
// integer types
<< QgsVectorDataProvider::NativeType( tr( "8 Bytes integer" ), "bigint", QVariant::Int )
<< QgsVectorDataProvider::NativeType( tr( "4 Bytes integer" ), "integer", QVariant::Int )
<< QgsVectorDataProvider::NativeType( tr( "2 Bytes integer" ), "smallint", QVariant::Int )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (numeric)" ), "numeric", QVariant::Double, 1, 31, 0, 31 )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (decimal)" ), "decimal", QVariant::Double, 1, 31, 0, 31 )
setNativeTypes( QList< NativeType >()
// integer types
<< QgsVectorDataProvider::NativeType( tr( "8 Bytes integer" ), "bigint", QVariant::Int )
<< QgsVectorDataProvider::NativeType( tr( "4 Bytes integer" ), "integer", QVariant::Int )
<< QgsVectorDataProvider::NativeType( tr( "2 Bytes integer" ), "smallint", QVariant::Int )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (numeric)" ), "numeric", QVariant::Double, 1, 31, 0, 31 )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (decimal)" ), "decimal", QVariant::Double, 1, 31, 0, 31 )
// floating point
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (real)" ), "real", QVariant::Double )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (double)" ), "double", QVariant::Double )
// floating point
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (real)" ), "real", QVariant::Double )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (double)" ), "double", QVariant::Double )
// date/time types
<< QgsVectorDataProvider::NativeType( tr( "Date" ), "date", QVariant::Date, -1, -1, -1, -1 )
<< QgsVectorDataProvider::NativeType( tr( "Time" ), "time", QVariant::Time, -1, -1, -1, -1 )
<< QgsVectorDataProvider::NativeType( tr( "Date & Time" ), "datetime", QVariant::DateTime, -1, -1, -1, -1 )
// date/time types
<< QgsVectorDataProvider::NativeType( tr( "Date" ), "date", QVariant::Date, -1, -1, -1, -1 )
<< QgsVectorDataProvider::NativeType( tr( "Time" ), "time", QVariant::Time, -1, -1, -1, -1 )
<< QgsVectorDataProvider::NativeType( tr( "Date & Time" ), "datetime", QVariant::DateTime, -1, -1, -1, -1 )
// string types
<< QgsVectorDataProvider::NativeType( tr( "Text, fixed length (char)" ), "char", QVariant::String, 1, 254 )
<< QgsVectorDataProvider::NativeType( tr( "Text, variable length (varchar)" ), "varchar", QVariant::String, 1, 32704 )
<< QgsVectorDataProvider::NativeType( tr( "Text, variable length large object (clob)" ), "clob", QVariant::String, 1, 2147483647 )
//DBCLOB is for 1073741824 double-byte characters, data length should be the same as CLOB (2147483647)?
<< QgsVectorDataProvider::NativeType( tr( "Text, variable length large object (dbclob)" ), "dbclob", QVariant::String, 1, 1073741824 )
;
// string types
<< QgsVectorDataProvider::NativeType( tr( "Text, fixed length (char)" ), "char", QVariant::String, 1, 254 )
<< QgsVectorDataProvider::NativeType( tr( "Text, variable length (varchar)" ), "varchar", QVariant::String, 1, 32704 )
<< QgsVectorDataProvider::NativeType( tr( "Text, variable length large object (clob)" ), "clob", QVariant::String, 1, 2147483647 )
//DBCLOB is for 1073741824 double-byte characters, data length should be the same as CLOB (2147483647)?
<< QgsVectorDataProvider::NativeType( tr( "Text, variable length large object (dbclob)" ), "dbclob", QVariant::String, 1, 1073741824 )
);
}
QgsDb2Provider::~QgsDb2Provider()

View File

@ -83,12 +83,12 @@ QgsDelimitedTextProvider::QgsDelimitedTextProvider( const QString& uri )
{
// Add supported types to enable creating expression fields in field calculator
mNativeTypes
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer)" ), "integer", QVariant::Int, 0, 10 )
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer - 64 bit)" ), "int8", QVariant::LongLong )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (double)" ), "double precision", QVariant::Double, -1, -1, -1, -1 )
<< QgsVectorDataProvider::NativeType( tr( "Text, unlimited length (text)" ), "text", QVariant::String, -1, -1, -1, -1 )
;
setNativeTypes( QList< NativeType >()
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer)" ), "integer", QVariant::Int, 0, 10 )
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer - 64 bit)" ), "int8", QVariant::LongLong )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (double)" ), "double precision", QVariant::Double, -1, -1, -1, -1 )
<< QgsVectorDataProvider::NativeType( tr( "Text, unlimited length (text)" ), "text", QVariant::String, -1, -1, -1, -1 )
);
QgsDebugMsg( "Delimited text file uri is " + uri );
@ -1076,7 +1076,7 @@ bool QgsDelimitedTextProvider::setSubsetString( const QString& subset, bool upda
}
}
mCacheMinMaxDirty = true;
clearMinMaxCache();
emit dataChanged();
return valid;
}

View File

@ -74,7 +74,7 @@ QgsGPXProvider::QgsGPXProvider( const QString& uri )
, mValid( false ) // assume that it won't work
{
// we always use UTF-8
mEncoding = QTextCodec::codecForName( "utf8" );
setEncoding( "utf8" );
// get the file name and the type parameter from the URI
int fileNameEnd = uri.indexOf( '?' );

View File

@ -757,7 +757,7 @@ QgsGrassFeatureSource::QgsGrassFeatureSource( const QgsGrassProvider* p )
, mGrassType( p->mGrassType )
, mQgisType( p->mQgisType )
, mFields( p->fields() )
, mEncoding( p->mEncoding )
, mEncoding( p->textEncoding() )
, mEditing( p->mEditBuffer )
{
Q_ASSERT( mLayer );

View File

@ -261,16 +261,17 @@ QgsGrassProvider::QgsGrassProvider( QString uri )
connect( mLayer->map(), SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
// TODO: types according to database
mNativeTypes
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer)" ), "integer", QVariant::Int, -1, -1, -1, -1 )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (real)" ), "double precision", QVariant::Double, -1, -1, -1, -1 )
setNativeTypes( QList<NativeType>()
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer)" ), "integer", QVariant::Int, -1, -1, -1, -1 )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (real)" ), "double precision", QVariant::Double, -1, -1, -1, -1 )
#if GRASS_VERSION_MAJOR < 7
<< QgsVectorDataProvider::NativeType( tr( "Text, limited variable length (varchar)" ), "varchar", QVariant::String, 1, 255, -1, -1 );
<< QgsVectorDataProvider::NativeType( tr( "Text, limited variable length (varchar)" ), "varchar", QVariant::String, 1, 255, -1, -1 )
#else
<< QgsVectorDataProvider::NativeType( tr( "Text" ), "text", QVariant::String );
<< QgsVectorDataProvider::NativeType( tr( "Text" ), "text", QVariant::String )
#endif
// TODO:
// << QgsVectorDataProvider::NativeType( tr( "Date" ), "date", QVariant::Date, 8, 8 );
// TODO:
// << QgsVectorDataProvider::NativeType( tr( "Date" ), "date", QVariant::Date, 8, 8 );
);
mValid = true;
@ -1020,7 +1021,7 @@ QgsAttributeMap *QgsGrassProvider::attributes( int field, int cat )
dbColumn *column = db_get_table_column( databaseTable, i );
db_convert_column_value_to_string( column, &dbstr );
QString v = mEncoding->toUnicode( db_get_string( &dbstr ) );
QString v = textEncoding()->toUnicode( db_get_string( &dbstr ) );
QgsDebugMsg( QString( "Value: %1" ).arg( v ) );
att->insert( i, QVariant( v ) );
}

View File

@ -64,36 +64,36 @@ QgsMemoryProvider::QgsMemoryProvider( const QString& uri )
mNextFeatureId = 1;
mNativeTypes
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer)" ), "integer", QVariant::Int, 0, 10 )
// Decimal number from OGR/Shapefile/dbf may come with length up to 32 and
// precision up to length-2 = 30 (default, if width is not specified in dbf is length = 24 precision = 15)
// We know that double (QVariant::Double) has only 15-16 significant numbers,
// but setting that correct limits would disable the use of memory provider with
// data from Shapefiles. In any case, the data are handled as doubles.
// So the limits set here are not correct but enable use of data from Shapefiles.
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (real)" ), "double", QVariant::Double, 0, 32, 0, 30 )
<< QgsVectorDataProvider::NativeType( tr( "Text (string)" ), "string", QVariant::String, 0, 255 )
setNativeTypes( QList< NativeType >()
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer)" ), "integer", QVariant::Int, 0, 10 )
// Decimal number from OGR/Shapefile/dbf may come with length up to 32 and
// precision up to length-2 = 30 (default, if width is not specified in dbf is length = 24 precision = 15)
// We know that double (QVariant::Double) has only 15-16 significant numbers,
// but setting that correct limits would disable the use of memory provider with
// data from Shapefiles. In any case, the data are handled as doubles.
// So the limits set here are not correct but enable use of data from Shapefiles.
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (real)" ), "double", QVariant::Double, 0, 32, 0, 30 )
<< QgsVectorDataProvider::NativeType( tr( "Text (string)" ), "string", QVariant::String, 0, 255 )
// date type
<< QgsVectorDataProvider::NativeType( tr( "Date" ), "date", QVariant::Date, -1, -1, -1, -1 )
<< QgsVectorDataProvider::NativeType( tr( "Time" ), "time", QVariant::Time, -1, -1, -1, -1 )
<< QgsVectorDataProvider::NativeType( tr( "Date & Time" ), "datetime", QVariant::DateTime, -1, -1, -1, -1 )
// date type
<< QgsVectorDataProvider::NativeType( tr( "Date" ), "date", QVariant::Date, -1, -1, -1, -1 )
<< QgsVectorDataProvider::NativeType( tr( "Time" ), "time", QVariant::Time, -1, -1, -1, -1 )
<< QgsVectorDataProvider::NativeType( tr( "Date & Time" ), "datetime", QVariant::DateTime, -1, -1, -1, -1 )
// integer types
<< QgsVectorDataProvider::NativeType( tr( "Whole number (smallint - 16bit)" ), "int2", QVariant::Int, -1, -1, 0, 0 )
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer - 32bit)" ), "int4", QVariant::Int, -1, -1, 0, 0 )
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer - 64bit)" ), "int8", QVariant::LongLong, -1, -1, 0, 0 )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (numeric)" ), "numeric", QVariant::Double, 1, 20, 0, 20 )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (decimal)" ), "decimal", QVariant::Double, 1, 20, 0, 20 )
// integer types
<< QgsVectorDataProvider::NativeType( tr( "Whole number (smallint - 16bit)" ), "int2", QVariant::Int, -1, -1, 0, 0 )
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer - 32bit)" ), "int4", QVariant::Int, -1, -1, 0, 0 )
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer - 64bit)" ), "int8", QVariant::LongLong, -1, -1, 0, 0 )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (numeric)" ), "numeric", QVariant::Double, 1, 20, 0, 20 )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (decimal)" ), "decimal", QVariant::Double, 1, 20, 0, 20 )
// floating point
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (real)" ), "real", QVariant::Double, -1, -1, -1, -1 )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (double)" ), "double precision", QVariant::Double, -1, -1, -1, -1 )
// floating point
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (real)" ), "real", QVariant::Double, -1, -1, -1, -1 )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (double)" ), "double precision", QVariant::Double, -1, -1, -1, -1 )
// string types
<< QgsVectorDataProvider::NativeType( tr( "Text, unlimited length (text)" ), "text", QVariant::String, -1, -1, -1, -1 )
;
// string types
<< QgsVectorDataProvider::NativeType( tr( "Text, unlimited length (text)" ), "text", QVariant::String, -1, -1, -1, -1 )
);
if ( url.hasQueryItem( "field" ) )
{
@ -477,7 +477,7 @@ bool QgsMemoryProvider::setSubsetString( const QString& theSQL, bool updateFeatu
}
mSubsetString = theSQL;
mCacheMinMaxDirty = true;
clearMinMaxCache();
emit dataChanged();
return true;

View File

@ -147,32 +147,32 @@ QgsMssqlProvider::QgsMssqlProvider( const QString& uri )
}
//fill type names into sets
mNativeTypes
// integer types
<< QgsVectorDataProvider::NativeType( tr( "8 Bytes integer" ), "bigint", QVariant::Int )
<< QgsVectorDataProvider::NativeType( tr( "4 Bytes integer" ), "int", QVariant::Int )
<< QgsVectorDataProvider::NativeType( tr( "2 Bytes integer" ), "smallint", QVariant::Int )
<< QgsVectorDataProvider::NativeType( tr( "1 Bytes integer" ), "tinyint", QVariant::Int )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (numeric)" ), "numeric", QVariant::Double, 1, 20, 0, 20 )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (decimal)" ), "decimal", QVariant::Double, 1, 20, 0, 20 )
setNativeTypes( QList<NativeType>()
// integer types
<< QgsVectorDataProvider::NativeType( tr( "8 Bytes integer" ), "bigint", QVariant::Int )
<< QgsVectorDataProvider::NativeType( tr( "4 Bytes integer" ), "int", QVariant::Int )
<< QgsVectorDataProvider::NativeType( tr( "2 Bytes integer" ), "smallint", QVariant::Int )
<< QgsVectorDataProvider::NativeType( tr( "1 Bytes integer" ), "tinyint", QVariant::Int )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (numeric)" ), "numeric", QVariant::Double, 1, 20, 0, 20 )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (decimal)" ), "decimal", QVariant::Double, 1, 20, 0, 20 )
// floating point
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (real)" ), "real", QVariant::Double )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (double)" ), "float", QVariant::Double )
// floating point
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (real)" ), "real", QVariant::Double )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (double)" ), "float", QVariant::Double )
// date/time types
<< QgsVectorDataProvider::NativeType( tr( "Date" ), "date", QVariant::Date, -1, -1, -1, -1 )
<< QgsVectorDataProvider::NativeType( tr( "Time" ), "time", QVariant::Time, -1, -1, -1, -1 )
<< QgsVectorDataProvider::NativeType( tr( "Date & Time" ), "datetime", QVariant::DateTime, -1, -1, -1, -1 )
// date/time types
<< QgsVectorDataProvider::NativeType( tr( "Date" ), "date", QVariant::Date, -1, -1, -1, -1 )
<< QgsVectorDataProvider::NativeType( tr( "Time" ), "time", QVariant::Time, -1, -1, -1, -1 )
<< QgsVectorDataProvider::NativeType( tr( "Date & Time" ), "datetime", QVariant::DateTime, -1, -1, -1, -1 )
// string types
<< QgsVectorDataProvider::NativeType( tr( "Text, fixed length (char)" ), "char", QVariant::String, 1, 255 )
<< QgsVectorDataProvider::NativeType( tr( "Text, limited variable length (varchar)" ), "varchar", QVariant::String, 1, 255 )
<< QgsVectorDataProvider::NativeType( tr( "Text, fixed length unicode (nchar)" ), "nchar", QVariant::String, 1, 255 )
<< QgsVectorDataProvider::NativeType( tr( "Text, limited variable length unicode (nvarchar)" ), "nvarchar", QVariant::String, 1, 255 )
<< QgsVectorDataProvider::NativeType( tr( "Text, unlimited length (text)" ), "text", QVariant::String )
<< QgsVectorDataProvider::NativeType( tr( "Text, unlimited length unicode (ntext)" ), "text", QVariant::String )
;
// string types
<< QgsVectorDataProvider::NativeType( tr( "Text, fixed length (char)" ), "char", QVariant::String, 1, 255 )
<< QgsVectorDataProvider::NativeType( tr( "Text, limited variable length (varchar)" ), "varchar", QVariant::String, 1, 255 )
<< QgsVectorDataProvider::NativeType( tr( "Text, fixed length unicode (nchar)" ), "nchar", QVariant::String, 1, 255 )
<< QgsVectorDataProvider::NativeType( tr( "Text, limited variable length unicode (nvarchar)" ), "nvarchar", QVariant::String, 1, 255 )
<< QgsVectorDataProvider::NativeType( tr( "Text, unlimited length (text)" ), "text", QVariant::String )
<< QgsVectorDataProvider::NativeType( tr( "Text, unlimited length unicode (ntext)" ), "text", QVariant::String )
);
}
QgsMssqlProvider::~QgsMssqlProvider()

View File

@ -358,7 +358,7 @@ QgsOgrFeatureSource::QgsOgrFeatureSource( const QgsOgrProvider* p )
mLayerName = p->layerName();
mLayerIndex = p->layerIndex();
mSubsetString = p->mSubsetString;
mEncoding = p->mEncoding; // no copying - this is a borrowed pointer from Qt
mEncoding = p->textEncoding(); // no copying - this is a borrowed pointer from Qt
mFields = p->mAttributeFields;
for ( int i = ( p->mFirstFieldIsFid ) ? 1 : 0; i < mFields.size(); i++ )
mFieldsWithoutFid.append( mFields.at( i ) );

View File

@ -372,22 +372,24 @@ QgsOgrProvider::QgsOgrProvider( QString const & uri )
open( OpenModeInitial );
mNativeTypes
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer)" ), "integer", QVariant::Int, 1, 10 )
setNativeTypes( QList<NativeType>()
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer)" ), "integer", QVariant::Int, 1, 10 )
#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 2000000
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer 64 bit)" ), "integer64", QVariant::LongLong, 1, 10 )
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer 64 bit)" ), "integer64", QVariant::LongLong, 1, 10 )
#endif
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (real)" ), "double", QVariant::Double, 1, 20, 0, 15 )
<< QgsVectorDataProvider::NativeType( tr( "Text (string)" ), "string", QVariant::String, 1, 255 )
<< QgsVectorDataProvider::NativeType( tr( "Date" ), "date", QVariant::Date, 8, 8 );
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (real)" ), "double", QVariant::Double, 1, 20, 0, 15 )
<< QgsVectorDataProvider::NativeType( tr( "Text (string)" ), "string", QVariant::String, 1, 255 )
<< QgsVectorDataProvider::NativeType( tr( "Date" ), "date", QVariant::Date, 8, 8 )
);
// Some drivers do not support datetime type
// Please help to fill this list
if ( ogrDriverName != "ESRI Shapefile" )
{
mNativeTypes
<< QgsVectorDataProvider::NativeType( tr( "Time" ), "time", QVariant::Time, -1, -1 )
<< QgsVectorDataProvider::NativeType( tr( "Date & Time" ), "datetime", QVariant::DateTime );
setNativeTypes( QList<NativeType>()
<< QgsVectorDataProvider::NativeType( tr( "Time" ), "time", QVariant::Time, -1, -1 )
<< QgsVectorDataProvider::NativeType( tr( "Date & Time" ), "datetime", QVariant::DateTime )
);
}
QgsOgrConnPool::instance()->ref( dataSourceUri() );
@ -866,7 +868,7 @@ void QgsOgrProvider::loadFields()
#ifdef ANDROID
QString name = OGR_Fld_GetNameRef( fldDef );
#else
QString name = mEncoding->toUnicode( OGR_Fld_GetNameRef( fldDef ) );
QString name = textEncoding()->toUnicode( OGR_Fld_GetNameRef( fldDef ) );
#endif
if ( mAttributeFields.indexFromName( name ) != -1 )
@ -893,7 +895,7 @@ void QgsOgrProvider::loadFields()
#ifdef ANDROID
OGR_GetFieldTypeName( ogrType ),
#else
mEncoding->toUnicode( OGR_GetFieldTypeName( ogrType ) ),
textEncoding()->toUnicode( OGR_GetFieldTypeName( ogrType ) ),
#endif
width, prec
)
@ -1229,8 +1231,8 @@ bool QgsOgrProvider::addFeature( QgsFeature& f )
QgsDebugMsg( QString( "Writing string attribute %1 with %2, encoding %3" )
.arg( qgisAttId )
.arg( attrVal.toString(),
mEncoding->name().constData() ) );
OGR_F_SetFieldString( feature, ogrAttId, mEncoding->fromUnicode( attrVal.toString() ).constData() );
textEncoding()->name().data() ) );
OGR_F_SetFieldString( feature, ogrAttId, textEncoding()->fromUnicode( attrVal.toString() ).constData() );
break;
default:
@ -1353,7 +1355,7 @@ bool QgsOgrProvider::addAttributes( const QList<QgsField> &attributes )
continue;
}
OGRFieldDefnH fielddefn = OGR_Fld_Create( mEncoding->fromUnicode( iter->name() ).constData(), type );
OGRFieldDefnH fielddefn = OGR_Fld_Create( textEncoding()->fromUnicode( iter->name() ).constData(), type );
int width = iter->length();
if ( iter->precision() )
width += 1;
@ -1458,7 +1460,7 @@ bool QgsOgrProvider::renameAttributes( const QgsFieldNameMap& renamedAttributes
}
//type does not matter, it will not be used
OGRFieldDefnH fld = OGR_Fld_Create( mEncoding->fromUnicode( renameIt.value() ), OFTReal );
OGRFieldDefnH fld = OGR_Fld_Create( textEncoding()->fromUnicode( renameIt.value() ), OFTReal );
if ( OGR_L_AlterFieldDefn( ogrLayer, ogrFieldIndex, fld, ALTER_NAME_FLAG ) != OGRERR_NONE )
{
pushError( tr( "OGR error renaming field %1: %2" ).arg( fieldIndex ).arg( CPLGetLastErrorMsg() ) );
@ -1586,7 +1588,7 @@ bool QgsOgrProvider::changeAttributeValues( const QgsChangedAttributesMap &attr_
0 );
break;
case OFTString:
OGR_F_SetFieldString( of, f, mEncoding->fromUnicode( it2->toString() ).constData() );
OGR_F_SetFieldString( of, f, textEncoding()->fromUnicode( it2->toString() ).constData() );
break;
default:
pushError( tr( "Type %1 of attribute %2 of feature %3 unknown." ).arg( type ).arg( fid ).arg( f ) );
@ -1720,7 +1722,7 @@ bool QgsOgrProvider::createAttributeIndex( int field )
QByteArray quotedLayerName = quotedIdentifier( OGR_FD_GetName( OGR_L_GetLayerDefn( ogrOrigLayer ) ) );
QByteArray dropSql = "DROP INDEX ON " + quotedLayerName;
OGR_DS_ExecuteSQL( ogrDataSource, dropSql.constData(), OGR_L_GetSpatialFilter( ogrOrigLayer ), nullptr );
QByteArray createSql = "CREATE INDEX ON " + quotedLayerName + " USING " + mEncoding->fromUnicode( fields().at( field ).name() );
QByteArray createSql = "CREATE INDEX ON " + quotedLayerName + " USING " + textEncoding()->fromUnicode( fields().at( field ).name() );
OGR_DS_ExecuteSQL( ogrDataSource, createSql.constData(), OGR_L_GetSpatialFilter( ogrOrigLayer ), nullptr );
QFileInfo fi( mFilePath ); // to get the base name
@ -2792,17 +2794,17 @@ void QgsOgrProvider::uniqueValues( int index, QList<QVariant> &uniqueValues, int
// avoid GDAL #4509
return QgsVectorDataProvider::uniqueValues( index, uniqueValues, limit );
#else
QByteArray sql = "SELECT DISTINCT " + quotedIdentifier( mEncoding->fromUnicode( fld.name() ) );
QByteArray sql = "SELECT DISTINCT " + quotedIdentifier( textEncoding()->fromUnicode( fld.name() ) );
sql += " FROM " + quotedIdentifier( OGR_FD_GetName( OGR_L_GetLayerDefn( ogrLayer ) ) );
if ( !mSubsetString.isEmpty() )
{
sql += " WHERE " + mEncoding->fromUnicode( mSubsetString );
sql += " WHERE " + textEncoding()->fromUnicode( mSubsetString );
}
sql += " ORDER BY " + mEncoding->fromUnicode( fld.name() ) + " ASC"; // quoting of fieldname produces a syntax error
sql += " ORDER BY " + textEncoding()->fromUnicode( fld.name() ) + " ASC"; // quoting of fieldname produces a syntax error
QgsDebugMsg( QString( "SQL: %1" ).arg( mEncoding->toUnicode( sql ) ) );
QgsDebugMsg( QString( "SQL: %1" ).arg( textEncoding()->toUnicode( sql ) ) );
OGRLayerH l = OGR_DS_ExecuteSQL( ogrDataSource, sql.constData(), nullptr, nullptr );
if ( !l )
{
@ -2813,7 +2815,7 @@ void QgsOgrProvider::uniqueValues( int index, QList<QVariant> &uniqueValues, int
OGRFeatureH f;
while (( f = OGR_L_GetNextFeature( l ) ) )
{
uniqueValues << ( OGR_F_IsFieldSet( f, 0 ) ? convertValue( fld.type(), mEncoding->toUnicode( OGR_F_GetFieldAsString( f, 0 ) ) ) : QVariant( fld.type() ) );
uniqueValues << ( OGR_F_IsFieldSet( f, 0 ) ? convertValue( fld.type(), textEncoding()->toUnicode( OGR_F_GetFieldAsString( f, 0 ) ) ) : QVariant( fld.type() ) );
OGR_F_Destroy( f );
if ( limit >= 0 && uniqueValues.size() >= limit )
@ -2833,18 +2835,18 @@ QVariant QgsOgrProvider::minimumValue( int index ) const
QgsField fld = mAttributeFields.at( index );
// Don't quote column name (see https://trac.osgeo.org/gdal/ticket/5799#comment:9)
QByteArray sql = "SELECT MIN(" + mEncoding->fromUnicode( fld.name() );
QByteArray sql = "SELECT MIN(" + textEncoding()->fromUnicode( fld.name() );
sql += ") FROM " + quotedIdentifier( OGR_FD_GetName( OGR_L_GetLayerDefn( ogrLayer ) ) );
if ( !mSubsetString.isEmpty() )
{
sql += " WHERE " + mEncoding->fromUnicode( mSubsetString );
sql += " WHERE " + textEncoding()->fromUnicode( mSubsetString );
}
OGRLayerH l = OGR_DS_ExecuteSQL( ogrDataSource, sql.constData(), nullptr, nullptr );
if ( !l )
{
QgsDebugMsg( QString( "Failed to execute SQL: %1" ).arg( mEncoding->toUnicode( sql ) ) );
QgsDebugMsg( QString( "Failed to execute SQL: %1" ).arg( textEncoding()->toUnicode( sql ) ) );
return QgsVectorDataProvider::minimumValue( index );
}
@ -2855,7 +2857,7 @@ QVariant QgsOgrProvider::minimumValue( int index ) const
return QVariant();
}
QVariant value = OGR_F_IsFieldSet( f, 0 ) ? convertValue( fld.type(), mEncoding->toUnicode( OGR_F_GetFieldAsString( f, 0 ) ) ) : QVariant( fld.type() );
QVariant value = OGR_F_IsFieldSet( f, 0 ) ? convertValue( fld.type(), textEncoding()->toUnicode( OGR_F_GetFieldAsString( f, 0 ) ) ) : QVariant( fld.type() );
OGR_F_Destroy( f );
OGR_DS_ReleaseResultSet( ogrDataSource, l );
@ -2872,18 +2874,18 @@ QVariant QgsOgrProvider::maximumValue( int index ) const
QgsField fld = mAttributeFields.at( index );
// Don't quote column name (see https://trac.osgeo.org/gdal/ticket/5799#comment:9)
QByteArray sql = "SELECT MAX(" + mEncoding->fromUnicode( fld.name() );
QByteArray sql = "SELECT MAX(" + textEncoding()->fromUnicode( fld.name() );
sql += ") FROM " + quotedIdentifier( OGR_FD_GetName( OGR_L_GetLayerDefn( ogrLayer ) ) );
if ( !mSubsetString.isEmpty() )
{
sql += " WHERE " + mEncoding->fromUnicode( mSubsetString );
sql += " WHERE " + textEncoding()->fromUnicode( mSubsetString );
}
OGRLayerH l = OGR_DS_ExecuteSQL( ogrDataSource, sql.constData(), nullptr, nullptr );
if ( !l )
{
QgsDebugMsg( QString( "Failed to execute SQL: %1" ).arg( mEncoding->toUnicode( sql ) ) );
QgsDebugMsg( QString( "Failed to execute SQL: %1" ).arg( textEncoding()->toUnicode( sql ) ) );
return QgsVectorDataProvider::maximumValue( index );
}
@ -2894,7 +2896,7 @@ QVariant QgsOgrProvider::maximumValue( int index ) const
return QVariant();
}
QVariant value = OGR_F_IsFieldSet( f, 0 ) ? convertValue( fld.type(), mEncoding->toUnicode( OGR_F_GetFieldAsString( f, 0 ) ) ) : QVariant( fld.type() );
QVariant value = OGR_F_IsFieldSet( f, 0 ) ? convertValue( fld.type(), textEncoding()->toUnicode( OGR_F_GetFieldAsString( f, 0 ) ) ) : QVariant( fld.type() );
OGR_F_Destroy( f );
OGR_DS_ReleaseResultSet( ogrDataSource, l );
@ -3230,7 +3232,7 @@ OGRwkbGeometryType QgsOgrProvider::ogrWkbSingleFlatten( OGRwkbGeometryType type
OGRLayerH QgsOgrProvider::setSubsetString( OGRLayerH layer, OGRDataSourceH ds )
{
return QgsOgrProviderUtils::setSubsetString( layer, ds, mEncoding, mSubsetString );
return QgsOgrProviderUtils::setSubsetString( layer, ds, textEncoding(), mSubsetString );
}
OGRLayerH QgsOgrProviderUtils::setSubsetString( OGRLayerH layer, OGRDataSourceH ds, QTextCodec* encoding, const QString& subsetString )

View File

@ -250,8 +250,6 @@ class QgsOgrProvider : public QgsVectorDataProvider
int layerIndex() const { return mLayerIndex; }
QTextCodec* textEncoding() { return mEncoding; }
QByteArray quotedIdentifier( QByteArray field ) const;
/**

View File

@ -142,26 +142,26 @@ QgsOracleProvider::QgsOracleProvider( QString const & uri )
}
//fill type names into sets
mNativeTypes
// integer types
<< QgsVectorDataProvider::NativeType( tr( "Whole number" ), "number(10,0)", QVariant::Int )
<< QgsVectorDataProvider::NativeType( tr( "Whole big number" ), "number(20,0)", QVariant::LongLong )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (numeric)" ), "number", QVariant::Double, 1, 38, 0, 38 )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (decimal)" ), "double precision", QVariant::Double )
setNativeTypes( QList<NativeType>()
// integer types
<< QgsVectorDataProvider::NativeType( tr( "Whole number" ), "number(10,0)", QVariant::Int )
<< QgsVectorDataProvider::NativeType( tr( "Whole big number" ), "number(20,0)", QVariant::LongLong )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (numeric)" ), "number", QVariant::Double, 1, 38, 0, 38 )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (decimal)" ), "double precision", QVariant::Double )
// floating point
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (real)" ), "binary_float", QVariant::Double )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (double)" ), "binary_double", QVariant::Double )
// floating point
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (real)" ), "binary_float", QVariant::Double )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (double)" ), "binary_double", QVariant::Double )
// string types
<< QgsVectorDataProvider::NativeType( tr( "Text, fixed length (char)" ), "CHAR", QVariant::String, 1, 255 )
<< QgsVectorDataProvider::NativeType( tr( "Text, limited variable length (varchar2)" ), "VARCHAR2", QVariant::String, 1, 255 )
<< QgsVectorDataProvider::NativeType( tr( "Text, unlimited length (long)" ), "LONG", QVariant::String )
// string types
<< QgsVectorDataProvider::NativeType( tr( "Text, fixed length (char)" ), "CHAR", QVariant::String, 1, 255 )
<< QgsVectorDataProvider::NativeType( tr( "Text, limited variable length (varchar2)" ), "VARCHAR2", QVariant::String, 1, 255 )
<< QgsVectorDataProvider::NativeType( tr( "Text, unlimited length (long)" ), "LONG", QVariant::String )
// date type
<< QgsVectorDataProvider::NativeType( tr( "Date" ), "DATE", QVariant::Date, 38, 38, 0, 0 )
<< QgsVectorDataProvider::NativeType( tr( "Date & Time" ), "TIMESTAMP(6)", QVariant::DateTime, 38, 38, 6, 6 )
;
// date type
<< QgsVectorDataProvider::NativeType( tr( "Date" ), "DATE", QVariant::Date, 38, 38, 0, 0 )
<< QgsVectorDataProvider::NativeType( tr( "Date & Time" ), "TIMESTAMP(6)", QVariant::DateTime, 38, 38, 6, 6 )
);
QString key;
switch ( mPrimaryKeyType )

View File

@ -198,35 +198,35 @@ QgsPostgresProvider::QgsPostgresProvider( QString const & uri )
#endif
//fill type names into sets
mNativeTypes
// integer types
<< QgsVectorDataProvider::NativeType( tr( "Whole number (smallint - 16bit)" ), "int2", QVariant::Int, -1, -1, 0, 0 )
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer - 32bit)" ), "int4", QVariant::Int, -1, -1, 0, 0 )
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer - 64bit)" ), "int8", QVariant::LongLong, -1, -1, 0, 0 )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (numeric)" ), "numeric", QVariant::Double, 1, 20, 0, 20 )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (decimal)" ), "decimal", QVariant::Double, 1, 20, 0, 20 )
setNativeTypes( QList<NativeType>()
// integer types
<< QgsVectorDataProvider::NativeType( tr( "Whole number (smallint - 16bit)" ), "int2", QVariant::Int, -1, -1, 0, 0 )
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer - 32bit)" ), "int4", QVariant::Int, -1, -1, 0, 0 )
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer - 64bit)" ), "int8", QVariant::LongLong, -1, -1, 0, 0 )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (numeric)" ), "numeric", QVariant::Double, 1, 20, 0, 20 )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (decimal)" ), "decimal", QVariant::Double, 1, 20, 0, 20 )
// floating point
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (real)" ), "real", QVariant::Double, -1, -1, -1, -1 )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (double)" ), "double precision", QVariant::Double, -1, -1, -1, -1 )
// floating point
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (real)" ), "real", QVariant::Double, -1, -1, -1, -1 )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (double)" ), "double precision", QVariant::Double, -1, -1, -1, -1 )
// string types
<< QgsVectorDataProvider::NativeType( tr( "Text, fixed length (char)" ), "char", QVariant::String, 1, 255, -1, -1 )
<< QgsVectorDataProvider::NativeType( tr( "Text, limited variable length (varchar)" ), "varchar", QVariant::String, 1, 255, -1, -1 )
<< QgsVectorDataProvider::NativeType( tr( "Text, unlimited length (text)" ), "text", QVariant::String, -1, -1, -1, -1 )
// string types
<< QgsVectorDataProvider::NativeType( tr( "Text, fixed length (char)" ), "char", QVariant::String, 1, 255, -1, -1 )
<< QgsVectorDataProvider::NativeType( tr( "Text, limited variable length (varchar)" ), "varchar", QVariant::String, 1, 255, -1, -1 )
<< QgsVectorDataProvider::NativeType( tr( "Text, unlimited length (text)" ), "text", QVariant::String, -1, -1, -1, -1 )
// date type
<< QgsVectorDataProvider::NativeType( tr( "Date" ), "date", QVariant::Date, -1, -1, -1, -1 )
<< QgsVectorDataProvider::NativeType( tr( "Time" ), "time", QVariant::Time, -1, -1, -1, -1 )
<< QgsVectorDataProvider::NativeType( tr( "Date & Time" ), "timestamp without time zone", QVariant::DateTime, -1, -1, -1, -1 )
// date type
<< QgsVectorDataProvider::NativeType( tr( "Date" ), "date", QVariant::Date, -1, -1, -1, -1 )
<< QgsVectorDataProvider::NativeType( tr( "Time" ), "time", QVariant::Time, -1, -1, -1, -1 )
<< QgsVectorDataProvider::NativeType( tr( "Date & Time" ), "timestamp without time zone", QVariant::DateTime, -1, -1, -1, -1 )
// complex types
<< QgsVectorDataProvider::NativeType( tr( "Map" ), "hstore", QVariant::Map, -1, -1, -1, -1, QVariant::String )
<< QgsVectorDataProvider::NativeType( tr( "Array of number (integer - 32bit)" ), "int4[]", QVariant::List, -1, -1, -1, -1, QVariant::Int )
<< QgsVectorDataProvider::NativeType( tr( "Array of number (integer - 64bit)" ), "int8[]", QVariant::List, -1, -1, -1, -1, QVariant::LongLong )
<< QgsVectorDataProvider::NativeType( tr( "Array of number (double)" ), "double precision[]", QVariant::List, -1, -1, -1, -1, QVariant::Double )
<< QgsVectorDataProvider::NativeType( tr( "Array of text" ), "text[]", QVariant::StringList, -1, -1, -1, -1, QVariant::String )
;
// complex types
<< QgsVectorDataProvider::NativeType( tr( "Map" ), "hstore", QVariant::Map, -1, -1, -1, -1, QVariant::String )
<< QgsVectorDataProvider::NativeType( tr( "Array of number (integer - 32bit)" ), "int4[]", QVariant::List, -1, -1, -1, -1, QVariant::Int )
<< QgsVectorDataProvider::NativeType( tr( "Array of number (integer - 64bit)" ), "int8[]", QVariant::List, -1, -1, -1, -1, QVariant::LongLong )
<< QgsVectorDataProvider::NativeType( tr( "Array of number (double)" ), "double precision[]", QVariant::List, -1, -1, -1, -1, QVariant::Double )
<< QgsVectorDataProvider::NativeType( tr( "Array of text" ), "text[]", QVariant::StringList, -1, -1, -1, -1, QVariant::String )
);
QString key;
switch ( mPrimaryKeyType )
@ -4036,6 +4036,11 @@ QList<QgsRelation> QgsPostgresProvider::discoverRelations( const QgsVectorLayer*
return result;
}
QgsAttrPalIndexNameHash QgsPostgresProvider::palAttributeIndexNames() const
{
return mAttrPalIndexName;
}
/**
* Class factory to return a pointer to a newly created
* QgsPostgresProvider object

View File

@ -270,6 +270,11 @@ class QgsPostgresProvider : public QgsVectorDataProvider
virtual QList<QgsRelation> discoverRelations( const QgsVectorLayer* self, const QList<QgsVectorLayer*>& layers ) const override;
/**
* Return list of indexes to names for QgsPalLabeling fix
*/
virtual QgsAttrPalIndexNameHash palAttributeIndexNames() const override;
signals:
/**
* This is emitted whenever the worker thread has fully calculated the
@ -357,6 +362,9 @@ class QgsPostgresProvider : public QgsVectorDataProvider
*/
static QList<QgsVectorLayer*> searchLayers( const QList<QgsVectorLayer*>& layers, const QString& connectionInfo, const QString& schema, const QString& tableName );
/** Old-style mapping of index to name for QgsPalLabeling fix */
QgsAttrPalIndexNameHash mAttrPalIndexName;
QgsFields mAttributeFields;
QString mDataComment;

View File

@ -604,16 +604,16 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri )
spatialiteVersion();
//fill type names into sets
mNativeTypes
<< QgsVectorDataProvider::NativeType( tr( "Binary object (BLOB)" ), "BLOB", QVariant::ByteArray )
<< QgsVectorDataProvider::NativeType( tr( "Text" ), "TEXT", QVariant::String )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (double)" ), "FLOAT", QVariant::Double )
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer)" ), "INTEGER", QVariant::LongLong )
setNativeTypes( QList<NativeType>()
<< QgsVectorDataProvider::NativeType( tr( "Binary object (BLOB)" ), "BLOB", QVariant::ByteArray )
<< QgsVectorDataProvider::NativeType( tr( "Text" ), "TEXT", QVariant::String )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (double)" ), "FLOAT", QVariant::Double )
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer)" ), "INTEGER", QVariant::LongLong )
<< QgsVectorDataProvider::NativeType( tr( "Array of text" ), SPATIALITE_ARRAY_PREFIX.toUpper() + "TEXT" + SPATIALITE_ARRAY_SUFFIX.toUpper(), QVariant::StringList, 0, 0, 0, 0, QVariant::String )
<< QgsVectorDataProvider::NativeType( tr( "Array of decimal numbers (double)" ), SPATIALITE_ARRAY_PREFIX.toUpper() + "REAL" + SPATIALITE_ARRAY_SUFFIX.toUpper(), QVariant::List, 0, 0, 0, 0, QVariant::Double )
<< QgsVectorDataProvider::NativeType( tr( "Array of whole numbers (integer)" ), SPATIALITE_ARRAY_PREFIX.toUpper() + "INTEGER" + SPATIALITE_ARRAY_SUFFIX.toUpper(), QVariant::List, 0, 0, 0, 0, QVariant::LongLong )
;
<< QgsVectorDataProvider::NativeType( tr( "Array of text" ), SPATIALITE_ARRAY_PREFIX.toUpper() + "TEXT" + SPATIALITE_ARRAY_SUFFIX.toUpper(), QVariant::StringList, 0, 0, 0, 0, QVariant::String )
<< QgsVectorDataProvider::NativeType( tr( "Array of decimal numbers (double)" ), SPATIALITE_ARRAY_PREFIX.toUpper() + "REAL" + SPATIALITE_ARRAY_SUFFIX.toUpper(), QVariant::List, 0, 0, 0, 0, QVariant::Double )
<< QgsVectorDataProvider::NativeType( tr( "Array of whole numbers (integer)" ), SPATIALITE_ARRAY_PREFIX.toUpper() + "INTEGER" + SPATIALITE_ARRAY_SUFFIX.toUpper(), QVariant::List, 0, 0, 0, 0, QVariant::LongLong )
);
mValid = true;
}

View File

@ -494,7 +494,7 @@ QString QgsVirtualLayerProvider::subsetString() const
bool QgsVirtualLayerProvider::setSubsetString( const QString& subset, bool updateFeatureCount )
{
mSubset = subset;
mCacheMinMaxDirty = true;
clearMinMaxCache();
if ( updateFeatureCount )
updateStatistics();
return true;

View File

@ -666,7 +666,7 @@ bool QgsWFSProvider::setSubsetString( const QString& theSQL, bool updateFeatureC
mShared->invalidateCache();
mSubsetString = theSQL;
mCacheMinMaxDirty = true;
clearMinMaxCache();
// update URI
mShared->mFields = mThisTypenameFields;