Changeset 5007fde for src


Ignore:
Timestamp:
01/29/10 13:15:40 (13 years ago)
Author:
pavelpa <pavelpa@…>
Branches:
master, qt5
Children:
a023fd2
Parents:
1fb7a33
Message:

implemented importing the schedule from the Internet

Location:
src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/app/app.pro

    r1fb7a33 r5007fde  
    33TARGET = fosdem-schedule
    44DESTDIR = ../bin
    5 QT += sql xml
     5QT += sql xml network
    66
    77# module dependencies
  • src/gui/gui.pro

    r1fb7a33 r5007fde  
    55CONFIG += static
    66QT += sql \
    7     xml
     7    xml \
     8    network
    89
    910# module dependencies
  • src/gui/importschedulewidget.cpp

    r1fb7a33 r5007fde  
    66#include <QFile>
    77#include <QFileDialog>
     8#include <QNetworkProxy>
     9#include <QNetworkAccessManager>
     10#include <QNetworkReply>
    811#include <QDebug>
     12
     13const QString SCHEDULE_URL = "http://fosdem.org/2010/schedule/xml";
    914
    1015ImportScheduleWidget::ImportScheduleWidget(QWidget *aParent)
     
    2126
    2227    cancel->hide();
    23     online->hide();
    2428    importAction->hide();
     29    connect(online, SIGNAL(clicked()), SLOT(downloadSchedule()));
     30
     31    mNetworkAccessManager = new QNetworkAccessManager(this);
     32    connect(mNetworkAccessManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkQueryFinished(QNetworkReply*)));
     33    mNetworkAccessManager->setProxy(QNetworkProxy::applicationProxy());
    2534}
    2635
     
    3140        delete mXmlParser;
    3241        mXmlParser = NULL;
     42    }
     43    if(mNetworkAccessManager)
     44    {
     45        delete mNetworkAccessManager;
     46        mNetworkAccessManager = NULL;
    3347    }
    3448}
     
    5670        }
    5771
    58         QByteArray data = file.readAll();
    59         browse->hide();
    60         progressBar->show();
    61         int confId = mXmlParser->parseData(data);
     72        importData(file.readAll());
    6273
    63         progressBar->hide();
    64         browse->show();
    65         importScheduleLabel->setText("Import schedule: ");
    66 
    67         emit(scheduleImported(confId));
    6874    }
    6975    else
     
    7379}
    7480
     81void ImportScheduleWidget::networkQueryFinished(QNetworkReply *aReply)
     82{
     83    qDebug() << "ImportScheduleWidget::networkQueryFinished()";
     84
     85    if ( aReply->error() != QNetworkReply::NoError )
     86    {
     87        qDebug() << "Error occured during download: " << aReply->errorString();
     88    }
     89    else
     90    {
     91        importData(aReply->readAll());
     92    }
     93}
     94
     95void ImportScheduleWidget::downloadSchedule()
     96{
     97    qDebug() << "downloading schedule";
     98
     99    QNetworkRequest request;
     100    request.setUrl(QUrl(SCHEDULE_URL));
     101    mNetworkAccessManager->get(request);
     102}
     103
     104void ImportScheduleWidget::importData(const QByteArray &aData)
     105{
     106    browse->hide();
     107    online->hide();
     108    progressBar->show();
     109
     110    int confId = mXmlParser->parseData(aData);
     111
     112    progressBar->hide();
     113    browse->show();
     114    online->show();
     115    importScheduleLabel->setText("Import schedule: ");
     116
     117    emit(scheduleImported(confId));
     118}
     119
  • src/gui/importschedulewidget.h

    r1fb7a33 r5007fde  
    66
    77class ScheduleXmlParser;
     8class QNetworkAccessManager;
     9class QNetworkReply;
    810
    911class ImportScheduleWidget : public QWidget, Ui::ImportScheduleWidget
     
    1719        void parsingSchedule(const QString &aTitle);
    1820        void showParsingProgress(int progress);
     21        void networkQueryFinished(QNetworkReply *aReply);
     22        void downloadSchedule();
    1923    signals:
    2024        void scheduleImported(int confId);
    2125    private:
     26        void importData(const QByteArray &aData);
     27    private:
    2228        ScheduleXmlParser *mXmlParser;
     29        QNetworkAccessManager *mNetworkAccessManager;
    2330};
    2431
  • src/gui/mainwindow.cpp

    r1fb7a33 r5007fde  
    33#include <QTreeView>
    44#include <QFile>
     5#include <QNetworkProxy>
    56
    67#include <sqlengine.h>
     
    2223#include <tabcontainer.h>
    2324
     25const QString PROXY_URL("192.168.0.252");
     26const quint16 PROXY_PORT = 4040;
     27const QString PROXY_USERNAME;
     28const QString PROXY_PASSWD;
     29const bool DIRECT_CONNECTION = false;
     30
    2431MainWindow::MainWindow(int aEventId, QWidget *aParent)
    2532    : QMainWindow(aParent)
    2633{
    2734    setupUi(this);
     35
     36    qDebug() << "Setting-up proxy: " << PROXY_URL << ":" << PROXY_PORT;
     37    QNetworkProxy proxy(DIRECT_CONNECTION ? QNetworkProxy::NoProxy : QNetworkProxy::HttpProxy,
     38            PROXY_URL, PROXY_PORT, PROXY_USERNAME, PROXY_PASSWD);
     39    QNetworkProxy::setApplicationProxy(proxy);
    2840
    2941    int confId = Conference::activeConference();
Note: See TracChangeset for help on using the changeset viewer.