16 class KDReports::TextElementPrivate
24 bool m_boldIsSet =
false;
25 bool m_italic =
false;
26 bool m_italicIsSet =
false;
27 bool m_underline =
false;
28 bool m_underlineIsSet =
false;
29 bool m_strikeout =
false;
30 bool m_strikeoutIsSet =
false;
31 bool m_fontSet =
false;
32 qreal m_pointSize = 0;
39 , d(new TextElementPrivate)
46 , d(new TextElementPrivate(*other.d))
65 QTextCursor &cursor = builder.
cursor();
66 const int charPosition = cursor.position();
67 QTextCharFormat charFormat = cursor.charFormat();
70 #if QT_VERSION >= QT_VERSION_CHECK(5, 3, 0)
71 charFormat.setFont(d->m_font, QTextCharFormat::FontPropertiesSpecifiedOnly);
73 charFormat.setFont(d->m_font);
77 charFormat.setFontWeight(d->m_bold ? QFont::Bold : QFont::Normal);
79 charFormat.setFontItalic(d->m_italic);
80 if (d->m_underlineIsSet)
81 charFormat.setFontUnderline(d->m_underline);
82 if (d->m_strikeoutIsSet)
83 charFormat.setFontStrikeOut(d->m_strikeout);
84 if (d->m_pointSize > 0)
85 charFormat.setFontPointSize(d->m_pointSize);
86 if (!d->m_fontFamily.isEmpty())
87 #if QT_VERSION >= QT_VERSION_CHECK(6, 1, 0)
88 charFormat.setFontFamilies({d->m_fontFamily});
90 charFormat.setFontFamily(d->m_fontFamily);
92 if (d->m_foreground.isValid())
93 charFormat.setForeground(d->m_foreground);
95 charFormat.clearForeground();
96 if (background().style() != Qt::NoBrush)
97 charFormat.setBackground(background());
99 charFormat.clearBackground();
100 cursor.setCharFormat(charFormat);
101 cursor.insertText(d->m_string);
102 if (!d->m_id.isEmpty())
108 d->m_string.append(str);
119 d->m_fontFamily = family;
125 d->m_boldIsSet =
true;
130 d->m_italic = italic;
131 d->m_italicIsSet =
true;
136 d->m_underline = underline;
137 d->m_underlineIsSet =
true;
142 d->m_strikeout = strikeout;
143 d->m_strikeoutIsSet =
true;
148 d->m_pointSize = size;
159 d->m_foreground = color;
164 return d->m_foreground;
Element & operator=(const Element &other)
TextDocumentData & currentDocumentData()
void setTextValueMarker(int pos, const QString &id, int valueLength, bool html)
TextElement & operator=(const TextElement &other)
void setTextColor(const QColor &color)
void setFontFamily(const QString &family)
Set font attribute: family.
void setUnderline(bool underline)
Set font attribute: underline.
void setStrikeOut(bool strikeout)
Set font attribute: strike out.
void setItalic(bool italic)
Set font attribute: italic.
void setFont(const QFont &)
void setText(const QString &text)
TextElement(const QString &string=QString())
void setPointSize(qreal size)
Set font attribute: size in points. Can be integer or decimal.
void setBold(bool bold)
Set font attribute: bold.
void build(ReportBuilder &builder) const override
TextElement & operator<<(const QString &)
Element * clone() const override
void setId(const QString &id)
void cleanupVariableProperties(QTextCharFormat &charFormat)