Small performance optimization in ForumsDialog when manipulating the read status.

Calculate only processed toplevel items.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3357 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-08-11 08:31:11 +00:00
parent 2b597d4542
commit 2b3fb8e988

View File

@ -1508,7 +1508,7 @@ int ForumsDialog::getSelectedMsgCount(QList<QTreeWidgetItem*> *pRows, QList<QTre
void ForumsDialog::setMsgAsReadUnread(QList<QTreeWidgetItem*> &Rows, bool bRead)
{
QList<QTreeWidgetItem*>::iterator Row;
bool bChanged = false;
std::list<QTreeWidgetItem*> changedItems;
for (Row = Rows.begin(); Row != Rows.end(); Row++) {
uint32_t status = (*Row)->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt();
@ -1527,12 +1527,21 @@ void ForumsDialog::setMsgAsReadUnread(QList<QTreeWidgetItem*> &Rows, bool bRead)
rsForums->setMessageStatus(mCurrForumId, msgId, statusNew, FORUM_MSG_STATUS_READ | FORUM_MSG_STATUS_UNREAD_BY_USER);
(*Row)->setData(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS, statusNew);
bChanged = true;
QTreeWidgetItem *parentItem = *Row;
while (parentItem->parent()) {
parentItem = parentItem->parent();
}
if (std::find(changedItems.begin(), changedItems.end(), parentItem) == changedItems.end()) {
changedItems.push_back(parentItem);
}
}
}
if (bChanged) {
CalculateIconsAndFonts();
if (changedItems.size()) {
for (std::list<QTreeWidgetItem*>::iterator it = changedItems.begin(); it != changedItems.end(); it++) {
CalculateIconsAndFonts(*it);
}
updateMessageSummaryList(mCurrForumId);
}
}