start chat-implementing in startnetworkgamedialog with only chattools ;)
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user