From 6375136a5097705259a2ef4289a33ddcc1df6ba4 Mon Sep 17 00:00:00 2001 From: Laurent Trinques Date: Mon, 18 Aug 2025 14:04:27 +0200 Subject: [PATCH 1/2] Fix bughttps://qelectrotech.org/bugtracker/view.php?id=329 Modification of the int BACKUP_INTERVAL from 2 min to 20 min used by KautoSaveFile. On a large project with a 256 MB folio printed in A0 format, the graphical interface freezes for 30 seconds when KautoSaveFile writes this large amount of data to the disk every two minutes. Even if the programme crashes, you only lose 20 minutes of your work, which is not a big deal. Thanks to Enzo for reporting it and finding the problem. --- sources/qetproject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/qetproject.cpp b/sources/qetproject.cpp index 3ecb8bdf6..e81b365b9 100644 --- a/sources/qetproject.cpp +++ b/sources/qetproject.cpp @@ -41,7 +41,7 @@ #include #include -static int BACKUP_INTERVAL = 120000; //interval in ms of backup = 2min +static int BACKUP_INTERVAL = 1200000; //interval in ms of backup = 20min /** @brief QETProject::QETProject From 73ce3ae9fe877645f12ce0e9fd4ac9f4a8642d31 Mon Sep 17 00:00:00 2001 From: achim Date: Tue, 19 Aug 2025 20:16:31 +0200 Subject: [PATCH 2/2] Correct compositeText alignment on copying After the commit 'Correcting dynamicElementTextItem alignment on copying', not all composite text was displayed correctly. As soon as the composite text contained multiple variables in a line or user text, the alignment was no longer correct. Furthermore, the text value was not correctly written to the clipboard, so it was no longer present when pasting. I have corrected these errors here. --- sources/diagram.cpp | 121 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 99 insertions(+), 22 deletions(-) diff --git a/sources/diagram.cpp b/sources/diagram.cpp index 41996cf06..3e9ef7c12 100644 --- a/sources/diagram.cpp +++ b/sources/diagram.cpp @@ -38,6 +38,7 @@ #include "qetgraphicsitem/terminal.h" #include "qetxml.h" #include "undocommand/addelementtextcommand.h" +#include "qetinformation.h" #include #include @@ -2496,35 +2497,88 @@ bool Diagram::canRotateSelection() const void Diagram::correctTextPos(Element* elmt) { for (auto deti : elmt->dynamicTextItems()){ - if( deti->textFrom() == DynamicElementTextItem::ElementInfo || - deti->textFrom() == DynamicElementTextItem::CompositeText) { - if (deti->text().isEmpty()){ - deti->setText(deti->toPlainText()); + // correct dynamicElementTextItem of type ElementInfo + if( deti->textFrom() == DynamicElementTextItem::ElementInfo){ + // save current PlainText + deti->setText(deti->toPlainText()); + // writing an empty string to PlainText set + // the insertion point to the original insertion point + deti->setPlainText(""); + // block the alignment calculation for the next write action + deti->m_block_alignment = true; + // we need to set the plain text with its value, + // otherewise the text value will not be copy + deti->setPlainText(deti->text()); + deti->m_block_alignment = false; + } + // correct dynamicElementTextItem of type CompositeText + else if(deti->textFrom() == DynamicElementTextItem::CompositeText){ + QString composite_text = deti->compositeText(); + + // create compositeText() without variables for slave item + // This string corresponds to the original text with original insertion point + if(elmt->linkType()==Element::Slave){ + const QStringList variables_list = QETInformation::elementInfoKeys(); + for (auto &variable : variables_list){ + if(composite_text.contains(QETInformation::infoToVar(variable))) + composite_text.replace(QETInformation::infoToVar(variable),""); + } } - // block alignment calculation + // create compositeText() without variables for report item + else if(elmt->linkType()&Element::AllReport){ + const QStringList variables_list = QETInformation::folioReportInfoKeys(); + for (auto &variable : variables_list){ + if(composite_text.contains(QETInformation::infoToVar(variable))) + composite_text.replace(QETInformation::infoToVar(variable),""); + } + } + + deti->setText(deti->toPlainText()); + deti->setPlainText(composite_text); deti->m_block_alignment = true; deti->setPlainText(deti->text()); - // release the alignment calculation deti->m_block_alignment = false; - // writing an empty string sets the insertion point - // to the original insertion point - deti->setPlainText(""); + // We need the string for the restoration, so we save it + deti->setText(composite_text); } } - // same for textgroups + + // same for textgroups for (auto group : elmt->textGroups()){ for(DynamicElementTextItem *deti : group->texts()){ - if( deti->textFrom() == DynamicElementTextItem::ElementInfo || - deti->textFrom() == DynamicElementTextItem::CompositeText) { - if (deti->text().isEmpty()){ - deti->setText(deti->toPlainText()); - } + if( deti->textFrom() == DynamicElementTextItem::ElementInfo){ + deti->setText(deti->toPlainText()); deti->m_block_alignment = true; deti->setPlainText(deti->text()); deti->m_block_alignment = false; deti->setPlainText(""); } + + else if(deti->textFrom() == DynamicElementTextItem::CompositeText){ + QString composite_text = deti->compositeText(); + if(elmt->linkType()==Element::Slave){ + QStringList variables_list = QETInformation::elementInfoKeys(); + for (auto variable : variables_list){ + if(composite_text.contains(QETInformation::infoToVar(variable))) + composite_text.replace(QETInformation::infoToVar(variable),""); + } + } + else if(elmt->linkType()&Element::AllReport){ + QStringList variables_list = QETInformation::folioReportInfoKeys(); + for (auto variable : variables_list){ + if(composite_text.contains(QETInformation::infoToVar(variable))) + composite_text.replace(QETInformation::infoToVar(variable),""); + } + } + + deti->setText(deti->toPlainText()); + deti->setPlainText(composite_text); + deti->m_block_alignment = true; + deti->setPlainText(deti->text()); + deti->m_block_alignment = false; + deti->setText(composite_text); + } } } } @@ -2541,18 +2595,41 @@ void Diagram::correctTextPos(Element* elmt) void Diagram::restoreText(Element* elmt) { for (auto deti : elmt->dynamicTextItems()){ - if( deti->textFrom() == DynamicElementTextItem::ElementInfo || - deti->textFrom() == DynamicElementTextItem::CompositeText) - { + // restore info text + if( deti->textFrom() == DynamicElementTextItem::ElementInfo){ + // delete the actual plainText without alignmant calculation + deti->m_block_alignment = true; + deti->setPlainText(""); + deti->m_block_alignment = false; + // restore the plainText + deti->setPlainText(deti->text()); + } + // restore composite text + else if (deti->textFrom() == DynamicElementTextItem::CompositeText){ + QString composite_text = deti->text(); + deti->setText(deti->toPlainText()); + // set the PlainText to the origin text without alignment calculation + deti->m_block_alignment = true; + deti->setPlainText(composite_text); + deti->m_block_alignment = false; deti->setPlainText(deti->text()); } } - + // same for text groups for (auto group : elmt->textGroups()){ for(DynamicElementTextItem *deti : group->texts()){ - if( deti->textFrom() == DynamicElementTextItem::ElementInfo || - deti->textFrom() == DynamicElementTextItem::CompositeText) - { + if( deti->textFrom() == DynamicElementTextItem::ElementInfo){ + deti->m_block_alignment = true; + deti->setPlainText(""); + deti->m_block_alignment = false; + deti->setPlainText(deti->text()); + } + else if (deti->textFrom() == DynamicElementTextItem::CompositeText){ + QString composite_text = deti->text(); + deti->setText(deti->toPlainText()); + deti->m_block_alignment = true; + deti->setPlainText(composite_text); + deti->m_block_alignment = false; deti->setPlainText(deti->text()); } }