Browse Source

Expose suspend and resume methods for the dicom model

It seems that while the dicom model is active it keeps open
QSqlQuery instances that have a negative impact on the ability
to do inserts into the database.  These new methods allow a
user of this class to turn off the database and turn it back
on again without having to re-specify the directory.

There may be a faster way to implement this (i.e. by calling
finish on the queries and then re-execing them later) but this
implementation is much faster than what existed previously, where
the sqlite database would sleep waiting for a chance to insert
new data.
Steve Pieper 13 years ago
parent
commit
7e3458271c
2 changed files with 21 additions and 0 deletions
  1. 19 0
      Libs/DICOM/Widgets/ctkDICOMAppWidget.cpp
  2. 2 0
      Libs/DICOM/Widgets/ctkDICOMAppWidget.h

+ 19 - 0
Libs/DICOM/Widgets/ctkDICOMAppWidget.cpp

@@ -81,6 +81,9 @@ public:
   ctkDICOMFilterProxyModel DICOMProxyModel;
   QSharedPointer<ctkDICOMIndexer> DICOMIndexer;
 
+  // used when suspending the ctkDICOMModel
+  QSqlDatabase EmptyDatabase;
+
   QTimer* AutoPlayTimer;
 
   bool IsSearchWidgetPopUpMode;
@@ -301,6 +304,22 @@ void ctkDICOMAppWidget::openQueryDialog()
 }
 
 //----------------------------------------------------------------------------
+void ctkDICOMAppWidget::suspendModel()
+{
+  Q_D(ctkDICOMAppWidget);
+
+  d->DICOMModel.setDatabase(d->EmptyDatabase);
+}
+
+//----------------------------------------------------------------------------
+void ctkDICOMAppWidget::resumeModel()
+{
+  Q_D(ctkDICOMAppWidget);
+
+  d->DICOMModel.setDatabase(d->DICOMDatabase->database());
+}
+
+//----------------------------------------------------------------------------
 void ctkDICOMAppWidget::resetModel()
 {
   Q_D(ctkDICOMAppWidget);

+ 2 - 0
Libs/DICOM/Widgets/ctkDICOMAppWidget.h

@@ -57,6 +57,8 @@ public slots:
   void openExportDialog();
   void openQueryDialog();
 
+  void suspendModel();
+  void resumeModel();
   void resetModel();
 
 signals: