source: trunk/qt/FaviconCache.h @ 14539

Last change on this file since 14539 was 14539, checked in by mikedld, 6 years ago

Unify/prettify Qt client headers style

  • Property svn:keywords set to Date Rev Author Id
File size: 1.2 KB
Line 
1/*
2 * This file Copyright (C) 2012-2015 Mnemosyne LLC
3 *
4 * It may be used under the GNU GPL versions 2 or 3
5 * or any future license endorsed by Mnemosyne LLC.
6 *
7 * $Id: FaviconCache.h 14539 2015-06-12 22:12:12Z mikedld $
8 */
9
10#ifndef QTR_FAVICON_CACHE_H
11#define QTR_FAVICON_CACHE_H
12
13#include <QMap>
14#include <QString>
15#include <QObject>
16#include <QPixmap>
17
18class QNetworkAccessManager;
19class QNetworkReply;
20class QUrl;
21
22class FaviconCache: public QObject
23{
24    Q_OBJECT
25
26  public:
27    FaviconCache ();
28    virtual ~FaviconCache ();
29
30    // returns a cached pixmap, or a NULL pixmap if there's no match in the cache
31    QPixmap find (const QUrl& url);
32
33    // returns a cached pixmap, or a NULL pixmap if there's no match in the cache
34    QPixmap findFromHost (const QString& host);
35
36    // this will emit a signal when (if) the icon becomes ready
37    void add (const QUrl& url);
38
39    static QString getHost (const QUrl& url);
40    static QSize getIconSize ();
41
42  signals:
43    void pixmapReady (const QString& host);
44
45  private:
46    QString getCacheDir ();
47    void ensureCacheDirHasBeenScanned ();
48
49  private slots:
50    void onRequestFinished (QNetworkReply * reply);
51
52  private:
53    QNetworkAccessManager * myNAM;
54    QMap<QString, QPixmap> myPixmaps;
55};
56
57#endif // QTR_FAVICON_CACHE_H
Note: See TracBrowser for help on using the repository browser.