Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. #include "qseqbuffer.h"
  2. #include <QDebug>
  3.  
  4. QSeqBuffer::QSeqBuffer(QObject *parent) :
  5. QBuffer(parent),
  6. networkReply(0)
  7. {
  8.  
  9. }
  10.  
  11. void QSeqBuffer::startStreaming(QNetworkReply *parentReply){
  12. networkReply = parentReply;
  13. connect(networkReply,SIGNAL(downloadProgress(qint64,qint64)),SLOT(downloading(qint64,qint64)));
  14. }
  15.  
  16. bool QSeqBuffer::atEnd()
  17. {
  18. qDebug() << QString("QIODevice::atEnd = %1").arg(QIODevice::atEnd());
  19. qDebug() << QString("networkReply->isFinished = %1").arg(networkReply->isFinished());
  20. if(networkReply == NULL) return true;
  21. if(QIODevice::atEnd() && networkReply->isFinished()) return true;
  22. return false;
  23. }
  24.  
  25. void QSeqBuffer::downloading(qint64 cur, qint64 tot){
  26. if(size() == 0){
  27. write(networkReply->readAll());
  28. emit readyStream();
  29. }else{
  30. write(networkReply->readAll());
  31. }
  32. }
  33.  
  34. bool QSeqBuffer::isSequential(){
  35. qDebug() << "isSequential called";
  36. return true;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement