27 : m_contentDocument(contentDocument)
36 cursor().beginEditBlock();
41 const QTextCharFormat origCharFormat = cursor().charFormat();
43 cursor().setCharFormat(origCharFormat);
44 cursor().endEditBlock();
49 QTextCursor &cursor = this->cursor();
50 cursor.beginEditBlock();
59 QTextCharFormat charFormat = cursor.charFormat();
60 charFormat.setFont(m_defaultFont);
61 cursor.setCharFormat(charFormat);
63 QTextBlockFormat blockFormat;
64 blockFormat.setAlignment(horizontalAlignment);
65 setupBlockFormat(blockFormat);
67 if (backgroundColor.isValid())
68 blockFormat.setBackground(backgroundColor);
70 cursor.setBlockFormat(blockFormat);
74 cursor.endEditBlock();
76 #if 0 // DEBUG CODE for tab positions
77 if (!m_tabPositions.isEmpty()) {
78 QTextBlock block = cursor.document()->firstBlock();
80 qDebug() <<
"addBlock: Looking at block" << block.blockNumber() <<
"tabs:" << block.blockFormat().tabPositions().count();
82 }
while ( block.isValid() );
89 const int charPosition = cursor().position();
95 const QTextCharFormat origCharFormat = cursor().charFormat();
98 QTextCursor docCursor(¤tDocument());
99 docCursor.setPosition(charPosition);
100 cursor().setCharFormat(docCursor.charFormat());
102 cursor().beginEditBlock();
103 element.
build(*
this);
104 cursor().endEditBlock();
108 cursor().setCharFormat(origCharFormat);
113 QTextCursor &cursor = this->cursor();
114 cursor.beginEditBlock();
117 cursor.insertBlock();
122 QTextBlockFormat blockFormat;
124 cursor.setBlockFormat(blockFormat);
125 QTextCharFormat charFormat;
126 charFormat.setFontPointSize(1);
127 cursor.setCharFormat(charFormat);
128 cursor.endEditBlock();
134 addInlineElement(element);
139 addBlockElement(element, horizontalAlignment, backgroundColor);
144 addVariable(variable);
149 addVerticalSpacing(space);
155 QTextBlockFormat blockFormat = m_cursor.blockFormat();
156 blockFormat.setPageBreakPolicy(QTextFormat::PageBreak_AlwaysAfter);
157 m_cursor.setBlockFormat(blockFormat);
162 m_cursor.insertFragment(fragment);
168 Q_FOREACH (QTextOption::Tab tab, tabs) {
170 tabsInPixels.append(tab);
174 m_tabPositions = tabsInPixels;
175 m_contentDocument.setUsesTabPositions(
true);
180 m_tabPositions = parentBuilder.m_tabPositions;
181 m_leftMargin = parentBuilder.m_leftMargin;
182 m_rightMargin = parentBuilder.m_rightMargin;
183 m_topMargin = parentBuilder.m_topMargin;
184 m_bottomMargin = parentBuilder.m_bottomMargin;
185 m_defaultFont = parentBuilder.m_defaultFont;
190 static const char *types[] = {
"LeftTab",
"RightTab",
"CenterTab",
"DelimiterTab"};
191 dbg.space() <<
'(' << types[tab.type] << tab.position <<
"px" <<
')';
207 blockFormat.setTabPositions(m_tabPositions);
208 blockFormat.setLeftMargin(m_leftMargin);
209 blockFormat.setRightMargin(m_rightMargin);
210 blockFormat.setTopMargin(m_topMargin);
211 blockFormat.setBottomMargin(m_bottomMargin);
216 return m_cursor.position();