diff options
Diffstat (limited to 'examples/widgets/tools/treemodelcompleter/treemodelcompleter.cpp')
-rw-r--r-- | examples/widgets/tools/treemodelcompleter/treemodelcompleter.cpp | 12 |
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); } |