diff --git a/retroshare-gui/src/gui/common/GroupTreeWidget.cpp b/retroshare-gui/src/gui/common/GroupTreeWidget.cpp index 842a6c96b..bd310e58f 100644 --- a/retroshare-gui/src/gui/common/GroupTreeWidget.cpp +++ b/retroshare-gui/src/gui/common/GroupTreeWidget.cpp @@ -541,6 +541,18 @@ void GroupTreeWidget::setUnreadCount(QTreeWidgetItem *item, int unreadCount) item->setFont(GTW_COLUMN_NAME, itFont); } +void GroupTreeWidget::setCounts(QTreeWidgetItem *item, int unreadCount, int totalCount) +{ + if (item == NULL) { + return; + } + + setUnreadCount(item, unreadCount); + + item->setText(GTW_COLUMN_POSTS, QString::number(totalCount)); + item->setData(GTW_COLUMN_POSTS, ROLE_SORT, totalCount); +} + QTreeWidgetItem *GroupTreeWidget::getItemFromId(const QString &id) { if (id.isEmpty()) { diff --git a/retroshare-gui/src/gui/common/GroupTreeWidget.h b/retroshare-gui/src/gui/common/GroupTreeWidget.h index bccac18e2..ab67b10f0 100644 --- a/retroshare-gui/src/gui/common/GroupTreeWidget.h +++ b/retroshare-gui/src/gui/common/GroupTreeWidget.h @@ -113,6 +113,7 @@ public: void fillGroupItems(QTreeWidgetItem *categoryItem, const QList &itemList); // Set the unread count of an item void setUnreadCount(QTreeWidgetItem *item, int unreadCount); + void setCounts(QTreeWidgetItem *item, int unreadCount, int totalCount); bool isSearchRequestItem(QPoint &point,uint32_t& search_req_id); bool isSearchRequestResult(QPoint &point, QString &group_id, uint32_t& search_req_id); diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp index 2a57147b6..69fb0dcb7 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp @@ -1159,44 +1159,7 @@ void GxsGroupFrameDialog::updateGroupSummary() /*********************** **** **** **** ***********************/ /*********************** **** **** **** ***********************/ -void GxsGroupFrameDialog::updateGroupStatistics(const RsGxsGroupId &groupId) -{ - mGroupStatisticsToUpdate.insert(groupId); - mShouldUpdateGroupStatistics = true; -} -void GxsGroupFrameDialog::updateGroupStatisticsReal(const RsGxsGroupId &groupId) -{ - RsThread::async([this,groupId]() - { - GxsGroupStatistic stats; - - if(! getGroupStatistics(groupId, stats)) - { - std::cerr << __PRETTY_FUNCTION__ << " failed to collect group statistics for group " << groupId << std::endl; - return; - } - - RsQThreadUtils::postToObject( [this,stats, groupId]() - { - /* Here it goes any code you want to be executed on the Qt Gui - * thread, for example to update the data model with new information - * after a blocking call to RetroShare API complete, note that - * Qt::QueuedConnection is important! - */ - - QTreeWidgetItem *item = ui->groupTreeWidget->getItemFromId(QString::fromStdString(stats.mGrpId.toStdString())); - - if (item) - ui->groupTreeWidget->setUnreadCount(item, mCountChildMsgs ? (stats.mNumThreadMsgsUnread + stats.mNumChildMsgsUnread) : stats.mNumThreadMsgsUnread); - - mCachedGroupStats[groupId] = stats; - - getUserNotify()->updateIcon(); - - }, this ); - }); -} void GxsGroupFrameDialog::getServiceStatistics(GxsServiceStatistic& stats) const { @@ -1282,3 +1245,42 @@ void GxsGroupFrameDialog::distantRequestGroupData() checkRequestGroup(group_id) ; } +void GxsGroupFrameDialog::updateGroupStatistics(const RsGxsGroupId &groupId) +{ + mGroupStatisticsToUpdate.insert(groupId); + mShouldUpdateGroupStatistics = true; +} + +void GxsGroupFrameDialog::updateGroupStatisticsReal(const RsGxsGroupId &groupId) +{ + RsThread::async([this,groupId]() + { + GxsGroupStatistic stats; + + if(! getGroupStatistics(groupId, stats)) + { + std::cerr << __PRETTY_FUNCTION__ << " failed to collect group statistics for group " << groupId << std::endl; + return; + } + + RsQThreadUtils::postToObject( [this,stats, groupId]() + { + /* Here it goes any code you want to be executed on the Qt Gui + * thread, for example to update the data model with new information + * after a blocking call to RetroShare API complete, note that + * Qt::QueuedConnection is important! + */ + + QTreeWidgetItem *item = ui->groupTreeWidget->getItemFromId(QString::fromStdString(stats.mGrpId.toStdString())); + + if (item) + // ui->groupTreeWidget->setUnreadCount(item, mCountChildMsgs ? (stats.mNumThreadMsgsUnread + stats.mNumChildMsgsUnread) : stats.mNumThreadMsgsUnread); + ui->groupTreeWidget->setCounts(item, mCountChildMsgs ? (stats.mNumThreadMsgsUnread + stats.mNumChildMsgsUnread) : stats.mNumThreadMsgsUnread, stats.mNumMsgs); + + mCachedGroupStats[groupId] = stats; + + getUserNotify()->updateIcon(); + + }, this ); + }); +}