mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-09-29 22:24:13 +02:00
a8f940505d
Discussion #1070 proposed that rotate, like move, copy and delete, works on the whole group once one of its items is clicked. Rotate (Space) turned each member on its own spot instead, so rotating a group pulled it apart: two grouped texts side by side ended up each turned in place, no longer side by side. When the selection is exactly one whole group -- wires aside, which follow their symbols -- Rotate now turns it as one piece around its centre, as "Pivoter le groupe" (Shift+Space) already does (ItemGroups::soleWholeGroup()). Any other selection, including a single member picked out of its group, rotates as before. In the GUI, on two grouped texts selected by one click: Space on master leaves both where they were, turned; here it gives exactly what Shift+Space gives on both (both texts swung around the group's centre). tst_itemgroups: 4 new checks; without the whole-group condition, a picked member counts as a group and fails. ctest 24/24. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
63 lines
2.1 KiB
C++
63 lines
2.1 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 ITEMGROUPS_H
|
|
#define ITEMGROUPS_H
|
|
|
|
#include <QList>
|
|
#include <QUuid>
|
|
|
|
class QDomElement;
|
|
class QGraphicsItem;
|
|
class QGraphicsScene;
|
|
|
|
/**
|
|
Groups of items on a folio (discussion #1070): symbols, free texts,
|
|
shapes and pictures that select, move, copy and delete together.
|
|
|
|
A group is not an object in the scene. Each member keeps its place and
|
|
carries the group's uuid, and selecting one member selects them all;
|
|
moving, copying and deleting then need nothing new, because they act on
|
|
the selection. Re-parenting the members under a QGraphicsItemGroup would
|
|
make every position group-relative, which every piece of code reading a
|
|
symbol's position would have to learn about.
|
|
|
|
This part knows nothing of Diagram, so it can be tested on a plain scene.
|
|
*/
|
|
namespace ItemGroups
|
|
{
|
|
/// QGraphicsItem::data() key holding an item's group uuid.
|
|
inline constexpr int data_key = 0x475250; // "GRP"
|
|
|
|
/// XML attribute holding it, on <element>, <input>, <shape> and <image>.
|
|
inline constexpr char xml_attribute[] = "group";
|
|
|
|
QUuid groupOf(const QGraphicsItem *item);
|
|
void setGroup(QGraphicsItem *item, const QUuid &group);
|
|
|
|
void write(QDomElement &xml, const QGraphicsItem *item);
|
|
QUuid read(const QDomElement &xml);
|
|
|
|
bool completeSelection(QGraphicsScene *scene,
|
|
const QList<QGraphicsItem *> &previous,
|
|
bool toggling);
|
|
|
|
QUuid soleWholeGroup(const QList<QGraphicsItem *> &selected);
|
|
}
|
|
|
|
#endif // ITEMGROUPS_H
|