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

This file was deleted.

1 change: 1 addition & 0 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ SET(QGIS_CORE_SRCS
symbology-ng/qgssymbologyv2conversion.cpp
symbology-ng/qgssvgcache.cpp
symbology-ng/qgsellipsesymbollayerv2.cpp
symbology-ng/qgspointdisplacementrenderer.cpp

qgis.cpp
qgsapplication.cpp
Expand Down
13 changes: 11 additions & 2 deletions src/core/qgscoordinatereferencesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,18 @@ bool QgsCoordinateReferenceSystem::loadFromDb( QString db, QString expression, Q
{
mAuthId = QString( "USER:%1" ).arg( mSrsId );
}
else if ( mAuthId.startsWith( "EPSG:", Qt::CaseInsensitive ) )
{
OSRDestroySpatialReference( mCRS );
mCRS = OSRNewSpatialReference( NULL );
mIsValidFlag = OSRSetFromUserInput( mCRS, mAuthId.toLower().toAscii() ) == OGRERR_NONE;
setMapUnits();
}

setProj4String( toProj4 );
setMapUnits();
if ( !mIsValidFlag )
{
setProj4String( toProj4 );
}
}
else
{
Expand Down
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
14 changes: 7 additions & 7 deletions src/core/qgspallabeling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ QgsPalLayerSettings::QgsPalLayerSettings()
plusSign = false;
labelPerPart = false;
mergeLines = false;
multiLineLabels = false;
multiLineLabels = true;
minFeatureSize = 0.0;
vectorScaleFactor = 1.0;
rasterCompressFactor = 1.0;
Expand Down Expand Up @@ -434,10 +434,11 @@ void QgsPalLayerSettings::calculateLabelSize( const QFontMetricsF* fm, QString t
{
text.append( ">" );
}
QRectF labelRect = fm->boundingRect( text );

double w, h;
if ( !multiLineLabels )
{
QRectF labelRect = fm->boundingRect( text );
w = labelRect.width() / rasterCompressFactor;
h = labelRect.height() / rasterCompressFactor;
}
Expand All @@ -452,9 +453,9 @@ void QgsPalLayerSettings::calculateLabelSize( const QFontMetricsF* fm, QString t
if ( width > w )
{
w = width;
}
w /= rasterCompressFactor;
}
}
w /= rasterCompressFactor;
}
QgsPoint ptSize = xform->toMapCoordinatesF( w, h );

Expand All @@ -471,14 +472,13 @@ void QgsPalLayerSettings::registerFeature( QgsVectorLayer* layer, QgsFeature& f
QgsExpression* exp = getLabelExpression();
if ( exp->hasParserError() )
{
QgsDebugMsg( "PASER HAS ERROR:" + exp->parserErrorString() );
QgsDebugMsg( "Expression parser error:" + exp->parserErrorString() );
return;
}
QVariant result = exp->evaluate( &f, layer->dataProvider()->fields() );
QgsDebugMsg( "VALUE = " + result.toString() );
if ( exp->hasEvalError() )
{
QgsDebugMsg( "Expression Label Error = " + exp->evalErrorString() );
QgsDebugMsg( "Expression parser eval error:" + exp->evalErrorString() );
return;
}
labelText = result.toString();
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsscalecalculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void QgsScaleCalculator::setMapUnits( QGis::UnitType mapUnits )

QGis::UnitType QgsScaleCalculator::mapUnits() const
{
QgsDebugMsgLevel( QString( "Map units returned as %1" ).arg( QString::number( mMapUnits ) ), 3 );
QgsDebugMsgLevel( QString( "Map units returned as %1" ).arg( QString::number( mMapUnits ) ), 4 );
return mMapUnits;
}

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
class QgsVectorLayer;

/**A renderer that automatically displaces points with the same position*/
class QgsPointDisplacementRenderer: public QgsFeatureRendererV2
class CORE_EXPORT QgsPointDisplacementRenderer: public QgsFeatureRendererV2
{
public:
QgsPointDisplacementRenderer( const QString& labelAttributeName = "" );
Expand Down
4 changes: 4 additions & 0 deletions src/core/symbology-ng/qgsrendererv2registry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "qgscategorizedsymbolrendererv2.h"
#include "qgsgraduatedsymbolrendererv2.h"
#include "qgsrulebasedrendererv2.h"
#include "qgspointdisplacementrenderer.h"

QgsRendererV2Registry* QgsRendererV2Registry::mInstance = NULL;

Expand All @@ -24,6 +25,9 @@ QgsRendererV2Registry::QgsRendererV2Registry()
addRenderer( new QgsRendererV2Metadata( "RuleRenderer",
QObject::tr( "Rule-based" ),
QgsRuleBasedRendererV2::create ) );
addRenderer( new QgsRendererV2Metadata( "pointDisplacement",
QObject::tr( "Point displacement" ),
QgsPointDisplacementRenderer::create ) );
}

QgsRendererV2Registry::~QgsRendererV2Registry()
Expand Down
2 changes: 2 additions & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ symbology-ng/qgsvectorcolorbrewercolorrampv2dialog.cpp
symbology-ng/characterwidget.cpp
symbology-ng/qgsstylev2exportimportdialog.cpp
symbology-ng/qgsellipsesymbollayerv2widget.cpp
symbology-ng/qgspointdisplacementrendererwidget.cpp

attributetable/qgsattributetablemodel.cpp
attributetable/qgsattributetablememorymodel.cpp
Expand Down Expand Up @@ -98,6 +99,7 @@ symbology-ng/qgspenstylecombobox.h
symbology-ng/qgsbrushstylecombobox.h
symbology-ng/qgsstylev2exportimportdialog.h
symbology-ng/qgsellipsesymbollayerv2widget.h
symbology-ng/qgspointdisplacementrendererwidget.h

attributetable/qgsattributetableview.h
attributetable/qgsattributetablemodel.h
Expand Down
25 changes: 18 additions & 7 deletions src/gui/qgsexpressionbuilderwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,24 @@ void QgsExpressionBuilderWidget::on_txtExpressionString_textChanged()
// Maybe just calling exp.evaluate()?
if ( mLayer )
{
// TODO We should really cache the feature.
QgsFeature feature;
mLayer->featureAtId( 0 , feature );
QVariant value = exp.evaluate( &feature, mLayer->pendingFields() );

if ( !exp.hasEvalError() )
lblPreview->setText( value.toString() );
if ( !mFeature.isValid() )
{
mLayer->select( mLayer->pendingAllAttributesList() );
mLayer->nextFeature( mFeature );
}

if ( mFeature.isValid() )
{
QVariant value = exp.evaluate( &mFeature, mLayer->pendingFields() );
if ( !exp.hasEvalError() )
lblPreview->setText( value.toString() );
}
else
{
// The feautre is invaild because we don't have one but that doesn't mean user can't
// build a expression string. They just get no preview.
lblPreview->setText("");
}
}

if ( exp.hasParserError() || exp.hasEvalError() )
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsexpressionbuilderwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class GUI_EXPORT QgsExpressionBuilderWidget : public QWidget, private Ui::QgsExp
QStandardItemModel *mModel;
QgsExpressionItemSearchProxy *mProxyModel;
QMap<QString, QgsExpressionItem*> mExpressionGroups;
QgsFeature* mFeature;
QgsFeature mFeature;
};

#endif // QGSEXPRESSIONBUILDER_H
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

class QgsPointDisplacementRenderer;

class QgsPointDisplacementRendererWidget: public QgsRendererV2Widget, private Ui::QgsPointDisplacementRendererWidgetBase
class GUI_EXPORT QgsPointDisplacementRendererWidget: public QgsRendererV2Widget, private Ui::QgsPointDisplacementRendererWidgetBase
{
Q_OBJECT
public:
Expand Down
2 changes: 2 additions & 0 deletions src/gui/symbology-ng/qgsrendererv2propertiesdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "qgscategorizedsymbolrendererv2widget.h"
#include "qgsgraduatedsymbolrendererv2widget.h"
#include "qgsrulebasedrendererv2widget.h"
#include "qgspointdisplacementrendererwidget.h"

#include "qgssymbollevelsv2dialog.h"

Expand Down Expand Up @@ -53,6 +54,7 @@ static void _initRendererWidgetFunctions()
_initRenderer( "categorizedSymbol", QgsCategorizedSymbolRendererV2Widget::create, "rendererCategorizedSymbol.png" );
_initRenderer( "graduatedSymbol", QgsGraduatedSymbolRendererV2Widget::create, "rendererGraduatedSymbol.png" );
_initRenderer( "RuleRenderer", QgsRuleBasedRendererV2Widget::create );
_initRenderer( "pointDisplacement", QgsPointDisplacementRendererWidget::create );
initialized = true;
}

Expand Down
1 change: 0 additions & 1 deletion src/plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ ADD_SUBDIRECTORY(raster_terrain_analysis)
ADD_SUBDIRECTORY(coordinate_capture)
ADD_SUBDIRECTORY(dxf2shp_converter)
ADD_SUBDIRECTORY(evis)
ADD_SUBDIRECTORY(point_displacement_renderer)
ADD_SUBDIRECTORY(spatialquery)
ADD_SUBDIRECTORY(sqlanywhere)
ADD_SUBDIRECTORY(roadgraph)
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/georeferencer/qgsopenrasterdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void QgsOpenRasterDialog::on_tbnSelectRaster_clicked()

// What DOING this code?
QgsProject* prj = QgsProject::instance();
QString projBehaviour = settings.value( "/Projections/defaultBehaviour" ).toString();
QString projBehaviour = settings.value( "/Projections/defaultBehaviour", "prompt" ).toString();
QString projectCRS = prj->readEntry( "SpatialRefSys", "/ProjectCRSProj4String" );
int projectCrsId = prj->readNumEntry( "SpatialRefSys", "/ProjectCrsId" );

Expand Down
56 changes: 0 additions & 56 deletions src/plugins/point_displacement_renderer/CMakeLists.txt

This file was deleted.

86 changes: 0 additions & 86 deletions src/plugins/point_displacement_renderer/qgsdisplacementplugin.cpp

This file was deleted.

40 changes: 0 additions & 40 deletions src/plugins/point_displacement_renderer/qgsdisplacementplugin.h

This file was deleted.

23 changes: 13 additions & 10 deletions src/providers/postgres/qgspostgresprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,13 @@ QgsVectorLayerImport::ImportError QgsPostgresProvider::createEmptyLayer(
if ( primaryKeyType.isEmpty() )
{
primaryKeyType = "serial";
/* TODO
// check the feature count to choose if create a serial8 pk field
#if 0
// TODO: check the feature count to choose if create a serial8 pk field
if ( layer->featureCount() > 0xFFFFFF )
{
primaryKeyType = "serial8";
}*/
}
#endif
}

try
Expand Down Expand Up @@ -1153,13 +1154,15 @@ qint64 QgsPostgresProvider::getBinaryInt( PGresult *queryResult, int row, int co
char *p = PQgetvalue( queryResult, row, col );
size_t s = PQgetlength( queryResult, row, col );

#ifdef QGISDEBUG
QString buf = "";
for ( size_t i = 0; i < s; i++ )
{
buf += QString( "%1 " ).arg( *( unsigned char * )( p + i ), 0, 16, QLatin1Char( ' ' ) );
}

QgsDebugMsgLevel( QString( "int in hex:%1" ).arg( buf ), 3 );
QgsDebugMsgLevel( QString( "int in hex:%1" ).arg( buf ), 4 );
#endif

switch ( s )
{
Expand Down Expand Up @@ -1191,18 +1194,18 @@ qint64 QgsPostgresProvider::getBinaryInt( PGresult *queryResult, int row, int co

if ( swapEndian )
{
QgsDebugMsg( QString( "swap oid0:%1 oid1:%2" ).arg( oid0 ).arg( oid1 ) );
QgsDebugMsgLevel( QString( "swap oid0:%1 oid1:%2" ).arg( oid0 ).arg( oid1 ), 4 );
oid0 = ntohl( oid0 );
oid1 = ntohl( oid1 );
}

QgsDebugMsg( QString( "oid0:%1 oid1:%2" ).arg( oid0 ).arg( oid1 ) );
QgsDebugMsgLevel( QString( "oid0:%1 oid1:%2" ).arg( oid0 ).arg( oid1 ), 4 );
oid = oid0;
QgsDebugMsg( QString( "oid:%1" ).arg( oid ) );
QgsDebugMsgLevel( QString( "oid:%1" ).arg( oid ), 4 );
oid <<= 32;
QgsDebugMsg( QString( "oid:%1" ).arg( oid ) );
QgsDebugMsgLevel( QString( "oid:%1" ).arg( oid ), 4 );
oid |= oid1;
QgsDebugMsg( QString( "oid:%1" ).arg( oid ) );
QgsDebugMsgLevel( QString( "oid:%1" ).arg( oid ), 4 );
}
break;

Expand All @@ -1226,7 +1229,7 @@ bool QgsPostgresProvider::getFeature( PGresult *queryResult, int row, bool fetch
try
{
QgsFeatureId oid = getBinaryInt( queryResult, row, 0 );
QgsDebugMsgLevel( QString( "oid=%1" ).arg( oid ), 3 );
QgsDebugMsgLevel( QString( "oid=%1" ).arg( oid ), 4 );

feature.setFeatureId( oid );
feature.clearAttributeMap();
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)
SET(SPATIALITE_SRCS
qgsspatialiteprovider.cpp
qgsspatialitedataitems.cpp
qgsspatialiteconnection.cpp
qgsspatialitesourceselect.cpp
qgsspatialitetablemodel.cpp
)

SET(SPATIALITE_MOC_HDRS qgsspatialiteprovider.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)
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
520 changes: 520 additions & 0 deletions src/providers/spatialite/qgsspatialiteconnection.cpp

Large diffs are not rendered by default.

85 changes: 85 additions & 0 deletions src/providers/spatialite/qgsspatialiteconnection.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#ifndef QGSSPATIALITECONNECTION_H
#define QGSSPATIALITECONNECTION_H

#include <QStringList>
#include <QObject>

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

class QgsSpatiaLiteConnection : public QObject
{
public:
/** construct a connection. Name can be either stored connection name or a path to the database file */
QgsSpatiaLiteConnection( QString name );

QString path() { return mPath; }

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

typedef struct TableEntry
{
TableEntry( QString _tableName, QString _column, QString _type )
: tableName( _tableName ), column( _column ), type( _type ) {}
QString tableName;
QString column;
QString type;
} TableEntry;

enum Error
{
NoError,
NotExists,
FailedToOpen,
FailedToCheckMetadata,
FailedToGetTables,
};

Error fetchTables( bool loadGeometrylessTables );

/** return list of tables. fetchTables() function has to be called before */
QList<TableEntry> tables() { return mTables; }

/** return additional error message (if an error occurred before) */
QString errorMessage() { return mErrorMsg; }

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

/**Checks if geometry_columns and spatial_ref_sys exist and have expected layout*/
bool checkHasMetadataTables( sqlite3* handle );

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

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

/**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 );

QString mErrorMsg;
QString mPath; // full path to the database

QList<TableEntry> mTables;
};

#endif // QGSSPATIALITECONNECTION_H
192 changes: 192 additions & 0 deletions src/providers/spatialite/qgsspatialitedataitems.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
#include "qgsspatialitedataitems.h"

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

#include "qgslogger.h"

#include <QAction>


QgsSLConnectionItem::QgsSLConnectionItem( QgsDataItem* parent, QString name, QString path )
: QgsDataCollectionItem( parent, name, path )
{
mToolTip = QgsSpatiaLiteConnection::connectionPath( name );
}

QgsSLConnectionItem::~QgsSLConnectionItem()
{
}

static QgsLayerItem::LayerType _layerTypeFromDb( QString dbType )
{
if ( dbType == "POINT" || dbType == "MULTIPOINT" )
{
return QgsLayerItem::Point;
}
else if ( dbType == "LINESTRING" || dbType == "MULTILINESTRING" )
{
return QgsLayerItem::Line;
}
else if ( dbType == "POLYGON" || dbType == "MULTIPOLYGON" )
{
return QgsLayerItem::Polygon;
}
else if ( dbType == "qgis_table" )
{
return QgsLayerItem::Table;
}
else
{
return QgsLayerItem::NoType;
}
}

QVector<QgsDataItem*> QgsSLConnectionItem::createChildren()
{
QgsDebugMsg( "Entered" );
QVector<QgsDataItem*> children;
QgsSpatiaLiteConnection connection( mName );

QgsSpatiaLiteConnection::Error err = connection.fetchTables( false ); // TODO: allow geometryless tables
if ( err != QgsSpatiaLiteConnection::NoError )
{
QString msg;
switch ( err )
{
case QgsSpatiaLiteConnection::NotExists: msg = tr( "Database does not exist" ); break;
case QgsSpatiaLiteConnection::FailedToOpen: msg = tr( "Failed to open database" ); break;
case QgsSpatiaLiteConnection::FailedToCheckMetadata: msg = tr( "Failed to check metadata" ); break;
case QgsSpatiaLiteConnection::FailedToGetTables: msg = tr( "Failed to get list of tables" ); break;
default: msg = tr( "Unknown error" ); break;
}
QString msgDetails = connection.errorMessage();
if ( !msgDetails.isEmpty() )
msg = QString( "%1 (%2)" ).arg( msg ).arg( msgDetails );
children.append( new QgsErrorItem( this, msg, mPath + "/error" ) );
return children;
}

QString connectionInfo = QString( "dbname='%1'" ).arg( QString( connection.path() ).replace( "'", "\\'" ) );
QgsDataSourceURI uri( connectionInfo );

foreach( const QgsSpatiaLiteConnection::TableEntry& entry, connection.tables() )
{
uri.setDataSource( QString(), entry.tableName, entry.column, QString(), QString() );
QgsSLLayerItem * layer = new QgsSLLayerItem( this, entry.tableName, mPath + "/" + entry.tableName, uri.uri(), _layerTypeFromDb( entry.type ) );
children.append( layer );
}
return children;
}

bool QgsSLConnectionItem::equal( const QgsDataItem *other )
{
if ( type() != other->type() )
{
return false;
}
const QgsSLConnectionItem *o = dynamic_cast<const QgsSLConnectionItem *>( other );
return ( mPath == o->mPath && mName == o->mName );
}

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* actionDelete = new QAction( tr( "Delete" ), this );
connect( actionDelete, SIGNAL( triggered() ), this, SLOT( deleteConnection() ) );
lst.append( actionDelete );

return lst;
}

void QgsSLConnectionItem::editConnection()
{
}

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


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

QgsSLRootItem::QgsSLRootItem( QgsDataItem* parent, QString name, QString path )
: QgsDataCollectionItem( parent, name, path )
{
mIcon = QIcon( getThemePixmap( "mIconSpatialite.png" ) );
populate();
}

QgsSLRootItem::~QgsSLRootItem()
{
}

QVector<QgsDataItem*> QgsSLRootItem::createChildren()
{
QVector<QgsDataItem*> connections;
foreach( QString connName, QgsSpatiaLiteConnection::connectionList() )
{
QgsDataItem * conn = new QgsSLConnectionItem( this, connName, mPath + "/" + connName );
connections.push_back( conn );
}
return connections;
}

QList<QAction*> QgsSLRootItem::actions()
{
QList<QAction*> lst;

QAction* actionNew = new QAction( tr( "New..." ), this );
connect( actionNew, SIGNAL( triggered() ), this, SLOT( newConnection() ) );
lst.append( actionNew );

return lst;
}

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

void QgsSLRootItem::connectionsChanged()
{
refresh();
}

void QgsSLRootItem::newConnection()
{
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;
}

QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
{
Q_UNUSED( thePath );
return new QgsSLRootItem( parentItem, "SpatiaLite", "spatialite:" );
}
55 changes: 55 additions & 0 deletions src/providers/spatialite/qgsspatialitedataitems.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#ifndef QGSSPATIALITEDATAITEMS_H
#define QGSSPATIALITEDATAITEMS_H

#include "qgsdataitem.h"

class QgsSLLayerItem : public QgsLayerItem
{
public:
QgsSLLayerItem( QgsDataItem* parent, QString name, QString path, QString uri, LayerType layerType )
: QgsLayerItem( parent, name, path, uri, layerType, "spatialite" )
{
mPopulated = true; // no children are expected
}
};

class QgsSLConnectionItem : public QgsDataCollectionItem
{
Q_OBJECT
public:
QgsSLConnectionItem( QgsDataItem* parent, QString name, QString path );
~QgsSLConnectionItem();

QVector<QgsDataItem*> createChildren();
virtual bool equal( const QgsDataItem *other );

virtual QList<QAction*> actions();

public slots:
void editConnection();
void deleteConnection();

protected:
QString mDbPath;
};

class QgsSLRootItem : public QgsDataCollectionItem
{
Q_OBJECT
public:
QgsSLRootItem( QgsDataItem* parent, QString name, QString path );
~QgsSLRootItem();

QVector<QgsDataItem*> createChildren();

virtual QWidget * paramWidget();

virtual QList<QAction*> actions();

public slots:
void connectionsChanged();
void newConnection();
};


#endif // QGSSPATIALITEDATAITEMS_H
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.
4 changes: 2 additions & 2 deletions src/python/qgspythonutilsimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ QStringList QgsPythonUtilsImpl::pluginList()

QString output;
evalString( "'\\n'.join(qgis.utils.available_plugins)", output );
return output.split( QChar( '\n' ) );
return output.split( QChar( '\n' ), QString::SkipEmptyParts );
}

QString QgsPythonUtilsImpl::getPluginMetadata( QString pluginName, QString function )
Expand Down Expand Up @@ -513,5 +513,5 @@ QStringList QgsPythonUtilsImpl::listActivePlugins()
{
QString output;
evalString( "'\\n'.join(qgis.utils.active_plugins)", output );
return output.split( QChar( '\n' ) );
return output.split( QChar( '\n' ), QString::SkipEmptyParts );
}
File renamed without changes.