Skip to content

Commit 716f6c1

Browse files
author
jef
committed
sql anywhere: fix warnings (and obligatory reindentation (using scripts/prepare-commit.sh)
git-svn-id: http://svn.osgeo.org/qgis/trunk@14922 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 041365d commit 716f6c1

24 files changed

+4151
-3825
lines changed

src/plugins/sqlanywhere/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ SET (sqlanywhere_MOC_HDRS
2121
sanewconnection.h
2222
salayer.h
2323
sadbtablemodel.h
24-
sadbfilterproxymodel.h
2524
saquerybuilder.h
2625
)
2726

src/plugins/sqlanywhere/sadbfilterproxymodel.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
-------------------
55
begin : Dec 2010
66
copyright : (C) 2010 by iAnywhere Solutions, Inc.
7-
author : David DeHaan
7+
author : David DeHaan
88
email : ddehaan at sybase dot com
99
10-
This class was copied and modified from QgsDbFilterProxyModel because that
10+
This class was copied and modified from QgsDbFilterProxyModel because that
1111
class is not accessible to QGIS plugins. Therefore, the author gratefully
1212
acknowledges the following copyright on the original content:
13-
qgsdbfilterproxymodel.cpp
13+
qgsdbfilterproxymodel.cpp
1414
begin : Dec 2007
1515
copyright : (C) 2007 by Marco Hugentobler
1616
email : marco dot hugentobler at karto dot baug dot ethz dot ch

src/plugins/sqlanywhere/sadbfilterproxymodel.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
-------------------
55
begin : Dec 2010
66
copyright : (C) 2010 by iAnywhere Solutions, Inc.
7-
author : David DeHaan
7+
author : David DeHaan
88
email : ddehaan at sybase dot com
99
10-
This class was copied and modified from QgsDbFilterProxyModel because that
10+
This class was copied and modified from QgsDbFilterProxyModel because that
1111
class is not accessible to QGIS plugins. Therefore, the author gratefully
1212
acknowledges the following copyright on the original content:
13-
qgsdbfilterproxymodel.h
13+
qgsdbfilterproxymodel.h
1414
begin : Dec 2007
1515
copyright : (C) 2007 by Marco Hugentobler
1616
email : marco dot hugentobler at karto dot baug dot ethz dot ch

src/plugins/sqlanywhere/sadbtablemodel.cpp

+50-41
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
-------------------
66
begin : Dec 2010
77
copyright : (C) 2010 by iAnywhere Solutions, Inc.
8-
author : David DeHaan
8+
author : David DeHaan
99
email : ddehaan at sybase dot com
1010
11-
This class was copied and modified from QgsDbTableModel because that
11+
This class was copied and modified from QgsDbTableModel because that
1212
class is not accessible to QGIS plugins. Therefore, the author gratefully
1313
acknowledges the following copyright on the original content:
14-
qgsdbtablemodel.cpp
14+
qgsdbtablemodel.cpp
1515
begin : Dec 2007
1616
copyright : (C) 2007 by Marco Hugentobler
1717
email : marco dot hugentobler at karto dot baug dot ethz dot ch
@@ -171,35 +171,44 @@ void SaDbTableModel::setSql( const QModelIndex &index, const QString &sql )
171171
QString
172172
makeSubsetSql( QString prevSql, QString geomCol, QString geomType )
173173
{
174-
QString sql;
175-
QStringList types;
176-
if( geomType == "ST_POINT" ) {
177-
types << "'ST_POINT'";
178-
types << "'ST_MULTIPOINT'";
179-
180-
} else if( geomType == "ST_LINESTRING" ) {
181-
types << "'ST_LINESTRING'";
182-
types << "'ST_MULTILINESTRING'";
183-
184-
} else if( geomType == "ST_POLYGON" ) {
185-
types << "'ST_POLYGON'";
186-
types << "'ST_MULTIPOLYGON'";
187-
}
188-
189-
if( types.isEmpty() ) {
190-
sql = prevSql;
191-
192-
} else {
193-
sql = geomCol
194-
+ ".ST_GeometryType() IN ( "
195-
+ types.join( "," )
196-
+ " ) ";
197-
if( !prevSql.isEmpty() ) {
198-
sql += "AND ( " + prevSql + ") ";
199-
}
174+
QString sql;
175+
QStringList types;
176+
if ( geomType == "ST_POINT" )
177+
{
178+
types << "'ST_POINT'";
179+
types << "'ST_MULTIPOINT'";
180+
181+
}
182+
else if ( geomType == "ST_LINESTRING" )
183+
{
184+
types << "'ST_LINESTRING'";
185+
types << "'ST_MULTILINESTRING'";
186+
187+
}
188+
else if ( geomType == "ST_POLYGON" )
189+
{
190+
types << "'ST_POLYGON'";
191+
types << "'ST_MULTIPOLYGON'";
192+
}
193+
194+
if ( types.isEmpty() )
195+
{
196+
sql = prevSql;
197+
198+
}
199+
else
200+
{
201+
sql = geomCol
202+
+ ".ST_GeometryType() IN ( "
203+
+ types.join( "," )
204+
+ " ) ";
205+
if ( !prevSql.isEmpty() )
206+
{
207+
sql += "AND ( " + prevSql + ") ";
200208
}
209+
}
201210

202-
return sql;
211+
return sql;
203212
}
204213

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

244-
if ( !currentTypeIndex.isValid()
245-
|| !currentTableIndex.isValid()
246-
|| !currentSridIndex.isValid()
247-
|| !currentLineInterpIndex.isValid()
248-
|| !currentSqlIndex.isValid()
249-
|| !currentGeomColumnIndex.isValid() )
253+
if ( !currentTypeIndex.isValid()
254+
|| !currentTableIndex.isValid()
255+
|| !currentSridIndex.isValid()
256+
|| !currentLineInterpIndex.isValid()
257+
|| !currentSqlIndex.isValid()
258+
|| !currentGeomColumnIndex.isValid() )
250259
{
251260
continue;
252261
}
253262

254-
if ( itemFromIndex( currentTableIndex )->text() == table
255-
&& ( geomColText == attribute ) )
263+
if ( itemFromIndex( currentTableIndex )->text() == table
264+
&& ( geomColText == attribute ) )
256265
{
257-
if ( type.isEmpty() )
266+
if ( type.isEmpty() )
258267
{
259-
//the table has no valid geometry entry and so the item for
260-
//this table should be removed
268+
//the table has no valid geometry entry and so the item for
269+
//this table should be removed
261270
removeRow( i, indexFromItem( schemaItem ) );
262271
return;
263272
}

src/plugins/sqlanywhere/sadbtablemodel.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
-------------------
66
begin : Dec 2010
77
copyright : (C) 2010 by iAnywhere Solutions, Inc.
8-
author : David DeHaan
8+
author : David DeHaan
99
email : ddehaan at sybase dot com
1010
11-
This class was copied and modified from QgsDbTableModel because that
11+
This class was copied and modified from QgsDbTableModel because that
1212
class is not accessible to QGIS plugins. Therefore, the author gratefully
1313
acknowledges the following copyright on the original content:
14-
qgsdbtablemodel.cpp
14+
qgsdbtablemodel.cpp
1515
begin : Dec 2007
1616
copyright : (C) 2007 by Marco Hugentobler
1717
email : marco dot hugentobler at karto dot baug dot ethz dot ch

src/plugins/sqlanywhere/salayer.h

+15-14
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/***************************************************************************
22
salayer.h
3-
Definition of vector layer backed by a SQL Anywhere database
3+
Definition of vector layer backed by a SQL Anywhere database
44
-------------------
55
begin : Dec 2010
66
copyright : (C) 2010 by iAnywhere Solutions, Inc.
7-
author : David DeHaan
7+
author : David DeHaan
88
email : ddehaan at sybase dot com
99
1010
***************************************************************************
@@ -36,23 +36,24 @@ class SaLayer : public QgsVectorLayer
3636
public:
3737
//! Constructor
3838
SaLayer( QString path = QString::null
39-
, QString baseName = QString::null
40-
, bool loadDefaultStyleFlag = true )
41-
: QgsVectorLayer( path, baseName, "sqlanywhere", loadDefaultStyleFlag )
39+
, QString baseName = QString::null
40+
, bool loadDefaultStyleFlag = true )
41+
: QgsVectorLayer( path, baseName, "sqlanywhere", loadDefaultStyleFlag )
4242
{
43-
if( isValid() ) {
44-
// The parent QgsMapLayer initialized mDataSource = path.
45-
// Reset this to the value mDataProvider.dataSourceUri()
46-
// so that any modifications to the URI made by the
47-
// data provider make it back into the layer definition.
48-
mDataSource = dataProvider()->dataSourceUri();
49-
SaDebugMsg( "Modified layer source: " + mDataSource );
50-
}
43+
if ( isValid() )
44+
{
45+
// The parent QgsMapLayer initialized mDataSource = path.
46+
// Reset this to the value mDataProvider.dataSourceUri()
47+
// so that any modifications to the URI made by the
48+
// data provider make it back into the layer definition.
49+
mDataSource = dataProvider()->dataSourceUri();
50+
SaDebugMsg( "Modified layer source: " + mDataSource );
51+
}
5152
}
5253

5354
//! Destructor
5455
~SaLayer()
55-
{
56+
{
5657
}
5758
};
5859

src/plugins/sqlanywhere/sanewconnection.cpp

+53-47
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/***************************************************************************
22
sanewconnection.h
3-
Dialogue box for defining new connections to a SQL Anywhere database
3+
Dialogue box for defining new connections to a SQL Anywhere database
44
-------------------
55
begin : Dec 2010
66
copyright : (C) 2010 by iAnywhere Solutions, Inc.
7-
author : David DeHaan
7+
author : David DeHaan
88
email : ddehaan at sybase dot com
99
1010
***************************************************************************
@@ -47,12 +47,12 @@ SaNewConnection::SaNewConnection( QWidget *parent, const QString& connName, Qt::
4747
txtDatabase->setText( settings.value( key + "/database" ).toString() );
4848
txtParameters->setText( settings.value( key + "/parameters" ).toString() );
4949

50-
if ( settings.value( key + "/saveUsername", true ).toBool() )
50+
if ( settings.value( key + "/saveUsername", true ).toBool() )
5151
{
52-
txtUsername->setText( settings.value( key + "/username" ).toString() );
53-
chkStoreUsername->setChecked( true );
52+
txtUsername->setText( settings.value( key + "/username" ).toString() );
53+
chkStoreUsername->setChecked( true );
5454
}
55-
if ( settings.value( key + "/savePassword", false ).toBool() )
55+
if ( settings.value( key + "/savePassword", false ).toBool() )
5656
{
5757
txtPassword->setText( settings.value( key + "/password" ).toString() );
5858
chkStorePassword->setChecked( true );
@@ -61,7 +61,7 @@ SaNewConnection::SaNewConnection( QWidget *parent, const QString& connName, Qt::
6161
chkEstimateMetadata->setChecked( settings.value( key + "/estimateMetadata", false ).toBool() );
6262
chkOtherSchemas->setChecked( settings.value( key + "/otherSchemas", false ).toBool() );
6363

64-
}
64+
}
6565
}
6666

6767
SaNewConnection::~SaNewConnection()
@@ -116,49 +116,55 @@ void SaNewConnection::on_btnConnect_clicked()
116116

117117
void SaNewConnection::testConnection()
118118
{
119-
char errbuf[SACAPI_ERROR_SIZE];
120-
sacapi_i32 code;
121-
SqlAnyConnection *conn;
122-
123-
// load the SQL Anywhere interface
124-
if( !SqlAnyConnection::initApi() ) {
125-
QMessageBox::information( this,
126-
tr("Failed to load interface" ),
127-
tr( SqlAnyConnection::failedInitMsg() ) );
128-
return;
119+
char errbuf[SACAPI_ERROR_SIZE];
120+
sacapi_i32 code;
121+
SqlAnyConnection *conn;
122+
123+
// load the SQL Anywhere interface
124+
if ( !SqlAnyConnection::initApi() )
125+
{
126+
QMessageBox::information( this,
127+
tr( "Failed to load interface" ),
128+
tr( SqlAnyConnection::failedInitMsg() ) );
129+
return;
130+
}
131+
132+
// establish read-only connection to the database
133+
conn = SqlAnyConnection::connect( txtName->text()
134+
, txtHost->text(), txtPort->text(), txtServer->text()
135+
, txtDatabase->text(), txtParameters->text(), txtUsername->text()
136+
, txtPassword->text(), chkSimpleEncryption->isChecked()
137+
, chkEstimateMetadata->isChecked(), true
138+
, code, errbuf, sizeof( errbuf ) );
139+
if ( conn )
140+
{
141+
// retrieve the username and password, in case the user adjusted them
142+
QgsDataSourceURI theUri( conn->uri() );
143+
if ( chkStoreUsername->isChecked() )
144+
{
145+
txtUsername->setText( theUri.username() );
129146
}
130-
131-
// establish read-only connection to the database
132-
conn = SqlAnyConnection::connect( txtName->text()
133-
, txtHost->text(), txtPort->text(), txtServer->text()
134-
, txtDatabase->text(), txtParameters->text(), txtUsername->text()
135-
, txtPassword->text(), chkSimpleEncryption->isChecked()
136-
, chkEstimateMetadata->isChecked(), true
137-
, code, errbuf, sizeof( errbuf ) );
138-
if( conn ) {
139-
// retrieve the username and password, in case the user adjusted them
140-
QgsDataSourceURI theUri( conn->uri() );
141-
if ( chkStoreUsername->isChecked() ) {
142-
txtUsername->setText( theUri.username() );
143-
}
144-
if ( chkStorePassword->isChecked() ) {
145-
txtPassword->setText( theUri.password() );
146-
}
147-
conn->release();
148-
149-
QMessageBox::information( this,
147+
if ( chkStorePassword->isChecked() )
148+
{
149+
txtPassword->setText( theUri.password() );
150+
}
151+
conn->release();
152+
153+
QMessageBox::information( this,
150154
tr( "Test connection" ),
151155
tr( "Connection to %1 was successful" )
152-
.arg( txtDatabase->text() ) );
153-
} else {
154-
QMessageBox::information( this,
156+
.arg( txtDatabase->text() ) );
157+
}
158+
else
159+
{
160+
QMessageBox::information( this,
155161
tr( "Test connection" ),
156162
tr( "Connection failed. "
157-
"Check settings and try again.\n\n"
158-
"SQL Anywhere error code: %1\n"
159-
"Description: %2" )
160-
.arg( code )
161-
.arg( errbuf ) );
162-
}
163-
SqlAnyConnection::releaseApi();
163+
"Check settings and try again.\n\n"
164+
"SQL Anywhere error code: %1\n"
165+
"Description: %2" )
166+
.arg( code )
167+
.arg( errbuf ) );
168+
}
169+
SqlAnyConnection::releaseApi();
164170
}

src/plugins/sqlanywhere/sanewconnection.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/***************************************************************************
22
sanewconnection.h
3-
Dialogue box for defining new connections to a SQL Anywhere database
3+
Dialogue box for defining new connections to a SQL Anywhere database
44
-------------------
55
begin : Dec 2010
66
copyright : (C) 2010 by iAnywhere Solutions, Inc.
7-
author : David DeHaan
7+
author : David DeHaan
88
email : ddehaan at sybase dot com
99
1010
***************************************************************************

0 commit comments

Comments
 (0)