936 changes: 0 additions & 936 deletions src/app/spatialite/qgsspatialitesourceselect.cpp

This file was deleted.

1 change: 1 addition & 0 deletions src/core/qgsdataitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ class CORE_EXPORT QgsLayerItem : public QgsDataItem
QString mUri;
LayerType mLayerType;

public:
static const QIcon &iconPoint();
static const QIcon &iconLine();
static const QIcon &iconPolygon();
Expand Down
21 changes: 18 additions & 3 deletions src/providers/spatialite/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,20 @@
########################################################
# Files

SET(SPATIALITE_SRCS qgsspatialiteprovider.cpp qgsspatialitedataitems.cpp qgsspatialiteconnection.cpp)
SET(SPATIALITE_SRCS
qgsspatialiteprovider.cpp
qgsspatialitedataitems.cpp
qgsspatialiteconnection.cpp
qgsspatialitesourceselect.cpp
qgsspatialitetablemodel.cpp
)

SET(SPATIALITE_MOC_HDRS qgsspatialiteprovider.h qgsspatialitedataitems.h)
SET(SPATIALITE_MOC_HDRS
qgsspatialiteprovider.h
qgsspatialitedataitems.h
qgsspatialitesourceselect.h
qgsspatialitetablemodel.h
)


########################################################
Expand All @@ -13,7 +24,11 @@ SET(SPATIALITE_MOC_HDRS qgsspatialiteprovider.h qgsspatialitedataitems.h)
QT4_WRAP_CPP(SPATIALITE_MOC_SRCS ${SPATIALITE_MOC_HDRS})


INCLUDE_DIRECTORIES(../../core)
INCLUDE_DIRECTORIES(
../../core
../../gui
${CMAKE_CURRENT_BINARY_DIR}/../../ui
)

IF(WITH_INTERNAL_SPATIALITE)
INCLUDE_DIRECTORIES(
Expand Down
14 changes: 14 additions & 0 deletions src/providers/spatialite/qgsspatialiteconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ QStringList QgsSpatiaLiteConnection::connectionList()
return settings.childGroups();
}

void QgsSpatiaLiteConnection::deleteConnection( QString name )
{
QSettings settings;
QString key = "/SpatiaLite/connections/" + name;
settings.remove( key + "/sqlitepath" );
settings.remove( key );
}

QString QgsSpatiaLiteConnection::connectionPath( QString name )
{
QSettings settings;
return settings.value( "/SpatiaLite/connections/" + name + "/sqlitepath" ).toString();
}

// -------

QgsSpatiaLiteConnection::QgsSpatiaLiteConnection( QString name )
Expand Down
2 changes: 2 additions & 0 deletions src/providers/spatialite/qgsspatialiteconnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class QgsSpatiaLiteConnection : public QObject
QString path() { return mPath; }

static QStringList connectionList();
static void deleteConnection( QString name );
static QString connectionPath( QString name );

typedef struct TableEntry
{
Expand Down
36 changes: 14 additions & 22 deletions src/providers/spatialite/qgsspatialitedataitems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "qgsspatialiteprovider.h"
#include "qgsspatialiteconnection.h"
#include "qgsspatialitesourceselect.h"

#include "qgslogger.h"

Expand All @@ -11,6 +12,7 @@
QgsSLConnectionItem::QgsSLConnectionItem( QgsDataItem* parent, QString name, QString path )
: QgsDataCollectionItem( parent, name, path )
{
mToolTip = QgsSpatiaLiteConnection::connectionPath( name );
}

QgsSLConnectionItem::~QgsSLConnectionItem()
Expand Down Expand Up @@ -92,9 +94,9 @@ QList<QAction*> QgsSLConnectionItem::actions()
{
QList<QAction*> lst;

QAction* actionEdit = new QAction( tr( "Edit..." ), this );
connect( actionEdit, SIGNAL( triggered() ), this, SLOT( editConnection() ) );
lst.append( actionEdit );
//QAction* actionEdit = new QAction( tr( "Edit..." ), this );
//connect( actionEdit, SIGNAL( triggered() ), this, SLOT( editConnection() ) );
//lst.append( actionEdit );

QAction* actionDelete = new QAction( tr( "Delete" ), this );
connect( actionDelete, SIGNAL( triggered() ), this, SLOT( deleteConnection() ) );
Expand All @@ -105,23 +107,13 @@ QList<QAction*> QgsSLConnectionItem::actions()

void QgsSLConnectionItem::editConnection()
{
/*
QgsPgNewConnection nc( NULL, mName );
if ( nc.exec() )
{
// the parent should be updated
mParent->refresh();
}
*/
}

void QgsSLConnectionItem::deleteConnection()
{
/*
QgsPgSourceSelect::deleteConnection( mName );
QgsSpatiaLiteConnection::deleteConnection( mName );
// the parent should be updated
mParent->refresh();
*/
}


Expand Down Expand Up @@ -162,12 +154,9 @@ QList<QAction*> QgsSLRootItem::actions()

QWidget * QgsSLRootItem::paramWidget()
{
/*
QgsSLSourceSelect *select = new QgsSLSourceSelect( 0, 0, true, true );
QgsSpatiaLiteSourceSelect *select = new QgsSpatiaLiteSourceSelect( 0, 0, true );
connect( select, SIGNAL( connectionsChanged() ), this, SLOT( connectionsChanged() ) );
return select;
*/
return NULL;
}

void QgsSLRootItem::connectionsChanged()
Expand All @@ -177,17 +166,20 @@ void QgsSLRootItem::connectionsChanged()

void QgsSLRootItem::newConnection()
{
/*
QgsSLNewConnection nc( NULL );
if ( nc.exec() )
if ( QgsSpatiaLiteSourceSelect::newConnection( NULL ) )
{
refresh();
}
*/
}

// ---------------------------------------------------------------------------

QGISEXTERN QgsSpatiaLiteSourceSelect * selectWidget( QWidget * parent, Qt::WFlags fl )
{
// TODO: this should be somewhere else
return new QgsSpatiaLiteSourceSelect( parent, fl, false );
}

QGISEXTERN int dataCapabilities()
{
return QgsDataProvider::Database;
Expand Down
500 changes: 500 additions & 0 deletions src/providers/spatialite/qgsspatialitesourceselect.cpp

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@
#include "qgsspatialitetablemodel.h"
#include "qgscontexthelp.h"

extern "C"
{
#include <sqlite3.h>
}

#include <QThread>

#include <vector>
Expand All @@ -40,7 +35,6 @@ extern "C"

class QStringList;
class QTableWidgetItem;
class QgisApp;
class QPushButton;

/*! \class QgsSpatiaLiteSourceSelect
Expand All @@ -56,8 +50,11 @@ class QgsSpatiaLiteSourceSelect: public QDialog, private Ui::QgsDbSourceSelectBa

public:

/* Open file selector to add new connection */
static bool newConnection( QWidget* parent );

//! Constructor
QgsSpatiaLiteSourceSelect( QgisApp * app, Qt::WFlags fl = QgisGui::ModalDialogFlags );
QgsSpatiaLiteSourceSelect( QWidget * parent, Qt::WFlags fl = QgisGui::ModalDialogFlags, bool embedded = false );
//! Destructor
~QgsSpatiaLiteSourceSelect() {}
//! Populate the connection list combo box
Expand Down Expand Up @@ -96,6 +93,10 @@ class QgsSpatiaLiteSourceSelect: public QDialog, private Ui::QgsDbSourceSelectBa

void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }

signals:
void connectionsChanged();
void addDatabaseLayers( QStringList const & paths, QString const & providerKey );

private:
enum columns
{
Expand All @@ -108,31 +109,6 @@ class QgsSpatiaLiteSourceSelect: public QDialog, private Ui::QgsDbSourceSelectBa
typedef std::pair < QString, QString > geomPair;
typedef std::list < geomPair > geomCol;

/**Checks if geometry_columns_auth table exists*/
bool checkGeometryColumnsAuth( sqlite3 * handle );

/**Checks if views_geometry_columns table exists*/
bool checkViewsGeometryColumns( sqlite3 * handle );

/**Checks if virts_geometry_columns table exists*/
bool checkVirtsGeometryColumns( sqlite3 * handle );

/**Checks if this layer has been declared HIDDEN*/
bool isDeclaredHidden( sqlite3 * handle, QString table, QString geom );

/**Checks if this layer is a RasterLite-1 datasource*/
bool isRasterlite1Datasource( sqlite3 * handle, const char * table );

/**cleaning well-formatted SQL strings*/
QString quotedValue( QString value ) const;

/**Inserts information about the spatial tables into mTableModel*/
bool getTableInfo( sqlite3 * handle );

// SpatiaLite DB open / close
sqlite3 *openSpatiaLiteDb( QString path );
void closeSpatiaLiteDb( sqlite3 * handle );

// Set the position of the database connection list to the last
// used one.
void setConnectionListPosition();
Expand All @@ -145,8 +121,6 @@ class QgsSpatiaLiteSourceSelect: public QDialog, private Ui::QgsDbSourceSelectBa
QStringList m_selectedTables;
// Storage for the range of layer type icons
QMap < QString, QPair < QString, QIcon > >mLayerIcons;
//! Pointer to the qgis application mainwindow
QgisApp *qgisApp;
//! Model that acts as datasource for mTableTreeWidget
QgsSpatiaLiteTableModel mTableModel;
QgsDbFilterProxyModel mProxyModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include "qgsspatialitetablemodel.h"
#include "qgsapplication.h"
#include "qgisapp.h"
#include "qgsdataitem.h" // for icons

QgsSpatiaLiteTableModel::QgsSpatiaLiteTableModel(): QStandardItemModel(), mTableCount( 0 )
{
Expand Down Expand Up @@ -170,17 +170,17 @@ QIcon QgsSpatiaLiteTableModel::iconForType( QGis::WkbType type ) const
{
if ( type == QGis::WKBPoint || type == QGis::WKBPoint25D || type == QGis::WKBMultiPoint || type == QGis::WKBMultiPoint25D )
{
return QgisApp::getThemeIcon( "/mIconPointLayer.png" );
return QgsLayerItem::iconPoint();
}
else if ( type == QGis::WKBLineString || type == QGis::WKBLineString25D || type == QGis::WKBMultiLineString
|| type == QGis::WKBMultiLineString25D )
{
return QgisApp::getThemeIcon( "/mIconLineLayer.png" );
return QgsLayerItem::iconLine();
}
else if ( type == QGis::WKBPolygon || type == QGis::WKBPolygon25D || type == QGis::WKBMultiPolygon
|| type == QGis::WKBMultiPolygon25D )
{
return QgisApp::getThemeIcon( "/mIconPolygonLayer.png" );
return QgsLayerItem::iconPolygon();
}
else
return QIcon();
Expand Down
File renamed without changes.