20 #include <QTextCursor>
21 #include <QTextTableFormat>
23 class KDReports::AbstractTableElementPrivate
26 AbstractTableElementPrivate()
28 , m_borderBrush(Qt::darkGray )
32 , m_fontSpecified(false)
42 QVector<KDReports::AbstractTableElement::ColumnConstraint> m_constraints;
47 , d(new AbstractTableElementPrivate)
53 , d(new AbstractTableElementPrivate(*other.d))
68 d->m_constraints = constraints;
88 d->m_borderBrush = brush;
93 return d->m_borderBrush;
98 d->m_padding = padding;
124 d->m_defaultFont = font;
125 d->m_fontSpecified =
true;
130 *isSet = d->m_fontSpecified;
131 return d->m_defaultFont;
138 tableFormat.setWidth(QTextLength(QTextLength::FixedLength,
mmToPixels(d->m_width)));
140 tableFormat.setWidth(QTextLength(QTextLength::PercentageLength, d->m_width));
144 if (!d->m_constraints.isEmpty()) {
145 QVector<QTextLength> constraints;
146 constraints.reserve(d->m_constraints.size());
147 for (
const auto &c : qAsConst(d->m_constraints)) {
150 length = QTextLength(QTextLength::FixedLength,
mmToPixels(c.width));
152 length = QTextLength(QTextLength::PercentageLength, c.width);
154 constraints.append(length);
156 tableFormat.setColumnWidthConstraints(constraints);
159 tableFormat.setBorder(border());
160 tableFormat.setBorderBrush(borderBrush());
161 tableFormat.setCellPadding(
mmToPixels(padding()));
162 tableFormat.setCellSpacing(0);
163 if (d->m_fontSpecified) {
164 QTextCharFormat charFormat = textDocCursor.charFormat();
165 charFormat.setFont(d->m_defaultFont);
166 textDocCursor.setCharFormat(charFormat);