Sfoglia il codice sorgente

Update the progress dialog as files are indexed

The dialog will now support cancel and resize even though
the indexing is not being done in a different thread.
Steve Pieper 12 anni fa
parent
commit
d3c95adb58

+ 3 - 1
Libs/DICOM/Widgets/Testing/Cpp/ctkDICOMAppWidgetTest1.cpp

@@ -23,6 +23,7 @@
 #include <QDebug>
 #include <QDir>
 #include <QTimer>
+#include <QString>
 
 // ctkDICOMCore includes
 #include "ctkDICOMAppWidget.h"
@@ -40,7 +41,8 @@ int ctkDICOMAppWidgetTest1( int argc, char * argv [] )
   
   ctkDICOMAppWidget appWidget;
   appWidget.setDatabaseDirectory(QDir::currentPath());
-  appWidget.onAddToDatabase();
+  QString testString = QString("Test String");
+  appWidget.onFileIndexed(testString);
   appWidget.openImportDialog();
   appWidget.openExportDialog();
   appWidget.openQueryDialog();

+ 9 - 14
Libs/DICOM/Widgets/ctkDICOMAppWidget.cpp

@@ -25,6 +25,7 @@
 
 // Qt includes
 #include <QAction>
+#include <QCoreApplication>
 #include <QCheckBox>
 #include <QDebug>
 #include <QMetaType>
@@ -135,12 +136,7 @@ void ctkDICOMAppWidgetPrivate::showUpdateSchemaDialog()
     // by creating our own
     QLabel* progressLabel = new QLabel(q->tr("Initialization..."));
     UpdateSchemaProgress->setLabel(progressLabel);
-#ifdef Q_WS_MAC
-    // BUG: avoid deadlock of dialogs on mac
-    UpdateSchemaProgress->setWindowModality(Qt::NonModal);
-#else
     UpdateSchemaProgress->setWindowModality(Qt::ApplicationModal);
-#endif
     UpdateSchemaProgress->setMinimumDuration(0);
     UpdateSchemaProgress->setValue(0);
 
@@ -182,12 +178,7 @@ void ctkDICOMAppWidgetPrivate::showIndexerDialog()
     // by creating our own
     QLabel* progressLabel = new QLabel(q->tr("Initialization..."));
     IndexerProgress->setLabel(progressLabel);
-#ifdef Q_WS_MAC
-    // BUG: avoid deadlock of dialogs on mac
-    IndexerProgress->setWindowModality(Qt::NonModal);
-#else
     IndexerProgress->setWindowModality(Qt::ApplicationModal);
-#endif
     IndexerProgress->setMinimumDuration(0);
     IndexerProgress->setValue(0);
 
@@ -198,6 +189,8 @@ void ctkDICOMAppWidgetPrivate::showIndexerDialog()
             IndexerProgress, SLOT(setValue(int)));
     q->connect(DICOMIndexer.data(), SIGNAL(indexingFilePath(QString)),
             progressLabel, SLOT(setText(QString)));
+    q->connect(DICOMIndexer.data(), SIGNAL(indexingFilePath(QString)),
+            q, SLOT(onFileIndexed(QString)));
 
     // close the dialog
     q->connect(DICOMIndexer.data(), SIGNAL(indexingComplete()),
@@ -422,11 +415,13 @@ void ctkDICOMAppWidget::setSearchWidgetPopUpMode(bool flag){
 }
 
 //----------------------------------------------------------------------------
-void ctkDICOMAppWidget::onAddToDatabase()
+void ctkDICOMAppWidget::onFileIndexed(const QString& filePath)
 {
-  //Q_D(ctkDICOMAppWidget);
-
-  //d->
+  // Update the progress dialog when the file name changes
+  // - also allows for cancel button
+  QCoreApplication::instance()->processEvents();
+  qDebug() << "Indexing \n\n\n\n" << filePath <<"\n\n\n";
+  
 }
 
 //----------------------------------------------------------------------------

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

@@ -66,7 +66,7 @@ public:
 
 public Q_SLOTS:
   void setDatabaseDirectory(const QString& directory);
-  void onAddToDatabase();
+  void onFileIndexed(const QString& filePath);
 
   void openImportDialog();
   void openExportDialog();