本文整理汇总了C++中QTextList::item方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextList::item方法的具体用法?C++ QTextList::item怎么用?C++ QTextList::item使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextList
的用法示例。
在下文中一共展示了QTextList::item方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testListDelete
void TestChangeTrackedDelete::testListDelete()
{
TextTool *textTool = new TextTool(new MockCanvas);
KoTextEditor *textEditor = textTool->textEditor();
QVERIFY(textEditor);
QTextDocument *document = textEditor->document();
KTextDocumentLayout *layout = qobject_cast<KTextDocumentLayout*>(document->documentLayout());
QTextCursor *cursor = textEditor->cursor();
insertSampleList(document);
cursor->setPosition(16);
cursor->setPosition(152, QTextCursor::KeepAnchor);
ChangeTrackedDeleteCommand *delCommand = new ChangeTrackedDeleteCommand(ChangeTrackedDeleteCommand::NextChar, textTool);
textEditor->addCommand(delCommand);
QCOMPARE(document->characterAt(16).unicode(), (ushort)(QChar::ObjectReplacementCharacter));
// This is wierd. Without this loop present the succeeding call to inlineTextObject returs NULL. Why ??????
for (int i=0; i<document->characterCount(); i++) {
cursor->setPosition(i);
}
cursor->setPosition(17);
KDeleteChangeMarker *testMarker = dynamic_cast<KDeleteChangeMarker*>(layout->inlineTextObjectManager()->inlineTextObject(*cursor));
QTextDocumentFragment deleteData = KTextDocument(document).changeTracker()->elementById(testMarker->changeId())->deleteData();
QTextDocument deleteDocument;
QTextCursor deleteCursor(&deleteDocument);
deleteCursor.insertFragment(deleteData);
bool listFound = false;
for (int i=0; i < deleteDocument.characterCount(); i++) {
deleteCursor.setPosition(i);
if (deleteCursor.currentList()) {
listFound = true;
continue;
}
}
QVERIFY(listFound == true);
QTextList *deletedList = deleteCursor.currentList();
bool deletedListStatus = deletedList->format().boolProperty(KDeleteChangeMarker::DeletedList);
QVERIFY (deletedListStatus == true);
bool deletedListItemStatus;
deletedListItemStatus = deletedList->item(0).blockFormat().boolProperty(KDeleteChangeMarker::DeletedListItem);
QVERIFY(deletedListItemStatus == true);
deletedListItemStatus = deletedList->item(1).blockFormat().boolProperty(KDeleteChangeMarker::DeletedListItem);
QVERIFY(deletedListItemStatus == true);
deletedListItemStatus = deletedList->item(2).blockFormat().boolProperty(KDeleteChangeMarker::DeletedListItem);
QVERIFY(deletedListItemStatus == true);
deletedListItemStatus = deletedList->item(3).blockFormat().boolProperty(KDeleteChangeMarker::DeletedListItem);
QVERIFY(deletedListItemStatus == true);
deletedListItemStatus = deletedList->item(4).blockFormat().boolProperty(KDeleteChangeMarker::DeletedListItem);
QVERIFY(deletedListItemStatus == true);
delete textTool;
}
示例2: highlightListItems
void MainWindow::highlightListItems()
{
QTextCursor cursor = editor->textCursor();
QTextList *list = cursor.currentList();
if (!list)
return;
cursor.beginEditBlock();
//! [0]
for (int index = 0; index < list->count(); ++index) {
QTextBlock listItem = list->item(index);
//! [0]
QTextBlockFormat newBlockFormat = listItem.blockFormat();
newBlockFormat.setBackground(Qt::lightGray);
QTextCursor itemCursor = cursor;
itemCursor.setPosition(listItem.position());
//itemCursor.movePosition(QTextCursor::StartOfBlock);
itemCursor.movePosition(QTextCursor::EndOfBlock,
QTextCursor::KeepAnchor);
itemCursor.setBlockFormat(newBlockFormat);
/*
//! [1]
processListItem(listItem);
//! [1]
*/
//! [2]
}
//! [2]
cursor.endEditBlock();
}
示例3: setStyle
void KoList::setStyle(KListStyle *style)
{
if (style == 0) {
KStyleManager *styleManager = KTextDocument(d->document).styleManager();
Q_ASSERT(styleManager);
style = styleManager->defaultListStyle();
}
if (style != d->style) {
if (d->style)
disconnect(d->style, 0, this, 0);
d->style = style->clone(this);
connect(d->style, SIGNAL(styleChanged(int)), this, SLOT(styleChanged(int)));
}
for (int i = 0; i < d->textLists.count(); i++) {
QTextList *textList = d->textLists.value(i).data();
if (!textList)
continue;
KListLevelProperties properties = d->style->levelProperties(i+1);
if (properties.listId())
d->textListIds[i] = properties.listId();
QTextListFormat format;
properties.applyStyle(format);
textList->setFormat(format);
d->invalidate(textList->item(0));
}
}