MessengerWindow:

- Display nick and location once at startup and not on every tick.
- Optimized loop of std::list from "for" with iterator to std::find.

PeersDialog:
- Optimized some loop of std::list from "for" with iterator to std::find.


git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3395 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-08-25 18:31:56 +00:00
parent b85d41cdd7
commit dc7dd949ca
2 changed files with 12 additions and 26 deletions

View File

@ -51,6 +51,7 @@
#include <iostream>
#include <sstream>
#include <algorithm>
/* Images for context menu icons */
#define IMAGE_REMOVEFRIEND ":/images/removefriend16.png"
@ -207,6 +208,14 @@ MessengerWindow::MessengerWindow(QWidget* parent, Qt::WFlags flags)
// load settings
processSettings(true);
// add self nick
RsPeerDetails pd;
if (rsPeers->getPeerDetails(rsPeers->getOwnId(),pd)) {
QString titleStr("<span style=\"font-size:14pt; font-weight:500;"
"color:#FFFFFF;\">%1</span>");
ui.nicklabel->setText(titleStr.arg(QString::fromStdString(pd.name) + tr(" - ") + QString::fromStdString(pd.location)));
}
MainWindow *pMainWindow = MainWindow::getInstance();
if (pMainWindow) {
pMainWindow->initializeStatusObject(ui.statuscomboBox, true);
@ -385,14 +394,6 @@ void MessengerWindow::messengertreeWidgetCostumPopupMenu( QPoint point )
void MessengerWindow::updateMessengerDisplay()
{
if (RsAutoUpdatePage::eventsLocked() == false) {
// add self nick and Avatar to Friends.
RsPeerDetails pd;
if (rsPeers->getPeerDetails(rsPeers->getOwnId(),pd)) {
QString titleStr("<span style=\"font-size:14pt; font-weight:500;"
"color:#FFFFFF;\">%1</span>");
ui.nicklabel->setText(titleStr.arg(QString::fromStdString(pd.name) + tr(" - ") + QString::fromStdString(pd.location)));
}
insertPeers();
}
@ -438,15 +439,7 @@ void MessengerWindow::insertPeers()
int index = 0;
while (index < itemCount) {
std::string gpg_widget_id = peertreeWidget->topLevelItem(index)->data(COLUMN_DATA, ROLE_ID).toString().toStdString();
std::list<std::string>::iterator gpgfriendIt;
bool found = false;
for (gpgfriendIt = gpgFriends.begin(); gpgfriendIt != gpgFriends.end(); gpgfriendIt++) {
if (gpg_widget_id == *gpgfriendIt) {
found = true;
break;
}
}
if (!found) {
if (std::find(gpgFriends.begin(), gpgFriends.end(), gpg_widget_id) == gpgFriends.end()) {
delete (peertreeWidget->takeTopLevelItem(index));
// count again
itemCount = peertreeWidget->topLevelItemCount();

View File

@ -59,6 +59,7 @@
#include <sstream>
#include <time.h>
#include <sys/stat.h>
#include <algorithm>
#include <QSound>
@ -496,15 +497,7 @@ void PeersDialog::insertPeers()
int index = 0;
while (index < itemCount) {
std::string gpg_widget_id = (peertreeWidget->topLevelItem(index))->data(COLUMN_DATA, ROLE_ID).toString().toStdString();
std::list<std::string>::iterator gpgfriendIt;
bool found = false;
for (gpgfriendIt = gpgFriends.begin(); gpgfriendIt != gpgFriends.end(); gpgfriendIt++) {
if (gpg_widget_id == *gpgfriendIt) {
found = true;
break;
}
}
if (!found) {
if (std::find(gpgFriends.begin(), gpgFriends.end(), gpg_widget_id) == gpgFriends.end()) {
delete (peertreeWidget->takeTopLevelItem(index));
// count again
itemCount = peertreeWidget->topLevelItemCount();