Skip to content

Commit

Permalink
sql anywhere: fix warnings (and obligatory reindentation (using scrip…
Browse files Browse the repository at this point in the history
…ts/prepare-commit.sh)

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14922 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Dec 15, 2010
1 parent 7d8fe67 commit a7dc291
Show file tree
Hide file tree
Showing 24 changed files with 4,151 additions and 3,825 deletions.
1 change: 0 additions & 1 deletion src/plugins/sqlanywhere/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ SET (sqlanywhere_MOC_HDRS
sanewconnection.h
salayer.h
sadbtablemodel.h
sadbfilterproxymodel.h
saquerybuilder.h
)

Expand Down
6 changes: 3 additions & 3 deletions src/plugins/sqlanywhere/sadbfilterproxymodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
-------------------
begin : Dec 2010
copyright : (C) 2010 by iAnywhere Solutions, Inc.
author : David DeHaan
author : David DeHaan
email : ddehaan at sybase dot com
This class was copied and modified from QgsDbFilterProxyModel because that
This class was copied and modified from QgsDbFilterProxyModel because that
class is not accessible to QGIS plugins. Therefore, the author gratefully
acknowledges the following copyright on the original content:
qgsdbfilterproxymodel.cpp
qgsdbfilterproxymodel.cpp
begin : Dec 2007
copyright : (C) 2007 by Marco Hugentobler
email : marco dot hugentobler at karto dot baug dot ethz dot ch
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/sqlanywhere/sadbfilterproxymodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
-------------------
begin : Dec 2010
copyright : (C) 2010 by iAnywhere Solutions, Inc.
author : David DeHaan
author : David DeHaan
email : ddehaan at sybase dot com
This class was copied and modified from QgsDbFilterProxyModel because that
This class was copied and modified from QgsDbFilterProxyModel because that
class is not accessible to QGIS plugins. Therefore, the author gratefully
acknowledges the following copyright on the original content:
qgsdbfilterproxymodel.h
qgsdbfilterproxymodel.h
begin : Dec 2007
copyright : (C) 2007 by Marco Hugentobler
email : marco dot hugentobler at karto dot baug dot ethz dot ch
Expand Down
91 changes: 50 additions & 41 deletions src/plugins/sqlanywhere/sadbtablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
-------------------
begin : Dec 2010
copyright : (C) 2010 by iAnywhere Solutions, Inc.
author : David DeHaan
author : David DeHaan
email : ddehaan at sybase dot com
This class was copied and modified from QgsDbTableModel because that
This class was copied and modified from QgsDbTableModel because that
class is not accessible to QGIS plugins. Therefore, the author gratefully
acknowledges the following copyright on the original content:
qgsdbtablemodel.cpp
qgsdbtablemodel.cpp
begin : Dec 2007
copyright : (C) 2007 by Marco Hugentobler
email : marco dot hugentobler at karto dot baug dot ethz dot ch
Expand Down Expand Up @@ -171,35 +171,44 @@ void SaDbTableModel::setSql( const QModelIndex &index, const QString &sql )
QString
makeSubsetSql( QString prevSql, QString geomCol, QString geomType )
{
QString sql;
QStringList types;
if( geomType == "ST_POINT" ) {
types << "'ST_POINT'";
types << "'ST_MULTIPOINT'";

} else if( geomType == "ST_LINESTRING" ) {
types << "'ST_LINESTRING'";
types << "'ST_MULTILINESTRING'";

} else if( geomType == "ST_POLYGON" ) {
types << "'ST_POLYGON'";
types << "'ST_MULTIPOLYGON'";
}

if( types.isEmpty() ) {
sql = prevSql;

} else {
sql = geomCol
+ ".ST_GeometryType() IN ( "
+ types.join( "," )
+ " ) ";
if( !prevSql.isEmpty() ) {
sql += "AND ( " + prevSql + ") ";
}
QString sql;
QStringList types;
if ( geomType == "ST_POINT" )
{
types << "'ST_POINT'";
types << "'ST_MULTIPOINT'";

}
else if ( geomType == "ST_LINESTRING" )
{
types << "'ST_LINESTRING'";
types << "'ST_MULTILINESTRING'";

}
else if ( geomType == "ST_POLYGON" )
{
types << "'ST_POLYGON'";
types << "'ST_MULTIPOLYGON'";
}

if ( types.isEmpty() )
{
sql = prevSql;

}
else
{
sql = geomCol
+ ".ST_GeometryType() IN ( "
+ types.join( "," )
+ " ) ";
if ( !prevSql.isEmpty() )
{
sql += "AND ( " + prevSql + ") ";
}
}

return sql;
return sql;
}

void SaDbTableModel::setGeometryTypesForTable( const QString& schema, const QString& table, const QString& attribute, const QString& type, const QString& srid, const QString& lineInterp )
Expand Down Expand Up @@ -241,23 +250,23 @@ void SaDbTableModel::setGeometryTypesForTable( const QString& schema, const QStr
currentSqlIndex = currentChildIndex.sibling( i, dbtmSql );
QString sqlText = itemFromIndex( currentSqlIndex )->text();

if ( !currentTypeIndex.isValid()
|| !currentTableIndex.isValid()
|| !currentSridIndex.isValid()
|| !currentLineInterpIndex.isValid()
|| !currentSqlIndex.isValid()
|| !currentGeomColumnIndex.isValid() )
if ( !currentTypeIndex.isValid()
|| !currentTableIndex.isValid()
|| !currentSridIndex.isValid()
|| !currentLineInterpIndex.isValid()
|| !currentSqlIndex.isValid()
|| !currentGeomColumnIndex.isValid() )
{
continue;
}

if ( itemFromIndex( currentTableIndex )->text() == table
&& ( geomColText == attribute ) )
if ( itemFromIndex( currentTableIndex )->text() == table
&& ( geomColText == attribute ) )
{
if ( type.isEmpty() )
if ( type.isEmpty() )
{
//the table has no valid geometry entry and so the item for
//this table should be removed
//the table has no valid geometry entry and so the item for
//this table should be removed
removeRow( i, indexFromItem( schemaItem ) );
return;
}
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/sqlanywhere/sadbtablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
-------------------
begin : Dec 2010
copyright : (C) 2010 by iAnywhere Solutions, Inc.
author : David DeHaan
author : David DeHaan
email : ddehaan at sybase dot com
This class was copied and modified from QgsDbTableModel because that
This class was copied and modified from QgsDbTableModel because that
class is not accessible to QGIS plugins. Therefore, the author gratefully
acknowledges the following copyright on the original content:
qgsdbtablemodel.cpp
qgsdbtablemodel.cpp
begin : Dec 2007
copyright : (C) 2007 by Marco Hugentobler
email : marco dot hugentobler at karto dot baug dot ethz dot ch
Expand Down
29 changes: 15 additions & 14 deletions src/plugins/sqlanywhere/salayer.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/***************************************************************************
salayer.h
Definition of vector layer backed by a SQL Anywhere database
Definition of vector layer backed by a SQL Anywhere database
-------------------
begin : Dec 2010
copyright : (C) 2010 by iAnywhere Solutions, Inc.
author : David DeHaan
author : David DeHaan
email : ddehaan at sybase dot com
***************************************************************************
Expand Down Expand Up @@ -36,23 +36,24 @@ class SaLayer : public QgsVectorLayer
public:
//! Constructor
SaLayer( QString path = QString::null
, QString baseName = QString::null
, bool loadDefaultStyleFlag = true )
: QgsVectorLayer( path, baseName, "sqlanywhere", loadDefaultStyleFlag )
, QString baseName = QString::null
, bool loadDefaultStyleFlag = true )
: QgsVectorLayer( path, baseName, "sqlanywhere", loadDefaultStyleFlag )
{
if( isValid() ) {
// The parent QgsMapLayer initialized mDataSource = path.
// Reset this to the value mDataProvider.dataSourceUri()
// so that any modifications to the URI made by the
// data provider make it back into the layer definition.
mDataSource = dataProvider()->dataSourceUri();
SaDebugMsg( "Modified layer source: " + mDataSource );
}
if ( isValid() )
{
// The parent QgsMapLayer initialized mDataSource = path.
// Reset this to the value mDataProvider.dataSourceUri()
// so that any modifications to the URI made by the
// data provider make it back into the layer definition.
mDataSource = dataProvider()->dataSourceUri();
SaDebugMsg( "Modified layer source: " + mDataSource );
}
}

//! Destructor
~SaLayer()
{
{
}
};

Expand Down
100 changes: 53 additions & 47 deletions src/plugins/sqlanywhere/sanewconnection.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/***************************************************************************
sanewconnection.h
Dialogue box for defining new connections to a SQL Anywhere database
Dialogue box for defining new connections to a SQL Anywhere database
-------------------
begin : Dec 2010
copyright : (C) 2010 by iAnywhere Solutions, Inc.
author : David DeHaan
author : David DeHaan
email : ddehaan at sybase dot com
***************************************************************************
Expand Down Expand Up @@ -47,12 +47,12 @@ SaNewConnection::SaNewConnection( QWidget *parent, const QString& connName, Qt::
txtDatabase->setText( settings.value( key + "/database" ).toString() );
txtParameters->setText( settings.value( key + "/parameters" ).toString() );

if ( settings.value( key + "/saveUsername", true ).toBool() )
if ( settings.value( key + "/saveUsername", true ).toBool() )
{
txtUsername->setText( settings.value( key + "/username" ).toString() );
chkStoreUsername->setChecked( true );
txtUsername->setText( settings.value( key + "/username" ).toString() );
chkStoreUsername->setChecked( true );
}
if ( settings.value( key + "/savePassword", false ).toBool() )
if ( settings.value( key + "/savePassword", false ).toBool() )
{
txtPassword->setText( settings.value( key + "/password" ).toString() );
chkStorePassword->setChecked( true );
Expand All @@ -61,7 +61,7 @@ SaNewConnection::SaNewConnection( QWidget *parent, const QString& connName, Qt::
chkEstimateMetadata->setChecked( settings.value( key + "/estimateMetadata", false ).toBool() );
chkOtherSchemas->setChecked( settings.value( key + "/otherSchemas", false ).toBool() );

}
}
}

SaNewConnection::~SaNewConnection()
Expand Down Expand Up @@ -116,49 +116,55 @@ void SaNewConnection::on_btnConnect_clicked()

void SaNewConnection::testConnection()
{
char errbuf[SACAPI_ERROR_SIZE];
sacapi_i32 code;
SqlAnyConnection *conn;

// load the SQL Anywhere interface
if( !SqlAnyConnection::initApi() ) {
QMessageBox::information( this,
tr("Failed to load interface" ),
tr( SqlAnyConnection::failedInitMsg() ) );
return;
char errbuf[SACAPI_ERROR_SIZE];
sacapi_i32 code;
SqlAnyConnection *conn;

// load the SQL Anywhere interface
if ( !SqlAnyConnection::initApi() )
{
QMessageBox::information( this,
tr( "Failed to load interface" ),
tr( SqlAnyConnection::failedInitMsg() ) );
return;
}

// establish read-only connection to the database
conn = SqlAnyConnection::connect( txtName->text()
, txtHost->text(), txtPort->text(), txtServer->text()
, txtDatabase->text(), txtParameters->text(), txtUsername->text()
, txtPassword->text(), chkSimpleEncryption->isChecked()
, chkEstimateMetadata->isChecked(), true
, code, errbuf, sizeof( errbuf ) );
if ( conn )
{
// retrieve the username and password, in case the user adjusted them
QgsDataSourceURI theUri( conn->uri() );
if ( chkStoreUsername->isChecked() )
{
txtUsername->setText( theUri.username() );
}

// establish read-only connection to the database
conn = SqlAnyConnection::connect( txtName->text()
, txtHost->text(), txtPort->text(), txtServer->text()
, txtDatabase->text(), txtParameters->text(), txtUsername->text()
, txtPassword->text(), chkSimpleEncryption->isChecked()
, chkEstimateMetadata->isChecked(), true
, code, errbuf, sizeof( errbuf ) );
if( conn ) {
// retrieve the username and password, in case the user adjusted them
QgsDataSourceURI theUri( conn->uri() );
if ( chkStoreUsername->isChecked() ) {
txtUsername->setText( theUri.username() );
}
if ( chkStorePassword->isChecked() ) {
txtPassword->setText( theUri.password() );
}
conn->release();

QMessageBox::information( this,
if ( chkStorePassword->isChecked() )
{
txtPassword->setText( theUri.password() );
}
conn->release();

QMessageBox::information( this,
tr( "Test connection" ),
tr( "Connection to %1 was successful" )
.arg( txtDatabase->text() ) );
} else {
QMessageBox::information( this,
.arg( txtDatabase->text() ) );
}
else
{
QMessageBox::information( this,
tr( "Test connection" ),
tr( "Connection failed. "
"Check settings and try again.\n\n"
"SQL Anywhere error code: %1\n"
"Description: %2" )
.arg( code )
.arg( errbuf ) );
}
SqlAnyConnection::releaseApi();
"Check settings and try again.\n\n"
"SQL Anywhere error code: %1\n"
"Description: %2" )
.arg( code )
.arg( errbuf ) );
}
SqlAnyConnection::releaseApi();
}
4 changes: 2 additions & 2 deletions src/plugins/sqlanywhere/sanewconnection.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/***************************************************************************
sanewconnection.h
Dialogue box for defining new connections to a SQL Anywhere database
Dialogue box for defining new connections to a SQL Anywhere database
-------------------
begin : Dec 2010
copyright : (C) 2010 by iAnywhere Solutions, Inc.
author : David DeHaan
author : David DeHaan
email : ddehaan at sybase dot com
***************************************************************************
Expand Down
Loading

0 comments on commit a7dc291

Please sign in to comment.