QElectroTech  0.70
conductorpropertiesdialog.cpp
Go to the documentation of this file.
1 /*
2  Copyright 2006-2019 The QElectroTech Team
3  This file is part of QElectroTech.
4 
5  QElectroTech is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 2 of the License, or
8  (at your option) any later version.
9 
10  QElectroTech is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
20 #include "ui_conductorpropertiesdialog.h"
21 #include "conductor.h"
23 #include "diagram.h"
25 
33  QDialog(parent),
35 {
36  ui->setupUi(this);
37  m_cpw = new ConductorPropertiesWidget(conductor->properties());
38  m_cpw -> setHiddenOneTextPerFolio(true);
40  if (conductor -> diagram() -> defaultConductorProperties.m_one_text_per_folio == true &&
41  conductor -> relatedPotentialConductors().size()) {
43  }
44  ui -> main_layout -> insertWidget(0, m_cpw);
45 }
46 
51 {
52  delete ui;
53 }
54 
61 void ConductorPropertiesDialog::PropertiesDialog(Conductor *conductor, QWidget *parent)
62 {
63  ConductorPropertiesDialog cpd (conductor, parent);
64 
65  if (cpd.exec() == QDialog::Rejected || cpd.properties() == conductor->properties()) return;
66 
67  QVariant old_value, new_value;
68  old_value.setValue(conductor->properties());
69  new_value.setValue(cpd.properties());
70 
71  QPropertyUndoCommand *undo = new QPropertyUndoCommand(conductor, "properties", old_value, new_value);
72  undo->setText(tr("Modifier les propriétés d'un conducteur", "undo caption"));
73 
74  if (!conductor->relatedPotentialConductors().isEmpty() && cpd.applyAll())
75  {
76  undo->setText(tr("Modifier les propriétés de plusieurs conducteurs", "undo caption"));
77 
78  foreach (Conductor *potential_conductor, conductor->relatedPotentialConductors())
79  {
80  old_value.setValue(potential_conductor->properties());
81  new QPropertyUndoCommand (potential_conductor, "properties", old_value, new_value, undo);
82  }
83  }
84 
85  conductor->diagram()->undoStack().push(undo);
86 }
87 
93  return m_cpw -> properties();
94 }
95 
103  return ui -> m_apply_all_cb -> isChecked();
104 }
The QPropertyUndoCommand class This undo command manage QProperty of a QObject. This undo command can...
ConductorProperties properties
Conductor::properties.
Definition: conductor.h:48
ConductorProperties properties() const
ConductorPropertiesDialog::properties.
~ConductorPropertiesDialog() override
ConductorPropertiesDialog::~ConductorPropertiesDialog.
QSet< Conductor * > relatedPotentialConductors(const bool all_diagram=true, QList< Terminal *> *t_list=nullptr)
Conductor::relatedPotentialConductors Return all conductors at the same potential of this conductor...
Definition: conductor.cpp:1603
static void PropertiesDialog(Conductor *conductor, QWidget *parent=nullptr)
ConductorPropertiesDialog::PropertiesDialog Static method for open and apply properties.
bool applyAll() const
ConductorPropertiesDialog::applyAll.
Diagram * diagram() const
Definition: conductor.cpp:557
void setDisabledShowText(const bool &disable=true)
ConductorPropertiesWidget::setDisabledShowText.
Ui::ConductorPropertiesDialog * ui
QIcon tr
Definition: qeticons.cpp:204
QUndoStack & undoStack()
Definition: diagram.h:337
void setHiddenAvailableAutonum(const bool &hide)
ConductorPropertiesWidget::setHiddenAvailableAutonum Hide the label, combo box and push button of ava...
ConductorPropertiesDialog(Conductor *conductor, QWidget *parent=nullptr)
ConductorPropertiesDialog::ConductorPropertiesDialog Constructor.
ConductorPropertiesWidget * m_cpw