From a81a943bee20df3c7eb34bafb3e3fe878facfe4e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Enar=20V=C3=A4ikene?= Date: Thu, 7 Nov 2013 14:01:25 +0200 Subject: [PATCH 1/1] Ported to Qt5 Currently missing Qt plugin loading using eVaf XML files. --- CMakeLists.txt | 13 +++- src/apps/CMakeLists.txt | 8 +- src/apps/FileFinder/CMakeLists.txt | 4 +- src/apps/FileFinder/Engine/CMakeLists.txt | 10 ++- src/apps/FileFinder/Engine/engine.cpp | 2 - src/apps/FileFinder/Engine/engine.h | 2 + src/apps/FileFinder/GUI/CMakeLists.txt | 8 +- src/apps/FileFinder/GUI/gui.cpp | 6 +- src/apps/FileFinder/GUI/gui.h | 3 + src/apps/PswGen/CLI/CMakeLists.txt | 10 +-- src/apps/PswGen/CLI/cli.cpp | 2 - src/apps/PswGen/CLI/cli.h | 3 + src/apps/PswGen/CMakeLists.txt | 4 +- src/apps/PswGen/GUI/CMakeLists.txt | 9 +-- src/apps/PswGen/GUI/gui.cpp | 4 +- src/apps/PswGen/GUI/gui.h | 3 + src/apps/PswGen/Generator/CMakeLists.txt | 10 +-- src/apps/PswGen/Generator/module.cpp | 2 - src/apps/PswGen/Generator/module.h | 2 + src/apps/PswGen/Storage/CMakeLists.txt | 11 +-- src/apps/PswGen/Storage/module.cpp | 10 +-- src/apps/PswGen/Storage/module.h | 2 + src/apps/ScosTime/CMakeLists.txt | 11 ++- src/apps/ScosTime/gui.cpp | 4 +- src/apps/ScosTime/gui.h | 3 + src/libs/CMakeLists.txt | 4 +- src/libs/Common/CMakeLists.txt | 10 +-- src/libs/Common/config.cpp | 4 +- src/libs/Common/config.h | 2 +- src/libs/Common/eventqueue.cpp | 42 ++++++---- src/libs/Common/eventqueue.h | 14 +++- src/libs/Common/prop.cpp | 4 +- src/libs/Common/prop.h | 2 +- src/libs/Common/registry.cpp | 25 +++++- src/libs/Common/registry.h | 11 ++- src/libs/Gui/CMakeLists.txt | 7 +- src/libs/Plugins/CMakeLists.txt | 11 +-- src/libs/Plugins/pluginmanager.cpp | 59 +------------- src/libs/Plugins/pluginmanager_p.h | 7 -- src/libs/version_rc.h | 2 + src/main/CLI/CMakeLists.txt | 10 +-- src/main/CLI/main.cpp | 4 +- src/main/CMakeLists.txt | 4 +- src/main/GUI/CMakeLists.txt | 18 ++--- src/main/GUI/fatalerr.cpp | 2 +- src/main/GUI/main.cpp | 4 +- src/plugins/CMakeLists.txt | 4 +- src/plugins/LogView/CMakeLists.txt | 9 +-- src/plugins/LogView/factory.cpp | 2 - src/plugins/LogView/factory.h | 3 + src/plugins/LogView/logview.cpp | 2 +- src/plugins/SdiWindow/CMakeLists.txt | 9 +-- src/plugins/SdiWindow/factory.cpp | 2 - src/plugins/SdiWindow/factory.h | 2 + src/plugins/SdiWindow/sdiwindow.cpp | 95 ++++++++++------------- src/plugins/SdiWindow/sdiwindow.h | 22 +++--- src/plugins/Test/CMakeLists.txt | 9 +-- src/plugins/Test/factory.cpp | 2 - src/plugins/Test/factory.h | 3 + 59 files changed, 261 insertions(+), 295 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e7b58d0..7fbcdd6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,17 +1,22 @@ project(eVaf) -set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required -cmake_minimum_required(VERSION 2.6.0) +cmake_minimum_required(VERSION 2.8.9) if(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) + cmake_policy(SET CMP0020 NEW) endif(COMMAND cmake_policy) +# Find Qt packages +find_package(Qt5Core REQUIRED) +find_package(Qt5Xml REQUIRED) +find_package(Qt5Widgets) +find_package(Qt5Sql) + # Include our own cmake modules set(CMAKE_MODULE_PATH ${eVaf_SOURCE_DIR}/mk/cmake) -# Find Qt4 -find_package(Qt4 4.6 REQUIRED) +set(CMAKE_INCLUDE_CURRENT_DIR ON) # Default to the Debug build type if none is specified IF(NOT CMAKE_BUILD_TYPE) diff --git a/src/apps/CMakeLists.txt b/src/apps/CMakeLists.txt index 65cc4c4..d9521a3 100644 --- a/src/apps/CMakeLists.txt +++ b/src/apps/CMakeLists.txt @@ -1,5 +1,7 @@ -add_subdirectory(PswGen) +if(Qt5Sql_FOUND) + add_subdirectory(PswGen) +endif(Qt5Sql_FOUND) add_subdirectory(FileFinder) -if(QT_QTGUI_FOUND) +if(Qt5Widgets_FOUND) add_subdirectory(ScosTime) -endif(QT_QTGUI_FOUND) +endif(Qt5Widgets_FOUND) diff --git a/src/apps/FileFinder/CMakeLists.txt b/src/apps/FileFinder/CMakeLists.txt index 1e6d01c..3b7324f 100644 --- a/src/apps/FileFinder/CMakeLists.txt +++ b/src/apps/FileFinder/CMakeLists.txt @@ -1,6 +1,6 @@ set(eVaf_INCLUDE ${eVaf_INCLUDE} ${CMAKE_SOURCE_DIR}/src/apps/FileFinder) add_subdirectory(Engine) -if(QT_QTGUI_FOUND) +if(Qt5Widgets_FOUND) add_subdirectory(GUI) -endif(QT_QTGUI_FOUND) +endif(Qt5Widgets_FOUND) diff --git a/src/apps/FileFinder/Engine/CMakeLists.txt b/src/apps/FileFinder/Engine/CMakeLists.txt index af9c24a..310d509 100644 --- a/src/apps/FileFinder/Engine/CMakeLists.txt +++ b/src/apps/FileFinder/Engine/CMakeLists.txt @@ -2,8 +2,8 @@ set(TARGET FileFinderEngine) # Qt modules -set(QT_DONT_USE_QTGUI TRUE) -include(${QT_USE_FILE}) +#set(QT_DONT_USE_QTGUI TRUE) +#include(${QT_USE_FILE}) # Needed for exporting/importing symbols add_definitions(-DFILEFINDER_ENGINE_LIBRARY) @@ -30,10 +30,12 @@ if(WIN32 AND NOT MINGW) set(SRCS ${SRCS} version.rc) endif(WIN32 AND NOT MINGW) -qt4_wrap_cpp(MOC_SRCS ${MOC_HDRS}) +qt5_wrap_cpp(MOC_SRCS ${MOC_HDRS}) add_library(${TARGET} SHARED ${SRCS} ${MOC_SRCS}) -target_link_libraries(${TARGET} ${QT_LIBRARIES} ${eVaf_LIBRARIES}) +qt5_use_modules(${TARGET} Core) + +target_link_libraries(${TARGET} ${eVaf_LIBRARIES}) install(TARGETS ${TARGET} DESTINATION bin) diff --git a/src/apps/FileFinder/Engine/engine.cpp b/src/apps/FileFinder/Engine/engine.cpp index 5c79cfd..bd15220 100644 --- a/src/apps/FileFinder/Engine/engine.cpp +++ b/src/apps/FileFinder/Engine/engine.cpp @@ -19,7 +19,6 @@ #include "engine.h" -#include "version.h" #include #include @@ -27,7 +26,6 @@ #include VER_EXPORT_VERSION_INFO() -Q_EXPORT_PLUGIN2(VER_MODULE_NAME_STR, eVaf::FileFinder::Engine::Module) using namespace eVaf; using namespace eVaf::FileFinder; diff --git a/src/apps/FileFinder/Engine/engine.h b/src/apps/FileFinder/Engine/engine.h index 341df0a..a17d3cc 100644 --- a/src/apps/FileFinder/Engine/engine.h +++ b/src/apps/FileFinder/Engine/engine.h @@ -21,6 +21,7 @@ # define __FILEFINDER_ENGINE_ENGINE_H #include "ifilefinder.h" +#include "version.h" #include @@ -62,6 +63,7 @@ class Module : public Plugins::iPlugin { Q_OBJECT Q_INTERFACES(eVaf::Plugins::iPlugin) + Q_PLUGIN_METADATA(IID VER_MODULE_NAME_STR) public: diff --git a/src/apps/FileFinder/GUI/CMakeLists.txt b/src/apps/FileFinder/GUI/CMakeLists.txt index 56b5db4..3c9d64c 100644 --- a/src/apps/FileFinder/GUI/CMakeLists.txt +++ b/src/apps/FileFinder/GUI/CMakeLists.txt @@ -2,7 +2,7 @@ set(TARGET FileFinderGui) # Qt modules -include(${QT_USE_FILE}) +#include(${QT_USE_FILE}) # Include files include_directories(${eVaf_INCLUDE}) @@ -30,12 +30,14 @@ if(WIN32 AND NOT MINGW) set(SRCS ${SRCS} version.rc) endif(WIN32 AND NOT MINGW) -qt4_add_resources(RCC_SRCS ${RCCS}) +qt5_add_resources(RCC_SRCS ${RCCS}) -qt4_wrap_cpp(MOC_SRCS ${MOC_HDRS}) +qt5_wrap_cpp(MOC_SRCS ${MOC_HDRS}) add_library(${TARGET} SHARED ${SRCS} ${MOC_SRCS} ${RCC_SRCS}) +qt5_use_modules(${TARGET} Core Widgets) + target_link_libraries(${TARGET} ${QT_LIBRARIES} ${eVaf_LIBRARIES}) install(TARGETS ${TARGET} DESTINATION bin) diff --git a/src/apps/FileFinder/GUI/gui.cpp b/src/apps/FileFinder/GUI/gui.cpp index e664dd7..9574df1 100644 --- a/src/apps/FileFinder/GUI/gui.cpp +++ b/src/apps/FileFinder/GUI/gui.cpp @@ -18,7 +18,6 @@ */ #include "gui.h" -#include "version.h" #include "Engine/iFileFinder" @@ -28,10 +27,9 @@ #include #include -#include +#include VER_EXPORT_VERSION_INFO() -Q_EXPORT_PLUGIN2(VER_MODULE_NAME_STR, eVaf::FileFinder::GUI::Module) using namespace eVaf; @@ -44,7 +42,7 @@ void FileFinder::GUI::Internal::MainWidget::keyPressEvent(QKeyEvent * e) switch (e->key()) { case Qt::Key_Enter: case Qt::Key_Return: { - QList buttons = qFindChildren(this); + QList buttons = findChildren(); foreach (QPushButton * btn, buttons) { if (btn->isDefault() && btn->isVisible()) { if (btn->isEnabled()) diff --git a/src/apps/FileFinder/GUI/gui.h b/src/apps/FileFinder/GUI/gui.h index 4d22d0b..283b167 100644 --- a/src/apps/FileFinder/GUI/gui.h +++ b/src/apps/FileFinder/GUI/gui.h @@ -20,6 +20,8 @@ #ifndef __FILEFINDER_GUI_GUI_H # define __FILEFINDER_GUI_GUI_H +#include "version.h" + #include #include @@ -82,6 +84,7 @@ class Module : public Plugins::iPlugin { Q_OBJECT Q_INTERFACES(eVaf::Plugins::iPlugin) + Q_PLUGIN_METADATA(IID VER_MODULE_NAME_STR) public: diff --git a/src/apps/PswGen/CLI/CMakeLists.txt b/src/apps/PswGen/CLI/CMakeLists.txt index ef8ee22..8629168 100644 --- a/src/apps/PswGen/CLI/CMakeLists.txt +++ b/src/apps/PswGen/CLI/CMakeLists.txt @@ -1,10 +1,6 @@ # Name of the target set(TARGET PswCli) -# Qt modules -set(QT_DONT_USE_QTGUI TRUE) -include(${QT_USE_FILE}) - # Include files include_directories(${eVaf_INCLUDE}) @@ -26,10 +22,12 @@ if(WIN32 AND NOT MINGW) set(SRCS ${SRCS} version.rc) endif(WIN32 AND NOT MINGW) -qt4_wrap_cpp(MOC_SRCS ${MOC_HDRS}) +qt5_wrap_cpp(MOC_SRCS ${MOC_HDRS}) add_library(${TARGET} SHARED ${SRCS} ${MOC_SRCS}) -target_link_libraries(${TARGET} ${QT_LIBRARIES} ${eVaf_LIBRARIES}) +qt5_use_modules(${TARGET} Core) + +target_link_libraries(${TARGET} ${eVaf_LIBRARIES}) install(TARGETS ${TARGET} DESTINATION bin) diff --git a/src/apps/PswGen/CLI/cli.cpp b/src/apps/PswGen/CLI/cli.cpp index 51ea2b6..56a49fb 100644 --- a/src/apps/PswGen/CLI/cli.cpp +++ b/src/apps/PswGen/CLI/cli.cpp @@ -18,7 +18,6 @@ */ #include "cli.h" -#include "version.h" #include #include @@ -42,7 +41,6 @@ #endif VER_EXPORT_VERSION_INFO() -Q_EXPORT_PLUGIN2(VER_MODULE_NAME_STR, eVaf::PswGen::CLI::Module) //------------------------------------------------------------------- diff --git a/src/apps/PswGen/CLI/cli.h b/src/apps/PswGen/CLI/cli.h index 9747565..cf53859 100644 --- a/src/apps/PswGen/CLI/cli.h +++ b/src/apps/PswGen/CLI/cli.h @@ -20,6 +20,8 @@ #ifndef __PSWGEN_CLI_CLI_H # define __PSWGEN_CLI_CLI_H +#include "version.h" + #include #include @@ -46,6 +48,7 @@ class Module : public Plugins::iPlugin { Q_OBJECT Q_INTERFACES(eVaf::Plugins::iPlugin) + Q_PLUGIN_METADATA(IID VER_MODULE_NAME_STR) public: diff --git a/src/apps/PswGen/CMakeLists.txt b/src/apps/PswGen/CMakeLists.txt index 3eadf22..d612852 100644 --- a/src/apps/PswGen/CMakeLists.txt +++ b/src/apps/PswGen/CMakeLists.txt @@ -1,8 +1,8 @@ set(eVaf_INCLUDE ${eVaf_INCLUDE} ${CMAKE_SOURCE_DIR}/src/apps/PswGen) -if(QT_QTGUI_FOUND) +if(Qt5Widgets_FOUND) add_subdirectory(GUI) -endif(QT_QTGUI_FOUND) +endif(Qt5Widgets_FOUND) add_subdirectory(CLI) add_subdirectory(Generator) add_subdirectory(Storage) diff --git a/src/apps/PswGen/GUI/CMakeLists.txt b/src/apps/PswGen/GUI/CMakeLists.txt index 561060e..89e9473 100644 --- a/src/apps/PswGen/GUI/CMakeLists.txt +++ b/src/apps/PswGen/GUI/CMakeLists.txt @@ -1,9 +1,6 @@ # Name of the target set(TARGET PswGui) -# Qt modules -include(${QT_USE_FILE}) - # Include files include_directories(${eVaf_INCLUDE}) @@ -25,10 +22,12 @@ if(WIN32 AND NOT MINGW) set(SRCS ${SRCS} version.rc) endif(WIN32 AND NOT MINGW) -qt4_wrap_cpp(MOC_SRCS ${MOC_HDRS}) +qt5_wrap_cpp(MOC_SRCS ${MOC_HDRS}) add_library(${TARGET} SHARED ${SRCS} ${MOC_SRCS}) -target_link_libraries(${TARGET} ${QT_LIBRARIES} ${eVaf_LIBRARIES}) +qt5_use_modules(${TARGET} Core Widgets) + +target_link_libraries(${TARGET} ${eVaf_LIBRARIES}) install(TARGETS ${TARGET} DESTINATION bin) diff --git a/src/apps/PswGen/GUI/gui.cpp b/src/apps/PswGen/GUI/gui.cpp index 9ab2645..6f94ce9 100644 --- a/src/apps/PswGen/GUI/gui.cpp +++ b/src/apps/PswGen/GUI/gui.cpp @@ -18,7 +18,6 @@ */ #include "gui.h" -#include "version.h" #include "Generator/iGenerator" #include "Storage/iStorage" @@ -29,11 +28,10 @@ #include #include -#include +#include VER_EXPORT_VERSION_INFO() -Q_EXPORT_PLUGIN2(VER_MODULE_NAME_STR, eVaf::PswGen::GUI::Module) //------------------------------------------------------------------- diff --git a/src/apps/PswGen/GUI/gui.h b/src/apps/PswGen/GUI/gui.h index 246b556..f4abd24 100644 --- a/src/apps/PswGen/GUI/gui.h +++ b/src/apps/PswGen/GUI/gui.h @@ -20,6 +20,8 @@ #ifndef __PSWGEN_GUI_GUI_H #define __PSWGEN_GUI_GUI_H +#include "version.h" + #include #include @@ -45,6 +47,7 @@ class Module : public Plugins::iPlugin { Q_OBJECT Q_INTERFACES(eVaf::Plugins::iPlugin) + Q_PLUGIN_METADATA(IID VER_MODULE_NAME_STR) public: diff --git a/src/apps/PswGen/Generator/CMakeLists.txt b/src/apps/PswGen/Generator/CMakeLists.txt index 3d7c7eb..c4ca65f 100644 --- a/src/apps/PswGen/Generator/CMakeLists.txt +++ b/src/apps/PswGen/Generator/CMakeLists.txt @@ -1,10 +1,6 @@ # Name of the target set(TARGET PswGen) -# Qt modules -set(QT_DONT_USE_QTGUI TRUE) -include(${QT_USE_FILE}) - # Needed for exporting/importing symbols add_definitions(-DPSWGEN_GENERATOR_LIBRARY) @@ -29,10 +25,12 @@ if(WIN32 AND NOT MINGW) set(SRCS ${SRCS} version.rc) endif(WIN32 AND NOT MINGW) -qt4_wrap_cpp(MOC_SRCS ${MOC_HDRS}) +qt5_wrap_cpp(MOC_SRCS ${MOC_HDRS}) add_library(${TARGET} SHARED ${SRCS} ${MOC_SRCS}) -target_link_libraries(${TARGET} ${QT_LIBRARIES} ${eVaf_LIBRARIES}) +qt5_use_modules(${TARGET} Core) + +target_link_libraries(${TARGET} ${eVaf_LIBRARIES}) install(TARGETS ${TARGET} DESTINATION bin) diff --git a/src/apps/PswGen/Generator/module.cpp b/src/apps/PswGen/Generator/module.cpp index 9e24e56..bca1954 100644 --- a/src/apps/PswGen/Generator/module.cpp +++ b/src/apps/PswGen/Generator/module.cpp @@ -18,7 +18,6 @@ */ #include "module.h" -#include "version.h" #include #include @@ -26,7 +25,6 @@ #include VER_EXPORT_VERSION_INFO() -Q_EXPORT_PLUGIN2(VER_MODULE_NAME_STR, eVaf::PswGen::Generator::Module) using namespace eVaf; using namespace eVaf::PswGen; diff --git a/src/apps/PswGen/Generator/module.h b/src/apps/PswGen/Generator/module.h index 90affff..68cdb4c 100644 --- a/src/apps/PswGen/Generator/module.h +++ b/src/apps/PswGen/Generator/module.h @@ -21,6 +21,7 @@ # define __PSWGEN_GENERATOR_MODULE_H #include "igenerator.h" +#include "version.h" #include @@ -45,6 +46,7 @@ class Module : public Plugins::iPlugin { Q_OBJECT Q_INTERFACES(eVaf::Plugins::iPlugin) + Q_PLUGIN_METADATA(IID VER_MODULE_NAME_STR) public: diff --git a/src/apps/PswGen/Storage/CMakeLists.txt b/src/apps/PswGen/Storage/CMakeLists.txt index 2169469..e3ffd48 100644 --- a/src/apps/PswGen/Storage/CMakeLists.txt +++ b/src/apps/PswGen/Storage/CMakeLists.txt @@ -1,11 +1,6 @@ # Name of the target set(TARGET PswStorage) -# Qt modules -set(QT_USE_QTSQL TRUE) -set(QT_DONT_USE_QTGUI TRUE) -include(${QT_USE_FILE}) - # Needed for exporting symbols add_definitions(-DPSWGEN_STORAGE_LIBRARY) @@ -30,10 +25,12 @@ if(WIN32 AND NOT MINGW) set(SRCS ${SRCS} version.rc) endif(WIN32 AND NOT MINGW) -qt4_wrap_cpp(MOC_SRCS ${MOC_HDRS}) +qt5_wrap_cpp(MOC_SRCS ${MOC_HDRS}) add_library(${TARGET} SHARED ${SRCS} ${MOC_SRCS}) -target_link_libraries(${TARGET} ${QT_LIBRARIES} ${eVaf_LIBRARIES}) +qt5_use_modules(${TARGET} Core Sql) + +target_link_libraries(${TARGET} ${eVaf_LIBRARIES}) install(TARGETS ${TARGET} DESTINATION bin) diff --git a/src/apps/PswGen/Storage/module.cpp b/src/apps/PswGen/Storage/module.cpp index 12fda42..3c18b9a 100644 --- a/src/apps/PswGen/Storage/module.cpp +++ b/src/apps/PswGen/Storage/module.cpp @@ -18,7 +18,6 @@ */ #include "module.h" -#include "version.h" #include #include @@ -29,7 +28,6 @@ #include VER_EXPORT_VERSION_INFO() -Q_EXPORT_PLUGIN2(VER_MODULE_NAME_STR, eVaf::PswGen::Storage::Module) using namespace eVaf; using namespace eVaf::PswGen; @@ -170,10 +168,10 @@ bool StorageImpl::save(QString const & name, QExplicitlySharedDataPointerreset(); @@ -253,14 +251,14 @@ bool StorageImpl::loadData() return false; } + beginResetModel(); while (q.next()) { QString name = q.value(0).toString(); QExplicitlySharedDataPointer data( new Storage::Data(name, q.value(1).toString(), q.value(2).toInt(), uint(q.value(3).toInt()))); mData.insert(name, data); } - - reset(); + endResetModel(); return true; } diff --git a/src/apps/PswGen/Storage/module.h b/src/apps/PswGen/Storage/module.h index 7f53b26..49c7e6a 100644 --- a/src/apps/PswGen/Storage/module.h +++ b/src/apps/PswGen/Storage/module.h @@ -21,6 +21,7 @@ # define __PSWGEN_STORAGE_MODULE_H #include "istorage.h" +#include "version.h" #include @@ -49,6 +50,7 @@ class Module : public Plugins::iPlugin { Q_OBJECT Q_INTERFACES(eVaf::Plugins::iPlugin) + Q_PLUGIN_METADATA(IID VER_MODULE_NAME_STR) public: diff --git a/src/apps/ScosTime/CMakeLists.txt b/src/apps/ScosTime/CMakeLists.txt index c56fb72..e32c9ef 100644 --- a/src/apps/ScosTime/CMakeLists.txt +++ b/src/apps/ScosTime/CMakeLists.txt @@ -1,9 +1,6 @@ # Name of the target set(TARGET ScosTime) -# Qt modules -include(${QT_USE_FILE}) - # Include files include_directories(${eVaf_INCLUDE}) @@ -30,12 +27,14 @@ if(WIN32 AND NOT MINGW) set(SRCS ${SRCS} version.rc) endif(WIN32 AND NOT MINGW) -qt4_add_resources(RCC_SRCS ${RCCS}) +qt5_add_resources(RCC_SRCS ${RCCS}) -qt4_wrap_cpp(MOC_SRCS ${MOC_HDRS}) +qt5_wrap_cpp(MOC_SRCS ${MOC_HDRS}) add_library(${TARGET} SHARED ${SRCS} ${MOC_SRCS} ${RCC_SRCS}) -target_link_libraries(${TARGET} ${QT_LIBRARIES} ${eVaf_LIBRARIES}) +qt5_use_modules(${TARGET} Core Widgets) + +target_link_libraries(${TARGET} ${eVaf_LIBRARIES}) install(TARGETS ${TARGET} DESTINATION bin) diff --git a/src/apps/ScosTime/gui.cpp b/src/apps/ScosTime/gui.cpp index 1ea9ba1..1a978af 100644 --- a/src/apps/ScosTime/gui.cpp +++ b/src/apps/ScosTime/gui.cpp @@ -18,7 +18,6 @@ */ #include "gui.h" -#include "version.h" #include #include @@ -26,11 +25,10 @@ #include #include -#include +#include VER_EXPORT_VERSION_INFO() -Q_EXPORT_PLUGIN2(VER_MODULE_NAME_STR, eVaf::ScosTime::Module) //------------------------------------------------------------------- diff --git a/src/apps/ScosTime/gui.h b/src/apps/ScosTime/gui.h index fe6b5e3..581760b 100644 --- a/src/apps/ScosTime/gui.h +++ b/src/apps/ScosTime/gui.h @@ -20,6 +20,8 @@ #ifndef __SCOSTIME_GUI_H # define __SCOSTIME_GUI_H +#include "version.h" + #include #include @@ -41,6 +43,7 @@ class Module : public Plugins::iPlugin { Q_OBJECT Q_INTERFACES(eVaf::Plugins::iPlugin) + Q_PLUGIN_METADATA(IID VER_MODULE_NAME_STR) public: diff --git a/src/libs/CMakeLists.txt b/src/libs/CMakeLists.txt index eabd2bc..458a3d0 100644 --- a/src/libs/CMakeLists.txt +++ b/src/libs/CMakeLists.txt @@ -1,5 +1,5 @@ add_subdirectory(Plugins) add_subdirectory(Common) -if(QT_QTGUI_FOUND) +if(Qt5Widgets_FOUND) add_subdirectory(Gui) -endif(QT_QTGUI_FOUND) +endif(Qt5Widgets_FOUND) diff --git a/src/libs/Common/CMakeLists.txt b/src/libs/Common/CMakeLists.txt index 83affd4..ce5f10c 100644 --- a/src/libs/Common/CMakeLists.txt +++ b/src/libs/Common/CMakeLists.txt @@ -1,10 +1,6 @@ # Name of the target set(TARGET CommonLib) -# Qt modules -set(QT_DONT_USE_QTGUI TRUE) -include(${QT_USE_FILE}) - # Needed for exporting/importing symbols add_definitions(-DCOMMON_LIBRARY) @@ -49,10 +45,12 @@ if(WIN32 AND NOT MINGW) set(SRCS ${SRCS} version.rc) endif(WIN32 AND NOT MINGW) -qt4_wrap_cpp(MOC_SRCS ${MOC_HDRS}) +qt5_wrap_cpp(MOC_SRCS ${MOC_HDRS}) add_library(${TARGET} SHARED ${SRCS} ${MOC_SRCS}) -target_link_libraries(${TARGET} ${QT_LIBRARIES} ${eVaf_LIBRARIES}) +qt5_use_modules(${TARGET} Core) + +target_link_libraries(${TARGET} ${eVaf_LIBRARIES}) install(TARGETS ${TARGET} DESTINATION bin) diff --git a/src/libs/Common/config.cpp b/src/libs/Common/config.cpp index c4f0997..5303bb8 100644 --- a/src/libs/Common/config.cpp +++ b/src/libs/Common/config.cpp @@ -33,7 +33,7 @@ using namespace eVaf::Common; iConfig * iConfig::instance() { static Internal::Config singleton; - return singleton.interface(); + return singleton._interface(); } @@ -55,7 +55,7 @@ Config::~Config() done(); } -iConfig * Config::interface() const +iConfig * Config::_interface() const { return evafQueryInterface("iConfig"); } diff --git a/src/libs/Common/config.h b/src/libs/Common/config.h index 3c19aaf..49f2c8e 100644 --- a/src/libs/Common/config.h +++ b/src/libs/Common/config.h @@ -65,7 +65,7 @@ public: /** * Returns the current implementation of the iConfig interface */ - iConfig * interface() const; + iConfig * _interface() const; /** * Initializes the iConfig interface implementation. diff --git a/src/libs/Common/eventqueue.cpp b/src/libs/Common/eventqueue.cpp index 795224c..647d892 100644 --- a/src/libs/Common/eventqueue.cpp +++ b/src/libs/Common/eventqueue.cpp @@ -62,26 +62,20 @@ bool EventQueue::event(QEvent * e) uint id = event->id(); // Verify that this event is registered - QHash::const_iterator eventsIt = mEvents.constFind(id); + Events::const_iterator eventsIt = mEvents.constFind(id); if (eventsIt == mEvents.constEnd()) { return true; // We don't know it, but it is an eVaf event and we should handle it } // Send the event to all the subscribers - QHash > >::const_iterator subscribersIt = mSubscribers.constFind(id); + Subscribers::const_iterator subscribersIt = mSubscribers.constFind(id); if (subscribersIt != mSubscribers.constEnd()) { - QVector > subscribers = *subscribersIt; - int sz = subscribers.size(); + QVector subscribers = *subscribersIt; + int const sz = subscribers.size(); for (int i = 0; i < sz; ++i) { - // Get the subscriber object and make sure that it is still alive - QWeakPointer obj = subscribers.at(i); - if (obj.isNull()) { - continue; - } - // Notify the subscriber - bool rval = QCoreApplication::sendEvent(obj.data(), e); + bool const rval = QCoreApplication::sendEvent(subscribers.at(i), e); if (rval) { // The event was consumed and should be sent to any other subscribers @@ -133,7 +127,9 @@ uint EventQueue::subscribeEvent(uint id, QObject * obj) if (mSubscribers[id].indexOf(obj) != -1) return id; + // Add to the list of subscribers and connect to the destroyed() signal mSubscribers[id].append(obj); + connect(obj, SIGNAL(destroyed(QObject *)), this, SLOT(subscriberDestroyed(QObject *))); return id; } @@ -148,13 +144,16 @@ void EventQueue::unsubscribeEvent(uint id, QObject * obj) return; // Remove from the list of subscribers - QVector >::iterator it = mSubscribers[id].begin(); - QVector >::iterator e = mSubscribers[id].end(); + QVector::iterator it = mSubscribers[id].begin(); + QVector::const_iterator e = mSubscribers[id].end(); while (it != e) { - if (!it->isNull() && it->data() == obj) + if (*it == obj) { it = mSubscribers[id].erase(it); - else + disconnect(*it, SIGNAL(destroyed(QObject *)), this, SLOT(subscriberDestroyed(QObject*))); + } + else { ++it; + } } } @@ -162,3 +161,16 @@ void EventQueue::broadcastEvent(Event * event) { QCoreApplication::postEvent(this, event); } + +void EventQueue::subscriberDestroyed(QObject * obj) +{ + // Remove the subscriber from all the subscriber lists + Subscribers::iterator it = mSubscribers.begin(); + Subscribers::const_iterator e = mSubscribers.end(); + for (; it != e; ++it) { + int const idx = it->indexOf(obj); + if (idx != -1) { + it->remove(idx); + } + } +} diff --git a/src/libs/Common/eventqueue.h b/src/libs/Common/eventqueue.h index b029376..a4b834b 100644 --- a/src/libs/Common/eventqueue.h +++ b/src/libs/Common/eventqueue.h @@ -26,7 +26,6 @@ #include #include #include -#include namespace eVaf { @@ -72,10 +71,19 @@ private: // Members uint mNextEventId; /// List of registered events - QHash mEvents; + typedef QHash Events; + Events mEvents; /// List of subscribers - QHash > > mSubscribers; + typedef QHash > Subscribers; + Subscribers mSubscribers; + + +private slots: + + /// One of the subscribers is destroyed + /// We need to remove it from the list of subscribers. + void subscriberDestroyed(QObject * obj = 0); }; diff --git a/src/libs/Common/prop.cpp b/src/libs/Common/prop.cpp index 86d3b1e..f6cfec6 100644 --- a/src/libs/Common/prop.cpp +++ b/src/libs/Common/prop.cpp @@ -34,7 +34,7 @@ using namespace eVaf::Common; iProp * iProp::instance() { static Internal::Prop singleton; - return singleton.interface(); + return singleton._interface(); } @@ -57,7 +57,7 @@ Prop::~Prop() done(); } -iProp * Prop::interface() const +iProp * Prop::_interface() const { return evafQueryInterface("iProp"); } diff --git a/src/libs/Common/prop.h b/src/libs/Common/prop.h index 4e44e27..1574f25 100644 --- a/src/libs/Common/prop.h +++ b/src/libs/Common/prop.h @@ -51,7 +51,7 @@ public: /** * Returns the current implementation of the iProp interface */ - iProp * interface() const; + iProp * _interface() const; /** * Initializes the iProp interface implementation diff --git a/src/libs/Common/registry.cpp b/src/libs/Common/registry.cpp index 661d2c7..6c8cc62 100644 --- a/src/libs/Common/registry.cpp +++ b/src/libs/Common/registry.cpp @@ -54,13 +54,32 @@ Registry::~Registry() bool Registry::registerInterface(QString const & name, QObject * obj) { - mInterfaces.insert(name, QWeakPointer(obj)); + // Add the interface to the list of registered interfaces and connect to + // the destroyed() signal. + mInterfaces.insert(name, obj); + connect(obj, SIGNAL(destroyed()), this, SLOT(interfaceDestroyed(QObject *))); return true; } QObject * Registry::queryInterface(QString const & name) const { - QHash >::const_iterator it = mInterfaces.constFind(name); - return it != mInterfaces.constEnd() ? (*it).data() : 0; + Interfaces::const_iterator it = mInterfaces.constFind(name); + return it != mInterfaces.constEnd() ? *it : 0; +} + +void Registry::interfaceDestroyed(QObject * obj) +{ + // Interface object destroyed. Remove it from the list of registered + // interfaces. + Interfaces::iterator it = mInterfaces.begin(); + Interfaces::const_iterator e = mInterfaces.end(); + while (it != e) { + if (*it == obj) { + it = mInterfaces.erase(it); + } + else { + ++it; + } + } } diff --git a/src/libs/Common/registry.h b/src/libs/Common/registry.h index 9c05c50..e8bf68b 100644 --- a/src/libs/Common/registry.h +++ b/src/libs/Common/registry.h @@ -24,7 +24,6 @@ #include #include -#include #include namespace eVaf { @@ -59,7 +58,15 @@ public: private: /// All the registered interfaces - QHash > mInterfaces; + typedef QHash Interfaces; + Interfaces mInterfaces; + + +private slots: + + /// Interface object destroyed + /// We need to remove the interface from the list of registered interfaces + void interfaceDestroyed(QObject * obj = 0); }; diff --git a/src/libs/Gui/CMakeLists.txt b/src/libs/Gui/CMakeLists.txt index 8821dc1..eea9014 100644 --- a/src/libs/Gui/CMakeLists.txt +++ b/src/libs/Gui/CMakeLists.txt @@ -1,9 +1,6 @@ # Name of the target set(TARGET GuiLib) -# Qt modules -include(${QT_USE_FILE}) - # Needed for exporting/importing symbols add_definitions(-DGUI_LIBRARY) @@ -28,10 +25,12 @@ if(WIN32 AND NOT MINGW) set(SRCS ${SRCS} version.rc) endif(WIN32 AND NOT MINGW) -qt4_wrap_cpp(MOC_SRCS ${MOC_HDRS}) +qt5_wrap_cpp(MOC_SRCS ${MOC_HDRS}) add_library(${TARGET} SHARED ${SRCS} ${MOC_SRCS}) +qt5_use_modules(${TARGET} Core Widgets) + target_link_libraries(${TARGET} ${QT_LIBRARIES} ${eVaf_LIBRARIES}) install(TARGETS ${TARGET} DESTINATION bin) diff --git a/src/libs/Plugins/CMakeLists.txt b/src/libs/Plugins/CMakeLists.txt index edcfae6..c0c958e 100644 --- a/src/libs/Plugins/CMakeLists.txt +++ b/src/libs/Plugins/CMakeLists.txt @@ -1,11 +1,6 @@ # Name of the target set(TARGET PluginsLib) -# Qt modules -set(QT_DONT_USE_QTGUI TRUE) -set(QT_USE_QTXML TRUE) -include(${QT_USE_FILE}) - # Needed for exporting/importing symbols add_definitions(-DPLUGINS_LIBRARY) @@ -33,10 +28,12 @@ if(WIN32 AND NOT MINGW) set(SRCS ${SRCS} version.rc) endif(WIN32 AND NOT MINGW) -qt4_wrap_cpp(MOC_SRCS ${MOC_HDRS}) +qt5_wrap_cpp(MOC_SRCS ${MOC_HDRS}) add_library(${TARGET} SHARED ${SRCS} ${MOC_SRCS}) -target_link_libraries(${TARGET} ${QT_LIBRARIES} ${eVaf_LIBRARIES}) +qt5_use_modules(${TARGET} Core Xml) + +target_link_libraries(${TARGET} ${eVaf_LIBRARIES}) install(TARGETS ${TARGET} DESTINATION bin) diff --git a/src/libs/Plugins/pluginmanager.cpp b/src/libs/Plugins/pluginmanager.cpp index dac188f..5d08dcb 100644 --- a/src/libs/Plugins/pluginmanager.cpp +++ b/src/libs/Plugins/pluginmanager.cpp @@ -291,14 +291,8 @@ bool PluginManagerPrivate::loadPlugins() } // End element? } - // Load Qt plugins - int i; - for (i = 0; i < qtPlugins.size(); ++i) { - loadQtPlugin(qtPlugins.at(i)); - } - // Load eVaf plugins - i = 0; + int i = 0; while (i < mPlugins.size()) { if (!mPlugins.at(i)->load()) { EVAF_ERROR("Failed to load module '%s'", qPrintable(mPlugins.at(i)->name())); @@ -348,57 +342,6 @@ Module * PluginManagerPrivate::moduleByName(QString const & name) const return 0; } -bool PluginManagerPrivate::loadQtPlugin(QString const & name) const -{ - // Get the Qt plugin file name with the full path - QString fileName; - -#ifdef Q_OS_LINUX - fileName = QString("%1libq%2.so").arg(Common::iApp::instance()->qtPluginsDir()).arg(name); -# ifndef QT_NO_DEBUG - QString t = QString("%1libq%2.so.debug").arg(Common::iApp::instance()->qtPluginsDir()).arg(name); - if (QFile::exists(t)) - fileName = t; -# endif -#endif - -#ifdef Q_OS_WIN32 - fileName = QString("%1q%2%3").arg(Common::iApp::instance()->qtPluginsDir()).arg(name).arg("4.dll"); -# ifndef QT_NO_DEBUG - QString t = QString("%1q%2%3").arg(Common::iApp::instance()->qtPluginsDir()).arg(name).arg("d4.dll"); - if (!QFile::exists(t)) - fileName = t; -# endif -#endif - -#ifdef Q_OS_CYGWIN - fileName = QString("%1cygq%2.dll").arg(Common::iApp::instance()->qtPluginsDir()).arg(name); -# ifndef QT_NO_DEBUG - QString t = QString("%1libq%2.dll.debug").arg(Common::iApp::instance()->qtPluginsDir()).arg(name); - if (QFile::exists(t)) - fileName = t; -# endif -#endif - - if (fileName.isEmpty()) { - EVAF_ERROR("Don\'t know how to load Qt plugin '%s'", qPrintable(name)); - return false; - } - - EVAF_INFO("Loading Qt plugin '%s'", qPrintable(fileName)); - - QLibrary lib(fileName); - void * fn = lib.resolve("qt_plugin_instance"); - if (fn) { - qRegisterStaticPluginInstanceFunction(QtPluginInstanceFunction(fn)); - return true; - } - else { - EVAF_ERROR("Failed to load Qt plugin '%s' : %s", qPrintable(fileName), qPrintable(lib.errorString())); - return false; - } -} - //------------------------------------------------------------------- diff --git a/src/libs/Plugins/pluginmanager_p.h b/src/libs/Plugins/pluginmanager_p.h index 22a0de1..9033d15 100644 --- a/src/libs/Plugins/pluginmanager_p.h +++ b/src/libs/Plugins/pluginmanager_p.h @@ -91,13 +91,6 @@ private: // Methods */ Module * moduleByName(QString const & name) const; - /** - * Loads the Qt plugin - * @param Name of the Qt plugin - * @return True; false if failed - */ - bool loadQtPlugin(QString const & name) const; - }; /** diff --git a/src/libs/version_rc.h b/src/libs/version_rc.h index ed8a20f..6920cf1 100644 --- a/src/libs/version_rc.h +++ b/src/libs/version_rc.h @@ -20,6 +20,8 @@ #ifndef __VERSION_RC_H #define __VERSION_RC_H +#include + /** * Product's version number in the format major,minor,release */ diff --git a/src/main/CLI/CMakeLists.txt b/src/main/CLI/CMakeLists.txt index a3983a6..d86dcc5 100644 --- a/src/main/CLI/CMakeLists.txt +++ b/src/main/CLI/CMakeLists.txt @@ -1,10 +1,6 @@ # Name of the target set(TARGET eVafCLI) -# Qt modules -set(QT_DONT_USE_QTGUI TRUE) -include(${QT_USE_FILE}) - # Include files include_directories(${eVaf_INCLUDE}) @@ -27,10 +23,12 @@ if(WIN32 AND NOT MINGW) set(SRCS ${SRCS} version.rc cli.rc) endif(WIN32 AND NOT MINGW) -qt4_wrap_cpp(MOC_SRCS ${MOC_HDRS}) +qt5_wrap_cpp(MOC_SRCS ${MOC_HDRS}) add_executable(${TARGET} ${SRCS} ${MOC_SRCS}) -target_link_libraries(${TARGET} ${QT_LIBRARIES} ${eVaf_LIBRARIES}) +qt5_use_modules(${TARGET} Core) + +target_link_libraries(${TARGET} ${eVaf_LIBRARIES}) install(TARGETS ${TARGET} DESTINATION bin) diff --git a/src/main/CLI/main.cpp b/src/main/CLI/main.cpp index 0c3cbb6..691db7a 100644 --- a/src/main/CLI/main.cpp +++ b/src/main/CLI/main.cpp @@ -49,7 +49,7 @@ namespace Internal { * * This function outputs messages to the console and to the log file. */ -static void messageOutput(QtMsgType type, char const * const msg) +static void messageOutput(QtMsgType type, QMessageLogContext const &, QString const & msg) { static bool inHandler = false; @@ -238,7 +238,7 @@ int main(int argc, char ** argv) // Install our onw message handlers Common::iLogger::instance()->installFatalMsgHandler(Internal::fatalMsgHandler); - qInstallMsgHandler(Internal::messageOutput); + qInstallMessageHandler(Internal::messageOutput); // Process command-line arguments if (!Application::processCommandLine(argc, argv)) diff --git a/src/main/CMakeLists.txt b/src/main/CMakeLists.txt index e5169f7..29d32a7 100644 --- a/src/main/CMakeLists.txt +++ b/src/main/CMakeLists.txt @@ -1,4 +1,4 @@ -if(QT_QTGUI_FOUND) +if(Qt5Widgets_FOUND) add_subdirectory(GUI) -endif(QT_QTGUI_FOUND) +endif(Qt5Widgets_FOUND) add_subdirectory(CLI) diff --git a/src/main/GUI/CMakeLists.txt b/src/main/GUI/CMakeLists.txt index 367e2f5..cfb011c 100644 --- a/src/main/GUI/CMakeLists.txt +++ b/src/main/GUI/CMakeLists.txt @@ -1,10 +1,6 @@ # Name of the target set(TARGET eVafGUI) -# Qt modules -set(QT_USE_QTMAIN TRUE) -include(${QT_USE_FILE}) - # Include files include_directories(${eVaf_INCLUDE}) @@ -33,21 +29,23 @@ set(MOC_HDRS ) # Resources -#set(RCCS -# gui.qrc -#) +set(RCCS + gui.qrc +) # Version info resource file for Windows builds if(WIN32 AND NOT MINGW) set(SRCS ${SRCS} version.rc gui.rc) endif(WIN32 AND NOT MINGW) -qt4_add_resources(RCC_SRCS ${RCCS}) +qt5_add_resources(RCC_SRCS ${RCCS}) -qt4_wrap_cpp(MOC_SRCS ${MOC_HDRS}) +qt5_wrap_cpp(MOC_SRCS ${MOC_HDRS}) add_executable(${TARGET} WIN32 ${SRCS} ${MOC_SRCS} ${RCC_SRCS}) -target_link_libraries(${TARGET} ${QT_LIBRARIES} ${eVaf_LIBRARIES}) +qt5_use_modules(${TARGET} Core Widgets) + +target_link_libraries(${TARGET} ${eVaf_LIBRARIES}) install(TARGETS ${TARGET} DESTINATION bin) diff --git a/src/main/GUI/fatalerr.cpp b/src/main/GUI/fatalerr.cpp index 3c37b0f..24e6a59 100644 --- a/src/main/GUI/fatalerr.cpp +++ b/src/main/GUI/fatalerr.cpp @@ -19,7 +19,7 @@ #include "fatalerr.h" -#include +#include using namespace eVaf::GUI::Internal; diff --git a/src/main/GUI/main.cpp b/src/main/GUI/main.cpp index f0e765f..313d210 100644 --- a/src/main/GUI/main.cpp +++ b/src/main/GUI/main.cpp @@ -82,7 +82,7 @@ static eVaf::Common::iLogger::Severity ConsoleSeverityLevel = eVaf::Common::iLog * * This function outputs messages to the console and to the log file. */ -static void messageOutput(QtMsgType type, char const * const msg) +static void messageOutput(QtMsgType type, QMessageLogContext const &, QString const & msg) { static bool inHandler = false; @@ -357,7 +357,7 @@ int main(int argc, char ** argv) // Install our own message handlers Common::iLogger::instance()->installFatalMsgHandler(Internal::fatalMsgHandler); - qInstallMsgHandler(Internal::messageOutput); + qInstallMessageHandler(Internal::messageOutput); // Process command-line arguments if (!Application::processCommandLine(argc, argv)) diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index bffa796..b4bf96d 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -1,5 +1,5 @@ -if(QT_QTGUI_FOUND) +if(Qt5Widgets_FOUND) add_subdirectory(SdiWindow) add_subdirectory(LogView) add_subdirectory(Test) -endif(QT_QTGUI_FOUND) +endif(Qt5Widgets_FOUND) diff --git a/src/plugins/LogView/CMakeLists.txt b/src/plugins/LogView/CMakeLists.txt index ac0d07f..1d4b839 100644 --- a/src/plugins/LogView/CMakeLists.txt +++ b/src/plugins/LogView/CMakeLists.txt @@ -1,9 +1,6 @@ # Name of the target set(TARGET LogView) -# Qt modules -include(${QT_USE_FILE}) - # Needed for exporting/importing symbols add_definitions(-DLOGVIEW_LIBRARY) @@ -30,10 +27,12 @@ if(WIN32 AND NOT MINGW) set(SRCS ${SRCS} version.rc) endif(WIN32 AND NOT MINGW) -qt4_wrap_cpp(MOC_SRCS ${MOC_HDRS}) +qt5_wrap_cpp(MOC_SRCS ${MOC_HDRS}) add_library(${TARGET} SHARED ${SRCS} ${MOC_SRCS}) -target_link_libraries(${TARGET} ${QT_LIBRARIES} ${eVaf_LIBRARIES}) +qt5_use_modules(${TARGET} Core Widgets) + +target_link_libraries(${TARGET} ${eVaf_LIBRARIES}) install(TARGETS ${TARGET} DESTINATION bin) diff --git a/src/plugins/LogView/factory.cpp b/src/plugins/LogView/factory.cpp index c4d5d09..52a7773 100644 --- a/src/plugins/LogView/factory.cpp +++ b/src/plugins/LogView/factory.cpp @@ -19,7 +19,6 @@ #include "factory.h" #include "logview.h" -#include "version.h" #include @@ -28,7 +27,6 @@ using namespace eVaf::LogView; VER_EXPORT_VERSION_INFO() -Q_EXPORT_PLUGIN2(VER_MODULE_NAME_STR, Factory) //------------------------------------------------------------------- diff --git a/src/plugins/LogView/factory.h b/src/plugins/LogView/factory.h index 4d36f91..bdf3962 100644 --- a/src/plugins/LogView/factory.h +++ b/src/plugins/LogView/factory.h @@ -20,6 +20,8 @@ #ifndef __LOGVIEW_FACTORY_H # define __LOGVIEW_FACTORY_H +#include "version.h" + #include namespace eVaf { @@ -36,6 +38,7 @@ class Factory : public Plugins::iPluginFactory { Q_OBJECT Q_INTERFACES(eVaf::Plugins::iPluginFactory) + Q_PLUGIN_METADATA(IID VER_MODULE_NAME_STR) public: diff --git a/src/plugins/LogView/logview.cpp b/src/plugins/LogView/logview.cpp index 1f75c58..75e973e 100644 --- a/src/plugins/LogView/logview.cpp +++ b/src/plugins/LogView/logview.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include #include diff --git a/src/plugins/SdiWindow/CMakeLists.txt b/src/plugins/SdiWindow/CMakeLists.txt index cd0a8c0..75f9ce7 100644 --- a/src/plugins/SdiWindow/CMakeLists.txt +++ b/src/plugins/SdiWindow/CMakeLists.txt @@ -1,9 +1,6 @@ # Name of the target set(TARGET SdiWindow) -# Qt modules -include(${QT_USE_FILE}) - # Needed for exporting/importing symbols add_definitions(-DSDIWINDOW_LIBRARY) @@ -30,10 +27,12 @@ if(WIN32 AND NOT MINGW) set(SRCS ${SRCS} version.rc) endif(WIN32 AND NOT MINGW) -qt4_wrap_cpp(MOC_SRCS ${MOC_HDRS}) +qt5_wrap_cpp(MOC_SRCS ${MOC_HDRS}) add_library(${TARGET} SHARED ${SRCS} ${MOC_SRCS}) -target_link_libraries(${TARGET} ${QT_LIBRARIES} ${eVaf_LIBRARIES}) +qt5_use_modules(${TARGET} Core Widgets Xml) + +target_link_libraries(${TARGET} ${eVaf_LIBRARIES}) install(TARGETS ${TARGET} DESTINATION bin) diff --git a/src/plugins/SdiWindow/factory.cpp b/src/plugins/SdiWindow/factory.cpp index 5ce4d1a..a8a9a8b 100644 --- a/src/plugins/SdiWindow/factory.cpp +++ b/src/plugins/SdiWindow/factory.cpp @@ -19,7 +19,6 @@ #include "factory.h" #include "sdiwindow.h" -#include "version.h" #include @@ -28,7 +27,6 @@ using namespace eVaf::SdiWindow; VER_EXPORT_VERSION_INFO() -Q_EXPORT_PLUGIN2(VER_MODULE_NAME_STR, Factory) //------------------------------------------------------------------- diff --git a/src/plugins/SdiWindow/factory.h b/src/plugins/SdiWindow/factory.h index 5010928..78b2f72 100644 --- a/src/plugins/SdiWindow/factory.h +++ b/src/plugins/SdiWindow/factory.h @@ -20,6 +20,7 @@ #ifndef __SDIWINDOW_FACTORY_H # define __SDIWINDOW_FACTORY_H +#include "version.h" #include namespace eVaf { @@ -46,6 +47,7 @@ class Factory : public Plugins::iPluginFactory { Q_OBJECT Q_INTERFACES(eVaf::Plugins::iPluginFactory) + Q_PLUGIN_METADATA(IID VER_MODULE_NAME_STR) public: diff --git a/src/plugins/SdiWindow/sdiwindow.cpp b/src/plugins/SdiWindow/sdiwindow.cpp index c0e3587..eb1a449 100644 --- a/src/plugins/SdiWindow/sdiwindow.cpp +++ b/src/plugins/SdiWindow/sdiwindow.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include namespace eVaf { @@ -53,7 +53,6 @@ SdiWindow::iSdiWindow * SdiWindow::iSdiWindow::instance() SdiWindow::Internal::MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags flags) : QWidget(parent, flags) , mReady(false) - , mTimerId(0) { setObjectName(QString("%1-%2").arg(VER_MODULE_NAME_STR).arg(__FUNCTION__)); @@ -103,9 +102,6 @@ bool SdiWindow::Internal::MainWindow::init(QString const & args) setWindowTitle(Common::iApp::instance()->name()); - // Start the garbage collector timer - mTimerId = startTimer(60 * 1000); - show(); mReady = true; @@ -121,21 +117,15 @@ void SdiWindow::Internal::MainWindow::done() close(); - if (mTimerId) { - killTimer(mTimerId); - mTimerId = 0; - } - // Delete all the panels for (int i = mPanels.size() - 1; i >= 0; --i) { - QWeakPointer p = mPanels.at(i); - if (p) - delete p.data(); + disconnect(mPanels.at(i), SIGNAL(destroyed(QObject *)), this, SLOT(panelDestroyed(QObject *))); + delete mPanels.at(i); } mPanels.clear(); mMinimizedPanels.clear(); mPanelNames.clear(); - mMainPanel.clear(); + mMainPanel = 0; mMainPanelName.clear(); EVAF_INFO("%s finalized", qPrintable(objectName())); @@ -143,6 +133,7 @@ void SdiWindow::Internal::MainWindow::done() void SdiWindow::Internal::MainWindow::addPanel(QString const & name, Gui::Panel * panel) { + connect(panel, SIGNAL(destroyed(QObject *)), this, SLOT(panelDestroyed(QObject*))); mPanels.append(panel); mPanelNames.insert(name, panel); @@ -165,9 +156,9 @@ void SdiWindow::Internal::MainWindow::addPanel(QString const & name, Gui::Panel Gui::Panel * SdiWindow::Internal::MainWindow::panel(QString const & name) const { - QHash >::const_iterator it = mPanelNames.constFind(name); + QHash::const_iterator it = mPanelNames.constFind(name); if (it != mPanelNames.constEnd()) - return it.value().data(); + return it.value(); return 0; } @@ -246,12 +237,10 @@ void SdiWindow::Internal::MainWindow::setWindowSize() void SdiWindow::Internal::MainWindow::closeEvent(QCloseEvent * e) { // Try to close all the managed panels; ignore the event if one of the managed panels refuses to close - foreach (QWeakPointer p, mPanels) { - if (p) { - if (!p.data()->close()) { - e->ignore(); - return; - } + foreach (Gui::Panel * p, mPanels) { + if (!p->close()) { + e->ignore(); + return; } } @@ -266,9 +255,9 @@ void SdiWindow::Internal::MainWindow::changeEvent(QEvent * e) if (windowState() == Qt::WindowNoState && wse->oldState() == Qt::WindowMinimized) { // Restore all the managed panels that were previously minimized - foreach (QWeakPointer p, mMinimizedPanels) { - if (p && p.data()->isVisible()) - p.data()->showNormal(); + foreach (Gui::Panel * p, mMinimizedPanels) { + if (p->isVisible()) + p->showNormal(); } mMinimizedPanels.clear(); } @@ -277,13 +266,10 @@ void SdiWindow::Internal::MainWindow::changeEvent(QEvent * e) // Minimize all the managed panels that are not minimized yet mMinimizedPanels.clear(); - foreach (QWeakPointer p, mPanels) { - if (!p) - continue; - - if (p.data()->windowState() != Qt::WindowMinimized && p.data()->isVisible()) { + foreach (Gui::Panel * p, mPanels) { + if (p->windowState() != Qt::WindowMinimized && p->isVisible()) { mMinimizedPanels.append(p); - p.data()->showMinimized(); + p->showMinimized(); } } } @@ -291,36 +277,37 @@ void SdiWindow::Internal::MainWindow::changeEvent(QEvent * e) QWidget::changeEvent(e); } -void SdiWindow::Internal::MainWindow::timerEvent(QTimerEvent * e) +void SdiWindow::Internal::MainWindow::panelDestroyed(QObject * obj) { - if (e->timerId() == mTimerId) { - - // Remove panels that are deleted - { - QList >::iterator it = mPanels.begin(); - while (it != mPanels.end()) { - QWeakPointer p = *it; - if (!p) - it = mPanels.erase(it); - else - ++it; + // Remove panels that are deleted + { + QList::iterator it = mPanels.begin(); + while (it != mPanels.end()) { + if (*it == obj) { + it = mPanels.erase(it); + } + else { + ++it; } } + } - // Do the same with panel names - { - QHash >::iterator it = mPanelNames.begin(); - while (it != mPanelNames.end()) { - QWeakPointer p = it.value(); - if (!p) - it = mPanelNames.erase(it); - else - ++it; + // Do the same with panel names + { + QHash::iterator it = mPanelNames.begin(); + while (it != mPanelNames.end()) { + if (it.value() == obj) { + it = mPanelNames.erase(it); + } + else { + ++it; } } } - else - QWidget::timerEvent(e); + + if (mMainPanel == obj) { + mMainPanel = 0; + } } diff --git a/src/plugins/SdiWindow/sdiwindow.h b/src/plugins/SdiWindow/sdiwindow.h index 757ed28..4c46eea 100644 --- a/src/plugins/SdiWindow/sdiwindow.h +++ b/src/plugins/SdiWindow/sdiwindow.h @@ -31,7 +31,6 @@ #include #include #include -#include class QVBoxLayout; @@ -72,9 +71,6 @@ public: protected: // Methods - /// Garbage collector timer - virtual void timerEvent(QTimerEvent * e); - private: // Methods @@ -97,19 +93,16 @@ private: // Members QString mMainPanelName; /// List of GUI::Panel objects added to the manager - QList > mPanels; + QList mPanels; /// List of minimized GUI::Panel objects - QVector > mMinimizedPanels; + QVector mMinimizedPanels; /// Hash with panel names - QHash > mPanelNames; + QHash mPanelNames; /// Current main panel added to this window - QWeakPointer mMainPanel; - - /// Garbage collector timer ID - int mTimerId; + Gui::Panel * mMainPanel; private: // Methods @@ -117,6 +110,13 @@ private: // Methods /// Gets the main panel name from module attributes QString getMainPanelName(QString const & args) const; + +private slots: + + /// Panel destroyed signal. We need to remove the panel from all the + /// lists. + void panelDestroyed(QObject * obj = 0); + }; /** diff --git a/src/plugins/Test/CMakeLists.txt b/src/plugins/Test/CMakeLists.txt index bbf03ba..f4aa339 100644 --- a/src/plugins/Test/CMakeLists.txt +++ b/src/plugins/Test/CMakeLists.txt @@ -1,9 +1,6 @@ # Name of the target set(TARGET Test) -# Qt modules -include(${QT_USE_FILE}) - # Include files include_directories(${eVaf_INCLUDE}) @@ -27,10 +24,12 @@ if(WIN32 AND NOT MINGW) set(SRCS ${SRCS} version.rc) endif(WIN32 AND NOT MINGW) -qt4_wrap_cpp(MOC_SRCS ${MOC_HDRS}) +qt5_wrap_cpp(MOC_SRCS ${MOC_HDRS}) add_library(${TARGET} SHARED ${SRCS} ${MOC_SRCS}) -target_link_libraries(${TARGET} ${QT_LIBRARIES} ${eVaf_LIBRARIES}) +qt5_use_modules(${TARGET} Core Widgets) + +target_link_libraries(${TARGET} ${eVaf_LIBRARIES}) install(TARGETS ${TARGET} DESTINATION bin) diff --git a/src/plugins/Test/factory.cpp b/src/plugins/Test/factory.cpp index feb433f..e3cba8b 100644 --- a/src/plugins/Test/factory.cpp +++ b/src/plugins/Test/factory.cpp @@ -19,7 +19,6 @@ #include "factory.h" #include "test.h" -#include "version.h" #include @@ -28,7 +27,6 @@ using namespace eVaf::Test; VER_EXPORT_VERSION_INFO() -Q_EXPORT_PLUGIN2(VER_MODULE_NAME_STR, Factory) //------------------------------------------------------------------- diff --git a/src/plugins/Test/factory.h b/src/plugins/Test/factory.h index 089d869..fbb40c9 100644 --- a/src/plugins/Test/factory.h +++ b/src/plugins/Test/factory.h @@ -20,6 +20,8 @@ #ifndef __TEST_FACTORY_H #define __TEST_FACTORY_H +#include "version.h" + #include namespace eVaf { @@ -44,6 +46,7 @@ class Factory : public Plugins::iPluginFactory { Q_OBJECT Q_INTERFACES(eVaf::Plugins::iPluginFactory) + Q_PLUGIN_METADATA(IID VER_MODULE_NAME_STR) public: -- 2.47.0