qBittorrent
RSS::Item Class Referenceabstract

#include <rss_item.h>

Inheritance diagram for RSS::Item:
Collaboration diagram for RSS::Item:

Signals

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)
 

Public Member Functions

virtual QList< Article * > articles () const =0
 
virtual int unreadCount () const =0
 
virtual void markAsRead ()=0
 
virtual void refresh ()=0
 
QString path () const
 
QString name () const
 
virtual QJsonValue toJsonValue (bool withData=false) const =0
 

Static Public Member Functions

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

static const QChar PathSeparator
 

Protected Member Functions

 Item (const QString &path)
 
 ~Item () override
 
virtual void cleanup ()=0
 

Private Member Functions

void setPath (const QString &path)
 

Private Attributes

QString m_path
 

Friends

class Folder
 
class Session
 

Detailed Description

Definition at line 42 of file rss_item.h.

Constructor & Destructor Documentation

◆ Item()

Item::Item ( const QString &  path)
explicitprotected

Definition at line 41 of file rss_item.cpp.

42  : m_path(path)
43 {
44 }
QString m_path
Definition: rss_item.h:86
QString path() const
Definition: rss_item.cpp:57

◆ ~Item()

Item::~Item ( )
overrideprotected

Definition at line 46 of file rss_item.cpp.

46 {}

Member Function Documentation

◆ aboutToBeDestroyed

void RSS::Item::aboutToBeDestroyed ( Item item = nullptr)
signal

Referenced by RSS::Session::addItem(), RSS::Feed::~Feed(), and RSS::Folder::~Folder().

Here is the caller graph for this function:

◆ articleAboutToBeRemoved

void RSS::Item::articleAboutToBeRemoved ( Article article)
signal

◆ articleRead

void RSS::Item::articleRead ( Article article)
signal

Referenced by RSS::Folder::addItem(), RSS::Feed::handleArticleRead(), RSS::Feed::markAsRead(), and ArticleListWidget::setRSSItem().

Here is the caller graph for this function:

◆ articles()

virtual QList<Article *> RSS::Item::articles ( ) const
pure virtual

Implemented in RSS::Folder, and RSS::Feed.

Referenced by RSS::Folder::addItem(), RSS::Folder::removeItem(), and ArticleListWidget::setRSSItem().

Here is the caller graph for this function:

◆ cleanup()

virtual void RSS::Item::cleanup ( )
protectedpure virtual

Implemented in RSS::Folder, and RSS::Feed.

◆ expandPath()

QStringList Item::expandPath ( const QString &  path)
static

Definition at line 90 of file rss_item.cpp.

91 {
92  QStringList result;
93  if (path.isEmpty()) return result;
94  // if (!isValidRSSFolderName(folder))
95  // return result;
96 
97  int index = 0;
98  while ((index = path.indexOf(Item::PathSeparator, index)) >= 0)
99  {
100  result << path.left(index);
101  ++index;
102  }
103  result << path;
104 
105  return result;
106 }
static const QChar PathSeparator
Definition: rss_item.h:61

References path(), and PathSeparator.

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

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

◆ isValidPath()

bool Item::isValidPath ( const QString &  path)
static

Definition at line 67 of file rss_item.cpp.

68 {
69  static const QRegularExpression re(
70  QString(R"(\A[^\%1]+(\%1[^\%1]+)*\z)").arg(Item::PathSeparator)
71  , QRegularExpression::DontCaptureOption);
72 
73  if (path.isEmpty() || !re.match(path).hasMatch())
74  {
75  qDebug() << "Incorrect RSS Item path:" << path;
76  return false;
77  }
78 
79  return true;
80 }

References path(), and PathSeparator.

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

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

◆ joinPath()

QString Item::joinPath ( const QString &  path1,
const QString &  path2 
)
static

Definition at line 82 of file rss_item.cpp.

83 {
84  if (path1.isEmpty())
85  return path2;
86 
87  return (path1 + Item::PathSeparator + path2);
88 }

References PathSeparator.

Referenced by RSS::Session::addFeedToFolder(), RSS::Session::addSubfolder(), RSSWidget::askNewFolder(), FeedListWidget::dropEvent(), RSS::Session::handleFeedTitleChanged(), RSS::Session::loadLegacy(), RSSWidget::on_newFeedButton_clicked(), and RSSWidget::renameSelectedRSSItem().

Here is the caller graph for this function:

◆ markAsRead()

virtual void RSS::Item::markAsRead ( )
pure virtual

Implemented in RSS::Folder, and RSS::Feed.

Referenced by RSSController::markAsReadAction(), and RSSWidget::on_markReadButton_clicked().

Here is the caller graph for this function:

◆ name()

QString Item::name ( ) const

◆ newArticle

void RSS::Item::newArticle ( Article article)
signal

◆ parentPath()

QString Item::parentPath ( const QString &  path)
static

Definition at line 108 of file rss_item.cpp.

109 {
110  int pos;
111  return ((pos = path.lastIndexOf(Item::PathSeparator)) >= 0 ? path.left(pos) : "");
112 }

References path(), and PathSeparator.

Referenced by RSS::Session::handleFeedTitleChanged(), FeedListWidget::handleItemAdded(), FeedListWidget::handleItemPathChanged(), RSS::Session::loadLegacy(), RSS::Session::moveItem(), RSS::Session::prepareItemDest(), RSS::Session::removeItem(), and RSSWidget::renameSelectedRSSItem().

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

◆ path()

◆ pathChanged

void RSS::Item::pathChanged ( Item item = nullptr)
signal

Referenced by RSS::Session::addItem(), and setPath().

Here is the caller graph for this function:

◆ refresh()

virtual void RSS::Item::refresh ( )
pure virtual

Implemented in RSS::Folder, and RSS::Feed.

Referenced by RSSController::refreshItemAction(), and RSSWidget::refreshSelectedItems().

Here is the caller graph for this function:

◆ relativeName()

QString Item::relativeName ( const QString &  path)
static

Definition at line 114 of file rss_item.cpp.

115 {
116  int pos;
117  return ((pos = path.lastIndexOf(Item::PathSeparator)) >= 0 ? path.right(path.size() - (pos + 1)) : path);
118 }

References path(), and PathSeparator.

Referenced by RSS::Session::loadLegacy(), and name().

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

◆ setPath()

void Item::setPath ( const QString &  path)
private

Definition at line 48 of file rss_item.cpp.

49 {
50  if (path != m_path)
51  {
52  m_path = path;
53  emit pathChanged(this);
54  }
55 }
void pathChanged(Item *item=nullptr)

References m_path, path(), and pathChanged().

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

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

◆ toJsonValue()

virtual QJsonValue RSS::Item::toJsonValue ( bool  withData = false) const
pure virtual

Implemented in RSS::Folder, and RSS::Feed.

◆ unreadCount()

virtual int RSS::Item::unreadCount ( ) const
pure virtual

◆ unreadCountChanged

Friends And Related Function Documentation

◆ Folder

friend class Folder
friend

Definition at line 47 of file rss_item.h.

◆ Session

friend class Session
friend

Definition at line 48 of file rss_item.h.

Member Data Documentation

◆ m_path

QString RSS::Item::m_path
private

Definition at line 86 of file rss_item.h.

Referenced by path(), and setPath().

◆ PathSeparator

const QChar Item::PathSeparator
static

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