Browse Source

Fixed missing update if new data is added

Andreas Fetzer 11 years ago
parent
commit
a6c7263dd9
2 changed files with 17 additions and 3 deletions
  1. 12 3
      Libs/DICOM/Widgets/ctkDICOMTableView.cpp
  2. 5 0
      Libs/DICOM/Widgets/ctkDICOMTableView.h

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

@@ -127,9 +127,9 @@ void ctkDICOMTableViewPrivate::setUpTableView()
 
       QObject::connect(this->leSearchBox, SIGNAL(textChanged(QString)), q, SLOT(onFilterChanged()));
 
-      QObject::connect(this->dicomDatabase, SIGNAL(schemaUpdated()), q, SLOT(onDatabaseChanged()));
-
       QObject::connect(this->dicomDatabase, SIGNAL(databaseChanged()), q, SLOT(onDatabaseChanged()));
+      QObject::connect(this->dicomDatabase, SIGNAL(instanceAdded(const QString&)),
+                       q, SLOT(onInstanceAdded()));
     }
 }
 
@@ -215,7 +215,8 @@ void ctkDICOMTableView::setDicomDataBase(ctkDICOMDatabase *dicomDatabase)
   Q_D(ctkDICOMTableView);
   d->dicomDatabase = dicomDatabase;
   //Create connections for new database
-  QObject::connect(d->dicomDatabase, SIGNAL(schemaUpdated()), this, SLOT(onDatabaseChanged()));
+  QObject::connect(d->dicomDatabase, SIGNAL(instanceAdded(const QString&)),
+                   this, SLOT(onInstanceAdded()));
   QObject::connect(d->dicomDatabase, SIGNAL(databaseChanged()), this, SLOT(onDatabaseChanged()));
   this->setQuery();
   d->hideUIDColumns();
@@ -275,6 +276,14 @@ void ctkDICOMTableView::onFilterChanged()
   emit queryChanged(uids);
 }
 
+void ctkDICOMTableView::onInstanceAdded()
+{
+  Q_D(ctkDICOMTableView);
+  d->sqlWhereConditions.clear();
+  d->tblDicomDatabaseView->clearSelection();
+  d->leSearchBox->clear();
+}
+
 //------------------------------------------------------------------------------
 void ctkDICOMTableView::setQuery(const QStringList &uids)
 {

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

@@ -140,6 +140,11 @@ protected Q_SLOTS:
    */
   void onFilterChanged();
 
+  /**
+   * @brief Called if a new instance was added to the database
+   */
+  void onInstanceAdded();
+
 Q_SIGNALS:
   /**
    * @brief Is emitted when the selection in the tableview has changed