Files
qelectrotech-source-mirror/sources/cable/cablepropertiesdialog.h
T
Kellermorph bf9b34398d Add cable management: drawing, cores, numbering, cross-references and cable list
Cables are drawn line objects (toolbar button next to the auto
break/reconnect button, click-move-click, right click cancels), not
components. The type comes from a CSV catalog following the material
list pattern (designation, cores, core colours, editable through the
entry dialog with "Nouvelle entrée" / "Modifier l'entrée").

Each core is bound to the wire its colour label stands on, and the
cable reference is generated per core and written into the Conductor
entry via Conductor::setCableReference(label, cable uuid, slot). The
conductor entry is where it has to live because the terminal strip
plan (Klemmenplan) consumes it in the next step.

Numbering: "Cables" rule under Programmeinstellungen/Neues
Projekt/Nummerierung auto (mirrored in project properties), literal
"W" fallback without a rule, French gate dialog when no rule exists,
Nummerierung menu with the renumber dialog (preferred axis, per-folio
counter, rule and counter state written back, hand-typed names ask,
whole-project scope).

Also included: label block and under-line texts with per-text font and
alignment plus the material-list cell margins, free-core placement and
right-click removal, claim questions for wires of other cables,
multi-selection drag as one undo step, type change with confirmation,
cross-references for type "Cable" (%f-%l%c, own font, clickable links
in exported PDFs), report propagation of the cable definition,
Listes menu (table of contents, material list, terminal strip manager,
terminal generator plugin, cable list), cable list with freely
selectable columns (installation/localisation of cable, start and end,
Blatt start/end, length, used cores...), CSV export dialog with column
pick and preview in the Projekt menu, script API (addTable kind
"cable_list", exportCableList) and a unit test for the type catalog.
2026-10-08 15:56:00 +02:00

100 lines
3.2 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 CABLEPROPERTIESDIALOG_H
#define CABLEPROPERTIESDIALOG_H
#include "cable.h"
#include <QDialog>
#include <QPointer>
class CablePropertiesWidget;
class CablePart;
class Diagram;
class QLabel;
class QListWidget;
class QListWidgetItem;
/**
@brief The dialog which edits a cable once it is drawn.
Everything it holds belongs to the cable itself rather than to the
line which was drawn: whatever is typed here applies to every section
of that cable, on every folio, and the conductors it feeds get their
cable field worked out again as soon as it says it changed.
Under the count of cores it lists the cores of the type which stand
nowhere on the sheet yet: double-clicking one sends it to the very
line this dialog was asked from, which takes the mouse until he
clicks and leaves the core standing there.
*/
class CablePropertiesDialog : public QDialog
{
Q_OBJECT
public:
/**
@param cable the cable being edited
@param diagram the folio whose undo stack takes the edit
@param part the very line which was double-clicked, where a
core chosen in this dialog is to be put down
@param parent
*/
explicit CablePropertiesDialog(Cable *cable,
Diagram *diagram = nullptr,
CablePart *part = nullptr,
QWidget *parent = nullptr);
void accept() override;
private:
///Everything the form holds goes into the cable, as one step
void apply();
///What the count of cores under the form says right now
void updateCoreCount();
///He asked for the window choosing another type for this cable
void changeTypeRequested();
///Lists the cores of the type which stand nowhere yet
void fillFreeCores();
///He double-clicked one of them: put it down on the line
void placeRequested(QListWidgetItem *item);
/**
The small menu a right click on a core which stands
nowhere opens: one entry doing what a double click does
-- the dialog closes, the line takes the mouse, the mark
shows on it at once and the mouse is put down there.
@param pos where he right-clicked, in list coordinates
*/
void freeCoreMenu(const QPoint &pos);
private:
QPointer<Cable> m_cable;
Diagram *m_diagram = nullptr;
///The line whose dialog this is, and the one a core chosen
///here is put down on
QPointer<CablePart> m_part;
CablePropertiesWidget *m_fields = nullptr;
QLabel *m_cores = nullptr;
QLabel *m_free_label = nullptr;
QListWidget *m_free_cores = nullptr;
///True from the moment he picks a core to put down
bool m_placing = false;
};
#endif // CABLEPROPERTIESDIALOG_H