fix minor bug with the undo/redo of conductor text item

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2302 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2013-06-19 21:40:28 +00:00
parent c4bcc6fed7
commit 9f07f5ad1d
2 changed files with 15 additions and 21 deletions

View File

@@ -601,18 +601,13 @@ void RotateElementsCommand::undo() {
rotateElement(e, elements_to_rotate[e]); rotateElement(e, elements_to_rotate[e]);
} }
foreach(DiagramTextItem *dti, texts_to_rotate) { foreach(DiagramTextItem *dti, texts_to_rotate) {
//ConductorTextItem have got a default rotation propertie //ConductorTextItem have a default rotation angle, we apply a specific treatment
//so we apply specific undo method for him
if (ConductorTextItem *cti = qgraphicsitem_cast<ConductorTextItem *>(dti)) { if (ConductorTextItem *cti = qgraphicsitem_cast<ConductorTextItem *>(dti)) {
cti -> forceRotateByUser(previous_rotate_by_user_); cti -> forceRotateByUser(previous_rotate_by_user_[cti]);
//previous_rotate_by_user is false mean the rotation is propertie rotation (cti -> wasRotateByUser()) ? cti -> rotateBy(-appliedRotationAngle()) :
if (previous_rotate_by_user_ == false) {cti -> parentConductor() ->adjustTextItemPosition();} cti -> parentConductor() -> adjustTextItemPosition();
else {cti -> rotateBy(-applied_rotation_angle_);}
}
//this isn't a ConductorTextItem
else {
dti -> rotateBy(-applied_rotation_angle_);
} }
else {dti -> rotateBy(-applied_rotation_angle_);}
} }
} }
@@ -622,8 +617,9 @@ void RotateElementsCommand::redo() {
rotateElement(e, e -> orientation().next()); rotateElement(e, e -> orientation().next());
} }
foreach(DiagramTextItem *dti, texts_to_rotate) { foreach(DiagramTextItem *dti, texts_to_rotate) {
//we grab the previous rotation by user of each ConductorTextItem
if (ConductorTextItem *cti = qgraphicsitem_cast<ConductorTextItem *>(dti)) { if (ConductorTextItem *cti = qgraphicsitem_cast<ConductorTextItem *>(dti)) {
previous_rotate_by_user_ = cti -> wasRotateByUser(); previous_rotate_by_user_.insert(cti, cti -> wasRotateByUser());
cti -> forceRotateByUser(true); cti -> forceRotateByUser(true);
} }
dti -> rotateBy(applied_rotation_angle_); dti -> rotateBy(applied_rotation_angle_);
@@ -685,9 +681,6 @@ RotateTextsCommand::RotateTextsCommand(const QHash<DiagramTextItem *, double> &p
texts_to_rotate(previous_state), texts_to_rotate(previous_state),
applied_rotation_angle_(applied_rotation) applied_rotation_angle_(applied_rotation)
{ {
foreach(DiagramTextItem *text, texts_to_rotate.keys()) {
if (ConductorTextItem *cti = qgraphicsitem_cast<ConductorTextItem *>(text)) previous_rotate_by_user_ = cti -> wasRotateByUser();
}
defineCommandName(); defineCommandName();
} }
@@ -702,7 +695,6 @@ RotateTextsCommand::RotateTextsCommand(const QList<DiagramTextItem *> &texts, do
applied_rotation_angle_(applied_rotation) applied_rotation_angle_(applied_rotation)
{ {
foreach(DiagramTextItem *text, texts) { foreach(DiagramTextItem *text, texts) {
if (ConductorTextItem *cti = qgraphicsitem_cast<ConductorTextItem *>(text)) previous_rotate_by_user_ = cti -> wasMovedByUser();
texts_to_rotate.insert(text, text -> rotationAngle()); texts_to_rotate.insert(text, text -> rotationAngle());
} }
defineCommandName(); defineCommandName();
@@ -719,9 +711,8 @@ RotateTextsCommand::~RotateTextsCommand() {
*/ */
void RotateTextsCommand::undo() { void RotateTextsCommand::undo() {
foreach(DiagramTextItem *text, texts_to_rotate.keys()) { foreach(DiagramTextItem *text, texts_to_rotate.keys()) {
if (ConductorTextItem *cti = qgraphicsitem_cast<ConductorTextItem *>(text)) { if (ConductorTextItem *cti = qgraphicsitem_cast<ConductorTextItem *>(text))
cti -> forceRotateByUser(previous_rotate_by_user_); cti -> forceRotateByUser(previous_rotate_by_user_[cti]);
}
text -> setRotationAngle(texts_to_rotate[text]); text -> setRotationAngle(texts_to_rotate[text]);
} }
} }
@@ -732,7 +723,8 @@ void RotateTextsCommand::undo() {
void RotateTextsCommand::redo() { void RotateTextsCommand::redo() {
foreach(DiagramTextItem *text, texts_to_rotate.keys()) { foreach(DiagramTextItem *text, texts_to_rotate.keys()) {
if (ConductorTextItem *cti = qgraphicsitem_cast<ConductorTextItem *>(text)) { if (ConductorTextItem *cti = qgraphicsitem_cast<ConductorTextItem *>(text)) {
previous_rotate_by_user_ = cti -> wasRotateByUser(); //we grab the previous rotation by user of each ConductorTextItem
previous_rotate_by_user_.insert(cti, cti -> wasRotateByUser());
cti -> forceRotateByUser(true); cti -> forceRotateByUser(true);
} }
text -> setRotationAngle(applied_rotation_angle_); text -> setRotationAngle(applied_rotation_angle_);

View File

@@ -323,7 +323,8 @@ class RotateElementsCommand : public QUndoCommand {
QList<DiagramTextItem *> texts_to_rotate; QList<DiagramTextItem *> texts_to_rotate;
/// angle of rotation to be applied to text items /// angle of rotation to be applied to text items
qreal applied_rotation_angle_; qreal applied_rotation_angle_;
bool previous_rotate_by_user_; /// previous state of each conductor text item
QHash<ConductorTextItem *, bool> previous_rotate_by_user_;
}; };
/** /**
@@ -353,7 +354,8 @@ class RotateTextsCommand : public QUndoCommand {
QHash<DiagramTextItem *, double> texts_to_rotate; QHash<DiagramTextItem *, double> texts_to_rotate;
/// angle of rotation of all text items after the command /// angle of rotation of all text items after the command
double applied_rotation_angle_; double applied_rotation_angle_;
bool previous_rotate_by_user_; /// previous state of each conductor text item
QHash<ConductorTextItem *, bool> previous_rotate_by_user_;
}; };
/** /**