本文整理汇总了C++中QTextListFormat::indent方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextListFormat::indent方法的具体用法?C++ QTextListFormat::indent怎么用?C++ QTextListFormat::indent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextListFormat
的用法示例。
在下文中一共展示了QTextListFormat::indent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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
}
示例2: sl_DecreaseListIndent_Triggered
void TextEditWidget::sl_DecreaseListIndent_Triggered() {
QTextCursor cursor = this->textField->textCursor();
QTextList *textList = cursor.currentList();
if (!textList) {return;}
QTextListFormat format = textList->format();
if (format.indent() == 0) {return;}
format.setIndent(format.indent() - 1);
textList->setFormat(format);
}
示例3: convertList
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;
}
示例4: orderedListClicked
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();
}
示例5: 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();
}
示例6: frameToString
QString Format::frameToString( QTextFrame *frame )
{
QString out;
QTextFrame::iterator it;
for( it = frame->begin(); it != frame->end(); ++it ) {
QTextBlock block = it.currentBlock();
if ( block.isValid() ) {
out += "<block";
QTextCursor c( block );
QDateTime dt = TextFormats::lastModified( c );
if ( dt.isValid() ) {
out += " lastmodified=\"" + dt.toString( Qt::ISODate ) + "\"";
}
if ( TextFormats::isTitle( c ) ) {
out += " titlestyle=\"title\"";
} else if ( TextFormats::isSubTitle( c ) ) {
out += " titlestyle=\"subtitle\"";
}
QTextBlockFormat blockFormat = block.blockFormat();
if ( blockFormat.isValid() ) {
QTextList *list = block.textList();
if ( list ) {
QTextListFormat f = list->format();
out += " liststyle=\"";
switch( f.style() ) {
default:
case QTextListFormat::ListDisc:
out += "disc";
break;
case QTextListFormat::ListDecimal:
out += "decimal";
break;
}
out += "\"";
out += " listindent=\"" + QString::number( f.indent() ) + "\"";
} else {
if ( blockFormat.indent() != 0 ) {
out += " blockindent=\"" + QString::number( blockFormat.indent() ) +
"\"";
}
}
}
out += ">\n";
QTextBlock::iterator it2;
for( it2 = block.begin(); it2 != block.end(); ++it2 ) {
QTextFragment fragment = it2.fragment();
if ( !fragment.isValid() ) continue;
QString text = fragment.text();
QString outText;
for( int i = 0; i < text.size(); ++i ) {
if ( text.at( i ) == 0xfffc ) {
outText += "<todo status=\"";
QTextImageFormat imageFormat = fragment.charFormat().toImageFormat();
if ( imageFormat.isValid() ) {
if ( imageFormat.name().contains( "done" ) ) outText += "done";
else outText += "todo";
} else {
dbg() << "NO IMAGE FORMAT" << endl;
}
outText += "\"/>";
} else {
outText += escape( QString( text.at( i ) ) );
}
}
out += " <fragment";
QTextCharFormat format = fragment.charFormat();
if ( !format.anchorHref().isEmpty() ) {
out += " link=\"" + escape( format.anchorHref() ) + "\"";
}
if ( format.fontWeight() == QFont::Bold ) {
out += " bold=\"true\"";
}
if ( format.fontItalic() ) {
out += " italic=\"true\"";
}
if ( format.hasProperty( QTextFormat::FontPointSize ) &&
format.fontPointSize() != 10 ) {
out += " fontsize=\"" + QString::number( format.fontPointSize() ) +
"\"";
}
if ( outText.trimmed().isEmpty() ) outText.replace( " ", "[FIXME:space]" );
out += ">" + outText + "</fragment>\n";
}
//.........这里部分代码省略.........