diff --git a/Modules/CMakeLists.txt b/Modules/CMakeLists.txt index 7c4b4fef20..2257180a20 100644 --- a/Modules/CMakeLists.txt +++ b/Modules/CMakeLists.txt @@ -1,66 +1,67 @@ set(LIBPOSTFIX "Ext") # Modules must be listed according to their dependencies set(module_dirs + Qt4Qt5TestModule SceneSerializationBase PlanarFigure ImageExtraction ImageStatistics LegacyAdaptors IpPicSupport MitkExt SceneSerialization GraphAlgorithms ContourModel SurfaceInterpolation Segmentation PlanarFigureSegmentation OpenViewCore QmlMitk Qmitk QmitkExt SegmentationUI DiffusionImaging GPGPU IGT CameraCalibration IGTUI RigidRegistration RigidRegistrationUI DeformableRegistration DeformableRegistrationUI OpenCL OpenCVVideoSupport Overlays InputDevices ToFHardware ToFProcessing ToFUI US ClippingTools USUI DicomUI Simulation Remeshing Python ) set(MITK_DEFAULT_SUBPROJECTS MITK-Modules) foreach(module_dir ${module_dirs}) add_subdirectory(${module_dir}) endforeach() if(MITK_PRIVATE_MODULES) file(GLOB all_subdirs RELATIVE ${MITK_PRIVATE_MODULES} ${MITK_PRIVATE_MODULES}/*) foreach(subdir ${all_subdirs}) string(FIND ${subdir} "." _result) if(_result EQUAL -1) if(EXISTS ${MITK_PRIVATE_MODULES}/${subdir}/CMakeLists.txt) message(STATUS "Found private module ${subdir}") add_subdirectory(${MITK_PRIVATE_MODULES}/${subdir} private_modules/${subdir}) endif() endif() endforeach() endif(MITK_PRIVATE_MODULES) diff --git a/Modules/Qt4Qt5TestModule/CMakeLists.txt b/Modules/Qt4Qt5TestModule/CMakeLists.txt new file mode 100644 index 0000000000..c7db655fc8 --- /dev/null +++ b/Modules/Qt4Qt5TestModule/CMakeLists.txt @@ -0,0 +1,7 @@ +MITK_CREATE_MODULE(Qt4Qt5TestModule + QT4_MODULES QtCore QtTest # we want something in the Qt 4 case + QT5_MODULES Qt5Core Qt5Test # we want something else in the Qt 5 case + SUBPROJECTS MITK-CoreUI +) + +add_subdirectory(Testing) diff --git a/Modules/Qt4Qt5TestModule/QWonderString.cpp b/Modules/Qt4Qt5TestModule/QWonderString.cpp new file mode 100644 index 0000000000..3917e89d5f --- /dev/null +++ b/Modules/Qt4Qt5TestModule/QWonderString.cpp @@ -0,0 +1,59 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#include "QWonderString.h" + +#if QT_VERSION >= 0x050000 + // Qt 5 or higher + #include +#else + // Qt 4 + #include +#endif + +QWonderString::QWonderString(QObject* parent, const QString& text) +:QObject(parent) +,m_Text(text) +{ +} + +QString QWonderString::text() +{ + return m_Text; +} + +void QWonderString::setText(const QString& text) +{ + m_Text = text; + + if (m_Text.contains("y")) + emit happy(); + + if (m_Text.contains("k")) + emit sad(); +} + +QString QWonderString::penguinUID() +{ + QUuid id = QUuid::createUuid(); +#if QT_VERSION >= 0x050000 + QString returnValue = id.toString(); // explicit in Qt 5 +#else + QString returnValue = id; // implicit in Qt 4 +#endif + + return returnValue; +} diff --git a/Modules/Qt4Qt5TestModule/QWonderString.h b/Modules/Qt4Qt5TestModule/QWonderString.h new file mode 100644 index 0000000000..1cb7d62727 --- /dev/null +++ b/Modules/Qt4Qt5TestModule/QWonderString.h @@ -0,0 +1,56 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#ifndef QWonderString_h +#define QWonderString_h + +#include + +#include "Qt4Qt5TestModuleExports.h" + +/** + \brief PURPOSELESS class for testing. + + This class is meant to demonstrate a module that builds with both Qt4 and Qt5! + + There is nothing here to copy.. +*/ +class Qt4Qt5TestModule_EXPORT QWonderString : public QObject +{ + Q_OBJECT + + public: + + QWonderString(QObject* parent = 0, const QString& text = ""); + + QString text(); + + static QString penguinUID(); + + public slots: + void setText(const QString& text); + + signals: + + void happy(); + void sad(); + + protected: + + QString m_Text; +}; + +#endif diff --git a/Modules/Qt4Qt5TestModule/Testing/CMakeLists.txt b/Modules/Qt4Qt5TestModule/Testing/CMakeLists.txt new file mode 100644 index 0000000000..2a7c703628 --- /dev/null +++ b/Modules/Qt4Qt5TestModule/Testing/CMakeLists.txt @@ -0,0 +1,5 @@ + +# Qt 4 solution +SET(QT_USE_QTTEST 1) + +MITK_CREATE_MODULE_TESTS(EXTRA_DEPENDS Mitk) diff --git a/Modules/Qt4Qt5TestModule/Testing/QWonderStringTest.cpp b/Modules/Qt4Qt5TestModule/Testing/QWonderStringTest.cpp new file mode 100644 index 0000000000..47da6d5871 --- /dev/null +++ b/Modules/Qt4Qt5TestModule/Testing/QWonderStringTest.cpp @@ -0,0 +1,38 @@ +#include "mitkTestingMacros.h" + +#include + +#include "QWonderString.h" + +/** + Just SOME kind of testing, nothing meaningful. + + This test is just company to the Qt4Qt5TestModule, + which is mean to demostrate how to implement a + module for both Qt4 and Qt5 +*/ +int QWonderStringTest(int argc, char** argv) +{ + MITK_TEST_CONDITION( !QWonderString::penguinUID().isEmpty(), "Penguin registry working" ) + + QWonderString s; + + QSignalSpy happyCounter( &s, SIGNAL(happy())); + QSignalSpy sadCounter( &s, SIGNAL(sad())); + + MITK_TEST_CONDITION( happyCounter.count() == 0 && sadCounter.count() == 0, "No feelings in the beginning" ) + + s.setText("Happy feet"); + MITK_TEST_CONDITION( happyCounter.count() == 1, "Penguins are happy" ) + + s.setText("Talk too much"); + MITK_TEST_CONDITION( sadCounter.count() == 1, "Penguin ears bleed" ) + + s.setText("Fishy fish"); + MITK_TEST_CONDITION( happyCounter.count() == 2, "Penguins sleepy" ) + + s.setText("Knok knok"); + MITK_TEST_CONDITION( sadCounter.count() == 2, "Penguins irritated" ) + + return EXIT_SUCCESS; +} diff --git a/Modules/Qt4Qt5TestModule/Testing/files.cmake b/Modules/Qt4Qt5TestModule/Testing/files.cmake new file mode 100644 index 0000000000..55bb90f2a9 --- /dev/null +++ b/Modules/Qt4Qt5TestModule/Testing/files.cmake @@ -0,0 +1,5 @@ +set(MODULE_TESTS + QWonderStringTest.cpp +) + + diff --git a/Modules/Qt4Qt5TestModule/files.cmake b/Modules/Qt4Qt5TestModule/files.cmake new file mode 100644 index 0000000000..f20a244879 --- /dev/null +++ b/Modules/Qt4Qt5TestModule/files.cmake @@ -0,0 +1,7 @@ +set(CPP_FILES + QWonderString.cpp +) + +set(MOC_H_FILES + QWonderString.h +)