mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-04-19 07:33:11 +02:00
...
This commit is contained in:
parent
ae1f768c1a
commit
abaa0f8cd7
1 changed files with 14 additions and 0 deletions
|
|
@ -57,6 +57,11 @@ def data(self, index, role):
|
|||
except IndexError:
|
||||
pass
|
||||
return NONE
|
||||
|
||||
def index_for_prefix(self, prefix):
|
||||
for i, item in enumerate(self.current_items):
|
||||
if primary_startswith(item, prefix):
|
||||
return self.index(i)
|
||||
# }}}
|
||||
|
||||
class Completer(QListView): # {{{
|
||||
|
|
@ -111,6 +116,12 @@ def next_match(self, previous=False):
|
|||
index = self.model().index(r % self.model().rowCount())
|
||||
self.setCurrentIndex(index)
|
||||
|
||||
def scroll_to(self, orig):
|
||||
if orig:
|
||||
index = self.model().index_for_prefix(orig)
|
||||
if index is not None and index.isValid():
|
||||
self.setCurrentIndex(index)
|
||||
|
||||
def popup(self):
|
||||
p = self
|
||||
m = p.model()
|
||||
|
|
@ -252,12 +263,15 @@ def fset(self, items):
|
|||
# }}}
|
||||
|
||||
def complete(self, show_all=False):
|
||||
orig = None
|
||||
if show_all:
|
||||
orig = self.mcompleter.model().current_prefix
|
||||
self.mcompleter.set_completion_prefix('')
|
||||
if not self.mcompleter.model().current_items:
|
||||
self.mcompleter.hide()
|
||||
return
|
||||
self.mcompleter.popup()
|
||||
self.mcompleter.scroll_to(orig)
|
||||
|
||||
def relayout(self):
|
||||
self.mcompleter.popup()
|
||||
|
|
|
|||
Loading…
Reference in a new issue