source: trunk/qt/favicon.h @ 11053

Last change on this file since 11053 was 11053, checked in by charles, 12 years ago

(trunk qt) readability changes to the favicon cache

File size: 1.3 KB
Line 
1/*
2 * This file Copyright (C) 2010 Mnemosyne LLC
3 *
4 * This file is licensed by the GPL version 2.  Works owned by the
5 * Transmission project are granted a special exemption to clause 2(b)
6 * so that the bulk of its code can remain under the MIT license.
7 * This exemption does not extend to derived works not owned by
8 * the Transmission project.
9 *
10 * $Id$
11 */
12
13#ifndef FAVICON_CACHE_H
14#define FAVICON_CACHE_H
15
16class QNetworkAccessManager;
17class QNetworkReply;
18class QUrl;
19
20#include <QMap>
21#include <QString>
22#include <QStringList>
23#include <QObject>
24#include <QPixmap>
25
26class Favicons: public QObject
27{
28        Q_OBJECT;
29
30    public:
31
32        Favicons();
33        virtual ~Favicons();
34
35        /* returns a cached pixmap, or a NULL pixmap if there's no match in the cache */
36        QPixmap find( const QUrl& url );
37
38        /* this will emit a signal when (if) the icon becomes ready */
39        void add( const QUrl& url );
40
41    signals:
42
43        void pixmapReady( const QString& host );
44
45    private:
46
47        QStringList myPending;
48        QNetworkAccessManager * myNAM;
49        QMap<QString,QPixmap> myPixmaps;
50
51        QString getHost( const QUrl& url );
52
53        QString getCacheDir( );
54        void ensureCacheDirHasBeenScanned( );
55
56    private slots:
57
58        void onRequestFinished( QNetworkReply * reply );
59};
60
61#endif
Note: See TracBrowser for help on using the repository browser.