Skip to content

Commit fa8c364

Browse files
author
brushtyler
committed
Merged the source select UIs for both PG and SL to allow to use a subset query loading a SL layer
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15214 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 9f135b8 commit fa8c364

15 files changed

+205
-403
lines changed

src/app/CMakeLists.txt

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -301,17 +301,16 @@ ENDIF (POSTGRES_FOUND)
301301

302302
IF (HAVE_SPATIALITE)
303303
SET (QGIS_APP_SRCS ${QGIS_APP_SRCS}
304-
qgsspatialitesourceselect.cpp
305-
qgsnewspatialitelayerdialog.cpp
306-
qgsspatialitesridsdialog.cpp
307-
qgsspatialitefilterproxymodel.cpp
308-
qgsspatialitetablemodel.cpp
304+
spatialite/qgsspatialitesourceselect.cpp
305+
spatialite/qgsnewspatialitelayerdialog.cpp
306+
spatialite/qgsspatialitesridsdialog.cpp
307+
spatialite/qgsspatialitetablemodel.cpp
309308
)
310309
SET (QGIS_APP_MOC_HDRS ${QGIS_APP_MOC_HDRS}
311-
qgsspatialitesourceselect.h
312-
qgsnewspatialitelayerdialog.h
313-
qgsspatialitesridsdialog.h
314-
qgsspatialitetablemodel.h
310+
spatialite/qgsspatialitesourceselect.h
311+
spatialite/qgsnewspatialitelayerdialog.h
312+
spatialite/qgsspatialitesridsdialog.h
313+
spatialite/qgsspatialitetablemodel.h
315314
)
316315
ENDIF (HAVE_SPATIALITE)
317316

src/app/postgres/qgspgsourceselect.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
/* $Id$ */
1818
#ifndef QGSPGSOURCESELECT_H
1919
#define QGSPGSOURCESELECT_H
20-
#include "ui_qgspgsourceselectbase.h"
20+
#include "ui_qgsdbsourceselectbase.h"
2121
#include "qgisgui.h"
2222
#include "qgsdbfilterproxymodel.h"
2323
#include "qgsdbtablemodel.h"
@@ -99,7 +99,7 @@ class QgsPgSourceSelectDelegate : public QItemDelegate
9999
* for PostGIS enabled PostgreSQL databases. The user can then connect and add
100100
* tables from the database to the map canvas.
101101
*/
102-
class QgsPgSourceSelect : public QDialog, private Ui::QgsPgSourceSelectBase
102+
class QgsPgSourceSelect : public QDialog, private Ui::QgsDbSourceSelectBase
103103
{
104104
Q_OBJECT
105105

src/app/qgisapp.cpp

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@
112112
#include "qgscredentialdialog.h"
113113
#include "qgscursors.h"
114114
#include "qgscustomprojectiondialog.h"
115+
#include "qgsdatasourceuri.h"
115116
#include "qgsencodingfiledialog.h"
116117
#include "qgsexception.h"
117118
#include "qgsfeature.h"
@@ -235,8 +236,8 @@ extern "C"
235236
{
236237
#include <spatialite.h>
237238
}
238-
#include "qgsspatialitesourceselect.h"
239-
#include "qgsnewspatialitelayerdialog.h"
239+
#include "spatialite/qgsspatialitesourceselect.h"
240+
#include "spatialite/qgsnewspatialitelayerdialog.h"
240241
#endif
241242

242243
#include "qgspythonutils.h"
@@ -3025,17 +3026,16 @@ void QgisApp::addDatabaseLayer()
30253026

30263027
QApplication::setOverrideCursor( Qt::WaitCursor );
30273028

3028-
QString connectionInfo = dbs->connectionInfo();
30293029
// for each selected table, connect to the database, parse the Wkt geometry,
30303030
// and build a canvasitem for it
30313031
// readWKB(connectionInfo,tables);
30323032
QStringList::Iterator it = tables.begin();
30333033
while ( it != tables.end() )
30343034
{
3035-
30363035
// create the layer
30373036
//qWarning("creating layer");
3038-
QgsVectorLayer *layer = new QgsVectorLayer( connectionInfo + " " + *it, *it, "postgres" );
3037+
QgsDataSourceURI uri( *it );
3038+
QgsVectorLayer *layer = new QgsVectorLayer( uri.uri(), uri.table(), "postgres" );
30393039
if ( layer->isValid() )
30403040
{
30413041
// register this layer with the central layers registry
@@ -3101,20 +3101,13 @@ void QgisApp::addSpatiaLiteLayer()
31013101

31023102
QApplication::setOverrideCursor( Qt::WaitCursor );
31033103

3104-
QString connectionInfo = dbs->connectionInfo();
31053104
// for each selected table, connect to the database and build a canvasitem for it
31063105
QStringList::Iterator it = tables.begin();
31073106
while ( it != tables.end() )
31083107
{
3109-
// normalizing the layer name
3110-
QString layername = *it;
3111-
layername = layername.mid( 1 );
3112-
int idx = layername.indexOf( "\" (" );
3113-
if ( idx > 0 )
3114-
layername.truncate( idx );
3115-
31163108
// create the layer
3117-
QgsVectorLayer *layer = new QgsVectorLayer( "dbname='" + connectionInfo + "' table=" + *it + ") sql=", layername, "spatialite" );
3109+
QgsDataSourceURI uri( *it );
3110+
QgsVectorLayer *layer = new QgsVectorLayer( uri.uri(), uri.table(), "spatialite" );
31183111
if ( layer->isValid() )
31193112
{
31203113
// register this layer with the central layers registry

src/app/qgsspatialitefilterproxymodel.cpp

Lines changed: 0 additions & 52 deletions
This file was deleted.

src/app/qgsspatialitefilterproxymodel.h

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)