mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-09 13:34:14 +02:00
f5962ecd06
Every tr() source string in the code and the forms is now the English
text, and French is a translation (qet_fr.ts) like the other languages.
Generated, not hand-edited: master ef795a21e5 converted by
qet-en-source (harness 4c4ddc9).
3144 messages get an English source, 665 already had one, 0 left French; 8 shared-wording pairs disambiguated.
C++: 2904 literals in 233 files. Forms: 809 strings in 65 files. All 34 .ts files re-keyed; qet_fr.ts filled.
lupdate check: PASS. What each of 38 languages shows, old vs new: same 118266, English instead of French 38433, comment fallback 51, differences 0.
118 lines
4.3 KiB
C++
118 lines
4.3 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 "../qet.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("Wiring list", "window title"));
|
|
resize(900, 500);
|
|
|
|
auto *layout = new QVBoxLayout(this);
|
|
|
|
//The wiring list reads the database rather than the diagrams, and a
|
|
//conductor's row is only as fresh as the last thing that touched it.
|
|
//Refresh before querying so the dialog cannot show a wire number that
|
|
//was edited earlier in the session.
|
|
m_project->dataBase()->updateDB();
|
|
|
|
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"
|
|
//Wire numbers are text, so a plain sort puts "10" before "9".
|
|
//Numeric ones first, ordered by value; anything non-numeric
|
|
//after, ordered as text. The trailing wire_number keeps ties
|
|
//stable.
|
|
" ORDER BY diagram_position,"
|
|
" CASE WHEN wire_number GLOB '[0-9]*' THEN 0 ELSE 1 END,"
|
|
" CAST(wire_number AS INTEGER),"
|
|
" wire_number"),
|
|
m_project->dataBase()->database());
|
|
|
|
model->setHeaderData(0, Qt::Horizontal, tr("Wire", "column title"));
|
|
model->setHeaderData(1, Qt::Horizontal, tr("Component 1", "column title"));
|
|
model->setHeaderData(2, Qt::Horizontal, tr("Terminal 1", "column title"));
|
|
model->setHeaderData(3, Qt::Horizontal, tr("Component 2", "column title"));
|
|
model->setHeaderData(4, Qt::Horizontal, tr("Terminal 2", "column title"));
|
|
model->setHeaderData(5, Qt::Horizontal, tr("Sheet", "column title"));
|
|
|
|
const int excluded = m_project->dataBase()->excludedConductorCount();
|
|
|
|
//QSqlQueryModel fetches lazily, so rowCount() straight after
|
|
//setQuery() reports the first batch (256) rather than the query's
|
|
//size. Draining it first is what makes the count below true for a
|
|
//project with more wires than that.
|
|
while (model->canFetchMore()) {
|
|
model->fetchMore();
|
|
}
|
|
const int listed = model->rowCount();
|
|
|
|
auto *summary = new QLabel(this);
|
|
summary->setWordWrap(true);
|
|
if (excluded > 0)
|
|
{
|
|
//Rare now that Terminal::stableUuid() gives every terminal an
|
|
//identity: what is left is a conductor whose endpoint has no
|
|
//parent element at all. Still worth saying out loud rather than
|
|
//presenting a short list as if it were complete.
|
|
summary->setText(tr("%n conductors listed.", "wiring list summary", listed)
|
|
% QStringLiteral(" ")
|
|
% tr("%n conductors excluded: one end is not attached to any "
|
|
"element.",
|
|
"wiring list exclusion warning", excluded));
|
|
}
|
|
else {
|
|
summary->setText(tr("%n conductors listed.", "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);
|
|
|
|
QET::trackDialogGeometry(this);
|
|
}
|