From bd2026458e846d8b17050cbb84cdf6143e16ca80 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 21 Mar 2015 21:58:05 +0000 Subject: [PATCH] improvement of FriendList (Patch from Sehraf) git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8065 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/common/FriendList.cpp | 6 +-- retroshare-gui/src/gui/common/StatusDefs.cpp | 53 ++++++++++++++++++++ retroshare-gui/src/gui/common/StatusDefs.h | 2 + 3 files changed, 58 insertions(+), 3 deletions(-) diff --git a/retroshare-gui/src/gui/common/FriendList.cpp b/retroshare-gui/src/gui/common/FriendList.cpp index 9d5aecd03..b7615180b 100644 --- a/retroshare-gui/src/gui/common/FriendList.cpp +++ b/retroshare-gui/src/gui/common/FriendList.cpp @@ -928,11 +928,11 @@ void FriendList::insertPeers() sText += " - " + customStateString; } - QString connectStateString = StatusDefs::connectStateString(sslDetail); + QString connectStateString = StatusDefs::connectStateWithoutTransportTypeString(sslDetail); if (!isStatusColumnHidden) { sslItem->setText(COLUMN_STATE, connectStateString); } else if (!mHideState && connectStateString.isEmpty() == false) { - sText += " [" + StatusDefs::connectStateString(sslDetail) + "]"; + sText += " [" + connectStateString + "]"; } sslItem->setText( COLUMN_NAME, sText); @@ -956,7 +956,7 @@ void FriendList::insertPeers() /* IP */ - QString sslItemIP = (sslDetail.state & RS_PEER_STATE_CONNECTED)?QString(sslDetail.connectAddr.c_str()):QString("---"); + QString sslItemIP = (sslDetail.state & RS_PEER_STATE_CONNECTED) ? StatusDefs::connectStateIpString(sslDetail) : QString("---"); sslItem->setData(COLUMN_IP, Qt::DisplayRole, QVariant(sslItemIP)); sslItem->setData(COLUMN_IP, ROLE_SORT, sslItemIP); diff --git a/retroshare-gui/src/gui/common/StatusDefs.cpp b/retroshare-gui/src/gui/common/StatusDefs.cpp index 954d1413d..c48a04b31 100644 --- a/retroshare-gui/src/gui/common/StatusDefs.cpp +++ b/retroshare-gui/src/gui/common/StatusDefs.cpp @@ -200,3 +200,56 @@ QString StatusDefs::connectStateString(RsPeerDetails &details) return stateString; } + +QString StatusDefs::connectStateWithoutTransportTypeString(RsPeerDetails &details) +{ + QString stateString; + + switch (details.connectState) { + case 0: + stateString = peerStateString(details.state); + break; + case RS_PEER_CONNECTSTATE_TRYING_TCP: + stateString = qApp->translate("StatusDefs", "Trying TCP"); + break; + case RS_PEER_CONNECTSTATE_TRYING_UDP: + stateString = qApp->translate("StatusDefs", "Trying UDP"); + break; + case RS_PEER_CONNECTSTATE_CONNECTED_TCP: + case RS_PEER_CONNECTSTATE_CONNECTED_UDP: + case RS_PEER_CONNECTSTATE_CONNECTED_TOR: + case RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN: + stateString = qApp->translate("StatusDefs", "Connected"); + break; + } + + return stateString; +} + +QString StatusDefs::connectStateIpString(RsPeerDetails &details) +{ + QString stateString = QString(details.connectAddr.c_str()) + QString(" ["); + + switch (details.connectState) { + case 0: + stateString = peerStateString(details.state); + break; + case RS_PEER_CONNECTSTATE_TRYING_TCP: + case RS_PEER_CONNECTSTATE_CONNECTED_TCP: + stateString += qApp->translate("StatusDefs", "TCP"); + break; + case RS_PEER_CONNECTSTATE_TRYING_UDP: + case RS_PEER_CONNECTSTATE_CONNECTED_UDP: + stateString += qApp->translate("StatusDefs", "UDP"); + break; + case RS_PEER_CONNECTSTATE_CONNECTED_TOR: + stateString += qApp->translate("StatusDefs", "TOR"); + break; + case RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN: + stateString += qApp->translate("StatusDefs", "unkown"); + break; + } + stateString += QString("]"); + + return stateString; +} diff --git a/retroshare-gui/src/gui/common/StatusDefs.h b/retroshare-gui/src/gui/common/StatusDefs.h index f21298428..314208b0c 100644 --- a/retroshare-gui/src/gui/common/StatusDefs.h +++ b/retroshare-gui/src/gui/common/StatusDefs.h @@ -41,6 +41,8 @@ public: static QString peerStateString(int peerState); static QString connectStateString(RsPeerDetails &details); + static QString connectStateWithoutTransportTypeString(RsPeerDetails &details); + static QString connectStateIpString(RsPeerDetails &details); }; #endif