diff --git a/src/audiomixerboard.cpp b/src/audiomixerboard.cpp index 2a87897c..817c8a81 100755 --- a/src/audiomixerboard.cpp +++ b/src/audiomixerboard.cpp @@ -438,7 +438,7 @@ QString CAudioMixerBoard::GenFaderText ( CChannelShortInfo& ChanInfo ) const CHostAddress TempAddr = CHostAddress ( QHostAddress ( ChanInfo.iIpAddr ), 0 ); - return TempAddr.GetIpAddressStringNoLastByte(); + return TempAddr.toString ( CHostAddress::SM_IP_NO_LAST_BYTE ); } else { diff --git a/src/connectdlg.cpp b/src/connectdlg.cpp index b950c16c..0f06142e 100755 --- a/src/connectdlg.cpp +++ b/src/connectdlg.cpp @@ -42,7 +42,8 @@ CConnectDlg::CConnectDlg ( QWidget* parent, Qt::WindowFlags f ) ListViewServers->setColumnWidth ( 0, 170 ); ListViewServers->setColumnWidth ( 1, 130 ); ListViewServers->setColumnWidth ( 2, 55 ); - ListViewServers->setColumnWidth ( 3, 80 ); + ListViewServers->setColumnWidth ( 3, 65 ); + ListViewServers->setColumnWidth ( 4, 150 ); ListViewServers->clear(); @@ -130,30 +131,48 @@ void CConnectDlg::SetServerList ( const CHostAddress& InetAddr, pNewListViewItem->setText ( 2, QString().setNum ( vecServerInfo[iIdx].iNumClients ) ); - // store host address, note that for the very first entry which is + // the ping time shall be shown in bold font + QFont CurPingTimeFont = pNewListViewItem->font( 3 ); + CurPingTimeFont.setBold ( true ); + pNewListViewItem->setFont ( 3, CurPingTimeFont ); + + // get the host address, note that for the very first entry which is // the central server, we have to use the receive host address // instead + CHostAddress CurHostAddress; if ( iIdx > 0 ) { - pNewListViewItem->setData ( 0, Qt::UserRole, - vecServerInfo[iIdx].HostAddr.toString() ); + CurHostAddress = vecServerInfo[iIdx].HostAddr; } else { // substitude the receive host address for central server - pNewListViewItem->setData ( 0, Qt::UserRole, InetAddr.toString() ); + CurHostAddress = InetAddr; } + // IP address and port (use IP number without last byte) + // Definition: If the port number is the default port number, we do not + // show it. + if ( vecServerInfo[iIdx].HostAddr.iPort == LLCON_DEFAULT_PORT_NUMBER ) + { + // only show IP number, no port number + pNewListViewItem->setText ( 4, CurHostAddress. + toString ( CHostAddress::SM_IP_NO_LAST_BYTE ) ); + } + else + { + // show IP number and port + pNewListViewItem->setText ( 4, CurHostAddress. + toString ( CHostAddress::SM_IP_NO_LAST_BYTE_PORT ) ); + } -// TEST -pNewListViewItem->setText ( 2, - pNewListViewItem->data ( 0, Qt::UserRole ).toString() ); - - + // store host address + pNewListViewItem->setData ( 0, Qt::UserRole, + CurHostAddress.toString() ); } // start the ping timer since the server list is filled now - TimerPing.start ( PING_UPDATE_TIME_MS ); + TimerPing.start ( PING_UPDATE_TIME_SERVER_LIST_MS ); } void CConnectDlg::OnTimerPing() @@ -179,7 +198,8 @@ void CConnectDlg::OnTimerPing() } void CConnectDlg::SetPingTimeResult ( CHostAddress& InetAddr, - const int iPingTime ) + const int iPingTime, + const int iPingTimeLEDColor ) { // apply the received ping time to the correct server list entry const int iServerListLen = ListViewServers->topLevelItemCount(); @@ -192,19 +212,31 @@ void CConnectDlg::SetPingTimeResult ( CHostAddress& InetAddr, data ( 0, Qt::UserRole ).toString(). compare ( InetAddr.toString() ) ) { - // a ping time was received, set item to visible - ListViewServers->topLevelItem ( iIdx )->setHidden ( false ); + // update the color of the ping time font + switch ( iPingTimeLEDColor ) + { + case MUL_COL_LED_GREEN: + ListViewServers-> + topLevelItem ( iIdx )->setTextColor ( 3, Qt::darkGreen ); + break; -// TEST -QFont test = ListViewServers->topLevelItem ( iIdx )->font( 3 ); -test.setBold ( true ); -ListViewServers->topLevelItem ( iIdx )->setFont ( 3, test ); + case MUL_COL_LED_YELLOW: + ListViewServers-> + topLevelItem ( iIdx )->setTextColor ( 3, Qt::darkYellow ); + break; -ListViewServers->topLevelItem ( iIdx )->setTextColor ( 3, Qt::red ); + case MUL_COL_LED_RED: + ListViewServers-> + topLevelItem ( iIdx )->setTextColor ( 3, Qt::red ); + break; + } // update ping text ListViewServers->topLevelItem ( iIdx )-> setText ( 3, QString().setNum ( iPingTime ) + " ms" ); + + // a ping time was received, set item to visible + ListViewServers->topLevelItem ( iIdx )->setHidden ( false ); } } } diff --git a/src/connectdlg.h b/src/connectdlg.h index 81a98c06..3ed066f6 100755 --- a/src/connectdlg.h +++ b/src/connectdlg.h @@ -59,7 +59,9 @@ public: void SetServerList ( const CHostAddress& InetAddr, const CVector& vecServerInfo ); - void SetPingTimeResult ( CHostAddress& InetAddr, const int iPingTime ); + void SetPingTimeResult ( CHostAddress& InetAddr, + const int iPingTime, + const int iPingTimeLEDColor ); protected: virtual void showEvent ( QShowEvent* ); diff --git a/src/connectdlgbase.ui b/src/connectdlgbase.ui index 39fe2810..a083d6ae 100755 --- a/src/connectdlgbase.ui +++ b/src/connectdlgbase.ui @@ -47,6 +47,11 @@ Ping Time + + + Address + + diff --git a/src/global.h b/src/global.h index c880df63..188c08e3 100755 --- a/src/global.h +++ b/src/global.h @@ -134,6 +134,10 @@ // defines the time interval at which the ping time is updated in the GUI #define PING_UPDATE_TIME_MS 500 // ms +// defines the time interval at which the ping time is updated for the server +// list +#define PING_UPDATE_TIME_SERVER_LIST_MS 2000 // ms + // time-out until a registered server is deleted from the server list if no // new registering was made in minutes #define SERVLIST_TIME_OUT_MINUTES 60 // minutes diff --git a/src/llconclientdlg.cpp b/src/llconclientdlg.cpp index 24ee27ea..9f80f0b5 100755 --- a/src/llconclientdlg.cpp +++ b/src/llconclientdlg.cpp @@ -769,12 +769,28 @@ void CLlconClientDlg::OnPingTimeResult ( int iPingTime ) void CLlconClientDlg::OnCLPingTimeResult ( CHostAddress InetAddr, int iPingTime ) { + // color definition: <= 25 ms green, <= 50 ms yellow, otherwise red + int iPingTimeLEDColor; + if ( iPingTime <= 25 ) + { + iPingTimeLEDColor = MUL_COL_LED_GREEN; + } + else + { + if ( iPingTime <= 50 ) + { + iPingTimeLEDColor = MUL_COL_LED_YELLOW; + } + else + { + iPingTimeLEDColor = MUL_COL_LED_RED; + } + } -// TODO evaluate the background color for the ping time result in the -// table in this function (see function above, there also the LED color -// is calculated so we do the other here, too) - - ConnectDlg.SetPingTimeResult ( InetAddr, iPingTime ); + // update connection dialog server list + ConnectDlg.SetPingTimeResult ( InetAddr, + iPingTime, + iPingTimeLEDColor ); } void CLlconClientDlg::ConnectDisconnect ( const bool bDoStart ) diff --git a/src/llconserverdlgbase.ui b/src/llconserverdlgbase.ui index f453d0b4..acfd8f4b 100755 --- a/src/llconserverdlgbase.ui +++ b/src/llconserverdlgbase.ui @@ -41,7 +41,7 @@ - Client IP : Port + Client IP:Port diff --git a/src/server.cpp b/src/server.cpp index 8765f4dd..0ce240ee 100755 --- a/src/server.cpp +++ b/src/server.cpp @@ -831,8 +831,8 @@ void CServer::CreateAndSendChatTextForAllConChannels ( const int iCurChanID if ( ChanName.isEmpty() ) { // convert IP address to text and show it - ChanName = - vecChannels[iCurChanID].GetAddress().GetIpAddressStringNoLastByte(); + ChanName = vecChannels[iCurChanID].GetAddress(). + toString ( CHostAddress::SM_IP_NO_LAST_BYTE ); } // add time and name of the client at the beginning of the message text and @@ -1114,8 +1114,8 @@ void CServer::WriteHTMLChannelList() { // convert IP address to text and show it, remove last // digits - strCurChanName = - vecChannels[i].GetAddress().GetIpAddressStringNoLastByte(); + strCurChanName = vecChannels[i].GetAddress(). + toString ( CHostAddress::SM_IP_NO_LAST_BYTE ); } streamFileOut << "
  • " << strCurChanName << "
  • " << endl; diff --git a/src/util.h b/src/util.h index 993298fc..447bab8f 100755 --- a/src/util.h +++ b/src/util.h @@ -393,6 +393,13 @@ protected: class CHostAddress { public: + enum EStringMode + { + SM_IP_PORT, + SM_IP_NO_LAST_BYTE, + SM_IP_NO_LAST_BYTE_PORT + }; + CHostAddress() : InetAddr ( static_cast ( 0 ) ), iPort ( 0 ) {} @@ -421,16 +428,25 @@ public: ( CompAddr.iPort == iPort ) ); } - QString GetIpAddressStringNoLastByte() const + QString toString ( const EStringMode eStringMode = SM_IP_PORT ) const { - // remove the last byte of the IP address - return InetAddr.toString().section ( ".", 0, 2 ) + ".x"; - } + QString strReturn = InetAddr.toString(); - QString toString() const - { - // return in the format [IP number]:[port] - return InetAddr.toString() + ":" + QString().setNum ( iPort ); + if ( ( eStringMode == SM_IP_NO_LAST_BYTE ) || + ( eStringMode == SM_IP_NO_LAST_BYTE_PORT ) ) + { + // replace last byte by an "x" + strReturn = strReturn.section ( ".", 0, 2 ) + ".x"; + } + + if ( ( eStringMode == SM_IP_PORT ) || + ( eStringMode == SM_IP_NO_LAST_BYTE_PORT ) ) + { + // add port number after a semicolon + strReturn += ":" + QString().setNum ( iPort ); + } + + return strReturn; } QHostAddress InetAddr;