From: Hendrik Leppkes Date: Mon, 1 Feb 2010 22:01:05 +0000 (+0100) Subject: Store the type of the current tab completion (user or channel) in the TabCompleter... X-Git-Tag: 0.6-beta1~39 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=49813fa53b34ffa35837d30fd022e2fc72f57eb5;ds=sidebyside Store the type of the current tab completion (user or channel) in the TabCompleter instead of every CompletionKey struct. --- diff --git a/src/uisupport/tabcompleter.cpp b/src/uisupport/tabcompleter.cpp index 751385a1..7426ed4d 100644 --- a/src/uisupport/tabcompleter.cpp +++ b/src/uisupport/tabcompleter.cpp @@ -34,6 +34,7 @@ const Network *TabCompleter::_currentNetwork; BufferId TabCompleter::_currentBufferId; QString TabCompleter::_currentBufferName; +TabCompleter::Type TabCompleter::_completionType; TabCompleter::TabCompleter(MultiLineEdit *_lineEdit) : QObject(_lineEdit), @@ -70,7 +71,7 @@ void TabCompleter::buildCompletionList() { _completionType = ChannelTab; foreach(IrcChannel *ircChannel, _currentNetwork->ircChannels()) { if(regex.indexIn(ircChannel->name()) > -1) - _completionMap[CompletionKey(ircChannel->name(), ChannelTab)] = ircChannel->name(); + _completionMap[ircChannel->name()] = ircChannel->name(); } } else { // user completion @@ -83,16 +84,16 @@ void TabCompleter::buildCompletionList() { return; foreach(IrcUser *ircUser, channel->ircUsers()) { if(regex.indexIn(ircUser->nick()) > -1) - _completionMap[CompletionKey(ircUser->nick().toLower(), UserTab)] = ircUser->nick(); + _completionMap[ircUser->nick().toLower()] = ircUser->nick(); } } break; case BufferInfo::QueryBuffer: if(regex.indexIn(_currentBufferName) > -1) - _completionMap[CompletionKey(_currentBufferName.toLower(), UserTab)] = _currentBufferName; + _completionMap[_currentBufferName.toLower()] = _currentBufferName; case BufferInfo::StatusBuffer: if(!_currentNetwork->myNick().isEmpty() && regex.indexIn(_currentNetwork->myNick()) > -1) - _completionMap[CompletionKey(_currentNetwork->myNick().toLower(), UserTab)] = _currentNetwork->myNick(); + _completionMap[_currentNetwork->myNick().toLower()] = _currentNetwork->myNick(); break; default: return; @@ -161,7 +162,7 @@ bool TabCompleter::eventFilter(QObject *obj, QEvent *event) { // this determines the sort order bool TabCompleter::CompletionKey::operator<(const CompletionKey &other) const { - switch(this->type) { + switch(_completionType) { case UserTab: { IrcUser *thisUser = _currentNetwork->ircUser(this->contents); diff --git a/src/uisupport/tabcompleter.h b/src/uisupport/tabcompleter.h index bb5c0b32..b8461ee7 100644 --- a/src/uisupport/tabcompleter.h +++ b/src/uisupport/tabcompleter.h @@ -35,6 +35,11 @@ class TabCompleter : public QObject { Q_OBJECT public: + enum Type { + UserTab = 0x01, + ChannelTab = 0x02 + }; + explicit TabCompleter(MultiLineEdit *inputLine_); void reset(); @@ -43,15 +48,10 @@ public: virtual bool eventFilter(QObject *obj, QEvent *event); private: - enum Type { - UserTab = 0x01, - ChannelTab = 0x02 - }; struct CompletionKey { - inline CompletionKey(const QString &n, const Type t) { contents = n; type = t; } + inline CompletionKey(const QString &n) { contents = n; } bool operator<(const CompletionKey &other) const; - Type type; QString contents; }; @@ -62,11 +62,11 @@ private: static const Network *_currentNetwork; static BufferId _currentBufferId; static QString _currentBufferName; + static Type _completionType; QMap _completionMap; // QStringList completionTemplates; - Type _completionType; QMap::Iterator _nextCompletion; int _lastCompletionLength;