simplified the addIfUnique mechanism in NewsFeed by using a data-based identifier for items

This commit is contained in:
csoler 2019-12-03 22:30:13 +01:00
parent fcbecbaa16
commit b85be7cc8e
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
21 changed files with 62 additions and 165 deletions

View File

@ -213,14 +213,7 @@ void NewsFeed::handleConnectionEvent(std::shared_ptr<const RsEvent> event)
switch(e.mConnectionType) switch(e.mConnectionType)
{ {
case RsConnectionEvent::PEER_CONNECTED: case RsConnectionEvent::PEER_CONNECTED: addFeedItemIfUnique(new PeerItem(this, NEWSFEED_PEERLIST, e.mSslId, PEER_TYPE_CONNECT, false), true);
addFeedItemIfUnique(new PeerItem(this, NEWSFEED_PEERLIST, e.mSslId, PEER_TYPE_CONNECT, false),
PEER_TYPE_CONNECT,
e.mSslId.toStdString(),
std::string(),
std::string(),
std::string(),
true);
break; break;
case RsConnectionEvent::PEER_DISCONNECTED: break;// not handled yet case RsConnectionEvent::PEER_DISCONNECTED: break;// not handled yet
@ -230,20 +223,9 @@ void NewsFeed::handleConnectionEvent(std::shared_ptr<const RsEvent> event)
if(!rsPeers->getPeerDetails(e.mSslId,det)) if(!rsPeers->getPeerDetails(e.mSslId,det))
return; return;
addFeedItemIfUnique(new SecurityItem(this, addFeedItemIfUnique(new SecurityItem(this, NEWSFEED_SECLIST, det.gpg_id, e.mSslId, det.location, std::string(), RS_FEED_ITEM_SEC_AUTH_DENIED, false), true );
NEWSFEED_SECLIST, }
det.gpg_id, e.mSslId, break;
det.location,
std::string(),
RS_FEED_ITEM_SEC_AUTH_DENIED,
false),
RS_FEED_ITEM_SEC_AUTH_DENIED,
e.mSslId.toStdString(),
std::string(),
std::string(),
std::string(),
true );
} break;
default: break; default: break;
} }
@ -280,19 +262,7 @@ void NewsFeed::handleSecurityEvent(std::shared_ptr<const RsEvent> event)
RsPeerDetails det; RsPeerDetails det;
rsPeers->getPeerDetails(e.mSslId,det) || rsPeers->getGPGDetails(e.mPgpId,det); rsPeers->getPeerDetails(e.mSslId,det) || rsPeers->getGPGDetails(e.mPgpId,det);
addFeedItemIfUnique(new SecurityItem(this, addFeedItemIfUnique(new SecurityItem(this, NEWSFEED_SECLIST, det.gpg_id, det.id, det.location, e.mLocator.toString(), FeedItemType, true), true );
NEWSFEED_SECLIST,
det.gpg_id, det.id,
det.location,
e.mLocator.toString(),
FeedItemType,
true),
FeedItemType,
e.mSslId.toStdString(),
std::string(),
std::string(),
std::string(),
true );
if (Settings->getMessageFlags() & RS_MESSAGE_CONNECT_ATTEMPT) if (Settings->getMessageFlags() & RS_MESSAGE_CONNECT_ATTEMPT)
MessageComposer::addConnectAttemptMsg(e.mPgpId, e.mSslId, QString::fromStdString(det.name + "(" + det.location + ")")); MessageComposer::addConnectAttemptMsg(e.mPgpId, e.mSslId, QString::fromStdString(det.name + "(" + det.location + ")"));
@ -1146,80 +1116,14 @@ void NewsFeed::addFeedItem(FeedItem *item)
ui->feedWidget->addFeedItem(item, ROLE_RECEIVED, QDateTime::currentDateTime()); ui->feedWidget->addFeedItem(item, ROLE_RECEIVED, QDateTime::currentDateTime());
} }
struct AddFeedItemIfUniqueData void NewsFeed::addFeedItemIfUnique(FeedItem *item, bool replace)
{ {
AddFeedItemIfUniqueData(FeedItem *feedItem, int type FeedItem *feedItem = ui->feedWidget->findFeedItem(item->uniqueIdentifier());
, const std::string& id1, const std::string& id2
, const std::string& id3, const std::string& id4) if (feedItem)
: mType(type), mId1(id1), mId2(id2), mId3(id3), mId4(id4)
{ {
mGxsCircleItem = dynamic_cast<GxsCircleItem*>(feedItem); if (!replace)
mPeerItem = dynamic_cast<PeerItem*>(feedItem);
mSecItem = dynamic_cast<SecurityItem*>(feedItem);
mSecurityIpItem = dynamic_cast<SecurityIpItem*>(feedItem);
}
int mType;
const std::string& mId1;
const std::string& mId2;
const std::string& mId3;
const std::string& mId4;
GxsCircleItem *mGxsCircleItem;
PeerItem *mPeerItem;
SecurityItem *mSecItem;
SecurityIpItem *mSecurityIpItem;
};
static bool addFeedItemIfUniqueCallback(FeedItem *feedItem, void *data)
{ {
AddFeedItemIfUniqueData *findData = (AddFeedItemIfUniqueData*) data;
if (!findData || findData->mId1.empty()) {
return false;
}
if (findData->mGxsCircleItem) {
GxsCircleItem *gxsCircleItem = dynamic_cast<GxsCircleItem*>(feedItem);
if (gxsCircleItem && gxsCircleItem->isSame(RsGxsCircleId(findData->mId1), RsGxsId(findData->mId2), findData->mType)) {
return true;
}
return false;
}
if (findData->mPeerItem) {
PeerItem *peerItem = dynamic_cast<PeerItem*>(feedItem);
if (peerItem && peerItem->isSame(RsPeerId(findData->mId1), findData->mType)) {
return true;
}
return false;
}
if (findData->mSecItem) {
SecurityItem *secitem = dynamic_cast<SecurityItem*>(feedItem);
if (secitem && secitem->isSame(RsPeerId(findData->mId1), findData->mType)) {
return true;
}
return false;
}
if (findData->mSecurityIpItem) {
SecurityIpItem *securityIpItem = dynamic_cast<SecurityIpItem*>(feedItem);
if (securityIpItem && securityIpItem->isSame(RsPeerId(findData->mId1), findData->mId2, findData->mId3, findData->mType)) {
return true;
}
return false;
}
return false;
}
void NewsFeed::addFeedItemIfUnique(FeedItem *item, int itemType, const std::string& id1, const std::string& id2, const std::string& id3, const std::string& id4, bool replace)
{
AddFeedItemIfUniqueData data(item, itemType, id1, id2, id3, id4);
FeedItem *feedItem = ui->feedWidget->findFeedItem(addFeedItemIfUniqueCallback, &data);
if (feedItem) {
if (!replace) {
delete item; delete item;
return; return;
} }
@ -1230,12 +1134,12 @@ void NewsFeed::addFeedItemIfUnique(FeedItem *item, int itemType, const std::stri
addFeedItem(item); addFeedItem(item);
} }
void NewsFeed::remUniqueFeedItem(FeedItem *item, int itemType, const std::string &id1, const std::string &id2, const std::string &id3, const std::string &id4) void NewsFeed::remUniqueFeedItem(FeedItem *item)
{ {
AddFeedItemIfUniqueData data(item, itemType, id1, id2, id3, id4); FeedItem *feedItem = ui->feedWidget->findFeedItem(item->uniqueIdentifier());
FeedItem *feedItem = ui->feedWidget->findFeedItem(addFeedItemIfUniqueCallback, &data);
if (feedItem) { if (feedItem)
{
delete item; delete item;
ui->feedWidget->removeFeedItem(feedItem); ui->feedWidget->removeFeedItem(feedItem);
@ -1304,7 +1208,7 @@ void NewsFeed::addFeedItemPeerOffset(const RsFeedItem &fi)
PeerItem *pi = new PeerItem(this, NEWSFEED_PEERLIST, RsPeerId(fi.mId1), PEER_TYPE_OFFSET, false); PeerItem *pi = new PeerItem(this, NEWSFEED_PEERLIST, RsPeerId(fi.mId1), PEER_TYPE_OFFSET, false);
/* add to layout */ /* add to layout */
addFeedItemIfUnique(pi, PEER_TYPE_OFFSET, fi.mId1, fi.mId2, fi.mId3, fi.mId4, false); addFeedItemIfUnique(pi, false);
#ifdef NEWS_DEBUG #ifdef NEWS_DEBUG
std::cerr << "NewsFeed::addFeedItemPeerOffset()"; std::cerr << "NewsFeed::addFeedItemPeerOffset()";
@ -1318,7 +1222,7 @@ void NewsFeed::addFeedItemSecurityConnectAttempt(const RsFeedItem &fi)
SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, RsPgpId(fi.mId1), RsPeerId(fi.mId2), fi.mId3, fi.mId4, fi.mType, false); SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, RsPgpId(fi.mId1), RsPeerId(fi.mId2), fi.mId3, fi.mId4, fi.mType, false);
/* add to layout */ /* add to layout */
addFeedItemIfUnique(pi, fi.mType, fi.mId2, "", "", "", false); addFeedItemIfUnique(pi, false);
#ifdef NEWS_DEBUG #ifdef NEWS_DEBUG
std::cerr << "NewsFeed::addFeedItemSecurityConnectAttempt()"; std::cerr << "NewsFeed::addFeedItemSecurityConnectAttempt()";
@ -1332,7 +1236,7 @@ void NewsFeed::addFeedItemSecurityAuthDenied(const RsFeedItem &fi)
SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, RsPgpId(fi.mId1), RsPeerId(fi.mId2), fi.mId3, fi.mId4, fi.mType, false); SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, RsPgpId(fi.mId1), RsPeerId(fi.mId2), fi.mId3, fi.mId4, fi.mType, false);
/* add to layout */ /* add to layout */
addFeedItemIfUnique(pi, RS_FEED_ITEM_SEC_AUTH_DENIED, fi.mId2, "", "", "", false); addFeedItemIfUnique(pi, false);
#ifdef NEWS_DEBUG #ifdef NEWS_DEBUG
std::cerr << "NewsFeed::addFeedItemSecurityAuthDenied()"; std::cerr << "NewsFeed::addFeedItemSecurityAuthDenied()";
@ -1346,7 +1250,7 @@ void NewsFeed::addFeedItemSecurityUnknownIn(const RsFeedItem &fi)
SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, RsPgpId(fi.mId1), RsPeerId(fi.mId2), fi.mId3, fi.mId4, RS_FEED_ITEM_SEC_UNKNOWN_IN, false); SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, RsPgpId(fi.mId1), RsPeerId(fi.mId2), fi.mId3, fi.mId4, RS_FEED_ITEM_SEC_UNKNOWN_IN, false);
/* add to layout */ /* add to layout */
addFeedItemIfUnique(pi, RS_FEED_ITEM_SEC_UNKNOWN_IN, fi.mId2, "", "", "", false); addFeedItemIfUnique(pi, false);
#ifdef NEWS_DEBUG #ifdef NEWS_DEBUG
std::cerr << "NewsFeed::addFeedItemSecurityUnknownIn()"; std::cerr << "NewsFeed::addFeedItemSecurityUnknownIn()";
@ -1360,7 +1264,7 @@ void NewsFeed::addFeedItemSecurityUnknownOut(const RsFeedItem &fi)
SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, RsPgpId(fi.mId1), RsPeerId(fi.mId2), fi.mId3, fi.mId4, RS_FEED_ITEM_SEC_UNKNOWN_OUT, false); SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, RsPgpId(fi.mId1), RsPeerId(fi.mId2), fi.mId3, fi.mId4, RS_FEED_ITEM_SEC_UNKNOWN_OUT, false);
/* add to layout */ /* add to layout */
addFeedItemIfUnique(pi, RS_FEED_ITEM_SEC_UNKNOWN_OUT, fi.mId2, "", "", "", false); addFeedItemIfUnique(pi, false);
#ifdef NEWS_DEBUG #ifdef NEWS_DEBUG
std::cerr << "NewsFeed::addFeedItemSecurityUnknownOut()"; std::cerr << "NewsFeed::addFeedItemSecurityUnknownOut()";
@ -1374,7 +1278,7 @@ void NewsFeed::addFeedItemSecurityIpBlacklisted(const RsFeedItem &fi, bool isTes
SecurityIpItem *pi = new SecurityIpItem(this, RsPeerId(fi.mId1), fi.mId2, fi.mResult1, RS_FEED_ITEM_SEC_IP_BLACKLISTED, isTest); SecurityIpItem *pi = new SecurityIpItem(this, RsPeerId(fi.mId1), fi.mId2, fi.mResult1, RS_FEED_ITEM_SEC_IP_BLACKLISTED, isTest);
/* add to layout */ /* add to layout */
addFeedItemIfUnique(pi, RS_FEED_ITEM_SEC_IP_BLACKLISTED, fi.mId1, fi.mId2, fi.mId3, fi.mId4, false); addFeedItemIfUnique(pi, false);
#ifdef NEWS_DEBUG #ifdef NEWS_DEBUG
std::cerr << "NewsFeed::addFeedItemSecurityIpBlacklisted()"; std::cerr << "NewsFeed::addFeedItemSecurityIpBlacklisted()";
@ -1388,7 +1292,7 @@ void NewsFeed::addFeedItemSecurityWrongExternalIpReported(const RsFeedItem &fi,
SecurityIpItem *pi = new SecurityIpItem(this, RsPeerId(fi.mId1), fi.mId2, fi.mId3, RS_FEED_ITEM_SEC_IP_WRONG_EXTERNAL_IP_REPORTED, isTest); SecurityIpItem *pi = new SecurityIpItem(this, RsPeerId(fi.mId1), fi.mId2, fi.mId3, RS_FEED_ITEM_SEC_IP_WRONG_EXTERNAL_IP_REPORTED, isTest);
/* add to layout */ /* add to layout */
addFeedItemIfUnique(pi, RS_FEED_ITEM_SEC_IP_WRONG_EXTERNAL_IP_REPORTED, fi.mId1, fi.mId2, fi.mId3, fi.mId4, false); addFeedItemIfUnique(pi, false);
#ifdef NEWS_DEBUG #ifdef NEWS_DEBUG
std::cerr << "NewsFeed::addFeedItemSecurityWrongExternalIpReported()"; std::cerr << "NewsFeed::addFeedItemSecurityWrongExternalIpReported()";
@ -1656,7 +1560,7 @@ void NewsFeed::addFeedItemCircleMembReq(const RsFeedItem &fi)
GxsCircleItem *item = new GxsCircleItem(this, NEWSFEED_CIRCLELIST, circleId, gxsId, RS_FEED_ITEM_CIRCLE_MEMB_REQ); GxsCircleItem *item = new GxsCircleItem(this, NEWSFEED_CIRCLELIST, circleId, gxsId, RS_FEED_ITEM_CIRCLE_MEMB_REQ);
/* add to layout */ /* add to layout */
addFeedItemIfUnique(item, RS_FEED_ITEM_CIRCLE_MEMB_REQ, fi.mId1, fi.mId2, fi.mId3, fi.mId4, false); addFeedItemIfUnique(item, false);
#ifdef NEWS_DEBUG #ifdef NEWS_DEBUG
std::cerr << "NewsFeed::addFeedItemCircleMembReq()" << std::endl; std::cerr << "NewsFeed::addFeedItemCircleMembReq()" << std::endl;
@ -1676,7 +1580,7 @@ void NewsFeed::remFeedItemCircleMembReq(const RsFeedItem &fi)
GxsCircleItem *item = new GxsCircleItem(this, NEWSFEED_CIRCLELIST, circleId, gxsId, RS_FEED_ITEM_CIRCLE_MEMB_REQ); GxsCircleItem *item = new GxsCircleItem(this, NEWSFEED_CIRCLELIST, circleId, gxsId, RS_FEED_ITEM_CIRCLE_MEMB_REQ);
/* add to layout */ /* add to layout */
remUniqueFeedItem(item, RS_FEED_ITEM_CIRCLE_MEMB_REQ, fi.mId1, fi.mId2, fi.mId3, fi.mId4); remUniqueFeedItem(item);
#ifdef NEWS_DEBUG #ifdef NEWS_DEBUG
std::cerr << "NewsFeed::remFeedItemCircleMembReq()" << std::endl; std::cerr << "NewsFeed::remFeedItemCircleMembReq()" << std::endl;

View File

@ -106,8 +106,8 @@ private:
void handleConnectionEvent(std::shared_ptr<const RsEvent> event); void handleConnectionEvent(std::shared_ptr<const RsEvent> event);
void addFeedItem(FeedItem *item); void addFeedItem(FeedItem *item);
void addFeedItemIfUnique(FeedItem *item, int itemType, const std::string& id1, const std::string& id2, const std::string& id3, const std::string& id4, bool replace); void addFeedItemIfUnique(FeedItem *item, bool replace);
void remUniqueFeedItem(FeedItem *item, int itemType, const std::string& id1, const std::string& id2, const std::string& id3, const std::string& id4); void remUniqueFeedItem(FeedItem *item);
void addFeedItemPeerConnect(const RsFeedItem &fi); void addFeedItemPeerConnect(const RsFeedItem &fi);
void addFeedItemPeerDisconnect(const RsFeedItem &fi); void addFeedItemPeerDisconnect(const RsFeedItem &fi);

View File

@ -49,6 +49,7 @@ public:
const RsPostedPost &getPost() const; const RsPostedPost &getPost() const;
RsPostedPost &post(); RsPostedPost &post();
QString uniqueIdentifier() const override { return "PostedItem " + QString::fromStdString(mMessageId.toStdString()); }
protected: protected:
/* FeedItem */ /* FeedItem */
virtual void doExpand(bool open); virtual void doExpand(bool open);

View File

@ -476,14 +476,13 @@ void RSFeedWidget::withAll(RSFeedWidgetCallbackFunction callback, void *data)
} }
} }
FeedItem *RSFeedWidget::findFeedItem(RSFeedWidgetFindCallbackFunction callback, void *data) FeedItem *RSFeedWidget::findFeedItem(const QString& identifier)
{ {
if (!callback) {
return NULL;
}
QTreeWidgetItemIterator it(ui->treeWidget); QTreeWidgetItemIterator it(ui->treeWidget);
QTreeWidgetItem *treeItem; QTreeWidgetItem *treeItem;
// this search could probably be automatised by giving the tree items the identifier as data for some specific role, then calling QTreeWidget::findItems()
#warning TODO
while ((treeItem = *it) != NULL) { while ((treeItem = *it) != NULL) {
++it; ++it;
@ -492,10 +491,9 @@ FeedItem *RSFeedWidget::findFeedItem(RSFeedWidgetFindCallbackFunction callback,
continue; continue;
} }
if (callback(feedItem, data)) { if (feedItem->uniqueIdentifier() == identifier)
return feedItem; return feedItem;
} }
}
return NULL; return NULL;
} }

View File

@ -71,7 +71,7 @@ public:
bool scrollTo(FeedItem *feedItem, bool focus); bool scrollTo(FeedItem *feedItem, bool focus);
void withAll(RSFeedWidgetCallbackFunction callback, void *data); void withAll(RSFeedWidgetCallbackFunction callback, void *data);
FeedItem *findFeedItem(RSFeedWidgetFindCallbackFunction callback, void *data); FeedItem *findFeedItem(const QString &identifier);
void selectedFeedItems(QList<FeedItem*> &feedItems); void selectedFeedItems(QList<FeedItem*> &feedItems);

View File

@ -37,6 +37,7 @@ public:
void updateItemStatic(); void updateItemStatic();
virtual QString uniqueIdentifier() const override { return "ChatMsgItem " + QString::fromStdString(mPeerId.toStdString()) ;}
protected: protected:
/* FeedItem */ /* FeedItem */
virtual void doExpand(bool /*open*/) {} virtual void doExpand(bool /*open*/) {}

View File

@ -36,6 +36,12 @@ public:
bool wasExpanded() { return mWasExpanded; } bool wasExpanded() { return mWasExpanded; }
void expand(bool open); void expand(bool open);
/*!
* \brief uniqueIdentifier
* \return returns a string that is unique to this specific item. The string will be used to search for an existing item that
* would contain the same information. It should therefore sumarise the data represented by the item.
*/
virtual QString uniqueIdentifier() const =0;
protected: protected:
virtual void doExpand(bool open) = 0; virtual void doExpand(bool open) = 0;
virtual void expandFill(bool /*first*/) {} virtual void expandFill(bool /*first*/) {}

View File

@ -42,6 +42,7 @@ public:
bool setGroup(const RsGxsChannelGroup &group); bool setGroup(const RsGxsChannelGroup &group);
QString uniqueIdentifier() const override { return "GxsChannelGroupItem " + QString::fromStdString(mGroup.mMeta.mGroupId.toStdString()) ; }
protected: protected:
/* FeedItem */ /* FeedItem */
virtual void doExpand(bool open); virtual void doExpand(bool open);

View File

@ -53,6 +53,8 @@ public:
//GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsChannelPost &post, bool isHome, bool autoUpdate); //GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsChannelPost &post, bool isHome, bool autoUpdate);
virtual ~GxsChannelPostItem(); virtual ~GxsChannelPostItem();
virtual QString uniqueIdentifier() const override { "GxsChannelPostItem " + QString::fromStdString(mPost.mMeta.mMsgId.toStdString()) ; }
bool setGroup(const RsGxsChannelGroup &group, bool doFill = true); bool setGroup(const RsGxsChannelGroup &group, bool doFill = true);
bool setPost(const RsGxsChannelPost &post, bool doFill = true); bool setPost(const RsGxsChannelPost &post, bool doFill = true);

View File

@ -125,14 +125,9 @@ void GxsCircleItem::setup()
} }
bool GxsCircleItem::isSame(const RsGxsCircleId &circleId, const RsGxsId &gxsId, uint32_t type) QString GxsCircleItem::uniqueIdentifier() const
{ {
if ((mCircleId == circleId) && (mGxsId == gxsId) && (mType == type)) return "GxsCircle " + QString::fromStdString(mCircleId.toStdString()) + " " + QString::fromStdString(mGxsId.toStdString()) + " " + QString::number(mType);
{
return true;
}
return false;
} }
void GxsCircleItem::removeItem() void GxsCircleItem::removeItem()

View File

@ -52,8 +52,7 @@ public:
GxsCircleItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsCircleId &circleId, const RsGxsId &gxsId, const uint32_t type); GxsCircleItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsCircleId &circleId, const RsGxsId &gxsId, const uint32_t type);
virtual ~GxsCircleItem(); virtual ~GxsCircleItem();
bool isSame(const RsGxsCircleId &circleId, const RsGxsId &gxsId, uint32_t type); QString uniqueIdentifier() const override;
void loadRequest(const TokenQueue *queue, const TokenRequest &req); void loadRequest(const TokenQueue *queue, const TokenRequest &req);

View File

@ -42,6 +42,7 @@ public:
bool setGroup(const RsGxsForumGroup &group); bool setGroup(const RsGxsForumGroup &group);
virtual QString uniqueIdentifier() const override { return "GxsForumGroupItem " + QString::fromStdString(mGroup.mMeta.mGroupId.toStdString()) ; }
protected: protected:
/* FeedItem */ /* FeedItem */
virtual void doExpand(bool open); virtual void doExpand(bool open);

View File

@ -43,6 +43,7 @@ public:
bool setGroup(const RsGxsForumGroup &group, bool doFill = true); bool setGroup(const RsGxsForumGroup &group, bool doFill = true);
bool setMessage(const RsGxsForumMsg &msg, bool doFill = true); bool setMessage(const RsGxsForumMsg &msg, bool doFill = true);
QString uniqueIdentifier() const override { return "GxsForumMsgItem " + QString::fromStdString(mMessage.mMeta.mMsgId.toStdString()) ; }
protected: protected:
/* FeedItem */ /* FeedItem */
virtual void doExpand(bool open); virtual void doExpand(bool open);

View File

@ -38,6 +38,7 @@ public:
void updateItemStatic(); void updateItemStatic();
virtual QString uniqueIdentifier() const override { return "MsgItem " + QString::fromStdString(mMsgId) ; }
protected: protected:
/* FeedItem */ /* FeedItem */
virtual void doExpand(bool open); virtual void doExpand(bool open);

View File

@ -67,16 +67,10 @@ PeerItem::PeerItem(FeedHolder *parent, uint32_t feedId, const RsPeerId &peerId,
updateItem(); updateItem();
} }
QString PeerItem::uniqueIdentifier() const
bool PeerItem::isSame(const RsPeerId &peerId, uint32_t type)
{ {
if ((mPeerId == peerId) && (mType == type)) return "PeerItem " + QString::fromStdString(mPeerId.toStdString()) + " " + QString::number(mType) ;
{
return true;
} }
return false;
}
void PeerItem::updateItemStatic() void PeerItem::updateItemStatic()
{ {

View File

@ -43,7 +43,7 @@ public:
void updateItemStatic(); void updateItemStatic();
bool isSame(const RsPeerId &peerId, uint32_t type); virtual QString uniqueIdentifier() const;
protected: protected:
/* FeedItem */ /* FeedItem */

View File

@ -42,6 +42,8 @@ public:
bool setGroup(const RsPostedGroup &group); bool setGroup(const RsPostedGroup &group);
virtual QString uniqueIdentifier() const override { return "PostedGroupItem " + QString::fromStdString(mGroup.mMeta.mGroupId.toStdString()) ; }
protected: protected:
/* FeedItem */ /* FeedItem */
virtual void doExpand(bool open); virtual void doExpand(bool open);

View File

@ -78,13 +78,10 @@ void SecurityIpItem::setup()
updateItem(); updateItem();
} }
bool SecurityIpItem::isSame(const RsPeerId &sslId, const std::string& ipAddr, const std::string& ipAddrReported, uint32_t type) QString SecurityIpItem::uniqueIdentifier() const
{ {
if (mType == type && mSslId==sslId && mIpAddr == ipAddr && mIpAddrReported == ipAddrReported) { return "SecurityItem " + QString::number(mType) + " " + QString::fromStdString(mSslId.toStdString())
return true; + " " + QString::fromStdString(mIpAddr) + " " + QString::fromStdString(mIpAddrReported) ;
}
return false;
} }
void SecurityIpItem::updateItemStatic() void SecurityIpItem::updateItemStatic()

View File

@ -43,7 +43,7 @@ public:
void updateItemStatic(); void updateItemStatic();
bool isSame(const RsPeerId &sslId, const std::string& ipAddr, const std::string& ipAddrReported, uint32_t type); QString uniqueIdentifier() const override;
protected: protected:
/* FeedItem */ /* FeedItem */

View File

@ -81,16 +81,10 @@ SecurityItem::SecurityItem(FeedHolder *parent, uint32_t feedId, const RsPgpId &g
updateItem(); updateItem();
} }
QString SecurityItem::uniqueIdentifier() const
bool SecurityItem::isSame(const RsPeerId &sslId, uint32_t type)
{ {
if ((mSslId == sslId) && (mType == type)) return "SecurityItem " + QString::number(mType) + " " + QString::fromStdString(mSslId.toStdString());
{
return true;
} }
return false;
}
void SecurityItem::updateItemStatic() void SecurityItem::updateItemStatic()
{ {

View File

@ -42,7 +42,7 @@ public:
void updateItemStatic(); void updateItemStatic();
bool isSame(const RsPeerId &sslId, uint32_t type); QString uniqueIdentifier() const override;
protected: protected:
/* FeedItem */ /* FeedItem */