mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-09-28 21:34:12 +02:00
5b8d05fc1e
Slice 4 of discussion #503, on top of slice 3 (#629): the smallest surface that makes wiring_list_view visible, plus the diagnostic the view needs to be honest about what it is missing. Projet > "Liste de câblage (base de données)" opens a read-only table of wiring_list_view, headed by a line stating how many conductors are listed and, when non-zero, how many were excluded and why. Deliberately not another exporter. QET already ships a wiring-list CSV export (Projet > Exporter le plan de câblage, and --export-cables) which walks the project XML; measured on the same projects it produces a row per conductor and resolves labels correctly when the project has them. Adding a second, competing CSV would be worse, not better -- the database path's value is what it unlocks (terminal plans, BOM joins), not replacing that export. projectDataBase::excludedConductorCount() counts, from the live scene, the conductors deliberately absent from the conductor table because a terminal has no uuid. Counted from the scene precisely because the database is where those conductors are not. Verified: 671 on examples/industrial.qet (which has 1794 terminals and no terminal uuids at all, so its list is empty and now says so), 0 on a project whose elements do carry terminal uuids. KNOWN GAP, not fixed here and the reason this is opened for discussion rather than merge: after a save/reload the component columns are blank for slave elements. populateElementTable()/populateElementInfoTable() only insert Simple|Terminal|Master|Thumbnail, so slave elements -- relay contacts, i.e. a large share of real wire endpoints -- have no row in element_info for the view to read a label from. Measured on a two-slave- contact project after reload: element rows 0, element_info rows 0, terminal rows 2, conductor rows 1; the wire is listed (slice 3's LEFT JOIN keeps it) but both component names are empty, where the existing CSV export shows K1 -> K2 for the same file. Closing that gap means widening a filter shared with the nomenclature and summary views, which would change what those existing, shipped features contain. That is a maintainer decision, not one to take unilaterally inside an additive slice.
94 lines
3.4 KiB
C++
94 lines
3.4 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/>.
|
|
*/
|
|
#include "wiringlistdialog.h"
|
|
|
|
#include "../dataBase/projectdatabase.h"
|
|
#include "../qetproject.h"
|
|
|
|
#include <QDialogButtonBox>
|
|
#include <QHeaderView>
|
|
#include <QLabel>
|
|
#include <QSqlQueryModel>
|
|
#include <QTableView>
|
|
#include <QVBoxLayout>
|
|
|
|
/**
|
|
@brief WiringListDialog::WiringListDialog
|
|
@param project : project whose wiring list is shown
|
|
@param parent : parent widget
|
|
*/
|
|
WiringListDialog::WiringListDialog(QETProject *project, QWidget *parent) :
|
|
QDialog(parent),
|
|
m_project(project)
|
|
{
|
|
setWindowTitle(tr("Liste de câblage", "window title"));
|
|
resize(900, 500);
|
|
|
|
auto *layout = new QVBoxLayout(this);
|
|
|
|
auto *model = new QSqlQueryModel(this);
|
|
model->setQuery(QStringLiteral(
|
|
"SELECT wire_number, from_element_label, from_terminal,"
|
|
" to_element_label, to_terminal, diagram_position"
|
|
" FROM wiring_list_view"
|
|
" ORDER BY diagram_position, wire_number"),
|
|
m_project->dataBase()->database());
|
|
|
|
model->setHeaderData(0, Qt::Horizontal, tr("Fil", "column title"));
|
|
model->setHeaderData(1, Qt::Horizontal, tr("Composant 1", "column title"));
|
|
model->setHeaderData(2, Qt::Horizontal, tr("Borne 1", "column title"));
|
|
model->setHeaderData(3, Qt::Horizontal, tr("Composant 2", "column title"));
|
|
model->setHeaderData(4, Qt::Horizontal, tr("Borne 2", "column title"));
|
|
model->setHeaderData(5, Qt::Horizontal, tr("Folio", "column title"));
|
|
|
|
const int excluded = m_project->dataBase()->excludedConductorCount();
|
|
const int listed = model->rowCount();
|
|
|
|
auto *summary = new QLabel(this);
|
|
summary->setWordWrap(true);
|
|
if (excluded > 0)
|
|
{
|
|
//The count matters more than it looks: a project whose elements
|
|
//all predate terminal uuids yields an entirely empty list, and
|
|
//without this line that is indistinguishable from a project with
|
|
//no wires in it.
|
|
summary->setText(tr("%n conducteur(s) listé(s).", "wiring list summary", listed)
|
|
% QStringLiteral(" ")
|
|
% tr("%n conducteur(s) exclu(s) : leurs éléments ne définissent pas"
|
|
" d'identifiant de borne (définition d'élément trop ancienne).",
|
|
"wiring list exclusion warning", excluded));
|
|
}
|
|
else {
|
|
summary->setText(tr("%n conducteur(s) listé(s).", "wiring list summary", listed));
|
|
}
|
|
layout->addWidget(summary);
|
|
|
|
auto *view = new QTableView(this);
|
|
view->setModel(model);
|
|
view->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
|
view->setSelectionBehavior(QAbstractItemView::SelectRows);
|
|
view->setAlternatingRowColors(true);
|
|
view->verticalHeader()->setVisible(false);
|
|
view->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
|
layout->addWidget(view);
|
|
|
|
auto *buttons = new QDialogButtonBox(QDialogButtonBox::Close, this);
|
|
connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
|
layout->addWidget(buttons);
|
|
}
|