summaryrefslogtreecommitdiffstats
path: root/examples/widgets/tools/treemodelcompleter/treemodelcompleter.cpp
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2019-09-06 20:27:33 +0200
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2019-09-11 20:36:17 +0200
commit3fede6cb547b783377e833c9b269d4cecfe47e61 (patch)
treefb5bbbe2613017487436d669b9ecfe090e29074c /examples/widgets/tools/treemodelcompleter/treemodelcompleter.cpp
parent78437ef0d2d662663bbc827befc849cad5886b63 (diff)
Cleanup QtWidgets (tools) examples
Cleanup QtWidgets tools examples: - use member-init (clang-tidy) - fix includes/don't include QtWidgets globally - include own header first - use nullptr (clang-tidy) - avoid c-style casts - use QVector instead QList - use QItemDelegate instead QStyledItemDelegate Change-Id: Ibe9440cdf711e5cc2138c054864edebe1fc95731 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Diffstat (limited to 'examples/widgets/tools/treemodelcompleter/treemodelcompleter.cpp')
-rw-r--r--examples/widgets/tools/treemodelcompleter/treemodelcompleter.cpp12
1 files changed, 3 insertions, 9 deletions
diff --git a/examples/widgets/tools/treemodelcompleter/treemodelcompleter.cpp b/examples/widgets/tools/treemodelcompleter/treemodelcompleter.cpp
index cab0476e3c..8930c815d5 100644
--- a/examples/widgets/tools/treemodelcompleter/treemodelcompleter.cpp
+++ b/examples/widgets/tools/treemodelcompleter/treemodelcompleter.cpp
@@ -80,26 +80,20 @@ QString TreeModelCompleter::separator() const
//! [3]
QStringList TreeModelCompleter::splitPath(const QString &path) const
{
- if (sep.isNull()) {
- return QCompleter::splitPath(path);
- }
-
- return path.split(sep);
+ return (sep.isNull() ? QCompleter::splitPath(path) : path.split(sep));
}
//! [3]
//! [4]
QString TreeModelCompleter::pathFromIndex(const QModelIndex &index) const
{
- if (sep.isNull()) {
+ if (sep.isNull())
return QCompleter::pathFromIndex(index);
- }
// navigate up and accumulate data
QStringList dataList;
- for (QModelIndex i = index; i.isValid(); i = i.parent()) {
+ for (QModelIndex i = index; i.isValid(); i = i.parent())
dataList.prepend(model()->data(i, completionRole()).toString());
- }
return dataList.join(sep);
}