XBEL example: minor simplifications
Pass one function's return as a parameter to another directly.
Use a ternary expression rather than conditional initialization.
Use initializer-list construction instead of appending to an empty
QStringList; and inline the result where it's used.
Task-number: QTBUG-111228
Change-Id: I781aedba8dcc4251193b55d82fe684c9b5da241a
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
(cherry picked from commit 5fd4a65d95
)
This commit is contained in:
parent
cd1ef4db4f
commit
33d7e170e6
@ -70,9 +70,7 @@ void XbelReader::readXBEL()
|
||||
void XbelReader::readTitle(QTreeWidgetItem *item)
|
||||
{
|
||||
Q_ASSERT(xml.isStartElement() && xml.name() == QLatin1String("title"));
|
||||
|
||||
QString title = xml.readElementText();
|
||||
item->setText(0, title);
|
||||
item->setText(0, xml.readElementText());
|
||||
}
|
||||
//! [4]
|
||||
|
||||
@ -130,12 +128,7 @@ void XbelReader::readBookmark(QTreeWidgetItem *item)
|
||||
|
||||
QTreeWidgetItem *XbelReader::createChildItem(QTreeWidgetItem *item)
|
||||
{
|
||||
QTreeWidgetItem *childItem;
|
||||
if (item) {
|
||||
childItem = new QTreeWidgetItem(item);
|
||||
} else {
|
||||
childItem = new QTreeWidgetItem(treeWidget);
|
||||
}
|
||||
QTreeWidgetItem *childItem = item ? new QTreeWidgetItem(item) : new QTreeWidgetItem(treeWidget);
|
||||
childItem->setData(0, Qt::UserRole, xml.name().toString());
|
||||
return childItem;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user