2014-09-02 18:41:25 +00:00
|
|
|
/*
|
2024-03-29 10:09:48 +01:00
|
|
|
Copyright 2006-2024 The QElectroTech Team
|
2014-09-02 18:41:25 +00:00
|
|
|
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 "conductorpropertiesdialog.h"
|
2020-12-08 19:57:35 +01:00
|
|
|
|
|
|
|
#include "../QPropertyUndoCommand/qpropertyundocommand.h"
|
|
|
|
#include "../diagram.h"
|
|
|
|
#include "../qetgraphicsitem/conductor.h"
|
2014-09-02 18:41:25 +00:00
|
|
|
#include "conductorpropertieswidget.h"
|
2020-12-08 19:57:35 +01:00
|
|
|
#include "ui_conductorpropertiesdialog.h"
|
2014-09-02 18:41:25 +00:00
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
@brief ConductorPropertiesDialog::ConductorPropertiesDialog
|
|
|
|
Constructor
|
2022-12-04 08:21:12 -05:00
|
|
|
@param conductor : conductor to edit properties
|
2020-08-20 21:57:35 +02:00
|
|
|
@param parent : parent widget
|
2020-08-16 11:19:36 +02:00
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
ConductorPropertiesDialog::ConductorPropertiesDialog(
|
|
|
|
Conductor *conductor, QWidget *parent) :
|
2014-09-02 18:41:25 +00:00
|
|
|
QDialog(parent),
|
|
|
|
ui(new Ui::ConductorPropertiesDialog)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
m_cpw = new ConductorPropertiesWidget(conductor->properties());
|
2014-10-03 17:02:01 +00:00
|
|
|
m_cpw -> setHiddenOneTextPerFolio(true);
|
2017-02-27 16:58:05 +00:00
|
|
|
m_cpw->setHiddenAvailableAutonum(true);
|
2014-10-13 18:42:38 +00:00
|
|
|
if (conductor -> diagram() -> defaultConductorProperties.m_one_text_per_folio == true &&
|
|
|
|
conductor -> relatedPotentialConductors().size()) {
|
|
|
|
m_cpw->setDisabledShowText();
|
|
|
|
}
|
2015-08-26 21:46:47 +00:00
|
|
|
ui -> main_layout -> insertWidget(0, m_cpw);
|
2014-09-02 18:41:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
@brief ConductorPropertiesDialog::~ConductorPropertiesDialog
|
|
|
|
*/
|
2014-09-02 18:41:25 +00:00
|
|
|
ConductorPropertiesDialog::~ConductorPropertiesDialog()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
@brief ConductorPropertiesDialog::PropertiesDialog
|
|
|
|
Static method for open and apply properties.
|
2022-12-04 08:21:12 -05:00
|
|
|
@param conductor : conductor to edit properties
|
2020-08-20 21:57:35 +02:00
|
|
|
@param parent : parent widget
|
2020-08-16 11:19:36 +02:00
|
|
|
*/
|
2020-08-20 21:58:23 +02:00
|
|
|
void ConductorPropertiesDialog::PropertiesDialog(Conductor *conductor,
|
|
|
|
QWidget *parent)
|
2015-08-09 12:06:31 +00:00
|
|
|
{
|
2014-09-02 18:41:25 +00:00
|
|
|
ConductorPropertiesDialog cpd (conductor, parent);
|
|
|
|
|
2020-08-20 21:58:23 +02:00
|
|
|
if (cpd.exec() == QDialog::Rejected
|
|
|
|
|| cpd.properties() == conductor->properties()) return;
|
2015-08-22 13:18:20 +00:00
|
|
|
|
|
|
|
QVariant old_value, new_value;
|
|
|
|
old_value.setValue(conductor->properties());
|
|
|
|
new_value.setValue(cpd.properties());
|
2014-09-02 18:41:25 +00:00
|
|
|
|
2018-07-30 15:24:29 +00:00
|
|
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(conductor, "properties", old_value, new_value);
|
2015-08-22 13:18:20 +00:00
|
|
|
undo->setText(tr("Modifier les propriétés d'un conducteur", "undo caption"));
|
|
|
|
|
2015-08-29 14:18:30 +00:00
|
|
|
if (!conductor->relatedPotentialConductors().isEmpty() && cpd.applyAll())
|
2015-08-22 13:18:20 +00:00
|
|
|
{
|
|
|
|
undo->setText(tr("Modifier les propriétés de plusieurs conducteurs", "undo caption"));
|
2014-09-02 18:41:25 +00:00
|
|
|
|
2017-02-05 16:18:50 +00:00
|
|
|
foreach (Conductor *potential_conductor, conductor->relatedPotentialConductors())
|
2015-08-09 12:06:31 +00:00
|
|
|
{
|
2015-08-29 14:18:30 +00:00
|
|
|
old_value.setValue(potential_conductor->properties());
|
|
|
|
new QPropertyUndoCommand (potential_conductor, "properties", old_value, new_value, undo);
|
2014-09-02 18:41:25 +00:00
|
|
|
}
|
|
|
|
}
|
2015-08-22 13:18:20 +00:00
|
|
|
|
|
|
|
conductor->diagram()->undoStack().push(undo);
|
2014-09-02 18:41:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
@brief ConductorPropertiesDialog::properties
|
|
|
|
@return the edited properties
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
ConductorProperties ConductorPropertiesDialog::properties() const
|
|
|
|
{
|
2014-09-02 18:41:25 +00:00
|
|
|
return m_cpw -> properties();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
@brief ConductorPropertiesDialog::applyAll
|
|
|
|
@return
|
2022-12-04 08:21:12 -05:00
|
|
|
true -> must apply properties to all conductors at the same potential
|
2020-08-16 11:19:36 +02:00
|
|
|
false -> must apply properties only for the edited conductor
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
bool ConductorPropertiesDialog::applyAll() const
|
|
|
|
{
|
2014-09-02 18:41:25 +00:00
|
|
|
return ui -> m_apply_all_cb -> isChecked();
|
|
|
|
}
|