mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-09-28 04:54:13 +02:00
9738345b45
Affichage > "Garder les en-têtes visibles" adds a bar along the top and the left of the diagram view that repeats the folio's column numbers and row letters, aligned with the cells at any zoom, so they stay in sight when the folio's own headers are scrolled away. Off by default; the choice is stored as diagrameditor/cell_rulers. The bars are CellRuler widgets in the view's margins (setViewportMargins), not scene items, so printing and PDF/PNG/DXF export never see them, and they paint with the application palette outside of the dark-palette inversion. They keep a constant thickness; when cells get narrower than their labels, only every 2nd, 5th, 10th... label is written. A bar is hidden when the folio hides that header. Showing or hiding them keeps the centre of the view where it was. The labels come from BorderCellLabels, now also used by BorderTitleBlock::draw(), so the bars and the border cannot disagree. PNG export of all 133 folios of the examples is pixel-identical to master, with border-columns_0 true and false. Known limits: changing border-columns_0 repaints the bars at the next scroll or zoom; the menu toggle updates the views of its own editor window only, like the grid toggle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G2d2Zi8BfrYRPX88zhaoFG
52 lines
1.7 KiB
C++
52 lines
1.7 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/>.
|
|
*/
|
|
#ifndef BORDERCELLLABELS_H
|
|
#define BORDERCELLLABELS_H
|
|
|
|
#include <QString>
|
|
|
|
/// The labels the border of a folio writes on its rows and columns, shared
|
|
/// by BorderTitleBlock::draw() and the cell rulers of DiagramView so the
|
|
/// two cannot disagree. Header-only so it can be unit-tested directly --
|
|
/// see tests/qttest/tst_bordercelllabels.cpp.
|
|
namespace BorderCellLabels {
|
|
|
|
/// @return the label of row \a row, counted from 1: A..Z, then AA, AB...
|
|
/// (the sequence BorderTitleBlock::incrementLetters() walks through).
|
|
inline QString rowLabel(int row)
|
|
{
|
|
QString label;
|
|
while (row > 0) {
|
|
--row;
|
|
label.prepend(QChar('A' + row % 26));
|
|
row /= 26;
|
|
}
|
|
return label;
|
|
}
|
|
|
|
/// @return the label of column \a column, counted from 1. When
|
|
/// \a starts_at_zero (the "border-columns_0" setting) the first column
|
|
/// is labelled 0.
|
|
inline QString columnLabel(int column, bool starts_at_zero)
|
|
{
|
|
return QString::number(starts_at_zero ? column - 1 : column);
|
|
}
|
|
}
|
|
|
|
#endif // BORDERCELLLABELS_H
|