Browse Source

Add ctkDICOMWidgets tests. Cleanup code

ctkDICOMDirectoryListWidgetTest1, ctkDICOMImportWidgetTest1,
ctkDICOMListenerWidgetTest1, ctkDICOMQueryResultsTabWidgetTest1 and
ctkDICOMThumbnailWidgetTest1 have been added
Julien Finet 14 years ago
parent
commit
89c099b87d

+ 2 - 6
Libs/DICOM/Widgets/Resources/UI/ctkDICOMImportWidget.ui

@@ -56,7 +56,7 @@
    <sender>buttonBox</sender>
    <signal>accepted()</signal>
    <receiver>ctkDICOMImportWidget</receiver>
-   <slot>onOK()</slot>
+   <slot>close()</slot>
    <hints>
     <hint type="sourcelabel">
      <x>199</x>
@@ -72,7 +72,7 @@
    <sender>buttonBox</sender>
    <signal>rejected()</signal>
    <receiver>ctkDICOMImportWidget</receiver>
-   <slot>onCancel()</slot>
+   <slot>close()</slot>
    <hints>
     <hint type="sourcelabel">
      <x>199</x>
@@ -85,8 +85,4 @@
    </hints>
   </connection>
  </connections>
- <slots>
-  <slot>onOK()</slot>
-  <slot>onCancel()</slot>
- </slots>
 </ui>

+ 10 - 0
Libs/DICOM/Widgets/Testing/Cpp/CMakeLists.txt

@@ -3,8 +3,13 @@ SET(KIT ${PROJECT_NAME})
 CREATE_TEST_SOURCELIST(Tests ${KIT}CppTests.cpp
   ctkDICOMAppWidgetTest1.cpp
   ctkDICOMDatasetViewTest1.cpp
+  ctkDICOMDirectoryListWidgetTest1.cpp
+  ctkDICOMImportWidgetTest1.cpp
+  ctkDICOMListenerWidgetTest1.cpp
   ctkDICOMModelTest2.cpp
   ctkDICOMQueryRetrieveWidgetTest1.cpp
+  ctkDICOMQueryResultsTabWidgetTest1.cpp
+  ctkDICOMThumbnailWidgetTest1.cpp
   )
 
 SET (TestsToRun ${Tests})
@@ -30,6 +35,9 @@ SIMPLE_TEST(ctkDICOMAppWidgetTest1)
 ADD_TEST( ctkDICOMDatasetViewTest1  ${KIT_TESTS} 
           ctkDICOMDatasetViewTest1  ${CTKData_DIR}/Data/DICOM/MRHEAD/000055.IMA)
 SET_PROPERTY(TEST ctkDICOMDatasetViewTest1 PROPERTY LABELS ${PROJECT_NAME})
+SIMPLE_TEST(ctkDICOMDirectoryListWidgetTest1)
+SIMPLE_TEST(ctkDICOMImportWidgetTest1)
+SIMPLE_TEST(ctkDICOMListenerWidgetTest1)
 
 ADD_TEST( ctkDICOMModelTest2 ${KIT_TESTS}
           ctkDICOMModelTest2 ${CMAKE_CURRENT_BINARY_DIR}/dicom.db
@@ -37,3 +45,5 @@ ADD_TEST( ctkDICOMModelTest2 ${KIT_TESTS}
 SET_PROPERTY(TEST ctkDICOMModelTest2 PROPERTY LABELS ${PROJECT_NAME})
 
 SIMPLE_TEST(ctkDICOMQueryRetrieveWidgetTest1)
+SIMPLE_TEST(ctkDICOMQueryResultsTabWidgetTest1)
+SIMPLE_TEST(ctkDICOMThumbnailWidgetTest1)

+ 19 - 0
Libs/DICOM/Widgets/Testing/Cpp/ctkDICOMAppWidgetTest1.cpp

@@ -1,3 +1,22 @@
+/*=========================================================================
+
+  Library:   CTK
+
+  Copyright (c) Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=========================================================================*/
 
 // Qt includes
 #include <QApplication>

+ 19 - 0
Libs/DICOM/Widgets/Testing/Cpp/ctkDICOMDatasetViewTest1.cpp

@@ -1,3 +1,22 @@
+/*=========================================================================
+
+  Library:   CTK
+
+  Copyright (c) Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=========================================================================*/
 
 // Qt includes
 #include <QApplication>

+ 55 - 0
Libs/DICOM/Widgets/Testing/Cpp/ctkDICOMDirectoryListWidgetTest1.cpp

@@ -0,0 +1,55 @@
+/*=========================================================================
+
+  Library:   CTK
+
+  Copyright (c) Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=========================================================================*/
+
+// Qt includes
+#include <QApplication>
+#include <QDir>
+#include <QTimer>
+
+// ctkDICOMCore includes
+#include "ctkDICOMDirectoryListWidget.h"
+
+// STD includes
+#include <iostream>
+
+int ctkDICOMDirectoryListWidgetTest1( int argc, char * argv [] )
+{
+  QApplication app(argc, argv);
+
+  ctkDICOMDatabase database;
+  ctkDICOMDirectoryListWidget listWidget;
+  listWidget.setDICOMDatabase(0);
+  listWidget.setDICOMDatabase(&database);
+  listWidget.addDirectory(QDir::tempPath());
+  listWidget.removeDirectory();
+
+  listWidget.show();
+
+  if (argc <= 1 || QString(argv[1]) != "-I")
+    {
+    QTimer::singleShot(200, &app, SLOT(quit()));
+    }
+
+  // if Qt uses the native dialog, then there is no way to force
+  // the getExistingDirectory dialog to close. so we can't test it.
+  //listWidget.addDirectory();
+
+  return app.exec();
+}

+ 51 - 0
Libs/DICOM/Widgets/Testing/Cpp/ctkDICOMImportWidgetTest1.cpp

@@ -0,0 +1,51 @@
+/*=========================================================================
+
+  Library:   CTK
+
+  Copyright (c) Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=========================================================================*/
+
+// Qt includes
+#include <QApplication>
+#include <QDir>
+#include <QTimer>
+
+// ctkDICOMCore includes
+#include "ctkDICOMDatabase.h"
+
+// ctkDICOMWidget includes
+#include "ctkDICOMImportWidget.h"
+
+// STD includes
+#include <iostream>
+
+int ctkDICOMImportWidgetTest1( int argc, char * argv [] )
+{
+  QApplication app(argc, argv);
+
+  ctkDICOMDatabase* database = new ctkDICOMDatabase;
+  ctkDICOMImportWidget importWidget;
+  importWidget.setDICOMDatabase(QSharedPointer<ctkDICOMDatabase>(database));
+  importWidget.setTopDirectory(QDir::tempPath());
+  importWidget.show();
+
+  if (argc <= 1 || QString(argv[1]) != "-I")
+    {
+    QTimer::singleShot(200, &app, SLOT(quit()));
+    }
+
+  return app.exec();
+}

+ 44 - 0
Libs/DICOM/Widgets/Testing/Cpp/ctkDICOMListenerWidgetTest1.cpp

@@ -0,0 +1,44 @@
+/*=========================================================================
+
+  Library:   CTK
+
+  Copyright (c) Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=========================================================================*/
+
+// Qt includes
+#include <QApplication>
+#include <QTimer>
+
+// ctkDICOMCore includes
+#include "ctkDICOMListenerWidget.h"
+
+// STD includes
+#include <iostream>
+
+int ctkDICOMListenerWidgetTest1( int argc, char * argv [] )
+{
+  QApplication app(argc, argv);
+
+  ctkDICOMListenerWidget listenerWidget;
+  listenerWidget.show();
+
+  if (argc <= 1 || QString(argv[1]) != "-I")
+    {
+    QTimer::singleShot(200, &app, SLOT(quit()));
+    }
+
+  return app.exec();
+}

+ 19 - 0
Libs/DICOM/Widgets/Testing/Cpp/ctkDICOMModelTest2.cpp

@@ -1,3 +1,22 @@
+/*=========================================================================
+
+  Library:   CTK
+
+  Copyright (c) Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=========================================================================*/
 
 // Qt includes
 #include <QApplication>

+ 45 - 0
Libs/DICOM/Widgets/Testing/Cpp/ctkDICOMQueryResultsTabWidgetTest1.cpp

@@ -0,0 +1,45 @@
+/*=========================================================================
+
+  Library:   CTK
+
+  Copyright (c) Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=========================================================================*/
+
+// Qt includes
+#include <QApplication>
+#include <QTimer>
+
+// ctkDICOMCore includes
+#include "ctkDICOMQueryResultsTabWidget.h"
+
+// STD includes
+#include <iostream>
+
+int ctkDICOMQueryResultsTabWidgetTest1( int argc, char * argv [] )
+{
+  QApplication app(argc, argv);
+
+  ctkDICOMQueryResultsTabWidget widget;
+  widget.disableCloseOnTab(0);
+  widget.show();
+
+  if (argc <= 1 || QString(argv[1]) != "-I")
+    {
+    QTimer::singleShot(200, &app, SLOT(quit()));
+    }
+
+  return app.exec();
+}

+ 20 - 0
Libs/DICOM/Widgets/Testing/Cpp/ctkDICOMQueryRetrieveWidgetTest1.cpp

@@ -1,3 +1,23 @@
+/*=========================================================================
+
+  Library:   CTK
+
+  Copyright (c) Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=========================================================================*/
+
 // Qt includes
 #include <QApplication>
 #include <QDebug>

+ 62 - 0
Libs/DICOM/Widgets/Testing/Cpp/ctkDICOMThumbnailWidgetTest1.cpp

@@ -0,0 +1,62 @@
+/*=========================================================================
+
+  Library:   CTK
+
+  Copyright (c) Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=========================================================================*/
+
+// Qt includes
+#include <QApplication>
+#include <QTimer>
+
+// ctkDICOMCore includes
+#include "ctkDICOMThumbnailWidget.h"
+
+// STD includes
+#include <iostream>
+
+int ctkDICOMThumbnailWidgetTest1( int argc, char * argv [] )
+{
+  QApplication app(argc, argv);
+
+  ctkDICOMThumbnailWidget widget;
+
+  widget.setText("Test");
+  if (widget.text() != "Test")
+    {
+    std::cerr << "ctkDICOMThumbnailWidget::setText failed."
+              << " text: " << qPrintable(widget.text())
+              << " expected: Test" << std::endl;
+    return EXIT_FAILURE;
+    }
+
+  widget.setPixmap(QPixmap());
+  if (widget.pixmap())
+    {
+    std::cerr << "ctkDICOMThumbnailWidget::setPixmap failed:"
+              << widget.pixmap() << std::endl;
+    return EXIT_FAILURE;
+    }
+
+  widget.show();
+
+  if (argc <= 1 || QString(argv[1]) != "-I")
+    {
+    QTimer::singleShot(200, &app, SLOT(quit()));
+    }
+
+  return app.exec();
+}

+ 56 - 26
Libs/DICOM/Widgets/ctkDICOMDirectoryListWidget.cpp

@@ -1,3 +1,22 @@
+/*=========================================================================
+
+  Library:   CTK
+
+  Copyright (c) Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=========================================================================*/
 
 // Qt includes
 #include <QFileDialog>
@@ -22,7 +41,7 @@ class ctkDICOMDirectoryListWidgetPrivate: public Ui_ctkDICOMDirectoryListWidget
 public:
   ctkDICOMDirectoryListWidgetPrivate(){}
   ctkDICOMDatabase*       database;
-  QSqlTableModel* directoryListModel;
+  QSqlTableModel*         directoryListModel;
 };
 
 //----------------------------------------------------------------------------
@@ -33,15 +52,16 @@ public:
 // ctkDICOMDirectoryListWidget methods
 
 //----------------------------------------------------------------------------
-ctkDICOMDirectoryListWidget::ctkDICOMDirectoryListWidget(QWidget* _parent):Superclass(_parent), 
-  d_ptr(new ctkDICOMDirectoryListWidgetPrivate)
+ctkDICOMDirectoryListWidget::ctkDICOMDirectoryListWidget(QWidget* parentWidget)
+ : Superclass(parentWidget)
+ , d_ptr(new ctkDICOMDirectoryListWidgetPrivate)
 {
   Q_D(ctkDICOMDirectoryListWidget);
 
   d->setupUi(this);
 
-  connect(d->addButton, SIGNAL(clicked()), this, SLOT(addDirectoryClicked()));
-  connect(d->removeButton, SIGNAL(clicked()), this, SLOT(removeDirectoryClicked()));
+  connect(d->addButton, SIGNAL(clicked()), this, SLOT(addDirectory()));
+  connect(d->removeButton, SIGNAL(clicked()), this, SLOT(removeDirectory()));
 
   d->removeButton->setDisabled(true);
 }
@@ -52,35 +72,41 @@ ctkDICOMDirectoryListWidget::~ctkDICOMDirectoryListWidget()
 }
 
 //----------------------------------------------------------------------------
-void ctkDICOMDirectoryListWidget::addDirectoryClicked()
+void ctkDICOMDirectoryListWidget::addDirectory()
 {
-  Q_D(ctkDICOMDirectoryListWidget);
   QString newDir = QFileDialog::getExistingDirectory(this, tr("Open Directory"));
 
   if ( !newDir.isEmpty() )
-  {
-    QSqlRecord newDirRecord;
-    newDirRecord.append(QSqlField("Dirname",QVariant::String));
-    newDirRecord.setValue("Dirname",newDir);
-    /*bool success = */d->directoryListModel->insertRecord(-1,newDirRecord);
-    bool success2 = d->directoryListModel->submitAll();
-    if ( !success2 )
     {
-      qDebug() << d->directoryListModel->lastError();
+    this->addDirectory(newDir);
     }
-    //addDirectoryQuery.prepare("insert into Directories VALUES ( :dirname )");
-    //addDirectoryQuery.bindValue(":dirname",newDir);
-    //addDirectoryQuery.exec();
+}
 
-//    d->directoryListModel;
-  }
+//----------------------------------------------------------------------------
+void ctkDICOMDirectoryListWidget::addDirectory(const QString& newDir)
+{
+  Q_D(ctkDICOMDirectoryListWidget);
+  QSqlRecord newDirRecord;
+  newDirRecord.append(QSqlField("Dirname",QVariant::String));
+  newDirRecord.setValue("Dirname",newDir);
+  /*bool success = */d->directoryListModel->insertRecord(-1,newDirRecord);
+  bool success2 = d->directoryListModel->submitAll();
+  if ( !success2 )
+    {
+    qDebug() << d->directoryListModel->lastError();
+    }
+  //addDirectoryQuery.prepare("insert into Directories VALUES ( :dirname )");
+  //addDirectoryQuery.bindValue(":dirname",newDir);
+  //addDirectoryQuery.exec();
+
+  //    d->directoryListModel;
 
-//d->directoryListView->setModel(NULL);
-// d->tableView->setModel(NULL);
+  //d->directoryListView->setModel(NULL);
+  // d->tableView->setModel(NULL);
 }
 
 //----------------------------------------------------------------------------
-void ctkDICOMDirectoryListWidget::removeDirectoryClicked()
+void ctkDICOMDirectoryListWidget::removeDirectory()
 {
   Q_D(ctkDICOMDirectoryListWidget);
   while ( ! d->directoryListView->selectionModel()->selectedIndexes().empty() )
@@ -96,7 +122,8 @@ void ctkDICOMDirectoryListWidget::setDICOMDatabase(ctkDICOMDatabase* dicomDataba
 {
   Q_D(ctkDICOMDirectoryListWidget);
   d->database = dicomDatabase;
-  d->directoryListModel =  new QSqlTableModel(this,d->database->database());
+  d->directoryListModel = new QSqlTableModel(
+    this, d->database ? d->database->database() : QSqlDatabase());
   d->directoryListModel->setTable("Directories");
   d->directoryListModel->setEditStrategy(QSqlTableModel::OnFieldChange);
   d->directoryListModel->select();
@@ -105,11 +132,14 @@ void ctkDICOMDirectoryListWidget::setDICOMDatabase(ctkDICOMDatabase* dicomDataba
   connect ( d->directoryListView->selectionModel(),
             SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&)),
             this,
-            SLOT(directorySelectionChanged(const QItemSelection & , const QItemSelection &  )));
+            SLOT(directorySelectionChanged(const QItemSelection & ,
+                                           const QItemSelection &  )));
 }
 
 //----------------------------------------------------------------------------
-void ctkDICOMDirectoryListWidget::directorySelectionChanged( const QItemSelection  & selected, const QItemSelection  & deselected )
+void ctkDICOMDirectoryListWidget
+::directorySelectionChanged( const QItemSelection  & selected,
+                             const QItemSelection  & deselected )
 {
   Q_UNUSED(deselected);
   Q_D(ctkDICOMDirectoryListWidget);

+ 7 - 3
Libs/DICOM/Widgets/ctkDICOMDirectoryListWidget.h

@@ -38,12 +38,16 @@ class CTK_DICOM_WIDGETS_EXPORT ctkDICOMDirectoryListWidget : public QWidget
 public:
   typedef QWidget Superclass;
   explicit ctkDICOMDirectoryListWidget(QWidget* parent=0);
-  void setDICOMDatabase(ctkDICOMDatabase*);
   virtual ~ctkDICOMDirectoryListWidget();
 
+  void setDICOMDatabase(ctkDICOMDatabase*);
+
 public slots:
-  void addDirectoryClicked();
-  void removeDirectoryClicked();
+  void addDirectory();
+  void addDirectory(const QString&);
+  void removeDirectory();
+
+protected slots:
   void directorySelectionChanged( const QItemSelection  & selected, const QItemSelection  & deselected );
 
 protected:

+ 40 - 16
Libs/DICOM/Widgets/ctkDICOMImportWidget.cpp

@@ -1,3 +1,23 @@
+/*=========================================================================
+
+  Library:   CTK
+
+  Copyright (c) Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=========================================================================*/
+
 //ctkDICOMCore includes
 #include "ctkDICOMDatabase.h"
 
@@ -30,22 +50,24 @@ public:
 // ctkDICOMImportWidget methods
 
 //----------------------------------------------------------------------------
-ctkDICOMImportWidget::ctkDICOMImportWidget(QWidget* _parent):Superclass(_parent), 
-  d_ptr(new ctkDICOMImportWidgetPrivate)
+ctkDICOMImportWidget::ctkDICOMImportWidget(QWidget* parentWidget)
+  : Superclass(parentWidget)
+  , d_ptr(new ctkDICOMImportWidgetPrivate)
 {
   Q_D(ctkDICOMImportWidget);
-  
+
   d->setupUi(this);
-  
+
   d->DirectoryWidget->setDirectory(QDir::homePath());
 
   d->FileSystemModel = new QFileSystemModel(this);
   d->FileSystemModel->setRootPath(QDir::homePath());
   d->directoryList->setModel(d->FileSystemModel);
-  d->directoryList->setRootIndex(d->FileSystemModel->index(QDir::homePath()));
 
   //connect signals and slots
-  connect(d->DirectoryWidget, SIGNAL(directoryChanged(const QString&)), this, SLOT(onTopDirectoryChanged(const QString&)));
+  connect(d->DirectoryWidget, SIGNAL(directoryChanged(const QString&)),
+          this, SLOT(onTopDirectoryChanged(const QString&)));
+  this->onTopDirectoryChanged(d->DirectoryWidget->directory());
 }
 
 //----------------------------------------------------------------------------
@@ -56,22 +78,24 @@ ctkDICOMImportWidget::~ctkDICOMImportWidget()
   d->FileSystemModel->deleteLater();
 }
 
-void ctkDICOMImportWidget::onOK(){
-  
-  this->close();
-}
-
-void ctkDICOMImportWidget::onCancel(){
-  this->close();
+//----------------------------------------------------------------------------
+void ctkDICOMImportWidget::setTopDirectory(const QString& path)
+{
+  Q_D(ctkDICOMImportWidget);
+  d->DirectoryWidget->setDirectory(path);
 }
 
-void ctkDICOMImportWidget::onTopDirectoryChanged(const QString& path){
+//----------------------------------------------------------------------------
+void ctkDICOMImportWidget::onTopDirectoryChanged(const QString& path)
+{
   Q_D(ctkDICOMImportWidget);
-  
   d->directoryList->setRootIndex(d->FileSystemModel->index(path));
 }
 
-void ctkDICOMImportWidget::setDICOMDatabase(QSharedPointer<ctkDICOMDatabase> database){
+//----------------------------------------------------------------------------
+void ctkDICOMImportWidget
+::setDICOMDatabase(QSharedPointer<ctkDICOMDatabase> database)
+{
   Q_D(ctkDICOMImportWidget);
 
   d->DICOMDatabase = database;

+ 6 - 4
Libs/DICOM/Widgets/ctkDICOMImportWidget.h

@@ -40,6 +40,12 @@ public:
 
   void setDICOMDatabase(QSharedPointer<ctkDICOMDatabase> database);
 
+public slots:
+  void setTopDirectory(const QString& path);
+
+protected slots:
+  void onTopDirectoryChanged(const QString& path);
+
 protected:
   QScopedPointer<ctkDICOMImportWidgetPrivate> d_ptr;
 
@@ -47,10 +53,6 @@ private:
   Q_DECLARE_PRIVATE(ctkDICOMImportWidget);
   Q_DISABLE_COPY(ctkDICOMImportWidget);
 
-public slots:
-  void onOK();
-  void onCancel();
-  void onTopDirectoryChanged(const QString& path);
 };
 
 #endif

+ 23 - 3
Libs/DICOM/Widgets/ctkDICOMListenerWidget.cpp

@@ -1,3 +1,22 @@
+/*=========================================================================
+
+  Library:   CTK
+
+  Copyright (c) Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=========================================================================*/
 
 // ctkDICOMWidgets includes
 #include "ctkDICOMListenerWidget.h"
@@ -18,11 +37,12 @@ public:
 // ctkDICOMListenerWidget methods
 
 //----------------------------------------------------------------------------
-ctkDICOMListenerWidget::ctkDICOMListenerWidget(QWidget* _parent):Superclass(_parent), 
-  d_ptr(new ctkDICOMListenerWidgetPrivate)
+ctkDICOMListenerWidget::ctkDICOMListenerWidget(QWidget* parentWidget)
+  : Superclass(parentWidget)
+  , d_ptr(new ctkDICOMListenerWidgetPrivate)
 {
   Q_D(ctkDICOMListenerWidget);
-  
+
   d->setupUi(this);
 }
 

+ 21 - 1
Libs/DICOM/Widgets/ctkDICOMQueryResultsTabWidget.cpp

@@ -1,3 +1,22 @@
+/*=========================================================================
+
+  Library:   CTK
+
+  Copyright (c) Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=========================================================================*/
 
 // Qt widgets
 #include <QDebug>
@@ -10,7 +29,8 @@
 // ctkDICOMQueryResultsTabWidget methods
 
 //----------------------------------------------------------------------------
-ctkDICOMQueryResultsTabWidget::ctkDICOMQueryResultsTabWidget(QWidget* _parent):Superclass(_parent)
+ctkDICOMQueryResultsTabWidget::ctkDICOMQueryResultsTabWidget(QWidget* parentWidget)
+ : Superclass(parentWidget)
 {
 }
 

+ 1 - 1
Libs/DICOM/Widgets/ctkDICOMQueryResultsTabWidget.h

@@ -36,7 +36,7 @@ public:
   virtual ~ctkDICOMQueryResultsTabWidget();
 
   void disableCloseOnTab(int index);
-  
+
 private:
 };
 

+ 46 - 7
Libs/DICOM/Widgets/ctkDICOMThumbnailWidget.cpp

@@ -1,4 +1,22 @@
+/*=========================================================================
 
+  Library:   CTK
+
+  Copyright (c) Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=========================================================================*/
 
 // ctkDICOMWidgets includes
 #include "ctkDICOMThumbnailWidget.h"
@@ -11,7 +29,6 @@
 class ctkDICOMThumbnailWidgetPrivate: public Ui_ctkDICOMThumbnailWidget
 {
 public:
-  ctkDICOMThumbnailWidgetPrivate(){}
 };
 
 //----------------------------------------------------------------------------
@@ -22,11 +39,12 @@ public:
 // ctkDICOMThumbnailWidget methods
 
 //----------------------------------------------------------------------------
-ctkDICOMThumbnailWidget::ctkDICOMThumbnailWidget(QWidget* _parent):Superclass(_parent), 
-  d_ptr(new ctkDICOMThumbnailWidgetPrivate)
+ctkDICOMThumbnailWidget::ctkDICOMThumbnailWidget(QWidget* parentWidget)
+  : Superclass(parentWidget)
+  , d_ptr(new ctkDICOMThumbnailWidgetPrivate)
 {
   Q_D(ctkDICOMThumbnailWidget);
-  
+
   d->setupUi(this);
 }
 
@@ -35,18 +53,39 @@ ctkDICOMThumbnailWidget::~ctkDICOMThumbnailWidget()
 {
 }
 
-void ctkDICOMThumbnailWidget::setText(QString &text){
+//----------------------------------------------------------------------------
+void ctkDICOMThumbnailWidget::setText(const QString &text)
+{
   Q_D(ctkDICOMThumbnailWidget);
 
   d->textLabel->setText(text);
 }
 
-void ctkDICOMThumbnailWidget::setPixmap(QPixmap &pixmap){
+//----------------------------------------------------------------------------
+QString ctkDICOMThumbnailWidget::text()const
+{
+  Q_D(const ctkDICOMThumbnailWidget);
+  return d->textLabel->text();
+}
+
+//----------------------------------------------------------------------------
+void ctkDICOMThumbnailWidget::setPixmap(const QPixmap &pixmap)
+{
   Q_D(ctkDICOMThumbnailWidget);
 
   d->pixmapLabel->setPixmap(pixmap);
 }
 
-void ctkDICOMThumbnailWidget::mousePressEvent(QMouseEvent* event){
+//----------------------------------------------------------------------------
+const QPixmap* ctkDICOMThumbnailWidget::pixmap()const
+{
+  Q_D(const ctkDICOMThumbnailWidget);
+  return d->textLabel->pixmap();
+}
+
+//----------------------------------------------------------------------------
+void ctkDICOMThumbnailWidget::mousePressEvent(QMouseEvent* event)
+{
+  Q_UNUSED(event);
   emit selected(*this);
 }

+ 9 - 4
Libs/DICOM/Widgets/ctkDICOMThumbnailWidget.h

@@ -31,19 +31,24 @@ class ctkDICOMThumbnailWidgetPrivate;
 class CTK_DICOM_WIDGETS_EXPORT ctkDICOMThumbnailWidget : public QWidget
 {
   Q_OBJECT
+  Q_PROPERTY(QString text READ text WRITE setText)
+  Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap)
 public:
   typedef QWidget Superclass;
   explicit ctkDICOMThumbnailWidget(QWidget* parent=0);
   virtual ~ctkDICOMThumbnailWidget();
 
-  void setText(QString& text);
-  void setPixmap(QPixmap& pixmap);
-  
+  void setText(const QString& text);
+  QString text()const;
+
+  void setPixmap(const QPixmap& pixmap);
+  const QPixmap* pixmap()const;
+
 protected:
   QScopedPointer<ctkDICOMThumbnailWidgetPrivate> d_ptr;
 
   virtual void mousePressEvent(QMouseEvent* event);
-  
+
 private:
   Q_DECLARE_PRIVATE(ctkDICOMThumbnailWidget);
   Q_DISABLE_COPY(ctkDICOMThumbnailWidget);