29QString 
QgsGdalGuiUtils::createDatabaseURI( 
const QString &connectionType, 
const QString &host, 
const QString &database, QString port, 
const QString &configId, QString username, QString password, 
bool expandAuthConfig )
 
   35  if ( !configId.isEmpty() )
 
   44  if ( connectionType == QLatin1String( 
"ESRI Personal GeoDatabase" ) )
 
   46    uri = 
"PGeo:" + database;
 
   48  else if ( connectionType == QLatin1String( 
"ESRI ArcSDE" ) )
 
   51      port = QStringLiteral( 
"5151" );
 
   53    uri = 
"SDE:" + host + 
",PORT:" + port + 
',' + database + 
',' + username + 
',' + password;
 
   55  else if ( connectionType == QLatin1String( 
"Informix DataBlade" ) )
 
   58    uri = 
"IDB:dbname=" + database;
 
   60    if ( !host.isEmpty() )
 
   61      uri += QStringLiteral( 
" server=%1" ).arg( host );
 
   63    if ( !username.isEmpty() )
 
   65      uri += QStringLiteral( 
" user=%1" ).arg( username );
 
   67      if ( !password.isEmpty() )
 
   68        uri += QStringLiteral( 
" pass=%1" ).arg( password );
 
   71  else if ( connectionType == QLatin1String( 
"Ingres" ) )
 
   74    uri = 
"@driver=ingres,dbname=" + database;
 
   75    if ( !username.isEmpty() )
 
   77      uri += QStringLiteral( 
",userid=%1" ).arg( username );
 
   79      if ( !password.isEmpty() )
 
   80        uri += QStringLiteral( 
",password=%1" ).arg( password );
 
   83  else if ( connectionType == QLatin1String( 
"MySQL" ) )
 
   85    uri = 
"MySQL:" + database;
 
   87    if ( !host.isEmpty() )
 
   89      uri += QStringLiteral( 
",host=%1" ).arg( host );
 
   91      if ( !port.isEmpty() )
 
   92        uri += QStringLiteral( 
",port=%1" ).arg( port );
 
   95    if ( !username.isEmpty() )
 
   97      uri += QStringLiteral( 
",user=%1" ).arg( username );
 
   99      if ( !password.isEmpty() )
 
  100        uri += QStringLiteral( 
",password=%1" ).arg( password );
 
  103  else if ( connectionType == QLatin1String( 
"MSSQL" ) )
 
  105    uri = QStringLiteral( 
"MSSQL:" );
 
  107    if ( !host.isEmpty() )
 
  109      uri += QStringLiteral( 
";server=%1" ).arg( host );
 
  111      if ( !port.isEmpty() )
 
  112        uri += QStringLiteral( 
",%1" ).arg( port );
 
  115    if ( !username.isEmpty() )
 
  117      uri += QStringLiteral( 
";uid=%1" ).arg( username );
 
  119      if ( !password.isEmpty() )
 
  120        uri += QStringLiteral( 
";pwd=%1" ).arg( password );
 
  123      uri += QLatin1String( 
";trusted_connection=yes" );
 
  125    if ( !database.isEmpty() )
 
  126      uri += QStringLiteral( 
";database=%1" ).arg( database );
 
  128  else if ( connectionType == QLatin1String( 
"Oracle Spatial" ) )
 
  130    uri = 
"OCI:" + username;
 
  132    if ( ( !username.isEmpty() && !password.isEmpty() ) || ( username.isEmpty() && password.isEmpty() ) )
 
  135      if ( !password.isEmpty() )
 
  139    if ( !host.isEmpty() || !database.isEmpty() )
 
  143      if ( !host.isEmpty() )
 
  146        if ( !port.isEmpty() )
 
  150      if ( !database.isEmpty() )
 
  152        if ( !host.isEmpty() )
 
  158  else if ( connectionType == QLatin1String( 
"ODBC" ) )
 
  160    if ( !username.isEmpty() )
 
  162      if ( password.isEmpty() )
 
  164        uri = 
"ODBC:" + username + 
'@' + database;
 
  168        uri = 
"ODBC:" + username + 
'/' + password + 
'@' + database;
 
  173      uri = 
"ODBC:" + database;
 
  176  else if ( connectionType == QLatin1String( 
"OGDI Vectors" ) )
 
  179  else if ( connectionType == QLatin1String( 
"PostgreSQL" ) )
 
  181    uri = 
"PG:dbname='" + database + 
'\'';
 
  183    if ( !host.isEmpty() )
 
  185      uri += QStringLiteral( 
" host='%1'" ).arg( host );
 
  187      if ( !port.isEmpty() )
 
  188        uri += QStringLiteral( 
" port='%1'" ).arg( port );
 
  191    if ( !username.isEmpty() )
 
  193      uri += QStringLiteral( 
" user='%1'" ).arg( username );
 
  195      if ( !password.isEmpty() )
 
  196        uri += QStringLiteral( 
" password='%1'" ).arg( password );
 
  202  if ( !( configId.isEmpty() ) )
 
  204    if ( !expandAuthConfig )
 
  206      uri += QStringLiteral( 
" authcfg='%1'" ).arg( configId );
 
  210      QStringList connectionItems;
 
  211      connectionItems << uri;
 
  214        uri = connectionItems.join( QString() );
 
  218  QgsDebugMsgLevel( 
"Connection type is=" + connectionType + 
" and uri=" + uri, 2 );
 
 
  223QString 
QgsGdalGuiUtils::createProtocolURI( 
const QString &type, 
const QString &url, 
const QString &configId, 
const QString &username, 
const QString &password, 
bool expandAuthConfig )
 
  227  if ( type == QLatin1String( 
"vsicurl" ) )
 
  229    prefix = QStringLiteral( 
"/vsicurl/" );
 
  230    if ( !uri.startsWith( prefix ) )
 
  233      if ( !uri.startsWith( QLatin1String( 
"http://" ) ) && !uri.startsWith( QLatin1String( 
"https://" ) ) && !uri.startsWith( QLatin1String( 
"ftp://" ) ) )
 
  235        uri.prepend( QStringLiteral( 
"http://" ) );
 
  237      uri.prepend( prefix );
 
  240  else if ( type == QLatin1String( 
"vsis3" )
 
  241            || type == QLatin1String( 
"vsigs" )
 
  242            || type == QLatin1String( 
"vsiaz" )
 
  243            || type == QLatin1String( 
"vsiadls" )
 
  244            || type == QLatin1String( 
"vsioss" )
 
  245            || type == QLatin1String( 
"vsiswift" )
 
  246            || type == QLatin1String( 
"vsihdfs" ) )
 
  248    prefix = QStringLiteral( 
"/%1/" ).arg( type );
 
  249    if ( !uri.startsWith( prefix ) )
 
  251      uri.prepend( prefix );
 
  255  else if ( type.startsWith( QLatin1String( 
"GeoJSON" ) ) )
 
  259  else if ( type == QLatin1String( 
"CouchDB" ) )
 
  261    prefix = QStringLiteral( 
"couchdb:" );
 
  262    if ( !uri.startsWith( prefix ) )
 
  264      uri.prepend( prefix );
 
  267  else if ( type == QLatin1String( 
"DODS/OPeNDAP" ) )
 
  269    prefix = QStringLiteral( 
"DODS:" );
 
  270    if ( !uri.startsWith( prefix ) )
 
  272      uri.prepend( prefix );
 
  275  else if ( type == QLatin1String( 
"WFS3" ) )
 
  277    prefix = QStringLiteral( 
"WFS3:" );
 
  278    if ( !uri.startsWith( prefix ) )
 
  280      uri.prepend( prefix );
 
  285  if ( !configId.isEmpty() )
 
  287    if ( expandAuthConfig )
 
  289      QStringList connectionItems;
 
  290      connectionItems << uri;
 
  293        uri = connectionItems.join( QString() );
 
  298      uri += QStringLiteral( 
" authcfg='%1'" ).arg( configId );
 
  301  else if ( !( username.isEmpty() || password.isEmpty() ) )
 
  303    uri.replace( QLatin1String( 
"://" ), QStringLiteral( 
"://%1:%2@" ).arg( username, password ) );
 
 
  310  switch ( option.
type )
 
  314      QComboBox *cb = 
new QComboBox( parent );
 
  315      if ( includeDefaultChoices )
 
  319      for ( 
const QString &val : std::as_const( option.
options ) )
 
  321        cb->addItem( val, val );
 
  323      cb->setCurrentIndex( 0 );
 
  330      QComboBox *cb = 
new QComboBox( parent );
 
  331      if ( includeDefaultChoices )
 
  335      cb->addItem( QObject::tr( 
"Yes" ), 
"YES" );
 
  336      cb->addItem( QObject::tr( 
"No" ), 
"NO" );
 
  337      cb->setCurrentIndex( 0 );
 
  347      if ( includeDefaultChoices )
 
  349        res->setPlaceholderText( QObject::tr( 
"Default" ) );
 
  358      if ( option.
minimum.isValid() )
 
  359        res->setMinimum( option.
minimum.toInt() );
 
  361        res->setMinimum( 0 );
 
  362      if ( option.
maximum.isValid() )
 
  363        res->setMaximum( option.
maximum.toInt() );
 
  365        res->setMaximum( std::numeric_limits<int>::max() - 1 );
 
  366      if ( includeDefaultChoices )
 
  368        res->setMinimum( res->minimum() - 1 );
 
  383      if ( option.
minimum.isValid() )
 
  384        res->setMinimum( option.
minimum.toDouble() );
 
  386        res->setMinimum( 0 );
 
  387      if ( option.
maximum.isValid() )
 
  388        res->setMaximum( option.
maximum.toDouble() );
 
  390        res->setMaximum( std::numeric_limits<double>::max() - 1 );
 
  393      if ( includeDefaultChoices )
 
  395        res->setMinimum( res->minimum() - 1 );
 
 
static QgsAuthManager * authManager()
Returns the application's authentication manager instance.
 
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value.
 
void setClearValueMode(ClearValueMode mode, const QString &clearValueText=QString())
Defines if the clear value should be the minimum or maximum values of the widget or a custom value.
 
void clear() override
Sets the current value to the value defined by the clear value.
 
@ MinimumValue
Reset value to minimum()
 
void setClearValue(double customValue, const QString &clearValueText=QString())
Defines the clear value as a custom value and will automatically set the clear value mode to CustomVa...
 
QLineEdit subclass with built in support for clearing the widget's value and handling custom null val...
 
void setShowClearButton(bool visible)
Sets whether the widget's clear button is visible.
 
static QString createProtocolURI(const QString &type, const QString &url, const QString &configId, const QString &username, const QString &password, bool expandAuthConfig=false)
Create protocol uri from connection parameters.
 
static QString createDatabaseURI(const QString &connectionType, const QString &host, const QString &database, QString port, const QString &configId, QString username, QString password, bool expandAuthConfig=false)
Create database uri from connection parameters.
 
static QWidget * createWidgetForOption(const QgsGdalOption &option, QWidget *parent=nullptr, bool includeDefaultChoices=false)
Creates a new widget for configuration a GDAL option.
 
Encapsulates the definition of a GDAL configuration option.
 
QVariant defaultValue
Default value.
 
QVariant maximum
Maximum acceptable value.
 
QStringList options
Available choices, for Select options.
 
QVariant minimum
Minimum acceptable value.
 
@ Select
Selection option.
 
QString description
Option description.
 
A spin box with a clear button that will set the value to the defined clear value.
 
@ MinimumValue
Reset value to minimum()
 
void setClearValueMode(ClearValueMode mode, const QString &clearValueText=QString())
Defines if the clear value should be the minimum or maximum values of the widget or a custom value.
 
void setClearValue(int customValue, const QString &clearValueText=QString())
Defines the clear value as a custom value and will automatically set the clear value mode to CustomVa...
 
void clear() override
Sets the current value to the value defined by the clear value.
 
static QVariant createNullVariant(QMetaType::Type metaType)
Helper method to properly create a null QVariant from a metaType Returns the created QVariant.
 
#define QgsDebugMsgLevel(str, level)