Changeset View
Changeset View
Standalone View
Standalone View
src/subscription/subscriptionlistmodel.h
Show All 21 Lines | 1 | /* | |||
---|---|---|---|---|---|
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. | ||
23 | */ | 23 | */ | ||
24 | #ifndef AKREGATOR_SUBSCRIPTIONLISTMODEL_H | 24 | #ifndef AKREGATOR_SUBSCRIPTIONLISTMODEL_H | ||
25 | #define AKREGATOR_SUBSCRIPTIONLISTMODEL_H | 25 | #define AKREGATOR_SUBSCRIPTIONLISTMODEL_H | ||
26 | 26 | | |||
27 | #include "akregatorpart_export.h" | 27 | #include "akregatorpart_export.h" | ||
28 | 28 | | |||
29 | #include <QAbstractItemModel> | 29 | #include <QAbstractItemModel> | ||
30 | #include <QSet> | ||||
31 | #include <QSortFilterProxyModel> | ||||
30 | 32 | | |||
31 | #include <QSharedPointer> | 33 | #include <QSharedPointer> | ||
32 | 34 | | |||
33 | namespace Akregator { | 35 | namespace Akregator { | ||
34 | class Feed; | 36 | class Feed; | ||
35 | class FeedList; | 37 | class FeedList; | ||
36 | class Folder; | 38 | class Folder; | ||
37 | class TreeNode; | 39 | class TreeNode; | ||
38 | 40 | | |||
41 | /** | ||||
42 | * Filters feeds with unread counts. | ||||
43 | */ | ||||
44 | class FilterUnreadProxyModel : public QSortFilterProxyModel | ||||
dvratil: `{` on a new line | |||||
45 | { | ||||
46 | Q_OBJECT | ||||
47 | public: | ||||
48 | explicit FilterUnreadProxyModel(QObject* parent = nullptr); | ||||
dvratil: `nullptr` instead of `0` | |||||
49 | | ||||
50 | bool doFilter() const; | ||||
dvratil: `{` and `}` on separate lines, ideally un-inline | |||||
51 | | ||||
dvratil: un-inline | |||||
52 | void setDoFilter(bool v); | ||||
53 | | ||||
54 | void setSourceModel(QAbstractItemModel *src) override; | ||||
dvratil: - missing `override`
- un-inline this function | |||||
55 | | ||||
56 | public slots: | ||||
mlaurent: move code in cpp file please | |||||
57 | void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected); | ||||
58 | void clearCache(); | ||||
59 | | ||||
60 | private: | ||||
61 | bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override; | ||||
62 | | ||||
63 | typedef QSet<QModelIndex> SelectionHierarchy; | ||||
64 | | ||||
65 | bool m_doFilter; | ||||
66 | SelectionHierarchy m_selectedHierarchy; | ||||
67 | }; | ||||
68 | | ||||
39 | class AKREGATORPART_EXPORT SubscriptionListModel : public QAbstractItemModel | 69 | class AKREGATORPART_EXPORT SubscriptionListModel : public QAbstractItemModel | ||
40 | { | 70 | { | ||
41 | Q_OBJECT | 71 | Q_OBJECT | ||
42 | public: | 72 | public: | ||
43 | 73 | | |||
44 | enum Role { | 74 | enum Role { | ||
45 | SubscriptionIdRole = Qt::UserRole, | 75 | SubscriptionIdRole = Qt::UserRole, | ||
dvratil: Missing `override` | |||||
46 | IsFetchableRole, | 76 | IsFetchableRole, | ||
47 | IsGroupRole, | 77 | IsGroupRole, | ||
48 | IsAggregationRole, | 78 | IsAggregationRole, | ||
49 | LinkRole, | 79 | LinkRole, | ||
50 | IdRole, | 80 | IdRole, | ||
51 | IsOpenRole, | 81 | IsOpenRole, | ||
52 | HasUnreadRole | 82 | HasUnreadRole | ||
53 | }; | 83 | }; | ||
Show All 24 Lines | |||||
78 | QStringList mimeTypes() const override; | 108 | QStringList mimeTypes() const override; | ||
79 | 109 | | |||
80 | QMimeData *mimeData(const QModelIndexList &indexes) const override; | 110 | QMimeData *mimeData(const QModelIndexList &indexes) const override; | ||
81 | 111 | | |||
82 | bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override; | 112 | bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override; | ||
83 | 113 | | |||
84 | bool setData(const QModelIndex &idx, const QVariant &value, int role = Qt::EditRole) override; | 114 | bool setData(const QModelIndex &idx, const QVariant &value, int role = Qt::EditRole) override; | ||
85 | 115 | | |||
86 | uint nodeIdForIndex(const QModelIndex &index) const; | | |||
87 | | ||||
88 | private: | 116 | private: | ||
89 | QModelIndex indexForNode(const TreeNode *node) const; | 117 | QModelIndex indexForNode(const TreeNode *node) const; | ||
90 | 118 | | |||
91 | private Q_SLOTS: | 119 | private Q_SLOTS: | ||
92 | 120 | | |||
93 | void subscriptionAdded(Akregator::TreeNode *); | 121 | void subscriptionAdded(Akregator::TreeNode *); | ||
94 | 122 | | |||
95 | void aboutToRemoveSubscription(Akregator::TreeNode *); | 123 | void aboutToRemoveSubscription(Akregator::TreeNode *); | ||
Show All 21 Lines | |||||
117 | class AKREGATORPART_EXPORT FolderExpansionHandler : public QObject | 145 | class AKREGATORPART_EXPORT FolderExpansionHandler : public QObject | ||
118 | { | 146 | { | ||
119 | Q_OBJECT | 147 | Q_OBJECT | ||
120 | 148 | | |||
121 | public: | 149 | public: | ||
122 | explicit FolderExpansionHandler(QObject *parent = nullptr); | 150 | explicit FolderExpansionHandler(QObject *parent = nullptr); | ||
123 | 151 | | |||
124 | void setFeedList(const QSharedPointer<FeedList> &feedList); | 152 | void setFeedList(const QSharedPointer<FeedList> &feedList); | ||
125 | void setModel(Akregator::SubscriptionListModel *model); | 153 | void setModel(QAbstractItemModel *model); | ||
126 | 154 | | |||
127 | public Q_SLOTS: | 155 | public Q_SLOTS: | ||
128 | void itemExpanded(const QModelIndex &index); | 156 | void itemExpanded(const QModelIndex &index); | ||
129 | void itemCollapsed(const QModelIndex &index); | 157 | void itemCollapsed(const QModelIndex &index); | ||
130 | 158 | | |||
131 | private: | 159 | private: | ||
132 | void setExpanded(const QModelIndex &index, bool expanded); | 160 | void setExpanded(const QModelIndex &index, bool expanded); | ||
133 | 161 | | |||
134 | private: | 162 | private: | ||
135 | QSharedPointer<FeedList> m_feedList; | 163 | QSharedPointer<FeedList> m_feedList; | ||
136 | SubscriptionListModel *m_model = nullptr; | 164 | QAbstractItemModel *m_model = nullptr; | ||
137 | }; | 165 | }; | ||
138 | } // namespace Akregator | 166 | } // namespace Akregator | ||
139 | 167 | | |||
140 | #endif // AKREGATOR_SUBSCRIPTIONLISTMODEL_H | 168 | #endif // AKREGATOR_SUBSCRIPTIONLISTMODEL_H |
{ on a new line