Skip to content

Commit 78c5195

Browse files
committed
Add Qt5 support
1 parent 97e7969 commit 78c5195

File tree

107 files changed

+462
-130
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+462
-130
lines changed

CMakeLists.txt

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -219,20 +219,44 @@ SET (HAVE_MSSQL TRUE)
219219
#############################################################
220220
# search for Qt4
221221
SET(QT_MIN_VERSION 4.7.0)
222-
FIND_PACKAGE(Qt4 ${QT_MIN_VERSION} REQUIRED)
222+
SET (ENABLE_QT5 FALSE CACHE BOOL "If enabled will try to find Qt5 before looking for Qt4")
223+
IF (ENABLE_QT5)
224+
FIND_PACKAGE(Qt5Core QUIET)
225+
FIND_PACKAGE(Qt5Gui REQUIRED)
226+
FIND_PACKAGE(Qt5Widgets REQUIRED)
227+
FIND_PACKAGE(Qt5Network REQUIRED)
228+
FIND_PACKAGE(Qt5Xml REQUIRED)
229+
FIND_PACKAGE(Qt5Svg REQUIRED)
230+
FIND_PACKAGE(Qt5Concurrent REQUIRED)
231+
FIND_PACKAGE(Qt5PrintSupport REQUIRED)
232+
FIND_PACKAGE(Qt5WebKit REQUIRED)
233+
FIND_PACKAGE(Qt5WebKitWidgets REQUIRED)
234+
FIND_PACKAGE(Qt5Test REQUIRED)
235+
FIND_PACKAGE(Qt5UiTools REQUIRED)
236+
FIND_PACKAGE(Qt5Script REQUIRED)
237+
FIND_PACKAGE(Qt5Sql REQUIRED)
238+
SET(QT5_BUILD TRUE)
239+
240+
INCLUDE("cmake/modules/ECMQt4To5Porting.cmake")
241+
ELSE()
242+
FIND_PACKAGE(Qt4 ${QT_MIN_VERSION} REQUIRED)
243+
SET(QT_USE_QTXML 1)
244+
SET(QT_USE_QTNETWORK 1)
245+
SET(QT_USE_QTSVG 1)
246+
SET(QT_USE_QTSQL 1)
247+
SET(QT_USE_QTWEBKIT 1)
248+
IF (WITH_CUSTOM_WIDGETS)
249+
SET(QT_USE_QTDESIGNER 1)
250+
ENDIF (WITH_CUSTOM_WIDGETS)
251+
252+
IF (NOT QT_QTXML_FOUND OR NOT QT_QTNETWORK_FOUND OR NOT QT_QTSVG_FOUND OR NOT QT_QTSQL_FOUND OR NOT QT_QTWEBKIT_FOUND OR (WITH_CUSTOM_WIDGETS AND NOT QT_QTDESIGNER_FOUND))
253+
MESSAGE(SEND_ERROR "Some Qt4 modules haven't been found!")
254+
ENDIF (NOT QT_QTXML_FOUND OR NOT QT_QTNETWORK_FOUND OR NOT QT_QTSVG_FOUND OR NOT QT_QTSQL_FOUND OR NOT QT_QTWEBKIT_FOUND OR (WITH_CUSTOM_WIDGETS AND NOT QT_QTDESIGNER_FOUND))
255+
256+
INCLUDE( ${QT_USE_FILE} )
257+
ENDIF()
258+
223259
MESSAGE(STATUS "Found Qt version: ${QTVERSION}")
224-
SET(QT_USE_QTXML 1)
225-
SET(QT_USE_QTNETWORK 1)
226-
SET(QT_USE_QTSVG 1)
227-
SET(QT_USE_QTSQL 1)
228-
SET(QT_USE_QTWEBKIT 1)
229-
IF (WITH_CUSTOM_WIDGETS)
230-
SET(QT_USE_QTDESIGNER 1)
231-
ENDIF (WITH_CUSTOM_WIDGETS)
232-
233-
IF (NOT QT_QTXML_FOUND OR NOT QT_QTNETWORK_FOUND OR NOT QT_QTSVG_FOUND OR NOT QT_QTSQL_FOUND OR NOT QT_QTWEBKIT_FOUND OR (WITH_CUSTOM_WIDGETS AND NOT QT_QTDESIGNER_FOUND))
234-
MESSAGE(SEND_ERROR "Some Qt4 modules haven't been found!")
235-
ENDIF (NOT QT_QTXML_FOUND OR NOT QT_QTNETWORK_FOUND OR NOT QT_QTSVG_FOUND OR NOT QT_QTSQL_FOUND OR NOT QT_QTWEBKIT_FOUND OR (WITH_CUSTOM_WIDGETS AND NOT QT_QTDESIGNER_FOUND))
236260

237261
IF (WITH_QTMOBILITY)
238262
FIND_PACKAGE(QtMobility 1.1.0)
@@ -282,8 +306,6 @@ IF (SUPPRESS_QT_WARNINGS)
282306
INCLUDE_DIRECTORIES(SYSTEM ${QT_INCLUDE_DIR})
283307
ENDIF (SUPPRESS_QT_WARNINGS)
284308

285-
INCLUDE( ${QT_USE_FILE} )
286-
287309
# Disable automatic conversion from QString to ASCII 8-bit strings (char *)
288310
# (Keeps code compatible with Qt/Mac/64bit)
289311
ADD_DEFINITIONS(-DQT_NO_CAST_TO_ASCII)

cmake/modules/ECMQt4To5Porting.cmake

Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
1+
#=============================================================================
2+
# Copyright 2005-2011 Kitware, Inc.
3+
# All rights reserved.
4+
#
5+
# Redistribution and use in source and binary forms, with or without
6+
# modification, are permitted provided that the following conditions
7+
# are met:
8+
#
9+
# * Redistributions of source code must retain the above copyright
10+
# notice, this list of conditions and the following disclaimer.
11+
#
12+
# * Redistributions in binary form must reproduce the above copyright
13+
# notice, this list of conditions and the following disclaimer in the
14+
# documentation and/or other materials provided with the distribution.
15+
#
16+
# * Neither the name of Kitware, Inc. nor the names of its
17+
# contributors may be used to endorse or promote products derived
18+
# from this software without specific prior written permission.
19+
#
20+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24+
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27+
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28+
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31+
#=============================================================================
32+
33+
# The automoc_qt4 macro is superceded by CMAKE_AUTOMOC from CMake 2.8.6
34+
# A Qt 5 version is not provided by CMake or Qt.
35+
36+
include(MacroAddFileDependencies)
37+
38+
MACRO (QT4_GET_MOC_FLAGS _moc_flags)
39+
SET(${_moc_flags})
40+
GET_DIRECTORY_PROPERTY(_inc_DIRS INCLUDE_DIRECTORIES)
41+
42+
FOREACH(_current ${_inc_DIRS})
43+
IF("${_current}" MATCHES "\\.framework/?$")
44+
STRING(REGEX REPLACE "/[^/]+\\.framework" "" framework_path "${_current}")
45+
SET(${_moc_flags} ${${_moc_flags}} "-F${framework_path}")
46+
ELSE("${_current}" MATCHES "\\.framework/?$")
47+
SET(${_moc_flags} ${${_moc_flags}} "-I${_current}")
48+
ENDIF("${_current}" MATCHES "\\.framework/?$")
49+
ENDFOREACH(_current ${_inc_DIRS})
50+
51+
GET_DIRECTORY_PROPERTY(_defines COMPILE_DEFINITIONS)
52+
FOREACH(_current ${_defines})
53+
SET(${_moc_flags} ${${_moc_flags}} "-D${_current}")
54+
ENDFOREACH(_current ${_defines})
55+
56+
IF(Q_OS_WIN)
57+
SET(${_moc_flags} ${${_moc_flags}} -DWIN32)
58+
ENDIF(Q_OS_WIN)
59+
60+
ENDMACRO(QT4_GET_MOC_FLAGS)
61+
62+
# helper macro to set up a moc rule
63+
MACRO (QT4_CREATE_MOC_COMMAND infile outfile moc_flags moc_options)
64+
# For Windows, create a parameters file to work around command line length limit
65+
IF (WIN32)
66+
# Pass the parameters in a file. Set the working directory to
67+
# be that containing the parameters file and reference it by
68+
# just the file name. This is necessary because the moc tool on
69+
# MinGW builds does not seem to handle spaces in the path to the
70+
# file given with the @ syntax.
71+
GET_FILENAME_COMPONENT(_moc_outfile_name "${outfile}" NAME)
72+
GET_FILENAME_COMPONENT(_moc_outfile_dir "${outfile}" PATH)
73+
IF(_moc_outfile_dir)
74+
SET(_moc_working_dir WORKING_DIRECTORY ${_moc_outfile_dir})
75+
ENDIF(_moc_outfile_dir)
76+
SET (_moc_parameters_file ${outfile}_parameters)
77+
SET (_moc_parameters ${moc_flags} ${moc_options} -o "${outfile}" "${infile}")
78+
STRING (REPLACE ";" "\n" _moc_parameters "${_moc_parameters}")
79+
FILE (WRITE ${_moc_parameters_file} "${_moc_parameters}")
80+
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
81+
COMMAND ${QT_MOC_EXECUTABLE} @${_moc_outfile_name}_parameters
82+
DEPENDS ${infile}
83+
${_moc_working_dir}
84+
VERBATIM)
85+
ELSE (WIN32)
86+
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
87+
COMMAND ${QT_MOC_EXECUTABLE}
88+
ARGS ${moc_flags} ${moc_options} -o ${outfile} ${infile}
89+
DEPENDS ${infile} VERBATIM)
90+
ENDIF (WIN32)
91+
ENDMACRO (QT4_CREATE_MOC_COMMAND)
92+
93+
94+
MACRO(QT4_AUTOMOC)
95+
QT4_GET_MOC_FLAGS(_moc_INCS)
96+
97+
SET(_matching_FILES )
98+
FOREACH (_current_FILE ${ARGN})
99+
100+
GET_FILENAME_COMPONENT(_abs_FILE ${_current_FILE} ABSOLUTE)
101+
# if "SKIP_AUTOMOC" is set to true, we will not handle this file here.
102+
# This is required to make uic work correctly:
103+
# we need to add generated .cpp files to the sources (to compile them),
104+
# but we cannot let automoc handle them, as the .cpp files don't exist yet when
105+
# cmake is run for the very first time on them -> however the .cpp files might
106+
# exist at a later run. at that time we need to skip them, so that we don't add two
107+
# different rules for the same moc file
108+
GET_SOURCE_FILE_PROPERTY(_skip ${_abs_FILE} SKIP_AUTOMOC)
109+
110+
IF ( NOT _skip AND EXISTS ${_abs_FILE} )
111+
112+
FILE(READ ${_abs_FILE} _contents)
113+
114+
GET_FILENAME_COMPONENT(_abs_PATH ${_abs_FILE} PATH)
115+
116+
STRING(REGEX MATCHALL "# *include +[^ ]+\\.moc[\">]" _match "${_contents}")
117+
IF(_match)
118+
FOREACH (_current_MOC_INC ${_match})
119+
STRING(REGEX MATCH "[^ <\"]+\\.moc" _current_MOC "${_current_MOC_INC}")
120+
121+
GET_FILENAME_COMPONENT(_basename ${_current_MOC} NAME_WE)
122+
IF(EXISTS ${_abs_PATH}/${_basename}.hpp)
123+
SET(_header ${_abs_PATH}/${_basename}.hpp)
124+
ELSE(EXISTS ${_abs_PATH}/${_basename}.hpp)
125+
SET(_header ${_abs_PATH}/${_basename}.h)
126+
ENDIF(EXISTS ${_abs_PATH}/${_basename}.hpp)
127+
SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_current_MOC})
128+
QT4_CREATE_MOC_COMMAND(${_header} ${_moc} "${_moc_INCS}" "")
129+
MACRO_ADD_FILE_DEPENDENCIES(${_abs_FILE} ${_moc})
130+
ENDFOREACH (_current_MOC_INC)
131+
ENDIF(_match)
132+
ENDIF ( NOT _skip AND EXISTS ${_abs_FILE} )
133+
ENDFOREACH (_current_FILE)
134+
ENDMACRO(QT4_AUTOMOC)
135+
136+
137+
# Portability helpers.
138+
139+
set(QT_QTGUI_LIBRARIES
140+
${Qt5Gui_LIBRARIES}
141+
${Qt5Widgets_LIBRARIES}
142+
${Qt5PrintSupport_LIBRARIES}
143+
${Qt5Svg_LIBRARIES}
144+
)
145+
146+
set(QT_INCLUDES
147+
${Qt5Gui_INCLUDE_DIRS}
148+
${Qt5Widgets_INCLUDE_DIRS}
149+
${Qt5PrintSupport_INCLUDE_DIRS}
150+
${Qt5Svg_INCLUDE_DIRS}
151+
)
152+
set(QT_QTGUI_LIBRARY ${QT_QTGUI_LIBRARIES})
153+
154+
set(_qt_modules
155+
Core
156+
Declarative
157+
Widgets
158+
Script
159+
ScriptTools
160+
Network
161+
Test
162+
Designer
163+
Concurrent
164+
Xml
165+
XmlPatterns
166+
UiTools
167+
Qml
168+
Quick1
169+
WebKit
170+
WebKitWidgets
171+
Sql
172+
OpenGL
173+
)
174+
175+
foreach(_module ${_qt_modules})
176+
string(TOUPPER ${_module} _module_upper)
177+
set(QT_QT${_module_upper}_LIBRARIES ${Qt5${_module}_LIBRARIES})
178+
set(QT_QT${_module_upper}_LIBRARY ${QT_QT${_module_upper}_LIBRARIES})
179+
list(APPEND QT_INCLUDES ${Qt5${_module}_INCLUDE_DIRS})
180+
set(QT_QT${_module_upper}_FOUND ${Qt5${_module}_FOUND})
181+
endforeach()
182+
183+
list(APPEND QT_QTCORE_LIBRARIES ${Qt5Concurrent_LIBRARIES})
184+
list(APPEND QT_QTCORE_LIBRARY ${Qt5Concurrent_LIBRARIES})
185+
186+
list(APPEND QT_QTWEBKIT_LIBRARIES ${Qt5WebKitWidgets_LIBRARIES})
187+
list(APPEND QT_QTWEBKIT_LIBRARY ${Qt5WebKitWidgets_LIBRARIES})
188+
189+
set(QT_QTDECLARATIVE_LIBRARIES ${Qt5Quick1_LIBRARIES})
190+
set(QT_QTDECLARATIVE_LIBRARY ${Qt5Quick1_LIBRARIES})
191+
192+
set(QT_LRELEASE_EXECUTABLE lrelease-qt5)
193+
set(QT_LUPDATE_EXECUTABLE lupdate-qt5)
194+
195+
set(QT_INSTALL_PREFIX ${_qt5Core_install_prefix})
196+
197+
get_target_property(QT_QMAKE_EXECUTABLE Qt5::qmake LOCATION)
198+
set(QT_RCC_EXECUTABLE Qt5::rcc LOCATION)
199+
if (TARGET Qt5::uic)
200+
get_target_property(QT_UIC_EXECUTABLE Qt5::uic LOCATION)
201+
endif()
202+
203+
204+
if (TARGET Qt5::qdbuscpp2xml)
205+
get_target_property(QT_QDBUSCPP2XML_EXECUTABLE Qt5::qdbuscpp2xml LOCATION)
206+
endif()
207+
208+
if (TARGET Qt5::qdbusxml2cpp)
209+
get_target_property(QT_QDBUSXML2CPP_EXECUTABLE Qt5::qdbusxml2cpp LOCATION)
210+
endif()
211+
212+
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0)
213+
214+
macro(qt4_wrap_ui)
215+
qt5_wrap_ui(${ARGN})
216+
endmacro()
217+
218+
macro(qt4_wrap_cpp)
219+
qt5_wrap_cpp(${ARGN})
220+
endmacro()
221+
222+
macro(qt4_generate_moc)
223+
qt5_generate_moc(${ARGN})
224+
endmacro()
225+
226+
macro(qt4_add_dbus_adaptor)
227+
qt5_add_dbus_adaptor(${ARGN})
228+
endmacro()
229+
230+
macro(qt4_add_dbus_interfaces)
231+
qt5_add_dbus_interfaces(${ARGN})
232+
endmacro()
233+
234+
macro(qt4_add_dbus_interface)
235+
qt5_add_dbus_interface(${ARGN})
236+
endmacro()
237+
238+
macro(qt4_generate_dbus_interface)
239+
qt5_generate_dbus_interface(${ARGN})
240+
endmacro()
241+
242+
macro(qt4_add_resources)
243+
qt5_add_resources(${ARGN})
244+
endmacro()
245+

src/app/main.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include <QString>
3030
#include <QStringList>
3131
#include <QStyle>
32-
#include <QPlastiqueStyle>
3332
#include <QTranslator>
3433
#include <QImageReader>
3534
#include <QMessageBox>

src/core/CMakeLists.txt

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ SET(QGIS_CORE_SRCS
9494
qgsgeometryvalidator.cpp
9595
qgsgml.cpp
9696
qgsgmlschema.cpp
97-
qgshttptransaction.cpp
9897
qgslabel.cpp
9998
qgslabelattributes.cpp
10099
qgslabelsearchtree.cpp
@@ -268,9 +267,14 @@ SET(QGIS_CORE_SRCS
268267
raster/qgssinglebandpseudocolorrenderer.cpp
269268
raster/qgsbrightnesscontrastfilter.cpp
270269
raster/qgshuesaturationfilter.cpp
271-
272270
)
273271

272+
IF (NOT QT5_BUILD)
273+
SET(QGIS_CORE_SRCS ${QGIS_CORE_SRCS}
274+
qgshttptransaction.cpp
275+
)
276+
ENDIF (NOT QT5_BUILD)
277+
274278
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
275279
# spatialindex headers produce warnings
276280
SET_SOURCE_FILES_PROPERTIES(qgsspatialindex.cpp PROPERTIES COMPILE_FLAGS -Wno-overloaded-virtual)
@@ -351,7 +355,6 @@ SET(QGIS_CORE_MOC_HDRS
351355
qgsdataprovider.h
352356
qgsgml.h
353357
qgsgmlschema.h
354-
qgshttptransaction.h
355358
qgsmaplayer.h
356359
qgsmaplayerlegend.h
357360
qgsmaplayerregistry.h
@@ -428,6 +431,12 @@ SET(QGIS_CORE_MOC_HDRS
428431
layertree/qgslayertreeregistrybridge.h
429432
)
430433

434+
IF (NOT QT5_BUILD)
435+
SET(QGIS_CORE_MOC_HDRS ${QGIS_CORE_MOC_HDRS}
436+
qgshttptransaction.h
437+
)
438+
ENDIF (NOT QT5_BUILD)
439+
431440
IF (WITH_INTERNAL_QEXTSERIALPORT)
432441
SET(QGIS_CORE_MOC_HDRS ${QGIS_CORE_MOC_HDRS}
433442
gps/qextserialport/qextserialport.h
@@ -493,7 +502,6 @@ SET(QGIS_CORE_HDRS
493502
qgsgml.h
494503
qgsgmlschema.h
495504
qgsgeometrycache.h
496-
qgshttptransaction.h
497505
qgslabel.h
498506
qgslabelattributes.h
499507
qgslabelsearchtree.h
@@ -664,6 +672,12 @@ SET(QGIS_CORE_HDRS
664672
layertree/qgslayertreeutils.h
665673
)
666674

675+
IF (NOT QT5_BUILD)
676+
SET(QGIS_CORE_HDRS ${QGIS_CORE_HDRS}
677+
qgshttptransaction.h
678+
)
679+
ENDIF (NOT QT5_BUILD)
680+
667681
IF (QT_MOBILITY_LOCATION_FOUND)
668682
SET(QGIS_CORE_HDRS ${QGIS_CORE_HDRS}
669683
gps/qgsqtlocationconnection.h

src/core/composer/qgscomposerattributetablemodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ bool QgsComposerAttributeTableColumnModel::setData( const QModelIndex& index, co
188188
if ( column->heading().isEmpty() || ( column->heading() == column->attribute() ) )
189189
{
190190
column->setHeading( value.toString() );
191-
emit dataChanged( createIndex( index.row(), 1, 0 ), createIndex( index.row(), 1, 0 ) );
191+
emit dataChanged( createIndex( index.row(), 1 ), createIndex( index.row(), 1 ) );
192192
}
193193
column->setAttribute( value.toString() );
194194
emit dataChanged( index, index );

0 commit comments

Comments
 (0)