nick-autocompletition, scrollable chat-history

This commit is contained in:
doitux committed 2007-10-09 07:50:56 +00:00
1 parent 9ba000d7f9
commit 8e8ee03325
8 files changed
+143 -27

No files matched your search

@@ -31,6 +31,12 @@ using namespace std;
LobbyChat::LobbyChat(gameLobbyDialogImpl* l, ConfigFile *c) : myLobby(l), myConfig(c)
{
chatInputCompleter = new QCompleter(myLobby->treeWidget_NickList->model());
chatInputCompleter->setCaseSensitivity(Qt::CaseInsensitive);
chatInputCompleter->setCompletionMode(QCompleter::InlineCompletion);
myLobby->lineEdit_ChatInput->setCompleter(chatInputCompleter);
}
LobbyChat::~LobbyChat()
@@ -42,6 +48,7 @@ void LobbyChat::sendMessage() {
if (myNick.size())
{
fillChatLinesHistory(myLobby->lineEdit_ChatInput->text());
QString tmpMsg(myLobby->lineEdit_ChatInput->text());
if (tmpMsg.size())
{
@@ -237,3 +244,22 @@ void LobbyChat::chatServerError(int errorCode)
// myLobby->textBrowser_ChatDisplay->append(errorMsg);
}
void LobbyChat::fillChatLinesHistory(QString fillString) {
chatLinesHistory << fillString;
if(chatLinesHistory.size() > 50) chatLinesHistory.removeFirst();
// QStringList::const_iterator constIterator;
// for (constIterator = chatLinesHistory.constBegin(); constIterator != chatLinesHistory.constEnd(); ++constIterator) {
// cout << (*constIterator).toLocal8Bit().constData() << endl;
// }
}
void LobbyChat::showChatHistoryIndex(int index) {
if(index <= chatLinesHistory.size() && index > 0) {
// cout << chatLinesHistory.size() << " : " << index << endl;
myLobby->lineEdit_ChatInput->setText(chatLinesHistory.at(chatLinesHistory.size()-(index)));
}
}
@@ -22,6 +22,7 @@
#include <string>
#include <QtCore>
#include <QtGui>
class gameLobbyDialogImpl;
class Session;
@@ -52,12 +53,21 @@ public slots:
void chatError(int errorCode);
void chatServerError(int errorCode);
void fillChatLinesHistory(QString fillString);
void showChatHistoryIndex(int index);
int getChatLinesHistorySize() { return chatLinesHistory.size(); }
private:
gameLobbyDialogImpl *myLobby;
ConfigFile *myConfig;
QString myNick;
QStringList chatLinesHistory;
QCompleter *chatInputCompleter;
// friend class GuiWrapper;
};