mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-24 15:05:35 -04:00
Added notify of meta changes to RsGenExchange
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7428 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
15718cbca9
commit
60a67846b0
15 changed files with 177 additions and 48 deletions
|
@ -14,8 +14,8 @@ RsGxsUpdateBroadcastBase::RsGxsUpdateBroadcastBase(RsGxsIfaceHelper *ifaceImpl,
|
|||
|
||||
mUpdateBroadcast = RsGxsUpdateBroadcast::get(ifaceImpl);
|
||||
connect(mUpdateBroadcast, SIGNAL(changed()), this, SLOT(updateBroadcastChanged()));
|
||||
connect(mUpdateBroadcast, SIGNAL(grpsChanged(std::list<RsGxsGroupId>)), this, SLOT(updateBroadcastGrpsChanged(std::list<RsGxsGroupId>)));
|
||||
connect(mUpdateBroadcast, SIGNAL(msgsChanged(std::map<RsGxsGroupId,std::vector<RsGxsMessageId> >)), this, SLOT(updateBroadcastMsgsChanged(std::map<RsGxsGroupId,std::vector<RsGxsMessageId> >)));
|
||||
connect(mUpdateBroadcast, SIGNAL(grpsChanged(std::list<RsGxsGroupId>, std::list<RsGxsGroupId>)), this, SLOT(updateBroadcastGrpsChanged(std::list<RsGxsGroupId>,std::list<RsGxsGroupId>)));
|
||||
connect(mUpdateBroadcast, SIGNAL(msgsChanged(std::map<RsGxsGroupId,std::vector<RsGxsMessageId> >, std::map<RsGxsGroupId,std::vector<RsGxsMessageId> >)), this, SLOT(updateBroadcastMsgsChanged(std::map<RsGxsGroupId,std::vector<RsGxsMessageId> >,std::map<RsGxsGroupId,std::vector<RsGxsMessageId> >)));
|
||||
}
|
||||
|
||||
RsGxsUpdateBroadcastBase::~RsGxsUpdateBroadcastBase()
|
||||
|
@ -42,7 +42,9 @@ void RsGxsUpdateBroadcastBase::securedUpdateDisplay()
|
|||
|
||||
/* Clear updated ids */
|
||||
mGrpIds.clear();
|
||||
mGrpIdsMeta.clear(),
|
||||
mMsgIds.clear();
|
||||
mMsgIdsMeta.clear();
|
||||
}
|
||||
|
||||
void RsGxsUpdateBroadcastBase::showEvent(QShowEvent */*event*/)
|
||||
|
@ -53,7 +55,7 @@ void RsGxsUpdateBroadcastBase::showEvent(QShowEvent */*event*/)
|
|||
}
|
||||
|
||||
if (!mUpdateWhenInvisible) {
|
||||
if (!mGrpIds.empty() || !mMsgIds.empty()) {
|
||||
if (!mGrpIds.empty() || !mGrpIdsMeta.empty() || !mMsgIds.empty() || !mMsgIdsMeta.empty()) {
|
||||
securedUpdateDisplay();
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +71,7 @@ void RsGxsUpdateBroadcastBase::updateBroadcastChanged()
|
|||
}
|
||||
}
|
||||
|
||||
void RsGxsUpdateBroadcastBase::updateBroadcastGrpsChanged(const std::list<RsGxsGroupId> &grpIds)
|
||||
void RsGxsUpdateBroadcastBase::updateBroadcastGrpsChanged(const std::list<RsGxsGroupId> &grpIds, const std::list<RsGxsGroupId> &grpIdsMeta)
|
||||
{
|
||||
std::list<RsGxsGroupId>::const_iterator it;
|
||||
for (it = grpIds.begin(); it != grpIds.end(); ++it) {
|
||||
|
@ -77,9 +79,14 @@ void RsGxsUpdateBroadcastBase::updateBroadcastGrpsChanged(const std::list<RsGxsG
|
|||
mGrpIds.push_back(*it);
|
||||
}
|
||||
}
|
||||
for (it = grpIdsMeta.begin(); it != grpIdsMeta.end(); ++it) {
|
||||
if (std::find(mGrpIdsMeta.begin(), mGrpIdsMeta.end(), *it) == mGrpIdsMeta.end()) {
|
||||
mGrpIdsMeta.push_back(*it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RsGxsUpdateBroadcastBase::updateBroadcastMsgsChanged(const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgIds)
|
||||
void RsGxsUpdateBroadcastBase::updateBroadcastMsgsChanged(const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgIds, const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgIdsMeta)
|
||||
{
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::const_iterator mapIt;
|
||||
for (mapIt = msgIds.begin(); mapIt != msgIds.end(); ++mapIt) {
|
||||
|
@ -87,6 +94,54 @@ void RsGxsUpdateBroadcastBase::updateBroadcastMsgsChanged(const std::map<RsGxsGr
|
|||
const std::vector<RsGxsMessageId> &srcMsgIds = mapIt->second;
|
||||
std::vector<RsGxsMessageId> &destMsgIds = mMsgIds[grpId];
|
||||
|
||||
std::vector<RsGxsMessageId>::const_iterator msgIt;
|
||||
for (msgIt = srcMsgIds.begin(); msgIt != srcMsgIds.end(); ++msgIt) {
|
||||
if (std::find(destMsgIds.begin(), destMsgIds.end(), *msgIt) == destMsgIds.end()) {
|
||||
destMsgIds.push_back(*msgIt);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (mapIt = msgIdsMeta.begin(); mapIt != msgIdsMeta.end(); ++mapIt) {
|
||||
const RsGxsGroupId &grpId = mapIt->first;
|
||||
const std::vector<RsGxsMessageId> &srcMsgIds = mapIt->second;
|
||||
std::vector<RsGxsMessageId> &destMsgIds = mMsgIdsMeta[grpId];
|
||||
|
||||
std::vector<RsGxsMessageId>::const_iterator msgIt;
|
||||
for (msgIt = srcMsgIds.begin(); msgIt != srcMsgIds.end(); ++msgIt) {
|
||||
if (std::find(destMsgIds.begin(), destMsgIds.end(), *msgIt) == destMsgIds.end()) {
|
||||
destMsgIds.push_back(*msgIt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RsGxsUpdateBroadcastBase::getAllGrpIds(std::list<RsGxsGroupId> &grpIds)
|
||||
{
|
||||
std::list<RsGxsGroupId>::const_iterator it;
|
||||
for (it = mGrpIds.begin(); it != mGrpIds.end(); ++it) {
|
||||
if (std::find(grpIds.begin(), grpIds.end(), *it) == grpIds.end()) {
|
||||
grpIds.push_back(*it);
|
||||
}
|
||||
}
|
||||
for (it = mGrpIdsMeta.begin(); it != mGrpIdsMeta.end(); ++it) {
|
||||
if (std::find(grpIds.begin(), grpIds.end(), *it) == grpIds.end()) {
|
||||
grpIds.push_back(*it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RsGxsUpdateBroadcastBase::getAllMsgIds(std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgIds)
|
||||
{
|
||||
/* Copy first map */
|
||||
msgIds = mMsgIds;
|
||||
|
||||
/* Append second map */
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::const_iterator mapIt;
|
||||
for (mapIt = mMsgIdsMeta.begin(); mapIt != mMsgIdsMeta.end(); ++mapIt) {
|
||||
const RsGxsGroupId &grpId = mapIt->first;
|
||||
const std::vector<RsGxsMessageId> &srcMsgIds = mapIt->second;
|
||||
std::vector<RsGxsMessageId> &destMsgIds = msgIds[grpId];
|
||||
|
||||
std::vector<RsGxsMessageId>::const_iterator msgIt;
|
||||
for (msgIt = srcMsgIds.begin(); msgIt != srcMsgIds.end(); ++msgIt) {
|
||||
if (std::find(destMsgIds.begin(), destMsgIds.end(), *msgIt) == destMsgIds.end()) {
|
||||
|
|
|
@ -19,7 +19,11 @@ public:
|
|||
virtual ~RsGxsUpdateBroadcastBase();
|
||||
|
||||
const std::list<RsGxsGroupId> &getGrpIds() { return mGrpIds; }
|
||||
const std::list<RsGxsGroupId> &getGrpIdsMeta() { return mGrpIdsMeta; }
|
||||
void getAllGrpIds(std::list<RsGxsGroupId> &grpIds);
|
||||
const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &getMsgIds() { return mMsgIds; }
|
||||
const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &getMsgIdsMeta() { return mMsgIdsMeta; }
|
||||
void getAllMsgIds(std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgIds);
|
||||
|
||||
protected:
|
||||
void fillComplete();
|
||||
|
@ -32,8 +36,8 @@ signals:
|
|||
|
||||
private slots:
|
||||
void updateBroadcastChanged();
|
||||
void updateBroadcastGrpsChanged(const std::list<RsGxsGroupId>& grpIds);
|
||||
void updateBroadcastMsgsChanged(const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >& msgIds);
|
||||
void updateBroadcastGrpsChanged(const std::list<RsGxsGroupId>& grpIds, const std::list<RsGxsGroupId> &grpIdsMeta);
|
||||
void updateBroadcastMsgsChanged(const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >& msgIds, const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >& msgIdsMeta);
|
||||
void securedUpdateDisplay();
|
||||
|
||||
private:
|
||||
|
@ -41,5 +45,7 @@ private:
|
|||
bool mFillComplete;
|
||||
bool mUpdateWhenInvisible; // Update also when not visible
|
||||
std::list<RsGxsGroupId> mGrpIds;
|
||||
std::list<RsGxsGroupId> mGrpIdsMeta;
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > mMsgIds;
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > mMsgIdsMeta;
|
||||
};
|
||||
|
|
|
@ -27,11 +27,31 @@ const std::list<RsGxsGroupId> &RsGxsUpdateBroadcastWidget::getGrpIds()
|
|||
return mBase->getGrpIds();
|
||||
}
|
||||
|
||||
const std::list<RsGxsGroupId> &RsGxsUpdateBroadcastWidget::getGrpIdsMeta()
|
||||
{
|
||||
return mBase->getGrpIdsMeta();
|
||||
}
|
||||
|
||||
void RsGxsUpdateBroadcastWidget::getAllGrpIds(std::list<RsGxsGroupId> &grpIds)
|
||||
{
|
||||
mBase->getAllGrpIds(grpIds);
|
||||
}
|
||||
|
||||
const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &RsGxsUpdateBroadcastWidget::getMsgIds()
|
||||
{
|
||||
return mBase->getMsgIds();
|
||||
}
|
||||
|
||||
const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &RsGxsUpdateBroadcastWidget::getMsgIdsMeta()
|
||||
{
|
||||
return mBase->getMsgIdsMeta();
|
||||
}
|
||||
|
||||
void RsGxsUpdateBroadcastWidget::getAllMsgIds(std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgIds)
|
||||
{
|
||||
mBase->getAllMsgIds(msgIds);
|
||||
}
|
||||
|
||||
void RsGxsUpdateBroadcastWidget::fillDisplay(bool complete)
|
||||
{
|
||||
updateDisplay(complete);
|
||||
|
|
|
@ -25,7 +25,11 @@ public:
|
|||
void fillComplete();
|
||||
void setUpdateWhenInvisible(bool update);
|
||||
const std::list<RsGxsGroupId> &getGrpIds();
|
||||
const std::list<RsGxsGroupId> &getGrpIdsMeta();
|
||||
void getAllGrpIds(std::list<RsGxsGroupId> &grpIds);
|
||||
const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &getMsgIds();
|
||||
const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &getMsgIdsMeta();
|
||||
void getAllMsgIds(std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgIds);
|
||||
|
||||
protected:
|
||||
virtual void showEvent(QShowEvent *event);
|
||||
|
|
|
@ -44,20 +44,22 @@ RsGxsUpdateBroadcast *RsGxsUpdateBroadcast::get(RsGxsIfaceHelper *ifaceImpl)
|
|||
void RsGxsUpdateBroadcast::poll()
|
||||
{
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > msgs;
|
||||
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > msgsMeta;
|
||||
std::list<RsGxsGroupId> grps;
|
||||
std::list<RsGxsGroupId> grpsMeta;
|
||||
|
||||
if (mIfaceImpl->updated(true, true))
|
||||
{
|
||||
mIfaceImpl->msgsChanged(msgs);
|
||||
if (!msgs.empty())
|
||||
mIfaceImpl->msgsChanged(msgs, msgsMeta);
|
||||
if (!msgs.empty() || !msgsMeta.empty())
|
||||
{
|
||||
emit msgsChanged(msgs);
|
||||
emit msgsChanged(msgs, msgsMeta);
|
||||
}
|
||||
|
||||
mIfaceImpl->groupsChanged(grps);
|
||||
if (!grps.empty())
|
||||
mIfaceImpl->groupsChanged(grps, grpsMeta);
|
||||
if (!grps.empty() || !grpsMeta.empty())
|
||||
{
|
||||
emit grpsChanged(grps);
|
||||
emit grpsChanged(grps, grpsMeta);
|
||||
}
|
||||
|
||||
emit changed();
|
||||
|
|
|
@ -19,8 +19,8 @@ public:
|
|||
|
||||
signals:
|
||||
void changed();
|
||||
void msgsChanged(const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >& msgIds);
|
||||
void grpsChanged(const std::list<RsGxsGroupId>& grpIds);
|
||||
void msgsChanged(const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >& msgIds, const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >& msgIdsMeta);
|
||||
void grpsChanged(const std::list<RsGxsGroupId>& grpIds, const std::list<RsGxsGroupId>& grpIdsMeta);
|
||||
|
||||
private slots:
|
||||
void poll();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue