Require Qt >= 5.5

This commit is contained in:
Nyall Dawson 2016-09-20 09:45:28 +10:00
parent 361dd2e8cc
commit 88e4410af1
33 changed files with 58 additions and 389 deletions

View File

@ -246,47 +246,28 @@ ELSE (WITH_QTWEBKIT)
MESSAGE(STATUS "Qt WebKit support DISABLED.")
ENDIF(WITH_QTWEBKIT)
#############################################################
# search for Qt4
SET(QT_MIN_VERSION 4.8.0)
SET (ENABLE_QT5 FALSE CACHE BOOL "If enabled will try to find Qt5 before looking for Qt4")
IF (ENABLE_QT5)
FIND_PACKAGE(Qt5Core QUIET)
FIND_PACKAGE(Qt5Gui REQUIRED)
FIND_PACKAGE(Qt5Widgets REQUIRED)
FIND_PACKAGE(Qt5Network REQUIRED)
FIND_PACKAGE(Qt5Xml REQUIRED)
FIND_PACKAGE(Qt5Svg REQUIRED)
FIND_PACKAGE(Qt5Concurrent REQUIRED)
FIND_PACKAGE(Qt5PrintSupport REQUIRED)
FIND_PACKAGE(Qt5Positioning)
IF (WITH_QTWEBKIT)
FIND_PACKAGE(Qt5WebKit REQUIRED)
FIND_PACKAGE(Qt5WebKitWidgets REQUIRED)
ENDIF(WITH_QTWEBKIT)
FIND_PACKAGE(Qt5Test REQUIRED)
FIND_PACKAGE(Qt5UiTools REQUIRED)
FIND_PACKAGE(Qt5Script REQUIRED)
FIND_PACKAGE(Qt5Sql REQUIRED)
SET(QT5_BUILD TRUE)
INCLUDE("cmake/modules/ECMQt4To5Porting.cmake")
MESSAGE(STATUS "Found Qt version: ${Qt5Core_VERSION_STRING}")
ELSE()
FIND_PACKAGE(Qt4 ${QT_MIN_VERSION} REQUIRED)
SET(QT_USE_QTXML 1)
SET(QT_USE_QTNETWORK 1)
SET(QT_USE_QTSVG 1)
SET(QT_USE_QTSQL 1)
IF (WITH_QTWEBKIT)
SET(QT_USE_QTWEBKIT 1)
ENDIF(WITH_QTWEBKIT)
IF (NOT QT_QTXML_FOUND OR NOT QT_QTNETWORK_FOUND OR NOT QT_QTSVG_FOUND OR NOT QT_QTSQL_FOUND OR (WITH_QTWEBKIT AND NOT QT_QTWEBKIT_FOUND) OR (WITH_CUSTOM_WIDGETS AND NOT QT_QTDESIGNER_FOUND))
MESSAGE(SEND_ERROR "Some Qt4 modules haven't been found!")
ENDIF (NOT QT_QTXML_FOUND OR NOT QT_QTNETWORK_FOUND OR NOT QT_QTSVG_FOUND OR NOT QT_QTSQL_FOUND OR (WITH_QTWEBKIT AND NOT QT_QTWEBKIT_FOUND) OR (WITH_CUSTOM_WIDGETS AND NOT QT_QTDESIGNER_FOUND))
INCLUDE( ${QT_USE_FILE} )
MESSAGE(STATUS "Found Qt version: ${QTVERSION}")
ENDIF()
# search for Qt5
SET(QT_MIN_VERSION 5.5.0)
FIND_PACKAGE(Qt5Core QUIET)
FIND_PACKAGE(Qt5Gui REQUIRED)
FIND_PACKAGE(Qt5Widgets REQUIRED)
FIND_PACKAGE(Qt5Network REQUIRED)
FIND_PACKAGE(Qt5Xml REQUIRED)
FIND_PACKAGE(Qt5Svg REQUIRED)
FIND_PACKAGE(Qt5Concurrent REQUIRED)
FIND_PACKAGE(Qt5PrintSupport REQUIRED)
FIND_PACKAGE(Qt5Positioning)
IF (WITH_QTWEBKIT)
FIND_PACKAGE(Qt5WebKit REQUIRED)
FIND_PACKAGE(Qt5WebKitWidgets REQUIRED)
ENDIF(WITH_QTWEBKIT)
FIND_PACKAGE(Qt5Test REQUIRED)
FIND_PACKAGE(Qt5UiTools REQUIRED)
FIND_PACKAGE(Qt5Script REQUIRED)
FIND_PACKAGE(Qt5Sql REQUIRED)
SET(QT5_BUILD TRUE)
INCLUDE("cmake/modules/ECMQt4To5Porting.cmake")
MESSAGE(STATUS "Found Qt version: ${Qt5Core_VERSION_STRING}")
IF (WITH_QTMOBILITY)
FIND_PACKAGE(QtMobility 1.1.0)
@ -690,7 +671,7 @@ IF (UNIX AND NOT APPLE)
SET (QGIS_MANUAL_DIR ${CMAKE_INSTALL_PREFIX}/${QGIS_MANUAL_SUBDIR})
ENDIF (UNIX AND NOT APPLE)
SET (DISABLE_DEPRECATED ${ENABLE_QT5} CACHE BOOL "If set to true, it will disable deprecated functionality to prepare for the next generation of QGIS")
SET (DISABLE_DEPRECATED FALSE CACHE BOOL "If set to true, it will disable deprecated functionality to prepare for the next generation of QGIS")
IF (DISABLE_DEPRECATED)
ADD_DEFINITIONS(-DQGIS_DISABLE_DEPRECATED)
ENDIF (DISABLE_DEPRECATED)
@ -699,12 +680,7 @@ ENDIF (DISABLE_DEPRECATED)
#############################################################
# Python build dependency
SET (ENABLE_PYTHON3 ${ENABLE_QT5} CACHE BOOL "If enabled will try to find Python 3 before looking for Python 2")
IF(ENABLE_PYTHON3)
SET(PYTHON_VER 3 CACHE STRING "Python version")
ELSE(ENABLE_PYTHON3)
SET(PYTHON_VER 2.7 CACHE STRING "Python version")
ENDIF(ENABLE_PYTHON3)
SET(PYTHON_VER 3 CACHE STRING "Python version")
FIND_PACKAGE(PythonInterp ${PYTHON_VER} REQUIRED)
@ -715,17 +691,10 @@ IF (WITH_BINDINGS)
FIND_PACKAGE(PythonLibrary REQUIRED)
# python support: check for interpreter, sip, pyqt4
IF(ENABLE_QT5)
FIND_PACKAGE(PyQt5 REQUIRED)
SET(PYQT_SIP_FLAGS ${PYQT5_SIP_FLAGS})
SET(PYQT_SIP_DIR ${PYQT5_SIP_DIR})
ELSE(ENABLE_QT5)
FIND_PACKAGE(PyQt4 REQUIRED)
# setup SIP variables
SET(PYQT_SIP_FLAGS ${PYQT4_SIP_FLAGS})
SET(PYQT_SIP_DIR ${PYQT4_SIP_DIR})
ENDIF(ENABLE_QT5)
# python support: check for interpreter, sip, pyqt5
FIND_PACKAGE(PyQt5 REQUIRED)
SET(PYQT_SIP_FLAGS ${PYQT5_SIP_FLAGS})
SET(PYQT_SIP_DIR ${PYQT5_SIP_DIR})
SEPARATE_ARGUMENTS(PYQT_SIP_FLAGS) # convert space separated values to a list
FIND_PACKAGE(SIP REQUIRED)
@ -742,11 +711,7 @@ IF (WITH_BINDINGS)
ENDIF (NOT BINDINGS_GLOBAL_INSTALL)
IF (WITH_CUSTOM_WIDGETS)
IF(ENABLE_QT5)
SET(PYUIC_WIDGET_PLUGIN_DIRECTORY ${PYQT5_MOD_DIR}/uic/widget-plugins/)
ELSE(ENABLE_QT5)
SET(PYUIC_WIDGET_PLUGIN_DIRECTORY ${PYQT4_MOD_DIR}/uic/widget-plugins/)
ENDIF(ENABLE_QT5)
SET(PYUIC_WIDGET_PLUGIN_DIRECTORY ${PYQT5_MOD_DIR}/uic/widget-plugins/)
ENDIF (WITH_CUSTOM_WIDGETS)
ENDIF (WITH_BINDINGS)

View File

@ -51,8 +51,6 @@ cmake \
-DWITH_ASTYLE=ON \
-DWITH_SERVER=ON \
-DWITH_INTERNAL_YAML=OFF \
-DENABLE_QT5=ON \
-DENABLE_PYTHON3=ON \
-DDISABLE_DEPRECATED=ON \
-DPORT_PLUGINS=ON \
-DCXX_EXTRA_FLAGS="$CLANG_WARNINGS" \

View File

@ -44,11 +44,7 @@ else(EXISTS "${PYTHON_INCLUDE_PATH}" AND EXISTS "${PYTHON_LIBRARY}" AND EXISTS "
endif("${PYTHON_CUSTOM_FRAMEWORK}" MATCHES "Python\\.framework")
endif(APPLE AND PYTHON_CUSTOM_FRAMEWORK)
IF (ENABLE_PYTHON3)
FIND_PACKAGE(PythonInterp 3)
ELSE (ENABLE_PYTHON3)
FIND_PACKAGE(PythonInterp 2.7)
ENDIF (ENABLE_PYTHON3)
FIND_PACKAGE(PythonInterp 3)
if(PYTHONINTERP_FOUND)
FIND_FILE(_find_lib_python_py FindLibPython.py PATHS ${CMAKE_MODULE_PATH})

View File

@ -20,11 +20,7 @@ if(QCA_INCLUDE_DIR AND QCA_LIBRARY)
else(QCA_INCLUDE_DIR AND QCA_LIBRARY)
if(ENABLE_QT5)
set(QCA_LIBRARY_NAMES qca-qt5 qca2-qt5)
else(ENABLE_QT5)
set(QCA_LIBRARY_NAMES qca qca2)
endif(ENABLE_QT5)
set(QCA_LIBRARY_NAMES qca-qt5 qca2-qt5)
find_library(QCA_LIBRARY
NAMES ${QCA_LIBRARY_NAMES}

View File

@ -33,11 +33,7 @@ ELSE(EXISTS QSCINTILLA_VERSION_STR)
/usr/include
)
if(ENABLE_QT5)
set(QSCINTILLA_LIBRARY_NAMES qscintilla2-qt5 libqt5scintilla2 libqscintilla2-qt5 qt5scintilla2 libqscintilla2-qt5.dylib)
else(ENABLE_QT5)
set(QSCINTILLA_LIBRARY_NAMES qscintilla2 libqscintilla2 libqscintilla2.dylib)
endif(ENABLE_QT5)
set(QSCINTILLA_LIBRARY_NAMES qscintilla2-qt5 libqt5scintilla2 libqscintilla2-qt5 qt5scintilla2 libqscintilla2-qt5.dylib)
find_library(QSCINTILLA_LIBRARY
NAMES ${QSCINTILLA_LIBRARY_NAMES}

View File

@ -23,11 +23,7 @@ ELSE(EXISTS QSCI_MOD_VERSION_STR)
FIND_FILE(_find_qsci_py FindQsci.py PATHS ${CMAKE_MODULE_PATH})
IF(ENABLE_QT5)
SET(QSCI_VER 5)
ELSE(ENABLE_QT5)
SET(QSCI_VER 4)
ENDIF(ENABLE_QT5)
SET(QSCI_VER 5)
EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} ${_find_qsci_py} ${QSCI_VER} OUTPUT_VARIABLE qsci_ver)
@ -37,17 +33,10 @@ ELSE(EXISTS QSCI_MOD_VERSION_STR)
ENDIF(qsci_ver)
IF(QSCI_FOUND)
IF(ENABLE_QT5)
FIND_PATH(QSCI_SIP_DIR
NAMES Qsci/qscimod5.sip
PATHS ${PYQT5_SIP_DIR}
)
ELSE(ENABLE_QT5)
FIND_PATH(QSCI_SIP_DIR
NAMES Qsci/qscimod4.sip
PATHS ${PYQT4_SIP_DIR}
)
ENDIF(ENABLE_QT5)
FIND_PATH(QSCI_SIP_DIR
NAMES Qsci/qscimod5.sip
PATHS ${PYQT5_SIP_DIR}
)
IF(NOT QSCI_FIND_QUIETLY)
MESSAGE(STATUS "Found QScintilla2 PyQt module: ${QSCI_MOD_VERSION_STR}")

View File

@ -20,11 +20,7 @@ FIND_PATH(QWT_INCLUDE_DIR NAMES qwt.h PATHS
PATH_SUFFIXES qwt-qt4 qwt qwt5 qwt6
)
if(ENABLE_QT5)
set(QWT_LIBRARY_NAMES qwt-qt5 qwt6-qt5)
else(ENABLE_QT5)
set(QWT_LIBRARY_NAMES qwt qwt6 qwt5 qwt-qt4 qwt6-qt4 qwt5-qt4)
endif(ENABLE_QT5)
set(QWT_LIBRARY_NAMES qwt-qt5 qwt6-qt5)
find_library(QWT_LIBRARY
NAMES ${QWT_LIBRARY_NAMES}

View File

@ -4,15 +4,9 @@
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
IF(ENABLE_QT5)
SET(PYUIC_PROG_NAME pyuic5)
SET(PYUIC_PROG_NAMES pyuic5)
SET(PYRCC_PROG_NAME pyrcc5)
ELSE(ENABLE_QT5)
SET(PYUIC_PROG_NAME pyuic4)
SET(PYUIC_PROG_NAMES python2-pyuic4 pyuic4)
SET(PYRCC_PROG_NAME pyrcc4)
ENDIF(ENABLE_QT5)
SET(PYUIC_PROG_NAME pyuic5)
SET(PYUIC_PROG_NAMES pyuic5)
SET(PYRCC_PROG_NAME pyrcc5)
IF(NOT PYUIC_PROGRAM)
IF (MSVC)

View File

@ -121,10 +121,6 @@ INCLUDE_DIRECTORIES(
${CMAKE_BINARY_DIR} # qgsconfig.h, qgsversion.h
)
IF(NOT ENABLE_QT5)
SET(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} QT5_SUPPORT)
ENDIF(NOT ENABLE_QT5)
IF(NOT ANDROID)
SET(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} ANDROID)
ENDIF(NOT ANDROID)
@ -146,9 +142,6 @@ IF(PYQT4_VERSION_NUM LESS 263680) # 0x040600
SET(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} PROXY_FACTORY)
ENDIF(PYQT4_VERSION_NUM LESS 263680)
IF(NOT PYQT4_VERSION_NUM LESS 263941 AND NOT ENABLE_QT5) # 0x040705
SET(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} QSETINT_CONVERSION)
ENDIF(NOT PYQT4_VERSION_NUM LESS 263941 AND NOT ENABLE_QT5)
#
IF(NOT PYQT4_VERSION_NUM LESS 264194) # 0x040802
SET(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} QSETTYPE_CONVERSION)

View File

@ -23,11 +23,7 @@ SET(PYQT_COMPAT_FILES
ADD_CUSTOM_TARGET(pyqtcompat ALL)
ADD_DEPENDENCIES(pyqtcompat pyutils)
IF(ENABLE_QT5)
SET(PYQT_PREFIX PyQt5)
ELSE(ENABLE_QT5)
SET(PYQT_PREFIX PyQt4)
ENDIF(ENABLE_QT5)
SET(PYQT_PREFIX PyQt5)
FOREACH(pyfile ${PYQT_COMPAT_FILES})
GET_FILENAME_COMPONENT(_dir ${pyfile} PATH)

View File

@ -35,43 +35,12 @@ ENDMACRO(EXT_PYLIB lib)
# Our yaml package is not compatible with python 3
# Fallback to system package by default
IF(PYTHON_VER VERSION_LESS 3)
EXT_PYLIB(yaml TRUE)
ELSEIF(PYTHON_VER VERSION_LESS 3)
EXT_PYLIB(yaml FALSE)
ENDIF(PYTHON_VER VERSION_LESS 3)
EXT_PYLIB(yaml FALSE)
FOREACH(pkg httplib2 jinja2 markupsafe owslib pygments dateutil pytz nose2 requests)
EXT_PYLIB(${pkg} TRUE)
ENDFOREACH(pkg)
IF(NOT ENABLE_PYTHON3)
SET (WITH_INTERNAL_FUTURE TRUE CACHE BOOL "Determines whether python future should be included")
IF(WITH_INTERNAL_FUTURE)
ADD_CUSTOM_TARGET(pyfuture)
FILE(GLOB items RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/future future/*)
FOREACH(item ${items})
INSTALL(DIRECTORY future/${item} DESTINATION "${QGIS_PYTHON_DIR}")
FILE(GLOB_RECURSE files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/future future/*)
ADD_CUSTOM_COMMAND(TARGET pyfuture
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${item} "${PYTHON_OUTPUT_DIRECTORY}/"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${files}
)
PY_COMPILE(pyfuture "${PYTHON_OUTPUT_DIRECTORY}/${item}")
ADD_CUSTOM_COMMAND(TARGET clean-staged-plugins
COMMAND ${CMAKE_COMMAND} -E remove_directory "${PYTHON_OUTPUT_DIRECTORY}/${item}"
)
ENDFOREACH(item ${items})
ADD_DEPENDENCIES(staged-plugins pyfuture)
ENDIF(WITH_INTERNAL_FUTURE)
ENDIF(NOT ENABLE_PYTHON3)
SET (WITH_INTERNAL_SIX TRUE CACHE BOOL "Determines whether python six should be included")
IF(WITH_INTERNAL_SIX)
INSTALL(FILES six.py DESTINATION "${QGIS_PYTHON_DIR}")

View File

@ -8,17 +8,16 @@
FILE(WRITE ${CMAKE_BINARY_DIR}/stagecount 0)
IF(ENABLE_QT5)
# The target port-plugins acts as a container for all port-plugin-XXX targets
# Each port-plugin-XXX target will run scripts/2to3 on a plugin and migrate
# Python 3 and Qt 5 code.
SET (PORT_PLUGINS FALSE CACHE BOOL "Determines whether python plugins in staged or installed locations should be migrated to Python 3 and Qt 5")
IF(PORT_PLUGINS)
ADD_CUSTOM_TARGET(port-plugins ALL)
ELSE(PORT_PLUGINS)
ADD_CUSTOM_TARGET(port-plugins)
ENDIF(PORT_PLUGINS)
ENDIF(ENABLE_QT5)
# The target port-plugins acts as a container for all port-plugin-XXX targets
# Each port-plugin-XXX target will run scripts/2to3 on a plugin and migrate
# Python 3 and Qt 5 code.
SET (PORT_PLUGINS FALSE CACHE BOOL "Determines whether python plugins in staged or installed locations should be migrated to Python 3 and Qt 5")
IF(PORT_PLUGINS)
ADD_CUSTOM_TARGET(port-plugins ALL)
ELSE(PORT_PLUGINS)
ADD_CUSTOM_TARGET(port-plugins)
ENDIF(PORT_PLUGINS)
MACRO (PLUGIN_INSTALL plugin subdir )
FILE(READ ${CMAKE_BINARY_DIR}/stagecount n)
@ -47,12 +46,10 @@ MACRO (PLUGIN_INSTALL plugin subdir )
ADD_CUSTOM_TARGET(staged-${plugin} DEPENDS zzz-${plugin}-stageinstall)
FILE(WRITE ${_cmake} "")
IF(ENABLE_QT5)
ADD_CUSTOM_TARGET(port-plugin-${plugin})
PY_2TO3(port-plugin-${plugin} ${PYTHON_OUTPUT_DIRECTORY}/plugins/${plugin})
ADD_DEPENDENCIES(port-plugins port-plugin-${plugin})
ADD_DEPENDENCIES(port-plugin-${plugin} staged-${plugin})
ENDIF(ENABLE_QT5)
ADD_CUSTOM_TARGET(port-plugin-${plugin})
PY_2TO3(port-plugin-${plugin} ${PYTHON_OUTPUT_DIRECTORY}/plugins/${plugin})
ADD_DEPENDENCIES(port-plugins port-plugin-${plugin})
ADD_DEPENDENCIES(port-plugin-${plugin} staged-${plugin})
ENDIF(NOT TARGET zzz-${plugin}-stageinstall)
ADD_CUSTOM_TARGET(zzz-${plugin}-${n}-depend DEPENDS ${ARGN})

View File

@ -34,9 +34,6 @@
#include <QString>
#include <QStringList>
#include <QStyle>
#if QT_VERSION < 0x050000
#include <QPlastiqueStyle>
#endif
#include <QDesktopWidget>
#include <QTranslator>
#include <QImageReader>
@ -419,11 +416,9 @@ void myMessageOutput( QtMsgType type, const char *msg )
}
#if QT_VERSION >= 0x050500
case QtInfoMsg:
myPrint( "Info: %s\n", msg );
break;
#endif
}
}
@ -949,12 +944,6 @@ int main( int argc, char *argv[] )
QApplication::setStyle( style );
mySettings.setValue( "/qgis/style", QApplication::style()->objectName() );
}
#ifdef Q_OS_WIN
#if QT_VERSION < 0x050000
else
QApplication::setStyle( new QPlastiqueStyle );
#endif
#endif
/* Translation file for QGIS.
*/

View File

@ -30,12 +30,10 @@ QString QgsAuthCertUtils::getSslProtocolName( QSsl::SslProtocol protocol )
{
switch ( protocol )
{
#if QT_VERSION >= 0x040800
case QSsl::SecureProtocols:
return QObject::tr( "SecureProtocols" );
case QSsl::TlsV1SslV3:
return QObject::tr( "TlsV1SslV3" );
#endif
case QSsl::TlsV1:
return QObject::tr( "TlsV1" );
case QSsl::SslV3:

View File

@ -25,17 +25,9 @@
class QgsAuthConfigSslServer;
#if QT_VERSION >= 0x050000
#define SSL_ISSUER_INFO( var, prop ) var.issuerInfo( prop ).value(0)
#else
#define SSL_ISSUER_INFO( var, prop ) var.issuerInfo( prop )
#endif
#if QT_VERSION >= 0x050000
#define SSL_SUBJECT_INFO( var, prop ) var.subjectInfo( prop ).value(0)
#else
#define SSL_SUBJECT_INFO( var, prop ) var.subjectInfo( prop )
#endif
/** \ingroup core
* \brief Utilities for working with certificates and keys

View File

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

View File

@ -125,21 +125,7 @@ class CORE_EXPORT Qgis
// retrieved from QLibrary::resolve to function pointers.
// It's assumed that this works on all systems supporting
// QLibrary
#if QT_VERSION >= 0x050000
#define cast_to_fptr(f) f
#else
inline void ( *cast_to_fptr( void *p ) )()
{
union
{
void *p;
void ( *f )();
} u;
u.p = p;
return u.f;
}
#endif
/** \ingroup core
* RAII signal blocking class. Used for temporarily blocking signals from a QObject
@ -267,32 +253,6 @@ CORE_EXPORT double qgsPermissiveToDouble( QString string, bool& ok );
*/
CORE_EXPORT int qgsPermissiveToInt( QString string, bool& ok );
// Add missing qHash implementation for QDate, QTime, QDateTime
// implementations taken from upstream Qt5 versions
#if QT_VERSION < 0x050000
//! Hash implementation for QDateTime
//! @note not available in Python bindings
inline uint qHash( const QDateTime &key )
{
return qHash( key.toMSecsSinceEpoch() );
}
//! Hash implementation for QDate
//! @note not available in Python bindings
inline uint qHash( const QDate &key )
{
return qHash( key.toJulianDay() );
}
//! Hash implementation for QTime
//! @note not available in Python bindings
inline uint qHash( const QTime &key )
{
return QTime( 0, 0, 0, 0 ).msecsTo( key );
}
#endif
//! Compares two QVariant values and returns whether the first is less than the second.
//! Useful for sorting lists of variants, correctly handling sorting of the various
//! QVariant data types (such as strings, numeric values, dates and times)

View File

@ -55,10 +55,6 @@
#include "qgsmessagelog.h"
#include "qgscsexception.h"
#if QT_VERSION < 0x050000
#include <qtextdocument.h>
#endif
// from parser
extern QgsExpression::Node* parseExpression( const QString& str, QString& parserErrorMsg );
@ -4927,11 +4923,7 @@ QString QgsExpression::helpText( QString name )
if ( f.mType == tr( "group" ) )
name = group( name );
#if QT_VERSION < 0x050000
name = Qt::escape( name );
#else
name = name.toHtmlEscaped();
#endif
QString helpContents( QString( "<h3>%1</h3>\n<div class=\"description\"><p>%2</p></div>" )
.arg( tr( "%1 %2" ).arg( f.mType, name ),

View File

@ -439,7 +439,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;
@ -452,7 +451,6 @@ QString QgsFontUtils::asCSS( const QFont& font, double pointToPixelScale )
case QFont::ExtraBold:
cssWeight = 800;
break;
#endif
}
css += QString( "font-weight: %1;" ).arg( cssWeight );

View File

@ -216,7 +216,6 @@ QVariant QgsMapLayerModel::data( const QModelIndex &index, int role ) const
return QVariant();
}
#if QT_VERSION >= 0x050000
QHash<int, QByteArray> QgsMapLayerModel::roleNames() const
{
QHash<int, QByteArray> roles = QAbstractItemModel::roleNames();
@ -225,7 +224,6 @@ QHash<int, QByteArray> QgsMapLayerModel::roleNames() const
return roles;
}
#endif
Qt::ItemFlags QgsMapLayerModel::flags( const QModelIndex &index ) const
{

View File

@ -88,14 +88,12 @@ class CORE_EXPORT QgsMapLayerModel : public QAbstractItemModel
int columnCount( const QModelIndex &parent ) const override;
QVariant data( const QModelIndex &index, int role ) const override;
#if QT_VERSION >= 0x050000
/**
* Returns strings for all roles supported by this model.
*
* @note Available only with Qt5 (python and c++)
*/
QHash<int, QByteArray> roleNames() const override;
#endif
bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
Qt::ItemFlags flags( const QModelIndex &index ) const override;

View File

@ -432,7 +432,6 @@ QWidget* QgsProviderRegistry::selectWidget( const QString & providerKey,
return selectFactory( parent, fl );
}
#if QT_VERSION >= 0x050000
QFunctionPointer QgsProviderRegistry::function( QString const & providerKey,
QString const & functionName )
{
@ -450,25 +449,6 @@ QFunctionPointer QgsProviderRegistry::function( QString const & providerKey,
return 0;
}
}
#else
void *QgsProviderRegistry::function( QString const & providerKey,
QString const & functionName )
{
QLibrary myLib( library( providerKey ) );
QgsDebugMsg( "Library name is " + myLib.fileName() );
if ( myLib.load() )
{
return myLib.resolve( functionName.toLatin1().data() );
}
else
{
QgsDebugMsg( "Cannot load library: " + myLib.errorString() );
return nullptr;
}
}
#endif
QLibrary *QgsProviderRegistry::providerLibrary( QString const & providerKey ) const
{

View File

@ -84,7 +84,6 @@ class CORE_EXPORT QgsProviderRegistry
QWidget *selectWidget( const QString & providerKey,
QWidget * parent = nullptr, Qt::WindowFlags fl = Qt::WindowFlags() );
#if QT_VERSION >= 0x050000
/** Get pointer to provider function
@param providerKey identificator of the provider
@param functionName name of function
@ -92,15 +91,6 @@ class CORE_EXPORT QgsProviderRegistry
*/
QFunctionPointer function( const QString & providerKey,
const QString & functionName );
#else
/** Get pointer to provider function
* @param providerKey identificator of the provider
* @param functionName name of function
* @return pointer to function or NULL on error
*/
void *function( const QString & providerKey,
const QString & functionName );
#endif
QLibrary *providerLibrary( const QString & providerKey ) const;

View File

@ -45,13 +45,8 @@ QString QgsStringUtils::capitalize( const QString& string, QgsStringUtils::Capit
wordSplitter.setPosition( 0 );
bool first = true;
#if QT_VERSION >= 0x050000
while (( first && wordSplitter.boundaryReasons() & QTextBoundaryFinder::StartOfItem )
|| wordSplitter.toNextBoundary() >= 0 )
#else
while (( first && wordSplitter.boundaryReasons() & QTextBoundaryFinder::StartWord )
|| wordSplitter.toNextBoundary() >= 0 )
#endif
{
first = false;
letterSplitter.setPosition( wordSplitter.position() );

View File

@ -131,12 +131,10 @@ void QgsAuthSslConfigWidget::setUpSslConfigTree()
// add config field names
mProtocolItem = addRootItem( tr( "Protocol" ) );
mProtocolCmbBx = new QComboBox( treeSslConfig );
#if QT_VERSION >= 0x040800
mProtocolCmbBx->addItem( QgsAuthCertUtils::getSslProtocolName( QSsl::SecureProtocols ),
( int )QSsl::SecureProtocols );
mProtocolCmbBx->addItem( QgsAuthCertUtils::getSslProtocolName( QSsl::TlsV1SslV3 ),
( int )QSsl::TlsV1SslV3 );
#endif
mProtocolCmbBx->addItem( QgsAuthCertUtils::getSslProtocolName( QSsl::TlsV1 ),
( int )QSsl::TlsV1 );
mProtocolCmbBx->addItem( QgsAuthCertUtils::getSslProtocolName( QSsl::SslV3 ),

View File

@ -690,20 +690,12 @@ void QgsAttributeForm::onAttributeChanged( const QVariant& value )
if ( value.isNull() )
{
// not good
#if QT_VERSION >= 0x050000
buddy->setText( QString( "%1<font color=\"red\">❌</font>" ).arg( text ) );
#else
buddy->setText( QString( "%1<font color=\"red\">*</font>" ).arg( text ) );
#endif
}
else
{
// good
#if QT_VERSION >= 0x050000
buddy->setText( QString( "%1<font color=\"green\">✔</font>" ).arg( text ) );
#else
buddy->setText( QString( "%1<font color=\"green\">*</font>" ).arg( text ) );
#endif
}
}
}

View File

@ -764,7 +764,6 @@ bool QgsColorSwatchDelegate::editorEvent( QEvent *event, QAbstractItemModel *mod
QColor color = index.model()->data( index, Qt::DisplayRole ).value<QColor>();
#if QT_VERSION >= 0x050000
QgsPanelWidget* panel = QgsPanelWidget::findParentPanel( qobject_cast< QWidget* >( parent() ) );
if ( panel && panel->dockMode() )
{
@ -776,7 +775,6 @@ bool QgsColorSwatchDelegate::editorEvent( QEvent *event, QAbstractItemModel *mod
panel->openPanel( colorWidget );
return true;
}
#endif
QColor newColor = QgsColorDialog::getColor( color, mParent, tr( "Select color" ), true );
if ( !newColor.isValid() )
@ -792,11 +790,9 @@ bool QgsColorSwatchDelegate::editorEvent( QEvent *event, QAbstractItemModel *mod
void QgsColorSwatchDelegate::colorChanged()
{
#if QT_VERSION >= 0x050000
if ( QgsCompoundColorWidget* colorWidget = qobject_cast< QgsCompoundColorWidget* >( sender() ) )
{
QModelIndex index = colorWidget->property( "index" ).toModelIndex();
const_cast< QAbstractItemModel* >( index.model() )->setData( index, colorWidget->color(), Qt::EditRole );
}
#endif
}

View File

@ -39,9 +39,5 @@ int QgsTableWidgetItem::sortRole() const
bool QgsTableWidgetItem::operator<( const QTableWidgetItem& other ) const
{
#if QT_VERSION < 0x050000
return data( mSortRole ).toString() < other.data( mSortRole ).toString();
#else
return data( mSortRole ) < other.data( mSortRole );
#endif
}

View File

@ -139,7 +139,7 @@ WId Session::windowId() const
// https://bugreports.qt-project.org/browse/QTBUG-41942
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
return 0;
return 0;
#else
if ( _views.count() == 0 ) {
return 0;

View File

@ -26,9 +26,7 @@
#include <QSettings>
#include <QRegExp>
#include <QUrl>
#if QT_VERSION >= 0x050000
#include <QUrlQuery>
#endif
#include "qgsapplication.h"
#include "qgsdataprovider.h"
@ -155,12 +153,8 @@ QgsDelimitedTextProvider::QgsDelimitedTextProvider( const QString& uri )
if ( url.hasQueryItem( "subset" ) )
{
#if QT_VERSION < 0x050000
subset = url.queryItemValue( "subset" );
#else
// We need to specify FullyDecoded so that %25 is decoded as %
subset = QUrlQuery( url ).queryItemValue( "subset" , QUrl::FullyDecoded );
#endif
QgsDebugMsg( "subset is: " + subset );
}

View File

@ -331,80 +331,6 @@ QString QgsPostgresProvider::storageType() const
return "PostgreSQL database with PostGIS extension";
}
// Qt5 has that built in
// ... BUT it does not behave exactly the same way as our implementation
// (e.g. comparison of QVariantList does not work)
#if QT_VERSION < 0x050000
static bool operator<( const QVariant &a, const QVariant &b )
{
// invalid < NULL < any value
if ( !a.isValid() )
return b.isValid();
else if ( a.isNull() )
return b.isValid() && !b.isNull();
else if ( !b.isValid() || b.isNull() )
return false;
if ( a.type() == b.type() )
{
switch ( a.type() )
{
case QVariant::Int:
case QVariant::Char:
return a.toInt() < b.toInt();
case QVariant::Double:
return a.toDouble() < b.toDouble();
case QVariant::LongLong:
return a.toLongLong() < b.toLongLong();
case QVariant::List:
case QVariant::StringList:
{
const QList<QVariant> al = a.toList();
const QList<QVariant> bl = b.toList();
int i, n = qMin( al.size(), bl.size() );
for ( i = 0; i < n && al[i].type() == bl[i].type() && al[i].isNull() == bl[i].isNull() && al[i] == bl[i]; i++ )
;
if ( i == n )
return al.size() < bl.size();
else
return al[i] < bl[i];
}
case QVariant::Map:
return a.toMap() < b.toMap();
case QVariant::Date:
return a.toDate() < b.toDate();
case QVariant::Time:
return a.toTime() < b.toTime();
case QVariant::DateTime:
return a.toDateTime() < b.toDateTime();
case QVariant::Bool:
return a.toBool() < b.toBool();
case QVariant::UInt:
return a.toUInt() < b.toUInt();
case QVariant::ULongLong:
return a.toULongLong() < b.toULongLong();
default:
break;
}
}
return a.canConvert( QVariant::String ) && b.canConvert( QVariant::String ) && a.toString() < b.toString();
}
#endif
#if QT_VERSION >= 0x050000 && QT_VERSION < 0x050600
#include <algorithm>
template <typename T>

View File

@ -205,11 +205,7 @@ void TestQgsAuthConfig::testConfigSslServer()
QgsAuthConfigSslServer sslconfig;
QVERIFY( sslconfig.isNull() );
#if QT_VERSION >= 0x040800
QCOMPARE( sslconfig.qtVersion(), 480 );
#else
QCOMPARE( sslconfig.qtVersion(), 470 );
#endif
QCOMPARE( sslconfig.version(), 1 );
QCOMPARE( sslconfig.sslPeerVerifyMode(), QSslSocket::VerifyPeer );

View File

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