mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-13 20:23:04 +02:00
Use QPropertyUndoCommand instead of ChangeSeveralConductorsPropertiesCommand and ChangeConductorsPropertiesCommand.
Remove class ChangeSeveralConductorsPropertiesCommand and ChangeConductorsPropertiesCommand. git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4092 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
parent
c801c3e0a5
commit
ed75c57c1d
@ -16,13 +16,13 @@
|
|||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "conductorautonumerotation.h"
|
#include "conductorautonumerotation.h"
|
||||||
#include "diagramcommands.h"
|
|
||||||
#include "numerotationcontextcommands.h"
|
#include "numerotationcontextcommands.h"
|
||||||
#include "qetdiagrameditor.h"
|
#include "qetdiagrameditor.h"
|
||||||
#include "conductor.h"
|
#include "conductor.h"
|
||||||
#include "diagram.h"
|
#include "diagram.h"
|
||||||
#include "potentialtextsdialog.h"
|
#include "potentialtextsdialog.h"
|
||||||
#include "qet.h"
|
#include "qet.h"
|
||||||
|
#include "QPropertyUndoCommand/qpropertyundocommand.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ConductorAutoNumerotation::ConductorAutoNumerotation
|
* @brief ConductorAutoNumerotation::ConductorAutoNumerotation
|
||||||
@ -80,42 +80,34 @@ void ConductorAutoNumerotation::checkPotential(Conductor *conductor, QUndoComman
|
|||||||
* @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
|
||||||
*/
|
*/
|
||||||
void ConductorAutoNumerotation::applyText(QString t) {
|
void ConductorAutoNumerotation::applyText(QString t)
|
||||||
|
{
|
||||||
if (!conductor_) return;
|
if (!conductor_) return;
|
||||||
|
|
||||||
if (conductor_list.empty())
|
QVariant old_value, new_value;
|
||||||
{
|
|
||||||
//initialize the corresponding UndoCommand object
|
|
||||||
ChangeConductorPropertiesCommand *ccpc = new ChangeConductorPropertiesCommand (conductor_, m_parent_undo);
|
|
||||||
ccpc -> setOldSettings (conductor_ -> properties());
|
|
||||||
ConductorProperties cp = conductor_ -> properties();
|
ConductorProperties cp = conductor_ -> properties();
|
||||||
|
old_value.setValue(cp);
|
||||||
cp.text = t;
|
cp.text = t;
|
||||||
ccpc -> setNewSettings(cp);
|
new_value.setValue(cp);
|
||||||
if (!m_parent_undo)
|
|
||||||
m_diagram -> undoStack().push(ccpc);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
QList <Conductor *> clist = conductor_list.toList();
|
|
||||||
clist << conductor_;
|
|
||||||
QList <ConductorProperties> old_properties, new_properties;
|
|
||||||
ConductorProperties cp;
|
|
||||||
|
|
||||||
foreach (Conductor *c, clist)
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(conductor_, "properties", old_value, new_value, m_parent_undo);
|
||||||
|
undo->setText(QObject::tr("Modifier les propriétés d'un conducteur", "undo caption"));
|
||||||
|
|
||||||
|
if (!conductor_list.isEmpty())
|
||||||
{
|
{
|
||||||
old_properties << c -> properties();
|
undo->setText(QObject::tr("Modifier les propriétés de plusieurs conducteurs", "undo caption"));
|
||||||
cp = c -> properties();
|
foreach (Conductor *cond, conductor_list)
|
||||||
cp.text = t;
|
{
|
||||||
new_properties << cp;
|
ConductorProperties cp2 = cond -> properties();
|
||||||
|
old_value.setValue(cp2);
|
||||||
|
cp2.text = t;
|
||||||
|
new_value.setValue(cp2);
|
||||||
|
new QPropertyUndoCommand(cond, "properties", old_value, new_value, undo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//initialize the corresponding UndoCommand object
|
|
||||||
ChangeSeveralConductorsPropertiesCommand *cscpc = new ChangeSeveralConductorsPropertiesCommand(clist, m_parent_undo);
|
|
||||||
cscpc -> setOldSettings(old_properties);
|
|
||||||
cscpc -> setNewSettings(new_properties);
|
|
||||||
if (!m_parent_undo)
|
if (!m_parent_undo)
|
||||||
m_diagram -> undoStack().push(cscpc);
|
m_diagram->undoStack().push(undo);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,9 +17,12 @@
|
|||||||
*/
|
*/
|
||||||
#ifndef CONDUCTOR_PROPERTIES_H
|
#ifndef CONDUCTOR_PROPERTIES_H
|
||||||
#define CONDUCTOR_PROPERTIES_H
|
#define CONDUCTOR_PROPERTIES_H
|
||||||
|
|
||||||
#include "qet.h"
|
#include "qet.h"
|
||||||
#include <QtWidgets>
|
#include <QColor>
|
||||||
#include <QtXml>
|
|
||||||
|
class QPainter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This class represents the properties of a singleline conductor.
|
This class represents the properties of a singleline conductor.
|
||||||
*/
|
*/
|
||||||
@ -109,4 +112,7 @@ class ConductorProperties {
|
|||||||
void readStyle(const QString &);
|
void readStyle(const QString &);
|
||||||
QString writeStyle() const;
|
QString writeStyle() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(ConductorProperties)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
#include "diagram.h"
|
#include "diagram.h"
|
||||||
#include "qetgraphicsitem/diagramtextitem.h"
|
#include "qetgraphicsitem/diagramtextitem.h"
|
||||||
#include "qetgraphicsitem/diagramimageitem.h"
|
#include "qetgraphicsitem/diagramimageitem.h"
|
||||||
#include "conductorautonumerotation.h"
|
|
||||||
#include <QPropertyAnimation>
|
#include <QPropertyAnimation>
|
||||||
|
|
||||||
QString itemText(const QetGraphicsItem *item) {
|
QString itemText(const QetGraphicsItem *item) {
|
||||||
@ -810,140 +809,3 @@ void ChangeBorderCommand::redo() {
|
|||||||
diagram -> showMe();
|
diagram -> showMe();
|
||||||
diagram -> border_and_titleblock.importBorder(new_properties);
|
diagram -> border_and_titleblock.importBorder(new_properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
Constructeur
|
|
||||||
@param c Le conducteur dont on modifie les proprietes
|
|
||||||
@param parent QUndoCommand parent
|
|
||||||
*/
|
|
||||||
ChangeConductorPropertiesCommand::ChangeConductorPropertiesCommand(Conductor *c, QUndoCommand *parent) :
|
|
||||||
QUndoCommand(QObject::tr("modifier les propriétés d'un conducteur", "undo caption"), parent),
|
|
||||||
conductor(c),
|
|
||||||
old_settings_set(false),
|
|
||||||
new_settings_set(false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Destructeur
|
|
||||||
ChangeConductorPropertiesCommand::~ChangeConductorPropertiesCommand() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/// definit l'ancienne configuration
|
|
||||||
void ChangeConductorPropertiesCommand::setOldSettings(const ConductorProperties &properties) {
|
|
||||||
old_properties = properties;
|
|
||||||
old_settings_set = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// definit la nouvelle configuration
|
|
||||||
void ChangeConductorPropertiesCommand::setNewSettings(const ConductorProperties &properties) {
|
|
||||||
new_properties = properties;
|
|
||||||
new_settings_set = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Annule les changements - Attention : les anciens et nouveaux parametres
|
|
||||||
doivent avoir ete definis a l'aide de setNewSettings et setOldSettings
|
|
||||||
*/
|
|
||||||
void ChangeConductorPropertiesCommand::undo() {
|
|
||||||
if (conductor -> diagram()) conductor -> diagram() -> showMe();
|
|
||||||
if (old_settings_set && new_settings_set) {
|
|
||||||
conductor -> setProperties(old_properties);
|
|
||||||
conductor -> update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Refait les changements - Attention : les anciens et nouveaux parametres
|
|
||||||
doivent avoir ete definis a l'aide de setNewSettings et setOldSettings
|
|
||||||
*/
|
|
||||||
void ChangeConductorPropertiesCommand::redo() {
|
|
||||||
if (conductor -> diagram()) conductor -> diagram() -> showMe();
|
|
||||||
if (old_settings_set && new_settings_set) {
|
|
||||||
conductor -> setProperties(new_properties);
|
|
||||||
conductor -> update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Constructeur
|
|
||||||
@param c La liste des conducteurs dont on modifie les proprietes
|
|
||||||
@param parent QUndoCommand parent
|
|
||||||
*/
|
|
||||||
ChangeSeveralConductorsPropertiesCommand::ChangeSeveralConductorsPropertiesCommand(QList<Conductor *>c, QUndoCommand *parent) :
|
|
||||||
QUndoCommand(QObject::tr("modifier les propriétés de plusieurs conducteurs", "undo caption"), parent),
|
|
||||||
conductors(c),
|
|
||||||
old_settings_set(false),
|
|
||||||
new_settings_set(false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Destructeur
|
|
||||||
ChangeSeveralConductorsPropertiesCommand::~ChangeSeveralConductorsPropertiesCommand() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/// definit l'ancienne configuration
|
|
||||||
void ChangeSeveralConductorsPropertiesCommand::setOldSettings(const QList<ConductorProperties> &properties) {
|
|
||||||
if (!old_settings_set) {
|
|
||||||
old_properties = properties;
|
|
||||||
old_settings_set = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// definit la nouvelle configuration
|
|
||||||
void ChangeSeveralConductorsPropertiesCommand::setNewSettings(const QList<ConductorProperties> &properties) {
|
|
||||||
if (!new_settings_set) {
|
|
||||||
new_properties = properties;
|
|
||||||
new_settings_set = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChangeSeveralConductorsPropertiesCommand::setNewSettings(const ConductorProperties &properties) {
|
|
||||||
if (!new_settings_set) {
|
|
||||||
single_new_properties = properties;
|
|
||||||
new_settings_set = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Annule les changements - Attention : les anciens et nouveaux parametres
|
|
||||||
doivent avoir ete definis a l'aide de setNewSettings et setOldSettings
|
|
||||||
*/
|
|
||||||
void ChangeSeveralConductorsPropertiesCommand::undo() {
|
|
||||||
if (conductors.first() -> diagram()) conductors.first() -> diagram();
|
|
||||||
if (old_settings_set && new_settings_set) {
|
|
||||||
int i=0;
|
|
||||||
foreach(Conductor *c, conductors) {
|
|
||||||
c -> setProperties(old_properties.at(i));
|
|
||||||
c -> update();
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Refait les changements - Attention : les anciens et nouveaux parametres
|
|
||||||
doivent avoir ete definis a l'aide de setNewSettings et setOldSettings
|
|
||||||
*/
|
|
||||||
void ChangeSeveralConductorsPropertiesCommand::redo() {
|
|
||||||
if (conductors.first() -> diagram()) conductors.first() -> diagram();
|
|
||||||
if (old_settings_set && new_settings_set) {
|
|
||||||
|
|
||||||
//new propertie are the same for each conductor
|
|
||||||
if (new_properties.isEmpty()) {
|
|
||||||
foreach(Conductor *c, conductors) {
|
|
||||||
c -> setProperties(single_new_properties);
|
|
||||||
c -> update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//new propertie are different for each conductor
|
|
||||||
else {
|
|
||||||
int i=0;
|
|
||||||
foreach(Conductor *c, conductors) {
|
|
||||||
c -> setProperties(new_properties.at(i));
|
|
||||||
c -> update();
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -17,10 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
#ifndef DIAGRAM_COMMANDS_H
|
#ifndef DIAGRAM_COMMANDS_H
|
||||||
#define DIAGRAM_COMMANDS_H
|
#define DIAGRAM_COMMANDS_H
|
||||||
#include <QtWidgets>
|
|
||||||
#include "borderproperties.h"
|
#include "borderproperties.h"
|
||||||
#include "qetgraphicsitem/conductor.h"
|
#include "qetgraphicsitem/conductor.h"
|
||||||
#include "conductorproperties.h"
|
|
||||||
#include "diagramcontent.h"
|
#include "diagramcontent.h"
|
||||||
#include "titleblockproperties.h"
|
#include "titleblockproperties.h"
|
||||||
#include "qet.h"
|
#include "qet.h"
|
||||||
@ -416,70 +415,4 @@ class ChangeBorderCommand : public QUndoCommand {
|
|||||||
BorderProperties new_properties;
|
BorderProperties new_properties;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
This command changes the properties for a particular conductor.
|
|
||||||
*/
|
|
||||||
class ChangeConductorPropertiesCommand : public QUndoCommand {
|
|
||||||
// constructors, destructor
|
|
||||||
public:
|
|
||||||
ChangeConductorPropertiesCommand(Conductor *, QUndoCommand * = 0);
|
|
||||||
virtual ~ChangeConductorPropertiesCommand();
|
|
||||||
private:
|
|
||||||
ChangeConductorPropertiesCommand(const ChangeConductorPropertiesCommand &);
|
|
||||||
|
|
||||||
// methods
|
|
||||||
public:
|
|
||||||
virtual void undo();
|
|
||||||
virtual void redo();
|
|
||||||
virtual void setOldSettings(const ConductorProperties &);
|
|
||||||
virtual void setNewSettings(const ConductorProperties &);
|
|
||||||
|
|
||||||
// attributes
|
|
||||||
private:
|
|
||||||
/// modified conductor
|
|
||||||
Conductor *conductor;
|
|
||||||
/// properties before the change
|
|
||||||
ConductorProperties old_properties;
|
|
||||||
/// properties after the change
|
|
||||||
ConductorProperties new_properties;
|
|
||||||
/// track whether pre-change properties were set
|
|
||||||
bool old_settings_set;
|
|
||||||
/// track whether post-change properties were set
|
|
||||||
bool new_settings_set;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
This command changes the properties for several conductors.
|
|
||||||
*/
|
|
||||||
class ChangeSeveralConductorsPropertiesCommand : public QUndoCommand {
|
|
||||||
// constructors, destructor
|
|
||||||
public:
|
|
||||||
ChangeSeveralConductorsPropertiesCommand(QList<Conductor *>, QUndoCommand * = 0);
|
|
||||||
virtual ~ChangeSeveralConductorsPropertiesCommand();
|
|
||||||
private:
|
|
||||||
ChangeSeveralConductorsPropertiesCommand(const ChangeSeveralConductorsPropertiesCommand &);
|
|
||||||
|
|
||||||
// methods
|
|
||||||
public:
|
|
||||||
virtual void undo();
|
|
||||||
virtual void redo();
|
|
||||||
virtual void setOldSettings(const QList<ConductorProperties> &);
|
|
||||||
virtual void setNewSettings(const QList<ConductorProperties> &);
|
|
||||||
virtual void setNewSettings(const ConductorProperties &);
|
|
||||||
|
|
||||||
// attributes
|
|
||||||
private:
|
|
||||||
/// modified conductor
|
|
||||||
QList<Conductor *> conductors;
|
|
||||||
/// properties before the change
|
|
||||||
QList <ConductorProperties> old_properties;
|
|
||||||
/// properties after the change
|
|
||||||
QList <ConductorProperties> new_properties;
|
|
||||||
/// single properties for each conductor
|
|
||||||
ConductorProperties single_new_properties;
|
|
||||||
/// track whether pre-change properties were set
|
|
||||||
bool old_settings_set;
|
|
||||||
/// track whether post-change properties were set
|
|
||||||
bool new_settings_set;
|
|
||||||
};
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
#include "diagrampropertiesdialog.h"
|
#include "diagrampropertiesdialog.h"
|
||||||
#include "dveventinterface.h"
|
#include "dveventinterface.h"
|
||||||
#include "diagrameventaddelement.h"
|
#include "diagrameventaddelement.h"
|
||||||
|
#include "QPropertyUndoCommand/qpropertyundocommand.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur
|
Constructeur
|
||||||
@ -947,9 +948,9 @@ void DiagramView::editSelectedConductorColor() {
|
|||||||
Edit the color of the given conductor
|
Edit the color of the given conductor
|
||||||
@param edited_conductor Conductor we want to change the color
|
@param edited_conductor Conductor we want to change the color
|
||||||
*/
|
*/
|
||||||
void DiagramView::editConductorColor(Conductor *edited_conductor) {
|
void DiagramView::editConductorColor(Conductor *edited_conductor)
|
||||||
if (scene -> isReadOnly()) return;
|
{
|
||||||
if (!edited_conductor) return;
|
if (scene -> isReadOnly() || !edited_conductor) return;
|
||||||
|
|
||||||
// store the initial properties of the provided conductor
|
// store the initial properties of the provided conductor
|
||||||
ConductorProperties initial_properties = edited_conductor -> properties();
|
ConductorProperties initial_properties = edited_conductor -> properties();
|
||||||
@ -963,17 +964,20 @@ void DiagramView::editConductorColor(Conductor *edited_conductor) {
|
|||||||
color_dialog -> setCurrentColor(initial_properties.color);
|
color_dialog -> setCurrentColor(initial_properties.color);
|
||||||
|
|
||||||
// asks the user what color he wishes to apply
|
// asks the user what color he wishes to apply
|
||||||
if (color_dialog -> exec() == QDialog::Accepted) {
|
if (color_dialog -> exec() == QDialog::Accepted)
|
||||||
|
{
|
||||||
QColor new_color = color_dialog -> selectedColor();
|
QColor new_color = color_dialog -> selectedColor();
|
||||||
if (new_color != initial_properties.color) {
|
if (new_color != initial_properties.color)
|
||||||
|
{
|
||||||
// the user chose a different color
|
// the user chose a different color
|
||||||
ConductorProperties new_properties = initial_properties;
|
QVariant old_value, new_value;
|
||||||
new_properties.color = new_color;
|
old_value.setValue(initial_properties);
|
||||||
|
initial_properties.color = new_color;
|
||||||
|
new_value.setValue(initial_properties);
|
||||||
|
|
||||||
ChangeConductorPropertiesCommand *ccpc = new ChangeConductorPropertiesCommand(edited_conductor);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(edited_conductor, "properties", old_value, new_value);
|
||||||
ccpc -> setOldSettings(initial_properties);
|
undo->setText(tr("Modifier les propriétés d'un conducteur", "undo caption"));
|
||||||
ccpc -> setNewSettings(new_properties);
|
diagram() -> undoStack().push(undo);
|
||||||
diagram() -> undoStack().push(ccpc);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
#include "conductorautonumerotation.h"
|
#include "conductorautonumerotation.h"
|
||||||
#include "conductorpropertiesdialog.h"
|
#include "conductorpropertiesdialog.h"
|
||||||
|
#include "QPropertyUndoCommand/qpropertyundocommand.h"
|
||||||
|
|
||||||
#define PR(x) qDebug() << #x " = " << x;
|
#define PR(x) qDebug() << #x " = " << x;
|
||||||
|
|
||||||
bool Conductor::pen_and_brush_initialized = false;
|
bool Conductor::pen_and_brush_initialized = false;
|
||||||
@ -1371,6 +1373,7 @@ void Conductor::readProperties() {
|
|||||||
text_item -> setVisible(properties_.m_show_text);
|
text_item -> setVisible(properties_.m_show_text);
|
||||||
}
|
}
|
||||||
calculateTextItemPosition();
|
calculateTextItemPosition();
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1415,14 +1418,15 @@ void Conductor::displayedTextChanged() {
|
|||||||
|
|
||||||
if (qmbreturn == 0 || qmbreturn == QMessageBox::No)
|
if (qmbreturn == 0 || qmbreturn == QMessageBox::No)
|
||||||
{
|
{
|
||||||
// initialise l'objet UndoCommand correspondant
|
QVariant old_value, new_value;
|
||||||
|
old_value.setValue(properties_);
|
||||||
ConductorProperties new_properties(properties_);
|
ConductorProperties new_properties(properties_);
|
||||||
new_properties.text = text_item -> toPlainText();
|
new_properties.text = text_item -> toPlainText();
|
||||||
|
new_value.setValue(new_properties);
|
||||||
|
|
||||||
ChangeConductorPropertiesCommand *ccpc = new ChangeConductorPropertiesCommand(this);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(this, "properties", old_value, new_value);
|
||||||
ccpc -> setOldSettings(properties_);
|
undo->setText(tr("Modifier les propriétés d'un conducteur", "undo caption"));
|
||||||
ccpc -> setNewSettings(new_properties);
|
my_diagram -> undoStack().push(undo);
|
||||||
my_diagram -> undoStack().push(ccpc);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#define CONDUCTOR_H
|
#define CONDUCTOR_H
|
||||||
|
|
||||||
#include "conductorproperties.h"
|
#include "conductorproperties.h"
|
||||||
|
#include <QGraphicsPathItem>
|
||||||
|
|
||||||
class ConductorProfile;
|
class ConductorProfile;
|
||||||
class ConductorSegmentProfile;
|
class ConductorSegmentProfile;
|
||||||
@ -34,12 +35,13 @@ typedef QHash<Qt::Corner, ConductorProfile> ConductorProfilesGroup;
|
|||||||
This class represents a conductor, i.e. a wire between two element
|
This class represents a conductor, i.e. a wire between two element
|
||||||
terminals.
|
terminals.
|
||||||
*/
|
*/
|
||||||
class Conductor : public QObject, public QGraphicsPathItem {
|
class Conductor : public QObject, public QGraphicsPathItem
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY(QPointF pos READ pos WRITE setPos)
|
Q_PROPERTY(QPointF pos READ pos WRITE setPos)
|
||||||
Q_PROPERTY(int animPath READ fakePath WRITE updatePathAnimate)
|
Q_PROPERTY(int animPath READ fakePath WRITE updatePathAnimate)
|
||||||
|
Q_PROPERTY(ConductorProperties properties READ properties WRITE setProperties)
|
||||||
|
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
|
@ -38,6 +38,7 @@ class XmlElementsCollection;
|
|||||||
class MoveElementsHandler;
|
class MoveElementsHandler;
|
||||||
class MoveTitleBlockTemplatesHandler;
|
class MoveTitleBlockTemplatesHandler;
|
||||||
class NumerotationContext;
|
class NumerotationContext;
|
||||||
|
class QUndoStack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This class represents a QET project. Typically saved as a .qet file, it
|
This class represents a QET project. Typically saved as a .qet file, it
|
||||||
|
@ -18,11 +18,10 @@
|
|||||||
|
|
||||||
#include "conductorpropertiesdialog.h"
|
#include "conductorpropertiesdialog.h"
|
||||||
#include "ui_conductorpropertiesdialog.h"
|
#include "ui_conductorpropertiesdialog.h"
|
||||||
|
|
||||||
#include "conductor.h"
|
#include "conductor.h"
|
||||||
#include "conductorpropertieswidget.h"
|
#include "conductorpropertieswidget.h"
|
||||||
#include "diagramcommands.h"
|
|
||||||
#include "diagram.h"
|
#include "diagram.h"
|
||||||
|
#include "QPropertyUndoCommand/qpropertyundocommand.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ConductorPropertiesDialog::ConductorPropertiesDialog
|
* @brief ConductorPropertiesDialog::ConductorPropertiesDialog
|
||||||
@ -58,36 +57,31 @@ ConductorPropertiesDialog::~ConductorPropertiesDialog()
|
|||||||
* @param conductor, conductor to edit propertie
|
* @param conductor, conductor to edit propertie
|
||||||
* @param parent, parent widget
|
* @param parent, parent widget
|
||||||
*/
|
*/
|
||||||
void ConductorPropertiesDialog::PropertiesDialog(Conductor *conductor, QWidget *parent) {
|
void ConductorPropertiesDialog::PropertiesDialog(Conductor *conductor, QWidget *parent)
|
||||||
|
{
|
||||||
ConductorPropertiesDialog cpd (conductor, parent);
|
ConductorPropertiesDialog cpd (conductor, parent);
|
||||||
|
|
||||||
if (cpd.exec() == QDialog::Accepted && cpd.properties() != conductor->properties()) {
|
if (cpd.exec() == QDialog::Accepted && cpd.properties() != conductor->properties())
|
||||||
|
{
|
||||||
|
QVariant old_value, new_value;
|
||||||
|
old_value.setValue(conductor->properties());
|
||||||
|
new_value.setValue(cpd.properties());
|
||||||
|
|
||||||
if (cpd.applyAll()) {
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(conductor, "properties", old_value, new_value);
|
||||||
QList <Conductor *> conductorslist = conductor -> relatedPotentialConductors().toList();
|
undo->setText(tr("Modifier les propriétés d'un conducteur", "undo caption"));
|
||||||
conductorslist << conductor;
|
|
||||||
QList <ConductorProperties> old_properties_list;
|
|
||||||
|
|
||||||
foreach (Conductor *c, conductorslist) {
|
//Make undo for all related potiential conductors
|
||||||
if (c == conductor) {
|
if (cpd.applyAll() && !conductor->relatedPotentialConductors().isEmpty())
|
||||||
old_properties_list << conductor -> properties();
|
{
|
||||||
} else {
|
undo->setText(tr("Modifier les propriétés de plusieurs conducteurs", "undo caption"));
|
||||||
old_properties_list << c -> properties();
|
foreach (Conductor *cond, conductor->relatedPotentialConductors())
|
||||||
c -> setProperties( cpd.properties() );
|
{
|
||||||
|
old_value.setValue(cond->properties());
|
||||||
|
new QPropertyUndoCommand (cond, "properties", old_value, new_value, undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//initialize the corresponding UndoCommand object
|
|
||||||
ChangeSeveralConductorsPropertiesCommand *cscpc = new ChangeSeveralConductorsPropertiesCommand(conductorslist);
|
conductor->diagram()->undoStack().push(undo);
|
||||||
cscpc -> setOldSettings(old_properties_list);
|
|
||||||
cscpc -> setNewSettings(cpd.properties());
|
|
||||||
conductor -> diagram() -> undoStack().push(cscpc);
|
|
||||||
} else {
|
|
||||||
// initialize the corresponding UndoCommand object
|
|
||||||
ChangeConductorPropertiesCommand *ccpc = new ChangeConductorPropertiesCommand(conductor);
|
|
||||||
ccpc -> setOldSettings(conductor -> properties());
|
|
||||||
ccpc -> setNewSettings(cpd.properties());
|
|
||||||
conductor -> diagram() -> undoStack().push(ccpc);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "potentialtextsdialog.h"
|
#include "potentialtextsdialog.h"
|
||||||
#include "ui_potentialtextsdialog.h"
|
#include "ui_potentialtextsdialog.h"
|
||||||
#include <QSignalMapper>
|
#include <QSignalMapper>
|
||||||
|
#include <QRadioButton>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief PotentialTextsDialog::PotentialTextsDialog
|
* @brief PotentialTextsDialog::PotentialTextsDialog
|
||||||
|
Loading…
x
Reference in New Issue
Block a user