|
@@ -23,6 +23,7 @@ email : jef at norbit dot de |
|
|
#include "qgscontexthelp.h" |
|
|
#include "qgsoracleprovider.h" |
|
|
#include "qgsoraclenewconnection.h" |
|
|
#include "qgsoracletablecache.h" |
|
|
#include "qgsmanageconnectionsdialog.h" |
|
|
#include "qgsquerybuilder.h" |
|
|
#include "qgsdatasourceuri.h" |
|
@@ -79,7 +80,8 @@ QWidget *QgsOracleSourceSelectDelegate::createEditor( QWidget *parent, const QSt |
|
|
if ( values.size() == 0 ) |
|
|
{ |
|
|
QString ownerName = index.sibling( index.row(), QgsOracleTableModel::dbtmOwner ).data( Qt::DisplayRole ).toString(); |
|
|
values = mConn->pkCandidates( ownerName, tableName ); |
|
|
if ( conn() ) |
|
|
values = conn()->pkCandidates( ownerName, tableName ); |
|
|
} |
|
|
|
|
|
if ( values.size() == 0 ) |
|
@@ -198,8 +200,6 @@ QgsOracleSourceSelect::QgsOracleSourceSelect( QWidget *parent, Qt::WindowFlags f |
|
|
connect( mBuildQueryButton, SIGNAL( clicked() ), this, SLOT( buildQuery() ) ); |
|
|
} |
|
|
|
|
|
populateConnectionList(); |
|
|
|
|
|
mSearchModeComboBox->addItem( tr( "Wildcard" ) ); |
|
|
mSearchModeComboBox->addItem( tr( "RegExp" ) ); |
|
|
|
|
@@ -251,6 +251,8 @@ QgsOracleSourceSelect::QgsOracleSourceSelect( QWidget *parent, Qt::WindowFlags f |
|
|
mSearchModeComboBox->setVisible( false ); |
|
|
mSearchModeLabel->setVisible( false ); |
|
|
mSearchTableEdit->setVisible( false ); |
|
|
|
|
|
populateConnectionList(); |
|
|
} |
|
|
/** Autoconnected SLOTS **/ |
|
|
// Slot for adding a new connection |
|
@@ -274,6 +276,8 @@ void QgsOracleSourceSelect::on_btnDelete_clicked() |
|
|
|
|
|
QgsOracleConn::deleteConnection( cmbConnections->currentText() ); |
|
|
|
|
|
QgsOracleTableCache::removeFromCache( cmbConnections->currentText() ); |
|
|
|
|
|
populateConnectionList(); |
|
|
emit connectionsChanged(); |
|
|
} |
|
@@ -304,6 +308,9 @@ void QgsOracleSourceSelect::on_btnEdit_clicked() |
|
|
QgsOracleNewConnection *nc = new QgsOracleNewConnection( this, cmbConnections->currentText() ); |
|
|
if ( nc->exec() ) |
|
|
{ |
|
|
if ( nc->connName() != nc->originalConnName() ) |
|
|
QgsOracleTableCache::renameConnectionInCache( nc->originalConnName(), nc->connName() ); |
|
|
|
|
|
populateConnectionList(); |
|
|
emit connectionsChanged(); |
|
|
} |
|
@@ -321,6 +328,15 @@ void QgsOracleSourceSelect::on_cmbConnections_currentIndexChanged( const QString |
|
|
cbxAllowGeometrylessTables->blockSignals( true ); |
|
|
cbxAllowGeometrylessTables->setChecked( QgsOracleConn::allowGeometrylessTables( text ) ); |
|
|
cbxAllowGeometrylessTables->blockSignals( false ); |
|
|
|
|
|
// populate the table list |
|
|
QgsDataSourceURI uri = QgsOracleConn::connUri( cmbConnections->currentText() ); |
|
|
mConnInfo = uri.connectionInfo(); |
|
|
mUseEstimatedMetadata = uri.useEstimatedMetadata(); |
|
|
|
|
|
QgsDebugMsg( "Connection info: " + uri.connectionInfo() ); |
|
|
|
|
|
loadTableFromCache(); |
|
|
} |
|
|
|
|
|
void QgsOracleSourceSelect::on_cbxAllowGeometrylessTables_stateChanged( int ) |
|
@@ -452,6 +468,8 @@ void QgsOracleSourceSelect::populateConnectionList() |
|
|
btnDelete->setDisabled( cmbConnections->count() == 0 ); |
|
|
btnConnect->setDisabled( cmbConnections->count() == 0 ); |
|
|
cmbConnections->setDisabled( cmbConnections->count() == 0 ); |
|
|
|
|
|
on_cmbConnections_currentIndexChanged( cmbConnections->currentText() ); |
|
|
} |
|
|
|
|
|
// Slot for performing action when the Add button is clicked |
|
@@ -498,18 +516,12 @@ void QgsOracleSourceSelect::on_btnConnect_clicked() |
|
|
QModelIndex rootItemIndex = mTableModel.indexFromItem( mTableModel.invisibleRootItem() ); |
|
|
mTableModel.removeRows( 0, mTableModel.rowCount( rootItemIndex ), rootItemIndex ); |
|
|
|
|
|
// populate the table list |
|
|
QgsDataSourceURI uri = QgsOracleConn::connUri( cmbConnections->currentText() ); |
|
|
|
|
|
QgsDebugMsg( "Connection info: " + uri.connectionInfo() ); |
|
|
|
|
|
mConnInfo = uri.connectionInfo(); |
|
|
mUseEstimatedMetadata = uri.useEstimatedMetadata(); |
|
|
|
|
|
QApplication::setOverrideCursor( Qt::BusyCursor ); |
|
|
|
|
|
QgsDataSourceURI uri = QgsOracleConn::connUri( cmbConnections->currentText() ); |
|
|
|
|
|
mIsConnected = true; |
|
|
mTablesTreeDelegate->setConn( QgsOracleConn::connectDb( uri.connectionInfo() ) ); |
|
|
mTablesTreeDelegate->setConnectionInfo( uri.connectionInfo() ); |
|
|
|
|
|
mColumnTypeThread = new QgsOracleColumnTypeThread( cmbConnections->currentText(), |
|
|
mUseEstimatedMetadata, |
|
@@ -544,8 +556,31 @@ void QgsOracleSourceSelect::finishList() |
|
|
mTablesTreeView->sortByColumn( QgsOracleTableModel::dbtmOwner, Qt::AscendingOrder ); |
|
|
} |
|
|
|
|
|
static QgsOracleTableCache::CacheFlags _currentFlags( QString connName, bool useEstimatedMetadata, bool allowGeometrylessTables ) |
|
|
{ |
|
|
QgsOracleTableCache::CacheFlags flags; |
|
|
if ( QgsOracleConn::geometryColumnsOnly( connName ) ) |
|
|
flags |= QgsOracleTableCache::OnlyLookIntoMetadataTable; |
|
|
if ( QgsOracleConn::userTablesOnly( connName ) ) |
|
|
flags |= QgsOracleTableCache::OnlyLookForUserTables; |
|
|
if ( QgsOracleConn::onlyExistingTypes( connName ) ) |
|
|
flags |= QgsOracleTableCache::OnlyExistingGeometryTypes; |
|
|
if ( useEstimatedMetadata ) |
|
|
flags |= QgsOracleTableCache::UseEstimatedTableMetadata; |
|
|
if ( allowGeometrylessTables ) |
|
|
flags |= QgsOracleTableCache::AllowGeometrylessTables; |
|
|
return flags; |
|
|
} |
|
|
|
|
|
void QgsOracleSourceSelect::columnThreadFinished() |
|
|
{ |
|
|
if ( !mColumnTypeThread->isStopped() ) |
|
|
{ |
|
|
QString connName = mColumnTypeThread->connectionName(); |
|
|
QgsOracleTableCache::CacheFlags flags = _currentFlags( connName, mColumnTypeThread->useEstimatedMetadata(), mColumnTypeThread->allowGeometrylessTables() ); |
|
|
QgsOracleTableCache::saveToCache( connName, flags, mColumnTypeThread->layerProperties() ); |
|
|
} |
|
|
|
|
|
delete mColumnTypeThread; |
|
|
mColumnTypeThread = 0; |
|
|
btnConnect->setText( tr( "Connect" ) ); |
|
@@ -628,3 +663,26 @@ void QgsOracleSourceSelect::setSearchExpression( const QString& regexp ) |
|
|
{ |
|
|
Q_UNUSED( regexp ); |
|
|
} |
|
|
|
|
|
void QgsOracleSourceSelect::loadTableFromCache() |
|
|
{ |
|
|
QModelIndex rootItemIndex = mTableModel.indexFromItem( mTableModel.invisibleRootItem() ); |
|
|
mTableModel.removeRows( 0, mTableModel.rowCount( rootItemIndex ), rootItemIndex ); |
|
|
|
|
|
QString connName = cmbConnections->currentText(); |
|
|
QVector<QgsOracleLayerProperty> layers; |
|
|
if ( !QgsOracleTableCache::loadFromCache( connName, _currentFlags( connName, mUseEstimatedMetadata, cbxAllowGeometrylessTables->isChecked() ), layers ) ) |
|
|
return; |
|
|
|
|
|
foreach ( const QgsOracleLayerProperty& layerProperty, layers ) |
|
|
mTableModel.addTableEntry( layerProperty ); |
|
|
|
|
|
QApplication::setOverrideCursor( Qt::BusyCursor ); |
|
|
|
|
|
QgsDataSourceURI uri = QgsOracleConn::connUri( connName ); |
|
|
|
|
|
mIsConnected = true; |
|
|
mTablesTreeDelegate->setConnectionInfo( uri.connectionInfo() ); |
|
|
|
|
|
finishList(); |
|
|
} |
0 comments on commit
5b72daa