ctkDICOMTableView.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. // Qt includes
  17. #include <QItemSelection>
  18. #include <QWidget>
  19. // ctkDICOMCore includes
  20. #include "ctkDICOMDatabase.h"
  21. #include "ctkDICOMWidgetsExport.h"
  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. * Constructs ctkDICOMTableView without underlying database and table name
  38. * @param parent parentwidget
  39. */
  40. explicit ctkDICOMTableView(QWidget* parent = 0);
  41. /**
  42. * ctor with tablename as parameter
  43. * @param parent the parent widget
  44. * @param queryTableName the name of the table of the ctkDICOMDatabase which shall be displayed
  45. */
  46. explicit ctkDICOMTableView(QString queryTableName = "Patients", QWidget* parent = 0);
  47. /**
  48. * ctor with tablename and database as parameter
  49. * @param ctkDicomDataBase the ctkDICOMDatabase which shall be used
  50. * @param parent the parent widget
  51. * @param queryTableName the name of the table of the ctkDICOMDatabase which shall be displayed
  52. */
  53. explicit ctkDICOMTableView (ctkDICOMDatabase* dicomDataBase, QString queryTableName = "Patients", QWidget* parent = 0);
  54. virtual ~ctkDICOMTableView();
  55. /**
  56. * @brief Setting the ctkDICOMDatabase which shall be queried
  57. * @param dicomDataBase the underlying database
  58. */
  59. void setDicomDataBase(ctkDICOMDatabase* dicomDatabase);
  60. /**
  61. * Setting the table name which shall be used for the database query
  62. * @param tableName the name of the database table
  63. */
  64. void setQueryTableName(const QString &tableName);
  65. /**
  66. * Setting the foreign key for the database query. This is usefull if e.g. you
  67. * want to select the studies for a certain patient
  68. * @param foreignKey the foreign key which will be used for the query
  69. */
  70. void setQueryForeignKey(const QString &foreignKey);
  71. /**
  72. * Set the query for the underlying database. If the uid list is not empty just the
  73. * entries with the according uids are selected
  74. * @param uids a list of uids which should be selected
  75. */
  76. void setQuery (const QStringList &uids = QStringList());
  77. /**
  78. * @brief Returns the uids of the current selected rows
  79. * @return a list containing all the uids of the selected rows
  80. */
  81. QStringList currentSelection() const;
  82. public Q_SLOTS:
  83. /**
  84. * @brief slot is called if the selection of the tableview is changed
  85. * Within this slot the signal signalSelectionChanged is emitted
  86. */
  87. void onSelectionChanged();
  88. /**
  89. * @brief Updates the query which is used for displaying the table content
  90. * @param uids the uids of the table entries which shall be displayed
  91. */
  92. void onUpdateQuery(const QStringList &uids);
  93. protected Q_SLOTS:
  94. /**
  95. * @brief Called when the underlying database changes
  96. */
  97. void onDatabaseChanged();
  98. /**
  99. * @brief Called when the text of the ctkSearchBox has changed
  100. */
  101. void onFilterChanged();
  102. Q_SIGNALS:
  103. /**
  104. * @brief Is emitted when the selection in the tableview has changed
  105. * @param uids the list of uids of the selected objects
  106. */
  107. void selectionChanged(const QStringList &uids);
  108. /**
  109. * @brief Is emitted when the data selection has changed
  110. */
  111. void selectionChanged(const QItemSelection&,const QItemSelection&);
  112. /**
  113. * @brief Is emitted when the query text has changed
  114. * @param uids the list of uids of the objects included in the query
  115. */
  116. void queryChanged(const QStringList &uids);
  117. void doubleClicked(const QModelIndex&);
  118. protected:
  119. QScopedPointer<ctkDICOMTableViewPrivate> d_ptr;
  120. Q_DECLARE_PRIVATE(ctkDICOMTableView)
  121. Q_DISABLE_COPY(ctkDICOMTableView)
  122. };
  123. #endif // __ctkDICOMTableView_h