42 QTextCursor cursor = editor->textCursor();
43 QTextList *list = cursor.currentList();
48 cursor.beginEditBlock();
50 for (
int index = 0; index < list->count(); ++index) {
51 QTextBlock listItem = list->item(index);
53 QTextBlockFormat newBlockFormat = listItem.blockFormat();
54 newBlockFormat.setBackground(Qt::lightGray);
55 QTextCursor itemCursor = cursor;
56 itemCursor.setPosition(listItem.position());
58 itemCursor.movePosition(QTextCursor::EndOfBlock,
59 QTextCursor::KeepAnchor);
60 itemCursor.setBlockFormat(newBlockFormat);
62
63
64
65
69 cursor.endEditBlock();
74 QTextCursor cursor = editor->textCursor();
75 QTextFrame *frame = cursor.currentFrame();
80 QTreeWidget *treeWidget =
new QTreeWidget;
81 treeWidget->setColumnCount(1);
82 QStringList headerLabels;
83 headerLabels << tr(
"Lists");
84 treeWidget->setHeaderLabels(headerLabels);
86 QTreeWidgetItem *parentItem =
nullptr;
87 QTreeWidgetItem *item;
88 QTreeWidgetItem *lastItem =
nullptr;
90 previousItems.clear();
93 QTextFrame::iterator it;
94 for (it = frame->begin(); !(it.atEnd()); ++it) {
96 QTextBlock block = it.currentBlock();
98 if (block.isValid()) {
100 QTextList *list = block.textList();
103 int index = list->itemNumber(block);
106 parentItems.append(parentItem);
107 previousItems.append(lastItem);
108 listStructures.append(list);
109 parentItem = lastItem;
113 item =
new QTreeWidgetItem(parentItem, lastItem);
115 item =
new QTreeWidgetItem(treeWidget, lastItem);
119 while (parentItem != 0 && listStructures.last() != list) {
120 listStructures.pop_back();
121 parentItem = parentItems.takeLast();
122 lastItem = previousItems.takeLast();
125 item =
new QTreeWidgetItem(parentItem, lastItem);
127 item =
new QTreeWidgetItem(treeWidget, lastItem);
129 item->setText(0, block.text());
132
133
134
135
144 treeWidget->setWindowTitle(tr(
"List Contents"));
150 QTextCursor cursor = editor->textCursor();
151 cursor.beginEditBlock();
153 QTextList *list = cursor.currentList();
154 QTextListFormat listFormat;
156 listFormat = list->format();
158 listFormat.setStyle(QTextListFormat::ListDisc);
159 listFormat.setIndent(listFormat.indent() + 1);
160 cursor.insertList(listFormat);
162 cursor.endEditBlock();
void highlightListItems()