|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:BSD$ |
|
10 ** You may use this file under the terms of the BSD license as follows: |
|
11 ** |
|
12 ** "Redistribution and use in source and binary forms, with or without |
|
13 ** modification, are permitted provided that the following conditions are |
|
14 ** met: |
|
15 ** * Redistributions of source code must retain the above copyright |
|
16 ** notice, this list of conditions and the following disclaimer. |
|
17 ** * Redistributions in binary form must reproduce the above copyright |
|
18 ** notice, this list of conditions and the following disclaimer in |
|
19 ** the documentation and/or other materials provided with the |
|
20 ** distribution. |
|
21 ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor |
|
22 ** the names of its contributors may be used to endorse or promote |
|
23 ** products derived from this software without specific prior written |
|
24 ** permission. |
|
25 ** |
|
26 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
27 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
28 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
29 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
30 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
31 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
32 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
33 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
34 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
35 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
36 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." |
|
37 ** $QT_END_LICENSE$ |
|
38 ** |
|
39 ****************************************************************************/ |
|
40 |
|
41 #ifndef FLICKRDEMO_H |
|
42 #define FLICKRDEMO_H |
|
43 |
|
44 #include <QDialog> |
|
45 #include <QMainWindow> |
|
46 #include <QNetworkReply> |
|
47 #include <QSize> |
|
48 |
|
49 QT_BEGIN_NAMESPACE |
|
50 class QAction; |
|
51 class QDialogButtonBox; |
|
52 class QLabel; |
|
53 class QNetworkAccessManager; |
|
54 class QNetworkRequest; |
|
55 class QProgressDialog; |
|
56 class QPushButton; |
|
57 class QWidget; |
|
58 QT_END_NAMESPACE |
|
59 |
|
60 //// QtMobility API headers |
|
61 #include <qmobilityglobal.h> |
|
62 |
|
63 #include "xqlistwidget.h" |
|
64 |
|
65 QTM_BEGIN_NAMESPACE |
|
66 class QNetworkSession; |
|
67 class QGeoPositionInfoSource; |
|
68 class QGeoPositionInfo; |
|
69 class QGeoSatelliteInfoSource; |
|
70 class QGeoSatelliteInfo; |
|
71 QTM_END_NAMESPACE |
|
72 |
|
73 #include "connectivityhelper.h" |
|
74 |
|
75 // Use the QtMobility namespace |
|
76 QTM_USE_NAMESPACE |
|
77 |
|
78 class FlickrDemo: public QMainWindow |
|
79 { |
|
80 Q_OBJECT |
|
81 |
|
82 public: |
|
83 FlickrDemo(QWidget* parent = 0); |
|
84 ~FlickrDemo(); |
|
85 |
|
86 private: |
|
87 void createMenus(); |
|
88 void viewSatelliteInfo(); |
|
89 bool parsePictureList(QString xmlString); |
|
90 void downloadFlickerPictureList(); |
|
91 void downloadPictureFromFlickr(); |
|
92 void downloadNextThumbnail(); |
|
93 |
|
94 private Q_SLOTS: |
|
95 void delayedInit(); |
|
96 void networkSessionOpened(); |
|
97 |
|
98 void downloadButtonClicked(); |
|
99 void cancelDownload(); |
|
100 |
|
101 /* |
|
102 void httpRequestFinished(int requestId, bool error); |
|
103 void readResponseHeader(const QHttpResponseHeader& responseHeader); |
|
104 void updateDataReadProgress(int bytesRead, int totalBytes); |
|
105 */ |
|
106 |
|
107 void pictureListDownloadProgress(qint64 bytesReceived, qint64 bytesTotal); |
|
108 void pictureListFinished(); |
|
109 void pictureListError(QNetworkReply::NetworkError code); |
|
110 void clearPictureListRequest(); |
|
111 |
|
112 void thumbnailFinished(); |
|
113 void thumbnailError(QNetworkReply::NetworkError code); |
|
114 void clearThumbnailRequest(); |
|
115 |
|
116 void pictureDownloadProgress(qint64 bytesReceived, qint64 bytesTotal); |
|
117 void pictureFinished(); |
|
118 void pictureError(QNetworkReply::NetworkError code); |
|
119 void clearPictureRequest(); |
|
120 |
|
121 // QGeoPositionInfoSource |
|
122 void positionUpdated(const QGeoPositionInfo &gpsPos); |
|
123 |
|
124 // QGeoSatelliteInfoSource |
|
125 void satellitesInViewUpdated(const QList<QGeoSatelliteInfo>&); |
|
126 void satellitesInUseUpdated(const QList<QGeoSatelliteInfo>&); |
|
127 |
|
128 private: |
|
129 static const QSize gridSize; |
|
130 static const QSize thumbnailSize; |
|
131 static const QSize imageSize; |
|
132 static const QString apikey; |
|
133 static const QString savePath; |
|
134 |
|
135 void displayImage(const QPixmap &pixmap); |
|
136 |
|
137 QLabel *locationLabel; |
|
138 QLabel *satellitesLabel; |
|
139 XQListWidget *listWidget; |
|
140 QPushButton *downloadButton; |
|
141 |
|
142 QAction* m_downloadAct; |
|
143 |
|
144 bool m_logfileInUse; |
|
145 QGeoPositionInfoSource* m_location; |
|
146 QGeoSatelliteInfoSource* m_satellite; |
|
147 |
|
148 QNetworkSession* m_session; |
|
149 ConnectivityHelper *m_connectivityHelper; |
|
150 |
|
151 QProgressDialog *m_progressDialog; |
|
152 |
|
153 QNetworkAccessManager *m_nam; |
|
154 QNetworkReply *m_pictureListReply; |
|
155 QNetworkReply *m_thumbnailReply; |
|
156 QNetworkReply *m_pictureReply; |
|
157 |
|
158 int m_pages; |
|
159 int m_page; |
|
160 |
|
161 int m_satellitesInView; |
|
162 int m_satellitesUsed; |
|
163 double m_latitude; |
|
164 double m_longitude; |
|
165 |
|
166 bool m_downloadPictureList; |
|
167 int m_nameCounter; |
|
168 QStringList m_names; |
|
169 bool m_shuttingDown; |
|
170 }; |
|
171 |
|
172 class PictureDialog: public QDialog |
|
173 { |
|
174 Q_OBJECT |
|
175 |
|
176 public: |
|
177 PictureDialog(const QPixmap& pixmapd, const QString& pictureName, QWidget* parent = 0); |
|
178 |
|
179 private: |
|
180 QLabel *label; |
|
181 QLabel *imageLabel; |
|
182 QDialogButtonBox *buttonBox; |
|
183 }; |
|
184 |
|
185 #endif // FLICKRDEMO_H |
|
186 |