qBittorrent
feedlistwidget.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  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  *
20  * In addition, as a special exception, the copyright holders give permission to
21  * link this program with the OpenSSL project's "OpenSSL" library (or with
22  * modified versions of it that use the same license as the "OpenSSL" library),
23  * and distribute the linked executables. You must obey the GNU General Public
24  * License in all respects for all of the code used other than "OpenSSL". If you
25  * modify file(s), you may extend this exception to your version of the file(s),
26  * but you are not obligated to do so. If you do not wish to do so, delete this
27  * exception statement from your version.
28  */
29 
30 #pragma once
31 
32 #include <QHash>
33 #include <QTreeWidget>
34 
35 namespace RSS
36 {
37  class Article;
38  class Feed;
39  class Folder;
40  class Item;
41 }
42 
43 class FeedListWidget final : public QTreeWidget
44 {
45  Q_OBJECT
46 
47 public:
48  explicit FeedListWidget(QWidget *parent);
49 
50  QTreeWidgetItem *stickyUnreadItem() const;
51  QList<QTreeWidgetItem *> getAllOpenedFolders(QTreeWidgetItem *parent = nullptr) const;
52  RSS::Item *getRSSItem(QTreeWidgetItem *item) const;
53  QTreeWidgetItem *mapRSSItem(RSS::Item *rssItem) const;
54  QString itemPath(QTreeWidgetItem *item) const;
55  bool isFeed(QTreeWidgetItem *item) const;
56  bool isFolder(QTreeWidgetItem *item) const;
57 
58 private slots:
59  void handleItemAdded(RSS::Item *rssItem);
61  void handleFeedIconLoaded(RSS::Feed *feed);
63  void handleItemPathChanged(RSS::Item *rssItem);
65 
66 private:
67  void dragMoveEvent(QDragMoveEvent *event) override;
68  void dropEvent(QDropEvent *event) override;
69  QTreeWidgetItem *createItem(RSS::Item *rssItem, QTreeWidgetItem *parentItem = nullptr);
70  void fill(QTreeWidgetItem *parent, RSS::Folder *rssParent);
71 
72  QHash<RSS::Item *, QTreeWidgetItem *> m_rssToTreeItemMapping;
73  QTreeWidgetItem *m_unreadStickyItem;
74 };
QString itemPath(QTreeWidgetItem *item) const
void dragMoveEvent(QDragMoveEvent *event) override
void handleItemUnreadCountChanged(RSS::Item *rssItem)
QHash< RSS::Item *, QTreeWidgetItem * > m_rssToTreeItemMapping
QTreeWidgetItem * stickyUnreadItem() const
void handleFeedIconLoaded(RSS::Feed *feed)
bool isFolder(QTreeWidgetItem *item) const
RSS::Item * getRSSItem(QTreeWidgetItem *item) const
void handleItemPathChanged(RSS::Item *rssItem)
QTreeWidgetItem * m_unreadStickyItem
QTreeWidgetItem * createItem(RSS::Item *rssItem, QTreeWidgetItem *parentItem=nullptr)
void handleFeedStateChanged(RSS::Feed *feed)
void handleItemAdded(RSS::Item *rssItem)
void handleItemAboutToBeRemoved(RSS::Item *rssItem)
FeedListWidget(QWidget *parent)
QTreeWidgetItem * mapRSSItem(RSS::Item *rssItem) const
bool isFeed(QTreeWidgetItem *item) const
void dropEvent(QDropEvent *event) override
QList< QTreeWidgetItem * > getAllOpenedFolders(QTreeWidgetItem *parent=nullptr) const
void fill(QTreeWidgetItem *parent, RSS::Folder *rssParent)