mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-11 22:54:12 +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:
@@ -18,6 +18,10 @@
|
||||
#include "propertieseditorfactory.h"
|
||||
|
||||
#include "../PropertiesEditor/propertieseditorwidget.h"
|
||||
#include "../cable/cablepart.h"
|
||||
#include "../cable/cablepropertieseditorwidget.h"
|
||||
#include "../cablelist/cablelistmodel.h"
|
||||
#include "../cablelist/cablelistmodelpropertieswidget.h"
|
||||
#include "../qetgraphicsitem/ViewItem/projectdbmodel.h"
|
||||
#include "../qetgraphicsitem/ViewItem/qetgraphicstableitem.h"
|
||||
#include "../qetgraphicsitem/ViewItem/ui/graphicstablepropertieseditor.h"
|
||||
@@ -54,7 +58,7 @@ PropertiesEditorWidget *PropertiesEditorFactory::propertiesEditor(
|
||||
PropertiesEditorWidget *editor,
|
||||
QWidget *parent)
|
||||
{
|
||||
if (auto m = static_cast<ProjectDBModel *>(model))
|
||||
if (auto m = dynamic_cast<ProjectDBModel *>(model))
|
||||
{
|
||||
if (editor &&
|
||||
editor->metaObject()->className()
|
||||
@@ -65,6 +69,17 @@ PropertiesEditorWidget *PropertiesEditorFactory::propertiesEditor(
|
||||
}
|
||||
return new ProjectDBModelPropertiesWidget(m, parent);
|
||||
}
|
||||
if (auto m = dynamic_cast<CableListModel *>(model))
|
||||
{
|
||||
if (editor &&
|
||||
editor->metaObject()->className()
|
||||
== CableListModelPropertiesWidget::staticMetaObject.className())
|
||||
{
|
||||
static_cast<CableListModelPropertiesWidget *>(editor)->setModel(m);
|
||||
return editor;
|
||||
}
|
||||
return new CableListModelPropertiesWidget(m, parent);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -239,6 +254,27 @@ PropertiesEditorWidget *PropertiesEditorFactory::propertiesEditor(
|
||||
}
|
||||
return new GraphicsTablePropertiesEditor(table, parent);
|
||||
}
|
||||
case CablePart::Type: //1012
|
||||
{
|
||||
if (count_ > 1) {
|
||||
return nullptr;
|
||||
}
|
||||
auto part = static_cast<CablePart *>(item);
|
||||
//The fields belong to the cable, never to one of its
|
||||
//lines: whichever line is picked, it is the cable which
|
||||
//is edited.
|
||||
Cable *cable = part->cable();
|
||||
if (!cable) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (class_name == CablePropertiesEditorWidget::staticMetaObject.className())
|
||||
{
|
||||
static_cast<CablePropertiesEditorWidget *>(editor)->setCable(cable, part);
|
||||
return editor;
|
||||
}
|
||||
return new CablePropertiesEditorWidget(cable, part, parent);
|
||||
}
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
*/
|
||||
#include "qetgraphicstablefactory.h"
|
||||
|
||||
#include "../cablelist/cablelistmodel.h"
|
||||
#include "../cablelist/cablequerywidget.h"
|
||||
#include "../dataBase/ui/elementquerywidget.h"
|
||||
#include "../dataBase/ui/summaryquerywidget.h"
|
||||
#include "../diagram.h"
|
||||
@@ -71,6 +73,26 @@ void QetGraphicsTableFactory::createAndAddSummary(Diagram *diagram)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QetGraphicsTableFactory::createAndAddCableList
|
||||
Open a dialog for ask user the config of the table,
|
||||
create a cable list table and add it to diagram
|
||||
@param diagram
|
||||
*/
|
||||
void QetGraphicsTableFactory::createAndAddCableList(Diagram *diagram)
|
||||
{
|
||||
QScopedPointer<AddTableDialog> d(
|
||||
new AddTableDialog(
|
||||
new CableQueryWidget(),
|
||||
diagram->views().first()));
|
||||
d->setWindowTitle(QObject::tr("Ajouter une liste de câbles"));
|
||||
d->setTableName(QObject::tr("Liste des câbles"));
|
||||
|
||||
if (d->exec()) {
|
||||
create(diagram, d.data());
|
||||
}
|
||||
}
|
||||
|
||||
void QetGraphicsTableFactory::create(Diagram *diagram, AddTableDialog *dialog)
|
||||
{
|
||||
auto table_ = newTable(diagram, dialog);
|
||||
@@ -124,20 +146,33 @@ QetGraphicsTableItem *QetGraphicsTableFactory::newTable(Diagram *diagram, AddTab
|
||||
|
||||
if (!previous_table)
|
||||
{
|
||||
QString identifier_;
|
||||
QString query_;
|
||||
QAbstractTableModel *model = nullptr;
|
||||
|
||||
if (auto query_widget = dynamic_cast<ElementQueryWidget *>(dialog->contentWidget())) {
|
||||
identifier_ = query_widget->modelIdentifier();
|
||||
query_ = query_widget->queryStr();
|
||||
auto *db_model = new ProjectDBModel(diagram->project(), diagram->project());
|
||||
db_model->setIdentifier(query_widget->modelIdentifier());
|
||||
db_model->setQuery(query_widget->queryStr());
|
||||
model = db_model;
|
||||
} else if (auto query_widget = dynamic_cast<SummaryQueryWidget *>(dialog->contentWidget())) {
|
||||
identifier_ = query_widget->modelIdentifier();
|
||||
query_ = query_widget->queryStr();
|
||||
auto *db_model = new ProjectDBModel(diagram->project(), diagram->project());
|
||||
db_model->setIdentifier(query_widget->modelIdentifier());
|
||||
db_model->setQuery(query_widget->queryStr());
|
||||
model = db_model;
|
||||
} else if (auto query_widget = dynamic_cast<CableQueryWidget *>(dialog->contentWidget())) {
|
||||
auto *cable_model = new CableListModel(diagram->project(), diagram->project());
|
||||
cable_model->setIdentifier(CableQueryWidget::modelIdentifier());
|
||||
//No entries chosen is no mistake to correct: an empty
|
||||
//set of columns makes an empty table, the same grey
|
||||
//frame a nomenclature table makes without entries
|
||||
cable_model->setFields(query_widget->selectedKeys());
|
||||
model = cable_model;
|
||||
} else {
|
||||
//A content widget this factory does not know leaves an
|
||||
//empty database model behind, which is what it has
|
||||
//always done
|
||||
model = new ProjectDBModel(diagram->project(), diagram->project());
|
||||
}
|
||||
|
||||
auto model = new ProjectDBModel(diagram->project(), diagram->project());
|
||||
model->setIdentifier(identifier_);
|
||||
model->setQuery(query_);
|
||||
model->setData(model->index(0,0), int(dialog->tableAlignment()), Qt::TextAlignmentRole);
|
||||
model->setData(model->index(0,0), dialog->tableFont(), Qt::FontRole);
|
||||
model->setData(model->index(0,0), QETUtils::marginsToString(dialog->headerMargins()), Qt::UserRole+1);
|
||||
|
||||
@@ -32,6 +32,7 @@ class QetGraphicsTableFactory
|
||||
|
||||
static void createAndAddNomenclature(Diagram *diagram);
|
||||
static void createAndAddSummary(Diagram *diagram);
|
||||
static void createAndAddCableList(Diagram *diagram);
|
||||
// Public so a caller that has already built and configured an
|
||||
// AddTableDialog itself (never shown or exec'd -- the two
|
||||
// methods above always exec() one, which the scripting API
|
||||
|
||||
Reference in New Issue
Block a user