|
@@ -3,11 +3,18 @@
|
|
|
#include <QTabBar>
|
|
|
#include <QSettings>
|
|
|
|
|
|
+// ctkDICOMCore includes
|
|
|
+#include "ctkDICOM.h"
|
|
|
+#include "ctkDICOMModel.h"
|
|
|
+#include "ctkDICOMQuery.h"
|
|
|
+#include "ctkDICOMRetrieve.h"
|
|
|
+
|
|
|
// ctkDICOMWidgets includes
|
|
|
#include "ctkDICOMQueryRetrieveWidget.h"
|
|
|
#include "ctkDICOMQueryResultsTabWidget.h"
|
|
|
#include "ui_ctkDICOMQueryRetrieveWidget.h"
|
|
|
|
|
|
+
|
|
|
#include <ctkLogger.h>
|
|
|
static ctkLogger logger("org.commontk.DICOM.Widgets.ctkDICOMQueryRetrieveWidget");
|
|
|
|
|
@@ -16,6 +23,8 @@ class ctkDICOMQueryRetrieveWidgetPrivate: public Ui_ctkDICOMQueryRetrieveWidget
|
|
|
{
|
|
|
public:
|
|
|
ctkDICOMQueryRetrieveWidgetPrivate(){}
|
|
|
+
|
|
|
+ QMap<QString, ctkDICOMQuery*> queries;
|
|
|
};
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
@@ -33,9 +42,7 @@ ctkDICOMQueryRetrieveWidget::ctkDICOMQueryRetrieveWidget(QWidget* _parent):Super
|
|
|
|
|
|
d->setupUi(this);
|
|
|
|
|
|
- d->results->disableCloseOnTab(0);
|
|
|
connect(d->queryButton, SIGNAL(clicked()), this, SLOT(processQuery()));
|
|
|
- connect(d->results, SIGNAL(tabCloseRequested(int)), this, SLOT(onTabCloseRequested(int)));
|
|
|
}
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
@@ -44,24 +51,19 @@ ctkDICOMQueryRetrieveWidget::~ctkDICOMQueryRetrieveWidget()
|
|
|
}
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
-void ctkDICOMQueryRetrieveWidget::onDatabaseDirectoryChanged(const QString& directory)
|
|
|
+void ctkDICOMQueryRetrieveWidget::setRetrieveDirectory(const QString& directory)
|
|
|
{
|
|
|
QSettings settings;
|
|
|
- settings.setValue("DatabaseDirectory", directory);
|
|
|
+ settings.setValue("RetrieveDirectory", directory);
|
|
|
settings.sync();
|
|
|
}
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
-void ctkDICOMQueryRetrieveWidget::onTabCloseRequested(int index)
|
|
|
+void ctkDICOMQueryRetrieveWidget::setRetrieveDatabaseFileName(const QString& fileName)
|
|
|
{
|
|
|
- Q_D(ctkDICOMQueryRetrieveWidget);
|
|
|
-
|
|
|
- if (index == 0)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- d->results->removeTab(index);
|
|
|
+ QSettings settings;
|
|
|
+ settings.setValue("RetrieveDatabaseFileName", fileName);
|
|
|
+ settings.sync();
|
|
|
}
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
@@ -69,11 +71,60 @@ void ctkDICOMQueryRetrieveWidget::processQuery()
|
|
|
{
|
|
|
Q_D(ctkDICOMQueryRetrieveWidget);
|
|
|
|
|
|
- d->serverNodeWidget->populateQuery();
|
|
|
- d->queryWidget->populateQuery();
|
|
|
+ ctkDICOMQuery query;
|
|
|
|
|
|
- QTreeView *queryResults = new QTreeView;
|
|
|
- int tabIndex = d->results->addTab(queryResults, tr("Query Results"));
|
|
|
- d->results->setCurrentIndex(tabIndex);
|
|
|
-}
|
|
|
+ // TODO: convert widget to query parameters
|
|
|
+ // TODO: add interface to ctkDICOMQuery for specifying query params
|
|
|
+ //d->queryWidget->populateQuery();
|
|
|
|
|
|
+ QStringList nodes = d->serverNodeWidget->nodes();
|
|
|
+ foreach (QString node, nodes)
|
|
|
+ {
|
|
|
+ d->queries[node] = new ctkDICOMQuery;
|
|
|
+ QMap<QString, QString> parameters = d->serverNodeWidget->nodeParameters(node);
|
|
|
+ d->queries[node]->setCallingAETitle(node);
|
|
|
+ }
|
|
|
+
|
|
|
+#if 0
|
|
|
+TODO: map the server node options to the query classes
|
|
|
+
|
|
|
+ query.setCallingAETitle ( QString ( argv[2] ) );
|
|
|
+ query.setCalledAETitle ( QString ( argv[3] ) );
|
|
|
+ query.setHost ( QString ( argv[4] ) );
|
|
|
+ int port;
|
|
|
+ bool ok;
|
|
|
+ port = QString ( argv[5] ).toInt ( &ok );
|
|
|
+ if ( !ok )
|
|
|
+ {
|
|
|
+ std::cerr << "Could not convert " << argv[5] << " to an integer" << std::endl;
|
|
|
+ print_usage();
|
|
|
+ return EXIT_FAILURE;
|
|
|
+ }
|
|
|
+ query.setPort ( port );
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ query.query ( myCTK.database() );
|
|
|
+ }
|
|
|
+ catch (std::exception e)
|
|
|
+ {
|
|
|
+ return EXIT_FAILURE;
|
|
|
+ }
|
|
|
+ return EXIT_SUCCESS;
|
|
|
+#endif
|
|
|
+
|
|
|
+ // TODO: create a map of server locations to query results in the private class
|
|
|
+ ctkDICOM queryResultDatabase;
|
|
|
+
|
|
|
+ try { queryResultDatabase.openDatabase( ":memory:" ); }
|
|
|
+ catch (std::exception e)
|
|
|
+ {
|
|
|
+ logger.error ( "Database error: " + queryResultDatabase.GetLastError() );
|
|
|
+ queryResultDatabase.closeDatabase();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ ctkDICOMModel model;
|
|
|
+ model.setDatabase(queryResultDatabase.database());
|
|
|
+ d->results->setModel(&model);
|
|
|
+}
|