From 74978b77b7074512e27b03ac7210c453efd94720 Mon Sep 17 00:00:00 2001 From: thunder2 Date: Sat, 29 May 2010 21:56:34 +0000 Subject: [PATCH] some optimizations in PeersDialog::insertPeers do not call too much into the libretroshare git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3031 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/PeersDialog.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/retroshare-gui/src/gui/PeersDialog.cpp b/retroshare-gui/src/gui/PeersDialog.cpp index 9bda3e3c0..8ed229b9b 100644 --- a/retroshare-gui/src/gui/PeersDialog.cpp +++ b/retroshare-gui/src/gui/PeersDialog.cpp @@ -373,9 +373,10 @@ void PeersDialog::insertPeers() //add own gpg id, if we have more than on location (ssl client) std::list ownSslContacts; - rsPeers->getSSLChildListOfGPGId(rsPeers->getGPGOwnId(), ownSslContacts); + std::string ownId = rsPeers->getGPGOwnId(); + rsPeers->getSSLChildListOfGPGId(ownId, ownSslContacts); if (ownSslContacts.size() > 0) { - gpgFriends.push_back(rsPeers->getGPGOwnId()); + gpgFriends.push_back(ownId); } /* get a link to the table */ @@ -416,7 +417,7 @@ void PeersDialog::insertPeers() RsPeerDetails detail; if ((!rsPeers->getPeerDetails(*it, detail) || !detail.accept_connection) - && detail.gpg_id != rsPeers->getGPGOwnId()) { + && detail.gpg_id != ownId) { //don't accept anymore connection, remove from the view if (gpg_item) { delete (peertreeWidget->takeTopLevelItem(peertreeWidget->indexOfTopLevelItem(gpg_item))); @@ -488,13 +489,15 @@ void PeersDialog::insertPeers() /* not displayed, used to find back the item */ sslItem -> setText(3, QString::fromStdString(sslDetail.id)); - if (rsMsgs->getCustomStateString(sslDetail.id) != "") { - sslItem -> setText( 0, tr("location : ") + QString::fromStdString(sslDetail.location) + tr(" - ") + QString::fromStdString(rsMsgs->getCustomStateString(sslDetail.id))); - sslItem -> setToolTip( 0, tr("location : ") + QString::fromStdString(sslDetail.location) + tr(" - ") + QString::fromStdString(rsMsgs->getCustomStateString(sslDetail.id))); + QString sText; + std::string customStateString = rsMsgs->getCustomStateString(sslDetail.id); + if (customStateString.empty() == false) { + sText = tr("location : ") + QString::fromStdString(sslDetail.location) + tr(" - ") + QString::fromStdString(customStateString); } else { - sslItem -> setText( 0, tr("location : ") + QString::fromStdString(sslDetail.location)); - sslItem -> setToolTip( 0, tr("location : ") + QString::fromStdString(sslDetail.location)); + sText = tr("location : ") + QString::fromStdString(sslDetail.location); } + sslItem -> setText( 0, sText); + sslItem -> setToolTip( 0, sText); /* not displayed, used to find back the item */ sslItem -> setText(1, QString::fromStdString(sslDetail.autoconnect));