|
@@ -22,13 +22,13 @@
|
|
|
#include "ctkDICOMObjectListWidget.h"
|
|
|
#include "ui_ctkDICOMObjectListWidget.h"
|
|
|
|
|
|
-// STD includes
|
|
|
-#include <iostream>
|
|
|
-
|
|
|
// Qt includes
|
|
|
+#include <QApplication>
|
|
|
+#include <QClipboard>
|
|
|
+#include <QDesktopServices>
|
|
|
#include <QString>
|
|
|
#include <QStringList>
|
|
|
-#include <QTimer>
|
|
|
+#include <QUrl>
|
|
|
|
|
|
//CTK includes
|
|
|
#include <ctkDICOMObjectModel.h>
|
|
@@ -42,9 +42,11 @@ public:
|
|
|
ctkDICOMObjectListWidgetPrivate();
|
|
|
~ctkDICOMObjectListWidgetPrivate();
|
|
|
void populateDICOMObjectTreeView(const QString& fileName);
|
|
|
+ void setPathLabel(const QString& currentFile);
|
|
|
|
|
|
QString currentFile;
|
|
|
QStringList fileList;
|
|
|
+ ctkDICOMObjectModel* dicomObjectModel;
|
|
|
};
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
@@ -53,26 +55,27 @@ public:
|
|
|
//----------------------------------------------------------------------------
|
|
|
ctkDICOMObjectListWidgetPrivate::ctkDICOMObjectListWidgetPrivate()
|
|
|
{
|
|
|
-
|
|
|
}
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
ctkDICOMObjectListWidgetPrivate::~ctkDICOMObjectListWidgetPrivate()
|
|
|
{
|
|
|
-
|
|
|
}
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
void ctkDICOMObjectListWidgetPrivate::populateDICOMObjectTreeView(const QString& fileName)
|
|
|
{
|
|
|
- //TODO: Check memory management
|
|
|
- ctkDICOMObjectModel* dcmObjModel = new ctkDICOMObjectModel;
|
|
|
- dcmObjModel->setFile(fileName);
|
|
|
- this->dcmObjectTreeView->reset();
|
|
|
- this->dcmObjectTreeView->setModel(dcmObjModel);
|
|
|
+ this->dicomObjectModel->setFile(fileName);
|
|
|
+ this->dcmObjectTreeView->setModel(this->dicomObjectModel);
|
|
|
this->dcmObjectTreeView->expandAll();
|
|
|
}
|
|
|
|
|
|
+// --------------------------------------------------------------------------
|
|
|
+void ctkDICOMObjectListWidgetPrivate::setPathLabel(const QString& currentFile)
|
|
|
+{
|
|
|
+ currentPathLabel->setText(currentFile);
|
|
|
+}
|
|
|
+
|
|
|
//----------------------------------------------------------------------------
|
|
|
// ctkDICOMObjectListWidget methods
|
|
|
|
|
@@ -83,20 +86,29 @@ ctkDICOMObjectListWidget::ctkDICOMObjectListWidget(QWidget* _parent):Superclass(
|
|
|
Q_D(ctkDICOMObjectListWidget);
|
|
|
|
|
|
d->setupUi(this);
|
|
|
- d->currentPathLineEdit->setReadOnly(true);
|
|
|
- connect(d->fileSlider, SIGNAL(valueChanged(int)), this, SLOT(updateWidget()));
|
|
|
+ d->dicomObjectModel = new ctkDICOMObjectModel(this);
|
|
|
+
|
|
|
+ d->fileSliderWidget->setPageStep(1);
|
|
|
+
|
|
|
+ d->currentPathLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
|
|
+ connect(d->fileSliderWidget, SIGNAL(valueChanged(double)), this, SLOT(updateWidget()));
|
|
|
+ connect(d->dcmObjectTreeView, SIGNAL(doubleClicked(const QModelIndex&))
|
|
|
+ ,this, SLOT(openLookupUrl(const QModelIndex&)));
|
|
|
+ connect(d->copyPathPushButton , SIGNAL(clicked(bool)),this, SLOT(copyPath()));
|
|
|
}
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
ctkDICOMObjectListWidget::~ctkDICOMObjectListWidget()
|
|
|
{
|
|
|
+ Q_D(ctkDICOMObjectListWidget);
|
|
|
+ d->dicomObjectModel->deleteLater();
|
|
|
}
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
void ctkDICOMObjectListWidget::setCurrentFile(const QString& newFileName)
|
|
|
{
|
|
|
Q_D(ctkDICOMObjectListWidget);
|
|
|
- d->currentPathLineEdit->setText(newFileName);
|
|
|
+ d->setPathLabel(newFileName);
|
|
|
}
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
@@ -107,32 +119,51 @@ void ctkDICOMObjectListWidget::setFileList(const QStringList& fileList)
|
|
|
if (d-> fileList.size()> 0)
|
|
|
{
|
|
|
d->currentFile = d->fileList[0];
|
|
|
- d->currentPathLineEdit->setText(d->currentFile );
|
|
|
+ d->setPathLabel(d->currentFile );
|
|
|
+ d->currentPathLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
|
|
|
d->populateDICOMObjectTreeView(d->currentFile );
|
|
|
- d->fileSlider->setMaximum(d->fileList.size()-1);
|
|
|
+ d->fileSliderWidget->setMaximum(fileList.size()-1);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
// --------------------------------------------------------------------------
|
|
|
QString ctkDICOMObjectListWidget::currentFile()
|
|
|
{
|
|
|
- Q_D(const ctkDICOMObjectListWidget);
|
|
|
+ Q_D(ctkDICOMObjectListWidget);
|
|
|
return d->currentFile;
|
|
|
}
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
QStringList ctkDICOMObjectListWidget::fileList()
|
|
|
{
|
|
|
- Q_D(const ctkDICOMObjectListWidget);
|
|
|
+ Q_D(ctkDICOMObjectListWidget);
|
|
|
return d->fileList;
|
|
|
}
|
|
|
+// --------------------------------------------------------------------------
|
|
|
|
|
|
+void ctkDICOMObjectListWidget::openLookupUrl(const QModelIndex& index)
|
|
|
+{
|
|
|
+ if (index.column() == 0)
|
|
|
+ {
|
|
|
+ QVariant data = index.data();
|
|
|
+ QString lookupUrl = "http://dicomlookup.com/lookup.asp?sw=Tnumber&q="+data.toString();
|
|
|
+ QUrl url(lookupUrl);
|
|
|
+ QDesktopServices::openUrl(url);
|
|
|
+ }
|
|
|
+}
|
|
|
// --------------------------------------------------------------------------
|
|
|
+
|
|
|
void ctkDICOMObjectListWidget::updateWidget()
|
|
|
{
|
|
|
Q_D(ctkDICOMObjectListWidget);
|
|
|
- int fileNumber = d->fileSlider->value();
|
|
|
- d->currentFile = d->fileList[fileNumber];
|
|
|
- d->currentPathLineEdit->setText(d->currentFile);
|
|
|
+ d->currentFile = d->fileList[static_cast<int>(d->fileSliderWidget->value())];
|
|
|
+ d->setPathLabel(d->currentFile);
|
|
|
d->populateDICOMObjectTreeView(d->currentFile);
|
|
|
+ }
|
|
|
+// --------------------------------------------------------------------------
|
|
|
+
|
|
|
+void ctkDICOMObjectListWidget::copyPath()
|
|
|
+{
|
|
|
+ Q_D(ctkDICOMObjectListWidget);
|
|
|
+ QClipboard *clipboard = QApplication::clipboard();
|
|
|
+ clipboard->setText(d->currentFile);
|
|
|
}
|