ctkDICOMTableView.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) Kitware Inc.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0.txt
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =========================================================================*/
  14. #ifndef CTKDICOMTABLEVIEW_H
  15. #define CTKDICOMTABLEVIEW_H
  16. #include "ctkDICOMWidgetsExport.h"
  17. // ctkDICOMCore includes
  18. #include "ctkDICOMDatabase.h"
  19. // Qt includes
  20. #include <QWidget>
  21. #include <QItemSelection>
  22. class ctkDICOMTableViewPrivate;
  23. /**
  24. * @brief The ctkDICOMTableView displays the content of a specific table of the ctkDICOMDatabase
  25. *
  26. * The ctkDICOMTableView holds a QTableView which displays the content of the selected
  27. * ctkDICOMDatabase. It also holds a ctkSearchBox which allows filtering of the table content.
  28. *
  29. * @ingroup DICOM_Widgets
  30. */
  31. class CTK_DICOM_WIDGETS_EXPORT ctkDICOMTableView : public QWidget
  32. {
  33. Q_OBJECT
  34. public:
  35. typedef QWidget Superclass;
  36. /**
  37. * ctor with tablename as parameter
  38. * @param parent the parent widget
  39. * @param queryTableName the name of the table of the ctkDICOMDatabase which shall be displayed
  40. */
  41. explicit ctkDICOMTableView(QWidget* parent = 0, QString queryTableName = "Patients");
  42. /**
  43. * ctor with tablename and database as parameter
  44. * @param ctkDicomDataBase the ctkDICOMDatabase which shall be used
  45. * @param parent the parent widget
  46. * @param queryTableName the name of the table of the ctkDICOMDatabase which shall be displayed
  47. */
  48. explicit ctkDICOMTableView (QSharedPointer<ctkDICOMDatabase> ctkDicomDataBase, QWidget* parent = 0, QString queryTableName = "Patients");
  49. virtual ~ctkDICOMTableView();
  50. void setCTKDicomDataBase(QSharedPointer<ctkDICOMDatabase> dicomDataBase);
  51. /**
  52. * Setting the table name which shall be used for the database query
  53. * @param tableName the name of the database table
  54. */
  55. void setQueryTableName(const QString &tableName);
  56. /**
  57. * Setting the foreign key for the database query. This is usefull if e.g. you
  58. * want to select the studies for a certain patient
  59. * @param foreignKey the foreign key which will be used for the query
  60. */
  61. void setQueryForeignKey(const QString &foreignKey);
  62. void setQueryPrimaryKey(const QString &primaryKey);
  63. public Q_SLOTS:
  64. /**
  65. * @brief slot is called if the selection of the tableview is changed
  66. * Within this slot the signal signalSelectionChanged is emitted
  67. */
  68. void onSelectionChanged();
  69. /**
  70. * @brief Updates the query which is used for displaying the table content
  71. * @param uids the uids of the table entries which shall be displayed
  72. */
  73. void onUpdateQuery(const QStringList &uids);
  74. protected Q_SLOTS:
  75. /**
  76. * @brief Called when the underlying database changes
  77. */
  78. void onDatabaseChanged();
  79. /**
  80. * @brief Called when the text of the ctkSearchBox has changed
  81. */
  82. void onFilterChanged();
  83. Q_SIGNALS:
  84. /**
  85. * @brief Is emitted when the selection in the tableview has changed
  86. * @param uids the list of uids of the selected objects
  87. */
  88. void signalSelectionChanged(const QStringList &uids);
  89. /**
  90. * @brief Is emitted when the filter text has changed
  91. * @param uids the list of uids of the selected objects
  92. */
  93. void signalQueryChanged(const QStringList &uids);
  94. void signalSelectionChanged(const QItemSelection&,const QItemSelection&);
  95. protected:
  96. QScopedPointer<ctkDICOMTableViewPrivate> d_ptr;
  97. private:
  98. QStringList getUIDsForAllRows();
  99. Q_DECLARE_PRIVATE(ctkDICOMTableView)
  100. Q_DISABLE_COPY(ctkDICOMTableView)
  101. };
  102. #endif // CTKDICOMTABLEVIEW_H