mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-09-29 22:24:13 +02:00
2dbaa69186
Grouping two symbols and then locking one of them (Lock position in its properties) left the group in a broken state: dragging the unlocked symbol pulled it away while the locked one stayed, and dragging the locked one did nothing. The move simply dropped locked items, so the rest of the group went without them. A group with a locked member now does not move at all, whichever member is dragged, and the status bar says why. This is the rule the item-groups proposal (discussion #1070) set out for this case. The same rule applies to the arrow keys and to the Align commands, which share DiagramContent::removeNonMovableItems(). Also fixed on the way, for a plain selection with a locked symbol: a wire between the locked symbol and one being dragged kept its user-placed text moving with the dragged end. Such a wire is now redrawn only, as a wire to an unselected symbol already is. Checked in the GUI on two symbols joined by a wire (grafcet example), master against this branch, positions read from the saved file: - drag the unlocked member: master moves it 190 px, this branch moves nothing and shows the message - arrow keys on the selected group (3 runs each): master moves the unlocked member, this branch nothing - the same two symbols ungrouped: both move the unlocked one, as before - user-placed wire text: master shifts it 190 px, this branch keeps it ctest: 34/34. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
69 lines
2.0 KiB
C++
69 lines
2.0 KiB
C++
/*
|
|
Copyright 2006-2026 The QElectroTech Team
|
|
This file is part of QElectroTech.
|
|
|
|
QElectroTech is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
QElectroTech is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
#ifndef ELEMENTS_MOVER_H
|
|
#define ELEMENTS_MOVER_H
|
|
|
|
#include <QPointF>
|
|
#include <QPointer>
|
|
#include "diagramcontent.h"
|
|
|
|
class ConductorTextItem;
|
|
class Diagram;
|
|
class QStatusBar;
|
|
|
|
/**
|
|
This class manages the interactive movement of different items (elements,
|
|
conductors, text items etc...) on a particular diagram.
|
|
|
|
A movement work in 3 steps:
|
|
1: beginMovement -> init a new movement
|
|
2: continueMovement -> continue the current movement
|
|
3: endMovement -> finish the current movement
|
|
|
|
A movement in progress must finish before starting a new movement. We can
|
|
know if element mover is ready for a new movement by calling isReady().
|
|
*/
|
|
class ElementsMover {
|
|
// constructors, destructor
|
|
public:
|
|
ElementsMover();
|
|
virtual ~ElementsMover();
|
|
private:
|
|
ElementsMover(const ElementsMover &);
|
|
|
|
// methods
|
|
public:
|
|
bool isReady() const;
|
|
int beginMovement(Diagram *, QGraphicsItem * = nullptr);
|
|
void continueMovement(const QPointF &);
|
|
void endMovement();
|
|
bool holds(const QGraphicsItem *item) const;
|
|
|
|
// attributes
|
|
private:
|
|
bool m_movement_running{false};
|
|
QPointF m_current_movement;
|
|
Diagram *m_diagram{nullptr};
|
|
QGraphicsItem *m_movement_driver{nullptr};
|
|
bool m_driver_held{false};
|
|
DiagramContent m_moved_content;
|
|
QPointer<QStatusBar> m_status_bar;
|
|
|
|
};
|
|
#endif
|