QStringList completionList is now QMap<QString,QString> completionMap.
}
void TabCompleter::buildCompletionList() {
}
void TabCompleter::buildCompletionList() {
- completionList.clear();
// this is the first time tab is pressed -> build up the completion list and it's iterator
QModelIndex currentIndex = Client::bufferModel()->currentIndex();
if(!currentIndex.data(NetworkModel::BufferIdRole).isValid()) {
// this is the first time tab is pressed -> build up the completion list and it's iterator
QModelIndex currentIndex = Client::bufferModel()->currentIndex();
if(!currentIndex.data(NetworkModel::BufferIdRole).isValid()) {
- nextCompletion = completionList.begin();
+ nextCompletion = completionMap.begin();
QString tabAbbrev = inputLine->text().left(inputLine->cursorPosition()).section(' ',-1,-1);
QRegExp regex(QString("^[^a-zA-Z]*").append(tabAbbrev), Qt::CaseInsensitive);
QString tabAbbrev = inputLine->text().left(inputLine->cursorPosition()).section(' ',-1,-1);
QRegExp regex(QString("^[^a-zA-Z]*").append(tabAbbrev), Qt::CaseInsensitive);
- QMap<QString, QString> sortMap;
foreach(IrcUser *ircUser, channel->ircUsers()) {
if(regex.indexIn(ircUser->nick()) > -1) {
foreach(IrcUser *ircUser, channel->ircUsers()) {
if(regex.indexIn(ircUser->nick()) > -1) {
- sortMap[ircUser->nick().toLower()] = ircUser->nick();
+ completionMap[ircUser->nick().toLower()] = ircUser->nick();
- foreach (QString str, sortMap)
- completionList << str;
- nextCompletion = completionList.begin();
+ nextCompletion = completionMap.begin();
lastCompletionLength = tabAbbrev.length();
}
lastCompletionLength = tabAbbrev.length();
}
- if (nextCompletion != completionList.end()) {
+ if (nextCompletion != completionMap.end()) {
// clear previous completion
for (int i = 0; i < lastCompletionLength; i++) {
inputLine->backspace();
// clear previous completion
for (int i = 0; i < lastCompletionLength; i++) {
inputLine->backspace();
// we're at the end of the list -> start over again
} else {
// we're at the end of the list -> start over again
} else {
- nextCompletion = completionList.begin();
+ if(!completionMap.isEmpty()) {
+ nextCompletion = completionMap.begin();
+ complete();
+ }
#define _TABCOMPLETER_H_
#include <QObject>
#define _TABCOMPLETER_H_
#include <QObject>
+#include <QString>
+#include <QMap>
class InputLine;
class IrcUser;
class InputLine;
class IrcUser;
bool enabled;
QString nickSuffix;
bool enabled;
QString nickSuffix;
- QStringList completionList;
+ QMap<QString, QString> completionMap;
// QStringList completionTemplates;
// QStringList completionTemplates;
- QStringList::Iterator nextCompletion;
+ QMap<QString, QString>::Iterator nextCompletion;
int lastCompletionLength;
void buildCompletionList();
int lastCompletionLength;
void buildCompletionList();