diff --git a/.gitignore b/.gitignore index 5b87bee2..f68ecdd0 100755 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ .directory *.pro.user* CMakeLists.txt.user +CMakeLists.txt.user.* quickqanava.pro.user QuickContainers/quickcontainers.pro.user QuickGeoGL/quickgeogl.pro.user diff --git a/CMakeLists.txt b/CMakeLists.txt index cfe6c721..0ae4bbae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,7 @@ if (${QUICK_QANAVA_CI}) add_subdirectory(samples/groups) # Used to test CI endif() +add_subdirectory(samples/groups) if (${QUICK_QANAVA_BUILD_SAMPLES}) add_subdirectory(samples/advanced) add_subdirectory(samples/connector) diff --git a/samples/groups/SampleGroups.qml b/samples/groups/SampleGroups.qml index 2c2b79bd..2ffc4864 100644 --- a/samples/groups/SampleGroups.qml +++ b/samples/groups/SampleGroups.qml @@ -125,7 +125,7 @@ ApplicationWindow { groupEditor.group = undefined contextMenu.node = undefined } - onRightClicked: { + onRightClicked: (pos) => { contextMenu.x = pos.x contextMenu.y = pos.y contextMenu.open() @@ -180,6 +180,21 @@ ApplicationWindow { } } MenuSeparator { } + MenuItem { + text: "Append column" + enabled: contextMenu.group?.isTable || false + onClicked: { + contextMenu.group.insertColumn() + } + } + MenuItem { + text: "Append row" + enabled: contextMenu.group?.isTable || false + onClicked: { + contextMenu.group.insertRow() + } + } + MenuSeparator { } MenuItem { text: "Send to front" enabled: contextMenu.group !== undefined diff --git a/samples/groups/groups.cpp b/samples/groups/groups.cpp index 4f2cb34d..ec8192de 100644 --- a/samples/groups/groups.cpp +++ b/samples/groups/groups.cpp @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file groups.cpp +// \file groups.cpp // \author benoit@qanava.org -// \date 2016 03 23 +// \date 2016 03 23 //----------------------------------------------------------------------------- // Qt headers diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 47caa2ae..80b48aa4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -141,34 +141,23 @@ set(qan_qml_files # Configure Qt set(CMAKE_AUTOMOC ON) -qt_wrap_cpp(qan_source_files, qan_header_files) # Creates .moc files from sources +#qt_wrap_cpp(qan_moc_files ${qan_header_files}) # Creates .moc files from sources set(CMAKE_AUTORCC ON) set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$:QT_QML_DEBUG>) # Configure QuickQanava library ############################################### -# FIXME #248 -# list(APPEND qan_resources QuickQanava_static.qrc) -# add_library(QuickQanava STATIC -# ${qan_source_files} -# ${qan_header_files} -# ${quickcontainers_source_files} -# ${quickcontainers_header_files} -# ${qan_resources} -# ) - # qt_add_library(QuickQanava STATIC) qt_add_qml_module(QuickQanava STATIC URI QuickQanava # VERSION 2.5 SOURCES - ${qan_source_files} ${qan_header_files} ${quickcontainers_source_files} ${quickcontainers_header_files} + ${qan_source_files} ${qan_header_files} ${qan_moc_files} ${quickcontainers_source_files} ${quickcontainers_header_files} QML_FILES ${qan_qml_files} RESOURCE_PREFIX / OUTPUT_DIRECTORY QuickQanava - #RESOURCE QuickQanava_static.qrc ) set(QT_QML_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/QuickQanava) @@ -178,24 +167,6 @@ target_include_directories(QuickQanava $ ) -# target_compile_features(QuickQanava -# PUBLIC -# cxx_std_17 -# ) - -# install(FILES -# ${qan_header_files} -# DESTINATION include/quickqanava -# ) - -# install(TARGETS QuickQanava -# EXPORT Targets -# LIBRARY DESTINATION lib -# ARCHIVE DESTINATION lib -# RUNTIME DESTINATION bin -# INCLUDES DESTINATION include/quickqanava -# ) - set(CMAKE_INCLUDE_CURRENT_DIR ON) target_link_libraries(QuickQanava PUBLIC Qt6::Core Qt6::Gui diff --git a/src/CanvasNodeTemplate.qml b/src/CanvasNodeTemplate.qml index 171b0afa..b8ebe862 100644 --- a/src/CanvasNodeTemplate.qml +++ b/src/CanvasNodeTemplate.qml @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file NodeCanvasTemplate.qml +// \file NodeCanvasTemplate.qml // \author benoit@destrat.io -// \date 2015 11 30 +// \date 2015 11 30 //----------------------------------------------------------------------------- import QtQuick diff --git a/src/Edge.qml b/src/Edge.qml index 98b121cb..b03a24d8 100644 --- a/src/Edge.qml +++ b/src/Edge.qml @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file Edge.qml +// \file Edge.qml // \author benoit@destrat.io -// \date 2016 09 04 +// \date 2016 09 04 //----------------------------------------------------------------------------- import QtQuick diff --git a/src/EdgeCurvedPath.qml b/src/EdgeCurvedPath.qml index e7354653..ad81b5b1 100644 --- a/src/EdgeCurvedPath.qml +++ b/src/EdgeCurvedPath.qml @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file EdgeCurvedPath.qml +// \file EdgeCurvedPath.qml // \author benoit@destrat.io -// \date 2022 10 02 +// \date 2022 10 02 //----------------------------------------------------------------------------- import QtQuick diff --git a/src/EdgeDstArrowPath.qml b/src/EdgeDstArrowPath.qml index ba6e6d88..1dcc961a 100644 --- a/src/EdgeDstArrowPath.qml +++ b/src/EdgeDstArrowPath.qml @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file EdgeDstArrowPath.qml +// \file EdgeDstArrowPath.qml // \author benoit@destrat.io -// \date 2022 10 02 +// \date 2022 10 02 //----------------------------------------------------------------------------- import QtQuick diff --git a/src/EdgeDstCirclePath.qml b/src/EdgeDstCirclePath.qml index 4c53f252..65cc8710 100644 --- a/src/EdgeDstCirclePath.qml +++ b/src/EdgeDstCirclePath.qml @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file EdgeDstCirclePath.qml +// \file EdgeDstCirclePath.qml // \author benoit@destrat.io -// \date 2022 10 02 +// \date 2022 10 02 //----------------------------------------------------------------------------- import QtQuick diff --git a/src/EdgeDstRectPath.qml b/src/EdgeDstRectPath.qml index dcc139a1..5698fa4c 100644 --- a/src/EdgeDstRectPath.qml +++ b/src/EdgeDstRectPath.qml @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file EdgeDstRectPath.qml +// \file EdgeDstRectPath.qml // \author benoit@destrat.io -// \date 2022 10 02 +// \date 2022 10 02 //----------------------------------------------------------------------------- import QtQuick diff --git a/src/EdgeOrthoPath.qml b/src/EdgeOrthoPath.qml index 756b7032..80ae0151 100644 --- a/src/EdgeOrthoPath.qml +++ b/src/EdgeOrthoPath.qml @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file EdgeOrthoPath.qml +// \file EdgeOrthoPath.qml // \author benoit@destrat.io -// \date 2022 10 02 +// \date 2022 10 02 //----------------------------------------------------------------------------- import QtQuick diff --git a/src/EdgeSrcArrowPath.qml b/src/EdgeSrcArrowPath.qml index efcee57e..8f2b1d72 100644 --- a/src/EdgeSrcArrowPath.qml +++ b/src/EdgeSrcArrowPath.qml @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file EdgeSrcArrowPath.qml +// \file EdgeSrcArrowPath.qml // \author benoit@destrat.io -// \date 2022 10 02 +// \date 2022 10 02 //----------------------------------------------------------------------------- import QtQuick diff --git a/src/EdgeSrcCirclePath.qml b/src/EdgeSrcCirclePath.qml index d0c24825..666c0e1d 100644 --- a/src/EdgeSrcCirclePath.qml +++ b/src/EdgeSrcCirclePath.qml @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file EdgeSrcCirclePath.qml +// \file EdgeSrcCirclePath.qml // \author benoit@destrat.io -// \date 2022 10 02 +// \date 2022 10 02 //----------------------------------------------------------------------------- import QtQuick diff --git a/src/EdgeSrcRectPath.qml b/src/EdgeSrcRectPath.qml index 223edad8..ad88d29f 100644 --- a/src/EdgeSrcRectPath.qml +++ b/src/EdgeSrcRectPath.qml @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file EdgeSrcRectPath.qml +// \file EdgeSrcRectPath.qml // \author benoit@destrat.io -// \date 2022 10 02 +// \date 2022 10 02 //----------------------------------------------------------------------------- import QtQuick diff --git a/src/EdgeStraightPath.qml b/src/EdgeStraightPath.qml index 02ed40d6..2b7d25f0 100644 --- a/src/EdgeStraightPath.qml +++ b/src/EdgeStraightPath.qml @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file EdgeStraightPath.qml +// \file EdgeStraightPath.qml // \author benoit@destrat.io -// \date 2022 10 02 +// \date 2022 10 02 //----------------------------------------------------------------------------- import QtQuick diff --git a/src/EdgeTemplate.qml b/src/EdgeTemplate.qml index 6c968d20..5b08f5e6 100644 --- a/src/EdgeTemplate.qml +++ b/src/EdgeTemplate.qml @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file EdgeTemplate.qml +// \file EdgeTemplate.qml // \author benoit@destrat.io -// \date 2017 11 17 +// \date 2017 11 17 //----------------------------------------------------------------------------- import QtQuick diff --git a/src/GraphView.qml b/src/GraphView.qml index 8d788706..b1954088 100644 --- a/src/GraphView.qml +++ b/src/GraphView.qml @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file GraphView.qml +// \file GraphView.qml // \author benoit@destrat.io -// \date 2015 08 01 +// \date 2015 08 01 //----------------------------------------------------------------------------- import QtQuick diff --git a/src/Group.qml b/src/Group.qml index 21b80f2c..7aa7a988 100644 --- a/src/Group.qml +++ b/src/Group.qml @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file Group.qml +// \file Group.qml // \author benoit@destrat.io -// \date 2016 03 22 +// \date 2016 03 22 //----------------------------------------------------------------------------- import QtQuick diff --git a/src/HorizontalDock.qml b/src/HorizontalDock.qml index 8a7937ec..6d0dd0dd 100644 --- a/src/HorizontalDock.qml +++ b/src/HorizontalDock.qml @@ -26,9 +26,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. -// \file HorizontalDock.qml +// \file HorizontalDock.qml // \author benoit@destrat.io -// \date 2017 08 28 +// \date 2017 08 28 //----------------------------------------------------------------------------- import QtQuick import QtQuick.Layouts diff --git a/src/LabelEditor.qml b/src/LabelEditor.qml index 71845d41..051025da 100644 --- a/src/LabelEditor.qml +++ b/src/LabelEditor.qml @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file LabelEditor.qml +// \file LabelEditor.qml // \author benoit@destrat.io -// \date 2015 11 30 +// \date 2015 11 30 //----------------------------------------------------------------------------- import QtQuick diff --git a/src/LineGrid.qml b/src/LineGrid.qml index 47e0f8b7..5b4ff8e8 100644 --- a/src/LineGrid.qml +++ b/src/LineGrid.qml @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file LineGrid.qml +// \file LineGrid.qml // \author benoit@destrat.io -// \date 2017 11 16 +// \date 2017 11 16 //----------------------------------------------------------------------------- import QtQuick diff --git a/src/Node.qml b/src/Node.qml index 7cc810e9..798a3fc9 100644 --- a/src/Node.qml +++ b/src/Node.qml @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file Node.qml +// \file Node.qml // \author benoit@destrat.io -// \date 2015 06 16 +// \date 2015 06 16 //----------------------------------------------------------------------------- import QtQuick diff --git a/src/OriginCross.qml b/src/OriginCross.qml index afe1a19b..675b1945 100644 --- a/src/OriginCross.qml +++ b/src/OriginCross.qml @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file OriginCross.qml +// \file OriginCross.qml // \author benoit@destrat.io -// \date 2024 08 23 +// \date 2024 08 23 //----------------------------------------------------------------------------- import QtQuick diff --git a/src/Port.qml b/src/Port.qml index ea7e7b22..2b630ce8 100644 --- a/src/Port.qml +++ b/src/Port.qml @@ -26,9 +26,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. -// \file Port.qml +// \file Port.qml // \author benoit@destrat.io -// \date 2017 08 12 +// \date 2017 08 12 //----------------------------------------------------------------------------- import QtQuick diff --git a/src/QuickQanava.h b/src/QuickQanava.h index a479ce74..7577ead5 100755 --- a/src/QuickQanava.h +++ b/src/QuickQanava.h @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file QuickQanava.h +// \file QuickQanava.h // \author benoit@destrat.io -// \date 2016 02 04 +// \date 2016 02 04 //----------------------------------------------------------------------------- #pragma once diff --git a/src/RectGlowEffect.qml b/src/RectGlowEffect.qml index 8a1d3d82..4864afb0 100644 --- a/src/RectGlowEffect.qml +++ b/src/RectGlowEffect.qml @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file RectGlowEffect.qml +// \file RectGlowEffect.qml // \author benoit@destrat.io -// \date 2018 03 23 +// \date 2018 03 23 //----------------------------------------------------------------------------- import QtQuick diff --git a/src/RectGradientBackground.qml b/src/RectGradientBackground.qml index 46fc4aa9..47d80858 100644 --- a/src/RectGradientBackground.qml +++ b/src/RectGradientBackground.qml @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file RectGradientBackground.qml +// \file RectGradientBackground.qml // \author benoit@destrat.io -// \date 2018 03 25 +// \date 2018 03 25 //----------------------------------------------------------------------------- import QtQuick diff --git a/src/RectGradientGlowBackground.qml b/src/RectGradientGlowBackground.qml index 8da67e46..12893a1d 100644 --- a/src/RectGradientGlowBackground.qml +++ b/src/RectGradientGlowBackground.qml @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file RectGradientGlowBackground.qml +// \file RectGradientGlowBackground.qml // \author benoit@destrat.io -// \date 2018 03 25 +// \date 2018 03 25 //----------------------------------------------------------------------------- import QtQuick diff --git a/src/RectGradientShadowBackground.qml b/src/RectGradientShadowBackground.qml index aa7b5aae..9777482b 100644 --- a/src/RectGradientShadowBackground.qml +++ b/src/RectGradientShadowBackground.qml @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file RectGradientShadowBackground.qml +// \file RectGradientShadowBackground.qml // \author benoit@destrat.io -// \date 2018 03 25 +// \date 2018 03 25 //----------------------------------------------------------------------------- import QtQuick diff --git a/src/RectGroupTemplate.qml b/src/RectGroupTemplate.qml index 57d2cb50..74837b73 100644 --- a/src/RectGroupTemplate.qml +++ b/src/RectGroupTemplate.qml @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file RectGroupTemplate.qml +// \file RectGroupTemplate.qml // \author benoit@destrat.io -// \date 2016 06 21 +// \date 2016 06 21 //----------------------------------------------------------------------------- import QtQuick diff --git a/src/RectNodeTemplate.qml b/src/RectNodeTemplate.qml index ef32ba36..636755b8 100644 --- a/src/RectNodeTemplate.qml +++ b/src/RectNodeTemplate.qml @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file RectNodeTemplate.qml +// \file RectNodeTemplate.qml // \author benoit@destrat.io -// \date 2015 11 30 +// \date 2015 11 30 //----------------------------------------------------------------------------- import QtQuick diff --git a/src/RectShadowEffect.qml b/src/RectShadowEffect.qml index 4c66f52a..dde1e177 100644 --- a/src/RectShadowEffect.qml +++ b/src/RectShadowEffect.qml @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file RectShadowEffect.qml +// \file RectShadowEffect.qml // \author benoit@destrat.io -// \date 2017 11 17 +// \date 2017 11 17 //----------------------------------------------------------------------------- import QtQuick diff --git a/src/RectSolidBackground.qml b/src/RectSolidBackground.qml index 754dd2e2..d359276d 100644 --- a/src/RectSolidBackground.qml +++ b/src/RectSolidBackground.qml @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file RectSolidBackground.qml +// \file RectSolidBackground.qml // \author benoit@destrat.io -// \date 2017 11 17 +// \date 2017 11 17 //----------------------------------------------------------------------------- import QtQuick diff --git a/src/RectSolidGlowBackground.qml b/src/RectSolidGlowBackground.qml index 64fd5c1e..f826e743 100644 --- a/src/RectSolidGlowBackground.qml +++ b/src/RectSolidGlowBackground.qml @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file RectSolidGlowBackground.qml +// \file RectSolidGlowBackground.qml // \author benoit@destrat.io -// \date 2018 03 23 +// \date 2018 03 23 //----------------------------------------------------------------------------- import QtQuick diff --git a/src/RectSolidShadowBackground.qml b/src/RectSolidShadowBackground.qml index 26e17a48..fb1daaab 100644 --- a/src/RectSolidShadowBackground.qml +++ b/src/RectSolidShadowBackground.qml @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file RectSolidShadowBackground.qml +// \file RectSolidShadowBackground.qml // \author benoit@destrat.io -// \date 2017 11 17 +// \date 2017 11 17 //----------------------------------------------------------------------------- import QtQuick diff --git a/src/SelectionItem.qml b/src/SelectionItem.qml index 3dc181e6..b70b9e6e 100644 --- a/src/SelectionItem.qml +++ b/src/SelectionItem.qml @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file SelectionItem.qml +// \file SelectionItem.qml // \author benoit@destrat.io -// \date 2015 06 16 +// \date 2015 06 16 // Contributed by @Jackneill 20170930 //----------------------------------------------------------------------------- diff --git a/src/TableBorder.qml b/src/TableBorder.qml index 87cf849d..09a303f5 100644 --- a/src/TableBorder.qml +++ b/src/TableBorder.qml @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file TableBorder.qml +// \file TableBorder.qml // \author benoit@destrat.io -// \date 2022 01 26 +// \date 2022 01 26 //----------------------------------------------------------------------------- import QtQuick diff --git a/src/TableCell.qml b/src/TableCell.qml index 7d9e4412..2d3c3272 100644 --- a/src/TableCell.qml +++ b/src/TableCell.qml @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file TableCell.qml +// \file TableCell.qml // \author benoit@destrat.io -// \date 2022 01 26 +// \date 2022 01 26 //----------------------------------------------------------------------------- import QtQuick diff --git a/src/TableGroup.qml b/src/TableGroup.qml index 0cb42bf3..11a98539 100644 --- a/src/TableGroup.qml +++ b/src/TableGroup.qml @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file TableGroup.qml +// \file TableGroup.qml // \author benoit@destrat.io -// \date 2023 01 26 +// \date 2023 01 26 //----------------------------------------------------------------------------- import QtQuick diff --git a/src/VerticalDock.qml b/src/VerticalDock.qml index fab71699..1869ef3c 100644 --- a/src/VerticalDock.qml +++ b/src/VerticalDock.qml @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file VerticalDock.qml +// \file VerticalDock.qml // \author benoit@destrat.io -// \date 2017 08 28 +// \date 2017 08 28 //----------------------------------------------------------------------------- import QtQuick diff --git a/src/gtpo/container_adapter.h b/src/gtpo/container_adapter.h index a7fa9d6f..3b184b36 100755 --- a/src/gtpo/container_adapter.h +++ b/src/gtpo/container_adapter.h @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file container_adapter.h +// \file container_adapter.h // \author benoit@destrat.io -// \date 2017 03 04 +// \date 2017 03 04 //----------------------------------------------------------------------------- #pragma once diff --git a/src/gtpo/edge.h b/src/gtpo/edge.h index 715fc146..2c276847 100644 --- a/src/gtpo/edge.h +++ b/src/gtpo/edge.h @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the GTpo software library. // -// \file edge.h +// \file edge.h // \author benoit@destrat.io -// \date 2017 03 04 +// \date 2017 03 04 //----------------------------------------------------------------------------- #pragma once diff --git a/src/gtpo/graph.h b/src/gtpo/graph.h index 369106e3..5cf6a6f1 100644 --- a/src/gtpo/graph.h +++ b/src/gtpo/graph.h @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the GTpo software library. // -// \file graph.h +// \file graph.h // \author benoit@destrat.io -// \date 2016 01 22 +// \date 2016 01 22 //----------------------------------------------------------------------------- #pragma once diff --git a/src/gtpo/graph.hpp b/src/gtpo/graph.hpp index 07d956eb..a534a859 100644 --- a/src/gtpo/graph.hpp +++ b/src/gtpo/graph.hpp @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the GTpo software library. // -// \file graph.hpp +// \file graph.hpp // \author benoit@destrat.io -// \date 2016 01 22 +// \date 2016 01 22 //----------------------------------------------------------------------------- namespace gtpo { // ::gtpo diff --git a/src/gtpo/graph_property.h b/src/gtpo/graph_property.h index 3c07abac..a2ec2f1c 100644 --- a/src/gtpo/graph_property.h +++ b/src/gtpo/graph_property.h @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the GTpo software library. // -// \file graph_property.h +// \file graph_property.h // \author benoit@destrat.io -// \date 2018 06 25 +// \date 2018 06 25 //----------------------------------------------------------------------------- #pragma once diff --git a/src/gtpo/node.h b/src/gtpo/node.h index de110658..e02bd292 100644 --- a/src/gtpo/node.h +++ b/src/gtpo/node.h @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the GTpo software library. // -// \file node.h +// \file node.h // \author benoit@destrat.io -// \date 2016 01 22 +// \date 2016 01 22 //----------------------------------------------------------------------------- #pragma once diff --git a/src/gtpo/node.hpp b/src/gtpo/node.hpp index eef0f7a6..1222174d 100644 --- a/src/gtpo/node.hpp +++ b/src/gtpo/node.hpp @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the GTpo software. // -// \file node.hpp +// \file node.hpp // \author benoit@destrat.io -// \date 2016 01 22 +// \date 2016 01 22 //----------------------------------------------------------------------------- namespace gtpo { // ::gtpo diff --git a/src/gtpo/observable.h b/src/gtpo/observable.h index 164e8618..9c24ce97 100644 --- a/src/gtpo/observable.h +++ b/src/gtpo/observable.h @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the GTpo software library. // -// \file observable.h +// \file observable.h // \author benoit@destrat.io -// \date 2016 02 08 +// \date 2016 02 08 //----------------------------------------------------------------------------- #pragma once diff --git a/src/gtpo/observer.h b/src/gtpo/observer.h index 3daea2bb..951119c7 100644 --- a/src/gtpo/observer.h +++ b/src/gtpo/observer.h @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the GTpo software library. // -// \file observer.h +// \file observer.h // \author benoit@destrat.io -// \date 2016 02 08 +// \date 2016 02 08 //----------------------------------------------------------------------------- #pragma once diff --git a/src/qanAbstractDraggableCtrl.h b/src/qanAbstractDraggableCtrl.h index a6dd28d4..7232fc1a 100644 --- a/src/qanAbstractDraggableCtrl.h +++ b/src/qanAbstractDraggableCtrl.h @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanAbstractDraggableCtrl.h +// \file qanAbstractDraggableCtrl.h // \author benoit@destrat.io -// \date 2017 06 30 +// \date 2017 06 30 //----------------------------------------------------------------------------- #pragma once diff --git a/src/qanAnalysisTimeHeatMap.cpp b/src/qanAnalysisTimeHeatMap.cpp index 8e50c3ec..05b54132 100755 --- a/src/qanAnalysisTimeHeatMap.cpp +++ b/src/qanAnalysisTimeHeatMap.cpp @@ -25,9 +25,9 @@ */ //----------------------------------------------------------------------------- -// \file qanAnalysisTimeHeatMap.cpp +// \file qanAnalysisTimeHeatMap.cpp // \author benoit@destrat.io -// \date 2017 06 04 +// \date 2017 06 04 //----------------------------------------------------------------------------- // Qt headers diff --git a/src/qanBehaviour.cpp b/src/qanBehaviour.cpp index 68bd86b8..37f2adfa 100644 --- a/src/qanBehaviour.cpp +++ b/src/qanBehaviour.cpp @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanBehaviour.cpp +// \file qanBehaviour.cpp // \author benoit@destrat.io -// \date 2016 04 04 +// \date 2016 04 04 //----------------------------------------------------------------------------- // QuickQanava headers diff --git a/src/qanBehaviour.h b/src/qanBehaviour.h index 396757b2..3db0c4c4 100755 --- a/src/qanBehaviour.h +++ b/src/qanBehaviour.h @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanBehaviour.h +// \file qanBehaviour.h // \author benoit@destrat.io -// \date 2016 04 04 +// \date 2016 04 04 //----------------------------------------------------------------------------- #pragma once diff --git a/src/qanBottomResizer.cpp b/src/qanBottomResizer.cpp index 795df907..e8725f71 100644 --- a/src/qanBottomResizer.cpp +++ b/src/qanBottomResizer.cpp @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanBottomResizer.cpp +// \file qanBottomResizer.cpp // \author benoit@destrat.io -// \date 2022 10 09 +// \date 2022 10 09 //----------------------------------------------------------------------------- // Qt headers @@ -216,7 +216,7 @@ void BottomResizer::mousePressEvent(QMouseEvent* event) if (!isVisible()) return; if (_target) { - _dragInitialPos = event->windowPos(); + _dragInitialPos = event->scenePosition(); _targetInitialSize = {_target->width(), _target->height()}; emit resizeStart(_target ? QSizeF{_target->width(), _target->height()} : // Use of target ok. QSizeF{}); diff --git a/src/qanBottomResizer.h b/src/qanBottomResizer.h index 2354a5bf..7ab2cb05 100644 --- a/src/qanBottomResizer.h +++ b/src/qanBottomResizer.h @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanBottomResizer.h +// \file qanBottomResizer.h // \author benoit@destrat.io -// \date 2022 10 09 +// \date 2022 10 09 //----------------------------------------------------------------------------- #pragma once diff --git a/src/qanBottomRightResizer.cpp b/src/qanBottomRightResizer.cpp index 237f34ec..0c0a214d 100644 --- a/src/qanBottomRightResizer.cpp +++ b/src/qanBottomRightResizer.cpp @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanBottomRightResizer.cpp +// \file qanBottomRightResizer.cpp // \author benoit@destrat.io -// \date 2016 07 08 +// \date 2016 07 08 //----------------------------------------------------------------------------- // Std headers diff --git a/src/qanBottomRightResizer.h b/src/qanBottomRightResizer.h index d758acb7..ea596c9b 100644 --- a/src/qanBottomRightResizer.h +++ b/src/qanBottomRightResizer.h @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanBottomRightResizer.h +// \file qanBottomRightResizer.h // \author benoit@destrat.io -// \date 2016 07 08 +// \date 2016 07 08 //----------------------------------------------------------------------------- #pragma once diff --git a/src/qanConnector.cpp b/src/qanConnector.cpp index 6feacecd..2e71c220 100644 --- a/src/qanConnector.cpp +++ b/src/qanConnector.cpp @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanConnector.cpp +// \file qanConnector.cpp // \author benoit@destrat.io -// \date 2017 03 10 +// \date 2017 03 10 //----------------------------------------------------------------------------- // Qt headers diff --git a/src/qanConnector.h b/src/qanConnector.h index 44b7608c..d77f74aa 100644 --- a/src/qanConnector.h +++ b/src/qanConnector.h @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanConnector.h +// \file qanConnector.h // \author benoit@destrat.io -// \date 2017 03 10 +// \date 2017 03 10 //----------------------------------------------------------------------------- #pragma once diff --git a/src/qanDraggable.cpp b/src/qanDraggable.cpp index 89136dc9..d34e2d45 100644 --- a/src/qanDraggable.cpp +++ b/src/qanDraggable.cpp @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanDraggable.cpp +// \file qanDraggable.cpp // \author benoit@destrat.io -// \date 2016 03 15 +// \date 2016 03 15 //----------------------------------------------------------------------------- // QuickQanava headers diff --git a/src/qanDraggable.h b/src/qanDraggable.h index 5e299b3d..b2679773 100644 --- a/src/qanDraggable.h +++ b/src/qanDraggable.h @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanDraggable.h +// \file qanDraggable.h // \author benoit@destrat.io -// \date 2017 03 15 +// \date 2017 03 15 //----------------------------------------------------------------------------- #pragma once diff --git a/src/qanDraggableCtrl.cpp b/src/qanDraggableCtrl.cpp index 0626fa8b..7b05d8a4 100644 --- a/src/qanDraggableCtrl.cpp +++ b/src/qanDraggableCtrl.cpp @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanDraggableCtrl.cpp +// \file qanDraggableCtrl.cpp // \author benoit@destrat.io -// \date 2017 03 15 +// \date 2017 03 15 //----------------------------------------------------------------------------- // QuickQanava headers diff --git a/src/qanDraggableCtrl.h b/src/qanDraggableCtrl.h index f02f4c30..6b8911b8 100644 --- a/src/qanDraggableCtrl.h +++ b/src/qanDraggableCtrl.h @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanDraggableCtrl.h +// \file qanDraggableCtrl.h // \author benoit@destrat.io -// \date 2017 03 15 +// \date 2017 03 15 //----------------------------------------------------------------------------- #pragma once diff --git a/src/qanEdge.cpp b/src/qanEdge.cpp index afacb6af..8e130b97 100644 --- a/src/qanEdge.cpp +++ b/src/qanEdge.cpp @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanEdge.cpp +// \file qanEdge.cpp // \author benoit@destrat.io -// \date 2004 February 15 +// \date 2004 February 15 //----------------------------------------------------------------------------- // Qt headers diff --git a/src/qanEdge.h b/src/qanEdge.h index 5ac2a58c..888e8a5d 100644 --- a/src/qanEdge.h +++ b/src/qanEdge.h @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanEdge.h +// \file qanEdge.h // \author benoit@destrat.io -// \date 2004 February 15 +// \date 2004 February 15 //----------------------------------------------------------------------------- #pragma once diff --git a/src/qanEdgeDraggableCtrl.cpp b/src/qanEdgeDraggableCtrl.cpp index f2150097..9c462fa7 100644 --- a/src/qanEdgeDraggableCtrl.cpp +++ b/src/qanEdgeDraggableCtrl.cpp @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanEdgeDraggableCtrl.cpp +// \file qanEdgeDraggableCtrl.cpp // \author benoit@destrat.io -// \date 2021 10 29 +// \date 2021 10 29 //----------------------------------------------------------------------------- // QuickQanava headers @@ -86,7 +86,7 @@ bool EdgeDraggableCtrl::handleMouseMoveEvent(QMouseEvent* event) const auto rootItem = graph->getContainerItem(); if (rootItem != nullptr && // Root item exist, left button is pressed and the target item event->buttons().testFlag(Qt::LeftButton)) { // is draggable and not collapsed - const auto sceneDragPos = rootItem->mapFromGlobal(event->globalPos()); + const auto sceneDragPos = rootItem->mapFromGlobal(event->globalPosition()); if (!_targetItem->getDragged()) { beginDragMove(sceneDragPos, _targetItem->getSelected()); return true; diff --git a/src/qanEdgeDraggableCtrl.h b/src/qanEdgeDraggableCtrl.h index 5b8db539..6de84024 100644 --- a/src/qanEdgeDraggableCtrl.h +++ b/src/qanEdgeDraggableCtrl.h @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanEdgeDraggableCtrl.h +// \file qanEdgeDraggableCtrl.h // \author benoit@destrat.io -// \date 2021 10 29 +// \date 2021 10 29 //----------------------------------------------------------------------------- #pragma once diff --git a/src/qanEdgeItem.cpp b/src/qanEdgeItem.cpp index d169f920..4a6eb8c1 100644 --- a/src/qanEdgeItem.cpp +++ b/src/qanEdgeItem.cpp @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanEdgeItem.cpp +// \file qanEdgeItem.cpp // \author benoit@destrat.io -// \date 2017 03 02 +// \date 2017 03 02 //----------------------------------------------------------------------------- // Qt headers @@ -1116,8 +1116,8 @@ void EdgeItem::mouseDoubleClickEvent(QMouseEvent* event) { if ((getEdge() != nullptr && !getEdge()->getLocked()) && event->button() == Qt::LeftButton && - contains(event->localPos())) { - emit edgeDoubleClicked(this, event->localPos()); + contains(event->position())) { + emit edgeDoubleClicked(this, event->position()); event->accept(); } else @@ -1130,7 +1130,7 @@ void EdgeItem::mousePressEvent(QMouseEvent* event) // Note 20211030: Do not take getLocked() into account, // otherwise onEdgeDoubleClicked() is no longer fired (and edge // can't be unlocked with a visual editor ! - if (contains(event->localPos())) { + if (contains(event->position())) { // Selection management if ((event->button() == Qt::LeftButton || event->button() == Qt::RightButton) && @@ -1142,11 +1142,11 @@ void EdgeItem::mousePressEvent(QMouseEvent* event) } if (event->button() == Qt::LeftButton) { - emit edgeClicked(this, event->localPos()); + emit edgeClicked(this, event->position()); event->accept(); } else if (event->button() == Qt::RightButton) { - emit edgeRightClicked(this, event->localPos()); + emit edgeRightClicked(this, event->position()); event->accept(); } } else @@ -1361,7 +1361,7 @@ void EdgeItem::dragEnterEvent(QDragEnterEvent* event) void EdgeItem::dragMoveEvent(QDragMoveEvent* event) { if (getAcceptDrops()) { - qreal d = distanceFromLine(event->posF( ), QLineF{_p1, _p2}); + qreal d = distanceFromLine(event->position(), QLineF{_p1, _p2}); if (d > 0. && d < 5.) event->accept(); else event->ignore(); diff --git a/src/qanEdgeItem.h b/src/qanEdgeItem.h index a9a8678d..0dc4618f 100644 --- a/src/qanEdgeItem.h +++ b/src/qanEdgeItem.h @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanEdgeItem.h +// \file qanEdgeItem.h // \author benoit@destrat.io -// \date 2016 03 04 +// \date 2016 03 04 //----------------------------------------------------------------------------- #pragma once diff --git a/src/qanGraph.cpp b/src/qanGraph.cpp index 5e63f62e..43d4a5c0 100644 --- a/src/qanGraph.cpp +++ b/src/qanGraph.cpp @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanGraph.cpp +// \file qanGraph.cpp // \author benoit@destrat.io -// \date 2004 February 15 +// \date 2004 February 15 //----------------------------------------------------------------------------- // Std headers @@ -68,14 +68,8 @@ Graph::Graph(QQuickItem* parent) noexcept : Graph::~Graph() { - // Force diconnection of node/edges signals, it avoid - // triggering code on this partially deleted graph when a node or - // edge destroyed() signal is binded to something that try to access this - // partially destroyed graph (for example a nodes/edges model...!). - for (const auto node: get_nodes()) - node->disconnect(node, 0, 0, 0); - for (const auto edge: get_edges()) - edge->disconnect(edge, 0, 0, 0); + // Note 20251219: forced disconnection of all signals from nodes and edges removed, it was a fix + // for pre qt6 versions and is not recommended with latest Qt versions. } void Graph::classBegin() @@ -243,7 +237,7 @@ qan::Group* Graph::groupAt(const QPointF& p, const QSizeF& s, const QQuickItem* // 1. std::vector groups; groups.reserve(static_cast(get_groups().size())); - for (const auto group : qAsConst(get_groups().getContainer())) { + for (const auto group : std::as_const(get_groups().getContainer())) { if (group != nullptr) groups.push_back(group); } @@ -265,7 +259,7 @@ qan::Group* Graph::groupAt(const QPointF& p, const QSizeF& s, const QQuickItem* // 3. if (getContainerItem() == nullptr) return nullptr; - for (const auto group : qAsConst(groups)) { + for (const auto group : std::as_const(groups)) { if (group && group->getItem() != nullptr && group->getItem() != except) { @@ -1396,21 +1390,21 @@ void Graph::selectAll() void Graph::removeSelection() { const auto& selectedNodes = getSelectedNodes(); - for (const auto& node: qAsConst(selectedNodes)) + for (const auto& node: std::as_const(selectedNodes)) if (node && !node->getIsProtected() && !node->getLocked()) removeNode(node); const auto& selectedGroups = getSelectedGroups(); - for (const auto& group: qAsConst(selectedGroups)) + for (const auto& group: std::as_const(selectedGroups)) if (group && !group->getIsProtected() && !group->getLocked()) removeGroup(group); const auto& selectedEdges = getSelectedEdges(); - for (const auto& edge: qAsConst(selectedEdges)) + for (const auto& edge: std::as_const(selectedEdges)) if (edge && !edge->getIsProtected() && !edge->getLocked()) @@ -1449,7 +1443,7 @@ void Graph::clearSelection() std::copy(_selectedEdges.cbegin(), _selectedEdges.cend(), std::back_inserter(selectedEdgesCopy)); - for (auto& edge : qAsConst(selectedEdgesCopy)) + for (auto& edge : std::as_const(selectedEdgesCopy)) if (edge != nullptr && edge->getItem() != nullptr) edge->getItem()->setSelected(false); @@ -2262,7 +2256,7 @@ bool Graph::isAncestor(const qan::Node& node, const qan::Node& candidate) con auto Graph::collectGroupsNodes(const QVector& groups) const noexcept -> std::unordered_set { std::unordered_set r; - for (const auto group: qAsConst(groups)) // Collect all group nodes and their sub groups nodes + for (const auto group: std::as_const(groups)) // Collect all group nodes and their sub groups nodes if (group != nullptr) // recursively collectGroupNodes_rec(group, r); return r; diff --git a/src/qanGraph.h b/src/qanGraph.h index eb1dd9c7..c6b5ddac 100644 --- a/src/qanGraph.h +++ b/src/qanGraph.h @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanGraph.h +// \file qanGraph.h // \author benoit@destrat.io -// \date 2004 February 15 +// \date 2004 February 15 //----------------------------------------------------------------------------- #pragma once diff --git a/src/qanGraphView.cpp b/src/qanGraphView.cpp index d56cfa11..a83dd4e3 100644 --- a/src/qanGraphView.cpp +++ b/src/qanGraphView.cpp @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanGraphView.cpp +// \file qanGraphView.cpp // \author benoit@destrat.io -// \date 2016 08 15 +// \date 2016 08 15 //----------------------------------------------------------------------------- // Qt headers diff --git a/src/qanGraphView.h b/src/qanGraphView.h index 4bf5fd40..f44d1d89 100644 --- a/src/qanGraphView.h +++ b/src/qanGraphView.h @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanGraphView.h +// \file qanGraphView.h // \author benoit@destrat.io -// \date 2016 08 15 +// \date 2016 08 15 //----------------------------------------------------------------------------- #pragma once diff --git a/src/qanGrid.cpp b/src/qanGrid.cpp index 59aeffaa..b382b34e 100644 --- a/src/qanGrid.cpp +++ b/src/qanGrid.cpp @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanGrid.cpp +// \file qanGrid.cpp // \author benoit@destrat.io -// \date 2017 01 29 +// \date 2017 01 29 //----------------------------------------------------------------------------- // Std headers diff --git a/src/qanGrid.h b/src/qanGrid.h index 53bf9566..3ded6493 100644 --- a/src/qanGrid.h +++ b/src/qanGrid.h @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanGrid.h +// \file qanGrid.h // \author benoit@destrat.io -// \date 2017 01 29 +// \date 2017 01 29 //----------------------------------------------------------------------------- #pragma once diff --git a/src/qanGroup.cpp b/src/qanGroup.cpp index 49442d65..fb5f3bb0 100644 --- a/src/qanGroup.cpp +++ b/src/qanGroup.cpp @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanGroup.cpp +// \file qanGroup.cpp // \author benoit@destrat.io -// \date 2016 03 22 +// \date 2016 03 22 //----------------------------------------------------------------------------- // Qt headers @@ -58,7 +58,7 @@ std::unordered_set Group::collectAdjacentEdges() const { std::unordered_set edges = qan::Node::collectAdjacentEdges(); if (is_group()) { - for (const auto groupNode: qAsConst(group_nodes())) { + for (const auto groupNode: std::as_const(group_nodes())) { if (groupNode != nullptr) { const auto qanGroupNode = qobject_cast(groupNode); if (qanGroupNode != nullptr) { diff --git a/src/qanGroupItem.cpp b/src/qanGroupItem.cpp index 3d0019ba..dd7ab00c 100644 --- a/src/qanGroupItem.cpp +++ b/src/qanGroupItem.cpp @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanGroupItem.cpp +// \file qanGroupItem.cpp // \author benoit@destrat.io -// \date 2017 03 02 +// \date 2017 03 02 //----------------------------------------------------------------------------- // QuickQanava headers @@ -131,8 +131,7 @@ bool GroupItem::setDragPolicy(DragPolicy dragPolicy) noexcept } return false; } -GroupItem::DragPolicy GroupItem::getDragPolicy() noexcept { return _dragPolicy; } -const GroupItem::DragPolicy GroupItem::getDragPolicy() const noexcept { return _dragPolicy; } +GroupItem::DragPolicy GroupItem::getDragPolicy() const noexcept { return _dragPolicy; } void GroupItem::groupMoved() { @@ -217,7 +216,7 @@ void GroupItem::mouseDoubleClickEvent(QMouseEvent* event) if (event->button() == Qt::LeftButton && (getNode() != nullptr && !getNode()->getLocked())) - emit groupDoubleClicked(this, event->localPos()); + emit groupDoubleClicked(this, event->position()); } void GroupItem::mousePressEvent(QMouseEvent* event) @@ -235,9 +234,9 @@ void GroupItem::mousePressEvent(QMouseEvent* event) } if (event->button() == Qt::LeftButton) - emit groupClicked(this, event->localPos()); + emit groupClicked(this, event->position()); else if (event->button() == Qt::RightButton) - emit groupRightClicked(this, event->localPos()); + emit groupRightClicked(this, event->position()); } //----------------------------------------------------------------------------- diff --git a/src/qanGroupItem.h b/src/qanGroupItem.h index 3c7f8f42..584ff799 100644 --- a/src/qanGroupItem.h +++ b/src/qanGroupItem.h @@ -137,9 +137,7 @@ class GroupItem : public qan::NodeItem //! \copydoc DragPolicy virtual bool setDragPolicy(DragPolicy dragPolicy) noexcept; //! \copydoc DragPolicy - DragPolicy getDragPolicy() noexcept; - //! \copydoc DragPolicy - const DragPolicy getDragPolicy() const noexcept; + DragPolicy getDragPolicy() const noexcept; protected: //! \copydoc DragPolicy DragPolicy _dragPolicy = DragPolicy::Header; diff --git a/src/qanLineGrid.cpp b/src/qanLineGrid.cpp index 11c41e60..7194f6cd 100644 --- a/src/qanLineGrid.cpp +++ b/src/qanLineGrid.cpp @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanLineGrid.cpp +// \file qanLineGrid.cpp // \author benoit@destrat.io -// \date 2019 11 09 (initial code 2017 01 29) +// \date 2019 11 09 (initial code 2017 01 29) //----------------------------------------------------------------------------- // Std headers diff --git a/src/qanLineGrid.h b/src/qanLineGrid.h index b23054e6..a44a9b51 100644 --- a/src/qanLineGrid.h +++ b/src/qanLineGrid.h @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava library. Copyright 2016 Benoit AUTHEMAN. // -// \file qanLineGrid.h +// \file qanLineGrid.h // \author benoit@destrat.io -// \date 2019 11 09 (initial code 2017 01 29) +// \date 2019 11 09 (initial code 2017 01 29) //----------------------------------------------------------------------------- #pragma once diff --git a/src/qanNavigable.cpp b/src/qanNavigable.cpp index 4f9c68da..b847a515 100644 --- a/src/qanNavigable.cpp +++ b/src/qanNavigable.cpp @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanNavigable.cpp +// \file qanNavigable.cpp // \author benoit@destrat.io -// \date 2015 07 19 +// \date 2015 07 19 //----------------------------------------------------------------------------- // QuickQanava headers diff --git a/src/qanNavigable.h b/src/qanNavigable.h index e5ad9804..942ba8e7 100644 --- a/src/qanNavigable.h +++ b/src/qanNavigable.h @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanNavigable.h +// \file qanNavigable.h // \author benoit@destrat.io -// \date 2015 07 19 +// \date 2015 07 19 //----------------------------------------------------------------------------- #pragma once @@ -348,9 +348,9 @@ protected slots: protected: //! Called when the mouse is clicked in the container (base implementation empty). - virtual void navigableClicked(QPointF pos, QPointF globalPos) { Q_UNUSED(pos); } + virtual void navigableClicked(QPointF pos, QPointF globalPos) { Q_UNUSED(pos); Q_UNUSED(globalPos); } //! Called when the mouse is right clicked in the container (base implementation empty). - virtual void navigableRightClicked(QPointF pos, QPointF globalPos) { Q_UNUSED(pos); } + virtual void navigableRightClicked(QPointF pos, QPointF globalPos) { Q_UNUSED(pos); Q_UNUSED(globalPos); } //! Called when the container item is scaled (zoomed) or panned (base implementation empty). virtual void navigableContainerItemModified() { } diff --git a/src/qanNavigablePreview.cpp b/src/qanNavigablePreview.cpp index 833dd2c7..35a7c532 100644 --- a/src/qanNavigablePreview.cpp +++ b/src/qanNavigablePreview.cpp @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanNavigablePreview.cpp +// \file qanNavigablePreview.cpp // \author benoit@destrat.io -// \date 2017 06 02 +// \date 2017 06 02 //----------------------------------------------------------------------------- // QuickQanava headers diff --git a/src/qanNavigablePreview.h b/src/qanNavigablePreview.h index 7ddd3389..7bd45d88 100644 --- a/src/qanNavigablePreview.h +++ b/src/qanNavigablePreview.h @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanNavigablePreview.h +// \file qanNavigablePreview.h // \author benoit@destrat.io -// \date 2017 06 02 +// \date 2017 06 02 //----------------------------------------------------------------------------- #pragma once diff --git a/src/qanNode.cpp b/src/qanNode.cpp index 67932eab..4f0681cb 100644 --- a/src/qanNode.cpp +++ b/src/qanNode.cpp @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanNode.cpp +// \file qanNode.cpp // \author benoit@destrat.io -// \date 2004 February 15 +// \date 2004 February 15 //----------------------------------------------------------------------------- // Qt headers @@ -140,11 +140,11 @@ QAbstractItemModel* Node::qmlGetOutEdges() const std::unordered_set Node::collectAdjacentEdges() const { std::unordered_set edges; - for (const auto in_edge: qAsConst(get_in_edges())) { + for (const auto in_edge: std::as_const(get_in_edges())) { if (in_edge != nullptr) edges.insert(in_edge); } - for (const auto out_edge: qAsConst(get_out_edges())) { + for (const auto out_edge: std::as_const(get_out_edges())) { if (out_edge != nullptr) edges.insert(out_edge); } diff --git a/src/qanNode.h b/src/qanNode.h index 92bfdfd0..c0c0e5c2 100644 --- a/src/qanNode.h +++ b/src/qanNode.h @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanNode.h +// \file qanNode.h // \author benoit@destrat.io -// \date 2004 February 15 +// \date 2004 February 15 //----------------------------------------------------------------------------- #pragma once diff --git a/src/qanNodeItem.cpp b/src/qanNodeItem.cpp index 325d61a5..a01fd871 100644 --- a/src/qanNodeItem.cpp +++ b/src/qanNodeItem.cpp @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanNodeItem.cpp +// \file qanNodeItem.cpp // \author benoit@destrat.io -// \date 2016 03 04 +// \date 2016 03 04 //----------------------------------------------------------------------------- // Std headers @@ -309,7 +309,7 @@ void NodeItem::mouseDoubleClickEvent(QMouseEvent* event) if (event->button() == Qt::LeftButton && (getNode() != nullptr && !getNode()->getLocked())) - emit nodeDoubleClicked(this, event->localPos()); + emit nodeDoubleClicked(this, event->position()); } void NodeItem::mouseMoveEvent(QMouseEvent* event) @@ -331,7 +331,7 @@ void NodeItem::mouseMoveEvent(QMouseEvent* event) void NodeItem::mousePressEvent(QMouseEvent* event) { bool accepted = !getCollapsed() && // Fast exit - isInsideBoundingShape(event->localPos()); + isInsideBoundingShape(event->position()); if (accepted) { forceActiveFocus(); @@ -348,9 +348,9 @@ void NodeItem::mousePressEvent(QMouseEvent* event) // QML notifications if (event->button() == Qt::LeftButton) - emit nodeClicked(this, event->localPos()); + emit nodeClicked(this, event->position()); else if (event->button() == Qt::RightButton) - emit nodeRightClicked(this, event->localPos()); + emit nodeRightClicked(this, event->position()); event->accept(); } else event->ignore(); @@ -444,7 +444,7 @@ bool NodeItem::isInsideBoundingShape(QPointF p) /* Port/Dock Management *///--------------------------------------------------- qan::PortItem* NodeItem::findPort(const QString& portId) const noexcept { - for (const auto port : qAsConst(_ports)){ // Note: std::as_const is officially c++17 + for (const auto port : std::as_const(_ports)){ // Note: std::as_const is officially c++17 const auto portItem = qobject_cast(port); if (portItem != nullptr && portItem->getId() == portId) { @@ -457,7 +457,7 @@ qan::PortItem* NodeItem::findPort(const QString& portId) const noexcept void NodeItem::updatePortsEdges() { - for (const auto port : qAsConst(_ports)){ // Note: std::as_const is officially c++17 + for (const auto port : std::as_const(_ports)){ // Note: std::as_const is officially c++17 const auto portItem = qobject_cast(port); if (portItem != nullptr) portItem->updateEdges(); diff --git a/src/qanNodeItem.h b/src/qanNodeItem.h index c655567a..ba956e67 100644 --- a/src/qanNodeItem.h +++ b/src/qanNodeItem.h @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanNodeItem.h +// \file qanNodeItem.h // \author benoit@destrat.io -// \date 2016 03 04 +// \date 2016 03 04 //----------------------------------------------------------------------------- #pragma once diff --git a/src/qanPortItem.cpp b/src/qanPortItem.cpp index 342ea4e9..fd2ab6bd 100644 --- a/src/qanPortItem.cpp +++ b/src/qanPortItem.cpp @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanPortItem.cpp +// \file qanPortItem.cpp // \author benoit@destrat.io -// \date 2017 08 10 +// \date 2017 08 10 //----------------------------------------------------------------------------- // Qt headers diff --git a/src/qanPortItem.h b/src/qanPortItem.h index 46a630d7..dc5a3fee 100644 --- a/src/qanPortItem.h +++ b/src/qanPortItem.h @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanPortItem.h +// \file qanPortItem.h // \author benoit@destrat.io -// \date 2017 08 10 +// \date 2017 08 10 //----------------------------------------------------------------------------- #pragma once diff --git a/src/qanRightResizer.cpp b/src/qanRightResizer.cpp index dcf74fa9..2139aab0 100644 --- a/src/qanRightResizer.cpp +++ b/src/qanRightResizer.cpp @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanRightResizer.cpp +// \file qanRightResizer.cpp // \author benoit@destrat.io -// \date 2022 10 09 +// \date 2022 10 09 //----------------------------------------------------------------------------- // Qt headers diff --git a/src/qanRightResizer.h b/src/qanRightResizer.h index 64da06bf..f9da6197 100644 --- a/src/qanRightResizer.h +++ b/src/qanRightResizer.h @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanRightResizer.h +// \file qanRightResizer.h // \author benoit@destrat.io -// \date 2022 10 09 +// \date 2022 10 09 //----------------------------------------------------------------------------- #pragma once diff --git a/src/qanSelectable.cpp b/src/qanSelectable.cpp index c644c60f..e6d1d32f 100644 --- a/src/qanSelectable.cpp +++ b/src/qanSelectable.cpp @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanSelectable.cpp +// \file qanSelectable.cpp // \author benoit@destrat.io -// \date 2016 03 15 +// \date 2016 03 15 //----------------------------------------------------------------------------- // QuickQanava headers diff --git a/src/qanSelectable.h b/src/qanSelectable.h index 93bac0c5..da16a8dc 100644 --- a/src/qanSelectable.h +++ b/src/qanSelectable.h @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanSelectable.h +// \file qanSelectable.h // \author benoit@destrat.io -// \date 2017 03 15 +// \date 2017 03 15 //----------------------------------------------------------------------------- #pragma once diff --git a/src/qanStyle.cpp b/src/qanStyle.cpp index 9e000539..a611bb89 100644 --- a/src/qanStyle.cpp +++ b/src/qanStyle.cpp @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanStyle.cpp +// \file qanStyle.cpp // \author benoit@destrat.io -// \date 2015 06 05 +// \date 2015 06 05 //----------------------------------------------------------------------------- // Qt headers diff --git a/src/qanStyleManager.cpp b/src/qanStyleManager.cpp index b306f4ad..758b980d 100644 --- a/src/qanStyleManager.cpp +++ b/src/qanStyleManager.cpp @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanStyleManager.cpp +// \file qanStyleManager.cpp // \author benoit@destrat.io -// \date 2015 06 05 +// \date 2015 06 05 //----------------------------------------------------------------------------- // Qt headers diff --git a/src/qanTableBorder.cpp b/src/qanTableBorder.cpp index 65d01242..09563d6f 100644 --- a/src/qanTableBorder.cpp +++ b/src/qanTableBorder.cpp @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanTableBorder.cpp +// \file qanTableBorder.cpp // \author benoit@destrat.io -// \date 2023 01 26 +// \date 2023 01 26 //----------------------------------------------------------------------------- // Std headers diff --git a/src/qanTableBorder.h b/src/qanTableBorder.h index d61af7e0..845ed2e8 100644 --- a/src/qanTableBorder.h +++ b/src/qanTableBorder.h @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanTableBorder.h +// \file qanTableBorder.h // \author benoit@destrat.io -// \date 2023 01 26 +// \date 2023 01 26 //----------------------------------------------------------------------------- #pragma once diff --git a/src/qanTableCell.cpp b/src/qanTableCell.cpp index 7da1c598..318f9765 100644 --- a/src/qanTableCell.cpp +++ b/src/qanTableCell.cpp @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanTableCell.cpp +// \file qanTableCell.cpp // \author benoit@destrat.io -// \date 2023 01 26 +// \date 2023 01 26 //----------------------------------------------------------------------------- // QuickQanava headers diff --git a/src/qanTableGroup.cpp b/src/qanTableGroup.cpp index 1b079b24..3b6555dd 100644 --- a/src/qanTableGroup.cpp +++ b/src/qanTableGroup.cpp @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanTableGroup.cpp +// \file qanTableGroup.cpp // \author benoit@destrat.io -// \date 2023 01 25 +// \date 2023 01 25 //----------------------------------------------------------------------------- // Qt headers @@ -110,6 +110,20 @@ void TableGroup::initializeLayout() tableGroupItem->initializeTableLayout(); } +void TableGroup::insertColumn() +{ + auto tableGroupItem = qobject_cast(getItem()); + if (tableGroupItem) + tableGroupItem->insertColumn(); +} + +void TableGroup::insertRow() +{ + auto tableGroupItem = qobject_cast(getItem()); + if (tableGroupItem) + tableGroupItem->insertRow(); +} + bool TableGroup::setRows(int rows) { if (rows != _rows) { diff --git a/src/qanTableGroup.h b/src/qanTableGroup.h index 7380c795..7b9678d4 100644 --- a/src/qanTableGroup.h +++ b/src/qanTableGroup.h @@ -105,6 +105,12 @@ class TableGroup : public qan::Group //! Initialize a "default" layout. Q_INVOKABLE void initializeLayout(); + //! Insert (append) a new column in table. + Q_INVOKABLE void insertColumn(); + + //! Insert (append) a new row in table. + Q_INVOKABLE void insertRow(); + public: //! \copydoc getRows() Q_PROPERTY(int rows READ getRows WRITE setRows NOTIFY rowsChanged FINAL) diff --git a/src/qanTableGroupItem.cpp b/src/qanTableGroupItem.cpp index 06503c03..f4bfb188 100644 --- a/src/qanTableGroupItem.cpp +++ b/src/qanTableGroupItem.cpp @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanTableGroupItem.cpp +// \file qanTableGroupItem.cpp // \author benoit@destrat.io -// \date 2023 01 26 +// \date 2023 01 26 //----------------------------------------------------------------------------- // QuickQanava headers @@ -110,6 +110,7 @@ void TableGroupItem::clearLayout() void TableGroupItem::initialize(int cols, int rows) { //qWarning() << "qan::TableGroupItem::initialize(): rows=" << rows << " cols=" << cols; + //qWarning() << " tablegroup rows=" << getTableGroup()->getRows() << " cols=" << getTableGroup()->getCols(); //qWarning() << " container=" << getContainer(); if (rows <= 0 || cols <= 0) { qWarning() << "TableGroupItem::initialize(): Error, invalid rows or cols count."; @@ -122,10 +123,7 @@ void TableGroupItem::initialize(int cols, int rows) return; } clearLayout(); - createCells(rows * cols); // Create cells - - auto borderComponent = new QQmlComponent(engine, "qrc:/QuickQanava/TableBorder.qml", - QQmlComponent::PreferSynchronous, nullptr); + initializeCells(rows * cols); // Create cells // Notes: // - There is no "exterior" borders: @@ -143,104 +141,52 @@ void TableGroupItem::initialize(int cols, int rows) // // So cell index in _cells at (col=c, row=r) is _cells[(r * cols) + c] - createBorders(cols - 1, rows - 1); - int c = 1; - for (auto verticalBorder: _verticalBorders) { - if (verticalBorder == nullptr) - continue; - for (int r = 0; r < rows; r++) { - verticalBorder->addPrevCell(_cells[(r * cols) + c - 1]); - verticalBorder->addNextCell(_cells[(r * cols) + c]); - } - c++; - } - - int r = 1; - for (auto horizontalBorder: _horizontalBorders) { - if (horizontalBorder == nullptr) - continue; - for (int c = 0; c < cols; c++) { - horizontalBorder->addPrevCell(_cells[((r-1) * cols) + c]); - horizontalBorder->addNextCell(_cells[(r * cols) + c]); - } - r++; - } - - borderComponent->deleteLater(); + initializeBorders(cols - 1, rows - 1); + initializeCellsLinks(); // Link borders and cells // Note 20240830: Do not call initializeTableLayout(), // it is up to the user to do that, it might not be // desirable in vertain serialization use cases. } -void TableGroupItem::createCells(int cellsCount) +void TableGroupItem::initializeCells(int cellsCount) { if (cellsCount <= 0) { - qWarning() << "TableGroupItem::createCells(): Error, invalid rows or cols count."; + qWarning() << "TableGroupItem::initializeCells(): Error, invalid rows or cols count."; return; } if (cellsCount == static_cast(_cells.size())) return; - auto engine = qmlEngine(this); if (engine == nullptr) { - qWarning() << "qan::TableGroupItem::createCells(): Error, no QML engine."; + qWarning() << "qan::TableGroupItem::initializeCells(): Error, no QML engine."; return; } - // Create cells - auto cellComponent = new QQmlComponent(engine, "qrc:/QuickQanava/TableCell.qml", - QQmlComponent::PreferSynchronous, nullptr); for (auto c = 0; c < cellsCount; c++) { - auto cell = qobject_cast(createFromComponent(*cellComponent)); - if (cell != nullptr) { + auto cell = createCell(); + if (cell != nullptr) _cells.push_back(cell); - cell->setParentItem(getContainer() != nullptr ? getContainer() : this); - cell->setVisible(true); - cell->setTable(getTableGroup()); - } } - - cellComponent->deleteLater(); } -void TableGroupItem::createBorders(int verticalBordersCount, int horizontalBordersCount) +void TableGroupItem::initializeBorders(int verticalBordersCount, int horizontalBordersCount) { - //qWarning() << "qan::TableGroupItem::createBorders(): verticalBordersCount=" << verticalBordersCount << " horizontalBordersCount=" << horizontalBordersCount; + //qWarning() << "qan::TableGroupItem::initializeBorders(): verticalBordersCount=" << verticalBordersCount << " horizontalBordersCount=" << horizontalBordersCount; if (verticalBordersCount < 0 || // Might be 0 for 1x1 tables horizontalBordersCount < 0) { - qWarning() << "TableGroupItem::createBorders(): Error, invalid vertical or horizontal borders count."; - return; - } - auto engine = qmlEngine(this); - if (engine == nullptr) { - qWarning() << "qan::TableGroupItem::createBorders(): Error, no QML engine."; + qWarning() << "TableGroupItem::initializeBorders(): Error, invalid vertical or horizontal borders count."; return; } - const auto borderComponent = new QQmlComponent(engine, "qrc:/QuickQanava/TableBorder.qml", - QQmlComponent::PreferSynchronous, nullptr); - qan::TableBorder* prevBorder = nullptr; if (verticalBordersCount != static_cast(_verticalBorders.size())) { for (auto v = 0; v < verticalBordersCount; v++) { - auto border = qobject_cast(createFromComponent(*borderComponent)); + auto border = createBorder(); if (border != nullptr) { - border->setTableGroup(getTableGroup()); border->setOrientation(Qt::Vertical); - border->setParentItem(getContainer() != nullptr ? getContainer() : this); - border->setVisible(true); border->setPrevBorder(prevBorder); - connect(border, &qan::TableBorder::modified, - this, [this]() { - const auto graph = this->getGraph(); - const auto tableGroup = this->getTableGroup(); - if (graph != nullptr && - tableGroup != nullptr) - emit graph->tableModified(tableGroup); - }); _verticalBorders.push_back(border); - if (prevBorder != nullptr) // Audacious initialization of prevBorder nextBorder prevBorder->setNextBorder(border); // with this border prevBorder = border; @@ -250,31 +196,207 @@ void TableGroupItem::createBorders(int verticalBordersCount, int horizontalBo prevBorder = nullptr; if (horizontalBordersCount != static_cast(_horizontalBorders.size())) { for (auto h = 0; h < horizontalBordersCount; h++) { - auto border = qobject_cast(createFromComponent(*borderComponent)); + auto border = createBorder(); if (border != nullptr) { - border->setTableGroup(getTableGroup()); border->setOrientation(Qt::Horizontal); - border->setParentItem(getContainer() != nullptr ? getContainer() : this); - border->setVisible(true); border->setPrevBorder(prevBorder); - connect(border, &qan::TableBorder::modified, - this, [this]() { + _horizontalBorders.push_back(border); + if (prevBorder != nullptr) // Audacious initialization of prevBorder nextBorder + prevBorder->setNextBorder(border); // with this border + prevBorder = border; + } + } + } +} + +void TableGroupItem::initializeCellsLinks() +{ + auto tableGroup = getTableGroup(); + if (tableGroup == nullptr) + return; + const std::size_t rows = tableGroup->getRows() > 0 ? tableGroup->getRows() : 0; + const std::size_t cols = tableGroup->getCols() > 0 ? tableGroup->getCols() : 0; + if (_cells.size() != (rows * cols)) + return; + int c = 1; + for (auto verticalBorder: _verticalBorders) { + if (verticalBorder == nullptr) + continue; + for (std::size_t r = 0; r < rows; r++) { + verticalBorder->addPrevCell(_cells[(r * cols) + c - 1]); + verticalBorder->addNextCell(_cells[(r * cols) + c]); + } + c++; + } + int r = 1; + for (auto horizontalBorder: _horizontalBorders) { + if (horizontalBorder == nullptr) + continue; + for (std::size_t c = 0; c < cols; c++) { + horizontalBorder->addPrevCell(_cells[((r-1) * cols) + c]); + horizontalBorder->addNextCell(_cells[(r * cols) + c]); + } + r++; + } +} + +qan::TableBorder* TableGroupItem::createBorder() +{ + if (TableGroupItem::_borderComponent == nullptr) { + auto engine = qmlEngine(this); + if (engine == nullptr) { + qWarning() << "qan::TableGroupItem::initializeBorders(): Error, no QML engine."; + return nullptr; + } + // Component is parented to graph, will be destroyed when graph is destroyed + TableGroupItem::_borderComponent = new QQmlComponent(engine, "qrc:/QuickQanava/TableBorder.qml", + QQmlComponent::PreferSynchronous, getGraph()); + } + if (!TableGroupItem::_borderComponent) + return nullptr; + auto border = qobject_cast(createFromComponent(*TableGroupItem::_borderComponent)); + if (border != nullptr) { + border->setTableGroup(getTableGroup()); + border->setParentItem(getContainer() != nullptr ? getContainer() : this); + border->setVisible(true); + connect(border, &qan::TableBorder::modified, + this, [this]() { const auto graph = this->getGraph(); const auto tableGroup = this->getTableGroup(); if (graph != nullptr && tableGroup != nullptr) - emit graph->tableModified(tableGroup); + emit graph->tableModified(tableGroup); }); - _horizontalBorders.push_back(border); + } + return border; +} - if (prevBorder != nullptr) // Audacious initialization of prevBorder nextBorder - prevBorder->setNextBorder(border); // with this border - prevBorder = border; - } + +qan::TableCell* TableGroupItem::createCell() +{ + if (TableGroupItem::_cellComponent == nullptr) { + auto engine = qmlEngine(this); + if (engine == nullptr) { + qWarning() << "qan::TableGroupItem::initializeBorders(): Error, no QML engine."; + return nullptr; } + // Component is parented to graph, will be destroyed when graph is destroyed + TableGroupItem::_cellComponent = new QQmlComponent(engine, "qrc:/QuickQanava/TableCell.qml", + QQmlComponent::PreferSynchronous, nullptr); + } + if (!TableGroupItem::_cellComponent) + return nullptr; + auto cell = qobject_cast(createFromComponent(*TableGroupItem::_cellComponent)); + if (cell != nullptr) { + cell->setParentItem(getContainer() != nullptr ? getContainer() : this); + cell->setVisible(true); + cell->setTable(getTableGroup()); + } + return cell; +} + +void TableGroupItem::insertColumn() +{ + // Algorithm: + // Create a new vertical border for the new column + // Create new cells for the new cols column count + qWarning() << "qan::TableGroupItem::insertColumn()"; + const auto container = getContainer(); + if (container == nullptr) + return; + auto tableGroup = getTableGroup(); + if (tableGroup == nullptr) + return; + qan::TableBorder* prevBorder = _verticalBorders.empty() ? nullptr : _verticalBorders.back(); + if (prevBorder == nullptr) + return; + const auto width = container->width(); + auto border = createBorder(); + if (border != nullptr) { + border->setOrientation(Qt::Vertical); + border->setPrevBorder(prevBorder); + _verticalBorders.push_back(border); + prevBorder->setNextBorder(border); + const auto x = prevBorder->x() + ((width - prevBorder->x()) / 2.0); + border->setX(x); + border->setSx(x / width); + border->setHeight(prevBorder->height()); + border->setWidth(3); + } + + // Update the _cells array, be very carefull there is a mapping from + // old table layout to new layout. Done in 2 phase: copy old cells + // to the new layout, then initialize new cells in the new column + const auto oldCols = tableGroup->getCols(); + const auto oldRows = tableGroup->getRows(); + const auto newCols = oldCols + 1; + const auto newRows = oldRows; + Cells_t newCells; + newCells.resize(newCols * newRows); + for (auto r = 0; r < oldRows; r++) // Copy old cells to new table + for (auto c = 0; c < oldRows; c++) + newCells[(r * newCols) + c] = _cells[(r * oldCols) + c]; + for (auto r = 0; r < oldRows; r++) { // Create new cells for new column + auto cell = createCell(); + qWarning() << "cell=" << cell; + newCells[(r * newCols) + (newCols - 1)] = cell; } + _cells = newCells; + tableGroup->setCols(newCols); + // Initialize links between border and cells, then layout cells with valid size + initializeCellsLinks(); + layoutCells(); +} - borderComponent->deleteLater(); +void TableGroupItem::insertRow() +{ + // Algorithm: + // Create a new horizontal border for the new row + // Create new cells for the new row + // qWarning() << "qan::TableGroupItem::insertRow()"; + const auto container = getContainer(); + if (container == nullptr) + return; + auto tableGroup = getTableGroup(); + if (tableGroup == nullptr) + return; + qan::TableBorder* prevBorder = _horizontalBorders.empty() ? nullptr : _horizontalBorders.back(); + if (prevBorder == nullptr) + return; + const auto height = container->height(); + auto border = createBorder(); + if (border != nullptr) { + border->setOrientation(Qt::Horizontal); + border->setPrevBorder(prevBorder); + _horizontalBorders.push_back(border); + prevBorder->setNextBorder(border); + const auto y = prevBorder->y() + ((height - prevBorder->y()) / 2.0); + border->setY(y); + border->setSy(y / height); + border->setWidth(prevBorder->width()); + border->setHeight(3); + } + + // Update the _cells array, be very carefull there is a mapping from + // old table layout to new layout. Done in 2 phase: copy old cells + // to the new layout, then initialize new cells in the new column + const auto oldCols = tableGroup->getCols(); + const auto oldRows = tableGroup->getRows(); + const auto newCols = oldCols; + const auto newRows = oldRows + 1; + Cells_t newCells; + newCells.resize(newCols * newRows); + // No need to map since the cells are "appended" (see insertColumn()). + std::copy(_cells.begin(), _cells.end(), newCells.begin()); + for (auto c = 0; c < newCols; c++) { // Create new cells for new row + auto cell = createCell(); + newCells[((newRows - 1) * newCols) + c] = cell; + } + _cells = newCells; + tableGroup->setRows(newRows); + // Initialize links between border and cells, then layout cells with valid size + initializeCellsLinks(); + layoutCells(); } auto TableGroupItem::createFromComponent(QQmlComponent& component) -> QQuickItem* @@ -317,17 +439,17 @@ void TableGroupItem::initializeTableLayout() return; const auto tableWidth = tableContainer->width(); const auto tableHeight = tableContainer->height(); - const auto tableSize = tableContainer->size(); - qWarning() << "qan::TableGroupItem::initializeTableLayout(): tableSize=" << tableSize; + //const auto tableSize = tableContainer->size(); + //qWarning() << "qan::TableGroupItem::initializeTableLayout(): tableSize=" << tableSize; if (qRound(tableWidth) <= 0 || qRound(tableHeight) <= 0) return; const int cols = tableGroup->getCols(); const int rows = tableGroup->getRows(); const auto spacing = tableGroup != nullptr ? tableGroup->getCellSpacing() : - 5.; + 5.; const auto padding = tableGroup != nullptr ? tableGroup->getTablePadding() : - 2.; + 2.; if (cols <= 0 || rows <= 0) { qWarning() << "qan::TableGroupItem::initializeTableLayout(): Error, rows and columns count can't be <= 0."; @@ -339,13 +461,13 @@ void TableGroupItem::initializeTableLayout() } const auto cellWidth = tableWidth > 0. ? (tableWidth - - (2 * padding) - - ((cols - 1) * spacing)) / cols : - 0.; + - (2 * padding) + - ((cols - 1) * spacing)) / cols : + 0.; const auto cellHeight = tableHeight > 0. ? (tableHeight - - (2 * padding) - - ((rows - 1) * spacing)) / rows : - 0.; + - (2 * padding) + - ((rows - 1) * spacing)) / rows : + 0.; //qWarning() << " cellWidth=" << cellWidth << " cellHeight=" << cellHeight; @@ -389,8 +511,6 @@ void TableGroupItem::initializeTableLayout() (r * cellHeight) + (spacing / 2.); horizontalBorder->setX(0.); - // FIXME #1756 BTW, ce serait peut-ĂȘtre bien aussi de normaliser - // width et heght en prevision merge... const auto borderY = y - borderHeight2; horizontalBorder->setSy(borderY / tableHeight); horizontalBorder->setWidth(tableWidth); @@ -403,9 +523,7 @@ void TableGroupItem::initializeTableLayout() // it will be called automatically when border are moved. // Note 20230406: In fact calling layout cell is necessary for rows==1, cols==1 // table that need special handling to dimension cells since there is no horiz/vert borders. - // FIXME #1756 layoutTable(); - //layoutCells(); } void TableGroupItem::layoutTable() @@ -425,8 +543,8 @@ void TableGroupItem::layoutTable() if (tableSize.isEmpty() || tableSize.isNull()) return; - qWarning() << "TableGroupItem::layoutTable(): " << getGroup()->getLabel() << - " tableWidth=" << tableWidth << "tableHeight=" << tableHeight; + // qWarning() << "TableGroupItem::layoutTable(): " << getGroup()->getLabel() << + // " tableWidth=" << tableWidth << "tableHeight=" << tableHeight; // Project normalized sx/sy coordinates to table item container CS. for (const auto verticalBorder: _verticalBorders) { @@ -519,7 +637,8 @@ bool TableGroupItem::setGroup(qan::Group* group) noexcept if (cell != nullptr) cell->setTable(tableGroup); - // Note 20240831: Do not layout it is up to the user to call qan::TableGroup::initializeLayout() + // Note 20240831: Do not layout it is up to the user to call qan::TableGroup::initializeLayout(), + // for example you might want to use custom serialization code return true; } } @@ -536,8 +655,8 @@ void TableGroupItem::groupNodeItem(qan::NodeItem* nodeItem, qan::TableCell* g { //qWarning() << "qan::TableGroupItem::groupNodeItem(): nodeItem=" << nodeItem << " groupCell=" << groupCell; // PRECONDITIONS: - // nodeItem can't be nullptr - // A 'container' must have been configured + // nodeItem can't be nullptr + // A 'container' must have been configured Q_UNUSED(groupCell) Q_UNUSED(transform) if (nodeItem == nullptr || @@ -608,7 +727,7 @@ void TableGroupItem::mouseDoubleClickEvent(QMouseEvent* event) if (event->button() == Qt::LeftButton && (getNode() != nullptr && !getNode()->getLocked())) - emit groupDoubleClicked(this, event->localPos()); + emit groupDoubleClicked(this, event->position()); } void TableGroupItem::mousePressEvent(QMouseEvent* event) @@ -616,18 +735,18 @@ void TableGroupItem::mousePressEvent(QMouseEvent* event) qan::NodeItem::mousePressEvent(event); if (event->button() == Qt::LeftButton && // Selection management - getGroup() && - isSelectable() && - !getCollapsed() && // Locked/Collapsed group is not selectable - !getNode()->getLocked()) { + getGroup() && + isSelectable() && + !getCollapsed() && // Locked/Collapsed group is not selectable + !getNode()->getLocked()) { if (getGraph()) getGraph()->selectGroup(*getGroup(), event->modifiers()); } if (event->button() == Qt::LeftButton) - emit groupClicked(this, event->localPos()); + emit groupClicked(this, event->position()); else if (event->button() == Qt::RightButton) - emit groupRightClicked(this, event->localPos()); + emit groupRightClicked(this, event->position()); } //----------------------------------------------------------------------------- diff --git a/src/qanTableGroupItem.h b/src/qanTableGroupItem.h index 91b3e64e..7519b73e 100644 --- a/src/qanTableGroupItem.h +++ b/src/qanTableGroupItem.h @@ -84,9 +84,31 @@ class TableGroupItem : public qan::GroupItem //! Initialize a table withe default cells and borders. void initialize(int cols, int rows); +public: + void initializeCells(int cellsCount); + void initializeBorders(int verticalBordersCount, int horizontalBordersCount); +protected: + //! Initialize the links between . + void initializeCellsLinks(); + +protected: + //! Factory of TableBorder.qml components, return nullptr on error, border is returned partially configured. + qan::TableBorder* createBorder(); +private: + // TableBorder.qml component cache. + inline static QQmlComponent* _borderComponent = nullptr; +protected: + //! Factory of TableCell.qml components, return nullptr on error, cell is returned partially configured. + qan::TableCell* createCell(); +private: + // TableCell.qml component cache. + inline static QQmlComponent* _cellComponent = nullptr; - void createCells(int cellsCount); - void createBorders(int verticalBordersCount, int horizontalBordersCount); +public: + //! Insert (append) a column. + void insertColumn(); + //! Insert (append) a row. + void insertRow(); protected: auto createFromComponent(QQmlComponent& component) -> QQuickItem*; diff --git a/src/qanTreeLayouts.cpp b/src/qanTreeLayouts.cpp index 5c7c23a2..5655e1dd 100644 --- a/src/qanTreeLayouts.cpp +++ b/src/qanTreeLayouts.cpp @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanOrgTreeLayout.h +// \file qanOrgTreeLayout.h // \author benoit@destrat.io -// \date 2024 08 13 +// \date 2024 08 13 //----------------------------------------------------------------------------- // Std headers @@ -75,7 +75,7 @@ void NaiveTreeLayout::layout(qan::Node& root) noexcept return r; // <-- hand tuned ChatGPT code - std::queue> nodeLevelqueue; + std::queue> nodeLevelqueue; std::unordered_set visited; nodeLevelqueue.push({root, 0}); @@ -209,8 +209,7 @@ bool OrgTreeLayout::setLayoutOrientation(OrgTreeLayout::LayoutOrientation lay } return false; } -OrgTreeLayout::LayoutOrientation OrgTreeLayout::getLayoutOrientation() noexcept { return _layoutOrientation; } -const OrgTreeLayout::LayoutOrientation OrgTreeLayout::getLayoutOrientation() const noexcept { return _layoutOrientation; } +OrgTreeLayout::LayoutOrientation OrgTreeLayout::getLayoutOrientation() const noexcept { return _layoutOrientation; } void OrgTreeLayout::layout(qan::Node& root, qreal xSpacing, qreal ySpacing) noexcept diff --git a/src/qanTreeLayouts.h b/src/qanTreeLayouts.h index bcc447e6..48904740 100644 --- a/src/qanTreeLayouts.h +++ b/src/qanTreeLayouts.h @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanOrgTreeLayout.h +// \file qanOrgTreeLayout.h // \author benoit@destrat.io -// \date 2024 08 13 +// \date 2024 08 13 //----------------------------------------------------------------------------- #pragma once @@ -162,9 +162,7 @@ class OrgTreeLayout : public QObject //! \copydoc LayoutOrientation bool setLayoutOrientation(LayoutOrientation layoutOrientation) noexcept; //! \copydoc LayoutOrientation - LayoutOrientation getLayoutOrientation() noexcept; - //! \copydoc LayoutOrientation - const LayoutOrientation getLayoutOrientation() const noexcept; + LayoutOrientation getLayoutOrientation() const noexcept; protected: //! \copydoc LayoutOrientation LayoutOrientation _layoutOrientation = LayoutOrientation::Vertical; @@ -195,4 +193,3 @@ class OrgTreeLayout : public QObject } // ::qan QML_DECLARE_TYPE(qan::OrgTreeLayout) - diff --git a/src/qanUtils.cpp b/src/qanUtils.cpp index d3435665..c17f1702 100644 --- a/src/qanUtils.cpp +++ b/src/qanUtils.cpp @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanUtils.cpp +// \file qanUtils.cpp // \author benoit@destrat.io -// \date 2017 03 17 +// \date 2017 03 17 //----------------------------------------------------------------------------- // Qt headers diff --git a/src/qanUtils.h b/src/qanUtils.h index f54825f0..b76f6a0f 100644 --- a/src/qanUtils.h +++ b/src/qanUtils.h @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- // This file is a part of the QuickQanava software library. // -// \file qanUtils.h +// \file qanUtils.h // \author benoit@destrat.io -// \date 2017 03 17 +// \date 2017 03 17 //----------------------------------------------------------------------------- #pragma once diff --git a/src/quickcontainers/QuickContainers.h b/src/quickcontainers/QuickContainers.h index fd10800c..0da47d30 100644 --- a/src/quickcontainers/QuickContainers.h +++ b/src/quickcontainers/QuickContainers.h @@ -29,7 +29,7 @@ // // \file QuickContainer.h // \author benoit@destrat.io -// \date 2012 02 08 +// \date 2012 02 08 //----------------------------------------------------------------------------- #pragma once