QTimeSeries Homepage

Main Page   Alphabetical List   Compound List   File List   Compound Members  

qts_downloaddialog.ui.h

00001 /****************************************************************************
00002 ** ui.h extension file, included from the uic-generated form implementation.
00003 **
00004 ** If you wish to add, delete or rename slots use Qt Designer which will
00005 ** update this file, preserving your code. Create an init() slot in place of
00006 ** a constructor, and a destroy() slot in place of a destructor.
00007 *****************************************************************************/
00008 
00009 void QTS_DownloadDialog::init() {
00010     urlOperator = new QUrlOperator();
00011     connect(urlOperator, SIGNAL(start(QNetworkOperation*)),
00012             this, SLOT(slotStart(QNetworkOperation*)));
00013     connect(urlOperator, SIGNAL(finished(QNetworkOperation*)),
00014             this, SLOT(slotFinished(QNetworkOperation*)));
00015     connect(urlOperator, SIGNAL(dataTransferProgress(int, int, QNetworkOperation*)),
00016             this, SLOT(slotDataTransferProgress(int, int, QNetworkOperation*)));
00017     connect(urlOperator, SIGNAL(data(const QByteArray&, QNetworkOperation*)),
00018             this, SLOT(slotData(const QByteArray&, QNetworkOperation*)));
00019     connect(bCancel, SIGNAL(clicked()),
00020             this, SLOT(cancelled()));   
00021 }
00022 
00023 void QTS_DownloadDialog::destroy() {   
00024     delete urlOperator;
00025     delete file;
00026 }
00027 
00028 void QTS_DownloadDialog::startDownload(const QString& url, const QString& fileName) {
00029     bytes = 0;    
00030     file = new QFile(fileName);
00031     file->open(IO_WriteOnly);
00032     urlOperator->get(url);
00033 }
00034 
00038 void QTS_DownloadDialog::slotStart(QNetworkOperation*) {
00039     RS_DEBUG->print("QTS_DownloadDialog::slotStart\n");
00040 }
00041 
00042 
00046 void QTS_DownloadDialog::slotFinished(QNetworkOperation*) {
00047     RS_DEBUG->print("QTS_DownloadDialog::slotFinished\n");
00048   
00049     file->flush();
00050     file->close();
00051     accept();
00052 }
00053 
00054 
00058 void QTS_DownloadDialog::slotDataTransferProgress(int, int, QNetworkOperation*) {
00059     //printf("progress: %d/%d\n", bytesDone, bytesTotal);
00060 }
00061 
00062 void QTS_DownloadDialog::slotData(const QByteArray& data, QNetworkOperation*) {
00063     //printf("data...\n");
00064 
00065     file->writeBlock(data);
00066     file->flush();
00067 
00068     bytes+=data.size();
00069 
00070     lBytes->setText(QString("%1").arg(bytes));
00071     
00072     RS_DEBUG->print("Retrieving data: %d Bytes", bytes);
00073 
00074     //for (int i=0; i<data.size(); ++i) {
00075     //    printf("%c", data.at(i));
00076     //}
00077     //printf("\n");
00078 }
00079 
00080 void QTS_DownloadDialog::cancelled() {
00081     RS_DEBUG->print("QTS_DownloadDialog::cancelled\n");
00082     
00083     file->remove();
00084     reject();
00085 }
00086 

Copyright © 2002, Andrew Mustun <andrew@mustun.com>. All rights reserved.
System documentation was generated using doxygen.