OpendTect-6_4  6.4
qnetworkaccessconn.h
Go to the documentation of this file.
1 #ifndef qnetworkaccessconn_h
2 #define qnetworkaccessconn_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: Nanne Hemstra
9  Date: January 2012
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 
16 #include "odnetworkaccess.h"
17 #include "odnetworkreply.h"
18 #include <QNetworkAccessManager>
19 #include <QNetworkReply>
20 #include <QNetworkRequest>
21 
22 QT_BEGIN_NAMESPACE
23 
24 
25 class QNetworkReplyConn : public QObject
26 {
27  Q_OBJECT
28  friend class ODNetworkReply;
29 
30 protected:
31 
32 QNetworkReplyConn( QNetworkReply* sndr, ODNetworkReply* rec )
33  : sender_(sndr), receiver_(rec)
34 {
35  connect( sender_, SIGNAL(downloadProgress(qint64,qint64)),
36  this, SLOT(downloadProgress(qint64,qint64)) );
37  connect( sender_, SIGNAL(error(QNetworkReply::NetworkError)),
38  this, SLOT(error(QNetworkReply::NetworkError)) );
39  connect( sender_, SIGNAL(finished()),
40  this, SLOT(finished()) );
41  connect( sender_, SIGNAL(metaDataChanged()),
42  this, SLOT(metaDataChanged()) );
43  connect( sender_, SIGNAL(uploadProgress(qint64,qint64)),
44  this, SLOT(uploadProgress(qint64,qint64)) );
45 
46  // From QIODevice
47  connect( sender_, SIGNAL(aboutToClose()),
48  this, SLOT(aboutToClose()) );
49  connect( sender_, SIGNAL(bytesWritten(qint64)),
50  this, SLOT(bytesWritten(qint64)) );
51  connect( sender_, SIGNAL(readyRead()),
52  this, SLOT(readyRead()) );
53 }
54 
55 private slots:
56 
57 void downloadProgress(qint64 nrdone,qint64 totalnr)
58 {}
59 
60 void error(QNetworkReply::NetworkError)
61 { receiver_->error.trigger(); }
62 
63 void finished()
65 
67 {}
68 
69 void uploadProgress(qint64 bytes,qint64 totalbytes)
70 {
71  receiver_->setBytesUploaded( bytes );
72  receiver_->setTotalBytesToUpload( totalbytes );
74 }
75 
77 {}
78 
79 void bytesWritten(qint64)
80 {}
81 
83 {}
84 
85 void readyRead()
87 
88 private:
89 
90  QNetworkReply* sender_;
92 
93 };
94 
95 QT_END_NAMESPACE
96 
97 #endif
Notifier< ODNetworkReply > readyRead
Definition: odnetworkreply.h:51
void bytesWritten(qint64)
Definition: qnetworkaccessconn.h:79
ODNetworkReply * receiver_
Definition: qnetworkaccessconn.h:91
void uploadProgress(qint64 bytes, qint64 totalbytes)
Definition: qnetworkaccessconn.h:69
void aboutToClose()
Definition: qnetworkaccessconn.h:76
void setTotalBytesToUpload(const od_int64 bytes)
Definition: odnetworkreply.h:36
void readChannelFinished()
Definition: qnetworkaccessconn.h:82
void error(QNetworkReply::NetworkError)
Definition: qnetworkaccessconn.h:60
Definition: qnetworkaccessconn.h:25
Definition: odnetworkreply.h:24
void metaDataChanged()
Definition: qnetworkaccessconn.h:66
Notifier< ODNetworkReply > finished
Definition: odnetworkreply.h:45
void finished()
Definition: qnetworkaccessconn.h:63
void trigger(T &t)
Definition: callback.h:258
void downloadProgress(qint64 nrdone, qint64 totalnr)
Definition: qnetworkaccessconn.h:57
Notifier< ODNetworkReply > error
Definition: odnetworkreply.h:47
QNetworkReply * sender_
Definition: qnetworkaccessconn.h:90
QNetworkReplyConn(QNetworkReply *sndr, ODNetworkReply *rec)
Definition: qnetworkaccessconn.h:32
Notifier< ODNetworkReply > uploadProgress
Definition: odnetworkreply.h:48
void readyRead()
Definition: qnetworkaccessconn.h:85
void setBytesUploaded(const od_int64 bytes)
Definition: odnetworkreply.h:34

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2019