Skip to content

Commit

Permalink
More refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Oct 8, 2018
1 parent ad25261 commit 7464575
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
13 changes: 6 additions & 7 deletions src/providers/mssql/qgsmssqldataitems.cpp
Expand Up @@ -16,6 +16,7 @@
***************************************************************************/

#include "qgsmssqldataitems.h"
#include "qgsmssqlconnection.h"

#include "qgsmssqlgeomcolumntypethread.h"
#include "qgslogger.h"
Expand Down Expand Up @@ -71,9 +72,9 @@ void QgsMssqlConnectionItem::readConnectionSettings()
mPassword = settings.value( key + "/password" ).toString();
}

mUseGeometryColumns = settings.value( key + "/geometryColumns", false ).toBool();
mUseEstimatedMetadata = settings.value( key + "/estimatedMetadata", false ).toBool();
mAllowGeometrylessTables = settings.value( key + "/allowGeometrylessTables", true ).toBool();
mUseGeometryColumns = QgsMssqlConnection::useEstimatedMetadata( mName );
mUseEstimatedMetadata = QgsMssqlConnection::useEstimatedMetadata( mName );
mAllowGeometrylessTables = QgsMssqlConnection::allowGeometrylessTables( mName );

mConnInfo = "dbname='" + mDatabase + "' host='" + mHost + "' user='" + mUsername + "' password='" + mPassword + '\'';
if ( !mService.isEmpty() )
Expand Down Expand Up @@ -356,12 +357,10 @@ QList<QAction *> QgsMssqlConnectionItem::actions( QWidget *parent )
return lst;
}

void QgsMssqlConnectionItem::setAllowGeometrylessTables( bool allow )
void QgsMssqlConnectionItem::setAllowGeometrylessTables( const bool allow )
{
mAllowGeometrylessTables = allow;
QString key = "/MSSQL/connections/" + mName;
QgsSettings settings;
settings.setValue( key + "/allowGeometrylessTables", allow );
QgsMssqlConnection::setAllowGeometrylessTables( mName, allow );
refresh();
}

Expand Down
2 changes: 1 addition & 1 deletion src/providers/mssql/qgsmssqlnewconnection.cpp
Expand Up @@ -50,7 +50,7 @@ QgsMssqlNewConnection::QgsMssqlNewConnection( QWidget *parent, const QString &co
listDatabase->addItem( settings.value( key + "/database" ).toString() );
listDatabase->setCurrentRow( 0 );
cb_geometryColumns->setChecked( QgsMssqlConnection::geometryColumnsOnly( connName ) );
cb_allowGeometrylessTables->setChecked( QgsMssqlConnection::geometryColumnsOnly( connName ) );
cb_allowGeometrylessTables->setChecked( QgsMssqlConnection::allowGeometrylessTables( connName ) );
cb_useEstimatedMetadata->setChecked( QgsMssqlConnection::useEstimatedMetadata( connName ) );

if ( settings.value( key + "/saveUsername" ).toString() == QLatin1String( "true" ) )
Expand Down
8 changes: 3 additions & 5 deletions src/providers/mssql/qgsmssqlsourceselect.cpp
Expand Up @@ -293,7 +293,7 @@ void QgsMssqlSourceSelect::cmbConnections_activated( int )
settings.setValue( QStringLiteral( "MSSQL/connections/selected" ), cmbConnections->currentText() );

cbxAllowGeometrylessTables->blockSignals( true );
cbxAllowGeometrylessTables->setChecked( settings.value( "/MSSQL/connections/" + cmbConnections->currentText() + "/allowGeometrylessTables", false ).toBool() );
cbxAllowGeometrylessTables->setChecked( QgsMssqlConnection::allowGeometrylessTables( cmbConnections->currentText() ) );
cbxAllowGeometrylessTables->blockSignals( false );
}

Expand Down Expand Up @@ -495,11 +495,9 @@ void QgsMssqlSourceSelect::btnConnect_clicked()
password = settings.value( key + "/password" ).toString();
}

bool useGeometryColumns = settings.value( key + "/geometryColumns", false ).toBool();

bool useGeometryColumns = QgsMssqlConnection::geometryColumnsOnly( cmbConnections->currentText() );
bool allowGeometrylessTables = cbxAllowGeometrylessTables->isChecked();

bool estimateMetadata = settings.value( key + "/estimatedMetadata", true ).toBool();
bool estimateMetadata = QgsMssqlConnection::useEstimatedMetadata( cmbConnections->currentText() );

mConnInfo = "dbname='" + database + '\'';
if ( !host.isEmpty() )
Expand Down

0 comments on commit 7464575

Please sign in to comment.