Skip to content

Commit

Permalink
Fix more qt deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Feb 5, 2020
1 parent 05c3186 commit b8a12be
Show file tree
Hide file tree
Showing 14 changed files with 160 additions and 124 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
9 changes: 9 additions & 0 deletions src/app/qgsidentifyresultsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <QFileDialog>
#include <QFileInfo>
#include <QRegExp>
#include <QScreen>

//graph
#include <qwt_plot.h>
Expand Down Expand Up @@ -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 )
{
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgssnappinglayertreemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
15 changes: 4 additions & 11 deletions src/gui/symbology/qgsgraduatedsymbolrendererwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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() );
Expand Down
10 changes: 8 additions & 2 deletions src/gui/symbology/qgsgraduatedsymbolrendererwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/providers/arcgisrest/qgsamsprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
77 changes: 40 additions & 37 deletions src/providers/delimitedtext/qgsdelimitedtextfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 "
Expand All @@ -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 );
Expand Down Expand Up @@ -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;
}

Expand Down
Loading

0 comments on commit b8a12be

Please sign in to comment.