X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=gui%2Fchannelwidgetinput.cpp;h=813d1c8c67d8da625554cf6ff3395c3e70e581ee;hp=f3276c2adfc2d2b3ab62a1d92a0e6709eb0c24ef;hb=fd718b6209f1ad2bcd199c44c2dae3b0cb0f633b;hpb=9cbaab34158d0f2e77c18d6ac055582102812553 diff --git a/gui/channelwidgetinput.cpp b/gui/channelwidgetinput.cpp index f3276c2a..813d1c8c 100644 --- a/gui/channelwidgetinput.cpp +++ b/gui/channelwidgetinput.cpp @@ -19,47 +19,28 @@ ***************************************************************************/ #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(); - } + 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 +70,5 @@ void ChannelWidgetInput::enter() { void ChannelWidgetInput::updateNickList(QStringList l) { nickList = l; + emit nickListUpdated(l); }