1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
|
/*
* Copyright (C) 2007 Tobias Koenig <tokoe@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef CACHEDPROVIDER_H
#define CACHEDPROVIDER_H
#include "comicprovider.h"
#include <QHash>
/**
* This class provides comics from the local cache.
*/
class CachedProvider : public ComicProvider
{
Q_OBJECT
public:
/**
* Creates a new cached provider.
*
* @param parent The parent object.
* param args The arguments.
*/
explicit CachedProvider(QObject *parent, const QVariantList &args = QVariantList());
/**
* Destroys the cached provider.
*/
~CachedProvider() override;
/**
* Returns the identifier type.
*
* Is always StringIdentifier here.
*/
IdentifierType identifierType() const override;
/**
* Returns the type of identifier that is used by this
* comic provider.
*/
QString suffixType() const override;
/**
* Returns the requested image.
*
* Note: This method returns only a valid image after the
* finished() signal has been emitted.
*/
QImage image() const override;
/**
* Returns the identifier of the comic request (name + date).
*/
QString identifier() const override;
/**
* Returns the identifier suffix of the next comic.
*/
QString nextIdentifier() const override;
/**
* Returns the identifier suffix of the previous comic.
*/
QString previousIdentifier() const override;
/**
* Returns the identifier of the first strip.
*/
QString firstStripIdentifier() const override;
/**
* Returns the identifier of the last cached strip.
*/
QString lastCachedStripIdentifier() const;
/**
* Returns the title of the strip.
*/
QString stripTitle() const override;
/**
* Returns the author of the comic.
*/
QString comicAuthor() const override;
/**
* Returns additionalText of the comic.
*/
QString additionalText() const override;
/**
* Returns the name for the comic
*/
QString name() const override;
/**
* Returns whether the comic is leftToRight or not
*/
bool isLeftToRight() const override;
/**
* Returns whether the comic is topToBottom or not
*/
bool isTopToBottom() const override;
/**
* Returns whether a comic with the given @p identifier is cached.
*/
static bool isCached(const QString &identifier);
/**
* Map of keys and values to store in the config file for an individual identifier
*/
typedef QHash<QString, QString> Settings;
/**
* Stores the given @p comic with the given @p identifier in the cache.
*/
static bool storeInCache(const QString &identifier, const QImage &comic, const Settings &info = Settings());
/**
* Returns the website of the comic.
*/
QUrl websiteUrl() const override;
QUrl imageUrl() const override;
/**
* Returns the shop website of the comic.
*/
QUrl shopUrl() const override;
/**
* Returns the maximum number of cached strips per comic, -1 means that there is no limit
* @note defaulte is -1
*/
static int maxComicLimit();
/**
* Sets the maximum number of cached strips per comic, -1 means that there is no limit
*/
static void setMaxComicLimit(int limit);
private Q_SLOTS:
void triggerFinished();
private:
static const int CACHE_DEFAULT;
};
#endif
|