/src/qtbase/src/gui/text/qtexttable.h
Line | Count | Source (jump to first uncovered line) |
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 QTEXTTABLE_H |
5 | | #define QTEXTTABLE_H |
6 | | |
7 | | #include <QtGui/qtguiglobal.h> |
8 | | #include <QtCore/qobject.h> |
9 | | #include <QtGui/qtextobject.h> |
10 | | |
11 | | QT_BEGIN_NAMESPACE |
12 | | |
13 | | |
14 | | class QTextCursor; |
15 | | class QTextTable; |
16 | | class QTextTablePrivate; |
17 | | |
18 | | class Q_GUI_EXPORT QTextTableCell |
19 | | { |
20 | | public: |
21 | 0 | QTextTableCell() : table(nullptr) {} |
22 | 0 | ~QTextTableCell() {} |
23 | 0 | QTextTableCell(const QTextTableCell &o) : table(o.table), fragment(o.fragment) {} |
24 | | QTextTableCell &operator=(const QTextTableCell &o) |
25 | 0 | { table = o.table; fragment = o.fragment; return *this; } |
26 | | |
27 | | void setFormat(const QTextCharFormat &format); |
28 | | QTextCharFormat format() const; |
29 | | |
30 | | int row() const; |
31 | | int column() const; |
32 | | |
33 | | int rowSpan() const; |
34 | | int columnSpan() const; |
35 | | |
36 | 0 | inline bool isValid() const { return table != nullptr; } |
37 | | |
38 | | QTextCursor firstCursorPosition() const; |
39 | | QTextCursor lastCursorPosition() const; |
40 | | int firstPosition() const; |
41 | | int lastPosition() const; |
42 | | |
43 | | inline bool operator==(const QTextTableCell &other) const |
44 | 0 | { return table == other.table && fragment == other.fragment; } |
45 | | inline bool operator!=(const QTextTableCell &other) const |
46 | 0 | { return !operator==(other); } |
47 | | |
48 | | QTextFrame::iterator begin() const; |
49 | | QTextFrame::iterator end() const; |
50 | | |
51 | | int tableCellFormatIndex() const; |
52 | | |
53 | | private: |
54 | | friend class QTextTable; |
55 | | QTextTableCell(const QTextTable *t, int f) |
56 | 0 | : table(t), fragment(f) {} |
57 | | |
58 | | const QTextTable *table; |
59 | | int fragment; |
60 | | }; |
61 | | |
62 | | class Q_GUI_EXPORT QTextTable : public QTextFrame |
63 | | { |
64 | | Q_OBJECT |
65 | | public: |
66 | | explicit QTextTable(QTextDocument *doc); |
67 | | ~QTextTable(); |
68 | | |
69 | | void resize(int rows, int cols); |
70 | | void insertRows(int pos, int num); |
71 | | void insertColumns(int pos, int num); |
72 | | void appendRows(int count); |
73 | | void appendColumns(int count); |
74 | | void removeRows(int pos, int num); |
75 | | void removeColumns(int pos, int num); |
76 | | |
77 | | void mergeCells(int row, int col, int numRows, int numCols); |
78 | | void mergeCells(const QTextCursor &cursor); |
79 | | void splitCell(int row, int col, int numRows, int numCols); |
80 | | |
81 | | int rows() const; |
82 | | int columns() const; |
83 | | |
84 | | QTextTableCell cellAt(int row, int col) const; |
85 | | QTextTableCell cellAt(int position) const; |
86 | | QTextTableCell cellAt(const QTextCursor &c) const; |
87 | | |
88 | | QTextCursor rowStart(const QTextCursor &c) const; |
89 | | QTextCursor rowEnd(const QTextCursor &c) const; |
90 | | |
91 | | void setFormat(const QTextTableFormat &format); |
92 | 0 | QTextTableFormat format() const { return QTextObject::format().toTableFormat(); } |
93 | | |
94 | | private: |
95 | | Q_DISABLE_COPY(QTextTable) |
96 | | Q_DECLARE_PRIVATE(QTextTable) |
97 | | friend class QTextTableCell; |
98 | | }; |
99 | | |
100 | | QT_END_NAMESPACE |
101 | | |
102 | | #endif // QTEXTTABLE_H |