From: Marcus Eggenberger Date: Fri, 11 Jul 2008 11:49:38 +0000 (+0200) Subject: tabcompleter works now for queries and statusbuffer (own nick) too X-Git-Tag: 0.3.0~281 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=76d08e513d6aad5964786edc49f172d8b9481951 tabcompleter works now for queries and statusbuffer (own nick) too --- diff --git a/src/uisupport/tabcompleter.cpp b/src/uisupport/tabcompleter.cpp index cd82ee2b..cfdf5d4c 100644 --- a/src/uisupport/tabcompleter.cpp +++ b/src/uisupport/tabcompleter.cpp @@ -51,34 +51,37 @@ void TabCompleter::buildCompletionList() { return; NetworkId networkId = currentIndex.data(NetworkModel::NetworkIdRole).value(); - QString channelName = currentIndex.sibling(currentIndex.row(), 0).data().toString(); + QString bufferName = currentIndex.sibling(currentIndex.row(), 0).data().toString(); const Network *network = Client::network(networkId); if(!network) return; - IrcChannel *channel = network->ircChannel(channelName); - if(!channel) - return; - - // FIXME commented for debugging - /* - disconnect(this, SLOT(ircUserJoinedOrParted(IrcUser *))); - connect(channel, SIGNAL(ircUserJoined(IrcUser *)), - this, SLOT(ircUserJoinedOrParted(IrcUser *))); - connect(channel, SIGNAL(ircUserParted(IrcUser *)), - this, SLOT(ircUserJoinedOrParted(IrcUser *))); - */ QString tabAbbrev = inputLine->text().left(inputLine->cursorPosition()).section(' ',-1,-1); QRegExp regex(QString("^[^a-zA-Z]*").append(QRegExp::escape(tabAbbrev)), Qt::CaseInsensitive); - foreach(IrcUser *ircUser, channel->ircUsers()) { - if(regex.indexIn(ircUser->nick()) > -1) { - completionMap[ircUser->nick().toLower()] = ircUser->nick(); + switch(static_cast(currentIndex.data(NetworkModel::BufferTypeRole).toInt())) { + case BufferInfo::ChannelBuffer: + IrcChannel *channel = network->ircChannel(bufferName); + if(!channel) + return; + foreach(IrcUser *ircUser, channel->ircUsers()) { + if(regex.indexIn(ircUser->nick()) > -1) + completionMap[ircUser->nick().toLower()] = ircUser->nick(); } + break; + case BufferInfo::QueryBuffer: + if(regex.indexIn(bufferName) > -1) + completionMap[bufferName.toLower()] = bufferName; + case BufferInfo::StatusBuffer: + if(!network->myNick().isEmpty() && regex.indexIn(network->myNick()) > -1) + completionMap[network->myNick().toLower()] = network->myNick(); + break; + default: + return; } - + nextCompletion = completionMap.begin(); lastCompletionLength = tabAbbrev.length(); }