mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-11-29 20:06:38 -05:00
simplified the addIfUnique mechanism in NewsFeed by using a data-based identifier for items
This commit is contained in:
parent
fcbecbaa16
commit
b85be7cc8e
21 changed files with 62 additions and 165 deletions
|
|
@ -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);
|
||||
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) {
|
||||
++it;
|
||||
|
||||
|
|
@ -492,9 +491,8 @@ FeedItem *RSFeedWidget::findFeedItem(RSFeedWidgetFindCallbackFunction callback,
|
|||
continue;
|
||||
}
|
||||
|
||||
if (callback(feedItem, data)) {
|
||||
if (feedItem->uniqueIdentifier() == identifier)
|
||||
return feedItem;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ public:
|
|||
bool scrollTo(FeedItem *feedItem, bool focus);
|
||||
|
||||
void withAll(RSFeedWidgetCallbackFunction callback, void *data);
|
||||
FeedItem *findFeedItem(RSFeedWidgetFindCallbackFunction callback, void *data);
|
||||
FeedItem *findFeedItem(const QString &identifier);
|
||||
|
||||
void selectedFeedItems(QList<FeedItem*> &feedItems);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue