Permalink
Cannot retrieve contributors at this time
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?
orthanc-qt/orthancaccess.cpp
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
45 lines (37 sloc)
1.07 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "orthancaccess.hpp" | |
#include <QMetaProperty> | |
#include <QNetworkRequest> | |
#include <QApplication> | |
#include <QThreadStorage> | |
namespace orthanc { | |
OrthancAccess::OrthancAccess(QObject *parent) : QNetworkAccessManager(parent) | |
{ | |
qDebug() << "Creating access object " << this; | |
} | |
QThreadStorage<OrthancAccess*> _access; | |
QNetworkReply *OrthancAccess::get(const QString &request,QObject *requestor) | |
{ | |
Q_ASSERT(!prefix.isEmpty()); | |
QUrl url=prefix; | |
url.setPath(QString("/")+request); | |
QNetworkRequest req(url); | |
req.setOriginatingObject(requestor); | |
// qDebug() << "Sending request" << req.url() << "for" << requestor; | |
return QNetworkAccessManager::get(req); | |
} | |
void OrthancAccess::setPrefix(QString _prefix) | |
{ | |
// @todo make sure no request is currently running | |
prefix=QUrl(_prefix); | |
const QString host=prefix.host(); | |
const int port=prefix.port(); | |
connectToHost(host,port); | |
} | |
OrthancAccess &access() | |
{ | |
if(!_access.hasLocalData()) | |
_access.setLocalData(new OrthancAccess); | |
Q_ASSERT(_access.localData()); | |
return *_access.localData(); | |
} | |
} | |