New methods for calculating the count of peers and messages. It should be faster than getting all data in std::list.

Now used in MainWindow.cpp, MessagesDialog.cpp and peerstatus.cpp

void p3Peers::getPeerCount (unsigned int *pnFriendCount, unsigned int *pnOnlineCount);
void p3Msgs::getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox);


git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2898 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-05-13 19:20:40 +00:00
parent e5667a915d
commit 84a87fa11b
15 changed files with 99 additions and 61 deletions

View file

@ -351,19 +351,11 @@ void MainWindow::updateStatus()
if (natstatus)
natstatus->getNATStatus();
std::list<std::string> ids;
rsPeers->getOnlineList(ids);
int online = ids.size();
unsigned int online = 0;
rsPeers->getPeerCount (NULL, &online);
std::list<MsgInfoSummary> msgList;
std::list<MsgInfoSummary>::const_iterator it;
rsMsgs -> getMessageSummaries(msgList);
int newInboxCount = 0;
for(it = msgList.begin(); it != msgList.end(); it++)
if ((it -> msgflags & RS_MSG_BOXMASK) == RS_MSG_INBOX && ((it -> msgflags & RS_MSG_NEW) == RS_MSG_NEW))
newInboxCount ++;
unsigned int newInboxCount = 0;
rsMsgs->getMessageCount (NULL, &newInboxCount, NULL, NULL, NULL);
if(newInboxCount)
messageAction->setIcon(QIcon(QPixmap(":/images/messages_new.png"))) ;

View file

@ -79,12 +79,14 @@ public:
Transfers, /** Transfers page. */
SharedDirectories, /** Shared Directories page. */
Messages, /** Messages page. */
#ifndef RS_RELEASE_VERSION
Links, /** Links page. */
Channels, /** Channels page. */
#endif
Forums, /** Forums page. */
Blogs /** Blogs page. */
#ifdef BLOGS
Blogs, /** Blogs page. */
#endif
};
/** Create main window */

View file

@ -1381,39 +1381,14 @@ void MessagesDialog::filterColumnChanged()
void MessagesDialog::updateMessageSummaryList()
{
std::list<MsgInfoSummary> msgList;
std::list<MsgInfoSummary>::const_iterator it;
unsigned int newInboxCount = 0;
unsigned int newOutboxCount = 0;
unsigned int newDraftCount = 0;
unsigned int newSentboxCount = 0;
unsigned int inboxCount = 0;
rsMsgs -> getMessageSummaries(msgList);
int newInboxCount = 0;
int newOutboxCount = 0;
int newDraftCount = 0;
int newSentboxCount = 0;
int inboxCount = 0;
/*calculating the new messages*/
for(it = msgList.begin(); it != msgList.end(); it++)
{
if ((it -> msgflags & RS_MSG_BOXMASK) == RS_MSG_INBOX)
{
inboxCount ++;
if ((it -> msgflags & RS_MSG_NEW) == RS_MSG_NEW) {
newInboxCount ++;
}
}
if ((it -> msgflags & RS_MSG_BOXMASK) == RS_MSG_OUTBOX)
{
newOutboxCount ++;
}
if ((it -> msgflags & RS_MSG_BOXMASK) == RS_MSG_DRAFTBOX)
{
newDraftCount ++;
}
if ((it -> msgflags & RS_MSG_BOXMASK) == RS_MSG_SENTBOX )
{
newSentboxCount ++;
}
}
/* calculating the new messages */
rsMsgs->getMessageCount (&inboxCount, &newInboxCount, &newOutboxCount, &newDraftCount, &newSentboxCount);
QString textItem;
/*updating the labels in leftcolumn*/

View file

@ -67,8 +67,7 @@ const uint32_t SFI_DEFAULT_PERIOD = (30 * 3600 * 24); /* 30 Days */
/** Constructor */
SubFileItem::SubFileItem(std::string hash, std::string name, std::string path, uint64_t size,
uint32_t flags, std::string srcId)
:QWidget(NULL), mFileHash(hash), mFileName(name), mFileSize(size), mSrcId(srcId),
mPath(path)
:QWidget(NULL), mPath(path), mFileHash(hash), mFileName(name), mFileSize(size), mSrcId(srcId)
{
/* Invoke the Qt Designer generated object setup routine */
setupUi(this);

View file

@ -63,25 +63,21 @@ void PeerStatus::getPeerStatus()
{
/* set users/friends/network */
std::list<std::string> ids;
rsPeers->getOnlineList(ids);
int online = ids.size();
ids.clear();
rsPeers->getFriendList(ids);
int friends = ids.size();
unsigned int nFriendCount = 0;
unsigned int nOnlineCount = 0;
rsPeers->getPeerCount (&nFriendCount, &nOnlineCount);
std::ostringstream out;
out << friends << " ";
out << nFriendCount << " ";
std::ostringstream out2;
out2 << online << " ";
out2 << nOnlineCount << " ";
if (statusPeers)
statusPeers -> setText( tr("<span style=\"color:#000000\"><strong>Friends:</strong></span>") + " " + QString::fromStdString(out.str()) + " | " + tr("<span style=\"color:#0000FF\"><strong>Online:</strong></span>") + " " + QString::fromStdString(out2.str()) );
if (online > 0)
if (nOnlineCount > 0)
{
iconLabel->setPixmap(QPixmap::QPixmap(":/images/user/identity16.png"));
}