From 6d165cbb6174a4d298e245424c3f608efa53c99a Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Mon, 2 Jul 2012 14:04:18 +0200 Subject: [PATCH 1/3] Select the first matching completion when opening a combobox completion popup --- src/calibre/gui2/complete.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/calibre/gui2/complete.py b/src/calibre/gui2/complete.py index 947493cbb9..f4aa70d1f5 100644 --- a/src/calibre/gui2/complete.py +++ b/src/calibre/gui2/complete.py @@ -164,9 +164,19 @@ class MultiCompleteComboBox(EnComboBox): self.setLineEdit(self.le) def showPopup(self): + print 'here' c = self.le._completer + v = unicode(c.currentCompletion()) + print v c.setCompletionPrefix('') c.complete() + i = 0; + while c.setCurrentRow(i): + cr = unicode(c.currentIndex().data().toString()) + if cr.startswith(v): + c.popup().setCurrentIndex(c.currentIndex()) + return + i += 1 def update_items_cache(self, complete_items): self.lineEdit().update_items_cache(complete_items) From 1d9285df7aee841823b45f12b882ba279be2865e Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Mon, 2 Jul 2012 14:19:14 +0200 Subject: [PATCH 2/3] Remove print statements --- src/calibre/gui2/complete.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/calibre/gui2/complete.py b/src/calibre/gui2/complete.py index f4aa70d1f5..86e31ee30c 100644 --- a/src/calibre/gui2/complete.py +++ b/src/calibre/gui2/complete.py @@ -164,10 +164,8 @@ class MultiCompleteComboBox(EnComboBox): self.setLineEdit(self.le) def showPopup(self): - print 'here' c = self.le._completer v = unicode(c.currentCompletion()) - print v c.setCompletionPrefix('') c.complete() i = 0; From 7b502b06f74cf445c2ccf979b164e0531ee37a9b Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Mon, 2 Jul 2012 16:00:30 +0200 Subject: [PATCH 3/3] Limit selection in completion popup to boxes containing less than completion_change_to_ascii_sorting items --- src/calibre/gui2/complete.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/calibre/gui2/complete.py b/src/calibre/gui2/complete.py index 86e31ee30c..6ce6cc2ff0 100644 --- a/src/calibre/gui2/complete.py +++ b/src/calibre/gui2/complete.py @@ -168,13 +168,14 @@ class MultiCompleteComboBox(EnComboBox): v = unicode(c.currentCompletion()) c.setCompletionPrefix('') c.complete() - i = 0; - while c.setCurrentRow(i): - cr = unicode(c.currentIndex().data().toString()) - if cr.startswith(v): - c.popup().setCurrentIndex(c.currentIndex()) - return - i += 1 + if c.model().rowCount() < tweaks['completion_change_to_ascii_sorting']: + i = 0; + while c.setCurrentRow(i): + cr = unicode(c.currentIndex().data().toString()) + if cr.startswith(v): + c.popup().setCurrentIndex(c.currentIndex()) + break + i += 1 def update_items_cache(self, complete_items): self.lineEdit().update_items_cache(complete_items)