X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=gui%2Fchannelwidgetinput.cpp;h=37ec8f77296026da6b0d3fc21b6b09fe6daa246a;hp=f3276c2adfc2d2b3ab62a1d92a0e6709eb0c24ef;hb=a37f958a6db77af048619b4af1553ef47dca295f;hpb=9cbaab34158d0f2e77c18d6ac055582102812553 diff --git a/gui/channelwidgetinput.cpp b/gui/channelwidgetinput.cpp index f3276c2a..37ec8f77 100644 --- a/gui/channelwidgetinput.cpp +++ b/gui/channelwidgetinput.cpp @@ -19,47 +19,26 @@ ***************************************************************************/ #include "channelwidgetinput.h" -#include ChannelWidgetInput::ChannelWidgetInput(QWidget *parent) : QLineEdit(parent) { idx = 0; - tabMode = false; + //tabMode = false; connect(this, SIGNAL(returnPressed()), this, SLOT(enter())); + TabCompleter *tc = new TabCompleter(this); + tabComplete = tc; + connect(this, SIGNAL(nickListUpdated(QStringList)), tabComplete, SLOT(updateNickList(QStringList))); } void ChannelWidgetInput::keyPressEvent(QKeyEvent * event) { if(event->key() == Qt::Key_Tab) { // Tabcomplete if(text().length() > 0) { - if (not tabMode) { - QString tabAbbrev = text().left(cursorPosition()).section(' ',-1,-1); - tabCompleteList.clear(); - foreach(QString nick, nickList) { - if(nick.toLower().startsWith(tabAbbrev.toLower())) { - tabCompleteList << nick; - } - } - - tabCompleteList.sort(); - lastCompletionLength = tabAbbrev.length(); - tabMode = true; - nextCompletion = tabCompleteList.begin(); - } - if (nextCompletion != tabCompleteList.end()) { - for (int i = 0; i < lastCompletionLength; i++) { - backspace(); - } - insert(*nextCompletion); - lastCompletionLength = nextCompletion->length(); - nextCompletion++; - } else if (tabCompleteList.end() != tabCompleteList.begin()) { - nextCompletion = tabCompleteList.begin(); - } + tabComplete->complete(); } event->accept(); } else { - tabMode = false; + tabComplete->disable(); if(event->key() == Qt::Key_Up) { if(idx > 0) { idx--; setText(history[idx]); } event->accept(); @@ -89,4 +68,5 @@ void ChannelWidgetInput::enter() { void ChannelWidgetInput::updateNickList(QStringList l) { nickList = l; + emit nickListUpdated(l); }