浏览代码

Give user of class option to wait on completion of indexing

The gui handles this by listenting for signals, but when using the
class programmatically a second call to the indexer cancels the
previous operation.  With this new method, you can wait for completion.

http://www.na-mic.org/Bug/view.php?id=2618
and
http://na-mic.org/Bug/view.php?id=2516
Steve Pieper 12 年之前
父节点
当前提交
c4f3cd3260
共有 2 个文件被更改,包括 13 次插入0 次删除
  1. 7 0
      Libs/DICOM/Core/ctkDICOMIndexer.cpp
  2. 6 0
      Libs/DICOM/Core/ctkDICOMIndexer.h

+ 7 - 0
Libs/DICOM/Core/ctkDICOMIndexer.cpp

@@ -296,6 +296,13 @@ void ctkDICOMIndexer::refreshDatabase(ctkDICOMDatabase& dicomDatabase, const QSt
   }
 
 //----------------------------------------------------------------------------
+void ctkDICOMIndexer::waitForImportFinished()
+{
+  Q_D(ctkDICOMIndexer);
+  d->DirectoryImportWatcher.waitForFinished();
+}
+
+//----------------------------------------------------------------------------
 void ctkDICOMIndexer::cancel()
 {
   Q_D(ctkDICOMIndexer);

+ 6 - 0
Libs/DICOM/Core/ctkDICOMIndexer.h

@@ -82,6 +82,12 @@ public:
 
   Q_INVOKABLE void refreshDatabase(ctkDICOMDatabase& database, const QString& directoryName);
 
+  ///
+  /// \brief ensures that the QFuture threads have all finished indexing
+  /// before returning control.
+  ///
+  Q_INVOKABLE void waitForImportFinished();
+
 Q_SIGNALS:
   void foundFilesToIndex(int);
   void indexingFileNumber(int);