QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgstiledsceneconnectiondialog.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgstiledsceneconnectiondialog.cpp
3 ---------------------
4 begin : June 2023
5 copyright : (C) 2023 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
17
18#include "qgsgui.h"
19#include "qgssettings.h"
21
22#include <QMessageBox>
23#include <QPushButton>
24
25#include "moc_qgstiledsceneconnectiondialog.cpp"
26
28
29QgsTiledSceneConnectionDialog::QgsTiledSceneConnectionDialog( QWidget *parent )
30 : QDialog( parent )
31{
32 setupUi( this );
34
35 buttonBox->button( QDialogButtonBox::Ok )->setDisabled( true );
36
37 connect( mEditName, &QLineEdit::textChanged, this, &QgsTiledSceneConnectionDialog::updateOkButtonState );
38 connect( mEditUrl, &QLineEdit::textChanged, this, &QgsTiledSceneConnectionDialog::updateOkButtonState );
39}
40
41void QgsTiledSceneConnectionDialog::setConnection( const QString &name, const QString &uri )
42{
43 mEditName->setText( name );
44 mOriginalConnectionName = name;
45
47 mEditUrl->setText( conn.url );
48
49 mAuthSettings->setUsername( conn.username );
50 mAuthSettings->setPassword( conn.password );
51 mEditReferer->setText( conn.httpHeaders[QgsHttpHeaders::KEY_REFERER].toString() );
52 mAuthSettings->setConfigId( conn.authCfg );
53}
54
55QString QgsTiledSceneConnectionDialog::connectionUri() const
56{
58 conn.url = mEditUrl->text();
59
60 conn.username = mAuthSettings->username();
61 conn.password = mAuthSettings->password();
62 conn.httpHeaders[QgsHttpHeaders::KEY_REFERER] = mEditReferer->text();
63 conn.authCfg = mAuthSettings->configId();
64
66}
67
68QString QgsTiledSceneConnectionDialog::connectionName() const
69{
70 return mEditName->text();
71}
72
73void QgsTiledSceneConnectionDialog::updateOkButtonState()
74{
75 const bool enabled = !mEditName->text().isEmpty() && !mEditUrl->text().isEmpty();
76 buttonBox->button( QDialogButtonBox::Ok )->setEnabled( enabled );
77}
78
79void QgsTiledSceneConnectionDialog::accept()
80{
81 const QString newConnectionName = mEditName->text();
82
83 // on rename delete original entry first
84 if ( !mOriginalConnectionName.isNull() && mOriginalConnectionName != newConnectionName )
85 {
86 QgsSettings settings;
87 QgsTiledSceneProviderConnection( QString() ).remove( mOriginalConnectionName );
88 settings.sync();
89 }
90
91 QDialog::accept();
92}
93
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
Definition qgsgui.cpp:221
static const QString KEY_REFERER
Used in settings as the referer key.
Stores settings for use within QGIS.
Definition qgssettings.h:65
void sync()
Writes any unsaved changes to permanent storage, and reloads any settings that have been changed in t...
Represents connections to tiled scene data sources.
void remove(const QString &name) const override
Deletes the connection from the settings.
static Data decodedUri(const QString &uri)
Returns a connection uri decoded to a data structure.
static QString encodedUri(const Data &data)
Returns connection data encoded as a string.
Represents decoded data of a tiled scene connection.
QString authCfg
Authentication configuration ID.