File indexing completed on 2024-03-24 05:00:53
0001 /* This file is part of the KDE project 0002 0003 SPDX-FileCopyrightText: 2004 Gary Cramblitt <garycramblitt@comcast.net> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef _AKREGATORPLUGIN_H_ 0009 #define _AKREGATORPLUGIN_H_ 0010 0011 #include <kabstractfileitemactionplugin.h> 0012 0013 class KFileItem; 0014 class KFileItemListProperties; 0015 0016 namespace Akregator 0017 { 0018 0019 /** 0020 * Class implementing a plugin which adds an "Add to Akregator" entry to feed files in the file manager 0021 */ 0022 class AkregatorMenu : public KAbstractFileItemActionPlugin 0023 { 0024 Q_OBJECT 0025 0026 public: 0027 /** 0028 * @brief Constructor 0029 */ 0030 AkregatorMenu(QObject *parent, const QVariantList &args); 0031 0032 /** 0033 * @brief Destructor 0034 */ 0035 ~AkregatorMenu() override = default; 0036 0037 /** 0038 * @brief Override of `KAbstractFileItemActionPlugin::actions` 0039 * @param fileItemInfos information about the selected file items. 0040 * @param parent the parent for the returned actions 0041 */ 0042 QList<QAction *> actions(const KFileItemListProperties &fileItemInfos, QWidget *parent) override; 0043 0044 public slots: 0045 /** 0046 * @brief Adds the feed with the given URL to Akregator 0047 * @param url the url of the feed 0048 */ 0049 void addFeed(const QString &url); 0050 0051 private: 0052 /** 0053 * @brief Whether or not the given `KFileItem` represents a feed URL 0054 * 0055 * A `KFileItem` is considered to represent a feed URL if its mimetype is one of those listed in #m_feedMimeTypes. 0056 * @param item the item describing the URL to check 0057 * @return `true` if @p item represents a feed and `false` otherwise. 0058 */ 0059 bool isFeedUrl(const KFileItem &item) const; 0060 0061 private: 0062 /** 0063 * @brief A list of suitable mimetypes for feeds 0064 */ 0065 const QStringList m_feedMimeTypes = {QStringLiteral("application/rss+xml"), QStringLiteral("text/rdf"), QStringLiteral("application/xml")}; 0066 }; 0067 0068 } 0069 0070 #endif