mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 05:00:33 +01: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:
@@ -26,7 +26,6 @@
|
||||
#include "diagram.h"
|
||||
#include "qetgraphicsitem/diagramtextitem.h"
|
||||
#include "qetgraphicsitem/diagramimageitem.h"
|
||||
#include "conductorautonumerotation.h"
|
||||
#include <QPropertyAnimation>
|
||||
|
||||
QString itemText(const QetGraphicsItem *item) {
|
||||
@@ -810,140 +809,3 @@ void ChangeBorderCommand::redo() {
|
||||
diagram -> showMe();
|
||||
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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user