Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#ifndef RESOURCE_HPP
#define RESOURCE_HPP
#include "orthancaccess.hpp"
#include <QJsonDocument>
#include <QImage>
#include <QTemporaryFile>
#include <QMimeType>
#include <QBuffer>
namespace orthanc {
class Resource:public QObject{
Q_OBJECT
QString m_type;
QIODevice &m_target;
protected:
QNetworkReply *my_reply;
int m_timeout;
private slots:
void receive(qint64 bytesReceived, qint64 bytesTotal)const;
public:
Resource(QString url, QString expected_type, QIODevice &target, int timeout, QObject *parent=NULL);
virtual ~Resource();
bool isReady() const;
QUrl url() const;
bool waitForFinished(int msec) const;
QMetaObject::Connection connectFinished(QObject *obj, const char *slot);
};
class BufferedResource:public Resource{
Q_OBJECT
QBuffer buffer;
public:
BufferedResource(QString url, QString expected_type, int timeout=1000, QObject *parent=NULL):
Resource(url,expected_type,buffer,timeout,parent){buffer.open(QIODevice::ReadWrite);}
QByteArray get()const;
};
class JsonResource:public BufferedResource{
Q_OBJECT
public:
JsonResource(QString url, int timeout=1000, QObject *parent=NULL):BufferedResource(url,"application/json",timeout,parent){}
QJsonDocument get()const;
static QJsonValue dig(QStringList path, const QJsonObject &obj);
QJsonValue dig(const QString &path) const;
};
class ImageResource:public BufferedResource{
Q_OBJECT
QImage image;
public:
ImageResource(QString url, QObject *parent=NULL):BufferedResource(url,"image/png",5000,parent){}
QImage get()const;
};
}
#endif // RESOURCE_HPP