mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
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:
@@ -125,40 +125,44 @@ void ElementsMover::endMovement()
|
|||||||
// A movement must be inited
|
// A movement must be inited
|
||||||
if (!movement_running_) return;
|
if (!movement_running_) return;
|
||||||
|
|
||||||
// No need of an undo command if the movement is NULL
|
QUndoCommand *undo_object = nullptr;
|
||||||
if (!current_movement_.isNull()) {
|
|
||||||
// Create an undo object for this new movement
|
|
||||||
MoveElementsCommand *undo_object = new MoveElementsCommand(
|
|
||||||
diagram_,
|
|
||||||
moved_content_,
|
|
||||||
current_movement_
|
|
||||||
);
|
|
||||||
|
|
||||||
//There is only one element moved, and project authorize auto conductor,
|
//Create undo move if there is a movement
|
||||||
//we try auto connection of conductor;
|
if (!current_movement_.isNull())
|
||||||
typedef DiagramContent dc;
|
undo_object = new MoveElementsCommand(diagram_, moved_content_, current_movement_);
|
||||||
if (moved_content_.items(dc::TextFields | dc::Images | dc::Shapes).size() == 0 &&
|
|
||||||
moved_content_.items(dc::Elements).size() == 1 &&
|
//There is only one element moved, and project authorize auto conductor,
|
||||||
diagram_ -> project() -> autoConductor())
|
//we try auto connection of conductor;
|
||||||
|
typedef DiagramContent dc;
|
||||||
|
if (moved_content_.items(dc::TextFields | dc::Images | dc::Shapes).size() == 0 &&
|
||||||
|
moved_content_.items(dc::Elements).size() == 1 &&
|
||||||
|
diagram_ -> project() -> autoConductor())
|
||||||
|
{
|
||||||
|
Element *elmt = moved_content_.elements.toList().first();
|
||||||
|
|
||||||
|
while (!elmt -> AlignedFreeTerminals().isEmpty())
|
||||||
{
|
{
|
||||||
Element *elmt = moved_content_.elements.toList().first();
|
QPair <Terminal *, Terminal *> pair = elmt -> AlignedFreeTerminals().takeFirst();
|
||||||
|
|
||||||
while (!elmt -> AlignedFreeTerminals().isEmpty())
|
Conductor *conductor = new Conductor(pair.first, pair.second);
|
||||||
{
|
conductor -> setProperties(diagram_ -> defaultConductorProperties);
|
||||||
QPair <Terminal *, Terminal *> pair = elmt->AlignedFreeTerminals().takeFirst();
|
|
||||||
|
|
||||||
Conductor *conductor = new Conductor(pair.first, pair.second);
|
//Create an undo object for each new auto conductor, with undo_object for parent if exist
|
||||||
conductor -> setProperties(diagram_ -> defaultConductorProperties);
|
//Else the first undo for this auto conductor become the undo_object
|
||||||
//Create an undo object for each new auto conductor, with undo_object for parent;
|
if (undo_object)
|
||||||
new AddItemCommand<Conductor *>(conductor, diagram_, QPointF(), undo_object);
|
new AddItemCommand<Conductor *>(conductor, diagram_, QPointF(), undo_object);
|
||||||
//Autonum the new conductor, the undo command associated for this, have for parent undo_object
|
else
|
||||||
ConductorAutoNumerotation can (conductor, diagram_, undo_object);
|
undo_object = new AddItemCommand<Conductor *>(conductor, diagram_, QPointF());
|
||||||
can.numerate();
|
|
||||||
};
|
//Autonum the new conductor, the undo command associated for this, have for parent undo_object
|
||||||
}
|
ConductorAutoNumerotation can (conductor, diagram_, undo_object);
|
||||||
|
can.numerate();
|
||||||
diagram_ -> undoStack().push(undo_object);
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Add undo_object if exist
|
||||||
|
if (undo_object)
|
||||||
|
diagram_ -> undoStack().push(undo_object);
|
||||||
|
|
||||||
// There is no movement in progress now
|
// There is no movement in progress now
|
||||||
movement_running_ = false;
|
movement_running_ = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user