Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE][API] postgres provider refactoring:
- use m prefix for member variables and s prefix for class variables - refactor QgsPostgresProvider::Conn and QgsPostgresConnection to QgsPostgresConn - put QgsColumnTypeThread into separate file - use QgsPostgresConn in QgsPgSourceSelect - cleaner abort of column type thread (e.g. remove unfinished columns from selection list) - [API] move QgsDbTableModel as QgsPgTableModel to provider - [FEATURE] support for arbitrary key (including non-numeric and multi column) - [FEATURE][API] support for requesting a certain geometry type and/or srid in QgsDataSourceURI * no more explicit filter strings * support for empty tables without gemetry_columns entry or GEOMETRY type.
- Loading branch information
Showing
24 changed files
with
3,651 additions
and
3,796 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/*************************************************************************** | ||
qgscolumntypethread.cpp - lookup postgres geometry type and srid in a thread | ||
------------------- | ||
begin : 3.1.2012 | ||
copyright : (C) 2012 by Juergen E. Fischer | ||
email : jef at norbit dot de | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgscolumntypethread.h" | ||
|
||
#include <QMetaType> | ||
|
||
QgsGeomColumnTypeThread::QgsGeomColumnTypeThread( QgsPostgresConn *conn, bool useEstimatedMetaData ) | ||
: QThread() | ||
, mConn( conn ) | ||
, mUseEstimatedMetadata( useEstimatedMetaData ) | ||
{ | ||
qRegisterMetaType<QgsPostgresLayerProperty>( "QgsPostgresLayerProperty" ); | ||
} | ||
|
||
void QgsGeomColumnTypeThread::addGeometryColumn( QgsPostgresLayerProperty layerProperty ) | ||
{ | ||
layerProperties << layerProperty; | ||
} | ||
|
||
void QgsGeomColumnTypeThread::stop() | ||
{ | ||
mStopped = true; | ||
} | ||
|
||
void QgsGeomColumnTypeThread::run() | ||
{ | ||
if ( !mConn ) | ||
return; | ||
|
||
mStopped = false; | ||
|
||
foreach( QgsPostgresLayerProperty layerProperty, layerProperties ) | ||
{ | ||
if ( !mStopped ) | ||
{ | ||
mConn->retrieveLayerTypes( layerProperty, mUseEstimatedMetadata ); | ||
} | ||
else | ||
{ | ||
layerProperty.type = ""; | ||
} | ||
|
||
// Now tell the layer list dialog box... | ||
emit setLayerType( layerProperty ); | ||
} | ||
|
||
mConn->disconnect(); | ||
mConn = 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/*************************************************************************** | ||
qgscolumntypethread.cpp - lookup postgres geometry type and srid in a thread | ||
------------------- | ||
begin : 3.1.2012 | ||
copyright : (C) 2012 by Juergen E. Fischer | ||
email : jef at norbit dot de | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
#ifndef QGSCOLUMNTYPETHREAD_H | ||
#define QGSCOLUMNTYPETHREAD_H | ||
|
||
#include <QThread> | ||
#include "qgspostgresconn.h" | ||
|
||
// A class that determines the geometry type of a given database | ||
// schema.table.column, with the option of doing so in a separate | ||
// thread. | ||
|
||
class QgsGeomColumnTypeThread : public QThread | ||
{ | ||
Q_OBJECT | ||
public: | ||
QgsGeomColumnTypeThread( QgsPostgresConn *conn, bool useEstimatedMetaData ); | ||
void addGeometryColumn( QgsPostgresLayerProperty layerProperty ); | ||
|
||
// These functions get the layer types and pass that information out | ||
// by emitting the setLayerType() signal. | ||
virtual void run(); | ||
|
||
signals: | ||
void setLayerType( QgsPostgresLayerProperty layerProperty ); | ||
|
||
public slots: | ||
void stop(); | ||
|
||
private: | ||
QgsGeomColumnTypeThread() {} | ||
|
||
QgsPostgresConn *mConn; | ||
bool mUseEstimatedMetadata; | ||
bool mStopped; | ||
QList<QgsPostgresLayerProperty> layerProperties; | ||
}; | ||
|
||
#endif // QGSCOLUMNTYPETHREAD_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/*************************************************************************** | ||
qgsdbfilterproxymodel.cpp - description | ||
------------------------- | ||
begin : Dec 2007 | ||
copyright : (C) 2007 by Marco Hugentobler | ||
email : marco dot hugentobler at karto dot baug dot ethz dot ch | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgsdbfilterproxymodel.h" | ||
|
||
QgsDbFilterProxyModel::QgsDbFilterProxyModel( QObject* parent ): QSortFilterProxyModel( parent ) | ||
{ | ||
|
||
} | ||
|
||
QgsDbFilterProxyModel::~QgsDbFilterProxyModel() | ||
{ | ||
|
||
} | ||
|
||
bool QgsDbFilterProxyModel::filterAcceptsRow( int row, const QModelIndex & source_parent ) const | ||
{ | ||
//if parent is valid, we have a toplevel item that should be always shown | ||
if ( !source_parent.isValid() ) | ||
{ | ||
return true; | ||
} | ||
|
||
//else we have a row that describes a table and that | ||
//should be tested using the given wildcard/regexp | ||
return QSortFilterProxyModel::filterAcceptsRow( row, source_parent ); | ||
} | ||
|
||
void QgsDbFilterProxyModel::_setFilterWildcard( const QString& pattern ) | ||
{ | ||
QSortFilterProxyModel::setFilterWildcard( pattern ); | ||
emit layoutChanged(); | ||
} | ||
|
||
void QgsDbFilterProxyModel::_setFilterRegExp( const QString& pattern ) | ||
{ | ||
QSortFilterProxyModel::setFilterRegExp( pattern ); | ||
emit layoutChanged(); | ||
} |
Oops, something went wrong.