mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-06-07 18:43:14 +02:00
Compare commits
42 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 31aaf50572 | |||
| 81ec28d1cf | |||
| 3bbb6385b8 | |||
| 757df90951 | |||
| eeb453f120 | |||
| 6afd9fe48d | |||
| 6eff69bc6b | |||
| c9304892e0 | |||
| 59f547b4a2 | |||
| 0084dcf289 | |||
| 0804d3524a | |||
| 2b0dd1b188 | |||
| 3c2c889922 | |||
| 27cff81ee7 | |||
| 40a7995993 | |||
| 45afd9af0e | |||
| 20b7e1763d | |||
| 9044d532ac | |||
| 50efc318e0 | |||
| e4d2dbd2a6 | |||
| ddf40854dc | |||
| ef0fa6e7ac | |||
| 237c21bad8 | |||
| 260ce2a8bc | |||
| 6199367166 | |||
| d073e810b8 | |||
| a1572be8fa | |||
| 6c52d95201 | |||
| d3463def98 | |||
| 4009e6aaab | |||
| 6ff518ec3b | |||
| 513927424f | |||
| 864a3f166f | |||
| 6111d8ca2c | |||
| e0b26592c7 | |||
| a17ceaba85 | |||
| e987d8c271 | |||
| 74e6657ca5 | |||
| e1d15f3b77 | |||
| 81f51b3d58 | |||
| a36de7de74 | |||
| 15ae8b0058 |
+30
-24
@@ -16,7 +16,7 @@
|
||||
|
||||
include(cmake/hoto_update_cmake_message.cmake)
|
||||
|
||||
cmake_minimum_required(VERSION 3.21.1 FATAL_ERROR)
|
||||
cmake_minimum_required(VERSION 3.14...3.19 FATAL_ERROR)
|
||||
|
||||
project(qelectrotech
|
||||
VERSION 0.9.0
|
||||
@@ -27,13 +27,6 @@ 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()
|
||||
|
||||
# Add sub directories
|
||||
option(PACKAGE_TESTS "Build the tests" ON)
|
||||
@@ -50,17 +43,42 @@ 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)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
find_package(
|
||||
QT
|
||||
NAMES
|
||||
Qt6
|
||||
Qt5
|
||||
COMPONENTS
|
||||
${QET_COMPONENTS}
|
||||
REQUIRED
|
||||
)
|
||||
|
||||
find_package(
|
||||
Qt${QT_VERSION_MAJOR}
|
||||
COMPONENTS
|
||||
${QET_COMPONENTS}
|
||||
REQUIRED)
|
||||
|
||||
set(CMAKE_AUTOUIC_SEARCH_PATHS ${QET_DIR}/sources/ui)
|
||||
qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
|
||||
set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION "${QET_DIR}/lang")
|
||||
qt5_add_translation(QM_FILES ${TS_FILES})
|
||||
|
||||
# als laatse
|
||||
include(cmake/define_definitions.cmake)
|
||||
|
||||
qt_add_executable(
|
||||
add_executable(
|
||||
${PROJECT_NAME}
|
||||
${QET_RES_FILES}
|
||||
${QET_SRC_FILES}
|
||||
@@ -68,24 +86,13 @@ qt_add_executable(
|
||||
${QET_DIR}/qelectrotech.qrc
|
||||
)
|
||||
|
||||
if(QMFILES_AS_RESOURCE)
|
||||
qt_add_translations(${PROJECT_NAME} TS_FILES ${TS_FILES} RESOURCE_PREFIX "/lang")
|
||||
else()
|
||||
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()
|
||||
|
||||
find_package(SQLite3 REQUIRED)
|
||||
|
||||
target_link_libraries(
|
||||
${PROJECT_NAME}
|
||||
PUBLIC
|
||||
PRIVATE
|
||||
pugixml::pugixml
|
||||
SingleApplication::SingleApplication
|
||||
SQLite::SQLite3
|
||||
${KF6_PRIVATE_LIBRARIES}
|
||||
${KF5_PRIVATE_LIBRARIES}
|
||||
${QET_PRIVATE_LIBRARIES}
|
||||
)
|
||||
|
||||
@@ -142,7 +149,6 @@ install(FILES LICENSE ELEMENTS.LICENSE CREDIT README ChangeLog DESTINATION share
|
||||
install(FILES misc/org.qelectrotech.qelectrotech.desktop DESTINATION share/applications)
|
||||
install(FILES misc/qelectrotech.xml DESTINATION share/mime/packages)
|
||||
install(FILES misc/qelectrotech.appdata.xml DESTINATION ${QET_APPDATA_PATH})
|
||||
if(NOT QMFILES_AS_RESOURCE)
|
||||
install(FILES ${QM_FILES} DESTINATION ${QET_LANG_PATH})
|
||||
endif()
|
||||
install(FILES ${QM_FILES} DESTINATION ${QET_LANG_PATH})
|
||||
|
||||
endif()
|
||||
|
||||
@@ -62,15 +62,10 @@ message("PROJECT_SOURCE_DIR :" ${PROJECT_SOURCE_DIR})
|
||||
message("QET_DIR :" ${QET_DIR})
|
||||
message("GIT_COMMIT_SHA :" ${GIT_COMMIT_SHA})
|
||||
|
||||
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)
|
||||
if(BUILD_WITH_KF5)
|
||||
message("KF5_GIT_TAG :" ${KF5_GIT_TAG})
|
||||
else()
|
||||
add_definitions(-DBUILD_WITHOUT_KF5)
|
||||
endif()
|
||||
message("QET_COMPONENTS :" ${QET_COMPONENTS})
|
||||
message("Qt version :" ${Qt6_VERSION})
|
||||
|
||||
if(QMFILES_AS_RESOURCE)
|
||||
add_definitions(-DQMFILES_AS_RESOURCE)
|
||||
endif()
|
||||
message("QT_VERSION_MAJOR :" ${QT_VERSION_MAJOR})
|
||||
|
||||
@@ -31,8 +31,5 @@ add_definitions(-DQT_MESSAGELOGCONTEXT)
|
||||
# In order to do so, uncomment the following line.
|
||||
#add_definitions(-DTODO_LIST)
|
||||
|
||||
# Build with KF6
|
||||
option(BUILD_WITH_KF6 "Build with KF6" ON)
|
||||
|
||||
# Use translations as a Qt resource
|
||||
option(QMFILES_AS_RESOURCE "Use .qm files as Qt resource" ON)
|
||||
# Build with KF5
|
||||
option(BUILD_WITH_KF5 "Build with KF5" ON)
|
||||
|
||||
+36
-29
@@ -14,47 +14,54 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
message(STATUS "fetch_kdeaddons")
|
||||
message(" - fetch_kdeaddons")
|
||||
|
||||
if(BUILD_WITH_KF6)
|
||||
option(BUILD_KF6 "Build KF6 libraries, use system ones otherwise" OFF)
|
||||
block(PROPAGATE KF6_GIT_TAG)
|
||||
set(BUILD_TESTING OFF)
|
||||
set(KDE_SKIP_TEST_SETTINGS ON)
|
||||
set(BUILD_DESIGNERPLUGIN OFF)
|
||||
set(KCOREADDONS_USE_QML OFF)
|
||||
set(BUILD_QCH OFF)
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
find_package(ECM 6.8.0 REQUIRED NO_MODULE)
|
||||
list(APPEND CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
|
||||
if(DEFINED BUILD_WITH_KF5)
|
||||
Include(FetchContent)
|
||||
|
||||
if(BUILD_KF6)
|
||||
Include(FetchContent)
|
||||
option(BUILD_KF5 "Build KF5 libraries, use system ones otherwise" YES)
|
||||
|
||||
if(NOT DEFINED KF6_GIT_TAG)
|
||||
set(KF6_GIT_TAG v6.8.0)
|
||||
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)
|
||||
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 ${KF6_GIT_TAG})
|
||||
GIT_TAG ${KF5_GIT_TAG})
|
||||
FetchContent_MakeAvailable(kcoreaddons)
|
||||
get_target_property(kca_version KF6::CoreAddons VERSION)
|
||||
|
||||
FetchContent_Declare(
|
||||
kwidgetsaddons
|
||||
GIT_REPOSITORY https://invent.kde.org/frameworks/kwidgetsaddons.git
|
||||
GIT_TAG ${KF5_GIT_TAG})
|
||||
FetchContent_MakeAvailable(kwidgetsaddons)
|
||||
else()
|
||||
find_package(KF6CoreAddons REQUIRED)
|
||||
set(kca_version ${KF6CoreAddons_VERSION})
|
||||
find_package(KF5CoreAddons REQUIRED)
|
||||
find_package(KF5WidgetsAddons REQUIRED)
|
||||
endif()
|
||||
|
||||
get_target_property(kwa_type KF6::CoreAddons TYPE)
|
||||
|
||||
message(NOTICE "ecm version : " ${ECM_VERSION})
|
||||
message(NOTICE "kcoreaddons library : " ${kca_type})
|
||||
message(NOTICE "kcoreaddons version : " ${kca_version})
|
||||
endblock()
|
||||
|
||||
set(KF6_PRIVATE_LIBRARIES
|
||||
KF6::CoreAddons
|
||||
set(KF5_PRIVATE_LIBRARIES
|
||||
KF5::WidgetsAddons
|
||||
KF5::CoreAddons
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -25,7 +25,7 @@ if(BUILD_PUGIXML)
|
||||
FetchContent_Declare(
|
||||
pugixml
|
||||
GIT_REPOSITORY https://github.com/zeux/pugixml.git
|
||||
GIT_TAG v1.14)
|
||||
GIT_TAG v1.11.4)
|
||||
|
||||
FetchContent_MakeAvailable(pugixml)
|
||||
else()
|
||||
|
||||
@@ -26,6 +26,6 @@ Include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
SingleApplication
|
||||
GIT_REPOSITORY https://github.com/itay-grudev/SingleApplication.git
|
||||
GIT_TAG v3.5.1)
|
||||
GIT_TAG v3.2.0)
|
||||
|
||||
FetchContent_MakeAvailable(SingleApplication)
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
message(" - qet_compilation_vars")
|
||||
|
||||
set(QET_COMPONENTS
|
||||
Core
|
||||
Gui
|
||||
LinguistTools
|
||||
PrintSupport
|
||||
Xml
|
||||
@@ -111,12 +109,6 @@ 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
|
||||
@@ -718,6 +710,7 @@ set(QET_SRC_FILES
|
||||
|
||||
set(TS_FILES
|
||||
${QET_DIR}/lang/qet_ar.ts
|
||||
${QET_DIR}/lang/qet_be.ts
|
||||
${QET_DIR}/lang/qet_ca.ts
|
||||
${QET_DIR}/lang/qet_cs.ts
|
||||
${QET_DIR}/lang/qet_da.ts
|
||||
@@ -734,7 +727,6 @@ 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_no.ts
|
||||
${QET_DIR}/lang/qet_pl.ts
|
||||
${QET_DIR}/lang/qet_pt.ts
|
||||
|
||||
@@ -29,4 +29,4 @@ add_definitions(-DQET_ALLOW_OVERRIDE_CD_OPTION)
|
||||
add_definitions(-DQET_ALLOW_OVERRIDE_DD_OPTION)
|
||||
|
||||
#comment the line below to disable the project database export
|
||||
add_definitions(-DQET_EXPORT_PROJECT_DB)
|
||||
#add_definitions(-DQET_EXPORT_PROJECT_DB) #error Todo
|
||||
|
||||
+196
-158
File diff suppressed because it is too large
Load Diff
+196
-158
File diff suppressed because it is too large
Load Diff
+196
-158
File diff suppressed because it is too large
Load Diff
+196
-158
File diff suppressed because it is too large
Load Diff
Binary file not shown.
+197
-159
File diff suppressed because it is too large
Load Diff
+196
-158
File diff suppressed because it is too large
Load Diff
Binary file not shown.
+196
-158
File diff suppressed because it is too large
Load Diff
+196
-158
File diff suppressed because it is too large
Load Diff
Binary file not shown.
+201
-163
File diff suppressed because it is too large
Load Diff
+196
-158
File diff suppressed because it is too large
Load Diff
+196
-158
File diff suppressed because it is too large
Load Diff
+196
-158
File diff suppressed because it is too large
Load Diff
+196
-158
File diff suppressed because it is too large
Load Diff
+196
-158
File diff suppressed because it is too large
Load Diff
+196
-158
File diff suppressed because it is too large
Load Diff
Binary file not shown.
+198
-159
File diff suppressed because it is too large
Load Diff
Binary file not shown.
+196
-158
File diff suppressed because it is too large
Load Diff
Binary file not shown.
+196
-158
File diff suppressed because it is too large
Load Diff
+196
-158
File diff suppressed because it is too large
Load Diff
+196
-158
File diff suppressed because it is too large
Load Diff
+196
-158
File diff suppressed because it is too large
Load Diff
+196
-158
File diff suppressed because it is too large
Load Diff
+196
-158
File diff suppressed because it is too large
Load Diff
+196
-158
File diff suppressed because it is too large
Load Diff
+196
-158
File diff suppressed because it is too large
Load Diff
+196
-158
File diff suppressed because it is too large
Load Diff
+196
-158
File diff suppressed because it is too large
Load Diff
+196
-158
File diff suppressed because it is too large
Load Diff
@@ -10,37 +10,37 @@ MimeType=application/x-qet-project;application/x-qet-element;application/x-qet-t
|
||||
Categories=Graphics;Qt;VectorGraphics;Science;Electricity;Engineering;
|
||||
Keywords=Graphics;Science;Electricity;Engineering;
|
||||
Comment=Edit electrical diagrams.
|
||||
Comment[de]=Elektroschaltpläne erstellen und bearbeiten.
|
||||
Comment[fr]=Éditer des schémas électriques.
|
||||
Comment[ar]=تحرير مخططات كهربائية
|
||||
Comment[es]=Editar esquemas eléctricos
|
||||
Comment[ru]=Создание и редактирование электрических схем.
|
||||
Comment[ca]=Editar esquemes elèctrics.
|
||||
Comment[pt]=Criar esquemas eléctricos.
|
||||
Comment[cs]=Editor výkresů elektrických obvodů
|
||||
Comment[pl]=Edycja schematów elektrycznych
|
||||
Comment[it]=Disegnare schemi elettrici
|
||||
Comment[hr]=Uredi elektro sheme
|
||||
Comment[el]=Επεξεργασία ηλεκτρικών διαγραμμάτων
|
||||
Comment[nl]=Bewerken bedradingsdiagrammen.
|
||||
Comment[be]=Bewerken elektrisch schema.
|
||||
Comment[ca]=Editar esquemes elèctrics.
|
||||
Comment[cs]=Editor výkresů elektrických obvodů
|
||||
Comment[da]=Rediger elektriske diagrammer.
|
||||
Comment[de]=Elektroschaltpläne erstellen und bearbeiten.
|
||||
Comment[el]=Επεξεργασία ηλεκτρικών διαγραμμάτων
|
||||
Comment[es]=Editar esquemas eléctricos
|
||||
Comment[fr]=Éditer des schémas électriques.
|
||||
Comment[hr]=Uredi elektro sheme
|
||||
Comment[it]=Disegnare schemi elettrici
|
||||
Comment[ja]=電気回路図の編集。
|
||||
Comment[nl]=Bewerken bedradingsdiagrammen.
|
||||
Comment[pl]=Edycja schematów elektrycznych
|
||||
Comment[pt]=Criar esquemas eléctricos.
|
||||
Comment[ru]=Создание и редактирование электрических схем.
|
||||
Comment[sk]=Úprava elektrických schém.
|
||||
GenericName=Electrical diagram editor
|
||||
GenericName[de]=Schaltplaneditor
|
||||
GenericName[fr]=Éditeur de schémas électriques
|
||||
GenericName[ar]=مُحرّر مخططات كهربائية
|
||||
GenericName[es]=Editor de esquemas eléctricos
|
||||
GenericName[ru]=Редактор электрических схем
|
||||
GenericName[pt]=Editor de esquemas eléctricos.
|
||||
GenericName[cs]=Editor výkresů elektrických obvodů
|
||||
GenericName[pl]=Edytor schematów elektrycznych
|
||||
GenericName[it]=Programma per disegnare schemi elettrici
|
||||
GenericName[hr]=Editor elektro sheme
|
||||
GenericName[el]=Επεξεργαστής ηλεκτρικών διαγραμμάτων
|
||||
GenericName[nl]=Elektrische schema editor
|
||||
GenericName[be]=Elektrische schema editor
|
||||
GenericName[cs]=Editor výkresů elektrických obvodů
|
||||
GenericName[da]=Elektrisk diagram redigering
|
||||
GenericName[de]=Schaltplaneditor
|
||||
GenericName[el]=Επεξεργαστής ηλεκτρικών διαγραμμάτων
|
||||
GenericName[es]=Editor de esquemas eléctricos
|
||||
GenericName[fr]=Éditeur de schémas électriques
|
||||
GenericName[hr]=Editor elektro sheme
|
||||
GenericName[it]=Programma per disegnare schemi elettrici
|
||||
GenericName[ja]=電気回路図エディタ
|
||||
GenericName[nl]=Elektrische schema editor
|
||||
GenericName[pl]=Edytor schematów elektrycznych
|
||||
GenericName[pt]=Editor de esquemas eléctricos.
|
||||
GenericName[ru]=Редактор электрических схем
|
||||
GenericName[sk]=Editor elektrických schém
|
||||
|
||||
@@ -26,8 +26,11 @@
|
||||
#include "xmlprojectelementcollectionitem.h"
|
||||
|
||||
#include <QFutureWatcher>
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
||||
#include <QtConcurrentMap>
|
||||
|
||||
#else
|
||||
#include <QtConcurrentRun>
|
||||
#endif
|
||||
|
||||
/**
|
||||
@brief ElementsCollectionModel::ElementsCollectionModel
|
||||
@@ -293,9 +296,15 @@ void ElementsCollectionModel::loadCollections(bool common_collection,
|
||||
&QFutureWatcher<void>::finished,
|
||||
watcher,
|
||||
&QFutureWatcher<void>::deleteLater);
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
||||
m_future = QtConcurrent::map(m_items_list_to_setUp, setUpData);
|
||||
|
||||
#else
|
||||
# if TODO_LIST
|
||||
# pragma message("@TODO remove code for QT 6 or later")
|
||||
# endif
|
||||
qDebug() << "Help code for QT 6 or later"
|
||||
<< "QtConcurrent::run its backwards now...function, object, args";
|
||||
#endif
|
||||
watcher->setFuture(m_future);
|
||||
}
|
||||
|
||||
|
||||
@@ -765,7 +765,7 @@ void ElementsCollectionWidget::search()
|
||||
}
|
||||
|
||||
//start the search when text have at least 3 letters.
|
||||
if (text.length() < 3) {
|
||||
if (text.count() < 3) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -805,15 +805,15 @@ bool ElementsLocation::setXml(const QDomDocument &xml_document) const
|
||||
qDebug() << "Help code for QT 6 or later";
|
||||
|
||||
QString path_ = collectionPath(false);
|
||||
QRegularExpression rx(QRegularExpression::anchoredPattern("(.*)/(.*\\.elmt)"));
|
||||
QRegularExpressionMatch match = rx.match(path_);
|
||||
if (match.hasMatch())
|
||||
QRegularExpression rx("^(.*)/(.*\\.elmt)$");
|
||||
|
||||
if (rx.exactMatch(path_))
|
||||
{
|
||||
return project()
|
||||
->embeddedElementCollection()
|
||||
->addElementDefinition(
|
||||
match.captured(1),
|
||||
match.captured(2),
|
||||
rx.cap(1),
|
||||
rx.cap(2),
|
||||
xml_document.documentElement());
|
||||
}
|
||||
else
|
||||
|
||||
@@ -46,125 +46,64 @@ XmlElementCollection::XmlElementCollection(QETProject *project) :
|
||||
collection.appendChild(import);
|
||||
|
||||
NamesList names;
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
||||
|
||||
const QChar russian_data[24] = {
|
||||
0x0418, 0x043C, 0x043F, 0x043E, 0x0440, 0x0442, 0x0438, 0x0440,
|
||||
0x043E, 0x0432, 0x0430, 0x043D, 0x043D, 0x044B, 0x0435, 0x0020,
|
||||
0x044D, 0x043B, 0x0435, 0x043C, 0x0435, 0x043D, 0x0442, 0x044B};
|
||||
const QChar chinese_data[4] ={
|
||||
QChar(0x5BFC), QChar(0x5165), QChar(0x5143), QChar(0x4EF6)};
|
||||
const QChar greek_data[18] = {
|
||||
0x0395,
|
||||
0x03b9,
|
||||
0x03c3,
|
||||
0x03b7,
|
||||
0x03b3,
|
||||
0x03bc,
|
||||
0x03ad,
|
||||
0x03bd,
|
||||
0x03b1,
|
||||
0x0020,
|
||||
0x03c3,
|
||||
0x03c4,
|
||||
0x03bf,
|
||||
0x03b9,
|
||||
0x03c7,
|
||||
0x03b5,
|
||||
0x03af,
|
||||
0x03b1};
|
||||
const QChar turkish_data[12] = {
|
||||
0x0130,
|
||||
0x0074,
|
||||
0x0068,
|
||||
0x0061,
|
||||
0x006C,
|
||||
0x0020,
|
||||
0x00F6,
|
||||
0x011F,
|
||||
0x0065,
|
||||
0x006C,
|
||||
0x0065,
|
||||
0x0072};
|
||||
const QChar ukrainian_data[20] = {
|
||||
0x0406,
|
||||
0x043c,
|
||||
0x043f,
|
||||
0x043e,
|
||||
0x0440,
|
||||
0x0442,
|
||||
0x043e,
|
||||
0x0432,
|
||||
0x0430,
|
||||
0x043d,
|
||||
0x0456,
|
||||
0x0020,
|
||||
0x0435,
|
||||
0x043b,
|
||||
0x0435,
|
||||
0x043c,
|
||||
0x0435,
|
||||
0x043d,
|
||||
0x0442,
|
||||
0x0438};
|
||||
QChar(0x0395), QChar(0x03b9), QChar(0x03c3), QChar(0x03b7),
|
||||
QChar(0x03b3), QChar(0x03bc), QChar(0x03ad), QChar(0x03bd),
|
||||
QChar(0x03b1), QChar(0x0020), QChar(0x03c3), QChar(0x03c4),
|
||||
QChar(0x03bf), QChar(0x03b9), QChar(0x03c7), QChar(0x03b5),
|
||||
QChar(0x03af), QChar(0x03b1)};
|
||||
const QChar japanese_data[10] = {
|
||||
0x30A4,
|
||||
0x30F3,
|
||||
0x30D0,
|
||||
0x30FC,
|
||||
0x30C8,
|
||||
0x3055,
|
||||
0x308C,
|
||||
0x305F,
|
||||
0x8981,
|
||||
0x7D20};
|
||||
|
||||
QChar(0x30A4), QChar(0x30F3), QChar(0x30D0), QChar(0x30FC),
|
||||
QChar(0x30C8), QChar(0x3055), QChar(0x308C), QChar(0x305F),
|
||||
QChar(0x8981), QChar(0x7D20)};
|
||||
const QChar russian_data[24] = {
|
||||
QChar(0x0418), QChar(0x043C), QChar(0x043F), QChar(0x043E),
|
||||
QChar(0x0440), QChar(0x0442), QChar(0x0438), QChar(0x0440),
|
||||
QChar(0x043E), QChar(0x0432), QChar(0x0430), QChar(0x043D),
|
||||
QChar(0x043D), QChar(0x044B), QChar(0x0435), QChar(0x0020),
|
||||
QChar(0x044D), QChar(0x043B), QChar(0x0435), QChar(0x043C),
|
||||
QChar(0x0435), QChar(0x043D), QChar(0x0442), QChar(0x044B)};
|
||||
const QChar turkish_data[12] = {
|
||||
QChar(0x0130), QChar(0x0074), QChar(0x0068), QChar(0x0061),
|
||||
QChar(0x006C), QChar(0x0020), QChar(0x00F6), QChar(0x011F),
|
||||
QChar(0x0065), QChar(0x006C), QChar(0x0065), QChar(0x0072)};
|
||||
const QChar ukrainian_data[20] = {
|
||||
QChar(0x0406), QChar(0x043c), QChar(0x043f), QChar(0x043e),
|
||||
QChar(0x0440), QChar(0x0442), QChar(0x043e), QChar(0x0432),
|
||||
QChar(0x0430), QChar(0x043d), QChar(0x0456), QChar(0x0020),
|
||||
QChar(0x0435), QChar(0x043b), QChar(0x0435), QChar(0x043c),
|
||||
QChar(0x0435), QChar(0x043d), QChar(0x0442), QChar(0x0438)};
|
||||
names.addName("ca", "Elements importats");
|
||||
names.addName("cs", "Zavedené prvky");
|
||||
names.addName("da", "Importerede elementer");
|
||||
names.addName("de", "Importierte elemente");
|
||||
names.addName("de", "Importierte Elemente");
|
||||
names.addName("el", QString(greek_data, 18));
|
||||
//names.addName("el", "Εισηγμένα στοιχεία);
|
||||
names.addName("en", "Imported elements");
|
||||
names.addName("es", "Elementos importados");
|
||||
names.addName("fr", "Éléments importés");
|
||||
names.addName("hr", "Uvezeni elementi");
|
||||
names.addName("it", "Elementi importati");
|
||||
names.addName("ja", QString(japanese_data, 10));
|
||||
names.addName("nl_BE", "Elementen geïmporteerd");
|
||||
//names.addName("ja", "インバートされた要素");
|
||||
names.addName("nl", "Elementen geïmporteerd");
|
||||
names.addName("nl_BE", "Elementen geïmporteerd");
|
||||
names.addName("pl", "Elementy importowane");
|
||||
names.addName("pt_BR", "elementos importados");
|
||||
names.addName("pt", "elementos importados");
|
||||
names.addName("pt", "Elementos importados");
|
||||
names.addName("pt_BR", "Elementos importados");
|
||||
names.addName("ro", "Elemente importate");
|
||||
names.addName("ru", QString(russian_data, 24));
|
||||
//names.addName("ru", "Импортированные элементы");
|
||||
names.addName("sl", "Uvoženi elementi");
|
||||
names.addName("sv", "Importerade element");
|
||||
names.addName("tr", QString(turkish_data, 12));
|
||||
//names.addName("tr", "İthal öğeler");
|
||||
names.addName("uk", QString(ukrainian_data, 20));
|
||||
#else
|
||||
# if TODO_LIST
|
||||
# pragma message("@TODO remove code for QT 6 or later")
|
||||
# endif
|
||||
qDebug() << "Help code for QT 6 or later";
|
||||
names.addName("ca", "Elements importats");
|
||||
names.addName("cs", "Zavedené prvky");
|
||||
names.addName("da", "Importerede elementer");
|
||||
names.addName("de", "Importierte elemente");
|
||||
names.addName("el", "Εισηγμένα στοιχεία");
|
||||
names.addName("en", "Imported elements");
|
||||
names.addName("es", "Elementos importados");
|
||||
names.addName("fr", "Éléments importés");
|
||||
names.addName("hr", "Uvezeni elementi");
|
||||
names.addName("it", "Elementi importati");
|
||||
names.addName("ja", "インバートされた要素");
|
||||
names.addName("nl_BE", "Elementen geïmporteerd");
|
||||
names.addName("nl", "Elementen geïmporteerd");
|
||||
names.addName("pl", "Elementy importowane");
|
||||
names.addName("pt_BR", "elementos importados");
|
||||
names.addName("pt", "elementos importados");
|
||||
names.addName("ro", "Elemente importate");
|
||||
names.addName("ru", "Импортированные элементы");
|
||||
names.addName("sl", "Uvoženi elementi");
|
||||
names.addName("tr", "İthal öğeler");
|
||||
names.addName("uk", "Імпортовані елементи");
|
||||
#endif
|
||||
//names.addName("uk", "Імпортовані елементи");
|
||||
names.addName("zh", QString(chinese_data, 4));
|
||||
//names.addName("zh", "导入元件");
|
||||
|
||||
import.appendChild(names.toXml(m_dom_document));
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
#include "terminalstripdrawer.h"
|
||||
#include <QPainter>
|
||||
#include <QHash>
|
||||
|
||||
namespace TerminalStripDrawer {
|
||||
|
||||
@@ -203,7 +202,7 @@ void TerminalStripDrawer::paint(QPainter *painter)
|
||||
painter->restore();
|
||||
|
||||
//Draw the bridges
|
||||
for (const auto &points_ : std::as_const(bridges_anchor_points))
|
||||
for (const auto &points_ : qAsConst(bridges_anchor_points))
|
||||
{
|
||||
painter->save();
|
||||
auto pen_{painter->pen()};
|
||||
|
||||
@@ -126,7 +126,7 @@ void RemoveTerminalFromStripCommand::redo()
|
||||
if (m_strip)
|
||||
{
|
||||
QVector<QSharedPointer<RealTerminal>> real_t;
|
||||
for (const auto &real_t_vector : std::as_const(m_terminals)) {
|
||||
for (const auto &real_t_vector : qAsConst(m_terminals)) {
|
||||
real_t.append(real_t_vector);
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ void UnGroupTerminalsCommand::undo()
|
||||
m_terminal_strip->groupTerminals(key, m_physical_real_H.value(key));
|
||||
}
|
||||
//Second, set level.
|
||||
for (const auto &pair : std::as_const(m_real_t_level)) {
|
||||
for (const auto &pair : qAsConst(m_real_t_level)) {
|
||||
m_terminal_strip->setLevel(pair.first, pair.second);
|
||||
}
|
||||
}
|
||||
@@ -78,7 +78,7 @@ void UnGroupTerminalsCommand::redo()
|
||||
{
|
||||
if (m_terminal_strip)
|
||||
{
|
||||
for (const auto &value : std::as_const(m_physical_real_H)) {
|
||||
for (const auto &value : qAsConst(m_physical_real_H)) {
|
||||
m_terminal_strip->unGroupTerminals(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ bool PhysicalTerminal::setLevelOf(const QSharedPointer<RealTerminal> &terminal,
|
||||
if (i >= 0)
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,14,0)
|
||||
m_real_terminal.swapItemsAt(i, std::min((qsizetype)level, m_real_terminal.size()-1));
|
||||
m_real_terminal.swapItemsAt(i, std::min(level, 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]);
|
||||
|
||||
@@ -466,7 +466,7 @@ QSharedPointer<RealTerminal> TerminalStrip::realTerminalForUuid(const QUuid &uui
|
||||
QVector<QSharedPointer<RealTerminal>> TerminalStrip::realTerminals() const
|
||||
{
|
||||
QVector<QSharedPointer<RealTerminal>> vector_;
|
||||
for (const auto &phy : std::as_const(m_physical_terminals)) {
|
||||
for (const auto &phy : qAsConst(m_physical_terminals)) {
|
||||
vector_.append(phy->realTerminals());
|
||||
}
|
||||
return vector_;
|
||||
@@ -639,7 +639,7 @@ bool TerminalStrip::isBridgeable(const QVector<QSharedPointer<RealTerminal>> &re
|
||||
// Get the physical terminal and pos
|
||||
auto first_physical_terminal = first_real_terminal->physicalTerminal();
|
||||
QVector<shared_physical_terminal> physical_vector{first_physical_terminal};
|
||||
QVector<qsizetype> pos_vector{m_physical_terminals.indexOf(first_physical_terminal)};
|
||||
QVector<int> pos_vector{m_physical_terminals.indexOf(first_physical_terminal)};
|
||||
|
||||
auto bridge_ = isBridged(first_real_terminal);
|
||||
//bool to know at the end of this function if at least one terminal is not bridged
|
||||
@@ -856,7 +856,7 @@ QSharedPointer<TerminalStripBridge> TerminalStrip::isBridged(const QSharedPointe
|
||||
{
|
||||
if (real_terminal)
|
||||
{
|
||||
for (const auto &bridge_ : std::as_const(m_bridge)) {
|
||||
for (const auto &bridge_ : qAsConst(m_bridge)) {
|
||||
if (bridge_->realTerminals().contains(real_terminal))
|
||||
return bridge_;
|
||||
}
|
||||
@@ -983,7 +983,7 @@ QDomElement TerminalStrip::toXml(QDomDocument &parent_document)
|
||||
}
|
||||
root_elmt.appendChild(xml_layout);
|
||||
|
||||
for (const auto &bridge_ : std::as_const(m_bridge)) {
|
||||
for (const auto &bridge_ : qAsConst(m_bridge)) {
|
||||
root_elmt.appendChild(bridge_->toXml(parent_document));
|
||||
}
|
||||
|
||||
@@ -1024,7 +1024,7 @@ bool TerminalStrip::fromXml(QDomElement &xml_element)
|
||||
for (auto &xml_real : QETXML::findInDomElement(xml_physical, RealTerminal::xmlTagName()))
|
||||
{
|
||||
const auto uuid_ = QUuid(xml_real.attribute(QStringLiteral("element_uuid")));
|
||||
for (auto terminal_elmt : std::as_const(free_terminals))
|
||||
for (auto terminal_elmt : qAsConst(free_terminals))
|
||||
{
|
||||
if (terminal_elmt->uuid() == uuid_)
|
||||
{
|
||||
|
||||
@@ -85,7 +85,7 @@ QDomElement TerminalStripBridge::toXml(QDomDocument &parent_document) const
|
||||
root_elmt.setAttribute(QStringLiteral("color"), m_color.name());
|
||||
|
||||
auto terminals_elmt = parent_document.createElement(QStringLiteral("real_terminals"));
|
||||
for (const auto &real_t : std::as_const(m_real_terminals))
|
||||
for (const auto &real_t : qAsConst(m_real_terminals))
|
||||
{
|
||||
if (real_t)
|
||||
{
|
||||
@@ -106,7 +106,7 @@ void TerminalStripBridge::fromXml(const QDomElement &dom_element)
|
||||
}
|
||||
|
||||
m_uuid = QUuid(dom_element.attribute(QStringLiteral("uuid"), m_uuid.toString()));
|
||||
m_color = QColor::fromString(dom_element.attribute(QStringLiteral("color")));
|
||||
m_color.setNamedColor(dom_element.attribute(QStringLiteral("color")));
|
||||
|
||||
const auto real_t_vector = QETXML::subChild(dom_element,
|
||||
QStringLiteral("real_terminals"),
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="1" colspan="2">
|
||||
<widget class="ColorComboBox" name="m_bridge_color_cb"/>
|
||||
<widget class="KColorCombo" name="m_bridge_color_cb"/>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
@@ -323,9 +323,9 @@
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>ColorComboBox</class>
|
||||
<class>KColorCombo</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>../../colorcombobox.h</header>
|
||||
<header>kcolorcombo.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
|
||||
@@ -535,7 +535,7 @@ modelRealTerminalData TerminalStripModel::dataAtRow(int row) const
|
||||
else
|
||||
{
|
||||
auto current_row = 0;
|
||||
for (const auto &physical_data : std::as_const(m_physical_data))
|
||||
for (const auto &physical_data : qAsConst(m_physical_data))
|
||||
{
|
||||
for (const auto &real_data : physical_data.real_data)
|
||||
{
|
||||
@@ -567,7 +567,7 @@ void TerminalStripModel::replaceDataAtRow(modelRealTerminalData data, int row)
|
||||
auto current_row = 0;
|
||||
auto current_physical = 0;
|
||||
|
||||
for (const auto &physical_data : std::as_const(m_physical_data))
|
||||
for (const auto &physical_data : qAsConst(m_physical_data))
|
||||
{
|
||||
auto current_real = 0;
|
||||
for (int i=0 ; i<physical_data.real_data.count() ; ++i)
|
||||
@@ -606,7 +606,7 @@ modelPhysicalTerminalData TerminalStripModel::physicalDataAtIndex(int index) con
|
||||
int current_phy = -1;
|
||||
bool match_ = false;
|
||||
|
||||
for (const auto &ptd_ : std::as_const(m_physical_data))
|
||||
for (const auto &ptd_ : qAsConst(m_physical_data))
|
||||
{
|
||||
current_checked_index += ptd_.real_data.size();
|
||||
++current_phy;
|
||||
@@ -637,9 +637,9 @@ modelRealTerminalData TerminalStripModel::realDataAtIndex(int index) const
|
||||
|
||||
int current_checked_index = -1;
|
||||
|
||||
for (const auto & ptd_ : std::as_const(m_physical_data))
|
||||
for (const auto & ptd_ : qAsConst(m_physical_data))
|
||||
{
|
||||
for (const auto & rtd_ : std::as_const(ptd_.real_data)) {
|
||||
for (const auto & rtd_ : qAsConst(ptd_.real_data)) {
|
||||
++current_checked_index;
|
||||
if (current_checked_index == index) {
|
||||
return rtd_;
|
||||
|
||||
@@ -29,12 +29,12 @@
|
||||
#include "modelTerminalData.h"
|
||||
|
||||
//Code to use QColor as key for QHash
|
||||
inline size_t qHash(const QColor &key, size_t seed) {
|
||||
inline uint qHash(const QColor &key, uint seed) {
|
||||
return qHash(key.name(), seed);
|
||||
}
|
||||
|
||||
//needed to use QPointer<Element> as key of QHash
|
||||
inline size_t qHash(const QPointer<Element> &key, size_t seed) {
|
||||
inline uint qHash(const QPointer<Element> &key, uint seed) {
|
||||
if (key)
|
||||
return qHash(key->uuid(), seed);
|
||||
else
|
||||
|
||||
@@ -60,7 +60,7 @@ void TerminalStripTreeDockWidget::reload()
|
||||
m_uuid_terminal_H.clear();
|
||||
m_uuid_strip_H.clear();
|
||||
|
||||
for (const auto &connection_ : std::as_const(m_strip_changed_connection)) {
|
||||
for (const auto &connection_ : qAsConst(m_strip_changed_connection)) {
|
||||
disconnect(connection_);
|
||||
}
|
||||
m_strip_changed_connection.clear();
|
||||
@@ -222,7 +222,7 @@ void TerminalStripTreeDockWidget::buildTree()
|
||||
return a->name() < b->name();
|
||||
});
|
||||
|
||||
for (const auto &ts : std::as_const(ts_vector)) {
|
||||
for (const auto &ts : qAsConst(ts_vector)) {
|
||||
addTerminalStrip(ts);
|
||||
}
|
||||
addFreeTerminal();
|
||||
@@ -324,7 +324,7 @@ void TerminalStripTreeDockWidget::addFreeTerminal()
|
||||
|
||||
auto free_terminal_item = ui->m_tree_view->topLevelItem(1);
|
||||
|
||||
for (const auto terminal : std::as_const(vector_))
|
||||
for (const auto terminal : qAsConst(vector_))
|
||||
{
|
||||
QUuid uuid_ = terminal->uuid();
|
||||
QStringList strl{terminal->actualLabel()};
|
||||
|
||||
@@ -57,9 +57,9 @@ bool NumerotationContext::addValue(const QString &type,
|
||||
const QVariant &value,
|
||||
const int increase,
|
||||
const int initialvalue) {
|
||||
if (!keyIsAcceptable(type) && !value.canConvert<QString>())
|
||||
if (!keyIsAcceptable(type) && !value.canConvert(QVariant::String))
|
||||
return false;
|
||||
if (keyIsNumber(type) && !value.canConvert<int>())
|
||||
if (keyIsNumber(type) && !value.canConvert(QVariant::Int))
|
||||
return false;
|
||||
|
||||
QString valuestr = value.toString();
|
||||
|
||||
@@ -55,8 +55,11 @@ BorderTitleBlock::BorderTitleBlock(QObject *parent) :
|
||||
m_titleblock_template_renderer = new TitleBlockTemplateRenderer(this);
|
||||
m_titleblock_template_renderer -> setTitleBlockTemplate(QETApp::defaultTitleBlockTemplate());
|
||||
|
||||
// disable the QPicture-based cache to avoid rendering errors and crashes
|
||||
// disable the QPicture-based cache from Qt 4.8 to avoid rendering errors and crashes
|
||||
#if QT_VERSION < QT_VERSION_CHECK(4, 8, 0) // ### Qt 6: remove
|
||||
#else
|
||||
m_titleblock_template_renderer -> setUseCache(false);
|
||||
#endif
|
||||
|
||||
// dimensions par defaut du schema
|
||||
importBorder(BorderProperties());
|
||||
@@ -236,8 +239,7 @@ void BorderTitleBlock::borderToXml(QDomElement &xml_elmt) {
|
||||
xml_elmt.setAttribute("displayrows", rowsAreDisplayed() ? "true" : "false");
|
||||
|
||||
// attribut datant de la version 0.1 - laisse pour retrocompatibilite
|
||||
// attribute from version 0.1 - leave for backwards-compatibility
|
||||
xml_elmt.setAttribute("height", QString("%1").arg(diagramHeight()));
|
||||
xml_elmt.setAttribute("height", QString("%1").arg(diagramHeight()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -947,7 +949,7 @@ QString BorderTitleBlock::incrementLetters(const QString &string) {
|
||||
last_digit = (char)(string[string.length()-1].unicode()) + 1;
|
||||
return(first_digits + QString(last_digit));
|
||||
} else {
|
||||
return(incrementLetters(first_digits) % "A");
|
||||
return(incrementLetters(first_digits) + "A");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
/*
|
||||
Copyright 2006-2025 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/>.
|
||||
*/
|
||||
#include "colorbutton.h"
|
||||
|
||||
#include <QColorDialog>
|
||||
#include <QPainter>
|
||||
|
||||
/**
|
||||
@brief ColorButton::ColorButton
|
||||
Simple constructor
|
||||
@param parent QObject parent of the ColorButton
|
||||
*/
|
||||
ColorButton::ColorButton(QWidget *parent) : QPushButton(parent)
|
||||
{
|
||||
connect(this, &QPushButton::clicked, this, &ColorButton::clicked);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Getter for current color
|
||||
@return The current selected color
|
||||
*/
|
||||
const QColor ColorButton::color()
|
||||
{
|
||||
return m_color;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Setter for current color
|
||||
*/
|
||||
void ColorButton::setColor(const QColor &color)
|
||||
{
|
||||
m_color = color;
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
@brief ColorButton::clicked
|
||||
Opens a color selection dialog and lets the user select a color.
|
||||
@param checked Not used
|
||||
*/
|
||||
void ColorButton::clicked(bool checked)
|
||||
{
|
||||
// Open color selection dialog
|
||||
auto new_color = QColorDialog::getColor(m_color, this, tr("Select color"), QColorDialog::DontUseNativeDialog);
|
||||
|
||||
// Validate user input
|
||||
if (new_color.isValid()) {
|
||||
m_color = new_color;
|
||||
emit changed(new_color);
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief ColorButton::paintEvent
|
||||
Paints a filled rectangle with the current selected color on the button surface.
|
||||
@param e Paint event context
|
||||
*/
|
||||
void ColorButton::paintEvent(QPaintEvent *e) {
|
||||
QPushButton::paintEvent(e);
|
||||
|
||||
// Padding for the color indicator
|
||||
const int padding_x = 5;
|
||||
const int padding_y = 5;
|
||||
|
||||
QPainter painter(this);
|
||||
|
||||
// Get dimensions of the button paint surface
|
||||
auto r_width = painter.device()->width();
|
||||
auto r_height = painter.device()->height();
|
||||
|
||||
// Paint a rectangle with a margin of 5
|
||||
auto color_indicator = QRect(padding_x, padding_y, r_width - padding_x * 2, r_height - padding_y * 2);
|
||||
painter.fillRect(color_indicator, m_color);
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
Copyright 2006-2025 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/>.
|
||||
*/
|
||||
#ifndef COLORBUTTON_H
|
||||
#define COLORBUTTON_H
|
||||
|
||||
#include <QColor>
|
||||
#include <QObject>
|
||||
#include <QPushButton>
|
||||
#include <Qt>
|
||||
|
||||
/**
|
||||
@brief The ColorButton class
|
||||
*/
|
||||
class ColorButton : public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ColorButton(QWidget * = nullptr);
|
||||
|
||||
const QColor color();
|
||||
void setColor(const QColor &);
|
||||
|
||||
public slots:
|
||||
void clicked(bool = false);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *) override;
|
||||
|
||||
signals:
|
||||
void changed(const QColor &);
|
||||
|
||||
private:
|
||||
/// @brief Current selected color
|
||||
QColor m_color = Qt::black;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
Copyright 2006-2025 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/>.
|
||||
*/
|
||||
#include "colorcombobox.h"
|
||||
|
||||
#include "colorcomboboxdelegate.h"
|
||||
|
||||
#include <QColorDialog>
|
||||
#include <QPainter>
|
||||
#include <QStylePainter>
|
||||
#include <Qt>
|
||||
|
||||
|
||||
/**
|
||||
@brief ColorComboBox::ColorComboBox
|
||||
Simple constructor
|
||||
@param parent QObject parent of the ColorComboBox
|
||||
*/
|
||||
ColorComboBox::ColorComboBox(QWidget *parent) : QComboBox(parent)
|
||||
{
|
||||
connect(this, &QComboBox::activated, this, &ColorComboBox::colorSelected);
|
||||
setItemDelegate(new ColorComboBoxDelegate());
|
||||
}
|
||||
|
||||
/**
|
||||
@brief ColorComboBox::setColors
|
||||
Sets the colors of the combo box. An item at the top will be added to allow selection
|
||||
of a custom color.
|
||||
@param colors Vector of colors to add to the combo box
|
||||
*/
|
||||
void ColorComboBox::setColors(const QVector<QColor> &colors)
|
||||
{
|
||||
addItem(tr("[Custom color...]"), QColor(Qt::black));
|
||||
for(auto &color : colors) {
|
||||
addItem(color.name(), color);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief ColorComboBox::colorSelected
|
||||
Opens a color selection dialog and lets the user select a color.
|
||||
@param checked Not used
|
||||
*/
|
||||
void ColorComboBox::colorSelected(int index)
|
||||
{
|
||||
if (index == 0) {
|
||||
// Open color selection dialog if custom color is selected
|
||||
auto new_color = QColorDialog::getColor(itemData(index).value<QColor>(), this, tr("Select color"), QColorDialog::DontUseNativeDialog);
|
||||
|
||||
// Validate and emit user input color
|
||||
if (new_color.isValid()) {
|
||||
setItemData(index, new_color);
|
||||
emit activated(new_color);
|
||||
}
|
||||
} else {
|
||||
// Emit color from selected combo box row
|
||||
emit activated(itemData(index).value<QColor>());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief ColorComboBox::paintEvent
|
||||
Paints a filled rectangle with the current selected color on the combo box surface.
|
||||
@param e Paint event context
|
||||
*/
|
||||
void ColorComboBox::paintEvent(QPaintEvent *e) {
|
||||
// Padding for the color indicator
|
||||
const int padding_x = 5;
|
||||
const int padding_y = 5;
|
||||
|
||||
// Create painter and draw a vanilla combobox
|
||||
QStylePainter painter(this);
|
||||
QStyleOptionComboBox opt;
|
||||
initStyleOption(&opt);
|
||||
painter.drawComplexControl(QStyle::CC_ComboBox, opt);
|
||||
|
||||
// Get dimensions of the combo box paint surface
|
||||
auto r_width = painter.device()->width();
|
||||
auto r_height = painter.device()->height();
|
||||
|
||||
// Paint a rectangle with a margin
|
||||
auto color_indicator = QRect(padding_x, padding_y, r_width - padding_x * 2, r_height - padding_y * 2);
|
||||
painter.fillRect(color_indicator, itemData(currentIndex()).value<QColor>());
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
Copyright 2006-2025 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/>.
|
||||
*/
|
||||
#ifndef COLORCOMBOBOX_H
|
||||
#define COLORCOMBOBOX_H
|
||||
|
||||
#include <QColor>
|
||||
#include <QObject>
|
||||
#include <QComboBox>
|
||||
#include <QVector>
|
||||
#include <Qt>
|
||||
|
||||
/**
|
||||
@brief The ColorComboBox class
|
||||
*/
|
||||
class ColorComboBox : public QComboBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ColorComboBox(QWidget * = nullptr);
|
||||
|
||||
void setColors(const QVector<QColor> &);
|
||||
|
||||
public slots:
|
||||
void colorSelected(int);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *) override;
|
||||
|
||||
signals:
|
||||
void activated(const QColor &);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
Copyright 2006-2025 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/>.
|
||||
*/
|
||||
#include "colorcomboboxdelegate.h"
|
||||
|
||||
#include <QColor>
|
||||
#include <QPainter>
|
||||
#include <QPalette>
|
||||
#include <QtDebug>
|
||||
|
||||
/**
|
||||
@brief ColorComboBoxDelegate::paint
|
||||
Paints a filled rectangle on the drop down item with the items color.
|
||||
@param painter Painter context
|
||||
@param option Style options
|
||||
@param index Index of the item to paint
|
||||
|
||||
*/
|
||||
void ColorComboBoxDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
// Padding for the color indicator
|
||||
const int padding_x = 5;
|
||||
const int padding_y = 2;
|
||||
|
||||
painter->save();
|
||||
|
||||
if (index.row() > 0)
|
||||
{
|
||||
auto rect = option.rect;
|
||||
|
||||
// Draw mouseover background
|
||||
if (option.state & QStyle::State_MouseOver)
|
||||
{
|
||||
auto pal = option.widget->palette();
|
||||
painter->fillRect(rect, pal.color(QPalette::Highlight));
|
||||
}
|
||||
|
||||
// Draw color indicator rectangle
|
||||
auto color = qvariant_cast<QColor>(index.data());
|
||||
rect.adjust(padding_x, padding_y, -padding_x, -padding_y);
|
||||
painter->fillRect(rect, color);
|
||||
} else {
|
||||
// Draw a normal drop down item for custom color
|
||||
QStyledItemDelegate::paint(painter, option, index);
|
||||
}
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
Copyright 2006-2025 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/>.
|
||||
*/
|
||||
#ifndef COLORCOMBOBOXDELEGATE_H
|
||||
#define COLORCOMBOBOXDELEGATE_H
|
||||
|
||||
#include <QStyledItemDelegate>
|
||||
|
||||
/**
|
||||
@brief The ColorComboBoxDelegate class
|
||||
Handles drawing of items in the drop down list of ColorComboBox.
|
||||
*/
|
||||
class ColorComboBoxDelegate : public QStyledItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
void paint(QPainter *, const QStyleOptionViewItem &, const QModelIndex &) const override;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -72,7 +72,14 @@ bool ConductorNumExport::toCsv()
|
||||
if (file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
{
|
||||
QTextStream stream(&file);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) // ### Qt 6: remove
|
||||
stream << wiresNum() << endl;
|
||||
#else
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove code for QT 5.15 or later")
|
||||
#endif
|
||||
stream << wiresNum() << &Qt::endl(stream);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
|
||||
@@ -376,31 +376,31 @@ void ConductorProperties::fromXml(QDomElement &e)
|
||||
*/
|
||||
void ConductorProperties::toSettings(QSettings &settings, const QString &prefix) const
|
||||
{
|
||||
settings.setValue(prefix % "color", color.name());
|
||||
settings.setValue(prefix % "bicolor", m_bicolor);
|
||||
settings.setValue(prefix % "color2", m_color_2.name());
|
||||
settings.setValue(prefix % "dash-size", m_dash_size);
|
||||
settings.setValue(prefix % "style", writeStyle());
|
||||
settings.setValue(prefix % "type", typeToString(type));
|
||||
settings.setValue(prefix % "text", text);
|
||||
settings.setValue(prefix % "text_color", text_color.name());
|
||||
settings.setValue(prefix % "formula", m_formula);
|
||||
settings.setValue(prefix % "cable", m_cable);
|
||||
settings.setValue(prefix % "bus", m_bus);
|
||||
settings.setValue(prefix % "function", m_function);
|
||||
settings.setValue(prefix % "tension_protocol", m_tension_protocol);
|
||||
settings.setValue(prefix % "conductor_color", m_wire_color);
|
||||
settings.setValue(prefix % "conductor_section", m_wire_section);
|
||||
settings.setValue(prefix % "textsize", QString::number(text_size));
|
||||
settings.setValue(prefix % "size", QString::number(cond_size));
|
||||
settings.setValue(prefix % "displaytext", m_show_text);
|
||||
settings.setValue(prefix % "onetextperfolio", m_one_text_per_folio);
|
||||
settings.setValue(prefix % "vertirotatetext", QString::number(verti_rotate_text));
|
||||
settings.setValue(prefix % "horizrotatetext", QString::number(horiz_rotate_text));
|
||||
settings.setValue(prefix + "color", color.name());
|
||||
settings.setValue(prefix + "bicolor", m_bicolor);
|
||||
settings.setValue(prefix + "color2", m_color_2.name());
|
||||
settings.setValue(prefix + "dash-size", m_dash_size);
|
||||
settings.setValue(prefix + "style", writeStyle());
|
||||
settings.setValue(prefix + "type", typeToString(type));
|
||||
settings.setValue(prefix + "text", text);
|
||||
settings.setValue(prefix + "text_color", text_color.name());
|
||||
settings.setValue(prefix + "formula", m_formula);
|
||||
settings.setValue(prefix + "cable", m_cable);
|
||||
settings.setValue(prefix + "bus", m_bus);
|
||||
settings.setValue(prefix + "function", m_function);
|
||||
settings.setValue(prefix + "tension_protocol", m_tension_protocol);
|
||||
settings.setValue(prefix + "conductor_color", m_wire_color);
|
||||
settings.setValue(prefix + "conductor_section", m_wire_section);
|
||||
settings.setValue(prefix + "textsize", QString::number(text_size));
|
||||
settings.setValue(prefix + "size", QString::number(cond_size));
|
||||
settings.setValue(prefix + "displaytext", m_show_text);
|
||||
settings.setValue(prefix + "onetextperfolio", m_one_text_per_folio);
|
||||
settings.setValue(prefix + "vertirotatetext", QString::number(verti_rotate_text));
|
||||
settings.setValue(prefix + "horizrotatetext", QString::number(horiz_rotate_text));
|
||||
|
||||
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
||||
settings.setValue(prefix % "horizontal-alignment", me.valueToKey(m_horizontal_alignment));
|
||||
settings.setValue(prefix % "vertical-alignment", me.valueToKey(m_vertical_alignment));
|
||||
settings.setValue(prefix + "horizontal-alignment", me.valueToKey(m_horizontal_alignment));
|
||||
settings.setValue(prefix + "vertical-alignment", me.valueToKey(m_vertical_alignment));
|
||||
|
||||
singleLineProperties.toSettings(settings, prefix);
|
||||
}
|
||||
@@ -417,36 +417,36 @@ void ConductorProperties::fromSettings(QSettings &settings, const QString &prefi
|
||||
QColor settings_color_2 = QColor(settings.value(prefix + "color2").toString());
|
||||
m_color_2 = (settings_color_2.isValid()? settings_color_2 : QColor(Qt::black));
|
||||
|
||||
m_bicolor = settings.value(prefix % "bicolor", false).toBool();
|
||||
m_dash_size = settings.value(prefix % "dash-size", 1).toInt();
|
||||
m_bicolor = settings.value(prefix + "bicolor", false).toBool();
|
||||
m_dash_size = settings.value(prefix + "dash-size", 1).toInt();
|
||||
|
||||
QString setting_type = settings.value(prefix % "type", typeToString(Multi)).toString();
|
||||
QString setting_type = settings.value(prefix + "type", typeToString(Multi)).toString();
|
||||
type = (setting_type == typeToString(Single)? Single : Multi);
|
||||
|
||||
singleLineProperties.fromSettings(settings, prefix);
|
||||
|
||||
text = settings.value(prefix % "text", "_").toString();
|
||||
QColor settings_text_color = QColor(settings.value(prefix % "text_color").toString());
|
||||
text = settings.value(prefix + "text", "_").toString();
|
||||
QColor settings_text_color = QColor(settings.value(prefix + "text_color").toString());
|
||||
text_color = (settings_text_color.isValid()? settings_text_color : QColor(Qt::black));
|
||||
m_formula = settings.value(prefix % "formula", "").toString();
|
||||
m_cable = settings.value(prefix % "cable", "").toString();
|
||||
m_bus = settings.value(prefix % "bus", "").toString();
|
||||
m_function = settings.value(prefix % "function", "").toString();
|
||||
m_tension_protocol = settings.value(prefix % "tension_protocol", "").toString();
|
||||
m_wire_color = settings.value(prefix % "conductor_color", "").toString();
|
||||
m_wire_section = settings.value(prefix % "conductor_section", "").toString();
|
||||
text_size = settings.value(prefix % "textsize", "7").toInt();
|
||||
cond_size = settings.value(prefix % "size", "1").toInt();
|
||||
m_show_text = settings.value(prefix % "displaytext", true).toBool();
|
||||
m_one_text_per_folio = settings.value(prefix % "onetextperfolio", false).toBool();
|
||||
verti_rotate_text = settings.value((prefix % "vertirotatetext"), "270").toDouble();
|
||||
horiz_rotate_text = settings.value((prefix % "horizrotatetext"), "0").toDouble();
|
||||
m_formula = settings.value(prefix + "formula", "").toString();
|
||||
m_cable = settings.value(prefix + "cable", "").toString();
|
||||
m_bus = settings.value(prefix + "bus", "").toString();
|
||||
m_function = settings.value(prefix + "function", "").toString();
|
||||
m_tension_protocol = settings.value(prefix + "tension_protocol", "").toString();
|
||||
m_wire_color = settings.value(prefix + "conductor_color", "").toString();
|
||||
m_wire_section = settings.value(prefix + "conductor_section", "").toString();
|
||||
text_size = settings.value(prefix + "textsize", "7").toInt();
|
||||
cond_size = settings.value(prefix + "size", "1").toInt();
|
||||
m_show_text = settings.value(prefix + "displaytext", true).toBool();
|
||||
m_one_text_per_folio = settings.value(prefix + "onetextperfolio", false).toBool();
|
||||
verti_rotate_text = settings.value((prefix + "vertirotatetext"), "270").toDouble();
|
||||
horiz_rotate_text = settings.value((prefix + "horizrotatetext"), "0").toDouble();
|
||||
|
||||
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
||||
m_horizontal_alignment = Qt::Alignment(me.keyToValue(settings.value(prefix % "horizontal-alignment", "AlignBottom").toString().toStdString().data()));
|
||||
m_vertical_alignment = Qt::Alignment(me.keyToValue(settings.value(prefix % "vertical-alignment", "AlignRight").toString().toStdString().data()));
|
||||
m_horizontal_alignment = Qt::Alignment(me.keyToValue(settings.value(prefix + "horizontal-alignment", "AlignBottom").toString().toStdString().data()));
|
||||
m_vertical_alignment = Qt::Alignment(me.keyToValue(settings.value(prefix + "vertical-alignment", "AlignRight").toString().toStdString().data()));
|
||||
|
||||
readStyle(settings.value(prefix % "style").toString());
|
||||
readStyle(settings.value(prefix + "style").toString());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -811,7 +811,14 @@ void ConductorProperties::readStyle(const QString &style_string) {
|
||||
if (style_string.isEmpty()) return;
|
||||
|
||||
// recupere la liste des couples style / valeur
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
|
||||
QStringList styles = style_string.split(";", QString::SkipEmptyParts);
|
||||
#else
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove code QString::SkipEmptyParts for QT 5.14 or later")
|
||||
#endif
|
||||
QStringList styles = style_string.split(";", Qt::SkipEmptyParts);
|
||||
#endif
|
||||
|
||||
QRegularExpression Rx("^(?<name>[a-z-]+): (?<value>[a-z-]+)$");
|
||||
if (!Rx.isValid())
|
||||
@@ -889,10 +896,10 @@ int SingleLineProperties::operator!=(const SingleLineProperties &other) const
|
||||
void SingleLineProperties::toSettings(QSettings &settings,
|
||||
const QString &prefix) const
|
||||
{
|
||||
settings.setValue(prefix % "hasGround", hasGround);
|
||||
settings.setValue(prefix % "hasNeutral", hasNeutral);
|
||||
settings.setValue(prefix % "phases", phases);
|
||||
settings.setValue(prefix % "pen", is_pen);
|
||||
settings.setValue(prefix + "hasGround", hasGround);
|
||||
settings.setValue(prefix + "hasNeutral", hasNeutral);
|
||||
settings.setValue(prefix + "phases", phases);
|
||||
settings.setValue(prefix + "pen", is_pen);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -901,8 +908,8 @@ void SingleLineProperties::toSettings(QSettings &settings,
|
||||
*/
|
||||
void SingleLineProperties::fromSettings(QSettings &settings,
|
||||
const QString &prefix) {
|
||||
hasGround = settings.value(prefix % "hasGround", true).toBool();
|
||||
hasNeutral = settings.value(prefix % "hasNeutral", true).toBool();
|
||||
phases = settings.value(prefix % "phases", 1).toInt();
|
||||
is_pen = settings.value(prefix % "pen", false).toBool();
|
||||
hasGround = settings.value(prefix + "hasGround", true).toBool();
|
||||
hasNeutral = settings.value(prefix + "hasNeutral", true).toBool();
|
||||
phases = settings.value(prefix + "phases", 1).toInt();
|
||||
is_pen = settings.value(prefix + "pen", false).toBool();
|
||||
}
|
||||
|
||||
@@ -253,12 +253,10 @@ bool projectDataBase::createDataBase()
|
||||
return false;
|
||||
}
|
||||
|
||||
QSqlQuery *temp_query = new QSqlQuery(m_data_base);
|
||||
temp_query->exec("PRAGMA temp_store = MEMORY");
|
||||
temp_query->exec("PRAGMA journal_mode = MEMORY");
|
||||
temp_query->exec("PRAGMA synchronous = OFF");
|
||||
delete temp_query;
|
||||
|
||||
m_data_base.exec("PRAGMA temp_store = MEMORY");
|
||||
m_data_base.exec("PRAGMA journal_mode = MEMORY");
|
||||
m_data_base.exec("PRAGMA synchronous = OFF");
|
||||
|
||||
QSqlQuery query_(m_data_base);
|
||||
bool first_ = true;
|
||||
|
||||
|
||||
+47
-17
@@ -151,7 +151,7 @@ Diagram::~Diagram()
|
||||
continue;
|
||||
deletable_items.append(qgi);
|
||||
}
|
||||
for (const auto &item : std::as_const(deletable_items))
|
||||
for (const auto &item : qAsConst(deletable_items))
|
||||
{
|
||||
removeItem(item);
|
||||
delete item;
|
||||
@@ -186,7 +186,7 @@ void Diagram::drawBackground(QPainter *p, const QRectF &r) {
|
||||
p -> drawRect(r);
|
||||
|
||||
if (draw_grid_) {
|
||||
/* Draw the point of the grid
|
||||
/* Draw the points of the grid
|
||||
* if background color is black,
|
||||
* then grid spots shall be white,
|
||||
* else they shall be black in color.
|
||||
@@ -227,7 +227,28 @@ void Diagram::drawBackground(QPainter *p, const QRectF &r) {
|
||||
points << QPoint(gx, gy);
|
||||
}
|
||||
}
|
||||
p -> drawPoints(points);
|
||||
|
||||
qreal zoom_factor = p->transform().m11();
|
||||
int minWidthPen = settings.value(QStringLiteral("diagrameditor/grid_pointsize_min"), 1).toInt();
|
||||
int maxWidthPen = settings.value(QStringLiteral("diagrameditor/grid_pointsize_max"), 1).toInt();
|
||||
pen.setWidth(minWidthPen);
|
||||
if (minWidthPen != maxWidthPen) {
|
||||
qreal stepPen = (maxWidthPen - minWidthPen) / (qreal)maxWidthPen;
|
||||
qreal stepZoom = (5.0 - 1.0) / maxWidthPen;
|
||||
for (int n=0; n<maxWidthPen; n++) {
|
||||
if ((zoom_factor > (1.0 + n * stepZoom)) && (zoom_factor <= (1.0 + (n+1) * stepZoom))) {
|
||||
int widthPen = minWidthPen + qRound(n * stepPen);
|
||||
pen.setWidth(widthPen);
|
||||
}
|
||||
}
|
||||
if (zoom_factor <= 1.0)
|
||||
pen.setWidth(minWidthPen);
|
||||
else if (zoom_factor > (1.0 + stepZoom * maxWidthPen))
|
||||
pen.setWidth(maxWidthPen);
|
||||
}
|
||||
p -> setPen(pen);
|
||||
if (zoom_factor > 0.5) // no grid below ... !
|
||||
p -> drawPoints(points);
|
||||
}
|
||||
|
||||
if (use_border_) border_and_titleblock.draw(p);
|
||||
@@ -1139,8 +1160,8 @@ Terminal* findTerminal(int conductor_index,
|
||||
assert(conductor_index == 1 || conductor_index == 2);
|
||||
|
||||
auto str_index = QString::number(conductor_index);
|
||||
QString element_index = QStringLiteral("element") % str_index;
|
||||
QString terminal_index = QStringLiteral("terminal") % str_index;
|
||||
QString element_index = QStringLiteral("element") + str_index;
|
||||
QString terminal_index = QStringLiteral("terminal") + str_index;
|
||||
|
||||
if (f.hasAttribute(element_index)) {
|
||||
QUuid element_uuid = QUuid(f.attribute(element_index));
|
||||
@@ -1453,13 +1474,13 @@ bool Diagram::fromXml(QDomElement &document,
|
||||
if (position != QPointF())
|
||||
{
|
||||
QVector <QGraphicsItem *> added_items;
|
||||
for (auto element : std::as_const(added_elements )) added_items << element;
|
||||
for (auto cond : std::as_const(added_conductors )) added_items << cond;
|
||||
for (auto shape : std::as_const(added_shapes )) added_items << shape;
|
||||
for (auto text : std::as_const(added_texts )) added_items << text;
|
||||
for (auto image : std::as_const(added_images )) added_items << image;
|
||||
for (auto table : std::as_const(added_tables )) added_items << table;
|
||||
for (const auto &strip : std::as_const(added_strips)) added_items << strip;
|
||||
for (auto element : qAsConst(added_elements )) added_items << element;
|
||||
for (auto cond : qAsConst(added_conductors )) added_items << cond;
|
||||
for (auto shape : qAsConst(added_shapes )) added_items << shape;
|
||||
for (auto text : qAsConst(added_texts )) added_items << text;
|
||||
for (auto image : qAsConst(added_images )) added_items << image;
|
||||
for (auto table : qAsConst(added_tables )) added_items << table;
|
||||
for (const auto &strip : qAsConst(added_strips)) added_items << strip;
|
||||
|
||||
//Get the top left corner of the rectangle that contain all added items
|
||||
QRectF items_rect;
|
||||
@@ -1483,6 +1504,14 @@ bool Diagram::fromXml(QDomElement &document,
|
||||
if (content_ptr) {
|
||||
content_ptr -> m_elements = added_elements;
|
||||
content_ptr -> m_conductors_to_move = added_conductors;
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
|
||||
content_ptr -> m_text_fields = added_texts.toSet();
|
||||
content_ptr -> m_images = added_images.toSet();
|
||||
content_ptr -> m_shapes = added_shapes.toSet();
|
||||
#else
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove code for QT 5.14 or later")
|
||||
#endif
|
||||
content_ptr -> m_text_fields = QSet<IndependentTextItem *>(
|
||||
added_texts.begin(),
|
||||
added_texts.end());
|
||||
@@ -1493,6 +1522,7 @@ bool Diagram::fromXml(QDomElement &document,
|
||||
added_shapes.begin(),
|
||||
added_shapes.end());
|
||||
content_ptr->m_terminal_strip.swap(added_strips);
|
||||
#endif
|
||||
content_ptr->m_tables.swap(added_tables);
|
||||
}
|
||||
|
||||
@@ -1527,9 +1557,9 @@ void Diagram::folioSequentialsFromXml(const QDomElement &root,
|
||||
QStringList list;
|
||||
int i = 1;
|
||||
while (folioseq.hasAttribute(seq
|
||||
% QString::number(i))) {
|
||||
+ QString::number(i))) {
|
||||
list << folioseq.attribute(
|
||||
seq % QString::number(i));
|
||||
seq + QString::number(i));
|
||||
i++;
|
||||
}
|
||||
hash->insert(title,list);
|
||||
@@ -1559,11 +1589,11 @@ void Diagram::refreshContents()
|
||||
conductor->refreshText();
|
||||
}
|
||||
|
||||
for (auto &table : std::as_const(dc_.m_tables)) {
|
||||
for (auto &table : qAsConst(dc_.m_tables)) {
|
||||
table->initLink();
|
||||
}
|
||||
|
||||
for (auto &strip :std::as_const(dc_.m_terminal_strip)) {
|
||||
for (auto &strip :qAsConst(dc_.m_terminal_strip)) {
|
||||
strip->refreshPending();
|
||||
}
|
||||
}
|
||||
@@ -1748,7 +1778,7 @@ void Diagram::invertSelection()
|
||||
item_list << item;
|
||||
}
|
||||
}
|
||||
for (auto item : std::as_const(item_list)) {
|
||||
for (auto item : qAsConst(item_list)) {
|
||||
item -> setSelected(!item -> isSelected());
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ DiagramContent::DiagramContent(Diagram *diagram, bool selected) :
|
||||
item_list = diagram->items();
|
||||
}
|
||||
|
||||
for (const auto &item : std::as_const(item_list))
|
||||
for (const auto &item : qAsConst(item_list))
|
||||
{
|
||||
switch (item->type())
|
||||
{
|
||||
@@ -391,10 +391,10 @@ QList<QGraphicsItem *> DiagramContent::items(int filter) const
|
||||
if (filter & ElementTextFields) for(auto qgi : m_element_texts) items_list << qgi;
|
||||
if (filter & TextGroup) for(auto qgi : m_texts_groups) items_list << qgi;
|
||||
if (filter & Tables) for(auto qgi : m_tables) items_list << qgi;
|
||||
if (filter & TerminalStrip) for(const auto qgi : std::as_const(m_terminal_strip)) items_list << qgi;
|
||||
if (filter & TerminalStrip) for(const auto qgi : qAsConst(m_terminal_strip)) items_list << qgi;
|
||||
|
||||
if (filter & SelectedOnly) {
|
||||
for(const auto &qgi : std::as_const(items_list)) {
|
||||
for(const auto &qgi : qAsConst(items_list)) {
|
||||
if (!qgi -> isSelected()) items_list.removeOne(qgi);
|
||||
}
|
||||
}
|
||||
@@ -420,7 +420,7 @@ int DiagramContent::count(int filter) const
|
||||
if (filter & ElementTextFields) for(auto deti : m_element_texts) { if (deti -> isSelected()) ++ count; }
|
||||
if (filter & TextGroup) for(auto etig : m_texts_groups) { if (etig -> isSelected()) ++ count; }
|
||||
if (filter & Tables) for(auto table : m_tables) { if (table -> isSelected()) ++ count; }
|
||||
if (filter & TerminalStrip) for(const auto &strip : std::as_const(m_terminal_strip)) {if (strip->isSelected()) ++ count;}
|
||||
if (filter & TerminalStrip) for(const auto &strip : qAsConst(m_terminal_strip)) {if (strip->isSelected()) ++ count;}
|
||||
}
|
||||
else {
|
||||
if (filter & Elements) count += m_elements.count();
|
||||
|
||||
+49
-5
@@ -93,10 +93,7 @@ DiagramView::DiagramView(Diagram *diagram, QWidget *parent) :
|
||||
|
||||
connect(m_diagram, SIGNAL(showDiagram(Diagram*)), this, SIGNAL(showDiagram(Diagram*)));
|
||||
connect(m_diagram, SIGNAL(sceneRectChanged(QRectF)), this, SLOT(adjustSceneRect()));
|
||||
// TODO: review the following line. Old line commented out, been broken since commit
|
||||
// "27dcd5ef007a282d1a5a7f2f3dcaefc62669d668".
|
||||
// connect(&(m_diagram -> border_and_titleblock), SIGNAL(diagramTitleChanged(const QString &)), this, SLOT(updateWindowTitle()));
|
||||
connect(&(m_diagram->border_and_titleblock), &BorderTitleBlock::informationChanged, this, &DiagramView::updateWindowTitle);
|
||||
connect(&(m_diagram -> border_and_titleblock), SIGNAL(diagramTitleChanged(const QString &)), this, SLOT(updateWindowTitle()));
|
||||
connect(diagram, SIGNAL(findElementRequired(ElementsLocation)), this, SIGNAL(findElementRequired(ElementsLocation)));
|
||||
|
||||
QShortcut *edit_conductor_color_shortcut = new QShortcut(QKeySequence(Qt::Key_F2), this);
|
||||
@@ -206,9 +203,18 @@ void DiagramView::handleElementDrop(QDropEvent *event)
|
||||
return;
|
||||
}
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
||||
diagram()->setEventInterface(
|
||||
new DiagramEventAddElement(
|
||||
location, diagram(), mapToScene(event->pos())));
|
||||
#else
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove code for QT 6 or later")
|
||||
#endif
|
||||
diagram()->setEventInterface(
|
||||
new DiagramEventAddElement(
|
||||
location, diagram(), event->position()));
|
||||
#endif
|
||||
|
||||
//Set focus to the view to get event
|
||||
this->setFocus();
|
||||
@@ -277,8 +283,17 @@ void DiagramView::handleTextDrop(QDropEvent *e) {
|
||||
iti -> setHtml (e -> mimeData() -> text());
|
||||
}
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
||||
|
||||
m_diagram->undoStack().push(new AddGraphicsObjectCommand(
|
||||
iti, m_diagram, mapToScene(e->pos())));
|
||||
#else
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove code for QT 6 or later")
|
||||
#endif
|
||||
m_diagram->undoStack().push(new AddGraphicsObjectCommand(
|
||||
iti, m_diagram, e->position()));
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -432,7 +447,15 @@ void DiagramView::mousePressEvent(QMouseEvent *e)
|
||||
|
||||
if (m_event_interface && m_event_interface->mousePressEvent(e)) return;
|
||||
|
||||
//Start drag view when hold the middle button
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 1) // ### Qt 6: remove
|
||||
if (e->button() == Qt::MidButton)
|
||||
#else
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove code for QT 6 or later")
|
||||
#endif
|
||||
if (e->button() == Qt::MiddleButton)
|
||||
#endif
|
||||
{
|
||||
m_drag_last_pos = e->pos();
|
||||
viewport()->setCursor(Qt::ClosedHandCursor);
|
||||
@@ -482,7 +505,14 @@ void DiagramView::mouseMoveEvent(QMouseEvent *e)
|
||||
if (m_event_interface && m_event_interface->mouseMoveEvent(e)) return;
|
||||
|
||||
// Drag the view
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 1) // ### Qt 6: remove
|
||||
if (e->buttons() == Qt::MidButton)
|
||||
#else
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove code for QT 6 or later")
|
||||
#endif
|
||||
if (e->buttons() == Qt::MiddleButton)
|
||||
#endif
|
||||
{
|
||||
QScrollBar *h = horizontalScrollBar();
|
||||
QScrollBar *v = verticalScrollBar();
|
||||
@@ -543,7 +573,14 @@ void DiagramView::mouseReleaseEvent(QMouseEvent *e)
|
||||
if (m_event_interface && m_event_interface->mouseReleaseEvent(e)) return;
|
||||
|
||||
// Stop drag view
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 1) // ### Qt 6: remove
|
||||
if (e->button() == Qt::MidButton)
|
||||
#else
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove code for QT 6 or later")
|
||||
#endif
|
||||
if (e->button() == Qt::MiddleButton)
|
||||
#endif
|
||||
{
|
||||
viewport()->setCursor(Qt::ArrowCursor);
|
||||
}
|
||||
@@ -577,7 +614,14 @@ void DiagramView::mouseReleaseEvent(QMouseEvent *e)
|
||||
QMenu *menu = new QMenu(this);
|
||||
menu->addAction(act);
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
||||
menu->popup(e->globalPos());
|
||||
#else
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove code for QT 6 or later")
|
||||
#endif
|
||||
menu->popup(e->pos());
|
||||
#endif
|
||||
}
|
||||
|
||||
m_free_rubberbanding = false;
|
||||
@@ -1109,7 +1153,7 @@ void DiagramView::editSelection()
|
||||
QGraphicsItem *item = m_diagram->selectedItems().first();
|
||||
|
||||
//We use dynamic_cast instead of qgraphicsitem_cast for QetGraphicsItem
|
||||
//because they haven't got they own type().
|
||||
//because they haven't got their own type().
|
||||
//Use qgraphicsitem_cast will have weird behavior for this class.
|
||||
if (IndependentTextItem *iti = qgraphicsitem_cast<IndependentTextItem *>(item))
|
||||
iti -> edit();
|
||||
|
||||
@@ -63,9 +63,9 @@ void OpenElmtCommand::redo()
|
||||
m_scene->addItems(m_graphics_item.toVector());
|
||||
}
|
||||
|
||||
#pragma message("@TODO uncommante slot_select when fixed, see itemChange function for each primitive")
|
||||
//Commented because take a lot of time
|
||||
//when a lot of primitive are loaded
|
||||
//need work
|
||||
#pragma message("@TODO uncomment slot_select when fixed, see itemChange function for each primitive")
|
||||
//Commented because it takes a lot of time
|
||||
//when a lot of primitives are loaded!
|
||||
//needs work
|
||||
//m_scene->slot_select(m_graphics_item);
|
||||
}
|
||||
|
||||
@@ -478,10 +478,12 @@ const QDomDocument ElementScene::toXml(bool all_parts)
|
||||
root.appendChild(element_info);
|
||||
}
|
||||
|
||||
//complementary information about the element
|
||||
QDomElement informations_element = xml_document.createElement("informations");
|
||||
root.appendChild(informations_element);
|
||||
informations_element.appendChild(xml_document.createTextNode(m_element_data.m_drawing_information.trimmed()));
|
||||
//complementary information about the element, when available
|
||||
if (!(m_element_data.m_drawing_information.trimmed().isEmpty())) {
|
||||
QDomElement informations_element = xml_document.createElement("informations");
|
||||
root.appendChild(informations_element);
|
||||
informations_element.appendChild(xml_document.createTextNode(m_element_data.m_drawing_information.trimmed()));
|
||||
}
|
||||
|
||||
QDomElement description = xml_document.createElement("description");
|
||||
|
||||
@@ -746,7 +748,7 @@ void ElementScene::addItems(QVector<QGraphicsItem *> items)
|
||||
*/
|
||||
void ElementScene::removeItems(QVector<QGraphicsItem *> items)
|
||||
{
|
||||
const qsizetype previous_selected_count{selectedItems().size()};
|
||||
const int previous_selected_count{selectedItems().size()};
|
||||
|
||||
//block signal to avoid multiple emit of selection changed,
|
||||
//we emit this signal only once at the end of this function.
|
||||
|
||||
@@ -480,6 +480,7 @@ bool ElementView::event(QEvent *e) {
|
||||
|
||||
/**
|
||||
Utilise le pincement du trackpad pour zoomer
|
||||
Use trackpad pinch to zoom
|
||||
@brief ElementView::gestureEvent
|
||||
@param event
|
||||
@return
|
||||
@@ -502,6 +503,7 @@ bool ElementView::gestureEvent(QGestureEvent *event){
|
||||
|
||||
/**
|
||||
Dessine l'arriere-plan de l'editeur, cad la grille.
|
||||
Draws the editor background, i.e. the grid.
|
||||
@param p Le QPainter a utiliser pour dessiner
|
||||
@param r Le rectangle de la zone a dessiner
|
||||
*/
|
||||
@@ -514,20 +516,23 @@ void ElementView::drawBackground(QPainter *p, const QRectF &r) {
|
||||
p -> setRenderHint(QPainter::SmoothPixmapTransform, false);
|
||||
|
||||
// dessine un fond blanc
|
||||
// draw a white background
|
||||
p -> setPen(Qt::NoPen);
|
||||
p -> setBrush(Qt::white);
|
||||
p -> drawRect(r);
|
||||
|
||||
// determine le zoom en cours
|
||||
// determine the zoom-level
|
||||
qreal zoom_factor = transform().m11();
|
||||
|
||||
// choisit la granularite de la grille en fonction du zoom en cours
|
||||
// selects the grid granularity according to the current zoom level
|
||||
int drawn_x_grid = 1;//scene_ -> xGrid();
|
||||
int drawn_y_grid = 1;//scene_ -> yGrid();
|
||||
bool draw_grid = true;
|
||||
bool draw_cross = false;
|
||||
|
||||
if (zoom_factor < (4.0/3.0)) { //< no grid
|
||||
if (zoom_factor < 1.0) { //< no grid
|
||||
draw_grid = false;
|
||||
} else if (zoom_factor < 4.0) { //< grid 10*10
|
||||
drawn_x_grid *= 10;
|
||||
@@ -547,25 +552,43 @@ void ElementView::drawBackground(QPainter *p, const QRectF &r) {
|
||||
m_scene->setGrid(drawn_x_grid, drawn_y_grid);
|
||||
|
||||
if (draw_grid) {
|
||||
// draw the dot of the grid
|
||||
// draw the dots of the grid
|
||||
QPen pen(Qt::black);
|
||||
pen.setCosmetic(true);
|
||||
QSettings settings;
|
||||
int minWidthPen = settings.value(QStringLiteral("elementeditor/grid_pointsize_min"), 1).toInt();
|
||||
int maxWidthPen = settings.value(QStringLiteral("elementeditor/grid_pointsize_max"), 1).toInt();
|
||||
pen.setWidth(minWidthPen);
|
||||
if (minWidthPen != maxWidthPen) {
|
||||
qreal stepPen = (maxWidthPen - minWidthPen) / (qreal)maxWidthPen;
|
||||
qreal stepZoom = (25.0 - 1.0) / maxWidthPen;
|
||||
for (int n=0; n<maxWidthPen; n++) {
|
||||
if ((zoom_factor > (1.0 + n * stepZoom)) && (zoom_factor <= (1.0 + (n+1) * stepZoom))) {
|
||||
int widthPen = minWidthPen + qRound(n * stepPen);
|
||||
pen.setWidth(widthPen);
|
||||
}
|
||||
}
|
||||
if (zoom_factor <= 1.0)
|
||||
pen.setWidth(minWidthPen);
|
||||
else if (zoom_factor > (1.0 + stepZoom * maxWidthPen))
|
||||
pen.setWidth(maxWidthPen);
|
||||
}
|
||||
p -> setPen(pen);
|
||||
p -> setBrush(Qt::NoBrush);
|
||||
qreal limite_x = r.x() + r.width();
|
||||
qreal limite_y = r.y() + r.height();
|
||||
qreal limit_x = r.x() + r.width();
|
||||
qreal limit_y = r.y() + r.height();
|
||||
|
||||
int g_x = (int)ceil(r.x());
|
||||
while (g_x % drawn_x_grid) ++ g_x;
|
||||
int g_y = (int)ceil(r.y());
|
||||
while (g_y % drawn_y_grid) ++ g_y;
|
||||
|
||||
for (int gx = g_x ; gx < limite_x ; gx += drawn_x_grid) {
|
||||
for (int gy = g_y ; gy < limite_y ; gy += drawn_y_grid) {
|
||||
for (int gx = g_x ; gx < limit_x ; gx += drawn_x_grid) {
|
||||
for (int gy = g_y ; gy < limit_y ; gy += drawn_y_grid) {
|
||||
if (draw_cross) {
|
||||
if (!(gx % 10) && !(gy % 10)) {
|
||||
p -> drawLine(QLineF(gx - 0.25, gy, gx + 0.25, gy));
|
||||
p -> drawLine(QLineF(gx, gy - 0.25, gx, gy + 0.25));
|
||||
p -> drawLine(QLineF(gx - (pen.width()/4.0), gy, gx + (pen.width()/4.0), gy));
|
||||
p -> drawLine(QLineF(gx, gy - (pen.width()/4.0), gx, gy + (pen.width()/4.0)));
|
||||
} else {
|
||||
p -> drawPoint(gx, gy);
|
||||
}
|
||||
|
||||
@@ -61,14 +61,7 @@ void PartArc::paint(QPainter *painter, const QStyleOptionGraphicsItem *options,
|
||||
//Always remove the brush
|
||||
painter -> setBrush(Qt::NoBrush);
|
||||
QPen t = painter -> pen();
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
||||
t.setCosmetic(options && options -> levelOfDetail < 1.0);
|
||||
#else
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove code for QT 6 or later")
|
||||
#endif
|
||||
t.setCosmetic(options && options -> levelOfDetailFromTransform(painter->worldTransform()) < 1.0);
|
||||
#endif
|
||||
painter -> setPen(t);
|
||||
|
||||
if (isSelected())
|
||||
@@ -175,25 +168,25 @@ void PartArc::setRotation(qreal angle) {
|
||||
qreal diffAngle = qRound((angle - rotation()) * 100.0) / 100.0;
|
||||
m_rot = QET::correctAngle(angle, true);
|
||||
// idea taken from QET_ElementScaler:
|
||||
auto p1 = mapToScene(m_rect.x(),m_rect.y());
|
||||
qreal width = m_rect.height();
|
||||
qreal height = m_rect.width();
|
||||
qreal x; qreal y;
|
||||
if (diffAngle > 0) {
|
||||
m_start_angle += 270.0 * 16;
|
||||
while (m_start_angle < 0) { m_start_angle += (360*16); }
|
||||
while (m_start_angle >= (360*16)) { m_start_angle -= (360*16); }
|
||||
qreal width = m_rect.height();
|
||||
qreal height = m_rect.width();
|
||||
qreal x = (m_rect.y() + m_rect.height()) * (-1);
|
||||
qreal y = m_rect.x();
|
||||
m_rect = QRectF(x, y, width, height);
|
||||
} else {
|
||||
m_start_angle -= 270.0 * 16;
|
||||
while (m_start_angle < 0) { m_start_angle += (360*16); }
|
||||
while (m_start_angle >= (360*16)) { m_start_angle -= (360*16); }
|
||||
qreal width = m_rect.height();
|
||||
qreal height = m_rect.width();
|
||||
qreal x = m_rect.y();
|
||||
qreal y = (m_rect.x() + m_rect.width()) * (-1);
|
||||
m_rect = QRectF(x, y, width, height);
|
||||
m_start_angle += 270.0 * 16;
|
||||
while (m_start_angle < 0) { m_start_angle += (360*16); }
|
||||
while (m_start_angle >= (360*16)) { m_start_angle -= (360*16); }
|
||||
x = (p1.y() + m_rect.height()) * (-1);
|
||||
y = p1.x();
|
||||
} else {
|
||||
m_start_angle -= 270.0 * 16;
|
||||
while (m_start_angle < 0) { m_start_angle += (360*16); }
|
||||
while (m_start_angle >= (360*16)) { m_start_angle -= (360*16); }
|
||||
x = p1.y();
|
||||
y = (p1.x() + m_rect.width()) * (-1);
|
||||
}
|
||||
p1 = mapFromScene(x, y);
|
||||
m_rect = QRectF(p1.x(), p1.y(), width, height);
|
||||
|
||||
prepareGeometryChange();
|
||||
adjustHandlerPos();
|
||||
@@ -209,8 +202,10 @@ void PartArc::flip() {
|
||||
m_span_angle = (-1) * m_span_angle;
|
||||
while (m_start_angle < 0) { m_start_angle += (360*16); }
|
||||
while (m_start_angle >= (360*16)) { m_start_angle -= (360*16); }
|
||||
qreal y = ((-1.0) * m_rect.y()) - m_rect.height();
|
||||
m_rect = QRectF(m_rect.x(), y, m_rect.width(), m_rect.height());
|
||||
auto p1 = mapToScene(m_rect.x(),m_rect.y());
|
||||
p1.setY(((-1.0) * p1.y()) - m_rect.height());
|
||||
p1 = mapFromScene(p1.x(),p1.y());
|
||||
m_rect = QRectF(m_rect.x(), p1.y(), m_rect.width(), m_rect.height());
|
||||
prepareGeometryChange();
|
||||
adjustHandlerPos();
|
||||
emit rectChanged();
|
||||
@@ -221,8 +216,10 @@ void PartArc::mirror() {
|
||||
m_span_angle = (-1) * m_span_angle;
|
||||
while (m_start_angle < 0) { m_start_angle += (360*16); }
|
||||
while (m_start_angle >= (360*16)) { m_start_angle -= (360*16); }
|
||||
qreal x = ((-1.0) * m_rect.x()) - m_rect.width();
|
||||
m_rect = QRectF(x, m_rect.y(), m_rect.width(), m_rect.height());
|
||||
auto p1 = mapToScene(m_rect.x(),m_rect.y());
|
||||
p1.setX(((-1.0) * p1.x()) - m_rect.width());
|
||||
p1 = mapFromScene(p1.x(), p1.y());
|
||||
m_rect = QRectF(p1.x(), m_rect.y(), m_rect.width(), m_rect.height());
|
||||
prepareGeometryChange();
|
||||
adjustHandlerPos();
|
||||
emit rectChanged();
|
||||
|
||||
@@ -57,14 +57,7 @@ void PartEllipse::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
|
||||
|
||||
QPen t = painter -> pen();
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
||||
t.setCosmetic(options && options -> levelOfDetail < 1.0);
|
||||
#else
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove code for QT 6 or later")
|
||||
#endif
|
||||
t.setCosmetic(options && options -> levelOfDetailFromTransform(painter->worldTransform()) < 1.0);
|
||||
#endif
|
||||
if (isSelected())
|
||||
t.setColor(Qt::red);
|
||||
|
||||
@@ -241,19 +234,19 @@ void PartEllipse::setRotation(qreal angle) {
|
||||
qreal diffAngle = qRound((angle - rotation()) * 100.0) / 100.0;
|
||||
m_rot = QET::correctAngle(angle, true);
|
||||
// idea taken from QET_ElementScaler:
|
||||
auto p1 = mapToScene(m_rect.x(), m_rect.y());
|
||||
qreal width = m_rect.height();
|
||||
qreal height = m_rect.width();
|
||||
qreal x; qreal y;
|
||||
if (diffAngle > 0) {
|
||||
qreal width = m_rect.height();
|
||||
qreal height = m_rect.width();
|
||||
qreal x = (m_rect.y() + m_rect.height()) * (-1);
|
||||
qreal y = m_rect.x();
|
||||
m_rect = QRectF(x, y, width, height);
|
||||
x = (p1.y() + m_rect.height()) * (-1);
|
||||
y = p1.x();
|
||||
} else {
|
||||
qreal width = m_rect.height();
|
||||
qreal height = m_rect.width();
|
||||
qreal x = m_rect.y();
|
||||
qreal y = (m_rect.x() + m_rect.width()) * (-1);
|
||||
m_rect = QRectF(x, y, width, height);
|
||||
x = m_rect.y();
|
||||
y = (m_rect.x() + m_rect.width()) * (-1);
|
||||
}
|
||||
p1 = mapFromScene(x, y);
|
||||
m_rect = QRectF(p1.x(), p1.y(), width, height);
|
||||
prepareGeometryChange();
|
||||
adjustHandlerPos();
|
||||
emit rectChanged();
|
||||
@@ -264,16 +257,20 @@ qreal PartEllipse::rotation() const {
|
||||
}
|
||||
|
||||
void PartEllipse::flip() {
|
||||
qreal y = ((-1.0) * m_rect.y()) - m_rect.height();
|
||||
m_rect = QRectF(m_rect.x(), y, m_rect.width(), m_rect.height());
|
||||
auto p1 = mapToScene(m_rect.x(), m_rect.y());
|
||||
p1.setY(((-1.0) * p1.y()) - m_rect.height());
|
||||
p1 = mapFromScene(p1.x(), p1.y());
|
||||
m_rect = QRectF(p1.x(), p1.y(), m_rect.width(), m_rect.height());
|
||||
prepareGeometryChange();
|
||||
adjustHandlerPos();
|
||||
emit rectChanged();
|
||||
}
|
||||
|
||||
void PartEllipse::mirror() {
|
||||
qreal x = ((-1.0) * m_rect.x()) - m_rect.width();
|
||||
m_rect = QRectF(x, m_rect.y(), m_rect.width(), m_rect.height());
|
||||
auto p1 = mapToScene(m_rect.x(), m_rect.y());
|
||||
p1.setX(((-1.0) * p1.x()) - m_rect.width());
|
||||
p1 = mapFromScene(p1.x(), p1.y());
|
||||
m_rect = QRectF(p1.x(), p1.y(), m_rect.width(), m_rect.height());
|
||||
prepareGeometryChange();
|
||||
adjustHandlerPos();
|
||||
emit rectChanged();
|
||||
|
||||
@@ -81,14 +81,7 @@ void PartLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *options,
|
||||
QPen t = painter -> pen();
|
||||
t.setJoinStyle(Qt::MiterJoin);
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
||||
t.setCosmetic(options && options -> levelOfDetail < 1.0);
|
||||
#else
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove code for QT 6 or later")
|
||||
#endif
|
||||
t.setCosmetic(options && options -> levelOfDetailFromTransform(painter->worldTransform()) < 1.0);
|
||||
#endif
|
||||
if (isSelected()) t.setColor(Qt::red);
|
||||
|
||||
painter -> setPen(t);
|
||||
@@ -581,8 +574,12 @@ void PartLine::setSecondEndLength(const qreal &l)
|
||||
void PartLine::setRotation(qreal angle) {
|
||||
qreal diffAngle = qRound((angle - rotation()) * 100.0) / 100.0;
|
||||
m_rot = QET::correctAngle(angle, true);
|
||||
m_line.setP1(QTransform().rotate(diffAngle).map(m_line.p1()));
|
||||
m_line.setP2(QTransform().rotate(diffAngle).map(m_line.p2()));
|
||||
auto p1 = mapToScene(m_line.p1());
|
||||
auto p2 = mapToScene(m_line.p2());
|
||||
p1 = QTransform().rotate(diffAngle).map(p1);
|
||||
p2 = QTransform().rotate(diffAngle).map(p2);
|
||||
m_line.setP1(mapFromScene(p1));
|
||||
m_line.setP2(mapFromScene(p2));
|
||||
prepareGeometryChange();
|
||||
setLine(m_line);
|
||||
adjustHandlerPos();
|
||||
@@ -594,8 +591,12 @@ qreal PartLine::rotation() const {
|
||||
}
|
||||
|
||||
void PartLine::flip() {
|
||||
m_line.setP1(QPointF(m_line.p1().x(), (-1) * m_line.p1().y()));
|
||||
m_line.setP2(QPointF(m_line.p2().x(), (-1) * m_line.p2().y()));
|
||||
auto p1 = mapToScene(m_line.p1());
|
||||
auto p2 = mapToScene(m_line.p2());
|
||||
p1 = QPointF(p1.x(), (-1) * p1.y());
|
||||
p2 = QPointF(p2.x(), (-1) * p2.y());
|
||||
m_line.setP1(mapFromScene(p1));
|
||||
m_line.setP2(mapFromScene(p2));
|
||||
setLine(m_line);
|
||||
prepareGeometryChange();
|
||||
adjustHandlerPos();
|
||||
@@ -603,8 +604,12 @@ void PartLine::flip() {
|
||||
}
|
||||
|
||||
void PartLine::mirror() {
|
||||
m_line.setP1(QPointF((-1) * m_line.p1().x(), m_line.p1().y()));
|
||||
m_line.setP2(QPointF((-1) * m_line.p2().x(), m_line.p2().y()));
|
||||
auto p1 = mapToScene(m_line.p1());
|
||||
auto p2 = mapToScene(m_line.p2());
|
||||
p1 = QPointF((-1) * p1.x(), p1.y());
|
||||
p2 = QPointF((-1) * p2.x(), p2.y());
|
||||
m_line.setP1(mapFromScene(p1));
|
||||
m_line.setP2(mapFromScene(p2));
|
||||
setLine(m_line);
|
||||
prepareGeometryChange();
|
||||
adjustHandlerPos();
|
||||
|
||||
@@ -66,14 +66,7 @@ void PartPolygon::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
|
||||
applyStylesToQPainter(*painter);
|
||||
|
||||
QPen t = painter -> pen();
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
||||
t.setCosmetic(options && options -> levelOfDetail < 1.0);
|
||||
#else
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove code for QT 6 or later")
|
||||
#endif
|
||||
t.setCosmetic(options && options -> levelOfDetailFromTransform(painter->worldTransform()) < 1.0);
|
||||
#endif
|
||||
if (isSelected()) t.setColor(Qt::red);
|
||||
painter -> setPen(t);
|
||||
|
||||
@@ -299,8 +292,12 @@ void PartPolygon::resetAllHandlerColor()
|
||||
void PartPolygon::setRotation(qreal angle) {
|
||||
qreal diffAngle = qRound((angle - rotation()) * 100.0) / 100.0;
|
||||
m_rot = QET::correctAngle(angle, true);
|
||||
QTransform rotation = QTransform().rotate(diffAngle);
|
||||
setPolygon(rotation.map(m_polygon));
|
||||
for (auto &pt : m_polygon) {
|
||||
pt = mapToScene(pt.x(), pt.y());
|
||||
pt = QTransform().rotate(diffAngle).map(pt);
|
||||
pt = mapFromScene(pt.x(), pt.y());
|
||||
}
|
||||
setPolygon(m_polygon);
|
||||
prepareGeometryChange();
|
||||
adjustHandlerPos();
|
||||
emit polygonChanged();
|
||||
@@ -312,7 +309,9 @@ qreal PartPolygon::rotation() const {
|
||||
|
||||
void PartPolygon::flip() {
|
||||
for (auto &pt : m_polygon) {
|
||||
pt = mapToScene(pt.x(), pt.y());
|
||||
pt = QPointF(pt.x(), (-1) * pt.y());
|
||||
pt = mapFromScene(pt.x(), pt.y());
|
||||
}
|
||||
setPolygon(m_polygon);
|
||||
prepareGeometryChange();
|
||||
@@ -322,7 +321,9 @@ void PartPolygon::flip() {
|
||||
|
||||
void PartPolygon::mirror() {
|
||||
for (auto &pt : m_polygon) {
|
||||
pt = mapToScene(pt.x(), pt.y());
|
||||
pt = QPointF((-1) * pt.x(), pt.y());
|
||||
pt = mapFromScene(pt.x(), pt.y());
|
||||
}
|
||||
setPolygon(m_polygon);
|
||||
prepareGeometryChange();
|
||||
|
||||
@@ -54,14 +54,7 @@ void PartRectangle::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
|
||||
Q_UNUSED(widget);
|
||||
applyStylesToQPainter(*painter);
|
||||
QPen t = painter -> pen();
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
||||
t.setCosmetic(options && options -> levelOfDetail < 1.0);
|
||||
#else
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove code for QT 6 or later")
|
||||
#endif
|
||||
t.setCosmetic(options && options -> levelOfDetailFromTransform(painter->worldTransform()) < 1.0);
|
||||
#endif
|
||||
if (isSelected())
|
||||
t.setColor(Qt::red);
|
||||
|
||||
@@ -170,22 +163,19 @@ void PartRectangle::setYRadius(qreal Y)
|
||||
void PartRectangle::setRotation(qreal angle) {
|
||||
qreal diffAngle = qRound((angle - rotation()) * 100.0) / 100.0;
|
||||
m_rot = QET::correctAngle(angle, true);
|
||||
// for whatever reason: with "rect" we need to use scene-positions...
|
||||
auto pos = mapToScene(m_rect.x(),m_rect.y());
|
||||
auto p1 = mapToScene(m_rect.x(),m_rect.y());
|
||||
qreal width = m_rect.height();
|
||||
qreal height = m_rect.width();
|
||||
qreal x; qreal y;
|
||||
if (diffAngle > 0) {
|
||||
x = (pos.y() + m_rect.height()) * (-1);
|
||||
y = pos.x();
|
||||
x = (p1.y() + m_rect.height()) * (-1);
|
||||
y = p1.x();
|
||||
} else {
|
||||
x = pos.y();
|
||||
y = (pos.x() + m_rect.width()) * (-1);
|
||||
x = p1.y();
|
||||
y = (p1.x() + m_rect.width()) * (-1);
|
||||
}
|
||||
|
||||
pos = mapFromScene(x, y);
|
||||
m_rect.setX(pos.x()); m_rect.setY(pos.y());
|
||||
m_rect.setWidth(width); m_rect.setHeight(height);
|
||||
p1 = mapFromScene(x, y);
|
||||
m_rect = QRectF(p1.x(), p1.y(), width, height);
|
||||
std::swap (m_xRadius, m_yRadius);
|
||||
|
||||
prepareGeometryChange();
|
||||
@@ -198,13 +188,13 @@ qreal PartRectangle::rotation() const {
|
||||
}
|
||||
|
||||
void PartRectangle::flip() {
|
||||
// for whatever reason: with "rect" we need to use scene-positions...
|
||||
qreal height = m_rect.height();
|
||||
auto pos = mapToScene(m_rect.x(),m_rect.y());
|
||||
qreal x = pos.x();
|
||||
qreal y = ((-1.0) * pos.y()) - height;
|
||||
pos = mapFromScene(x, y);
|
||||
m_rect.setX(pos.x()); m_rect.setY(pos.y());
|
||||
auto height = m_rect.height();
|
||||
auto p1 = mapToScene(m_rect.x(),m_rect.y());
|
||||
qreal x = p1.x();
|
||||
qreal y = ((-1.0) * p1.y()) - height;
|
||||
p1 = mapFromScene(x, y);
|
||||
m_rect.setX(p1.x());
|
||||
m_rect.setY(p1.y());
|
||||
m_rect.setHeight(height);
|
||||
prepareGeometryChange();
|
||||
adjustHandlerPos();
|
||||
@@ -212,13 +202,13 @@ void PartRectangle::flip() {
|
||||
}
|
||||
|
||||
void PartRectangle::mirror() {
|
||||
// for whatever reason: with "rect" we need to use scene-positions...
|
||||
qreal width = m_rect.width();
|
||||
auto pos = mapToScene(m_rect.x(),m_rect.y());
|
||||
qreal x = ((-1.0) * pos.x()) - width;
|
||||
qreal y = pos.y();
|
||||
pos = mapFromScene(x, y);
|
||||
m_rect.setX(pos.x()); m_rect.setY(pos.y());
|
||||
auto width = m_rect.width();
|
||||
auto p1 = mapToScene(m_rect.x(),m_rect.y());
|
||||
qreal x = ((-1.0) * p1.x()) - width;
|
||||
qreal y = p1.y();
|
||||
p1 = mapFromScene(x, y);
|
||||
m_rect.setX(p1.x());
|
||||
m_rect.setY(p1.y());
|
||||
m_rect.setWidth(width);
|
||||
prepareGeometryChange();
|
||||
adjustHandlerPos();
|
||||
|
||||
@@ -84,18 +84,8 @@ void PartTerminal::paint(
|
||||
QPen t;
|
||||
t.setWidthF(1.0);
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
||||
t.setCosmetic(options && options -> levelOfDetail < 1.0);
|
||||
#else
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove code for QT 6 or later")
|
||||
#endif
|
||||
t.setCosmetic(
|
||||
options
|
||||
&& options->levelOfDetailFromTransform(
|
||||
painter->worldTransform())
|
||||
< 1.0);
|
||||
#endif
|
||||
t.setCosmetic(options && options -> levelOfDetailFromTransform(painter->worldTransform()) < 1.0);
|
||||
|
||||
// dessin de la borne en rouge
|
||||
t.setColor(isSelected() ? Terminal::neutralColor : Qt::red);
|
||||
painter -> setPen(t);
|
||||
@@ -168,23 +158,20 @@ void PartTerminal::setRotation(qreal angle) {
|
||||
else new_ori = Qet::West;
|
||||
|
||||
qreal diffAngle = qRound((angle - rotation()) * 100.0) / 100.0;
|
||||
double tmp, y, x;
|
||||
if (diffAngle > 0) {
|
||||
tmp = d->m_pos.y();
|
||||
y = d->m_pos.x();
|
||||
x = (-1) * tmp;
|
||||
} else {
|
||||
tmp = d->m_pos.x();
|
||||
x = d->m_pos.y();
|
||||
y = (-1) * tmp;
|
||||
}
|
||||
d->m_pos.setX(x); d->m_pos.setY(y);
|
||||
|
||||
auto p1 = QTransform().rotate(diffAngle).map(pos());
|
||||
d->m_pos.setX(p1.x()); d->m_pos.setY(p1.y());
|
||||
setPos(d->m_pos);
|
||||
setOrientation(new_ori);
|
||||
updateSecondPoint();
|
||||
prepareGeometryChange();
|
||||
emit orientationChanged(); // all terminal-signals call "updateForm"
|
||||
}
|
||||
|
||||
/**
|
||||
@brief PartTerminal::rotation
|
||||
@return current rotation-angle in degrees
|
||||
*/
|
||||
qreal PartTerminal::rotation() const {
|
||||
switch (d->m_orientation) {
|
||||
case Qet::North : return 0;
|
||||
@@ -195,9 +182,13 @@ qreal PartTerminal::rotation() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief PartTerminal::flip
|
||||
turn part upside down
|
||||
*/
|
||||
void PartTerminal::flip() {
|
||||
d->m_pos.setY((-1.0) * d->m_pos.y());
|
||||
|
||||
d->m_pos.setX( pos().x());
|
||||
d->m_pos.setY((-1.0) * pos().y());
|
||||
switch (d->m_orientation) {
|
||||
case Qet::North : setOrientation(Qet::South);
|
||||
break;
|
||||
@@ -212,8 +203,13 @@ void PartTerminal::flip() {
|
||||
emit yChanged(); // all terminal-signals call "updateForm"
|
||||
}
|
||||
|
||||
/**
|
||||
@brief PartTerminal::mirror
|
||||
turn part from left to right
|
||||
*/
|
||||
void PartTerminal::mirror() {
|
||||
d->m_pos.setX((-1.0) * d->m_pos.x());
|
||||
d->m_pos.setX((-1.0) * pos().x());
|
||||
d->m_pos.setY( pos().y());
|
||||
switch (d->m_orientation) {
|
||||
case Qet::North : break;
|
||||
case Qet::East : setOrientation(Qet::West);
|
||||
|
||||
@@ -140,7 +140,10 @@ void DynamicTextFieldEditor::updateForm()
|
||||
ui -> m_user_text_le -> setText(m_text_field.data() -> text());
|
||||
ui -> m_size_sb -> setValue(m_text_field.data() -> font().pointSize());
|
||||
ui->m_keep_visual_rotation_cb->setChecked(m_text_field.data()->keepVisualRotation());
|
||||
#ifdef BUILD_WITHOUT_KF5
|
||||
#else
|
||||
m_color_kpb -> setColor(m_text_field.data() -> color());
|
||||
#endif
|
||||
ui -> m_width_sb -> setValue(m_text_field.data() -> textWidth());
|
||||
ui -> m_font_pb -> setText(m_text_field -> font().family());
|
||||
|
||||
@@ -166,13 +169,16 @@ void DynamicTextFieldEditor::updateForm()
|
||||
|
||||
void DynamicTextFieldEditor::setupWidget()
|
||||
{
|
||||
m_color_kpb = new ColorButton(this);
|
||||
#ifdef BUILD_WITHOUT_KF5
|
||||
#else
|
||||
m_color_kpb = new KColorButton(this);
|
||||
m_color_kpb->setObjectName(QString::fromUtf8("m_color_kpb"));
|
||||
|
||||
connect(m_color_kpb, &ColorButton::changed,
|
||||
this, &DynamicTextFieldEditor::m_color_kpb_changed);
|
||||
connect(m_color_kpb, &KColorButton::changed,
|
||||
this, &DynamicTextFieldEditor::on_m_color_kpb_changed);
|
||||
|
||||
ui->m_main_grid_layout->addWidget(m_color_kpb, 6, 1, 1, 2);
|
||||
#endif
|
||||
}
|
||||
|
||||
void DynamicTextFieldEditor::setUpConnections()
|
||||
@@ -306,8 +312,8 @@ void DynamicTextFieldEditor::on_m_width_sb_editingFinished()
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicTextFieldEditor::on_m_elmt_info_cb_activated(int index) {
|
||||
Q_UNUSED(index)
|
||||
void DynamicTextFieldEditor::on_m_elmt_info_cb_activated(const QString &arg1) {
|
||||
Q_UNUSED(arg1)
|
||||
|
||||
QString info = ui -> m_elmt_info_cb -> currentData().toString();
|
||||
for (int i = 0; i < m_parts.length(); i++) {
|
||||
@@ -408,7 +414,7 @@ void DynamicTextFieldEditor::on_m_font_pb_clicked()
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicTextFieldEditor::m_color_kpb_changed(QColor newColor) {
|
||||
void DynamicTextFieldEditor::on_m_color_kpb_changed(const QColor &newColor) {
|
||||
if (!newColor.isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,10 @@
|
||||
#include "../elementitemeditor.h"
|
||||
#include "../graphicspart/partdynamictextfield.h"
|
||||
|
||||
#include "../../colorbutton.h"
|
||||
#ifdef BUILD_WITHOUT_KF5
|
||||
#else
|
||||
# include <KColorButton>
|
||||
#endif
|
||||
|
||||
namespace Ui {
|
||||
class DynamicTextFieldEditor;
|
||||
@@ -58,13 +61,13 @@ class DynamicTextFieldEditor : public ElementItemEditor {
|
||||
void on_m_size_sb_editingFinished();
|
||||
void on_m_frame_cb_clicked();
|
||||
void on_m_width_sb_editingFinished();
|
||||
void on_m_elmt_info_cb_activated(int index);
|
||||
void on_m_elmt_info_cb_activated(const QString &arg1);
|
||||
void on_m_text_from_cb_activated(int index);
|
||||
void on_m_composite_text_pb_clicked();
|
||||
void on_m_alignment_pb_clicked();
|
||||
void on_m_font_pb_clicked();
|
||||
|
||||
void m_color_kpb_changed(QColor newColor);
|
||||
void on_m_color_kpb_changed(const QColor &newColor);
|
||||
|
||||
void on_m_keep_visual_rotation_cb_clicked();
|
||||
|
||||
@@ -74,7 +77,10 @@ class DynamicTextFieldEditor : public ElementItemEditor {
|
||||
QList<PartDynamicTextField*> m_parts;
|
||||
QList<QMetaObject::Connection> m_connection_list;
|
||||
|
||||
ColorButton* m_color_kpb = nullptr;
|
||||
#ifdef BUILD_WITHOUT_KF5
|
||||
#else
|
||||
KColorButton* m_color_kpb = nullptr;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // DYNAMICTEXTFIELDEDITOR_H
|
||||
|
||||
@@ -487,7 +487,7 @@ void QETElementEditor::fillPartsList()
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove code for QT 6 or later")
|
||||
#endif
|
||||
v.setValue(qgi);
|
||||
qDebug()<<"Help code for QT 6 or later";
|
||||
#endif
|
||||
qlwi -> setData(42, v);
|
||||
m_parts_list -> addItem(qlwi);
|
||||
@@ -1069,7 +1069,7 @@ void QETElementEditor::updateAction()
|
||||
<< ui->m_revert_selection_action
|
||||
<< ui->m_paste_from_file_action
|
||||
<< ui->m_paste_from_element_action;
|
||||
for (auto action : std::as_const(ro_list)) {
|
||||
for (auto action : qAsConst(ro_list)) {
|
||||
action->setDisabled(m_read_only);
|
||||
}
|
||||
|
||||
@@ -1084,7 +1084,7 @@ void QETElementEditor::updateAction()
|
||||
<< ui->m_flip_action
|
||||
<< ui->m_mirror_action;
|
||||
auto items_selected = !m_read_only && m_elmt_scene->selectedItems().count();
|
||||
for (auto action : std::as_const(select_list)) {
|
||||
for (auto action : qAsConst(select_list)) {
|
||||
action->setEnabled(items_selected);
|
||||
}
|
||||
|
||||
|
||||
@@ -229,7 +229,7 @@ void TerminalEditor::activeConnections(bool active)
|
||||
m_editor_connections << connect(ui->m_type_cb, QOverload<int>::of(&QComboBox::activated),
|
||||
this, &TerminalEditor::typeEdited);
|
||||
} else {
|
||||
for (auto const & con : std::as_const(m_editor_connections)) {
|
||||
for (auto const & con : qAsConst(m_editor_connections)) {
|
||||
QObject::disconnect(con);
|
||||
}
|
||||
m_editor_connections.clear();
|
||||
|
||||
@@ -62,7 +62,10 @@ void TextEditor::updateForm()
|
||||
m_rotation_sb -> setValue(m_text -> rotation());
|
||||
m_size_sb -> setValue(m_text -> font().pointSize());
|
||||
m_font_pb -> setText(m_text -> font().family());
|
||||
#ifdef BUILD_WITHOUT_KF5
|
||||
#else
|
||||
m_color_pb -> setColor(m_text -> defaultTextColor());
|
||||
#endif
|
||||
|
||||
setUpEditConnection();
|
||||
}
|
||||
@@ -81,7 +84,7 @@ void TextEditor::setUpChangeConnection(QPointer<PartText> part)
|
||||
|
||||
void TextEditor::disconnectChangeConnection()
|
||||
{
|
||||
for (const auto &connection : std::as_const(m_change_connection)) {
|
||||
for (const auto &connection : qAsConst(m_change_connection)) {
|
||||
disconnect(connection);
|
||||
}
|
||||
m_change_connection.clear();
|
||||
@@ -341,16 +344,19 @@ void TextEditor::setUpWidget(QWidget *parent)
|
||||
m_line_edit->setPlaceholderText(tr("Entrer votre texte ici"));
|
||||
|
||||
gridLayout->addWidget(m_line_edit, 0, 0, 1, 6);
|
||||
m_color_pb = new ColorButton(parent);
|
||||
#ifdef BUILD_WITHOUT_KF5
|
||||
#else
|
||||
m_color_pb = new KColorButton(parent);
|
||||
m_color_pb->setObjectName(QString::fromUtf8("m_color_pb"));
|
||||
|
||||
connect(
|
||||
m_color_pb,
|
||||
&ColorButton::changed,
|
||||
&KColorButton::changed,
|
||||
this,
|
||||
&TextEditor::on_m_color_pb_changed);
|
||||
|
||||
gridLayout->addWidget(m_color_pb, 2, 5, 1, 1);
|
||||
#endif
|
||||
QLabel *label_5 = new QLabel(parent);
|
||||
label_5->setObjectName(QString::fromUtf8("label_5"));
|
||||
|
||||
|
||||
@@ -25,7 +25,10 @@
|
||||
#include <QSpinBox>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include "../../colorbutton.h"
|
||||
#ifdef BUILD_WITHOUT_KF5
|
||||
#else
|
||||
#include <KColorButton>
|
||||
#endif
|
||||
class PartText;
|
||||
|
||||
class TextEditor : public ElementItemEditor {
|
||||
@@ -62,7 +65,10 @@ class TextEditor : public ElementItemEditor {
|
||||
QSpinBox *m_size_sb;
|
||||
QLineEdit *m_line_edit;
|
||||
QPushButton *m_font_pb;
|
||||
ColorButton *m_color_pb;
|
||||
#ifdef BUILD_WITHOUT_KF5
|
||||
#else
|
||||
KColorButton *m_color_pb;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // TEXTEDITOR_H
|
||||
|
||||
@@ -59,11 +59,11 @@ QVector <QPointer<Element>> ElementProvider::freeElement(ElementData::Types filt
|
||||
QList<Element *> elmt_list;
|
||||
|
||||
//search in all diagram
|
||||
for (const auto &diagram_ : std::as_const(m_diagram_list))
|
||||
for (const auto &diagram_ : qAsConst(m_diagram_list))
|
||||
{
|
||||
//get all element in diagram d
|
||||
elmt_list = diagram_->elements();
|
||||
for (const auto &elmt_ : std::as_const(elmt_list))
|
||||
for (const auto &elmt_ : qAsConst(elmt_list))
|
||||
{
|
||||
if (filter & elmt_->elementData().m_type &&
|
||||
elmt_->isFree())
|
||||
@@ -106,7 +106,7 @@ QList <Element *> ElementProvider::fromUuids(QList<QUuid> uuid_list) const
|
||||
QVector<QPointer<Element>> ElementProvider::find(ElementData::Types elmt_type) const
|
||||
{
|
||||
QVector<QPointer<Element>> returned_vector;
|
||||
for (const auto &diagram_ : std::as_const(m_diagram_list))
|
||||
for (const auto &diagram_ : qAsConst(m_diagram_list))
|
||||
{
|
||||
const auto elmt_list = diagram_->elements();
|
||||
for (const auto &elmt_ : elmt_list)
|
||||
@@ -198,7 +198,7 @@ QVector<TerminalElement *> ElementProvider::freeTerminal() const
|
||||
{
|
||||
QVector<TerminalElement *> vector_;
|
||||
|
||||
for (const auto &diagram : std::as_const(m_diagram_list))
|
||||
for (const auto &diagram : qAsConst(m_diagram_list))
|
||||
{
|
||||
const auto elmt_list{diagram->elements()};
|
||||
|
||||
|
||||
@@ -45,19 +45,18 @@ ElementsCollectionCache::ElementsCollectionCache(const QString &database_path, Q
|
||||
qDebug() << "Unable to open the SQLite database " << database_path << " as " << connection_name << ": " << cache_db_.lastError();
|
||||
else
|
||||
{
|
||||
QSqlQuery *temp_query = new QSqlQuery(cache_db_);
|
||||
temp_query->exec("PRAGMA temp_store = MEMORY");
|
||||
temp_query->exec("PRAGMA journal_mode = MEMORY");
|
||||
temp_query->exec("PRAGMA page_size = 4096");
|
||||
temp_query->exec("PRAGMA cache_size = 16384");
|
||||
temp_query->exec("PRAGMA locking_mode = EXCLUSIVE");
|
||||
temp_query->exec("PRAGMA synchronous = OFF");
|
||||
cache_db_.exec("PRAGMA temp_store = MEMORY");
|
||||
cache_db_.exec("PRAGMA journal_mode = MEMORY");
|
||||
cache_db_.exec("PRAGMA page_size = 4096");
|
||||
cache_db_.exec("PRAGMA cache_size = 16384");
|
||||
cache_db_.exec("PRAGMA locking_mode = EXCLUSIVE");
|
||||
cache_db_.exec("PRAGMA synchronous = OFF");
|
||||
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO the tables could already exist, handle that case.")
|
||||
#endif
|
||||
//@TODO the tables could already exist, handle that case.
|
||||
temp_query->exec("CREATE TABLE names"
|
||||
cache_db_.exec("CREATE TABLE names"
|
||||
"("
|
||||
"path VARCHAR(512) NOT NULL,"
|
||||
"locale VARCHAR(2) NOT NULL,"
|
||||
@@ -66,13 +65,12 @@ ElementsCollectionCache::ElementsCollectionCache(const QString &database_path, Q
|
||||
"PRIMARY KEY(path, locale)"
|
||||
");");
|
||||
|
||||
temp_query->exec("CREATE TABLE pixmaps"
|
||||
cache_db_.exec("CREATE TABLE pixmaps"
|
||||
"("
|
||||
"path VARCHAR(512) NOT NULL UNIQUE,"
|
||||
"uuid VARCHAR(512) NOT NULL,"
|
||||
"pixmap BLOB, PRIMARY KEY(path),"
|
||||
"FOREIGN KEY(path) REFERENCES names (path) ON DELETE CASCADE);");
|
||||
delete temp_query;
|
||||
|
||||
// prepare queries
|
||||
select_name_ = new QSqlQuery(cache_db_);
|
||||
|
||||
@@ -59,7 +59,7 @@ ExportElementTextPattern::ExportElementTextPattern(Element *elmt) :
|
||||
return;
|
||||
|
||||
//Check if a conf with the same name already exist
|
||||
if (QFileInfo::exists(dir.absoluteFilePath(m_name % ".xml")))
|
||||
if (QFileInfo::exists(dir.absoluteFilePath(m_name + ".xml")))
|
||||
{
|
||||
bool r = QMessageBox::question(parentWidget(),
|
||||
QObject::tr("Configuration de textes"),
|
||||
@@ -71,7 +71,7 @@ ExportElementTextPattern::ExportElementTextPattern(Element *elmt) :
|
||||
}
|
||||
|
||||
QDomDocument doc = xmlConf();
|
||||
QET::writeXmlFile(doc, dir.absoluteFilePath(m_name % ".xml"));
|
||||
QET::writeXmlFile(doc, dir.absoluteFilePath(m_name + ".xml"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -202,7 +202,7 @@ void ImportElementTextPattern::apply(QString name, bool erase) const
|
||||
if(!name.endsWith(".xml"))
|
||||
name.append(".xml");
|
||||
|
||||
QFile conf_file(QETApp::configDir() % "/element_texts_pattern/" % name);
|
||||
QFile conf_file(QETApp::configDir() + "/element_texts_pattern/" + name);
|
||||
if(!conf_file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
return;
|
||||
|
||||
|
||||
+14
-34
@@ -128,9 +128,7 @@ int ExportDialog::diagramsToExportCount() const
|
||||
|
||||
/**
|
||||
Met en place la liste des schemas
|
||||
Set up the schematics list
|
||||
@return Le widget representant la liste des schemas
|
||||
The widget representing the list of schematics
|
||||
*/
|
||||
QWidget *ExportDialog::initDiagramsListPart()
|
||||
{
|
||||
@@ -141,17 +139,17 @@ QWidget *ExportDialog::initDiagramsListPart()
|
||||
reset_mapper_ = new QSignalMapper(this);
|
||||
clipboard_mapper_ = new QSignalMapper(this);
|
||||
|
||||
connect(preview_mapper_, SIGNAL(mappedInt(int)), this, SLOT(slot_previewDiagram(int)));
|
||||
connect(width_mapper_, SIGNAL(mappedInt(int)), this, SLOT(slot_correctHeight(int)));
|
||||
connect(height_mapper_, SIGNAL(mappedInt(int)), this, SLOT(slot_correctWidth(int)));
|
||||
connect(ratio_mapper_, SIGNAL(mappedInt(int)), this, SLOT(slot_keepRatioChanged(int)));
|
||||
connect(reset_mapper_, SIGNAL(mappedInt(int)), this, SLOT(slot_resetSize(int)));
|
||||
connect(clipboard_mapper_, SIGNAL(mappedInt(int)), this, SLOT(slot_exportToClipBoard(int)));
|
||||
connect(preview_mapper_, SIGNAL(mapped(int)), this, SLOT(slot_previewDiagram(int)));
|
||||
connect(width_mapper_, SIGNAL(mapped(int)), this, SLOT(slot_correctHeight(int)));
|
||||
connect(height_mapper_, SIGNAL(mapped(int)), this, SLOT(slot_correctWidth(int)));
|
||||
connect(ratio_mapper_, SIGNAL(mapped(int)), this, SLOT(slot_keepRatioChanged(int)));
|
||||
connect(reset_mapper_, SIGNAL(mapped(int)), this, SLOT(slot_resetSize(int)));
|
||||
connect(clipboard_mapper_, SIGNAL(mapped(int)), this, SLOT(slot_exportToClipBoard(int)));
|
||||
|
||||
diagrams_list_layout_ = new QGridLayout();
|
||||
|
||||
int line_count = 0;
|
||||
diagrams_list_layout_ -> addWidget(new QLabel(tr("Titre du folio")), line_count, 1, Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
diagrams_list_layout_ -> addWidget(new QLabel(tr("Titre du folio")), line_count, 1, Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
diagrams_list_layout_ -> addWidget(new QLabel(tr("Nom de fichier")), line_count, 2, Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
diagrams_list_layout_ -> addWidget(new QLabel(tr("Dimensions")), line_count, 3, Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
|
||||
@@ -247,28 +245,21 @@ QSize ExportDialog::diagramSize(Diagram *diagram)
|
||||
Cette methode ajuste la largeur d'un des schemas a exporter en fonction de
|
||||
sa hauteur si et seulement si l'option "Conserver les proportions" est
|
||||
activee pour ce schema.
|
||||
This method adjusts the width of one of the layouts to be exported
|
||||
according to its height if, and only if, the ‘Keep proportions’ option
|
||||
is enabled for this layout.
|
||||
@param diagram_id numero du schema concerne / number of drawing concerned
|
||||
@param diagram_id numero du schema concerne
|
||||
*/
|
||||
void ExportDialog::slot_correctWidth(int diagram_id)
|
||||
{
|
||||
// recupere l'ExportDiagramLine concernee
|
||||
// retrieve the ExportDiagramLine concerned
|
||||
ExportDialog::ExportDiagramLine *current_diagram = diagram_lines_[diagram_id];
|
||||
if (!current_diagram) return;
|
||||
|
||||
// ne fait rien si l'option "Conserver les proportions" n'est pas activee
|
||||
// do nothing if the ‘Keep proportions’ option is not active
|
||||
if (!(current_diagram -> keep_ratio -> isChecked())) return;
|
||||
|
||||
// recupere les proportions du schema
|
||||
// retrieve the proportions of the diagram
|
||||
qreal diagram_ratio = diagramRatio(current_diagram -> diagram);
|
||||
|
||||
// ajuste la largeur
|
||||
// adjust the width
|
||||
current_diagram -> width -> blockSignals(true);
|
||||
current_diagram -> width -> setValue(qRound(current_diagram -> height -> value() * diagram_ratio));
|
||||
current_diagram -> width -> blockSignals(false);
|
||||
@@ -278,28 +269,21 @@ void ExportDialog::slot_correctWidth(int diagram_id)
|
||||
Cette methode ajuste la hauteur d'un des schemas a exporter en fonction de
|
||||
sa largeur si et seulement si l'option "Conserver les proportions" est
|
||||
activee pour ce schema.
|
||||
This method adjusts the height of one of the layouts to be exported
|
||||
according to its width if, and only if, the ‘Keep proportions’ option
|
||||
is enabled for this layout.
|
||||
@param diagram_id numero du schema concerne / number of drawing concerned
|
||||
@param diagram_id numero du schema concerne
|
||||
*/
|
||||
void ExportDialog::slot_correctHeight(int diagram_id)
|
||||
{
|
||||
// recupere l'ExportDiagramLine concernee
|
||||
// retrieve the ExportDiagramLine concerned
|
||||
ExportDialog::ExportDiagramLine *current_diagram = diagram_lines_[diagram_id];
|
||||
if (!current_diagram) return;
|
||||
|
||||
// ne fait rien si l'option "Conserver les proportions" n'est pas activee
|
||||
// do nothing if the ‘Keep proportions’ option is not active
|
||||
if (!(current_diagram -> keep_ratio -> isChecked())) return;
|
||||
|
||||
// recupere les proportions du schema
|
||||
// retrieve the proportions of the diagram
|
||||
qreal diagram_ratio = diagramRatio(current_diagram -> diagram);
|
||||
|
||||
// ajuste la hauteur
|
||||
// adjust the height
|
||||
current_diagram -> height -> blockSignals(true);
|
||||
current_diagram -> height -> setValue(qRound(current_diagram -> width -> value() / diagram_ratio));
|
||||
current_diagram -> height -> blockSignals(false);
|
||||
@@ -313,12 +297,10 @@ void ExportDialog::slot_correctHeight(int diagram_id)
|
||||
void ExportDialog::slot_keepRatioChanged(int diagram_id)
|
||||
{
|
||||
// recupere l'ExportDiagramLine concernee
|
||||
// retrieve the ExportDiagramLine concerned
|
||||
ExportDialog::ExportDiagramLine *current_diagram = diagram_lines_[diagram_id];
|
||||
if (!current_diagram) return;
|
||||
|
||||
// gere l'icone du bouton "Conserver les proportions"
|
||||
// manages the ‘Keep proportions’ button icon
|
||||
if (current_diagram -> keep_ratio -> isChecked()) {
|
||||
current_diagram -> keep_ratio -> setIcon(QET::Icons::ObjectLocked);
|
||||
} else {
|
||||
@@ -326,11 +308,9 @@ void ExportDialog::slot_keepRatioChanged(int diagram_id)
|
||||
}
|
||||
|
||||
// ne fait rien si l'option "Conserver les proportions" n'est pas activee
|
||||
// do nothing if the ‘Keep proportions’ option is not active
|
||||
if (!(current_diagram -> keep_ratio -> isChecked())) return;
|
||||
|
||||
// au contraire, si elle est activee, ajuste la hauteur en fonction de la largeur
|
||||
// on the other hand, if it is active, adjusts the height according to the width
|
||||
slot_correctHeight(diagram_id);
|
||||
}
|
||||
|
||||
@@ -790,7 +770,7 @@ void ExportDialog::exportDiagram(ExportDiagramLine *diagram_line) {
|
||||
|
||||
// recupere le format a utiliser (acronyme et extension)
|
||||
QString format_acronym = export_properties.format;
|
||||
QString format_extension = "." % format_acronym.toLower();
|
||||
QString format_extension = "." + format_acronym.toLower();
|
||||
|
||||
// determine le nom de fichier a utiliser
|
||||
QString diagram_path = diagram_line -> file_name -> text();
|
||||
@@ -887,7 +867,7 @@ void ExportDialog::slot_checkDiagramsCount()
|
||||
void ExportDialog::slot_changeFilesExtension(bool force_extension) {
|
||||
// recupere le format a utiliser (acronyme et extension)
|
||||
QString format_acronym = epw -> exportProperties().format;
|
||||
QString format_extension = "." % format_acronym.toLower();
|
||||
QString format_extension = "." + format_acronym.toLower();
|
||||
|
||||
// set maximum width / height according limitations in QPainter
|
||||
if ((format_extension == ".bmp") ||
|
||||
@@ -917,11 +897,11 @@ void ExportDialog::slot_changeFilesExtension(bool force_extension) {
|
||||
// cas 2 : l'extension est absente
|
||||
if (diagram_filename_info.suffix().isEmpty()) {
|
||||
if (force_extension) {
|
||||
diagram_filename = diagram_filename_info.completeBaseName() % format_extension;
|
||||
diagram_filename = diagram_filename_info.completeBaseName() + format_extension;
|
||||
}
|
||||
} else {
|
||||
// cas 3 : l'extension est presente mais erronee
|
||||
diagram_filename = diagram_filename_info.completeBaseName() % format_extension;
|
||||
diagram_filename = diagram_filename_info.completeBaseName() + format_extension;
|
||||
}
|
||||
|
||||
diagram_line -> file_name -> setText(diagram_filename);
|
||||
@@ -1034,7 +1014,7 @@ ExportDialog::ExportDiagramLine::ExportDiagramLine(Diagram *dia, QSize diagram_s
|
||||
if (diagram_title.isEmpty()) diagram_title = QObject::tr("Folio sans titre");
|
||||
QString diagram_filename = diagram -> title();
|
||||
if (diagram_filename.isEmpty()) diagram_filename = QObject::tr("schema");
|
||||
diagram_filename = QET::stringToFileName(diagram_index % "_" % diagram_filename);
|
||||
diagram_filename = QET::stringToFileName(diagram_index + "_" + diagram_filename);
|
||||
|
||||
title_label = new QLabel(diagram_title);
|
||||
|
||||
|
||||
@@ -54,24 +54,24 @@ ExportProperties::~ExportProperties()
|
||||
void ExportProperties::toSettings(QSettings &settings,
|
||||
const QString &prefix) const
|
||||
{
|
||||
settings.setValue(prefix % "path",
|
||||
settings.setValue(prefix + "path",
|
||||
QDir::toNativeSeparators(
|
||||
destination_directory.absolutePath()));
|
||||
settings.setValue(prefix % "format",
|
||||
settings.setValue(prefix + "format",
|
||||
format);
|
||||
settings.setValue(prefix % "drawgrid",
|
||||
settings.setValue(prefix + "drawgrid",
|
||||
draw_grid);
|
||||
settings.setValue(prefix % "drawborder",
|
||||
settings.setValue(prefix + "drawborder",
|
||||
draw_border);
|
||||
settings.setValue(prefix % "drawtitleblock",
|
||||
settings.setValue(prefix + "drawtitleblock",
|
||||
draw_titleblock);
|
||||
settings.setValue(prefix % "drawterminals",
|
||||
settings.setValue(prefix + "drawterminals",
|
||||
draw_terminals);
|
||||
settings.setValue(prefix % "drawbgtransparent",
|
||||
settings.setValue(prefix + "drawbgtransparent",
|
||||
draw_bg_transparent);
|
||||
settings.setValue(prefix % "drawcoloredconductors",
|
||||
settings.setValue(prefix + "drawcoloredconductors",
|
||||
draw_colored_conductors);
|
||||
settings.setValue(prefix % "area",
|
||||
settings.setValue(prefix + "area",
|
||||
QET::diagramAreaToString(exported_area));
|
||||
}
|
||||
|
||||
@@ -85,30 +85,30 @@ void ExportProperties::fromSettings(QSettings &settings,
|
||||
QString export_path = QETApp::documentDir();
|
||||
destination_directory.setPath(
|
||||
settings.value(
|
||||
prefix % "path",
|
||||
prefix + "path",
|
||||
export_path).toString());
|
||||
if (!destination_directory.exists())
|
||||
destination_directory.setPath(export_path);
|
||||
|
||||
format = settings.value(prefix % "format").toString();
|
||||
format = settings.value(prefix + "format").toString();
|
||||
|
||||
draw_grid = settings.value(prefix % "drawgrid",
|
||||
draw_grid = settings.value(prefix + "drawgrid",
|
||||
false).toBool();
|
||||
draw_border = settings.value(prefix % "drawborder",
|
||||
draw_border = settings.value(prefix + "drawborder",
|
||||
true ).toBool();
|
||||
draw_titleblock = settings.value(prefix % "drawtitleblock",
|
||||
draw_titleblock = settings.value(prefix + "drawtitleblock",
|
||||
true ).toBool();
|
||||
draw_terminals = settings.value(prefix % "drawterminals",
|
||||
draw_terminals = settings.value(prefix + "drawterminals",
|
||||
false).toBool();
|
||||
draw_bg_transparent = settings.value(prefix % "drawbgtransparent",
|
||||
draw_bg_transparent = settings.value(prefix + "drawbgtransparent",
|
||||
false).toBool();
|
||||
draw_colored_conductors = settings.value(
|
||||
prefix % "drawcoloredconductors",
|
||||
prefix + "drawcoloredconductors",
|
||||
true ).toBool();
|
||||
|
||||
exported_area = QET::diagramAreaFromString(
|
||||
settings.value(
|
||||
prefix % "area",
|
||||
prefix + "area",
|
||||
"border").toString());
|
||||
}
|
||||
|
||||
|
||||
+77
-39
@@ -55,6 +55,43 @@ void MachineInfo::send_info_to_debug()
|
||||
<< QLibraryInfo::isDebugBuild();
|
||||
qInfo()<< "Qt library version:"
|
||||
<< QLibraryInfo::version();
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
||||
qInfo()<< "Qt library location default prefix:"
|
||||
<< QLibraryInfo::location(QLibraryInfo::PrefixPath);
|
||||
qInfo()<< "Qt library location documentation:"
|
||||
<< QLibraryInfo::location(QLibraryInfo::DocumentationPath);
|
||||
qInfo()<< "Qt library location headers:"
|
||||
<< QLibraryInfo::location(QLibraryInfo::HeadersPath);
|
||||
qInfo()<< "Qt library location libraries:"
|
||||
<< QLibraryInfo::location(QLibraryInfo::LibrariesPath);
|
||||
qInfo()<< "Qt library location executables:"
|
||||
<< QLibraryInfo::location(QLibraryInfo::LibraryExecutablesPath);
|
||||
qInfo()<< "Qt library location Qt binaries:"
|
||||
<< QLibraryInfo::location(QLibraryInfo::BinariesPath);
|
||||
qInfo()<< "Qt library location Qt plugins:"
|
||||
<< QLibraryInfo::location(QLibraryInfo::PluginsPath);
|
||||
qInfo()<< "Qt library location installed QML extensions:"
|
||||
<< QLibraryInfo::location(QLibraryInfo::ImportsPath);
|
||||
qInfo()<< "Qt library location installed QML extensions:"
|
||||
<< QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath);
|
||||
qInfo()<< "Qt library location dependent Qt data:"
|
||||
<< QLibraryInfo::location(QLibraryInfo::ArchDataPath);
|
||||
qInfo()<< "Qt library location independent Qt data:"
|
||||
<< QLibraryInfo::location(QLibraryInfo::DataPath);
|
||||
qInfo()<< "Qt library location translation:"
|
||||
<< QLibraryInfo::location(QLibraryInfo::TranslationsPath);
|
||||
qInfo()<< "Qt library location examples:"
|
||||
<< QLibraryInfo::location(QLibraryInfo::ExamplesPath);
|
||||
qInfo()<< "Qt library location Qt testcases:"
|
||||
<< QLibraryInfo::location(QLibraryInfo::TestsPath);
|
||||
#ifndef Q_OS_WIN
|
||||
qInfo()<< "Qt library location Qt settings:"
|
||||
<< QLibraryInfo::location(QLibraryInfo::SettingsPath);
|
||||
#endif
|
||||
#else
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove code for QT 6 or later")
|
||||
#endif
|
||||
qInfo()<< "Qt library path default prefix:"
|
||||
<< QLibraryInfo::path(QLibraryInfo::PrefixPath);
|
||||
qInfo()<< "Qt library path documentation:"
|
||||
@@ -86,33 +123,34 @@ void MachineInfo::send_info_to_debug()
|
||||
#ifndef Q_OS_WIN
|
||||
qInfo()<< "Qt library path Qt settings:"
|
||||
<< QLibraryInfo::path(QLibraryInfo::SettingsPath);
|
||||
#endif
|
||||
#endif
|
||||
if (strlen(GIT_COMMIT_SHA)) {
|
||||
qInfo() << "GitRevision " % QString(GIT_COMMIT_SHA);
|
||||
qInfo() << "GitRevision " + QString(GIT_COMMIT_SHA);
|
||||
}
|
||||
qInfo()<< "QElectroTech V " % QetVersion::displayedVersion();
|
||||
qInfo()<< QObject::tr("Compilation : ") % pc.built.version;
|
||||
qInfo()<< "Built with Qt " % pc.built.QT
|
||||
% " - " % pc.built.arch
|
||||
% " - Date : " % pc.built.date
|
||||
% " : " % pc.built.time;
|
||||
qInfo()<< "Run with Qt " % QString(qVersion())
|
||||
% " using"
|
||||
% QString(" %1 thread(s)").arg(pc.cpu.ThreadCount);
|
||||
qInfo()<< "CPU : " % pc.cpu.info;
|
||||
qInfo()<< "QElectroTech V " + QetVersion::displayedVersion();
|
||||
qInfo()<< QObject::tr("Compilation : ") + pc.built.version;
|
||||
qInfo()<< "Built with Qt " + pc.built.QT
|
||||
+ " - " + pc.built.arch
|
||||
+ " - Date : " + pc.built.date
|
||||
+ " : " + pc.built.time;
|
||||
qInfo()<< "Run with Qt "+ QString(qVersion())
|
||||
+ " using"
|
||||
+ QString(" %1 thread(s)").arg(pc.cpu.ThreadCount);
|
||||
qInfo()<< "CPU : " + pc.cpu.info;
|
||||
qInfo()<< pc.ram.Total;
|
||||
qInfo()<< pc.ram.Available;
|
||||
qInfo()<< "GPU : " % pc.gpu.info;
|
||||
qInfo()<< "GPU RAM : " % pc.gpu.RAM;
|
||||
qInfo()<< "GPU : " + pc.gpu.info;
|
||||
qInfo()<< "GPU RAM : " + pc.gpu.RAM;
|
||||
|
||||
qInfo()<< "OS : " % pc.os.type
|
||||
% " - " % pc.cpu.Architecture
|
||||
% " - Version : " % pc.os.name
|
||||
% " - Kernel : " % pc.os.kernel;
|
||||
qInfo()<< "OS : " + pc.os.type
|
||||
+ " - " + pc.cpu.Architecture
|
||||
+ " - Version : "+pc.os.name
|
||||
+ " - Kernel : "+pc.os.kernel;
|
||||
qInfo()<< "";
|
||||
|
||||
qInfo()<< " OS System language:"<< QLocale::system().name();
|
||||
qInfo()<< " OS System Native Country Name:"<< QLocale::system().nativeTerritoryName();
|
||||
qInfo()<< " OS System Native Country Name:"<< QLocale::system().nativeCountryName();
|
||||
qInfo()<< " OS System Native Language Name:"<< QLocale::system().nativeLanguageName();
|
||||
qInfo()<< "";
|
||||
qInfo()<< " System language defined in QET configuration:"<< QString(QETApp::langFromSetting().toLatin1());
|
||||
@@ -133,8 +171,8 @@ void MachineInfo::send_info_to_debug()
|
||||
qInfo()<< " App Config Location:"<< QETApp::configDir();
|
||||
qInfo()<< " For data-files (user-/company-collections, titleblocks, etc.):";
|
||||
qInfo()<< " App Data Location:"<< QETApp::dataDir();
|
||||
qInfo()<< " Directory for project's autosave files (stalefiles):";
|
||||
qInfo()<< " Autosave:"<< QETApp::autosaveDir() % "/autosave";
|
||||
qInfo()<< " Directory for project stalefiles:";
|
||||
qInfo()<< " Generic Data Location:"<< QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/stalefiles/QElectroTech/";
|
||||
// qInfo()<< " App Local DataLocation:"<< QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation);
|
||||
// qInfo()<< " Home Location:"<< QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
|
||||
// qInfo()<< " Runtime Location:"<< QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
|
||||
@@ -150,7 +188,7 @@ void MachineInfo::send_info_to_debug()
|
||||
QDirIterator it1(QETApp::commonElementsDir().toLatin1(),nameFilters, QDir::Files, QDirIterator::Subdirectories);
|
||||
while (it1.hasNext())
|
||||
{
|
||||
if(it1.next() != "")
|
||||
if(it1.next() > 0 )
|
||||
{
|
||||
commomElementsDir ++;
|
||||
}
|
||||
@@ -162,7 +200,7 @@ void MachineInfo::send_info_to_debug()
|
||||
QDirIterator it2(QETApp::customElementsDir().toLatin1(), nameFilters, QDir::Files, QDirIterator::Subdirectories);
|
||||
while (it2.hasNext())
|
||||
{
|
||||
if(it2.next() != "")
|
||||
if(it2.next() > 0 )
|
||||
{
|
||||
customElementsDir ++;
|
||||
}
|
||||
@@ -173,7 +211,7 @@ void MachineInfo::send_info_to_debug()
|
||||
QDirIterator it3(QETApp::companyElementsDir().toLatin1(), nameFilters, QDir::Files, QDirIterator::Subdirectories);
|
||||
while (it3.hasNext())
|
||||
{
|
||||
if(it3.next() != "")
|
||||
if(it3.next() > 0 )
|
||||
{
|
||||
companyElementsDir ++;
|
||||
}
|
||||
@@ -414,29 +452,29 @@ int32_t MachineInfo::i_max_screen_height() {
|
||||
*/
|
||||
QString MachineInfo::compilation_info()
|
||||
{
|
||||
QString compilation_info = "<br />" % QObject::tr("Compilation : ");
|
||||
QString compilation_info = "<br />" + QObject::tr("Compilation : ");
|
||||
compilation_info +=pc.built.version;
|
||||
|
||||
compilation_info += "<br>Built with Qt " % pc.built.QT;
|
||||
compilation_info += " - " % pc.built.arch;
|
||||
compilation_info += " - Date : " % pc.built.date;
|
||||
compilation_info += " : " % pc.built.time;
|
||||
compilation_info += "<br>Built with Qt " + pc.built.QT;
|
||||
compilation_info += " - " + pc.built.arch;
|
||||
compilation_info += " - Date : " + pc.built.date;
|
||||
compilation_info += " : " + pc.built.time;
|
||||
if (strlen(GIT_COMMIT_SHA)) {
|
||||
compilation_info += "<br> Git Revision : " % QString(GIT_COMMIT_SHA);
|
||||
compilation_info += "<br> Git Revision : " + QString(GIT_COMMIT_SHA);
|
||||
}
|
||||
compilation_info += " <br>Run with Qt " % QString(qVersion());
|
||||
compilation_info += " <br>Run with Qt " + QString(qVersion());
|
||||
compilation_info += " using"
|
||||
+ QString(" %1 thread(s)").arg(pc.cpu.ThreadCount);
|
||||
compilation_info += "<br> CPU : " % pc.cpu.info;
|
||||
compilation_info += "<br>" % pc.ram.Total;
|
||||
compilation_info += "<br>" % pc.ram.Available;
|
||||
compilation_info += "<br>GPU : " % pc.gpu.info;
|
||||
compilation_info += "<br>GPU RAM : " % pc.gpu.RAM;
|
||||
compilation_info += "<br> CPU : " + pc.cpu.info;
|
||||
compilation_info += "<br>" + pc.ram.Total;
|
||||
compilation_info += "<br>" + pc.ram.Available;
|
||||
compilation_info += "<br>GPU : " + pc.gpu.info;
|
||||
compilation_info += "<br>GPU RAM : " + pc.gpu.RAM;
|
||||
|
||||
compilation_info += "<br> OS : " % pc.os.type;
|
||||
compilation_info += " - " % pc.cpu.Architecture;
|
||||
compilation_info += " - Version : " % pc.os.name;
|
||||
compilation_info += "</br> - Kernel : " % pc.os.kernel;
|
||||
compilation_info += "<br> OS : " + pc.os.type;
|
||||
compilation_info += " - " + pc.cpu.Architecture;
|
||||
compilation_info += " - Version : "+pc.os.name;
|
||||
compilation_info += "</br> - Kernel : "+pc.os.kernel;
|
||||
compilation_info += "<br> *** Qt screens *** </br>";
|
||||
|
||||
for (int ii = 0; ii < pc.screen.count; ++ii) {
|
||||
|
||||
@@ -84,12 +84,12 @@ class MachineInfo
|
||||
QString version=
|
||||
#ifdef __GNUC__
|
||||
#ifdef __APPLE_CC__
|
||||
"CLANG " % QString(__clang_version__);
|
||||
"CLANG " + QString(__clang_version__);
|
||||
#else
|
||||
"GCC " % QString(__VERSION__);
|
||||
"GCC " + QString(__VERSION__);
|
||||
#endif
|
||||
#elif defined(Q_CC_MSVC)
|
||||
"MSVC " % QString(QT_STRINGIFY(_MSC_FULL_VER));
|
||||
"MSVC " + QString(QT_STRINGIFY(_MSC_FULL_VER));
|
||||
#endif
|
||||
QString QT=QString(QT_VERSION_STR);
|
||||
QString date=QString(__DATE__);
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@
|
||||
#include "utils/qetsettings.h"
|
||||
|
||||
#include <QStyleFactory>
|
||||
#include <QThreadPool>
|
||||
#include <QtConcurrentRun>
|
||||
|
||||
/**
|
||||
@brief myMessageOutput
|
||||
@@ -216,7 +216,7 @@ QGuiApplication::setHighDpiScaleFactorRoundingPolicy(QetSettings::hdpiScaleFacto
|
||||
QObject::connect(&app, &SingleApplication::receivedMessage,
|
||||
&qetapp, &QETApp::receiveMessage);
|
||||
|
||||
QThreadPool::globalInstance()->start([=]()
|
||||
QtConcurrent::run([=]()
|
||||
{
|
||||
// for debugging
|
||||
qInstallMessageHandler(myMessageOutput);
|
||||
|
||||
@@ -24,6 +24,13 @@
|
||||
|
||||
#include "ui_projectprintwindow.h"
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
||||
# include <QDesktopWidget>
|
||||
#else
|
||||
# if TODO_LIST
|
||||
# pragma message("@TODO remove code for QT 6 or later")
|
||||
# endif
|
||||
#endif
|
||||
#include <QMarginsF>
|
||||
#include <QPageSetupDialog>
|
||||
#include <QPainter>
|
||||
@@ -43,7 +50,14 @@ void ProjectPrintWindow::launchDialog(QETProject *project, QPrinter::OutputForma
|
||||
auto printer_ = new QPrinter();
|
||||
QPrinter printer(QPrinter::HighResolution);
|
||||
printer_->setDocName(ProjectPrintWindow::docName(project));
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 1) // ### Qt 6: remove
|
||||
printer_->setOrientation(QPrinter::Landscape);
|
||||
#else
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove code for QT 6 or later")
|
||||
# endif
|
||||
printer_->setPageOrientation(QPageLayout::Landscape);
|
||||
#endif
|
||||
|
||||
if (format == QPrinter::NativeFormat) //To physical printer
|
||||
{
|
||||
@@ -52,7 +66,14 @@ void ProjectPrintWindow::launchDialog(QETProject *project, QPrinter::OutputForma
|
||||
print_dialog.setWindowFlags(Qt::Sheet);
|
||||
#endif
|
||||
print_dialog.setWindowTitle(tr("Options d'impression", "window title"));
|
||||
print_dialog.setOptions(QAbstractPrintDialog::PrintShowPageSize);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
||||
print_dialog.setEnabledOptions(QAbstractPrintDialog::PrintShowPageSize);
|
||||
#else
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove code for QT 6 or later")
|
||||
#endif
|
||||
qDebug()<<"Help code for QT 6 or later";
|
||||
#endif
|
||||
if (print_dialog.exec() == QDialog::Rejected) {
|
||||
delete printer_;
|
||||
return;
|
||||
@@ -61,7 +82,7 @@ void ProjectPrintWindow::launchDialog(QETProject *project, QPrinter::OutputForma
|
||||
else //To pdf file
|
||||
{
|
||||
auto dir_path = project->currentDir();
|
||||
QString file_name = QDir::toNativeSeparators(QDir::cleanPath(dir_path % "/" % printer_->docName()));
|
||||
QString file_name = QDir::toNativeSeparators(QDir::cleanPath(dir_path + "/" + printer_->docName()));
|
||||
if (!file_name.endsWith(".pdf")) {
|
||||
file_name.append(".pdf");
|
||||
}
|
||||
@@ -169,21 +190,23 @@ ProjectPrintWindow::~ProjectPrintWindow()
|
||||
*/
|
||||
void ProjectPrintWindow::requestPaint()
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
#ifdef QT_DEBUG
|
||||
qDebug() << "--";
|
||||
qDebug() << "DiagramPrintDialog::print printer_->resolution() before " << m_printer->resolution();
|
||||
qDebug() << "DiagramPrintDialog::print screennumber " << QApplication::desktop()->screenNumber();
|
||||
#endif
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
|
||||
#ifdef Q_OS_WIN
|
||||
#ifdef QT_DEBUG
|
||||
qDebug() << "--";
|
||||
qDebug() << "DiagramPrintDialog::print printer_->resolution() before " << m_printer->resolution();
|
||||
qDebug() << "DiagramPrintDialog::print screennumber " << QApplication::desktop()->screenNumber();
|
||||
#endif
|
||||
|
||||
QScreen *srn = QApplication::screens().at(QApplication::desktop()->screenNumber());
|
||||
qreal dotsPerInch = (qreal)srn->logicalDotsPerInch();
|
||||
m_printer->setResolution(dotsPerInch);
|
||||
QScreen *srn = QApplication::screens().at(QApplication::desktop()->screenNumber());
|
||||
qreal dotsPerInch = (qreal)srn->logicalDotsPerInch();
|
||||
m_printer->setResolution(dotsPerInch);
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
qDebug() << "DiagramPrintDialog::print dotsPerInch " << dotsPerInch;
|
||||
qDebug() << "DiagramPrintDialog::print printer_->resolution() after" << m_printer->resolution();
|
||||
qDebug() << "--";
|
||||
#ifdef QT_DEBUG
|
||||
qDebug() << "DiagramPrintDialog::print dotsPerInch " << dotsPerInch;
|
||||
qDebug() << "DiagramPrintDialog::print printer_->resolution() after" << m_printer->resolution();
|
||||
qDebug() << "--";
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -236,8 +259,15 @@ void ProjectPrintWindow::printDiagram(Diagram *diagram, bool fit_page, QPainter
|
||||
diagram->render(painter, QRectF(), diagram_rect, Qt::KeepAspectRatio);
|
||||
} else {
|
||||
// Print on one or several pages
|
||||
auto printed_rect = full_page ? printer->paperRect(QPrinter::Millimeter)
|
||||
: printer->pageRect(QPrinter::Millimeter);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 1) // ### Qt 6: remove
|
||||
auto printed_rect = full_page ? printer->paperRect() : printer->pageRect();
|
||||
#else
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove code for QT 6 or later")
|
||||
#endif
|
||||
qDebug()<<"Help code for QT 6 or later";
|
||||
auto printed_rect = full_page ? printer->paperRect(QPrinter::Millimeter) : printer->pageRect(QPrinter::Millimeter);
|
||||
#endif
|
||||
auto used_width = printed_rect.width();
|
||||
auto used_height = printed_rect.height();
|
||||
auto h_pages_count = horizontalPagesCount(diagram, option, full_page);
|
||||
@@ -246,17 +276,24 @@ void ProjectPrintWindow::printDiagram(Diagram *diagram, bool fit_page, QPainter
|
||||
QVector<QVector<QRect>> page_grid;
|
||||
//The diagram is printed on a matrix of sheet
|
||||
//scrolls through the rows of the matrix
|
||||
qreal y_offset = 0;
|
||||
auto y_offset = 0;
|
||||
for (auto i=0 ; i<v_pages_count ; ++i)
|
||||
{
|
||||
page_grid << QVector<QRect>();
|
||||
//scrolls through the lines of sheet
|
||||
qreal x_offset = 0;
|
||||
auto x_offset = 0;
|
||||
for (auto j=0 ; j<h_pages_count ; ++j)
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 1) // ### Qt 6: remove
|
||||
page_grid.last() << QRect(QPoint(x_offset, y_offset),
|
||||
QSize(qMin(used_width, diagram_rect.width() - x_offset),
|
||||
qMin(used_height, diagram_rect.height() - y_offset)));
|
||||
#else
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove code for QT 6 or later")
|
||||
#endif
|
||||
qDebug()<<"Help code for QT 6 or later";
|
||||
#endif
|
||||
x_offset += used_width;
|
||||
}
|
||||
y_offset += used_height;
|
||||
@@ -321,10 +358,17 @@ int ProjectPrintWindow::horizontalPagesCount(
|
||||
Diagram *diagram, const ExportProperties &option, bool full_page) const
|
||||
{
|
||||
QRect printable_area;
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 1) // ### Qt 6: remove
|
||||
printable_area = full_page ? m_printer->paperRect() : m_printer->pageRect();
|
||||
#else
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove code for QT 6 or later")
|
||||
# endif
|
||||
printable_area =
|
||||
full_page ?
|
||||
m_printer->pageLayout().fullRectPixels(m_printer->resolution()) :
|
||||
m_printer->pageLayout().paintRectPixels(m_printer->resolution());
|
||||
#endif
|
||||
QRect diagram_rect = diagramRect(diagram, option);
|
||||
|
||||
int h_pages_count = int(ceil(qreal(diagram_rect.width()) / qreal(printable_area.width())));
|
||||
@@ -343,10 +387,17 @@ int ProjectPrintWindow::verticalPagesCount(
|
||||
Diagram *diagram, const ExportProperties &option, bool full_page) const
|
||||
{
|
||||
QRect printable_area;
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 1) // ### Qt 6: remove
|
||||
printable_area = full_page ? m_printer->paperRect() : m_printer->pageRect();
|
||||
#else
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove code for QT 6 or later")
|
||||
# endif
|
||||
printable_area =
|
||||
full_page ?
|
||||
m_printer->pageLayout().fullRectPixels(m_printer->resolution()) :
|
||||
m_printer->pageLayout().paintRectPixels(m_printer->resolution());
|
||||
#endif
|
||||
QRect diagram_rect = diagramRect(diagram, option);
|
||||
|
||||
int v_pages_count = int(ceil(qreal(diagram_rect.height()) / qreal(printable_area.height())));
|
||||
@@ -417,6 +468,43 @@ void ProjectPrintWindow::loadPageSetupForCurrentPrinter()
|
||||
}
|
||||
|
||||
settings.beginGroup(printer_section);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 1) // ### Qt 6: remove
|
||||
if (settings.contains("orientation")) {
|
||||
QString value = settings.value("orientation", "landscape").toString();
|
||||
m_printer -> setOrientation(value == "landscape" ? QPrinter::Landscape : QPrinter::Portrait);
|
||||
}
|
||||
if (settings.contains("papersize")) {
|
||||
int value = settings.value("papersize", QPrinter::A4).toInt();
|
||||
if (value == QPrinter::Custom) {
|
||||
bool w_ok, h_ok;
|
||||
int w = settings.value("customwidthmm", -1).toInt(&w_ok);
|
||||
int h = settings.value("customheightmm", -1).toInt(&h_ok);
|
||||
if (w_ok && h_ok && w != -1 && h != -1) {
|
||||
m_printer -> setPaperSize(QSizeF(w, h), QPrinter::Millimeter);
|
||||
}
|
||||
} else if (value < QPrinter::Custom) {
|
||||
m_printer -> setPaperSize(static_cast<QPrinter::PaperSize>(value));
|
||||
}
|
||||
}
|
||||
|
||||
qreal margins[4];
|
||||
m_printer -> getPageMargins(&margins[0], &margins[1], &margins[2], &margins[3], QPrinter::Millimeter);
|
||||
QStringList margins_names(QStringList() << "left" << "top" << "right" << "bottom");
|
||||
for (int i = 0 ; i < 4 ; ++ i) {
|
||||
bool conv_ok;
|
||||
qreal value = settings.value("margin" + margins_names.at(i), -1.0).toReal(&conv_ok);
|
||||
if (conv_ok && value != -1.0) margins[i] = value;
|
||||
}
|
||||
m_printer->setPageMargins(
|
||||
margins[0],
|
||||
margins[1],
|
||||
margins[2],
|
||||
margins[3],
|
||||
QPrinter::Millimeter);
|
||||
#else
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove code for QT 6 or later")
|
||||
# endif
|
||||
if (settings.contains("orientation"))
|
||||
{
|
||||
QString value = settings.value("orientation", "landscape").toString();
|
||||
@@ -462,13 +550,14 @@ void ProjectPrintWindow::loadPageSetupForCurrentPrinter()
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
bool conv_ok;
|
||||
qreal value = settings.value("margin" % margins_names.at(i), -1.0)
|
||||
qreal value = settings.value("margin" + margins_names.at(i), -1.0)
|
||||
.toReal(&conv_ok);
|
||||
if (conv_ok && value != -1.0) margins[i] = value;
|
||||
}
|
||||
m_printer->setPageMargins(
|
||||
QMarginsF(margins[0], margins[1], margins[2], margins[3]),
|
||||
QPageLayout::Millimeter);
|
||||
#endif
|
||||
m_printer->setFullPage(
|
||||
settings.value("fullpage", "false").toString() == "true");
|
||||
|
||||
@@ -485,6 +574,35 @@ void ProjectPrintWindow::savePageSetupForCurrentPrinter()
|
||||
settings.beginGroup("printers");
|
||||
settings.beginGroup(printer_section);
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 1) // ### Qt 6: remove
|
||||
settings.setValue("orientation", m_printer -> orientation() == QPrinter::Portrait ? "portrait" : "landscape");
|
||||
settings.setValue("papersize", int(m_printer -> paperSize()));
|
||||
if (m_printer -> paperSize() == QPrinter::Custom) {
|
||||
QSizeF size = m_printer -> paperSize(QPrinter::Millimeter);
|
||||
settings.setValue("customwidthmm", size.width());
|
||||
settings.setValue("customheightmm", size.height());
|
||||
} else {
|
||||
settings.remove("customwidthmm");
|
||||
settings.remove("customheightmm");
|
||||
}
|
||||
qreal left, top, right, bottom;
|
||||
m_printer
|
||||
->getPageMargins(&left, &top, &right, &bottom, QPrinter::Millimeter);
|
||||
settings.setValue("marginleft", left);
|
||||
settings.setValue("margintop", top);
|
||||
settings.setValue("marginright", right);
|
||||
settings.setValue("marginbottom", bottom);
|
||||
settings.setValue("fullpage", m_printer->fullPage() ? "true" : "false");
|
||||
settings.endGroup();
|
||||
settings.endGroup();
|
||||
settings.sync();
|
||||
|
||||
#else
|
||||
# if TODO_LIST
|
||||
# pragma message("@TODO remove code for QT 6 or later")
|
||||
# endif
|
||||
qDebug() << "Help code for QT 6 or later";
|
||||
|
||||
settings.setValue(
|
||||
"orientation",
|
||||
m_printer->pageLayout().orientation() == QPageLayout::Portrait ?
|
||||
@@ -515,6 +633,7 @@ void ProjectPrintWindow::savePageSetupForCurrentPrinter()
|
||||
settings.endGroup();
|
||||
settings.endGroup();
|
||||
settings.sync();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -44,17 +44,17 @@ QDomElement UserProperties::toXml(QDomDocument &xml_document) const
|
||||
|
||||
for (auto i = m_properties.begin(); i != m_properties.end(); ++i)
|
||||
{
|
||||
auto type = i.value().typeId();
|
||||
auto type = i.value().type();
|
||||
switch(type) {
|
||||
case QMetaType::QString:
|
||||
case QVariant::Type::String:
|
||||
up.appendChild(QETXML::createXmlProperty(i.key(), i.value().toString())); break;
|
||||
case QMetaType::Int:
|
||||
case QVariant::Type::Int:
|
||||
up.appendChild(QETXML::createXmlProperty(i.key(), i.value().toInt())); break;
|
||||
case QMetaType::Double:
|
||||
case QVariant::Type::Double:
|
||||
up.appendChild(QETXML::createXmlProperty(i.key(), i.value().toDouble())); break;
|
||||
case QMetaType::Bool:
|
||||
case QVariant::Type::Bool:
|
||||
up.appendChild(QETXML::createXmlProperty(i.key(), i.value().toBool())); break;
|
||||
case QMetaType::QColor:
|
||||
case QVariant::Type::Color:
|
||||
up.appendChild(QETXML::createXmlProperty(i.key(), QColor(i.value().value<QColor>()))); break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -32,6 +32,10 @@
|
||||
en orientation. Si la chaine fait plusieurs caracteres, seul le
|
||||
premier est pris en compte. En cas d'incoherence, Qet::North est
|
||||
retourne.
|
||||
Used to convert a string of characters (‘n’, ‘s’, ‘e’ or ‘w’)
|
||||
into orientation. If the string is made up of several characters,
|
||||
only the only the first is taken into account. In the event of an
|
||||
inconsistency, Qet::North is returned.
|
||||
@param s Chaine de caractere cense representer une orientation
|
||||
@return l'orientation designee par la chaine de caractere
|
||||
*/
|
||||
@@ -60,6 +64,7 @@ QString Qet::orientationToString(Qet::Orientation o) {
|
||||
|
||||
/**
|
||||
Indique si deux orientations de Borne sont sur le meme axe (Vertical / Horizontal).
|
||||
Indicates whether two terminal orientations are on the same axis (Vertical / Horizontal).
|
||||
@param a La premiere orientation de Borne
|
||||
@param b La seconde orientation de Borne
|
||||
@return Un booleen a true si les deux orientations de bornes sont sur le meme axe
|
||||
|
||||
+4
-23
@@ -45,7 +45,7 @@
|
||||
#define STRINGIFY(x) #x
|
||||
#include <QProcessEnvironment>
|
||||
#include <QRegularExpression>
|
||||
#ifdef BUILD_WITHOUT_KF6
|
||||
#ifdef BUILD_WITHOUT_KF5
|
||||
#else
|
||||
# include <KAutoSaveFile>
|
||||
#endif
|
||||
@@ -222,23 +222,6 @@ void QETApp::setLanguage(const QString &desired_language) {
|
||||
|
||||
// load translations for the QET application
|
||||
// charge les traductions pour l'application QET
|
||||
#ifdef QMFILES_AS_RESOURCE
|
||||
if (!qetTranslator.load(QLocale(desired_language), "qet" "_", ":/lang")) {
|
||||
/* in case of failure,
|
||||
* we fall back on the native channels for French
|
||||
* en cas d'echec,
|
||||
* on retombe sur les chaines natives pour le francais
|
||||
*/
|
||||
if (desired_language != "fr") {
|
||||
// use of the English version by default
|
||||
// utilisation de la version anglaise par defaut
|
||||
if(!qetTranslator.load(QLocale(desired_language), "qet", "_", ":/lang"))
|
||||
qWarning() << "failed to load"
|
||||
<< ":/lang/qet_en.qm" << "(" << __FILE__
|
||||
<< __LINE__ << __FUNCTION__ << ")";
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (!qetTranslator.load("qet_" + desired_language, languages_path)) {
|
||||
/* in case of failure,
|
||||
* we fall back on the native channels for French
|
||||
@@ -254,8 +237,6 @@ void QETApp::setLanguage(const QString &desired_language) {
|
||||
<< __LINE__ << __FUNCTION__ << ")";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
qInfo() << "Loaded language file:" << qetTranslator.filePath();
|
||||
qApp->installTranslator(&qetTranslator);
|
||||
|
||||
QString ltr_special_string = tr(
|
||||
@@ -1279,7 +1260,7 @@ QFont QETApp::diagramTextsFont(qreal size)
|
||||
}
|
||||
/**
|
||||
@brief QETApp::diagramTextsItemFont
|
||||
the font for to use in independent text item
|
||||
the font to use in independent text items
|
||||
@param size of font
|
||||
@return
|
||||
*/
|
||||
@@ -1294,7 +1275,7 @@ QFont QETApp::diagramTextsItemFont(qreal size)
|
||||
9.0).toDouble();
|
||||
auto diagram_texts_item_weight =
|
||||
static_cast<QFont::Weight>(
|
||||
settings.value("diagramitemweight").toInt());
|
||||
settings.value("diagramitemweight", QFont::Normal).toInt());
|
||||
QString diagram_texts_item_style = settings.value("diagramitemstyle",
|
||||
"normal").toString();
|
||||
|
||||
@@ -2387,7 +2368,7 @@ void QETApp::buildSystemTrayMenu()
|
||||
*/
|
||||
void QETApp::checkBackupFiles()
|
||||
{
|
||||
#ifdef BUILD_WITHOUT_KF6
|
||||
#ifdef BUILD_WITHOUT_KF5
|
||||
return;
|
||||
#else
|
||||
QList<KAutoSaveFile *> stale_files = KAutoSaveFile::allStaleFiles();
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
#include "ui/diagrameditorhandlersizewidget.h"
|
||||
#include "TerminalStrip/ui/addterminalstripitemdialog.h"
|
||||
|
||||
#ifdef BUILD_WITHOUT_KF6
|
||||
#ifdef BUILD_WITHOUT_KF5
|
||||
#else
|
||||
# include <KAutoSaveFile>
|
||||
#endif
|
||||
@@ -95,7 +95,7 @@ QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) :
|
||||
m_workspace.setTabsClosable(true);
|
||||
|
||||
//Set the signal mapper
|
||||
connect(&windowMapper, SIGNAL(mapped(QWidget*)), this, SLOT(activateWidget(QWidget*)));
|
||||
connect(&windowMapper, SIGNAL(mapped(QWidget *)), this, SLOT(activateWidget(QWidget *)));
|
||||
|
||||
setWindowTitle(tr("QElectroTech", "window title"));
|
||||
setWindowIcon(QET::Icons::QETLogo);
|
||||
@@ -1597,7 +1597,7 @@ void QETDiagramEditor::slot_updateUndoStack()
|
||||
|
||||
/**
|
||||
@brief QETDiagramEditor::slot_updateComplexActions
|
||||
Manage the actions who need some conditions to be enable or not.
|
||||
Manage the actions that need some conditions to be enabled or not.
|
||||
This method does nothing if there is no project opened
|
||||
*/
|
||||
void QETDiagramEditor::slot_updateComplexActions()
|
||||
@@ -1633,7 +1633,7 @@ void QETDiagramEditor::slot_updateComplexActions()
|
||||
int selected_elements_count = dc.count(DiagramContent::Elements);
|
||||
m_find_element->setEnabled(selected_elements_count == 1);
|
||||
|
||||
//Action that need items (elements, conductors, texts...) selected, to be enabled
|
||||
//Actions that need items (elements, conductors, texts...) selected, to be enabled
|
||||
bool copiable_items = dc.hasCopiableItems();
|
||||
bool deletable_items = dc.hasDeletableItems();
|
||||
m_cut -> setEnabled(!ro && copiable_items);
|
||||
@@ -1892,7 +1892,7 @@ bool QETDiagramEditor::drawGrid() const
|
||||
return m_draw_grid->isChecked();
|
||||
}
|
||||
|
||||
#ifdef BUILD_WITHOUT_KF6
|
||||
#ifdef BUILD_WITHOUT_KF5
|
||||
#else
|
||||
/**
|
||||
@brief QETDiagramEditor::openBackupFiles
|
||||
|
||||
@@ -43,7 +43,7 @@ class DiagramPropertiesEditorDockWidget;
|
||||
class ElementsCollectionWidget;
|
||||
class AutoNumberingDockWidget;
|
||||
|
||||
#ifdef BUILD_WITHOUT_KF6
|
||||
#ifdef BUILD_WITHOUT_KF5
|
||||
#else
|
||||
class KAutoSaveFile;
|
||||
#endif
|
||||
@@ -69,7 +69,7 @@ class QETDiagramEditor : public QETMainWindow
|
||||
ProjectView *currentProjectView() const;
|
||||
QETProject *currentProject() const;
|
||||
bool drawGrid() const;
|
||||
#ifdef BUILD_WITHOUT_KF6
|
||||
#ifdef BUILD_WITHOUT_KF5
|
||||
#else
|
||||
void openBackupFiles (QList<KAutoSaveFile *> backup_files);
|
||||
#endif
|
||||
@@ -195,9 +195,7 @@ class QETDiagramEditor : public QETMainWindow
|
||||
*m_terminal_strip_dialog = nullptr, ///<Launch terminal strip dialog
|
||||
*m_project_terminalBloc, ///< generate terminal block
|
||||
*m_project_export_conductor_num,///<Export the wire num to csv
|
||||
#ifdef QET_EXPORT_PROJECT_DB
|
||||
*m_export_project_db, ///Export to file the internal database of the current project
|
||||
#endif
|
||||
*m_tile_window, ///< Show MDI subwindows as tile
|
||||
*m_cascade_window, ///< Show MDI subwindows as cascade
|
||||
*m_previous_window, ///< Switch to the previous document
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user