mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 13:30:34 +01:00
Mod some qWarning add QObject::tr
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
/*
|
||||
Copyright 2006-2020 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/>.
|
||||
*/
|
||||
@@ -43,21 +43,21 @@ void SearchAndReplaceWorker::replaceDiagram(QList<Diagram *> diagram_list)
|
||||
if (diagram_list.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
QETProject *project = diagram_list.first()->project();
|
||||
for (Diagram *d : diagram_list) {
|
||||
if (d->project() != project) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QUndoStack *us = project->undoStack();
|
||||
us->beginMacro(QObject::tr("Chercher/remplacer les propriétés de folio"));
|
||||
for (Diagram *d : diagram_list)
|
||||
{
|
||||
TitleBlockProperties old_propertie = d->border_and_titleblock.exportTitleBlock();
|
||||
TitleBlockProperties new_properties = old_propertie;
|
||||
|
||||
|
||||
new_properties.title = applyChange(new_properties.title, m_titleblock_properties.title);
|
||||
new_properties.author = applyChange(new_properties.author, m_titleblock_properties.author);
|
||||
new_properties.filename = applyChange(new_properties.filename, m_titleblock_properties.filename);
|
||||
@@ -74,9 +74,9 @@ void SearchAndReplaceWorker::replaceDiagram(QList<Diagram *> diagram_list)
|
||||
new_properties.date = m_titleblock_properties.date;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
new_properties.context.add(m_titleblock_properties.context);
|
||||
|
||||
|
||||
if (old_propertie != new_properties) {
|
||||
project->undoStack()->push(new ChangeTitleBlockCommand(d, old_propertie, new_properties));
|
||||
}
|
||||
@@ -105,7 +105,7 @@ void SearchAndReplaceWorker::replaceElement(QList<Element *> list)
|
||||
if (list.isEmpty() || !list.first()->diagram()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
QETProject *project_ = list.first()->diagram()->project();
|
||||
for (Element *elmt : list)
|
||||
{
|
||||
@@ -115,7 +115,7 @@ void SearchAndReplaceWorker::replaceElement(QList<Element *> list)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
project_->undoStack()->beginMacro(QObject::tr("Chercher/remplacer les propriétés d'éléments."));
|
||||
for (Element *elmt : list)
|
||||
{
|
||||
@@ -131,7 +131,7 @@ void SearchAndReplaceWorker::replaceElement(QList<Element *> list)
|
||||
new_context.addValue(key, applyChange(old_context.value(key).toString(),
|
||||
m_element_context.value(key).toString()));
|
||||
}
|
||||
|
||||
|
||||
if (old_context != new_context)
|
||||
{
|
||||
ChangeElementInformationCommand *undo = new ChangeElementInformationCommand(elmt, old_context, new_context);
|
||||
@@ -167,7 +167,7 @@ void SearchAndReplaceWorker::replaceIndiText(QList<IndependentTextItem *> list)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
project_->undoStack()->beginMacro(QObject::tr("Chercher/remplacer des textes independants"));
|
||||
for (IndependentTextItem *text : list)
|
||||
{
|
||||
@@ -199,7 +199,7 @@ void SearchAndReplaceWorker::replaceConductor(QList<Conductor *> list)
|
||||
if (list.isEmpty() || !list.first()->diagram()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
QETProject *project_ = list.first()->diagram()->project();
|
||||
for (Conductor *c : list) {
|
||||
if (!c->diagram() ||
|
||||
@@ -207,12 +207,12 @@ void SearchAndReplaceWorker::replaceConductor(QList<Conductor *> list)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
project_->undoStack()->beginMacro(QObject::tr("Chercher/remplacer les propriétés de conducteurs."));
|
||||
for (Conductor *c : list)
|
||||
{
|
||||
ConductorProperties cp = applyChange(c->properties(), m_conductor_properties);
|
||||
|
||||
|
||||
if (cp != c->properties())
|
||||
{
|
||||
QSet <Conductor *> conductors_list = c->relatedPotentialConductors(true);
|
||||
@@ -253,7 +253,7 @@ void SearchAndReplaceWorker::replaceAdvanced(
|
||||
QList<Conductor *> conductors)
|
||||
{
|
||||
QETProject *project_ = nullptr;
|
||||
|
||||
|
||||
//Some test to check if a least one list have one item
|
||||
//and if all items belong to the same project
|
||||
if (!diagrams.isEmpty()) {
|
||||
@@ -267,7 +267,7 @@ void SearchAndReplaceWorker::replaceAdvanced(
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
for (Diagram *dd : diagrams) {
|
||||
if (dd->project() != project_) {
|
||||
return;
|
||||
@@ -289,12 +289,12 @@ void SearchAndReplaceWorker::replaceAdvanced(
|
||||
}
|
||||
}
|
||||
//The end of the test
|
||||
|
||||
|
||||
int who = m_advanced_struct.who;
|
||||
if (who == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
project_->undoStack()->beginMacro(QObject::tr("Rechercher / remplacer avancé"));
|
||||
if (who == 0)
|
||||
{
|
||||
@@ -328,7 +328,7 @@ void SearchAndReplaceWorker::replaceAdvanced(
|
||||
{
|
||||
QSet <Conductor *> potential_conductors = conductor->relatedPotentialConductors(true);
|
||||
potential_conductors << conductor;
|
||||
|
||||
|
||||
for (Conductor *c : potential_conductors)
|
||||
{
|
||||
QVariant old_value, new_value;
|
||||
@@ -344,10 +344,16 @@ void SearchAndReplaceWorker::replaceAdvanced(
|
||||
for (IndependentTextItem *text : texts)
|
||||
{
|
||||
QRegularExpression rx(m_advanced_struct.search);
|
||||
if (!rx.isValid())
|
||||
{
|
||||
qWarning() <<QObject::tr("this is an error in the code")
|
||||
<< rx.errorString()
|
||||
<< rx.patternErrorOffset();
|
||||
}
|
||||
QString replace = m_advanced_struct.replace;
|
||||
QString after = text->toPlainText();
|
||||
after = after.replace(rx, replace);
|
||||
|
||||
|
||||
if (after != text->toPlainText()) {
|
||||
project_->undoStack()->push(new ChangeDiagramTextCommand(text, text->toPlainText(), after));
|
||||
}
|
||||
@@ -380,7 +386,7 @@ void SearchAndReplaceWorker::setupLineEdit(QLineEdit *l,
|
||||
ConductorProperties SearchAndReplaceWorker::invalidConductorProperties()
|
||||
{
|
||||
ConductorProperties cp;
|
||||
|
||||
|
||||
//init with invalid value the conductor properties
|
||||
cp.text_size = 0;
|
||||
cp.text.clear();
|
||||
@@ -393,7 +399,7 @@ ConductorProperties SearchAndReplaceWorker::invalidConductorProperties()
|
||||
cp.cond_size = 0;
|
||||
cp.m_color_2 = QColor();
|
||||
cp.m_dash_size = 0;
|
||||
|
||||
|
||||
return cp;
|
||||
}
|
||||
|
||||
@@ -408,7 +414,7 @@ ConductorProperties SearchAndReplaceWorker::applyChange(
|
||||
const ConductorProperties &change)
|
||||
{
|
||||
ConductorProperties new_properties = original;
|
||||
|
||||
|
||||
if (change.text_size > 2) {new_properties.text_size = change.text_size;}
|
||||
new_properties.m_formula = applyChange(new_properties.m_formula, change.m_formula);
|
||||
new_properties.text = applyChange(new_properties.text, change.text);
|
||||
@@ -430,7 +436,7 @@ ConductorProperties SearchAndReplaceWorker::applyChange(
|
||||
if (change.m_color_2.isValid()) {new_properties.m_color_2 = change.m_color_2;}
|
||||
if (change.m_dash_size >= 2) {new_properties.m_dash_size = change.m_dash_size;}
|
||||
new_properties.singleLineProperties = change.singleLineProperties;
|
||||
|
||||
|
||||
return new_properties;
|
||||
}
|
||||
|
||||
@@ -457,10 +463,16 @@ QString SearchAndReplaceWorker::applyChange(const QString &original,
|
||||
TitleBlockProperties SearchAndReplaceWorker::replaceAdvanced(Diagram *diagram)
|
||||
{
|
||||
TitleBlockProperties p = diagram->border_and_titleblock.exportTitleBlock();
|
||||
|
||||
|
||||
if (m_advanced_struct.who == 0)
|
||||
{
|
||||
QRegularExpression rx(m_advanced_struct.search);
|
||||
if (!rx.isValid())
|
||||
{
|
||||
qWarning() <<QObject::tr("this is an error in the code")
|
||||
<< rx.errorString()
|
||||
<< rx.patternErrorOffset();
|
||||
}
|
||||
QString replace = m_advanced_struct.replace;
|
||||
QString what = m_advanced_struct.what;
|
||||
if (what == "title") {p.title = p.title.replace(rx, replace);}
|
||||
@@ -483,19 +495,25 @@ TitleBlockProperties SearchAndReplaceWorker::replaceAdvanced(Diagram *diagram)
|
||||
DiagramContext SearchAndReplaceWorker::replaceAdvanced(Element *element)
|
||||
{
|
||||
DiagramContext context = element->elementInformations();
|
||||
|
||||
|
||||
if (m_advanced_struct.who == 1)
|
||||
{
|
||||
QString what = m_advanced_struct.what;
|
||||
if (context.contains(what))
|
||||
{
|
||||
QRegularExpression rx(m_advanced_struct.search);
|
||||
if (!rx.isValid())
|
||||
{
|
||||
qWarning() <<QObject::tr("this is an error in the code")
|
||||
<< rx.errorString()
|
||||
<< rx.patternErrorOffset();
|
||||
}
|
||||
QString replace = m_advanced_struct.replace;
|
||||
QString value = context[what].toString();
|
||||
context.addValue(what, value.replace(rx, replace));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
@@ -509,13 +527,19 @@ ConductorProperties SearchAndReplaceWorker::replaceAdvanced(
|
||||
Conductor *conductor)
|
||||
{
|
||||
ConductorProperties properties = conductor->properties();
|
||||
|
||||
|
||||
if (m_advanced_struct.who == 2)
|
||||
{
|
||||
QRegularExpression rx(m_advanced_struct.search);
|
||||
if (!rx.isValid())
|
||||
{
|
||||
qWarning() <<QObject::tr("this is an error in the code")
|
||||
<< rx.errorString()
|
||||
<< rx.patternErrorOffset();
|
||||
}
|
||||
QString what = m_advanced_struct.what;
|
||||
QString replace = m_advanced_struct.replace;
|
||||
|
||||
|
||||
if (what == "formula") {properties.m_formula.replace(rx, replace);}
|
||||
else if (what == "text") {properties.text.replace(rx, replace);}
|
||||
else if (what == "function") {properties.m_function.replace(rx, replace);}
|
||||
@@ -523,6 +547,6 @@ ConductorProperties SearchAndReplaceWorker::replaceAdvanced(
|
||||
else if (what == "conductor_color") {properties.m_wire_color.replace(rx, replace);}
|
||||
else if (what == "conductor_section") {properties.m_wire_section.replace(rx, replace);}
|
||||
}
|
||||
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user