Skip to content

Commit 3919cc2

Browse files
committedNov 13, 2017
[auth][ogr][feature] Add basic authentication to selected OGR sources
- Protocol - DB (integration with QGIS auth system)
1 parent fe4f150 commit 3919cc2

9 files changed

+933
-225
lines changed
 

‎src/auth/basic/qgsauthbasicmethod.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ QgsAuthBasicMethod::QgsAuthBasicMethod()
4242
<< QStringLiteral( "wfs" ) // convert to lowercase
4343
<< QStringLiteral( "wcs" )
4444
<< QStringLiteral( "wms" )
45+
<< QStringLiteral( "ogr" )
4546
<< QStringLiteral( "proxy" ) );
4647
}
4748

@@ -85,7 +86,6 @@ bool QgsAuthBasicMethod::updateNetworkRequest( QNetworkRequest &request, const Q
8586
bool QgsAuthBasicMethod::updateDataSourceUriItems( QStringList &connectionItems, const QString &authcfg,
8687
const QString &dataprovider )
8788
{
88-
Q_UNUSED( dataprovider )
8989
QgsAuthMethodConfig mconfig = getMethodConfig( authcfg );
9090
if ( !mconfig.isValid() )
9191
{
@@ -102,6 +102,21 @@ bool QgsAuthBasicMethod::updateDataSourceUriItems( QStringList &connectionItems,
102102
return false;
103103
}
104104

105+
// Branch for OGR protocol:
106+
if ( dataprovider == QStringLiteral( "ogr" ) )
107+
{
108+
if ( ! password.isEmpty() )
109+
{
110+
// inject username and password into the URL
111+
connectionItems.replaceInStrings( QStringLiteral( "://" ), QStringLiteral( "://%1:%2@" ).arg( username, password ) );
112+
}
113+
else
114+
{
115+
QgsDebugMsg( QString( "Update URI items FAILED for authcfg: %1: password empty" ).arg( authcfg ) );
116+
}
117+
}
118+
119+
// OGR database might use the standard URI way, we need to process this part in all cases
105120
QString userparam = "user='" + escapeUserPass( username ) + '\'';
106121
int userindx = connectionItems.indexOf( QRegExp( "^user='.*" ) );
107122
if ( userindx != -1 )

‎src/gui/ogr/qgsnewogrconnection.cpp

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,25 @@ QgsNewOgrConnection::QgsNewOgrConnection( QWidget *parent, const QString &connTy
5757
txtDatabase->setText( settings.value( key + "/database" ).toString() );
5858
QString port = settings.value( key + "/port" ).toString();
5959
txtPort->setText( port );
60-
txtUsername->setText( settings.value( key + "/username" ).toString() );
61-
if ( settings.value( key + "/save" ).toString() == QLatin1String( "true" ) )
60+
if ( settings.value( key + "/store_username" ).toString() == QLatin1String( "true" ) )
6261
{
63-
txtPassword->setText( settings.value( key + "/password" ).toString() );
64-
chkStorePassword->setChecked( true );
62+
mAuthSettingsDatabase->setUsername( settings.value( key + "/username" ).toString() );
63+
mAuthSettingsDatabase->setStoreUsernameChecked( true );
6564
}
65+
if ( settings.value( key + "/store_password" ).toString() == QLatin1String( "true" ) )
66+
{
67+
mAuthSettingsDatabase->setPassword( settings.value( key + "/password" ).toString() );
68+
mAuthSettingsDatabase->setStorePasswordChecked( true );
69+
}
70+
mAuthSettingsDatabase->setConfigId( settings.value( key + "/configid" ).toString() );
6671
cmbDatabaseTypes->setCurrentIndex( cmbDatabaseTypes->findText( connType ) );
6772
txtName->setText( connName );
6873
txtName->setEnabled( false );
6974
cmbDatabaseTypes->setEnabled( false );
7075
}
7176
txtName->setValidator( new QRegExpValidator( QRegExp( "[^\\/]+" ), txtName ) );
77+
mAuthSettingsDatabase->setDataprovider( QStringLiteral( "ogr" ) );
78+
mAuthSettingsDatabase->showStoreCheckboxes( true );
7279
}
7380

7481
QgsNewOgrConnection::~QgsNewOgrConnection()
@@ -80,9 +87,13 @@ QgsNewOgrConnection::~QgsNewOgrConnection()
8087
void QgsNewOgrConnection::testConnection()
8188
{
8289
QString uri;
83-
uri = createDatabaseURI( cmbDatabaseTypes->currentText(), txtHost->text(),
84-
txtDatabase->text(), txtPort->text(),
85-
txtUsername->text(), txtPassword->text() );
90+
uri = createDatabaseURI( cmbDatabaseTypes->currentText(),
91+
txtHost->text(),
92+
txtDatabase->text(),
93+
txtPort->text(),
94+
mAuthSettingsDatabase->configId(),
95+
mAuthSettingsDatabase->username(),
96+
mAuthSettingsDatabase->password() );
8697
QgsDebugMsg( "Connecting using uri = " + uri );
8798
OGRRegisterAll();
8899
OGRDataSourceH poDS;
@@ -133,9 +144,11 @@ void QgsNewOgrConnection::accept()
133144
settings.setValue( baseKey + "/host", txtHost->text() );
134145
settings.setValue( baseKey + "/database", txtDatabase->text() );
135146
settings.setValue( baseKey + "/port", txtPort->text() );
136-
settings.setValue( baseKey + "/username", txtUsername->text() );
137-
settings.setValue( baseKey + "/password", chkStorePassword->isChecked() ? txtPassword->text() : QLatin1String( "" ) );
138-
settings.setValue( baseKey + "/save", chkStorePassword->isChecked() ? "true" : "false" );
147+
settings.setValue( baseKey + "/username", mAuthSettingsDatabase->storeUsernameIsChecked() ? mAuthSettingsDatabase->username() : QLatin1String( "" ) );
148+
settings.setValue( baseKey + "/password", mAuthSettingsDatabase->storePasswordIsChecked() ? mAuthSettingsDatabase->password() : QLatin1String( "" ) );
149+
settings.setValue( baseKey + "/store_username", mAuthSettingsDatabase->storeUsernameIsChecked() ? "true" : "false" );
150+
settings.setValue( baseKey + "/store_password", mAuthSettingsDatabase->storePasswordIsChecked() ? "true" : "false" );
151+
settings.setValue( baseKey + "/configid", mAuthSettingsDatabase->configId() );
139152

140153
QDialog::accept();
141154
}

‎src/gui/ogr/qgsogrhelperfunctions.cpp

Lines changed: 52 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,31 @@
1818

1919
#include "qgsogrhelperfunctions.h"
2020
#include "qgslogger.h"
21+
#include "qgsapplication.h"
22+
#include "qgsauthmanager.h"
2123
#include <QRegExp>
2224

23-
QString createDatabaseURI( const QString &connectionType, const QString &host, const QString &database, QString port, const QString &user, const QString &password )
25+
QString createDatabaseURI( const QString &connectionType, const QString &host, const QString &database, QString port, const QString &configId, QString username, QString password )
2426
{
2527
QString uri;
2628

29+
// If an auth configuration is set, override username and password
30+
// Note that only Basic auth (username/password) is for now supported for OGR connections
31+
if ( ! configId.isEmpty() )
32+
{
33+
// Pass to updateDataSourceUriItems empty user/password in the format it likes
34+
QStringList connectionItems;
35+
connectionItems << QStringLiteral( "user=''" ) << QStringLiteral( "password=''" );
36+
if ( QgsApplication::authManager()->updateDataSourceUriItems( connectionItems, configId, QStringLiteral( "ogr" ) ) )
37+
{
38+
QRegExp userRe( "^user='([^']+)'" );
39+
QRegExp passRe( "^password='([^']+)'" );
40+
// Extracts the username and password
41+
username = QString( connectionItems.at( 0 ) ).replace( userRe, "\\1" );
42+
password = QString( connectionItems.at( 1 ) ).replace( passRe, "\\1" );
43+
}
44+
}
45+
2746
//todo:add default ports for all kind of databases
2847
if ( connectionType == QLatin1String( "ESRI Personal GeoDatabase" ) )
2948
{
@@ -34,7 +53,7 @@ QString createDatabaseURI( const QString &connectionType, const QString &host, c
3453
if ( port.isEmpty() )
3554
port = QStringLiteral( "5151" );
3655

37-
uri = "SDE:" + host + ",PORT:" + port + ',' + database + ',' + user + ',' + password;
56+
uri = "SDE:" + host + ",PORT:" + port + ',' + database + ',' + username + ',' + password;
3857
}
3958
else if ( connectionType == QLatin1String( "Informix DataBlade" ) )
4059
{
@@ -44,9 +63,9 @@ QString createDatabaseURI( const QString &connectionType, const QString &host, c
4463
if ( !host.isEmpty() )
4564
uri += QStringLiteral( " server=%1" ).arg( host );
4665

47-
if ( !user.isEmpty() )
66+
if ( !username.isEmpty() )
4867
{
49-
uri += QStringLiteral( " user=%1" ).arg( user );
68+
uri += QStringLiteral( " user=%1" ).arg( username );
5069

5170
if ( !password.isEmpty() )
5271
uri += QStringLiteral( " pass=%1" ).arg( password );
@@ -56,9 +75,9 @@ QString createDatabaseURI( const QString &connectionType, const QString &host, c
5675
{
5776
//not tested
5877
uri = "@driver=ingres,dbname=" + database;
59-
if ( !user.isEmpty() )
78+
if ( !username.isEmpty() )
6079
{
61-
uri += QStringLiteral( ",userid=%1" ).arg( user );
80+
uri += QStringLiteral( ",userid=%1" ).arg( username );
6281

6382
if ( !password.isEmpty() )
6483
uri += QStringLiteral( ",password=%1" ).arg( password );
@@ -76,9 +95,9 @@ QString createDatabaseURI( const QString &connectionType, const QString &host, c
7695
uri += QStringLiteral( ",port=%1" ).arg( port );
7796
}
7897

79-
if ( !user.isEmpty() )
98+
if ( !username.isEmpty() )
8099
{
81-
uri += QStringLiteral( ",user=%1" ).arg( user );
100+
uri += QStringLiteral( ",user=%1" ).arg( username );
82101

83102
if ( !password.isEmpty() )
84103
uri += QStringLiteral( ",password=%1" ).arg( password );
@@ -96,9 +115,9 @@ QString createDatabaseURI( const QString &connectionType, const QString &host, c
96115
uri += QStringLiteral( ",%1" ).arg( port );
97116
}
98117

99-
if ( !user.isEmpty() )
118+
if ( !username.isEmpty() )
100119
{
101-
uri += QStringLiteral( ";uid=%1" ).arg( user );
120+
uri += QStringLiteral( ";uid=%1" ).arg( username );
102121

103122
if ( !password.isEmpty() )
104123
uri += QStringLiteral( ";pwd=%1" ).arg( password );
@@ -111,10 +130,10 @@ QString createDatabaseURI( const QString &connectionType, const QString &host, c
111130
}
112131
else if ( connectionType == QLatin1String( "Oracle Spatial" ) )
113132
{
114-
uri = "OCI:" + user;
133+
uri = "OCI:" + username;
115134

116-
if ( ( !user.isEmpty() && !password.isEmpty() ) ||
117-
( user.isEmpty() && password.isEmpty() ) )
135+
if ( ( !username.isEmpty() && !password.isEmpty() ) ||
136+
( username.isEmpty() && password.isEmpty() ) )
118137
{
119138
uri += '/';
120139
if ( !password.isEmpty() )
@@ -142,15 +161,15 @@ QString createDatabaseURI( const QString &connectionType, const QString &host, c
142161
}
143162
else if ( connectionType == QLatin1String( "ODBC" ) )
144163
{
145-
if ( !user.isEmpty() )
164+
if ( !username.isEmpty() )
146165
{
147166
if ( password.isEmpty() )
148167
{
149-
uri = "ODBC:" + user + '@' + database;
168+
uri = "ODBC:" + username + '@' + database;
150169
}
151170
else
152171
{
153-
uri = "ODBC:" + user + '/' + password + '@' + database;
172+
uri = "ODBC:" + username + '/' + password + '@' + database;
154173
}
155174

156175
}
@@ -174,9 +193,9 @@ QString createDatabaseURI( const QString &connectionType, const QString &host, c
174193
uri += QStringLiteral( " port='%1'" ).arg( port );
175194
}
176195

177-
if ( !user.isEmpty() )
196+
if ( !username.isEmpty() )
178197
{
179-
uri += QStringLiteral( " user='%1'" ).arg( user );
198+
uri += QStringLiteral( " user='%1'" ).arg( username );
180199

181200
if ( !password.isEmpty() )
182201
uri += QStringLiteral( " password='%1'" ).arg( password );
@@ -190,7 +209,7 @@ QString createDatabaseURI( const QString &connectionType, const QString &host, c
190209
}
191210

192211

193-
QString createProtocolURI( const QString &type, const QString &url )
212+
QString createProtocolURI( const QString &type, const QString &url, const QString &configId, const QString &username, const QString &password )
194213
{
195214
QString uri;
196215
if ( type == QLatin1String( "GeoJSON" ) )
@@ -206,5 +225,19 @@ QString createProtocolURI( const QString &type, const QString &url )
206225
uri = QStringLiteral( "DODS:%1" ).arg( url );
207226
}
208227
QgsDebugMsg( "Connection type is=" + type + " and uri=" + uri );
228+
// Update URI with authentication information
229+
if ( ! configId.isEmpty() )
230+
{
231+
QStringList connectionItems;
232+
connectionItems << uri;
233+
if ( QgsApplication::authManager()->updateDataSourceUriItems( connectionItems, configId, QStringLiteral( "ogr" ) ) )
234+
{
235+
uri = connectionItems.join( QString() );
236+
}
237+
}
238+
else if ( !( username.isEmpty() || password.isEmpty( ) ) )
239+
{
240+
uri.replace( QStringLiteral( "://" ), QStringLiteral( "://%1:%2@" ).arg( username, password ) );
241+
}
209242
return uri;
210243
}

‎src/gui/ogr/qgsogrhelperfunctions.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626
* \brief Create database uri from connection parameters
2727
* \note not available in python bindings
2828
*/
29-
QString GUI_EXPORT createDatabaseURI( const QString &connectionType, const QString &host, const QString &database, QString port, const QString &user, const QString &password );
29+
QString GUI_EXPORT createDatabaseURI( const QString &connectionType, const QString &host, const QString &database, QString port, const QString &configId, QString username, QString password );
3030

3131
/**
3232
* CreateProtocolURI
3333
* \brief Create protocol uri from connection parameters
3434
* \note not available in python bindings
3535
*/
36-
QString GUI_EXPORT createProtocolURI( const QString &type, const QString &url );
36+
QString GUI_EXPORT createProtocolURI( const QString &type, const QString &url, const QString &configId, const QString &username, const QString &password );

‎src/providers/ogr/qgsogrdbitems.cpp

Lines changed: 503 additions & 0 deletions
Large diffs are not rendered by default.

‎src/providers/ogr/qgsogrdbitems.h

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
/***************************************************************************
2+
qgsogrdbitems.h - QgsOgrDbItems are data items for file-based OGR/GDAL
3+
DBs like GeoPackage and SpatiaLite
4+
5+
---------------------
6+
begin : 18.9.2017
7+
copyright : (C) 2017 by Alessandro Pasotti
8+
email : apasotti at boundlessgeo dot com
9+
***************************************************************************
10+
* *
11+
* This program is free software; you can redistribute it and/or modify *
12+
* it under the terms of the GNU General Public License as published by *
13+
* the Free Software Foundation; either version 2 of the License, or *
14+
* (at your option) any later version. *
15+
* *
16+
***************************************************************************/
17+
#ifndef QGSOGRDBITEMS_H
18+
#define QGSOGRDBITEMS_H
19+
20+
21+
class QgsOgrDbItems
22+
{
23+
public:
24+
QgsOgrDbItems();
25+
};
26+
27+
28+
29+
#include "qgsdataitem.h"
30+
#include "qgsdataitemprovider.h"
31+
#include "qgsdataprovider.h"
32+
33+
34+
/**
35+
* \brief The QgsOgrDbAbstractLayerItem class is the base class for OgrDb raster and vector layers
36+
*/
37+
class QgsOgrDbAbstractLayerItem : public QgsLayerItem
38+
{
39+
Q_OBJECT
40+
41+
protected:
42+
QgsOgrDbAbstractLayerItem( QgsDataItem *parent, const QString &name, const QString &path, const QString &uri, LayerType layerType, const QString &providerKey );
43+
44+
/**
45+
* Subclasses need to implement this function with
46+
* the real deletion implementation
47+
*/
48+
virtual bool executeDeleteLayer( QString &errCause );
49+
#ifdef HAVE_GUI
50+
QList<QAction *> actions();
51+
public slots:
52+
virtual void deleteLayer();
53+
#endif
54+
};
55+
56+
57+
class QgsOgrDbRasterLayerItem : public QgsOgrDbAbstractLayerItem
58+
{
59+
Q_OBJECT
60+
61+
public:
62+
QgsOgrDbRasterLayerItem( QgsDataItem *parent, const QString &name, const QString &path, const QString &uri );
63+
protected:
64+
virtual bool executeDeleteLayer( QString &errCause ) override;
65+
};
66+
67+
68+
class QgsOgrDbVectorLayerItem : public QgsOgrDbAbstractLayerItem
69+
{
70+
Q_OBJECT
71+
72+
public:
73+
QgsOgrDbVectorLayerItem( QgsDataItem *parent, const QString &name, const QString &path, const QString &uri, LayerType layerType );
74+
protected:
75+
virtual bool executeDeleteLayer( QString &errCause ) override;
76+
};
77+
78+
79+
/**
80+
* \brief The QgsOgrDbCollectionItem class is the base class for
81+
* OgrDb container
82+
*/
83+
class QgsOgrDbCollectionItem : public QgsDataCollectionItem
84+
{
85+
Q_OBJECT
86+
87+
public:
88+
QgsOgrDbCollectionItem( QgsDataItem *parent, const QString &name, const QString &path );
89+
QVector<QgsDataItem *> createChildren() override;
90+
virtual bool equal( const QgsDataItem *other ) override;
91+
92+
#ifdef HAVE_GUI
93+
virtual bool acceptDrop() override { return true; }
94+
virtual bool handleDrop( const QMimeData *data, Qt::DropAction action ) override;
95+
QList<QAction *> actions() override;
96+
#endif
97+
98+
//! Return the layer type from \a geometryType
99+
static QgsLayerItem::LayerType layerTypeFromDb( const QString &geometryType );
100+
101+
//! Delete a OgrDb layer
102+
static bool deleteOgrDbRasterLayer( const QString &uri, QString &errCause );
103+
104+
public slots:
105+
#ifdef HAVE_GUI
106+
void addTable();
107+
void addConnection();
108+
#endif
109+
110+
protected:
111+
QString mPath;
112+
};
113+
114+
115+
/**
116+
* \brief The QgsOgrDbConnectionItem class adds the stored
117+
* connection management to QgsOgrDbCollectionItem
118+
*/
119+
class QgsOgrDbConnectionItem : public QgsOgrDbCollectionItem
120+
{
121+
Q_OBJECT
122+
123+
public:
124+
QgsOgrDbConnectionItem( QgsDataItem *parent, const QString &name, const QString &path );
125+
virtual bool equal( const QgsDataItem *other ) override;
126+
127+
#ifdef HAVE_GUI
128+
QList<QAction *> actions() override;
129+
#endif
130+
131+
public slots:
132+
#ifdef HAVE_GUI
133+
void editConnection();
134+
void deleteConnection();
135+
#endif
136+
137+
};
138+
139+
140+
#endif // QGSOGRDBITEMS_H

‎src/providers/ogr/qgsogrsourceselect.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ QgsOgrSourceSelect::QgsOgrSourceSelect( QWidget *parent, Qt::WindowFlags fl, Qgs
123123
if ( radioSrcProtocol->isChecked() )
124124
emit enableButtons( !text.isEmpty() );
125125
} );
126+
// Set filter for ogr compatible auth methods
127+
mAuthSettingsProtocol->setDataprovider( QStringLiteral( "ogr" ) );
126128
}
127129

128130
QgsOgrSourceSelect::~QgsOgrSourceSelect()
@@ -179,6 +181,7 @@ void QgsOgrSourceSelect::deleteConnection()
179181
settings.remove( key + "/password" );
180182
settings.remove( key + "/port" );
181183
settings.remove( key + "/save" );
184+
settings.remove( key + "/autchcfg" );
182185
settings.remove( key );
183186
cmbConnections->removeItem( cmbConnections->currentIndex() ); // populateConnectionList();
184187
setConnectionListPosition();
@@ -285,9 +288,10 @@ void QgsOgrSourceSelect::addButtonClicked()
285288
QString port = settings.value( baseKey + "/port" ).toString();
286289
QString user = settings.value( baseKey + "/username" ).toString();
287290
QString pass = settings.value( baseKey + "/password" ).toString();
291+
QString configid = settings.value( baseKey + "/configid" ).toString();
288292

289293
bool makeConnection = false;
290-
if ( pass.isEmpty() )
294+
if ( pass.isEmpty() && configid.isEmpty( ) )
291295
{
292296
if ( cmbDatabaseTypes->currentText() == QLatin1String( "MSSQL" ) )
293297
makeConnection = true;
@@ -299,13 +303,14 @@ void QgsOgrSourceSelect::addButtonClicked()
299303
&makeConnection );
300304
}
301305

302-
if ( makeConnection || !pass.isEmpty() )
306+
if ( makeConnection || !( pass.isEmpty() && configid.isEmpty( ) ) )
303307
{
304308
mDataSources << createDatabaseURI(
305309
cmbDatabaseTypes->currentText(),
306310
host,
307311
database,
308312
port,
313+
configid,
309314
user,
310315
pass
311316
);
@@ -321,7 +326,11 @@ void QgsOgrSourceSelect::addButtonClicked()
321326
return;
322327
}
323328

324-
mDataSources << createProtocolURI( cmbProtocolTypes->currentText(), protocolURI->text() );
329+
mDataSources << createProtocolURI( cmbProtocolTypes->currentText(),
330+
protocolURI->text(),
331+
mAuthSettingsProtocol->configId(),
332+
mAuthSettingsProtocol->username(),
333+
mAuthSettingsProtocol->password() );
325334
}
326335
else if ( radioSrcFile->isChecked() )
327336
{

‎src/ui/qgsnewogrconnectionbase.ui

Lines changed: 65 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<x>0</x>
88
<y>0</y>
99
<width>404</width>
10-
<height>348</height>
10+
<height>386</height>
1111
</rect>
1212
</property>
1313
<property name="sizePolicy">
@@ -41,12 +41,57 @@
4141
<property name="spacing">
4242
<number>6</number>
4343
</property>
44+
<item row="1" column="0">
45+
<widget class="QDialogButtonBox" name="buttonBox">
46+
<property name="standardButtons">
47+
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
48+
</property>
49+
</widget>
50+
</item>
4451
<item row="0" column="0">
4552
<widget class="QGroupBox" name="GroupBox1">
4653
<property name="title">
4754
<string>Connection Information</string>
4855
</property>
49-
<layout class="QGridLayout" name="gridLayout_1">
56+
<layout class="QGridLayout" name="gridLayout">
57+
<item row="8" column="0" colspan="4">
58+
<widget class="QPushButton" name="btnConnect">
59+
<property name="text">
60+
<string>&amp;Test Connection</string>
61+
</property>
62+
</widget>
63+
</item>
64+
<item row="5" column="0" rowspan="3" colspan="4">
65+
<widget class="QGroupBox" name="mAuthGroupBox">
66+
<property name="title">
67+
<string>Authentication</string>
68+
</property>
69+
<layout class="QVBoxLayout" name="verticalLayout_3">
70+
<property name="leftMargin">
71+
<number>6</number>
72+
</property>
73+
<property name="topMargin">
74+
<number>6</number>
75+
</property>
76+
<property name="rightMargin">
77+
<number>6</number>
78+
</property>
79+
<property name="bottomMargin">
80+
<number>6</number>
81+
</property>
82+
<item>
83+
<widget class="QgsAuthSettingsWidget" name="mAuthSettingsDatabase" native="true">
84+
<property name="sizePolicy">
85+
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
86+
<horstretch>0</horstretch>
87+
<verstretch>0</verstretch>
88+
</sizepolicy>
89+
</property>
90+
</widget>
91+
</item>
92+
</layout>
93+
</widget>
94+
</item>
5095
<item row="0" column="0">
5196
<widget class="QLabel" name="label">
5297
<property name="text">
@@ -57,26 +102,16 @@
57102
</property>
58103
</widget>
59104
</item>
60-
<item row="0" column="1" colspan="2">
61-
<widget class="QComboBox" name="cmbDatabaseTypes"/>
62-
</item>
63105
<item row="1" column="0">
64106
<widget class="QLabel" name="TextLabel1_2">
65107
<property name="text">
66-
<string>Name</string>
108+
<string>&amp;Name</string>
67109
</property>
68110
<property name="buddy">
69111
<cstring>txtName</cstring>
70112
</property>
71113
</widget>
72114
</item>
73-
<item row="1" column="1" colspan="2">
74-
<widget class="QLineEdit" name="txtName">
75-
<property name="toolTip">
76-
<string>Name of the new connection</string>
77-
</property>
78-
</widget>
79-
</item>
80115
<item row="2" column="0">
81116
<widget class="QLabel" name="TextLabel1">
82117
<property name="text">
@@ -87,9 +122,6 @@
87122
</property>
88123
</widget>
89124
</item>
90-
<item row="2" column="1" colspan="2">
91-
<widget class="QLineEdit" name="txtHost"/>
92-
</item>
93125
<item row="3" column="0">
94126
<widget class="QLabel" name="TextLabel2">
95127
<property name="text">
@@ -100,9 +132,6 @@
100132
</property>
101133
</widget>
102134
</item>
103-
<item row="3" column="1" colspan="2">
104-
<widget class="QLineEdit" name="txtDatabase"/>
105-
</item>
106135
<item row="4" column="0">
107136
<widget class="QLabel" name="TextLabel2_2">
108137
<property name="text">
@@ -113,87 +142,48 @@
113142
</property>
114143
</widget>
115144
</item>
116-
<item row="4" column="1" colspan="2">
117-
<widget class="QLineEdit" name="txtPort">
118-
<property name="text">
119-
<string/>
120-
</property>
121-
</widget>
122-
</item>
123-
<item row="5" column="0">
124-
<widget class="QLabel" name="TextLabel3">
125-
<property name="text">
126-
<string>Username</string>
127-
</property>
128-
<property name="buddy">
129-
<cstring>txtUsername</cstring>
145+
<item row="1" column="1" colspan="3">
146+
<widget class="QLineEdit" name="txtName">
147+
<property name="toolTip">
148+
<string>Name of the new connection</string>
130149
</property>
131150
</widget>
132151
</item>
133-
<item row="5" column="1" colspan="2">
134-
<widget class="QLineEdit" name="txtUsername"/>
135-
</item>
136-
<item row="6" column="0">
137-
<widget class="QLabel" name="TextLabel3_2">
138-
<property name="text">
139-
<string>Password</string>
140-
</property>
141-
<property name="buddy">
142-
<cstring>txtPassword</cstring>
143-
</property>
144-
</widget>
152+
<item row="0" column="1" colspan="3">
153+
<widget class="QComboBox" name="cmbDatabaseTypes"/>
145154
</item>
146-
<item row="6" column="1" colspan="2">
147-
<widget class="QgsPasswordLineEdit" name="txtPassword">
148-
<property name="echoMode">
149-
<enum>QLineEdit::Password</enum>
150-
</property>
151-
</widget>
155+
<item row="2" column="1" colspan="3">
156+
<widget class="QLineEdit" name="txtHost"/>
152157
</item>
153-
<item row="7" column="0">
154-
<widget class="QCheckBox" name="chkStorePassword">
155-
<property name="text">
156-
<string>Save Password</string>
157-
</property>
158-
</widget>
158+
<item row="3" column="1" colspan="3">
159+
<widget class="QLineEdit" name="txtDatabase"/>
159160
</item>
160-
<item row="7" column="2">
161-
<widget class="QPushButton" name="btnConnect">
161+
<item row="4" column="1" colspan="3">
162+
<widget class="QLineEdit" name="txtPort">
162163
<property name="text">
163-
<string>&amp;Test Connect</string>
164+
<string/>
164165
</property>
165166
</widget>
166167
</item>
167168
</layout>
168169
</widget>
169170
</item>
170-
<item row="1" column="0">
171-
<widget class="QDialogButtonBox" name="buttonBox">
172-
<property name="standardButtons">
173-
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
174-
</property>
175-
</widget>
176-
</item>
177171
</layout>
178172
</widget>
179173
<layoutdefault spacing="6" margin="11"/>
180174
<customwidgets>
181175
<customwidget>
182-
<class>QgsPasswordLineEdit</class>
183-
<extends>QLineEdit</extends>
184-
<header>qgspasswordlineedit.h</header>
176+
<class>QgsAuthSettingsWidget</class>
177+
<extends>QWidget</extends>
178+
<header>auth/qgsauthsettingswidget.h</header>
179+
<container>1</container>
185180
</customwidget>
186181
</customwidgets>
187182
<tabstops>
188-
<tabstop>cmbDatabaseTypes</tabstop>
189183
<tabstop>txtName</tabstop>
190184
<tabstop>txtHost</tabstop>
191185
<tabstop>txtDatabase</tabstop>
192186
<tabstop>txtPort</tabstop>
193-
<tabstop>txtUsername</tabstop>
194-
<tabstop>txtPassword</tabstop>
195-
<tabstop>chkStorePassword</tabstop>
196-
<tabstop>btnConnect</tabstop>
197187
<tabstop>buttonBox</tabstop>
198188
</tabstops>
199189
<resources/>

‎src/ui/qgsogrsourceselectbase.ui

Lines changed: 120 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<x>0</x>
1111
<y>0</y>
1212
<width>450</width>
13-
<height>575</height>
13+
<height>658</height>
1414
</rect>
1515
</property>
1616
<property name="sizePolicy">
@@ -26,15 +26,76 @@
2626
<iconset>
2727
<normaloff>.</normaloff>.</iconset>
2828
</property>
29-
<layout class="QGridLayout" name="gridLayout">
30-
<item row="5" column="0">
31-
<widget class="QDialogButtonBox" name="buttonBox">
32-
<property name="standardButtons">
33-
<set>QDialogButtonBox::Help</set>
29+
<layout class="QVBoxLayout" name="verticalLayout_4">
30+
<item>
31+
<widget class="QGroupBox" name="srcGroupBox_2">
32+
<property name="sizePolicy">
33+
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
34+
<horstretch>0</horstretch>
35+
<verstretch>0</verstretch>
36+
</sizepolicy>
3437
</property>
38+
<property name="title">
39+
<string>Source type</string>
40+
</property>
41+
<layout class="QVBoxLayout" name="verticalLayout">
42+
<item>
43+
<layout class="QHBoxLayout" name="horizontalLayout">
44+
<item>
45+
<widget class="QRadioButton" name="radioSrcFile">
46+
<property name="text">
47+
<string>F&amp;ile</string>
48+
</property>
49+
</widget>
50+
</item>
51+
<item>
52+
<widget class="QRadioButton" name="radioSrcDirectory">
53+
<property name="text">
54+
<string>&amp;Directory</string>
55+
</property>
56+
</widget>
57+
</item>
58+
<item>
59+
<widget class="QRadioButton" name="radioSrcDatabase">
60+
<property name="text">
61+
<string>Da&amp;tabase</string>
62+
</property>
63+
</widget>
64+
</item>
65+
<item>
66+
<widget class="QRadioButton" name="radioSrcProtocol">
67+
<property name="text">
68+
<string>Protoco&amp;l</string>
69+
</property>
70+
</widget>
71+
</item>
72+
</layout>
73+
</item>
74+
<item>
75+
<layout class="QHBoxLayout" name="horizontalLayout_2">
76+
<item>
77+
<widget class="QLabel" name="label_3">
78+
<property name="text">
79+
<string>Encoding</string>
80+
</property>
81+
</widget>
82+
</item>
83+
<item>
84+
<widget class="QComboBox" name="cmbEncodings">
85+
<property name="minimumSize">
86+
<size>
87+
<width>341</width>
88+
<height>0</height>
89+
</size>
90+
</property>
91+
</widget>
92+
</item>
93+
</layout>
94+
</item>
95+
</layout>
3596
</widget>
3697
</item>
37-
<item row="1" column="0">
98+
<item>
3899
<widget class="QGroupBox" name="protocolGroupBox">
39100
<property name="sizePolicy">
40101
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@@ -52,19 +113,19 @@
52113
<string>Protocol</string>
53114
</property>
54115
<layout class="QGridLayout" name="gridLayout_2">
55-
<item row="0" column="1" rowspan="2">
56-
<widget class="QComboBox" name="cmbProtocolTypes"/>
57-
</item>
58116
<item row="1" column="0" rowspan="2">
59117
<widget class="QLabel" name="label">
60118
<property name="text">
61-
<string>URI</string>
119+
<string>&amp;URI</string>
62120
</property>
63121
<property name="buddy">
64122
<cstring>protocolURI</cstring>
65123
</property>
66124
</widget>
67125
</item>
126+
<item row="0" column="1" rowspan="2">
127+
<widget class="QComboBox" name="cmbProtocolTypes"/>
128+
</item>
68129
<item row="2" column="1">
69130
<widget class="QLineEdit" name="protocolURI"/>
70131
</item>
@@ -75,10 +136,41 @@
75136
</property>
76137
</widget>
77138
</item>
139+
<item row="3" column="0" colspan="2">
140+
<widget class="QGroupBox" name="mAuthGroupBox">
141+
<property name="title">
142+
<string>Authentication</string>
143+
</property>
144+
<layout class="QVBoxLayout" name="verticalLayout_3">
145+
<property name="leftMargin">
146+
<number>6</number>
147+
</property>
148+
<property name="topMargin">
149+
<number>6</number>
150+
</property>
151+
<property name="rightMargin">
152+
<number>6</number>
153+
</property>
154+
<property name="bottomMargin">
155+
<number>6</number>
156+
</property>
157+
<item>
158+
<widget class="QgsAuthSettingsWidget" name="mAuthSettingsProtocol" native="true">
159+
<property name="sizePolicy">
160+
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
161+
<horstretch>0</horstretch>
162+
<verstretch>0</verstretch>
163+
</sizepolicy>
164+
</property>
165+
</widget>
166+
</item>
167+
</layout>
168+
</widget>
169+
</item>
78170
</layout>
79171
</widget>
80172
</item>
81-
<item row="2" column="0">
173+
<item>
82174
<widget class="QGroupBox" name="fileGroupBox">
83175
<property name="sizePolicy">
84176
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@@ -124,12 +216,12 @@
124216
</widget>
125217
</item>
126218
<item row="1" column="1">
127-
<widget class="QgsFileWidget" name="mFileWidget"/>
219+
<widget class="QgsFileWidget" name="mFileWidget" native="true"/>
128220
</item>
129221
</layout>
130222
</widget>
131223
</item>
132-
<item row="3" column="0">
224+
<item>
133225
<widget class="QGroupBox" name="dbGroupBox">
134226
<property name="sizePolicy">
135227
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@@ -206,75 +298,7 @@
206298
</layout>
207299
</widget>
208300
</item>
209-
<item row="0" column="0">
210-
<widget class="QGroupBox" name="srcGroupBox_2">
211-
<property name="sizePolicy">
212-
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
213-
<horstretch>0</horstretch>
214-
<verstretch>0</verstretch>
215-
</sizepolicy>
216-
</property>
217-
<property name="title">
218-
<string>Source type</string>
219-
</property>
220-
<layout class="QVBoxLayout" name="verticalLayout">
221-
<item>
222-
<layout class="QHBoxLayout" name="horizontalLayout">
223-
<item>
224-
<widget class="QRadioButton" name="radioSrcFile">
225-
<property name="text">
226-
<string>File</string>
227-
</property>
228-
</widget>
229-
</item>
230-
<item>
231-
<widget class="QRadioButton" name="radioSrcDirectory">
232-
<property name="text">
233-
<string>Directory</string>
234-
</property>
235-
</widget>
236-
</item>
237-
<item>
238-
<widget class="QRadioButton" name="radioSrcDatabase">
239-
<property name="text">
240-
<string>Database</string>
241-
</property>
242-
</widget>
243-
</item>
244-
<item>
245-
<widget class="QRadioButton" name="radioSrcProtocol">
246-
<property name="text">
247-
<string>Protocol</string>
248-
</property>
249-
</widget>
250-
</item>
251-
</layout>
252-
</item>
253-
<item>
254-
<layout class="QHBoxLayout" name="horizontalLayout_2">
255-
<item>
256-
<widget class="QLabel" name="label_3">
257-
<property name="text">
258-
<string>Encoding</string>
259-
</property>
260-
</widget>
261-
</item>
262-
<item>
263-
<widget class="QComboBox" name="cmbEncodings">
264-
<property name="minimumSize">
265-
<size>
266-
<width>341</width>
267-
<height>0</height>
268-
</size>
269-
</property>
270-
</widget>
271-
</item>
272-
</layout>
273-
</item>
274-
</layout>
275-
</widget>
276-
</item>
277-
<item row="4" column="0">
301+
<item>
278302
<spacer name="verticalSpacer">
279303
<property name="orientation">
280304
<enum>Qt::Vertical</enum>
@@ -287,6 +311,13 @@
287311
</property>
288312
</spacer>
289313
</item>
314+
<item>
315+
<widget class="QDialogButtonBox" name="buttonBox">
316+
<property name="standardButtons">
317+
<set>QDialogButtonBox::Help</set>
318+
</property>
319+
</widget>
320+
</item>
290321
</layout>
291322
</widget>
292323
<layoutdefault spacing="6" margin="11"/>
@@ -296,6 +327,12 @@
296327
<extends>QWidget</extends>
297328
<header>qgsfilewidget.h</header>
298329
</customwidget>
330+
<customwidget>
331+
<class>QgsAuthSettingsWidget</class>
332+
<extends>QWidget</extends>
333+
<header>auth/qgsauthsettingswidget.h</header>
334+
<container>1</container>
335+
</customwidget>
299336
</customwidgets>
300337
<tabstops>
301338
<tabstop>radioSrcFile</tabstop>
@@ -316,38 +353,6 @@
316353
</tabstops>
317354
<resources/>
318355
<connections>
319-
<connection>
320-
<sender>buttonBox</sender>
321-
<signal>accepted()</signal>
322-
<receiver>QgsOgrSourceSelectDialogBase</receiver>
323-
<slot>accept()</slot>
324-
<hints>
325-
<hint type="sourcelabel">
326-
<x>451</x>
327-
<y>699</y>
328-
</hint>
329-
<hint type="destinationlabel">
330-
<x>481</x>
331-
<y>297</y>
332-
</hint>
333-
</hints>
334-
</connection>
335-
<connection>
336-
<sender>buttonBox</sender>
337-
<signal>rejected()</signal>
338-
<receiver>QgsOgrSourceSelectDialogBase</receiver>
339-
<slot>reject()</slot>
340-
<hints>
341-
<hint type="sourcelabel">
342-
<x>392</x>
343-
<y>699</y>
344-
</hint>
345-
<hint type="destinationlabel">
346-
<x>281</x>
347-
<y>339</y>
348-
</hint>
349-
</hints>
350-
</connection>
351356
<connection>
352357
<sender>radioSrcDatabase</sender>
353358
<signal>toggled(bool)</signal>

0 commit comments

Comments
 (0)
Please sign in to comment.