Add UI for DIDKIT.
This commit is contained in:
82
DIDKit/App/Model/FileItem.cpp
Normal file
82
DIDKit/App/Model/FileItem.cpp
Normal file
@@ -0,0 +1,82 @@
|
||||
#include "FileItem.h"
|
||||
#include "FileItemAction.h"
|
||||
|
||||
FileItem::FileItem(FileItemDataPointer mData, FileItem* aParent, FileItemActionPointer aAction)
|
||||
: mParent(aParent)
|
||||
, mChilds(QList<FileItem*>())
|
||||
, mData(mData)
|
||||
, mAction(aAction)
|
||||
{
|
||||
if (mParent != nullptr)
|
||||
{
|
||||
mParent->setChild(this);
|
||||
}
|
||||
}
|
||||
|
||||
FileItem::~FileItem()
|
||||
{
|
||||
qDeleteAll(mChilds);
|
||||
mChilds.clear();
|
||||
}
|
||||
|
||||
void FileItem::setChild(FileItem* aChild)
|
||||
{
|
||||
mChilds.append(aChild);
|
||||
}
|
||||
|
||||
void FileItem::setChilds(const QList<FileItem*>& aChilds)
|
||||
{
|
||||
mChilds.append(aChilds);
|
||||
}
|
||||
|
||||
void FileItem::removeChild(int aIndex)
|
||||
{
|
||||
mChilds.removeAt(aIndex);
|
||||
}
|
||||
|
||||
int FileItem::childCount()
|
||||
{
|
||||
return mChilds.count();
|
||||
}
|
||||
|
||||
FileItem* FileItem::getChild(int aIndex)
|
||||
{
|
||||
if (aIndex < mChilds.count())
|
||||
{
|
||||
return mChilds.at(aIndex);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FileItem* FileItem::getParent()
|
||||
{
|
||||
return mParent;
|
||||
}
|
||||
|
||||
FileItemDataPointer FileItem::getData()
|
||||
{
|
||||
return mData;
|
||||
}
|
||||
|
||||
int FileItem::getIndexRow()
|
||||
{
|
||||
if (mParent)
|
||||
{
|
||||
return mParent->mChilds.indexOf(this);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void FileItem::clearChilds()
|
||||
{
|
||||
qDeleteAll(mChilds);
|
||||
mChilds.clear();
|
||||
}
|
||||
|
||||
void FileItem::executeAction()
|
||||
{
|
||||
if(!mAction.isNull())
|
||||
{
|
||||
mAction->execute();
|
||||
}
|
||||
}
|
||||
37
DIDKit/App/Model/FileItem.h
Normal file
37
DIDKit/App/Model/FileItem.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef FILEITEM_H
|
||||
#define FILEITEM_H
|
||||
|
||||
#include <QList>
|
||||
#include <QVariant>
|
||||
#include <QSharedPointer>
|
||||
|
||||
class FileItemAction;
|
||||
typedef QSharedPointer<QVariant> FileItemDataPointer;
|
||||
typedef QSharedPointer<FileItemAction> FileItemActionPointer;
|
||||
|
||||
|
||||
class FileItem
|
||||
{
|
||||
public:
|
||||
explicit FileItem(FileItemDataPointer aData, FileItem* aParent = nullptr, FileItemActionPointer aAction = QSharedPointer<FileItemAction>());
|
||||
~FileItem();
|
||||
void setChild(FileItem* aChild);
|
||||
void setChilds(const QList<FileItem*>& aChilds);
|
||||
void removeChild(int aIndex);
|
||||
int childCount();
|
||||
FileItem* getChild(int aIndex);
|
||||
FileItem* getParent();
|
||||
FileItemDataPointer getData();
|
||||
int getIndexRow();
|
||||
void clearChilds();
|
||||
void executeAction();
|
||||
|
||||
private:
|
||||
FileItem* mParent;
|
||||
QList<FileItem*> mChilds;
|
||||
FileItemDataPointer mData;
|
||||
FileItemActionPointer mAction;
|
||||
|
||||
};
|
||||
|
||||
#endif // FILEITEM_H
|
||||
24
DIDKit/App/Model/FileItemAction.cpp
Normal file
24
DIDKit/App/Model/FileItemAction.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include "FileItemAction.h"
|
||||
|
||||
#include "IO/DICOM/ExtendMedicalImageProperties.h"
|
||||
#include "PropertyTableModel.h"
|
||||
|
||||
FileItemAction::FileItemAction(PropertyTableModel* aTableModel, ExtendMedicalImageProperties* aProperty)
|
||||
: mTableModel(aTableModel)
|
||||
, mProperty(aProperty)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void FileItemAction::execute()
|
||||
{
|
||||
mTableModel->setModelData(0,0,mProperty->GetSeriesNumber());
|
||||
mTableModel->setModelData(0,1,mProperty->GetSeriesDescription());
|
||||
mTableModel->setModelData(0,2,mProperty->GetAcquisitionDate());
|
||||
mTableModel->setModelData(0,3,mProperty->GetAcquisitionTime());
|
||||
mTableModel->setModelData(0,4,mProperty->GetModality());
|
||||
mTableModel->setModelData(0,5,QString::number(mProperty->GetColumns()));
|
||||
mTableModel->setModelData(0,6,QString::number(mProperty->GetRows()));
|
||||
mTableModel->setModelData(0,7,QString::number(mProperty->GetFileNames().size()));
|
||||
|
||||
}
|
||||
18
DIDKit/App/Model/FileItemAction.h
Normal file
18
DIDKit/App/Model/FileItemAction.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef FILEITEMACTION_H
|
||||
#define FILEITEMACTION_H
|
||||
|
||||
class ExtendMedicalImageProperties;
|
||||
class PropertyTableModel;
|
||||
|
||||
class FileItemAction
|
||||
{
|
||||
public:
|
||||
FileItemAction(PropertyTableModel* aTableModel, ExtendMedicalImageProperties* aProperty);
|
||||
void execute();
|
||||
|
||||
private:
|
||||
PropertyTableModel* mTableModel;
|
||||
ExtendMedicalImageProperties* mProperty;
|
||||
};
|
||||
|
||||
#endif // FILEITEMACTION_H
|
||||
180
DIDKit/App/Model/FileModel.cpp
Normal file
180
DIDKit/App/Model/FileModel.cpp
Normal file
@@ -0,0 +1,180 @@
|
||||
#include "FileModel.h"
|
||||
#include "FileItem.h"
|
||||
#include "FileItemAction.h"
|
||||
|
||||
#include "IO/DICOM/ExtendMedicalImageProperties.h"
|
||||
#include "DICOMPropertiesStore.h"
|
||||
|
||||
FileModel::FileModel(PropertyTableModel* aTableModel, QObject *parent)
|
||||
: QAbstractItemModel(parent)
|
||||
, mRootItem(new FileItem(FileItemDataPointer(new QVariant("root"))))
|
||||
, mPatientList(nullptr)
|
||||
, mTableModel(aTableModel)
|
||||
{
|
||||
setModelData();
|
||||
}
|
||||
|
||||
FileModel::~FileModel()
|
||||
{
|
||||
delete mRootItem;
|
||||
}
|
||||
|
||||
QVariant FileModel::data(const QModelIndex &aIndex, int aRole) const
|
||||
{
|
||||
if (aRole != Qt::DisplayRole)
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
if (!aIndex.isValid())
|
||||
{
|
||||
return *mRootItem->getData();
|
||||
}
|
||||
|
||||
FileItem* item = static_cast<FileItem*>(aIndex.internalPointer());
|
||||
if (item == nullptr)
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
return *item->getData();
|
||||
}
|
||||
|
||||
QModelIndex FileModel::index(int aRow, int aColumn, const QModelIndex &aParent) const
|
||||
{
|
||||
if (!hasIndex(aRow, aColumn, aParent))
|
||||
{
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
FileItem* parentItem;
|
||||
|
||||
if (!aParent.isValid())
|
||||
{
|
||||
parentItem = mRootItem;
|
||||
}
|
||||
else
|
||||
{
|
||||
parentItem = static_cast<FileItem*>(aParent.internalPointer());
|
||||
}
|
||||
|
||||
FileItem* childItem = parentItem->getChild(aRow);
|
||||
if (childItem)
|
||||
{
|
||||
return createIndex(aRow, aColumn, childItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
return QModelIndex();
|
||||
}
|
||||
}
|
||||
|
||||
QModelIndex FileModel::parent(const QModelIndex &aIndex) const
|
||||
{
|
||||
if (!aIndex.isValid())
|
||||
{
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
FileItem *childItem = static_cast<FileItem*>(aIndex.internalPointer());
|
||||
FileItem *parentItem = childItem->getParent();
|
||||
|
||||
if (parentItem == nullptr || parentItem == mRootItem)
|
||||
{
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
return createIndex(parentItem->getIndexRow(), 0, parentItem);
|
||||
}
|
||||
|
||||
int FileModel::rowCount(const QModelIndex& aParent) const
|
||||
{
|
||||
if (aParent.column() > 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!aParent.isValid())
|
||||
{
|
||||
return mRootItem->childCount();
|
||||
}
|
||||
|
||||
FileItem* item = static_cast<FileItem*>(aParent.internalPointer());
|
||||
if(item == nullptr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return item->childCount();
|
||||
}
|
||||
|
||||
int FileModel::columnCount(const QModelIndex &aParent) const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void FileModel::setModelData()
|
||||
{
|
||||
clearModelData();
|
||||
mPatientList = DICOMPropertiesStore::GetInstance()->getPatientsList();
|
||||
beginResetModel();
|
||||
//Patient Node
|
||||
std::map<std::string,PatientInfo*>::iterator patientIter;
|
||||
for(patientIter = mPatientList->begin();patientIter != mPatientList->end(); ++patientIter)
|
||||
{
|
||||
FileItem* patient = new FileItem(
|
||||
FileItemDataPointer(new QVariant(QString("Patient: %1, Name: %2, Birth Date: %3")
|
||||
.arg(patientIter->first.c_str(),patientIter->second->patient_name.c_str(),patientIter->second->birth_date.c_str()))),mRootItem);
|
||||
//Study Node
|
||||
std::map<std::string,StudyInfo*>::iterator studyIter;
|
||||
StudiesMapType* studyMap = patientIter->second->studies;
|
||||
for(studyIter = studyMap->begin();studyIter != studyMap->end(); ++studyIter)
|
||||
{
|
||||
FileItem* study = new FileItem(FileItemDataPointer(new QVariant(QString("Study: %1, Date: %2")
|
||||
.arg(studyIter->first.c_str(), studyIter->second->study_date.c_str()))),patient);
|
||||
//Series Node
|
||||
std::map<std::string,ImageSetMapType*>::iterator seriesIter;
|
||||
SeriesMapType* seriesMap = studyIter->second->series;
|
||||
for(seriesIter = seriesMap->begin();seriesIter != seriesMap->end(); ++seriesIter)
|
||||
{
|
||||
FileItem* series = new FileItem(FileItemDataPointer(new QVariant(QString("Series: ")+seriesIter->first.c_str())),study);
|
||||
//Image Set Node
|
||||
std::map<std::string,ExtendMedicalImageProperties*>::iterator imageSetIter;
|
||||
ImageSetMapType* imageSetMap = seriesIter->second;
|
||||
for(imageSetIter = imageSetMap->begin();imageSetIter != imageSetMap->end(); ++imageSetIter)
|
||||
{
|
||||
ExtendMedicalImageProperties* property = imageSetIter->second;
|
||||
FileItem* imageSet = new FileItem(FileItemDataPointer(new QVariant(QString("ImageSet: ")+imageSetIter->first.c_str() + QString(" ")
|
||||
+ QString::number(property->GetFileNames().size())))
|
||||
, series
|
||||
, FileItemActionPointer(new FileItemAction(mTableModel,property)));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void FileModel::clearModelData()
|
||||
{
|
||||
if (rowCount() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
beginResetModel();
|
||||
mRootItem->clearChilds();
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void FileModel::executeItemAction(const QModelIndex& aIndex)
|
||||
{
|
||||
if(aIndex.isValid())
|
||||
{
|
||||
FileItem* item = static_cast<FileItem*>(aIndex.internalPointer());
|
||||
if (item != nullptr)
|
||||
{
|
||||
item->executeAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
35
DIDKit/App/Model/FileModel.h
Normal file
35
DIDKit/App/Model/FileModel.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifndef FILEMODEL_H
|
||||
#define FILEMODEL_H
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
|
||||
#include "IO/Common/DICOMTypes.h"
|
||||
|
||||
class FileItem;
|
||||
class PropertyTableModel;
|
||||
|
||||
class FileModel : public QAbstractItemModel
|
||||
{
|
||||
public:
|
||||
explicit FileModel(PropertyTableModel* aTableModel, QObject *parent = nullptr);
|
||||
~FileModel() override;
|
||||
|
||||
QVariant data(const QModelIndex &aIndex, int aRole) const override;
|
||||
// Qt::ItemFlags flags(const QModelIndex &aIndex) const override;
|
||||
// QVariant headerData(int aSection, Qt::Orientation orientation,
|
||||
// int aRole = Qt::DisplayRole) const override;
|
||||
QModelIndex index(int aRow, int aColumn, const QModelIndex &aParent = QModelIndex()) const override;
|
||||
QModelIndex parent(const QModelIndex &aIndex) const override;
|
||||
int rowCount(const QModelIndex &aParent = QModelIndex()) const override;
|
||||
int columnCount(const QModelIndex &aParent = QModelIndex()) const override;
|
||||
void setModelData();
|
||||
void clearModelData();
|
||||
void executeItemAction(const QModelIndex& aIndex);
|
||||
|
||||
private:
|
||||
FileItem* mRootItem;
|
||||
PatientsMapType* mPatientList;
|
||||
PropertyTableModel* mTableModel;
|
||||
};
|
||||
|
||||
#endif // FILEMODEL_H
|
||||
22
DIDKit/App/Model/PropertyTableModel.cpp
Normal file
22
DIDKit/App/Model/PropertyTableModel.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#include "PropertyTableModel.h"
|
||||
#include <QStandardItem>
|
||||
#include <QDebug>
|
||||
|
||||
PropertyTableModel::PropertyTableModel(QObject *parent)
|
||||
: QStandardItemModel(parent)
|
||||
{
|
||||
setHorizontalHeaderLabels(QStringList()<<tr("Series Num")<<tr("Series Des")<<tr("Date")<<tr("Time")
|
||||
<<tr("Modality")<<tr("Column")<<tr("Rows")<<tr("Image Count"));
|
||||
}
|
||||
|
||||
PropertyTableModel::~PropertyTableModel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void PropertyTableModel::setModelData(int aRow,int aColumn,const QString& aData)
|
||||
{
|
||||
for(int i=0;i< columnCount() ;++i)
|
||||
setItem(aRow,aColumn,new QStandardItem(aData));
|
||||
}
|
||||
|
||||
15
DIDKit/App/Model/PropertyTableModel.h
Normal file
15
DIDKit/App/Model/PropertyTableModel.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef PROPERTYTABLEMODEL_H
|
||||
#define PROPERTYTABLEMODEL_H
|
||||
|
||||
#include <QStandardItemModel>
|
||||
|
||||
class PropertyTableModel : public QStandardItemModel
|
||||
{
|
||||
public:
|
||||
explicit PropertyTableModel(QObject *parent = nullptr);
|
||||
~PropertyTableModel() override;
|
||||
void setModelData(int aRow,int aColumn,const QString& aData);
|
||||
|
||||
};
|
||||
|
||||
#endif // PROPERTYTABLEMODEL_H
|
||||
Reference in New Issue
Block a user