X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=gui%2Fchannelwidgetinput.cpp;h=37ec8f77296026da6b0d3fc21b6b09fe6daa246a;hp=893623d24c209504928bcc08f9c0b5ffd632d655;hb=a37f958a6db77af048619b4af1553ef47dca295f;hpb=2a068c11e76c7b34afb64d443dbb1afd2e208aaa diff --git a/gui/channelwidgetinput.cpp b/gui/channelwidgetinput.cpp index 893623d2..37ec8f77 100644 --- a/gui/channelwidgetinput.cpp +++ b/gui/channelwidgetinput.cpp @@ -22,27 +22,34 @@ ChannelWidgetInput::ChannelWidgetInput(QWidget *parent) : QLineEdit(parent) { idx = 0; + //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_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 +68,5 @@ void ChannelWidgetInput::enter() { void ChannelWidgetInput::updateNickList(QStringList l) { nickList = l; + emit nickListUpdated(l); }