Fix more qt deprecation warnings

This commit is contained in:
Nyall Dawson 2020-02-05 10:54:37 +10:00
parent 05c3186324
commit b8a12be5b7
14 changed files with 160 additions and 124 deletions

View File

@ -63,7 +63,13 @@ Toggle the link between classes boundaries
void rowsMoved();
void modelDataChanged();
void refreshRanges( bool reset = false );
void refreshRanges( bool reset );
%Docstring
Refreshes the ranges for the renderer.
The ``reset`` argument is deprecated and has no effect.
%End
protected slots:

View File

@ -37,6 +37,7 @@
#include <QFileDialog>
#include <QFileInfo>
#include <QRegExp>
#include <QScreen>
//graph
#include <qwt_plot.h>
@ -951,7 +952,15 @@ void QgsIdentifyResultsDialog::addFeature( QgsRasterLayer *layer,
QgsIdentifyResultsWebViewItem *attrItem = new QgsIdentifyResultsWebViewItem( lstResults );
#ifdef WITH_QTWEBKIT
attrItem->webView()->page()->setLinkDelegationPolicy( QWebPage::DelegateExternalLinks );
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
const int horizontalDpi = qApp->desktop()->screen()->logicalDpiX();
#else
QScreen *screen = QGuiApplication::screenAt( mapToGlobal( QPoint( width() / 2, 0 ) ) );
const int horizontalDpi = screen->logicalDotsPerInchX();
#endif
// Adjust zoom: text is ok, but HTML seems rather big at least on Linux/KDE
if ( horizontalDpi > 96 )
{

View File

@ -72,7 +72,7 @@ class APP_EXPORT QgsSnappingLayerTreeModel : public QSortFilterProxyModel
QgsLayerTreeModel *layerTreeModel() const;
void setLayerTreeModel( QgsLayerTreeModel *layerTreeModel );
void resetLayerTreeModel() { reset(); }
void resetLayerTreeModel() { beginResetModel(); endResetModel(); }
QgsVectorLayer *vectorLayer( const QModelIndex &idx ) const;

View File

@ -373,16 +373,9 @@ void QgsGraduatedSymbolRendererModel::sort( int column, Qt::SortOrder order )
emit dataChanged( createIndex( 0, 0 ), createIndex( mRenderer->ranges().size(), 0 ) );
}
void QgsGraduatedSymbolRendererModel::updateSymbology( bool resetModel )
void QgsGraduatedSymbolRendererModel::updateSymbology()
{
if ( resetModel )
{
reset();
}
else
{
emit dataChanged( createIndex( 0, 0 ), createIndex( mRenderer->ranges().size(), 0 ) );
}
emit dataChanged( createIndex( 0, 0 ), createIndex( mRenderer->ranges().size(), 0 ) );
}
void QgsGraduatedSymbolRendererModel::updateLabels()
@ -898,12 +891,12 @@ void QgsGraduatedSymbolRendererWidget::clearParameterWidgets()
mParameterWidgetWrappers.clear();
}
void QgsGraduatedSymbolRendererWidget::refreshRanges( bool reset )
void QgsGraduatedSymbolRendererWidget::refreshRanges( bool )
{
if ( !mModel )
return;
mModel->updateSymbology( reset );
mModel->updateSymbology();
disconnectUpdateHandlers();
spinGraduatedClasses->setValue( mRenderer->ranges().count() );

View File

@ -59,7 +59,7 @@ class GUI_EXPORT QgsGraduatedSymbolRendererModel : public QAbstractItemModel
void deleteRows( QList<int> rows );
void removeAllRows();
void sort( int column, Qt::SortOrder order = Qt::AscendingOrder ) override;
void updateSymbology( bool resetModel = false );
void updateSymbology();
void updateLabels();
signals:
@ -125,7 +125,13 @@ class GUI_EXPORT QgsGraduatedSymbolRendererWidget : public QgsRendererWidget, pr
void rowsMoved();
void modelDataChanged();
void refreshRanges( bool reset = false );
/**
* Refreshes the ranges for the renderer.
*
* The \a reset argument is deprecated and has no effect.
*/
void refreshRanges( bool reset );
private slots:
void mSizeUnitWidget_changed();

View File

@ -165,7 +165,7 @@ void QgsAmsLegendFetcher::handleFinished()
{
maxImageSize.setWidth( std::max( maxImageSize.width(), legendEntry.second.width() ) );
maxImageSize.setHeight( std::max( maxImageSize.height(), legendEntry.second.height() ) );
textWidth = std::max( textWidth, fm.width( legendEntry.first ) + 10 );
textWidth = std::max( textWidth, fm.boundingRect( legendEntry.first ).width() + 10 );
}
double scaleFactor = maxImageSize.width() == 0 || maxImageSize.height() == 0 ? 1.0 :
std::min( 1., std::min( double( imageSize ) / maxImageSize.width(), double( imageSize ) / maxImageSize.height() ) );

View File

@ -536,10 +536,12 @@ QgsDelimitedTextFeatureSource::QgsDelimitedTextFeatureSource( const QgsDelimited
QUrl url = p->mFile->url();
// make sure watcher not created when using iterator (e.g. for rendering, see issue #15558)
if ( url.hasQueryItem( QStringLiteral( "watchFile" ) ) )
QUrlQuery query( url );
if ( query.hasQueryItem( QStringLiteral( "watchFile" ) ) )
{
url.removeQueryItem( QStringLiteral( "watchFile" ) );
query.removeQueryItem( QStringLiteral( "watchFile" ) );
}
url.setQuery( query );
mFile.reset( new QgsDelimitedTextFile() );
mFile->setFromUrl( url );

View File

@ -133,15 +133,16 @@ bool QgsDelimitedTextFile::setFromUrl( const QUrl &url )
setFileName( url.toLocalFile() );
// Extract the encoding
if ( url.hasQueryItem( QStringLiteral( "encoding" ) ) )
const QUrlQuery query( url );
if ( query.hasQueryItem( QStringLiteral( "encoding" ) ) )
{
mEncoding = url.queryItemValue( QStringLiteral( "encoding" ) );
mEncoding = query.queryItemValue( QStringLiteral( "encoding" ) );
}
//
if ( url.hasQueryItem( QStringLiteral( "watchFile" ) ) )
if ( query.hasQueryItem( QStringLiteral( "watchFile" ) ) )
{
mUseWatcher = url.queryItemValue( QStringLiteral( "watchFile" ) ).toUpper().startsWith( 'Y' );
mUseWatcher = query.queryItemValue( QStringLiteral( "watchFile" ) ).toUpper().startsWith( 'Y' );
}
// The default type is csv, to be consistent with the
@ -156,12 +157,12 @@ bool QgsDelimitedTextFile::setFromUrl( const QUrl &url )
// Prefer simple "type" for delimiter type, but include delimiterType
// as optional name for backwards compatibility
if ( url.hasQueryItem( QStringLiteral( "type" ) ) || url.hasQueryItem( QStringLiteral( "delimiterType" ) ) )
if ( query.hasQueryItem( QStringLiteral( "type" ) ) || query.hasQueryItem( QStringLiteral( "delimiterType" ) ) )
{
if ( url.hasQueryItem( QStringLiteral( "type" ) ) )
type = url.queryItemValue( QStringLiteral( "type" ) );
else if ( url.hasQueryItem( QStringLiteral( "delimiterType" ) ) )
type = url.queryItemValue( QStringLiteral( "delimiterType" ) );
if ( query.hasQueryItem( QStringLiteral( "type" ) ) )
type = query.queryItemValue( QStringLiteral( "type" ) );
else if ( query.hasQueryItem( QStringLiteral( "delimiterType" ) ) )
type = query.queryItemValue( QStringLiteral( "delimiterType" ) );
// Support for previous version of Qgs - plain chars had
// quote characters ' or "
@ -177,37 +178,37 @@ bool QgsDelimitedTextFile::setFromUrl( const QUrl &url )
escape.clear();
}
}
if ( url.hasQueryItem( QStringLiteral( "delimiter" ) ) )
if ( query.hasQueryItem( QStringLiteral( "delimiter" ) ) )
{
delimiter = url.queryItemValue( QStringLiteral( "delimiter" ) );
delimiter = query.queryItemValue( QStringLiteral( "delimiter" ) );
}
if ( url.hasQueryItem( QStringLiteral( "quote" ) ) )
if ( query.hasQueryItem( QStringLiteral( "quote" ) ) )
{
quote = url.queryItemValue( QStringLiteral( "quote" ) );
quote = query.queryItemValue( QStringLiteral( "quote" ) );
}
if ( url.hasQueryItem( QStringLiteral( "escape" ) ) )
if ( query.hasQueryItem( QStringLiteral( "escape" ) ) )
{
escape = url.queryItemValue( QStringLiteral( "escape" ) );
escape = query.queryItemValue( QStringLiteral( "escape" ) );
}
if ( url.hasQueryItem( QStringLiteral( "skipLines" ) ) )
if ( query.hasQueryItem( QStringLiteral( "skipLines" ) ) )
{
mSkipLines = url.queryItemValue( QStringLiteral( "skipLines" ) ).toInt();
mSkipLines = query.queryItemValue( QStringLiteral( "skipLines" ) ).toInt();
}
if ( url.hasQueryItem( QStringLiteral( "useHeader" ) ) )
if ( query.hasQueryItem( QStringLiteral( "useHeader" ) ) )
{
mUseHeader = ! url.queryItemValue( QStringLiteral( "useHeader" ) ).toUpper().startsWith( 'N' );
mUseHeader = ! query.queryItemValue( QStringLiteral( "useHeader" ) ).toUpper().startsWith( 'N' );
}
if ( url.hasQueryItem( QStringLiteral( "skipEmptyFields" ) ) )
if ( query.hasQueryItem( QStringLiteral( "skipEmptyFields" ) ) )
{
mDiscardEmptyFields = ! url.queryItemValue( QStringLiteral( "skipEmptyFields" ) ).toUpper().startsWith( 'N' );
mDiscardEmptyFields = ! query.queryItemValue( QStringLiteral( "skipEmptyFields" ) ).toUpper().startsWith( 'N' );
}
if ( url.hasQueryItem( QStringLiteral( "trimFields" ) ) )
if ( query.hasQueryItem( QStringLiteral( "trimFields" ) ) )
{
mTrimFields = ! url.queryItemValue( QStringLiteral( "trimFields" ) ).toUpper().startsWith( 'N' );
mTrimFields = ! query.queryItemValue( QStringLiteral( "trimFields" ) ).toUpper().startsWith( 'N' );
}
if ( url.hasQueryItem( QStringLiteral( "maxFields" ) ) )
if ( query.hasQueryItem( QStringLiteral( "maxFields" ) ) )
{
mMaxFields = url.queryItemValue( QStringLiteral( "maxFields" ) ).toInt();
mMaxFields = query.queryItemValue( QStringLiteral( "maxFields" ) ).toInt();
}
QgsDebugMsg( "Delimited text file is: " + mFileName );
@ -245,47 +246,49 @@ bool QgsDelimitedTextFile::setFromUrl( const QUrl &url )
QUrl QgsDelimitedTextFile::url()
{
QUrl url = QUrl::fromLocalFile( mFileName );
QUrlQuery query( url );
if ( mEncoding != QLatin1String( "UTF-8" ) )
{
url.addQueryItem( QStringLiteral( "encoding" ), mEncoding );
query.addQueryItem( QStringLiteral( "encoding" ), mEncoding );
}
if ( mUseWatcher )
{
url.addQueryItem( QStringLiteral( "watchFile" ), QStringLiteral( "yes" ) );
query.addQueryItem( QStringLiteral( "watchFile" ), QStringLiteral( "yes" ) );
}
url.addQueryItem( QStringLiteral( "type" ), type() );
query.addQueryItem( QStringLiteral( "type" ), type() );
if ( mType == DelimTypeRegexp )
{
url.addQueryItem( QStringLiteral( "delimiter" ), mDelimRegexp.pattern() );
query.addQueryItem( QStringLiteral( "delimiter" ), mDelimRegexp.pattern() );
}
if ( mType == DelimTypeCSV )
{
if ( mDelimChars != QLatin1String( "," ) ) url.addQueryItem( QStringLiteral( "delimiter" ), encodeChars( mDelimChars ) );
if ( mQuoteChar != QLatin1String( "\"" ) ) url.addQueryItem( QStringLiteral( "quote" ), encodeChars( mQuoteChar ) );
if ( mEscapeChar != QLatin1String( "\"" ) ) url.addQueryItem( QStringLiteral( "escape" ), encodeChars( mEscapeChar ) );
if ( mDelimChars != QLatin1String( "," ) ) query.addQueryItem( QStringLiteral( "delimiter" ), encodeChars( mDelimChars ) );
if ( mQuoteChar != QLatin1String( "\"" ) ) query.addQueryItem( QStringLiteral( "quote" ), encodeChars( mQuoteChar ) );
if ( mEscapeChar != QLatin1String( "\"" ) ) query.addQueryItem( QStringLiteral( "escape" ), encodeChars( mEscapeChar ) );
}
if ( mSkipLines > 0 )
{
url.addQueryItem( QStringLiteral( "skipLines" ), QString::number( mSkipLines ) );
query.addQueryItem( QStringLiteral( "skipLines" ), QString::number( mSkipLines ) );
}
if ( ! mUseHeader )
{
url.addQueryItem( QStringLiteral( "useHeader" ), QStringLiteral( "No" ) );
query.addQueryItem( QStringLiteral( "useHeader" ), QStringLiteral( "No" ) );
}
if ( mTrimFields )
{
url.addQueryItem( QStringLiteral( "trimFields" ), QStringLiteral( "Yes" ) );
query.addQueryItem( QStringLiteral( "trimFields" ), QStringLiteral( "Yes" ) );
}
if ( mDiscardEmptyFields && mType != DelimTypeWhitespace )
{
url.addQueryItem( QStringLiteral( "skipEmptyFields" ), QStringLiteral( "Yes" ) );
query.addQueryItem( QStringLiteral( "skipEmptyFields" ), QStringLiteral( "Yes" ) );
}
if ( mMaxFields > 0 )
{
url.addQueryItem( QStringLiteral( "maxFields" ), QString::number( mMaxFields ) );
query.addQueryItem( QStringLiteral( "maxFields" ), QString::number( mMaxFields ) );
}
url.setQuery( query );
return url;
}

View File

@ -72,15 +72,16 @@ QgsDelimitedTextProvider::QgsDelimitedTextProvider( const QString &uri, const Pr
QgsDebugMsg( "Delimited text file uri is " + uri );
QUrl url = QUrl::fromEncoded( uri.toLatin1() );
const QUrl url = QUrl::fromEncoded( uri.toLatin1() );
mFile = qgis::make_unique< QgsDelimitedTextFile >();
mFile->setFromUrl( url );
QString subset;
if ( url.hasQueryItem( QStringLiteral( "geomType" ) ) )
const QUrlQuery query( url );
if ( query.hasQueryItem( QStringLiteral( "geomType" ) ) )
{
QString gtype = url.queryItemValue( QStringLiteral( "geomType" ) ).toLower();
QString gtype = query.queryItemValue( QStringLiteral( "geomType" ) ).toLower();
if ( gtype == QLatin1String( "point" ) ) mGeometryType = QgsWkbTypes::PointGeometry;
else if ( gtype == QLatin1String( "line" ) ) mGeometryType = QgsWkbTypes::LineGeometry;
else if ( gtype == QLatin1String( "polygon" ) ) mGeometryType = QgsWkbTypes::PolygonGeometry;
@ -89,30 +90,30 @@ QgsDelimitedTextProvider::QgsDelimitedTextProvider( const QString &uri, const Pr
if ( mGeometryType != QgsWkbTypes::NullGeometry )
{
if ( url.hasQueryItem( QStringLiteral( "wktField" ) ) )
if ( query.hasQueryItem( QStringLiteral( "wktField" ) ) )
{
mWktFieldName = url.queryItemValue( QStringLiteral( "wktField" ) );
mWktFieldName = query.queryItemValue( QStringLiteral( "wktField" ) );
mGeomRep = GeomAsWkt;
QgsDebugMsg( "wktField is: " + mWktFieldName );
}
else if ( url.hasQueryItem( QStringLiteral( "xField" ) ) && url.hasQueryItem( QStringLiteral( "yField" ) ) )
else if ( query.hasQueryItem( QStringLiteral( "xField" ) ) && query.hasQueryItem( QStringLiteral( "yField" ) ) )
{
mGeomRep = GeomAsXy;
mGeometryType = QgsWkbTypes::PointGeometry;
mXFieldName = url.queryItemValue( QStringLiteral( "xField" ) );
mYFieldName = url.queryItemValue( QStringLiteral( "yField" ) );
if ( url.hasQueryItem( QStringLiteral( "zField" ) ) )
mZFieldName = url.queryItemValue( QStringLiteral( "zField" ) );
if ( url.hasQueryItem( QStringLiteral( "mField" ) ) )
mMFieldName = url.queryItemValue( QStringLiteral( "mField" ) );
mXFieldName = query.queryItemValue( QStringLiteral( "xField" ) );
mYFieldName = query.queryItemValue( QStringLiteral( "yField" ) );
if ( query.hasQueryItem( QStringLiteral( "zField" ) ) )
mZFieldName = query.queryItemValue( QStringLiteral( "zField" ) );
if ( query.hasQueryItem( QStringLiteral( "mField" ) ) )
mMFieldName = query.queryItemValue( QStringLiteral( "mField" ) );
QgsDebugMsg( "xField is: " + mXFieldName );
QgsDebugMsg( "yField is: " + mYFieldName );
QgsDebugMsg( "zField is: " + mZFieldName );
QgsDebugMsg( "mField is: " + mMFieldName );
if ( url.hasQueryItem( QStringLiteral( "xyDms" ) ) )
if ( query.hasQueryItem( QStringLiteral( "xyDms" ) ) )
{
mXyDms = ! url.queryItemValue( QStringLiteral( "xyDms" ) ).toLower().startsWith( 'n' );
mXyDms = ! query.queryItemValue( QStringLiteral( "xyDms" ) ).toLower().startsWith( 'n' );
}
}
else
@ -122,33 +123,33 @@ QgsDelimitedTextProvider::QgsDelimitedTextProvider( const QString &uri, const Pr
}
mDetectTypes = true;
if ( url.hasQueryItem( QStringLiteral( "detectTypes" ) ) )
mDetectTypes = ! url.queryItemValue( QStringLiteral( "detectTypes" ) ).toLower().startsWith( 'n' );
if ( query.hasQueryItem( QStringLiteral( "detectTypes" ) ) )
mDetectTypes = ! query.queryItemValue( QStringLiteral( "detectTypes" ) ).toLower().startsWith( 'n' );
if ( url.hasQueryItem( QStringLiteral( "decimalPoint" ) ) )
mDecimalPoint = url.queryItemValue( QStringLiteral( "decimalPoint" ) );
if ( query.hasQueryItem( QStringLiteral( "decimalPoint" ) ) )
mDecimalPoint = query.queryItemValue( QStringLiteral( "decimalPoint" ) );
if ( url.hasQueryItem( QStringLiteral( "crs" ) ) )
mCrs.createFromString( url.queryItemValue( QStringLiteral( "crs" ) ) );
if ( query.hasQueryItem( QStringLiteral( "crs" ) ) )
mCrs.createFromString( query.queryItemValue( QStringLiteral( "crs" ) ) );
if ( url.hasQueryItem( QStringLiteral( "subsetIndex" ) ) )
if ( query.hasQueryItem( QStringLiteral( "subsetIndex" ) ) )
{
mBuildSubsetIndex = ! url.queryItemValue( QStringLiteral( "subsetIndex" ) ).toLower().startsWith( 'n' );
mBuildSubsetIndex = ! query.queryItemValue( QStringLiteral( "subsetIndex" ) ).toLower().startsWith( 'n' );
}
if ( url.hasQueryItem( QStringLiteral( "spatialIndex" ) ) )
if ( query.hasQueryItem( QStringLiteral( "spatialIndex" ) ) )
{
mBuildSpatialIndex = ! url.queryItemValue( QStringLiteral( "spatialIndex" ) ).toLower().startsWith( 'n' );
mBuildSpatialIndex = ! query.queryItemValue( QStringLiteral( "spatialIndex" ) ).toLower().startsWith( 'n' );
}
if ( url.hasQueryItem( QStringLiteral( "subset" ) ) )
if ( query.hasQueryItem( QStringLiteral( "subset" ) ) )
{
// We need to specify FullyDecoded so that %25 is decoded as %
subset = QUrlQuery( url ).queryItemValue( QStringLiteral( "subset" ), QUrl::FullyDecoded );
subset = query.queryItemValue( QStringLiteral( "subset" ), QUrl::FullyDecoded );
QgsDebugMsg( "subset is: " + subset );
}
if ( url.hasQueryItem( QStringLiteral( "quiet" ) ) ) mShowInvalidLines = false;
if ( query.hasQueryItem( QStringLiteral( "quiet" ) ) ) mShowInvalidLines = false;
// Do an initial scan of the file to determine field names, types,
// geometry type (for Wkt), extents, etc. Parameter value subset.isEmpty()
@ -1128,10 +1129,12 @@ bool QgsDelimitedTextProvider::setSubsetString( const QString &subset, bool upda
void QgsDelimitedTextProvider::setUriParameter( const QString &parameter, const QString &value )
{
QUrl url = QUrl::fromEncoded( dataSourceUri().toLatin1() );
if ( url.hasQueryItem( parameter ) )
url.removeAllQueryItems( parameter );
QUrlQuery query( url );
if ( query.hasQueryItem( parameter ) )
query.removeAllQueryItems( parameter );
if ( ! value.isEmpty() )
url.addQueryItem( parameter, value );
query.addQueryItem( parameter, value );
url.setQuery( query );
setDataSourceUri( QString::fromLatin1( url.toEncoded() ) );
}

View File

@ -138,16 +138,17 @@ void QgsDelimitedTextSourceSelect::addButtonClicked()
//Build the delimited text URI from the user provided information
QUrl url = mFile->url();
QUrlQuery query( url );
url.addQueryItem( QStringLiteral( "detectTypes" ), cbxDetectTypes->isChecked() ? QStringLiteral( "yes" ) : QStringLiteral( "no" ) );
query.addQueryItem( QStringLiteral( "detectTypes" ), cbxDetectTypes->isChecked() ? QStringLiteral( "yes" ) : QStringLiteral( "no" ) );
if ( cbxPointIsComma->isChecked() )
{
url.addQueryItem( QStringLiteral( "decimalPoint" ), QStringLiteral( "," ) );
query.addQueryItem( QStringLiteral( "decimalPoint" ), QStringLiteral( "," ) );
}
if ( cbxXyDms->isChecked() )
{
url.addQueryItem( QStringLiteral( "xyDms" ), QStringLiteral( "yes" ) );
query.addQueryItem( QStringLiteral( "xyDms" ), QStringLiteral( "yes" ) );
}
bool haveGeom = true;
@ -157,19 +158,19 @@ void QgsDelimitedTextSourceSelect::addButtonClicked()
if ( !cmbXField->currentText().isEmpty() && !cmbYField->currentText().isEmpty() )
{
field = cmbXField->currentText();
url.addQueryItem( QStringLiteral( "xField" ), field );
query.addQueryItem( QStringLiteral( "xField" ), field );
field = cmbYField->currentText();
url.addQueryItem( QStringLiteral( "yField" ), field );
query.addQueryItem( QStringLiteral( "yField" ), field );
}
if ( !cmbZField->currentText().isEmpty() )
{
field = cmbZField->currentText();
url.addQueryItem( QStringLiteral( "zField" ), field );
query.addQueryItem( QStringLiteral( "zField" ), field );
}
if ( !cmbMField->currentText().isEmpty() )
{
field = cmbMField->currentText();
url.addQueryItem( QStringLiteral( "mField" ), field );
query.addQueryItem( QStringLiteral( "mField" ), field );
}
}
else if ( geomTypeWKT->isChecked() )
@ -177,36 +178,37 @@ void QgsDelimitedTextSourceSelect::addButtonClicked()
if ( ! cmbWktField->currentText().isEmpty() )
{
QString field = cmbWktField->currentText();
url.addQueryItem( QStringLiteral( "wktField" ), field );
query.addQueryItem( QStringLiteral( "wktField" ), field );
}
if ( cmbGeometryType->currentIndex() > 0 )
{
url.addQueryItem( QStringLiteral( "geomType" ), cmbGeometryType->currentText() );
query.addQueryItem( QStringLiteral( "geomType" ), cmbGeometryType->currentText() );
}
}
else
{
haveGeom = false;
url.addQueryItem( QStringLiteral( "geomType" ), QStringLiteral( "none" ) );
query.addQueryItem( QStringLiteral( "geomType" ), QStringLiteral( "none" ) );
}
if ( haveGeom )
{
QgsCoordinateReferenceSystem crs = crsGeometry->crs();
if ( crs.isValid() )
{
url.addQueryItem( QStringLiteral( "crs" ), crs.authid() );
query.addQueryItem( QStringLiteral( "crs" ), crs.authid() );
}
}
if ( ! geomTypeNone->isChecked() )
{
url.addQueryItem( QStringLiteral( "spatialIndex" ), cbxSpatialIndex->isChecked() ? QStringLiteral( "yes" ) : QStringLiteral( "no" ) );
query.addQueryItem( QStringLiteral( "spatialIndex" ), cbxSpatialIndex->isChecked() ? QStringLiteral( "yes" ) : QStringLiteral( "no" ) );
}
url.addQueryItem( QStringLiteral( "subsetIndex" ), cbxSubsetIndex->isChecked() ? QStringLiteral( "yes" ) : QStringLiteral( "no" ) );
url.addQueryItem( QStringLiteral( "watchFile" ), cbxWatchFile->isChecked() ? QStringLiteral( "yes" ) : QStringLiteral( "no" ) );
query.addQueryItem( QStringLiteral( "subsetIndex" ), cbxSubsetIndex->isChecked() ? QStringLiteral( "yes" ) : QStringLiteral( "no" ) );
query.addQueryItem( QStringLiteral( "watchFile" ), cbxWatchFile->isChecked() ? QStringLiteral( "yes" ) : QStringLiteral( "no" ) );
url.setQuery( query );
// store the settings
saveSettings();
saveSettingsForFile( mFileWidget->filePath() );

View File

@ -526,8 +526,10 @@ void QgsWcsProvider::setCoverageCrs( QString const &crs )
void QgsWcsProvider::setQueryItem( QUrl &url, const QString &item, const QString &value ) const
{
url.removeQueryItem( item );
url.addQueryItem( item, value );
QUrlQuery query( url );
query.removeQueryItem( item );
query.addQueryItem( item, value );
url.setQuery( query );
}
bool QgsWcsProvider::readBlock( int bandNo, QgsRectangle const &viewExtent, int pixelWidth, int pixelHeight, void *block, QgsRasterBlockFeedback *feedback )

View File

@ -264,7 +264,9 @@ bool QgsBaseNetworkRequest::sendPOST( const QUrl &url, const QString &contentTyp
{
// Hack for testing purposes
QUrl modifiedUrl( url );
modifiedUrl.addQueryItem( QStringLiteral( "POSTDATA" ), QString::fromUtf8( data ) );
QUrlQuery query( modifiedUrl );
query.addQueryItem( QStringLiteral( "POSTDATA" ), QString::fromUtf8( data ) );
modifiedUrl.setQuery( query );
return sendGET( modifiedUrl, QString(), true, true, false );
}

View File

@ -41,15 +41,17 @@ QgsWfsCapabilities::QgsWfsCapabilities( const QString &uri, const QgsDataProvide
bool QgsWfsCapabilities::requestCapabilities( bool synchronous, bool forceRefresh )
{
QUrl url( mUri.baseURL( ) );
url.addQueryItem( QStringLiteral( "REQUEST" ), QStringLiteral( "GetCapabilities" ) );
QUrlQuery query( url );
query.addQueryItem( QStringLiteral( "REQUEST" ), QStringLiteral( "GetCapabilities" ) );
const QString &version = mUri.version();
if ( version == QgsWFSConstants::VERSION_AUTO )
// MapServer honours the order with the first value being the preferred one
url.addQueryItem( QStringLiteral( "ACCEPTVERSIONS" ), QStringLiteral( "2.0.0,1.1.0,1.0.0" ) );
query.addQueryItem( QStringLiteral( "ACCEPTVERSIONS" ), QStringLiteral( "2.0.0,1.1.0,1.0.0" ) );
else
url.addQueryItem( QStringLiteral( "VERSION" ), version );
query.addQueryItem( QStringLiteral( "VERSION" ), version );
url.setQuery( query );
if ( !sendGET( url, QString(), synchronous, forceRefresh ) )
{
emit gotCapabilities();

View File

@ -46,40 +46,42 @@ QgsWFSDataSourceURI::QgsWFSDataSourceURI( const QString &uri )
};
QUrl url( uri );
QUrlQuery query( url );
// Transform all param keys to lowercase
const auto items( url.queryItems() );
const QList<QPair<QString, QString> > items( query.queryItems() );
for ( const queryItem &item : items )
{
url.removeQueryItem( item.first );
url.addQueryItem( item.first.toLower(), item.second );
query.removeQueryItem( item.first );
query.addQueryItem( item.first.toLower(), item.second );
}
QString srsname = url.queryItemValue( QgsWFSConstants::URI_PARAM_SRSNAME );
QString bbox = url.queryItemValue( QgsWFSConstants::URI_PARAM_BBOX );
QString typeName = url.queryItemValue( QgsWFSConstants::URI_PARAM_TYPENAME );
QString version = url.queryItemValue( QgsWFSConstants::URI_PARAM_VERSION );
QString filter = url.queryItemValue( QgsWFSConstants::URI_PARAM_FILTER );
QString outputFormat = url.queryItemValue( QgsWFSConstants::URI_PARAM_OUTPUTFORMAT );
mAuth.mAuthCfg = url.queryItemValue( QgsWFSConstants::URI_PARAM_AUTHCFG );
QString srsname = query.queryItemValue( QgsWFSConstants::URI_PARAM_SRSNAME );
QString bbox = query.queryItemValue( QgsWFSConstants::URI_PARAM_BBOX );
QString typeName = query.queryItemValue( QgsWFSConstants::URI_PARAM_TYPENAME );
QString version = query.queryItemValue( QgsWFSConstants::URI_PARAM_VERSION );
QString filter = query.queryItemValue( QgsWFSConstants::URI_PARAM_FILTER );
QString outputFormat = query.queryItemValue( QgsWFSConstants::URI_PARAM_OUTPUTFORMAT );
mAuth.mAuthCfg = query.queryItemValue( QgsWFSConstants::URI_PARAM_AUTHCFG );
// NOTE: A defined authcfg overrides any older username/password auth
// Only check for older auth if it is undefined
if ( mAuth.mAuthCfg.isEmpty() )
{
mAuth.mUserName = url.queryItemValue( QgsWFSConstants::URI_PARAM_USERNAME );
mAuth.mUserName = query.queryItemValue( QgsWFSConstants::URI_PARAM_USERNAME );
// In QgsDataSourceURI, the "username" param is named "user", check it
if ( mAuth.mUserName.isEmpty() )
{
mAuth.mUserName = url.queryItemValue( QgsWFSConstants::URI_PARAM_USER );
mAuth.mUserName = query.queryItemValue( QgsWFSConstants::URI_PARAM_USER );
}
mAuth.mPassword = url.queryItemValue( QgsWFSConstants::URI_PARAM_PASSWORD );
mAuth.mPassword = query.queryItemValue( QgsWFSConstants::URI_PARAM_PASSWORD );
}
// Now remove all stuff that is not the core URL
for ( auto param : url.queryItems() )
for ( const QPair<QString, QString> &param : query.queryItems() )
{
if ( sFilter.contains( param.first.toLower() ) )
url.removeAllQueryItems( param.first );
query.removeAllQueryItems( param.first );
}
url.setQuery( query );
mURI = QgsDataSourceUri();
mURI.setParam( QgsWFSConstants::URI_PARAM_URL, url.toEncoded() );
@ -102,19 +104,20 @@ QgsWFSDataSourceURI::QgsWFSDataSourceURI( const QString &uri )
else
{
QUrl url( mURI.param( QgsWFSConstants::URI_PARAM_URL ) );
QUrlQuery query( url );
bool URLModified = false;
bool somethingChanged = false;
do
{
somethingChanged = false;
const auto items( url.queryItems() );
const QList<QPair<QString, QString> > items( query.queryItems() );
for ( const queryItem &item : items )
{
const QString lowerName( item.first.toLower() );
if ( lowerName == QgsWFSConstants::URI_PARAM_OUTPUTFORMAT )
{
setOutputFormat( item.second );
url.removeQueryItem( item.first );
query.removeQueryItem( item.first );
somethingChanged = true;
URLModified = true;
break;
@ -125,7 +128,7 @@ QgsWFSDataSourceURI::QgsWFSDataSourceURI( const QString &uri )
lowerName == QLatin1String( "typenames" ) ||
lowerName == QLatin1String( "version" ) )
{
url.removeQueryItem( item.first );
query.removeQueryItem( item.first );
somethingChanged = true;
URLModified = true;
break;
@ -133,6 +136,7 @@ QgsWFSDataSourceURI::QgsWFSDataSourceURI( const QString &uri )
}
}
while ( somethingChanged );
url.setQuery( query );
if ( URLModified )
{
mURI.setParam( QgsWFSConstants::URI_PARAM_URL, url.toEncoded() );
@ -172,10 +176,12 @@ const QString QgsWFSDataSourceURI::uri() const
QUrl QgsWFSDataSourceURI::baseURL( bool bIncludeServiceWFS ) const
{
QUrl url( mURI.param( QgsWFSConstants::URI_PARAM_URL ) );
QUrlQuery query( url );
if ( bIncludeServiceWFS )
{
url.addQueryItem( QStringLiteral( "SERVICE" ), QStringLiteral( "WFS" ) );
query.addQueryItem( QStringLiteral( "SERVICE" ), QStringLiteral( "WFS" ) );
}
url.setQuery( query );
return url;
}