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
|
/*
* 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 <QtCore/QHash>
/**
* This class provides comics from the local cache.
*/
class CachedProvider : public ComicProvider
{
Q_OBJECT
public:
/**
* Creates a new cached provider.
*
* @param identifier The identifier of the cached comic.
* @param parent The parent object.
*/
explicit CachedProvider( QObject *parent, const QVariantList &args = QVariantList() );
/**
* Destroys the cached provider.
*/
~CachedProvider();
/**
* Returns the identifier type.
*
* Is always StringIdentifier here.
*/
IdentifierType identifierType() const;
/**
* Returns the type of identifier that is used by this
* comic provider.
*/
virtual QString suffixType() const;
/**
* Returns the requested image.
*
* Note: This method returns only a valid image after the
* finished() signal has been emitted.
*/
virtual QImage image() const;
/**
* Returns the identifier of the comic request (name + date).
*/
virtual QString identifier() const;
/**
* Returns the identifier suffix of the next comic.
*/
virtual QString nextIdentifier() const;
/**
* Returns the identifier suffix of the previous comic.
*/
virtual QString previousIdentifier() const;
/**
* Returns the identifier of the first strip.
*/
virtual QString firstStripIdentifier() const;
/**
* Returns the identifier of the last cached strip.
*/
QString lastCachedStripIdentifier() const;
/**
* Returns the title of the strip.
*/
virtual QString stripTitle() const;
/**
* Returns the author of the comic.
*/
virtual QString comicAuthor() const;
/**
* Returns additionalText of the comic.
*/
virtual QString additionalText() const;
/**
* Returns the name for the comic
*/
virtual QString name() const;
/**
* Returns wether the comic is leftToRight or not
*/
virtual bool isLeftToRight() const;
/**
* Returns wether the comic is topToBottom or not
*/
virtual bool isTopToBottom() const;
/**
* 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.
*/
virtual KUrl websiteUrl() const;
/**
* Returns the shop website of the comic.
*/
virtual KUrl shopUrl() const;
private Q_SLOTS:
void triggerFinished();
};
#endif
|