mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-15 01:54:14 +02:00
9078e4e321
The scripting API (scripts and the assistant's live mode) reached a folio through diagrams(), which builds every folio, for every call. A folio's own data -- count, title, uuid, title block, border, wire defaults -- now comes from folios(), built or not; a call reading or changing a folio's items builds that folio, as showing it does (built()); selecting a symbol by uuid builds the folio the project database places it on. Search and replace and the continuity check still build every folio. DiagramContent worked out one wire of each potential when made, which follows potentials through folio reports and built the folios at the other end, for every caller; it is now worked out when first asked (Search and replace asks; a merge asks both sides, as before). tst_lazyfolios: on a .qetz, a script reads every folio's title, uuid and border building none (fails with diagrams()), and the symbols and wires of the folio with the most links to other folios as when built, building that folio only (27 before potentials were lazy). ctest 96/96 but modal_quit_regression in both modes: a race in that test (gdb interrupts the main thread inside malloc while the folio view repaints during the dialog, master too), 2 of 23 runs here, 0 of 10 on master, passing alone. 342 corpus projects save the same in all four arms, and export the same wiring list and wire numbers lazily. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
116 lines
3.7 KiB
C++
116 lines
3.7 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 DIAGRAM_CONTENT_H
|
|
#define DIAGRAM_CONTENT_H
|
|
|
|
#include <QSet>
|
|
#include <optional>
|
|
#include <QVector>
|
|
|
|
#include "../qetgraphicsitem/terminalelement.h"
|
|
|
|
class QGraphicsItem;
|
|
class Conductor;
|
|
class Element;
|
|
class IndependentTextItem;
|
|
class DiagramImageItem;
|
|
class QetShapeItem;
|
|
class DynamicElementTextItem;
|
|
class ElementTextItemGroup;
|
|
class Diagram;
|
|
class DiagramTextItem;
|
|
class QetGraphicsTableItem;
|
|
class TerminalStripItem;
|
|
|
|
/**
|
|
This class provides a container that makes the transmission of diagram content
|
|
to other functions/methods easier. The different kind of items are made
|
|
available through a handful of filter-aware methods. Considering selected
|
|
elements are to be moved, the filter notably distinguishes conductors to be
|
|
moved from those to be updated.
|
|
Please note this container does not systematically contains a whole
|
|
diagram: it may describe only a part of it, e.g. selected items.
|
|
*/
|
|
class DiagramContent
|
|
{
|
|
public:
|
|
DiagramContent();
|
|
DiagramContent(Diagram *diagram, bool selected = true);
|
|
~DiagramContent();
|
|
|
|
/// Used to filter the different items carried by this container.
|
|
enum Filter {
|
|
Elements = 1,
|
|
TextFields = 2,
|
|
ElementTextFields = 4,
|
|
Images = 8,
|
|
ConductorsToMove = 16,
|
|
ConductorsToUpdate = 32,
|
|
OtherConductors = 64,
|
|
AnyConductor = 112,
|
|
Shapes = 128,
|
|
TextGroup = 256,
|
|
Tables = 512,
|
|
TerminalStrip = 1024,
|
|
All = 2047,
|
|
SelectedOnly = 2048
|
|
};
|
|
|
|
QList<Element *> m_elements;
|
|
QSet<IndependentTextItem *> m_text_fields;
|
|
QSet<DiagramImageItem *> m_images;
|
|
QSet<QetShapeItem *> m_shapes;
|
|
QList<Conductor *> m_conductors_to_update;
|
|
QList<Conductor *> m_conductors_to_move;
|
|
QList<Conductor *> m_other_conductors;
|
|
QSet<DynamicElementTextItem *> m_element_texts;
|
|
QSet<ElementTextItemGroup *> m_texts_groups;
|
|
QList<QGraphicsItem *> m_selected_items;
|
|
QVector<QetGraphicsTableItem *> m_tables;
|
|
QVector<TerminalStripItem *> m_terminal_strip;
|
|
QVector<QPointer<TerminalElement>> m_terminal_elements;
|
|
|
|
|
|
QList<DiagramTextItem *> selectedTexts() const;
|
|
QList<ElementTextItemGroup *> selectedTextsGroup() const;
|
|
QList<Conductor *> conductors(int = AnyConductor) const;
|
|
QList<Conductor *> potentialConductors() const;
|
|
bool hasDeletableItems() const;
|
|
bool hasCopiableItems() const;
|
|
QList<QGraphicsItem *> items(int = All) const;
|
|
QString sentence(int = All) const;
|
|
int count(int = All) const;
|
|
void clear();
|
|
int removeNonMovableItems();
|
|
|
|
DiagramContent& operator+=(const DiagramContent& other);
|
|
bool potentialIsManaged(QList<Conductor *>conductors);
|
|
bool hasTextEditing();
|
|
|
|
private:
|
|
int removePinnedGroups();
|
|
/// The wires potentialConductors() is made from, in order
|
|
QList<Conductor *> m_potential_candidates;
|
|
/// One wire of each potential, worked out when first asked:
|
|
/// following a potential goes through folio reports to other
|
|
/// folios, building those not built yet (QET_LAZY_FOLIOS)
|
|
mutable std::optional<QList<Conductor *>> m_potential_conductors;
|
|
};
|
|
QDebug &operator<<(QDebug, DiagramContent &);
|
|
#endif
|