more required changes for Qt6 compatibility

This commit is contained in:
jkriege2 2022-04-22 13:27:31 +02:00
parent 6bcb0b9a9f
commit 0a5fa42470
70 changed files with 471 additions and 224 deletions

View File

@ -1,8 +1,5 @@
cmake_minimum_required(VERSION 3.1) cmake_minimum_required(VERSION 3.1)
# configure compiler
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED on)
if(NOT APPLE) if(NOT APPLE)
set(CMAKE_INSTALL_RPATH $ORIGIN) set(CMAKE_INSTALL_RPATH $ORIGIN)

View File

@ -6,7 +6,15 @@ set(CMAKE_AUTOUIC ON)
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED) find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED) find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED)
if(${QT_VERSION_MAJOR}>=6) if(${QT_VERSION_MAJOR} VERSION_GREATER_EQUAL "6")
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS OpenGLWidgets REQUIRED) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS OpenGLWidgets)
endif()
# configure compiler
if(${QT_VERSION_MAJOR} VERSION_LESS "6" )
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED on)
else()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED on)
endif() endif()

View File

@ -3,13 +3,26 @@ function(jkqtplotter_deployqt TARGET_NAME)
if (WIN32) if (WIN32)
get_target_property(_qmake_executable Qt${QT_VERSION_MAJOR}::qmake IMPORTED_LOCATION) get_target_property(_qmake_executable Qt${QT_VERSION_MAJOR}::qmake IMPORTED_LOCATION)
get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY) get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY)
find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${_qt_bin_dir}") find_program(WINDEPLOYQT_ENV_SETUP qtenv2.bat HINTS "${_qt_bin_dir}")
set(WINDEPLOYQTOPTION "--release")
if (CMAKE_BUILD_TYPE STREQUAL "Debug") if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(WINDEPLOYQTOPTION "--debug") find_program(WINDEPLOYQT_EXECUTABLE NAMES windeployqt.debug.bat HINTS "${_qt_bin_dir}")
else()
find_program(WINDEPLOYQT_EXECUTABLE NAMES windeployqt HINTS "${_qt_bin_dir}")
endif() endif()
if(${QT_VERSION_MAJOR} VERSION_GREATER_EQUAL "6")
set(WINDEPLOYQTOPTION "")
set(WINDEPLOYQTPACKAGES "")
else()
set(WINDEPLOYQTOPTION "--release --compiler-runtime")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(WINDEPLOYQTOPTION "--debug --compiler-runtime")
endif()
set(WINDEPLOYQTPACKAGES "-xml -printsupport -svg -opengl")
endif()
# install system runtime lib # install system runtime lib
include( InstallRequiredSystemLibraries ) include( InstallRequiredSystemLibraries )
if( CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS ) if( CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS )
@ -18,13 +31,7 @@ function(jkqtplotter_deployqt TARGET_NAME)
get_filename_component(CMAKE_CXX_COMPILER_BINPATH ${CMAKE_CXX_COMPILER} DIRECTORY ) get_filename_component(CMAKE_CXX_COMPILER_BINPATH ${CMAKE_CXX_COMPILER} DIRECTORY )
add_custom_command(TARGET ${TARGET_NAME} POST_BUILD add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E COMMAND "${WINDEPLOYQT_ENV_SETUP}" && "${WINDEPLOYQT_EXECUTABLE}" ${WINDEPLOYQTOPTION} ${WINDEPLOYQTPACKAGES} \"$<TARGET_FILE:${TARGET_NAME}>\"
env PATH="${CMAKE_CXX_COMPILER_BINPATH}\;${_qt_bin_dir}" "${WINDEPLOYQT_EXECUTABLE}"
--compiler-runtime
-xml
-printsupport
${WINDEPLOYQTOPTION}
\"$<TARGET_FILE:${TARGET_NAME}>\"
COMMENT "Running windeployqt ... " COMMENT "Running windeployqt ... "
) )
endif(WIN32) endif(WIN32)

View File

@ -14,7 +14,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -103,7 +103,8 @@ void doExample()
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -12,7 +12,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -20,7 +20,7 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -13,7 +13,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -19,7 +19,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -13,7 +13,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -19,7 +19,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -19,7 +19,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -19,7 +19,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -169,7 +169,8 @@ void drawWithTimeAxis(JKQTPlotter& plot) {
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -18,7 +18,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -13,7 +13,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -14,7 +14,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -11,7 +11,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -135,7 +135,8 @@ void drawExample(QApplication& app, const QString& name) {
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -13,7 +13,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -85,7 +85,8 @@ void drawEllExample(JKQTPlotter* plot, double x0, double y0, double wid, double
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -13,7 +13,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -13,7 +13,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -12,7 +12,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -12,7 +12,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -18,7 +18,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -14,7 +14,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -12,7 +12,7 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -4,7 +4,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -6,7 +6,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -15,7 +15,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -13,7 +13,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -16,7 +16,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -12,7 +12,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -12,7 +12,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -13,7 +13,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -18,7 +18,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -14,7 +14,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -15,7 +15,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -12,13 +12,15 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -8,7 +8,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -103,7 +103,8 @@ void addGraph(JKQTPlotter& plot, bool swapXY) {
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -13,7 +13,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -12,7 +12,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -6,7 +6,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -14,7 +14,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -13,7 +13,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -5,7 +5,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -5,7 +5,8 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -164,7 +164,8 @@ JKQTPlotter* showPlot() {
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
#endif #endif

View File

@ -10,7 +10,10 @@ message( STATUS "Version: ${PROJECT_VERSION}")
if (CMAKE_BUILD_TYPE) if (CMAKE_BUILD_TYPE)
message( STATUS "Build type: ${CMAKE_BUILD_TYPE}") message( STATUS "Build type: ${CMAKE_BUILD_TYPE}")
endif(CMAKE_BUILD_TYPE) endif(CMAKE_BUILD_TYPE)
message( STATUS "Using compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}" ) message( STATUS "Using CMake: ${CMAKE_VERSION}")
message( STATUS " Generator: ${CMAKE_GENERATOR}")
message( STATUS "Using compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}, platform: ${CMAKE_CXX_PLATFORM_ID}" )
message( STATUS "C++ Standard: C++${CMAKE_CXX_STANDARD}, required: ${CMAKE_CXX_STANDARD_REQUIRED}" )
message( STATUS "Architecture: ${CMAKE_CXX_LIBRARY_ARCHITECTURE} / ${CMAKE_LIBRARY_ARCHITECTURE}" ) message( STATUS "Architecture: ${CMAKE_CXX_LIBRARY_ARCHITECTURE} / ${CMAKE_LIBRARY_ARCHITECTURE}" )
message( STATUS "System Name: ${CMAKE_SYSTEM_NAME}" ) message( STATUS "System Name: ${CMAKE_SYSTEM_NAME}" )
message( STATUS "Processor Name: ${CMAKE_SYSTEM_PROCESSOR}" ) message( STATUS "Processor Name: ${CMAKE_SYSTEM_PROCESSOR}" )

View File

@ -100,9 +100,15 @@ if(JKQtPlotter_BUILD_SHARED_LIBS)
target_link_libraries(${libsh_name} PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Xml Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::PrintSupport) target_link_libraries(${libsh_name} PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Xml Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::PrintSupport)
target_compile_definitions(${libsh_name} PUBLIC JKQTCOMMON_LIB_IN_DLL) target_compile_definitions(${libsh_name} PUBLIC JKQTCOMMON_LIB_IN_DLL)
target_compile_definitions(${libsh_name} PRIVATE JKQTCOMMON_LIB_EXPORT_LIBRARY) target_compile_definitions(${libsh_name} PRIVATE JKQTCOMMON_LIB_EXPORT_LIBRARY)
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 11) if(${QT_VERSION_MAJOR} VERSION_LESS "6")
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE) set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 11)
target_compile_features(${libsh_name} PUBLIC cxx_std_11) set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${libsh_name} PUBLIC cxx_std_11)
else()
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 17)
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${libsh_name} PUBLIC cxx_std_17)
endif()
if(MINGW) if(MINGW)
# COMPILER-SETTINGS FOR MINGW # COMPILER-SETTINGS FOR MINGW
target_compile_options(${libsh_name} PUBLIC -fexceptions) target_compile_options(${libsh_name} PUBLIC -fexceptions)
@ -125,9 +131,15 @@ if(JKQtPlotter_BUILD_STATIC_LIBS)
add_library(${lib_name} STATIC ${SOURCES} ${HEADERS}) add_library(${lib_name} STATIC ${SOURCES} ${HEADERS})
set_property(TARGET ${lib_name} PROPERTY VERSION "${PROJECT_VERSION}") set_property(TARGET ${lib_name} PROPERTY VERSION "${PROJECT_VERSION}")
set_property(TARGET ${lib_name} PROPERTY OUTPUT_NAME "${lib_name_decorated}") set_property(TARGET ${lib_name} PROPERTY OUTPUT_NAME "${lib_name_decorated}")
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 11) if(${QT_VERSION_MAJOR} VERSION_LESS "6")
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE) set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 11)
target_compile_features(${lib_name} PUBLIC cxx_std_11) set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${lib_name} PUBLIC cxx_std_11)
else()
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 17)
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${lib_name} PUBLIC cxx_std_17)
endif()
if(MINGW) if(MINGW)
# COMPILER-SETTINGS FOR MINGW # COMPILER-SETTINGS FOR MINGW
target_compile_options(${lib_name} PUBLIC -fexceptions) target_compile_options(${lib_name} PUBLIC -fexceptions)

View File

@ -7,8 +7,7 @@
# package requires Qt 5/6 # package requires Qt 5/6
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED) find_package(Qt@QT_VERSION_MAJOR@ COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED)
# include auto-generated targets.cmake file # include auto-generated targets.cmake file
include("${CMAKE_CURRENT_LIST_DIR}/@JKQTP_CURRENT_TARGET_FILENAME@") include("${CMAKE_CURRENT_LIST_DIR}/@JKQTP_CURRENT_TARGET_FILENAME@")

View File

@ -31,6 +31,9 @@
#else #else
# include <QDesktopWidget> # include <QDesktopWidget>
#endif #endif
#if QT_VERSION>=QT_VERSION_CHECK(6,0,0)
# include <QByteArrayView>
#endif
void jksaveWidgetGeometry(QSettings& settings, QWidget* widget, const QString& prefix) { void jksaveWidgetGeometry(QSettings& settings, QWidget* widget, const QString& prefix) {
settings.setValue(prefix+"pos", widget->pos()); settings.setValue(prefix+"pos", widget->pos());
@ -102,20 +105,19 @@ QString jkVariantListToString(const QList<QVariant>& data, const QString& separa
else r=r+v.toString(); else r=r+v.toString();
#else #else
# define QVARIANT_TYPESBASE QVariant
switch (v.type()) { switch (v.type()) {
case QVARIANT_TYPESBASE::Bool: r=r+loc.toString(v.toBool()); break; case QVariant::Bool: r=r+loc.toString(v.toBool()); break;
case QVARIANT_TYPESBASE::Char: r=r+loc.toString(v.toInt()); break; case QVariant::Char: r=r+loc.toString(v.toInt()); break;
case QVARIANT_TYPESBASE::Date: r=r+loc.toString(v.toDate()); break; case QVariant::Date: r=r+loc.toString(v.toDate()); break;
case QVARIANT_TYPESBASE::DateTime: r=r+loc.toString(v.toDateTime()); break; case QVariant::DateTime: r=r+loc.toString(v.toDateTime()); break;
case QVARIANT_TYPESBASE::Double: r=r+loc.toString(v.toDouble()); break; case QVariant::Double: r=r+loc.toString(v.toDouble()); break;
case QVARIANT_TYPESBASE::Int: r=r+loc.toString(v.toInt()); break; case QVariant::Int: r=r+loc.toString(v.toInt()); break;
case QVARIANT_TYPESBASE::LongLong: r=r+loc.toString(v.toLongLong()); break; case QVariant::LongLong: r=r+loc.toString(v.toLongLong()); break;
case QVARIANT_TYPESBASE::String: r=r+QString("\"%1\"").arg(v.toString().replace("\"", "_").replace("\t", " ").replace("\r", "").replace("\n", " ").replace(",", " ").replace(";", " ")); break; case QVariant::String: r=r+QString("\"%1\"").arg(v.toString().replace("\"", "_").replace("\t", " ").replace("\r", "").replace("\n", " ").replace(",", " ").replace(";", " ")); break;
case QVARIANT_TYPESBASE::Time: r=r+loc.toString(v.toTime()); break; case QVariant::Time: r=r+loc.toString(v.toTime()); break;
case QVARIANT_TYPESBASE::UInt: r=r+loc.toString(v.toUInt()); break; case QVariant::UInt: r=r+loc.toString(v.toUInt()); break;
case QVARIANT_TYPESBASE::ULongLong: r=r+loc.toString(v.toULongLong()); break; case QVariant::ULongLong: r=r+loc.toString(v.toULongLong()); break;
//case : r=r+loc.toString(v.); break; //case : r=r+loc.toString(v.); break;
default: r=r+v.toString(); break; default: r=r+v.toString(); break;
} }
@ -266,3 +268,12 @@ Qt::MouseButton jkqtp_String2MouseButton(const QString &button)
if (but=="EXTRA24") return Qt::ExtraButton24; if (but=="EXTRA24") return Qt::ExtraButton24;
return Qt::NoButton; return Qt::NoButton;
} }
quint16 jkqtp_checksum(const void *data, size_t len)
{
#if QT_VERSION>=QT_VERSION_CHECK(6,0,0)
return qChecksum(QByteArrayView(static_cast<const uint8_t*>(data), len));
#else
return qChecksum(data, len);
#endif
}

View File

@ -134,6 +134,12 @@ JKQTCOMMON_LIB_EXPORT QString jkqtp_MouseButton2String(Qt::MouseButton button, b
* \see jkqtp_MouseButton2String() * \see jkqtp_MouseButton2String()
*/ */
JKQTCOMMON_LIB_EXPORT Qt::MouseButton jkqtp_String2MouseButton(const QString &button); JKQTCOMMON_LIB_EXPORT Qt::MouseButton jkqtp_String2MouseButton(const QString &button);
/** \brief convert a <a href="http://doc.qt.io/qt-5/qstring.html">QString</a> (created by jkqtp_MouseButton2String() ) to <a href="http://doc.qt.io/qt-5/qt.html#MouseButton-enum">Qt::MouseButton</a>
* \ingroup tools
*
* \see jkqtp_MouseButton2String()
*/
JKQTCOMMON_LIB_EXPORT quint16 jkqtp_checksum(const void* data, size_t len);
#endif // JKQTTOOLS_H #endif // JKQTTOOLS_H

View File

@ -21,7 +21,7 @@ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
# Set up source files # Set up source files
set(SOURCES set(SOURCES
jkqtfastplotter.cpp ${CMAKE_CURRENT_LIST_DIR}/jkqtfastplotter.cpp
) )
set(HEADERS set(HEADERS
@ -40,10 +40,17 @@ if(JKQtPlotter_BUILD_SHARED_LIBS)
set_property(TARGET ${libsh_name} PROPERTY VERSION "${PROJECT_VERSION}") set_property(TARGET ${libsh_name} PROPERTY VERSION "${PROJECT_VERSION}")
set_property(TARGET ${libsh_name} PROPERTY OUTPUT_NAME "${libsh_name_decorated}") set_property(TARGET ${libsh_name} PROPERTY OUTPUT_NAME "${libsh_name_decorated}")
target_link_libraries(${libsh_name} PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::PrintSupport Qt${QT_VERSION_MAJOR}::OpenGL JKQTCommonSharedLib) target_link_libraries(${libsh_name} PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::PrintSupport Qt${QT_VERSION_MAJOR}::OpenGL JKQTCommonSharedLib)
if(${QT_VERSION_MAJOR} VERSION_LESS "6")
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${libsh_name} PUBLIC cxx_std_11)
else()
target_link_libraries(${libsh_name} PUBLIC Qt${QT_VERSION_MAJOR}::OpenGLWidgets)
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 17)
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${libsh_name} PUBLIC cxx_std_17)
endif()
target_compile_definitions(${libsh_name} PUBLIC JKQTFASTPLOTTER_LIB_IN_DLL) target_compile_definitions(${libsh_name} PUBLIC JKQTFASTPLOTTER_LIB_IN_DLL)
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${libsh_name} PUBLIC cxx_std_11)
if(MINGW) if(MINGW)
# COMPILER-SETTINGS FOR MINGW # COMPILER-SETTINGS FOR MINGW
target_compile_options(${libsh_name} PUBLIC -fexceptions) target_compile_options(${libsh_name} PUBLIC -fexceptions)
@ -67,8 +74,6 @@ if(JKQtPlotter_BUILD_STATIC_LIBS)
add_library(${lib_name} STATIC ${SOURCES} ${RESOURCES} ${HEADERS}) add_library(${lib_name} STATIC ${SOURCES} ${RESOURCES} ${HEADERS})
set_property(TARGET ${lib_name} PROPERTY VERSION "${PROJECT_VERSION}") set_property(TARGET ${lib_name} PROPERTY VERSION "${PROJECT_VERSION}")
set_property(TARGET ${lib_name} PROPERTY OUTPUT_NAME "${lib_name_decorated}") set_property(TARGET ${lib_name} PROPERTY OUTPUT_NAME "${lib_name_decorated}")
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
if(MINGW) if(MINGW)
# COMPILER-SETTINGS FOR MINGW # COMPILER-SETTINGS FOR MINGW
target_compile_options(${lib_name} PUBLIC -fexceptions) target_compile_options(${lib_name} PUBLIC -fexceptions)
@ -77,10 +82,16 @@ if(JKQtPlotter_BUILD_STATIC_LIBS)
target_compile_options(${lib_name} PUBLIC /EHsc) target_compile_options(${lib_name} PUBLIC /EHsc)
target_compile_definitions(${lib_name} PUBLIC NOMINMAX) target_compile_definitions(${lib_name} PUBLIC NOMINMAX)
endif() endif()
target_compile_features(${lib_name} PUBLIC cxx_std_11)
target_link_libraries(${lib_name} PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::PrintSupport Qt${QT_VERSION_MAJOR}::OpenGL JKQTCommonLib) target_link_libraries(${lib_name} PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::PrintSupport Qt${QT_VERSION_MAJOR}::OpenGL JKQTCommonLib)
if(${QT_VERSION_MAJOR}>=6) if(${QT_VERSION_MAJOR} VERSION_LESS "6")
target_link_libraries(${lib_name} PUBLIC t${QT_VERSION_MAJOR}::OpenGLWidgets) set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${lib_name} PUBLIC cxx_std_11)
else()
target_link_libraries(${lib_name} PUBLIC Qt${QT_VERSION_MAJOR}::OpenGLWidgets)
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 17)
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${lib_name} PUBLIC cxx_std_17)
endif() endif()
target_include_directories(${lib_name} PUBLIC target_include_directories(${lib_name} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/../> $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/../>

View File

@ -7,8 +7,10 @@
# package requires Qt 5/6 # package requires Qt 5/6
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED) find_package(Qt@QT_VERSION_MAJOR@ COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED) if(${QT_VERSION_MAJOR} VERSION_GREATER_EQUAL "6")
find_package(Qt@QT_VERSION_MAJOR@ REQUIRED COMPONENTS OpenGLWidgets)
endif()
find_package(JKQTCommon@JKQTP_CURRENT_TARGET_SHAREDPART@Lib REQUIRED PATHS ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_MODULE_PATH}) find_package(JKQTCommon@JKQTP_CURRENT_TARGET_SHAREDPART@Lib REQUIRED PATHS ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_MODULE_PATH})
# include auto-generated targets.cmake file # include auto-generated targets.cmake file

View File

@ -47,9 +47,15 @@ if(JKQtPlotter_BUILD_SHARED_LIBS)
target_link_libraries(${libsh_name} PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::PrintSupport JKQTCommonSharedLib) target_link_libraries(${libsh_name} PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::PrintSupport JKQTCommonSharedLib)
target_compile_definitions(${libsh_name} PUBLIC JKQTMATHTEXT_LIB_IN_DLL) target_compile_definitions(${libsh_name} PUBLIC JKQTMATHTEXT_LIB_IN_DLL)
target_compile_definitions(${libsh_name} PRIVATE JKQTMATHTEXT_LIB_EXPORT_LIBRARY) target_compile_definitions(${libsh_name} PRIVATE JKQTMATHTEXT_LIB_EXPORT_LIBRARY)
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 11) if(${QT_VERSION_MAJOR} VERSION_LESS "6")
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE) set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 11)
target_compile_features(${libsh_name} PUBLIC cxx_std_11) set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${libsh_name} PUBLIC cxx_std_11)
else()
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 17)
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${libsh_name} PUBLIC cxx_std_17)
endif()
if(MINGW) if(MINGW)
# COMPILER-SETTINGS FOR MINGW # COMPILER-SETTINGS FOR MINGW
target_compile_options(${libsh_name} PUBLIC -fexceptions) target_compile_options(${libsh_name} PUBLIC -fexceptions)
@ -75,9 +81,15 @@ if(JKQtPlotter_BUILD_STATIC_LIBS)
add_library(${lib_name} STATIC ${SOURCES} ${RESOURCES} ${HEADERS}) add_library(${lib_name} STATIC ${SOURCES} ${RESOURCES} ${HEADERS})
set_property(TARGET ${lib_name} PROPERTY VERSION "${PROJECT_VERSION}") set_property(TARGET ${lib_name} PROPERTY VERSION "${PROJECT_VERSION}")
set_property(TARGET ${lib_name} PROPERTY OUTPUT_NAME "${lib_name_decorated}") set_property(TARGET ${lib_name} PROPERTY OUTPUT_NAME "${lib_name_decorated}")
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 11) if(${QT_VERSION_MAJOR} VERSION_LESS "6")
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE) set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 11)
target_compile_features(${lib_name} PUBLIC cxx_std_11) set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${lib_name} PUBLIC cxx_std_11)
else()
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 17)
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${lib_name} PUBLIC cxx_std_17)
endif()
if(MINGW) if(MINGW)
# COMPILER-SETTINGS FOR MINGW # COMPILER-SETTINGS FOR MINGW
target_compile_options(${lib_name} PUBLIC -fexceptions) target_compile_options(${lib_name} PUBLIC -fexceptions)

View File

@ -7,8 +7,7 @@
# package requires Qt 5/6 # package requires Qt 5/6
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED) find_package(Qt@QT_VERSION_MAJOR@ COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED)
find_package(JKQTCommon@JKQTP_CURRENT_TARGET_SHAREDPART@Lib REQUIRED PATHS ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_MODULE_PATH}) find_package(JKQTCommon@JKQTP_CURRENT_TARGET_SHAREDPART@Lib REQUIRED PATHS ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_MODULE_PATH})

View File

@ -1194,14 +1194,16 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject {
}; };
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
inline size_t qHash(const JKQTMathText::tbrDataH& data, size_t /*seed=0*/) {
#else
inline uint qHash(const JKQTMathText::tbrDataH& data) { inline uint qHash(const JKQTMathText::tbrDataH& data) {
return qHash(data.f.family())+qHash(data.text); #endif
return qHash(data.f.family())+qHash(data.text);
} }
/*! \brief A QLabel-derived class that draws an equation with LaTeX markup using JKQTMathText /*! \brief A QLabel-derived class that draws an equation with LaTeX markup using JKQTMathText
\ingroup jkqtmathtext \ingroup jkqtmathtext

View File

@ -202,9 +202,15 @@ if(JKQtPlotter_BUILD_SHARED_LIBS)
set_property(TARGET ${libsh_name} PROPERTY VERSION "${PROJECT_VERSION}") set_property(TARGET ${libsh_name} PROPERTY VERSION "${PROJECT_VERSION}")
set_property(TARGET ${libsh_name} PROPERTY OUTPUT_NAME "${libsh_name_decorated}") set_property(TARGET ${libsh_name} PROPERTY OUTPUT_NAME "${libsh_name_decorated}")
target_link_libraries(${libsh_name} PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::PrintSupport Qt${QT_VERSION_MAJOR}::Svg Qt${QT_VERSION_MAJOR}::Xml JKQTCommonSharedLib JKQTMathTextSharedLib) target_link_libraries(${libsh_name} PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::PrintSupport Qt${QT_VERSION_MAJOR}::Svg Qt${QT_VERSION_MAJOR}::Xml JKQTCommonSharedLib JKQTMathTextSharedLib)
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 11) if(${QT_VERSION_MAJOR} VERSION_LESS "6")
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE) set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 11)
target_compile_features(${libsh_name} PUBLIC cxx_std_11) set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${libsh_name} PUBLIC cxx_std_11)
else()
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 17)
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${libsh_name} PUBLIC cxx_std_17)
endif()
target_compile_definitions(${libsh_name} PUBLIC JKQTPLOTTER_LIB_IN_DLL) target_compile_definitions(${libsh_name} PUBLIC JKQTPLOTTER_LIB_IN_DLL)
target_compile_definitions(${libsh_name} PRIVATE JKQTPLOTTER_LIB_EXPORT_LIBRARY) target_compile_definitions(${libsh_name} PRIVATE JKQTPLOTTER_LIB_EXPORT_LIBRARY)
if(MINGW) if(MINGW)
@ -229,8 +235,15 @@ if(JKQtPlotter_BUILD_STATIC_LIBS)
add_library(${lib_name} STATIC ${SOURCES_BASE} ${SOURCES_GRAPHS} ${SOURCES_GUI} ${RESOURCES} ${HEADERS_BASE} ${HEADERS_GRAPHS} ${HEADERS_GUI}) add_library(${lib_name} STATIC ${SOURCES_BASE} ${SOURCES_GRAPHS} ${SOURCES_GUI} ${RESOURCES} ${HEADERS_BASE} ${HEADERS_GRAPHS} ${HEADERS_GUI})
set_property(TARGET ${lib_name} PROPERTY VERSION "${PROJECT_VERSION}") set_property(TARGET ${lib_name} PROPERTY VERSION "${PROJECT_VERSION}")
set_property(TARGET ${lib_name} PROPERTY OUTPUT_NAME "${lib_name_decorated}") set_property(TARGET ${lib_name} PROPERTY OUTPUT_NAME "${lib_name_decorated}")
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 11) if(${QT_VERSION_MAJOR} VERSION_LESS "6")
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE) set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${lib_name} PUBLIC cxx_std_11)
else()
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 17)
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${lib_name} PUBLIC cxx_std_17)
endif()
if(MINGW) if(MINGW)
# COMPILER-SETTINGS FOR MINGW # COMPILER-SETTINGS FOR MINGW
target_compile_options(${lib_name} PUBLIC -fexceptions) target_compile_options(${lib_name} PUBLIC -fexceptions)
@ -239,7 +252,6 @@ if(JKQtPlotter_BUILD_STATIC_LIBS)
target_compile_options(${lib_name} PUBLIC /EHsc) target_compile_options(${lib_name} PUBLIC /EHsc)
target_compile_definitions(${lib_name} PUBLIC NOMINMAX) target_compile_definitions(${lib_name} PUBLIC NOMINMAX)
endif() endif()
target_compile_features(${lib_name} PUBLIC cxx_std_11)
target_include_directories(${lib_name} PUBLIC target_include_directories(${lib_name} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/../> $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/../>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>

View File

@ -6,8 +6,7 @@
# #
# package requires Qt 5/6 # package requires Qt 5/6
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED) find_package(Qt@QT_VERSION_MAJOR@ COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED)
find_package(JKQTCommon@JKQTP_CURRENT_TARGET_SHAREDPART@Lib REQUIRED PATHS ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_MODULE_PATH}) find_package(JKQTCommon@JKQTP_CURRENT_TARGET_SHAREDPART@Lib REQUIRED PATHS ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_MODULE_PATH})
find_package(JKQTMathText@JKQTP_CURRENT_TARGET_SHAREDPART@Lib REQUIRED PATHS ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_MODULE_PATH}) find_package(JKQTMathText@JKQTP_CURRENT_TARGET_SHAREDPART@Lib REQUIRED PATHS ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_MODULE_PATH})

View File

@ -25,6 +25,7 @@
#include "jkqtcommon/jkqtpenhancedpainter.h" #include "jkqtcommon/jkqtpenhancedpainter.h"
#include "jkqtplotter/jkqtplotter.h" #include "jkqtplotter/jkqtplotter.h"
#include "jkqtcommon/jkqtpgeometrytools.h" #include "jkqtcommon/jkqtpgeometrytools.h"
#include "jkqtcommon/jkqttools.h"
#include <QDebug> #include <QDebug>
#include <QImageWriter> #include <QImageWriter>
#include <QFileDialog> #include <QFileDialog>
@ -63,7 +64,7 @@ void JKQTPContourPlot::draw(JKQTPEnhancedPainter &painter)
int64_t colChecksum=-1; int64_t colChecksum=-1;
if (data && Nx*Ny>0) { if (data && Nx*Ny>0) {
colChecksum=static_cast<int64_t>(qChecksum(reinterpret_cast<const char*>(data), static_cast<int64_t>(Nx)*static_cast<int64_t>(Ny)* static_cast<int64_t>(getSampleSize()/sizeof(char)))); colChecksum=static_cast<int64_t>(jkqtp_checksum(reinterpret_cast<const char*>(data), static_cast<int64_t>(Nx)*static_cast<int64_t>(Ny)* static_cast<int64_t>(getSampleSize()/sizeof(char))));
} }
/*if (parent && parent->getDatastore() && imageColumn>=0) { /*if (parent && parent->getDatastore() && imageColumn>=0) {
colChecksum=static_cast<int64_t>(parent->getDatastore()->getColumnChecksum(imageColumn)); colChecksum=static_cast<int64_t>(parent->getDatastore()->getColumnChecksum(imageColumn));

View File

@ -129,6 +129,26 @@ void JKQTPEnhancedTableView::copySelectionToExcel(int copyrole, bool storeHead)
if (sel.size()==1) { if (sel.size()==1) {
QVariant vdata=sel[0].data(copyrole); QVariant vdata=sel[0].data(copyrole);
QString txt=""; QString txt="";
#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0))
switch (vdata.typeId()) {
case QMetaType::Int:
case QMetaType::LongLong:
case QMetaType::UInt:
case QMetaType::ULongLong:
case QMetaType::Bool:
txt=vdata.toString();
break;
case QMetaType::Double:
txt=loc.toString(vdata.toDouble());
break;
case QMetaType::QPointF:
txt=loc.toString(vdata.toPointF().x());
break;
default:
txt=QString("\"%1\"").arg(vdata.toString().replace('"', "''").replace('\n', "\\n ").replace('\r', "\\r ").replace('\t', " "));
break;
}
#else
switch (vdata.type()) { switch (vdata.type()) {
case QVariant::Int: case QVariant::Int:
case QVariant::LongLong: case QVariant::LongLong:
@ -147,6 +167,7 @@ void JKQTPEnhancedTableView::copySelectionToExcel(int copyrole, bool storeHead)
txt=QString("\"%1\"").arg(vdata.toString().replace('"', "''").replace('\n', "\\n ").replace('\r', "\\r ").replace('\t', " ")); txt=QString("\"%1\"").arg(vdata.toString().replace('"', "''").replace('\n', "\\n ").replace('\r', "\\r ").replace('\t', " "));
break; break;
} }
#endif
QApplication::clipboard()->setText(txt); QApplication::clipboard()->setText(txt);
} else { } else {
QSet<int> rows, cols; QSet<int> rows, cols;
@ -210,6 +231,26 @@ void JKQTPEnhancedTableView::copySelectionToExcel(int copyrole, bool storeHead)
int c=collist.indexOf(sel[i].column()); int c=collist.indexOf(sel[i].column());
QVariant vdata=sel[i].data(copyrole); QVariant vdata=sel[i].data(copyrole);
QString txt=""; QString txt="";
#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0))
switch (vdata.typeId()) {
case QMetaType::Int:
case QMetaType::LongLong:
case QMetaType::UInt:
case QMetaType::ULongLong:
case QMetaType::Bool:
txt=vdata.toString();
break;
case QMetaType::Double:
txt=loc.toString(vdata.toDouble());
break;
case QMetaType::QPointF:
txt=loc.toString(vdata.toPointF().x());
break;
default:
txt=QString("\"%1\"").arg(vdata.toString().replace('"', "''").replace('\n', "\\n ").replace('\r', "\\r ").replace('\t', " "));
break;
}
#else
switch (vdata.type()) { switch (vdata.type()) {
case QVariant::Int: case QVariant::Int:
case QVariant::LongLong: case QVariant::LongLong:
@ -228,6 +269,7 @@ void JKQTPEnhancedTableView::copySelectionToExcel(int copyrole, bool storeHead)
txt=QString("\"%1\"").arg(vdata.toString().replace('"', "''").replace('\n', "\\n ").replace('\r', "\\r ").replace('\t', " ")); txt=QString("\"%1\"").arg(vdata.toString().replace('"', "''").replace('\n', "\\n ").replace('\r', "\\r ").replace('\t', " "));
break; break;
} }
#endif
int shift=0; int shift=0;
if (storeHead) shift=1; if (storeHead) shift=1;
if ((r>=0) && (c>=0) && (r<=data.size()) && (c<=colcnt))data[r+shift][c+shift]=txt; if ((r>=0) && (c>=0) && (r<=data.size()) && (c<=colcnt))data[r+shift][c+shift]=txt;
@ -256,6 +298,26 @@ void JKQTPEnhancedTableView::copySelectionToCSV(int copyrole, bool storeHead, co
if (sel.size()==1) { if (sel.size()==1) {
QVariant vdata=sel[0].data(copyrole); QVariant vdata=sel[0].data(copyrole);
QString txt=""; QString txt="";
#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0))
switch (vdata.typeId()) {
case QMetaType::Int:
case QMetaType::LongLong:
case QMetaType::UInt:
case QMetaType::ULongLong:
case QMetaType::Bool:
txt=vdata.toString();
break;
case QMetaType::Double:
txt=JKQTPDoubleToQString(vdata.toDouble(), 15, 'g', decimalpoint);
break;
case QMetaType::QPointF:
txt=JKQTPDoubleToQString(vdata.toPointF().x(), 15, 'g', decimalpoint);
break;
default:
txt=QString("\"%1\"").arg(vdata.toString().replace('"', "''").replace('\n', "\\n ").replace('\r', "\\r ").replace('\t', " "));
break;
}
#else
switch (vdata.type()) { switch (vdata.type()) {
case QVariant::Int: case QVariant::Int:
case QVariant::LongLong: case QVariant::LongLong:
@ -274,6 +336,7 @@ void JKQTPEnhancedTableView::copySelectionToCSV(int copyrole, bool storeHead, co
txt=QString("\"%1\"").arg(vdata.toString().replace('"', "''").replace('\n', "\\n ").replace('\r', "\\r ").replace('\t', " ")); txt=QString("\"%1\"").arg(vdata.toString().replace('"', "''").replace('\n', "\\n ").replace('\r', "\\r ").replace('\t', " "));
break; break;
} }
#endif
QApplication::clipboard()->setText(txt); QApplication::clipboard()->setText(txt);
} else { } else {
QSet<int> rows, cols; QSet<int> rows, cols;
@ -337,6 +400,26 @@ void JKQTPEnhancedTableView::copySelectionToCSV(int copyrole, bool storeHead, co
int c=collist.indexOf(sel[i].column()); int c=collist.indexOf(sel[i].column());
QVariant vdata=sel[i].data(copyrole); QVariant vdata=sel[i].data(copyrole);
QString txt=""; QString txt="";
#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0))
switch (vdata.typeId()) {
case QMetaType::Int:
case QMetaType::LongLong:
case QMetaType::UInt:
case QMetaType::ULongLong:
case QMetaType::Bool:
txt=vdata.toString();
break;
case QMetaType::Double:
txt=JKQTPDoubleToQString(vdata.toDouble(), 15, 'g', decimalpoint);
break;
case QMetaType::QPointF:
txt=JKQTPDoubleToQString(vdata.toPointF().x(), 15, 'g', decimalpoint);
break;
default:
txt=QString("\"%1\"").arg(vdata.toString().replace('"', "''").replace('\n', "\\n ").replace('\r', "\\r ").replace('\t', " "));
break;
}
#else
switch (vdata.type()) { switch (vdata.type()) {
case QVariant::Int: case QVariant::Int:
case QVariant::LongLong: case QVariant::LongLong:
@ -355,6 +438,7 @@ void JKQTPEnhancedTableView::copySelectionToCSV(int copyrole, bool storeHead, co
txt=QString("\"%1\"").arg(vdata.toString().replace('"', "''").replace('\n', "\\n ").replace('\r', "\\r ").replace('\t', " ")); txt=QString("\"%1\"").arg(vdata.toString().replace('"', "''").replace('\n', "\\n ").replace('\r', "\\r ").replace('\t', " "));
break; break;
} }
#endif
int shift=0; int shift=0;
if (storeHead) shift=1; if (storeHead) shift=1;
if ((r>=0) && (c>=0) && (r<=data.size()) && (c<=colcnt))data[r+shift][c+shift]=txt; if ((r>=0) && (c>=0) && (r<=data.size()) && (c<=colcnt))data[r+shift][c+shift]=txt;
@ -568,7 +652,12 @@ QSizeF JKQTPEnhancedTableView::getTotalSize() const
void JKQTPEnhancedTableView::paint(QPainter &painter, double scale, int page, double hhh, double vhw, const QList<int>& pageCols, const QList<int>& pageRows, QPrinter* p) void JKQTPEnhancedTableView::paint(QPainter &painter, double scale, int page, double hhh, double vhw, const QList<int>& pageCols, const QList<int>& pageRows, QPrinter* p)
{ {
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
QStyleOptionViewItem option = viewOptions(); QStyleOptionViewItem option;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
initViewItemOption(&option);
#else
option = viewOptions();
#endif
painter.scale(scale, scale); painter.scale(scale, scale);
QPen headerPen("black"); QPen headerPen("black");
headerPen.setWidth(2); headerPen.setWidth(2);

View File

@ -778,29 +778,30 @@ void JKQTBasePlotter::calcPlotScaling(JKQTPEnhancedPainter& painter){
internalPlotKeyBorderBottom=0; internalPlotKeyBorderBottom=0;
internalPlotKeyBorderLeft=0; internalPlotKeyBorderLeft=0;
internalPlotKeyBorderRight=0; internalPlotKeyBorderRight=0;
const qreal Xwid=kfm.boundingRect('X').width();
if (plotterStyle.keyStyle.position==JKQTPKeyOutsideTopRight) { if (plotterStyle.keyStyle.position==JKQTPKeyOutsideTopRight) {
internalPlotKeyBorderTop=keyHeight+2*plotterStyle.keyStyle.yMargin*kfm.width('X')+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.yOffset*kfm.width('X')+2; internalPlotKeyBorderTop=keyHeight+2*plotterStyle.keyStyle.yMargin*Xwid+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.yOffset*Xwid+2;
internalPlotBorderTop = internalPlotBorderTop + internalPlotKeyBorderTop; internalPlotBorderTop = internalPlotBorderTop + internalPlotKeyBorderTop;
} else if (plotterStyle.keyStyle.position==JKQTPKeyOutsideTopLeft) { } else if (plotterStyle.keyStyle.position==JKQTPKeyOutsideTopLeft) {
internalPlotKeyBorderTop=keyHeight+2*plotterStyle.keyStyle.yMargin*kfm.width('X')+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.yOffset*kfm.width('X')+2; internalPlotKeyBorderTop=keyHeight+2*plotterStyle.keyStyle.yMargin*Xwid+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.yOffset*Xwid+2;
internalPlotBorderTop = internalPlotBorderTop + internalPlotKeyBorderTop; internalPlotBorderTop = internalPlotBorderTop + internalPlotKeyBorderTop;
} else if (plotterStyle.keyStyle.position==JKQTPKeyOutsideLeftTop) { } else if (plotterStyle.keyStyle.position==JKQTPKeyOutsideLeftTop) {
internalPlotKeyBorderLeft=keyWidth+2*plotterStyle.keyStyle.xMargin*kfm.width('X')+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.xOffset*kfm.width('X')+2; internalPlotKeyBorderLeft=keyWidth+2*plotterStyle.keyStyle.xMargin*Xwid+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.xOffset*Xwid+2;
internalPlotBorderLeft = internalPlotBorderLeft + internalPlotKeyBorderLeft; internalPlotBorderLeft = internalPlotBorderLeft + internalPlotKeyBorderLeft;
} else if (plotterStyle.keyStyle.position==JKQTPKeyOutsideLeftBottom) { } else if (plotterStyle.keyStyle.position==JKQTPKeyOutsideLeftBottom) {
internalPlotKeyBorderLeft=keyWidth+2*plotterStyle.keyStyle.xMargin*kfm.width('X')+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.xOffset*kfm.width('X')+2; internalPlotKeyBorderLeft=keyWidth+2*plotterStyle.keyStyle.xMargin*Xwid+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.xOffset*Xwid+2;
internalPlotBorderLeft = internalPlotBorderLeft + internalPlotKeyBorderLeft; internalPlotBorderLeft = internalPlotBorderLeft + internalPlotKeyBorderLeft;
} else if (plotterStyle.keyStyle.position==JKQTPKeyOutsideBottomRight) { } else if (plotterStyle.keyStyle.position==JKQTPKeyOutsideBottomRight) {
internalPlotKeyBorderBottom=keyHeight+2*plotterStyle.keyStyle.yMargin*kfm.width('X')+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.yOffset*kfm.width('X')+2; internalPlotKeyBorderBottom=keyHeight+2*plotterStyle.keyStyle.yMargin*Xwid+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.yOffset*Xwid+2;
internalPlotBorderBottom = internalPlotBorderBottom + internalPlotKeyBorderBottom; internalPlotBorderBottom = internalPlotBorderBottom + internalPlotKeyBorderBottom;
} else if (plotterStyle.keyStyle.position==JKQTPKeyOutsideBottomLeft) { } else if (plotterStyle.keyStyle.position==JKQTPKeyOutsideBottomLeft) {
internalPlotKeyBorderBottom=keyHeight+2*plotterStyle.keyStyle.yMargin*kfm.width('X')+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.yOffset*kfm.width('X')+2; internalPlotKeyBorderBottom=keyHeight+2*plotterStyle.keyStyle.yMargin*Xwid+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.yOffset*Xwid+2;
internalPlotBorderBottom = internalPlotBorderBottom + internalPlotKeyBorderBottom; internalPlotBorderBottom = internalPlotBorderBottom + internalPlotKeyBorderBottom;
} else if (plotterStyle.keyStyle.position==JKQTPKeyOutsideRightTop) { } else if (plotterStyle.keyStyle.position==JKQTPKeyOutsideRightTop) {
internalPlotKeyBorderRight = keyWidth+2*plotterStyle.keyStyle.xMargin*kfm.width('X')+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.xOffset*kfm.width('X')+2; internalPlotKeyBorderRight = keyWidth+2*plotterStyle.keyStyle.xMargin*Xwid+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.xOffset*Xwid+2;
internalPlotBorderRight = internalPlotBorderRight + internalPlotKeyBorderRight; internalPlotBorderRight = internalPlotBorderRight + internalPlotKeyBorderRight;
} else if (plotterStyle.keyStyle.position==JKQTPKeyOutsideRightBottom) { } else if (plotterStyle.keyStyle.position==JKQTPKeyOutsideRightBottom) {
internalPlotKeyBorderRight = keyWidth+2*plotterStyle.keyStyle.xMargin*kfm.width('X')+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.xOffset*kfm.width('X')+2; internalPlotKeyBorderRight = keyWidth+2*plotterStyle.keyStyle.xMargin*Xwid+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.xOffset*Xwid+2;
internalPlotBorderRight = internalPlotBorderRight + internalPlotKeyBorderRight; internalPlotBorderRight = internalPlotBorderRight + internalPlotKeyBorderRight;
} }
@ -1052,13 +1053,14 @@ void JKQTBasePlotter::drawKey(JKQTPEnhancedPainter& painter) {
QFont kf(plotterStyle.defaultFontName, 10); QFont kf(plotterStyle.defaultFontName, 10);
kf.setPointSizeF(plotterStyle.keyStyle.fontSize*fontSizeMultiplier); kf.setPointSizeF(plotterStyle.keyStyle.fontSize*fontSizeMultiplier);
QFontMetricsF kfm(kf); QFontMetricsF kfm(kf);
const qreal Xwid=kfm.boundingRect('X').width();
// get the size of the key and if keyWidth>0 && keyHeight>0 draw the frame and the contents // get the size of the key and if keyWidth>0 && keyHeight>0 draw the frame and the contents
double keyWidth=0; double keyWidth=0;
double keyHeight=0; double keyHeight=0;
getKeyExtent(painter, &keyWidth, &keyHeight); getKeyExtent(painter, &keyWidth, &keyHeight);
double keyRectangleWidth=keyWidth+2.0*plotterStyle.keyStyle.xMargin*kfm.width('X')+2.0*plotterStyle.keyStyle.frameWidth*lineWidthPrintMultiplier; double keyRectangleWidth=keyWidth+2.0*plotterStyle.keyStyle.xMargin*Xwid+2.0*plotterStyle.keyStyle.frameWidth*lineWidthPrintMultiplier;
double keyRectangleHeight=keyHeight+2.0*plotterStyle.keyStyle.yMargin*kfm.width('X')+2.0*plotterStyle.keyStyle.frameWidth*lineWidthPrintMultiplier; double keyRectangleHeight=keyHeight+2.0*plotterStyle.keyStyle.yMargin*Xwid+2.0*plotterStyle.keyStyle.frameWidth*lineWidthPrintMultiplier;
if ((keyWidth>0) && (keyHeight>0)) { if ((keyWidth>0) && (keyHeight>0)) {
// key position // key position
@ -1067,64 +1069,64 @@ void JKQTBasePlotter::drawKey(JKQTPEnhancedPainter& painter) {
// default: inside top-right // default: inside top-right
double x0=internalPlotBorderLeft+internalPlotWidth-keyRectangleWidth; double x0=internalPlotBorderLeft+internalPlotWidth-keyRectangleWidth;
double x=x0-plotterStyle.keyStyle.xOffset*kfm.width('X'); double x=x0-plotterStyle.keyStyle.xOffset*Xwid;
double y0=internalPlotBorderTop; double y0=internalPlotBorderTop;
double y=y0+plotterStyle.keyStyle.yOffset*kfm.width('X'); double y=y0+plotterStyle.keyStyle.yOffset*Xwid;
switch(plotterStyle.keyStyle.position) { switch(plotterStyle.keyStyle.position) {
case JKQTPKeyOutsideTopRight: case JKQTPKeyOutsideTopRight:
x0=internalPlotBorderLeft+internalPlotWidth+internalPlotBorderRight-keyRectangleWidth; x0=internalPlotBorderLeft+internalPlotWidth+internalPlotBorderRight-keyRectangleWidth;
x=x0-plotterStyle.keyStyle.xOffset*kfm.width('X'); x=x0-plotterStyle.keyStyle.xOffset*Xwid;
y0=internalTitleHeight; y0=internalTitleHeight;
y=y0+plotterStyle.keyStyle.yOffset*kfm.width('X'); y=y0+plotterStyle.keyStyle.yOffset*Xwid;
break; break;
case JKQTPKeyOutsideTopLeft: case JKQTPKeyOutsideTopLeft:
x0=internalPlotBorderLeft; x0=internalPlotBorderLeft;
x=x0+plotterStyle.keyStyle.xOffset*kfm.width('X'); x=x0+plotterStyle.keyStyle.xOffset*Xwid;
y0=internalTitleHeight; y0=internalTitleHeight;
y=y0+plotterStyle.keyStyle.yOffset*kfm.width('X'); y=y0+plotterStyle.keyStyle.yOffset*Xwid;
break; break;
case JKQTPKeyOutsideBottomRight: case JKQTPKeyOutsideBottomRight:
x0=internalPlotBorderLeft+internalPlotWidth-keyRectangleWidth; x0=internalPlotBorderLeft+internalPlotWidth-keyRectangleWidth;
x=x0-plotterStyle.keyStyle.xOffset*kfm.width('X'); x=x0-plotterStyle.keyStyle.xOffset*Xwid;
y0=internalPlotBorderTop+internalPlotHeight+internalPlotBorderBottom-keyRectangleHeight; y0=internalPlotBorderTop+internalPlotHeight+internalPlotBorderBottom-keyRectangleHeight;
y=y0-plotterStyle.keyStyle.yOffset*kfm.width('X'); y=y0-plotterStyle.keyStyle.yOffset*Xwid;
break; break;
case JKQTPKeyOutsideBottomLeft: case JKQTPKeyOutsideBottomLeft:
x0=internalPlotBorderLeft; x0=internalPlotBorderLeft;
x=x0+plotterStyle.keyStyle.xOffset*kfm.width('X'); x=x0+plotterStyle.keyStyle.xOffset*Xwid;
y0=internalPlotBorderTop+internalPlotHeight+internalPlotBorderBottom-keyRectangleHeight; y0=internalPlotBorderTop+internalPlotHeight+internalPlotBorderBottom-keyRectangleHeight;
y=y0-plotterStyle.keyStyle.yOffset*kfm.width('X'); y=y0-plotterStyle.keyStyle.yOffset*Xwid;
break; break;
case JKQTPKeyOutsideRightTop: case JKQTPKeyOutsideRightTop:
x0=internalPlotBorderLeft+internalPlotWidth+internalPlotBorderRight-keyRectangleWidth; x0=internalPlotBorderLeft+internalPlotWidth+internalPlotBorderRight-keyRectangleWidth;
x=x0-plotterStyle.keyStyle.xOffset*kfm.width('X'); x=x0-plotterStyle.keyStyle.xOffset*Xwid;
y0=internalPlotBorderTop; y0=internalPlotBorderTop;
y=y0+plotterStyle.keyStyle.yOffset*kfm.width('X'); y=y0+plotterStyle.keyStyle.yOffset*Xwid;
break; break;
case JKQTPKeyOutsideRightBottom: case JKQTPKeyOutsideRightBottom:
x0=internalPlotBorderLeft+internalPlotWidth+internalPlotBorderRight-keyRectangleWidth; x0=internalPlotBorderLeft+internalPlotWidth+internalPlotBorderRight-keyRectangleWidth;
x=x0-plotterStyle.keyStyle.xOffset*kfm.width('X'); x=x0-plotterStyle.keyStyle.xOffset*Xwid;
y0=internalPlotBorderTop+internalPlotHeight-keyRectangleHeight; y0=internalPlotBorderTop+internalPlotHeight-keyRectangleHeight;
y=y0-plotterStyle.keyStyle.yOffset*kfm.width('X'); y=y0-plotterStyle.keyStyle.yOffset*Xwid;
break; break;
case JKQTPKeyOutsideLeftTop: case JKQTPKeyOutsideLeftTop:
x0=0; x0=0;
x=x0+plotterStyle.keyStyle.xOffset*kfm.width('X'); x=x0+plotterStyle.keyStyle.xOffset*Xwid;
y0=internalPlotBorderTop; y0=internalPlotBorderTop;
y=y0+plotterStyle.keyStyle.yOffset*kfm.width('X'); y=y0+plotterStyle.keyStyle.yOffset*Xwid;
break; break;
case JKQTPKeyOutsideLeftBottom: case JKQTPKeyOutsideLeftBottom:
x0=0; x0=0;
x=x0+plotterStyle.keyStyle.xOffset*kfm.width('X'); x=x0+plotterStyle.keyStyle.xOffset*Xwid;
y0=internalPlotBorderTop+internalPlotHeight-keyRectangleHeight; y0=internalPlotBorderTop+internalPlotHeight-keyRectangleHeight;
y=y0-plotterStyle.keyStyle.yOffset*kfm.width('X'); y=y0-plotterStyle.keyStyle.yOffset*Xwid;
break; break;
@ -1132,27 +1134,27 @@ void JKQTBasePlotter::drawKey(JKQTPEnhancedPainter& painter) {
case JKQTPKeyInsideBottomRight: case JKQTPKeyInsideBottomRight:
x0=internalPlotBorderLeft+internalPlotWidth-keyRectangleWidth; x0=internalPlotBorderLeft+internalPlotWidth-keyRectangleWidth;
x=x0-plotterStyle.keyStyle.xOffset*kfm.width('X'); x=x0-plotterStyle.keyStyle.xOffset*Xwid;
y0=internalPlotBorderTop+internalPlotHeight-keyRectangleHeight; y0=internalPlotBorderTop+internalPlotHeight-keyRectangleHeight;
y=y0-plotterStyle.keyStyle.yOffset*kfm.width('X'); y=y0-plotterStyle.keyStyle.yOffset*Xwid;
break; break;
case JKQTPKeyInsideBottomLeft: case JKQTPKeyInsideBottomLeft:
x0=internalPlotBorderLeft; x0=internalPlotBorderLeft;
x=x0+plotterStyle.keyStyle.xOffset*kfm.width('X'); x=x0+plotterStyle.keyStyle.xOffset*Xwid;
y0=internalPlotBorderTop+internalPlotHeight-keyRectangleHeight; y0=internalPlotBorderTop+internalPlotHeight-keyRectangleHeight;
y=y0-plotterStyle.keyStyle.yOffset*kfm.width('X'); y=y0-plotterStyle.keyStyle.yOffset*Xwid;
break; break;
case JKQTPKeyInsideTopLeft: case JKQTPKeyInsideTopLeft:
x0=internalPlotBorderLeft; x0=internalPlotBorderLeft;
x=x0+plotterStyle.keyStyle.xOffset*kfm.width('X'); x=x0+plotterStyle.keyStyle.xOffset*Xwid;
y0=internalPlotBorderTop; y0=internalPlotBorderTop;
y=y0+plotterStyle.keyStyle.yOffset*kfm.width('X'); y=y0+plotterStyle.keyStyle.yOffset*Xwid;
break; break;
case JKQTPKeyInsideTopRight: case JKQTPKeyInsideTopRight:
x0=internalPlotBorderLeft+internalPlotWidth-keyRectangleWidth; x0=internalPlotBorderLeft+internalPlotWidth-keyRectangleWidth;
x=x0-plotterStyle.keyStyle.xOffset*kfm.width('X'); x=x0-plotterStyle.keyStyle.xOffset*Xwid;
y0=internalPlotBorderTop; y0=internalPlotBorderTop;
y=y0+plotterStyle.keyStyle.yOffset*kfm.width('X'); y=y0+plotterStyle.keyStyle.yOffset*Xwid;
break; break;
} }
QRectF rectKey; QRectF rectKey;
@ -1177,8 +1179,8 @@ void JKQTBasePlotter::drawKey(JKQTPEnhancedPainter& painter) {
} else { } else {
painter.drawRoundedRect(rectKey, pt2px(painter, plotterStyle.keyStyle.frameRounding), pt2px(painter, plotterStyle.keyStyle.frameRounding)); painter.drawRoundedRect(rectKey, pt2px(painter, plotterStyle.keyStyle.frameRounding), pt2px(painter, plotterStyle.keyStyle.frameRounding));
} }
y=y+plotterStyle.keyStyle.yMargin*kfm.width('X')+plotterStyle.keyStyle.frameWidth*lineWidthMultiplier/2.0; y=y+plotterStyle.keyStyle.yMargin*Xwid+plotterStyle.keyStyle.frameWidth*lineWidthMultiplier/2.0;
x=x+plotterStyle.keyStyle.xMargin*kfm.width('X')+plotterStyle.keyStyle.frameWidth*lineWidthMultiplier/2.0; x=x+plotterStyle.keyStyle.xMargin*Xwid+plotterStyle.keyStyle.frameWidth*lineWidthMultiplier/2.0;
painter.setPen(pf); painter.setPen(pf);
@ -1229,7 +1231,9 @@ void JKQTBasePlotter::drawPlot(JKQTPEnhancedPainter& painter) {
if (plotterStyle.widgetBackgroundBrush!=QBrush(Qt::transparent)) painter.fillRect(QRectF(0,0,widgetWidth/paintMagnification, widgetHeight/paintMagnification), plotterStyle.widgetBackgroundBrush); if (plotterStyle.widgetBackgroundBrush!=QBrush(Qt::transparent)) painter.fillRect(QRectF(0,0,widgetWidth/paintMagnification, widgetHeight/paintMagnification), plotterStyle.widgetBackgroundBrush);
} }
QRectF rPlotBack(internalPlotBorderLeft, internalPlotBorderTop, internalPlotWidth, internalPlotHeight); QRectF rPlotBack(internalPlotBorderLeft, internalPlotBorderTop, internalPlotWidth, internalPlotHeight);
#if QT_VERSION<QT_VERSION_CHECK(6,0,0)
painter.setRenderHint(JKQTPEnhancedPainter::NonCosmeticDefaultPen, true); painter.setRenderHint(JKQTPEnhancedPainter::NonCosmeticDefaultPen, true);
#endif
painter.setRenderHint(JKQTPEnhancedPainter::Antialiasing, plotterStyle.useAntiAliasingForSystem); painter.setRenderHint(JKQTPEnhancedPainter::Antialiasing, plotterStyle.useAntiAliasingForSystem);
painter.setRenderHint(JKQTPEnhancedPainter::TextAntialiasing, plotterStyle.useAntiAliasingForText); painter.setRenderHint(JKQTPEnhancedPainter::TextAntialiasing, plotterStyle.useAntiAliasingForText);
if (plotterStyle.plotFrameVisible) { if (plotterStyle.plotFrameVisible) {
@ -1742,7 +1746,7 @@ bool JKQTBasePlotter::exportpreview(QSizeF pageSize, bool unitIsMM) {
{ {
QPalette p(scroll->palette()); QPalette p(scroll->palette());
// Set background colour to black // Set background colour to black
p.setColor(QPalette::Background, Qt::darkGray); p.setColor(QPalette::Window, Qt::darkGray);
scroll->setPalette(p); scroll->setPalette(p);
} }
exportPreviewLabel=new QLabel(scroll); exportPreviewLabel=new QLabel(scroll);
@ -1751,7 +1755,7 @@ bool JKQTBasePlotter::exportpreview(QSizeF pageSize, bool unitIsMM) {
{ {
QPalette p(exportPreviewLabel->palette()); QPalette p(exportPreviewLabel->palette());
// Set background colour to black // Set background colour to black
p.setColor(QPalette::Background, Qt::darkGray); p.setColor(QPalette::Window, Qt::darkGray);
exportPreviewLabel->setPalette(p); exportPreviewLabel->setPalette(p);
} }
@ -3306,8 +3310,8 @@ void JKQTBasePlotter::copyData() {
QTextStream txt(&result); QTextStream txt(&result);
QLocale loc=QLocale::system(); QLocale loc=QLocale::system();
loc.setNumberOptions(QLocale::OmitGroupSeparator); loc.setNumberOptions(QLocale::OmitGroupSeparator);
QChar dp=loc.decimalPoint(); const auto dp=loc.decimalPoint();
QString sep="\t"; const QString sep="\t";
datastore->saveCSV(txt, cols, sep, QString(dp), " ", "\""); datastore->saveCSV(txt, cols, sep, QString(dp), " ", "\"");
txt.flush(); txt.flush();
} }
@ -4140,21 +4144,22 @@ void JKQTBasePlotter::drawKeyContents(JKQTPEnhancedPainter& painter, double x, d
#ifdef JKQTBP_AUTOTIMER #ifdef JKQTBP_AUTOTIMER
jkaaot.write(QString("one-col: graph %1: %2").arg(i).arg(g->getTitle())); jkaaot.write(QString("one-col: graph %1: %2").arg(i).arg(g->getTitle()));
#endif #endif
const auto Xwid=kfm.boundingRect('X').width();
if (!g->getTitle().isEmpty() && g->isVisible()) { if (!g->getTitle().isEmpty() && g->isVisible()) {
QSizeF fs=getTextSizeSize(plotterStyle.defaultFontName,plotterStyle.keyStyle.fontSize*fontSizeMultiplier,g->getTitle(),painter);// mt.getSize(painter); QSizeF fs=getTextSizeSize(plotterStyle.defaultFontName,plotterStyle.keyStyle.fontSize*fontSizeMultiplier,g->getTitle(),painter);// mt.getSize(painter);
double itheight=qMax(plotterStyle.keyStyle.itemHeight*kfm.width('X'), fs.height()); double itheight=qMax(plotterStyle.keyStyle.itemHeight*Xwid, fs.height());
QRectF markerRect(x, y+1.5*lineWidthMultiplier, plotterStyle.keyStyle.sampleLineLength*kfm.width('X'), itheight-3.0*lineWidthMultiplier); QRectF markerRect(x, y+1.5*lineWidthMultiplier, plotterStyle.keyStyle.sampleLineLength*Xwid, itheight-3.0*lineWidthMultiplier);
g->drawKeyMarker(painter, markerRect); g->drawKeyMarker(painter, markerRect);
mathText.setFontColor(plotterStyle.keyStyle.textColor); mathText.setFontColor(plotterStyle.keyStyle.textColor);
mathText.setFontSize(plotterStyle.keyStyle.fontSize*fontSizeMultiplier); mathText.setFontSize(plotterStyle.keyStyle.fontSize*fontSizeMultiplier);
mathText.setFontRomanOrSpecial(plotterStyle.defaultFontName); mathText.setFontRomanOrSpecial(plotterStyle.defaultFontName);
mathText.parse(g->getTitle()); mathText.parse(g->getTitle());
QRectF txtRect(x+(plotterStyle.keyStyle.sampleLineLength+plotterStyle.keyStyle.xSeparation)*kfm.width('X'),y, key_text_width, itheight); QRectF txtRect(x+(plotterStyle.keyStyle.sampleLineLength+plotterStyle.keyStyle.xSeparation)*Xwid,y, key_text_width, itheight);
mathText.draw(painter, Qt::AlignLeft|Qt::AlignVCenter, txtRect); mathText.draw(painter, Qt::AlignLeft|Qt::AlignVCenter, txtRect);
//if (itheight<key_item_height*kfm.height()) itheight=key_item_height*kfm.height(); //if (itheight<key_item_height*kfm.height()) itheight=key_item_height*kfm.height();
//y=y+itheight+(plotterStyle.keyStyle.ySeparation)*kfm.height(); //y=y+itheight+(plotterStyle.keyStyle.ySeparation)*kfm.height();
y=y+key_text_height+(plotterStyle.keyStyle.ySeparation)*kfm.width('X'); y=y+key_text_height+(plotterStyle.keyStyle.ySeparation)*Xwid;
if (plotterStyle.debugShowRegionBoxes) { if (plotterStyle.debugShowRegionBoxes) {
painter.save(); auto __finalpaintinner=JKQTPFinally([&painter]() {painter.restore();}); painter.save(); auto __finalpaintinner=JKQTPFinally([&painter]() {painter.restore();});
QPen p("orange"); QPen p("orange");
@ -4178,16 +4183,17 @@ void JKQTBasePlotter::drawKeyContents(JKQTPEnhancedPainter& painter, double x, d
jkaaot.write(QString("one-row: graph %1: %2").arg(i).arg(g->getTitle())); jkaaot.write(QString("one-row: graph %1: %2").arg(i).arg(g->getTitle()));
#endif #endif
if (!g->getTitle().isEmpty() && g->isVisible()) { if (!g->getTitle().isEmpty() && g->isVisible()) {
const auto Xwid=kfm.boundingRect('X').width();
QSizeF fs=getTextSizeSize(plotterStyle.defaultFontName,plotterStyle.keyStyle.fontSize*fontSizeMultiplier,g->getTitle(),painter);// mt.getSize(painter); QSizeF fs=getTextSizeSize(plotterStyle.defaultFontName,plotterStyle.keyStyle.fontSize*fontSizeMultiplier,g->getTitle(),painter);// mt.getSize(painter);
double itheight=qMax(plotterStyle.keyStyle.itemHeight*kfm.width('X'), fs.height()); double itheight=qMax(plotterStyle.keyStyle.itemHeight*Xwid, fs.height());
QRectF markerRect(x, y+1.5*lineWidthMultiplier, plotterStyle.keyStyle.sampleLineLength*kfm.width('X'), itheight-3.0*lineWidthMultiplier); QRectF markerRect(x, y+1.5*lineWidthMultiplier, plotterStyle.keyStyle.sampleLineLength*Xwid, itheight-3.0*lineWidthMultiplier);
g->drawKeyMarker(painter, markerRect); g->drawKeyMarker(painter, markerRect);
mathText.setFontColor(plotterStyle.keyStyle.textColor); mathText.setFontColor(plotterStyle.keyStyle.textColor);
mathText.setFontSize(plotterStyle.keyStyle.fontSize*fontSizeMultiplier); mathText.setFontSize(plotterStyle.keyStyle.fontSize*fontSizeMultiplier);
mathText.setFontRomanOrSpecial(plotterStyle.defaultFontName); mathText.setFontRomanOrSpecial(plotterStyle.defaultFontName);
mathText.parse(g->getTitle()); mathText.parse(g->getTitle());
QRectF txtRect(x+(plotterStyle.keyStyle.sampleLineLength+plotterStyle.keyStyle.xSeparation)*kfm.width('X'),y, fs.width(), itheight); QRectF txtRect(x+(plotterStyle.keyStyle.sampleLineLength+plotterStyle.keyStyle.xSeparation)*Xwid,y, fs.width(), itheight);
mathText.draw(painter, Qt::AlignLeft|Qt::AlignVCenter, txtRect); mathText.draw(painter, Qt::AlignLeft|Qt::AlignVCenter, txtRect);
if (plotterStyle.debugShowRegionBoxes) { if (plotterStyle.debugShowRegionBoxes) {
painter.save(); auto __finalpaintinner=JKQTPFinally([&painter]() {painter.restore();}); painter.save(); auto __finalpaintinner=JKQTPFinally([&painter]() {painter.restore();});
@ -4203,11 +4209,11 @@ void JKQTBasePlotter::drawKeyContents(JKQTPEnhancedPainter& painter, double x, d
} }
//if (itheight<key_item_height*kfm.height()) itheight=key_item_height*kfm.height(); //if (itheight<key_item_height*kfm.height()) itheight=key_item_height*kfm.height();
//y=y+itheight+(plotterStyle.keyStyle.ySeparation)*kfm.height(); //y=y+itheight+(plotterStyle.keyStyle.ySeparation)*kfm.height();
x=x+fs.width()+(2.0*plotterStyle.keyStyle.xSeparation+plotterStyle.keyStyle.sampleLineLength)*kfm.width('X'); x=x+fs.width()+(2.0*plotterStyle.keyStyle.xSeparation+plotterStyle.keyStyle.sampleLineLength)*Xwid;
} }
} }
} else if (plotterStyle.keyStyle.layout==JKQTPKeyLayoutMultiColumn) { } else if (plotterStyle.keyStyle.layout==JKQTPKeyLayoutMultiColumn) {
//int columns=floor(static_cast<double>(plotWidth)/static_cast<double>(key_item_width*kfm.width('X'))); //int columns=floor(static_cast<double>(plotWidth)/static_cast<double>(key_item_width*Xwid));
bool colfirst=true; bool colfirst=true;
if (plotterStyle.keyStyle.position==JKQTPKeyInsideTopLeft || plotterStyle.keyStyle.position==JKQTPKeyInsideTopRight if (plotterStyle.keyStyle.position==JKQTPKeyInsideTopLeft || plotterStyle.keyStyle.position==JKQTPKeyInsideTopRight
@ -4219,6 +4225,7 @@ void JKQTBasePlotter::drawKeyContents(JKQTPEnhancedPainter& painter, double x, d
int c=1; int c=1;
double xx=x; double xx=x;
double yy=y; double yy=y;
const auto Xwid=kfm.boundingRect('X').width();
for (int i=0; i<graphs.size(); i++) { for (int i=0; i<graphs.size(); i++) {
JKQTPPlotElement* g=graphs[i]; JKQTPPlotElement* g=graphs[i];
#ifdef JKQTBP_AUTOTIMER #ifdef JKQTBP_AUTOTIMER
@ -4226,15 +4233,15 @@ void JKQTBasePlotter::drawKeyContents(JKQTPEnhancedPainter& painter, double x, d
#endif #endif
if (!g->getTitle().isEmpty() && g->isVisible()) { if (!g->getTitle().isEmpty() && g->isVisible()) {
//QSizeF fs=getTextSizeSize(plotterStyle.defaultFontName,plotterStyle.keyStyle.fontSize*fontSizeMultiplier,g->getTitle(),painter);// mt.getSize(painter); //QSizeF fs=getTextSizeSize(plotterStyle.defaultFontName,plotterStyle.keyStyle.fontSize*fontSizeMultiplier,g->getTitle(),painter);// mt.getSize(painter);
double itheight=qMax(plotterStyle.keyStyle.itemHeight*kfm.width('X'), key_text_height); double itheight=qMax(plotterStyle.keyStyle.itemHeight*Xwid, key_text_height);
QRectF markerRect(xx, yy+1.5*lineWidthMultiplier, plotterStyle.keyStyle.sampleLineLength*kfm.width('X'), itheight-3.0*lineWidthMultiplier); QRectF markerRect(xx, yy+1.5*lineWidthMultiplier, plotterStyle.keyStyle.sampleLineLength*Xwid, itheight-3.0*lineWidthMultiplier);
g->drawKeyMarker(painter, markerRect); g->drawKeyMarker(painter, markerRect);
mathText.setFontColor(plotterStyle.keyStyle.textColor); mathText.setFontColor(plotterStyle.keyStyle.textColor);
mathText.setFontSize(plotterStyle.keyStyle.fontSize*fontSizeMultiplier); mathText.setFontSize(plotterStyle.keyStyle.fontSize*fontSizeMultiplier);
mathText.setFontRomanOrSpecial(plotterStyle.defaultFontName); mathText.setFontRomanOrSpecial(plotterStyle.defaultFontName);
mathText.parse(g->getTitle()); mathText.parse(g->getTitle());
//QSizeF fs=mt.getSize(painter); //QSizeF fs=mt.getSize(painter);
QRectF txtRect(xx+(plotterStyle.keyStyle.sampleLineLength+plotterStyle.keyStyle.xSeparation)*kfm.width('X'),yy, key_text_width, key_text_height); QRectF txtRect(xx+(plotterStyle.keyStyle.sampleLineLength+plotterStyle.keyStyle.xSeparation)*Xwid,yy, key_text_width, key_text_height);
mathText.draw(painter, Qt::AlignLeft|Qt::AlignVCenter, txtRect); mathText.draw(painter, Qt::AlignLeft|Qt::AlignVCenter, txtRect);
if (plotterStyle.debugShowRegionBoxes) { if (plotterStyle.debugShowRegionBoxes) {
@ -4251,26 +4258,26 @@ void JKQTBasePlotter::drawKeyContents(JKQTPEnhancedPainter& painter, double x, d
} }
if (colfirst) { if (colfirst) {
yy=yy+key_text_height+(plotterStyle.keyStyle.ySeparation)*kfm.width('X'); yy=yy+key_text_height+(plotterStyle.keyStyle.ySeparation)*Xwid;
l++; l++;
if (l>lines) { if (l>lines) {
l=1; l=1;
c++; c++;
xx=xx+key_text_width+(plotterStyle.keyStyle.sampleLineLength+2.0*plotterStyle.keyStyle.xSeparation)*kfm.width('X'); xx=xx+key_text_width+(plotterStyle.keyStyle.sampleLineLength+2.0*plotterStyle.keyStyle.xSeparation)*Xwid;
/*if (plotterStyle.keyStyle.autosize) xx=xx+key_text_width+(key_line_length+3.0*plotterStyle.keyStyle.xSeparation)*kfm.width('X'); /*if (plotterStyle.keyStyle.autosize) xx=xx+key_text_width+(key_line_length+3.0*plotterStyle.keyStyle.xSeparation)*Xwid;
else xx=xx+(key_item_width+2.0*plotterStyle.keyStyle.xSeparation)*kfm.width('X');*/ else xx=xx+(key_item_width+2.0*plotterStyle.keyStyle.xSeparation)*Xwid;*/
yy=y; yy=y;
} }
} else { } else {
/*if (plotterStyle.keyStyle.autosize) xx=xx+key_text_width+(key_line_length+3.0*plotterStyle.keyStyle.xSeparation)*kfm.width('X'); /*if (plotterStyle.keyStyle.autosize) xx=xx+key_text_width+(key_line_length+3.0*plotterStyle.keyStyle.xSeparation)*Xwid;
else xx=xx+(key_item_width+2.0*plotterStyle.keyStyle.xSeparation)*kfm.width('X');*/ else xx=xx+(key_item_width+2.0*plotterStyle.keyStyle.xSeparation)*Xwid;*/
xx=xx+key_text_width+(plotterStyle.keyStyle.sampleLineLength+2.0*plotterStyle.keyStyle.xSeparation)*kfm.width('X'); xx=xx+key_text_width+(plotterStyle.keyStyle.sampleLineLength+2.0*plotterStyle.keyStyle.xSeparation)*Xwid;
c++; c++;
if (c>columns) { if (c>columns) {
c=1; c=1;
l++; l++;
//yy=yy+(key_item_height+plotterStyle.keyStyle.ySeparation)*kfm.height(); //yy=yy+(key_item_height+plotterStyle.keyStyle.ySeparation)*kfm.height();
yy=yy+itheight+(plotterStyle.keyStyle.ySeparation)*kfm.width('X'); yy=yy+itheight+(plotterStyle.keyStyle.ySeparation)*Xwid;
xx=x; xx=x;
} }
} }
@ -4292,7 +4299,8 @@ void JKQTBasePlotter::getKeyExtent(JKQTPEnhancedPainter& painter, double* width,
f.setFamily(plotterStyle.defaultFontName); f.setFamily(plotterStyle.defaultFontName);
f.setPointSizeF(plotterStyle.keyStyle.fontSize*fontSizeMultiplier); f.setPointSizeF(plotterStyle.keyStyle.fontSize*fontSizeMultiplier);
QFontMetricsF kfm(f); QFontMetricsF kfm(f);
if (text_height!=nullptr) *text_height=plotterStyle.keyStyle.itemHeight*kfm.width('X'); const qreal Xwid=kfm.boundingRect('X').width();
if (text_height!=nullptr) *text_height=plotterStyle.keyStyle.itemHeight*Xwid;
if (plotterStyle.keyStyle.layout==JKQTPKeyLayoutOneColumn) { if (plotterStyle.keyStyle.layout==JKQTPKeyLayoutOneColumn) {
int keyHeight=graphs.size(); int keyHeight=graphs.size();
double w=0; double w=0;
@ -4310,18 +4318,18 @@ void JKQTBasePlotter::getKeyExtent(JKQTPEnhancedPainter& painter, double* width,
QSizeF fs=getTextSizeSize(plotterStyle.defaultFontName, plotterStyle.keyStyle.fontSize*fontSizeMultiplier, graphs[i]->getTitle(), painter); QSizeF fs=getTextSizeSize(plotterStyle.defaultFontName, plotterStyle.keyStyle.fontSize*fontSizeMultiplier, graphs[i]->getTitle(), painter);
if (fs.width()>w) w=fs.width(); if (fs.width()>w) w=fs.width();
if (text_height && fs.height()>*text_height) *text_height=fs.height(); if (text_height && fs.height()>*text_height) *text_height=fs.height();
h=h+qMax(plotterStyle.keyStyle.itemHeight*kfm.width('X'), fs.height())+plotterStyle.keyStyle.ySeparation*kfm.width('X'); h=h+qMax(plotterStyle.keyStyle.itemHeight*Xwid, fs.height())+plotterStyle.keyStyle.ySeparation*Xwid;
} }
} }
if (plotterStyle.keyStyle.autosize) { if (plotterStyle.keyStyle.autosize) {
if (width) *width=w+(plotterStyle.keyStyle.sampleLineLength+2.0*plotterStyle.keyStyle.xSeparation)*kfm.width('X'); if (width) *width=w+(plotterStyle.keyStyle.sampleLineLength+2.0*plotterStyle.keyStyle.xSeparation)*Xwid;
if (text_width!=nullptr) *text_width=w+2.0*kfm.width('X'); if (text_width!=nullptr) *text_width=w+2.0*Xwid;
} else { } else {
if (width) *width=plotterStyle.keyStyle.itemWidth*kfm.width('X'); if (width) *width=plotterStyle.keyStyle.itemWidth*Xwid;
if (text_width!=nullptr) *text_width=(plotterStyle.keyStyle.itemWidth-(plotterStyle.keyStyle.sampleLineLength+plotterStyle.keyStyle.xSeparation))*kfm.width('X'); if (text_width!=nullptr) *text_width=(plotterStyle.keyStyle.itemWidth-(plotterStyle.keyStyle.sampleLineLength+plotterStyle.keyStyle.xSeparation))*Xwid;
} }
if (h>plotterStyle.keyStyle.ySeparation*kfm.width('X')) h=h-plotterStyle.keyStyle.ySeparation*kfm.width('X'); if (h>plotterStyle.keyStyle.ySeparation*Xwid) h=h-plotterStyle.keyStyle.ySeparation*Xwid;
if (height) *height=h;//keyHeight*key_item_height*kfm.width('X'); if (height) *height=h;//keyHeight*key_item_height*Xwid;
if (columns_count) *columns_count=1; if (columns_count) *columns_count=1;
if (lines_count) *lines_count=keyHeight; if (lines_count) *lines_count=keyHeight;
} else if (plotterStyle.keyStyle.layout==JKQTPKeyLayoutOneRow) { } else if (plotterStyle.keyStyle.layout==JKQTPKeyLayoutOneRow) {
@ -4341,19 +4349,19 @@ void JKQTBasePlotter::getKeyExtent(JKQTPEnhancedPainter& painter, double* width,
QSizeF fs=getTextSizeSize(plotterStyle.defaultFontName, plotterStyle.keyStyle.fontSize*fontSizeMultiplier, graphs[i]->getTitle(), painter); QSizeF fs=getTextSizeSize(plotterStyle.defaultFontName, plotterStyle.keyStyle.fontSize*fontSizeMultiplier, graphs[i]->getTitle(), painter);
if (fs.height()>h) h=fs.height(); if (fs.height()>h) h=fs.height();
if (text_width && fs.width()>*text_width) *text_width=fs.width(); if (text_width && fs.width()>*text_width) *text_width=fs.width();
w=w+fs.width()+(plotterStyle.keyStyle.sampleLineLength+2.0*plotterStyle.keyStyle.xSeparation)*kfm.width('X'); w=w+fs.width()+(plotterStyle.keyStyle.sampleLineLength+2.0*plotterStyle.keyStyle.xSeparation)*Xwid;
} }
} }
if (h<plotterStyle.keyStyle.itemHeight*kfm.width('X')) h=plotterStyle.keyStyle.itemHeight*kfm.width('X'); if (h<plotterStyle.keyStyle.itemHeight*Xwid) h=plotterStyle.keyStyle.itemHeight*Xwid;
if (plotterStyle.keyStyle.autosize) { if (plotterStyle.keyStyle.autosize) {
if (height) *height=h; if (height) *height=h;
if (text_height!=nullptr) *text_height=h; if (text_height!=nullptr) *text_height=h;
} else { } else {
if (height) *height=h; if (height) *height=h;
if (text_height!=nullptr) *text_height=(plotterStyle.keyStyle.itemHeight-(plotterStyle.keyStyle.ySeparation))*kfm.width('X'); if (text_height!=nullptr) *text_height=(plotterStyle.keyStyle.itemHeight-(plotterStyle.keyStyle.ySeparation))*Xwid;
} }
if (w>(plotterStyle.keyStyle.xSeparation)*kfm.width('X')) w=w-(plotterStyle.keyStyle.xSeparation)*kfm.width('X'); if (w>(plotterStyle.keyStyle.xSeparation)*Xwid) w=w-(plotterStyle.keyStyle.xSeparation)*Xwid;
if (width) *width=w;//keyHeight*key_item_height*kfm.width('X'); if (width) *width=w;//keyHeight*key_item_height*Xwid;
if (columns_count) *columns_count=keyWidth; if (columns_count) *columns_count=keyWidth;
if (lines_count) *lines_count=1; if (lines_count) *lines_count=1;
} else if (plotterStyle.keyStyle.layout==JKQTPKeyLayoutMultiColumn) { } else if (plotterStyle.keyStyle.layout==JKQTPKeyLayoutMultiColumn) {
@ -4382,12 +4390,12 @@ void JKQTBasePlotter::getKeyExtent(JKQTPEnhancedPainter& painter, double* width,
if (text_height) { if (text_height) {
if (plotterStyle.keyStyle.autosize) *text_height=txtH; if (plotterStyle.keyStyle.autosize) *text_height=txtH;
else *text_height=plotterStyle.keyStyle.itemHeight*kfm.width('X'); else *text_height=plotterStyle.keyStyle.itemHeight*Xwid;
} }
double columns=floor(double(internalPlotWidth)/(w+(2.0*plotterStyle.keyStyle.xSeparation+plotterStyle.keyStyle.sampleLineLength)*kfm.width('X'))); double columns=floor(double(internalPlotWidth)/(w+(2.0*plotterStyle.keyStyle.xSeparation+plotterStyle.keyStyle.sampleLineLength)*Xwid));
if (!plotterStyle.keyStyle.autosize) columns=floor(double(internalPlotWidth)/((plotterStyle.keyStyle.itemWidth+2.0*plotterStyle.keyStyle.xSeparation+plotterStyle.keyStyle.sampleLineLength)*kfm.width('X'))); if (!plotterStyle.keyStyle.autosize) columns=floor(double(internalPlotWidth)/((plotterStyle.keyStyle.itemWidth+2.0*plotterStyle.keyStyle.xSeparation+plotterStyle.keyStyle.sampleLineLength)*Xwid));
columns=qMin(columns, keyHeight); columns=qMin(columns, keyHeight);
int lines=static_cast<int>(ceil(static_cast<double>(keyHeight)/static_cast<double>(columns))); int lines=static_cast<int>(ceil(static_cast<double>(keyHeight)/static_cast<double>(columns)));
lines=jkqtp_roundTo<int>(qMin(static_cast<double>(lines), keyHeight)); lines=jkqtp_roundTo<int>(qMin(static_cast<double>(lines), keyHeight));
@ -4395,9 +4403,9 @@ void JKQTBasePlotter::getKeyExtent(JKQTPEnhancedPainter& painter, double* width,
if (plotterStyle.keyStyle.position==JKQTPKeyInsideTopLeft || plotterStyle.keyStyle.position==JKQTPKeyInsideTopRight if (plotterStyle.keyStyle.position==JKQTPKeyInsideTopLeft || plotterStyle.keyStyle.position==JKQTPKeyInsideTopRight
|| plotterStyle.keyStyle.position==JKQTPKeyOutsideTopLeft || plotterStyle.keyStyle.position==JKQTPKeyOutsideTopRight) { || plotterStyle.keyStyle.position==JKQTPKeyOutsideTopLeft || plotterStyle.keyStyle.position==JKQTPKeyOutsideTopRight) {
if (plotterStyle.keyStyle.autosize) { if (plotterStyle.keyStyle.autosize) {
lines=static_cast<int>(floor(static_cast<double>(internalPlotHeight)/static_cast<double>(txtH+(plotterStyle.keyStyle.ySeparation)*kfm.width('X')))); lines=static_cast<int>(floor(static_cast<double>(internalPlotHeight)/static_cast<double>(txtH+(plotterStyle.keyStyle.ySeparation)*Xwid)));
} else { } else {
lines=static_cast<int>(floor(static_cast<double>(internalPlotHeight)/static_cast<double>((plotterStyle.keyStyle.itemHeight+plotterStyle.keyStyle.ySeparation)*kfm.width('X')))); lines=static_cast<int>(floor(static_cast<double>(internalPlotHeight)/static_cast<double>((plotterStyle.keyStyle.itemHeight+plotterStyle.keyStyle.ySeparation)*Xwid)));
} }
columns=static_cast<int>(ceil(static_cast<double>(keyHeight)/static_cast<double>(lines))); columns=static_cast<int>(ceil(static_cast<double>(keyHeight)/static_cast<double>(lines)));
lines=jkqtp_roundTo<int>(qMin(static_cast<double>(lines), keyHeight)); lines=jkqtp_roundTo<int>(qMin(static_cast<double>(lines), keyHeight));
@ -4408,15 +4416,15 @@ void JKQTBasePlotter::getKeyExtent(JKQTPEnhancedPainter& painter, double* width,
if (lines_count) *lines_count=lines; if (lines_count) *lines_count=lines;
if (plotterStyle.keyStyle.autosize) { if (plotterStyle.keyStyle.autosize) {
if (width) *width=(w+(plotterStyle.keyStyle.sampleLineLength+3.0*plotterStyle.keyStyle.xSeparation)*kfm.width('X'))*columns; if (width) *width=(w+(plotterStyle.keyStyle.sampleLineLength+3.0*plotterStyle.keyStyle.xSeparation)*Xwid)*columns;
if (height) *height=lines*(txtH+plotterStyle.keyStyle.ySeparation*kfm.width('X')); if (height) *height=lines*(txtH+plotterStyle.keyStyle.ySeparation*Xwid);
if (lines>0) *height=*height-plotterStyle.keyStyle.ySeparation*kfm.width('X'); if (lines>0) *height=*height-plotterStyle.keyStyle.ySeparation*Xwid;
if (text_width!=nullptr) *text_width=w; if (text_width!=nullptr) *text_width=w;
} else { } else {
if (width) *width=(plotterStyle.keyStyle.itemWidth+2.0*plotterStyle.keyStyle.xSeparation)*kfm.width('X')*columns; if (width) *width=(plotterStyle.keyStyle.itemWidth+2.0*plotterStyle.keyStyle.xSeparation)*Xwid*columns;
if (height) *height=lines*(plotterStyle.keyStyle.itemHeight+plotterStyle.keyStyle.ySeparation)*kfm.width('X'); if (height) *height=lines*(plotterStyle.keyStyle.itemHeight+plotterStyle.keyStyle.ySeparation)*Xwid;
if (lines>0) *height=*height-plotterStyle.keyStyle.ySeparation*kfm.width('X'); if (lines>0) *height=*height-plotterStyle.keyStyle.ySeparation*Xwid;
if (text_width!=nullptr) *text_width=(plotterStyle.keyStyle.itemWidth-(plotterStyle.keyStyle.sampleLineLength+plotterStyle.keyStyle.xSeparation))*kfm.width('X'); if (text_width!=nullptr) *text_width=(plotterStyle.keyStyle.itemWidth-(plotterStyle.keyStyle.sampleLineLength+plotterStyle.keyStyle.xSeparation))*Xwid;
} }
#ifdef SHOW_JKQTPLOTTER_DEBUG #ifdef SHOW_JKQTPLOTTER_DEBUG
qDebug()<<"getKeyExtent(): mult-column: columns="<<columns<<" lines="<<lines; qDebug()<<"getKeyExtent(): mult-column: columns="<<columns<<" lines="<<lines;
@ -5023,7 +5031,14 @@ bool JKQTPPaintDeviceAdapter::useLatexParser() const
QPaintDevice *JKQTPPaintDeviceAdapter::createPaintdeviceMM(const QString &filename, double widthMM, double heightMM) const QPaintDevice *JKQTPPaintDeviceAdapter::createPaintdeviceMM(const QString &filename, double widthMM, double heightMM) const
{ {
return createPaintdevice(filename, jkqtp_roundTo<int>(widthMM/25.4*QApplication::desktop()->logicalDpiX()), jkqtp_roundTo<int>(heightMM/25.4*QApplication::desktop()->logicalDpiY())); #if QT_VERSION>=QT_VERSION_CHECK(6,0,0)
const qreal dpix=qGuiApp->primaryScreen()->logicalDotsPerInchX();
const qreal dpiy=qGuiApp->primaryScreen()->logicalDotsPerInchY();
#else
const qreal dpix=QApplication::desktop()->logicalDpiX();
const qreal dpiy=QApplication::desktop()->logicalDpiY();
#endif
return createPaintdevice(filename, jkqtp_roundTo<int>(widthMM/25.4*dpix), jkqtp_roundTo<int>(heightMM/25.4*dpiy));
} }
JKQTPSaveDataAdapter::~JKQTPSaveDataAdapter() = default; JKQTPSaveDataAdapter::~JKQTPSaveDataAdapter() = default;

View File

@ -2130,7 +2130,11 @@ class JKQTPLOTTER_LIB_EXPORT JKQTBasePlotter: public QObject {
/** \brief qHash()-specialization /** \brief qHash()-specialization
* \ingroup jkqtpplottersupprt * \ingroup jkqtpplottersupprt
*/ */
inline uint qHash(const JKQTBasePlotter::textSizeKey& data) { #if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
inline size_t qHash(const JKQTBasePlotter::textSizeKey& data, size_t /*seed=0*/) {
#else
inline uint qHash(const JKQTBasePlotter::textSizeKey& data, uint /*seed=0*/) {
#endif
return qHash(data.f.family())+qHash(data.text); return qHash(data.f.family())+qHash(data.text);
} }

View File

@ -1056,7 +1056,7 @@ void JKQTPDatastore::saveCSV(QTextStream& txt, const QSet<int>& userColumns, con
// find out the decimal and the thousand separator // find out the decimal and the thousand separator
QLocale loc=QLocale::c(); QLocale loc=QLocale::c();
loc.setNumberOptions(QLocale::OmitGroupSeparator); loc.setNumberOptions(QLocale::OmitGroupSeparator);
QChar dsep=loc.decimalPoint(); const auto dsep=loc.decimalPoint();
txt.setLocale(loc); txt.setLocale(loc);

View File

@ -22,6 +22,7 @@
#include "jkqtplotter/jkqtplotter_imexport.h" #include "jkqtplotter/jkqtplotter_imexport.h"
#include "jkqtplotter/jkqtptools.h" #include "jkqtplotter/jkqtptools.h"
#include "jkqtcommon/jkqtpdebuggingtools.h" #include "jkqtcommon/jkqtpdebuggingtools.h"
#include "jkqtcommon/jkqttools.h"
#include <vector> #include <vector>
#include <cmath> #include <cmath>
#include <iostream> #include <iostream>
@ -2518,7 +2519,7 @@ quint16 JKQTPColumn::calculateChecksum() const
{ {
if (!datastore) return 0; if (!datastore) return 0;
if (!datastore->getItem(datastoreItem)) return 0; if (!datastore->getItem(datastoreItem)) return 0;
return qChecksum(reinterpret_cast<const char*>(getPointer(0)), static_cast<uint>(getRows()*sizeof(double))); return jkqtp_checksum(reinterpret_cast<const char*>(getPointer(0)), static_cast<uint>(getRows()*sizeof(double)));
} }
//////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -479,7 +479,9 @@ void JKQTPlotter::paintUserAction() {
image=oldImage; image=oldImage;
if (image.width()>0 && image.height()>0 && !image.isNull()) { if (image.width()>0 && image.height()>0 && !image.isNull()) {
JKQTPEnhancedPainter painter(&image); JKQTPEnhancedPainter painter(&image);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
painter.setRenderHint(JKQTPEnhancedPainter::NonCosmeticDefaultPen, true); painter.setRenderHint(JKQTPEnhancedPainter::NonCosmeticDefaultPen, true);
#endif
painter.setRenderHint(JKQTPEnhancedPainter::Antialiasing, true); painter.setRenderHint(JKQTPEnhancedPainter::Antialiasing, true);
painter.setRenderHint(JKQTPEnhancedPainter::TextAntialiasing, true); painter.setRenderHint(JKQTPEnhancedPainter::TextAntialiasing, true);
painter.setPen(plotterStyle.userActionOverlayPen); painter.setPen(plotterStyle.userActionOverlayPen);
@ -1437,12 +1439,12 @@ QAction* JKQTPlotter::getActMouseLeftAsToolTip() const {
void JKQTPlotter::setOverrideMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifiers modifier, JKQTPMouseDragActions action) void JKQTPlotter::setOverrideMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifiers modifier, JKQTPMouseDragActions action)
{ {
registeredOverrideMouseDragActionModes.insert(qMakePair<Qt::MouseButton, Qt::KeyboardModifiers>(button, modifier), action); registeredOverrideMouseDragActionModes.insert(QPair<Qt::MouseButton, Qt::KeyboardModifiers>(button, modifier), action);
} }
void JKQTPlotter::resetOverrideMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifiers modifier) void JKQTPlotter::resetOverrideMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifiers modifier)
{ {
registeredOverrideMouseDragActionModes.remove(qMakePair<Qt::MouseButton, Qt::KeyboardModifiers>(button, modifier)); registeredOverrideMouseDragActionModes.remove(QPair<Qt::MouseButton, Qt::KeyboardModifiers>(button, modifier));
} }
void JKQTPlotter::setContextMenuMode(JKQTPContextMenuModes mode) { void JKQTPlotter::setContextMenuMode(JKQTPContextMenuModes mode) {
@ -1686,7 +1688,7 @@ JKQTPMouseDragActionsHashMapIterator JKQTPlotter::findMatchingMouseDragAction(Qt
if (found) *found=false; if (found) *found=false;
JKQTPMouseDragActionsHashMapIterator it=registeredOverrideMouseDragActionModes.cbegin(); JKQTPMouseDragActionsHashMapIterator it=registeredOverrideMouseDragActionModes.cbegin();
while (it!=registeredOverrideMouseDragActionModes.cend() ) { while (it!=registeredOverrideMouseDragActionModes.cend() ) {
if (it.key()==qMakePair<Qt::MouseButton, Qt::KeyboardModifiers>(button, modifiers)) { if (it.key()==QPair<Qt::MouseButton, Qt::KeyboardModifiers>(button, modifiers)) {
if (found) *found=true; if (found) *found=true;
return it; return it;
} }
@ -1694,7 +1696,7 @@ JKQTPMouseDragActionsHashMapIterator JKQTPlotter::findMatchingMouseDragAction(Qt
} }
it=plotterStyle.registeredMouseDragActionModes.cbegin(); it=plotterStyle.registeredMouseDragActionModes.cbegin();
while (it!=plotterStyle.registeredMouseDragActionModes.cend() ) { while (it!=plotterStyle.registeredMouseDragActionModes.cend() ) {
if (it.key()==qMakePair<Qt::MouseButton, Qt::KeyboardModifiers>(button, modifiers)) { if (it.key()==QPair<Qt::MouseButton, Qt::KeyboardModifiers>(button, modifiers)) {
if (found) *found=true; if (found) *found=true;
return it; return it;
} }
@ -1707,7 +1709,7 @@ JKQTPMouseDoubleClickActionsHashMapIterator JKQTPlotter::findMatchingMouseDouble
{ {
if (found) *found=false; if (found) *found=false;
for (JKQTPMouseDoubleClickActionsHashMapIterator it=plotterStyle.registeredMouseDoubleClickActions.cbegin(); it!=plotterStyle.registeredMouseDoubleClickActions.cend(); ++it) { for (JKQTPMouseDoubleClickActionsHashMapIterator it=plotterStyle.registeredMouseDoubleClickActions.cbegin(); it!=plotterStyle.registeredMouseDoubleClickActions.cend(); ++it) {
if (it.key()==qMakePair<Qt::MouseButton, Qt::KeyboardModifiers>(button, modifiers)) { if (it.key()==QPair<Qt::MouseButton, Qt::KeyboardModifiers>(button, modifiers)) {
if (found) *found=true; if (found) *found=true;
return it; return it;
} }
@ -1738,7 +1740,7 @@ void JKQTPlotter::setPlotUpdateEnabled(bool enable)
void JKQTPlotter::registerMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifiers modifier, JKQTPMouseDragActions action) void JKQTPlotter::registerMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifiers modifier, JKQTPMouseDragActions action)
{ {
plotterStyle.registeredMouseDragActionModes[qMakePair<Qt::MouseButton, Qt::KeyboardModifiers>(button, modifier)]=action; plotterStyle.registeredMouseDragActionModes[QPair<Qt::MouseButton, Qt::KeyboardModifiers>(button, modifier)]=action;
if (button==Qt::LeftButton && modifier==Qt::NoModifier) { if (button==Qt::LeftButton && modifier==Qt::NoModifier) {
actMouseLeftAsDefault->setChecked(true); actMouseLeftAsDefault->setChecked(true);
resetMouseLeftAction(); resetMouseLeftAction();
@ -1747,7 +1749,7 @@ void JKQTPlotter::registerMouseDragAction(Qt::MouseButton button, Qt::KeyboardMo
void JKQTPlotter::deregisterMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifiers modifier) void JKQTPlotter::deregisterMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifiers modifier)
{ {
plotterStyle.registeredMouseDragActionModes.remove(qMakePair<Qt::MouseButton, Qt::KeyboardModifiers>(button, modifier)); plotterStyle.registeredMouseDragActionModes.remove(QPair<Qt::MouseButton, Qt::KeyboardModifiers>(button, modifier));
} }
void JKQTPlotter::clearAllRegisteredMouseDragActions() void JKQTPlotter::clearAllRegisteredMouseDragActions()
@ -1757,12 +1759,12 @@ void JKQTPlotter::clearAllRegisteredMouseDragActions()
void JKQTPlotter::registerMouseDoubleClickAction(Qt::MouseButton button, Qt::KeyboardModifiers modifier, JKQTPMouseDoubleClickActions action) void JKQTPlotter::registerMouseDoubleClickAction(Qt::MouseButton button, Qt::KeyboardModifiers modifier, JKQTPMouseDoubleClickActions action)
{ {
plotterStyle.registeredMouseDoubleClickActions[qMakePair<Qt::MouseButton, Qt::KeyboardModifiers>(button, modifier)]=action; plotterStyle.registeredMouseDoubleClickActions[QPair<Qt::MouseButton, Qt::KeyboardModifiers>(button, modifier)]=action;
} }
void JKQTPlotter::deregisterMouseDoubleClickAction(Qt::MouseButton button, Qt::KeyboardModifiers modifier) void JKQTPlotter::deregisterMouseDoubleClickAction(Qt::MouseButton button, Qt::KeyboardModifiers modifier)
{ {
plotterStyle.registeredMouseDoubleClickActions.remove(qMakePair<Qt::MouseButton, Qt::KeyboardModifiers>(button, modifier)); plotterStyle.registeredMouseDoubleClickActions.remove(QPair<Qt::MouseButton, Qt::KeyboardModifiers>(button, modifier));
} }
void JKQTPlotter::clearAllRegisteredMouseDoubleClickActions() void JKQTPlotter::clearAllRegisteredMouseDoubleClickActions()

View File

@ -1727,8 +1727,11 @@ QT_BEGIN_NAMESPACE
* \internal * \internal
* \ingroup jkqtpplottersupprt * \ingroup jkqtpplottersupprt
*/ */
template<> #if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
inline uint qHash(const QPair<Qt::MouseButton,Qt::KeyboardModifiers> &key, uint seed ) noexcept(noexcept(qHash(key.first, seed)) && noexcept(qHash(key.second, seed))) { inline size_t qHash(const QPair<Qt::MouseButton,Qt::KeyboardModifiers> &key, size_t seed=0) {
#else
inline uint qHash(const QPair<Qt::MouseButton,Qt::KeyboardModifiers> &key, uint seed=0) {
#endif
return static_cast<uint>(key.first)+static_cast<uint>(key.second); return static_cast<uint>(key.first)+static_cast<uint>(key.second);
} }
@ -1736,8 +1739,11 @@ inline uint qHash(const QPair<Qt::MouseButton,Qt::KeyboardModifiers> &key, uint
* \internal * \internal
* \ingroup jkqtpplottersupprt * \ingroup jkqtpplottersupprt
*/ */
template<> #if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
inline uint qHash(const Qt::MouseButton &key, uint /*seed*/ ) noexcept(noexcept(qHash(key))) { inline size_t qHash(const Qt::MouseButton &key, size_t /*seed=0*/) {
#else
inline uint qHash(const Qt::MouseButton &key, uint /*seed=0*/) {
#endif
return static_cast<uint>(key); return static_cast<uint>(key);
} }
@ -1745,8 +1751,11 @@ inline uint qHash(const Qt::MouseButton &key, uint /*seed*/ ) noexcept(noexcept(
* \internal * \internal
* \ingroup jkqtpplottersupprt * \ingroup jkqtpplottersupprt
*/ */
template<> #if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
inline uint qHash(const Qt::KeyboardModifiers &key, uint /*seed*/ ) noexcept(noexcept(qHash(key))) { inline size_t qHash(const Qt::KeyboardModifiers &key, size_t /*seed=0*/) {
#else
inline uint qHash(const Qt::KeyboardModifiers &key, uint /*seed=0*/) {
#endif
return static_cast<uint>(key); return static_cast<uint>(key);
} }