Simplify FilenamePrompt._insert_text

This commit is contained in:
Florian Bruhin 2016-10-31 16:08:46 +01:00
parent 5b33978259
commit 60c6b7f0ab

View File

@ -573,16 +573,11 @@ class FilenamePrompt(_BasePrompt):
index: The QModelIndex of the selected element.
clicked: Whether the element was clicked.
"""
parts = []
cur = index
while cur.isValid():
parts.append(cur.data())
cur = cur.parent()
path = os.path.normpath(os.path.join(*reversed(parts)))
path = os.path.normpath(self._file_model.filePath(index))
if clicked:
path += os.sep
log.prompt.debug('Clicked {!r} -> {}'.format(parts, path))
log.prompt.debug('Inserting path {}'.format(path))
self._lineedit.setText(path)
self._lineedit.setFocus()
if clicked: