mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-03 17:34:12 +02:00
86da56b866
Below 100 % ElementView::drawBackground() hid the grid and also set the snap step to 1 unit, so anything dragged while zoomed out landed off the grid with nothing on screen to show it. A large symbol opens fitted to the window below 100 %, which is why the report also says "when the selection is big". Keep hiding the grid below 100 % (its dots would merge into a grey wash), but snap every 10 units, as at 100 %. The zoom-to-grid rule moves into a header-only ElementViewGrid so it can be tested without an editor window, like textgrid.h. Checked in the editor: a one-rectangle symbol zoomed out to about 0.6x, its edge dragged by (15, 10) px and saved: master moves it by (28, 18), this branch by (30, 20). tst_elementviewgrid fails with the old step 1 and passes now; ctest 45/45. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
46 lines
1.4 KiB
C++
46 lines
1.4 KiB
C++
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
#include <QtTest>
|
|
|
|
#include "editor/elementviewgrid.h"
|
|
|
|
// The symbol editor's snap step at each zoom (bugtracker #112): below
|
|
// 100 % the grid is hidden but parts must still snap every 10 units.
|
|
class tst_elementviewgrid : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
private slots:
|
|
void stepAtZoom_data()
|
|
{
|
|
QTest::addColumn<qreal>("zoom");
|
|
QTest::addColumn<int>("step");
|
|
QTest::addColumn<bool>("drawGrid");
|
|
QTest::addColumn<bool>("drawCross");
|
|
|
|
QTest::newRow("10 % (fit to a big symbol)") << 0.10 << 10 << false << false;
|
|
QTest::newRow("62.5 %, the #112 case") << 0.625 << 10 << false << false;
|
|
QTest::newRow("100 %") << 1.0 << 10 << true << false;
|
|
QTest::newRow("200 %") << 2.0 << 10 << true << false;
|
|
QTest::newRow("400 %") << 4.0 << 5 << true << true;
|
|
QTest::newRow("800 %") << 8.0 << 2 << true << true;
|
|
QTest::newRow("1000 %") << 10.0 << 1 << true << true;
|
|
}
|
|
|
|
void stepAtZoom()
|
|
{
|
|
QFETCH(qreal, zoom);
|
|
QFETCH(int, step);
|
|
QFETCH(bool, drawGrid);
|
|
QFETCH(bool, drawCross);
|
|
|
|
const ElementViewGrid grid = ElementViewGrid::forZoom(zoom);
|
|
QCOMPARE(grid.step, step);
|
|
QCOMPARE(grid.draw_grid, drawGrid);
|
|
QCOMPARE(grid.draw_cross, drawCross);
|
|
}
|
|
};
|
|
|
|
QTEST_APPLESS_MAIN(tst_elementviewgrid)
|
|
|
|
#include "tst_elementviewgrid.moc"
|