Skip to content

Commit

Permalink
some clear article work
Browse files Browse the repository at this point in the history
  • Loading branch information
jagannatharjun committed Dec 30, 2023
1 parent 82859b2 commit 4cd973e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/base/rss/rss_feed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ void Feed::refresh()
emit stateChanged(this);
}

void Feed::clear()
{
emit articlesAboutToReset();
m_articles.clear();
m_articlesByDate.clear();
emit articlesReset();
}

QUuid Feed::uid() const
{
return m_uid;
Expand Down
2 changes: 2 additions & 0 deletions src/base/rss/rss_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ namespace RSS
void newArticle(Article *article);
void articleRead(Article *article);
void articleAboutToBeRemoved(Article *article);
void articlesAboutToReset();
void articlesReset();

protected:
explicit Item(const QString &path);
Expand Down
9 changes: 9 additions & 0 deletions src/gui/rss/articlelistwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ void ArticleListWidget::setRSSItem(RSS::Item *rssItem, bool unreadOnly)
connect(m_rssItem, &RSS::Item::newArticle, this, &ArticleListWidget::handleArticleAdded);
connect(m_rssItem, &RSS::Item::articleRead, this, &ArticleListWidget::handleArticleRead);
connect(m_rssItem, &RSS::Item::articleAboutToBeRemoved, this, &ArticleListWidget::handleArticleAboutToBeRemoved);
connect(m_rssItem, &RSS::Item::articlesAboutToReset, this, &ArticleListWidget::handleArticlesAboutToBeReset);

for (auto *article : asConst(rssItem->articles()))
{
Expand Down Expand Up @@ -115,6 +116,14 @@ void ArticleListWidget::handleArticleAboutToBeRemoved(RSS::Article *rssArticle)
checkInvariant();
}

void ArticleListWidget::handleArticlesAboutToBeReset()
{
for (QListWidgetItem *item : m_rssArticleToListItemMapping)
delete item;

m_rssArticleToListItemMapping.clear();
}

void ArticleListWidget::checkInvariant() const
{
Q_ASSERT(count() == m_rssArticleToListItemMapping.count());
Expand Down
1 change: 1 addition & 0 deletions src/gui/rss/articlelistwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ private slots:
void handleArticleAdded(RSS::Article *rssArticle);
void handleArticleRead(RSS::Article *rssArticle);
void handleArticleAboutToBeRemoved(RSS::Article *rssArticle);
void handleArticlesAboutToBeReset();

private:
void checkInvariant() const;
Expand Down

0 comments on commit 4cd973e

Please sign in to comment.