diff options
author | Nils Jeisecke <jeisecke@saltation.de> | 2015-12-17 16:34:26 +0100 |
---|---|---|
committer | Nils Jeisecke <nils.jeisecke@saltation.com> | 2019-08-08 16:46:09 +0200 |
commit | 8664ee610d3d8bb8a2a578a6aa6bfd38afe4fcda (patch) | |
tree | 7b986d0fc25ad03a96d92c8ee583b817a4a3b1ff /src/gui/text/qtextformat.h | |
parent | bab8262bce2d63da08d1454377309ca0f1e003a9 (diff) |
QTextDocument: allow css-styling of table cell borders
This allows to set the width, style and color of each table cell's edge
(left, right, top, bottom).
Setting the table's border-collapse mode will disable explicit cell
spacing. The basic CSS border collision rules are applied (wider border
wins, vertical over horizontal).
Setting the table's border width to a value >= 1 and enabling
borderCollapse will now draw a simple and clean table grid (1px) with an
outer border of the specified width and color.
[ChangeLog][QtGui][QTextDocument] Added CSS style table cell border
formatting with border-collapse mode.
Change-Id: I324d82284802df4c88c13c5b902fec1f4768b67e
Fixes: QTBUG-36152
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/gui/text/qtextformat.h')
-rw-r--r-- | src/gui/text/qtextformat.h | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/src/gui/text/qtextformat.h b/src/gui/text/qtextformat.h index a91461dcae..12f14a1555 100644 --- a/src/gui/text/qtextformat.h +++ b/src/gui/text/qtextformat.h @@ -242,6 +242,7 @@ public: TableCellSpacing = 0x4102, TableCellPadding = 0x4103, TableHeaderRowCount = 0x4104, + TableBorderCollapse = 0x4105, // table cell properties TableCellRowSpan = 0x4810, @@ -252,6 +253,21 @@ public: TableCellLeftPadding = 0x4814, TableCellRightPadding = 0x4815, + TableCellTopBorder = 0x4816, + TableCellBottomBorder = 0x4817, + TableCellLeftBorder = 0x4818, + TableCellRightBorder = 0x4819, + + TableCellTopBorderStyle = 0x481a, + TableCellBottomBorderStyle = 0x481b, + TableCellLeftBorderStyle = 0x481c, + TableCellRightBorderStyle = 0x481d, + + TableCellTopBorderBrush = 0x481e, + TableCellBottomBorderBrush = 0x481f, + TableCellLeftBorderBrush = 0x4820, + TableCellRightBorderBrush = 0x4821, + // image properties ImageName = 0x5000, ImageTitle = 0x5001, @@ -966,6 +982,11 @@ public: inline int headerRowCount() const { return intProperty(TableHeaderRowCount); } + inline void setBorderCollapse(bool borderCollapse) + { setProperty(TableBorderCollapse, borderCollapse); } + inline bool borderCollapse() const + { return boolProperty(TableBorderCollapse); } + protected: explicit QTextTableFormat(const QTextFormat &fmt); friend class QTextFormat; @@ -1007,6 +1028,72 @@ public: inline void setPadding(qreal padding); + inline void setTopBorder(qreal width) + { setProperty(TableCellTopBorder, width); } + inline qreal topBorder() const + { return doubleProperty(TableCellTopBorder); } + + inline void setBottomBorder(qreal width) + { setProperty(TableCellBottomBorder, width); } + inline qreal bottomBorder() const + { return doubleProperty(TableCellBottomBorder); } + + inline void setLeftBorder(qreal width) + { setProperty(TableCellLeftBorder, width); } + inline qreal leftBorder() const + { return doubleProperty(TableCellLeftBorder); } + + inline void setRightBorder(qreal width) + { setProperty(TableCellRightBorder, width); } + inline qreal rightBorder() const + { return doubleProperty(TableCellRightBorder); } + + inline void setBorder(qreal width); + + inline void setTopBorderStyle(QTextFrameFormat::BorderStyle style) + { setProperty(TableCellTopBorderStyle, style); } + inline QTextFrameFormat::BorderStyle topBorderStyle() const + { return static_cast<QTextFrameFormat::BorderStyle>(intProperty(TableCellTopBorderStyle)); } + + inline void setBottomBorderStyle(QTextFrameFormat::BorderStyle style) + { setProperty(TableCellBottomBorderStyle, style); } + inline QTextFrameFormat::BorderStyle bottomBorderStyle() const + { return static_cast<QTextFrameFormat::BorderStyle>(intProperty(TableCellBottomBorderStyle)); } + + inline void setLeftBorderStyle(QTextFrameFormat::BorderStyle style) + { setProperty(TableCellLeftBorderStyle, style); } + inline QTextFrameFormat::BorderStyle leftBorderStyle() const + { return static_cast<QTextFrameFormat::BorderStyle>(intProperty(TableCellLeftBorderStyle)); } + + inline void setRightBorderStyle(QTextFrameFormat::BorderStyle style) + { setProperty(TableCellRightBorderStyle, style); } + inline QTextFrameFormat::BorderStyle rightBorderStyle() const + { return static_cast<QTextFrameFormat::BorderStyle>(intProperty(TableCellRightBorderStyle)); } + + inline void setBorderStyle(QTextFrameFormat::BorderStyle style); + + inline void setTopBorderBrush(const QBrush &brush) + { setProperty(TableCellTopBorderBrush, brush); } + inline QBrush topBorderBrush() const + { return brushProperty(TableCellTopBorderBrush); } + + inline void setBottomBorderBrush(const QBrush &brush) + { setProperty(TableCellBottomBorderBrush, brush); } + inline QBrush bottomBorderBrush() const + { return brushProperty(TableCellBottomBorderBrush); } + + inline void setLeftBorderBrush(const QBrush &brush) + { setProperty(TableCellLeftBorderBrush, brush); } + inline QBrush leftBorderBrush() const + { return brushProperty(TableCellLeftBorderBrush); } + + inline void setRightBorderBrush(const QBrush &brush) + { setProperty(TableCellRightBorderBrush, brush); } + inline QBrush rightBorderBrush() const + { return brushProperty(TableCellRightBorderBrush); } + + inline void setBorderBrush(const QBrush &brush); + protected: explicit QTextTableCellFormat(const QTextFormat &fmt); friend class QTextFormat; @@ -1062,6 +1149,29 @@ inline void QTextTableCellFormat::setPadding(qreal padding) setRightPadding(padding); } +inline void QTextTableCellFormat::setBorder(qreal width) +{ + setTopBorder(width); + setBottomBorder(width); + setLeftBorder(width); + setRightBorder(width); +} + +inline void QTextTableCellFormat::setBorderStyle(QTextFrameFormat::BorderStyle style) +{ + setTopBorderStyle(style); + setBottomBorderStyle(style); + setLeftBorderStyle(style); + setRightBorderStyle(style); +} + +inline void QTextTableCellFormat::setBorderBrush(const QBrush &brush) +{ + setTopBorderBrush(brush); + setBottomBorderBrush(brush); + setLeftBorderBrush(brush); + setRightBorderBrush(brush); +} QT_END_NAMESPACE |