Skip to content

Commit

Permalink
Remove all use of deprecated Qt methods up to Qt 5.14
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Oct 7, 2020
1 parent aa50eb0 commit 6da6a45
Show file tree
Hide file tree
Showing 69 changed files with 204 additions and 127 deletions.
2 changes: 1 addition & 1 deletion src/app/3d/qgs3dmapcanvas.cpp
Expand Up @@ -46,7 +46,7 @@ Qgs3DMapCanvas::Qgs3DMapCanvas( QWidget *parent )
mNavigationWidget = new Qgs3DNavigationWidget( this );

QHBoxLayout *hLayout = new QHBoxLayout( this );
hLayout->setMargin( 0 );
hLayout->setContentsMargins( 0, 0, 0, 0 );
hLayout->addWidget( mContainer, 1 );
hLayout->addWidget( mNavigationWidget );
this->setOnScreenNavigationVisibility(
Expand Down
8 changes: 8 additions & 0 deletions src/app/decorations/qgsdecorationgrid.cpp
Expand Up @@ -267,7 +267,11 @@ void QgsDecorationGrid::render( const QgsMapSettings &mapSettings, QgsRenderCont
hIt = horizontalLines.constBegin();
for ( ; hIt != horizontalLines.constEnd(); ++hIt )
{
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
if ( hIt->second.intersect( vIt->second, &intersectionPoint ) == QLineF::BoundedIntersection )
#else
if ( hIt->second.intersects( vIt->second, &intersectionPoint ) == QLineF::BoundedIntersection )
#endif
{
mMarkerSymbol->renderPoint( intersectionPoint, nullptr, context );
}
Expand Down Expand Up @@ -398,7 +402,11 @@ bool clipByRect( QLineF &line, const QPolygonF &rect )
for ( ; it != borderLines.constEnd(); ++it )
{
QPointF intersectionPoint;
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
if ( it->intersect( line, &intersectionPoint ) == QLineF::BoundedIntersection )
#else
if ( it->intersects( line, &intersectionPoint ) == QLineF::BoundedIntersection )
#endif
{
intersectionList.push_back( intersectionPoint );
if ( intersectionList.size() >= 2 )
Expand Down
16 changes: 16 additions & 0 deletions src/app/georeferencer/qgsresidualplotitem.cpp
Expand Up @@ -177,15 +177,23 @@ double QgsResidualPlotItem::maxMMToPixelRatioForGCP( const QgsGeorefDataPoint *p
if ( residual.y() > 0 )
{
QLineF lowerFrameLine( 0, rect().height(), rect().width(), rect().height() );
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
if ( residualLine.intersect( lowerFrameLine, &intersectionPoint ) != QLineF::NoIntersection )
#else
if ( residualLine.intersects( lowerFrameLine, &intersectionPoint ) != QLineF::NoIntersection )
#endif
{
upDownDist = dist( QPointF( pixelXMM, pixelYMM ), intersectionPoint );
}
}
else if ( residual.y() < 0 )
{
QLineF upperFrameLine( 0, 0, mExtent.xMaximum(), 0 );
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
if ( residualLine.intersect( upperFrameLine, &intersectionPoint ) != QLineF::NoIntersection )
#else
if ( residualLine.intersects( upperFrameLine, &intersectionPoint ) != QLineF::NoIntersection )
#endif
{
upDownDist = dist( QPointF( pixelXMM, pixelYMM ), intersectionPoint );
}
Expand All @@ -195,15 +203,23 @@ double QgsResidualPlotItem::maxMMToPixelRatioForGCP( const QgsGeorefDataPoint *p
if ( residual.x() > 0 )
{
QLineF rightFrameLine( rect().width(), 0, rect().width(), rect().height() );
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
if ( residualLine.intersect( rightFrameLine, &intersectionPoint ) != QLineF::NoIntersection )
#else
if ( residualLine.intersects( rightFrameLine, &intersectionPoint ) != QLineF::NoIntersection )
#endif
{
leftRightDist = dist( QPointF( pixelXMM, pixelYMM ), intersectionPoint );
}
}
else if ( residual.x() < 0 )
{
QLineF leftFrameLine( 0, 0, 0, rect().height() );
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
if ( residualLine.intersect( leftFrameLine, &intersectionPoint ) != QLineF::NoIntersection )
#else
if ( residualLine.intersects( leftFrameLine, &intersectionPoint ) != QLineF::NoIntersection )
#endif
{
leftRightDist = dist( QPointF( pixelXMM, pixelYMM ), intersectionPoint );
}
Expand Down
2 changes: 0 additions & 2 deletions src/app/layout/qgslayoutdesignerdialog.cpp
Expand Up @@ -312,10 +312,8 @@ QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFla
//create layout view
QGridLayout *viewLayout = new QGridLayout();
viewLayout->setSpacing( 0 );
viewLayout->setMargin( 0 );
viewLayout->setContentsMargins( 0, 0, 0, 0 );
centralWidget()->layout()->setSpacing( 0 );
centralWidget()->layout()->setMargin( 0 );
centralWidget()->layout()->setContentsMargins( 0, 0, 0, 0 );

mMessageBar = new QgsMessageBar( centralWidget() );
Expand Down
2 changes: 1 addition & 1 deletion src/app/layout/qgsreportorganizerwidget.cpp
Expand Up @@ -49,7 +49,7 @@ QgsReportOrganizerWidget::QgsReportOrganizerWidget( QWidget *parent, QgsLayoutDe
#endif

QVBoxLayout *vLayout = new QVBoxLayout();
vLayout->setMargin( 0 );
vLayout->setContentsMargins( 0, 0, 0, 0 );
vLayout->setSpacing( 0 );
mSettingsFrame->setLayout( vLayout );

Expand Down
3 changes: 1 addition & 2 deletions src/app/qgisapp.cpp
Expand Up @@ -1196,7 +1196,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
QgsGui::instance()->enableAutoGeometryRestore( dialog );
QVBoxLayout *layout = new QVBoxLayout( dialog );
layout->addWidget( mSnappingDialog );
layout->setMargin( 0 );
layout->setContentsMargins( 0, 0, 0, 0 );
mSnappingDialogContainer = dialog;
}
endProfile();
Expand Down Expand Up @@ -4794,7 +4794,6 @@ void QgisApp::initLayerTreeView()
toolbar->addAction( mActionRemoveLayer );

QVBoxLayout *vboxLayout = new QVBoxLayout;
vboxLayout->setMargin( 0 );
vboxLayout->setContentsMargins( 0, 0, 0, 0 );
vboxLayout->setSpacing( 0 );
vboxLayout->addWidget( toolbar );
Expand Down
8 changes: 2 additions & 6 deletions src/app/qgisappinterface.cpp
Expand Up @@ -780,14 +780,10 @@ bool QgisAppInterface::openFeatureForm( QgsVectorLayer *vlayer, QgsFeature &f, b

void QgisAppInterface::preloadForm( const QString &uifile )
{
QSignalMapper *signalMapper = new QSignalMapper( this );
mTimer = new QTimer( this );

connect( mTimer, SIGNAL( timeout() ), signalMapper, SLOT( map() ) );
connect( signalMapper, SIGNAL( mapped( QString ) ), mTimer, SLOT( stop() ) );
connect( signalMapper, SIGNAL( mapped( QString ) ), this, SLOT( cacheloadForm( QString ) ) );

signalMapper->setMapping( mTimer, uifile );
connect( mTimer, &QTimer::timeout, mTimer, &QTimer::stop );
connect( mTimer, &QTimer::timeout, this, [ = ] { cacheloadForm( uifile ); } );

mTimer->start( 0 );
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisappinterface.h
Expand Up @@ -318,7 +318,7 @@ class APP_EXPORT QgisAppInterface : public QgisInterface

private slots:

void cacheloadForm( const QString &uifile );
void cacheloadForm( const QString &uifile = QString() );

private:

Expand Down
2 changes: 0 additions & 2 deletions src/app/qgsattributetabledialog.cpp
Expand Up @@ -151,7 +151,6 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *layer, QgsAttr

setAttribute( Qt::WA_DeleteOnClose );

layout()->setMargin( 0 );
layout()->setContentsMargins( 0, 0, 0, 0 );
static_cast< QGridLayout * >( layout() )->setVerticalSpacing( 0 );

Expand Down Expand Up @@ -1009,7 +1008,6 @@ void QgsAttributeTableDialog::toggleDockMode( bool docked )

QVBoxLayout *vl = new QVBoxLayout();
vl->setContentsMargins( 0, 0, 0, 0 );
vl->setMargin( 0 );
vl->addWidget( this );
mDialog->setLayout( vl );

Expand Down
1 change: 0 additions & 1 deletion src/app/qgsbookmarks.cpp
Expand Up @@ -50,7 +50,6 @@ QgsBookmarks::QgsBookmarks( QWidget *parent )

connect( lstBookmarks, &QTreeView::doubleClicked, this, &QgsBookmarks::lstBookmarks_doubleClicked );

bookmarksDockContents->layout()->setMargin( 0 );
bookmarksDockContents->layout()->setContentsMargins( 0, 0, 0, 0 );
static_cast< QGridLayout * >( bookmarksDockContents->layout() )->setVerticalSpacing( 0 );

Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsfixattributedialog.cpp
Expand Up @@ -32,7 +32,7 @@ void QgsFixAttributeDialog::init( QgsVectorLayer *layer, const QgsAttributeEdito
{
setWindowTitle( tr( "%1 - Fix Pasted Features" ).arg( layer->name() ) );
setLayout( new QGridLayout() );
layout()->setMargin( 0 );
layout()->setContentsMargins( 0, 0, 0, 0 );

mUnfixedFeatures = mFeatures;
mCurrentFeature = mFeatures.begin();
Expand Down
2 changes: 0 additions & 2 deletions src/app/qgsmapcanvasdockwidget.cpp
Expand Up @@ -44,7 +44,6 @@ QgsMapCanvasDockWidget::QgsMapCanvasDockWidget( const QString &name, QWidget *pa
setAttribute( Qt::WA_DeleteOnClose );

mContents->layout()->setContentsMargins( 0, 0, 0, 0 );
mContents->layout()->setMargin( 0 );
static_cast< QVBoxLayout * >( mContents->layout() )->setSpacing( 0 );

setWindowTitle( name );
Expand All @@ -67,7 +66,6 @@ QgsMapCanvasDockWidget::QgsMapCanvasDockWidget( const QString &name, QWidget *pa

mMainWidget->setLayout( new QVBoxLayout() );
mMainWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
mMainWidget->layout()->setMargin( 0 );

mMainWidget->layout()->addWidget( mMapCanvas );

Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsrelationadddlg.cpp
Expand Up @@ -39,7 +39,7 @@ QgsFieldPairWidget::QgsFieldPairWidget( int index, QWidget *parent )
, mEnabled( index == 0 )
{
mLayout = new QHBoxLayout();
mLayout->setMargin( 0 );
mLayout->setContentsMargins( 0, 0, 0, 0 );

mAddButton = new QToolButton( this );
mAddButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/symbologyAdd.svg" ) ) );
Expand Down
1 change: 0 additions & 1 deletion src/app/qgsselectbyformdialog.cpp
Expand Up @@ -37,7 +37,6 @@ QgsSelectByFormDialog::QgsSelectByFormDialog( QgsVectorLayer *layer, const QgsAt
mForm->setMode( QgsAttributeEditorContext::SearchMode );

QVBoxLayout *vLayout = new QVBoxLayout();
vLayout->setMargin( 0 );
vLayout->setContentsMargins( 0, 0, 0, 0 );
setLayout( vLayout );

Expand Down
5 changes: 0 additions & 5 deletions src/app/qgswelcomepage.cpp
Expand Up @@ -50,7 +50,6 @@ QgsWelcomePage::QgsWelcomePage( bool skipVersionCheck, QWidget *parent )
QgsSettings settings;

QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->setMargin( 0 );
mainLayout->setContentsMargins( 0, 0, 0, 0 );
setLayout( mainLayout );

Expand All @@ -60,7 +59,6 @@ QgsWelcomePage::QgsWelcomePage( bool skipVersionCheck, QWidget *parent )
QWidget *leftContainer = new QWidget();
QVBoxLayout *leftLayout = new QVBoxLayout;
leftLayout->setContentsMargins( 0, 0, 0, 0 );
leftLayout->setMargin( 0 );

int titleSize = static_cast<int>( QApplication::fontMetrics().height() * 1.4 );
mRecentProjectsTitle = new QLabel( QStringLiteral( "<div style='font-size:%1px;font-weight:bold'>%2</div>" ).arg( QString::number( titleSize ), tr( "Recent Projects" ) ) );
Expand Down Expand Up @@ -90,7 +88,6 @@ QgsWelcomePage::QgsWelcomePage( bool skipVersionCheck, QWidget *parent )
QWidget *rightContainer = new QWidget();
QVBoxLayout *rightLayout = new QVBoxLayout;
rightLayout->setContentsMargins( 0, 0, 0, 0 );
rightLayout->setMargin( 0 );

if ( !QgsSettings().value( QStringLiteral( "%1/disabled" ).arg( QgsNewsFeedParser::keyForFeed( QStringLiteral( FEED_URL ) ) ), false, QgsSettings::Core ).toBool() )
{
Expand All @@ -99,7 +96,6 @@ QgsWelcomePage::QgsWelcomePage( bool skipVersionCheck, QWidget *parent )
QWidget *newsContainer = new QWidget();
QVBoxLayout *newsLayout = new QVBoxLayout();
newsLayout->setContentsMargins( 0, 0, 0, 0 );
newsLayout->setMargin( 0 );
mNewsFeedTitle = new QLabel( QStringLiteral( "<div style='font-size:%1px;font-weight:bold'>%2</div>" ).arg( titleSize ).arg( tr( "News" ) ) );
mNewsFeedTitle->setContentsMargins( titleSize / 2, titleSize / 6, 0, 0 );
newsLayout->addWidget( mNewsFeedTitle, 0 );
Expand Down Expand Up @@ -127,7 +123,6 @@ QgsWelcomePage::QgsWelcomePage( bool skipVersionCheck, QWidget *parent )
QWidget *templateContainer = new QWidget();
QVBoxLayout *templateLayout = new QVBoxLayout();
templateLayout->setContentsMargins( 0, 0, 0, 0 );
templateLayout->setMargin( 0 );
QLabel *templatesTitle = new QLabel( QStringLiteral( "<div style='font-size:%1px;font-weight:bold'>%2</div>" ).arg( titleSize ).arg( tr( "Project Templates" ) ) );
templatesTitle->setContentsMargins( titleSize / 2, titleSize / 6, 0, 0 );
templateLayout->addWidget( templatesTitle, 0 );
Expand Down
13 changes: 13 additions & 0 deletions src/core/diagram/qgstextdiagram.cpp
Expand Up @@ -174,19 +174,32 @@ void QgsTextDiagram::renderDiagram( const QgsFeature &feature, QgsRenderContext
QLineF verticalLine( baseX + w / nCategories * i, baseY + h, baseX + w / nCategories * i, baseY );
if ( baseX + w / nCategories * i < baseX + w / 2.0 )
{
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
verticalLine.intersect( triangleEdgeLeft, &intersectionPoint1 );
#else
verticalLine.intersects( triangleEdgeLeft, &intersectionPoint1 );
#endif
}
else
{
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
verticalLine.intersect( triangleEdgeRight, &intersectionPoint1 );
#else
verticalLine.intersects( triangleEdgeRight, &intersectionPoint1 );
#endif
}
p->drawLine( QPointF( baseX + w / nCategories * i, baseY + h ), intersectionPoint1 );
}
else //vertical
{
QLineF horizontalLine( baseX, baseY + h / nCategories * i, baseX + w, baseY + h / nCategories * i );
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
horizontalLine.intersect( triangleEdgeLeft, &intersectionPoint1 );
horizontalLine.intersect( triangleEdgeRight, &intersectionPoint2 );
#else
horizontalLine.intersects( triangleEdgeLeft, &intersectionPoint1 );
horizontalLine.intersects( triangleEdgeRight, &intersectionPoint2 );
#endif
p->drawLine( intersectionPoint1, intersectionPoint2 );
}
}
Expand Down
16 changes: 16 additions & 0 deletions src/core/labeling/qgspallabeling.cpp
Expand Up @@ -1331,7 +1331,11 @@ QPixmap QgsPalLayerSettings::labelSettingsPreviewPixmap( const QgsPalLayerSettin
textRect.setTop( bottom - textHeight );
textRect.setBottom( bottom );

#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
const double iconWidth = QFontMetricsF( QFont() ).width( 'X' ) * Qgis::UI_SCALE_FACTOR;
#else
const double iconWidth = QFontMetricsF( QFont() ).horizontalAdvance( 'X' ) * Qgis::UI_SCALE_FACTOR;
#endif

if ( settings.callout() && settings.callout()->enabled() )
{
Expand Down Expand Up @@ -1520,7 +1524,11 @@ void QgsPalLayerSettings::calculateLabelSize( const QFontMetricsF *fm, const QSt
{
QString dirSym = leftDirSymb;

#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
if ( fm->width( rightDirSymb ) > fm->width( dirSym ) )
#else
if ( fm->horizontalAdvance( rightDirSymb ) > fm->horizontalAdvance( dirSym ) )
#endif
dirSym = rightDirSymb;

switch ( placeDirSymb )
Expand Down Expand Up @@ -1561,7 +1569,11 @@ void QgsPalLayerSettings::calculateLabelSize( const QFontMetricsF *fm, const QSt

for ( const auto &line : multiLineSplit )
{
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
w = std::max( w, fm->width( line ) );
#else
w = std::max( w, fm->horizontalAdvance( line ) );
#endif
}
break;
}
Expand All @@ -1586,7 +1598,11 @@ void QgsPalLayerSettings::calculateLabelSize( const QFontMetricsF *fm, const QSt
double widthHorizontal = 0.0;
for ( const auto &line : multiLineSplit )
{
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
widthHorizontal = std::max( w, fm->width( line ) );
#else
widthHorizontal = std::max( w, fm->horizontalAdvance( line ) );
#endif
}

double widthVertical = 0.0;
Expand Down
13 changes: 13 additions & 0 deletions src/core/labeling/qgstextlabelfeature.cpp
Expand Up @@ -109,7 +109,11 @@ void QgsTextLabelFeature::calculateInfo( bool curvedLabeling, QFontMetricsF *fm,
{
// reconstruct how Qt creates word spacing, then adjust per individual stored character
// this will allow PAL to create each candidate width = character width + correct spacing
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
charWidth = fm->width( mClusters[i] );
#else
charWidth = fm->horizontalAdvance( mClusters[i] );
#endif
if ( curvedLabeling )
{
wordSpaceFix = qreal( 0.0 );
Expand All @@ -121,14 +125,23 @@ void QgsTextLabelFeature::calculateInfo( bool curvedLabeling, QFontMetricsF *fm,
}
// this workaround only works for clusters with a single character. Not sure how it should be handled
// with multi-character clusters.
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
if ( mClusters[i].length() == 1 &&
!qgsDoubleNear( fm->width( QString( mClusters[i].at( 0 ) ) ), fm->width( mClusters[i].at( 0 ) ) + letterSpacing ) )
#else
if ( mClusters[i].length() == 1 &&
!qgsDoubleNear( fm->horizontalAdvance( QString( mClusters[i].at( 0 ) ) ), fm->horizontalAdvance( mClusters[i].at( 0 ) ) + letterSpacing ) )
#endif
{
// word spacing applied when it shouldn't be
wordSpaceFix -= wordSpacing;
}

#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
charWidth = fm->width( QString( mClusters[i] ) ) + wordSpaceFix;
#else
charWidth = fm->horizontalAdvance( QString( mClusters[i] ) ) + wordSpaceFix;
#endif
}

double labelWidth = mapScale * charWidth;
Expand Down

0 comments on commit 6da6a45

Please sign in to comment.