mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Text item : reduce a lot of code for several text item
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3379 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -329,7 +329,13 @@ void MoveElementsCommand::move(const QPointF &actual_movement) {
|
||||
typedef DiagramContent dc;
|
||||
|
||||
//Move every movable item, except conductor
|
||||
foreach (QGraphicsItem *qgi, content_to_move.items(dc::Elements | dc::TextFields | dc::Images | dc::Shapes)) {
|
||||
foreach (QGraphicsItem *qgi, content_to_move.items(dc::Elements | dc::TextFields | dc::ElementTextFields | dc::Images | dc::Shapes)) {
|
||||
//If curent item have parent, and parent item is in content_to_move
|
||||
//we don't apply movement to this item, because this item will be moved by is parent.
|
||||
if (qgi->parentItem()) {
|
||||
if (content_to_move.items().contains(qgi->parentItem()))
|
||||
continue;
|
||||
}
|
||||
if(qgi->toGraphicsObject()) {
|
||||
setupAnimation(qgi->toGraphicsObject(), "pos", qgi->pos(), qgi->pos() + actual_movement);
|
||||
}
|
||||
@@ -382,66 +388,6 @@ void MoveElementsCommand::setupAnimation(QObject *target, const QByteArray &prop
|
||||
m_anim_group->addAnimation(animation);
|
||||
}
|
||||
|
||||
/**
|
||||
Constructeur
|
||||
@param diagram Schema sur lequel on deplace des champs de texte
|
||||
@param texts Liste des textes deplaces
|
||||
@param m translation subie par les elements
|
||||
@param parent QUndoCommand parent
|
||||
*/
|
||||
MoveElementsTextsCommand::MoveElementsTextsCommand(
|
||||
Diagram *diagram,
|
||||
const QSet<ElementTextItem *> &texts,
|
||||
const QPointF &m,
|
||||
QUndoCommand *parent
|
||||
) :
|
||||
QUndoCommand(parent),
|
||||
diagram(diagram),
|
||||
texts_to_move(texts),
|
||||
movement(m),
|
||||
first_redo(true)
|
||||
{
|
||||
QString moved_content_sentence = QET::ElementsAndConductorsSentence(0, 0, texts_to_move.count());
|
||||
|
||||
setText(
|
||||
QString(
|
||||
QObject::tr(
|
||||
"d\351placer %1",
|
||||
"undo caption - %1 is a sentence listing the moved content"
|
||||
).arg(moved_content_sentence)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/// Destructeur
|
||||
MoveElementsTextsCommand::~MoveElementsTextsCommand() {
|
||||
}
|
||||
|
||||
/// annule le deplacement
|
||||
void MoveElementsTextsCommand::undo() {
|
||||
diagram -> showMe();
|
||||
move(-movement);
|
||||
}
|
||||
|
||||
/// refait le deplacement
|
||||
void MoveElementsTextsCommand::redo() {
|
||||
diagram -> showMe();
|
||||
if (first_redo) first_redo = false;
|
||||
else move(movement);
|
||||
}
|
||||
|
||||
/**
|
||||
deplace les elements et conducteurs
|
||||
@param actual_movement translation a effectuer sur les elements et conducteurs
|
||||
*/
|
||||
void MoveElementsTextsCommand::move(const QPointF &actual_movement) {
|
||||
// deplace les textes
|
||||
foreach(ElementTextItem *text, texts_to_move) {
|
||||
QPointF applied_movement = text -> mapMovementToParent(text -> mapMovementFromScene(actual_movement));
|
||||
text -> setPos(text -> pos() + applied_movement);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Constructeur
|
||||
@param diagram Schema sur lequel on deplace des champs de texte
|
||||
|
||||
Reference in New Issue
Block a user