Reapply "Add cable management: drawing, cores, numbering, cross-references and cable list"

This reverts commit 2bb3343d2d.
This commit is contained in:
Laurent Trinques
2026-10-11 05:00:01 +02:00
parent 124a889be3
commit 1cd8fadbc4
113 changed files with 18793 additions and 209 deletions
+44 -9
View File
@@ -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("Add a cable list"));
d->setTableName(QObject::tr("Cable list"));
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);