mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Completion popup: Fix display of items containing line breaks
This commit is contained in:
parent
eb2360f6aa
commit
fbb5208aac
@ -63,6 +63,11 @@ class CompleteModel(QAbstractListModel): # {{{
|
|||||||
|
|
||||||
def data(self, index, role):
|
def data(self, index, role):
|
||||||
if role == Qt.ItemDataRole.DisplayRole:
|
if role == Qt.ItemDataRole.DisplayRole:
|
||||||
|
try:
|
||||||
|
return self.current_items[index.row()].replace('\n', ' ')
|
||||||
|
except IndexError:
|
||||||
|
pass
|
||||||
|
if role == Qt.ItemDataRole.UserRole:
|
||||||
try:
|
try:
|
||||||
return self.current_items[index.row()]
|
return self.current_items[index.row()]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
@ -106,7 +111,7 @@ class Completer(QListView): # {{{
|
|||||||
if not self.isVisible():
|
if not self.isVisible():
|
||||||
return
|
return
|
||||||
self.hide()
|
self.hide()
|
||||||
text = self.model().data(index, Qt.ItemDataRole.DisplayRole)
|
text = self.model().data(index, Qt.ItemDataRole.UserRole)
|
||||||
self.item_selected.emit(str(text))
|
self.item_selected.emit(str(text))
|
||||||
|
|
||||||
def set_items(self, items):
|
def set_items(self, items):
|
||||||
@ -531,7 +536,7 @@ if __name__ == '__main__':
|
|||||||
d.setLayout(QVBoxLayout())
|
d.setLayout(QVBoxLayout())
|
||||||
le = EditWithComplete(d)
|
le = EditWithComplete(d)
|
||||||
d.layout().addWidget(le)
|
d.layout().addWidget(le)
|
||||||
items = ['one', 'otwo', 'othree', 'ooone', 'ootwo', 'other', 'odd', 'over', 'orc', 'oven', 'owe',
|
items = ['oane\n line2\n line3', 'otwo', 'othree', 'ooone', 'ootwo', 'other', 'odd', 'over', 'orc', 'oven', 'owe',
|
||||||
'oothree', 'a1', 'a2','Edgas', 'Èdgar', 'Édgaq', 'Edgar', 'Édgar']
|
'oothree', 'a1', 'a2','Edgas', 'Èdgar', 'Édgaq', 'Edgar', 'Édgar']
|
||||||
le.update_items_cache(items)
|
le.update_items_cache(items)
|
||||||
le.show_initial_value('')
|
le.show_initial_value('')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user