Selaa lähdekoodia

Add support for Qt5

Todo:
* Test with Qt4
* Make sure ctkMacroWrapPythonQt.cmake works correctly
Julien Finet 12 vuotta sitten
vanhempi
commit
47b3421658
100 muutettua tiedostoa jossa 776 lisäystä ja 368 poistoa
  1. 1 0
      CMake/CTKConfig.cmake.in
  2. 5 1
      CMake/ctkFunctionGeneratePluginManifest.cmake
  3. 26 11
      CMake/ctkMacroBuildApp.cmake
  4. 26 11
      CMake/ctkMacroBuildLib.cmake
  5. 5 1
      CMake/ctkMacroBuildLibWrapper.cmake
  6. 24 11
      CMake/ctkMacroBuildPlugin.cmake
  7. 22 9
      CMake/ctkMacroBuildQtPlugin.cmake
  8. 36 16
      CMake/ctkMacroGenerateMocs.cmake
  9. 5 1
      CMake/ctkMacroGeneratePluginResourceFile.cmake
  10. 8 8
      CMake/ctkMacroSetupPlugins.cmake
  11. 37 23
      CMake/ctkMacroSetupQt.cmake
  12. 3 1
      CMake/ctkMacroWrapPythonQt.cmake
  13. 8 0
      CMake/ctkQt.cmake
  14. 6 2
      CMake/ctkScriptWrapPythonQt_Light.cmake
  15. 13 3
      CMakeExternals/PythonQt.cmake
  16. 2 2
      CMakeExternals/VTK.cmake
  17. 11 4
      Libs/CommandLineModules/Core/CMakeLists.txt
  18. 21 10
      Libs/CommandLineModules/Core/Testing/Cpp/CMakeLists.txt
  19. 1 1
      Libs/CommandLineModules/Core/ctkCmdLineModuleXmlProgressWatcher.cpp
  20. 21 9
      Libs/CommandLineModules/Frontend/QtGui/Testing/Cpp/CMakeLists.txt
  21. 19 10
      Libs/CommandLineModules/Testing/Cpp/CMakeLists.txt
  22. 1 0
      Libs/Core/CMakeLists.txt
  23. 15 6
      Libs/Core/Testing/Cpp/CMakeLists.txt
  24. 1 1
      Libs/Core/Testing/Cpp/ctkAbstractLibraryFactoryTest1.cpp
  25. 13 4
      Libs/Core/ctkAbstractLibraryFactory.h
  26. 3 2
      Libs/Core/ctkAbstractLibraryFactory.tpp
  27. 2 2
      Libs/Core/ctkCheckableModelHelper.cpp
  28. 12 2
      Libs/Core/ctkErrorLogQtMessageHandler.cpp
  29. 5 0
      Libs/Core/ctkErrorLogQtMessageHandler.h
  30. 6 1
      Libs/Core/target_libraries.cmake
  31. 1 1
      Libs/DICOM/Core/ctkDICOMDatabase.cpp
  32. 5 5
      Libs/DICOM/Core/ctkDICOMItem.cpp
  33. 5 5
      Libs/DICOM/Core/ctkDICOMQuery.cpp
  34. 3 0
      Libs/DICOM/Core/target_libraries.cmake
  35. 2 0
      Libs/DICOM/Widgets/Plugins/ctkDICOMWidgetsPlugins.cpp
  36. 3 0
      Libs/DICOM/Widgets/Plugins/ctkDICOMWidgetsPlugins.h
  37. 5 0
      Libs/DICOM/Widgets/ctkDICOMServerNodeWidget.cpp
  38. 7 2
      Libs/PluginFramework/Documentation/Snippets/EventAdmin-Intro/files.cmake
  39. 4 4
      Libs/PluginFramework/Testing/org.commontk.pluginfwtest/ctkPluginFrameworkTestSuite.cpp
  40. 1 1
      Libs/PluginFramework/Testing/org.commontk.pluginfwtest/ctkServiceTrackerTestSuite.cpp
  41. 1 1
      Libs/PluginFramework/ctkPluginFrameworkUtil.cpp
  42. 1 1
      Libs/PluginFramework/ctkServices.cpp
  43. 4 2
      Libs/Scripting/Python/Core/CMakeLists.txt
  44. 10 2
      Libs/Scripting/Python/Core/Python/CMakeLists.txt
  45. 2 13
      Libs/Scripting/Python/Core/Python/qt/__init__.py
  46. 9 3
      Libs/Scripting/Python/Core/Testing/Cpp/CMakeLists.txt
  47. 2 2
      Libs/Scripting/Python/Core/ctkAbstractPythonManager.cpp
  48. 3 0
      Libs/Scripting/Python/Core/ctkScriptingPythonCoreConfigure.h.in
  49. 4 0
      Libs/Scripting/Python/Core/ctk_library_options.cmake
  50. 2 0
      Libs/Scripting/Python/Widgets/Plugins/ctkScriptingPythonWidgetsPlugins.cpp
  51. 6 2
      Libs/Scripting/Python/Widgets/Plugins/ctkScriptingPythonWidgetsPlugins.h
  52. 6 4
      Libs/Scripting/Python/Widgets/ctkPythonConsole.cpp
  53. 1 1
      Libs/Testing/ctkTest.h
  54. 5 1
      Libs/Visualization/VTK/Core/Testing/Cpp/CMakeLists.txt
  55. 2 0
      Libs/Visualization/VTK/Widgets/Plugins/ctkVTKWidgetsPlugins.cpp
  56. 6 3
      Libs/Visualization/VTK/Widgets/Plugins/ctkVTKWidgetsPlugins.h
  57. 23 11
      Libs/Visualization/VTK/Widgets/Testing/Cpp/CMakeLists.txt
  58. 5 1
      Libs/Visualization/VTK/Widgets/ctkVTKMagnifyView.cpp
  59. 2 2
      Libs/Visualization/VTK/Widgets/ctkVTKMagnifyView_p.h
  60. 4 1
      Libs/Visualization/VTK/Widgets/target_libraries.cmake
  61. 11 4
      Libs/Widgets/CMakeLists.txt
  62. 2 0
      Libs/Widgets/Plugins/ctkWidgetsPlugins.cpp
  63. 6 3
      Libs/Widgets/Plugins/ctkWidgetsPlugins.h
  64. 59 28
      Libs/Widgets/Testing/Cpp/CMakeLists.txt
  65. 9 10
      Libs/Widgets/ctkBasePopupWidget.cpp
  66. 3 2
      Libs/Widgets/ctkBasePopupWidget_p.h
  67. 1 2
      Libs/Widgets/ctkButtonGroup.cpp
  68. 0 1
      Libs/Widgets/ctkCheckableComboBox.cpp
  69. 2 2
      Libs/Widgets/ctkCheckableHeaderView.cpp
  70. 0 1
      Libs/Widgets/ctkCheckablePushButton.cpp
  71. 5 1
      Libs/Widgets/ctkCollapsibleButton.cpp
  72. 1 0
      Libs/Widgets/ctkConsole.cpp
  73. 2 2
      Libs/Widgets/ctkCoordinatesWidget.h
  74. 2 2
      Libs/Widgets/ctkDoubleRangeSlider.cpp
  75. 2 1
      Libs/Widgets/ctkDoubleSlider.cpp
  76. 2 2
      Libs/Widgets/ctkDoubleSpinBox_p.h
  77. 9 1
      Libs/Widgets/ctkIconEnginePlugin.cpp
  78. 18 4
      Libs/Widgets/ctkIconEnginePlugin.h
  79. 9 5
      Libs/Widgets/ctkMaterialPropertyPreviewLabel.cpp
  80. 0 1
      Libs/Widgets/ctkMenuButton.cpp
  81. 1 0
      Libs/Widgets/ctkMenuComboBox.cpp
  82. 3 3
      Libs/Widgets/ctkMenuComboBox_p.h
  83. 22 3
      Libs/Widgets/ctkPixmapIconEngine.cpp
  84. 11 1
      Libs/Widgets/ctkPixmapIconEngine.h
  85. 13 9
      Libs/Widgets/ctkPopupWidget.cpp
  86. 2 2
      Libs/Widgets/ctkRangeWidget.cpp
  87. 2 1
      Libs/Widgets/ctkScreenshotDialog_p.h
  88. 3 3
      Libs/Widgets/ctkSliderWidget.cpp
  89. 18 7
      Libs/Widgets/ctkTestApplication.cpp
  90. 4 0
      Libs/Widgets/ctkTestApplication.h
  91. 4 2
      Libs/Widgets/ctkTreeComboBox.cpp
  92. 3 3
      Libs/Widgets/ctkWorkflowWidget.cpp
  93. 3 0
      Libs/Widgets/target_libraries.cmake
  94. 1 1
      Libs/ctkExport.h.in
  95. 14 4
      Plugins/org.commontk.eventbus/Testing/Cpp/CMakeLists.txt
  96. 1 1
      Plugins/org.commontk.eventbus/ctkEventBusManager.cpp
  97. 4 4
      Plugins/org.commontk.eventbus/ctkEventDefinitions.h
  98. 6 6
      Plugins/org.commontk.eventbus/ctkEventDispatcher.cpp
  99. 26 26
      Plugins/org.commontk.eventbus/ctkEventDispatcherLocal.cpp
  100. 0 0
      Plugins/org.commontk.eventbus/ctkNetworkConnectorQXMLRPC.cpp

+ 1 - 0
CMake/CTKConfig.cmake.in

@@ -141,6 +141,7 @@ SET(CTK_QT_RCC_EXECUTABLE "@QT_RCC_EXECUTABLE@")
 SET(CTK_QT_MOC_EXECUTABLE "@QT_MOC_EXECUTABLE@")
 SET(CTK_QT_UIC_EXECUTABLE "@QT_UIC_EXECUTABLE@")
 SET(CTK_QT_QMAKE_EXECUTABLE "@QT_QMAKE_EXECUTABLE@")
+SET(CTK_QT_VERSION "@CTK_QT_VERSION@")
 
 # The CTK version number
 SET(CTK_MAJOR_VERSION "@CTK_MAJOR_VERSION@")

+ 5 - 1
CMake/ctkFunctionGeneratePluginManifest.cmake

@@ -96,7 +96,11 @@ function(ctkFunctionGeneratePluginManifest QRC_SRCS)
   configure_file("${CTK_CMAKE_DIR}/MANIFEST.MF.in" "${_manifest_filepath}" @ONLY)
   configure_file("${CTK_CMAKE_DIR}/plugin_manifest.qrc.in" "${_manifest_qrc_filepath}" @ONLY)
 
-  QT4_ADD_RESOURCES(_qrc_src ${_manifest_qrc_filepath})
+  if (CTK_QT_VERSION VERSION_GREATER "4")
+    QT5_ADD_RESOURCES(_qrc_src ${_manifest_qrc_filepath})
+  else()
+    QT4_ADD_RESOURCES(_qrc_src ${_manifest_qrc_filepath})
+  endif()
 
   set(${QRC_SRCS} ${${QRC_SRCS}} ${_qrc_src} PARENT_SCOPE)
 

+ 26 - 11
CMake/ctkMacroBuildApp.cmake

@@ -74,17 +74,32 @@ macro(ctkMacroBuildApp)
   set(MY_MOC_CPP)
   set(MY_QRC_SRCS)
 
-  # Wrap
-  if(MY_MOC_SRCS)
-    # this is a workaround for Visual Studio. The relative include paths in the generated
-    # moc files can get very long and can't be resolved by the MSVC compiler.
-    foreach(moc_src ${MY_MOC_SRCS})
-      QT4_WRAP_CPP(MY_MOC_CPP ${moc_src} OPTIONS -f${moc_src})
-    endforeach()
-  endif()
-  QT4_WRAP_UI(MY_UI_CPP ${MY_UI_FORMS})
-  if(DEFINED MY_RESOURCES)
-    QT4_ADD_RESOURCES(MY_QRC_SRCS ${MY_RESOURCES})
+  if (CTK_QT_VERSION VERSION_GREATER "4")
+    # Wrap
+    if(MY_MOC_SRCS)
+      # this is a workaround for Visual Studio. The relative include paths in the generated
+      # moc files can get very long and can't be resolved by the MSVC compiler.
+      foreach(moc_src ${MY_MOC_SRCS})
+        QT5_WRAP_CPP(MY_MOC_CPP ${moc_src} OPTIONS -f${moc_src})
+      endforeach()
+    endif()
+    QT5_WRAP_UI(MY_UI_CPP ${MY_UI_FORMS})
+    if(DEFINED MY_RESOURCES)
+      QT5_ADD_RESOURCES(MY_QRC_SRCS ${MY_RESOURCES})
+    endif()
+  else()
+    # Wrap
+    if(MY_MOC_SRCS)
+      # this is a workaround for Visual Studio. The relative include paths in the generated
+      # moc files can get very long and can't be resolved by the MSVC compiler.
+      foreach(moc_src ${MY_MOC_SRCS})
+        QT4_WRAP_CPP(MY_MOC_CPP ${moc_src} OPTIONS -f${moc_src})
+      endforeach()
+    endif()
+    QT4_WRAP_UI(MY_UI_CPP ${MY_UI_FORMS})
+    if(DEFINED MY_RESOURCES)
+      QT4_ADD_RESOURCES(MY_QRC_SRCS ${MY_RESOURCES})
+    endif()
   endif()
 
   source_group("Resources" FILES

+ 26 - 11
CMake/ctkMacroBuildLib.cmake

@@ -101,17 +101,32 @@ macro(ctkMacroBuildLib)
   set(MY_UI_CPP)
   set(MY_QRC_SRCS)
 
-  # Wrap
-  if(MY_MOC_SRCS)
-    # this is a workaround for Visual Studio. The relative include paths in the generated
-    # moc files can get very long and can't be resolved by the MSVC compiler.
-    foreach(moc_src ${MY_MOC_SRCS})
-      QT4_WRAP_CPP(MY_MOC_CPP ${moc_src} OPTIONS -f${moc_src})
-    endforeach()
-  endif()
-  QT4_WRAP_UI(MY_UI_CPP ${MY_UI_FORMS})
-  if(DEFINED MY_RESOURCES)
-    QT4_ADD_RESOURCES(MY_QRC_SRCS ${MY_RESOURCES})
+  if (CTK_QT_VERSION VERSION_GREATER "4")
+    # Wrap
+    if(MY_MOC_SRCS)
+      # this is a workaround for Visual Studio. The relative include paths in the generated
+      # moc files can get very long and can't be resolved by the MSVC compiler.
+      foreach(moc_src ${MY_MOC_SRCS})
+        qt5_wrap_cpp(MY_MOC_CPP ${moc_src} OPTIONS -f${moc_src})
+      endforeach()
+    endif()
+    qt5_wrap_ui(MY_UI_CPP ${MY_UI_FORMS})
+    if(DEFINED MY_RESOURCES)
+      qt5_add_resources(MY_QRC_SRCS ${MY_RESOURCES})
+    endif()
+  else()
+    # Wrap
+    if(MY_MOC_SRCS)
+      # this is a workaround for Visual Studio. The relative include paths in the generated
+      # moc files can get very long and can't be resolved by the MSVC compiler.
+      foreach(moc_src ${MY_MOC_SRCS})
+        QT4_WRAP_CPP(MY_MOC_CPP ${moc_src} OPTIONS -f${moc_src})
+      endforeach()
+    endif()
+    QT4_WRAP_UI(MY_UI_CPP ${MY_UI_FORMS})
+    if(DEFINED MY_RESOURCES)
+      QT4_ADD_RESOURCES(MY_QRC_SRCS ${MY_RESOURCES})
+    endif()
   endif()
 
   source_group("Resources" FILES

+ 5 - 1
CMake/ctkMacroBuildLibWrapper.cmake

@@ -96,7 +96,11 @@ macro(ctkMacroBuildLibWrapper)
     KIT_PYTHONQT_SRCS "${MY_SRCS}" ${CTK_WRAP_PYTHONQT_FULL} ${HAS_DECORATOR})
   if(HAS_DECORATOR)
     list(APPEND KIT_PYTHONQT_SRCS ${DECORATOR_HEADER})
-    QT4_WRAP_CPP(KIT_PYTHONQT_SRCS ${DECORATOR_HEADER} OPTIONS -f${DECORATOR_HEADER})
+    if (CTK_QT_VERSION VERSION_GREATER "4")
+      qt5_wrap_cpp(KIT_PYTHONQT_SRCS ${DECORATOR_HEADER} OPTIONS -f${DECORATOR_HEADER})
+    else()
+      QT4_WRAP_CPP(KIT_PYTHONQT_SRCS ${DECORATOR_HEADER} OPTIONS -f${DECORATOR_HEADER})
+    endif()
   endif()
   add_library(${lib_name}PythonQt ${MY_WRAPPER_LIBRARY_TYPE} ${KIT_PYTHONQT_SRCS})
   target_link_libraries(${lib_name}PythonQt ${lib_name} ${my_EXTRA_PYTHON_LIBRARIES})

+ 24 - 11
CMake/ctkMacroBuildPlugin.cmake

@@ -170,18 +170,31 @@ macro(ctkMacroBuildPlugin)
   set(MY_QRC_SRCS)
 
   # Wrap
-  if(MY_MOC_SRCS)
-    # this is a workaround for Visual Studio. The relative include paths in the generated
-    # moc files can get very long and can't be resolved by the MSVC compiler.
-    foreach(moc_src ${MY_MOC_SRCS})
-      QT4_WRAP_CPP(MY_MOC_CPP ${moc_src} OPTIONS -f${moc_src})
-    endforeach()
-  endif()
-  QT4_WRAP_UI(MY_UI_CPP ${MY_UI_FORMS})
-  if(DEFINED MY_RESOURCES)
-    QT4_ADD_RESOURCES(MY_QRC_SRCS ${MY_RESOURCES})
+  if (CTK_QT_VERSION VERSION_GREATER "4")
+    if(MY_MOC_SRCS)
+      # this is a workaround for Visual Studio. The relative include paths in the generated
+      # moc files can get very long and can't be resolved by the MSVC compiler.
+      foreach(moc_src ${MY_MOC_SRCS})
+        QT5_WRAP_CPP(MY_MOC_CPP ${moc_src} OPTIONS -f${moc_src})
+      endforeach()
+    endif()
+    QT5_WRAP_UI(MY_UI_CPP ${MY_UI_FORMS})
+    if(DEFINED MY_RESOURCES)
+      QT5_ADD_RESOURCES(MY_QRC_SRCS ${MY_RESOURCES})
+    endif()
+  else()
+    if(MY_MOC_SRCS)
+      # this is a workaround for Visual Studio. The relative include paths in the generated
+      # moc files can get very long and can't be resolved by the MSVC compiler.
+      foreach(moc_src ${MY_MOC_SRCS})
+        QT4_WRAP_CPP(MY_MOC_CPP ${moc_src} OPTIONS -f${moc_src})
+      endforeach()
+    endif()
+    QT4_WRAP_UI(MY_UI_CPP ${MY_UI_FORMS})
+    if(DEFINED MY_RESOURCES)
+      QT4_ADD_RESOURCES(MY_QRC_SRCS ${MY_RESOURCES})
+    endif()
   endif()
-
   # Add the generated manifest qrc file
   set(manifest_qrc_src )
   ctkFunctionGeneratePluginManifest(manifest_qrc_src

+ 22 - 9
CMake/ctkMacroBuildQtPlugin.cmake

@@ -49,16 +49,20 @@ macro(ctkMacroBuildQtPlugin)
 
   # --------------------------------------------------------------------------
   # Include dirs
+
   set(my_includes
     ${CTK_BASE_INCLUDE_DIRS}
-    ${QT_QTDESIGNER_INCLUDE_DIR}
     ${CMAKE_CURRENT_SOURCE_DIR}
     ${CMAKE_CURRENT_BINARY_DIR}
     ${MY_INCLUDE_DIRECTORIES}
     )
-  include_directories(
-    ${my_includes}
-    )
+
+  if (CTK_QT_VERSION VERSION_GREATER "4")
+    list(APPEND my_includes ${Qt5Designer_INCLUDE_DIRS})
+  else()
+    list(APPEND my_includes ${QT_QTDESIGNER_INCLUDE_DIR})
+  endif()
+  include_directories(${my_includes})
 
   set(MY_LIBRARY_EXPORT_DIRECTIVE ${MY_EXPORT_DIRECTIVE})
   set(MY_EXPORT_HEADER_PREFIX ${MY_NAME})
@@ -82,11 +86,20 @@ macro(ctkMacroBuildQtPlugin)
   set(MY_QRC_SRCS)
 
   # Wrap
-  QT4_WRAP_CPP(MY_MOC_CPP ${MY_MOC_SRCS})
-  QT4_WRAP_UI(MY_UI_CPP ${MY_UI_FORMS})
-  set(MY_QRC_SRCS "")
-  if(DEFINED MY_RESOURCES)
-    QT4_ADD_RESOURCES(MY_QRC_SRCS ${MY_RESOURCES})
+  if (CTK_QT_VERSION VERSION_GREATER "4")
+    qt5_wrap_cpp(MY_MOC_CPP ${MY_MOC_SRCS})
+    qt5_wrap_ui(MY_UI_CPP ${MY_UI_FORMS})
+    set(MY_QRC_SRCS "")
+    if(DEFINED MY_RESOURCES)
+      qt5_add_resources(MY_QRC_SRCS ${MY_RESOURCES})
+    endif()
+  else()
+    QT4_WRAP_CPP(MY_MOC_CPP ${MY_MOC_SRCS})
+    QT4_WRAP_UI(MY_UI_CPP ${MY_UI_FORMS})
+    set(MY_QRC_SRCS "")
+    if(DEFINED MY_RESOURCES)
+      QT4_ADD_RESOURCES(MY_QRC_SRCS ${MY_RESOURCES})
+    endif()
   endif()
 
   source_group("Resources" FILES

+ 36 - 16
CMake/ctkMacroGenerateMocs.cmake

@@ -1,21 +1,41 @@
 
-# QT4_GENERATE_MOCS(inputfile1 [inputfile2 ...])
+if (CTK_QT_VERSION VERSION_GREATER "4")
+  # QT5_GENERATE_MOCS(inputfile1 [inputfile2 ...])
+  macro(QT5_GENERATE_MOCS)
+    foreach(file ${ARGN})
+      set(moc_file moc_${file})
+      QT5_GENERATE_MOC(${file} ${moc_file})
 
-macro(QT4_GENERATE_MOCS)
-  foreach(file ${ARGN})
-    set(moc_file moc_${file})
-    QT4_GENERATE_MOC(${file} ${moc_file})
-
-    get_filename_component(source_name ${file} NAME_WE)
-    get_filename_component(source_ext ${file} EXT)
-    if(${source_ext} MATCHES "\\.[hH]")
-      if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${source_name}.cpp)
-        set(source_ext .cpp)
-      elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${source_name}.cxx)
-        set(source_ext .cxx)
+      get_filename_component(source_name ${file} NAME_WE)
+      get_filename_component(source_ext ${file} EXT)
+      if(${source_ext} MATCHES "\\.[hH]")
+        if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${source_name}.cpp)
+          set(source_ext .cpp)
+        elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${source_name}.cxx)
+          set(source_ext .cxx)
+        endif()
       endif()
-    endif()
-    set_property(SOURCE ${source_name}${source_ext} APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${moc_file})
-  endforeach()
+      set_property(SOURCE ${source_name}${source_ext} APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${moc_file})
+    endforeach()
 endmacro()
 
+else()
+  # QT4_GENERATE_MOCS(inputfile1 [inputfile2 ...])
+  macro(QT4_GENERATE_MOCS)
+    foreach(file ${ARGN})
+      set(moc_file moc_${file})
+      QT4_GENERATE_MOC(${file} ${moc_file})
+      get_filename_component(source_name ${file} NAME_WE)
+      get_filename_component(source_ext ${file} EXT)
+      if(${source_ext} MATCHES "\\.[hH]")
+        if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${source_name}.cpp)
+          set(source_ext .cpp)
+        elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${source_name}.cxx)
+          set(source_ext .cxx)
+        endif()
+      endif()
+      set_property(SOURCE ${source_name}${source_ext} APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${moc_file})
+    endforeach()
+  endmacro()
+endif()
+

+ 5 - 1
CMake/ctkMacroGeneratePluginResourceFile.cmake

@@ -39,6 +39,10 @@ macro(ctkMacroGeneratePluginResourceFile QRC_SRCS)
 ")
   configure_file("${CTK_CMAKE_DIR}/plugin_resources_cached.qrc.in" "${_qrc_filepath}" @ONLY)
 
-  QT4_ADD_RESOURCES(${QRC_SRCS} ${_qrc_filepath})
+  if (CTK_QT_VERSION VERSION_GREATER "4")
+    QT5_ADD_RESOURCES(${QRC_SRCS} ${_qrc_filepath})
+  else()
+    QT4_ADD_RESOURCES(${QRC_SRCS} ${_qrc_filepath})
+  endif()
 
 endmacro()

+ 8 - 8
CMake/ctkMacroSetupPlugins.cmake

@@ -102,14 +102,14 @@ macro(ctkMacroSetupPlugins )
   endif()
   
   # Set up Qt, if not already done
-  if(NOT QT4_FOUND)
-    set(minimum_required_qt_version "4.6")
-    find_package(Qt4 REQUIRED)
-
-    if("${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}" VERSION_LESS "${minimum_required_qt_version}")
-      message(FATAL_ERROR "error: CTK requires Qt >= ${minimum_required_qt_version} -- you cannot use Qt ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}.")
-    endif()
-  endif()
+  #if(NOT QT4_FOUND)
+  #  set(minimum_required_qt_version "4.6")
+  #  find_package(Qt4 REQUIRED)
+
+  #  if("${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}" VERSION_LESS "${minimum_required_qt_version}")
+  #    message(FATAL_ERROR "error: CTK requires Qt >= ${minimum_required_qt_version} -- you cannot use Qt ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}.")
+  #  endif()
+  #endif()
   
   # Set the variable QT_INSTALLED_LIBRARY_DIR that contains all
   # Qt shared libraries

+ 37 - 23
CMake/ctkMacroSetupQt.cmake

@@ -20,34 +20,48 @@
 
 #! \ingroup CMakeUtilities
 macro(ctkMacroSetupQt)
+  include(ctkQt)
 
-  set(minimum_required_qt_version "4.6")
+  if (CTK_QT_VERSION VERSION_GREATER "4")
+    set(qt_modules Core Sql WebKit Widgets Xml)
+    list(APPEND qt_modules Designer ) # plugins
+    list(APPEND qt_modules Network) # Visualization/VTK
+    list(APPEND qt_modules OpenGL) # Widgets/ctkWidgetsUtils and Visualization/VTK
+    if (${BUILD_TESTING})
+      list(APPEND qt_modules Test)
+    endif()
+    foreach(qt_module ${qt_modules})
+      find_package(Qt5${qt_module} REQUIRED)
+    endforeach()
+  else()
+    set(minimum_required_qt_version "4.6")
 
-  find_package(Qt4)
-  
-  if(QT4_FOUND)
+    find_package(Qt4)
 
-    if("${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}" VERSION_LESS "${minimum_required_qt_version}")
-      message(FATAL_ERROR "error: CTK requires Qt >= ${minimum_required_qt_version} -- you cannot use Qt ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}.")
-    endif()
+    if(QT4_FOUND)
 
-    set(QT_USE_QTNETWORK ON)
-    set(QT_USE_QTSQL ON)
-    set(QT_USE_QTOPENGL ON)
-    set(QT_USE_QTXML ON)
-    set(QT_USE_QTXMLPATTERNS ON)
-    set(QT_USE_QTTEST ${BUILD_TESTING})
-    include(${QT_USE_FILE})
-
-    # Set variable QT_INSTALLED_LIBRARY_DIR that will contains
-    # Qt shared library
-    set(QT_INSTALLED_LIBRARY_DIR ${QT_LIBRARY_DIR})
-    if(WIN32)
-      get_filename_component(QT_INSTALLED_LIBRARY_DIR ${QT_QMAKE_EXECUTABLE} PATH)
-    endif()
+      if("${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}" VERSION_LESS "${minimum_required_qt_version}")
+        message(FATAL_ERROR "error: CTK requires Qt >= ${minimum_required_qt_version} -- you cannot use Qt ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}.")
+      endif()
 
-  else()
-    message(FATAL_ERROR "error: Qt4 was not found on your system. You probably need to set the QT_QMAKE_EXECUTABLE variable")
+      set(QT_USE_QTNETWORK ON)
+      set(QT_USE_QTSQL ON)
+      set(QT_USE_QTOPENGL ON)
+      set(QT_USE_QTXML ON)
+      set(QT_USE_QTXMLPATTERNS ON)
+      set(QT_USE_QTTEST ${BUILD_TESTING})
+      include(${QT_USE_FILE})
+
+      # Set variable QT_INSTALLED_LIBRARY_DIR that will contains
+      # Qt shared library
+      set(QT_INSTALLED_LIBRARY_DIR ${QT_LIBRARY_DIR})
+      if(WIN32)
+        get_filename_component(QT_INSTALLED_LIBRARY_DIR ${QT_QMAKE_EXECUTABLE} PATH)
+      endif()
+
+    else()
+      message(FATAL_ERROR "error: Qt4 was not found on your system. You probably need to set the QT_QMAKE_EXECUTABLE variable")
+    endif()
   endif()
 
 endmacro()

+ 3 - 1
CMake/ctkMacroWrapPythonQt.cmake

@@ -299,7 +299,9 @@ macro(ctkMacroWrapPythonQt WRAPPING_NAMESPACE TARGET SRCS_LIST_NAME SOURCES IS_W
   set(moc_flags)
 
   # Grab moc flags
-  QT4_GET_MOC_FLAGS(moc_flags)
+  if (CTK_QT_VERSION VERSION_EQUAL "4")
+    QT4_GET_MOC_FLAGS(moc_flags)
+  endif()
 
   # Prepare custom_command argument
   set(moc_flags_arg)

+ 8 - 0
CMake/ctkQt.cmake

@@ -0,0 +1,8 @@
+set(CTK_QT_VERSION "4" CACHE STRING "Expected Qt version")
+mark_as_advanced(CTK_QT_VERSION)
+
+set_property(CACHE CTK_QT_VERSION PROPERTY STRINGS 4 5)
+
+if(NOT (CTK_QT_VERSION VERSION_EQUAL "4" OR CTK_QT_VERSION VERSION_EQUAL "5"))
+  message(FATAL_ERROR "Expected value for CTK_QT_VERSION is either '4' or '5'")
+endif()

+ 6 - 2
CMake/ctkScriptWrapPythonQt_Light.cmake

@@ -34,7 +34,7 @@
 #    cmake -DWRAPPING_NAMESPACE:STRING=org.commontk -DTARGET:STRING=MyLib
 #          -DSOURCES:STRING="file1^^file2" -DINCLUDE_DIRS:STRING=/path1:/path2
 #          -DWRAP_INT_DIR:STRING=subir/subir/
-#          -DOUTPUT_DIR:PATH=/path  -DQT_QMAKE_EXECUTABLE:PATH=/path/to/qt/qmake
+#          -DOUTPUT_DIR:PATH=/path  [-DQT_QMAKE_EXECUTABLE:PATH=/path/to/qt/qmake]
 #          -DPYTHON_EXECUTABLE:FILEPATH=/path/to/python
 #          -DPYTHON_LIBRARY_PATH:PATH=/path/to/pythonlib
 #          -DHAS_DECORATOR:BOOL=True
@@ -112,7 +112,11 @@ foreach(var WRAPPING_NAMESPACE TARGET SOURCES INCLUDE_DIRS WRAP_INT_DIR HAS_DECO
 endforeach()
 
 # Check for non-existing ${var}
-foreach(var QT_QMAKE_EXECUTABLE OUTPUT_DIR PYTHON_EXECUTABLE PYTHON_LIBRARY_PATH)
+set(requiredVariables OUTPUT_DIR PYTHON_EXECUTABLE PYTHON_LIBRARY_PATH)
+if (CTK_QT_VERSION VERSION_EQUAL "4")
+  list(APPEND QT_QMAKE_EXECUTABLE requiredVariables)
+endif()
+foreach(var )
   if(NOT EXISTS ${${var}})
     message(FATAL_ERROR "Failed to find ${var}=\"${${var}}\" when calling ctkScriptWrapPythonQt")
   endif()

+ 13 - 3
CMakeExternals/PythonQt.cmake

@@ -33,7 +33,18 @@ if(${add_project})
       endif()
 
       # Enable Qt libraries PythonQt wrapping if required
-      set(qtlibs core gui network opengl sql svg uitools webkit xml)
+      if (CTK_QT_VERSION VERSION_GREATER "4")
+        list(APPEND ep_PythonQt_args
+          -DPythonQt_QT_VERSION:STRING=${CTK_QT_VERSION}
+          -DCMAKE_PREFIX_PATH:STRING=${CMAKE_PREFIX_PATH}
+          )
+        set(qtlibs Core Gui Widgets Network OpenGL PrintSupport Sql Svg UiTools WebKit WebKitWidgets Xml)
+      else()
+        list(APPEND ep_PythonQt_args
+          -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}
+          )
+        set(qtlibs core gui network opengl sql svg uitools webkit xml)
+      endif()
       foreach(qtlib All ${qtlibs})
         string(TOUPPER ${qtlib} qtlib_uppercase)
         list(APPEND ep_PythonQt_args -DPythonQt_Wrap_Qt${qtlib}:BOOL=${CTK_LIB_Scripting/Python/Core_PYTHONQT_WRAP_QT${qtlib_uppercase}})
@@ -53,7 +64,7 @@ if(${add_project})
         message(FATAL_ERROR "error: Python is required to build ${PROJECT_NAME}")
       endif()
 
-      set(revision_tag 9c92fd212605bb5ff4d462323763acf65d87e4a7)
+      set(revision_tag 42864bb4747ea1442429a6bc4c2a665bcb011cc9)
       if(${proj}_REVISION_TAG)
         set(revision_tag ${${proj}_REVISION_TAG})
       endif()
@@ -79,7 +90,6 @@ if(${add_project})
         BUILD_COMMAND ""
         CMAKE_CACHE_ARGS
           ${ep_common_cache_args}
-          -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}
           -DPYTHON_INCLUDE_DIR:PATH=${PYTHON_INCLUDE_DIR}
           -DPYTHON_LIBRARY:FILEPATH=${PYTHON_LIBRARY}
           ${ep_PythonQt_args}

+ 2 - 2
CMakeExternals/VTK.cmake

@@ -37,7 +37,7 @@ if(${add_project} OR CTK_LIB_Scripting/Python/Core_PYTHONQT_USE_VTK)
 
     if(NOT DEFINED VTK_DIR)
 
-      set(revision_tag v5.10.0)
+      set(revision_tag v5.10.1-qt5)
       if(${proj}_REVISION_TAG)
         set(revision_tag ${${proj}_REVISION_TAG})
       endif()
@@ -49,7 +49,7 @@ if(${add_project} OR CTK_LIB_Scripting/Python/Core_PYTHONQT_USE_VTK)
         set(location_args GIT_REPOSITORY ${${proj}_GIT_REPOSITORY}
                           GIT_TAG ${revision_tag})
       else()
-        set(location_args GIT_REPOSITORY "${git_protocol}://vtk.org/VTK.git"
+        set(location_args GIT_REPOSITORY "${git_protocol}://github.com/finetjul/VTK.git"
                           GIT_TAG ${revision_tag})
       endif()
 

+ 11 - 4
Libs/CommandLineModules/Core/CMakeLists.txt

@@ -57,10 +57,17 @@ set(KIT_MOC_SRCS
   ctkCmdLineModuleManager.h
 )
 
-QT4_GENERATE_MOCS(
-  ctkCmdLineModuleFrontend.h
-  ctkCmdLineModuleXmlProgressWatcher.h
-)
+if(CTK_QT_VERSION VERSION_GREATER "4")
+  QT5_GENERATE_MOCS(
+    ctkCmdLineModuleFrontend.h
+    ctkCmdLineModuleXmlProgressWatcher.h
+    )
+else()
+  QT4_GENERATE_MOCS(
+    ctkCmdLineModuleFrontend.h
+    ctkCmdLineModuleXmlProgressWatcher.h
+    )
+endif()
 
 #list(APPEND KIT_SRCS
 #  ${CMAKE_CURRENT_BINARY_DIR}/moc_ctkCmdLineModuleXmlProgressWatcher.h

+ 21 - 10
Libs/CommandLineModules/Core/Testing/Cpp/CMakeLists.txt

@@ -23,18 +23,29 @@ include_directories(
   )
 
 set(Tests_MOC_CPP)
-QT4_WRAP_CPP(Tests_MOC_CPP ${Tests_MOC_SRCS})
-QT4_GENERATE_MOCS(
-  ctkCmdLineModuleManagerTest.cpp
-  ctkCmdLineModuleXmlProgressWatcherTest.cpp
-)
 set(Tests_UI_CPP)
-if(TEST_UI_FORMS)
-  QT4_WRAP_UI(Tests_UI_CPP ${Tests_UI_FORMS})
-endif()
 set(Tests_RESOURCES_SRCS)
-QT4_ADD_RESOURCES(Tests_RESOURCES_SRCS ${Tests_RESOURCES})
-
+if (CTK_QT_VERSION VERSION_GREATER "4")
+  QT5_WRAP_CPP(Tests_MOC_CPP ${Tests_MOC_SRCS})
+  QT5_GENERATE_MOCS(
+    ctkCmdLineModuleManagerTest.cpp
+    ctkCmdLineModuleXmlProgressWatcherTest.cpp
+    )
+  if(TEST_UI_FORMS)
+    QT5_WRAP_UI(Tests_UI_CPP ${Tests_UI_FORMS})
+  endif()
+  QT5_ADD_RESOURCES(Tests_RESOURCES_SRCS ${Tests_RESOURCES})
+else()
+  QT4_WRAP_CPP(Tests_MOC_CPP ${Tests_MOC_SRCS})
+  QT4_GENERATE_MOCS(
+    ctkCmdLineModuleManagerTest.cpp
+    ctkCmdLineModuleXmlProgressWatcherTest.cpp
+    )
+  if(TEST_UI_FORMS)
+    QT4_WRAP_UI(Tests_UI_CPP ${Tests_UI_FORMS})
+  endif()
+  QT4_ADD_RESOURCES(Tests_RESOURCES_SRCS ${Tests_RESOURCES})
+endif()
 add_executable(${KIT}CppTests ${Tests} ${Tests_SRCS} ${Tests_MOC_CPP} ${Tests_UI_CPP} ${Tests_RESOURCES_SRCS})
 target_link_libraries(${KIT}CppTests ${LIBRARY_NAME} ${CTK_BASE_LIBRARIES})
 

+ 1 - 1
Libs/CommandLineModules/Core/ctkCmdLineModuleXmlProgressWatcher.cpp

@@ -90,7 +90,7 @@ public:
       {
         if (stack.empty())
         {
-          QByteArray output(reader.text().toString().toAscii());
+          QByteArray output(reader.text().toString().toLatin1());
           // get rid of a possible newline after the last xml end tag
           if (output.startsWith('\n')) output = output.remove(0,1);
           outputData.append(output);

+ 21 - 9
Libs/CommandLineModules/Frontend/QtGui/Testing/Cpp/CMakeLists.txt

@@ -25,17 +25,29 @@ include_directories(
   )
 
 set(Tests_MOC_CPP)
-QT4_WRAP_CPP(Tests_MOC_CPP ${Tests_MOC_SRCS})
-QT4_GENERATE_MOCS(
-  ctkCmdLineModuleFrontendQtGuiTest.cpp
-  ctkCmdLineModuleQtXslTransformTest.cpp
-  )
 set(Tests_UI_CPP)
-if(TEST_UI_FORMS)
-  QT4_WRAP_UI(Tests_UI_CPP ${Tests_UI_FORMS})
-endif()
 set(Tests_RESOURCES_SRCS)
-QT4_ADD_RESOURCES(Tests_RESOURCES_SRCS ${Tests_RESOURCES})
+if(CTK_QT_VERSION VERSION_GREATER "4")
+  QT5_WRAP_CPP(Tests_MOC_CPP ${Tests_MOC_SRCS})
+  QT5_GENERATE_MOCS(
+    ctkCmdLineModuleFrontendQtGuiTest.cpp
+    ctkCmdLineModuleQtXslTransformTest.cpp
+    )
+  if(TEST_UI_FORMS)
+    QT5_WRAP_UI(Tests_UI_CPP ${Tests_UI_FORMS})
+  endif()
+  QT5_ADD_RESOURCES(Tests_RESOURCES_SRCS ${Tests_RESOURCES})
+else()
+  QT4_WRAP_CPP(Tests_MOC_CPP ${Tests_MOC_SRCS})
+  QT4_GENERATE_MOCS(
+    ctkCmdLineModuleFrontendQtGuiTest.cpp
+    ctkCmdLineModuleQtXslTransformTest.cpp
+    )
+  if(TEST_UI_FORMS)
+    QT4_WRAP_UI(Tests_UI_CPP ${Tests_UI_FORMS})
+  endif()
+  QT4_ADD_RESOURCES(Tests_RESOURCES_SRCS ${Tests_RESOURCES})
+endif()
 
 add_executable(${KIT}CppTests ${Tests} ${Tests_SRCS} ${Tests_MOC_CPP} ${Tests_UI_CPP} ${Tests_RESOURCES_SRCS})
 target_link_libraries(${KIT}CppTests ${LIBRARY_NAME} ${CTK_BASE_LIBRARIES})

+ 19 - 10
Libs/CommandLineModules/Testing/Cpp/CMakeLists.txt

@@ -68,18 +68,27 @@ if(CTK_LIB_CommandLineModules/Frontend/QtGui)
 endif()
 
 set(Tests_MOC_CPP)
-QT4_WRAP_CPP(Tests_MOC_CPP ${Tests_MOC_SRCS})
-
-if(_test_mocs)
-  QT4_GENERATE_MOCS(${_test_mocs})
-endif()
-
 set(Tests_UI_CPP)
-if(TEST_UI_FORMS)
-  QT4_WRAP_UI(Tests_UI_CPP ${Tests_UI_FORMS})
-endif()
 set(Tests_RESOURCES_SRCS)
-QT4_ADD_RESOURCES(Tests_RESOURCES_SRCS ${Tests_RESOURCES})
+if (CTK_QT_VERSION VERSION_GREATER "4")
+  QT5_WRAP_CPP(Tests_MOC_CPP ${Tests_MOC_SRCS})
+  if(_test_mocs)
+    QT5_GENERATE_MOCS(${_test_mocs})
+  endif()
+  if(TEST_UI_FORMS)
+    QT5_WRAP_UI(Tests_UI_CPP ${Tests_UI_FORMS})
+  endif()
+  QT5_ADD_RESOURCES(Tests_RESOURCES_SRCS ${Tests_RESOURCES})
+else()
+  QT4_WRAP_CPP(Tests_MOC_CPP ${Tests_MOC_SRCS})
+  if(_test_mocs)
+    QT4_GENERATE_MOCS(${_test_mocs})
+  endif()
+  if(TEST_UI_FORMS)
+    QT4_WRAP_UI(Tests_UI_CPP ${Tests_UI_FORMS})
+  endif()
+  QT4_ADD_RESOURCES(Tests_RESOURCES_SRCS ${Tests_RESOURCES})
+endif()
 
 add_executable(${KIT}CppTests ${Tests} ${Tests_SRCS} ${Tests_MOC_CPP} ${Tests_UI_CPP} ${Tests_RESOURCES_SRCS})
 target_link_libraries(${KIT}CppTests ${_additional_link_libraries})

+ 1 - 0
Libs/Core/CMakeLists.txt

@@ -99,6 +99,7 @@ set(KIT_MOC_SRCS
   ctkCommandLineParser.h
   ctkErrorLogFDMessageHandler_p.h
   ctkErrorLogModel.h
+  ctkErrorLogQtMessageHandler.h
   ctkLinearValueProxy.h
   ctkLogger.h
   ctkHistogram.h

+ 15 - 6
Libs/Core/Testing/Cpp/CMakeLists.txt

@@ -101,12 +101,21 @@ set(Tests_Helpers_MOC_SRCS
   )
 
 set(Tests_Helpers_MOC_CPP)
-QT4_WRAP_CPP(Tests_Helpers_MOC_CPP ${Tests_Helpers_MOC_SRCS})
-QT4_GENERATE_MOCS(
-  ctkBooleanMapperTest.cpp
-  ctkLinearValueProxyTest.cpp
-  ctkUtilsTest.cpp
-  )
+if(CTK_QT_VERSION VERSION_GREATER "4")
+  QT5_WRAP_CPP(Tests_Helpers_MOC_CPP ${Tests_Helpers_MOC_SRCS})
+  QT5_GENERATE_MOCS(
+    ctkBooleanMapperTest.cpp
+    ctkLinearValueProxyTest.cpp
+    ctkUtilsTest.cpp
+    )
+else()
+  QT4_WRAP_CPP(Tests_Helpers_MOC_CPP ${Tests_Helpers_MOC_SRCS})
+  QT4_GENERATE_MOCS(
+    ctkBooleanMapperTest.cpp
+    ctkLinearValueProxyTest.cpp
+    ctkUtilsTest.cpp
+    )
+endif()
 
 if(HAVE_BFD)
   add_executable(ctkBinaryFileDescriptorTestHelper ctkBinaryFileDescriptorTestHelper.cpp)

+ 1 - 1
Libs/Core/Testing/Cpp/ctkAbstractLibraryFactoryTest1.cpp

@@ -45,7 +45,7 @@ protected:
     QScopedPointer<ctkDummyLibrary> module(new ctkDummyLibrary());
     foreach(QString symbol, this->Symbols)
       {
-      void* res = this->symbolAddress(symbol);
+      SymbolAddressType res = this->symbolAddress(symbol);
       if (!res)
         {
         }

+ 13 - 4
Libs/Core/ctkAbstractLibraryFactory.h

@@ -34,9 +34,18 @@
 template<typename BaseClassType>
 class ctkFactoryLibraryItem : public ctkAbstractFactoryFileBasedItem<BaseClassType>
 {
+
+public:
+
+#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
+  typedef void* SymbolAddressType;
+#else
+  typedef QFunctionPointer SymbolAddressType;
+#endif
+
 protected:
-  typedef typename QHash<QString, void*>::const_iterator ConstIterator;
-  typedef typename QHash<QString, void*>::iterator       Iterator;
+  typedef typename QHash<QString, SymbolAddressType>::const_iterator ConstIterator;
+  typedef typename QHash<QString, SymbolAddressType>::iterator       Iterator;
 
 public:
   //explicit ctkFactoryLibraryItem(const QString& path);
@@ -55,11 +64,11 @@ public:
   
   /// 
   /// Get symbol address
-  void* symbolAddress(const QString& symbol)const;
+  SymbolAddressType symbolAddress(const QString& symbol)const;
 
 protected:
   mutable QLibrary      Library;
-  QHash<QString, void*> ResolvedSymbols;
+  QHash<QString, SymbolAddressType> ResolvedSymbols;
   QStringList           Symbols;
 };
 

+ 3 - 2
Libs/Core/ctkAbstractLibraryFactory.tpp

@@ -83,7 +83,7 @@ bool ctkFactoryLibraryItem<BaseClassType>::resolve()
       continue;
       }
 
-    void * resolvedSymbol = this->Library.resolve(symbol.toLatin1());
+    SymbolAddressType resolvedSymbol = this->Library.resolve(symbol.toLatin1());
     if (!resolvedSymbol)
       {
       this->appendLoadErrorString(QString("Failed to resolve mandatory symbol '%1'").arg(symbol));
@@ -96,7 +96,8 @@ bool ctkFactoryLibraryItem<BaseClassType>::resolve()
 
 //-----------------------------------------------------------------------------
 template<typename BaseClassType>
-void* ctkFactoryLibraryItem<BaseClassType>::symbolAddress(const QString& symbol)const
+typename ctkFactoryLibraryItem<BaseClassType>::SymbolAddressType
+ctkFactoryLibraryItem<BaseClassType>::symbolAddress(const QString& symbol)const
 {
   ConstIterator iter = this->ResolvedSymbols.find(symbol);
   if ( iter == this->ResolvedSymbols.constEnd())

+ 2 - 2
Libs/Core/ctkCheckableModelHelper.cpp

@@ -22,8 +22,8 @@
 #include <QAbstractItemModel>
 #include <QApplication>
 #include <QDebug>
+#include <QPointer>
 #include <QStandardItemModel>
-#include <QWeakPointer>
 
 // CTK includes
 #include "ctkCheckableModelHelper.h"
@@ -56,7 +56,7 @@ public:
 
   void forceCheckability(const QModelIndex& index);
 
-  QWeakPointer<QAbstractItemModel> Model;
+  QPointer<QAbstractItemModel> Model;
   QModelIndex         RootIndex;
   Qt::Orientation     Orientation;
   bool                HeaderIsUpdating;

+ 12 - 2
Libs/Core/ctkErrorLogQtMessageHandler.cpp

@@ -53,10 +53,12 @@ ctkErrorLogQtMessageHandler::ctkErrorLogQtMessageHandler() : Superclass()
 namespace
 {
 //------------------------------------------------------------------------------
-void ctkErrorLogModelQtMessageOutput(QtMsgType type, const char *msg)
+void ctkErrorLogModelQtMessageOutput(QtMsgType type,
+                                     const QMessageLogContext& context,
+                                     const QString& msg)
 {
   // Warning: To avoid inifinite loop, do not use Q_ASSERT in this function.
-  if (QString(msg).isEmpty())
+  if (msg.isEmpty())
     {
     return;
     }
@@ -107,10 +109,18 @@ void ctkErrorLogQtMessageHandler::setEnabledInternal(bool value)
 {
   if (value)
     {
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+    this->SavedQtMessageHandler = qInstallMessageHandler(ctkErrorLogModelQtMessageOutput);
+#else
     this->SavedQtMessageHandler = qInstallMsgHandler(ctkErrorLogModelQtMessageOutput);
+#endif
     }
   else
     {
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+    qInstallMessageHandler(this->SavedQtMessageHandler);
+#else
     qInstallMsgHandler(this->SavedQtMessageHandler);
+#endif
     }
 }

+ 5 - 0
Libs/Core/ctkErrorLogQtMessageHandler.h

@@ -29,6 +29,7 @@
 /// \ingroup Core
 class CTK_CORE_EXPORT ctkErrorLogQtMessageHandler : public ctkErrorLogAbstractMessageHandler
 {
+  Q_OBJECT
 public:
   typedef ctkErrorLogAbstractMessageHandler Superclass;
 
@@ -39,7 +40,11 @@ public:
   virtual QString handlerName()const;
   virtual void setEnabledInternal(bool value);
 
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+  QtMessageHandler SavedQtMessageHandler;
+#else
   QtMsgHandler SavedQtMessageHandler;
+#endif
 };
 
 #endif

+ 6 - 1
Libs/Core/target_libraries.cmake

@@ -5,6 +5,11 @@
 #
 
 set(target_libraries
-  QT_LIBRARIES
   BFD_LIBRARIES
   )
+
+if (CTK_QT_VERSION VERSION_GREATER "4")
+  list(APPEND target_libraries Qt5Core_LIBRARIES Qt5Widgets_LIBRARIES )
+else()
+  list(APPEND target_libraries QT_LIBRARIES)
+endif()

+ 1 - 1
Libs/DICOM/Core/ctkDICOMDatabase.cpp

@@ -1295,7 +1295,7 @@ void ctkDICOMDatabasePrivate::insert( const ctkDICOMItem& ctkDataset, const QStr
                 && (thumbnailInfo.lastModified() > QFileInfo(filename).lastModified())))
             {
               QDir(q->databaseDirectory() + "/thumbs/").mkpath(studySeriesDirectory);
-              DicomImage dcmImage(QDir::toNativeSeparators(filename).toAscii());
+              DicomImage dcmImage(QDir::toNativeSeparators(filename).toLatin1());
               thumbnailGenerator->generateThumbnail(&dcmImage, thumbnailPath);
             }
         }

+ 5 - 5
Libs/DICOM/Core/ctkDICOMItem.cpp

@@ -115,7 +115,7 @@ void ctkDICOMItem::InitializeFromFile(const QString& filename,
   DcmDataset *dataset;
 
   DcmFileFormat fileformat;
-  OFCondition status = fileformat.loadFile(filename.toAscii().data(), readXfer, groupLength, maxReadLength, readMode);
+  OFCondition status = fileformat.loadFile(filename.toLatin1().data(), readXfer, groupLength, maxReadLength, readMode);
   dataset = fileformat.getAndRemoveDataset();
 
   if (!status.good())
@@ -157,7 +157,7 @@ void ctkDICOMItem::Serialize()
   // construct Qt type from that contents
   QByteArray qtArray = QByteArray::fromRawData( static_cast<const char*>(readbuffer), datasetsize );
   //std::cerr << "** Buffer size: " << qtArray.size() << std::endl;
-  QString stringbuffer = QString::fromAscii(qtArray.toBase64());
+  QString stringbuffer = QString::fromLatin1(qtArray.toBase64());
 
   //std::cerr << "** String of size " << stringbuffer.size() << " looks like this:\n" << stringbuffer.toStdString() << std::endl << std::endl;
 
@@ -207,7 +207,7 @@ void ctkDICOMItem::Deserialize()
 
   //std::cerr << "** " << (void*)this << " ctkDICOMItem: Deserialize Dataset from string of size " << stringbuffer.size() << "\n" << stringbuffer.toStdString() << std::endl;
 
-  QByteArray qtArray = QByteArray::fromBase64( stringbuffer.toAscii() );
+  QByteArray qtArray = QByteArray::fromBase64( stringbuffer.toLatin1() );
   //std::cerr << "** " << (void*)this << " ctkDICOMItem: Deserialize Dataset from byte array of size " << qtArray.size() << std::endl;
 
   DcmInputBufferStream dcmbuffer;
@@ -390,11 +390,11 @@ QString ctkDICOMItem::Decode( const DcmTag& tag, const OFString& raw ) const
       QString encodingName( qtEncodingNamesForDICOMEncodingNames[d->m_SpecificCharacterSet] );
       if ( !decoders.contains( encodingName ) )
       {
-        QTextCodec* codec = QTextCodec::codecForName( encodingName.toAscii() );
+        QTextCodec* codec = QTextCodec::codecForName( encodingName.toLatin1() );
         if (!codec)
         {
           std::cerr << "Could not create QTextCodec object for '" << encodingName.toStdString() << "'. Using default encoding instead." << std::endl;
-          decoders.insert( encodingName, QTextCodec::codecForCStrings()->makeDecoder() ); // uses Latin1
+          decoders.insert( encodingName, QTextCodec::codecForName("UTF-8")->makeDecoder() ); // uses Latin1
         }
         else
         {

+ 5 - 5
Libs/DICOM/Core/ctkDICOMQuery.cpp

@@ -331,19 +331,19 @@ bool ctkDICOMQuery::query(ctkDICOMDatabase& database )
       {
       // make the filter a wildcard in dicom style
       d->Query->putAndInsertString( DCM_PatientName,
-        (QString("*") + d->Filters[key].toString() + QString("*")).toAscii().data());
+        (QString("*") + d->Filters[key].toString() + QString("*")).toLatin1().data());
       }
     else if ( key == QString("Study") && !d->Filters[key].toString().isEmpty())
       {
       // make the filter a wildcard in dicom style
       d->Query->putAndInsertString( DCM_StudyDescription,
-        (QString("*") + d->Filters[key].toString() + QString("*")).toAscii().data());
+        (QString("*") + d->Filters[key].toString() + QString("*")).toLatin1().data());
       }
     else if ( key == QString("ID") && !d->Filters[key].toString().isEmpty())
       {
       // make the filter a wildcard in dicom style
       d->Query->putAndInsertString( DCM_PatientID,
-        (QString("*") + d->Filters[key].toString() + QString("*")).toAscii().data());
+        (QString("*") + d->Filters[key].toString() + QString("*")).toLatin1().data());
       }
     else if ( key == QString("Modalities") && !d->Filters[key].toString().isEmpty())
       {
@@ -355,7 +355,7 @@ bool ctkDICOMQuery::query(ctkDICOMDatabase& database )
       }
       modalitySearch.chop(1); // remove final backslash
       logger.debug("modalityInStudySearch " + modalitySearch);
-      d->Query->putAndInsertString( DCM_ModalitiesInStudy, modalitySearch.toAscii().data() );
+      d->Query->putAndInsertString( DCM_ModalitiesInStudy, modalitySearch.toLatin1().data() );
       }
     // Rememer Series Description for later series query if we go through the keys now
     else if ( key == QString("Series") && !d->Filters[key].toString().isEmpty())
@@ -374,7 +374,7 @@ bool ctkDICOMQuery::query(ctkDICOMDatabase& database )
     QString dateRange = d->Filters["StartDate"].toString() +
                         QString("-") +
                         d->Filters["EndDate"].toString();
-    d->Query->putAndInsertString ( DCM_StudyDate, dateRange.toAscii().data() );
+    d->Query->putAndInsertString ( DCM_StudyDate, dateRange.toLatin1().data() );
     logger.debug("Query on study date " + dateRange);
     }
   emit progress(30);

+ 3 - 0
Libs/DICOM/Core/target_libraries.cmake

@@ -8,3 +8,6 @@ set(target_libraries
   CTKCore
   DCMTK_LIBRARIES
   )
+if (CTK_QT_VERSION VERSION_GREATER "4")
+  list(APPEND target_libraries Qt5Sql_LIBRARIES)
+endif()

+ 2 - 0
Libs/DICOM/Widgets/Plugins/ctkDICOMWidgetsPlugins.cpp

@@ -24,4 +24,6 @@
 // CTK includes
 #include "ctkDICOMWidgetsPlugins.h"
 
+#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
 Q_EXPORT_PLUGIN2(customwidgetplugin, ctkDICOMWidgetsPlugins);
+#endif

+ 3 - 0
Libs/DICOM/Widgets/Plugins/ctkDICOMWidgetsPlugins.h

@@ -34,6 +34,9 @@ class CTK_DICOM_WIDGETS_PLUGINS_EXPORT ctkDICOMWidgetsPlugins
   , public QDesignerCustomWidgetCollectionInterface
 {
   Q_OBJECT
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+  Q_PLUGIN_METADATA(IID "org.commontk.DICOM")
+#endif
   Q_INTERFACES(QDesignerCustomWidgetCollectionInterface);
 
 public:

+ 5 - 0
Libs/DICOM/Widgets/ctkDICOMServerNodeWidget.cpp

@@ -64,8 +64,13 @@ ctkDICOMServerNodeWidget::ctkDICOMServerNodeWidget(QWidget* parentWidget)
     NameColumn, Qt::Horizontal, static_cast<int>(Qt::Unchecked), Qt::CheckStateRole);
   QHeaderView* previousHeaderView = d->NodeTable->horizontalHeader();
   ctkCheckableHeaderView* headerView = new ctkCheckableHeaderView(Qt::Horizontal, d->NodeTable);
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+  headerView->setSectionsClickable(previousHeaderView->sectionsClickable());
+  headerView->setSectionsMovable(previousHeaderView->sectionsMovable());
+#else
   headerView->setClickable(previousHeaderView->isClickable());
   headerView->setMovable(previousHeaderView->isMovable());
+#endif
   headerView->setHighlightSections(previousHeaderView->highlightSections());
   headerView->checkableModelHelper()->setPropagateDepth(-1);
   d->NodeTable->setHorizontalHeader(headerView);

+ 7 - 2
Libs/PluginFramework/Documentation/Snippets/EventAdmin-Intro/files.cmake

@@ -8,6 +8,11 @@ set(_moc_files
 )
 
 foreach(_moc_file ${_moc_files})
-  QT4_WRAP_CPP(snippet_src_files EventAdmin-Intro/${_moc_file}
-               OPTIONS -f${CMAKE_CURRENT_SOURCE_DIR}/EventAdmin-Intro/${_moc_file})
+  if (CTK_QT_VERSION VERSION_GREATER "4")
+    QT4_WRAP_CPP(snippet_src_files EventAdmin-Intro/${_moc_file}
+      OPTIONS -f${CMAKE_CURRENT_SOURCE_DIR}/EventAdmin-Intro/${_moc_file})
+  else()
+    QT5_WRAP_CPP(snippet_src_files EventAdmin-Intro/${_moc_file}
+      OPTIONS -f${CMAKE_CURRENT_SOURCE_DIR}/EventAdmin-Intro/${_moc_file})
+  endif()
 endforeach()

+ 4 - 4
Libs/PluginFramework/Testing/org.commontk.pluginfwtest/ctkPluginFrameworkTestSuite.cpp

@@ -63,7 +63,7 @@ void ctkPluginFrameworkTestSuite::initTestCase()
   catch (const ctkException& e)
   {
     QString msg  = QString("plugin framework test suite ") + e.what() + ": SETUP:FAIL";
-    QFAIL(msg.toAscii());
+    QFAIL(msg.toLatin1());
   }
 
   try
@@ -77,7 +77,7 @@ void ctkPluginFrameworkTestSuite::initTestCase()
   catch (const ctkException& e)
   {
     QString msg  = QString("plugin framework test suite ") + e.what() + ": SETUP:FAIL";
-    QFAIL(msg.toAscii());
+    QFAIL(msg.toLatin1());
   }
 
   try
@@ -91,7 +91,7 @@ void ctkPluginFrameworkTestSuite::initTestCase()
   catch (const ctkException& e)
   {
     QString msg  = QString("plugin framework test suite ") + e.what() + ": SETUP:FAIL";
-    QFAIL(msg.toAscii());
+    QFAIL(msg.toLatin1());
   }
 
   try
@@ -101,7 +101,7 @@ void ctkPluginFrameworkTestSuite::initTestCase()
   catch (const ctkException& e)
   {
     QString msg  = QString("plugin framework test suite ") + e.what() + ": SETUP:FAIL";
-    QFAIL(msg.toAscii());
+    QFAIL(msg.toLatin1());
   }
 
   qDebug() << "### plugin framework test suite: SETUP:PASS";

+ 1 - 1
Libs/PluginFramework/Testing/org.commontk.pluginfwtest/ctkServiceTrackerTestSuite.cpp

@@ -64,7 +64,7 @@ void ctkServiceTrackerTestSuite::runTest()
   catch (const ctkPluginException& pexcS)
   {
     QString msg = QString("Test plugin: ") + pexcS.what();
-    QFAIL(msg.toAscii());
+    QFAIL(msg.toLatin1());
   }
 
   // 1. Create a ctkServiceTracker with ctkServiceTrackerCustomizer == null

+ 1 - 1
Libs/PluginFramework/ctkPluginFrameworkUtil.cpp

@@ -64,7 +64,7 @@ public:
       else
       {
         QChar c = s.at(pos);
-        switch (c.toAscii())
+        switch (c.toLatin1())
         {
         case '"':
           quote = !quote;

+ 1 - 1
Libs/PluginFramework/ctkServices.cpp

@@ -151,7 +151,7 @@ void ctkServices::updateServiceRegistrationOrder(const ctkServiceRegistration& s
 //----------------------------------------------------------------------------
 bool ctkServices::checkServiceClass(QObject* service, const QString& cls) const
 {
-  return service->inherits(cls.toAscii());
+  return service->inherits(cls.toLatin1());
 }
 
 //----------------------------------------------------------------------------

+ 4 - 2
Libs/Scripting/Python/Core/CMakeLists.txt

@@ -28,9 +28,11 @@ set(KIT_resources
 #
 # Configure file describing which Qt modules are wrapped
 #
-foreach(qtlib CORE GUI NETWORK OPENGL SQL SVG UITOOLS WEBKIT XML XMLPATTERNS)
+set(QT_PYTHON_WRAPPED_LIBRARIES_LIST Core Gui Widgets Network OpenGL Sql Svg UiTools WebKit WebKitWidgets Xml XmlPatterns)
+foreach(qtlib ${QT_PYTHON_WRAPPED_LIBRARIES_LIST})
+  string(TOUPPER ${qtlib} qtlib)
   set(CTK_PYTHONQT_WRAP_QT${qtlib} ${CTK_LIB_Scripting/Python/Core_PYTHONQT_WRAP_QT${qtlib}})
-  #message(CTK_LIB_Scripting/Python/Core_PYTHONQT_WRAP_QT${qtlib}:${CTK_LIB_Scripting/Python/Core_PYTHONQT_WRAP_QT${qtlib}})
+  message(CTK_LIB_Scripting/Python/Core_PYTHONQT_WRAP_QT${qtlib}:${CTK_LIB_Scripting/Python/Core_PYTHONQT_WRAP_QT${qtlib}})
 endforeach()
 
 configure_file(

+ 10 - 2
Libs/Scripting/Python/Core/Python/CMakeLists.txt

@@ -1,8 +1,16 @@
 
 
-set(KIT_PYTHON_SCRIPTS
-  qt/__init__
+set(KIT_PYTHON_SCRIPTS)
+
+string(REPLACE ";" "', '" QT_PYTHON_WRAPPED_LIBRARIES "${QT_PYTHON_WRAPPED_LIBRARIES_LIST}" )
+set(QT_PYTHON_WRAPPED_LIBRARIES "'${QT_PYTHON_WRAPPED_LIBRARIES}'")
+
+configure_file(
+  qt/__init__.py.in
+  ${CMAKE_CURRENT_BINARY_DIR}/qt/__init__.py
+  @ONLY
   )
+list(APPEND KIT_PYTHON_SCRIPTS ${CMAKE_CURRENT_BINARY_DIR}/qt/__init__.py)
 
 # If it applies, the variable CTK_PYTHON_WRAPPED_LIBRARIES will contain
 # the comma separated list of package to load

+ 2 - 13
Libs/Scripting/Python/Core/Python/qt/__init__.py

@@ -1,18 +1,7 @@
 """ This module loads all the classes from the wrapped Qt libraries into
 its namespace."""
 
-__kits_to_load = [
-'Core',
-'Gui', 
-'Network', 
-'OpenGL', 
-'Sql',
-'Svg',
-'UiTools',
-'WebKit',
-'Xml', 
-'XmlPatterns'
-]
+__kits_to_load = [ @QT_PYTHON_WRAPPED_LIBRARIES@ ]
 
 # Set to True when debugging
 _CTK_VERBOSE_IMPORT = False
@@ -23,6 +12,6 @@ for kit in __kits_to_load:
    except ImportError as detail:
      if _CTK_VERBOSE_IMPORT:
        print detail
-   
+
 # Removing things the user shouldn't have to see.
 del __kits_to_load, _CTK_VERBOSE_IMPORT

+ 9 - 3
Libs/Scripting/Python/Core/Testing/Cpp/CMakeLists.txt

@@ -13,9 +13,15 @@ set(LIBRARY_NAME ${PROJECT_NAME})
 include_directories(${CMAKE_SOURCE_DIR}/Libs/Testing
                     ${CMAKE_CURRENT_BINARY_DIR})
 
-QT4_GENERATE_MOCS(
-  ctkAbstractPythonManagerTest.cpp
-  )
+if (CTK_QT_VERSION VERSION_GREATER "4")
+  QT5_GENERATE_MOCS(
+    ctkAbstractPythonManagerTest.cpp
+    )
+else()
+  QT4_GENERATE_MOCS(
+    ctkAbstractPythonManagerTest.cpp
+    )
+endif()
 
 add_executable(${KIT}CppTests ${Tests})
 target_link_libraries(${KIT}CppTests ${LIBRARY_NAME} ${CTK_BASE_LIBRARIES})

+ 2 - 2
Libs/Scripting/Python/Core/ctkAbstractPythonManager.cpp

@@ -312,7 +312,7 @@ QStringList ctkAbstractPythonManager::pythonAttributes(const QString& pythonVari
   QStringList moduleList = module.split(".", QString::SkipEmptyParts);
   foreach(const QString& module, moduleList)
     {
-    object = PyDict_GetItemString(dict, module.toAscii().data());
+    object = PyDict_GetItemString(dict, module.toLatin1().data());
     if (prevObject) { Py_DECREF(prevObject); }
     if (!object)
       {
@@ -327,7 +327,7 @@ QStringList ctkAbstractPythonManager::pythonAttributes(const QString& pythonVari
     return QStringList();
     }
 
-//  PyObject* object = PyDict_GetItemString(dict, module.toAscii().data());
+//  PyObject* object = PyDict_GetItemString(dict, module.toLatin1().data());
 //  if (!object)
 //    {
 //    return QStringList();

+ 3 - 0
Libs/Scripting/Python/Core/ctkScriptingPythonCoreConfigure.h.in

@@ -9,12 +9,15 @@
 
 #cmakedefine CTK_PYTHONQT_WRAP_QTCORE
 #cmakedefine CTK_PYTHONQT_WRAP_QTGUI
+#cmakedefine CTK_PYTHONQT_WRAP_QTWIDGETS
 #cmakedefine CTK_PYTHONQT_WRAP_QTNETWORK
 #cmakedefine CTK_PYTHONQT_WRAP_QTOPENGL
+#cmakedefine CTK_PYTHONQT_WRAP_QTPRINTSUPPORT
 #cmakedefine CTK_PYTHONQT_WRAP_QTSQL
 #cmakedefine CTK_PYTHONQT_WRAP_QTSVG
 #cmakedefine CTK_PYTHONQT_WRAP_QTUITOOLS
 #cmakedefine CTK_PYTHONQT_WRAP_QTWEBKIT
+#cmakedefine CTK_PYTHONQT_WRAP_QTWEBKITWIDGETS
 #cmakedefine CTK_PYTHONQT_WRAP_QTXML
 #cmakedefine CTK_PYTHONQT_WRAP_QTXMLPATTERNS
 

+ 4 - 0
Libs/Scripting/Python/Core/ctk_library_options.cmake

@@ -10,11 +10,15 @@ set(ctk_library_options
   PYTHONQT_WRAP_QTALL:OFF
   PYTHONQT_WRAP_QTCORE:OFF
   PYTHONQT_WRAP_QTGUI:OFF
+  PYTHONQT_WRAP_QTWIDGETS:OFF
   PYTHONQT_WRAP_QTNETWORK:OFF
   PYTHONQT_WRAP_QTOPENGL:OFF
+  PYTHONQT_WRAP_QTPRINTSUPPORT:OFF
   PYTHONQT_WRAP_QTSQL:OFF
   PYTHONQT_WRAP_QTSVG:OFF
   PYTHONQT_WRAP_QTUITOOLS:OFF
   PYTHONQT_WRAP_QTWEBKIT:OFF
+  PYTHONQT_WRAP_QTWEBKITWIDGETS:OFF
   PYTHONQT_WRAP_QTXML:OFF
+  PYTHONQT_WRAP_QTXMLPATTERNS:OFF
   )

+ 2 - 0
Libs/Scripting/Python/Widgets/Plugins/ctkScriptingPythonWidgetsPlugins.cpp

@@ -24,4 +24,6 @@
 // CTK includes
 #include "ctkScriptingPythonWidgetsPlugins.h"
 
+#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
 Q_EXPORT_PLUGIN2(customwidgetplugin, ctkScriptingPythonWidgetsPlugins);
+#endif

+ 6 - 2
Libs/Scripting/Python/Widgets/Plugins/ctkScriptingPythonWidgetsPlugins.h

@@ -29,10 +29,14 @@
 #include "ctkPythonConsolePlugin.h"
 
 /// \class Group the plugins in one library
-class CTK_SCRIPTING_PYTHON_WIDGETS_PLUGINS_EXPORT ctkScriptingPythonWidgetsPlugins : 
-  public QObject, public QDesignerCustomWidgetCollectionInterface
+class CTK_SCRIPTING_PYTHON_WIDGETS_PLUGINS_EXPORT ctkScriptingPythonWidgetsPlugins
+  : public QObject
+  , public QDesignerCustomWidgetCollectionInterface
 {
   Q_OBJECT
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+  Q_PLUGIN_METADATA(IID "org.commontk.Python")
+#endif
   Q_INTERFACES(QDesignerCustomWidgetCollectionInterface);
 
 public:

+ 6 - 4
Libs/Scripting/Python/Widgets/ctkPythonConsole.cpp

@@ -49,7 +49,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 =========================================================================*/
 
 // Qt includes
+#include <QAbstractItemView>
 #include <QCoreApplication>
+#include <QIcon>
 #include <QResizeEvent>
 #include <QScrollBar>
 #include <QStringListModel>
@@ -268,7 +270,7 @@ bool ctkPythonConsolePrivate::push(const QString& code)
   PyObject *res = PyObject_CallMethod(this->InteractiveConsole,
                                       const_cast<char*>("push"),
                                       const_cast<char*>("z"),
-                                      buffer.toAscii().data());
+                                      buffer.toLatin1().data());
   if (res)
     {
     int status = 0;
@@ -381,7 +383,7 @@ void ctkPythonConsole::initialize(ctkAbstractPythonManager* newPythonManager)
 //  d->printOutputMessage("\n");
 //  emit this->executing(true);
 ////   d->Interpreter->RunSimpleString(
-////     script.toAscii().data());
+////     script.toLatin1().data());
 //  emit this->executing(false);
 //  d->promptForInput();
 //}
@@ -397,7 +399,7 @@ QString ctkPythonConsole::ps1() const
 //----------------------------------------------------------------------------
 void ctkPythonConsole::setPs1(const QString& newPs1)
 {
-  PySys_SetObject(const_cast<char*>("ps1"), PyString_FromString(newPs1.toAscii().data()));
+  PySys_SetObject(const_cast<char*>("ps1"), PyString_FromString(newPs1.toLatin1().data()));
 }
 
 //----------------------------------------------------------------------------
@@ -411,7 +413,7 @@ QString ctkPythonConsole::ps2() const
 //----------------------------------------------------------------------------
 void ctkPythonConsole::setPs2(const QString& newPs2)
 {
-  PySys_SetObject(const_cast<char*>("ps2"), PyString_FromString(newPs2.toAscii().data()));
+  PySys_SetObject(const_cast<char*>("ps2"), PyString_FromString(newPs2.toLatin1().data()));
 }
 
 //----------------------------------------------------------------------------

+ 1 - 1
Libs/Testing/ctkTest.h

@@ -94,7 +94,7 @@ static void mouseEvent(QTest::MouseAction action, QWidget *widget, Qt::MouseButt
     static const char *mouseActionNames[] =
         { "MousePress", "MouseRelease", "MouseClick", "MouseDClick", "MouseMove" };
     QString warning = QString::fromLatin1("Mouse event \"%1\" not accepted by receiving widget");
-    QTest::qWarn(warning.arg(QString::fromLatin1(mouseActionNames[static_cast<int>(action)])).toAscii().data());
+    QTest::qWarn(warning.arg(QString::fromLatin1(mouseActionNames[static_cast<int>(action)])).toLatin1().data());
     }
 }
 

+ 5 - 1
Libs/Visualization/VTK/Core/Testing/Cpp/CMakeLists.txt

@@ -42,7 +42,11 @@ set(KIT_HELPER_SRCS
   ctkVTKObjectTestHelper.cpp
   )
 
-QT4_WRAP_CPP(KIT_HELPER_SRCS ctkVTKObjectTestHelper.h)
+if(CTK_QT_VERSION VERSION_GREATER "4")
+  QT5_WRAP_CPP(KIT_HELPER_SRCS ctkVTKObjectTestHelper.h)
+else()
+  QT4_WRAP_CPP(KIT_HELPER_SRCS ctkVTKObjectTestHelper.h)
+endif()
 
 #
 # Tests

+ 2 - 0
Libs/Visualization/VTK/Widgets/Plugins/ctkVTKWidgetsPlugins.cpp

@@ -24,4 +24,6 @@
 // CTK includes
 #include "ctkVTKWidgetsPlugins.h"
 
+#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
 Q_EXPORT_PLUGIN2(customwidgetplugin, ctkVTKWidgetsPlugins);
+#endif

+ 6 - 3
Libs/Visualization/VTK/Widgets/Plugins/ctkVTKWidgetsPlugins.h

@@ -43,11 +43,14 @@
 #include "ctkVTKThresholdWidgetPlugin.h"
 
 /// \class Group the plugins in one library
-class CTK_VISUALIZATION_VTK_WIDGETS_PLUGINS_EXPORT ctkVTKWidgetsPlugins :
-  public QObject,
-  public QDesignerCustomWidgetCollectionInterface
+class CTK_VISUALIZATION_VTK_WIDGETS_PLUGINS_EXPORT ctkVTKWidgetsPlugins
+  : public QObject
+  , public QDesignerCustomWidgetCollectionInterface
 {
   Q_OBJECT
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+  Q_PLUGIN_METADATA(IID "org.commontk.VTKWidgets")
+#endif
   Q_INTERFACES(QDesignerCustomWidgetCollectionInterface);
 
 public:

+ 23 - 11
Libs/Visualization/VTK/Widgets/Testing/Cpp/CMakeLists.txt

@@ -94,19 +94,31 @@ if(CTK_USE_QTTESTING)
 endif()
 
 set(TEST_MOC_CPP)
-if(TEST_MOC_SOURCES)
-  QT4_WRAP_CPP(TEST_MOC_CPP ${TEST_MOC_SOURCES})
-endif()
-QT4_GENERATE_MOCS(
-  ctkVTKPropertyWidgetTest.cpp
-  )
-
 set(TEST_UI_CPP)
-if(TEST_UI_FORMS)
-  QT4_WRAP_UI(TEST_UI_CPP ${TEST_UI_FORMS})
-endif()
 set(Tests_RESOURCES_SRCS)
-QT4_ADD_RESOURCES(Tests_RESOURCES_SRCS ${Tests_RESOURCES})
+if(CTK_QT_VERSION VERSION_GREATER "4")
+  if(TEST_MOC_SOURCES)
+    QT5_WRAP_CPP(TEST_MOC_CPP ${TEST_MOC_SOURCES})
+  endif()
+  QT5_GENERATE_MOCS(
+    ctkVTKPropertyWidgetTest.cpp
+    )
+  if(TEST_UI_FORMS)
+    QT5_WRAP_UI(TEST_UI_CPP ${TEST_UI_FORMS})
+  endif()
+  QT5_ADD_RESOURCES(Tests_RESOURCES_SRCS ${Tests_RESOURCES})
+else()
+  if(TEST_MOC_SOURCES)
+    QT4_WRAP_CPP(TEST_MOC_CPP ${TEST_MOC_SOURCES})
+  endif()
+  QT4_GENERATE_MOCS(
+    ctkVTKPropertyWidgetTest.cpp
+    )
+  if(TEST_UI_FORMS)
+    QT4_WRAP_UI(TEST_UI_CPP ${TEST_UI_FORMS})
+  endif()
+  QT4_ADD_RESOURCES(Tests_RESOURCES_SRCS ${Tests_RESOURCES})
+endif()
 
 add_executable(${KIT}CppTests ${Tests} ${TEST_MOC_CPP} ${TEST_UI_CPP} ${Tests_RESOURCES_SRCS})
 target_link_libraries(${KIT}CppTests ${LIBRARY_NAME} vtkCharts ${CTK_BASE_LIBRARIES})

+ 5 - 1
Libs/Visualization/VTK/Widgets/ctkVTKMagnifyView.cpp

@@ -605,7 +605,7 @@ bool ctkVTKMagnifyView::eventFilter(QObject * obj, QEvent * event)
   Q_ASSERT(widget);
   Q_D(ctkVTKMagnifyView);
   Q_ASSERT(d->ObservedQVTKWidgets.contains(widget));
-  d->EventHandler.Widget = QWeakPointer<QVTKWidget>(widget);
+  d->EventHandler.Widget = widget;
 
   QEvent::Type eventType = event->type();
 
@@ -614,7 +614,11 @@ bool ctkVTKMagnifyView::eventFilter(QObject * obj, QEvent * event)
     {
     QMouseEvent * mouseEvent = static_cast<QMouseEvent *>(event);
     Q_ASSERT(mouseEvent);
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+    d->pushUpdatePixmapEvent(mouseEvent->localPos());
+#else
     d->pushUpdatePixmapEvent(mouseEvent->posF());
+#endif
     }
   // On enter, update the pixmap with the zoomed image (required for zooming when
   // widget is created with mouse already within it), and emit signal of enter event

+ 2 - 2
Libs/Visualization/VTK/Widgets/ctkVTKMagnifyView_p.h

@@ -22,7 +22,7 @@
 #define __ctkVTKMagnifyView_p_h
 
 // Qt includes
-#include <QObject>
+#include <QPointer>
 class QPointF;
 class QTimerEvent;
 
@@ -67,7 +67,7 @@ protected:
   struct EventHandlerStruct
     {
     PendingEventType EventType;
-    QWeakPointer<QVTKWidget> Widget;
+    QPointer<QVTKWidget> Widget;
     QPointF Position;
     int UpdateInterval;
     int TimerId;

+ 4 - 1
Libs/Visualization/VTK/Widgets/target_libraries.cmake

@@ -8,4 +8,7 @@ set(target_libraries
   VTK_LIBRARIES
   CTKWidgets
   CTKVisualizationVTKCore
-  )
+  )
+if (CTK_QT_VERSION VERSION_GREATER "4")
+  list(APPEND target_libraries Qt5Network_LIBRARIES Qt5WebKit_LIBRARIES)
+endif()

+ 11 - 4
Libs/Widgets/CMakeLists.txt

@@ -284,10 +284,17 @@ set(KIT_MOC_SRCS
   ctkWorkflowWidgetStep_p.h
   )
 
-QT4_GENERATE_MOCS(
-  ctkPathLineEdit.h
-  ctkPathListWidget.h
-)
+if(CTK_QT_VERSION VERSION_GREATER "4")
+  QT5_GENERATE_MOCS(
+    ctkPathLineEdit.h
+    ctkPathListWidget.h
+    )
+else()
+  QT4_GENERATE_MOCS(
+    ctkPathLineEdit.h
+    ctkPathListWidget.h
+    )
+endif()
 
 # UI files
 set(KIT_UI_FORMS

+ 2 - 0
Libs/Widgets/Plugins/ctkWidgetsPlugins.cpp

@@ -24,4 +24,6 @@
 // CTK includes
 #include "ctkWidgetsPlugins.h"
 
+#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
 Q_EXPORT_PLUGIN2(customwidgetplugin, ctkWidgetsPlugins);
+#endif

+ 6 - 3
Libs/Widgets/Plugins/ctkWidgetsPlugins.h

@@ -69,12 +69,15 @@
 #include "ctkWorkflowWidgetStepPlugin.h"
 
 /// \class Group the plugins in one library
-class CTK_WIDGETS_PLUGINS_EXPORT ctkWidgetsPlugins : public QObject,
-      public QDesignerCustomWidgetCollectionInterface
+class CTK_WIDGETS_PLUGINS_EXPORT ctkWidgetsPlugins
+  : public QObject
+  , public QDesignerCustomWidgetCollectionInterface
 {
   Q_OBJECT
   Q_INTERFACES(QDesignerCustomWidgetCollectionInterface);
-
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+  Q_PLUGIN_METADATA(IID "org.commontk.Widgets")
+#endif
 public:
   QList<QDesignerCustomWidgetInterface*> customWidgets() const
     {

+ 59 - 28
Libs/Widgets/Testing/Cpp/CMakeLists.txt

@@ -185,36 +185,67 @@ if(CTK_USE_QTTESTING)
 endif()
 
 set(Tests_MOC_CPP)
-QT4_WRAP_CPP(Tests_MOC_CPP ${Tests_MOC_SRCS})
-QT4_GENERATE_MOCS(
-  ctkCoordinatesWidgetTest.cpp
-  ctkCoordinatesWidgetValueProxyTest.cpp
-  ctkDoubleRangeSliderTest.cpp
-  ctkDoubleRangeSliderValueProxyTest.cpp
-  ctkDoubleSliderTest.cpp
-  ctkDoubleSliderValueProxyTest.cpp
-  ctkDoubleSpinBoxTest.cpp
-  ctkDoubleSpinBoxValueProxyTest.cpp
-  ctkFlatProxyModelTest.cpp
-  ctkFontButtonTest.cpp
-  ctkLanguageComboBoxTest.cpp
-  ctkMatrixWidgetTest.cpp
-  ctkMessageBoxDontShowAgainTest.cpp
-  ctkPathListWidgetTest.cpp
-  ctkPathListWidgetWithButtonsTest.cpp
-  ctkRangeSliderTest.cpp
-  ctkRangeWidgetTest.cpp
-  ctkRangeWidgetValueProxyTest.cpp
-  ctkSettingsPanelTest.cpp
-  ctkSliderWidgetTest.cpp
-  ctkSliderWidgetValueProxyTest.cpp
-  )
 set(Tests_UI_CPP)
-if(TEST_UI_FORMS)
-  QT4_WRAP_UI(Tests_UI_CPP ${Tests_UI_FORMS})
-endif()
 set(Tests_RESOURCES_SRCS)
-QT4_ADD_RESOURCES(Tests_RESOURCES_SRCS ${Tests_RESOURCES})
+if(CTK_QT_VERSION VERSION_GREATER "4")
+  QT5_WRAP_CPP(Tests_MOC_CPP ${Tests_MOC_SRCS})
+  QT5_GENERATE_MOCS(
+    ctkCoordinatesWidgetTest.cpp
+    ctkCoordinatesWidgetValueProxyTest.cpp
+    ctkDoubleRangeSliderTest.cpp
+    ctkDoubleRangeSliderValueProxyTest.cpp
+    ctkDoubleSliderTest.cpp
+    ctkDoubleSliderValueProxyTest.cpp
+    ctkDoubleSpinBoxTest.cpp
+    ctkDoubleSpinBoxValueProxyTest.cpp
+    ctkFlatProxyModelTest.cpp
+    ctkFontButtonTest.cpp
+    ctkLanguageComboBoxTest.cpp
+    ctkMatrixWidgetTest.cpp
+    ctkMessageBoxDontShowAgainTest.cpp
+    ctkPathListWidgetTest.cpp
+    ctkPathListWidgetWithButtonsTest.cpp
+    ctkRangeSliderTest.cpp
+    ctkRangeWidgetTest.cpp
+    ctkRangeWidgetValueProxyTest.cpp
+    ctkSettingsPanelTest.cpp
+    ctkSliderWidgetTest.cpp
+    ctkSliderWidgetValueProxyTest.cpp
+    )
+  if(TEST_UI_FORMS)
+    QT5_WRAP_UI(Tests_UI_CPP ${Tests_UI_FORMS})
+  endif()
+  QT5_ADD_RESOURCES(Tests_RESOURCES_SRCS ${Tests_RESOURCES})
+else()
+  QT4_WRAP_CPP(Tests_MOC_CPP ${Tests_MOC_SRCS})
+  QT4_GENERATE_MOCS(
+    ctkCoordinatesWidgetTest.cpp
+    ctkCoordinatesWidgetValueProxyTest.cpp
+    ctkDoubleRangeSliderTest.cpp
+    ctkDoubleRangeSliderValueProxyTest.cpp
+    ctkDoubleSliderTest.cpp
+    ctkDoubleSliderValueProxyTest.cpp
+    ctkDoubleSpinBoxTest.cpp
+    ctkDoubleSpinBoxValueProxyTest.cpp
+    ctkFlatProxyModelTest.cpp
+    ctkFontButtonTest.cpp
+    ctkLanguageComboBoxTest.cpp
+    ctkMatrixWidgetTest.cpp
+    ctkMessageBoxDontShowAgainTest.cpp
+    ctkPathListWidgetTest.cpp
+    ctkPathListWidgetWithButtonsTest.cpp
+    ctkRangeSliderTest.cpp
+    ctkRangeWidgetTest.cpp
+    ctkRangeWidgetValueProxyTest.cpp
+    ctkSettingsPanelTest.cpp
+    ctkSliderWidgetTest.cpp
+    ctkSliderWidgetValueProxyTest.cpp
+    )
+  if(TEST_UI_FORMS)
+    QT4_WRAP_UI(Tests_UI_CPP ${Tests_UI_FORMS})
+  endif()
+  QT4_ADD_RESOURCES(Tests_RESOURCES_SRCS ${Tests_RESOURCES})
+endif()
 
 add_executable(${KIT}CppTests ${Tests} ${Tests_SRCS} ${Tests_MOC_CPP} ${Tests_UI_CPP} ${Tests_RESOURCES_SRCS})
 target_link_libraries(${KIT}CppTests ${LIBRARY_NAME})

+ 9 - 10
Libs/Widgets/ctkBasePopupWidget.cpp

@@ -79,7 +79,6 @@ QGradient* duplicateGradient(const QGradient* gradient)
 ctkBasePopupWidgetPrivate::ctkBasePopupWidgetPrivate(ctkBasePopupWidget& object)
   :q_ptr(&object)
 {
-  this->BaseWidget = 0;
   this->Effect = ctkBasePopupWidget::ScrollEffect;
   this->EffectDuration = 333; // in ms
   this->EffectAlpha = 1.;
@@ -167,7 +166,7 @@ QWidgetList ctkBasePopupWidgetPrivate::focusWidgets(bool onlyVisible)const
     {
     res << const_cast<ctkBasePopupWidget*>(q);
     }
-  if (this->BaseWidget && (!onlyVisible || this->BaseWidget->isVisible()))
+  if (!this->BaseWidget.isNull() && (!onlyVisible || this->BaseWidget->isVisible()))
     {
     res << this->BaseWidget;
     }
@@ -238,7 +237,7 @@ void ctkBasePopupWidgetPrivate::setupPopupPixmapWidget()
     }
   else
     {
-    pixmap = QPixmap::grabWidget(q, QRect(QPoint(0,0), q->geometry().size()));
+    pixmap = q->grab(QRect(QPoint(0,0), q->geometry().size()));
     }
   this->PopupPixmapWidget->setPixmap(pixmap);
   this->PopupPixmapWidget->setAttribute(
@@ -302,7 +301,7 @@ QRect ctkBasePopupWidgetPrivate::closedGeometry(QRect openGeom)const
 // -------------------------------------------------------------------------
 QRect ctkBasePopupWidgetPrivate::baseGeometry()const
 {
-  if (!this->BaseWidget)
+  if (this->BaseWidget.isNull())
     {
     return QRect();
     }
@@ -314,7 +313,7 @@ QRect ctkBasePopupWidgetPrivate::baseGeometry()const
 QPoint ctkBasePopupWidgetPrivate::mapToGlobal(const QPoint& baseWidgetPoint)const
 {
   QPoint mappedPoint = baseWidgetPoint;
-  if (this->BaseWidget && this->BaseWidget->parentWidget())
+  if (!this->BaseWidget.isNull() && this->BaseWidget->parentWidget())
     {
     mappedPoint = this->BaseWidget->parentWidget()->mapToGlobal(mappedPoint);
     }
@@ -437,7 +436,7 @@ void ctkBasePopupWidgetPrivate::hideAll()
   // Before hiding, transfer the active window flag to its parent, this will
   // prevent the application to send a ApplicationDeactivate signal that
   // doesn't need to be done.
-  if (q->isActiveWindow() && this->BaseWidget)
+  if (q->isActiveWindow() && !this->BaseWidget.isNull())
     {
     qApp->setActiveWindow(this->BaseWidget->window());
     }
@@ -493,13 +492,13 @@ QWidget* ctkBasePopupWidget::baseWidget()const
 void ctkBasePopupWidget::setBaseWidget(QWidget* widget)
 {
   Q_D(ctkBasePopupWidget);
-  if (d->BaseWidget)
+  if (!d->BaseWidget.isNull())
     {
     //disconnect(d->BaseWidget, SIGNAL(destroyed(QObject*)),
     //           this, SLOT(onBaseWidgetDestroyed()));
     }
   d->BaseWidget = widget;
-  if (d->BaseWidget)
+  if (!d->BaseWidget.isNull())
     {
     //connect(d->BaseWidget, SIGNAL(destroyed(QObject*)),
     //        this, SLOT(onBaseWidgetDestroyed()));
@@ -698,7 +697,7 @@ void ctkBasePopupWidget::showPopup()
   
   if ((this->isVisible() &&
        d->currentAnimation()->state() == QAbstractAnimation::Stopped) ||
-      (d->BaseWidget && !d->BaseWidget->isVisible()))
+      (!d->BaseWidget.isNull() && !d->BaseWidget->isVisible()))
     {
     return;
     }
@@ -786,7 +785,7 @@ void ctkBasePopupWidget::hidePopup()
       d->PopupPixmapWidget->show();
       if (this->isActiveWindow())
         {
-        qApp->setActiveWindow(d->BaseWidget ? d->BaseWidget->window() : 0);
+        qApp->setActiveWindow(!d->BaseWidget.isNull() ? d->BaseWidget->window() : 0);
         }
       this->hide();
       break;

+ 3 - 2
Libs/Widgets/ctkBasePopupWidget_p.h

@@ -22,8 +22,9 @@
 #define __ctkBasePopupWidget_p_h
 
 // Qt includes
-class QPropertyAnimation;
+#include <QPointer>
 class QLabel;
+class QPropertyAnimation;
 
 // CTK includes
 #include "ctkBasePopupWidget.h"
@@ -84,7 +85,7 @@ public:
   void hideAll();
 
 protected:
-  QWidget* BaseWidget;
+  QPointer<QWidget> BaseWidget;
 
   double EffectAlpha;
 

+ 1 - 2
Libs/Widgets/ctkButtonGroup.cpp

@@ -18,10 +18,9 @@
 
 =========================================================================*/
 
-//Qt includes  
+//Qt includes
 #include <QAbstractButton>
 #include <QDebug>
-#include <QWeakPointer>
 
 // CTK includes
 #include "ctkButtonGroup.h"

+ 0 - 1
Libs/Widgets/ctkCheckableComboBox.cpp

@@ -21,7 +21,6 @@
 // Qt includes
 #include <QApplication>
 #include <QAbstractItemView>
-#include <QCleanlooksStyle>
 #include <QDebug>
 #include <QDesktopWidget>
 #include <QItemDelegate>

+ 2 - 2
Libs/Widgets/ctkCheckableHeaderView.cpp

@@ -406,7 +406,7 @@ void ctkCheckableHeaderView::initStyleSectionOption(QStyleOptionHeader *option,
     }
   QVariant foregroundBrush = this->model()->headerData(section, this->orientation(),
                                                   Qt::ForegroundRole);
-  if (qVariantCanConvert<QBrush>(foregroundBrush))
+  if (foregroundBrush.canConvert<QBrush>())
     {
     option->palette.setBrush(QPalette::ButtonText, qvariant_cast<QBrush>(foregroundBrush));
     }
@@ -414,7 +414,7 @@ void ctkCheckableHeaderView::initStyleSectionOption(QStyleOptionHeader *option,
   //QPointF oldBO = painter->brushOrigin();
   QVariant backgroundBrush = this->model()->headerData(section, this->orientation(),
                                                   Qt::BackgroundRole);
-  if (qVariantCanConvert<QBrush>(backgroundBrush)) 
+  if (backgroundBrush.canConvert<QBrush>())
     {
     option->palette.setBrush(QPalette::Button, qvariant_cast<QBrush>(backgroundBrush));
     option->palette.setBrush(QPalette::Window, qvariant_cast<QBrush>(backgroundBrush));

+ 0 - 1
Libs/Widgets/ctkCheckablePushButton.cpp

@@ -20,7 +20,6 @@
 
 // Qt includes
 #include <QApplication>
-#include <QCleanlooksStyle>
 #include <QDebug>
 #include <QDesktopWidget>
 #include <QLayout>

+ 5 - 1
Libs/Widgets/ctkCollapsibleButton.cpp

@@ -20,7 +20,9 @@
 
 // Qt includes
 #include <QApplication>
-#include <QCleanlooksStyle>
+#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
+# include <QCleanlooksStyle>
+#endif
 #include <QDebug>
 #include <QLayout>
 #include <QMouseEvent>
@@ -628,11 +630,13 @@ void ctkCollapsibleButton::paintEvent(QPaintEvent * _event)
   fopt.init(this);
   // HACK: on some styles, the frame doesn't exactly touch the button.
   // this is because the button has some kind of extra border.
+#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
   if (qobject_cast<QCleanlooksStyle*>(this->style()) != 0)
     {
     fopt.rect.setTop(buttonHeight - 1);
     }
   else
+#endif
     {
     fopt.rect.setTop(buttonHeight);
     }

+ 1 - 0
Libs/Widgets/ctkConsole.cpp

@@ -54,6 +54,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include <QClipboard>
 #include <QCompleter>
 #include <QKeyEvent>
+#include <QMimeData>
 #include <QPointer>
 #include <QTextCursor>
 #include <QVBoxLayout>

+ 2 - 2
Libs/Widgets/ctkCoordinatesWidget.h

@@ -22,8 +22,8 @@
 #define __ctkCoordinatesWidget_h
 
 // Qt includes
+#include <QPointer>
 #include <QWidget>
-#include <QWeakPointer>
 
 // CTK includes
 #include "ctkDoubleSpinBox.h"
@@ -197,7 +197,7 @@ protected:
   double* Coordinates;
   QList<int> LastUserEditedCoordinates;
   bool    ChangingDecimals;
-  QWeakPointer<ctkValueProxy> Proxy;
+  QPointer<ctkValueProxy> Proxy;
 };
 
 #endif

+ 2 - 2
Libs/Widgets/ctkDoubleRangeSlider.cpp

@@ -21,8 +21,8 @@
 // Qt includes
 #include <QDebug>
 #include <QHBoxLayout>
+#include <QPointer>
 #include <QVariant>
-#include <QWeakPointer>
 
 // CTK includes
 #include "ctkRangeSlider.h"
@@ -65,7 +65,7 @@ public:
   double MinValue;
   double MaxValue;
 
-  QWeakPointer<ctkValueProxy> Proxy;
+  QPointer<ctkValueProxy> Proxy;
 
 private:
   Q_DISABLE_COPY(ctkDoubleRangeSliderPrivate);

+ 2 - 1
Libs/Widgets/ctkDoubleSlider.cpp

@@ -22,6 +22,7 @@
 #include <QDebug>
 #include <QHBoxLayout>
 #include <QHelpEvent>
+#include <QPointer>
 #include <QStyle>
 #include <QStyleOptionSlider>
 #include <QToolTip>
@@ -77,7 +78,7 @@ public:
   double      PageStep;
   double      Value;
   /// Converts input value with displayed value
-  QWeakPointer<ctkValueProxy> Proxy;
+  QPointer<ctkValueProxy> Proxy;
 };
 
 // --------------------------------------------------------------------------

+ 2 - 2
Libs/Widgets/ctkDoubleSpinBox_p.h

@@ -23,7 +23,7 @@
 
 // Qt includes
 #include <QDoubleSpinBox>
-#include <QWeakPointer>
+#include <QPointer>
 class ctkDoubleSpinBoxPrivate;
 class ctkValueProxy;
 
@@ -100,7 +100,7 @@ public:
   mutable QSize CachedSizeHint;
   bool ForceInputValueUpdate;
 
-  QWeakPointer<ctkValueProxy> Proxy;
+  QPointer<ctkValueProxy> Proxy;
 
   void init();
   /// Compare two double previously rounded according to the number of decimals

+ 9 - 1
Libs/Widgets/ctkIconEnginePlugin.cpp

@@ -35,7 +35,11 @@ public:
 
 //------------------------------------------------------------------------------
 ctkIconEnginePlugin::ctkIconEnginePlugin(QObject* parentObject)
- :QIconEnginePluginV2(parentObject)
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+  : QIconEnginePlugin(parentObject)
+#else
+  : QIconEnginePluginV2(parentObject)
+#endif
   , d_ptr(new ctkIconEnginePluginPrivate)
 {
 }
@@ -46,7 +50,11 @@ ctkIconEnginePlugin::~ctkIconEnginePlugin()
 }
 
 //------------------------------------------------------------------------------
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+QIconEngine* ctkIconEnginePlugin::create(const QString& fileName)
+#else
 QIconEngineV2* ctkIconEnginePlugin::create(const QString& fileName)
+#endif
 {
   Q_D(ctkIconEnginePlugin);
   Q_UNUSED(fileName);

+ 18 - 4
Libs/Widgets/ctkIconEnginePlugin.h

@@ -21,14 +21,19 @@
 #ifndef __ctkIconEnginePlugin_h
 #define __ctkIconEnginePlugin_h
 
+#include "ctkWidgetsExport.h"
 // Qt includes
-#include <QIconEngineV2>
-#include <QIconEnginePluginV2>
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+# include <QIconEngine>
+# include <QIconEnginePlugin>
+#else
+# include <QIconEngineV2>
+# include <QIconEnginePluginV2>
+#endif
 
 // CTK includes
 #include "ctkPimpl.h"
 #include "ctkPixmapIconEngine.h"
-#include "ctkWidgetsExport.h"
 
 class ctkIconEnginePluginPrivate;
 class ctkIconEnginePrivate;
@@ -42,14 +47,23 @@ class ctkIconEnginePrivate;
 /// where the plugin must be located in "MyApp-build/plugins/iconengines"
 /// don't forget to declare in the cpp file:
 ///   Q_EXPORT_PLUGIN2(yourpluginName, ctkIconEnginePlugin)
-class CTK_WIDGETS_EXPORT ctkIconEnginePlugin: public QIconEnginePluginV2
+class CTK_WIDGETS_EXPORT ctkIconEnginePlugin
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+  : public QIconEnginePlugin
+#else
+  : public QIconEnginePluginV2
+#endif
 {
   Q_OBJECT;
 public:
   ctkIconEnginePlugin(QObject* parent = 0);
   virtual ~ctkIconEnginePlugin();
 
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+  virtual QIconEngine* create(const QString& filename=QString());
+#else
   virtual QIconEngineV2* create(const QString& filename=QString());
+#endif
   /// Support all the Qt image formats by default
   virtual QStringList keys()const;
 

+ 9 - 5
Libs/Widgets/ctkMaterialPropertyPreviewLabel.cpp

@@ -295,16 +295,20 @@ void ctkMaterialPropertyPreviewLabel::draw(QImage& image)
         ref.setZ( 2.*normal.z()*dot - light.z());
         ref.normalize();
 
-        qreal diffuseComp = qMax(diffuse * dot, 0.);
+        const qreal zero = 0.;
+        const qreal one = 1.;
+
+        qreal diffuseComp = qMax(diffuse * dot, zero);
         
-        qreal specularDot = qMax(QVector3D::dotProduct(ref, view), 0.);
+        dot = QVector3D::dotProduct(ref, view);
+        qreal specularDot = qMax(dot, zero);
         
         qreal specularComp = specular*pow(specularDot, specular_power);
         
         QVector3D intensity;
-        intensity.setX( qMin((ambient + diffuseComp)*d->Color.redF() + specularComp, 1.));
-        intensity.setY( qMin((ambient + diffuseComp)*d->Color.greenF() + specularComp, 1.));
-        intensity.setZ( qMin((ambient + diffuseComp)*d->Color.blueF() + specularComp, 1.));
+        intensity.setX( qMin((ambient + diffuseComp)*d->Color.redF() + specularComp, one));
+        intensity.setY( qMin((ambient + diffuseComp)*d->Color.greenF() + specularComp, one));
+        intensity.setZ( qMin((ambient + diffuseComp)*d->Color.blueF() + specularComp, one));
         
         if (opacity == 1.)
           {

+ 0 - 1
Libs/Widgets/ctkMenuButton.cpp

@@ -20,7 +20,6 @@
 
 // Qt includes
 #include <QApplication>
-#include <QCleanlooksStyle>
 #include <QDebug>
 #include <QDesktopWidget>
 #include <QLayout>

+ 1 - 0
Libs/Widgets/ctkMenuComboBox.cpp

@@ -19,6 +19,7 @@
 =========================================================================*/
 
 // Qt includes
+#include <QAbstractItemView>
 #include <QActionEvent>
 #include <QCompleter>
 #include <QDebug>

+ 3 - 3
Libs/Widgets/ctkMenuComboBox_p.h

@@ -23,7 +23,7 @@
 
 // Qt includes
 #include <QComboBox>
-#include <QWeakPointer>
+#include <QPointer>
 
 // CTK includes
 #include "ctkMenuComboBox.h"
@@ -46,7 +46,7 @@ public:
 Q_SIGNALS:
   void popupShown();
 public:
-  QWeakPointer<QMenu>  Menu;
+  QPointer<QMenu>  Menu;
 };
 
 // -------------------------------------------------------------------------
@@ -86,7 +86,7 @@ protected:
 
   ctkMenuComboBoxInternal*    MenuComboBox;
   ctkCompleter*               SearchCompleter;
-  QWeakPointer<QMenu>         Menu;
+  QPointer<QMenu>             Menu;
   QToolButton*                SearchButton;
 };
 

+ 22 - 3
Libs/Widgets/ctkPixmapIconEngine.cpp

@@ -33,7 +33,12 @@ ctkPixmapIconEngine::ctkPixmapIconEngine()
 }
 
 ctkPixmapIconEngine::ctkPixmapIconEngine(const ctkPixmapIconEngine &other)
-    : QIconEngineV2(other), pixmaps(other.pixmaps)
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+  : QIconEngine(other)
+#else
+  : QIconEngineV2(other)
+#endif
+  , pixmaps(other.pixmaps)
 {
 }
 
@@ -271,7 +276,11 @@ QString ctkPixmapIconEngine::key() const
     return QLatin1String("ctkPixmapIconEngine");
 }
 
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+QIconEngine *ctkPixmapIconEngine::clone() const
+#else
 QIconEngineV2 *ctkPixmapIconEngine::clone() const
+#endif
 {
     return new ctkPixmapIconEngine(*this);
 }
@@ -326,10 +335,16 @@ bool ctkPixmapIconEngine::write(QDataStream &out) const
 
 void ctkPixmapIconEngine::virtual_hook(int id, void *data)
 {
-    switch (id) {
+  switch (id) {
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+    case QIconEngine::AvailableSizesHook: {
+        QIconEngine::AvailableSizesArgument &arg =
+            *reinterpret_cast<QIconEngine::AvailableSizesArgument*>(data);
+#else
     case QIconEngineV2::AvailableSizesHook: {
         QIconEngineV2::AvailableSizesArgument &arg =
             *reinterpret_cast<QIconEngineV2::AvailableSizesArgument*>(data);
+#endif
         arg.sizes.clear();
         for (int i = 0; i < pixmaps.size(); ++i) {
             ctkPixmapIconEngineEntry &pe = pixmaps[i];
@@ -343,6 +358,10 @@ void ctkPixmapIconEngine::virtual_hook(int id, void *data)
         break;
     }
     default:
-        QIconEngineV2::virtual_hook(id, data);
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+      QIconEngine::virtual_hook(id, data);
+#else
+      QIconEngineV2::virtual_hook(id, data);
+#endif
     }
 }

+ 11 - 1
Libs/Widgets/ctkPixmapIconEngine.h

@@ -45,7 +45,13 @@ struct ctkPixmapIconEngineEntry
 };
 
 /// \ingroup Widgets
-class CTK_WIDGETS_EXPORT ctkPixmapIconEngine : public QIconEngineV2 {
+class CTK_WIDGETS_EXPORT ctkPixmapIconEngine
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+  : public QIconEngine
+#else
+  : public QIconEngineV2
+#endif
+{
 public:
     ctkPixmapIconEngine();
     ctkPixmapIconEngine(const ctkPixmapIconEngine &);
@@ -59,7 +65,11 @@ public:
 
     // v2 functions
     QString key() const;
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+    QIconEngine *clone() const;
+#else
     QIconEngineV2 *clone() const;
+#endif
     bool read(QDataStream &in);
     bool write(QDataStream &out) const;
     void virtual_hook(int id, void *data);

+ 13 - 9
Libs/Widgets/ctkPopupWidget.cpp

@@ -80,6 +80,10 @@ bool ctkPopupWidgetPrivate::eventFilter(QObject* obj, QEvent* event)
 {
   Q_Q(ctkPopupWidget);
   QWidget* widget = qobject_cast<QWidget*>(obj);
+  if (!widget)
+    {
+    return this->Superclass::eventFilter(obj, event);
+    }
   // Here are the application events, it's a lot of events, so we need to be
   // careful to be fast.
   if (event->type() == QEvent::ApplicationDeactivate)
@@ -91,7 +95,7 @@ bool ctkPopupWidgetPrivate::eventFilter(QObject* obj, QEvent* event)
     {
     QTimer::singleShot(0, this, SLOT(updateVisibility()));
     }
-  if (!this->BaseWidget)
+  if (this->BaseWidget.isNull())
     {
     return false;
     }
@@ -159,7 +163,7 @@ void ctkPopupWidgetPrivate::updateVisibility()
   Q_Q(ctkPopupWidget);
   // If the BaseWidget window is active, then there is no reason to cover the
   // popup.
-  if (!this->BaseWidget  ||
+  if (this->BaseWidget.isNull()  ||
       // the popupwidget active window is not active
       (!this->BaseWidget->window()->isActiveWindow() &&
       // and no other active window
@@ -179,7 +183,7 @@ void ctkPopupWidgetPrivate::updateVisibility()
           !(topLevelWidget->windowState() & Qt::WindowMinimized) &&
           topLevelWidget->windowType() != Qt::ToolTip &&
           topLevelWidget->windowType() != Qt::Popup &&
-          topLevelWidget != (this->BaseWidget ? this->BaseWidget->window() : 0) &&
+          topLevelWidget != (!this->BaseWidget.isNull() ? this->BaseWidget->window() : 0) &&
           topLevelWidget->frameGeometry().intersects(q->geometry()))
         {
         //qDebug() << "hide" << q << "because of: " << topLevelWidget
@@ -194,7 +198,7 @@ void ctkPopupWidgetPrivate::updateVisibility()
     }
   // If the base widget is hidden or minimized, we don't want to restore the
   // popup.
-  if (this->BaseWidget &&
+  if (!this->BaseWidget.isNull() &&
       (!this->BaseWidget->isVisible() ||
         this->BaseWidget->window()->windowState() & Qt::WindowMinimized))
     {
@@ -273,7 +277,7 @@ void ctkPopupWidget::setActive(bool active)
   d->Active = active;
   if (d->Active)
     {
-    if (d->BaseWidget)
+    if (!d->BaseWidget.isNull())
       {
       d->BaseWidget->installEventFilter(this);
       }
@@ -285,7 +289,7 @@ void ctkPopupWidget::setActive(bool active)
     }
   else // not active
     {
-    if (d->BaseWidget)
+    if (!d->BaseWidget.isNull())
       {
       d->BaseWidget->removeEventFilter(this);
       }
@@ -301,12 +305,12 @@ void ctkPopupWidget::setActive(bool active)
 void ctkPopupWidget::setBaseWidget(QWidget* widget)
 {
   Q_D(ctkPopupWidget);
-  if (d->BaseWidget)
+  if (!d->BaseWidget.isNull())
     {
     d->BaseWidget->removeEventFilter(this);
     }
   this->Superclass::setBaseWidget(widget);
-  if (d->BaseWidget && d->Active)
+  if (!d->BaseWidget.isNull() && d->Active)
     {
     d->BaseWidget->installEventFilter(this);
     }
@@ -513,7 +517,7 @@ void ctkPopupWidget::updatePopup()
      // to be automatically open, the mouse has to be over a child widget
       mouseOver &&
      // disable opening the popup when the popup is disabled
-      (!d->BaseWidget || d->BaseWidget->isEnabled()))
+      (d->BaseWidget.isNull() || d->BaseWidget->isEnabled()))
     {
     this->showPopup();
     }

+ 2 - 2
Libs/Widgets/ctkRangeWidget.cpp

@@ -21,7 +21,7 @@
 // Qt includes
 #include <QDebug>
 #include <QMouseEvent>
-#include <QWeakPointer>
+#include <QPointer>
 
 // CTK includes
 #include "ctkRangeWidget.h"
@@ -56,7 +56,7 @@ public:
   double        MaximumValueBeforeChange;
   bool          AutoSpinBoxWidth;
   Qt::Alignment SpinBoxAlignment;
-  QWeakPointer<ctkValueProxy> Proxy;
+  QPointer<ctkValueProxy> Proxy;
 };
 
 // --------------------------------------------------------------------------

+ 2 - 1
Libs/Widgets/ctkScreenshotDialog_p.h

@@ -22,6 +22,7 @@
 #define __ctkScreenshotDialog_p_h
 
 // Qt includes
+#include <QPointer>
 #include <QTimer>
 
 // CTK includes
@@ -72,7 +73,7 @@ public Q_SLOTS:
   void onHeightEdited();
 
 public:
-  QWeakPointer<QWidget> WidgetToGrab;
+  QPointer<QWidget>     WidgetToGrab;
   QPushButton*          CaptureButton;
   int                   CountDownValue;
   QTimer                CountDownTimer;

+ 3 - 3
Libs/Widgets/ctkSliderWidget.cpp

@@ -21,7 +21,7 @@
 // Qt includes
 #include <QDebug>
 #include <QMouseEvent>
-#include <QWeakPointer>
+#include <QPointer>
 
 // CTK includes
 #include "ctkPopupWidget.h"
@@ -29,7 +29,7 @@
 #include "ctkValueProxy.h"
 #include "ui_ctkSliderWidget.h"
 
-// STD includes 
+// STD includes
 #include <cmath>
 
 //-----------------------------------------------------------------------------
@@ -66,7 +66,7 @@ public:
   bool   BlockSetSliderValue;
   ctkSliderWidget::SynchronizeSiblings SynchronizeMode;
   ctkPopupWidget* SliderPopup;
-  QWeakPointer<ctkValueProxy> Proxy;
+  QPointer<ctkValueProxy> Proxy;
 };
 
 // --------------------------------------------------------------------------

+ 18 - 7
Libs/Widgets/ctkTestApplication.cpp

@@ -54,8 +54,11 @@ int ctkTestApplication::Error = 0;
 //-----------------------------------------------------------------------------
 ctkTestApplication::ctkTestApplication(int _argc, char** _argv)
 {
+#if QT_VERSION > QT_VERSION_CHECK(5,0,0)
+  qInstallMessageHandler(ctkTestApplication::messageHandler);
+#else
   qInstallMsgHandler(ctkTestApplication::messageHandler);
-  
+#endif
   // CMake generated driver removes argv[0], 
   // so let's put a dummy back in
   this->Argv.append("ctkTestApplication");
@@ -75,7 +78,11 @@ ctkTestApplication::ctkTestApplication(int _argc, char** _argv)
 ctkTestApplication::~ctkTestApplication()
 {
   delete this->App;
+#if QT_VERSION > QT_VERSION_CHECK(5,0,0)
+  qInstallMessageHandler(0);
+#else
   qInstallMsgHandler(0);
+#endif
 }
 
 //-----------------------------------------------------------------------------
@@ -110,23 +117,27 @@ int ctkTestApplication::exec(bool reportErrorsOnExit)
 }
 
 //-----------------------------------------------------------------------------
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+void ctkTestApplication::messageHandler(QtMsgType type, const QMessageLogContext &context, const QString& msg)
+#else
 void ctkTestApplication::messageHandler(QtMsgType type, const char *msg)
+#endif
 {
   switch(type)
   {
   case QtDebugMsg:
-    std::cerr << "Debug: " << msg << std::endl;
+    std::cerr << "Debug: " << msg.toStdString() << std::endl;
     break;
   case QtWarningMsg:
-    std::cerr << "Warning: " << msg << std::endl;
+    std::cerr << "Warning: " << msg.toStdString() << std::endl;
     Error++;
     break;
   case QtCriticalMsg:
-    std::cerr << "Critical: " << msg << std::endl;
+    std::cerr << "Critical: " << msg.toStdString() << std::endl;
     Error++;
     break;
   case QtFatalMsg:
-    std::cerr << "Fatal: " << msg << std::endl;
+    std::cerr << "Fatal: " << msg.toStdString() << std::endl;
     abort();
   }
 }
@@ -161,7 +172,7 @@ void ctkTestApplication::keyUp(QWidget* w, Qt::Key key, Qt::KeyboardModifiers mo
     off = 'A';
   if(key >= Qt::Key_A && key <= Qt::Key_Z)
     {
-    text.append(QChar::fromAscii(key - Qt::Key_A + off));
+    text.append(QChar::fromLatin1(key - Qt::Key_A + off));
     }
   QKeyEvent e(QEvent::KeyRelease, key, mod, text);
   if(!simulateEvent(w, &e))
@@ -182,7 +193,7 @@ void ctkTestApplication::keyDown(QWidget* w, Qt::Key key, Qt::KeyboardModifiers
     off = 'A';
   if(key >= Qt::Key_A && key <= Qt::Key_Z)
     {
-    text.append(QChar::fromAscii(key - Qt::Key_A + off));
+    text.append(QChar::fromLatin1(key - Qt::Key_A + off));
     }
   QKeyEvent e(QEvent::KeyPress, key, mod, text);
   if(!simulateEvent(w, &e))

+ 4 - 0
Libs/Widgets/ctkTestApplication.h

@@ -98,7 +98,11 @@ public:
   /// produced by QDebug during execution.
   static int exec(bool reportErrorsOnExit=false);
 
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+  static void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg);
+#else
   static void messageHandler(QtMsgType type, const char *msg);
+#endif
 
   static void delay(int ms);
 

+ 4 - 2
Libs/Widgets/ctkTreeComboBox.cpp

@@ -26,7 +26,9 @@
 #include <QKeyEvent>
 #include <QLayout>
 #include <QScrollBar>
-#include <QInputContext>
+#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
+# include <QInputContext>
+#endif
 #include <QMouseEvent>
 #include <QModelIndex>
 #include <QStack>
@@ -418,7 +420,7 @@ void ctkTreeComboBox::resizePopup()
         listRect.moveBottomLeft(above);
         }
 
-#ifndef QT_NO_IM
+#if QT_VERSION < QT_VERSION_CHECK(5,0,0) && !defined QT_NO_IM
       if (QInputContext *qic = this->inputContext())
         {
         qic->reset();

+ 3 - 3
Libs/Widgets/ctkWorkflowWidget.cpp

@@ -21,8 +21,8 @@
 // Qt includes
 #include <QApplication>
 #include <QDebug>
+#include <QPointer>
 #include <QStyle>
-#include <QWeakPointer>
 
 // CTK includes
 #include "ctkPushButton.h"
@@ -48,7 +48,7 @@ public:
   ctkWorkflowWidgetPrivate();
   ~ctkWorkflowWidgetPrivate();
 
-  QWeakPointer<ctkWorkflow>   Workflow;
+  QPointer<ctkWorkflow> Workflow;
 
   ctkWorkflowGroupBox*        WorkflowGroupBox;
   ctkWorkflowButtonBoxWidget* ButtonBoxWidget;
@@ -134,7 +134,7 @@ void ctkWorkflowWidget::setWorkflow(ctkWorkflow* newWorkflow)
                         this, SLOT(onStepRegistered(ctkWorkflowStep)));
     }
 
-  d->Workflow = QWeakPointer<ctkWorkflow>(newWorkflow);
+  d->Workflow = newWorkflow;
 
   if (!d->Workflow.isNull())
     {

+ 3 - 0
Libs/Widgets/target_libraries.cmake

@@ -7,3 +7,6 @@
 set(target_libraries
   CTKCore
   )
+if (CTK_QT_VERSION VERSION_GREATER "4")
+  list(APPEND target_libraries Qt5Xml_LIBRARIES Qt5OpenGL_LIBRARIES)
+endif()

+ 1 - 1
Libs/ctkExport.h.in

@@ -8,7 +8,7 @@
 #ifndef __@MY_EXPORT_HEADER_PREFIX@Export_h
 #define __@MY_EXPORT_HEADER_PREFIX@Export_h
 
-#include <QtCore/qglobal.h>
+#include <QtGlobal>
 
 #if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
 #  if defined(@MY_LIBNAME@_EXPORTS)

+ 14 - 4
Plugins/org.commontk.eventbus/Testing/Cpp/CMakeLists.txt

@@ -36,15 +36,25 @@ macro(ctkMacroInitProject test)
       if(NOT ${FILE_NAME} STREQUAL "main")
         ## Assign the moc custom filename
         set(MOC_FILE "${FILE_NAME}.moc")
-        QT4_GENERATE_MOC(${FILE_NAME_ABS} ${MOC_FILE})
+        if (CTK_QT_VERSION VERSION_GREATER "4")
+          QT5_GENERATE_MOC(${FILE_NAME_ABS} ${MOC_FILE})
+        else()
+          QT4_GENERATE_MOC(${FILE_NAME_ABS} ${MOC_FILE})
+        endif()
         list(APPEND MY_MOC_CXX "${CMAKE_CURRENT_BINARY_DIR}/${MOC_FILE}")
       endif()
     endforeach()
   else()
     ## Moc the library's .h files
-    QT4_WRAP_CPP(MY_MOC_CXX ${include_file_list})
-    QT4_WRAP_UI(MY_UI_CXX ${ui_file_list})
-    #QT4_ADD_RESOURCES(MY_RESOURCE_CXX ${resource_file_list})
+    if (CTK_QT_VERSION VERSION_GREATER "4")
+      QT5_WRAP_CPP(MY_MOC_CXX ${include_file_list})
+      QT5_WRAP_UI(MY_UI_CXX ${ui_file_list})
+      #QT5_ADD_RESOURCES(MY_RESOURCE_CXX ${resource_file_list})
+    else()
+      QT4_WRAP_CPP(MY_MOC_CXX ${include_file_list})
+      QT4_WRAP_UI(MY_UI_CXX ${ui_file_list})
+      #QT4_ADD_RESOURCES(MY_RESOURCE_CXX ${resource_file_list})
+    endif()
   endif()
 
   set(PROJECT_SRCS

+ 1 - 1
Plugins/org.commontk.eventbus/ctkEventBusManager.cpp

@@ -214,7 +214,7 @@ void ctkEventBusManager::startListen() {
     if(connector) {
         connector->startListen();
     } else {
-        qWarning("%s", tr("Server can not start. Create it first, then call startListen again!!").toAscii().data());
+        qWarning("%s", tr("Server can not start. Create it first, then call startListen again!!").toLatin1().data());
     }
 }
 

+ 4 - 4
Plugins/org.commontk.eventbus/ctkEventDefinitions.h

@@ -42,7 +42,7 @@ class ctkBusEvent;
         ctkBusEvent *properties = new ctkBusEvent(topic, ctkEventBus::ctkEventTypeLocal, ctkEventBus::ctkSignatureTypeSignal, static_cast<QObject*>(sender), signature); \
         bool ok = ctkEventBus::ctkEventBusManager::instance()->addEventProperty(*properties);\
         if(!ok) {\
-            qWarning("%s", tr("Some problem occourred during the signal registration with ID '%1'.").arg(topic).toAscii().data());\
+            qWarning("%s", tr("Some problem occourred during the signal registration with ID '%1'.").arg(topic).toLatin1().data());\
             if(properties) {delete properties; properties = NULL;} \
             }\
     }
@@ -52,7 +52,7 @@ class ctkBusEvent;
         ctkBusEvent *properties = new ctkBusEvent(topic, ctkEventBus::ctkEventTypeRemote, ctkEventBus::ctkSignatureTypeSignal, static_cast<QObject*>(sender), signature); \
         bool ok =  ctkEventBus::ctkEventBusManager::instance()->addEventProperty(*properties);\
         if(!ok) {\
-            qWarning("%s", tr("Some problem occourred during the signal registration with ID '%1'.").arg(topic).toAscii().data());\
+            qWarning("%s", tr("Some problem occourred during the signal registration with ID '%1'.").arg(topic).toLatin1().data());\
             if(properties) {delete properties; properties = NULL;} \
         }\
     }
@@ -62,7 +62,7 @@ class ctkBusEvent;
         ctkBusEvent *properties = new ctkBusEvent(topic, ctkEventBus::ctkEventTypeLocal, ctkEventBus::ctkSignatureTypeCallback, static_cast<QObject*>(observer), signature); \
         bool ok =  ctkEventBus::ctkEventBusManager::instance()->addEventProperty(*properties);\
         if(!ok) {\
-            qWarning("%s", tr("Some problem occourred during the callback registration with ID '%1'.").arg(topic).toAscii().data());\
+            qWarning("%s", tr("Some problem occourred during the callback registration with ID '%1'.").arg(topic).toLatin1().data());\
             if(properties) {delete properties; properties = NULL;} \
         }\
     }
@@ -72,7 +72,7 @@ class ctkBusEvent;
         ctkBusEvent *properties = new ctkBusEvent(topic, ctkEventBus::ctkEventTypeRemote, ctkEventBus::ctkSignatureTypeCallback, static_cast<QObject*>(sender), signature); \
         bool ok =  ctkEventBus::ctkEventBusManager::instance()->addEventProperty(*properties);\
         if(!ok) {\
-            qWarning("%s", tr("Some problem occourred during the callback registration with ID '%1'.").arg(topic).toAscii().data());\
+            qWarning("%s", tr("Some problem occourred during the callback registration with ID '%1'.").arg(topic).toLatin1().data());\
             if(properties) {delete properties; properties = NULL;} \
         }\
     }

+ 6 - 6
Plugins/org.commontk.eventbus/ctkEventDispatcher.cpp

@@ -92,7 +92,7 @@ bool ctkEventDispatcher::disconnectSignal(ctkBusEvent &props) {
     QString sig = props[SIGNATURE].toString();
     QString event_sig = SIGNAL_SIGNATURE;
     event_sig.append(sig);
-    bool result = obj_signal->disconnect(obj_signal, event_sig.toAscii(), 0, 0);
+    bool result = obj_signal->disconnect(obj_signal, event_sig.toLatin1(), 0, 0);
     return result;
 }
 
@@ -108,7 +108,7 @@ bool ctkEventDispatcher::disconnectCallback(ctkBusEvent &props) {
     QObject *objSignal = (*itemSignal)[OBJECT].value<QObject *>();
     QObject *objSlot = props[OBJECT].value<QObject *>();
 
-    return disconnect(objSignal, event_sig.toAscii(), objSlot, observer_sig.toAscii());
+    return disconnect(objSignal, event_sig.toLatin1(), objSlot, observer_sig.toLatin1());
 }
 
 bool ctkEventDispatcher::removeEventItem(ctkBusEvent &props) {
@@ -189,7 +189,7 @@ bool ctkEventDispatcher::addObserver(ctkBusEvent &props) {
         this->m_CallbacksHash.insertMulti(topic, dict);
         QObject *objSignal = (*itemEventProp)[OBJECT].value<QObject *>();
 
-        return connect(objSignal, event_sig.toAscii(), objSlot, observer_sig.toAscii());
+        return connect(objSignal, event_sig.toLatin1(), objSlot, observer_sig.toLatin1());
     }
     
     qDebug() << tr("Signal not valid for topic: %1").arg(topic);
@@ -303,9 +303,9 @@ bool ctkEventDispatcher::registerSignal(ctkBusEvent &props) {
         // Only one signal for a given id can be registered!!
         QObject *obj = props[OBJECT].value<QObject *>();
         if(obj != NULL) {
-            qWarning("%s", tr("Object %1 is trying to register a signal with Topic '%2' that has been already registered!!").arg(obj->metaObject()->className(), topic).toAscii().data());
+            qWarning("%s", tr("Object %1 is trying to register a signal with Topic '%2' that has been already registered!!").arg(obj->metaObject()->className(), topic).toLatin1().data());
         } else {
-            qWarning("%s", tr("NULL is trying to register a signal with Topic '%2' that has been already registered!!").arg(topic).toAscii().data());
+            qWarning("%s", tr("NULL is trying to register a signal with Topic '%2' that has been already registered!!").arg(topic).toLatin1().data());
         }
         return false;
     }
@@ -338,7 +338,7 @@ bool ctkEventDispatcher::registerSignal(ctkBusEvent &props) {
              event_sig.append(sig);
 
              QObject *objSlot = (*currentEvent)[OBJECT].value<QObject *>();
-             cumulativeConnect = cumulativeConnect && connect(objSignal, event_sig.toAscii(), objSlot, observer_sig.toAscii());
+             cumulativeConnect = cumulativeConnect && connect(objSignal, event_sig.toLatin1(), objSlot, observer_sig.toLatin1());
          }
          ctkBusEvent *dict = const_cast<ctkBusEvent *>(&props);
          this->m_SignalsHash.insert(topic, dict);

+ 26 - 26
Plugins/org.commontk.eventbus/ctkEventDispatcherLocal.cpp

@@ -45,113 +45,113 @@ void ctkEventDispatcherLocal::notifyEvent(ctkBusEvent &event_dictionary, ctkEven
                 if (returnArg == NULL || returnArg->data() == NULL) { //don't use return value
                     switch (argList->count()) {
                         case 0:
-                            this->metaObject()->invokeMethod(obj, signal_to_emit.toAscii());
+                            this->metaObject()->invokeMethod(obj, signal_to_emit.toLatin1());
                             break;
                         case 1:
-                            this->metaObject()->invokeMethod(obj, signal_to_emit.toAscii(), \
+                            this->metaObject()->invokeMethod(obj, signal_to_emit.toLatin1(), \
                             argList->at(0));
                             break;
                         case 2:
-                            this->metaObject()->invokeMethod(obj, signal_to_emit.toAscii(), \
+                            this->metaObject()->invokeMethod(obj, signal_to_emit.toLatin1(), \
                              argList->at(0), argList->at(1));
                             break;
                         case 3:
-                            this->metaObject()->invokeMethod(obj, signal_to_emit.toAscii(), \
+                            this->metaObject()->invokeMethod(obj, signal_to_emit.toLatin1(), \
                              argList->at(0), argList->at(1), argList->at(2));
                             break;
                         case 4:
-                            this->metaObject()->invokeMethod(obj, signal_to_emit.toAscii(), \
+                            this->metaObject()->invokeMethod(obj, signal_to_emit.toLatin1(), \
                              argList->at(0), argList->at(1), argList->at(2), argList->at(3));
                             break;
                         case 5:
-                            this->metaObject()->invokeMethod(obj, signal_to_emit.toAscii(), \
+                            this->metaObject()->invokeMethod(obj, signal_to_emit.toLatin1(), \
                              argList->at(0), argList->at(1), argList->at(2), argList->at(3), argList->at(4));
                             break;
                         case 6:
-                            this->metaObject()->invokeMethod(obj, signal_to_emit.toAscii(), \
+                            this->metaObject()->invokeMethod(obj, signal_to_emit.toLatin1(), \
                              argList->at(0), argList->at(1), argList->at(2), argList->at(3), argList->at(4), argList->at(5));
                             break;
                         case 7:
-                            this->metaObject()->invokeMethod(obj, signal_to_emit.toAscii(), \
+                            this->metaObject()->invokeMethod(obj, signal_to_emit.toLatin1(), \
                              argList->at(0), argList->at(1), argList->at(2), argList->at(3), argList->at(4), \
                              argList->at(5), argList->at(6));
                             break;
                         case 8:
-                            this->metaObject()->invokeMethod(obj, signal_to_emit.toAscii(), \
+                            this->metaObject()->invokeMethod(obj, signal_to_emit.toLatin1(), \
                              argList->at(0), argList->at(1), argList->at(2), argList->at(3), argList->at(4), \
                              argList->at(5), argList->at(6), argList->at(7));
                             break;
                         case 9:
-                            this->metaObject()->invokeMethod(obj, signal_to_emit.toAscii(), \
+                            this->metaObject()->invokeMethod(obj, signal_to_emit.toLatin1(), \
                              argList->at(0), argList->at(1), argList->at(2), argList->at(3), argList->at(4), \
                              argList->at(5), argList->at(6), argList->at(7), argList->at(8));
                             break;
                         case 10:
-                            this->metaObject()->invokeMethod(obj, signal_to_emit.toAscii(), \
+                            this->metaObject()->invokeMethod(obj, signal_to_emit.toLatin1(), \
                              argList->at(0), argList->at(1), argList->at(2), argList->at(3), argList->at(4), \
                              argList->at(5), argList->at(6), argList->at(7), argList->at(8), argList->at(9));
                             break;
                         default:
-                            qWarning("%s", tr("Number of arguments not supported. Max 10 arguments").toAscii().data());
+                            qWarning("%s", tr("Number of arguments not supported. Max 10 arguments").toLatin1().data());
                     } //switch
                  } else { //use return value
                     switch (argList->count()) {
                         case 0:
-                            this->metaObject()->invokeMethod(obj, signal_to_emit.toAscii(), *returnArg);
+                            this->metaObject()->invokeMethod(obj, signal_to_emit.toLatin1(), *returnArg);
                             break;
                         case 1:
-                            this->metaObject()->invokeMethod(obj, signal_to_emit.toAscii(), *returnArg,\
+                            this->metaObject()->invokeMethod(obj, signal_to_emit.toLatin1(), *returnArg,\
                             argList->at(0));
                             break;
                         case 2:
-                            this->metaObject()->invokeMethod(obj, signal_to_emit.toAscii(), *returnArg, \
+                            this->metaObject()->invokeMethod(obj, signal_to_emit.toLatin1(), *returnArg, \
                              argList->at(0), argList->at(1));
                             break;
                         case 3:
-                            this->metaObject()->invokeMethod(obj, signal_to_emit.toAscii(), *returnArg, \
+                            this->metaObject()->invokeMethod(obj, signal_to_emit.toLatin1(), *returnArg, \
                              argList->at(0), argList->at(1), argList->at(2));
                             break;
                         case 4:
-                            this->metaObject()->invokeMethod(obj, signal_to_emit.toAscii(), *returnArg, \
+                            this->metaObject()->invokeMethod(obj, signal_to_emit.toLatin1(), *returnArg, \
                              argList->at(0), argList->at(1), argList->at(2), argList->at(3));
                             break;
                         case 5:
-                            this->metaObject()->invokeMethod(obj, signal_to_emit.toAscii(), *returnArg, \
+                            this->metaObject()->invokeMethod(obj, signal_to_emit.toLatin1(), *returnArg, \
                              argList->at(0), argList->at(1), argList->at(2), argList->at(3), argList->at(4));
                             break;
                         case 6:
-                            this->metaObject()->invokeMethod(obj, signal_to_emit.toAscii(), *returnArg, \
+                            this->metaObject()->invokeMethod(obj, signal_to_emit.toLatin1(), *returnArg, \
                              argList->at(0), argList->at(1), argList->at(2), argList->at(3), argList->at(4), argList->at(5));
                             break;
                         case 7:
-                            this->metaObject()->invokeMethod(obj, signal_to_emit.toAscii(), *returnArg, \
+                            this->metaObject()->invokeMethod(obj, signal_to_emit.toLatin1(), *returnArg, \
                              argList->at(0), argList->at(1), argList->at(2), argList->at(3), argList->at(4), \
                              argList->at(5), argList->at(6));
                             break;
                         case 8:
-                            this->metaObject()->invokeMethod(obj, signal_to_emit.toAscii(), *returnArg, \
+                            this->metaObject()->invokeMethod(obj, signal_to_emit.toLatin1(), *returnArg, \
                              argList->at(0), argList->at(1), argList->at(2), argList->at(3), argList->at(4), \
                              argList->at(5), argList->at(6), argList->at(7));
                             break;
                         case 9:
-                            this->metaObject()->invokeMethod(obj, signal_to_emit.toAscii(), *returnArg, \
+                            this->metaObject()->invokeMethod(obj, signal_to_emit.toLatin1(), *returnArg, \
                              argList->at(0), argList->at(1), argList->at(2), argList->at(3), argList->at(4), \
                              argList->at(5), argList->at(6), argList->at(7), argList->at(8));
                             break;
                         case 10:
-                            this->metaObject()->invokeMethod(obj, signal_to_emit.toAscii(), *returnArg, \
+                            this->metaObject()->invokeMethod(obj, signal_to_emit.toLatin1(), *returnArg, \
                              argList->at(0), argList->at(1), argList->at(2), argList->at(3), argList->at(4), \
                              argList->at(5), argList->at(6), argList->at(7), argList->at(8), argList->at(9));
                             break;
                         default:
-                            qWarning("%s", tr("Number of arguments not supported. Max 10 arguments").toAscii().data());
+                            qWarning("%s", tr("Number of arguments not supported. Max 10 arguments").toLatin1().data());
                     } //switch
                  }
             } else {
                 if (returnArg == NULL || returnArg->data() == NULL) { //don't use return value
-                    this->metaObject()->invokeMethod(obj, signal_to_emit.toAscii());
+                    this->metaObject()->invokeMethod(obj, signal_to_emit.toLatin1());
                 } else {
-                    this->metaObject()->invokeMethod(obj, signal_to_emit.toAscii(), *returnArg);
+                    this->metaObject()->invokeMethod(obj, signal_to_emit.toLatin1(), *returnArg);
                 }
 
             }

+ 0 - 0
Plugins/org.commontk.eventbus/ctkNetworkConnectorQXMLRPC.cpp


Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä