File indexing completed on 2024-04-21 05:10:34
0001 /* 0002 This file is part of Akregator. 0003 0004 SPDX-FileCopyrightText: 2007 Frank Osterfeld <osterfeld@kde.org> 0005 0006 SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0 0007 */ 0008 0009 #pragma once 0010 0011 #include <KCompositeJob> 0012 0013 #include <QList> 0014 #include <QMap> 0015 #include <QPointer> 0016 #include <QString> 0017 0018 #include "akregator_export.h" 0019 0020 // transitional job classes 0021 namespace Akregator 0022 { 0023 class Article; 0024 class FeedList; 0025 class TreeNode; 0026 0027 struct ArticleId { 0028 QString feedUrl; 0029 QString guid; 0030 [[nodiscard]] bool operator<(const ArticleId &other) const 0031 { 0032 return feedUrl < other.feedUrl || (feedUrl == other.feedUrl && guid < other.guid); 0033 } 0034 }; 0035 0036 using ArticleIdList = QList<Akregator::ArticleId>; 0037 0038 class AKREGATOR_EXPORT CompositeJob : public KCompositeJob 0039 { 0040 Q_OBJECT 0041 public: 0042 explicit CompositeJob(QObject *parent = nullptr); 0043 [[nodiscard]] bool addSubjob(KJob *job) override; 0044 void start() override; 0045 }; 0046 0047 class AKREGATOR_EXPORT ArticleDeleteJob : public KJob 0048 { 0049 Q_OBJECT 0050 public: 0051 explicit ArticleDeleteJob(QObject *parent = nullptr); 0052 0053 void appendArticleIds(const Akregator::ArticleIdList &ids); 0054 void appendArticleId(const Akregator::ArticleId &id); 0055 0056 void start() override; 0057 0058 private Q_SLOTS: 0059 void doStart(); 0060 0061 private: 0062 QSharedPointer<FeedList> m_feedList; 0063 ArticleIdList m_ids; 0064 }; 0065 0066 class AKREGATOR_EXPORT ArticleModifyJob : public KJob 0067 { 0068 Q_OBJECT 0069 public: 0070 explicit ArticleModifyJob(QObject *parent = nullptr); 0071 0072 // TODO replace this by passing modified item later 0073 void setStatus(const ArticleId &id, int status); 0074 void setKeep(const ArticleId &id, bool keep); 0075 0076 void start() override; 0077 0078 private Q_SLOTS: 0079 void doStart(); 0080 0081 private: 0082 QSharedPointer<FeedList> m_feedList; 0083 QMap<ArticleId, bool> m_keepFlags; 0084 QMap<ArticleId, int> m_status; 0085 }; 0086 0087 class AKREGATOR_EXPORT ArticleListJob : public KJob 0088 { 0089 Q_OBJECT 0090 public: 0091 explicit ArticleListJob(TreeNode *parent = nullptr); 0092 0093 QList<Article> articles() const; 0094 TreeNode *node() const; 0095 0096 void start() override; 0097 0098 enum Error { ListingFailed = KJob::UserDefinedError }; 0099 0100 private Q_SLOTS: 0101 void doList(); 0102 0103 private: 0104 const QPointer<TreeNode> m_node; 0105 QList<Article> m_articles; 0106 }; 0107 } // namespace akregator