X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=gui%2Fchannelwidgetinput.cpp;h=813d1c8c67d8da625554cf6ff3395c3e70e581ee;hp=893623d24c209504928bcc08f9c0b5ffd632d655;hb=fd718b6209f1ad2bcd199c44c2dae3b0cb0f633b;hpb=2a068c11e76c7b34afb64d443dbb1afd2e208aaa diff --git a/gui/channelwidgetinput.cpp b/gui/channelwidgetinput.cpp index 893623d2..813d1c8c 100644 --- a/gui/channelwidgetinput.cpp +++ b/gui/channelwidgetinput.cpp @@ -23,26 +23,35 @@ ChannelWidgetInput::ChannelWidgetInput(QWidget *parent) : QLineEdit(parent) { idx = 0; 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_Up) { - if(idx > 0) { idx--; setText(history[idx]); } - event->accept(); - } else if(event->key() == Qt::Key_Down) { - if(idx < history.count()) idx++; - if(idx < history.count()) setText(history[idx]); - else setText(""); - event->accept(); - } else if(event->key() == Qt::Key_Tab) { + if(event->key() == Qt::Key_Tab) { // Tabcomplete - if(cursorPosition() == text().length()) { - - + if(text().length() > 0) { + tabComplete->complete(); } event->accept(); + } else { - QLineEdit::keyPressEvent(event); + tabComplete->disable(); + if(event->key() == Qt::Key_Up) { + if(idx > 0) { idx--; setText(history[idx]); } + event->accept(); + } else if(event->key() == Qt::Key_Down) { + if(idx < history.count()) idx++; + if(idx < history.count()) setText(history[idx]); + else setText(""); + event->accept(); + } else { + QLineEdit::keyPressEvent(event); + } } } @@ -61,4 +70,5 @@ void ChannelWidgetInput::enter() { void ChannelWidgetInput::updateNickList(QStringList l) { nickList = l; + emit nickListUpdated(l); }