Skip to content
Permalink
Browse files

Deprecate old WkbType in QgsDataSourceUri

  • Loading branch information
mhugo committed Feb 4, 2016
1 parent e2123c7 commit fa78ccf74d3f8f3f839ee4f389e634f98ae953e0
@@ -126,8 +126,19 @@ class QgsDataSourceURI
QString keyColumn() const;
void setKeyColumn( const QString& column );

QGis::WkbType wkbType() const;
void setWkbType( QGis::WkbType type );
/** The (old) wkb type.
@deprecated Will return QgsWKBTypes::Type in 3.0. Prefer newWkbType() in the meantime */
QGis::WkbType wkbType() const /Deprecated/;

/** The wkb type.
@note Will be removed in 3.0 */
QgsWKBTypes::Type newWkbType() const;

//! @deprecated See setWkbType( QgsWKBTypes::Type )
void setWkbType( QGis::WkbType type ) /Deprecated/;

//! Sets the wkb type
void setWkbType( QgsWKBTypes::Type type );

QString srid() const;
void setSrid( const QString& srid );
@@ -30,7 +30,7 @@ QgsDataSourceURI::QgsDataSourceURI()
, mKeyColumn( "" )
, mUseEstimatedMetadata( false )
, mSelectAtIdDisabled( false )
, mWkbType( QGis::WKBUnknown )
, mWkbType( QgsWKBTypes::Unknown )
{
// do nothing
}
@@ -40,7 +40,7 @@ QgsDataSourceURI::QgsDataSourceURI( QString uri )
, mKeyColumn( "" )
, mUseEstimatedMetadata( false )
, mSelectAtIdDisabled( false )
, mWkbType( QGis::WKBUnknown )
, mWkbType( QgsWKBTypes::Unknown )
{
int i = 0;
while ( i < uri.length() )
@@ -139,7 +139,7 @@ QgsDataSourceURI::QgsDataSourceURI( QString uri )
}
else if ( pname == "type" )
{
mWkbType = QGis::fromNewWkbType( QgsWKBTypes::parseType( pval ) );
mWkbType = QgsWKBTypes::parseType( pval );
}
else if ( pname == "selectatid" )
{
@@ -540,10 +540,10 @@ QString QgsDataSourceURI::uri( bool expandAuthConfig ) const
theUri += QString( " srid=%1" ).arg( mSrid );
}

if ( mWkbType != QGis::WKBUnknown && mWkbType != QGis::WKBNoGeometry )
if ( mWkbType != QgsWKBTypes::Unknown && mWkbType != QgsWKBTypes::NoGeometry )
{
theUri += " type=";
theUri += QgsWKBTypes::displayString( QgsWKBTypes::Type( mWkbType ) );
theUri += QgsWKBTypes::displayString( mWkbType );
}

if ( mSelectAtIdDisabled )
@@ -671,11 +671,21 @@ void QgsDataSourceURI::setDatabase( const QString &database )
}

QGis::WkbType QgsDataSourceURI::wkbType() const
{
return QGis::fromNewWkbType( mWkbType );
}

QgsWKBTypes::Type QgsDataSourceURI::newWkbType() const
{
return mWkbType;
}

void QgsDataSourceURI::setWkbType( QGis::WkbType wkbType )
{
mWkbType = QGis::fromOldWkbType( wkbType );
}

void QgsDataSourceURI::setWkbType( QgsWKBTypes::Type wkbType )
{
mWkbType = wkbType;
}
@@ -125,42 +125,79 @@ class CORE_EXPORT QgsDataSourceURI

//! Any associated authentication configuration ID
QString authConfigId() const;

//! Returns the username
QString username() const;

//! Returns the schema
QString schema() const;

//! Returns the table
QString table() const;

//! Returns the SQL query
QString sql() const;

//! Return the name of the geometry column
QString geometryColumn() const;

//! set use Estimated Metadata
void setUseEstimatedMetadata( bool theFlag );

//! Returns true if estimated metadata are used
bool useEstimatedMetadata() const;

//! Set to true to disable selection by id
void disableSelectAtId( bool theFlag );
//! Returns whether the selection by id is disabled
bool selectAtIdDisabled() const;

//! Clears the schema
void clearSchema();

//! set the table schema
// @note added in 2.11
void setSchema( const QString& schema );

//! Sets the SQL query
void setSql( const QString& sql );

//! Returns the host
QString host() const;
//! Returns the database
QString database() const;
//! Returns the port
QString port() const;
//! Returns the password
QString password() const;
//! Returns the SSL mode
enum SSLmode sslMode() const;

//! Returns the service name
QString service() const;

//! Returns the name of the (primary) key column
QString keyColumn() const;
//! Sets the name of the (primary) key column
void setKeyColumn( const QString& column );

QGis::WkbType wkbType() const;
void setWkbType( QGis::WkbType type );
/** The (old) wkb type.
@deprecated Will return QgsWKBTypes::Type in 3.0. Prefer newWkbType() in the meantime */
Q_DECL_DEPRECATED QGis::WkbType wkbType() const;

/** The wkb type.
@note Will be removed in 3.0 */
QgsWKBTypes::Type newWkbType() const;

//! @deprecated See setWkbType( QgsWKBTypes::Type )
Q_DECL_DEPRECATED void setWkbType( QGis::WkbType type );

//! Sets the wkb type
void setWkbType( QgsWKBTypes::Type type );

//! Returns the srid
QString srid() const;
//! Sets the srid
void setSrid( const QString& srid );

private:
@@ -201,7 +238,7 @@ class CORE_EXPORT QgsDataSourceURI
//! Disable SelectAtId capability (eg. to trigger the attribute table memory model for expensive views)
bool mSelectAtIdDisabled;
//! geometry type (or QGis::WKBUnknown if not specified)
QGis::WkbType mWkbType;
QgsWKBTypes::Type mWkbType;
//! SRID or a null string if not specified
QString mSrid;
//! Generic params store
@@ -505,7 +505,7 @@ QString QgsMssqlLayerItem::createUri()
QgsDataSourceURI uri = QgsDataSourceURI( connItem->connInfo() );
uri.setDataSource( mLayerProperty.schemaName, mLayerProperty.tableName, mLayerProperty.geometryColName, mLayerProperty.sql, pkColName );
uri.setSrid( mLayerProperty.srid );
uri.setWkbType( QgsMssqlTableModel::wkbTypeFromMssql( mLayerProperty.type ) );
uri.setWkbType( QGis::fromOldWkbType( QgsMssqlTableModel::wkbTypeFromMssql( mLayerProperty.type ) ) );
QgsDebugMsg( QString( "layer uri: %1" ).arg( uri.uri() ) );
return uri.uri();
}
@@ -66,7 +66,7 @@ QgsMssqlProvider::QgsMssqlProvider( const QString& uri )
else
mSRId = -1;

mWkbType = anUri.wkbType();
mWkbType = QGis::fromNewWkbType( anUri.newWkbType() );

mValid = true;

@@ -393,7 +393,7 @@ QString QgsMssqlTableModel::layerURI( const QModelIndex &index, const QString &c
QgsDataSourceURI uri( connInfo );
uri.setDataSource( schemaName, tableName, geomColumnName, sql, pkColumnName );
uri.setUseEstimatedMetadata( useEstimatedMetadata );
uri.setWkbType( wkbType );
uri.setWkbType( QGis::fromOldWkbType( wkbType ) );
uri.setSrid( srid );
uri.disableSelectAtId( !selectAtId );

@@ -372,7 +372,7 @@ QString QgsPgTableModel::layerURI( const QModelIndex &index, const QString& conn

uri.setDataSource( schemaName, tableName, geomColumnName, sql, cols.join( "," ) );
uri.setUseEstimatedMetadata( useEstimatedMetadata );
uri.setWkbType( wkbType );
uri.setWkbType( QGis::fromOldWkbType( wkbType ) );
uri.setSrid( srid );
uri.disableSelectAtId( !selectAtId );

@@ -449,8 +449,8 @@ QString QgsPGLayerItem::createUri()

QgsDataSourceURI uri( QgsPostgresConn::connUri( connItem->name() ).connectionInfo( false ) );
uri.setDataSource( mLayerProperty.schemaName, mLayerProperty.tableName, mLayerProperty.geometryColName, mLayerProperty.sql, pkColName );
uri.setWkbType( mLayerProperty.types[0] );
if ( uri.wkbType() != QGis::WKBNoGeometry )
uri.setWkbType( QGis::fromOldWkbType( mLayerProperty.types[0] ) );
if ( uri.newWkbType() != QgsWKBTypes::NoGeometry )
uri.setSrid( QString::number( mLayerProperty.srids[0] ) );
QgsDebugMsg( QString( "layer uri: %1" ).arg( uri.uri( false ) ) );
return uri.uri( false );
@@ -69,7 +69,7 @@ QgsPostgresProvider::QgsPostgresProvider( QString const & uri )
mGeometryColumn = mUri.geometryColumn();
mSqlWhereClause = mUri.sql();
mRequestedSrid = mUri.srid();
mRequestedGeomType = mUri.wkbType();
mRequestedGeomType = QGis::fromNewWkbType( mUri.newWkbType() );

if ( mSchemaName.isEmpty() && mTableName.startsWith( '(' ) && mTableName.endsWith( ')' ) )
{
@@ -1,5 +1,5 @@
/***************************************************************************
testqgsrectangle.cpp
testqgsdatasourceuri.cpp
--------------------------------------
Date : Thu Apr 16 2015
Copyright : (C) 2015 by Sandro Mani
@@ -18,7 +18,7 @@
//header for class being tested
#include <qgsdatasourceuri.h>

Q_DECLARE_METATYPE( QGis::WkbType )
Q_DECLARE_METATYPE( QgsWKBTypes::Type )
Q_DECLARE_METATYPE( QgsDataSourceURI::SSLmode )

class TestQgsDataSourceUri: public QObject
@@ -37,7 +37,7 @@ void TestQgsDataSourceUri::checkparser_data()
QTest::addColumn<QString>( "key" );
QTest::addColumn<bool>( "estimatedmetadata" );
QTest::addColumn<QString>( "srid" );
QTest::addColumn<QGis::WkbType>( "type" );
QTest::addColumn<QgsWKBTypes::Type>( "type" );
QTest::addColumn<bool>( "selectatid" );
QTest::addColumn<QString>( "service" );
QTest::addColumn<QString>( "user" );
@@ -56,7 +56,7 @@ void TestQgsDataSourceUri::checkparser_data()
<< "" // key
<< true // estimatedmetadata
<< "1000003007" // srid
<< QGis::WKBUnknown // type
<< QgsWKBTypes::Unknown // type
<< false // selectatid
<< "" // service
<< "myname" // user
@@ -76,7 +76,7 @@ void TestQgsDataSourceUri::checkparser_data()
<< "" // key
<< false // estimatedmetadata
<< "" // srid
<< QGis::WKBUnknown // type
<< QgsWKBTypes::Unknown // type
<< false // selectatid
<< "" // service
<< "myname" // user
@@ -89,6 +89,25 @@ void TestQgsDataSourceUri::checkparser_data()
<< "" // myparam
;

QTest::newRow( "pgmlsz" )
<< "PG: dbname=mydb host=myhost user=myname password=mypasswd port=5432 mode=2 schema=public column=geom table=mytable type=MultiLineStringZ"
<< "mytable" // table
<< "" // geometrycolumn
<< "" // key
<< false // estimatedmetadata
<< "" // srid
<< QgsWKBTypes::MultiLineStringZ // type
<< false // selectatid
<< "" // service
<< "myname" // user
<< "mypasswd" // password
<< "mydb" // dbname
<< "myhost" // host
<< "5432" // port
<< QgsDataSourceURI::SSLprefer // sslmode
<< "" // sql
<< "" // myparam
;
}

void TestQgsDataSourceUri::checkparser()
@@ -99,7 +118,7 @@ void TestQgsDataSourceUri::checkparser()
QFETCH( QString, key );
QFETCH( bool, estimatedmetadata );
QFETCH( QString, srid );
QFETCH( QGis::WkbType, type );
QFETCH( QgsWKBTypes::Type, type );
QFETCH( bool, selectatid );
QFETCH( QString, service );
QFETCH( QString, user );
@@ -117,7 +136,7 @@ void TestQgsDataSourceUri::checkparser()
QCOMPARE( ds.keyColumn(), key );
QCOMPARE( ds.useEstimatedMetadata(), estimatedmetadata );
QCOMPARE( ds.srid(), srid );
QCOMPARE( ds.wkbType(), type );
QCOMPARE( ds.newWkbType(), type );
QCOMPARE( ds.selectAtIdDisabled(), selectatid );
QCOMPARE( ds.service(), service );
QCOMPARE( ds.username(), user );

0 comments on commit fa78ccf

Please sign in to comment.
You can’t perform that action at this time.