mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-11 14:44:15 +02:00
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.
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
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 3 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/>.
|
||||
*/
|
||||
#include "cablelistmodelpropertieswidget.h"
|
||||
|
||||
#include "cablelistmodel.h"
|
||||
#include "cablequerywidget.h"
|
||||
|
||||
#include <QDialog>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QHBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
/**
|
||||
@brief CableListModelPropertiesWidget::CableListModelPropertiesWidget
|
||||
@param model
|
||||
@param parent
|
||||
*/
|
||||
CableListModelPropertiesWidget::CableListModelPropertiesWidget(
|
||||
CableListModel *model,
|
||||
QWidget *parent) :
|
||||
PropertiesEditorWidget(parent)
|
||||
{
|
||||
auto *layout = new QHBoxLayout(this);
|
||||
m_edit_pb = new QPushButton(tr("Modifier les colonnes..."), this);
|
||||
m_refresh_pb = new QPushButton(tr("Rafraîchir"), this);
|
||||
layout->addWidget(m_edit_pb);
|
||||
layout->addWidget(m_refresh_pb);
|
||||
layout->addStretch();
|
||||
|
||||
connect(m_edit_pb, &QPushButton::clicked, this, &CableListModelPropertiesWidget::editColumns);
|
||||
connect(m_refresh_pb, &QPushButton::clicked, this, &CableListModelPropertiesWidget::refreshRows);
|
||||
|
||||
setModel(model);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief CableListModelPropertiesWidget::setModel
|
||||
@param model
|
||||
*/
|
||||
void CableListModelPropertiesWidget::setModel(CableListModel *model)
|
||||
{
|
||||
m_model = model;
|
||||
m_edit_pb->setEnabled(m_model != nullptr);
|
||||
m_refresh_pb->setEnabled(m_model != nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief CableListModelPropertiesWidget::editColumns
|
||||
Ask for the columns again and put them on the table right away --
|
||||
the same immediate, not-undoable way the database table changes its
|
||||
query
|
||||
*/
|
||||
void CableListModelPropertiesWidget::editColumns()
|
||||
{
|
||||
if (!m_model) {
|
||||
return;
|
||||
}
|
||||
|
||||
QDialog d(this);
|
||||
d.setWindowTitle(tr("Colonnes de la liste des câbles"));
|
||||
auto *layout = new QVBoxLayout(&d);
|
||||
auto *widget = new CableQueryWidget(&d);
|
||||
widget->setFields(m_model->fields());
|
||||
layout->addWidget(widget);
|
||||
|
||||
auto *button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
layout->addWidget(button_box);
|
||||
connect(button_box, &QDialogButtonBox::accepted, &d, &QDialog::accept);
|
||||
connect(button_box, &QDialogButtonBox::rejected, &d, &QDialog::reject);
|
||||
|
||||
if (d.exec()) {
|
||||
m_model->setFields(widget->selectedKeys());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief CableListModelPropertiesWidget::refreshRows
|
||||
*/
|
||||
void CableListModelPropertiesWidget::refreshRows()
|
||||
{
|
||||
if (m_model) {
|
||||
m_model->refresh();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user