Skip to content

Commit

Permalink
Revert "OGR: add a download option to the protocol data source"
Browse files Browse the repository at this point in the history
This reverts commit cf0d45e.
  • Loading branch information
elpaso committed Jan 26, 2019
1 parent cf0d45e commit 45ef886
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 92 deletions.
46 changes: 5 additions & 41 deletions src/providers/ogr/qgsogrsourceselect.cpp
Expand Up @@ -28,7 +28,6 @@
#include "qgsvectordataprovider.h"
#include "qgssettings.h"
#include "qgsproviderregistry.h"
#include "qgsfiledownloader.h"
#include "ogr/qgsnewogrconnection.h"
#include "ogr/qgsogrhelperfunctions.h"

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

Expand Down Expand Up @@ -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() )
{
Expand Down
92 changes: 41 additions & 51 deletions src/ui/qgsogrsourceselectbase.ui
Expand Up @@ -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">
Expand Down Expand Up @@ -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">
Expand All @@ -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>
Expand Down Expand Up @@ -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>
Expand Down

0 comments on commit 45ef886

Please sign in to comment.