From 849328b50313161b117532514a943d9321802fe4 Mon Sep 17 00:00:00 2001 From: imn Date: Thu, 26 Nov 2015 17:41:19 +0300 Subject: [PATCH] Merge Qt5 porting. --- CMakeLists.txt | 24 +++++++----- src/PVGUI/CMakeLists.txt | 10 ++--- src/PVGUI/PVGUI_Module.cxx | 38 ++++++++++++++++--- src/PVGUI/PVGUI_Module.h | 6 ++- src/Plugins/ArrayRenamer/CMakeLists.txt | 3 +- .../pqArraysEditorPropertyWidget.cxx | 13 ++++++- .../MEDReader/ParaViewPlugin/CMakeLists.txt | 4 +- .../ParaViewPlugin/VectBoolSpreadSheet.cxx | 5 +++ .../TableReader/ParaViewPlugin/CMakeLists.txt | 5 ++- src/Plugins/View/CMakeLists.txt | 4 +- test/standalone/CMakeLists.txt | 7 +++- test/standalone/gui/CMakeLists.txt | 9 +++-- 12 files changed, 95 insertions(+), 33 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 08be4910..eeb3e46c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,21 +110,26 @@ ENDIF() ## ## From GUI: part 1 (Qt must be checked before ParaView) ## -FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui QtXml QtHelp) -# This search for qhelpgenerator is required here -# to avoid detecting native one due to bug in ParaViewMacros.cmake -FIND_PROGRAM(QT_HELP_GENERATOR - qhelpgenerator - PATHS "${QT_BINARY_DIR}" - NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH - DOC "qhelpgenerator used to compile Qt help project files") -MARK_AS_ADVANCED(QT_HELP_GENERATOR) +IF (NOT SALOME_GUI_BUILD_WITH_QT5) + FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui QtXml QtHelp) + # This search for qhelpgenerator is required here + # to avoid detecting native one due to bug in ParaViewMacros.cmake + FIND_PROGRAM(QT_HELP_GENERATOR + qhelpgenerator + PATHS "${QT_BINARY_DIR}" + NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH + DOC "qhelpgenerator used to compile Qt help project files") + MARK_AS_ADVANCED(QT_HELP_GENERATOR) +ELSE() + FIND_PACKAGE(SalomeQt5 REQUIRED) +ENDIF() ## ## Specific to ParaViS: ## FIND_PACKAGE(SalomeParaView REQUIRED) + # GUI itself has to be loaded AFTER ParaView: the ParaView config doesn't mix # well with the VTK one (and GUI loads VTK): FIND_PACKAGE(SalomeGUI REQUIRED) @@ -179,6 +184,7 @@ ENDIF() ## ## From SMESH ## + IF(SALOME_PARAVIS_BUILD_PLUGINS AND SALOME_PARAVIS_USE_SMESH_SOURCE) IF(NOT SALOME_PARAVIS_USE_GEOM_SOURCE) SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR} CACHE PATH "Path to the Salome GEOM") diff --git a/src/PVGUI/CMakeLists.txt b/src/PVGUI/CMakeLists.txt index 40962d0d..db0d0c48 100644 --- a/src/PVGUI/CMakeLists.txt +++ b/src/PVGUI/CMakeLists.txt @@ -17,7 +17,7 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -INCLUDE(UseQt4Ext) +INCLUDE(UseQtExt) # --- options --- @@ -57,7 +57,7 @@ SET(_ui_files resources/pqCustomSettingsWidget.ui ) -QT4_WRAP_UI(_ui_FORMS_HEADERS ${_ui_files}) +QT_WRAP_UIC(_ui_FORMS_HEADERS ${_ui_files}) # header files / to be processed by moc SET(_moc_HEADERS @@ -105,10 +105,10 @@ ENDIF() # --- sources --- # sources / rcc wrappings -QT4_ADD_RESOURCES(_rcc_SOURCES ${_rcc_RESOURCES}) +QT_ADD_RESOURCES(_rcc_SOURCES ${_rcc_RESOURCES}) # sources / moc wrappings -QT4_WRAP_CPP(_moc_SOURCES ${_moc_HEADERS}) +QT_WRAP_MOC(_moc_SOURCES ${_moc_HEADERS}) # sources / static SET(_other_SOURCES @@ -135,5 +135,5 @@ INSTALL(TARGETS PARAVIS EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_I # --- header and resources installation --- INSTALL(FILES ${PVGUI_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS}) -QT4_INSTALL_TS_RESOURCES("${_ts_RESOURCES}" "${SALOME_PARAVIS_INSTALL_RES_DATA}") +QT_INSTALL_TS_RESOURCES("${_ts_RESOURCES}" "${SALOME_PARAVIS_INSTALL_RES_DATA}") INSTALL(FILES ${_other_RESOURCES} DESTINATION ${SALOME_PARAVIS_INSTALL_RES_DATA}) diff --git a/src/PVGUI/PVGUI_Module.cxx b/src/PVGUI/PVGUI_Module.cxx index 2902f451..6fa52dbe 100644 --- a/src/PVGUI/PVGUI_Module.cxx +++ b/src/PVGUI/PVGUI_Module.cxx @@ -476,7 +476,7 @@ void PVGUI_Module::showView( bool toShow ) // this also connects to the pvserver and instantiates relevant PV behaviors } - pvWnd->setShown( toShow ); + pvWnd->setVisible( toShow ); if ( toShow ) pvWnd->setFocus(); } @@ -513,7 +513,7 @@ void PVGUI_Module::endWaitCursor() { QApplication::restoreOverrideCursor(); } - +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) /*! \brief Handler method for the output of messages. */ @@ -535,7 +535,29 @@ static void ParavisMessageOutput(QtMsgType type, const char *msg) break; } } - +#else +/*! + \brief Handler method for the output of messages. +*/ +static void ParavisMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) +{ + switch(type) + { + case QtDebugMsg: + vtkOutputWindow::GetInstance()->DisplayText(msg.toLatin1().constData()); + break; + case QtWarningMsg: + vtkOutputWindow::GetInstance()->DisplayErrorText(msg.toLatin1().constData()); + break; + case QtCriticalMsg: + vtkOutputWindow::GetInstance()->DisplayErrorText(msg.toLatin1().constData()); + break; + case QtFatalMsg: + vtkOutputWindow::GetInstance()->DisplayErrorText(msg.toLatin1().constData()); + break; + } +} +#endif /*! \brief Activate module. \param study current study @@ -544,8 +566,11 @@ static void ParavisMessageOutput(QtMsgType type, const char *msg) */ bool PVGUI_Module::activateModule( SUIT_Study* study ) { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) myOldMsgHandler = qInstallMsgHandler(ParavisMessageOutput); - +#else + myOldMsgHandler = qInstallMessageHandler(ParavisMessageOutput); +#endif SUIT_ExceptionHandler::addCleanUpRoutine( paravisCleanUp ); storeCommonWindowsState(); @@ -643,8 +668,11 @@ bool PVGUI_Module::deactivateModule( SUIT_Study* study ) SUIT_ExceptionHandler::removeCleanUpRoutine( paravisCleanUp ); if (myOldMsgHandler) +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) qInstallMsgHandler(myOldMsgHandler); - +#else + qInstallMessageHandler(myOldMsgHandler); +#endif restoreCommonWindowsState(); return LightApp_Module::deactivateModule( study ); diff --git a/src/PVGUI/PVGUI_Module.h b/src/PVGUI/PVGUI_Module.h index 7c1a8642..64fe6442 100644 --- a/src/PVGUI/PVGUI_Module.h +++ b/src/PVGUI/PVGUI_Module.h @@ -217,9 +217,11 @@ private: typedef QMap DockWindowMap; DockWindowMap myCommonMap; - +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) QtMsgHandler myOldMsgHandler; - +#else + QtMessageHandler myOldMsgHandler; +#endif vtkEventQtSlotConnect* VTKConnect; pqPythonScriptEditor* myTraceWindow; diff --git a/src/Plugins/ArrayRenamer/CMakeLists.txt b/src/Plugins/ArrayRenamer/CMakeLists.txt index c70f45ad..4c839fd1 100644 --- a/src/Plugins/ArrayRenamer/CMakeLists.txt +++ b/src/Plugins/ArrayRenamer/CMakeLists.txt @@ -22,13 +22,14 @@ PROJECT(ArrayRenamer) cmake_minimum_required(VERSION 2.8) +INCLUDE(UseQtExt) FIND_PACKAGE(ParaView REQUIRED) INCLUDE(${PARAVIEW_USE_FILE}) SET (outifaces) SET (outsrcs) -QT4_WRAP_CPP(moc_srcs pqArraysEditorPropertyWidget.h pqEditComponents.h) +QT_WRAP_MOC(moc_srcs pqArraysEditorPropertyWidget.h pqEditComponents.h) ADD_PARAVIEW_PROPERTY_GROUP_WIDGET(outifaces outsrcs TYPE "custom_arrays_editor" diff --git a/src/Plugins/ArrayRenamer/pqArraysEditorPropertyWidget.cxx b/src/Plugins/ArrayRenamer/pqArraysEditorPropertyWidget.cxx index 2de62af5..34db0376 100644 --- a/src/Plugins/ArrayRenamer/pqArraysEditorPropertyWidget.cxx +++ b/src/Plugins/ArrayRenamer/pqArraysEditorPropertyWidget.cxx @@ -435,9 +435,13 @@ pqEditComponents::pqEditComponents( pqComponentsModel* model, QWidget* parent ) QTableView* componentsTable = new QTableView( this ); componentsTable->setModel( model ); aCompsLayout->addWidget( componentsTable ); +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) componentsTable->horizontalHeader()->setResizeMode( pqComponentsModel::COMPONENT_NAME, QHeaderView::Stretch ); componentsTable->horizontalHeader()->setResizeMode( pqComponentsModel::NEW_COMPONENT_NAME, QHeaderView::Stretch ); - +#else + componentsTable->horizontalHeader()->setSectionResizeMode( pqComponentsModel::COMPONENT_NAME, QHeaderView::Stretch ); + componentsTable->horizontalHeader()->setSectionResizeMode( pqComponentsModel::NEW_COMPONENT_NAME, QHeaderView::Stretch ); +#endif /// Parameters QVBoxLayout *aParamsLayout = new QVBoxLayout( aParams ); myRenameAllComps = new QCheckBox( "Rename all similar Components", aParams ); @@ -486,10 +490,17 @@ pqArraysEditorPropertyWidget::pqArraysEditorPropertyWidget( vtkSMProxy* smproxy, // Layout QVBoxLayout* lay = new QVBoxLayout(this); lay->addWidget(myArraysTable); +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) myArraysTable->horizontalHeader()->setResizeMode( pqArraysModel::PROCESSING, QHeaderView::ResizeToContents ); myArraysTable->horizontalHeader()->setResizeMode( pqArraysModel::NAME, QHeaderView::Stretch); myArraysTable->horizontalHeader()->setResizeMode( pqArraysModel::NEW_NAME, QHeaderView::Stretch ); myArraysTable->horizontalHeader()->setResizeMode( pqArraysModel::COMPONENTS, QHeaderView::ResizeToContents ); +#else + myArraysTable->horizontalHeader()->setSectionResizeMode( pqArraysModel::PROCESSING, QHeaderView::ResizeToContents ); + myArraysTable->horizontalHeader()->setSectionResizeMode( pqArraysModel::NAME, QHeaderView::Stretch); + myArraysTable->horizontalHeader()->setSectionResizeMode( pqArraysModel::NEW_NAME, QHeaderView::Stretch ); + myArraysTable->horizontalHeader()->setSectionResizeMode( pqArraysModel::COMPONENTS, QHeaderView::ResizeToContents ); +#endif myArraysTable->resizeColumnsToContents(); // Connections diff --git a/src/Plugins/MEDReader/ParaViewPlugin/CMakeLists.txt b/src/Plugins/MEDReader/ParaViewPlugin/CMakeLists.txt index 65991d57..cd4feaf4 100644 --- a/src/Plugins/MEDReader/ParaViewPlugin/CMakeLists.txt +++ b/src/Plugins/MEDReader/ParaViewPlugin/CMakeLists.txt @@ -21,7 +21,7 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/../IO ) IF(PARAVIEW_BUILD_QT_GUI) - QT4_WRAP_UI(CLIENT_UI_SRCS + QT_WRAP_UIC(CLIENT_UI_SRCS Resources/UI/MEDReaderVectorsWidget.ui Resources/UI/MEDReaderTimeModeWidget.ui) @@ -41,7 +41,7 @@ IF(PARAVIEW_BUILD_QT_GUI) pqMEDReaderTimesFlagsWidget.cxx pqMEDReaderFieldsWidget.cxx) - QT4_WRAP_CPP(MOC_SRCS + QT_WRAP_MOC(MOC_SRCS pqExtractGroupFieldsWidget.h pqAbstractFieldsWidget.h VectBoolSpreadSheet.h diff --git a/src/Plugins/MEDReader/ParaViewPlugin/VectBoolSpreadSheet.cxx b/src/Plugins/MEDReader/ParaViewPlugin/VectBoolSpreadSheet.cxx index b878cbb3..286fe5dc 100644 --- a/src/Plugins/MEDReader/ParaViewPlugin/VectBoolSpreadSheet.cxx +++ b/src/Plugins/MEDReader/ParaViewPlugin/VectBoolSpreadSheet.cxx @@ -217,8 +217,13 @@ void VectBoolSpreadSheet::init() this->verticalHeader()->setMinimumSectionSize(2); this->verticalHeader()->setDefaultSectionSize(2); this->setItemDelegate(_delegate); +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) this->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents); this->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); +#else + this->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); + this->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); +#endif this->resizeColumnsToContents(); this->resizeRowsToContents(); //this->verticalHeader()->hide(); diff --git a/src/Plugins/TableReader/ParaViewPlugin/CMakeLists.txt b/src/Plugins/TableReader/ParaViewPlugin/CMakeLists.txt index 1b758fe2..2892bbc3 100644 --- a/src/Plugins/TableReader/ParaViewPlugin/CMakeLists.txt +++ b/src/Plugins/TableReader/ParaViewPlugin/CMakeLists.txt @@ -19,14 +19,15 @@ IF(PARAVIEW_BUILD_QT_GUI) + INCLUDE(UseQtExt) # Custom object panel for the reader and # custom display panel for line chart view - QT4_WRAP_UI(CLIENT_UI_SRCS + QT_WRAP_UIC(CLIENT_UI_SRCS Resources/UI/TableReaderPanel.ui Resources/UI/CustomXYChartDisplayPanel.ui ) - QT4_WRAP_CPP(MOC_SRCS + QT_WRAP_MOC(MOC_SRCS pqTableReaderPanel.h pqTableTo3DPanel.h pqCustomChartDisplayPanelImplementation.h diff --git a/src/Plugins/View/CMakeLists.txt b/src/Plugins/View/CMakeLists.txt index f7a12533..68ee2e0a 100755 --- a/src/Plugins/View/CMakeLists.txt +++ b/src/Plugins/View/CMakeLists.txt @@ -17,11 +17,13 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # +INCLUDE(UseQtExt) + # create a plugin with a custom view that shows up in ParaView's multi-view # manager. this plugin also contains a custom display panel # moc the Qt based .h files -QT4_WRAP_CPP(MOC_SRCS MyView.h MyDisplay.h MyViewActiveOptions.h MyViewOptions.h) +QT_WRAP_MOC(MOC_SRCS MyView.h MyDisplay.h MyViewActiveOptions.h MyViewOptions.h) # invoke macro to create sources for our custom view and display panel ADD_PARAVIEW_VIEW_MODULE( diff --git a/test/standalone/CMakeLists.txt b/test/standalone/CMakeLists.txt index f8c18436..9479e3fe 100644 --- a/test/standalone/CMakeLists.txt +++ b/test/standalone/CMakeLists.txt @@ -25,7 +25,12 @@ SET(CMAKE_BUILD_TYPE "Debug") OPTION(LIGHTPARAVIS_WITH_GUI "Build GUI test app" ON) # Package detection -FIND_PACKAGE(Qt4 REQUIRED) +IF (NOT SALOME_GUI_BUILD_WITH_QT5) + FIND_PACKAGE(Qt4 REQUIRED) +ELSE() + FIND_PACKAGE(Qt5Core) + FIND_PACKAGE(Qt5Gui) +ENDIF() LIST(APPEND CMAKE_PREFIX_PATH "$ENV{PARAVIEW_ROOT_DIR}") FIND_PACKAGE(ParaView REQUIRED) diff --git a/test/standalone/gui/CMakeLists.txt b/test/standalone/gui/CMakeLists.txt index 29579851..91b56427 100644 --- a/test/standalone/gui/CMakeLists.txt +++ b/test/standalone/gui/CMakeLists.txt @@ -18,6 +18,8 @@ # # Author: Adrien Bruneton (CEA) +INCLUDE(UseQtExt) + SET(pl_HEADERS PLMainWindow.hxx PLViewTab.hxx @@ -47,7 +49,6 @@ SET(CMAKE_INCLUDE_CURRENT_DIR ON) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) INCLUDE_DIRECTORIES(${PARAVIEW_INCLUDE_DIRS}) -INCLUDE(${QT_USE_FILE}) ADD_DEFINITIONS(${QT_DEFINITIONS}) # Generate resources that will embedded @@ -59,11 +60,11 @@ GENERATE_QT_RESOURCE_FROM_FILES( "/LightPara/Configuration" "${PROJECT_SOURCE_DIR}/gui/xml/ParaViewReaders.xml") -QT4_ADD_RESOURCES(rcs_sources +QT_ADD_RESOURCES(rcs_sources ${ui_resources} ) -QT4_WRAP_UI(pl_FORMS_HEADERS ${pl_FORMS}) -QT4_WRAP_CPP(pl_HEADERS_MOC ${pl_HEADERS}) +QT_WRAP_UIC(pl_FORMS_HEADERS ${pl_FORMS}) +QT_WRAP_MOC(pl_HEADERS_MOC ${pl_HEADERS}) ADD_EXECUTABLE(paraLight ${pl_SOURCES} -- 2.39.2