Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
305 | KeyOz | 1 | /* |
2 | * |
||
3 | * This file is part of QMapControl, |
||
4 | * an open-source cross-platform map widget |
||
5 | * |
||
6 | * Copyright (C) 2007 - 2008 Kai Winter |
||
7 | * |
||
8 | * This program is free software: you can redistribute it and/or modify |
||
9 | * it under the terms of the GNU Lesser General Public License as published by |
||
10 | * the Free Software Foundation, either version 3 of the License, or |
||
11 | * (at your option) any later version. |
||
12 | * |
||
13 | * This program is distributed in the hope that it will be useful, |
||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
16 | * GNU Lesser General Public License for more details. |
||
17 | * |
||
18 | * You should have received a copy of the GNU Lesser General Public License |
||
19 | * along with QMapControl. If not, see <http://www.gnu.org/licenses/>. |
||
20 | * |
||
21 | * Contact e-mail: kaiwinter@gmx.de |
||
22 | * Program URL : http://qmapcontrol.sourceforge.net/ |
||
23 | * |
||
24 | */ |
||
25 | |||
26 | #ifndef IMAGEMANAGER_H |
||
27 | #define IMAGEMANAGER_H |
||
28 | |||
29 | #include <QObject> |
||
30 | #include <QPixmapCache> |
||
31 | #include <QDebug> |
||
32 | #include <QMutex> |
||
33 | #include <QFile> |
||
34 | #include <QBuffer> |
||
35 | #include <QDir> |
||
36 | #include "mapnetwork.h" |
||
37 | |||
38 | namespace qmapcontrol |
||
39 | { |
||
40 | class MapNetwork; |
||
41 | /** |
||
42 | @author Kai Winter <kaiwinter@gmx.de> |
||
43 | */ |
||
44 | class ImageManager : public QObject |
||
45 | { |
||
46 | Q_OBJECT; |
||
47 | |||
48 | public: |
||
49 | static ImageManager* instance() |
||
50 | { |
||
51 | if(!m_Instance) |
||
52 | { |
||
53 | m_Instance = new ImageManager; |
||
54 | } |
||
55 | return m_Instance; |
||
56 | } |
||
57 | |||
58 | ~ImageManager(); |
||
59 | |||
60 | //! returns a QPixmap of the asked image |
||
61 | /*! |
||
62 | * If this component doesn´t have the image a network query gets started to load it. |
||
63 | * @param host the host of the image |
||
64 | * @param path the path to the image |
||
65 | * @return the pixmap of the asked image |
||
66 | */ |
||
67 | QPixmap getImage(const QString& host, const QString& path); |
||
68 | |||
69 | QPixmap prefetchImage(const QString& host, const QString& path); |
||
70 | |||
71 | void receivedImage(const QPixmap pixmap, const QString& url); |
||
72 | |||
73 | /*! |
||
74 | * This method is called by MapNetwork, after all images in its queue were loaded. |
||
75 | * The ImageManager emits a signal, which is used in MapControl to remove the zoom image. |
||
76 | * The zoom image should be removed on Tile Images with transparency. |
||
77 | * Else the zoom image stay visible behind the newly loaded tiles. |
||
78 | */ |
||
79 | void loadingQueueEmpty(); |
||
80 | |||
81 | /*! |
||
82 | * Aborts all current loading threads. |
||
83 | * This is useful when changing the zoom-factor, though newly needed images loads faster |
||
84 | */ |
||
85 | void abortLoading(); |
||
86 | |||
87 | //! sets the proxy for HTTP connections |
||
88 | /*! |
||
89 | * This method sets the proxy for HTTP connections. |
||
90 | * This is not provided by the current Qtopia version! |
||
91 | * @param host the proxy´s hostname or ip |
||
92 | * @param port the proxy´s port |
||
93 | */ |
||
94 | void setProxy(QString host, int port); |
||
95 | |||
96 | //! sets the cache directory for persistently saving map tiles |
||
97 | /*! |
||
98 | * |
||
99 | * @param path the path where map tiles should be stored |
||
100 | * @todo add maximum size |
||
101 | */ |
||
102 | void setCacheDir(const QDir& path); |
||
103 | |||
104 | private: |
||
105 | ImageManager(QObject* parent = 0); |
||
106 | ImageManager(const ImageManager&); |
||
107 | ImageManager& operator=(const ImageManager&); |
||
108 | QPixmap emptyPixmap; |
||
109 | MapNetwork* net; |
||
110 | QVector<QString> prefetch; |
||
111 | QDir cacheDir; |
||
112 | bool doPersistentCaching; |
||
113 | |||
114 | static ImageManager* m_Instance; |
||
115 | |||
116 | bool saveTile(QString tileName,QPixmap tileData); |
||
117 | bool loadTile(QString tileName,QPixmap &tileData); |
||
118 | bool tileExist(QString tileName); |
||
119 | |||
120 | signals: |
||
121 | void imageReceived(); |
||
122 | void loadingFinished(); |
||
123 | }; |
||
124 | } |
||
125 | #endif |