Переглянути джерело

Add getter for current selection to dicomtableview

Andreas Fetzer 11 роки тому
батько
коміт
9a3f71c6b1

+ 21 - 3
Libs/DICOM/Widgets/ctkDICOMTableView.cpp

@@ -53,6 +53,8 @@ public:
   QString queryTableName;
   QString queryForeignKey;
 
+  QStringList currentSelection;
+
 };
 //------------------------------------------------------------------------------
 
@@ -206,12 +208,12 @@ void ctkDICOMTableView::onSelectionChanged()
 {
   Q_D(ctkDICOMTableView);
 
-  QModelIndexList currentSelection = d->tblDicomDatabaseView->selectionModel()->selectedRows(0);
+  QModelIndexList selectedRows = d->tblDicomDatabaseView->selectionModel()->selectedRows(0);
   QStringList uids;
 
-  foreach(QModelIndex i, currentSelection)
+  foreach(QModelIndex i, selectedRows)
     {
-      uids << (QString("'") + i.data().toString() +"'");
+      uids<< (QString("'") + i.data().toString() +"'");
     }
   emit queryChanged(uids);
 }
@@ -257,3 +259,19 @@ void ctkDICOMTableView::setQuery(const QStringList &uids)
   if (d->dicomDatabase != 0)
     d->dicomSQLModel.setQuery(query, d->dicomDatabase->database());
 }
+
+
+QStringList ctkDICOMTableView::currentSelection()
+{
+  Q_D(ctkDICOMTableView);
+
+  QModelIndexList currentSelection = d->tblDicomDatabaseView->selectionModel()->selectedRows(0);
+  QStringList uids;
+
+  foreach(QModelIndex i, currentSelection)
+    {
+      uids<< /*(QString("'") + */i.data().toString() /*+"'")*/;
+    }
+
+  return  uids;
+}

+ 6 - 0
Libs/DICOM/Widgets/ctkDICOMTableView.h

@@ -89,6 +89,12 @@ public:
    */
   void setQuery (const QStringList &uids = QStringList());
 
+  /**
+   * @brief Returns the uids of the current selected rows
+   * @return a list containing all the uids of the selected rows
+   */
+  QStringList currentSelection();
+
 public Q_SLOTS:
 
   /**