'This is the event handler for the QCompleter.activated(QString) signal,
it is called when the user selects an item in the completer popup.'

def choose_completion(self, completion):

    if (not completion):
        self._do_text_changed(u'', u'')
        return
    words = self._words()
    if (words and (not self._ends_with_whitespace())):
        words.pop()
    words.append(completion)
    text = core.list2cmdline(words)
    self.setText(text)
    self.changed.emit()
    self._do_text_changed(text, u'')
    self.popup().hide()
