当前位置: 首页>>代码示例>>C++>>正文


C++ QTextList类代码示例

本文整理汇总了C++中QTextList的典型用法代码示例。如果您正苦于以下问题:C++ QTextList类的具体用法?C++ QTextList怎么用?C++ QTextList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QTextList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: KTextDocument

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));
    }
}
开发者ID:KDE,项目名称:koffice,代码行数:28,代码来源:KoList.cpp

示例2: cursor

void TextTools::indentLessClicked()
      {
      QTextList* list = cursor()->currentList();
      if (list == 0) {
            QTextBlockFormat format = cursor()->blockFormat();
            int indent = format.indent();
            if (indent) {
                  indent--;
                  format.setIndent(indent);
                  cursor()->insertBlock(format);
                  updateText();
                  }
            return;
            }
      QTextCharFormat format = cursor()->blockCharFormat();
      QTextListFormat listFormat = list->format();
      QTextBlock block = cursor()->block();
      if (block.next().isValid())
            block = block.next();
      else {
            block = QTextBlock();
            }
      cursor()->insertBlock(block.blockFormat());
      cursor()->setCharFormat(block.charFormat());
      updateText();
      }
开发者ID:briff,项目名称:MuseScore,代码行数:26,代码来源:texttools.cpp

示例3: exp

	QTextList *tryReadList(QTextList *list, const QString &line)
	{
		QTextList *listOut = list;
		QRegularExpression exp("^( *)(\\d+\\.|\\*) (.*)$");
		QRegularExpressionMatch match = exp.match(line);
		if (match.hasMatch())
		{
			const int indent = match.captured(1).size() / 2 + 1;
			const QString contents = match.captured(3);
			const bool ordered = match.captured(2) != "*";
			QTextListFormat fmt;
			fmt.setStyle(ordered ? QTextListFormat::ListDecimal : QTextListFormat::ListDisc);
			fmt.setIndent(indent);
			if (!listOut || fmt != listOut->format())
			{
				listOut = cursor.insertList(fmt);
			}
			else
			{
				cursor.insertBlock();
			}
			readInlineText(contents);
			listOut->add(cursor.block());
			return listOut;
		}
		else
		{
			return 0;
		}
	}
开发者ID:02JanDal,项目名称:QMarkdown,代码行数:30,代码来源:QMarkdown.cpp

示例4: 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();
}
开发者ID:cedrus,项目名称:qt4,代码行数:31,代码来源:mainwindow.cpp

示例5: sl_IncreaseListIndent_Triggered

void TextEditWidget::sl_IncreaseListIndent_Triggered() {
	QTextCursor cursor = this->textField->textCursor();
	QTextList *textList = cursor.currentList();
	if (!textList) {return;}

	QTextListFormat format = textList->format();
	format.setIndent(format.indent() + 1);
	textList->setFormat(format);
}
开发者ID:WalterSullivan,项目名称:qNotesManager,代码行数:9,代码来源:texteditwidget.cpp

示例6: QStringLiteral

bool Converter::convertList( QTextCursor *cursor, const QDomElement &element )
{
  const QString styleName = element.attribute( QStringLiteral("style-name") );
  const ListFormatProperty property = mStyleInformation->listProperty( styleName );

  QTextListFormat format;

  if ( cursor->currentList() ) { // we are in a nested list
    format = cursor->currentList()->format();
    format.setIndent( format.indent() + 1 );
  }

  property.apply( &format, 0 );

  QTextList *list = cursor->insertList( format );

  QDomElement itemChild = element.firstChildElement();
  int loop = 0;
  while ( !itemChild.isNull() ) {
    if ( itemChild.tagName() == QLatin1String( "list-item" ) ) {
      loop++;

      QDomElement childElement = itemChild.firstChildElement();
      while ( !childElement.isNull() ) {

        QTextBlock prevBlock;

        if ( childElement.tagName() == QLatin1String( "p" ) ) {
          if ( loop > 1 )
            cursor->insertBlock();

          prevBlock = cursor->block();

          if ( !convertParagraph( cursor, childElement, QTextBlockFormat(), true ) )
            return false;

        } else if ( childElement.tagName() == QLatin1String( "list" ) ) {
          prevBlock = cursor->block();

          if ( !convertList( cursor, childElement ) )
            return false;
        }

        if( prevBlock.isValid() )
            list->add( prevBlock );

        childElement = childElement.nextSiblingElement();
      }
    }

    itemChild = itemChild.nextSiblingElement();
  }

  return true;
}
开发者ID:KDE,项目名称:okular,代码行数:55,代码来源:converter.cpp

示例7: convertList

bool Converter::convertList(QTextCursor *cursor, const QDomElement &element)
{
    const QString styleName = element.attribute("style-name");
    const ListFormatProperty property = m_StyleInformation->listProperty(styleName);

    QTextListFormat format;

    QTextList *list = 0;
    if (cursor->currentList())
    {
        format = cursor->currentList()->format();
    }
    property.apply(&format);

    if (!firstTime)
        list = cursor->insertList(format);
    else
        list = cursor->createList(format);

    firstTime = true;

    QDomElement itemChild = element.firstChildElement();

    while (!itemChild.isNull())
    {
        if (itemChild.tagName() == QLatin1String("list-item"))
        {
            QDomElement childElement = itemChild.firstChildElement();
            while (!childElement.isNull())
            {
                if (childElement.tagName() == QLatin1String("p"))
                {
                    if (!convertParagraph(cursor, childElement, QTextBlockFormat(), true))
                    {
                        return false;
                    }
                    list->add(cursor->block());
                }
                else if (childElement.tagName() == QLatin1String("list"))
                {
                    if (!convertList(cursor, childElement))
                    {
                        return false;
                    }
                    list->add(cursor->block());
                }

                childElement = childElement.nextSiblingElement();
            }
        }        
        itemChild = itemChild.nextSiblingElement();
    }
    firstTime = false;
    return true;
}
开发者ID:madnight,项目名称:chessx,代码行数:55,代码来源:converter.cpp

示例8: updateStoredList

void KoList::updateStoredList(const QTextBlock &block)
{
    if (block.textList()) {
        int level = block.textList()->format().property(KListStyle::Level).toInt();
        QTextList *textList = block.textList();
        QTextListFormat format = textList->format();
        format.setProperty(KListStyle::ListId, (KListStyle::ListIdType)(textList));
        textList->setFormat(format);
        d->textLists[level-1] = textList;
        d->textListIds[level-1] = (KListStyle::ListIdType)textList;
    }
}
开发者ID:KDE,项目名称:koffice,代码行数:12,代码来源:KoList.cpp

示例9: TextTool

void TestChangeTrackedDelete::testListItemDelete()
{
    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(46);
    cursor->setPosition(78, QTextCursor::KeepAnchor);
    ChangeTrackedDeleteCommand *delCommand = new ChangeTrackedDeleteCommand(ChangeTrackedDeleteCommand::NextChar, textTool);
    textEditor->addCommand(delCommand);
    QCOMPARE(document->characterAt(46).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(47);
    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 == false);
    bool deletedListItemStatus;
    deletedListItemStatus  = deletedList->item(0).blockFormat().boolProperty(KDeleteChangeMarker::DeletedListItem);
    QVERIFY(deletedListItemStatus == false);
    deletedListItemStatus  = deletedList->item(1).blockFormat().boolProperty(KDeleteChangeMarker::DeletedListItem);
    QVERIFY(deletedListItemStatus == true);
    delete textTool;
}
开发者ID:KDE,项目名称:koffice,代码行数:50,代码来源:TestChangeTrackedDelete.cpp

示例10: insertList

void MainWindow::insertList()
{
    QTextCursor cursor = editor->textCursor();
    cursor.beginEditBlock();

    QTextList *list = cursor.currentList();
    QTextListFormat listFormat;
    if (list)
        listFormat = list->format();

    listFormat.setStyle(QTextListFormat::ListDisc);
    listFormat.setIndent(listFormat.indent() + 1);
    cursor.insertList(listFormat);

    cursor.endEditBlock();
}
开发者ID:cedrus,项目名称:qt4,代码行数:16,代码来源:mainwindow.cpp

示例11: remove

void KoList::add(const QTextBlock &block, int level)
{
    if (!block.isValid())
        return;

    if (level == 0) { // fetch the first proper level we have
        level = 1; // if nothing works...
        for (int i = 1; i <= 10; i++) {
            if (d->style->hasLevelProperties(i)) {
                level = i;
                break;
            }
        }
    }
    remove(block);

    QTextList *textList = d->textLists.value(level-1).data();
    if (!textList) {
        QTextCursor cursor(block);
        QTextListFormat format = d->style->listFormat(level);
        if (continueNumbering(level))
            format.setProperty(KListStyle::ContinueNumbering, true);
        textList = cursor.createList(format);
        format.setProperty(KListStyle::ListId, (KListStyle::ListIdType)(textList));
        textList->setFormat(format);
        d->textLists[level-1] = textList;
        d->textListIds[level-1] = (KListStyle::ListIdType)textList;
    } else {
        textList->add(block);
    }

    QTextCursor cursor(block);
    QTextBlockFormat blockFormat = cursor.blockFormat();
    if (d->style->styleId()) {
        blockFormat.setProperty(KParagraphStyle::ListStyleId, d->style->styleId());
    } else {
        blockFormat.clearProperty(KParagraphStyle::ListStyleId);
    }
    if (d->type == KoList::TextList) {
        blockFormat.clearProperty(KParagraphStyle::ListLevel);
    } else {
        blockFormat.setProperty(KParagraphStyle::ListLevel, level);
    }
    cursor.setBlockFormat(blockFormat);

    d->invalidate(block);
}
开发者ID:KDE,项目名称:koffice,代码行数:47,代码来源:KoList.cpp

示例12: WARNING

void TextEditWidget::sl_ListButton_Triggered(QAction* action) {
	if (!action) {
		WARNING("Null pointer recieved");
		return;
	}
	QTextListFormat::Style style = (QTextListFormat::Style)action->data().toInt();

	QTextCursor cursor = this->textField->textCursor();
	QTextList *textList = cursor.currentList();
	if (!textList) {
		WARNING("Wrong button state");
		return;
	}
	QTextListFormat format = textList->format();
	format.setStyle(style);
	textList->setFormat(format);
}
开发者ID:WalterSullivan,项目名称:qNotesManager,代码行数:17,代码来源:texteditwidget.cpp

示例13: QTextListFormat

void MainWindow::insertList()
{
    QTextCursor cursor = editor->textCursor();
    cursor.beginEditBlock();

    QTextList *list = cursor.currentList();
//! [0]
    listFormat = QTextListFormat()
    if list:
        listFormat = list.format()
        listFormat.setIndent(listFormat.indent() + 1)

    listFormat.setStyle(QTextListFormat.ListDisc)
    cursor.insertList(listFormat)
//! [0]

    cursor.endEditBlock();
}
开发者ID:BadSingleton,项目名称:pyside2,代码行数:18,代码来源:mainwindow.cpp

示例14: Q_ASSERT

void KoList::setContinueNumbering(int level, bool enable)
{
    Q_ASSERT(level > 0 && level <= 10);
    level = qMax(qMin(level, 10), 1);

    QBitArray bitArray = d->properties[ContinueNumbering].toBitArray();
    if (bitArray.isEmpty())
        bitArray.resize(10);
    bitArray.setBit(level-1, enable);
    d->properties[ContinueNumbering] = bitArray;

    QTextList *textList = d->textLists.value(level-1).data();
    if (!textList)
        return;
    QTextListFormat format = textList->format();
    if (enable) {
        format.setProperty(KListStyle::ContinueNumbering, true);
    } else {
        format.clearProperty(KListStyle::ContinueNumbering);
    }
    textList->setFormat(format);
}
开发者ID:KDE,项目名称:koffice,代码行数:22,代码来源:KoList.cpp

示例15: if

void MRichTextEdit::slotCursorPositionChanged()
{
    QTextList *pTextList = f_textedit->textCursor().currentList();

    if (m_lastBlockList && (pTextList == m_lastBlockList || (pTextList != 0 && m_lastBlockList != 0
                                                             && pTextList->format().style() == m_lastBlockList->format().style())))
    {
        return;
    }

    m_lastBlockList = pTextList;

    if (pTextList)
    {
        QTextListFormat lfmt = pTextList->format();
        if (lfmt.style() == QTextListFormat::ListDisc)
        {
            f_list_bullet->setChecked(true);
            f_list_ordered->setChecked(false);
        }
        else if (lfmt.style() == QTextListFormat::ListDecimal)
        {
            f_list_bullet->setChecked(false);
            f_list_ordered->setChecked(true);
        }
        else
        {
            f_list_bullet->setChecked(false);
            f_list_ordered->setChecked(false);
        }
    }
    else
    {
        f_list_bullet->setChecked(false);
        f_list_ordered->setChecked(false);
    }
}
开发者ID:Iownnoname,项目名称:qt,代码行数:37,代码来源:mrichtextedit.cpp


注:本文中的QTextList类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。