[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/work/kde4/playground/games/kombination/src
From:       Pino Toscano <toscano.pino () tiscali ! it>
Date:       2005-10-01 10:41:03
Message-ID: 1128163263.265432.16538.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 465934 by pino:

when sending a message, send also the nick who wrote that message


 M  +5 -5      chatwidget.cpp  
 M  +1 -1      chatwidget.h  
 M  +2 -1      client.cpp  
 M  +1 -1      client.h  
 M  +1 -1      kombination.cpp  
 M  +2 -1      player.cpp  
 M  +1 -1      player.h  
 M  +1 -1      server.cpp  


--- branches/work/kde4/playground/games/kombination/src/chatwidget.cpp #465933:465934
@@ -54,9 +54,9 @@
 	textEdit->append(i18n("<font color=\"blue\">* <b>%1</b> has joined the \
game</font>").arg(nick));  }
 
-void chatWidget::addMessage(const QString &message)
+void chatWidget::addMessage(const QString &nick, const QString &message)
 {
-	textEdit->append(message);
+	textEdit->append(i18n("%1 is the nick, %2 is the message", "&lt;<font \
color=\"green\">%1</font>&gt; %2").arg(nick).arg(message));  }
 
 void chatWidget::startGame()
@@ -72,11 +72,11 @@
 
 void chatWidget::sendMessage()
 {
-	if (messageLine->text().trimmed().isEmpty()) return;
-	QString message = i18n("%1 is the nick, %2 is the message", "&lt;%1&gt; \
%2").arg(m_nick).arg(messageLine->text()); +	QString message = \
messageLine->text().trimmed(); +	if (message.isEmpty()) return;
 	emit typedMessage(message);
 	// get the nick and prepend the name:
-	textEdit->append(message);
+	textEdit->append(i18n("%1 is the nick, %2 is the message", "&lt;%1&gt; \
%2").arg(m_nick).arg(message));  messageLine->clear();
 }
 
--- branches/work/kde4/playground/games/kombination/src/chatwidget.h #465933:465934
@@ -28,7 +28,7 @@
 
 	public slots:
 		void addPlayer(const QString &nick);
-		void addMessage(const QString &message);
+		void addMessage(const QString &nick, const QString &message);
 		void startGame();
 		void nextPlayer(const QString &nick, bool isItMe);
 
--- branches/work/kde4/playground/games/kombination/src/client.cpp #465933:465934
@@ -140,8 +140,9 @@
 
 void client::handleMessage()
 {
+	QString nick = m_stream.readLine();
 	QString message = m_stream.readLine();
-	emit gotMessage(message);
+	emit gotMessage(nick, message);
 }
 
 void client::sendMessage(const QString &message)
--- branches/work/kde4/playground/games/kombination/src/client.h #465933:465934
@@ -34,7 +34,7 @@
 	signals:
 		void error(const QString &text);
 		void connected();
-		void gotMessage(const QString &text);
+		void gotMessage(const QString &nick, const QString &text);
 		void newPlayer(const QString &nick);
 		void startGame();
 		void newTile(tile *t);
--- branches/work/kde4/playground/games/kombination/src/kombination.cpp \
#465933:465934 @@ -164,7 +164,7 @@
 	connect(m_client, SIGNAL(connected()), this, SLOT(connected()));
 	connect(m_client, SIGNAL(error(const QString &)), this, SLOT(clientError(const \
QString &)));  connect(m_client, SIGNAL(newPlayer(const QString &)), m_chatWidget, \
                SLOT(addPlayer(const QString &)));
-	connect(m_client, SIGNAL(gotMessage(const QString &)), m_chatWidget, \
SLOT(addMessage(const QString &))); +	connect(m_client, SIGNAL(gotMessage(const \
QString &, const QString &)), m_chatWidget, SLOT(addMessage(const QString &, const \
QString &)));  connect(m_client, SIGNAL(startGame()), m_chatWidget, \
SLOT(startGame()));  connect(m_client, SIGNAL(startGame()), this, SLOT(startGame()));
 	connect(m_client, SIGNAL(newTile(tile *)), m_tileWidget, SLOT(addTile(tile *)));
--- branches/work/kde4/playground/games/kombination/src/player.cpp #465933:465934
@@ -62,9 +62,10 @@
 	//deleteLater();
 }
 
-void player::sendMessage(const QString &message)
+void player::sendMessage(const QString &nick, const QString &message)
 {
 	m_stream << MESSAGE << endl;
+	m_stream << nick << endl;
 	m_stream << message << endl;
 }
 
--- branches/work/kde4/playground/games/kombination/src/player.h #465933:465934
@@ -32,7 +32,7 @@
 
 		void accepted(const QStringList &players);
 		void nickInUse();
-		void sendMessage(const QString &message);
+		void sendMessage(const QString &nick, const QString &message);
 		void startGame(const QList<tile *> &tiles);
 		void addPlayer(const QString &nick);
 		void nextTurn(const QString &nick);
--- branches/work/kde4/playground/games/kombination/src/server.cpp #465933:465934
@@ -104,7 +104,7 @@
 	for (int i = 0; i < m_clients.count(); i++)
 	{
 		aux = m_clients[i];
-		if (aux != p) aux->sendMessage(message);
+		if (aux != p) aux->sendMessage(p->nick(), message);
 	}
 }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic