qBittorrent
rss_item.h
Go to the documentation of this file.
1 /*
2  * Bittorrent Client using Qt and libtorrent.
3  * Copyright (C) 2017 Vladimir Golovnev <glassez@yandex.ru>
4  * Copyright (C) 2010 Christophe Dumez <chris@qbittorrent.org>
5  * Copyright (C) 2010 Arnaud Demaiziere <arnaud@qbittorrent.org>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  * In addition, as a special exception, the copyright holders give permission to
22  * link this program with the OpenSSL project's "OpenSSL" library (or with
23  * modified versions of it that use the same license as the "OpenSSL" library),
24  * and distribute the linked executables. You must obey the GNU General Public
25  * License in all respects for all of the code used other than "OpenSSL". If you
26  * modify file(s), you may extend this exception to your version of the file(s),
27  * but you are not obligated to do so. If you do not wish to do so, delete this
28  * exception statement from your version.
29  */
30 
31 #pragma once
32 
33 #include <QList>
34 #include <QObject>
35 
36 namespace RSS
37 {
38  class Article;
39  class Folder;
40  class Session;
41 
42  class Item : public QObject
43  {
44  Q_OBJECT
45  Q_DISABLE_COPY_MOVE(Item)
46 
47  friend class Folder;
48  friend class Session;
49 
50  public:
51  virtual QList<Article *> articles() const = 0;
52  virtual int unreadCount() const = 0;
53  virtual void markAsRead() = 0;
54  virtual void refresh() = 0;
55 
56  QString path() const;
57  QString name() const;
58 
59  virtual QJsonValue toJsonValue(bool withData = false) const = 0;
60 
61  static const QChar PathSeparator;
62 
63  static bool isValidPath(const QString &path);
64  static QString joinPath(const QString &path1, const QString &path2);
65  static QStringList expandPath(const QString &path);
66  static QString parentPath(const QString &path);
67  static QString relativeName(const QString &path);
68 
69  signals:
70  void pathChanged(Item *item = nullptr);
71  void unreadCountChanged(Item *item = nullptr);
72  void aboutToBeDestroyed(Item *item = nullptr);
73  void newArticle(Article *article);
74  void articleRead(Article *article);
76 
77  protected:
78  explicit Item(const QString &path);
79  ~Item() override;
80 
81  virtual void cleanup() = 0;
82 
83  private:
84  void setPath(const QString &path);
85 
86  QString m_path;
87  };
88 }
Definition: rss_article.h:43
static QString joinPath(const QString &path1, const QString &path2)
Definition: rss_item.cpp:82
void newArticle(Article *article)
virtual void markAsRead()=0
void pathChanged(Item *item=nullptr)
void articleAboutToBeRemoved(Article *article)
virtual QList< Article * > articles() const =0
void aboutToBeDestroyed(Item *item=nullptr)
static const QChar PathSeparator
Definition: rss_item.h:61
static QStringList expandPath(const QString &path)
Definition: rss_item.cpp:90
static QString parentPath(const QString &path)
Definition: rss_item.cpp:108
void unreadCountChanged(Item *item=nullptr)
static QString relativeName(const QString &path)
Definition: rss_item.cpp:114
QString name() const
Definition: rss_item.cpp:62
virtual void refresh()=0
void setPath(const QString &path)
Definition: rss_item.cpp:48
void articleRead(Article *article)
virtual int unreadCount() const =0
QString m_path
Definition: rss_item.h:86
static bool isValidPath(const QString &path)
Definition: rss_item.cpp:67
virtual QJsonValue toJsonValue(bool withData=false) const =0
QString path() const
Definition: rss_item.cpp:57
virtual void cleanup()=0