- // 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 *)));
- */
-
- completionList.clear();
- QString tabAbbrev = inputLine->text().left(inputLine->cursorPosition()).section(' ',-1,-1);
- completionList.clear();
- foreach(IrcUser *ircUser, channel->ircUsers()) {
- if(ircUser->nick().toLower().startsWith(tabAbbrev.toLower())) {
- completionList << ircUser->nick();
+ // channel completion - add all channels of the current network to the map
+ if(tabAbbrev.startsWith('#')) {
+ _completionType = ChannelTab;
+ foreach(IrcChannel *ircChannel, _currentNetwork->ircChannels()) {
+ if(regex.indexIn(ircChannel->name()) > -1)
+ _completionMap[CompletionKey(ircChannel->name(), ChannelTab)] = ircChannel->name();
+ }
+ } else {
+ // user completion
+ _completionType = UserTab;
+ switch(static_cast<BufferInfo::Type>(currentIndex.data(NetworkModel::BufferTypeRole).toInt())) {
+ case BufferInfo::ChannelBuffer:
+ { // scope is needed for local var declaration
+ IrcChannel *channel = _currentNetwork->ircChannel(_currentBufferName);
+ if(!channel)
+ return;
+ foreach(IrcUser *ircUser, channel->ircUsers()) {
+ if(regex.indexIn(ircUser->nick()) > -1)
+ _completionMap[CompletionKey(ircUser->nick().toLower(), UserTab)] = ircUser->nick();
+ }
+ }
+ break;
+ case BufferInfo::QueryBuffer:
+ if(regex.indexIn(_currentBufferName) > -1)
+ _completionMap[CompletionKey(_currentBufferName.toLower(), UserTab)] = _currentBufferName;
+ case BufferInfo::StatusBuffer:
+ if(!_currentNetwork->myNick().isEmpty() && regex.indexIn(_currentNetwork->myNick()) > -1)
+ _completionMap[CompletionKey(_currentNetwork->myNick().toLower(), UserTab)] = _currentNetwork->myNick();
+ break;
+ default:
+ return;