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.
Task-number: QTBUG-111228
Change-Id: I3d6416070f1d5490ec137e251daff0e1637fb788
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit 97f68cd306
)
This commit is contained in:
parent
03ee1e1002
commit
8bad89cf53
@ -80,10 +80,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]
|
||||
|
@ -153,6 +153,8 @@ void XbelTree::parseFolderElement(const QDomElement &element,
|
||||
bool folded = (element.attribute(foldedAttribute) != "no"_L1);
|
||||
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) {
|
||||
@ -171,7 +173,7 @@ void XbelTree::parseFolderElement(const QDomElement &element,
|
||||
} else if (child.tagName() == "separator"_L1) {
|
||||
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…
Reference in New Issue
Block a user