attempt to sort out the mess in item deletion in FeedHolder widgets

This commit is contained in:
csoler 2020-01-14 21:43:29 +01:00
parent a0b6f50b60
commit c552890459
No known key found for this signature in database
GPG key ID: 7BCA522266C0804C
35 changed files with 149 additions and 283 deletions

View file

@ -20,17 +20,15 @@
#include <iostream>
#include "FeedItem.h"
#include "FeedHolder.h"
/** Constructor */
FeedItem::FeedItem(QWidget *parent) : QWidget(parent), mHash(0)
FeedItem::FeedItem(FeedHolder *fh, uint32_t feedId, QWidget *parent) : QWidget(parent), mHash(0),mFeedHolder(fh),mFeedId(feedId)
{
mWasExpanded = false;
}
FeedItem::~FeedItem()
{
emit feedItemDestroyed(this);
}
FeedItem::~FeedItem() { }
void FeedItem::expand(bool open)
{
@ -48,12 +46,36 @@ void FeedItem::expand(bool open)
uint64_t FeedItem::hash_64bits(const std::string& s) const
{
if(mHash == 0)
{
mHash = 0x01110bbfa09;
for(uint32_t i=0;i<s.size();++i)
mHash = ~(((mHash << 31) ^ (mHash >> 3)) + s[i]*0x217898fbba7 + 0x0294379);
}
mHash = hash64(s);
return mHash;
}
uint64_t FeedItem::hash64(const std::string& s)
{
uint64_t hash = 0x01110bbfa09;
for(uint32_t i=0;i<s.size();++i)
hash = ~(((hash << 31) ^ (hash >> 3)) + s[i]*0x217898fbba7 + 0x0294379);
return hash;
}
void FeedItem::removeItem()
{
#ifdef DEBUG_ITEM
std::cerr << "MsgItem::removeItem()";
std::cerr << std::endl;
#endif
mFeedHolder->deleteFeedItem(this,0);
// mFeedHolder->lockLayout(this, true);
// hide();
//
// if (mFeedHolder)
// mFeedHolder->deleteFeedItem(this, mFeedId);
//
// mFeedHolder->lockLayout(this, false);
}