~ubuntu-branches/ubuntu/quantal/marble/quantal

« back to all changes in this revision

Viewing changes to src/lib/TileLoader.h

  • Committer: Bazaar Package Importer
  • Author(s): Philip Muškovac
  • Date: 2011-07-11 15:43:02 UTC
  • Revision ID: james.westby@ubuntu.com-20110711154302-lq69ftcx125g1jx5
Tags: upstream-4.6.90+repack
Import upstream version 4.6.90+repack

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2010 Jens-Michael Hoffmann <jmho@c-xx.com>
 
2
//
 
3
// This library is free software; you can redistribute it and/or
 
4
// modify it under the terms of the GNU Lesser General Public
 
5
// License as published by the Free Software Foundation; either
 
6
// version 2.1 of the License, or (at your option) any later version.
 
7
//
 
8
// This library is distributed in the hope that it will be useful,
 
9
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 
11
// Lesser General Public License for more details.
 
12
//
 
13
// You should have received a copy of the GNU Lesser General Public
 
14
// License along with this library. If not, see <http://www.gnu.org/licenses/>.
 
15
 
 
16
#ifndef MARBLE_TILELOADER_H
 
17
#define MARBLE_TILELOADER_H
 
18
 
 
19
#include <QtCore/QHash>
 
20
#include <QtCore/QObject>
 
21
#include <QtCore/QSet>
 
22
#include <QtCore/QString>
 
23
#include <QtGui/QImage>
 
24
 
 
25
#include "TileId.h"
 
26
#include "global.h"
 
27
 
 
28
class QByteArray;
 
29
class QImage;
 
30
class QUrl;
 
31
 
 
32
namespace Marble
 
33
{
 
34
class HttpDownloadManager;
 
35
class GeoSceneTexture;
 
36
class MapThemeManager;
 
37
 
 
38
class TileLoader: public QObject
 
39
{
 
40
    Q_OBJECT
 
41
 
 
42
 public:
 
43
    TileLoader( HttpDownloadManager * const, MapThemeManager const * mapThemeManager );
 
44
 
 
45
    QImage loadTile( TileId const & tileId, DownloadUsage const );
 
46
    void reloadTile( TileId const &tileId, DownloadUsage const );
 
47
    void downloadTile( TileId const & tileId );
 
48
 
 
49
    static int maximumTileLevel( GeoSceneTexture const & texture );
 
50
 
 
51
    /**
 
52
     * Returns whether the mandatory most basic tile level is fully available for
 
53
     * the given @p texture layer.
 
54
     */
 
55
    static bool baseTilesAvailable( GeoSceneTexture const & texture );
 
56
 
 
57
 public Q_SLOTS:
 
58
    void updateTile( QByteArray const & imageData, QString const & tileId );
 
59
 
 
60
    void updateTextureLayers();
 
61
 
 
62
 Q_SIGNALS:
 
63
    void downloadTile( QUrl const & sourceUrl, QString const & destinationFileName,
 
64
                       QString const & id, DownloadUsage );
 
65
 
 
66
    void tileCompleted( TileId const & tileId, QImage const & tileImage );
 
67
 
 
68
 private:
 
69
    GeoSceneTexture const * findTextureLayer( TileId const & ) const;
 
70
    QString tileFileName( TileId const & ) const;
 
71
    void triggerDownload( TileId const &, DownloadUsage const );
 
72
    QImage scaledLowerLevelTile( TileId const & );
 
73
 
 
74
    MapThemeManager const * const m_mapThemeManager;
 
75
 
 
76
    // TODO: comment about uint hash key
 
77
    QHash<uint, GeoSceneTexture const *> m_textureLayers;
 
78
 
 
79
    // contains tiles, for which a download has been triggered
 
80
    // because the tile was not there at all or is expired.
 
81
    QSet<TileId> m_waitingForUpdate;
 
82
};
 
83
 
 
84
}
 
85
 
 
86
#endif