19 #include "ui_searchandreplacewidget.h" 80 else if (
event->type() == QEvent::Show)
82 ui->m_search_le->setFocus();
87 return QWidget::event(
event);
112 qtwi->setHidden(
false);
114 ui->m_tree_widget->collapseAll();
115 ui->m_tree_widget->clearSelection();
117 ui->m_search_le->clear();
118 ui->m_replace_le->clear();
120 ui->m_search_le->setPalette(QPalette());
209 ui->m_advanced_pb ->setChecked(!hide);
210 ui->m_replace ->setHidden(hide);
211 ui->m_replace_le ->setHidden(hide);
212 ui->m_folio_pb ->setHidden(hide);
213 ui->m_element_pb ->setHidden(hide);
214 ui->m_conductor_pb ->setHidden(hide);
215 ui->m_tree_widget ->setHidden(hide);
216 ui->m_replace_pb ->setHidden(hide);
217 ui->m_replace_all_pb ->setHidden(hide);
218 ui->m_mode_cb ->setHidden(hide);
219 ui->m_case_sensitive_cb->setHidden(hide);
220 ui->m_advanced_replace_pb->setHidden(hide);
237 ui->m_replace_all_pb->setDisabled(
true);
240 ui->m_replace_all_pb->setEnabled(
true);
250 if (settings.value(
"genericpanel/folio",
true).toBool()) {
251 str = diagram->border_and_titleblock.finalfolio();
253 str = QString::number(diagram->folioIndex());
256 str.append(
" " + diagram->title());
258 QTreeWidgetItem *qtwi =
new QTreeWidgetItem(
m_folio_qtwi);
259 qtwi->setText(0, str);
260 qtwi->setData(0, Qt::UserRole,
searchTerms(diagram));
261 qtwi->setCheckState(0, Qt::Checked);
273 qtwi->sortChildren(0, Qt::AscendingOrder);
274 qtwi->setHidden(qtwi->childCount() ? false :
true);
280 qtwi->setText(0, iti->toPlainText());
281 qtwi->setCheckState(0, Qt::Checked);
282 qtwi->setData(0, Qt::UserRole, iti->toPlainText());
283 m_text_hash.insert(qtwi, QPointer<IndependentTextItem>(iti));
291 qtwi->setCheckState(0, Qt::Checked);
331 QTreeWidgetItem *qtwi =
new QTreeWidgetItem(parent);
340 str =
tr(
"Inconnue");
341 qtwi->setText(0, str);
342 qtwi->setCheckState(0, Qt::Checked);
343 qtwi->setData(0, Qt::UserRole,
searchTerms(element));
352 QString str =
ui->m_search_le->text();
356 (*it)->setHidden(
false);
360 item->setExpanded(
false);
365 ui->m_search_le->setPalette(QPalette());
370 (*it)->setHidden(
true);
377 QList<QTreeWidgetItem *> qtwi_list;
382 for (QTreeWidgetItem *qtwi : qtwi_list)
384 QStringList list = qtwi->data(0, Qt::UserRole).toStringList();
386 if(
ui->m_mode_cb->currentIndex() == 0)
389 list = list.filter(str,
ui->m_case_sensitive_cb->isChecked()? Qt::CaseSensitive : Qt::CaseInsensitive);
394 QRegularExpression rx(
"\\b" + str +
"\\b");
395 if (!
ui->m_case_sensitive_cb->isChecked()) {
396 rx.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
398 list = list.filter(rx);
403 qtwi->setHidden(
false);
408 QPalette background =
ui->m_search_le->palette();
409 background.setColor(QPalette::Base, match ? QColor(
"#E0FFF0") : QColor(
"#FFE0EF"));
410 ui->m_search_le->setPalette(background);
428 QTreeWidgetItem *parent = item->parent();
429 parent->setHidden(
false);
431 parent->setExpanded(expend_parent);
443 QTreeWidgetItem *qtwi = item;
445 qtwi =
ui->m_tree_widget->currentItem();
452 QTreeWidgetItemIterator
it(qtwi, flags);
455 QTreeWidgetItem *next_ = *
it;
472 QTreeWidgetItem *qtwi = item;
474 qtwi =
ui->m_tree_widget->currentItem();
481 QTreeWidgetItemIterator
it(qtwi, flags);
484 QTreeWidgetItem *previous_ = *
it;
500 QTreeWidgetItem *item_ =
ui->m_tree_widget->currentItem();
503 ui->m_next_pb->setEnabled(
true);
504 ui->m_previous_pb->setDisabled(
true);
508 QTreeWidgetItem *next_ = item_;
511 next_ =
nextItem(next_, QTreeWidgetItemIterator::NotHidden);
514 ui->m_next_pb->setDisabled(
true);
519 ui->m_next_pb->setEnabled(
true);
524 QTreeWidgetItem *previous_ = item_;
527 previous_ =
previousItem(previous_, QTreeWidgetItemIterator::NotHidden);
530 ui->m_previous_pb->setDisabled(
true);
535 ui->m_previous_pb->setEnabled(
true);
551 ui->m_tree_widget->blockSignals(
true);
556 ui->m_tree_widget->blockSignals(
false);
567 for (
int i=0 ; i<item->childCount() ; ++i)
569 item->child(i)->setCheckState(0, check);
570 if (deep && item->child(i)->childCount()) {
583 QTreeWidgetItem *parent = item->parent();
592 for (
int i=0 ; i<parent->childCount() ; ++i)
594 switch (parent->child(i)->checkState(0)) {
598 case Qt::PartiallyChecked:
606 if (check == parent->childCount()) {
607 parent->setCheckState(0, Qt::Checked);
609 else if (partially || check) {
610 parent->setCheckState(0, Qt::PartiallyChecked);
613 parent->setCheckState(0, Qt::Unchecked);
616 if (all_parents && item->parent()) {
628 if (!
ui->m_next_pb->isEnabled())
633 }
while ((
ui->m_tree_widget->currentItem()->checkState(0) != Qt::Checked) &&
634 ui->m_next_pb->isEnabled());
643 QList <Diagram *> diagram_list;
647 if (!qtwi->isHidden() && qtwi->checkState(0) == Qt::Checked)
651 diagram_list.append(p.data());
665 QList <Element *> element_list;
669 if (!qtwi->isHidden() && qtwi->checkState(0) == Qt::Checked)
673 element_list.append(p.data());
687 QList <Conductor *> conductor_list;
691 if (!qtwi->isHidden() && qtwi->checkState(0) == Qt::Checked)
695 conductor_list.append(c.data());
700 return conductor_list;
709 QList <IndependentTextItem *> text_list;
713 if (!qtwi->isHidden() && qtwi->checkState(0) == Qt::Checked)
715 QPointer<IndependentTextItem> t =
m_text_hash.value(qtwi);
717 text_list.append(t.data());
734 list.append(prop.
title);
737 list.append(prop.
plant);
740 list.append(prop.
folio);
741 list.append(prop.
date.toString());
760 QString str = context.
value(key).toString();
761 if (!str.isEmpty()) {
769 list.append(deti->toPlainText());
774 list.append(group->name());
778 list.append(deti->toPlainText());
796 list.append(properties.
text);
804 this->setHidden(
true);
819 diagram.data()->showMe();
826 elmt.data()->diagram()->showMe();
831 QPointer<IndependentTextItem> text =
m_text_hash.value(item);
833 text.data()->diagram()->showMe();
840 cond.data()->diagram()->showMe();
859 ui->m_search_le->setFocus();
881 elmt.data()->setHighlighted(
true);
886 QPointer<IndependentTextItem> text =
m_text_hash.value(current);
889 text.data()->setSelected(
true);
898 cond.data()->setSelected(
true);
908 if (current->checkState(0) == Qt::Checked && !
m_category_qtwi.contains(current)) {
909 ui->m_replace_pb->setEnabled(
true);
911 ui->m_replace_pb->setDisabled(
true);
917 QTreeWidgetItem *item =
nullptr;
921 item =
nextItem(
nullptr, QTreeWidgetItemIterator::NotHidden);
923 ui->m_tree_widget->setCurrentItem(item);
929 ui->m_tree_widget->setCurrentItem(item);
930 ui->m_tree_widget->scrollToItem(item);
936 QTreeWidgetItem *item =
nullptr;
940 item =
previousItem(
nullptr, QTreeWidgetItemIterator::NotHidden);
942 ui->m_tree_widget->setCurrentItem(item);
954 ui->m_tree_widget->setCurrentItem(item);
955 ui->m_tree_widget->scrollToItem(item);
964 int result = dialog->exec();
965 if (result == QDialogButtonBox::AcceptRole)
967 QString text =
ui->m_folio_pb->text();
968 if (!text.endsWith(
tr(
" [édité]"))) {
969 text.append(
tr(
" [édité]"));
971 ui->m_folio_pb->setText(text);
974 else if (result == QDialogButtonBox::ResetRole)
976 QString text =
ui->m_folio_pb->text();
977 if (text.endsWith(
tr(
" [édité]"))) {
978 text.remove(
tr(
" [édité]"));
980 ui->m_folio_pb->setText(text);
991 QTreeWidgetItem *qtwi =
ui->m_tree_widget->currentItem();
995 if (!
m_category_qtwi.contains(qtwi) && qtwi->checkState(0) == Qt::Checked)
997 if (
ui->m_folio_pb->text().endsWith(
tr(
" [édité]")) &&
1005 else if (
ui->m_element_pb->text().endsWith(
tr(
" [édité]")) &&
1013 else if (!
ui->m_replace_le->text().isEmpty() &&
1017 QPointer<IndependentTextItem> t =
m_text_hash.value(qtwi);
1023 else if (
ui->m_conductor_pb->text().endsWith(
tr(
" [édité]")) &&
1033 if (
ui->m_advanced_replace_pb->text().endsWith(
tr(
" [édité]")))
1035 QList <Diagram *>dl;
1036 QList <Element *>el;
1037 QList <IndependentTextItem *>tl;
1038 QList <Conductor *>cl;
1044 dl.append(d.data());
1051 el.append(e.data());
1056 QPointer<IndependentTextItem> t =
m_text_hash.value(qtwi);
1058 tl.append(t.data());
1065 cl.append(c.data());
1074 ui->m_replace_pb->setEnabled(
ui->m_next_pb->isEnabled());
1083 if (
ui->m_folio_pb->text().endsWith(
tr(
" [édité]"))) {
1086 if (
ui->m_element_pb->text().endsWith(
tr(
" [édité]"))) {
1089 if (!
ui->m_replace_le->text().isEmpty()) {
1093 if (
ui->m_conductor_pb->text().endsWith(
tr(
" [édité]"))) {
1096 if (
ui->m_advanced_replace_pb->text().endsWith(
tr(
" [édité]"))) {
1104 QString txt =
ui->m_search_le->text();
1106 ui->m_search_le->setText(txt);
1114 int result = dialog->exec();
1115 if (result == QDialogButtonBox::AcceptRole)
1117 QString text =
ui->m_element_pb->text();
1118 if (!text.endsWith(
tr(
" [édité]"))) {
1119 text.append(
tr(
" [édité]"));
1121 ui->m_element_pb->setText(text);
1124 else if (result == QDialogButtonBox::ResetRole)
1126 QString text =
ui->m_element_pb->text();
1127 if (text.endsWith(
tr(
" [édité]"))) {
1128 text.remove(
tr(
" [édité]"));
1130 ui->m_element_pb->setText(text);
1164 int result = dialog->exec();
1166 if (result == QDialogButtonBox::AcceptRole)
1168 QString text =
ui->m_conductor_pb->text();
1169 if (!text.endsWith(
tr(
" [édité]"))) {
1170 text.append(
tr(
" [édité]"));
1172 ui->m_conductor_pb->setText(text);
1175 else if (result == QDialogButtonBox::ResetRole)
1177 QString text =
ui->m_conductor_pb->text();
1178 if (text.endsWith(
tr(
" [édité]"))) {
1179 text.remove(
tr(
" [édité]"));
1181 ui->m_conductor_pb->setText(text);
1193 int result = dialog->exec();
1195 if (result == QDialogButtonBox::AcceptRole)
1197 QString text =
ui->m_advanced_replace_pb->text();
1198 if (!text.endsWith(
tr(
" [édité]"))) {
1199 text.append(
tr(
" [édité]"));
1201 ui->m_advanced_replace_pb->setText(text);
1204 else if (result == QDialogButtonBox::ResetRole)
1206 QString text =
ui->m_advanced_replace_pb->text();
1207 if (text.endsWith(
tr(
" [édité]"))) {
1208 text.remove(
tr(
" [édité]"));
1210 ui->m_advanced_replace_pb->setText(text);
QList< Conductor * > m_potential_conductors
QString locmach
Location(displayed by the default template)
QList< Diagram * > diagrams() const
ConductorProperties properties
Conductor::properties.
virtual kind linkType() const
The DynamicElementTextItem class This class provide a simple text field of element who can be added o...
QString plant
Plant (displayed by the default template)
void replaceDiagram(QList< Diagram *> diagram_list)
SearchAndReplaceWorker::replaceDiagram Replace all properties of each diagram in , by the current titleblock propertie of this worker.
DiagramContext elementInformations() const
TitleBlockProperties exportTitleBlock()
QVariant value(const QString &key) const
advancedReplaceStruct m_advanced_struct
DiagramContext m_element_context
void setTitleBlockProperties(const TitleBlockProperties &properties)
ReplaceFolioDialog::setTitleBlockProperties.
static ConductorProperties invalidConductorProperties()
QDate date
Date (displayed by the default template)
QString filename
Filename (displayed by the default template)
The ReplaceConductorDialog class A Qdialog to edit a conductor properties, use for the search and rep...
QSet< IndependentTextItem * > m_text_fields
QList< QString > keys(KeyOrder=None) const
DiagramContext context
Container for the additional, user-defined fields.
TitleBlockProperties titleBlockProperties() const
ReplaceFolioDialog::titleBlockProperties.
void replaceIndiText(QList< IndependentTextItem *> list)
SearchAndReplaceWorker::replaceIndiText Replace all displayed text of independent text of Each must ...
static QStringList elementInfoKeys()
QETApp::elementInfoKeys.
The ElementTextItemGroup class This class represent a group of element text Texts in the group can be...
void replaceElement(QList< Element *> list)
SearchAndReplaceWorker::replaceElement Replace all properties of each elements in All element must b...
QList< Element * > m_elements
QString author
Author of the diagram/folio (displayed by the default template)
DiagramContext context() const
ReplaceElementDialog::context.
advancedReplaceStruct advancedStruct() const
replaceAdvancedDialog::advancedStruct
QString m_tension_protocol
QString indexrev
Revision Index (displayed by the default template)
TitleBlockProperties m_titleblock_properties
void replaceConductor(QList< Conductor *> list)
SearchAndReplaceWorker::replaceConductor Replace all properties of each conductor in All conductor m...
QETProject * currentProject() const
QETDiagramEditor::currentProject.
QString folio
Folio information (displayed by the default template)
void replaceAdvanced(QList< Diagram *> diagrams=QList< Diagram *>(), QList< Element *> elements=QList< Element *>(), QList< IndependentTextItem *> texts=QList< IndependentTextItem *>(), QList< Conductor *> conductors=QList< Conductor *>())
SearchAndReplaceWorker::replaceAdvanced Apply the change of text according to the current advancedStr...
BorderTitleBlock border_and_titleblock
Diagram dimensions and title block.
ConductorProperties m_conductor_properties
QList< DynamicElementTextItem * > dynamicTextItems() const
Element::dynamicTextItems.
QString title
Folio title (displayed by the default template)
ConductorProperties properties() const
ReplaceConductorDialog::properties.
QList< ElementTextItemGroup * > textGroups() const
Element::textGroups.