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


C++ QTextListFormat类代码示例

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


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

示例1: 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

示例2: switch

void GraphicTextDialog::textStyle(int styleIndex)
{
    QTextCursor cursor = textEdit->textCursor();

    if(styleIndex != 0) {
        QTextListFormat::Style style = QTextListFormat::ListDisc;

        switch (styleIndex) {
            default:
            case 1:
                style = QTextListFormat::ListDisc;
                break;

            case 2:
                style = QTextListFormat::ListCircle;
                break;

            case 3:
                style = QTextListFormat::ListSquare;
                break;

            case 4:
                style = QTextListFormat::ListDecimal;
                break;

            case 5:
                style = QTextListFormat::ListLowerAlpha;
                break;

            case 6:
                style = QTextListFormat::ListUpperAlpha;
                break;
        }

        cursor.beginEditBlock();

        QTextBlockFormat blockFmt = cursor.blockFormat();

        QTextListFormat listFmt;

        if(cursor.currentList()) {
            listFmt = cursor.currentList()->format();
        } else {
            listFmt.setIndent(blockFmt.indent() + 1);
            blockFmt.setIndent(0);
            cursor.setBlockFormat(blockFmt);
        }

        listFmt.setStyle(style);

        cursor.createList(listFmt);

        cursor.endEditBlock();
    } else {
        // ####
        QTextBlockFormat bfmt;
        bfmt.setObjectIndex(-1);
        cursor.mergeBlockFormat(bfmt);
    }
}
开发者ID:damiansimanuk,项目名称:qucs-qt4,代码行数:60,代码来源:graphictextdialog.cpp

示例3: writeListFormat

void QTextOdfWriter::writeListFormat(QXmlStreamWriter &writer, QTextListFormat format, int formatIndex) const
{
    writer.writeStartElement(textNS, QString::fromLatin1("list-style"));
    writer.writeAttribute(styleNS, QString::fromLatin1("name"), QString::fromLatin1("L%1").arg(formatIndex));

    QTextListFormat::Style style = format.style();
    if (style == QTextListFormat::ListDecimal || style == QTextListFormat::ListLowerAlpha
            || style == QTextListFormat::ListUpperAlpha) {
        writer.writeStartElement(textNS, QString::fromLatin1("list-level-style-number"));
        writer.writeAttribute(styleNS, QString::fromLatin1("num-format"), bulletChar(style));
        writer.writeAttribute(styleNS, QString::fromLatin1("num-suffix"), QString::fromLatin1("."));
    } else {
        writer.writeStartElement(textNS, QString::fromLatin1("list-level-style-bullet"));
        writer.writeAttribute(textNS, QString::fromLatin1("bullet-char"), bulletChar(style));
    }

    writer.writeAttribute(textNS, QString::fromLatin1("level"), QString::number(format.indent()));
    writer.writeEmptyElement(styleNS, QString::fromLatin1("list-level-properties"));
    writer.writeAttribute(foNS, QString::fromLatin1("text-align"), QString::fromLatin1("start"));
    QString spacing = QString::fromLatin1("%1mm").arg(format.indent() * 8);
    writer.writeAttribute(textNS, QString::fromLatin1("space-before"), spacing);
    //writer.writeAttribute(textNS, QString::fromLatin1("min-label-width"), spacing);

    writer.writeEndElement(); // list-level-style-*
    writer.writeEndElement(); // list-style
}
开发者ID:Fale,项目名称:qtmoko,代码行数:26,代码来源:qtextodfwriter.cpp

示例4: textCursor

void KNoteEdit::textList()
{
    QTextCursor c = textCursor();
    c.beginEditBlock();

    if ( m_textList->isChecked() ) {
        QTextListFormat lf;
        QTextBlockFormat bf = c.blockFormat();

        lf.setIndent( bf.indent() + 1 );
        bf.setIndent( 0 );

        lf.setStyle( QTextListFormat::ListDisc );

        c.setBlockFormat( bf );
        c.createList( lf );
    } else {
        QTextBlockFormat bf;
        bf.setObjectIndex( -1 );
        c.setBlockFormat( bf );

    }

    c.endEditBlock();
}
开发者ID:chusopr,项目名称:kdepim-ktimetracker-akonadi,代码行数:25,代码来源:knoteedit.cpp

示例5: switch

//段落标号、编号
void MyChild::setStyle(int style)
{
    QTextCursor cursor = this->textCursor();

    if (style != 0) {
        QTextListFormat::Style stylename = QTextListFormat::ListDisc;

        switch (style) {
            default:
            case 1:
                stylename = QTextListFormat::ListDisc;
                break;
            case 2:
                stylename = QTextListFormat::ListCircle;
                break;
            case 3:
                stylename = QTextListFormat::ListSquare;
                break;
            case 4:
                stylename = QTextListFormat::ListDecimal;
                break;
            case 5:
                stylename = QTextListFormat::ListLowerAlpha;
                break;
            case 6:
                stylename = QTextListFormat::ListUpperAlpha;
                break;
            case 7:
                stylename = QTextListFormat::ListLowerRoman;
                break;
            case 8:
                stylename = QTextListFormat::ListUpperRoman;
                break;
        }

        cursor.beginEditBlock();

        QTextBlockFormat blockFmt = cursor.blockFormat();

        QTextListFormat listFmt;

        if (cursor.currentList()) {
            listFmt = cursor.currentList()->format();
        } else {
            listFmt.setIndent(blockFmt.indent() + 1);
            blockFmt.setIndent(0);
            cursor.setBlockFormat(blockFmt);
        }

        listFmt.setStyle(stylename);

        cursor.createList(listFmt);

        cursor.endEditBlock();
    } else {
        QTextBlockFormat bfmt;
        bfmt.setObjectIndex(-1);
        cursor.mergeBlockFormat(bfmt);
    }
}
开发者ID:Pengfei-Gao,项目名称:develop-reference-data,代码行数:61,代码来源:mychild.cpp

示例6: list

void MRichTextEdit::list(bool checked, QTextListFormat::Style style)
{
    QTextCursor cursor = f_textedit->textCursor();
    cursor.beginEditBlock();

    if (!checked)
    {
        QTextBlockFormat obfmt = cursor.blockFormat();
        QTextBlockFormat bfmt;
        bfmt.setIndent(obfmt.indent());
        cursor.setBlockFormat(bfmt);
    }
    else
    {
        QTextListFormat listFmt;

        if (cursor.currentList())
        {
            listFmt = cursor.currentList()->format();
        }
        listFmt.setStyle(style);
        cursor.createList(listFmt);
    }

    cursor.endEditBlock();
}
开发者ID:Iownnoname,项目名称:qt,代码行数:26,代码来源:mrichtextedit.cpp

示例7: 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

示例8: 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

示例9: level

int KoList::level(const QTextBlock &block)
{
    if (!block.textList())
        return 0;
    int l = block.blockFormat().intProperty(KParagraphStyle::ListLevel);
    if (!l) { // not a numbered-paragraph
        QTextListFormat format = block.textList()->format();
        l = format.intProperty(KListStyle::Level);
    }
    return l;
}
开发者ID:KDE,项目名称:koffice,代码行数:11,代码来源:KoList.cpp

示例10: ListId

// A convenience function to get a listId from a list-format
static KoListStyle::ListIdType ListId(const QTextListFormat &format)
{
    KoListStyle::ListIdType listId;

    if (sizeof(KoListStyle::ListIdType) == sizeof(uint))
        listId = format.property(KoListStyle::ListId).toUInt();
    else
        listId = format.property(KoListStyle::ListId).toULongLong();

    return listId;
}
开发者ID:ChrisJong,项目名称:krita,代码行数:12,代码来源:KoTextWriter_p.cpp

示例11: 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

示例12: switch

void MainWindow::ShowSort(int index)
{
    QTextCursor cursor=ui->sans_text->textCursor();

    if(index!=0)
    {
        QTextListFormat::Style style=QTextListFormat::ListDisc;
        switch(index)                           //设置style属性值
        {
        default:
        case 1:
            style=QTextListFormat::ListDisc; break;
        case 2:
            style=QTextListFormat::ListCircle; break;
        case 3:
            style=QTextListFormat::ListSquare; break;
        case 4:
            style=QTextListFormat::ListDecimal; break;
        case 5:
            style=QTextListFormat::ListLowerAlpha; break;
        case 6:
            style=QTextListFormat::ListUpperAlpha; break;
        case 7:
            style=QTextListFormat::ListLowerRoman; break;
        case 8:
            style=QTextListFormat::ListUpperRoman; break;
        }
        cursor.beginEditBlock();                //设置缩进值

        QTextBlockFormat blockFmt=cursor.blockFormat();
        QTextListFormat listFmt;

        if(cursor.currentList())
        {
            listFmt= cursor.currentList()->format();
        }
        else
        {
            listFmt.setIndent(blockFmt.indent()+1);
            blockFmt.setIndent(0);
            cursor.setBlockFormat(blockFmt);
        }
        listFmt.setStyle(style);
        cursor.createList(listFmt);
        cursor.endEditBlock();
    } else {
        QTextBlockFormat bfmt;
        bfmt.setObjectIndex(-1);
        cursor.mergeBlockFormat(bfmt);
    }
}
开发者ID:ganquan0910,项目名称:qt5-demos,代码行数:51,代码来源:mainwindow.cpp

示例13: visit

        void visit(QTextBlock &block) const {
            QTextBlockFormat format = block.blockFormat();
            // TODO make the 10 configurable.
            format.setLeftMargin(qMax(qreal(0.0), format.leftMargin() - 10));

            if (block.textList()) {
                const QTextListFormat listFormat = block.textList()->format();
                if (format.leftMargin() < listFormat.doubleProperty(KoListStyle::Margin)) {
                    format.setLeftMargin(listFormat.doubleProperty(KoListStyle::Margin));
                }
            }
            QTextCursor cursor(block);
            cursor.setBlockFormat(format);
        }
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:14,代码来源:KoTextEditor_format.cpp

示例14: textCursor

/*!
 * \brief   Changes the list attribute of the selected text to \a v
 */
void QwwRichTextEdit::setList(bool v){
    QTextCursor cur = textCursor();
    if(v){
      QTextListFormat listFormat;
      listFormat.setStyle(QTextListFormat::ListDisc);
      currentList = cur.createList(listFormat);
    } else {
      cur.setBlockFormat(QTextBlockFormat());
  //    cur.movePosition(QTextCursor::NextBlock);
//      cur.insertBlock(QTextBlockFormat());
      setTextCursor(cur);
      currentList = 0;
    }
  }
开发者ID:dewhisna,项目名称:KingJamesPureBibleSearch,代码行数:17,代码来源:qwwrichtextedit.cpp

示例15: cursor

void TextTools::orderedListClicked()
      {
      QTextCharFormat format = cursor()->charFormat();
      QTextListFormat listFormat;
      QTextList* list = cursor()->currentList();
      if (list) {
            listFormat = list->format();
            int indent = listFormat.indent();
            listFormat.setIndent(indent + 1);
            }
      listFormat.setStyle(QTextListFormat::ListDecimal);
      cursor()->insertList(listFormat);
      cursor()->setCharFormat(format);
      updateText();
      }
开发者ID:briff,项目名称:MuseScore,代码行数:15,代码来源:texttools.cpp


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