From 9495648d16d879a75a08cf0d64c2ffb7a93d6f0c Mon Sep 17 00:00:00 2001 From: thunder2 Date: Tue, 6 Jul 2010 21:17:41 +0000 Subject: [PATCH] Optimized call to p3Peers::getPeerCount in MainWindow::updateStatus git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3263 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/MainWindow.cpp | 15 ++++++++------- retroshare-gui/src/gui/statusbar/peerstatus.cpp | 6 +----- retroshare-gui/src/gui/statusbar/peerstatus.h | 2 +- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 933ea498b..fdc115f21 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -382,18 +382,19 @@ void MainWindow::updateStatus() if(RsAutoUpdatePage::eventsLocked()) return ; + unsigned int nFriendCount = 0; + unsigned int nOnlineCount = 0; + rsPeers->getPeerCount (&nFriendCount, &nOnlineCount); + if (ratesstatus) ratesstatus->getRatesStatus(); if (peerstatus) - peerstatus->getPeerStatus(); + peerstatus->getPeerStatus(nFriendCount, nOnlineCount); if (natstatus) natstatus->getNATStatus(); - unsigned int online = 0; - rsPeers->getPeerCount (NULL, &online); - unsigned int newInboxCount = 0; rsMsgs->getMessageCount (NULL, &newInboxCount, NULL, NULL, NULL, NULL); @@ -411,17 +412,17 @@ void MainWindow::updateStatus() trayIcon->setToolTip(tr("RetroShare") + "\n" + tr("You have %1 new message").arg(newInboxCount)); } } - else if (online == 0) + else if (nOnlineCount == 0) { trayIcon->setIcon(QIcon(IMAGE_NOONLINE)); trayIcon->setToolTip(tr("RetroShare")); } - else if (online < 2) + else if (nOnlineCount < 2) { trayIcon->setIcon(QIcon(IMAGE_ONEONLINE)); trayIcon->setToolTip(tr("RetroShare")); } - else if (online < 3) + else if (nOnlineCount < 3) { trayIcon->setIcon(QIcon(IMAGE_TWOONLINE)); trayIcon->setToolTip(tr("RetroShare")); diff --git a/retroshare-gui/src/gui/statusbar/peerstatus.cpp b/retroshare-gui/src/gui/statusbar/peerstatus.cpp index ff3d665b0..eea01f5fb 100644 --- a/retroshare-gui/src/gui/statusbar/peerstatus.cpp +++ b/retroshare-gui/src/gui/statusbar/peerstatus.cpp @@ -59,14 +59,10 @@ PeerStatus::~PeerStatus() { } -void PeerStatus::getPeerStatus() +void PeerStatus::getPeerStatus(unsigned int nFriendCount, unsigned int nOnlineCount) { /* set users/friends/network */ - unsigned int nFriendCount = 0; - unsigned int nOnlineCount = 0; - rsPeers->getPeerCount (&nFriendCount, &nOnlineCount); - std::ostringstream out; out << nFriendCount << " "; diff --git a/retroshare-gui/src/gui/statusbar/peerstatus.h b/retroshare-gui/src/gui/statusbar/peerstatus.h index f575ecab5..7d760d079 100644 --- a/retroshare-gui/src/gui/statusbar/peerstatus.h +++ b/retroshare-gui/src/gui/statusbar/peerstatus.h @@ -34,7 +34,7 @@ public: ~PeerStatus(); - void getPeerStatus( ); + void getPeerStatus(unsigned int nFriendCount, unsigned int nOnlineCount); private: