XBEL examples: construct the text of the separators cleanly
Create the fixed string once and reuse it. Also give a name to the escape code that's its repeated character. Pick-to: 6.6 6.5 Task-number: QTBUG-111228 Change-Id: I3d6416070f1d5490ec137e251daff0e1637fb788 Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
parent
b610c7aa89
commit
97f68cd306
@ -97,10 +97,12 @@ void XbelReader::readTitle(QTreeWidgetItem *item)
|
||||
void XbelReader::readSeparator(QTreeWidgetItem *item)
|
||||
{
|
||||
Q_ASSERT(xml.isStartElement() && xml.name() == "separator"_L1);
|
||||
constexpr char16_t midDot = u'\xB7';
|
||||
static const QString dots(30, midDot);
|
||||
|
||||
QTreeWidgetItem *separator = createChildItem(item);
|
||||
separator->setFlags(item ? item->flags() & ~Qt::ItemIsSelectable : Qt::ItemFlags{});
|
||||
separator->setText(0, QString(30, u'\xB7'));
|
||||
separator->setText(0, dots);
|
||||
xml.skipCurrentElement();
|
||||
}
|
||||
//! [5]
|
||||
|
@ -143,6 +143,8 @@ void XbelTree::parseFolderElement(const QDomElement &element,
|
||||
bool folded = (element.attribute(foldedAttribute()) != QLatin1String("no"));
|
||||
item->setExpanded(!folded);
|
||||
|
||||
constexpr char16_t midDot = u'\xB7';
|
||||
static const QString dots = QString(30, midDot);
|
||||
QDomElement child = element.firstChildElement();
|
||||
while (!child.isNull()) {
|
||||
if (child.tagName() == folderElement()) {
|
||||
@ -161,7 +163,7 @@ void XbelTree::parseFolderElement(const QDomElement &element,
|
||||
} else if (child.tagName() == QLatin1String("separator")) {
|
||||
QTreeWidgetItem *childItem = createItem(child, item);
|
||||
childItem->setFlags(item->flags() & ~(Qt::ItemIsSelectable | Qt::ItemIsEditable));
|
||||
childItem->setText(0, QString(30, u'\xB7'));
|
||||
childItem->setText(0, dots);
|
||||
}
|
||||
child = child.nextSiblingElement();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user