Skip to content
Permalink
Browse files

Revert "OGR: add a download option to the protocol data source"

This reverts commit cf0d45e.
  • Loading branch information
elpaso committed Jan 26, 2019
1 parent cf0d45e commit 45ef886173044981d524b7982931d85cb0e6614b
Showing with 46 additions and 92 deletions.
  1. +5 −41 src/providers/ogr/qgsogrsourceselect.cpp
  2. +41 −51 src/ui/qgsogrsourceselectbase.ui
@@ -28,7 +28,6 @@
#include "qgsvectordataprovider.h"
#include "qgssettings.h"
#include "qgsproviderregistry.h"
#include "qgsfiledownloader.h"
#include "ogr/qgsnewogrconnection.h"
#include "ogr/qgsogrhelperfunctions.h"

@@ -305,7 +304,6 @@ void QgsOgrSourceSelect::setProtocolWidgetsVisibility()
labelKey->show();
mKey->show();
mAuthWarning->show();
mDownloadCheckBox->hide();
}
else
{
@@ -317,7 +315,6 @@ void QgsOgrSourceSelect::setProtocolWidgetsVisibility()
labelKey->hide();
mKey->hide();
mAuthWarning->hide();
mDownloadCheckBox->show();
}
}

@@ -400,45 +397,12 @@ void QgsOgrSourceSelect::addButtonClicked()
{
uri = protocolURI->text();
}
if ( cloudType || ! mDownloadCheckBox->isChecked() )
{

mDataSources << createProtocolURI( cmbProtocolTypes->currentText(),
uri,
mAuthSettingsProtocol->configId(),
mAuthSettingsProtocol->username(),
mAuthSettingsProtocol->password() );
}
else
{
QTemporaryFile tempFile;
tempFile.setAutoRemove( false );
tempFile.open();
tempFile.close();
QString filePath { tempFile.fileName() };
QString fileEncoding { encoding() };
QString dsType { dataSourceType() };
QUrl url { uri };
url.setUserName( mAuthSettingsProtocol->username() );
url.setPassword( mAuthSettingsProtocol->password() );
// QgsFileDownloader will self destruct, no leaks here
// As long as the application keeps the data source select dialog
// alive for the whole application lifetime, the lambdas below are
// safe regarding to "this".
QgsFileDownloader *downloader = new QgsFileDownloader( url, filePath, mAuthSettingsProtocol->configId() );
connect( downloader, &QgsFileDownloader::downloadCompleted, [ = ]
{
emit addVectorLayers( QStringList() << filePath, fileEncoding, dsType );
} );
connect( downloader, &QgsFileDownloader::downloadError, [ = ]( QStringList errorMessages )
{
QMessageBox::warning( this,
tr( "Error downloading layer data" ),
errorMessages.join( "<br/>" ) );
} );

}

mDataSources << createProtocolURI( cmbProtocolTypes->currentText(),
uri,
mAuthSettingsProtocol->configId(),
mAuthSettingsProtocol->username(),
mAuthSettingsProtocol->password() );
}
else if ( radioSrcFile->isChecked() )
{
@@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>478</width>
<height>756</height>
<width>450</width>
<height>658</height>
</rect>
</property>
<property name="sizePolicy">
@@ -126,6 +126,29 @@
<string>Protocol</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="1">
<widget class="QComboBox" name="cmbProtocolTypes"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Type</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelProtocolURI">
<property name="text">
<string>&amp;URI</string>
</property>
<property name="buddy">
<cstring>protocolURI</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="protocolURI"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelBucket">
<property name="text">
@@ -134,48 +157,38 @@
<property name="buddy">
<cstring>mBucket</cstring>
</property>
</widget>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="mBucket"/>
</item>
<item row="5" column="0" colspan="2">
<widget class="QLabel" name="mAuthWarning">
<item row="3" column="0">
<widget class="QLabel" name="labelKey">
<property name="text">
<string>…</string>
<string>Object key</string>
</property>
<property name="buddy">
<cstring>mKey</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="mKey"/>
</item>
<item row="4" column="0" colspan="2">
<widget class="QLabel" name="mAuthWarning">
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Type</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelProtocolURI">
<property name="text">
<string>&amp;URI</string>
</property>
<property name="buddy">
<cstring>protocolURI</cstring>
<string>…</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="cmbProtocolTypes"/>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="mKey"/>
</item>
<item row="6" column="0" colspan="2">
<item row="5" column="0" colspan="2">
<widget class="QGroupBox" name="mAuthGroupBox">
<property name="title">
<string>Authentication</string>
@@ -206,29 +219,6 @@
</layout>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="protocolURI"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="labelKey">
<property name="text">
<string>Object key</string>
</property>
<property name="buddy">
<cstring>mKey</cstring>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="mDownloadCheckBox">
<property name="toolTip">
<string>This option is useful if the service is a streaming service.</string>
</property>
<property name="text">
<string>Download all data before opening</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

0 comments on commit 45ef886

Please sign in to comment.
You can’t perform that action at this time.