qtmobility/examples/flickrdemo/flickrdemo.h
changeset 1 2b40d63a9c3d
child 4 90517678cc4f
equal deleted inserted replaced
0:cfcbf08528c4 1:2b40d63a9c3d
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 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:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #ifndef FLICKRDEMO_H
       
    43 #define FLICKRDEMO_H
       
    44 
       
    45 #include <QtGui>
       
    46 #include <QtNetwork>
       
    47 
       
    48 //// QtMobility API headers
       
    49 #include <qmobilityglobal.h>
       
    50 
       
    51 #include "xqlistwidget.h"
       
    52 
       
    53 QTM_BEGIN_NAMESPACE
       
    54 class QNetworkSession;
       
    55 class QGeoPositionInfoSource;
       
    56 class QGeoPositionInfo;
       
    57 class QGeoSatelliteInfoSource;
       
    58 class QGeoSatelliteInfo;
       
    59 QTM_END_NAMESPACE
       
    60 
       
    61 #include "connectivityhelper.h"
       
    62 
       
    63 // Use the QtMobility namespace
       
    64 QTM_USE_NAMESPACE
       
    65 
       
    66 class FlickrDemo: public QMainWindow
       
    67 {
       
    68     Q_OBJECT
       
    69 
       
    70 public:
       
    71     FlickrDemo(QWidget* parent = 0);
       
    72     ~FlickrDemo();
       
    73 
       
    74 private:
       
    75     void createMenus();
       
    76     void viewSatelliteInfo();
       
    77     bool parsePictureList(QString xmlString);
       
    78     void downloadFlickerPictureList();
       
    79     void downloadPictureFromFlickr();
       
    80     void downloadNextThumbnail();
       
    81 
       
    82 private Q_SLOTS:
       
    83     void delayedInit();
       
    84     void networkSessionOpened();
       
    85 
       
    86     void downloadButtonClicked();
       
    87     void cancelDownload();
       
    88 
       
    89     void httpRequestFinished(int requestId, bool error);
       
    90     void readResponseHeader(const QHttpResponseHeader& responseHeader);
       
    91     void updateDataReadProgress(int bytesRead, int totalBytes);
       
    92 
       
    93     // QGeoPositionInfoSource
       
    94     void positionUpdated(const QGeoPositionInfo &gpsPos);
       
    95 
       
    96     // QGeoSatelliteInfoSource
       
    97     void satellitesInViewUpdated(const QList<QGeoSatelliteInfo>&);
       
    98     void satellitesInUseUpdated(const QList<QGeoSatelliteInfo>&);
       
    99 
       
   100 private:
       
   101     static const QSize gridSize;
       
   102     static const QSize thumbnailSize;
       
   103     static const QSize imageSize;
       
   104     static const QString apikey;
       
   105     static const QString savePath;
       
   106 
       
   107     void displayImage();
       
   108 
       
   109     QLabel *locationLabel;
       
   110     QLabel *satellitesLabel;
       
   111     XQListWidget *listWidget;
       
   112     QPushButton *downloadButton;
       
   113 
       
   114     QAction* m_downloadAct;
       
   115 
       
   116     bool m_logfileInUse;
       
   117     QGeoPositionInfoSource* m_location;
       
   118     QGeoSatelliteInfoSource* m_satellite;
       
   119 
       
   120     QNetworkSession* m_session;
       
   121     ConnectivityHelper *m_connectivityHelper;
       
   122 
       
   123     QProgressDialog *m_progressDialog;
       
   124     QHttp *m_http;
       
   125     QString m_filePath;
       
   126     QFile* m_file;
       
   127     int m_httpGetId;
       
   128     int m_httpThumbnailGetId;
       
   129     bool m_httpRequestAborted;
       
   130 
       
   131     int m_pages;
       
   132     int m_page;
       
   133 
       
   134     int m_satellitesInView;
       
   135     int m_satellitesUsed;
       
   136     double m_latitude;
       
   137     double m_longitude;
       
   138 
       
   139     bool m_downloadPictureList;
       
   140 
       
   141     bool m_downloadingThumbnails;
       
   142     int m_nameCounter;
       
   143     QStringList m_names;
       
   144 };
       
   145 
       
   146 class PictureDialog: public QDialog
       
   147 {
       
   148     Q_OBJECT
       
   149 
       
   150 public:
       
   151     PictureDialog(const QString& filePath, const QString& pictureName, QWidget* parent = 0);
       
   152 
       
   153 private slots:
       
   154     void clicked(QAbstractButton *button);
       
   155 
       
   156 private:
       
   157     static const QSize imageSize;
       
   158 
       
   159     QLabel *label;
       
   160     QLabel *imageLabel;
       
   161     QDialogButtonBox *buttonBox;
       
   162     QPushButton *keepButton;
       
   163     QPushButton *discardButton;
       
   164 };
       
   165 
       
   166 #endif // FLICKRDEMO_H
       
   167