QMapControl  0.9.7.4
mapnetwork.h
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 MAPNETWORK_H
27 #define MAPNETWORK_H
28 
29 #include "qmapcontrol_global.h"
30 #include <QObject>
31 #include <QDebug>
32 #include <QNetworkAccessManager>
33 #include <QNetworkReply>
34 #include <QNetworkProxy>
35 #include <QAuthenticator>
36 #include <QVector>
37 #include <QPixmap>
38 #include <QMutex>
39 #include "imagemanager.h"
40 
44 namespace qmapcontrol
45 {
46  class ImageManager;
47  class QMAPCONTROL_EXPORT MapNetwork : QObject
48  {
49  Q_OBJECT
50 
51  public:
52  MapNetwork(ImageManager* parent);
53  ~MapNetwork();
54 
55  void loadImage(const QString& host, const QString& url);
56 
62  bool imageIsLoading(QString url);
63 
68  void abortLoading();
69  void setProxy(QString host, int port, const QString username = QString(), const QString password = QString());
70 
75  int loadQueueSize() const;
76 
81  QNetworkAccessManager* nextFreeHttp();
82 
83  private:
84  Q_DISABLE_COPY (MapNetwork)
85 
86  ImageManager* parent;
87  QList<QNetworkAccessManager*> httpThreads;
88  QList<QNetworkReply*> replyList;
89  QMap<QString, QString> loadingMap;
90  qreal loaded;
91  mutable QMutex vectorMutex;
92  bool networkActive;
93  int nextThreadIndex;
94 
95  static const int kMAX_HTTP_THREADS;
96 
97  private slots:
98  void requestFinished(QNetworkReply *reply);
99  };
100 }
101 #endif
Definition: mapnetwork.h:47
QMapControl namespace.
Definition: arrowpoint.cpp:28