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 | | ||||
dvratil: `nullptr` instead of `0` | |||||
49 | explicit FilterUnreadProxyModel(QObject* parent = nullptr); | ||||
50 | | ||||
dvratil: `{` and `}` on separate lines, ideally un-inline | |||||
51 | bool doFilter() const | ||||
dvratil: un-inline | |||||
52 | { | ||||
53 | return m_doFilter; | ||||
54 | } | ||||
dvratil: - missing `override`
- un-inline this function | |||||
55 | | ||||
56 | void setDoFilter(bool v) | ||||
mlaurent: move code in cpp file please | |||||
57 | { | ||||
58 | m_doFilter = v; | ||||
59 | invalidateFilter(); | ||||
60 | } | ||||
61 | | ||||
62 | //reimpl | ||||
63 | void setSourceModel(QAbstractItemModel *src) override | ||||
64 | { | ||||
65 | clearCache(); | ||||
66 | QSortFilterProxyModel::setSourceModel(src); | ||||
67 | } | ||||
68 | | ||||
69 | public slots: | ||||
70 | void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected); | ||||
71 | void clearCache(); | ||||
72 | | ||||
73 | private: | ||||
74 | //reimpl | ||||
75 | bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override; | ||||
dvratil: Missing `override` | |||||
76 | | ||||
77 | typedef QSet<QModelIndex> SelectionHierarchy; | ||||
78 | | ||||
79 | bool m_doFilter; | ||||
80 | SelectionHierarchy m_selectedHierarchy; | ||||
81 | }; | ||||
82 | | ||||
39 | class AKREGATORPART_EXPORT SubscriptionListModel : public QAbstractItemModel | 83 | class AKREGATORPART_EXPORT SubscriptionListModel : public QAbstractItemModel | ||
40 | { | 84 | { | ||
41 | Q_OBJECT | 85 | Q_OBJECT | ||
42 | public: | 86 | public: | ||
43 | 87 | | |||
44 | enum Role { | 88 | enum Role { | ||
45 | SubscriptionIdRole = Qt::UserRole, | 89 | SubscriptionIdRole = Qt::UserRole, | ||
46 | IsFetchableRole, | 90 | IsFetchableRole, | ||
Show All 31 Lines | |||||
78 | QStringList mimeTypes() const override; | 122 | QStringList mimeTypes() const override; | ||
79 | 123 | | |||
80 | QMimeData *mimeData(const QModelIndexList &indexes) const override; | 124 | QMimeData *mimeData(const QModelIndexList &indexes) const override; | ||
81 | 125 | | |||
82 | bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override; | 126 | bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override; | ||
83 | 127 | | |||
84 | bool setData(const QModelIndex &idx, const QVariant &value, int role = Qt::EditRole) override; | 128 | bool setData(const QModelIndex &idx, const QVariant &value, int role = Qt::EditRole) override; | ||
85 | 129 | | |||
86 | uint nodeIdForIndex(const QModelIndex &index) const; | | |||
87 | | ||||
88 | private: | 130 | private: | ||
89 | QModelIndex indexForNode(const TreeNode *node) const; | 131 | QModelIndex indexForNode(const TreeNode *node) const; | ||
90 | 132 | | |||
91 | private Q_SLOTS: | 133 | private Q_SLOTS: | ||
92 | 134 | | |||
93 | void subscriptionAdded(Akregator::TreeNode *); | 135 | void subscriptionAdded(Akregator::TreeNode *); | ||
94 | 136 | | |||
95 | void aboutToRemoveSubscription(Akregator::TreeNode *); | 137 | void aboutToRemoveSubscription(Akregator::TreeNode *); | ||
Show All 21 Lines | |||||
117 | class AKREGATORPART_EXPORT FolderExpansionHandler : public QObject | 159 | class AKREGATORPART_EXPORT FolderExpansionHandler : public QObject | ||
118 | { | 160 | { | ||
119 | Q_OBJECT | 161 | Q_OBJECT | ||
120 | 162 | | |||
121 | public: | 163 | public: | ||
122 | explicit FolderExpansionHandler(QObject *parent = nullptr); | 164 | explicit FolderExpansionHandler(QObject *parent = nullptr); | ||
123 | 165 | | |||
124 | void setFeedList(const QSharedPointer<FeedList> &feedList); | 166 | void setFeedList(const QSharedPointer<FeedList> &feedList); | ||
125 | void setModel(Akregator::SubscriptionListModel *model); | 167 | void setModel(QAbstractItemModel *model); | ||
126 | 168 | | |||
127 | public Q_SLOTS: | 169 | public Q_SLOTS: | ||
128 | void itemExpanded(const QModelIndex &index); | 170 | void itemExpanded(const QModelIndex &index); | ||
129 | void itemCollapsed(const QModelIndex &index); | 171 | void itemCollapsed(const QModelIndex &index); | ||
130 | 172 | | |||
131 | private: | 173 | private: | ||
132 | void setExpanded(const QModelIndex &index, bool expanded); | 174 | void setExpanded(const QModelIndex &index, bool expanded); | ||
133 | 175 | | |||
134 | private: | 176 | private: | ||
135 | QSharedPointer<FeedList> m_feedList; | 177 | QSharedPointer<FeedList> m_feedList; | ||
136 | SubscriptionListModel *m_model = nullptr; | 178 | QAbstractItemModel *m_model = nullptr; | ||
137 | }; | 179 | }; | ||
138 | } // namespace Akregator | 180 | } // namespace Akregator | ||
139 | 181 | | |||
140 | #endif // AKREGATOR_SUBSCRIPTIONLISTMODEL_H | 182 | #endif // AKREGATOR_SUBSCRIPTIONLISTMODEL_H |
{ on a new line