Edit Book File List: Fix pre-selection of filename when renaming a file in the root

This commit is contained in:
Kovid Goyal 2015-10-21 20:45:29 +05:30
parent 038630f669
commit eb18b57463

View File

@ -99,7 +99,9 @@ class ItemDelegate(QStyledItemDelegate): # {{{
editor.setText(name) editor.setText(name)
ext_pos = name.rfind('.') ext_pos = name.rfind('.')
slash_pos = name.rfind('/') slash_pos = name.rfind('/')
if ext_pos > -1 and slash_pos > -1 and ext_pos > slash_pos + 1: if slash_pos == -1 and ext_pos > 0:
editor.setSelection(0, ext_pos)
elif ext_pos > -1 and slash_pos > -1 and ext_pos > slash_pos + 1:
editor.setSelection(slash_pos+1, ext_pos - slash_pos - 1) editor.setSelection(slash_pos+1, ext_pos - slash_pos - 1)
else: else:
editor.selectAll() editor.selectAll()