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/orthancitem.hpp
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
155 lines (132 sloc)
3.92 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
#ifndef ORTHANCITEM_HPP | |
#define ORTHANCITEM_HPP | |
#include "resource.hpp" | |
#include <QGraphicsView> | |
#include <set> | |
#include <QModelIndex> | |
class OrthancItem : public QObject{ | |
protected: | |
QModelIndex my_index; | |
public: | |
OrthancItem(QObject *parent):QObject(parent){} | |
virtual void updatePreview(QGraphicsView *preview)const; | |
QModelIndex index()const{return my_index;} | |
void setIndex(QModelIndex index){my_index=index;} | |
virtual bool hasChildren()const =0; | |
virtual QVariant data(int column)=0; | |
virtual bool populate()=0; | |
virtual QUrl downloadUrl()const=0; | |
virtual int childCount() const=0; | |
virtual OrthancItem *child(int row)=0; | |
}; | |
/// the representation of a database- resource (based on its REST-URL) | |
class OrthancResource { | |
protected: | |
QString date_path,time_path; | |
orthanc::JsonResource res; | |
public: | |
QJsonObject getStatistics()const; | |
QDateTime timeStamp()const; | |
OrthancResource(QString url,QObject *finishedListener=NULL,const char *finishedSlot=NULL):res(url){ | |
if(finishedListener) | |
res.connectFinished(finishedListener,finishedSlot); | |
} | |
QJsonValue dig(const QString &path) const; | |
QJsonObject getMainTags() const; | |
QUrl url() const; | |
}; | |
/// a item with children | |
class OrthancNode : public OrthancResource, public OrthancItem{ | |
protected: | |
virtual QJsonArray findChildrenList()const=0; | |
public: | |
OrthancNode(QString url, QObject *parent = 0);; | |
virtual QStringList getInstances(int *ksize) const; | |
virtual bool hasChildren() const{return true;} | |
QUrl downloadUrl() const; | |
}; | |
class OrthancDynamicNode : public OrthancNode | |
{ | |
Q_OBJECT | |
typedef bool (*sorterFunc)(const OrthancNode *left,const OrthancNode *right); | |
std::set<OrthancNode*,sorterFunc> children; | |
OrthancNode *incoming; | |
QStringList &pendingChildren(); | |
QJsonArray findChildrenList()const; | |
protected: | |
QString children_list_name; | |
QStringList *m_pending_children; | |
virtual OrthancNode *makeChild(QString id)=0; | |
public: | |
OrthancDynamicNode(QString url, sorterFunc sorter, QObject *parent = 0); | |
QStringList listChildIDs() const; | |
bool populate(); | |
OrthancItem *child(int row); | |
bool hasChildren()const; | |
signals: | |
void childReady(QModelIndex parent,OrthancItem *child,int row); | |
private: | |
typedef std::set<OrthancNode*,sorterFunc>::const_iterator const_child_iterator; | |
typedef std::set<OrthancNode*,sorterFunc>::iterator child_iterator; | |
private slots: | |
void newChild(); | |
// OrthancItem interface | |
public: | |
int childCount() const; | |
}; | |
class OrthancRoot : public OrthancDynamicNode{ | |
public: | |
OrthancRoot(QString type, QObject *parent = 0); | |
QVariant data(int); | |
// OrthancItem interface | |
public: | |
virtual QJsonArray findChildrenList() const; | |
// OrthancItem interface | |
protected: | |
OrthancNode *makeChild(QString id); | |
}; | |
class OrthancStudy:public OrthancDynamicNode{ | |
public: | |
OrthancStudy(QString id, OrthancDynamicNode *parent); | |
QVariant data(int column); | |
// OrthancItem interface | |
protected: | |
OrthancNode *makeChild(QString id); | |
}; | |
class OrthancFrame:public OrthancItem{ | |
int m_framenum; | |
public: | |
OrthancFrame(QString id,int frame_num,OrthancItem *parent):OrthancItem(parent),m_framenum(frame_num){ | |
setObjectName(id); | |
} | |
QVariant data(int column); | |
// OrthancItem interface | |
public: | |
void updatePreview(QGraphicsView *preview) const; | |
protected: | |
OrthancNode *makeChild(QString id); | |
public: | |
QUrl downloadUrl() const; | |
bool hasChildren() const{return false;} | |
bool populate(){return false;} | |
int childCount() const{return 0;} | |
OrthancItem *child(int /*row*/){return NULL;} | |
}; | |
class OrthancSeries:public OrthancNode{ | |
QList<OrthancFrame*> m_slices; | |
public: | |
OrthancSeries(QString id, OrthancDynamicNode *parent):OrthancNode("/series/"+id,parent){ | |
date_path="MainDicomTags/SeriesDate"; | |
time_path="MainDicomTags/SeriesTime"; | |
} | |
QVariant data(int column); | |
// OrthancNode interface | |
protected: | |
QJsonArray findChildrenList() const; | |
// OrthancItem interface | |
public: | |
bool populate(); | |
int childCount() const{return m_slices.size();} | |
OrthancItem *child(int row){return m_slices.at(row);} | |
}; | |
#endif // ORTHANCITEM_HPP |