mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-26 16:09:35 -05:00
removed calls to getServiceStatistics from GxsUserNotify and replaced by info collected by GxsGroupFrameDialog
This commit is contained in:
parent
c60f1d1331
commit
b0e61376f1
@ -239,7 +239,7 @@ public:
|
|||||||
mNumChildMsgsNew = 0;
|
mNumChildMsgsNew = 0;
|
||||||
mNumChildMsgsUnread = 0;
|
mNumChildMsgsUnread = 0;
|
||||||
mSizeStore = 0;
|
mSizeStore = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
uint32_t mNumMsgs;
|
uint32_t mNumMsgs;
|
||||||
|
@ -82,7 +82,7 @@ PostedDialog::~PostedDialog()
|
|||||||
|
|
||||||
UserNotify *PostedDialog::createUserNotify(QObject *parent)
|
UserNotify *PostedDialog::createUserNotify(QObject *parent)
|
||||||
{
|
{
|
||||||
return new PostedUserNotify(rsPosted, parent);
|
return new PostedUserNotify(rsPosted, this, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString PostedDialog::getHelpString() const
|
QString PostedDialog::getHelpString() const
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
#include "PostedUserNotify.h"
|
#include "PostedUserNotify.h"
|
||||||
#include "gui/MainWindow.h"
|
#include "gui/MainWindow.h"
|
||||||
|
|
||||||
PostedUserNotify::PostedUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent) :
|
PostedUserNotify::PostedUserNotify(RsGxsIfaceHelper *ifaceImpl, const GxsGroupFrameDialog *g, QObject *parent) :
|
||||||
GxsUserNotify(ifaceImpl, parent)
|
GxsUserNotify(ifaceImpl, g, parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,10 +34,6 @@ bool PostedUserNotify::hasSetting(QString *name, QString *group)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool PostedUserNotify::getServiceStatistics(GxsServiceStatistic& stat)
|
|
||||||
{
|
|
||||||
return rsPosted->getBoardsServiceStatistics(stat);
|
|
||||||
}
|
|
||||||
|
|
||||||
QIcon PostedUserNotify::getIcon()
|
QIcon PostedUserNotify::getIcon()
|
||||||
{
|
{
|
||||||
|
@ -28,10 +28,9 @@ class PostedUserNotify : public GxsUserNotify
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PostedUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent = 0);
|
PostedUserNotify(RsGxsIfaceHelper *ifaceImpl, const GxsGroupFrameDialog *g, QObject *parent = 0);
|
||||||
|
|
||||||
virtual bool hasSetting(QString *name, QString *group);
|
virtual bool hasSetting(QString *name, QString *group);
|
||||||
virtual bool getServiceStatistics(GxsServiceStatistic& stat) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual QIcon getIcon();
|
virtual QIcon getIcon();
|
||||||
|
@ -1116,7 +1116,7 @@ void GxsGroupFrameDialog::updateGroupStatistics(const RsGxsGroupId &groupId)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RsQThreadUtils::postToObject( [this,stats]()
|
RsQThreadUtils::postToObject( [this,stats, groupId]()
|
||||||
{
|
{
|
||||||
/* Here it goes any code you want to be executed on the Qt Gui
|
/* 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
|
* thread, for example to update the data model with new information
|
||||||
@ -1129,6 +1129,7 @@ void GxsGroupFrameDialog::updateGroupStatistics(const RsGxsGroupId &groupId)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
ui->groupTreeWidget->setUnreadCount(item, mCountChildMsgs ? (stats.mNumThreadMsgsUnread + stats.mNumChildMsgsUnread) : stats.mNumThreadMsgsUnread);
|
ui->groupTreeWidget->setUnreadCount(item, mCountChildMsgs ? (stats.mNumThreadMsgsUnread + stats.mNumChildMsgsUnread) : stats.mNumThreadMsgsUnread);
|
||||||
|
mCachedGroupStats[groupId] = stats;
|
||||||
|
|
||||||
getUserNotify()->updateIcon();
|
getUserNotify()->updateIcon();
|
||||||
|
|
||||||
@ -1136,6 +1137,23 @@ void GxsGroupFrameDialog::updateGroupStatistics(const RsGxsGroupId &groupId)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GxsGroupFrameDialog::getServiceStatistics(GxsServiceStatistic& stats) const
|
||||||
|
{
|
||||||
|
stats = GxsServiceStatistic(); // clears everything
|
||||||
|
|
||||||
|
for(auto it: mCachedGroupStats)
|
||||||
|
{
|
||||||
|
const GxsGroupStatistic& s(it.second);
|
||||||
|
|
||||||
|
stats.mNumMsgs += s.mNumMsgs;
|
||||||
|
stats.mNumGrps += 1;
|
||||||
|
stats.mSizeOfMsgs += s.mTotalSizeOfMsgs;
|
||||||
|
stats.mNumThreadMsgsNew += s.mNumThreadMsgsNew;
|
||||||
|
stats.mNumThreadMsgsUnread += s.mNumThreadMsgsUnread;
|
||||||
|
stats.mNumChildMsgsNew += s.mNumChildMsgsNew ;
|
||||||
|
stats.mNumChildMsgsUnread += s.mNumChildMsgsUnread ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TurtleRequestId GxsGroupFrameDialog::distantSearch(const QString& search_string) // this should be overloaded in the child class
|
TurtleRequestId GxsGroupFrameDialog::distantSearch(const QString& search_string) // this should be overloaded in the child class
|
||||||
{
|
{
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
#include "util/TokenQueue.h"
|
|
||||||
#include "GxsIdTreeWidgetItem.h"
|
#include "GxsIdTreeWidgetItem.h"
|
||||||
#include "GxsGroupDialog.h"
|
#include "GxsGroupDialog.h"
|
||||||
|
|
||||||
@ -80,6 +79,8 @@ public:
|
|||||||
|
|
||||||
virtual void getGroupList(std::map<RsGxsGroupId,RsGroupMetaData> &groups) ;
|
virtual void getGroupList(std::map<RsGxsGroupId,RsGroupMetaData> &groups) ;
|
||||||
|
|
||||||
|
void getServiceStatistics(GxsServiceStatistic& stats) const ;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void showEvent(QShowEvent *event) override;
|
virtual void showEvent(QShowEvent *event) override;
|
||||||
virtual void paintEvent(QPaintEvent *pe) override;
|
virtual void paintEvent(QPaintEvent *pe) override;
|
||||||
@ -175,20 +176,13 @@ private:
|
|||||||
|
|
||||||
virtual uint32_t requestGroupSummaryType() { return GXS_REQUEST_TYPE_GROUP_META; } // request only meta data
|
virtual uint32_t requestGroupSummaryType() { return GXS_REQUEST_TYPE_GROUP_META; } // request only meta data
|
||||||
|
|
||||||
void requestGroupStatistics(const RsGxsGroupId &groupId);
|
|
||||||
void loadGroupStatistics(const uint32_t &token);
|
|
||||||
|
|
||||||
// subscribe/unsubscribe ack.
|
// subscribe/unsubscribe ack.
|
||||||
// void acknowledgeSubscribeChange(const uint32_t &token);
|
|
||||||
|
|
||||||
GxsMessageFrameWidget *messageWidget(const RsGxsGroupId &groupId, bool ownTab);
|
GxsMessageFrameWidget *messageWidget(const RsGxsGroupId &groupId, bool ownTab);
|
||||||
GxsMessageFrameWidget *createMessageWidget(const RsGxsGroupId &groupId);
|
GxsMessageFrameWidget *createMessageWidget(const RsGxsGroupId &groupId);
|
||||||
|
|
||||||
GxsCommentDialog *commentWidget(const RsGxsMessageId &msgId);
|
GxsCommentDialog *commentWidget(const RsGxsMessageId &msgId);
|
||||||
|
|
||||||
// void requestGroupSummary_CurrentGroup(const RsGxsGroupId &groupId);
|
|
||||||
// void loadGroupSummary_CurrentGroup(const uint32_t &token);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void updateSearchResults();
|
void updateSearchResults();
|
||||||
|
|
||||||
@ -220,6 +214,7 @@ private:
|
|||||||
Ui::GxsGroupFrameDialog *ui;
|
Ui::GxsGroupFrameDialog *ui;
|
||||||
|
|
||||||
std::map<RsGxsGroupId,RsGroupMetaData> mCachedGroupMetas;
|
std::map<RsGxsGroupId,RsGroupMetaData> mCachedGroupMetas;
|
||||||
|
std::map<RsGxsGroupId,GxsGroupStatistic> mCachedGroupStats;
|
||||||
|
|
||||||
std::map<uint32_t,QTreeWidgetItem*> mSearchGroupsItems ;
|
std::map<uint32_t,QTreeWidgetItem*> mSearchGroupsItems ;
|
||||||
std::map<uint32_t,std::set<RsGxsGroupId> > mKnownGroups;
|
std::map<uint32_t,std::set<RsGxsGroupId> > mKnownGroups;
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
#define TOKEN_TYPE_STATISTICS 1
|
#define TOKEN_TYPE_STATISTICS 1
|
||||||
|
|
||||||
GxsUserNotify::GxsUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent) : UserNotify(parent)
|
GxsUserNotify::GxsUserNotify(RsGxsIfaceHelper *ifaceImpl, const GxsGroupFrameDialog *g,QObject *parent) : UserNotify(parent), mGroupFrameDialog(g)
|
||||||
{
|
{
|
||||||
mNewThreadMessageCount = 0;
|
mNewThreadMessageCount = 0;
|
||||||
mNewChildMessageCount = 0;
|
mNewChildMessageCount = 0;
|
||||||
@ -40,32 +40,17 @@ void GxsUserNotify::startUpdate()
|
|||||||
mNewThreadMessageCount = 0;
|
mNewThreadMessageCount = 0;
|
||||||
mNewChildMessageCount = 0;
|
mNewChildMessageCount = 0;
|
||||||
|
|
||||||
RsThread::async([this]()
|
|
||||||
{
|
|
||||||
// 1 - get message data from p3GxsForums
|
|
||||||
|
|
||||||
#ifdef DEBUG_FORUMS
|
GxsServiceStatistic stats;
|
||||||
std::cerr << "Retrieving post data for post " << mThreadId << std::endl;
|
mGroupFrameDialog->getServiceStatistics(stats);
|
||||||
#endif
|
|
||||||
|
|
||||||
GxsServiceStatistic stats;
|
/* Here it goes any code you want to be executed on the Qt Gui
|
||||||
|
|
||||||
if(!getServiceStatistics(stats))
|
|
||||||
return;
|
|
||||||
|
|
||||||
RsQThreadUtils::postToObject( [stats,this]()
|
|
||||||
{
|
|
||||||
/* 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
|
* thread, for example to update the data model with new information
|
||||||
* after a blocking call to RetroShare API complete */
|
* after a blocking call to RetroShare API complete */
|
||||||
|
|
||||||
mNewThreadMessageCount = stats.mNumThreadMsgsNew;
|
mNewThreadMessageCount = stats.mNumThreadMsgsNew;
|
||||||
mNewChildMessageCount = stats.mNumChildMsgsNew;
|
mNewChildMessageCount = stats.mNumChildMsgsNew;
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
|
||||||
}, this );
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include "gui/common/UserNotify.h"
|
#include "gui/common/UserNotify.h"
|
||||||
|
#include "gui/gxs/GxsGroupFrameDialog.h"
|
||||||
#include "util/TokenQueue.h"
|
#include "util/TokenQueue.h"
|
||||||
|
|
||||||
struct RsGxsIfaceHelper;
|
struct RsGxsIfaceHelper;
|
||||||
@ -33,12 +34,11 @@ class GxsUserNotify : public UserNotify
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GxsUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent = 0);
|
GxsUserNotify(RsGxsIfaceHelper *ifaceImpl, const GxsGroupFrameDialog *g, QObject *parent = 0);
|
||||||
virtual ~GxsUserNotify();
|
virtual ~GxsUserNotify();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void startUpdate();
|
virtual void startUpdate();
|
||||||
virtual bool getServiceStatistics(GxsServiceStatistic& stat)=0;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual unsigned int getNewCount() { return mCountChildMsgs ? (mNewThreadMessageCount + mNewChildMessageCount) : mNewThreadMessageCount; }
|
virtual unsigned int getNewCount() { return mCountChildMsgs ? (mNewThreadMessageCount + mNewChildMessageCount) : mNewThreadMessageCount; }
|
||||||
@ -48,6 +48,8 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
RsGxsUpdateBroadcastBase *mBase;
|
RsGxsUpdateBroadcastBase *mBase;
|
||||||
|
const GxsGroupFrameDialog *mGroupFrameDialog;
|
||||||
|
|
||||||
unsigned int mNewThreadMessageCount;
|
unsigned int mNewThreadMessageCount;
|
||||||
unsigned int mNewChildMessageCount;
|
unsigned int mNewChildMessageCount;
|
||||||
};
|
};
|
||||||
|
@ -109,7 +109,7 @@ QString GxsChannelDialog::getHelpString() const
|
|||||||
|
|
||||||
UserNotify *GxsChannelDialog::createUserNotify(QObject *parent)
|
UserNotify *GxsChannelDialog::createUserNotify(QObject *parent)
|
||||||
{
|
{
|
||||||
return new GxsChannelUserNotify(rsGxsChannels, parent);
|
return new GxsChannelUserNotify(rsGxsChannels,this, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsChannelDialog::shareOnChannel(const RsGxsGroupId& channel_id,const QList<RetroShareLink>& file_links)
|
void GxsChannelDialog::shareOnChannel(const RsGxsGroupId& channel_id,const QList<RetroShareLink>& file_links)
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
#include "GxsChannelUserNotify.h"
|
#include "GxsChannelUserNotify.h"
|
||||||
#include "gui/MainWindow.h"
|
#include "gui/MainWindow.h"
|
||||||
|
|
||||||
GxsChannelUserNotify::GxsChannelUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent) :
|
GxsChannelUserNotify::GxsChannelUserNotify(RsGxsIfaceHelper *ifaceImpl, const GxsGroupFrameDialog *g, QObject *parent) :
|
||||||
GxsUserNotify(ifaceImpl, parent)
|
GxsUserNotify(ifaceImpl, g, parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,11 +35,6 @@ bool GxsChannelUserNotify::hasSetting(QString *name, QString *group)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GxsChannelUserNotify::getServiceStatistics(GxsServiceStatistic& stat)
|
|
||||||
{
|
|
||||||
return rsGxsChannels->getChannelServiceStatistics(stat);
|
|
||||||
}
|
|
||||||
|
|
||||||
QIcon GxsChannelUserNotify::getIcon()
|
QIcon GxsChannelUserNotify::getIcon()
|
||||||
{
|
{
|
||||||
return QIcon(":/icons/png/channel.png");
|
return QIcon(":/icons/png/channel.png");
|
||||||
|
@ -22,16 +22,16 @@
|
|||||||
#define GXSCHANNELUSERNOTIFY_H
|
#define GXSCHANNELUSERNOTIFY_H
|
||||||
|
|
||||||
#include "gui/gxs/GxsUserNotify.h"
|
#include "gui/gxs/GxsUserNotify.h"
|
||||||
|
#include "gui/gxs/GxsGroupFrameDialog.h"
|
||||||
|
|
||||||
class GxsChannelUserNotify : public GxsUserNotify
|
class GxsChannelUserNotify : public GxsUserNotify
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GxsChannelUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent = 0);
|
GxsChannelUserNotify(RsGxsIfaceHelper *ifaceImpl, const GxsGroupFrameDialog *g, QObject *parent = 0);
|
||||||
|
|
||||||
virtual bool hasSetting(QString *name, QString *group);
|
virtual bool hasSetting(QString *name, QString *group);
|
||||||
virtual bool getServiceStatistics(GxsServiceStatistic& stat) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual QIcon getIcon();
|
virtual QIcon getIcon();
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
#include "GxsForumUserNotify.h"
|
#include "GxsForumUserNotify.h"
|
||||||
#include "gui/MainWindow.h"
|
#include "gui/MainWindow.h"
|
||||||
|
|
||||||
GxsForumUserNotify::GxsForumUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent) :
|
GxsForumUserNotify::GxsForumUserNotify(RsGxsIfaceHelper *ifaceImpl, const GxsGroupFrameDialog *g, QObject *parent) :
|
||||||
GxsUserNotify(ifaceImpl, parent)
|
GxsUserNotify(ifaceImpl, g, parent)
|
||||||
{
|
{
|
||||||
mCountChildMsgs = true;
|
mCountChildMsgs = true;
|
||||||
}
|
}
|
||||||
@ -35,10 +35,6 @@ bool GxsForumUserNotify::hasSetting(QString *name, QString *group)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool GxsForumUserNotify::getServiceStatistics(GxsServiceStatistic& stat)
|
|
||||||
{
|
|
||||||
return rsGxsForums->getForumServiceStatistics(stat);
|
|
||||||
}
|
|
||||||
|
|
||||||
QIcon GxsForumUserNotify::getIcon()
|
QIcon GxsForumUserNotify::getIcon()
|
||||||
{
|
{
|
||||||
|
@ -28,8 +28,7 @@ class GxsForumUserNotify : public GxsUserNotify
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GxsForumUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent = 0);
|
GxsForumUserNotify(RsGxsIfaceHelper *ifaceImpl, const GxsGroupFrameDialog *g, QObject *parent = 0);
|
||||||
virtual bool getServiceStatistics(GxsServiceStatistic& stat) override;
|
|
||||||
|
|
||||||
virtual bool hasSetting(QString *name, QString *group);
|
virtual bool hasSetting(QString *name, QString *group);
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ void GxsForumsDialog::shareInMessage(const RsGxsGroupId& forum_id,const QList<Re
|
|||||||
|
|
||||||
UserNotify *GxsForumsDialog::createUserNotify(QObject *parent)
|
UserNotify *GxsForumsDialog::createUserNotify(QObject *parent)
|
||||||
{
|
{
|
||||||
return new GxsForumUserNotify(rsGxsForums, parent);
|
return new GxsForumUserNotify(rsGxsForums,this, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GxsForumsDialog::text(TextType type)
|
QString GxsForumsDialog::text(TextType type)
|
||||||
|
Loading…
Reference in New Issue
Block a user