Skip to content

Commit

Permalink
Merged the source select UIs for both PG and SL to allow to use a sub…
Browse files Browse the repository at this point in the history
…set query loading a SL layer

git-svn-id: http://svn.osgeo.org/qgis/trunk@15214 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
brushtyler committed Feb 19, 2011
1 parent 6b68070 commit 05c7708
Show file tree
Hide file tree
Showing 15 changed files with 205 additions and 403 deletions.
17 changes: 8 additions & 9 deletions src/app/CMakeLists.txt
Expand Up @@ -301,17 +301,16 @@ ENDIF (POSTGRES_FOUND)

IF (HAVE_SPATIALITE)
SET (QGIS_APP_SRCS ${QGIS_APP_SRCS}
qgsspatialitesourceselect.cpp
qgsnewspatialitelayerdialog.cpp
qgsspatialitesridsdialog.cpp
qgsspatialitefilterproxymodel.cpp
qgsspatialitetablemodel.cpp
spatialite/qgsspatialitesourceselect.cpp
spatialite/qgsnewspatialitelayerdialog.cpp
spatialite/qgsspatialitesridsdialog.cpp
spatialite/qgsspatialitetablemodel.cpp
)
SET (QGIS_APP_MOC_HDRS ${QGIS_APP_MOC_HDRS}
qgsspatialitesourceselect.h
qgsnewspatialitelayerdialog.h
qgsspatialitesridsdialog.h
qgsspatialitetablemodel.h
spatialite/qgsspatialitesourceselect.h
spatialite/qgsnewspatialitelayerdialog.h
spatialite/qgsspatialitesridsdialog.h
spatialite/qgsspatialitetablemodel.h
)
ENDIF (HAVE_SPATIALITE)

Expand Down
4 changes: 2 additions & 2 deletions src/app/postgres/qgspgsourceselect.h
Expand Up @@ -17,7 +17,7 @@
/* $Id$ */
#ifndef QGSPGSOURCESELECT_H
#define QGSPGSOURCESELECT_H
#include "ui_qgspgsourceselectbase.h"
#include "ui_qgsdbsourceselectbase.h"
#include "qgisgui.h"
#include "qgsdbfilterproxymodel.h"
#include "qgsdbtablemodel.h"
Expand Down Expand Up @@ -99,7 +99,7 @@ class QgsPgSourceSelectDelegate : public QItemDelegate
* for PostGIS enabled PostgreSQL databases. The user can then connect and add
* tables from the database to the map canvas.
*/
class QgsPgSourceSelect : public QDialog, private Ui::QgsPgSourceSelectBase
class QgsPgSourceSelect : public QDialog, private Ui::QgsDbSourceSelectBase
{
Q_OBJECT

Expand Down
21 changes: 7 additions & 14 deletions src/app/qgisapp.cpp
Expand Up @@ -112,6 +112,7 @@
#include "qgscredentialdialog.h"
#include "qgscursors.h"
#include "qgscustomprojectiondialog.h"
#include "qgsdatasourceuri.h"
#include "qgsencodingfiledialog.h"
#include "qgsexception.h"
#include "qgsfeature.h"
Expand Down Expand Up @@ -235,8 +236,8 @@ extern "C"
{
#include <spatialite.h>
}
#include "qgsspatialitesourceselect.h"
#include "qgsnewspatialitelayerdialog.h"
#include "spatialite/qgsspatialitesourceselect.h"
#include "spatialite/qgsnewspatialitelayerdialog.h"
#endif

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

QApplication::setOverrideCursor( Qt::WaitCursor );

QString connectionInfo = dbs->connectionInfo();
// for each selected table, connect to the database, parse the Wkt geometry,
// and build a canvasitem for it
// readWKB(connectionInfo,tables);
QStringList::Iterator it = tables.begin();
while ( it != tables.end() )
{

// create the layer
//qWarning("creating layer");
QgsVectorLayer *layer = new QgsVectorLayer( connectionInfo + " " + *it, *it, "postgres" );
QgsDataSourceURI uri( *it );
QgsVectorLayer *layer = new QgsVectorLayer( uri.uri(), uri.table(), "postgres" );
if ( layer->isValid() )
{
// register this layer with the central layers registry
Expand Down Expand Up @@ -3101,20 +3101,13 @@ void QgisApp::addSpatiaLiteLayer()

QApplication::setOverrideCursor( Qt::WaitCursor );

QString connectionInfo = dbs->connectionInfo();
// for each selected table, connect to the database and build a canvasitem for it
QStringList::Iterator it = tables.begin();
while ( it != tables.end() )
{
// normalizing the layer name
QString layername = *it;
layername = layername.mid( 1 );
int idx = layername.indexOf( "\" (" );
if ( idx > 0 )
layername.truncate( idx );

// create the layer
QgsVectorLayer *layer = new QgsVectorLayer( "dbname='" + connectionInfo + "' table=" + *it + ") sql=", layername, "spatialite" );
QgsDataSourceURI uri( *it );
QgsVectorLayer *layer = new QgsVectorLayer( uri.uri(), uri.table(), "spatialite" );
if ( layer->isValid() )
{
// register this layer with the central layers registry
Expand Down
52 changes: 0 additions & 52 deletions src/app/qgsspatialitefilterproxymodel.cpp

This file was deleted.

39 changes: 0 additions & 39 deletions src/app/qgsspatialitefilterproxymodel.h

This file was deleted.

File renamed without changes.
File renamed without changes.

0 comments on commit 05c7708

Please sign in to comment.