mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-28 08:59:37 -05:00
Added display of unread message count in group tree.
Count unread messages by retrieving all messages of all subscribed groups until getGroupStatistic is available. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7439 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
8667cf9f92
commit
199c38b2b8
@ -51,6 +51,7 @@
|
|||||||
#define TOKEN_TYPE_GROUP_SUMMARY 1
|
#define TOKEN_TYPE_GROUP_SUMMARY 1
|
||||||
//#define TOKEN_TYPE_SUBSCRIBE_CHANGE 2
|
//#define TOKEN_TYPE_SUBSCRIBE_CHANGE 2
|
||||||
//#define TOKEN_TYPE_CURRENTGROUP 3
|
//#define TOKEN_TYPE_CURRENTGROUP 3
|
||||||
|
#define TOKEN_TYPE_STATISTICS 4
|
||||||
|
|
||||||
#define MAX_COMMENT_TITLE 32
|
#define MAX_COMMENT_TITLE 32
|
||||||
|
|
||||||
@ -196,6 +197,10 @@ void GxsGroupFrameDialog::updateDisplay(bool complete)
|
|||||||
if (complete || !getGrpIds().empty() || !getGrpIdsMeta().empty()) {
|
if (complete || !getGrpIds().empty() || !getGrpIdsMeta().empty()) {
|
||||||
/* Update group list */
|
/* Update group list */
|
||||||
requestGroupSummary();
|
requestGroupSummary();
|
||||||
|
} else {
|
||||||
|
if (!getMsgIds().empty() || !getMsgIdsMeta().empty()) {
|
||||||
|
updateMessageSummaryList(RsGxsGroupId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -735,37 +740,28 @@ void GxsGroupFrameDialog::updateMessageSummaryList(RsGxsGroupId groupId)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTreeWidgetItem *items[2] = { mYourGroups, mSubscribedGroups };
|
std::list<RsGxsGroupId> groupIds;
|
||||||
|
|
||||||
|
if (groupId.isNull()) {
|
||||||
|
QTreeWidgetItem *items[2] = { mYourGroups, mSubscribedGroups };
|
||||||
for (int item = 0; item < 2; item++) {
|
for (int item = 0; item < 2; item++) {
|
||||||
int child;
|
int child;
|
||||||
int childCount = items[item]->childCount();
|
int childCount = items[item]->childCount();
|
||||||
for (child = 0; child < childCount; child++) {
|
for (child = 0; child < childCount; child++) {
|
||||||
QTreeWidgetItem *childItem = items[item]->child(child);
|
QTreeWidgetItem *childItem = items[item]->child(child);
|
||||||
std::string childId = ui->groupTreeWidget->itemId(childItem).toStdString();
|
QString childId = ui->groupTreeWidget->itemId(childItem);
|
||||||
if (childId.empty()) {
|
if (childId.isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (groupId.isNull() || childId == groupId.toStdString()) {
|
groupIds.push_back(RsGxsGroupId(childId.toLatin1().constData()));
|
||||||
/* calculate unread messages */
|
|
||||||
unsigned int newMessageCount = 0;
|
|
||||||
unsigned int unreadMessageCount = 0;
|
|
||||||
|
|
||||||
//#TODO mInterface->getMessageCount(childId, newMessageCount, unreadMessageCount);
|
|
||||||
|
|
||||||
std::cerr << "IMPLEMENT mInterface->getMessageCount()";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
|
|
||||||
ui->groupTreeWidget->setUnreadCount(childItem, unreadMessageCount);
|
|
||||||
|
|
||||||
if (groupId.isNull() == false) {
|
|
||||||
/* Calculate only this group */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
groupIds.push_back(groupId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
requestGroupStatistics(groupIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************** **** **** **** ***********************/
|
/*********************** **** **** **** ***********************/
|
||||||
@ -877,6 +873,53 @@ void GxsGroupFrameDialog::loadGroupSummary(const uint32_t &token)
|
|||||||
/*********************** **** **** **** ***********************/
|
/*********************** **** **** **** ***********************/
|
||||||
/*********************** **** **** **** ***********************/
|
/*********************** **** **** **** ***********************/
|
||||||
|
|
||||||
|
void GxsGroupFrameDialog::requestGroupStatistics(const std::list<RsGxsGroupId> &groupIds)
|
||||||
|
{
|
||||||
|
// uint32_t token;
|
||||||
|
// GxsServiceStatistic stats;
|
||||||
|
// mInterface->getGroupStatistic(token, stats);
|
||||||
|
// TokenQueue->queueRequest(token, 0, RS_TOKREQ_ANSTYPE_ACK, TOKEN_TYPE_STATISTICS);
|
||||||
|
|
||||||
|
mTokenQueue->cancelActiveRequestTokens(TOKEN_TYPE_STATISTICS);
|
||||||
|
|
||||||
|
RsTokReqOptions opts;
|
||||||
|
opts.mReqType = GXS_REQUEST_TYPE_MSG_META;
|
||||||
|
|
||||||
|
uint32_t token;
|
||||||
|
mTokenQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, TOKEN_TYPE_STATISTICS);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GxsGroupFrameDialog::loadGroupStatistics(const uint32_t &token)
|
||||||
|
{
|
||||||
|
GxsMsgMetaMap msgList;
|
||||||
|
mInterface->getMsgSummary(token, msgList);
|
||||||
|
|
||||||
|
GxsMsgMetaMap::const_iterator groupIt;
|
||||||
|
for (groupIt = msgList.begin(); groupIt != msgList.end(); ++groupIt) {
|
||||||
|
const RsGxsGroupId &groupId = groupIt->first;
|
||||||
|
QTreeWidgetItem *item = ui->groupTreeWidget->getItemFromId(QString::fromStdString(groupId.toStdString()));
|
||||||
|
if (!item) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<RsMsgMetaData> &groupData = groupIt->second;
|
||||||
|
|
||||||
|
unsigned int newCount = 0;
|
||||||
|
std::vector<RsMsgMetaData>::const_iterator msgIt;
|
||||||
|
for (msgIt = groupData.begin(); msgIt != groupData.end(); ++msgIt) {
|
||||||
|
const RsMsgMetaData &metaData = *msgIt;
|
||||||
|
if (IS_MSG_NEW(metaData.mMsgStatus) || IS_MSG_UNREAD(metaData.mMsgStatus)) {
|
||||||
|
++newCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->groupTreeWidget->setUnreadCount(item, newCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*********************** **** **** **** ***********************/
|
||||||
|
/*********************** **** **** **** ***********************/
|
||||||
|
|
||||||
void GxsGroupFrameDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
void GxsGroupFrameDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_GROUPFRAMEDIALOG
|
#ifdef DEBUG_GROUPFRAMEDIALOG
|
||||||
@ -901,6 +944,10 @@ void GxsGroupFrameDialog::loadRequest(const TokenQueue *queue, const TokenReques
|
|||||||
// loadGroupSummary_CurrentGroup(req.mToken);
|
// loadGroupSummary_CurrentGroup(req.mToken);
|
||||||
// break;
|
// break;
|
||||||
|
|
||||||
|
case TOKEN_TYPE_STATISTICS:
|
||||||
|
loadGroupStatistics(req.mToken);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
std::cerr << "GxsGroupFrameDialog::loadRequest() ERROR: INVALID TYPE";
|
std::cerr << "GxsGroupFrameDialog::loadRequest() ERROR: INVALID TYPE";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
@ -147,6 +147,9 @@ private:
|
|||||||
void requestGroupSummary();
|
void requestGroupSummary();
|
||||||
void loadGroupSummary(const uint32_t &token);
|
void loadGroupSummary(const uint32_t &token);
|
||||||
|
|
||||||
|
void requestGroupStatistics(const std::list<RsGxsGroupId> &groupIds);
|
||||||
|
void loadGroupStatistics(const uint32_t &token);
|
||||||
|
|
||||||
// subscribe/unsubscribe ack.
|
// subscribe/unsubscribe ack.
|
||||||
// void acknowledgeSubscribeChange(const uint32_t &token);
|
// void acknowledgeSubscribeChange(const uint32_t &token);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user