fixed feed bug by moving away from std::string as a return type to uniqueIdentifier(). Now uint64_ hash is used and cached

This commit is contained in:
csoler 2019-12-21 14:33:53 +01:00
parent ff86d3cd20
commit 137cb5271d
No known key found for this signature in database
GPG key ID: 7BCA522266C0804C
22 changed files with 51 additions and 31 deletions

View file

@ -179,7 +179,7 @@ void RSFeedWidget::addFeedItem(FeedItem *feedItem, Qt::ItemDataRole sortRole, co
QTreeWidgetItem *treeItem = new RSTreeWidgetItem(mFeedCompareRole);
treeItem->setData(COLUMN_FEED, sortRole, value);
treeItem->setData(COLUMN_IDENTIFIER, Qt::DisplayRole, QString::fromStdString(feedItem->uniqueIdentifier()));
treeItem->setData(COLUMN_IDENTIFIER, Qt::DisplayRole, QString("%1").arg(feedItem->uniqueIdentifier(),8,16,QChar('0')));
ui->treeWidget->addTopLevelItem(treeItem);
ui->treeWidget->setItemWidget(treeItem, 0, feedItem);
@ -207,9 +207,9 @@ void RSFeedWidget::addFeedItem(FeedItem *feedItem, const QMap<Qt::ItemDataRole,
for (it = sort.begin(); it != sort.end(); ++it) {
treeItem->setData(COLUMN_FEED, it.key(), it.value());
}
treeItem->setData(COLUMN_IDENTIFIER, Qt::DisplayRole, QString("%1").arg(feedItem->uniqueIdentifier(),8,16,QChar('0')));
ui->treeWidget->addTopLevelItem(treeItem);
treeItem->setData(COLUMN_FEED, Qt::DisplayRole, QString::fromStdString(feedItem->uniqueIdentifier()));
ui->treeWidget->setItemWidget(treeItem, 0, feedItem);
feedAdded(feedItem, treeItem);
@ -438,10 +438,10 @@ void RSFeedWidget::feedItemDestroyed(FeedItem *feedItem)
emit feedCountChanged();
}
QTreeWidgetItem *RSFeedWidget::findTreeWidgetItem(const std::string& identifier)
QTreeWidgetItem *RSFeedWidget::findTreeWidgetItem(uint64_t identifier)
{
std::cerr << "FindTreeWidgetItem: looking for \"" << identifier << "\"" << std::endl;
QList<QTreeWidgetItem*> list = ui->treeWidget->findItems(QString::fromStdString(identifier),Qt::MatchExactly,COLUMN_IDENTIFIER);
QList<QTreeWidgetItem*> list = ui->treeWidget->findItems(QString("%1").arg(identifier,8,16,QChar('0')),Qt::MatchExactly,COLUMN_IDENTIFIER);
if(list.empty())
{
@ -495,7 +495,7 @@ void RSFeedWidget::withAll(RSFeedWidgetCallbackFunction callback, void *data)
}
}
FeedItem *RSFeedWidget::findFeedItem(const std::string& identifier)
FeedItem *RSFeedWidget::findFeedItem(uint64_t identifier)
{
QTreeWidgetItemIterator it(ui->treeWidget);
QTreeWidgetItem *treeItem=NULL;
@ -515,7 +515,7 @@ FeedItem *RSFeedWidget::findFeedItem(const std::string& identifier)
// if(feedItem->uniqueIdentifier() == identifier)
// causes a crash. I dont know why! If someone ever finds why, please tell me.
std::string id = feedItem->uniqueIdentifier();
uint64_t id = feedItem->uniqueIdentifier();
std::cerr << "Comparing \"" << id << "\"";
std::cerr << " to " << identifier << "\"" << " pthread_t = " << pthread_self() << std::endl;

View file

@ -71,7 +71,7 @@ public:
bool scrollTo(FeedItem *feedItem, bool focus);
void withAll(RSFeedWidgetCallbackFunction callback, void *data);
FeedItem *findFeedItem(const std::string &identifier);
FeedItem *findFeedItem(uint64_t identifier);
void selectedFeedItems(QList<FeedItem*> &feedItems);
@ -98,7 +98,7 @@ private:
void connectSignals(FeedItem *feedItem);
void disconnectSignals(FeedItem *feedItem);
FeedItem *feedItemFromTreeItem(QTreeWidgetItem *treeItem);
QTreeWidgetItem *findTreeWidgetItem(const std::string &identifier);
QTreeWidgetItem *findTreeWidgetItem(uint64_t identifier);
void filterItems();
void filterItem(QTreeWidgetItem *treeItem, FeedItem *feedItem);