瀏覽代碼

Added methods for getting the current table selection to the tablemanager. Removing of items is now done in the dicombrowser directly on the database

Andreas Fetzer 12 年之前
父節點
當前提交
7ad75a41e8

+ 16 - 1
Libs/DICOM/Widgets/ctkDICOMBrowser.cpp

@@ -432,7 +432,22 @@ void ctkDICOMBrowser::onQueryRetrieveFinished()
 void ctkDICOMBrowser::onRemoveAction()
 {
   Q_D(ctkDICOMBrowser);
-  d->dicomTableManager->deleteSelectedRows();
+  QStringList selectedSeriesUIDs = d->dicomTableManager->currentSeriesSelection();
+  QString uid;
+  foreach (uid, selectedSeriesUIDs)
+    {
+      d->DICOMDatabase->removeSeries(uid);
+    }
+  QStringList selectedStudiesUIDs = d->dicomTableManager->currentStudiesSelection();
+  foreach(uid, selectedStudiesUIDs)
+    {
+      d->DICOMDatabase->removeStudy(uid);
+    }
+  QStringList selectedPatientUIDs = d->dicomTableManager->currentPatientsSelection();
+  foreach(uid, selectedPatientUIDs)
+    {
+      d->DICOMDatabase->removePatient(uid);
+    }
 }
 
 //----------------------------------------------------------------------------

+ 14 - 31
Libs/DICOM/Widgets/ctkDICOMTableManager.cpp

@@ -160,37 +160,20 @@ Qt::Orientation ctkDICOMTableManager::tableOrientation()
 
 //------------------------------------------------------------------------------
 
-void ctkDICOMTableManager::deleteSelectedRows()
+QStringList ctkDICOMTableManager::currentPatientsSelection()
 {
   Q_D(ctkDICOMTableManager);
-  QStringList seriesUIDS = d->seriesTable->currentSelection();
-  if (seriesUIDS.size() != 0)
-    {
-      QString seriesUID;
-      foreach (seriesUID, seriesUIDS)
-        {
-          d->dicomDatabase->removeSeries(seriesUID);
-        }
-      return;
-    }
-  QStringList studiesUIDS = d->studiesTable->currentSelection();
-  if (studiesUIDS.size() != 0)
-    {
-      QString studyUID;
-      foreach (studyUID, studiesUIDS)
-        {
-          d->dicomDatabase->removeStudy(studyUID);
-        }
-      return;
-    }
-  QStringList patientsUIDS = d->patientsTable->currentSelection();
-  if (patientsUIDS.size() != 0)
-    {
-      QString patienUID;
-      foreach (patienUID, patientsUIDS)
-        {
-          d->dicomDatabase->removePatient(patienUID);
-        }
-      return;
-    }
+  return d->patientsTable->currentSelection();
+}
+
+QStringList ctkDICOMTableManager::currentStudiesSelection()
+{
+  Q_D(ctkDICOMTableManager);
+  return d->studiesTable->currentSelection();
+}
+
+QStringList ctkDICOMTableManager::currentSeriesSelection()
+{
+  Q_D(ctkDICOMTableManager);
+  return d->seriesTable->currentSelection();
 }

+ 5 - 2
Libs/DICOM/Widgets/ctkDICOMTableManager.h

@@ -61,9 +61,12 @@ public:
   Qt::Orientation tableOrientation();
 
   /**
-   * @brief Deletes the selected row from the database
+   * @brief Get the current selection of the dicomTableViews
+   * @return a list with the uids of the selected items
    */
-  void deleteSelectedRows();
+  QStringList currentPatientsSelection();
+  QStringList currentStudiesSelection();
+  QStringList currentSeriesSelection();
 
 Q_SIGNALS:
   // Signals for propagating selection changes of the different tables