Add auto conductor even if movement is null

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3627 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2015-01-23 14:35:49 +00:00
parent c1d20ca091
commit 6256468c8e

View File

@@ -125,14 +125,11 @@ void ElementsMover::endMovement()
// A movement must be inited
if (!movement_running_) return;
// No need of an undo command if the movement is NULL
if (!current_movement_.isNull()) {
// Create an undo object for this new movement
MoveElementsCommand *undo_object = new MoveElementsCommand(
diagram_,
moved_content_,
current_movement_
);
QUndoCommand *undo_object = nullptr;
//Create undo move if there is a movement
if (!current_movement_.isNull())
undo_object = new MoveElementsCommand(diagram_, moved_content_, current_movement_);
//There is only one element moved, and project authorize auto conductor,
//we try auto connection of conductor;
@@ -149,16 +146,23 @@ void ElementsMover::endMovement()
Conductor *conductor = new Conductor(pair.first, pair.second);
conductor -> setProperties(diagram_ -> defaultConductorProperties);
//Create an undo object for each new auto conductor, with undo_object for parent;
//Create an undo object for each new auto conductor, with undo_object for parent if exist
//Else the first undo for this auto conductor become the undo_object
if (undo_object)
new AddItemCommand<Conductor *>(conductor, diagram_, QPointF(), undo_object);
else
undo_object = new AddItemCommand<Conductor *>(conductor, diagram_, QPointF());
//Autonum the new conductor, the undo command associated for this, have for parent undo_object
ConductorAutoNumerotation can (conductor, diagram_, undo_object);
can.numerate();
};
}
//Add undo_object if exist
if (undo_object)
diagram_ -> undoStack().push(undo_object);
}
// There is no movement in progress now
movement_running_ = false;