Compare commits

..

15 Commits

Author SHA1 Message Date
joshua e6d29cf345 Merge branch 'master' into qt6_cmake_joshua 2026-07-31 21:15:21 +02:00
Laurent Trinques f16cf7dac8 Merge remote-tracking branch 'origin/master' into qt6_cmake_joshua
# Conflicts:
#	CMakeLists.txt
2026-05-28 09:32:07 +02:00
joshua 2d4f968348 Fix crash when collapse root item of macro element tree view
Add an icon to the macro type of FileElementCollectionItem.

The first time the model (ElementsCollectionModel) ask for decoration
role the FileElementCollectionItem check if icon is null, if true the
icon is set, if false the function return.

In the case of the macro type, befor this commit the macro have a null
icon, and so the setIcon is call each time (many) the mouse move hover
and cause a qet crash.
This commit fix that, only by setUp an icon
2026-05-06 00:20:07 +02:00
joshua 6f669e1074 Merge branch 'master' into qt6_cmake_joshua 2026-05-05 20:11:05 +02:00
joshua 0b91318749 Remove several QT_VERSION_CHECK
Remove several QT_VERSION_CHECK related to Qt5 and Qt4.
2026-03-19 19:54:51 +01:00
joshua 1ba97c7e92 Remove hoto_update_cmake_message.cmake 2026-03-03 21:45:48 +01:00
joshua cd09fc0d32 Re-enable git_update_submodules.cmake
Re-enable git_update_submodules.cmake, use for update the elements repo.
Remove the unused include : fetch_elements.cmake
2026-03-03 21:44:35 +01:00
Laurent Trinques 924fe082fb Update fr_window_build_msys2.md 2026-03-03 06:56:24 +01:00
joshua ad37b0f9a5 Add documentation for build under Windows
The documentation is available in french only.
Contributors, feel free to create a new documentation in English (create
a new directory named 'en' for this purpose).
2026-03-02 22:47:32 +01:00
joshua fedc1cb092 Made available compilation on windows with msys2
The aim of this commit is to easily build qelectrotech under windows
with qt6/cmake and the package tool MSYS2.

-Update some cmake file.
-Remove Git submodule for pugixml and single application
-Use cmake find_package for pugi xml
-Use cmake fetchContent for single application.
-Use cmake find_package for KCoreAddons and KWidgetsAddons.
-Minor change for pugi xml
-Minor change on ProjectPrintWindow class to compatible with Qt6 API.
2026-03-02 22:34:16 +01:00
joshua 5f318e09c8 Add forgotten file and folder.
Add folder and file to cmake.
2026-01-30 19:43:07 +01:00
joshua 27afeaefe2 Upgrade pugixml version.
Upgrade pugixml to be compatible with cmake >= 4.0.0.

Compatibility with CMake < 3.5 has been removed from CMake since 4.0.0.
Pugixml V1.11.4 used cmake 3.4. Latest version V1.15 use cmake VERSION
3.5...3.30
2026-01-30 18:46:21 +01:00
joshua ab2f933fdf Re-enable multi-threading to load collection
The name of the elements and folders of the collection are not displayed
until we hover the item with the mouse.
This due that QtConcurent::run was disabled at loading of collection in
the goal of use QtConcurrent::run with Qt6.
Run is made to run a function once.
Map is made to run a fonction for each item of a sequence (what we need
in this case).
Remove code of run and re-enable code for map.
2026-01-28 19:47:04 +01:00
joshua 7f718f672f Fix : can't open recent file 2026-01-28 00:15:09 +01:00
joshua 9ec02bc088 Build with qt6 and cmake
First build with qt6 and cmake.
QET compil, but a lot of things don't work.
Build tested on debian sid and ubuntu 25.04.

Dependency needed under debian and ubuntu :
qtcreator cmake qt6-tools-dev qt6-svg-dev libsqlite3-dev
libkf6coreaddons-dev extra-cmake-modules libkf6widgetsaddons-dev
2026-01-27 23:31:34 +01:00
200 changed files with 27675 additions and 46782 deletions
+1
View File
@@ -11,6 +11,7 @@ jobs:
permissions:
contents: write
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v4
with:
-6
View File
@@ -1,9 +1,3 @@
[submodule "pugixml"]
path = pugixml
url = https://github.com/zeux/pugixml.git
[submodule "SingleApplication"]
path = SingleApplication
url = https://github.com/itay-grudev/SingleApplication.git
[submodule "elements"]
path = elements
url = https://github.com/qelectrotech/qelectrotech-elements.git
+75 -114
View File
@@ -14,8 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
include(cmake/hoto_update_cmake_message.cmake)
cmake_minimum_required(VERSION 3.5...4.2)
project(qelectrotech
@@ -27,6 +25,13 @@ project(qelectrotech
include(cmake/copyright_message.cmake)
set(QET_DIR ${PROJECT_SOURCE_DIR})
include(cmake/qet_compilation_vars.cmake)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Qt6 REQUIRED COMPONENTS ${QET_COMPONENTS})
qt_standard_project_setup()
# QT_VERSION_MAJOR is chosen explicitly by whoever configures the build,
# via -DQT_VERSION_MAJOR=5 or -DQT_VERSION_MAJOR=6.
@@ -36,7 +41,7 @@ set(QET_DIR ${PROJECT_SOURCE_DIR})
# includes below, so every subdirectory and every FetchContent dependency
# sees a consistent, already-defined value.
if(NOT DEFINED QT_VERSION_MAJOR)
set(QT_VERSION_MAJOR 5)
set(QT_VERSION_MAJOR 6)
endif()
# Some third-party CMake projects we pull in via FetchContent (e.g.
@@ -49,10 +54,10 @@ endif()
set(QT_DEFAULT_MAJOR_VERSION ${QT_VERSION_MAJOR} CACHE STRING "Qt version to use (5 or 6)" FORCE)
# Add sub directories
option(PACKAGE_TESTS "Build the tests" ON)
option(PACKAGE_TESTS "Build the tests" NO)
if(PACKAGE_TESTS)
message("Add sub directory tests")
add_subdirectory(tests)
message("Add sub directory tests")
add_subdirectory(tests)
endif()
include(cmake/paths_compilation_installation.cmake)
@@ -63,10 +68,9 @@ include(cmake/git_last_commit_sha.cmake)
include(cmake/fetch_kdeaddons.cmake)
include(cmake/fetch_singleapplication.cmake)
include(cmake/fetch_pugixml.cmake)
include(cmake/qet_compilation_vars.cmake)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
SET(CMAKE_CXX_STANDARD 17)
@@ -82,7 +86,7 @@ find_package(
# when the GuiPrivate component is explicitly requested. Qt5 has no such
# component package and creates the target implicitly with Gui, so only
# request it on Qt6 - requesting it on Qt5 fails the whole configure.
if(QT_VERSION_MAJOR GREATER_EQUAL 6)
if(QT_VERSION_MAJOR GREATER_EQUAL 5)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS GuiPrivate)
endif()
@@ -107,11 +111,11 @@ set(CMAKE_AUTOUIC_SEARCH_PATHS ${QET_DIR}/sources/ui)
# lupdate rewriting a .ts while lrelease read the same file made the build
# fail with "Premature end of document".
set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION "${QET_DIR}/lang")
if(QT_VERSION_MAJOR EQUAL 6)
qt6_add_translation(QM_FILES ${TS_FILES})
else()
qt5_add_translation(QM_FILES ${TS_FILES})
endif()
#if(QT_VERSION_MAJOR EQUAL 6)
# qt6_add_translation(QM_FILES ${TS_FILES})
#else()
# qt5_add_translation(QM_FILES ${TS_FILES})
#endif()
add_custom_target(update_translations
COMMAND $<TARGET_FILE:Qt${QT_VERSION_MAJOR}::lupdate> ${CMAKE_SOURCE_DIR}/sources -ts ${TS_FILES}
@@ -120,117 +124,74 @@ add_custom_target(update_translations
VERBATIM
)
# als laatse
include(cmake/define_definitions.cmake)
# On Windows, WIN32 sets /SUBSYSTEM:WINDOWS to suppress the console window.
# Qt automatically links qtmain.lib which provides the WinMain entry point,
# so no source code change is needed.
if(WIN32)
add_executable(
${PROJECT_NAME}
WIN32
${QET_RES_FILES}
${QET_SRC_FILES}
${QM_FILES}
${QET_DIR}/qelectrotech.qrc
)
qt_add_executable(
${PROJECT_NAME}
${QET_RES_FILES}
${QET_SRC_FILES}
${QM_FILES}
${QET_DIR}/qelectrotech.qrc
)
if(QMFILES_AS_RESOURCE)
qt_add_translations(${PROJECT_NAME} TS_FILES ${TS_FILES} RESOURCE_PREFIX "/lang")
else()
add_executable(
${PROJECT_NAME}
${QET_RES_FILES}
${QET_SRC_FILES}
${QM_FILES}
${QET_DIR}/qelectrotech.qrc
)
qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION "${QET_DIR}/lang")
qt_add_translation(QM_FILES ${TS_FILES})
endif()
# Optional precompiled headers -- see QET_ENABLE_PCH in
# cmake/developer_options.cmake for what this trades away.
#
# target_precompile_headers() needs CMake 3.16; the project still declares a
# 3.5 minimum, so guard rather than raise it for an opt-in developer feature.
#
# The generator expressions are load-bearing, not decoration: this target also
# compiles the 18 C files of the bundled LZMA decoder
# (sources/import/edz/lzma/*.c), and an unguarded list applies to every
# language in the target, so the Qt headers would reach the C compiler and fail
# with "unknown type name 'namespace'". $<ANGLE-R> is required because a
# literal '>' would terminate the generator expression.
if(QET_ENABLE_PCH)
if(CMAKE_VERSION VERSION_LESS 3.16)
message(WARNING
"QET_ENABLE_PCH needs CMake 3.16 or newer (found ${CMAKE_VERSION}); "
"building without precompiled headers.")
else()
target_precompile_headers(${PROJECT_NAME} PRIVATE
"$<$<COMPILE_LANGUAGE:CXX>:<QtCore/QtCore$<ANGLE-R>>"
"$<$<COMPILE_LANGUAGE:CXX>:<QtGui/QtGui$<ANGLE-R>>"
"$<$<COMPILE_LANGUAGE:CXX>:<QtWidgets/QtWidgets$<ANGLE-R>>"
"$<$<COMPILE_LANGUAGE:CXX>:<QtXml/QtXml$<ANGLE-R>>"
)
message(STATUS "QET_ENABLE_PCH: precompiled headers enabled")
endif()
endif()
find_package(SQLite3 REQUIRED)
target_link_libraries(
${PROJECT_NAME}
PUBLIC
PRIVATE
pugixml::pugixml
SingleApplication::SingleApplication
SQLite3::SQLite3
${KF5_PRIVATE_LIBRARIES}
${QET_PRIVATE_LIBRARIES}
)
${PROJECT_NAME}
PUBLIC
PRIVATE
pugixml::pugixml
SingleApplication::SingleApplication
SQLite::SQLite3
${KF6_PRIVATE_LIBRARIES}
${QET_PRIVATE_LIBRARIES}
)
target_include_directories(
${PROJECT_NAME}
PRIVATE
${QET_DIR}/sources/titleblock
${QET_DIR}/sources/ui
${QET_DIR}/sources/qetgraphicsitem
${QET_DIR}/sources/qetgraphicsitem/ViewItem
${QET_DIR}/sources/qetgraphicsitem/ViewItem/ui
${QET_DIR}/sources/richtext
${QET_DIR}/sources/factory
${QET_DIR}/sources/properties
${QET_DIR}/sources/dvevent
${QET_DIR}/sources/editor
${QET_DIR}/sources/editor/esevent
${QET_DIR}/sources/editor/graphicspart
${QET_DIR}/sources/editor/ui
${QET_DIR}/sources/editor/UndoCommand
${QET_DIR}/sources/undocommand
${QET_DIR}/sources/diagramevent
${QET_DIR}/sources/ElementsCollection
${QET_DIR}/sources/ElementsCollection/ui
${QET_DIR}/sources/autoNum
${QET_DIR}/sources/autoNum/ui
${QET_DIR}/sources/ui/configpage
${QET_DIR}/sources/SearchAndReplace
${QET_DIR}/sources/SearchAndReplace/ui
${QET_DIR}/sources/NameList
${QET_DIR}/sources/NameList/ui
${QET_DIR}/sources/utils
${QET_DIR}/pugixml/src
${QET_DIR}/sources/dataBase
${QET_DIR}/sources/dataBase/ui
${QET_DIR}/sources/factory/ui
${QET_DIR}/sources/print
${QET_DIR}/sources/svg
)
if(NOT BUILD_WITH_KF5)
target_include_directories(
${PROJECT_NAME}
PRIVATE
${QET_DIR}/sources/ui/nokde
)
endif()
${PROJECT_NAME}
PRIVATE
${QET_DIR}/sources/titleblock
${QET_DIR}/sources/ui
${QET_DIR}/sources/qetgraphicsitem
${QET_DIR}/sources/qetgraphicsitem/ViewItem
${QET_DIR}/sources/qetgraphicsitem/ViewItem/ui
${QET_DIR}/sources/richtext
${QET_DIR}/sources/factory
${QET_DIR}/sources/properties
${QET_DIR}/sources/dvevent
${QET_DIR}/sources/editor
${QET_DIR}/sources/editor/esevent
${QET_DIR}/sources/editor/graphicspart
${QET_DIR}/sources/editor/ui
${QET_DIR}/sources/editor/UndoCommand
${QET_DIR}/sources/undocommand
${QET_DIR}/sources/diagramevent
${QET_DIR}/sources/ElementsCollection
${QET_DIR}/sources/ElementsCollection/ui
${QET_DIR}/sources/autoNum
${QET_DIR}/sources/autoNum/ui
${QET_DIR}/sources/ui/configpage
${QET_DIR}/sources/SearchAndReplace
${QET_DIR}/sources/SearchAndReplace/ui
${QET_DIR}/sources/NameList
${QET_DIR}/sources/NameList/ui
${QET_DIR}/sources/utils
${QET_DIR}/sources/dataBase
${QET_DIR}/sources/dataBase/ui
${QET_DIR}/sources/factory/ui
${QET_DIR}/sources/print
${QET_DIR}/sources/svg
)
install(TARGETS ${PROJECT_NAME})
if (NOT MINGW)
install(DIRECTORY ico/breeze-icons/16x16 DESTINATION ${QET_ICONS_PATH})
install(DIRECTORY ico/breeze-icons/22x22 DESTINATION ${QET_ICONS_PATH})
View File
+3
View File
@@ -59,6 +59,9 @@ Here are the technical choices made for the software development:
If you wish to be informed of the latest developments, browse the [archive](https://listengine.tuxfamily.org/lists.tuxfamily.org/qet/) of the project mailing list where all commits (changes) are registered. This archive is publicly available, you don't need any account to access it.
### Build QElectroTech under Windows
To build QElectroTech under microsoft Windows, please follow [these instructions (french)](md/fr/fr_window_build_summary.md)
# Features
+10 -5
View File
@@ -62,10 +62,15 @@ message("PROJECT_SOURCE_DIR :" ${PROJECT_SOURCE_DIR})
message("QET_DIR :" ${QET_DIR})
message("GIT_COMMIT_SHA :" ${GIT_COMMIT_SHA})
if(BUILD_WITH_KF5)
message("KF5_GIT_TAG :" ${KF5_GIT_TAG})
else()
add_definitions(-DBUILD_WITHOUT_KF5)
if(BUILD_WITH_KF6 AND BUILD_KF6)
message("KF6_GIT_TAG :" ${KF6_GIT_TAG})
endif()
if(NOT BUILD_WITH_KF6)
add_definitions(-DBUILD_WITHOUT_KF6)
endif()
message("QET_COMPONENTS :" ${QET_COMPONENTS})
message("QT_VERSION_MAJOR :" ${QT_VERSION_MAJOR})
message("Qt version :" ${Qt6_VERSION})
if(QMFILES_AS_RESOURCE)
add_definitions(-DQMFILES_AS_RESOURCE)
endif()
+4 -15
View File
@@ -31,19 +31,8 @@ add_definitions(-DQT_MESSAGELOGCONTEXT)
# In order to do so, uncomment the following line.
#add_definitions(-DTODO_LIST)
# Build with KF5
option(BUILD_WITH_KF5 "Build with KF5" ON)
# Build with KF6
option(BUILD_WITH_KF6 "Build with KF6" ON)
# Precompiled headers for the Qt umbrella headers.
#
# Off by default and intended for local development only. Building QET is
# dominated by re-parsing Qt's headers: a 214-line .cpp expands to ~198,000
# preprocessed lines, and compiling one translation unit costs ~4.1 s of which
# only ~0.35 s is optimisation (-O0 instead of -O3 saves 8%). A PCH caches the
# parsed header state and takes that ~4.1 s down to ~1.2 s.
#
# It is deliberately NOT on by default: a PCH satisfies includes that a source
# file forgot to make itself, so code written with it enabled can fail to
# compile for everyone else. Leaving it off keeps CI and contributors on the
# strict behaviour, and only developers who opt in trade that for the speed.
option(QET_ENABLE_PCH "Use precompiled headers (developer build speed; may mask missing #includes)" OFF)
# Use translations as a Qt resource
option(QMFILES_AS_RESOURCE "Use .qm files as Qt resource" ON)
+26 -38
View File
@@ -1,4 +1,4 @@
# Copyright 2006 The QElectroTech Team
# Copyright 2006-2026 The QElectroTech Team
# This file is part of QElectroTech.
#
# QElectroTech is free software: you can redistribute it and/or modify
@@ -14,54 +14,42 @@
# You should have received a copy of the GNU General Public License
# along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
message(" - fetch_kdeaddons")
option(BUILD_KF6 "Build KF6 libraries, use system ones otherwise" OFF)
if(BUILD_KF6)
block(PROPAGATE KF6_GIT_TAG)
message(STATUS " - fetch_kdeaddons")
set(KDE_SKIP_TEST_SETTINGS ON)
set(KCOREADDONS_USE_QML OFF)
set(KWIDGETSADDONS_USE_QML OFF)
set(BUILD_TESTING OFF)
set(BUILD_DESIGNERPLUGIN OFF)
set(BUILD_QCH OFF)
set(BUILD_SHARED_LIBS OFF)
if(BUILD_WITH_KF5)
Include(FetchContent)
Include(FetchContent)
option(BUILD_KF5 "Build KF5 libraries, use system ones otherwise" YES)
if(BUILD_KF5)
if(NOT DEFINED KF5_GIT_TAG)
#https://qelectrotech.org/forum/viewtopic.php?pid=13924#p13924
set(KF5_GIT_TAG v5.77.0)
if(NOT DEFINED KF6_GIT_TAG)
set(KF6_GIT_TAG v6.22.0)
endif()
# Fix stop the run autotests of kcoreaddons
# see
# https://invent.kde.org/frameworks/kcoreaddons/-/blob/master/CMakeLists.txt#L98
# issue:
# CMake Error at /usr/share/ECM/modules/ECMAddTests.cmake:89 (add_executable):
# Cannot find source file:
# see
# https://qelectrotech.org/forum/viewtopic.php?pid=13929#p13929
set(KDE_SKIP_TEST_SETTINGS "TRUE")
set(BUILD_TESTING "0")
FetchContent_Declare(
ecm
GIT_REPOSITORY https://invent.kde.org/frameworks/extra-cmake-modules.git
GIT_TAG ${KF5_GIT_TAG})
FetchContent_MakeAvailable(ecm)
FetchContent_Declare(
kcoreaddons
GIT_REPOSITORY https://invent.kde.org/frameworks/kcoreaddons.git
GIT_TAG ${KF5_GIT_TAG})
GIT_TAG ${KF6_GIT_TAG})
FetchContent_MakeAvailable(kcoreaddons)
FetchContent_Declare(
kwidgetsaddons
GIT_REPOSITORY https://invent.kde.org/frameworks/kwidgetsaddons.git
GIT_TAG ${KF5_GIT_TAG})
GIT_TAG ${KF6_GIT_TAG})
FetchContent_MakeAvailable(kwidgetsaddons)
else()
find_package(KF5CoreAddons REQUIRED)
find_package(KF5WidgetsAddons REQUIRED)
endif()
set(KF5_PRIVATE_LIBRARIES
KF5::WidgetsAddons
KF5::CoreAddons
)
endblock()
else()
find_package(KF6CoreAddons REQUIRED)
find_package(KF6WidgetsAddons REQUIRED)
endif()
set(KF6_PRIVATE_LIBRARIES
KF6::CoreAddons
KF6::WidgetsAddons
)
+4 -8
View File
@@ -1,4 +1,4 @@
# Copyright 2006 The QElectroTech Team
# Copyright 2006-2026 The QElectroTech Team
# This file is part of QElectroTech.
#
# QElectroTech is free software: you can redistribute it and/or modify
@@ -14,14 +14,10 @@
# You should have received a copy of the GNU General Public License
# along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
message(" - fetch_pugixml")
Include(FetchContent)
option(BUILD_PUGIXML "Build pugixml library, use system one otherwise" YES)
option(BUILD_PUGIXML "Build pugixml library, use system one otherwise" OFF)
if(BUILD_PUGIXML)
Include(FetchContent)
message(" - fetch pugixml")
FetchContent_Declare(
pugixml
GIT_REPOSITORY https://github.com/zeux/pugixml.git
+2 -5
View File
@@ -1,4 +1,4 @@
# Copyright 2006 The QElectroTech Team
# Copyright 2006-2026 The QElectroTech Team
# This file is part of QElectroTech.
#
# QElectroTech is free software: you can redistribute it and/or modify
@@ -16,9 +16,6 @@
message(" - fetch_singleapplication")
# https://github.com/itay-grudev/SingleApplication/issues/18
#qmake
#DEFINES += QAPPLICATION_CLASS=QGuiApplication
set(QAPPLICATION_CLASS QApplication)
Include(FetchContent)
@@ -26,6 +23,6 @@ Include(FetchContent)
FetchContent_Declare(
SingleApplication
GIT_REPOSITORY https://github.com/itay-grudev/SingleApplication.git
GIT_TAG v3.2.0)
GIT_TAG v3.5.4)
FetchContent_MakeAvailable(SingleApplication)
-25
View File
@@ -1,25 +0,0 @@
# Copyright 2006 The QElectroTech Team
# This file is part of QElectroTech.
#
# QElectroTech is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# QElectroTech is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
if(${CMAKE_VERSION} VERSION_LESS 3.14)
message(
"_____________________________________________________________________")
message("to update Cmake on linux:")
message("https://github.com/Kitware/CMake/")
message("linux => cmake-3.19.1-Linux-x86_64.sh")
message(" sudo ./cmake.sh --prefix=/usr/local/ --exclude-subdir")
message("windows good luck :)")
endif()
+13 -44
View File
@@ -24,6 +24,8 @@ message(" - qet_compilation_vars")
# QT_VERSION_MAJOR, after the main find_package.
# (Needed for QPdfEngine::drawHyperlink, the PDF internal links.)
set(QET_COMPONENTS
Core
Gui
LinguistTools
PrintSupport
Xml
@@ -116,16 +118,6 @@ set(QET_RES_FILES
set(QET_SRC_FILES
${QET_DIR}/sources/cli_export.cpp
${QET_DIR}/sources/cli_export.h
${QET_DIR}/sources/logging/crashhandler.cpp
${QET_DIR}/sources/logging/crashhandler.h
${QET_DIR}/sources/logging/eventloopwatchdog.cpp
${QET_DIR}/sources/logging/eventloopwatchdog.h
${QET_DIR}/sources/logging/logring.cpp
${QET_DIR}/sources/logging/logring.h
${QET_DIR}/sources/logging/qetlogger.cpp
${QET_DIR}/sources/logging/qetlogger.h
${QET_DIR}/sources/logging/ui/diagnosticsreportdialog.cpp
${QET_DIR}/sources/logging/ui/diagnosticsreportdialog.h
${QET_DIR}/sources/pdf_links.cpp
${QET_DIR}/sources/pdf_links.h
${QET_DIR}/sources/import/edz/edzarchive.cpp
@@ -160,6 +152,12 @@ set(QET_SRC_FILES
${QET_DIR}/sources/borderproperties.h
${QET_DIR}/sources/bordertitleblock.cpp
${QET_DIR}/sources/bordertitleblock.h
# ${QET_DIR}/sources/colorbutton.cpp
# ${QET_DIR}/sources/colorbutton.h
# ${QET_DIR}/sources/colorcombobox.cpp
# ${QET_DIR}/sources/colorcombobox.h
# ${QET_DIR}/sources/colorcomboboxdelegate.cpp
# ${QET_DIR}/sources/colorcomboboxdelegate.h
${QET_DIR}/sources/conductorautonumerotation.cpp
${QET_DIR}/sources/conductorautonumerotation.h
${QET_DIR}/sources/conductornumexport.cpp
@@ -258,8 +256,6 @@ set(QET_SRC_FILES
${QET_DIR}/sources/qtextorientationwidget.h
${QET_DIR}/sources/recentfiles.cpp
${QET_DIR}/sources/recentfiles.h
${QET_DIR}/sources/shortcutmanager.cpp
${QET_DIR}/sources/shortcutmanager.h
${QET_DIR}/sources/titleblockcell.cpp
${QET_DIR}/sources/titleblockcell.h
${QET_DIR}/sources/titleblockproperties.cpp
@@ -474,10 +470,6 @@ set(QET_SRC_FILES
${QET_DIR}/sources/PropertiesEditor/propertieseditorwidget.cpp
${QET_DIR}/sources/PropertiesEditor/propertieseditorwidget.h
${QET_DIR}/pugixml/src/pugiconfig.hpp
${QET_DIR}/pugixml/src/pugixml.cpp
${QET_DIR}/pugixml/src/pugixml.hpp
${QET_DIR}/sources/qetgraphicsitem/conductor.cpp
${QET_DIR}/sources/qetgraphicsitem/conductor.h
${QET_DIR}/sources/qetgraphicsitem/conductortextitem.cpp
@@ -540,6 +532,7 @@ set(QET_SRC_FILES
${QET_DIR}/sources/richtext/richtexteditor.cpp
${QET_DIR}/sources/richtext/richtexteditor_p.h
${QET_DIR}/sources/richtext/ui_addlinkdialog.h
${QET_DIR}/sources/SearchAndReplace/searchandreplaceworker.cpp
${QET_DIR}/sources/SearchAndReplace/searchandreplaceworker.h
@@ -557,6 +550,9 @@ set(QET_SRC_FILES
${QET_DIR}/sources/svg/qetsvg.cpp
${QET_DIR}/sources/svg/qetsvg.h
${QET_DIR}/sources/svg/qetsvg.cpp
${QET_DIR}/sources/svg/qetsvg.h
${QET_DIR}/sources/titleblock/dimension.cpp
${QET_DIR}/sources/titleblock/dimension.h
${QET_DIR}/sources/titleblock/dimensionwidget.cpp
@@ -692,8 +688,6 @@ set(QET_SRC_FILES
${QET_DIR}/sources/ui/dynamicelementtextitemeditor.h
${QET_DIR}/sources/ui/dynamicelementtextmodel.cpp
${QET_DIR}/sources/ui/dynamicelementtextmodel.h
${QET_DIR}/sources/ui/customelementinfopartwidget.cpp
${QET_DIR}/sources/ui/customelementinfopartwidget.h
${QET_DIR}/sources/ui/elementinfopartwidget.cpp
${QET_DIR}/sources/ui/elementinfopartwidget.h
${QET_DIR}/sources/ui/elementinfowidget.cpp
@@ -710,8 +704,6 @@ set(QET_SRC_FILES
${QET_DIR}/sources/ui/importelementdialog.h
${QET_DIR}/sources/ui/importelementtextpatterndialog.cpp
${QET_DIR}/sources/ui/importelementtextpatterndialog.h
${QET_DIR}/sources/ui/jumptoelementdialog.cpp
${QET_DIR}/sources/ui/jumptoelementdialog.h
${QET_DIR}/sources/ui/inditextpropertieswidget.cpp
${QET_DIR}/sources/ui/inditextpropertieswidget.h
${QET_DIR}/sources/ui/linksingleelementwidget.cpp
@@ -747,13 +739,9 @@ set(QET_SRC_FILES
${QET_DIR}/sources/ui/configpage/projectconfigpages.h
${QET_DIR}/sources/ui/configpage/guidespropertieswidget.cpp
${QET_DIR}/sources/ui/configpage/guidespropertieswidget.h
${QET_DIR}/sources/ui/configpage/shortcutsconfigpage.cpp
${QET_DIR}/sources/ui/configpage/shortcutsconfigpage.h
${QET_DIR}/sources/undocommand/addelementtextcommand.cpp
${QET_DIR}/sources/undocommand/addelementtextcommand.h
${QET_DIR}/sources/undocommand/adddiagramcommand.cpp
${QET_DIR}/sources/undocommand/adddiagramcommand.h
${QET_DIR}/sources/undocommand/addgraphicsobjectcommand.cpp
${QET_DIR}/sources/undocommand/addgraphicsobjectcommand.h
${QET_DIR}/sources/undocommand/changeelementdatacommand.cpp
@@ -768,12 +756,6 @@ set(QET_SRC_FILES
${QET_DIR}/sources/undocommand/itemmodelcommand.h
${QET_DIR}/sources/undocommand/linkelementcommand.cpp
${QET_DIR}/sources/undocommand/linkelementcommand.h
${QET_DIR}/sources/undocommand/movediagramcommand.cpp
${QET_DIR}/sources/undocommand/movediagramcommand.h
${QET_DIR}/sources/undocommand/removediagramcommand.cpp
${QET_DIR}/sources/undocommand/removediagramcommand.h
${QET_DIR}/sources/undocommand/setautonumcontextcommand.cpp
${QET_DIR}/sources/undocommand/setautonumcontextcommand.h
${QET_DIR}/sources/undocommand/rotateselectioncommand.cpp
${QET_DIR}/sources/undocommand/rotateselectioncommand.h
${QET_DIR}/sources/undocommand/rotatetextscommand.cpp
@@ -796,17 +778,6 @@ set(QET_SRC_FILES
${QET_DIR}/sources/xml/terminalstriplayoutpatternxml.h
)
if(NOT BUILD_WITH_KF5)
list(APPEND QET_SRC_FILES
${QET_DIR}/sources/ui/nokde/kautosavefile.cpp
${QET_DIR}/sources/ui/nokde/kautosavefile.h
${QET_DIR}/sources/ui/nokde/kcolorbutton.cpp
${QET_DIR}/sources/ui/nokde/kcolorbutton.h
${QET_DIR}/sources/ui/nokde/kcolorcombo.cpp
${QET_DIR}/sources/ui/nokde/kcolorcombo.h
)
endif()
set(TS_FILES
${QET_DIR}/lang/qet_ar.ts
${QET_DIR}/lang/qet_ca.ts
@@ -825,19 +796,17 @@ set(TS_FILES
${QET_DIR}/lang/qet_mn.ts
${QET_DIR}/lang/qet_nb.ts
${QET_DIR}/lang/qet_nl.ts
${QET_DIR}/lang/qet_nl_BE.ts
${QET_DIR}/lang/qet_nl_BE.ts
${QET_DIR}/lang/qet_no.ts
${QET_DIR}/lang/qet_pl.ts
${QET_DIR}/lang/qet_pt.ts
${QET_DIR}/lang/qet_pt_BR.ts
${QET_DIR}/lang/qet_ro.ts
${QET_DIR}/lang/qet_rs.ts
${QET_DIR}/lang/qet_ru.ts
${QET_DIR}/lang/qet_sk.ts
${QET_DIR}/lang/qet_sl.ts
${QET_DIR}/lang/qet_sr.ts
${QET_DIR}/lang/qet_sv.ts
${QET_DIR}/lang/qet_tr.ts
${QET_DIR}/lang/qet_uk.ts
${QET_DIR}/lang/qet_zh.ts
)
BIN
View File
Binary file not shown.
+864 -1318
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+864 -1310
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+864 -1312
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+864 -1310
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+861 -1308
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+864 -1310
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+855 -1303
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+864 -1310
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+862 -1308
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+863 -1311
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+859 -1303
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+864 -1310
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+862 -1306
View File
File diff suppressed because it is too large Load Diff
+867 -1311
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+853 -1299
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+859 -1305
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+864 -1310
View File
File diff suppressed because it is too large Load Diff
+862 -1308
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+864 -1312
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+867 -1313
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+860 -1306
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+864 -1312
View File
File diff suppressed because it is too large Load Diff
+862 -1310
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+864 -1312
View File
File diff suppressed because it is too large Load Diff
+862 -1310
View File
File diff suppressed because it is too large Load Diff
+862 -1312
View File
File diff suppressed because it is too large Load Diff
+862 -1310
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+862 -1308
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+863 -1307
View File
File diff suppressed because it is too large Load Diff
+859 -1307
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+860 -1304
View File
File diff suppressed because it is too large Load Diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

+101
View File
@@ -0,0 +1,101 @@
Compiler QElectroTech sous microsoft Windows 10 et 11 avec MSYS2
================================
Ce document décrit les étapes nécessaire afin de compilé QElectroTech sous Windows avec Qt6 et cmake en utilisant MSYS2.
# MSYS2
L'ensemble des outils nécessaire au développement et à la compilation de QElectroTech sous Windows sera installé par lintermédiaire de [MSYS2](https://www.msys2.org/). Cela comprend entre autre le framework [Qt6](https://www.qt.io/development/qt-framework/qt6), les outils cmake, les dépendances ([kde framework](https://develop.kde.org/docs/), [sqlite](https://sqlite.org/), [pugixml](https://pugixml.org/)), les outils de compilation [minGW](https://www.mingw-w64.org/)...
>Il sera nécessaire d'utiliser [winget](https://learn.microsoft.com/fr-fr/windows/package-manager/winget/), celui-ci est présent par défaut sous Windows 11, dans le cas de Windows 10, winget peut necessité d'être activé manuellement
# Installer GIT et MSYS2 avec winget
Avec power shell.
```
winget install Git.Git
```
puis
```
winget install MSYS2.MSYS2
```
## Mise à jour de MSYS2
Lors de la première utilisation de MSYS2 il est nécessaire de mettre celui-ci à jour.
Lancer "MSYS2 MSYS" depuis le menu démarré de Windows.
Une fenêtre avec un shell s'ouvre, dans celui-ci lancer la commande :
```
pacman -Syu
```
A la fin de la mise à jour MSYS2 MSYS se fermera automatiquement. Ouvrez le à nouveau et relancé la commande
```
pacman -Syu
```
## Installation des outils de devellopement
Toujours dans le shell MSYS2 MSYS lancer la commande suivante.
```
pacman -S mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-cmake mingw-w64-ucrt-x86_64-qt6-svg mingw-w64-ucrt-x86_64-qt6-base mingw-w64-ucrt-x86_64-sqlite3 mingw-w64-ucrt-x86_64-pugixml mingw-w64-ucrt-x86_64-kcoreaddons mingw-w64-ucrt-x86_64-kwidgetsaddons mingw-w64-ucrt-x86_64-extra-cmake-modules mingw-w64-ucrt-x86_64-gdb mingw-w64-ucrt-x86_64-qt6-translations mingw-w64-ucrt-x86_64-qt6-tools
```
> La quantité de paquets à installer est conséquent, en fonction de votre connexion internet cela peut prendre plusieurs dizaine de minute
L'ensemble des outils est mantenant installé 😀
# Installer Qt creator
Télécharger [l'installateur online de Qt](https://www.qt.io/development/download-qt-installer-oss) et lancer l'installation en suivant les indications de ce dernier.
>Dans le cas où vous comptez utilisé Qt Creator uniquement pour développez QElectroTech, lors de l'installation choisissez l'option "installation personnalisée" puis dans la page suivante sélectionné uniquement Qt Creator.
## Configurer Qt creator
Ouvrir Qt creator puis rendez vous dans "édition -> préférence -> kit"
### Versions de Qt
- Cliquer sur _ajouter_
- Renseigner _Chemin de qmake_ (exemple C:\\msys64\\ucrt64\\bin\\qmake.exe).
- Dans le champ _Nom :_ ajouter (msys2).
![](assets/windows_msys2_setup/qt_version.png)
### Compilateurs
- Cliquer sur _ajouter_ puis choisir _MinGW_.
- Renseigner _Emplacement du compilateur C_ (exemple C:\\msys64\\ucrt64\\bin\\g++.exe).
- Dans le champ _Nom :_ ajouter (msys2).
![](assets/windows_msys2_setup/compiler.png)
### Débogueurs
- Cliquer sur _ajouter_
- Renseigner _Chemin :_ (exemple C:\\msys64\\ucrt64\\bin\\gdb.exe).
- Dans le champ _Nom :_ ajouter (msys2).
![](assets/windows_msys2_setup/debugger.png)
### cmake
- Outils -> _Ajouter_
- Renseigner _Chemin :_ (exemple C:\\msys64\\ucrt64\\bin\\cmake.exe).
- Dans le champ _Nom :_ ajouter (msys2).
![](assets/windows_msys2_setup/cmake.png)
### KIT
Maintenant que tous les prérequis sont fait nous allons crée un kit utilisant les outils fournis par MSYS2. Cliquer sur _Ajouter_, un nouveau kit _manuel_ apparaît, nommer celui-ci par exemple _Qt6 msys2_ puis renseigner le compilateur, le débogueur, la version de Qt et Outils CMake en choisissant à chaque fois ceux que nous venons de créer.
puis cliquer sur _appliquer_.
![](assets/windows_msys2_setup/kit.png)
Bravo 🥳🥳 vous avez terminé l'installation de la totalité des outils de développement.
# Clonez le dépôts de QElectrotech
Clonez le dépôt de QElectroTech comme vous le faite habituellement, sinon utilisez les commandes suivante dans power shell.
Crée et/ou se rendre dans le dossier dans lequel vous voulez clonez le dépôt (dans l'exemple nous allons crée un dossier QElectroTech dans C:)
```
mkdir C:\QElectroTech
cd C:\QElectroTech
git clone --recursive https://github.com/qelectrotech/qelectrotech-source-mirror.git
```
Une fois le dépôt cloné lancer Qt creator puis choisir d'ouvrir un projet existant, en choisissant le _CMakeLists.txt_ se trouvant à la racine du projet QElectroTech, enfin dans l'assistant de création de projet choisir comme kit le kit que nous avons créer précédemment.
+13
View File
@@ -0,0 +1,13 @@
Compiler QElectroTech sous microsoft Windows 10 et 11
================================
Compiler QElectroTech pour et/ou sous Windows peut être effectué avec plusieurs méthode différente.
Ce document énumère uniquement les différentes méthode possible
N'est mentionné que les étapes nécessaire afin de compilé QElectroTech sous Windows avec Qt6 et cmake. Ce document ne traite pas la compilation avec Qt5 et qmake.
>QElectroTech 0.100 est la dernière version à utiliser Qt5. Les version suivante sont développé avec Qt6 et utilise cmake au lieu de qmake.
Il existe deux méthodes pour cela :
1. [Utiliser msys2 (méthode recommandé)](fr_window_build_msys2.md)
2. Télécharger et compiler l'ensemble des dépendances (non rédigé)
Submodule pugixml deleted from 27b68329de
+2 -7
View File
@@ -173,9 +173,7 @@ HEADERS += $$files(sources/*.h) \
$$files(sources/qet_elementscaler/*.h) \
$$files(sources/svg/*.h) \
$$files(sources/import/edz/*.h) \
$$files(sources/import/edz/lzma/*.h) \
$$files(sources/logging/*.h) \
$$files(sources/logging/ui/*.h)
$$files(sources/import/edz/lzma/*.h)
SOURCES += $$files(sources/*.cpp) \
$$files(sources/editor/*.cpp) \
@@ -221,10 +219,7 @@ SOURCES += $$files(sources/*.cpp) \
$$files(sources/qet_elementscaler/*.cpp) \
$$files(sources/svg/*.cpp) \
$$files(sources/import/edz/*.cpp) \
$$files(sources/import/edz/lzma/*.c) \
$$files(sources/logging/*.cpp) \
$$files(sources/logging/ui/*.cpp)
$$files(sources/import/edz/lzma/*.c)
# Needed for use promote QTreeWidget in terminalstripeditor.ui
INCLUDEPATH += sources/TerminalStrip/ui
@@ -25,9 +25,8 @@
#include "xmlelementcollection.h"
#include "xmlprojectelementcollectionitem.h"
#include <QFutureWatcher>
#include <QtConcurrentMap>
/**
@brief ElementsCollectionModel::ElementsCollectionModel
Constructor
@@ -290,9 +289,12 @@ void ElementsCollectionModel::loadCollections(bool common_collection,
connect(watcher, &QFutureWatcher<void>::progressRangeChanged,
this, &ElementsCollectionModel::loadingProgressRangeChanged);
connect(watcher, &QFutureWatcher<void>::finished,
this, &ElementsCollectionModel::loadingFinished);
connect(watcher, &QFutureWatcher<void>::finished, watcher, &QFutureWatcher<void>::deleteLater);
this, &ElementsCollectionModel::loadingFinished);
connect(
watcher,
&QFutureWatcher<void>::finished,
watcher,
&QFutureWatcher<void>::deleteLater);
m_future = QtConcurrent::map(m_items_list_to_setUp, setUpData);
watcher->setFuture(m_future);
@@ -949,14 +949,8 @@ void ElementsCollectionWidget::search()
}
hideCollection(true);
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
const QStringList text_list = text.split("+", QString::SkipEmptyParts);
#else
#if TODO_LIST
#pragma message("@TODO remove code for QT 5.14 or later")
#endif
const QStringList text_list = text.split("+", Qt::SkipEmptyParts);
#endif
QModelIndexList match_index;
for (QString txt : text_list) {
match_index << m_model->match(m_showed_index.isValid()
@@ -806,13 +806,13 @@ bool ElementsLocation::setXml(const QDomDocument &xml_document) const
QRegularExpression rx("^(.*)/(.*\\.elmt)$");
QRegularExpressionMatch match = rx.match(path_);
if (match.hasMatch())
if (auto regex_match = rx.match(path_); regex_match.hasMatch())
{
return project()
->embeddedElementCollection()
->addElementDefinition(
match.captured(1),
match.captured(2),
regex_match.captured(1),
regex_match.captured(2),
xml_document.documentElement());
}
else
@@ -20,7 +20,7 @@
#include "../NameList/nameslist.h"
#include "../diagramcontext.h"
#include "pugixml/src/pugixml.hpp"
#include "pugixml.hpp"
#include <QIcon>
#include <QString>
@@ -43,14 +43,6 @@ ElementsTreeView::ElementsTreeView(QWidget *parent) :
{
// force du noir sur une alternance de blanc (comme le schema) et de gris
// clair, avec du blanc sur bleu pas trop fonce pour la selection
//
// Element icons are rendered with colors read directly from each .elmt
// file (almost always black linework, matching printed-schematic
// convention) onto a transparent background -- so this view must keep
// a light background regardless of the OS/desktop theme, or the icons
// become invisible on dark themes. QAbstractItemView paints its rows
// using the viewport's palette, not the view's own, so the palette
// must be applied to both to actually take effect under every style.
QPalette qp = palette();
qp.setColor(QPalette::Text, Qt::black);
qp.setColor(QPalette::Base, Qt::white);
@@ -58,7 +50,6 @@ ElementsTreeView::ElementsTreeView(QWidget *parent) :
qp.setColor(QPalette::Highlight, QColor("#678db2"));
qp.setColor(QPalette::HighlightedText, Qt::black);
setPalette(qp);
viewport()->setPalette(qp);
}
/**
@@ -96,11 +87,7 @@ void ElementsTreeView::startElementDrag(const ElementsLocation &location)
{
if (! location.exist()) return;
#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0)
QDrag* drag = new QDrag(this);
#else
QScopedPointer<QDrag> drag(new QDrag(this));
#endif
auto drag = new QDrag{this};
QString location_str = location.toString();
QMimeData *mime_data = new QMimeData();
@@ -22,39 +22,7 @@
#include "../qeticons.h"
#include "elementslocation.h"
#include <QApplication>
#include <QDir>
#include <QPainter>
#include <QPixmap>
#include <QStyle>
namespace {
/**
@return the folder icon overlaid with a small warning badge in the
bottom-right corner. Used for a directory whose qet_directory could
not be read (@see FileElementCollectionItem::m_qet_directory_unreadable),
so the problem is visible in the tree itself and not only on hover
via the tooltip. Built once: same folder icon, same badge, every time.
*/
const QIcon &unreadableFolderIcon()
{
static const QIcon icon = []() {
QPixmap pixmap = QET::Icons::Folder.pixmap(16, 16);
const QPixmap badge = QApplication::style()
->standardIcon(QStyle::SP_MessageBoxWarning)
.pixmap(9, 9);
QPainter painter(&pixmap);
painter.drawPixmap(pixmap.width() - badge.width(),
pixmap.height() - badge.height(),
badge);
painter.end();
return QIcon(pixmap);
}();
return icon;
}
}
/**
@brief FileElementCollectionItem::FileElementCollectionItem
@@ -168,41 +136,18 @@ QString FileElementCollectionItem::localName()
}
else
{
// Fall back to the raw directory name (m_path) whenever the
// translated name can't be obtained -- qet_directory missing,
// unreadable (e.g. a Windows path-encoding issue with special
// characters, see bugtracker #332), malformed, or present but
// without a usable name entry -- rather than leaving the item
// blank.
QString display_name;
bool readable = false;
QString str(fileSystemPath() % "/qet_directory");
pugi::xml_document docu;
if (docu.load_file(str.toStdWString().c_str()))
if(docu.load_file(str.toStdWString().c_str()))
{
if (QString(docu.document_element().name())
== "qet-directory")
{
readable = true;
NamesList nl;
nl.fromXml(docu.document_element());
// Deliberately no fallback argument: a non-empty one
// is returned *before* NamesList::name() reaches its
// "first available translation" step, so passing
// m_path here would replace a perfectly good name in
// some other language with the raw directory name.
// The fallback belongs after the chain, not inside it.
display_name = nl.name();
setText(nl.name());
}
}
setText(display_name.isEmpty() ? m_path : display_name);
// Only a file-level failure counts: a readable qet-directory
// with no entry for the current language is not an error,
// NamesList::name() resolves that on its own. Recorded here
// and reported by setUpData(), which sets the tooltip after
// this runs.
m_qet_directory_unreadable = !readable;
}
}
else if (isElement()) {
@@ -405,21 +350,7 @@ void FileElementCollectionItem::setUpData()
}
}
// Falling back to the raw directory name keeps the folder usable, but
// on its own it hides the fact that a file is broken: the user sees a
// plausible name and never learns there is anything to repair. Say so
// above the collection path, which stays as the last line the way the
// element tooltip above builds it.
QStringList tip;
if (isDir() && m_qet_directory_unreadable)
{
tip << QObject::tr("Le fichier « %1 » est absent ou illisible : "
"le nom traduit de ce dossier n'a pas pu être lu, "
"son nom de dossier est affiché à la place.")
.arg(fileSystemPath() % "/qet_directory");
}
tip << collectionPath();
setToolTip(tip.join(QLatin1Char('\n')));
setToolTip(collectionPath());
}
/**
@@ -430,19 +361,6 @@ void FileElementCollectionItem::setUpData()
*/
void FileElementCollectionItem::setUpIcon()
{
// Must return unconditionally once an icon is set: setIcon() calls
// setData(), which emits dataChanged() regardless of whether the new
// icon differs from the old one (QIcon has no meaningful equality).
// QTreeView responds to dataChanged() by recomputing the row's size
// hint, which re-enters data() for this same index -- so without this
// guard, any repeated setIcon() here recurses until the stack
// overflows. Confirmed by crash report on PR #633.
//
// This item's m_qet_directory_unreadable is already final by the time
// this can run at all: ElementsCollectionModel only attaches itself
// to the tree view (making data() reachable) from loadingFinished(),
// which fires after the QtConcurrent::map over every item -- this one
// included -- has completed. So there is no race to work around here.
if (!icon().isNull())
return;
@@ -462,11 +380,10 @@ void FileElementCollectionItem::setUpIcon()
else
{
if (isDir()) {
setIcon(m_qet_directory_unreadable ? unreadableFolderIcon()
: QET::Icons::Folder);
setIcon(QET::Icons::Folder);
} else {
if (m_path.endsWith(".qetmak")) {
setIcon(QIcon());
setIcon(QET::Icons::PartRectangle);
} else {
ElementsLocation loc(collectionPath());
setIcon(loc.icon());
@@ -64,11 +64,6 @@ class FileElementCollectionItem : public ElementCollectionItem
private:
QString m_path;
/// True when this directory's qet_directory file is missing or
/// unreadable, so setUpData() can say so in the tooltip. Recorded
/// rather than acted on in localName(), because setUpData() resets
/// the tooltip afterwards and would otherwise discard it.
bool m_qet_directory_unreadable = false;
};
#endif // FILEELEMENTCOLLECTIONITEM2_H
+1 -1
View File
@@ -17,7 +17,7 @@
*/
#ifndef NAMES_LIST_H
#define NAMES_LIST_H
#include "pugixml/src/pugixml.hpp"
#include "pugixml.hpp"
#include <QtXml>
/**
+1 -6
View File
@@ -130,12 +130,7 @@ bool PhysicalTerminal::setLevelOf(const QSharedPointer<RealTerminal> &terminal,
const int i = m_real_terminal.indexOf(terminal);
if (i >= 0)
{
#if QT_VERSION >= QT_VERSION_CHECK(5,14,0)
m_real_terminal.swapItemsAt(i, std::min<int>(level, static_cast<int>(m_real_terminal.size())-1));
#else
auto j = std::min(level, m_real_terminal.size()-1);
std::swap(m_real_terminal.begin()[i], m_real_terminal.begin()[j]);
#endif
m_real_terminal.swapItemsAt(i, std::min(static_cast<qsizetype>(level), m_real_terminal.size()-1));
return true;
}
return false;
+1 -4
View File
@@ -64,11 +64,8 @@ bool TerminalStripData::fromXml(const QDomElement &xml_element)
"due to wrong tag name. Expected " << this->xmlTagName() << " used " << xml_element.tagName();
return false;
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
m_uuid = QUuid::fromString(xml_element.attribute(QStringLiteral("uuid")));
#else
m_uuid = QUuid(xml_element.attribute(QStringLiteral("uuid")));
#endif
for (auto &xml_info :
QETXML::findInDomElement(xml_element.firstChildElement(QStringLiteral("informations")),
@@ -35,11 +35,7 @@ TerminalStripTreeDockWidget::TerminalStripTreeDockWidget(QETProject *project, QW
ui->setupUi(this);
setProject(project);
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
ui->m_tree_view->expandRecursively(ui->m_tree_view->rootIndex());
#else
ui->m_tree_view->expandAll();
#endif
}
TerminalStripTreeDockWidget::~TerminalStripTreeDockWidget()
@@ -93,11 +89,7 @@ void TerminalStripTreeDockWidget::reload()
buildTree();
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
ui->m_tree_view->expandRecursively(ui->m_tree_view->rootIndex());
#else
ui->m_tree_view->expandAll();
#endif
//Reselect the tree widget item of the current edited strip
auto item = m_item_strip_H.key(current_);
+7 -79
View File
@@ -39,13 +39,11 @@ namespace autonum
sequentialNumbers::sequentialNumbers(const sequentialNumbers &other)
{
unit = other.unit;
wrap = other.wrap;
unit_folio = other.unit_folio;
ten = other.ten;
ten_folio = other.ten_folio;
hundred = other.hundred;
hundred_folio = other.hundred_folio;
alpha = other.alpha;
}
sequentialNumbers::~sequentialNumbers()
@@ -58,13 +56,11 @@ namespace autonum
return (*this);
unit = other.unit;
wrap = other.wrap;
unit_folio = other.unit_folio;
ten = other.ten;
ten_folio = other.ten_folio;
hundred = other.hundred;
hundred_folio = other.hundred_folio;
alpha = other.alpha;
return (*this);
}
@@ -72,13 +68,11 @@ namespace autonum
bool sequentialNumbers::operator==(const sequentialNumbers &other) const
{
if (unit == other.unit && \
wrap == other.wrap && \
unit_folio == other.unit_folio && \
ten == other.ten && \
ten_folio == other.ten_folio && \
hundred == other.hundred && \
hundred_folio == other.hundred_folio && \
alpha == other.alpha)
hundred_folio == other.hundred_folio)
return true;
else
return false;
@@ -110,11 +104,6 @@ namespace autonum
document,
"unit",
unit.join(";")));
if (!wrap.isEmpty())
element.appendChild(QETXML::textToDomElement(
document,
"wrap",
wrap.join(";")));
if (!unit_folio.isEmpty())
element.appendChild(QETXML::textToDomElement(
document,
@@ -140,11 +129,6 @@ namespace autonum
document,
"hundredFolio",
hundred_folio.join(";")));
if(!alpha.isEmpty())
element.appendChild(QETXML::textToDomElement(
document,
"alpha",
alpha.join(";")));
return element;
}
@@ -164,11 +148,6 @@ namespace autonum
from = element.firstChildElement("unit");
unit = from.text().split(";");
//Absent from files written before cyclic parts could be
//rendered; an empty list is the correct reading of that.
from = element.firstChildElement("wrap");
wrap = from.text().split(";");
from = element.firstChildElement("unitFolio");
unit_folio = from.text().split(";");
@@ -183,22 +162,17 @@ namespace autonum
from = element.firstChildElement("hundredFolio");
hundred_folio = from.text().split(";");
from = element.firstChildElement("alpha");
alpha = from.text().split(";");
}
//Clear this sequence
void sequentialNumbers::clear()
{
unit.clear();
wrap.clear();
unit_folio.clear();
ten.clear();
ten_folio.clear();
hundred.clear();
hundred_folio.clear();
alpha.clear();
}
/**
@@ -306,11 +280,6 @@ namespace autonum
str.replace("%{plc_function}", dc.value("plc_function").toString());
str.replace("%{plc_comment}", dc.value("plc_comment").toString());
str.replace("%{plc_crossref}", dc.value("plc_crossref").toString());
str.replace("%{plc_tc}", dc.value("plc_tc").toString());
str.replace("%{plc_t1}", dc.value("plc_t1").toString());
str.replace("%{plc_t2}", dc.value("plc_t2").toString());
str.replace("%{plc_t3}", dc.value("plc_t3").toString());
str.replace("%{plc_t4}", dc.value("plc_t4").toString());
return str;
}
@@ -445,11 +414,8 @@ namespace autonum
m_seq_struct.ten_folio.size()),
qMax(m_seq_struct.hundred_folio.size(),
m_seq_struct.unit.size())),
qMax(
qMax(m_seq_struct.hundred.size(),
m_seq_struct.ten.size()),
qMax(m_seq_struct.alpha.size(),
m_seq_struct.wrap.size()))
qMax(m_seq_struct.hundred.size(),
m_seq_struct.ten.size())
);
for (int i=1; i<=max ; i++)
@@ -457,9 +423,6 @@ namespace autonum
if (m_assigned_label.contains("%sequ_" + QString::number(i)) && m_seq_struct.unit.size() >= i) {
m_assigned_label.replace("%sequ_" + QString::number(i),m_seq_struct.unit.at(i-1));
}
if (m_assigned_label.contains("%seqw_" + QString::number(i)) && m_seq_struct.wrap.size() >= i) {
m_assigned_label.replace("%seqw_" + QString::number(i),m_seq_struct.wrap.at(i-1));
}
if (m_assigned_label.contains("%seqt_" + QString::number(i)) && m_seq_struct.ten.size() >= i) {
m_assigned_label.replace("%seqt_" + QString::number(i),m_seq_struct.ten.at(i-1));
}
@@ -475,9 +438,6 @@ namespace autonum
if (m_assigned_label.contains("%seqhf_" + QString::number(i)) && m_seq_struct.hundred_folio.size() >= i) {
m_assigned_label.replace("%seqhf_" + QString::number(i),m_seq_struct.hundred_folio.at(i-1));
}
if (m_assigned_label.contains("%seqa_" + QString::number(i)) && m_seq_struct.alpha.size() >= i) {
m_assigned_label.replace("%seqa_" + QString::number(i),m_seq_struct.alpha.at(i-1));
}
}
}
@@ -497,26 +457,12 @@ namespace autonum
{
if (context.itemAt(i).at(0) == type)
{
const QStringList item = context.itemAt(i);
//A zero-padding mask, spreadsheet style: its length is the
//minimum number of digits. It overrides the width implied
//by the part type, so "Chiffre 01" with a mask of "0000"
//pads to four. An absent mask -- which is every context
//written before the field existed -- falls through to the
//type's own width, so nothing about existing projects
//changes.
const QString mask = NumerotationContext::formatOf(item);
QString number;
if (type == "alpha")
//Alphabetic value, not an integer -- used as-is.
number = item.at(1);
else if (!mask.isEmpty())
number = QString("%1").arg(item.at(1).toInt(), mask.length(), 10, QChar('0'));
else if (type == "ten" || type == "tenfolio")
number = QString("%1").arg(item.at(1).toInt(), 2, 10, QChar('0'));
if (type == "ten" || type == "tenfolio")
number = QString("%1").arg(context.itemAt(i).at(1).toInt(), 2, 10, QChar('0'));
else if (type == "hundred" || type == "hundredfolio")
number = QString("%1").arg(item.at(1).toInt(), 3, 10, QChar('0'));
else number = QString::number(item.at(1).toInt());
number = QString("%1").arg(context.itemAt(i).at(1).toInt(), 3, 10, QChar('0'));
else number = QString::number(context.itemAt(i).at(1).toInt());
list.append(number);
}
}
@@ -582,10 +528,6 @@ namespace autonum
{
autonum::setSequentialToList(seqStruct.unit, context,"unit");
}
if (label.contains("%seqw_"))
{
autonum::setSequentialToList(seqStruct.wrap, context,"wrap");
}
if (label.contains("%sequf_"))
{
autonum::setSequentialToList(seqStruct.unit_folio, context,"unitfolio");
@@ -609,10 +551,6 @@ namespace autonum
autonum::setSequentialToList(seqStruct.hundred_folio, context,"hundredfolio");
autonum::setFolioSequentialToHash(seqStruct.hundred_folio, diagram->m_elmt_hundredfolio_max, hashKey);
}
if (label.contains("%seqa_"))
{
autonum::setSequentialToList(seqStruct.alpha, context,"alpha");
}
}
}
@@ -627,13 +565,11 @@ namespace autonum
QString value;
QString formula;
int count_unit = 0;
int count_wrap = 0;
int count_unitf = 0;
int count_ten = 0;
int count_tenf = 0;
int count_hundred = 0;
int count_hundredf = 0;
int count_alpha = 0;
for(int i=0 ; i<nc.size() ; i++)
{
@@ -670,10 +606,6 @@ namespace autonum
count_unit++;
formula.append("%sequ_" + QString::number(count_unit));
}
else if (type == "wrap") {
count_wrap++;
formula.append("%seqw_" + QString::number(count_wrap));
}
else if (type == "unitfolio") {
count_unitf++;
formula.append("%sequf_" + QString::number(count_unitf));
@@ -694,10 +626,6 @@ namespace autonum
count_hundredf++;
formula.append("%seqhf_" + QString::number(count_hundredf));
}
else if (type == "alpha") {
count_alpha++;
formula.append("%seqa_" + QString::number(count_alpha));
}
}
return formula;
-3
View File
@@ -47,14 +47,11 @@ namespace autonum
void clear();
QStringList unit;
/// Values of the cyclic (modulo) parts, referenced by %seqw_N.
QStringList wrap;
QStringList unit_folio;
QStringList ten;
QStringList ten_folio;
QStringList hundred;
QStringList hundred_folio;
QStringList alpha;
};
/**
+10 -40
View File
@@ -51,19 +51,12 @@ void NumerotationContext::clear ()
@param value the value itself
@param increase the increase number of value
@param initialvalue
@param modulus wrap-and-carry modulus (0 means "not a wrapping part")
@param format zero-padding mask, spreadsheet style: "00" pads to two
digits, "000" to three. Empty keeps the part type's natural width, so
an absent format reproduces exactly the behaviour of every context
written before this field existed.
@return true if value is append
*/
bool NumerotationContext::addValue(const QString &type,
const QVariant &value,
const int increase,
const int initialvalue,
const int modulus,
const QString &format) {
const int initialvalue) {
if (!keyIsAcceptable(type) && !value.canConvert<QString>())
return false;
if (keyIsNumber(type) && !value.canConvert<int>())
@@ -77,11 +70,7 @@ bool NumerotationContext::addValue(const QString &type,
+ "|"
+ QString::number(increase)
+ "|"
+ QString::number(initialvalue)
+ "|"
+ QString::number(modulus)
+ "|"
+ QString(format).remove("|");
+ QString::number(initialvalue);
return true;
}
@@ -136,7 +125,7 @@ QStringList NumerotationContext::itemAt(const int i) const
*/
QString NumerotationContext::validRegExpNum () const
{
return ("unit|unitfolio|ten|tenfolio|hundred|hundredfolio|wrap|alpha|string|idfolio|folio|plant|locmach|elementline|elementcolumn|elementprefix");
return ("unit|unitfolio|ten|tenfolio|hundred|hundredfolio|string|idfolio|folio|plant|locmach|elementline|elementcolumn|elementprefix");
}
/**
@@ -145,7 +134,7 @@ QString NumerotationContext::validRegExpNum () const
*/
QString NumerotationContext::validRegExpNumber() const
{
return ("unit|unitfolio|ten|tenfolio|hundred|hundredfolio|wrap");
return ("unit|unitfolio|ten|tenfolio|hundred|hundredfolio");
}
/**
@@ -183,12 +172,6 @@ QDomElement NumerotationContext::toXml(QDomDocument &d, const QString& str) {
strl.at(0) == ("hundredfolio")) {
part.setAttribute("initialvalue", strl.at(3));
}
if (strl.at(0) == ("wrap") && strl.size() > 4) {
part.setAttribute("modulus", strl.at(4));
}
if (strl.size() > 5 && !strl.at(5).isEmpty()) {
part.setAttribute("format", strl.at(5));
}
num_auto.appendChild(part);
}
return num_auto;
@@ -200,7 +183,7 @@ QDomElement NumerotationContext::toXml(QDomDocument &d, const QString& str) {
*/
void NumerotationContext::fromXml(QDomElement &e) {
clear();
foreach(QDomElement qde, QET::findInDomElement(e, "part")) addValue(qde.attribute("type"), qde.attribute("value"), qde.attribute("increase").toInt(), qde.attribute("initialvalue").toInt(), qde.attribute("modulus").toInt(), qde.attribute("format"));
foreach(QDomElement qde, QET::findInDomElement(e, "part")) addValue(qde.attribute("type"), qde.attribute("value"), qde.attribute("increase").toInt(), qde.attribute("initialvalue").toInt());
}
/**
@@ -210,23 +193,10 @@ void NumerotationContext::fromXml(QDomElement &e) {
@param content to replace current value
*/
void NumerotationContext::replaceValue(int index, QString content) {
QStringList strl = content_[index].split("|");
QString type = strl.at(0);
QString sep = "|";
QString type = content_[index].split("|").at(0);
const QString& value = std::move(content);
QString increase = strl.at(2);
QString initvalue = strl.at(3);
QString modulus = strl.size() > 4 ? strl.at(4) : QStringLiteral("0");
QString format = strl.size() > 5 ? strl.at(5) : QString();
content_[index] = type + "|" + value + "|" + increase + "|" + initvalue + "|" + modulus + "|" + format;
}
/**
@brief NumerotationContext::formatOf
@param item : a context item as returned by itemAt()
@return the part's zero-padding mask, or an empty string when it has
none -- which every context written before the field existed will be.
*/
QString NumerotationContext::formatOf(const QStringList &item)
{
return item.size() > 5 ? item.at(5) : QString();
QString increase = content_[index].split("|").at(2);
QString initvalue = content_[index].split("|").at(3);
content_[index].replace(content_[index], type + "|" + value + "|" + increase + "|" + initvalue);
}
+1 -6
View File
@@ -36,12 +36,7 @@ class NumerotationContext
bool addValue(const QString &,
const QVariant & = QVariant(1),
const int = 1,
const int = 0,
const int = 0,
const QString & = QString());
/// Zero-padding mask of a part, e.g. "00"; empty means the type's
/// own natural width. See addValue().
static QString formatOf(const QStringList &item);
const int = 0);
QString operator[] (const int &) const;
void operator << (const NumerotationContext &);
int size() const;
+3 -260
View File
@@ -48,15 +48,6 @@ NumerotationContext NumerotationContextCommands::next()
QStringList str = context_.itemAt(i);
setNumStrategy(str.at(0));
contextnum << strategy_ -> next(context_, i);
//Wrap-and-carry: str still holds the pre-increment value, so
//this checks the same condition WrapNum::next() used to decide
//whether to wrap its own value back to 0.
if (str.at(0) == "wrap" && str.size() > 4) {
int modulus = str.at(4).toInt();
if (modulus > 0 && (str.at(1).toInt() + str.at(2).toInt()) >= modulus)
carry(contextnum, i - 1);
}
}
return contextnum;
}
@@ -73,80 +64,10 @@ NumerotationContext NumerotationContextCommands::previous()
QStringList str = context_.itemAt(i);
setNumStrategy(str.at(0));
contextnum << strategy_ -> previous(context_, i);
if (str.at(0) == "wrap" && str.size() > 4) {
int modulus = str.at(4).toInt();
if (modulus > 0 && (str.at(1).toInt() - str.at(2).toInt()) < 0)
borrow(contextnum, i - 1);
}
}
return contextnum;
}
/**
@brief NumerotationContextCommands::carry
Add one unit to the nearest numeric part at or before from_index in
contextnum, skipping non-numeric parts (e.g. a "." string separator)
along the way. If that part is itself a wrap part and this pushes it
to (or past) its own modulus, it wraps back to 0 and the carry
cascades further back -- so wrap parts can be chained (e.g. seconds
wrapping into minutes wrapping into hours).
@param contextnum the context being built by next(); already contains
entries for every index <= from_index
@param from_index index to start looking from, going backwards
*/
void NumerotationContextCommands::carry(NumerotationContext &contextnum, int from_index)
{
for (int j = from_index; j >= 0; --j) {
QStringList strl = contextnum.itemAt(j);
if (!contextnum.keyIsNumber(strl.at(0)))
continue;
int value = strl.at(1).toInt() + 1;
if (strl.at(0) == "wrap" && strl.size() > 4) {
int modulus = strl.at(4).toInt();
if (modulus > 0 && value >= modulus) {
contextnum.replaceValue(j, QString::number(value - modulus));
carry(contextnum, j - 1);
return;
}
}
contextnum.replaceValue(j, QString::number(value));
return;
}
//No preceding numeric part: the carry has nowhere to go and is dropped,
//same as any other counter in this engine has no overflow tracking
//beyond the parts the user actually configured.
}
/**
@brief NumerotationContextCommands::borrow
Inverse of carry(): subtract one unit from the nearest numeric part at
or before from_index. If that part is itself a wrap part and this
takes it below 0, it wraps to (modulus - 1) and the borrow cascades
further back.
*/
void NumerotationContextCommands::borrow(NumerotationContext &contextnum, int from_index)
{
for (int j = from_index; j >= 0; --j) {
QStringList strl = contextnum.itemAt(j);
if (!contextnum.keyIsNumber(strl.at(0)))
continue;
int value = strl.at(1).toInt() - 1;
if (strl.at(0) == "wrap" && strl.size() > 4) {
int modulus = strl.at(4).toInt();
if (modulus > 0 && value < 0) {
contextnum.replaceValue(j, QString::number(value + modulus));
borrow(contextnum, j - 1);
return;
}
}
contextnum.replaceValue(j, QString::number(value));
return;
}
}
/**
@brief NumerotationContextCommands::toFinalString
@return the string represented by the numerotation context
@@ -196,18 +117,10 @@ void NumerotationContextCommands::setNumStrategy(const QString &str) {
strategy_ = new HundredFNum (diagram_);
return;
}
else if (str == "wrap") {
strategy_ = new WrapNum (diagram_);
return;
}
else if (str == "string") {
strategy_ = new StringNum (diagram_);
return;
}
else if (str == "alpha") {
strategy_ = new AlphaNum (diagram_);
return;
}
else if (str == "idfolio") {
strategy_ = new IdFolioNum (diagram_);
return;
@@ -259,7 +172,7 @@ NumerotationContext NumStrategy::nextString (const NumerotationContext &nc,
{
QStringList strl = nc.itemAt(i);
NumerotationContext newnc;
newnc.addValue(strl.at(0), strl.at(1), strl.at(2).toInt(), 0, 0, NumerotationContext::formatOf(strl));
newnc.addValue(strl.at(0), strl.at(1), strl.at(2).toInt());
return (newnc);
}
@@ -273,7 +186,7 @@ NumerotationContext NumStrategy::nextNumber (const NumerotationContext &nc,
QStringList strl = nc.itemAt(i);
NumerotationContext newnc;
QString value = QString::number( (strl.at(1).toInt()) + (strl.at(2).toInt()) );
newnc.addValue(strl.at(0), value, strl.at(2).toInt(), strl.at(3).toInt(), 0, NumerotationContext::formatOf(strl));
newnc.addValue(strl.at(0), value, strl.at(2).toInt(), strl.at(3).toInt());
return (newnc);
}
@@ -287,7 +200,7 @@ NumerotationContext NumStrategy::previousNumber(const NumerotationContext &nc,
QStringList strl = nc.itemAt(i);
NumerotationContext newnc;
QString value = QString::number( (strl.at(1).toInt()) - (strl.at(2).toInt()) );
newnc.addValue(strl.at(0), value, strl.at(2).toInt(), strl.at(3).toInt(), 0, NumerotationContext::formatOf(strl));
newnc.addValue(strl.at(0), value, strl.at(2).toInt(), strl.at(3).toInt());
return (newnc);
}
@@ -518,62 +431,6 @@ NumerotationContext HundredFNum::previous(const NumerotationContext &nc, const i
return (previousNumber(nc, i));
}
/**
Constructor
*/
WrapNum::WrapNum (Diagram *d):
NumStrategy (d)
{}
/**
@brief WrapNum::toRepresentedString
@return the represented string of num
*/
QString WrapNum::toRepresentedString(const QString num) const
{
return (num);
}
/**
@brief WrapNum::next
Wraps this part's own value back to 0 every `modulus` values (carrying
into the adjacent part is handled by NumerotationContextCommands::next(),
which has visibility into the other parts).
@return the next NumerotationContext nc at position i
*/
NumerotationContext WrapNum::next (const NumerotationContext &nc, const int i) const
{
QStringList strl = nc.itemAt(i);
NumerotationContext newnc;
int increase = strl.at(2).toInt();
int modulus = strl.size() > 4 ? strl.at(4).toInt() : 0;
int new_value = strl.at(1).toInt() + increase;
if (modulus > 0)
new_value %= modulus;
newnc.addValue(strl.at(0), QString::number(new_value), increase, strl.at(3).toInt(), modulus, NumerotationContext::formatOf(strl));
return (newnc);
}
/**
@brief WrapNum::previous
@return the previous NumerotationContext nc at posiiton i
*/
NumerotationContext WrapNum::previous(const NumerotationContext &nc, const int i) const
{
QStringList strl = nc.itemAt(i);
NumerotationContext newnc;
int increase = strl.at(2).toInt();
int modulus = strl.size() > 4 ? strl.at(4).toInt() : 0;
int new_value = strl.at(1).toInt() - increase;
if (modulus > 0) {
new_value %= modulus;
if (new_value < 0)
new_value += modulus;
}
newnc.addValue(strl.at(0), QString::number(new_value), increase, strl.at(3).toInt(), modulus, NumerotationContext::formatOf(strl));
return (newnc);
}
/**
Constructor
*/
@@ -608,120 +465,6 @@ NumerotationContext StringNum::previous(const NumerotationContext &nc, const int
return (nextString(nc, i));
}
namespace
{
/**
* @brief incrementAlpha
* Base-26 letter increment (a, b, ... z, aa, ab, ... az, ba, ...),
* the same algorithm as incrementing a spreadsheet column name.
* Carries right-to-left on 'z'/'Z' overflow; if the whole string
* overflows, a new leading letter is prepended (lowercase 'a').
* @param value : current alphabetic value; treated as "a" if empty.
* @return the next value.
*/
QString incrementAlpha(QString value)
{
if (value.isEmpty()) {
return QStringLiteral("a");
}
int i = value.length() - 1;
while (i >= 0 && (value.at(i) == QLatin1Char('z') || value.at(i) == QLatin1Char('Z'))) {
value[i] = value.at(i).isUpper() ? QLatin1Char('A') : QLatin1Char('a');
--i;
}
if (i < 0) {
value.prepend(QLatin1Char('a'));
} else {
value[i] = QChar(value.at(i).unicode() + 1);
}
return value;
}
/**
* @brief decrementAlpha
* Inverse of incrementAlpha(): borrows right-to-left on 'a'/'A'
* underflow. Symmetric shrink case (e.g. "aa" -> "z"): once every
* position has borrowed, the leading letter is dropped rather than
* left as an extra 'z'. A single-letter value already at "a"/"A" has
* no representable predecessor and is left unchanged, the same way
* the numeric parts don't clamp but a blank label would be worse
* here than a value that stops decreasing.
* @param value : current alphabetic value; treated as "a" if empty.
* @return the previous value.
*/
QString decrementAlpha(QString value)
{
if (value.isEmpty()) {
return QStringLiteral("a");
}
if (value.length() == 1) {
//A single letter has no representable predecessor once it
//reaches "a"/"A" -- clamp rather than mutate, since the loop
//below would otherwise turn it into "z"/"Z" (borrowing past
//the only position there is).
if (value.at(0) == QLatin1Char('a') || value.at(0) == QLatin1Char('A')) {
return value;
}
return QChar(value.at(0).unicode() - 1);
}
int i = value.length() - 1;
while (i >= 0 && (value.at(i) == QLatin1Char('a') || value.at(i) == QLatin1Char('A'))) {
value[i] = value.at(i).isUpper() ? QLatin1Char('Z') : QLatin1Char('z');
--i;
}
if (i < 0) {
//Every position borrowed: the whole value was "a...a", whose
//predecessor is one fewer "z" (e.g. "aa" -> "z").
value.remove(0, 1);
} else {
value[i] = QChar(value.at(i).unicode() - 1);
}
return value;
}
}
/**
Constructor
*/
AlphaNum::AlphaNum (Diagram *d):
NumStrategy (d)
{}
/**
@brief AlphaNum::toRepresentedString
@return the represented string of str
*/
QString AlphaNum::toRepresentedString(const QString str) const
{
return (str);
}
/**
@brief AlphaNum::next
@return the next NumerotationContext nc at position i
*/
NumerotationContext AlphaNum::next (const NumerotationContext &nc, const int i) const
{
QStringList strl = nc.itemAt(i);
NumerotationContext newnc;
newnc.addValue(strl.at(0), incrementAlpha(strl.at(1)), strl.at(2).toInt(), 0, 0, NumerotationContext::formatOf(strl));
return (newnc);
}
/**
@brief AlphaNum::previous
@return the previous NumerotationContext nc at posiiton i
*/
NumerotationContext AlphaNum::previous(const NumerotationContext &nc, const int i) const
{
QStringList strl = nc.itemAt(i);
NumerotationContext newnc;
newnc.addValue(strl.at(0), decrementAlpha(strl.at(1)), strl.at(2).toInt(), 0, 0, NumerotationContext::formatOf(strl));
return (newnc);
}
/**
Constructor
*/
@@ -38,8 +38,6 @@ class NumerotationContextCommands
private:
void setNumStrategy (const QString &);
static void carry(NumerotationContext &contextnum, int from_index);
static void borrow(NumerotationContext &contextnum, int from_index);
Diagram *diagram_;
NumerotationContext context_;
@@ -117,24 +115,6 @@ class HundredFNum: public NumStrategy
NumerotationContext previous (const NumerotationContext &, const int) const override;
};
/**
@brief The WrapNum class
A counter that wraps back to 0 (borrowing from initialvalue on the
way down) every `modulus` values, instead of counting up forever like
UnitNum/TenNum/HundredNum. Its own next()/previous() only computes its
own wrapped value; carrying into (or borrowing from) the preceding
numeric part is handled by NumerotationContextCommands::next()/
previous(), since only the composition loop can see adjacent parts.
*/
class WrapNum: public NumStrategy
{
public:
WrapNum (Diagram *);
QString toRepresentedString(const QString) const override;
NumerotationContext next (const NumerotationContext &, const int) const override;
NumerotationContext previous (const NumerotationContext &, const int) const override;
};
class StringNum: public NumStrategy
{
public:
@@ -144,23 +124,6 @@ class StringNum: public NumStrategy
NumerotationContext previous (const NumerotationContext &, const int) const override;
};
/**
@brief The AlphaNum class
Alphabetic auto-numbering (a, b, ... z, aa, ab, ...). Unlike StringNum
(a fixed, non-incrementing text segment), this is a real base-26
counter: next()/previous() carry/borrow entirely within this part's
own value, the same self-contained shape every other incrementing
NumStrategy already has.
*/
class AlphaNum: public NumStrategy
{
public:
AlphaNum (Diagram *);
QString toRepresentedString(const QString) const override;
NumerotationContext next (const NumerotationContext &, const int) const override;
NumerotationContext previous (const NumerotationContext &, const int) const override;
};
class IdFolioNum: public NumStrategy
{
public:
+1 -228
View File
@@ -20,15 +20,11 @@
#include "../../diagram.h"
#include "../../diagramview.h"
#include "../../qetapp.h"
#include "../../shortcutmanager.h"
#include "../../titleblockproperties.h"
#include "../../ui/projectpropertiesdialog.h"
#include "../numerotationcontext.h"
#include "ui_autonumberingdockwidget.h"
#include <QComboBox>
#include <QLineEdit>
/**
@brief AutoNumberingDockWidget::AutoNumberingDockWidget
Constructor
@@ -61,9 +57,6 @@ void AutoNumberingDockWidget::clear()
ui->m_conductor_cb->clear();
ui->m_element_cb->clear();
ui->m_folio_cb->clear();
ui->m_conductor_value_le->clear();
ui->m_element_value_le->clear();
ui->m_folio_value_le->clear();
}
void AutoNumberingDockWidget::projectClosed()
@@ -115,8 +108,6 @@ void AutoNumberingDockWidget::setProject(QETProject *project,
this,SLOT(setActive()));
//Conductor, Element and Folio Signals
disconnect(m_project, &QETProject::autoNumContextUpdated,
this, &AutoNumberingDockWidget::refreshValueFields);
disconnect(m_project, &QETProject::destroyed,
this, &AutoNumberingDockWidget::projectClosed);
}
@@ -154,16 +145,13 @@ void AutoNumberingDockWidget::setProject(QETProject *project,
this,SLOT(setActive()));
//Conductor, Element and Folio Signals
connect(m_project, &QETProject::autoNumContextUpdated,
this, &AutoNumberingDockWidget::refreshValueFields);
connect(m_project, &QETProject::destroyed,
this, &AutoNumberingDockWidget::projectClosed);
//Set Combobox Context
setContext();
ShortcutManager::instance().registerAction(ui->m_configure_pb, "autonum.configure",
tr("Autonumérotation"), Qt::CTRL | Qt::SHIFT | Qt::Key_P);
ui->m_configure_pb->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_P);
}
/**
@@ -199,12 +187,6 @@ void AutoNumberingDockWidget::setContext()
{ ui->m_folio_cb -> addItem(str);}
}
//The combo boxes have just been repopulated, so the value fields next
//to them are showing whatever the previous project left there.
refreshValueField(ui->m_conductor_cb, ui->m_conductor_value_le, AutoNumCategory::Conductor);
refreshValueField(ui->m_element_cb, ui->m_element_value_le, AutoNumCategory::Element);
refreshValueField(ui->m_folio_cb, ui->m_folio_value_le, AutoNumCategory::Folio);
this->setActive();
}
@@ -279,7 +261,6 @@ void AutoNumberingDockWidget::on_m_conductor_cb_activated(int)
m_project->setCurrentConductorAutoNum(current_autonum);
m_project_view->currentDiagram()->diagram()->setConductorsAutonumName(current_autonum);
m_project_view->currentDiagram()->diagram()->loadCndFolioSeq();
refreshValueField(ui->m_conductor_cb, ui->m_conductor_value_le, AutoNumCategory::Conductor);
}
/**
@@ -308,7 +289,6 @@ void AutoNumberingDockWidget::on_m_element_cb_activated(int)
{
m_project->setCurrrentElementAutonum(ui->m_element_cb->currentText());
m_project_view->currentDiagram()->diagram()->loadElmtFolioSeq();
refreshValueField(ui->m_element_cb, ui->m_element_value_le, AutoNumCategory::Element);
}
/**
@@ -346,7 +326,6 @@ void AutoNumberingDockWidget::on_m_folio_cb_activated(int) {
m_project->setDefaultTitleBlockProperties(ip);
}
emit(folioAutoNumChanged(current_autonum));
refreshValueField(ui->m_folio_cb, ui->m_folio_value_le, AutoNumCategory::Folio);
}
void AutoNumberingDockWidget::on_m_configure_pb_clicked()
@@ -358,209 +337,3 @@ void AutoNumberingDockWidget::on_m_configure_pb_clicked()
ppd.exec();
}
}
void AutoNumberingDockWidget::on_m_conductor_reset_start_pb_clicked()
{
resetAutoNum(ui->m_conductor_cb, AutoNumCategory::Conductor);
}
void AutoNumberingDockWidget::on_m_element_reset_start_pb_clicked()
{
resetAutoNum(ui->m_element_cb, AutoNumCategory::Element);
}
void AutoNumberingDockWidget::on_m_folio_reset_start_pb_clicked()
{
resetAutoNum(ui->m_folio_cb, AutoNumCategory::Folio);
}
void AutoNumberingDockWidget::on_m_conductor_value_le_editingFinished()
{
applyValueField(ui->m_conductor_cb, ui->m_conductor_value_le, AutoNumCategory::Conductor);
}
void AutoNumberingDockWidget::on_m_element_value_le_editingFinished()
{
applyValueField(ui->m_element_cb, ui->m_element_value_le, AutoNumCategory::Element);
}
void AutoNumberingDockWidget::on_m_folio_value_le_editingFinished()
{
applyValueField(ui->m_folio_cb, ui->m_folio_value_le, AutoNumCategory::Folio);
}
/**
@brief AutoNumberingDockWidget::contextFor
@return the numerotation context named by combo_box, for category
*/
NumerotationContext AutoNumberingDockWidget::contextFor(QComboBox *combo_box, AutoNumCategory category) const
{
const QString key = combo_box->currentText();
switch (category) {
case AutoNumCategory::Conductor: return m_project->conductorAutoNum(key);
case AutoNumCategory::Element: return m_project->elementAutoNum(key);
case AutoNumCategory::Folio: return m_project->folioAutoNum(key);
}
return NumerotationContext();
}
/**
@brief AutoNumberingDockWidget::storeContext
Write context back under the name selected in combo_box and flag the
project as modified -- without that last step the change is not saved
and the user is never asked to save it on close.
*/
void AutoNumberingDockWidget::storeContext(QComboBox *combo_box, AutoNumCategory category, const NumerotationContext &context)
{
const QString key = combo_box->currentText();
switch (category) {
case AutoNumCategory::Conductor: m_project->addConductorAutoNum(key, context); break;
case AutoNumCategory::Element: m_project->addElementAutoNum(key, context); break;
case AutoNumCategory::Folio: m_project->addFolioAutoNum(key, context); break;
}
m_project->setModified(true);
}
/**
@brief AutoNumberingDockWidget::counterIndex
@return the index of the part the value field shows: the last one that
actually progresses, i.e. the least significant digit of the number.
-1 when the context has no progressing part at all.
*/
int AutoNumberingDockWidget::counterIndex(const NumerotationContext &context)
{
for (int i = context.size() - 1 ; i >= 0 ; --i)
{
const QString type = context.itemAt(i).at(0);
if (type == QLatin1String("unit")
|| type == QLatin1String("ten")
|| type == QLatin1String("hundred")
|| type == QLatin1String("unitfolio")
|| type == QLatin1String("tenfolio")
|| type == QLatin1String("hundredfolio")
|| type == QLatin1String("wrap")
|| type == QLatin1String("alpha"))
return i;
}
return -1;
}
/**
@brief AutoNumberingDockWidget::refreshValueFields
Re-read all three value fields from the project. Called whenever a
numerotation context's values change, which includes every element or
conductor that consumes the next number -- without this the field only
caught up when the user re-picked a rule from the combo box, because
the combo's activated() signal fires on user interaction alone.
*/
void AutoNumberingDockWidget::refreshValueFields()
{
//Leave alone a field the user is typing in: numbering an element
//refreshes all three, and overwriting a half-typed value under the
//cursor is worse than showing it a moment out of date. Only this
//automatic path skips; an explicit refresh after a reset or an edit
//still writes, so the field always ends up canonical.
if (!ui->m_conductor_value_le->hasFocus())
refreshValueField(ui->m_conductor_cb, ui->m_conductor_value_le, AutoNumCategory::Conductor);
if (!ui->m_element_value_le->hasFocus())
refreshValueField(ui->m_element_cb, ui->m_element_value_le, AutoNumCategory::Element);
if (!ui->m_folio_value_le->hasFocus())
refreshValueField(ui->m_folio_cb, ui->m_folio_value_le, AutoNumCategory::Folio);
}
/**
@brief AutoNumberingDockWidget::refreshValueField
Show the current value of the selected context's counter, so the field
always reflects where the numbering has actually got to.
*/
void AutoNumberingDockWidget::refreshValueField(QComboBox *combo_box, QLineEdit *line_edit, AutoNumCategory category)
{
if (!m_project || combo_box->currentText().isEmpty())
{
line_edit->clear();
line_edit->setEnabled(false);
return;
}
const NumerotationContext context = contextFor(combo_box, category);
const int index = counterIndex(context);
line_edit->setEnabled(index >= 0);
line_edit->setText(index >= 0 ? context.itemAt(index).at(1) : QString());
}
/**
@brief AutoNumberingDockWidget::applyValueField
Write the value typed in line_edit to the counter it displays. An empty
field is treated as "no change" rather than as an empty value, so
clearing the box by accident cannot wipe the counter.
*/
void AutoNumberingDockWidget::applyValueField(QComboBox *combo_box, QLineEdit *line_edit, AutoNumCategory category)
{
if (!m_project || combo_box->currentText().isEmpty())
return;
NumerotationContext context = contextFor(combo_box, category);
const int index = counterIndex(context);
if (index < 0)
return;
const QString typed = line_edit->text();
if (typed.isEmpty() || typed == context.itemAt(index).at(1))
{
refreshValueField(combo_box, line_edit, category);
return;
}
context.replaceValue(index, typed);
storeContext(combo_box, category, context);
refreshValueField(combo_box, line_edit, category);
}
/**
@brief AutoNumberingDockWidget::resetAutoNum
Reset the numerotation context currently selected in combo_box back to
a per-type starting value, then write it back. Does nothing if no
context is selected.
Only parts that actually progress are touched: folio-anchored numeric
types go back to their own stored initialvalue, plain numeric types go
back to "1", a wrap part goes back to "0" because a modulo counter
cycles over [0, modulus) -- a PLC card addressed %IX0.0..%IX0.31 starts
at 0, not 1 -- and alpha goes back to "a". Non-incrementing types
(string, plant, locmach, idfolio, folio, elementline, elementcolumn,
elementprefix) are left alone: there is no "start" for them distinct
from the fixed or contextual value the user configured.
*/
void AutoNumberingDockWidget::resetAutoNum(QComboBox *combo_box, AutoNumCategory category)
{
if (!m_project || combo_box->currentText().isEmpty())
return;
NumerotationContext context = contextFor(combo_box, category);
for (int i = 0 ; i < context.size() ; ++i)
{
const QStringList item = context.itemAt(i);
const QString &type = item.at(0);
if (type == QLatin1String("unitfolio")
|| type == QLatin1String("tenfolio")
|| type == QLatin1String("hundredfolio"))
context.replaceValue(i, item.size() > 3 ? item.at(3) : QStringLiteral("1"));
else if (type == QLatin1String("unit")
|| type == QLatin1String("ten")
|| type == QLatin1String("hundred"))
context.replaceValue(i, QStringLiteral("1"));
else if (type == QLatin1String("wrap"))
context.replaceValue(i, QStringLiteral("0"));
else if (type == QLatin1String("alpha"))
context.replaceValue(i, QStringLiteral("a"));
}
storeContext(combo_box, category, context);
switch (category) {
case AutoNumCategory::Conductor: refreshValueField(combo_box, ui->m_conductor_value_le, category); break;
case AutoNumCategory::Element: refreshValueField(combo_box, ui->m_element_value_le, category); break;
case AutoNumCategory::Folio: refreshValueField(combo_box, ui->m_folio_value_le, category); break;
}
}
+1 -36
View File
@@ -23,9 +23,6 @@
#include <QDockWidget>
class QComboBox;
class QLineEdit;
namespace Ui {
class AutoNumberingDockWidget;
}
@@ -54,45 +51,13 @@ class AutoNumberingDockWidget : public QDockWidget
void folioAutoNumChanged();
void clear();
void projectClosed();
void refreshValueFields();
void on_m_configure_pb_clicked();
void on_m_conductor_reset_start_pb_clicked();
void on_m_element_reset_start_pb_clicked();
void on_m_folio_reset_start_pb_clicked();
void on_m_conductor_value_le_editingFinished();
void on_m_element_value_le_editingFinished();
void on_m_folio_value_le_editingFinished();
signals:
void folioAutoNumChanged(QString);
private:
enum class AutoNumCategory { Conductor, Element, Folio };
/**
@brief resetAutoNum
Reset the numerotation context currently selected in combo_box
(for the given category) to a per-type starting value. Does
nothing if no context is selected.
*/
void resetAutoNum(QComboBox *combo_box, AutoNumCategory category);
/// Read/write the numerotation context named in combo_box.
NumerotationContext contextFor(QComboBox *combo_box, AutoNumCategory category) const;
void storeContext(QComboBox *combo_box, AutoNumCategory category, const NumerotationContext &context);
/// Index of the counter the value field shows and edits: the last
/// part that actually progresses. Returns -1 when the context has
/// no such part (e.g. it is only fixed text).
static int counterIndex(const NumerotationContext &context);
/// Refresh a value field from its context, and apply a typed value.
void refreshValueField(QComboBox *combo_box, QLineEdit *line_edit, AutoNumCategory category);
void applyValueField(QComboBox *combo_box, QLineEdit *line_edit, AutoNumCategory category);
Ui::AutoNumberingDockWidget *ui;
QETProject* m_project = nullptr;
ProjectView* m_project_view = nullptr;
@@ -28,39 +28,6 @@
<item row="2" column="1">
<widget class="QComboBox" name="m_conductor_cb"/>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="m_conductor_reset_start_pb">
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Réinitialiser à la valeur de départ</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/view-refresh.png</normaloff>:/ico/16x16/view-refresh.png</iconset>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLineEdit" name="m_conductor_value_le">
<property name="maximumSize">
<size>
<width>70</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Valeur actuelle du compteur. Saisir une nouvelle valeur et valider pour la modifier.</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label">
<property name="text">
@@ -75,75 +42,9 @@
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QPushButton" name="m_element_reset_start_pb">
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Réinitialiser à la valeur de départ</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/view-refresh.png</normaloff>:/ico/16x16/view-refresh.png</iconset>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QLineEdit" name="m_element_value_le">
<property name="maximumSize">
<size>
<width>70</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Valeur actuelle du compteur. Saisir une nouvelle valeur et valider pour la modifier.</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="m_folio_cb"/>
</item>
<item row="4" column="2">
<widget class="QPushButton" name="m_folio_reset_start_pb">
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Réinitialiser à la valeur de départ</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/view-refresh.png</normaloff>:/ico/16x16/view-refresh.png</iconset>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QLineEdit" name="m_folio_value_le">
<property name="maximumSize">
<size>
<width>70</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Valeur actuelle du compteur. Saisir une nouvelle valeur et valider pour la modifier.</string>
</property>
</widget>
</item>
<item row="6" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
+2 -95
View File
@@ -18,10 +18,6 @@
#include "numparteditorw.h"
#include "ui_numparteditorw.h"
#include "../numerotationcontext.h"
#include <QRegularExpressionValidator>
/**
@brief NumPartEditorW::NumPartEditorW
Constructor
@@ -32,14 +28,10 @@ NumPartEditorW::NumPartEditorW(int type, QWidget *parent) :
QWidget(parent),
ui(new Ui::NumPartEditorW),
intValidator (new QIntValidator(0,99999,this)),
alphaValidator (new QRegularExpressionValidator(QRegularExpression("[A-Za-z]+"), this)),
m_edited_type(type)
{
ui -> setupUi(this);
setVisibleItems();
//The mask is a run of zeros and nothing else, so it cannot be typed
//into a state the renderer would have to reject.
ui -> format_le -> setValidator(new QRegularExpressionValidator(QRegularExpression("0*"), this));
setType(NumPartEditorW::unit, true);
}
@@ -59,7 +51,6 @@ NumPartEditorW::NumPartEditorW (NumerotationContext &context,
QWidget(parent),
ui(new Ui::NumPartEditorW),
intValidator (new QIntValidator(0,99999,this)),
alphaValidator (new QRegularExpressionValidator(QRegularExpression("[A-Za-z]+"), this)),
m_edited_type(type)
{
ui -> setupUi(this);
@@ -80,10 +71,6 @@ NumPartEditorW::NumPartEditorW (NumerotationContext &context,
setType(NumPartEditorW::hundred, true);
else if (strl.at(0)=="hundredfolio")
setType(NumPartEditorW::hundredfolio, true);
else if (strl.at(0)=="wrap")
setType(NumPartEditorW::wrap, true);
else if (strl.at(0)=="alpha")
setType(NumPartEditorW::alpha);
else if (strl.at(0)=="string")
setType(NumPartEditorW::string);
else if (strl.at(0)=="idfolio")
@@ -102,9 +89,6 @@ NumPartEditorW::NumPartEditorW (NumerotationContext &context,
setType(NumPartEditorW::elementprefix);
ui -> value_field -> setText(strl.at(1));
ui -> increase_spinBox -> setValue(strl.at(2).toInt());
if (strl.at(0)=="wrap" && strl.size() > 4)
ui -> modulus_spinBox -> setValue(strl.at(4).toInt());
ui -> format_le -> setText(NumerotationContext::formatOf(strl));
}
}
@@ -114,7 +98,6 @@ NumPartEditorW::NumPartEditorW (NumerotationContext &context,
NumPartEditorW::~NumPartEditorW()
{
delete intValidator;
delete alphaValidator;
delete ui;
}
@@ -127,8 +110,6 @@ void NumPartEditorW::setVisibleItems()
items << tr("Chiffre 1")
<< tr("Chiffre 01")
<< tr("Chiffre 001")
<< tr("Cyclique (modulo)")
<< tr("Alphabétique")
<< tr("Texte");
}
else if (m_edited_type == 1)
@@ -139,8 +120,6 @@ void NumPartEditorW::setVisibleItems()
<< tr("Chiffre 01 - Folio")
<< tr("Chiffre 001")
<< tr("Chiffre 001 - Folio")
<< tr("Cyclique (modulo)")
<< tr("Alphabétique")
<< tr("Texte")
<< tr("N° folio")
<< tr("Folio")
@@ -154,8 +133,6 @@ void NumPartEditorW::setVisibleItems()
<< tr("Chiffre 01 - Folio")
<< tr("Chiffre 001")
<< tr("Chiffre 001 - Folio")
<< tr("Cyclique (modulo)")
<< tr("Alphabétique")
<< tr("Texte")
<< tr("N° folio")
<< tr("Folio")
@@ -218,37 +195,18 @@ NumerotationContext NumPartEditorW::toNumContext()
case elementprefix:
type_str = "elementprefix";
break;
case wrap:
type_str = "wrap";
break;
case alpha:
type_str = "alpha";
break;
}
const QString number_format = ui -> format_le -> text();
if (type_str == "unitfolio"
|| type_str == "tenfolio"
|| type_str == "hundredfolio")
nc.addValue(type_str,
ui -> value_field -> displayText(),
ui -> increase_spinBox -> value(),
ui->value_field->displayText().toInt(),
0,
number_format);
else if (type_str == "wrap")
nc.addValue(type_str,
ui -> value_field -> displayText(),
ui -> increase_spinBox -> value(),
0,
ui -> modulus_spinBox -> value(),
number_format);
ui->value_field->displayText().toInt());
else
nc.addValue(type_str,
ui -> value_field -> displayText(),
ui -> increase_spinBox -> value(),
0,
0,
number_format);
ui -> increase_spinBox -> value());
return nc;
}
@@ -302,10 +260,6 @@ void NumPartEditorW::on_type_cb_activated(int) {
setType(elementcolumn);
else if (ui->type_cb->currentText() == tr("Element Prefix"))
setType(elementprefix);
else if (ui->type_cb->currentText() == tr("Cyclique (modulo)"))
setType(wrap);
else if (ui->type_cb->currentText() == tr("Alphabétique"))
setType(alpha);
emit changed();
}
@@ -326,22 +280,6 @@ void NumPartEditorW::on_increase_spinBox_valueChanged(int) {
if (!ui -> value_field -> text().isEmpty()) emit changed();
}
/**
@brief NumPartEditorW::on_modulus_spinBox_valueChanged
emit changed when modulus_spinBox value changed
*/
/**
@brief NumPartEditorW::on_format_le_textEdited
emit changed when the display format is edited
*/
void NumPartEditorW::on_format_le_textEdited(const QString &) {
emit changed();
}
void NumPartEditorW::on_modulus_spinBox_valueChanged(int) {
if (!ui -> value_field -> text().isEmpty()) emit changed();
}
/**
@brief NumPartEditorW::setType
Set good behavior by type t
@@ -361,7 +299,6 @@ void NumPartEditorW::setType(NumPartEditorW::type t, bool fnum) {
|| t==tenfolio
|| t==hundred
|| t==hundredfolio
|| t==wrap
)
&& (type_==string
|| type_==folio
@@ -383,7 +320,6 @@ void NumPartEditorW::setType(NumPartEditorW::type t, bool fnum) {
}
//@t isn't a numeric type
else if (t == string
|| t == alpha
|| t == folio
|| t == idfolio
|| t == elementline
@@ -397,13 +333,6 @@ void NumPartEditorW::setType(NumPartEditorW::type t, bool fnum) {
ui -> value_field -> setValidator(nullptr);
ui -> value_field -> setEnabled(true);
}
else if (t==alpha) {
//Alphabetic step is always exactly one letter (a, b, ...);
//there is no numeric "increase" to configure, unlike the
//digit-based part types.
ui -> value_field -> setValidator(alphaValidator);
ui -> value_field -> setEnabled(true);
}
else if (t==folio) {
ui -> value_field -> setDisabled(true);
ui -> increase_spinBox -> setDisabled(true);
@@ -433,24 +362,6 @@ void NumPartEditorW::setType(NumPartEditorW::type t, bool fnum) {
ui -> increase_spinBox -> setDisabled(true);
}
}
//A modulus of 0 means "no cycle", which makes a Cyclique part behave
//exactly like a plain digit. Defaulting it used to live in the numeric
//behavior block above, which is skipped when the previous type was
//itself numeric -- so the ordinary path of turning the default
//"Chiffre 1" into a "Cyclique (modulo)" left the modulus at 0 and
//produced a wrap part that never wrapped. Kept out of that block so it
//applies whatever the part was before, and only when the current value
//is unusable, so a modulus the user chose on purpose is not clobbered.
if (t == wrap && ui -> modulus_spinBox -> value() <= 0)
ui -> modulus_spinBox -> setValue(8);
ui -> modulus_spinBox -> setEnabled(t == wrap);
//A padding mask only means anything for a part rendered as a number.
const bool numeric = (t == unit || t == unitfolio || t == ten
|| t == tenfolio || t == hundred || t == hundredfolio
|| t == wrap);
ui -> format_le -> setEnabled(numeric);
if (!numeric)
ui -> format_le -> clear();
type_= t;
}
@@ -473,8 +384,6 @@ void NumPartEditorW::setCurrentIndex(NumPartEditorW::type t) {
i = ui->type_cb->findText(tr("Chiffre 001"));
else if (t == hundredfolio)
i = ui->type_cb->findText(tr("Chiffre 001 - Folio"));
else if (t == alpha)
i = ui->type_cb->findText(tr("Alphabétique"));
else if (t == string)
i = ui->type_cb->findText(tr("Texte"));
else if (t == idfolio)
@@ -491,7 +400,5 @@ void NumPartEditorW::setCurrentIndex(NumPartEditorW::type t) {
i = ui->type_cb->findText(tr("Element Column"));
else if (t == elementprefix)
i = ui->type_cb->findText(tr("Element Prefix"));
else if (t == wrap)
i = ui->type_cb->findText(tr("Cyclique (modulo)"));
ui->type_cb->setCurrentIndex(i);
}

Some files were not shown because too many files have changed in this diff Show More