mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Fixed count of new and unread messages for Channels and Posted.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7561 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
3a0e944ecf
commit
37ddbf63cc
@ -1494,8 +1494,10 @@ bool RsGxsDataAccess::getGroupStatistic(GroupStatisticRequest *req)
|
||||
req->mGroupStatistic.mGrpId = req->mGrpId;
|
||||
req->mGroupStatistic.mNumMsgs = msgMetaV.size();
|
||||
req->mGroupStatistic.mTotalSizeOfMsgs = 0;
|
||||
req->mGroupStatistic.mNumMsgsNew = 0;
|
||||
req->mGroupStatistic.mNumMsgsUnread = 0;
|
||||
req->mGroupStatistic.mNumThreadMsgsNew = 0;
|
||||
req->mGroupStatistic.mNumThreadMsgsUnread = 0;
|
||||
req->mGroupStatistic.mNumChildMsgsNew = 0;
|
||||
req->mGroupStatistic.mNumChildMsgsUnread = 0;
|
||||
|
||||
for(int i = 0; i < msgMetaV.size(); i++)
|
||||
{
|
||||
@ -1504,11 +1506,21 @@ bool RsGxsDataAccess::getGroupStatistic(GroupStatisticRequest *req)
|
||||
|
||||
if (IS_MSG_NEW(m->mMsgStatus))
|
||||
{
|
||||
++req->mGroupStatistic.mNumMsgsNew;
|
||||
if (m->mParentId.isNull())
|
||||
{
|
||||
++req->mGroupStatistic.mNumThreadMsgsNew;
|
||||
} else {
|
||||
++req->mGroupStatistic.mNumChildMsgsNew;
|
||||
}
|
||||
}
|
||||
if (IS_MSG_UNREAD(m->mMsgStatus))
|
||||
{
|
||||
++req->mGroupStatistic.mNumMsgsUnread;
|
||||
if (m->mParentId.isNull())
|
||||
{
|
||||
++req->mGroupStatistic.mNumThreadMsgsUnread;
|
||||
} else {
|
||||
++req->mGroupStatistic.mNumChildMsgsUnread;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1526,24 +1538,35 @@ bool RsGxsDataAccess::getServiceStatistic(ServiceStatisticRequest *req)
|
||||
std::map<RsGxsGroupId, RsGxsGrpMetaData*>::iterator mit = grpMeta.begin();
|
||||
|
||||
req->mServiceStatistic.mNumGrps = grpMeta.size();
|
||||
req->mServiceStatistic.mNumMsgs = 0;
|
||||
req->mServiceStatistic.mSizeOfGrps = 0;
|
||||
req->mServiceStatistic.mSizeOfMsgs = 0;
|
||||
req->mServiceStatistic.mNumGrpsSubscribed = 0;
|
||||
req->mServiceStatistic.mNumMsgsNew = 0;
|
||||
req->mServiceStatistic.mNumMsgsUnread = 0;
|
||||
req->mServiceStatistic.mNumThreadMsgsNew = 0;
|
||||
req->mServiceStatistic.mNumThreadMsgsUnread = 0;
|
||||
req->mServiceStatistic.mNumChildMsgsNew = 0;
|
||||
req->mServiceStatistic.mNumChildMsgsUnread = 0;
|
||||
|
||||
for(; mit != grpMeta.end(); mit++)
|
||||
{
|
||||
RsGxsGrpMetaData* m = mit->second;
|
||||
req->mServiceStatistic.mSizeOfGrps += m->mGrpSize + m->serial_size();
|
||||
|
||||
if (IS_GROUP_SUBSCRIBED(m->mSubscribeFlags))
|
||||
{
|
||||
++req->mServiceStatistic.mNumGrpsSubscribed;
|
||||
|
||||
GroupStatisticRequest gr;
|
||||
gr.mGrpId = m->mGroupId;
|
||||
getGroupStatistic(&gr);
|
||||
|
||||
req->mServiceStatistic.mNumMsgs += gr.mGroupStatistic.mNumMsgs;
|
||||
req->mServiceStatistic.mSizeOfMsgs += gr.mGroupStatistic.mTotalSizeOfMsgs;
|
||||
req->mServiceStatistic.mNumGrpsSubscribed += m->mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED ? 1 : 0;
|
||||
req->mServiceStatistic.mNumMsgsNew += gr.mGroupStatistic.mNumMsgsNew;
|
||||
req->mServiceStatistic.mNumMsgsUnread += gr.mGroupStatistic.mNumMsgsUnread;
|
||||
req->mServiceStatistic.mNumThreadMsgsNew += gr.mGroupStatistic.mNumThreadMsgsNew;
|
||||
req->mServiceStatistic.mNumThreadMsgsUnread += gr.mGroupStatistic.mNumThreadMsgsUnread;
|
||||
req->mServiceStatistic.mNumChildMsgsNew += gr.mGroupStatistic.mNumChildMsgsNew;
|
||||
req->mServiceStatistic.mNumChildMsgsUnread += gr.mGroupStatistic.mNumChildMsgsUnread;
|
||||
}
|
||||
|
||||
delete m;
|
||||
}
|
||||
|
@ -139,8 +139,10 @@ public:
|
||||
RsGxsGroupId mGrpId;
|
||||
uint32_t mNumMsgs;
|
||||
uint32_t mTotalSizeOfMsgs;
|
||||
uint32_t mNumMsgsNew;
|
||||
uint32_t mNumMsgsUnread;
|
||||
uint32_t mNumThreadMsgsNew;
|
||||
uint32_t mNumThreadMsgsUnread;
|
||||
uint32_t mNumChildMsgsNew;
|
||||
uint32_t mNumChildMsgsUnread;
|
||||
};
|
||||
|
||||
class GxsServiceStatistic
|
||||
@ -152,8 +154,10 @@ public:
|
||||
uint32_t mSizeOfMsgs;
|
||||
uint32_t mSizeOfGrps;
|
||||
uint32_t mNumGrpsSubscribed;
|
||||
uint32_t mNumMsgsNew;
|
||||
uint32_t mNumMsgsUnread;
|
||||
uint32_t mNumThreadMsgsNew;
|
||||
uint32_t mNumThreadMsgsUnread;
|
||||
uint32_t mNumChildMsgsNew;
|
||||
uint32_t mNumChildMsgsUnread;
|
||||
uint32_t mSizeStore;
|
||||
};
|
||||
|
||||
|
@ -74,6 +74,7 @@ GxsGroupFrameDialog::GxsGroupFrameDialog(RsGxsIfaceHelper *ifaceImpl, QWidget *p
|
||||
ui->setupUi(this);
|
||||
|
||||
mInitialized = false;
|
||||
mCountChildMsgs = false;
|
||||
mYourGroups = NULL;
|
||||
mSubscribedGroups = NULL;
|
||||
mPopularGroups = NULL;
|
||||
@ -897,7 +898,7 @@ void GxsGroupFrameDialog::loadGroupStatistics(const uint32_t &token)
|
||||
return;
|
||||
}
|
||||
|
||||
ui->groupTreeWidget->setUnreadCount(item, stats.mNumMsgsUnread);
|
||||
ui->groupTreeWidget->setUnreadCount(item, mCountChildMsgs ? (stats.mNumThreadMsgsUnread + stats.mNumChildMsgsUnread) : stats.mNumThreadMsgsUnread);
|
||||
}
|
||||
|
||||
/*********************** **** **** **** ***********************/
|
||||
|
@ -169,6 +169,9 @@ private:
|
||||
// void requestGroupSummary_CurrentGroup(const RsGxsGroupId &groupId);
|
||||
// void loadGroupSummary_CurrentGroup(const uint32_t &token);
|
||||
|
||||
protected:
|
||||
bool mCountChildMsgs; // Count unread child messages?
|
||||
|
||||
private:
|
||||
bool mInitialized;
|
||||
QString mSettingsName;
|
||||
|
@ -29,7 +29,9 @@
|
||||
GxsUserNotify::GxsUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent) :
|
||||
UserNotify(parent), TokenResponse()
|
||||
{
|
||||
mNewMessageCount = 0;
|
||||
mNewThreadMessageCount = 0;
|
||||
mNewChildMessageCount = 0;
|
||||
mCountChildMsgs = false;
|
||||
|
||||
mInterface = ifaceImpl;
|
||||
mTokenService = mInterface->getTokenService();
|
||||
@ -51,7 +53,8 @@ GxsUserNotify::~GxsUserNotify()
|
||||
|
||||
void GxsUserNotify::startUpdate()
|
||||
{
|
||||
mNewMessageCount = 0;
|
||||
mNewThreadMessageCount = 0;
|
||||
mNewChildMessageCount = 0;
|
||||
|
||||
uint32_t token;
|
||||
mTokenService->requestServiceStatistic(token);
|
||||
@ -68,7 +71,8 @@ void GxsUserNotify::loadRequest(const TokenQueue *queue, const TokenRequest &req
|
||||
GxsServiceStatistic stats;
|
||||
mInterface->getServiceStatistic(req.mToken, stats);
|
||||
|
||||
mNewMessageCount = stats.mNumMsgsNew;
|
||||
mNewThreadMessageCount = stats.mNumThreadMsgsNew;
|
||||
mNewChildMessageCount = stats.mNumChildMsgsNew;
|
||||
|
||||
update();
|
||||
}
|
||||
|
@ -44,14 +44,18 @@ protected:
|
||||
virtual void startUpdate();
|
||||
|
||||
private:
|
||||
virtual unsigned int getNewCount() { return mNewMessageCount; }
|
||||
virtual unsigned int getNewCount() { return mCountChildMsgs ? (mNewThreadMessageCount + mNewChildMessageCount) : mNewThreadMessageCount; }
|
||||
|
||||
protected:
|
||||
bool mCountChildMsgs; // Count new child messages?
|
||||
|
||||
private:
|
||||
RsGxsIfaceHelper *mInterface;
|
||||
RsTokenService *mTokenService;
|
||||
TokenQueue *mTokenQueue;
|
||||
RsGxsUpdateBroadcastBase *mBase;
|
||||
unsigned int mNewMessageCount;
|
||||
unsigned int mNewThreadMessageCount;
|
||||
unsigned int mNewChildMessageCount;
|
||||
};
|
||||
|
||||
#endif // GXSUSERNOTIFY_H
|
||||
|
@ -25,6 +25,7 @@
|
||||
GxsForumUserNotify::GxsForumUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent) :
|
||||
GxsUserNotify(ifaceImpl, parent)
|
||||
{
|
||||
mCountChildMsgs = true;
|
||||
}
|
||||
|
||||
bool GxsForumUserNotify::hasSetting(QString *name, QString *group)
|
||||
|
@ -30,6 +30,7 @@
|
||||
GxsForumsDialog::GxsForumsDialog(QWidget *parent)
|
||||
: GxsGroupFrameDialog(rsGxsForums, parent)
|
||||
{
|
||||
mCountChildMsgs = true;
|
||||
}
|
||||
|
||||
GxsForumsDialog::~GxsForumsDialog()
|
||||
|
Loading…
Reference in New Issue
Block a user