fixes and improvements to chat window
This commit is contained in:
parent
70d368c9b7
commit
a80ef7a9ca
3 changed files with 53 additions and 33 deletions
|
@ -115,19 +115,6 @@ void CChannelSet::CreateAndSendChanListForAllConChannels()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CChannelSet::CreateAndSendChatTextForAllConChannels ( const QString& strChatText )
|
|
||||||
{
|
|
||||||
// send chat text to all connected clients
|
|
||||||
for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
|
|
||||||
{
|
|
||||||
if ( vecChannels[i].IsConnected() )
|
|
||||||
{
|
|
||||||
// send message
|
|
||||||
vecChannels[i].CreateChatTextMes ( strChatText );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CChannelSet::CreateAndSendChanListForAllExceptThisChan ( const int iCurChanID )
|
void CChannelSet::CreateAndSendChanListForAllExceptThisChan ( const int iCurChanID )
|
||||||
{
|
{
|
||||||
// create channel list
|
// create channel list
|
||||||
|
@ -154,6 +141,35 @@ void CChannelSet::CreateAndSendChanListForThisChan ( const int iCurChanID )
|
||||||
vecChannels[iCurChanID].CreateConClientListMes ( vecChanInfo );
|
vecChannels[iCurChanID].CreateConClientListMes ( vecChanInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CChannelSet::CreateAndSendChatTextForAllConChannels ( const int iCurChanID,
|
||||||
|
const QString& strChatText )
|
||||||
|
{
|
||||||
|
// create message which is sent to all connected clients -------------------
|
||||||
|
// get client name, if name is empty, use IP address instead
|
||||||
|
QString ChanName = vecChannels[iCurChanID].GetName();
|
||||||
|
if ( ChanName.isEmpty() )
|
||||||
|
{
|
||||||
|
// convert IP address to text and show it
|
||||||
|
const QHostAddress addrTest ( vecChannels[iCurChanID].GetAddress().InetAddr );
|
||||||
|
ChanName = addrTest.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
// add name of the client at the beginning of the message text
|
||||||
|
const QString strActualMessageText =
|
||||||
|
"<" + ChanName + "> " + strChatText;
|
||||||
|
|
||||||
|
|
||||||
|
// send chat text to all connected clients ---------------------------------
|
||||||
|
for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
|
||||||
|
{
|
||||||
|
if ( vecChannels[i].IsConnected() )
|
||||||
|
{
|
||||||
|
// send message
|
||||||
|
vecChannels[i].CreateChatTextMes ( strActualMessageText );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int CChannelSet::GetFreeChan()
|
int CChannelSet::GetFreeChan()
|
||||||
{
|
{
|
||||||
// look for a free channel
|
// look for a free channel
|
||||||
|
|
|
@ -239,7 +239,7 @@ protected:
|
||||||
void CreateAndSendChanListForAllConChannels();
|
void CreateAndSendChanListForAllConChannels();
|
||||||
void CreateAndSendChanListForAllExceptThisChan ( const int iCurChanID );
|
void CreateAndSendChanListForAllExceptThisChan ( const int iCurChanID );
|
||||||
void CreateAndSendChanListForThisChan ( const int iCurChanID );
|
void CreateAndSendChanListForThisChan ( const int iCurChanID );
|
||||||
void CreateAndSendChatTextForAllConChannels ( const QString& strChatText );
|
void CreateAndSendChatTextForAllConChannels ( const int iCurChanID, const QString& strChatText );
|
||||||
|
|
||||||
/* do not use the vector class since CChannel does not have appropriate
|
/* do not use the vector class since CChannel does not have appropriate
|
||||||
copy constructor/operator */
|
copy constructor/operator */
|
||||||
|
@ -278,12 +278,12 @@ public slots:
|
||||||
void OnNameHasChangedCh4() { CreateAndSendChanListForAllConChannels(); }
|
void OnNameHasChangedCh4() { CreateAndSendChanListForAllConChannels(); }
|
||||||
void OnNameHasChangedCh5() { CreateAndSendChanListForAllConChannels(); }
|
void OnNameHasChangedCh5() { CreateAndSendChanListForAllConChannels(); }
|
||||||
|
|
||||||
void OnChatTextReceivedCh0(QString strChatText) { CreateAndSendChatTextForAllConChannels(strChatText); }
|
void OnChatTextReceivedCh0 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 0, strChatText ); }
|
||||||
void OnChatTextReceivedCh1(QString strChatText) { CreateAndSendChatTextForAllConChannels(strChatText); }
|
void OnChatTextReceivedCh1 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 1, strChatText ); }
|
||||||
void OnChatTextReceivedCh2(QString strChatText) { CreateAndSendChatTextForAllConChannels(strChatText); }
|
void OnChatTextReceivedCh2 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 2, strChatText ); }
|
||||||
void OnChatTextReceivedCh3(QString strChatText) { CreateAndSendChatTextForAllConChannels(strChatText); }
|
void OnChatTextReceivedCh3 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 3, strChatText ); }
|
||||||
void OnChatTextReceivedCh4(QString strChatText) { CreateAndSendChatTextForAllConChannels(strChatText); }
|
void OnChatTextReceivedCh4 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 4, strChatText ); }
|
||||||
void OnChatTextReceivedCh5(QString strChatText) { CreateAndSendChatTextForAllConChannels(strChatText); }
|
void OnChatTextReceivedCh5 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 5, strChatText ); }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void MessReadyForSending ( int iChID, CVector<uint8_t> vecMessage );
|
void MessReadyForSending ( int iChID, CVector<uint8_t> vecMessage );
|
||||||
|
|
|
@ -29,7 +29,11 @@
|
||||||
<widget class="QTextBrowser" name="TextViewChatWindow" />
|
<widget class="QTextBrowser" name="TextViewChatWindow" />
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="lineEditLocalInputText" />
|
<widget class="QLineEdit" name="lineEditLocalInputText" >
|
||||||
|
<property name="maxLength" >
|
||||||
|
<number>255</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" >
|
<layout class="QHBoxLayout" >
|
||||||
|
|
Loading…
Add table
Reference in a new issue