X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=gui%2Fchannelwidgetinput.cpp;h=c4d1a06fa3ae72592b59de811ad32d1814e2c265;hp=f3276c2adfc2d2b3ab62a1d92a0e6709eb0c24ef;hb=b10bb4b6768536f34fd5e7b00cb8755279af135d;hpb=9cbaab34158d0f2e77c18d6ac055582102812553 diff --git a/gui/channelwidgetinput.cpp b/gui/channelwidgetinput.cpp index f3276c2a..c4d1a06f 100644 --- a/gui/channelwidgetinput.cpp +++ b/gui/channelwidgetinput.cpp @@ -19,47 +19,24 @@ ***************************************************************************/ #include "channelwidgetinput.h" -#include ChannelWidgetInput::ChannelWidgetInput(QWidget *parent) : QLineEdit(parent) { idx = 0; - tabMode = false; connect(this, SIGNAL(returnPressed()), this, SLOT(enter())); + tabComplete = new TabCompleter(this); + connect(this, SIGNAL(nickListUpdated(QStringList)), tabComplete, SLOT(updateNickList(QStringList))); +} + +ChannelWidgetInput::~ChannelWidgetInput() { + delete tabComplete; } 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(); - } - } + if(event->key() == Qt::Key_Tab) { // Tabcomplete + 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 +66,5 @@ void ChannelWidgetInput::enter() { void ChannelWidgetInput::updateNickList(QStringList l) { nickList = l; + emit nickListUpdated(l); }