Warning, file /plasma/kdeplasma-addons/applets/comic/engine/cachedprovider.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002  *   SPDX-FileCopyrightText: 2007 Tobias Koenig <tokoe@kde.org>
0003  *   SPDX-FileCopyrightText: 2022 Alexander Lohnau <alexander.lohnau@gmx.de>
0004  *
0005  *   SPDX-License-Identifier: LGPL-2.0-only
0006  */
0007 
0008 #ifndef CACHEDPROVIDER_H
0009 #define CACHEDPROVIDER_H
0010 
0011 #include "comicprovider.h"
0012 #include "types.h"
0013 
0014 #include <QHash>
0015 
0016 /**
0017  * This class provides comics from the local cache.
0018  */
0019 class CachedProvider : public ComicProvider
0020 {
0021     Q_OBJECT
0022 
0023 public:
0024     /**
0025      * Creates a new cached provider.
0026      *
0027      * @param parent The parent object.
0028      * param args The arguments.
0029      */
0030     explicit CachedProvider(QObject *parent, const KPluginMetaData &data, IdentifierType type, const QString &identifier);
0031 
0032     /**
0033      * Destroys the cached provider.
0034      */
0035     ~CachedProvider() override;
0036 
0037     /**
0038      * Returns the identifier type.
0039      *
0040      * Is always StringIdentifier here.
0041      */
0042     IdentifierType identifierType() const override;
0043 
0044     /**
0045      * Returns the requested image.
0046      *
0047      * Note: This method returns only a valid image after the
0048      *       finished() signal has been emitted.
0049      */
0050     QImage image() const override;
0051 
0052     /**
0053      * Returns the identifier of the comic request (name + date).
0054      */
0055     QString identifier() const override;
0056 
0057     /**
0058      * Returns the identifier suffix of the next comic.
0059      */
0060     QString nextIdentifier() const override;
0061 
0062     /**
0063      * Returns the identifier suffix of the previous comic.
0064      */
0065     QString previousIdentifier() const override;
0066 
0067     /**
0068      * Returns the identifier of the first strip.
0069      */
0070     QString firstStripIdentifier() const override;
0071 
0072     /**
0073      * Returns the identifier of the last cached strip.
0074      */
0075     QString lastCachedStripIdentifier() const;
0076 
0077     /**
0078      * Returns the title of the strip.
0079      */
0080     QString stripTitle() const override;
0081 
0082     /**
0083      * Returns the author of the comic.
0084      */
0085     QString comicAuthor() const override;
0086 
0087     /**
0088      * Returns additionalText of the comic.
0089      */
0090     QString additionalText() const override;
0091 
0092     /**
0093      * Returns the name for the comic
0094      */
0095     QString name() const override;
0096 
0097     /**
0098      * Returns whether the comic is leftToRight or not
0099      */
0100     bool isLeftToRight() const override;
0101 
0102     /**
0103      * Returns whether the comic is topToBottom or not
0104      */
0105     bool isTopToBottom() const override;
0106 
0107     /**
0108      * Returns whether a comic with the given @p identifier is cached.
0109      */
0110     static bool isCached(const QString &identifier);
0111 
0112     /**
0113      * Map of keys and values to store in the config file for an individual identifier
0114      */
0115     typedef QHash<QString, QString> Settings;
0116 
0117     /**
0118      * Stores the given @p comic with the given @p identifier in the cache.
0119      */
0120     static bool storeInCache(const QString &identifier, const QImage &comic, const ComicMetaData &info);
0121 
0122     /**
0123      * Returns the website of the comic.
0124      */
0125     QUrl websiteUrl() const override;
0126 
0127     QUrl imageUrl() const override;
0128 
0129     /**
0130      * Returns the shop website of the comic.
0131      */
0132     QUrl shopUrl() const override;
0133 
0134     /**
0135      * Returns the maximum number of cached strips per comic, -1 means that there is no limit
0136      * @note defaulte is -1
0137      */
0138     static int maxComicLimit();
0139 
0140     /**
0141      * Sets the maximum number of cached strips per comic, -1 means that there is no limit
0142      */
0143     static void setMaxComicLimit(int limit);
0144 
0145 private Q_SLOTS:
0146     void triggerFinished();
0147 
0148 private:
0149     static const int CACHE_DEFAULT;
0150 };
0151 
0152 #endif