Skip to content
Permalink
Browse files
check/uncheck all MSSQL schemas (backport #42678)
  • Loading branch information
vcloarec authored and nyalldawson committed Apr 26, 2021
1 parent 8f0e606 commit 44d7dfabbef4e5491839ac65859baab47236d7c1
@@ -20,6 +20,7 @@
#include <QSqlDatabase>
#include <QSqlError>
#include <QRegExpValidator>
#include <QMenu>

#include "qgsmssqlnewconnection.h"
#include "qgsmssqlprovider.h"
@@ -95,6 +96,24 @@ QgsMssqlNewConnection::QgsMssqlNewConnection( QWidget *parent, const QString &co
cb_trustedConnection_clicked();

schemaView->setModel( &mSchemaModel );
schemaView->setContextMenuPolicy( Qt::CustomContextMenu );

connect( schemaView, &QWidget::customContextMenuRequested, this, [this]( const QPoint & p )
{
QMenu menu;
menu.addAction( tr( "Check All" ), this, [this]
{
mSchemaModel.checkAll();
} );

menu.addAction( tr( "Uncheck All" ), this, [this]
{
mSchemaModel.unCheckAll();
} );

menu.exec( this->schemaView->viewport()->mapToGlobal( p ) );
}
);
onCurrentDataBaseChange();

groupBoxSchemasFilter->setCollapsed( !groupBoxSchemasFilter->isChecked() );
@@ -353,6 +372,7 @@ void QgsMssqlNewConnection::onPrimaryKeyFromGeometryToggled( bool checked )
bar->pushInfo( tr( "Use primary key(s) from geometry_columns table" ), tr( "Primary key column found." ) );
}


bool QgsMssqlNewConnection::testExtentInGeometryColumns() const
{
QSqlDatabase db = getDatabase();
@@ -468,3 +488,15 @@ void QgsMssqlNewConnection::SchemaModel::setSettings( const QString &database, c
mExcludedSchemas = excludedSchemas;
endResetModel();
}

void QgsMssqlNewConnection::SchemaModel::checkAll()
{
mExcludedSchemas.clear();
emit dataChanged( index( 0, 0, QModelIndex() ), index( mSchemas.count() - 1, 0, QModelIndex() ) );
}

void QgsMssqlNewConnection::SchemaModel::unCheckAll()
{
mExcludedSchemas = mSchemas;
emit dataChanged( index( 0, 0, QModelIndex() ), index( mSchemas.count() - 1, 0, QModelIndex() ) );
}
@@ -80,6 +80,12 @@ class QgsMssqlNewConnection : public QDialog, private Ui::QgsMssqlNewConnectionB
//! Sets the settings for \a database
void setSettings( const QString &database, const QStringList &schemas, const QStringList &excludedSchemas );

//! Checks all schemas
void checkAll();

//! Unchecks all schemas
void unCheckAll();

private:
QString mDataBaseName;
QStringList mSchemas;
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>810</width>
<height>765</height>
<width>800</width>
<height>755</height>
</rect>
</property>
<property name="sizePolicy">
@@ -265,6 +265,13 @@ Untick save if you don't wish to be the case.</string>
</layout>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="checkBoxPKFromGeometryColumns">
<property name="text">
<string>Use primary key from geometry_columns table</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="cb_allowGeometrylessTables">
<property name="toolTip">
@@ -302,19 +309,6 @@ Untick save if you don't wish to be the case.</string>
</widget>
</item>
<item row="8" column="0" colspan="2">
<widget class="Line" name="line">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="9" column="0" colspan="2">
<widget class="QgsCollapsibleGroupBoxBasic" name="groupBoxSchemasFilter">
<property name="title">
<string>Use Only a Subset of Schemas</string>
@@ -347,20 +341,13 @@ Untick save if you don't wish to be the case.</string>
</layout>
</widget>
</item>
<item row="10" column="0" colspan="2">
<item row="9" column="0" colspan="2">
<widget class="QPushButton" name="btnConnect">
<property name="text">
<string>Test Connection</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="checkBoxPKFromGeometryColumns">
<property name="text">
<string>Use primary key from geometry_columns table</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

0 comments on commit 44d7dfa

Please sign in to comment.