Coverage Report

Created: 2026-05-16 07:21

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/qtbase/src/gui/text/qtextformat_p.h
Line
Count
Source
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
#ifndef QTEXTFORMAT_P_H
5
#define QTEXTFORMAT_P_H
6
7
//
8
//  W A R N I N G
9
//  -------------
10
//
11
// This file is not part of the Qt API.  It exists purely as an
12
// implementation detail.  This header file may change from version to
13
// version without notice, or even be removed.
14
//
15
// We mean it.
16
//
17
18
#include <QtGui/private/qtguiglobal_p.h>
19
#include "QtGui/qtextformat.h"
20
#include "QtCore/qlist.h"
21
#include <QtCore/qhash.h> // QMultiHash
22
23
QT_BEGIN_NAMESPACE
24
25
class Q_GUI_EXPORT QTextFormatCollection
26
{
27
public:
28
0
    QTextFormatCollection() {}
29
    ~QTextFormatCollection();
30
31
    void clear();
32
33
    inline QTextFormat objectFormat(int objectIndex) const
34
0
    { return format(objectFormatIndex(objectIndex)); }
35
    inline void setObjectFormat(int objectIndex, const QTextFormat &format)
36
0
    { setObjectFormatIndex(objectIndex, indexForFormat(format)); }
37
38
    int objectFormatIndex(int objectIndex) const;
39
    void setObjectFormatIndex(int objectIndex, int formatIndex);
40
41
    int createObjectIndex(const QTextFormat &f);
42
43
    int indexForFormat(const QTextFormat &f);
44
    bool hasFormatCached(const QTextFormat &format) const;
45
46
    QTextFormat format(int idx) const;
47
    inline QTextBlockFormat blockFormat(int index) const
48
0
    { return format(index).toBlockFormat(); }
49
    inline QTextCharFormat charFormat(int index) const
50
0
    { return format(index).toCharFormat(); }
51
    inline QTextListFormat listFormat(int index) const
52
0
    { return format(index).toListFormat(); }
53
    inline QTextTableFormat tableFormat(int index) const
54
0
    { return format(index).toTableFormat(); }
55
    inline QTextImageFormat imageFormat(int index) const
56
0
    { return format(index).toImageFormat(); }
57
58
0
    inline int numFormats() const { return formats.size(); }
59
60
    typedef QList<QTextFormat> FormatVector;
61
62
    FormatVector formats;
63
    QList<qint32> objFormats;
64
    QMultiHash<size_t,int> hashes;
65
66
0
    inline QFont defaultFont() const { return defaultFnt; }
67
    void setDefaultFont(const QFont &f);
68
69
0
    inline void setSuperScriptBaseline(qreal baseline) { defaultFormat.setSuperScriptBaseline(baseline); }
70
0
    inline void setSubScriptBaseline(qreal baseline) { defaultFormat.setSubScriptBaseline(baseline); }
71
0
    inline void setBaselineOffset(qreal baseline) { defaultFormat.setBaselineOffset(baseline); }
72
73
0
    inline QTextCharFormat defaultTextFormat() const { return defaultFormat; }
74
75
private:
76
    QFont defaultFnt;
77
    QTextCharFormat defaultFormat;
78
79
    Q_DISABLE_COPY_MOVE(QTextFormatCollection)
80
};
81
82
QT_END_NAMESPACE
83
84
#endif // QTEXTFORMAT_P_H