[qet] qet/qet: [5564] Search and replace : Diagram properties can be changed ( and mass changed) through the search and replace widget. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
- To: qet@xxxxxxxxxxxxxxxxxxx
- Subject: [qet] qet/qet: [5564] Search and replace : Diagram properties can be changed ( and mass changed) through the search and replace widget.
- From: subversion@xxxxxxxxxxxxx
- Date: Sun, 21 Oct 2018 11:55:00 +0200
Revision: 5564
Author: blacksun
Date: 2018-10-21 11:54:59 +0200 (Sun, 21 Oct 2018)
Log Message:
-----------
Search and replace : Diagram properties can be changed (and mass changed) through the search and replace widget.
Modified Paths:
--------------
trunk/sources/SearchAndReplace/ui/searchandreplacewidget.cpp
trunk/sources/SearchAndReplace/ui/searchandreplacewidget.h
trunk/sources/SearchAndReplace/ui/searchandreplacewidget.ui
trunk/sources/diagramcommands.cpp
trunk/sources/diagramcommands.h
trunk/sources/diagramcontext.cpp
trunk/sources/diagramcontext.h
trunk/sources/diagramview.cpp
trunk/sources/ui/diagrampropertiesdialog.cpp
Added Paths:
-----------
trunk/sources/SearchAndReplace/searchandreplaceworker.cpp
trunk/sources/SearchAndReplace/searchandreplaceworker.h
trunk/sources/SearchAndReplace/ui/replacefoliowidget.cpp
trunk/sources/SearchAndReplace/ui/replacefoliowidget.h
trunk/sources/SearchAndReplace/ui/replacefoliowidget.ui
trunk/sources/undocommand/changetitleblockcommand.cpp
trunk/sources/undocommand/changetitleblockcommand.h
Added: trunk/sources/SearchAndReplace/searchandreplaceworker.cpp
===================================================================
--- trunk/sources/SearchAndReplace/searchandreplaceworker.cpp (rev 0)
+++ trunk/sources/SearchAndReplace/searchandreplaceworker.cpp 2018-10-21 09:54:59 UTC (rev 5564)
@@ -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 <http://www.gnu.org/licenses/>.
+*/
+#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 *> 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<Diagram *> list;
+ list.append(diagram);
+ replaceDiagram(list);
+}
Added: trunk/sources/SearchAndReplace/searchandreplaceworker.h
===================================================================
--- trunk/sources/SearchAndReplace/searchandreplaceworker.h (rev 0)
+++ trunk/sources/SearchAndReplace/searchandreplaceworker.h 2018-10-21 09:54:59 UTC (rev 5564)
@@ -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 <http://www.gnu.org/licenses/>.
+*/
+#ifndef SEARCHANDREPLACEWORKER_H
+#define SEARCHANDREPLACEWORKER_H
+
+#include <QDate>
+
+#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 *> 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
Added: trunk/sources/SearchAndReplace/ui/replacefoliowidget.cpp
===================================================================
--- trunk/sources/SearchAndReplace/ui/replacefoliowidget.cpp (rev 0)
+++ trunk/sources/SearchAndReplace/ui/replacefoliowidget.cpp 2018-10-21 09:54:59 UTC (rev 5564)
@@ -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 <http://www.gnu.org/licenses/>.
+*/
+#include "replacefoliowidget.h"
+#include "ui_replacefoliowidget.h"
+#include "diagramcontextwidget.h"
+#include "searchandreplaceworker.h"
+
+#include <QDialogButtonBox>
+
+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());
+}
Added: trunk/sources/SearchAndReplace/ui/replacefoliowidget.h
===================================================================
--- trunk/sources/SearchAndReplace/ui/replacefoliowidget.h (rev 0)
+++ trunk/sources/SearchAndReplace/ui/replacefoliowidget.h 2018-10-21 09:54:59 UTC (rev 5564)
@@ -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 <http://www.gnu.org/licenses/>.
+*/
+#ifndef REPLACEFOLIOWIDGET_H
+#define REPLACEFOLIOWIDGET_H
+
+#include <QWidget>
+#include <QDialog>
+
+#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
Added: trunk/sources/SearchAndReplace/ui/replacefoliowidget.ui
===================================================================
--- trunk/sources/SearchAndReplace/ui/replacefoliowidget.ui (rev 0)
+++ trunk/sources/SearchAndReplace/ui/replacefoliowidget.ui 2018-10-21 09:54:59 UTC (rev 5564)
@@ -0,0 +1,388 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ReplaceFolioWidget</class>
+ <widget class="QWidget" name="ReplaceFolioWidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>449</width>
+ <height>389</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <widget class="QTabWidget" name="tabWidget">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="tabPosition">
+ <enum>QTabWidget::South</enum>
+ </property>
+ <property name="tabShape">
+ <enum>QTabWidget::Rounded</enum>
+ </property>
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <property name="elideMode">
+ <enum>Qt::ElideNone</enum>
+ </property>
+ <property name="usesScrollButtons">
+ <bool>true</bool>
+ </property>
+ <property name="tabsClosable">
+ <bool>false</bool>
+ </property>
+ <widget class="QWidget" name="tab">
+ <attribute name="title">
+ <string>Principales</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <layout class="QGridLayout" name="gridLayout_4">
+ <item row="9" column="1">
+ <widget class="QLabel" name="label_12">
+ <property name="text">
+ <string>Indice Rev</string>
+ </property>
+ </widget>
+ </item>
+ <item row="8" column="1">
+ <widget class="QLabel" name="label_11">
+ <property name="text">
+ <string>Localisation</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>Fichier :</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="3">
+ <widget class="QLineEdit" name="m_title_le">
+ <property name="toolTip">
+ <string>Disponible en tant que %title pour les modèles de cartouches</string>
+ </property>
+ <property name="placeholderText">
+ <string>Non modifier</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="3">
+ <widget class="QLineEdit" name="m_author_le">
+ <property name="toolTip">
+ <string>Disponible en tant que %author pour les modèles de cartouches</string>
+ </property>
+ <property name="placeholderText">
+ <string>Non modifier</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Auteur :</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>Date :</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="1">
+ <widget class="QLabel" name="label_10">
+ <property name="text">
+ <string>Installation :</string>
+ </property>
+ </widget>
+ </item>
+ <item row="9" column="3">
+ <widget class="QLineEdit" name="m_indice">
+ <property name="toolTip">
+ <string>Disponible en tant que %indexrev pour les modèles de cartouches</string>
+ </property>
+ <property name="placeholderText">
+ <string>Non modifier</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="3">
+ <widget class="QLineEdit" name="m_file_le">
+ <property name="toolTip">
+ <string>Disponible en tant que %filename pour les modèles de cartouches</string>
+ </property>
+ <property name="placeholderText">
+ <string>Non modifier</string>
+ </property>
+ </widget>
+ </item>
+ <item row="10" column="3">
+ <layout class="QGridLayout" name="gridLayout"/>
+ </item>
+ <item row="5" column="1">
+ <widget class="QLabel" name="label_6">
+ <property name="text">
+ <string>Folio :</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="3">
+ <layout class="QGridLayout" name="gridLayout_2" columnstretch="0,0,0">
+ <item row="1" column="0">
+ <widget class="QRadioButton" name="m_no_date_rb">
+ <property name="text">
+ <string>Pas de date</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QDateEdit" name="m_date_edit">
+ <property name="toolTip">
+ <string>Disponible en tant que %date pour les modèles de cartouches</string>
+ </property>
+ <property name="frame">
+ <bool>true</bool>
+ </property>
+ <property name="calendarPopup">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QRadioButton" name="m_fixed_date_rb">
+ <property name="text">
+ <string>Date fixe :</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2">
+ <widget class="QPushButton" name="m_date_now_pb">
+ <property name="toolTip">
+ <string>Appliquer la date actuelle</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset resource="../../../qelectrotech.qrc">
+ <normaloff>:/ico/22x22/start.png</normaloff>:/ico/22x22/start.png</iconset>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QRadioButton" name="m_unchanged_date">
+ <property name="text">
+ <string>Non &modifier</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="5" column="3">
+ <widget class="QLineEdit" name="m_folio_le">
+ <property name="toolTip">
+ <string>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</string>
+ </property>
+ <property name="placeholderText">
+ <string>Non modifier</string>
+ </property>
+ </widget>
+ </item>
+ <item row="8" column="3">
+ <widget class="QLineEdit" name="m_loc">
+ <property name="toolTip">
+ <string>Disponible en tant que %locmach pour les modèles de cartouches</string>
+ </property>
+ <property name="placeholderText">
+ <string>Non modifier</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="3">
+ <widget class="QLineEdit" name="m_mach">
+ <property name="toolTip">
+ <string>Disponible en tant que %machine pour les modèles de cartouches</string>
+ </property>
+ <property name="placeholderText">
+ <string>Non modifier</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Titre :</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="4">
+ <widget class="QCheckBox" name="m_title_cb">
+ <property name="toolTip">
+ <string>Supprimer ce texte</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="4">
+ <widget class="QCheckBox" name="m_author_cb">
+ <property name="toolTip">
+ <string>Supprimer ce texte</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="4">
+ <widget class="QCheckBox" name="m_file_cb">
+ <property name="toolTip">
+ <string>Supprimer ce texte</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="4">
+ <widget class="QCheckBox" name="m_folio_cb">
+ <property name="toolTip">
+ <string>Supprimer ce texte</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="4">
+ <widget class="QCheckBox" name="m_mach_cb">
+ <property name="toolTip">
+ <string>Supprimer ce texte</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="8" column="4">
+ <widget class="QCheckBox" name="m_loc_cb">
+ <property name="toolTip">
+ <string>Supprimer ce texte</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="9" column="4">
+ <widget class="QCheckBox" name="m_indice_cb">
+ <property name="toolTip">
+ <string>Supprimer ce texte</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tab_2">
+ <attribute name="title">
+ <string>Personnalisées</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QVBoxLayout" name="m_tab2_vlayout">
+ <item>
+ <widget class="QLabel" name="label_8">
+ <property name="text">
+ <string>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.</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources>
+ <include location="../../../qelectrotech.qrc"/>
+ </resources>
+ <connections>
+ <connection>
+ <sender>m_fixed_date_rb</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>m_date_edit</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>144</x>
+ <y>145</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>250</x>
+ <y>145</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>m_fixed_date_rb</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>m_date_now_pb</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>144</x>
+ <y>145</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>356</x>
+ <y>145</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
Modified: trunk/sources/SearchAndReplace/ui/searchandreplacewidget.cpp
===================================================================
--- trunk/sources/SearchAndReplace/ui/searchandreplacewidget.cpp 2018-10-18 00:05:40 UTC (rev 5563)
+++ trunk/sources/SearchAndReplace/ui/searchandreplacewidget.cpp 2018-10-21 09:54:59 UTC (rev 5564)
@@ -24,6 +24,7 @@
#include "element.h"
#include "independenttextitem.h"
#include "conductor.h"
+#include "replacefoliowidget.h"
#include <QSettings>
@@ -202,8 +203,9 @@
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 @@
}
}
+/**
+ * @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 @@
}
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 @@
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<Diagram> 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 <Diagram *> d;
+ for (QTreeWidgetItem *qtwi : m_diagram_hash.keys())
+ {
+ if (!qtwi->isHidden() && qtwi->checkState(0) == Qt::Checked)
+ {
+ QPointer <Diagram> p = m_diagram_hash.value(qtwi);
+ if (p) {
+ d.append(p.data());
+ }
+ }
+ }
+ m_worker.replaceDiagram(d);
+ }
+}
Modified: trunk/sources/SearchAndReplace/ui/searchandreplacewidget.h
===================================================================
--- trunk/sources/SearchAndReplace/ui/searchandreplacewidget.h 2018-10-18 00:05:40 UTC (rev 5563)
+++ trunk/sources/SearchAndReplace/ui/searchandreplacewidget.h 2018-10-21 09:54:59 UTC (rev 5564)
@@ -20,8 +20,10 @@
#include <QWidget>
#include <QTreeWidgetItemIterator>
+
#include "element.h"
#include "independenttextitem.h"
+#include "searchandreplaceworker.h"
class QTreeWidgetItem;
@@ -57,6 +59,7 @@
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 @@
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 @@
QPointer<Element> m_highlighted_element;
QPointer<QGraphicsObject> m_last_selected;
QHash<QTreeWidgetItem *, QPointer <Diagram>> m_diagram_hash;
+ SearchAndReplaceWorker m_worker;
};
#endif // SEARCHANDREPLACEWIDGET_H
Modified: trunk/sources/SearchAndReplace/ui/searchandreplacewidget.ui
===================================================================
--- trunk/sources/SearchAndReplace/ui/searchandreplacewidget.ui 2018-10-18 00:05:40 UTC (rev 5563)
+++ trunk/sources/SearchAndReplace/ui/searchandreplacewidget.ui 2018-10-21 09:54:59 UTC (rev 5564)
@@ -26,6 +26,20 @@
<property name="bottomMargin">
<number>0</number>
</property>
+ <item row="0" column="6">
+ <widget class="QPushButton" name="m_reload_pb">
+ <property name="toolTip">
+ <string>Actualiser</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset resource="../../../qelectrotech.qrc">
+ <normaloff>:/ico/16x16/view-refresh.png</normaloff>:/ico/16x16/view-refresh.png</iconset>
+ </property>
+ </widget>
+ </item>
<item row="0" column="4">
<widget class="QPushButton" name="m_next_pb">
<property name="toolTip">
@@ -43,6 +57,29 @@
</property>
</widget>
</item>
+ <item row="0" column="7">
+ <widget class="QPushButton" name="m_advanced_pb">
+ <property name="toolTip">
+ <string>Avancé</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset resource="../../../qelectrotech.qrc">
+ <normaloff>:/ico/16x16/configure-toolbars.png</normaloff>:/ico/16x16/configure-toolbars.png</iconset>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ <property name="flat">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
<item row="4" column="0" colspan="8">
<widget class="QTreeWidget" name="m_tree_widget">
<property name="uniformRowHeights">
@@ -81,6 +118,19 @@
</property>
</widget>
</item>
+ <item row="5" column="0">
+ <spacer name="m_v_spacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>0</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
<item row="0" column="0">
<widget class="QPushButton" name="m_quit_button">
<property name="toolTip">
@@ -100,138 +150,100 @@
</item>
<item row="0" column="3" rowspan="3">
<layout class="QGridLayout" name="gridLayout">
- <item row="1" column="1" colspan="4">
+ <item row="1" column="1" colspan="2">
<widget class="QLineEdit" name="m_replace_le">
+ <property name="placeholderText">
+ <string>Champ texte de folio</string>
+ </property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
- <item row="1" column="0">
- <widget class="QLabel" name="m_replace">
+ <item row="1" column="3">
+ <widget class="QPushButton" name="m_folio_pb">
<property name="text">
- <string>Remplacer :</string>
+ <string>Folio</string>
</property>
</widget>
</item>
- <item row="2" column="2">
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
+ <item row="0" column="1" colspan="5">
+ <widget class="QLineEdit" name="m_search_le">
+ <property name="clearButtonEnabled">
+ <bool>true</bool>
</property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="m_search">
+ <property name="text">
+ <string>Chercher :</string>
</property>
- </spacer>
+ </widget>
</item>
- <item row="2" column="3">
- <widget class="QPushButton" name="m_replace_pb">
- <property name="toolTip">
- <string>Remplacer la correspondance séléctionner</string>
+ <item row="1" column="4">
+ <widget class="QPushButton" name="m_element_pb">
+ <property name="enabled">
+ <bool>false</bool>
</property>
<property name="text">
- <string>Remplacer</string>
+ <string>Élément</string>
</property>
</widget>
</item>
- <item row="2" column="4">
- <widget class="QPushButton" name="m_replace_all_pb">
- <property name="toolTip">
- <string>Remplacer les correspondances coché</string>
+ <item row="1" column="5">
+ <widget class="QPushButton" name="m_conductor_pb">
+ <property name="enabled">
+ <bool>false</bool>
</property>
<property name="text">
- <string>Tout remplacer</string>
+ <string>Conducteur</string>
</property>
</widget>
</item>
- <item row="2" column="0">
- <widget class="QLabel" name="m_mode">
+ <item row="1" column="0">
+ <widget class="QLabel" name="m_replace">
<property name="text">
- <string>Mode :</string>
+ <string>Remplacer :</string>
</property>
</widget>
</item>
<item row="2" column="1">
- <widget class="QComboBox" name="m_mode_cb">
- <item>
- <property name="text">
- <string>Texte brut</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Mots entiers</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="0" column="1" colspan="4">
- <widget class="QLineEdit" name="m_search_le">
- <property name="clearButtonEnabled">
- <bool>true</bool>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
</property>
- </widget>
- </item>
- <item row="0" column="0">
- <widget class="QLabel" name="m_search">
- <property name="text">
- <string>Chercher :</string>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
</property>
- </widget>
+ </spacer>
</item>
</layout>
</item>
- <item row="0" column="7">
- <widget class="QPushButton" name="m_advanced_pb">
+ <item row="2" column="4" colspan="2">
+ <widget class="QPushButton" name="m_replace_pb">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
<property name="toolTip">
- <string>Avancé</string>
+ <string>Remplacer la correspondance séléctionner</string>
</property>
<property name="text">
- <string/>
+ <string>Remplacer</string>
</property>
- <property name="icon">
- <iconset resource="../../../qelectrotech.qrc">
- <normaloff>:/ico/16x16/configure-toolbars.png</normaloff>:/ico/16x16/configure-toolbars.png</iconset>
- </property>
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="checked">
- <bool>false</bool>
- </property>
- <property name="flat">
- <bool>false</bool>
- </property>
</widget>
</item>
- <item row="5" column="0">
- <spacer name="m_v_spacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>0</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="0" column="6">
- <widget class="QPushButton" name="m_reload_pb">
+ <item row="2" column="6" colspan="2">
+ <widget class="QPushButton" name="m_replace_all_pb">
<property name="toolTip">
- <string>Actualiser</string>
+ <string>Remplacer les correspondances coché</string>
</property>
<property name="text">
- <string/>
+ <string>Tout remplacer</string>
</property>
- <property name="icon">
- <iconset resource="../../../qelectrotech.qrc">
- <normaloff>:/ico/16x16/view-refresh.png</normaloff>:/ico/16x16/view-refresh.png</iconset>
- </property>
</widget>
</item>
</layout>
Modified: trunk/sources/diagramcommands.cpp
===================================================================
--- trunk/sources/diagramcommands.cpp 2018-10-18 00:05:40 UTC (rev 5563)
+++ trunk/sources/diagramcommands.cpp 2018-10-21 09:54:59 UTC (rev 5564)
@@ -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
@@ -530,44 +530,6 @@
/**
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
@param old_bp Anciennes proprietes du cadre du schema
@param new_bp Nouvelles proprietes du cadre du schema
Modified: trunk/sources/diagramcommands.h
===================================================================
--- trunk/sources/diagramcommands.h 2018-10-18 00:05:40 UTC (rev 5563)
+++ trunk/sources/diagramcommands.h 2018-10-21 09:54:59 UTC (rev 5564)
@@ -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,32 +272,8 @@
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.
*/
Modified: trunk/sources/diagramcontext.cpp
===================================================================
--- trunk/sources/diagramcontext.cpp 2018-10-18 00:05:40 UTC (rev 5563)
+++ trunk/sources/diagramcontext.cpp 2018-10-21 09:54:59 UTC (rev 5564)
@@ -21,6 +21,21 @@
#include <algorithm>
/**
+ * @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.
*/
QList<QString> DiagramContext::keys(DiagramContext::KeyOrder order) const
Modified: trunk/sources/diagramcontext.h
===================================================================
--- trunk/sources/diagramcontext.h 2018-10-18 00:05:40 UTC (rev 5563)
+++ trunk/sources/diagramcontext.h 2018-10-21 09:54:59 UTC (rev 5564)
@@ -56,6 +56,7 @@
DecreasingLength
};
+ void add(DiagramContext other);
QList<QString> keys(KeyOrder = None) const;
bool contains(const QString &) const;
const QVariant operator[](const QString &) const;
Modified: trunk/sources/diagramview.cpp
===================================================================
--- trunk/sources/diagramview.cpp 2018-10-18 00:05:40 UTC (rev 5563)
+++ trunk/sources/diagramview.cpp 2018-10-21 09:54:59 UTC (rev 5564)
@@ -43,6 +43,7 @@
#include "undocommand/deleteqgraphicsitemcommand.h"
#include "dynamicelementtextitem.h"
#include "multipastedialog.h"
+#include "changetitleblockcommand.h"
/**
Constructeur
Modified: trunk/sources/ui/diagrampropertiesdialog.cpp
===================================================================
--- trunk/sources/ui/diagrampropertiesdialog.cpp 2018-10-18 00:05:40 UTC (rev 5563)
+++ trunk/sources/ui/diagrampropertiesdialog.cpp 2018-10-21 09:54:59 UTC (rev 5564)
@@ -22,6 +22,7 @@
#include "diagramcommands.h"
#include "projectpropertiesdialog.h"
#include "diagram.h"
+#include "changetitleblockcommand.h"
/**
* @brief DiagramPropertiesDialog::DiagramPropertiesDialog
Added: trunk/sources/undocommand/changetitleblockcommand.cpp
===================================================================
--- trunk/sources/undocommand/changetitleblockcommand.cpp (rev 0)
+++ trunk/sources/undocommand/changetitleblockcommand.cpp 2018-10-21 09:54:59 UTC (rev 5564)
@@ -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 <http://www.gnu.org/licenses/>.
+*/
+
+#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());
+}
Added: trunk/sources/undocommand/changetitleblockcommand.h
===================================================================
--- trunk/sources/undocommand/changetitleblockcommand.h (rev 0)
+++ trunk/sources/undocommand/changetitleblockcommand.h 2018-10-21 09:54:59 UTC (rev 5564)
@@ -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 <http://www.gnu.org/licenses/>.
+*/
+#ifndef CHANGETITLEBLOCKCOMMAND_H
+#define CHANGETITLEBLOCKCOMMAND_H
+
+#include <QUndoCommand>
+
+#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