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
56 lines
1.8 KiB
C++
56 lines
1.8 KiB
C++
#include <QtTest>
|
|
|
|
#include "bordercelllabels.h"
|
|
|
|
class tst_bordercelllabels : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
// A copy of BorderTitleBlock::incrementLetters(), the walk the folio
|
|
// border used to draw its row labels with, as the reference rowLabel()
|
|
// must reproduce.
|
|
static QString incrementLetters(const QString &string)
|
|
{
|
|
if (string.isEmpty())
|
|
return QStringLiteral("A");
|
|
const QString first_digits(string.left(string.length() - 1));
|
|
const QChar last_digit(string.at(string.length() - 1));
|
|
if (last_digit != QLatin1Char('Z'))
|
|
return first_digits + QChar(last_digit.unicode() + 1);
|
|
return incrementLetters(first_digits) + QLatin1Char('A');
|
|
}
|
|
|
|
private slots:
|
|
void rowLabelsFollowTheBorderSequence()
|
|
{
|
|
QString expected(QStringLiteral("A"));
|
|
for (int row = 1; row <= 1000; ++row) {
|
|
QCOMPARE(BorderCellLabels::rowLabel(row), expected);
|
|
expected = incrementLetters(expected);
|
|
}
|
|
}
|
|
|
|
void rowLabelSamples()
|
|
{
|
|
QCOMPARE(BorderCellLabels::rowLabel(1), QStringLiteral("A"));
|
|
QCOMPARE(BorderCellLabels::rowLabel(26), QStringLiteral("Z"));
|
|
QCOMPARE(BorderCellLabels::rowLabel(27), QStringLiteral("AA"));
|
|
QCOMPARE(BorderCellLabels::rowLabel(52), QStringLiteral("AZ"));
|
|
QCOMPARE(BorderCellLabels::rowLabel(53), QStringLiteral("BA"));
|
|
QCOMPARE(BorderCellLabels::rowLabel(702), QStringLiteral("ZZ"));
|
|
QCOMPARE(BorderCellLabels::rowLabel(703), QStringLiteral("AAA"));
|
|
}
|
|
|
|
void columnLabels()
|
|
{
|
|
QCOMPARE(BorderCellLabels::columnLabel(1, true), QStringLiteral("0"));
|
|
QCOMPARE(BorderCellLabels::columnLabel(1, false), QStringLiteral("1"));
|
|
QCOMPARE(BorderCellLabels::columnLabel(17, true), QStringLiteral("16"));
|
|
QCOMPARE(BorderCellLabels::columnLabel(17, false), QStringLiteral("17"));
|
|
}
|
|
};
|
|
|
|
QTEST_APPLESS_MAIN(tst_bordercelllabels)
|
|
|
|
#include "tst_bordercelllabels.moc"
|