X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=gui%2Ftabcompleter.cpp;h=5b3e97f1d8b5c0c46301aff2a7101d5ffc89ee6f;hp=c9a7860d9dec46b9d11ba7ee4b13618bdd4252e6;hb=b10bb4b6768536f34fd5e7b00cb8755279af135d;hpb=7a0c26e22498cabadd791be32614ba65f69125c3 diff --git a/gui/tabcompleter.cpp b/gui/tabcompleter.cpp index c9a7860d..5b3e97f1 100644 --- a/gui/tabcompleter.cpp +++ b/gui/tabcompleter.cpp @@ -23,6 +23,7 @@ TabCompleter::TabCompleter(QLineEdit *l, QObject *parent) : QObject(parent) { lineEdit = l; enabled = false; + startOfLineSuffix = QString(": "); // TODO make start of line suffix configurable } void TabCompleter::updateNickList(QStringList l) { @@ -30,7 +31,7 @@ void TabCompleter::updateNickList(QStringList l) { } void TabCompleter::updateChannelList(QStringList l) { - + channelList = l; } void TabCompleter::buildCompletionList() { @@ -58,10 +59,22 @@ void TabCompleter::complete() { for (int i = 0; i < lastCompletionLength; i++) { lineEdit->backspace(); } - lineEdit->insert(*nextCompletion + ' '); - lastCompletionLength = nextCompletion->length() + 1; + + // insert completion + lineEdit->insert(*nextCompletion); + + // remember charcount to delete next time and advance to next completion + lastCompletionLength = nextCompletion->length(); nextCompletion++; - } else if (completionList.begin() != completionList.end()) { + + // we're completing the first word of the line + if(lineEdit->text().length() == lastCompletionLength) { + lineEdit->insert(startOfLineSuffix); + lastCompletionLength += 2; + } + + // we're at the end of the list -> start over again + } else { nextCompletion = completionList.begin(); }