From: Rene Gassmoeller Date: Fri, 23 Jun 2017 23:17:04 +0000 (-0600) Subject: Make compile with and use Qt5 by default. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de53718a80f3d686befd1779fa08f758b0a8a245;p=parameter_gui.git Make compile with and use Qt5 by default. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a702c0..f291d9a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,24 +20,44 @@ IF("${DEAL_II_EXECUTABLE_RELDIR}" STREQUAL "") SET(DEAL_II_EXECUTABLE_RELDIR "bin") ENDIF() -FIND_PACKAGE(Qt4 REQUIRED QtCore QtGui QtXml) -MARK_AS_ADVANCED(QT_QMAKE_EXECUTABLE) +FIND_PACKAGE(Qt5 COMPONENTS Core Gui Xml Widgets) + +IF(${Qt5_FOUND}) +ELSE() + FIND_PACKAGE(Qt4 REQUIRED QtCore QtGui QtXml) + INCLUDE(${QT_USE_FILE}) +ENDIF() -INCLUDE(${QT_USE_FILE}) +MARK_AS_ADVANCED(QT_QMAKE_EXECUTABLE) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) -QT4_WRAP_CPP(SOURCE_MOC - browse_lineedit.h - info_message.h - settings_dialog.h - mainwindow.h - parameter_delegate.h - ) +IF(${Qt5_FOUND}) + QT5_WRAP_CPP(SOURCE_MOC + browse_lineedit.h + info_message.h + settings_dialog.h + mainwindow.h + parameter_delegate.h + ) + + QT5_ADD_RESOURCES(SOURCE_RCC + application.qrc + ) +ELSE() + QT4_WRAP_CPP(SOURCE_MOC + browse_lineedit.h + info_message.h + settings_dialog.h + mainwindow.h + parameter_delegate.h + ) + + QT4_ADD_RESOURCES(SOURCE_RCC + application.qrc + ) +ENDIF() -QT4_ADD_RESOURCES(SOURCE_RCC - application.qrc - ) ADD_EXECUTABLE(parameter_gui_exe browse_lineedit.cpp @@ -68,3 +88,7 @@ EXPORT(TARGETS parameter_gui_exe ${CMAKE_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}Targets.cmake APPEND ) + +IF(${Qt5_FOUND}) + QT5_USE_MODULES(parameter_gui_exe Core Gui Xml Widgets) +ENDIF() diff --git a/browse_lineedit.cpp b/browse_lineedit.cpp index e35abde..26eb2c9 100644 --- a/browse_lineedit.cpp +++ b/browse_lineedit.cpp @@ -13,11 +13,13 @@ // // --------------------------------------------------------------------- - -#include - #include "browse_lineedit.h" +#if QT_VERSION >= 0x050000 +#include +#else +#include +#endif namespace dealii { diff --git a/info_message.cpp b/info_message.cpp index 20ce137..028a99a 100644 --- a/info_message.cpp +++ b/info_message.cpp @@ -14,10 +14,13 @@ // --------------------------------------------------------------------- -#include - #include "info_message.h" +#if QT_VERSION >= 0x050000 +#include +#else +#include +#endif namespace dealii { diff --git a/mainwindow.cpp b/mainwindow.cpp index 24d0077..fe8686c 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -14,14 +14,17 @@ // --------------------------------------------------------------------- -#include - #include "mainwindow.h" #include "parameter_delegate.h" #include "xml_parameter_reader.h" #include "xml_parameter_writer.h" #include "prm_parameter_writer.h" +#if QT_VERSION >= 0x050000 +#include +#else +#include +#endif namespace dealii { @@ -36,7 +39,11 @@ namespace dealii tree_widget = new QTreeWidget; // Setup the tree and the window first: +#if QT_VERSION >= 0x050000 + tree_widget->header()->setSectionResizeMode(QHeaderView::ResizeToContents); +#else tree_widget->header()->setResizeMode(QHeaderView::ResizeToContents); +#endif tree_widget->setHeaderLabels(QStringList() << tr("(Sub)Sections/Parameters") << tr("Value")); diff --git a/parameter_delegate.cpp b/parameter_delegate.cpp index 98b71c0..1b68c0b 100644 --- a/parameter_delegate.cpp +++ b/parameter_delegate.cpp @@ -14,12 +14,15 @@ // --------------------------------------------------------------------- -#include - #include "parameter_delegate.h" #include +#if QT_VERSION >= 0x050000 +#include +#else +#include +#endif namespace dealii { diff --git a/prm_parameter_writer.cpp b/prm_parameter_writer.cpp index e5d1777..4ef1ef9 100644 --- a/prm_parameter_writer.cpp +++ b/prm_parameter_writer.cpp @@ -14,10 +14,13 @@ // --------------------------------------------------------------------- -#include - #include "prm_parameter_writer.h" +#if QT_VERSION >= 0x050000 +#include +#else +#include +#endif namespace dealii { @@ -36,7 +39,7 @@ namespace dealii for (int i = 0; i < tree_widget->topLevelItemCount(); ++i) { const QString item_string = item_to_string(tree_widget->topLevelItem(i),0); - device->write(item_string.toAscii()); + device->write(item_string.toLatin1()); } return true; @@ -75,7 +78,7 @@ namespace dealii if (!item_string.isEmpty()) { - item_string.push_front("subsection " + item->text(0).toAscii() + "\n"); + item_string.push_front("subsection " + item->text(0).toLatin1() + "\n"); for (unsigned int i=0; i - #include "settings_dialog.h" +#if QT_VERSION >= 0x050000 +#include +#else +#include +#endif namespace dealii { diff --git a/xml_parameter_reader.cpp b/xml_parameter_reader.cpp index ea1f32c..dac8d5d 100644 --- a/xml_parameter_reader.cpp +++ b/xml_parameter_reader.cpp @@ -14,10 +14,13 @@ // --------------------------------------------------------------------- -#include - #include "xml_parameter_reader.h" +#if QT_VERSION >= 0x050000 +#include +#else +#include +#endif namespace dealii { diff --git a/xml_parameter_writer.cpp b/xml_parameter_writer.cpp index cbaa9e4..fccd1af 100644 --- a/xml_parameter_writer.cpp +++ b/xml_parameter_writer.cpp @@ -14,10 +14,13 @@ // --------------------------------------------------------------------- -#include - #include "xml_parameter_writer.h" +#if QT_VERSION >= 0x050000 +#include +#else +#include +#endif namespace dealii {