qBittorrent
RSS::Folder Class Referencefinal

#include <rss_folder.h>

Inheritance diagram for RSS::Folder:
Collaboration diagram for RSS::Folder:

Public Member Functions

QList< Article * > articles () const override
 
int unreadCount () const override
 
void markAsRead () override
 
void refresh () override
 
QList< Item * > items () const
 
QJsonValue toJsonValue (bool withData=false) const override
 
- Public Member Functions inherited from RSS::Item
QString path () const
 
QString name () const
 

Private Slots

void handleItemUnreadCountChanged ()
 

Private Member Functions

 Folder (const QString &path="")
 
 ~Folder () override
 
void cleanup () override
 
void addItem (Item *item)
 
void removeItem (Item *item)
 

Private Attributes

QList< Item * > m_items
 

Friends

class Session
 

Additional Inherited Members

- Signals inherited from RSS::Item
void pathChanged (Item *item=nullptr)
 
void unreadCountChanged (Item *item=nullptr)
 
void aboutToBeDestroyed (Item *item=nullptr)
 
void newArticle (Article *article)
 
void articleRead (Article *article)
 
void articleAboutToBeRemoved (Article *article)
 
- Static Public Member Functions inherited from RSS::Item
static bool isValidPath (const QString &path)
 
static QString joinPath (const QString &path1, const QString &path2)
 
static QStringList expandPath (const QString &path)
 
static QString parentPath (const QString &path)
 
static QString relativeName (const QString &path)
 
- Static Public Attributes inherited from RSS::Item
static const QChar PathSeparator
 
- Protected Member Functions inherited from RSS::Item
 Item (const QString &path)
 
 ~Item () override
 

Detailed Description

Definition at line 40 of file rss_folder.h.

Constructor & Destructor Documentation

◆ Folder()

Folder::Folder ( const QString &  path = "")
explicitprivate

Definition at line 43 of file rss_folder.cpp.

44  : Item(path)
45 {
46 }
Item(const QString &path)
Definition: rss_item.cpp:41
QString path() const
Definition: rss_item.cpp:57

◆ ~Folder()

Folder::~Folder ( )
overrideprivate

Definition at line 48 of file rss_folder.cpp.

49 {
50  emit aboutToBeDestroyed(this);
51 
52  for (auto item : asConst(items()))
53  delete item;
54 }
QList< Item * > items() const
Definition: rss_folder.cpp:94
void aboutToBeDestroyed(Item *item=nullptr)
constexpr std::add_const_t< T > & asConst(T &t) noexcept
Definition: global.h:42

References RSS::Item::aboutToBeDestroyed(), asConst(), and items().

Here is the call graph for this function:

Member Function Documentation

◆ addItem()

void Folder::addItem ( Item item)
private

Definition at line 119 of file rss_folder.cpp.

120 {
121  Q_ASSERT(item);
122  Q_ASSERT(!m_items.contains(item));
123 
124  m_items.append(item);
125  connect(item, &Item::newArticle, this, &Item::newArticle);
126  connect(item, &Item::articleRead, this, &Item::articleRead);
129 
130  for (auto article : asConst(item->articles()))
131  emit newArticle(article);
132 
133  if (item->unreadCount() > 0)
134  emit unreadCountChanged(this);
135 }
void handleItemUnreadCountChanged()
Definition: rss_folder.cpp:108
QList< Item * > m_items
Definition: rss_folder.h:68
void newArticle(Article *article)
void articleAboutToBeRemoved(Article *article)
virtual QList< Article * > articles() const =0
void unreadCountChanged(Item *item=nullptr)
void articleRead(Article *article)
virtual int unreadCount() const =0

References RSS::Item::articleAboutToBeRemoved(), RSS::Item::articleRead(), RSS::Item::articles(), asConst(), handleItemUnreadCountChanged(), m_items, RSS::Item::newArticle(), RSS::Item::unreadCount(), and RSS::Item::unreadCountChanged().

Referenced by RSS::Session::addItem().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ articles()

QList< Article * > Folder::articles ( ) const
overridevirtual

Implements RSS::Item.

Definition at line 56 of file rss_folder.cpp.

57 {
58  QList<Article *> news;
59 
60  for (Item *item : asConst(items()))
61  {
62  int n = news.size();
63  news << item->articles();
64  std::inplace_merge(news.begin(), news.begin() + n, news.end()
65  , [](Article *a1, Article *a2)
66  {
67  return Article::articleDateRecentThan(a1, a2->date());
68  });
69  }
70  return news;
71 }
Definition: rss_article.h:43

References asConst(), and items().

Here is the call graph for this function:

◆ cleanup()

void Folder::cleanup ( )
overrideprivatevirtual

Implements RSS::Item.

Definition at line 113 of file rss_folder.cpp.

114 {
115  for (Item *item : asConst(items()))
116  item->cleanup();
117 }

References asConst(), and items().

Here is the call graph for this function:

◆ handleItemUnreadCountChanged

void Folder::handleItemUnreadCountChanged ( )
privateslot

Definition at line 108 of file rss_folder.cpp.

109 {
110  emit unreadCountChanged(this);
111 }

References RSS::Item::unreadCountChanged().

Referenced by addItem().

Here is the caller graph for this function:

◆ items()

QList< Item * > Folder::items ( ) const

Definition at line 94 of file rss_folder.cpp.

95 {
96  return m_items;
97 }

References m_items.

Referenced by articles(), cleanup(), FeedListWidget::fill(), markAsRead(), refresh(), toJsonValue(), unreadCount(), and ~Folder().

Here is the caller graph for this function:

◆ markAsRead()

void Folder::markAsRead ( )
overridevirtual

Implements RSS::Item.

Definition at line 82 of file rss_folder.cpp.

83 {
84  for (Item *item : asConst(items()))
85  item->markAsRead();
86 }

References asConst(), and items().

Here is the call graph for this function:

◆ refresh()

void Folder::refresh ( )
overridevirtual

Implements RSS::Item.

Definition at line 88 of file rss_folder.cpp.

89 {
90  for (Item *item : asConst(items()))
91  item->refresh();
92 }

References asConst(), and items().

Referenced by RSS::Session::refresh().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeItem()

void Folder::removeItem ( Item item)
private

Definition at line 137 of file rss_folder.cpp.

138 {
139  Q_ASSERT(m_items.contains(item));
140 
141  for (auto article : asConst(item->articles()))
142  emit articleAboutToBeRemoved(article);
143 
144  item->disconnect(this);
145  m_items.removeOne(item);
146  if (item->unreadCount() > 0)
147  emit unreadCountChanged(this);
148 }

References RSS::Item::articleAboutToBeRemoved(), RSS::Item::articles(), asConst(), m_items, RSS::Item::unreadCount(), and RSS::Item::unreadCountChanged().

Referenced by RSS::Session::moveItem(), and RSS::Session::removeItem().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toJsonValue()

QJsonValue Folder::toJsonValue ( bool  withData = false) const
overridevirtual

Implements RSS::Item.

Definition at line 99 of file rss_folder.cpp.

100 {
101  QJsonObject jsonObj;
102  for (Item *item : asConst(items()))
103  jsonObj.insert(item->name(), item->toJsonValue(withData));
104 
105  return jsonObj;
106 }

References asConst(), and items().

Referenced by RSSController::itemsAction().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unreadCount()

int Folder::unreadCount ( ) const
overridevirtual

Implements RSS::Item.

Definition at line 73 of file rss_folder.cpp.

74 {
75  const auto itemList = items();
76  return std::accumulate(itemList.cbegin(), itemList.cend(), 0, [](const int acc, const Item *item)
77  {
78  return (acc + item->unreadCount());
79  });
80 }

References items().

Here is the call graph for this function:

Friends And Related Function Documentation

◆ Session

friend class Session
friend

Definition at line 45 of file rss_folder.h.

Member Data Documentation

◆ m_items

QList<Item *> RSS::Folder::m_items
private

Definition at line 68 of file rss_folder.h.

Referenced by addItem(), items(), and removeItem().


The documentation for this class was generated from the following files: