本文整理汇总了C++中QTextListFormat::stringProperty方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextListFormat::stringProperty方法的具体用法?C++ QTextListFormat::stringProperty怎么用?C++ QTextListFormat::stringProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextListFormat
的用法示例。
在下文中一共展示了QTextListFormat::stringProperty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: recalculate
void ListItemsHelper::recalculate()
{
//kDebug(32500);
const QTextListFormat format = m_textList->format();
const KoListStyle::Style listStyle = static_cast<KoListStyle::Style>(m_textList->format().style());
const QString prefix = format.stringProperty(KoListStyle::ListItemPrefix);
const QString suffix = format.stringProperty(KoListStyle::ListItemSuffix);
const int level = format.intProperty(KoListStyle::Level);
int dp = format.intProperty(KoListStyle::DisplayLevel);
if (dp > level)
dp = level;
const int displayLevel = dp ? dp : 1;
int startValue = 1;
if (format.hasProperty(KoListStyle::StartValue))
startValue = format.intProperty(KoListStyle::StartValue);
if (format.boolProperty(KoListStyle::ContinueNumbering)) {
// Look for the index of a previous list of the same numbering style and level
for (QTextBlock tb = m_textList->item(0).previous(); tb.isValid(); tb = tb.previous()) {
if (!tb.textList() || tb.textList() == m_textList)
continue; // no list here or it's the same list; keep looking
QTextListFormat otherFormat = tb.textList()->format();
if (otherFormat.intProperty(KoListStyle::Level) != level)
break; // found a different list but of a different level
if (otherFormat.style() == format.style()) {
if (KoTextBlockData *data = dynamic_cast<KoTextBlockData *>(tb.userData()))
startValue = data->counterIndex() + 1; // Start from previous list value + 1
}
break;
}
}
int index = startValue;
QList<QTextList*> sublistsToRecalculate;
qreal width = format.doubleProperty(KoListStyle::MinimumWidth);
for (int i = 0; i < m_textList->count(); i++) {
QTextBlock tb = m_textList->item(i);
//kDebug(32500) <<" *" << tb.text();
KoTextBlockData *data = dynamic_cast<KoTextBlockData*>(tb.userData());
if (!data) {
data = new KoTextBlockData();
tb.setUserData(data);
}
QTextBlockFormat blockFormat = tb.blockFormat();
if (blockFormat.boolProperty(KoParagraphStyle::UnnumberedListItem)
|| blockFormat.boolProperty(KoParagraphStyle::IsListHeader)) {
data->setCounterText(QString());
data->setPartialCounterText(QString());
continue;
}
if (blockFormat.boolProperty(KoParagraphStyle::RestartListNumbering))
index = format.intProperty(KoListStyle::StartValue);
const int paragIndex = blockFormat.intProperty(KoParagraphStyle::ListStartValue);
if (paragIndex > 0)
index = paragIndex;
//check if this is the first of this level meaning we should start from startvalue
QTextBlock b = tb.previous();
for (;b.isValid(); b = b.previous()) {
if (b.textList() == m_textList)
break; // all fine
if (b.textList() == 0)
continue;
QTextListFormat otherFormat = b.textList()->format();
if (otherFormat.style() != format.style())
continue; // uninteresting for us
if (b.textList()->format().intProperty(KoListStyle::Level) < level) {
index = startValue;
break;
}
}
QString item;
if (displayLevel > 1) {
int checkLevel = level;
int tmpDisplayLevel = displayLevel;
for (QTextBlock b = tb.previous(); tmpDisplayLevel > 1 && b.isValid(); b = b.previous()) {
if (b.textList() == 0)
continue;
QTextListFormat lf = b.textList()->format();
if (lf.style() != format.style())
continue; // uninteresting for us
const int otherLevel = lf.intProperty(KoListStyle::Level);
if (checkLevel <= otherLevel)
continue;
/*if(needsRecalc(b->textList())) {
TODO
} */
KoTextBlockData *otherData = dynamic_cast<KoTextBlockData*>(b.userData());
if (! otherData) {
kWarning(32500) << "Missing KoTextBlockData, Skipping textblock";
continue;
}
if (tmpDisplayLevel - 1 < otherLevel) { // can't just copy it fully since we are
//.........这里部分代码省略.........