mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 23:20:52 +01:00
Mod doc + Update Copyright date
And wrap code for better readability
This commit is contained in:
committed by
Laurent Trinques
parent
6aa6d055ec
commit
8c9b30acd6
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2014 The QElectroTech team
|
Copyright 2006-2020 The QElectroTech team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -26,16 +26,23 @@
|
|||||||
#include "assignvariables.h"
|
#include "assignvariables.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ConductorAutoNumerotation::ConductorAutoNumerotation
|
@brief ConductorAutoNumerotation::ConductorAutoNumerotation
|
||||||
* Constructor of autonum, after create a class, call numerate to apply the autonum.
|
Constructor of autonum, after create a class,
|
||||||
* When autonum is applyed, they do with an undo command added to the stack of diagram.
|
call numerate to apply the autonum.
|
||||||
* If you give a parent_undo at constructor, the undo command create in this class have parent_undo for parent,
|
When autonum is applyed,
|
||||||
* and wasn't added to the stack of diagram (it's the responsabillty of the parent_undo)
|
they do with an undo command added to the stack of diagram.
|
||||||
* @param conductor : the conductor to apply automatic numerotation
|
If you give a parent_undo at constructor,
|
||||||
* @param diagram : the diagram of conductor
|
the undo command create in this class have parent_undo for parent,
|
||||||
* @param parent_undo : parent undo command
|
and wasn't added to the stack of diagram
|
||||||
*/
|
(it's the responsabillty of the parent_undo)
|
||||||
ConductorAutoNumerotation::ConductorAutoNumerotation(Conductor *conductor, Diagram *diagram, QUndoCommand *parent_undo) :
|
@param conductor : the conductor to apply automatic numerotation
|
||||||
|
@param diagram : the diagram of conductor
|
||||||
|
@param parent_undo : parent undo command
|
||||||
|
*/
|
||||||
|
ConductorAutoNumerotation::ConductorAutoNumerotation(
|
||||||
|
Conductor *conductor,
|
||||||
|
Diagram *diagram,
|
||||||
|
QUndoCommand *parent_undo) :
|
||||||
m_diagram (diagram),
|
m_diagram (diagram),
|
||||||
m_conductor (conductor),
|
m_conductor (conductor),
|
||||||
conductor_list (conductor -> relatedPotentialConductors().values()),
|
conductor_list (conductor -> relatedPotentialConductors().values()),
|
||||||
@@ -43,19 +50,22 @@ ConductorAutoNumerotation::ConductorAutoNumerotation(Conductor *conductor, Diagr
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ConductorAutoNumerotation::numerate
|
@brief ConductorAutoNumerotation::numerate
|
||||||
* execute the automatic numerotation
|
execute the automatic numerotation
|
||||||
*/
|
*/
|
||||||
void ConductorAutoNumerotation::numerate() {
|
void ConductorAutoNumerotation::numerate() {
|
||||||
if (!m_conductor) return;
|
if (!m_conductor) return;
|
||||||
if (conductor_list.size() >= 1 ) numeratePotential();
|
if (conductor_list.size() >= 1 ) numeratePotential();
|
||||||
else if (m_conductor -> properties().type == ConductorProperties::Multi) numerateNewConductor();
|
else if (m_conductor -> properties().type == ConductorProperties::Multi)
|
||||||
|
numerateNewConductor();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ConductorAutoNumerotation::applyText
|
@brief ConductorAutoNumerotation::applyText
|
||||||
* apply the text @t to @conductor_ and all conductors at the same potential
|
apply the text @t to @conductor_
|
||||||
*/
|
and all conductors at the same potential
|
||||||
|
@param t : Conductor text
|
||||||
|
*/
|
||||||
void ConductorAutoNumerotation::applyText(const QString& t)
|
void ConductorAutoNumerotation::applyText(const QString& t)
|
||||||
{
|
{
|
||||||
if (!m_conductor) return;
|
if (!m_conductor) return;
|
||||||
@@ -70,20 +80,36 @@ void ConductorAutoNumerotation::applyText(const QString& t)
|
|||||||
|
|
||||||
if (m_parent_undo)
|
if (m_parent_undo)
|
||||||
{
|
{
|
||||||
new QPropertyUndoCommand(m_conductor, "properties", old_value, new_value, m_parent_undo);
|
new QPropertyUndoCommand(
|
||||||
|
m_conductor,
|
||||||
|
"properties",
|
||||||
|
old_value,
|
||||||
|
new_value,
|
||||||
|
m_parent_undo);
|
||||||
undo = m_parent_undo;
|
undo = m_parent_undo;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
undo = new QUndoCommand();
|
undo = new QUndoCommand();
|
||||||
new QPropertyUndoCommand(m_conductor, "properties", old_value, new_value, undo);
|
new QPropertyUndoCommand(
|
||||||
undo->setText(QObject::tr("Modifier les propriétés d'un conducteur", "undo caption"));
|
m_conductor,
|
||||||
|
"properties",
|
||||||
|
old_value,
|
||||||
|
new_value,
|
||||||
|
undo);
|
||||||
|
undo->setText(
|
||||||
|
QObject::tr(
|
||||||
|
"Modifier les propriétés d'un conducteur",
|
||||||
|
"undo caption"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!conductor_list.isEmpty())
|
if (!conductor_list.isEmpty())
|
||||||
{
|
{
|
||||||
if (!m_parent_undo)
|
if (!m_parent_undo)
|
||||||
undo->setText(QObject::tr("Modifier les propriétés de plusieurs conducteurs", "undo caption"));
|
undo->setText(
|
||||||
|
QObject::tr(
|
||||||
|
"Modifier les propriétés de plusieurs conducteurs",
|
||||||
|
"undo caption"));
|
||||||
|
|
||||||
foreach (Conductor *cond, conductor_list)
|
foreach (Conductor *cond, conductor_list)
|
||||||
{
|
{
|
||||||
@@ -91,7 +117,12 @@ void ConductorAutoNumerotation::applyText(const QString& t)
|
|||||||
old_value.setValue(cp2);
|
old_value.setValue(cp2);
|
||||||
cp2.text = t;
|
cp2.text = t;
|
||||||
new_value.setValue(cp2);
|
new_value.setValue(cp2);
|
||||||
new QPropertyUndoCommand(cond, "properties", old_value, new_value, undo);
|
new QPropertyUndoCommand(
|
||||||
|
cond,
|
||||||
|
"properties",
|
||||||
|
old_value,
|
||||||
|
new_value,
|
||||||
|
undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,15 +131,19 @@ void ConductorAutoNumerotation::applyText(const QString& t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ConductorAutoNumerotation::newProperties
|
@brief ConductorAutoNumerotation::newProperties
|
||||||
* Create a new properties according to the current autonum rule of diagram
|
Create a new properties according to the current autonum rule of diagram
|
||||||
* @param d
|
@param diagram : Diagram class
|
||||||
* @param cp
|
@param cp : ConductorProperties
|
||||||
* @param seq
|
@param seq : sequentialNumbers
|
||||||
*/
|
*/
|
||||||
void ConductorAutoNumerotation::newProperties(Diagram *diagram, ConductorProperties &cp, autonum::sequentialNumbers &seq)
|
void ConductorAutoNumerotation::newProperties(
|
||||||
|
Diagram *diagram,
|
||||||
|
ConductorProperties &cp,
|
||||||
|
autonum::sequentialNumbers &seq)
|
||||||
{
|
{
|
||||||
NumerotationContext context = diagram->project()->conductorAutoNum(diagram->conductorsAutonumName());
|
NumerotationContext context = diagram->project()->conductorAutoNum(
|
||||||
|
diagram->conductorsAutonumName());
|
||||||
if (context.isEmpty()) {
|
if (context.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -124,9 +159,9 @@ void ConductorAutoNumerotation::newProperties(Diagram *diagram, ConductorPropert
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ConductorAutoNumerotation::numeratePotential
|
@brief ConductorAutoNumerotation::numeratePotential
|
||||||
* Numerate a conductor on an existing potential
|
Numerate a conductor on an existing potential
|
||||||
*/
|
*/
|
||||||
void ConductorAutoNumerotation::numeratePotential()
|
void ConductorAutoNumerotation::numeratePotential()
|
||||||
{
|
{
|
||||||
ConductorProperties cp = conductor_list.first()->properties();
|
ConductorProperties cp = conductor_list.first()->properties();
|
||||||
@@ -136,7 +171,8 @@ void ConductorAutoNumerotation::numeratePotential()
|
|||||||
if (conductor->properties() != cp)
|
if (conductor->properties() != cp)
|
||||||
properties_equal = false;
|
properties_equal = false;
|
||||||
}
|
}
|
||||||
//Every properties of the potential is equal, so we apply it to m_conductor
|
// Every properties of the potential is equal,
|
||||||
|
// so we apply it to m_conductor
|
||||||
if (properties_equal)
|
if (properties_equal)
|
||||||
{
|
{
|
||||||
m_conductor->setProperties(cp);
|
m_conductor->setProperties(cp);
|
||||||
@@ -169,21 +205,25 @@ void ConductorAutoNumerotation::numeratePotential()
|
|||||||
//the texts isn't identicals
|
//the texts isn't identicals
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PotentialSelectorDialog psd(m_conductor, m_parent_undo, m_conductor->diagramEditor());
|
PotentialSelectorDialog psd(
|
||||||
|
m_conductor,
|
||||||
|
m_parent_undo,
|
||||||
|
m_conductor->diagramEditor());
|
||||||
psd.exec();
|
psd.exec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ConductorAutoNumerotation::numerateNewConductor
|
@brief ConductorAutoNumerotation::numerateNewConductor
|
||||||
* create and apply a new numerotation to @m_conductor
|
create and apply a new numerotation to @m_conductor
|
||||||
*/
|
*/
|
||||||
void ConductorAutoNumerotation::numerateNewConductor()
|
void ConductorAutoNumerotation::numerateNewConductor()
|
||||||
{
|
{
|
||||||
if (!m_conductor || m_diagram->conductorsAutonumName().isEmpty())
|
if (!m_conductor || m_diagram->conductorsAutonumName().isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
NumerotationContext context = m_diagram->project()->conductorAutoNum(m_diagram -> conductorsAutonumName());
|
NumerotationContext context = m_diagram->project()->conductorAutoNum(
|
||||||
|
m_diagram -> conductorsAutonumName());
|
||||||
if (context.isEmpty())
|
if (context.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -194,10 +234,17 @@ void ConductorAutoNumerotation::numerateNewConductor()
|
|||||||
cp.m_formula = formula;
|
cp.m_formula = formula;
|
||||||
m_conductor->setProperties(cp);
|
m_conductor->setProperties(cp);
|
||||||
|
|
||||||
autonum::setSequential(formula, m_conductor->rSequenceNum(), context, m_diagram, autoNum_name);
|
autonum::setSequential(formula,
|
||||||
|
m_conductor->rSequenceNum(),
|
||||||
|
context,
|
||||||
|
m_diagram,
|
||||||
|
autoNum_name);
|
||||||
|
|
||||||
NumerotationContextCommands ncc (context, m_diagram);
|
NumerotationContextCommands ncc (context, m_diagram);
|
||||||
m_diagram->project()->addConductorAutoNum(autoNum_name, ncc.next());
|
m_diagram->project()->addConductorAutoNum(autoNum_name, ncc.next());
|
||||||
|
|
||||||
applyText(autonum::AssignVariables::formulaToLabel(formula, m_conductor->rSequenceNum(), m_diagram));
|
applyText(autonum::AssignVariables::formulaToLabel(
|
||||||
|
formula,
|
||||||
|
m_conductor->rSequenceNum(),
|
||||||
|
m_diagram));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2014 The QElectroTech team
|
Copyright 2006-2020 The QElectroTech team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -26,16 +26,23 @@ class Conductor;
|
|||||||
class QUndoCommand;
|
class QUndoCommand;
|
||||||
class ConductorProperties;
|
class ConductorProperties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief The ConductorAutoNumerotation class
|
||||||
|
*/
|
||||||
class ConductorAutoNumerotation
|
class ConductorAutoNumerotation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//constructors & destructor
|
//constructors & destructor
|
||||||
ConductorAutoNumerotation (Conductor *conductor, Diagram *diagram, QUndoCommand *undo_parent = nullptr);
|
ConductorAutoNumerotation (Conductor *conductor,
|
||||||
|
Diagram *diagram,
|
||||||
|
QUndoCommand *undo_parent = nullptr);
|
||||||
|
|
||||||
//methods
|
//methods
|
||||||
void numerate ();
|
void numerate ();
|
||||||
void applyText (const QString&);
|
void applyText (const QString&);
|
||||||
static void newProperties(Diagram *diagram, ConductorProperties &cp, autonum::sequentialNumbers &seq);
|
static void newProperties(Diagram *diagram,
|
||||||
|
ConductorProperties &cp,
|
||||||
|
autonum::sequentialNumbers &seq);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//methods
|
//methods
|
||||||
|
|||||||
Reference in New Issue
Block a user