mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-13 20:23:04 +02:00
Dans l'editeur d'elements, les changements de noms sont desormais annulables
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@120 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
parent
b1ea7d6249
commit
a2a65b78a8
@ -263,3 +263,37 @@ void ChangeHotspotCommand::applyOffset(const QPointF &o) {
|
||||
qgi -> translate(o.x(), o.y());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Constructeur
|
||||
@param element_scene Element edite
|
||||
@param before Listes des noms avant changement
|
||||
@param after Listes des noms apres changement
|
||||
@param parent QUndoCommand parent
|
||||
*/
|
||||
ChangeNamesCommand::ChangeNamesCommand(
|
||||
ElementScene *element_scene,
|
||||
const NamesList &before,
|
||||
const NamesList &after,
|
||||
QUndoCommand *parent
|
||||
) :
|
||||
QUndoCommand(QObject::tr("modification noms"), parent),
|
||||
names_before(before),
|
||||
names_after(after),
|
||||
element(element_scene)
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructeur
|
||||
ChangeNamesCommand::~ChangeNamesCommand() {
|
||||
}
|
||||
|
||||
/// Annule le changement
|
||||
void ChangeNamesCommand::undo() {
|
||||
element -> setNames(names_before);
|
||||
}
|
||||
|
||||
/// Refait le changement
|
||||
void ChangeNamesCommand::redo() {
|
||||
element -> setNames(names_after);
|
||||
}
|
||||
|
@ -168,4 +168,29 @@ class ChangeHotspotCommand : public QUndoCommand {
|
||||
/// decalage a appliquer aux elements
|
||||
QPoint offset;
|
||||
};
|
||||
|
||||
/**
|
||||
Cette classe represente l'action de changer les noms d'un element
|
||||
*/
|
||||
class ChangeNamesCommand : public QUndoCommand {
|
||||
// constructeurs, destructeur
|
||||
public:
|
||||
ChangeNamesCommand(ElementScene *, const NamesList &, const NamesList &, QUndoCommand * = 0);
|
||||
virtual ~ChangeNamesCommand();
|
||||
private:
|
||||
ChangeNamesCommand(const ChangeNamesCommand &);
|
||||
|
||||
// methodes
|
||||
virtual void undo();
|
||||
virtual void redo();
|
||||
|
||||
// attributs
|
||||
private:
|
||||
/// Liste des noms avant changement
|
||||
NamesList names_before;
|
||||
/// Liste des noms apres changement
|
||||
NamesList names_after;
|
||||
/// scene sur laquelle se produisent les actions
|
||||
ElementScene *element;
|
||||
};
|
||||
#endif
|
||||
|
@ -449,17 +449,14 @@ void ElementScene::slot_editSizeHotSpot() {
|
||||
connect(dialog_buttons, SIGNAL(rejected()), &dialog_sh, SLOT(reject()));
|
||||
|
||||
// lance le dialogue
|
||||
if (dialog_sh.exec() == QDialog::Accepted) {
|
||||
undo_stack.push(
|
||||
new ChangeHotspotCommand(
|
||||
this,
|
||||
QSize(width(), height()),
|
||||
hotspot_editor -> elementSize(),
|
||||
_hotspot,
|
||||
hotspot_editor -> hotspot(),
|
||||
hotspot_editor -> mustTranslateParts() ? hotspot_editor -> offsetParts() : QPoint()
|
||||
)
|
||||
);
|
||||
if (dialog_sh.exec() != QDialog::Accepted) return;
|
||||
QSize new_size(hotspot_editor -> elementSize());
|
||||
QSize old_size(width(), height());
|
||||
QPoint new_hotspot(hotspot_editor -> hotspot());
|
||||
QPoint old_hotspot(_hotspot);
|
||||
|
||||
if (new_size != old_size || new_hotspot != old_hotspot) {
|
||||
undo_stack.push(new ChangeHotspotCommand(this, old_size, new_size, old_hotspot, new_hotspot, hotspot_editor -> offsetParts()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -521,6 +518,9 @@ void ElementScene::slot_editNames() {
|
||||
connect(dialog_buttons, SIGNAL(rejected()), &dialog, SLOT(reject()));
|
||||
|
||||
// lance le dialogue
|
||||
if (dialog.exec() == QDialog::Accepted) _names = names_widget -> names();
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
NamesList new_names(names_widget -> names());
|
||||
if (new_names != _names) undoStack().push(new ChangeNamesCommand(this, _names, new_names));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -127,6 +127,22 @@ QDomElement NamesList::toXml(QDomDocument &xml_document) const {
|
||||
return(names_elmt);
|
||||
}
|
||||
|
||||
/**
|
||||
@param nl une autre liste de noms
|
||||
@return true si les listes de noms sont differentes, false sinon
|
||||
*/
|
||||
bool NamesList::operator!=(const NamesList &nl) const {
|
||||
return(hash_names != nl.hash_names);
|
||||
}
|
||||
|
||||
/**
|
||||
@param nl une autre liste de noms
|
||||
@return true si les listes de noms sont identiques, false sinon
|
||||
*/
|
||||
bool NamesList::operator==(const NamesList &nl) const {
|
||||
return(hash_names == nl.hash_names);
|
||||
}
|
||||
|
||||
/**
|
||||
Retourne le nom approprie en fonction de la langue du systeme
|
||||
Par ordre de preference, on prendra :
|
||||
|
@ -23,6 +23,8 @@ class NamesList {
|
||||
int count() const;
|
||||
QString &operator[](const QString &);
|
||||
const QString operator[](const QString &) const;
|
||||
bool operator!=(const NamesList &) const;
|
||||
bool operator==(const NamesList &) const;
|
||||
const QString &name(const QString & = QString()) const;
|
||||
|
||||
// methodes relatives a XML
|
||||
|
Loading…
x
Reference in New Issue
Block a user