Skip to content
Permalink
Browse files

Fix more qt deprecation warnings

  • Loading branch information
nyalldawson committed Feb 5, 2020
1 parent 05c3186 commit b8a12be5b737d855d20c81cdddf07a7be1962cb4
@@ -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:

@@ -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 )
{
@@ -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;

@@ -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() );
@@ -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();
@@ -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() ) );
@@ -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 );
@@ -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;
}

0 comments on commit b8a12be

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