KD Chart API Documentation 3.1
Loading...
Searching...
No Matches
KDTextDocument.cpp
Go to the documentation of this file.
1/****************************************************************************
2**
3** This file is part of the KD Chart library.
4**
5** SPDX-FileCopyrightText: 2001 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
6**
7** SPDX-License-Identifier: MIT
8**
9****************************************************************************/
10
11#include "KDTextDocument.h"
12#include <QAbstractTextDocumentLayout>
13#include <QRect>
14#include <QTextBlock>
15#include <QtDebug>
16
17#include <KDABLibFakes>
18
19// This is an internal class that mimics some of the behavior of a
20// QLabel with rich text assigned, this is mostly a workaround around
21// QTextDocumentLayout not being a public class.
22
24 : QTextDocument(p)
25 , mSizeHint()
26 , mMinimumSizeHint()
27{
28}
29
31 : QTextDocument(text, p)
32 , mHintValid(false)
33 , mSizeHint()
34 , mMinimumSizeHint()
35{
36}
37
41
43{
44 if (!mHintValid)
46 return mSizeHint;
47}
48
50{
51 /*
52 QTextCursor cursor( this );
53 if ( ! cursor.atEnd() )
54 cursor.movePosition( QTextCursor::NextBlock );
55 qDebug() << "KDTextDocument::minimumSizeHint() found:" << cursor.block().text();
56 QSizeF s( documentLayout()->blockBoundingRect( cursor.block() ).size() );
57 qDebug() << "KDTextDocument::minimumSizeHint() found rect" << documentLayout()->blockBoundingRect( cursor.block());
58 return QSize( static_cast<int>(s.width()),
59 static_cast<int>(s.height()) );
60 */
61
62 if (mHintValid)
63 return mMinimumSizeHint;
64
65 mHintValid = true;
66 mSizeHint = sizeForWidth(-1);
67 QSize sz(-1, -1);
68
69 // PENDING(kalle) Cache
70 sz.rwidth() = sizeForWidth(0).width();
71 sz.rheight() = sizeForWidth(32000).height();
72 if (mSizeHint.height() < sz.height())
73 sz.rheight() = mSizeHint.height();
74
75 mMinimumSizeHint = sz;
76 return sz;
77}
78
79QSize KDTextDocument::sizeForWidth(int w)
80{
81 Q_UNUSED(w);
82
83 setPageSize(QSize(0, 100000));
84
86}
KDTextDocument(QObject *parent=nullptr)
~KDTextDocument() override
virtual QSizeF documentSize() const const=0
T qobject_cast(QObject *object)
int height() const const
int width() const const
QSize toSize() const const
QAbstractTextDocumentLayout * documentLayout() const const
void setPageSize(const QSizeF &size)

© 2001 Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
https://www.kdab.com/development-resources/qt-tools/kd-chart/
Generated on Wed May 1 2024 00:01:10 for KD Chart API Documentation by doxygen 1.9.8