Bump minimum Qt version to 5.9

This commit is contained in:
Nyall Dawson 2018-11-05 08:53:08 +10:00
parent 993dc81812
commit dc72f06e53
30 changed files with 4 additions and 194 deletions

View File

@ -315,14 +315,7 @@ IF(WITH_CORE)
ENDIF(WITH_QTWEBKIT)
#############################################################
# search for Qt5
IF (WITH_3D)
# for 3D support we strictly require Qt >= 5.9
# (Qt 3D was introduced in 5.7 but it is not stable enough in that branch)
# Qt 5.8 is missing some classes, https://github.com/qgis/QGIS/pull/5203#discussion_r142319862
SET(QT_MIN_VERSION 5.9.0)
ELSE ()
SET(QT_MIN_VERSION 5.4.0)
ENDIF()
SET(QT_MIN_VERSION 5.9.0)
FIND_PACKAGE(Qt5Core QUIET)
FIND_PACKAGE(Qt5Gui REQUIRED)
FIND_PACKAGE(Qt5Widgets REQUIRED)

View File

@ -97,7 +97,7 @@ Required build tools:
Required build dependencies:
- Qt >= 5.3.0
- Qt >= 5.9.0
- Proj >= 4.4.x
- GEOS >= 3.4
- Sqlite3 >= 3.0.0

View File

@ -15,7 +15,7 @@ Required build tools:
Required build dependencies:
- Qt >= 5.3.0
- Qt >= 5.9.0
- Proj >= 4.4.x
- GEOS >= 3.4
- Sqlite3 >= 3.0.0

View File

@ -97,11 +97,7 @@ class DlgSqlWindow(QWidget, Ui_Dialog):
self.btnCancel.setText(self.tr("Cancel (ESC)"))
self.btnCancel.setEnabled(False)
self.btnCancel.clicked.connect(self.executeSqlCanceled)
try:
self.btnCancel.setShortcut(QKeySequence.Cancel)
except AttributeError:
# QKeySequence.Cancel only available in Qt >= 5.6
pass
self.btnCancel.setShortcut(QKeySequence.Cancel)
self.progressBar.setEnabled(False)
self.progressBar.setRange(0, 100)
self.progressBar.setValue(0)

View File

@ -125,13 +125,8 @@ void QgsDecorationCopyright::render( const QgsMapSettings &mapSettings, QgsRende
double textHeight = QgsTextRenderer::textHeight( context, mTextFormat, displayStringList, QgsTextRenderer::Point, &fm );
QPaintDevice *device = context.painter()->device();
#if QT_VERSION < 0x050600
int deviceHeight = device->height() / device->devicePixelRatio();
int deviceWidth = device->width() / device->devicePixelRatio();
#else
int deviceHeight = device->height() / device->devicePixelRatioF();
int deviceWidth = device->width() / device->devicePixelRatioF();
#endif
float xOffset( 0 ), yOffset( 0 );

View File

@ -169,13 +169,8 @@ void QgsDecorationNorthArrow::render( const QgsMapSettings &mapSettings, QgsRend
) - centerYDouble );
// need width/height of paint device
QPaintDevice *device = context.painter()->device();
#if QT_VERSION < 0x050600
int deviceHeight = device->height() / device->devicePixelRatio();
int deviceWidth = device->width() / device->devicePixelRatio();
#else
int deviceHeight = device->height() / device->devicePixelRatioF();
int deviceWidth = device->width() / device->devicePixelRatioF();
#endif
// Set margin according to selected units
int xOffset = 0;

View File

@ -178,13 +178,8 @@ void QgsDecorationScaleBar::render( const QgsMapSettings &mapSettings, QgsRender
//Get canvas dimensions
QPaintDevice *device = context.painter()->device();
#if QT_VERSION < 0x050600
int deviceHeight = device->height() / device->devicePixelRatio();
int deviceWidth = device->width() / device->devicePixelRatio();
#else
int deviceHeight = device->height() / device->devicePixelRatioF();
int deviceWidth = device->width() / device->devicePixelRatioF();
#endif
//Get map units per pixel. This can be negative at times (to do with
//projections) and that just confuses the rest of the code in this

View File

@ -248,9 +248,7 @@ QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFla
setAcceptDrops( true );
setAttribute( Qt::WA_DeleteOnClose );
#if QT_VERSION >= 0x050600
setDockOptions( dockOptions() | QMainWindow::GroupedDragging );
#endif
//create layout view
QGridLayout *viewLayout = new QGridLayout();

View File

@ -411,11 +411,9 @@ void myMessageOutput( QtMsgType type, const char *msg )
break; // silence warnings
}
#if QT_VERSION >= 0x050500
case QtInfoMsg:
myPrint( "Info: %s\n", msg );
break;
#endif
}
}

View File

@ -712,9 +712,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
this->addAction( mActionToggleMapOnly );
endProfile();
#if QT_VERSION >= 0x050600
setDockOptions( dockOptions() | QMainWindow::GroupedDragging );
#endif
//////////

View File

@ -108,7 +108,6 @@ void QgisAppStyleSheet::buildStyleSheet( const QMap<QString, QVariant> &opts )
if ( fontSize != defaultSize || fontFamily != defaultFamily )
ss += QStringLiteral( "* { font: %1pt \"%2\"} " ).arg( fontSize, fontFamily );
#if QT_VERSION >= 0x050900
// Fix for macOS Qt 5.9+, where close boxes do not show on document mode tab bar tabs
// See: https://bugreports.qt.io/browse/QTBUG-61092
// https://bugreports.qt.io/browse/QTBUG-61742
@ -121,7 +120,6 @@ void QgisAppStyleSheet::buildStyleSheet( const QMap<QString, QVariant> &opts )
ss += QLatin1String( "QTabBar::close-button{ image: url(:/images/themes/default/mIconCloseTab.svg); }" );
ss += QLatin1String( "QTabBar::close-button:hover{ image: url(:/images/themes/default/mIconCloseTabHover.svg); }" );
}
#endif
// QGroupBox and QgsCollapsibleGroupBox, mostly for Ubuntu and Mac
bool gbxCustom = opts.value( QStringLiteral( "groupBoxCustom" ) ).toBool();

View File

@ -330,13 +330,7 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu()
for ( int row = 0; row < model->rowCount(); ++row )
{
QModelIndex index = model->index( row, 0 );
#if QT_VERSION <= 0x050601
// in Qt 5.6.1 and former, QVariant does not correctly convert enum using value
// see https://bugreports.qt.io/browse/QTBUG-53384
QgsMapLayer::StyleCategory category = static_cast<QgsMapLayer::StyleCategory>( model->data( index, Qt::UserRole ).toInt() );
#else
QgsMapLayer::StyleCategory category = model->data( index, Qt::UserRole ).value<QgsMapLayer::StyleCategory>();
#endif
QString name = model->data( index, Qt::DisplayRole ).toString();
QString tooltip = model->data( index, Qt::ToolTipRole ).toString();
QIcon icon = model->data( index, Qt::DecorationRole ).value<QIcon>();
@ -375,13 +369,7 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu()
for ( int row = 0; row < model->rowCount(); ++row )
{
QModelIndex index = model->index( row, 0 );
#if QT_VERSION <= 0x050601
// in Qt 5.6.1 and former, QVariant does not correctly convert enum using value
// see https://bugreports.qt.io/browse/QTBUG-53384
QgsMapLayer::StyleCategory category = static_cast<QgsMapLayer::StyleCategory>( model->data( index, Qt::UserRole ).toInt() );
#else
QgsMapLayer::StyleCategory category = model->data( index, Qt::UserRole ).value<QgsMapLayer::StyleCategory>();
#endif
QString name = model->data( index, Qt::DisplayRole ).toString();
QString tooltip = model->data( index, Qt::ToolTipRole ).toString();
QIcon icon = model->data( index, Qt::DecorationRole ).value<QIcon>();

View File

@ -242,13 +242,7 @@ bool QgsMapLayerStyleCategoriesModel::setData( const QModelIndex &index, const Q
if ( role == Qt::CheckStateRole )
{
#if QT_VERSION <= 0x050601
// in Qt 5.6.1 and former, QVariant does not correctly convert enum using value
// see https://bugreports.qt.io/browse/QTBUG-53384
QgsMapLayer::StyleCategory category = static_cast<QgsMapLayer::StyleCategory>( data( index, Qt::UserRole ).toInt() );
#else
QgsMapLayer::StyleCategory category = data( index, Qt::UserRole ).value<QgsMapLayer::StyleCategory>();
#endif
if ( value.value<Qt::CheckState>() == Qt::Checked )
{
mCategories |= category;

View File

@ -1608,13 +1608,7 @@ void QgsOptions::saveOptions()
mSettings->setValue( QStringLiteral( "/qgis/digitizing/disable_enter_attribute_values_dialog" ), chkDisableAttributeValuesDlg->isChecked() );
mSettings->setValue( QStringLiteral( "/qgis/digitizing/validate_geometries" ), mValidateGeometries->currentIndex() );
#if QT_VERSION <= 0x050601
// in Qt 5.6.1 and former, QVariant does not correctly convert enum using value
// see https://bugreports.qt.io/browse/QTBUG-53384
mSettings->setEnumValue( QStringLiteral( "/qgis/digitizing/offset_join_style" ), static_cast<QgsGeometry::JoinStyle>( mOffsetJoinStyleComboBox->currentData().toInt() ) );
#else
mSettings->setEnumValue( QStringLiteral( "/qgis/digitizing/offset_join_style" ), mOffsetJoinStyleComboBox->currentData().value<QgsGeometry::JoinStyle>() );
#endif
mSettings->setValue( QStringLiteral( "/qgis/digitizing/offset_quad_seg" ), mOffsetQuadSegSpinBox->value() );
mSettings->setValue( QStringLiteral( "/qgis/digitizing/offset_miter_limit" ), mCurveOffsetMiterLimitComboBox->value() );

View File

@ -80,13 +80,7 @@ QString QgsRelationAddDlg::relationName()
QgsRelation::RelationStrength QgsRelationAddDlg::relationStrength()
{
#if QT_VERSION <= 0x050601
// in Qt 5.6.1 and former, QVariant does not correctly convert enum using value
// see https://bugreports.qt.io/browse/QTBUG-53384
return static_cast<QgsRelation::RelationStrength>( mCbxRelationStrength->currentData().toInt() );
#else
return mCbxRelationStrength->currentData().value<QgsRelation::RelationStrength>();
#endif
}
void QgsRelationAddDlg::checkDefinitionValid()

View File

@ -115,13 +115,7 @@ QgsMapLayer::StyleCategories QgsVectorLayerLoadStyleDialog::styleCategories() co
QgsVectorLayerProperties::StyleType QgsVectorLayerLoadStyleDialog::currentStyleType() const
{
#if QT_VERSION <= 0x050601
// in Qt 5.6.1 and former, QVariant does not correctly convert enum using value
// see https://bugreports.qt.io/browse/QTBUG-53384
QgsVectorLayerProperties::StyleType type = static_cast<QgsVectorLayerProperties::StyleType>( mStyleTypeComboBox->currentData().toInt() );
#else
QgsVectorLayerProperties::StyleType type = mStyleTypeComboBox->currentData().value<QgsVectorLayerProperties::StyleType>();
#endif
if ( type == QgsVectorLayerProperties::QML )
{
QFileInfo fi( mFileWidget->filePath() );

View File

@ -57,10 +57,8 @@ int QgsDxfPaintDevice::metric( PaintDeviceMetric metric ) const
return 96;
case QPaintDevice::PdmDevicePixelRatio:
return 1;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
case QPaintDevice::PdmDevicePixelRatioScaled:
return 1;
#endif
}
return 0;
}

View File

@ -562,13 +562,7 @@ class CORE_EXPORT QgsProcessingParameterTypeVectorDestination : public QgsProces
ParameterFlags flags() const override
{
ParameterFlags flags = QgsProcessingParameterType::flags();
#if QT_VERSION >= 0x50700
flags.setFlag( ParameterFlag::ExposeToModeler, false );
#else
flags &= ~ParameterFlag::ExposeToModeler;
#endif
return flags;
}
@ -613,13 +607,7 @@ class CORE_EXPORT QgsProcessingParameterTypeFileDestination : public QgsProcessi
ParameterFlags flags() const override
{
ParameterFlags flags = QgsProcessingParameterType::flags();
#if QT_VERSION >= 0x50700
flags.setFlag( ParameterFlag::ExposeToModeler, false );
#else
flags &= ~ParameterFlag::ExposeToModeler;
#endif
return flags;
}
@ -664,13 +652,7 @@ class CORE_EXPORT QgsProcessingParameterTypeFolderDestination : public QgsProces
ParameterFlags flags() const override
{
ParameterFlags flags = QgsProcessingParameterType::flags();
#if QT_VERSION >= 0x50700
flags.setFlag( ParameterFlag::ExposeToModeler, false );
#else
flags &= ~ParameterFlag::ExposeToModeler;
#endif
return flags;
}
@ -714,13 +696,7 @@ class CORE_EXPORT QgsProcessingParameterTypeRasterDestination : public QgsProces
ParameterFlags flags() const override
{
ParameterFlags flags = QgsProcessingParameterType::flags();
#if QT_VERSION >= 0x50700
flags.setFlag( ParameterFlag::ExposeToModeler, false );
#else
flags &= ~ParameterFlag::ExposeToModeler;
#endif
return flags;
}
@ -976,13 +952,7 @@ class CORE_EXPORT QgsProcessingParameterTypeFeatureSink : public QgsProcessingPa
ParameterFlags flags() const override
{
ParameterFlags flags = QgsProcessingParameterType::flags();
#if QT_VERSION >= 0x50700
flags.setFlag( ParameterFlag::ExposeToModeler, false );
#else
flags &= ~ParameterFlag::ExposeToModeler;
#endif
return flags;
}

View File

@ -264,30 +264,9 @@ uint qHash( const QVariant &variant )
case QVariant::Char:
return qHash( variant.toChar() );
case QVariant::List:
#if QT_VERSION >= 0x050600
return qHash( variant.toList() );
#else
{
QVariantList list = variant.toList();
if ( list.isEmpty() )
return -1;
else
return qHash( list.at( 0 ) );
}
#endif
case QVariant::StringList:
#if QT_VERSION >= 0x050600
return qHash( variant.toStringList() );
#else
{
QStringList list = variant.toStringList();
if ( list.isEmpty() )
return -1;
else
return qHash( list.at( 0 ) );
}
#endif
case QVariant::ByteArray:
return qHash( variant.toByteArray() );
case QVariant::Date:

View File

@ -256,12 +256,7 @@ void QgsFeatureFilterModel::updateCompleter()
if ( mExtraIdentifierValueIndex != 0 )
{
beginMoveRows( QModelIndex(), mExtraIdentifierValueIndex, mExtraIdentifierValueIndex, QModelIndex(), 0 );
#if QT_VERSION < QT_VERSION_CHECK(5, 6, 0)
Entry extraEntry = mEntries.takeAt( mExtraIdentifierValueIndex );
mEntries.prepend( extraEntry );
#else
mEntries.move( mExtraIdentifierValueIndex, 0 );
#endif
endMoveRows();
}
firstRow = 1;

View File

@ -493,7 +493,6 @@ QString QgsFontUtils::asCSS( const QFont &font, double pointToPixelScale )
case QFont::Black:
cssWeight = 900;
break;
#if QT_VERSION >= 0x050500
case QFont::Thin:
cssWeight = 100;
break;
@ -506,7 +505,6 @@ QString QgsFontUtils::asCSS( const QFont &font, double pointToPixelScale )
case QFont::ExtraBold:
cssWeight = 800;
break;
#endif
}
css += QStringLiteral( "font-weight: %1;" ).arg( cssWeight );

View File

@ -194,9 +194,7 @@ bool QgsRenderChecker::runTest( const QString &testName,
mElapsedTime = myTime.elapsed();
QImage myImage = job.renderedImage();
#if QT_VERSION >= 0x050600
Q_ASSERT( myImage.devicePixelRatioF() == mMapSettings.devicePixelRatio() );
#endif
//
// Save the pixmap to disk so the user can make a

View File

@ -82,15 +82,11 @@ void QgsTask::cancel()
return;
mShouldTerminate = true;
#if QT_VERSION >= 0x050500
//can't cancel queued tasks with qt < 5.5
if ( mStatus == Queued || mStatus == OnHold )
{
// immediately terminate unstarted jobs
terminated();
}
#endif
if ( mStatus == Terminated )
{
@ -661,14 +657,11 @@ void QgsTaskManager::taskStatusChanged( int status )
if ( id < 0 )
return;
#if QT_VERSION >= 0x050500
mTaskMutex->lock();
QgsTaskRunnableWrapper *runnable = mTasks.value( id ).runnable;
mTaskMutex->unlock();
if ( runnable )
QThreadPool::globalInstance()->cancel( runnable );
#endif
if ( status == QgsTask::Terminated || status == QgsTask::Complete )
{
@ -770,10 +763,8 @@ bool QgsTaskManager::cleanupAndDeleteTask( QgsTask *task )
}
else
{
#if QT_VERSION >= 0x050500
if ( runnable )
QThreadPool::globalInstance()->cancel( runnable );
#endif
if ( isParent )
{
//task already finished, kill it

View File

@ -35,9 +35,7 @@
#include <QVector>
#include <QStringBuilder>
#include <QUrl>
#if QT_VERSION >= 0x050900
#include <QUndoCommand>
#endif
#include "qgssettings.h"
#include "qgsvectorlayer.h"
@ -3272,7 +3270,6 @@ void QgsVectorLayer::destroyEditCommand()
undoStack()->endMacro();
undoStack()->undo();
#if QT_VERSION >= 0x050900 // setObsolete is new in Qt 5.9
// it's not directly possible to pop the last command off the stack (the destroyed one)
// and delete, so we add a dummy obsolete command to force this to occur.
// Pushing the new command deletes the destroyed one, and since the new
@ -3280,7 +3277,6 @@ void QgsVectorLayer::destroyEditCommand()
std::unique_ptr< QUndoCommand > command = qgis::make_unique< QUndoCommand >();
command->setObsolete( true );
undoStack()->push( command.release() );
#endif
mEditCommandActive = false;
mDeletedFids.clear();

View File

@ -574,11 +574,7 @@ void QgsDualView::viewWillShowContextMenu( QMenu *menu, const QModelIndex &atInd
continue;
QgsAttributeTableAction *a = new QgsAttributeTableAction( action.name(), this, action.id(), sourceIndex );
#if QT_VERSION < QT_VERSION_CHECK(5, 6, 0)
menu->addAction( action.name(), a, SLOT( execute() ) );
#else
menu->addAction( action.name(), a, &QgsAttributeTableAction::execute );
#endif
}
}
@ -592,21 +588,13 @@ void QgsDualView::viewWillShowContextMenu( QMenu *menu, const QModelIndex &atInd
Q_FOREACH ( QgsMapLayerAction *action, registeredActions )
{
QgsAttributeTableMapLayerAction *a = new QgsAttributeTableMapLayerAction( action->text(), this, action, sourceIndex );
#if QT_VERSION < QT_VERSION_CHECK(5, 6, 0)
menu->addAction( action->text(), a, SLOT( execut() ) );
#else
menu->addAction( action->text(), a, &QgsAttributeTableMapLayerAction::execute );
#endif
}
}
menu->addSeparator();
QgsAttributeTableAction *a = new QgsAttributeTableAction( tr( "Open Form" ), this, QString(), sourceIndex );
#if QT_VERSION < QT_VERSION_CHECK(5, 6, 0)
menu->addAction( tr( "Open Form" ), a, SLOT( featureForm() ) );
#else
menu->addAction( tr( "Open Form" ), a, &QgsAttributeTableAction::featureForm );
#endif
}

View File

@ -697,11 +697,7 @@ QgsRectangle QgsMapCanvas::imageRect( const QImage &img, const QgsMapSettings &m
QgsLogger::warning( QStringLiteral( "The renderer map has a wrong device pixel ratio" ) );
}
#endif
#if QT_VERSION >= 0x050600
double res = m2p.mapUnitsPerPixel() / img.devicePixelRatioF();
#else
double res = m2p.mapUnitsPerPixel() / img.devicePixelRatio();
#endif
QgsRectangle rect( topLeft.x(), topLeft.y(), topLeft.x() + img.width()*res, topLeft.y() - img.height()*res );
return rect;
}

View File

@ -65,23 +65,12 @@ void QgsMapCanvasMap::paint( QPainter *painter )
int h = std::round( mItemSize.height() ) - 2;
bool scale = false;
#if QT_VERSION >= 0x050600
if ( mImage.size() != QSize( w, h ) * mImage.devicePixelRatioF() )
#else
if ( mImage.size() != QSize( w, h ) * mImage.devicePixelRatio() )
#endif
{
#if QT_VERSION >= 0x050600
QgsDebugMsg( QStringLiteral( "map paint DIFFERENT SIZE: img %1,%2 item %3,%4" )
.arg( mImage.width() / mImage.devicePixelRatioF() )
.arg( mImage.height() / mImage.devicePixelRatioF() )
.arg( w ).arg( h ) );
#else
QgsDebugMsg( QStringLiteral( "map paint DIFFERENT SIZE: img %1,%2 item %3,%4" )
.arg( mImage.width() / mImage.devicePixelRatio() )
.arg( mImage.height() / mImage.devicePixelRatio() )
.arg( w ).arg( h ) );
#endif
// This happens on zoom events when ::paint is called before
// the renderer has completed
scale = true;

View File

@ -373,17 +373,6 @@ QString QgsPostgresProvider::storageType() const
return QStringLiteral( "PostgreSQL database with PostGIS extension" );
}
#if QT_VERSION < 0x050600
#include <algorithm>
template <typename T>
bool operator<( const QList<T> &lhs, const QList<T> &rhs )
{
return std::lexicographical_compare( lhs.begin(), lhs.end(),
rhs.begin(), rhs.end() );
}
#endif
QgsFeatureIterator QgsPostgresProvider::getFeatures( const QgsFeatureRequest &request ) const
{
if ( !mValid )

View File

@ -333,9 +333,7 @@ void TestQgsField::displayString()
QgsField doubleFieldNoPrec( QStringLiteral( "double" ), QVariant::Double, QStringLiteral( "double" ), 10 );
QCOMPARE( doubleFieldNoPrec.displayString( 5.005005 ), QString( "5.005005" ) );
QCOMPARE( doubleFieldNoPrec.displayString( 5.005005005 ), QString( "5.005005005" ) );
#if QT_VERSION >= 0x050700
QCOMPARE( QLocale().numberOptions() & QLocale::NumberOption::OmitGroupSeparator, QLocale::NumberOption::DefaultNumberOptions );
#endif
QCOMPARE( doubleFieldNoPrec.displayString( 599999898999.0 ), QString( "599,999,898,999" ) );
//test NULL double

View File

@ -35,12 +35,7 @@ class TestQgsOgcUtils : public QObject
void initTestCase()
{
// Needed on Qt 5 so that the serialization of XML is consistent among all executions
#if QT_VERSION >= 0x50600
qSetGlobalQHashSeed( 0 );
#else
extern Q_CORE_EXPORT QBasicAtomicInt qt_qhash_seed;
qt_qhash_seed.store( 0 );
#endif
//
// Runs once before any tests are run