diff --git a/sources/SearchAndReplace/searchandreplaceworker.cpp b/sources/SearchAndReplace/searchandreplaceworker.cpp new file mode 100644 index 000000000..46ea7b772 --- /dev/null +++ b/sources/SearchAndReplace/searchandreplaceworker.cpp @@ -0,0 +1,140 @@ +/* + Copyright 2006-2018 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 . +*/ +#include "searchandreplaceworker.h" +#include "diagram.h" +#include "changetitleblockcommand.h" + +SearchAndReplaceWorker::SearchAndReplaceWorker() +{} + +/** + * @brief SearchAndReplaceWorker::clear + * All registred properties + */ +void SearchAndReplaceWorker::clear() +{ + m_titleblock_properties = TitleBlockProperties(); +} + +/** + * @brief SearchAndReplaceWorker::replaceDiagram + * Replace all properties of each diagram in @diagram_list, + * by the current titleblock propertie of this worker + * @param diagram_list, list of diagram to be changed, all diagrams must belong to the same project; + */ +void SearchAndReplaceWorker::replaceDiagram(QList 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; + + if (!m_titleblock_properties.title.isEmpty()) + { + if (m_titleblock_properties.title == eraseText()) { + new_properties.title.clear(); + } else { + new_properties.title = m_titleblock_properties.title; + } + } + if (!m_titleblock_properties.author.isEmpty()) + { + if (m_titleblock_properties.author == eraseText()) { + new_properties.author.clear(); + } else { + new_properties.author = m_titleblock_properties.author; + } + } + if (!m_titleblock_properties.filename.isEmpty()) + { + if (m_titleblock_properties.filename == eraseText()) { + new_properties.filename.clear(); + } else { + new_properties.filename = m_titleblock_properties.filename; + } + } + if (!m_titleblock_properties.machine.isEmpty()) + { + if (m_titleblock_properties.machine == eraseText()) { + new_properties.machine.clear(); + } else { + new_properties.machine = m_titleblock_properties.machine; + } + } + if (!m_titleblock_properties.locmach.isEmpty()) + { + if (m_titleblock_properties.locmach == eraseText()) { + new_properties.locmach.clear(); + } else { + new_properties.locmach = m_titleblock_properties.locmach; + } + } + if (!m_titleblock_properties.indexrev.isEmpty()) + { + if (m_titleblock_properties.indexrev == eraseText()) { + new_properties.indexrev.clear(); + } else { + new_properties.indexrev = m_titleblock_properties.indexrev; + } + } + if (!m_titleblock_properties.folio.isEmpty()) + { + if (m_titleblock_properties.folio == eraseText()) { + new_properties.folio.clear(); + } else { + new_properties.folio = m_titleblock_properties.folio; + } + } + + if (m_titleblock_properties.date.isValid()) + { + if (m_titleblock_properties.date == eraseDate()) { + new_properties.date = QDate(); + } else { + 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)); + } + } + us->endMacro(); +} + +void SearchAndReplaceWorker::replaceDiagram(Diagram *diagram) +{ + QList list; + list.append(diagram); + replaceDiagram(list); +} diff --git a/sources/SearchAndReplace/searchandreplaceworker.h b/sources/SearchAndReplace/searchandreplaceworker.h new file mode 100644 index 000000000..fa2bb89ff --- /dev/null +++ b/sources/SearchAndReplace/searchandreplaceworker.h @@ -0,0 +1,49 @@ +/* + Copyright 2006-2018 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 . +*/ +#ifndef SEARCHANDREPLACEWORKER_H +#define SEARCHANDREPLACEWORKER_H + +#include + +#include "titleblockproperties.h" + +class Diagram; + +/** + * @brief The SearchAndReplaceWorker class + * This class is the worker use to change properties when use the search and replace function of QET + */ +class SearchAndReplaceWorker +{ + public: + SearchAndReplaceWorker(); + + void clear(); + void replaceDiagram(QList diagram_list); + void replaceDiagram(Diagram *diagram); + + static QString eraseText() {return QString("XXXXXXXXXXXXXXXXXXX");} + static QDate eraseDate() {return QDate(1900, 1, 1);} + + private: + TitleBlockProperties m_titleblock_properties; + + friend class SearchAndReplaceWidget; +}; + +#endif // SEARCHANDREPLACEWORKER_H diff --git a/sources/SearchAndReplace/ui/replacefoliowidget.cpp b/sources/SearchAndReplace/ui/replacefoliowidget.cpp new file mode 100644 index 000000000..0533f9232 --- /dev/null +++ b/sources/SearchAndReplace/ui/replacefoliowidget.cpp @@ -0,0 +1,178 @@ +/* + Copyright 2006-2018 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 . +*/ +#include "replacefoliowidget.h" +#include "ui_replacefoliowidget.h" +#include "diagramcontextwidget.h" +#include "searchandreplaceworker.h" + +#include + +ReplaceFolioWidget::ReplaceFolioWidget(QWidget *parent) : + QWidget(parent), + ui(new Ui::ReplaceFolioWidget) +{ + ui->setupUi(this); + m_diagram_context_widget = new DiagramContextWidget(this); + ui->m_tab2_vlayout->addWidget(m_diagram_context_widget); +} + +ReplaceFolioWidget::~ReplaceFolioWidget() +{ + delete ui; +} + +/** + * @brief ReplaceFolioWidget::titleBlockProperties + * @return the title block properties edited by this widget + */ +TitleBlockProperties ReplaceFolioWidget::titleBlockProperties() const +{ + TitleBlockProperties prop; + prop.title = ui->m_title_le ->text(); + prop.author = ui->m_author_le->text(); + prop.filename = ui->m_file_le ->text(); + prop.machine = ui->m_mach ->text(); + prop.locmach = ui->m_loc ->text(); + prop.indexrev = ui->m_indice ->text(); + prop.folio = ui->m_folio_le ->text(); + + if (ui->m_unchanged_date->isChecked()) { + prop.date = QDate(); + prop.useDate = TitleBlockProperties::UseDateValue; + } + if (ui->m_no_date_rb->isChecked()) { + prop.date = SearchAndReplaceWorker::eraseDate(); + prop.useDate = TitleBlockProperties::UseDateValue; + } + else if (ui->m_fixed_date_rb->isChecked()) { + prop.date = ui->m_date_edit->date(); + prop.useDate = TitleBlockProperties::UseDateValue; + } + + prop.context = m_diagram_context_widget->context(); + return prop; +} + +/** + * @brief ReplaceFolioWidget::setTitleBlockProperties + * Set the title block properties edited by this widget + * @param properties + */ +void ReplaceFolioWidget::setTitleBlockProperties(const TitleBlockProperties &properties) +{ + ui->m_title_le ->setText (properties.title); + ui->m_author_le->setText (properties.author); + ui->m_file_le ->setText (properties.filename); + ui->m_mach ->setText (properties.machine); + ui->m_loc ->setText (properties.locmach); + ui->m_indice ->setText (properties.indexrev); + ui->m_folio_le ->setText (properties.folio); + + //About date + ui->m_date_now_pb->setDisabled(true); + ui->m_date_edit ->setDisabled(true); + ui->m_date_edit ->setDate(QDate::currentDate()); + + + if (properties.useDate == TitleBlockProperties::CurrentDate) { + ui -> m_fixed_date_rb ->setChecked(true); + } + else + { + if (properties.date.isNull()) { + ui->m_unchanged_date->setChecked(true); + } + else if (properties.date == SearchAndReplaceWorker::eraseDate()) { + ui->m_no_date_rb->setChecked(true); + } + else + { + ui->m_fixed_date_rb->setChecked(true); + ui->m_date_edit->setDate(properties.date); + } + } + //About date + + m_diagram_context_widget->setContext(properties.context); +} + +ReplaceFolioDialog::ReplaceFolioDialog(QWidget *parent) : + QDialog(parent) +{ + QVBoxLayout *layout = new QVBoxLayout(this); + layout->addWidget(m_widget = new ReplaceFolioWidget(this)); + layout->addWidget(m_button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Reset, this)); + + connect(m_button_box, &QDialogButtonBox::clicked, [this](QAbstractButton *button_) + { + this->done(m_button_box->buttonRole(button_)); + }); +} + +ReplaceFolioDialog::~ReplaceFolioDialog() +{} + +/** + * @brief ReplaceFolioDialog::titleBlockProperties + * @return The title block properties edited by this dialog + */ +TitleBlockProperties ReplaceFolioDialog::titleBlockProperties() const { + return m_widget->titleBlockProperties(); +} + +/** + * @brief ReplaceFolioDialog::setTitleBlockProperties + * @param properties : set the title block properties edited by this dialog + */ +void ReplaceFolioDialog::setTitleBlockProperties(const TitleBlockProperties &properties) { + m_widget->setTitleBlockProperties(properties); +} +void ReplaceFolioWidget::on_m_title_cb_clicked() { + ui->m_title_le->setText(ui->m_title_cb->isChecked() ? SearchAndReplaceWorker::eraseText() : QString()); + ui->m_title_le->setDisabled(ui->m_title_cb->isChecked()); +} + +void ReplaceFolioWidget::on_m_author_cb_clicked() { + ui->m_author_le->setText(ui->m_author_cb->isChecked() ? SearchAndReplaceWorker::eraseText() : QString()); + ui->m_author_le->setDisabled(ui->m_author_cb->isChecked()); +} + +void ReplaceFolioWidget::on_m_file_cb_clicked() { + ui->m_file_le->setText(ui->m_file_cb->isChecked() ? SearchAndReplaceWorker::eraseText() : QString()); + ui->m_file_le->setDisabled(ui->m_file_cb->isChecked()); +} + +void ReplaceFolioWidget::on_m_folio_cb_clicked() { + ui->m_folio_le->setText(ui->m_folio_cb->isChecked() ? SearchAndReplaceWorker::eraseText() : QString()); + ui->m_folio_le->setDisabled(ui->m_folio_cb->isChecked()); +} + +void ReplaceFolioWidget::on_m_mach_cb_clicked() { + ui->m_mach->setText(ui->m_mach_cb->isChecked() ? SearchAndReplaceWorker::eraseText() : QString()); + ui->m_mach->setDisabled(ui->m_mach_cb->isChecked()); +} + +void ReplaceFolioWidget::on_m_loc_cb_clicked() { + ui->m_loc->setText(ui->m_loc_cb->isChecked() ? SearchAndReplaceWorker::eraseText() : QString()); + ui->m_loc->setDisabled(ui->m_loc_cb->isChecked()); +} + +void ReplaceFolioWidget::on_m_indice_cb_clicked() { + ui->m_indice->setText(ui->m_indice_cb->isChecked() ? SearchAndReplaceWorker::eraseText() : QString()); + ui->m_indice->setDisabled(ui->m_indice_cb->isChecked()); +} diff --git a/sources/SearchAndReplace/ui/replacefoliowidget.h b/sources/SearchAndReplace/ui/replacefoliowidget.h new file mode 100644 index 000000000..a529221e5 --- /dev/null +++ b/sources/SearchAndReplace/ui/replacefoliowidget.h @@ -0,0 +1,76 @@ +/* + Copyright 2006-2018 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 . +*/ +#ifndef REPLACEFOLIOWIDGET_H +#define REPLACEFOLIOWIDGET_H + +#include +#include + +#include "diagramcontext.h" +#include "titleblockproperties.h" + +class DiagramContextWidget; +class QDialogButtonBox; + +namespace Ui { + class ReplaceFolioWidget; +} + +class ReplaceFolioWidget : public QWidget +{ + Q_OBJECT + + public: + explicit ReplaceFolioWidget(QWidget *parent = nullptr); + ~ReplaceFolioWidget(); + + TitleBlockProperties titleBlockProperties() const; + void setTitleBlockProperties (const TitleBlockProperties &properties); + + private slots: + void on_m_title_cb_clicked(); + void on_m_author_cb_clicked(); + void on_m_file_cb_clicked(); + void on_m_folio_cb_clicked(); + void on_m_mach_cb_clicked(); + void on_m_loc_cb_clicked(); + void on_m_indice_cb_clicked(); + + private: + Ui::ReplaceFolioWidget *ui; + DiagramContextWidget *m_diagram_context_widget = nullptr; + +}; + +class ReplaceFolioDialog : public QDialog +{ + Q_OBJECT + + public: + ReplaceFolioDialog(QWidget *parent = nullptr); + ~ReplaceFolioDialog(); + + TitleBlockProperties titleBlockProperties() const; + void setTitleBlockProperties (const TitleBlockProperties &properties); + + private: + ReplaceFolioWidget *m_widget = nullptr; + QDialogButtonBox *m_button_box = nullptr; +}; + +#endif // REPLACEFOLIOWIDGET_H diff --git a/sources/SearchAndReplace/ui/replacefoliowidget.ui b/sources/SearchAndReplace/ui/replacefoliowidget.ui new file mode 100644 index 000000000..d6bf9b1da --- /dev/null +++ b/sources/SearchAndReplace/ui/replacefoliowidget.ui @@ -0,0 +1,388 @@ + + + ReplaceFolioWidget + + + + 0 + 0 + 449 + 389 + + + + Form + + + + + + + 0 + 0 + + + + QTabWidget::South + + + QTabWidget::Rounded + + + 0 + + + Qt::ElideNone + + + true + + + false + + + + Principales + + + + + + + + Indice Rev + + + + + + + Localisation + + + + + + + Fichier : + + + + + + + Disponible en tant que %title pour les modèles de cartouches + + + Non modifier + + + + + + + Disponible en tant que %author pour les modèles de cartouches + + + Non modifier + + + + + + + Auteur : + + + + + + + Date : + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + Installation : + + + + + + + Disponible en tant que %indexrev pour les modèles de cartouches + + + Non modifier + + + + + + + Disponible en tant que %filename pour les modèles de cartouches + + + Non modifier + + + + + + + + + + Folio : + + + + + + + + + Pas de date + + + + + + + Disponible en tant que %date pour les modèles de cartouches + + + true + + + true + + + + + + + Date fixe : + + + + + + + Appliquer la date actuelle + + + + + + + :/ico/22x22/start.png:/ico/22x22/start.png + + + + + + + Non &modifier + + + + + + + + + Disponible en tant que %folio pour les modèles de cartouches +Les variables suivantes sont utilisables : +- %id : numéro du folio courant dans le projet +- %total : nombre total de folios dans le projet +- %autonum : Folio Auto Numeration + + + Non modifier + + + + + + + Disponible en tant que %locmach pour les modèles de cartouches + + + Non modifier + + + + + + + Disponible en tant que %machine pour les modèles de cartouches + + + Non modifier + + + + + + + Titre : + + + + + + + Supprimer ce texte + + + + + + + + + + Supprimer ce texte + + + + + + + + + + Supprimer ce texte + + + + + + + + + + Supprimer ce texte + + + + + + + + + + Supprimer ce texte + + + + + + + + + + Supprimer ce texte + + + + + + + + + + Supprimer ce texte + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + Personnalisées + + + + + + + + Vous pouvez définir ici vos propres associations noms/valeurs pour que le cartouche en tienne compte. Exemple : +associer le nom "volta" et la valeur "1745" remplacera %{volta} par 1745 dans le cartouche. + + + true + + + + + + + + + + + + + + + + + m_fixed_date_rb + toggled(bool) + m_date_edit + setEnabled(bool) + + + 144 + 145 + + + 250 + 145 + + + + + m_fixed_date_rb + toggled(bool) + m_date_now_pb + setEnabled(bool) + + + 144 + 145 + + + 356 + 145 + + + + + diff --git a/sources/SearchAndReplace/ui/searchandreplacewidget.cpp b/sources/SearchAndReplace/ui/searchandreplacewidget.cpp index 65900d3c1..070c03e12 100644 --- a/sources/SearchAndReplace/ui/searchandreplacewidget.cpp +++ b/sources/SearchAndReplace/ui/searchandreplacewidget.cpp @@ -24,6 +24,7 @@ #include "element.h" #include "independenttextitem.h" #include "conductor.h" +#include "replacefoliowidget.h" #include @@ -202,8 +203,9 @@ void SearchAndReplaceWidget::setHideAdvanced(bool hide) const ui->m_advanced_pb ->setChecked(!hide); ui->m_replace ->setHidden(hide); ui->m_replace_le ->setHidden(hide); - ui->m_mode ->setHidden(hide); - ui->m_mode_cb ->setHidden(hide); + ui->m_folio_pb ->setHidden(hide); + ui->m_element_pb ->setHidden(hide); + ui->m_conductor_pb ->setHidden(hide); ui->m_tree_widget ->setHidden(hide); ui->m_replace_pb ->setHidden(hide); ui->m_replace_all_pb->setHidden(hide); @@ -574,6 +576,22 @@ void SearchAndReplaceWidget::updateParentCheckState(QTreeWidgetItem *item, bool } } +/** + * @brief SearchAndReplaceWidget::activateNextChecked + * Activate the next checked (and visible) item + */ +void SearchAndReplaceWidget::activateNextChecked() +{ + //Next button is disabled, so there is not a next item. + if (!ui->m_next_pb->isEnabled()) + return; + + do { + on_m_next_pb_clicked(); + } while ((ui->m_tree_widget->currentItem()->checkState(0) != Qt::Checked) && + ui->m_next_pb->isEnabled()); +} + void SearchAndReplaceWidget::on_m_quit_button_clicked() { this->setHidden(true); } @@ -675,6 +693,11 @@ void SearchAndReplaceWidget::on_m_tree_widget_currentItemChanged(QTreeWidgetItem } updateNextPreviousButtons(); + if (current->checkState(0) == Qt::Checked && !m_category_qtwi.contains(current)) { + ui->m_replace_pb->setEnabled(true); + } else { + ui->m_replace_pb->setDisabled(true); + } } void SearchAndReplaceWidget::on_m_next_pb_clicked() @@ -720,3 +743,69 @@ void SearchAndReplaceWidget::on_m_previous_pb_clicked() ui->m_tree_widget->scrollToItem(item); on_m_tree_widget_itemDoubleClicked(item, 0); } + +void SearchAndReplaceWidget::on_m_folio_pb_clicked() +{ + ReplaceFolioDialog *dialog = new ReplaceFolioDialog(this); + dialog->setTitleBlockProperties(m_worker.m_titleblock_properties); + + int result = dialog->exec(); + if (result == QDialogButtonBox::AcceptRole) + { + QString text = ui->m_folio_pb->text(); + if (!text.endsWith(tr(" [Édité]"))) { + text.append(tr(" [Édité]")); + } + ui->m_folio_pb->setText(text); + m_worker.m_titleblock_properties = dialog->titleBlockProperties(); + } + else if (result == QDialogButtonBox::ResetRole) + { + QString text = ui->m_folio_pb->text(); + if (text.endsWith(tr(" [Édité]"))) { + text.remove(tr(" [Édité]")); + } + ui->m_folio_pb->setText(text); + m_worker.m_titleblock_properties = TitleBlockProperties(); + } +} + +void SearchAndReplaceWidget::on_m_replace_pb_clicked() +{ + QTreeWidgetItem *qtwi = ui->m_tree_widget->currentItem(); + if(!qtwi) { + return; + } + if (!m_category_qtwi.contains(qtwi) && qtwi->checkState(0) == Qt::Checked) + { + if (ui->m_folio_pb->text().endsWith(tr(" [Édité]")) && + m_diagram_hash.keys().contains(qtwi)) + { + QPointer d = m_diagram_hash.value(qtwi); + if (d) { + m_worker.replaceDiagram(d.data()); + } + } + } + activateNextChecked(); + ui->m_replace_pb->setEnabled(ui->m_next_pb->isEnabled()); +} + +void SearchAndReplaceWidget::on_m_replace_all_pb_clicked() +{ + if (ui->m_folio_pb->text().endsWith(tr(" [Édité]"))) + { + QList d; + for (QTreeWidgetItem *qtwi : m_diagram_hash.keys()) + { + if (!qtwi->isHidden() && qtwi->checkState(0) == Qt::Checked) + { + QPointer p = m_diagram_hash.value(qtwi); + if (p) { + d.append(p.data()); + } + } + } + m_worker.replaceDiagram(d); + } +} diff --git a/sources/SearchAndReplace/ui/searchandreplacewidget.h b/sources/SearchAndReplace/ui/searchandreplacewidget.h index 7e2803b18..b286cbf50 100644 --- a/sources/SearchAndReplace/ui/searchandreplacewidget.h +++ b/sources/SearchAndReplace/ui/searchandreplacewidget.h @@ -20,8 +20,10 @@ #include #include + #include "element.h" #include "independenttextitem.h" +#include "searchandreplaceworker.h" class QTreeWidgetItem; @@ -57,6 +59,7 @@ class SearchAndReplaceWidget : public QWidget void itemChanged(QTreeWidgetItem *item, int column); void setChildCheckState(QTreeWidgetItem *item, Qt::CheckState check, bool deep = true); void updateParentCheckState(QTreeWidgetItem *item, bool all_parents = true); + void activateNextChecked(); private slots: void on_m_quit_button_clicked(); @@ -66,8 +69,11 @@ class SearchAndReplaceWidget : public QWidget void on_m_tree_widget_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous); void on_m_next_pb_clicked(); void on_m_previous_pb_clicked(); + void on_m_folio_pb_clicked(); + void on_m_replace_pb_clicked(); + void on_m_replace_all_pb_clicked(); - private: + private: Ui::SearchAndReplaceWidget *ui; QETDiagramEditor *m_editor; QTreeWidgetItem *m_root_qtwi = nullptr, @@ -88,6 +94,7 @@ class SearchAndReplaceWidget : public QWidget QPointer m_highlighted_element; QPointer m_last_selected; QHash> m_diagram_hash; + SearchAndReplaceWorker m_worker; }; #endif // SEARCHANDREPLACEWIDGET_H diff --git a/sources/SearchAndReplace/ui/searchandreplacewidget.ui b/sources/SearchAndReplace/ui/searchandreplacewidget.ui index 3444121e3..60df2d3c6 100644 --- a/sources/SearchAndReplace/ui/searchandreplacewidget.ui +++ b/sources/SearchAndReplace/ui/searchandreplacewidget.ui @@ -26,6 +26,20 @@ 0 + + + + Actualiser + + + + + + + :/ico/16x16/view-refresh.png:/ico/16x16/view-refresh.png + + + @@ -43,6 +57,29 @@ + + + + Avancé + + + + + + + :/ico/16x16/configure-toolbars.png:/ico/16x16/configure-toolbars.png + + + true + + + false + + + false + + + @@ -81,6 +118,19 @@ + + + + Qt::Vertical + + + + 20 + 0 + + + + @@ -100,75 +150,24 @@ - + + + Champ texte de folio + true - - + + - Remplacer : + Folio - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Remplacer la correspondance séléctionner - - - Remplacer - - - - - - - Remplacer les correspondances coché - - - Tout remplacer - - - - - - - Mode : - - - - - - - - Texte brut - - - - - Mots entiers - - - - - + true @@ -182,55 +181,68 @@ + + + + false + + + Élément + + + + + + + false + + + Conducteur + + + + + + + Remplacer : + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + - - + + + + false + - Avancé + Remplacer la correspondance séléctionner - - - - - :/ico/16x16/configure-toolbars.png:/ico/16x16/configure-toolbars.png - - - true - - - false - - - false + Remplacer - - - - Qt::Vertical - - - - 20 - 0 - - - - - - + + - Actualiser + Remplacer les correspondances coché - - - - - :/ico/16x16/view-refresh.png:/ico/16x16/view-refresh.png + Tout remplacer diff --git a/sources/diagramcommands.cpp b/sources/diagramcommands.cpp index 26cbfbdfd..45651eea2 100644 --- a/sources/diagramcommands.cpp +++ b/sources/diagramcommands.cpp @@ -1,5 +1,5 @@ /* - Copyright 2006-2017 The QElectroTech Team + Copyright 2006-2018 The QElectroTech Team This file is part of QElectroTech. QElectroTech is free software: you can redistribute it and/or modify @@ -528,44 +528,6 @@ void ResetConductorCommand::redo() { } } -/** - Constructeur - @param d Schema dont on modifie le cartouche - @param old_ip Anciennes proprietes du cartouche - @param new_ip Nouvelles proprietes du cartouche - @param parent QUndoCommand parent -*/ -ChangeTitleBlockCommand::ChangeTitleBlockCommand( - Diagram *d, - const TitleBlockProperties &old_ip, - const TitleBlockProperties &new_ip, - QUndoCommand *parent -) : - QUndoCommand(QObject::tr("modifier le cartouche", "undo caption"), parent), - diagram(d), - old_titleblock(old_ip), - new_titleblock(new_ip) -{ -} - -/// Destructeur -ChangeTitleBlockCommand::~ChangeTitleBlockCommand() { -} - -/// Annule la modification de cartouche -void ChangeTitleBlockCommand::undo() { - diagram -> showMe(); - diagram -> border_and_titleblock.importTitleBlock(old_titleblock); - diagram -> invalidate(diagram -> border_and_titleblock.borderAndTitleBlockRect()); -} - -/// Refait la modification de cartouche -void ChangeTitleBlockCommand::redo() { - diagram -> showMe(); - diagram -> border_and_titleblock.importTitleBlock(new_titleblock); - diagram -> invalidate(diagram -> border_and_titleblock.borderAndTitleBlockRect()); -} - /** Constructeur @param dia Schema modifie diff --git a/sources/diagramcommands.h b/sources/diagramcommands.h index f1646ff1e..4182970c0 100644 --- a/sources/diagramcommands.h +++ b/sources/diagramcommands.h @@ -1,5 +1,5 @@ /* - Copyright 2006-2017 The QElectroTech Team + Copyright 2006-2018 The QElectroTech Team This file is part of QElectroTech. QElectroTech is free software: you can redistribute it and/or modify @@ -21,7 +21,6 @@ #include "borderproperties.h" #include "qetgraphicsitem/conductor.h" #include "diagramcontent.h" -#include "titleblockproperties.h" #include "qet.h" #include "qetgraphicsitem/qetshapeitem.h" #include "conductorprofile.h" @@ -273,31 +272,7 @@ class ResetConductorCommand : public QUndoCommand { Diagram *diagram; }; -/** - This command changes the title block properties for a particular diagram. -*/ -class ChangeTitleBlockCommand : public QUndoCommand { - // constructors, destructor - public: - ChangeTitleBlockCommand(Diagram *, const TitleBlockProperties &, const TitleBlockProperties &, QUndoCommand * = nullptr); - ~ChangeTitleBlockCommand() override; - private: - ChangeTitleBlockCommand(const ChangeTitleBlockCommand &); - - // methods - public: - void undo() override; - void redo() override; - - // attributes - private: - /// modified diagram - Diagram *diagram; - /// properties before the change - TitleBlockProperties old_titleblock; - /// properties after the change - TitleBlockProperties new_titleblock; -}; + /** This command changes the border properties of a particular diagram. diff --git a/sources/diagramcontext.cpp b/sources/diagramcontext.cpp index a6f1788ba..bfab5bf42 100644 --- a/sources/diagramcontext.cpp +++ b/sources/diagramcontext.cpp @@ -20,6 +20,21 @@ #include "qet.h" #include +/** + * @brief DiagramContext::add + * Add all value of @other to this. + * If a key already exist, the value is replaced. + * If a key doesn't exist, she will be added. + * All other keys of this context, which are not present in @other, stay unchanged. + * @param other + */ +void DiagramContext::add(DiagramContext other) +{ + for (QString key : other.keys()) { + addValue(key, other.value(key)); + } +} + /** @return a list containing all the keys in the context object. */ diff --git a/sources/diagramcontext.h b/sources/diagramcontext.h index 144233c82..e4243fdce 100644 --- a/sources/diagramcontext.h +++ b/sources/diagramcontext.h @@ -56,6 +56,7 @@ class DiagramContext DecreasingLength }; + void add(DiagramContext other); QList keys(KeyOrder = None) const; bool contains(const QString &) const; const QVariant operator[](const QString &) const; diff --git a/sources/diagramview.cpp b/sources/diagramview.cpp index 8a52bbbf6..51d1c0ea1 100644 --- a/sources/diagramview.cpp +++ b/sources/diagramview.cpp @@ -43,6 +43,7 @@ #include "undocommand/deleteqgraphicsitemcommand.h" #include "dynamicelementtextitem.h" #include "multipastedialog.h" +#include "changetitleblockcommand.h" /** Constructeur diff --git a/sources/ui/diagrampropertiesdialog.cpp b/sources/ui/diagrampropertiesdialog.cpp index 036361a26..39b8590c1 100644 --- a/sources/ui/diagrampropertiesdialog.cpp +++ b/sources/ui/diagrampropertiesdialog.cpp @@ -22,6 +22,7 @@ #include "diagramcommands.h" #include "projectpropertiesdialog.h" #include "diagram.h" +#include "changetitleblockcommand.h" /** * @brief DiagramPropertiesDialog::DiagramPropertiesDialog diff --git a/sources/undocommand/changetitleblockcommand.cpp b/sources/undocommand/changetitleblockcommand.cpp new file mode 100644 index 000000000..b0eca403b --- /dev/null +++ b/sources/undocommand/changetitleblockcommand.cpp @@ -0,0 +1,55 @@ +/* + Copyright 2006-2018 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 . +*/ + +#include "changetitleblockcommand.h" +#include "diagram.h" + +/** + * @brief ChangeTitleBlockCommand::ChangeTitleBlockCommand + * @param d + * @param old_ip + * @param new_ip + * @param parent + */ +ChangeTitleBlockCommand::ChangeTitleBlockCommand( + Diagram *d, + const TitleBlockProperties &old_ip, + const TitleBlockProperties &new_ip, + QUndoCommand *parent +) : + QUndoCommand(QObject::tr("modifier le cartouche", "undo caption"), parent), + diagram(d), + old_titleblock(old_ip), + new_titleblock(new_ip) +{} + +ChangeTitleBlockCommand::~ChangeTitleBlockCommand() {} + +void ChangeTitleBlockCommand::undo() +{ + diagram -> showMe(); + diagram -> border_and_titleblock.importTitleBlock(old_titleblock); + diagram -> invalidate(diagram -> border_and_titleblock.borderAndTitleBlockRect()); +} + +void ChangeTitleBlockCommand::redo() +{ + diagram -> showMe(); + diagram -> border_and_titleblock.importTitleBlock(new_titleblock); + diagram -> invalidate(diagram -> border_and_titleblock.borderAndTitleBlockRect()); +} diff --git a/sources/undocommand/changetitleblockcommand.h b/sources/undocommand/changetitleblockcommand.h new file mode 100644 index 000000000..ee520b536 --- /dev/null +++ b/sources/undocommand/changetitleblockcommand.h @@ -0,0 +1,48 @@ +/* + Copyright 2006-2018 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 . +*/ +#ifndef CHANGETITLEBLOCKCOMMAND_H +#define CHANGETITLEBLOCKCOMMAND_H + +#include + +#include "titleblockproperties.h" + +class Diagram; +/** + * @brief The ChangeTitleBlockCommand class + * This command changes the title block properties for a particular diagram. + */ +class ChangeTitleBlockCommand : public QUndoCommand +{ + public: + ChangeTitleBlockCommand(Diagram *, const TitleBlockProperties &, const TitleBlockProperties &, QUndoCommand * = nullptr); + ~ChangeTitleBlockCommand() override; + private: + ChangeTitleBlockCommand(const ChangeTitleBlockCommand &); + + public: + void undo() override; + void redo() override; + + private: + Diagram *diagram; + TitleBlockProperties old_titleblock; + TitleBlockProperties new_titleblock; +}; + +#endif // CHANGETITLEBLOCKCOMMAND_H