start chat-implementing in startnetworkgamedialog with only chattools ;)

This commit is contained in:
doitux
2007-10-12 21:16:02 +00:00
parent 78af20482e
commit add4695fbd
5 changed files with 80 additions and 12 deletions
+25 -1
View File
@@ -23,7 +23,7 @@
using namespace std;
ChatTools::ChatTools(QLineEdit* l, QTreeWidget *t) : nickAutoCompletitionCounter(0), myLineEdit(l), myNickTreeWidget(t), myNickStringList(NULL)
ChatTools::ChatTools(QLineEdit* l, QTreeWidget *t, QTextBrowser *b) : nickAutoCompletitionCounter(0), myLineEdit(l), myNickTreeWidget(t), myNickStringList(NULL), myTextBrowser(b)
{
}
@@ -33,6 +33,30 @@ ChatTools::~ChatTools()
}
void ChatTools::sendMessage() {
fillChatLinesHistory(myLineEdit->text());
// myW->getSession().sendChatMessage(myW->lineEdit_ChatInput->text().toUtf8().constData());
myLineEdit->setText("");
}
void ChatTools::receiveMessage(QString playerName, QString message) {
if(myTextBrowser)
myTextBrowser->append(playerName + ": " + message);
}
void ChatTools::clearChat() {
if(myTextBrowser)
myTextBrowser->clear();
}
void ChatTools::checkInputLength(QString string) {
if(string.toUtf8().length() > 120) myLineEdit->setMaxLength(string.length());
}
void ChatTools::fillChatLinesHistory(QString fillString) {
chatLinesHistory << fillString;
+8 -1
View File
@@ -29,12 +29,17 @@ class ChatTools : public QObject
Q_OBJECT
public:
ChatTools(QLineEdit* l, QTreeWidget *t = NULL);
ChatTools(QLineEdit* l, QTreeWidget *t = NULL, QTextBrowser *b = NULL);
~ChatTools();
public slots:
void sendMessage();
void receiveMessage(QString playerName, QString message);
void clearChat();
void checkInputLength(QString string);
void fillChatLinesHistory(QString fillString);
void showChatHistoryIndex(int index);
int getChatLinesHistorySize() { return chatLinesHistory.size(); }
@@ -53,6 +58,8 @@ private:
QLineEdit* myLineEdit;
QTreeWidget *myNickTreeWidget;
QStringList myNickStringList;
QTextBrowser* myTextBrowser;
// friend class GuiWrapper;
};