qt5base-lts/tests/auto/gui/text/qtextdocument/common.h
Lucie Gérard 05fc3aef53 Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.
Files that have to be modified by hand are modified.
License files are organized under LICENSES directory.

Task-number: QTBUG-67283
Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-05-16 16:37:38 +02:00

56 lines
1.6 KiB
C++

// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QAbstractTextDocumentLayout>
#include <private/qtextdocument_p.h>
#ifndef COMMON_H
#define COMMON_H
class QTestDocumentLayout : public QAbstractTextDocumentLayout
{
Q_OBJECT
public:
QTestDocumentLayout(QTextDocument *doc) : QAbstractTextDocumentLayout(doc), f(-1), called(false) {}
virtual void draw(QPainter *, const PaintContext &) override {}
virtual int hitTest(const QPointF &, Qt::HitTestAccuracy ) const override { return 0; }
virtual void documentChanged(int from, int oldLength, int length) override
{
called = true;
lastDocumentLengths.append(QTextDocumentPrivate::get(document())->length());
if (f < 0)
return;
if(from != f ||
o != oldLength ||
l != length) {
qDebug("checkDocumentChanged: got %d %d %d, expected %d %d %d", from, oldLength, length, f, o, l);
error = true;
}
}
virtual int pageCount() const override { return 1; }
virtual QSizeF documentSize() const override { return QSizeF(); }
virtual QRectF frameBoundingRect(QTextFrame *) const override { return QRectF(); }
virtual QRectF blockBoundingRect(const QTextBlock &) const override { return QRectF(); }
int f;
int o;
int l;
void expect(int from, int oldLength, int length) {
f = from;
o = oldLength;
l = length;
error = false;
called = false;
}
bool error;
bool called;
QList<int> lastDocumentLengths;
};
#endif