ctkDICOMTableView.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. Q_PROPERTY(bool filterActive READ filterActive)
  35. public:
  36. typedef QWidget Superclass;
  37. /**
  38. * Constructs ctkDICOMTableView without underlying database and table name
  39. * @param parent parentwidget
  40. */
  41. explicit ctkDICOMTableView(QWidget* parent = 0);
  42. /**
  43. * ctor with tablename as parameter
  44. * @param parent the parent widget
  45. * @param queryTableName the name of the table of the ctkDICOMDatabase which shall be displayed
  46. */
  47. explicit ctkDICOMTableView(QString queryTableName, QWidget* parent = 0);
  48. /**
  49. * ctor with tablename and database as parameter
  50. * @param ctkDicomDataBase the ctkDICOMDatabase which shall be used
  51. * @param parent the parent widget
  52. * @param queryTableName the name of the table of the ctkDICOMDatabase which shall be displayed
  53. */
  54. explicit ctkDICOMTableView (ctkDICOMDatabase* dicomDataBase, QString queryTableName, QWidget* parent = 0);
  55. virtual ~ctkDICOMTableView();
  56. /**
  57. * @brief Setting the ctkDICOMDatabase which shall be queried
  58. * @param dicomDataBase the underlying database
  59. */
  60. void setDicomDataBase(ctkDICOMDatabase* dicomDatabase);
  61. /**
  62. * Setting the table name which shall be used for the database query
  63. * @param tableName the name of the database table
  64. */
  65. void setQueryTableName(const QString &tableName);
  66. /**
  67. * Setting the foreign key for the database query. This is usefull if e.g. you
  68. * want to select the studies for a certain patient
  69. * @param foreignKey the foreign key which will be used for the query
  70. */
  71. void setQueryForeignKey(const QString &foreignKey);
  72. /**
  73. * Set the query for the underlying database. If the uid list is not empty just the
  74. * entries with the according uids are selected
  75. * @param uids a list of uids which should be selected
  76. */
  77. void setQuery (const QStringList &uids = QStringList());
  78. /**
  79. * @brief Add a where condition to the usual select statement
  80. * @param condition std::pair with column name and a value list
  81. */
  82. void addSqlWhereCondition(const std::pair<QString, QStringList>& condition);
  83. /**
  84. * @brief Returns the uids of the current selected rows
  85. * @return a list containing all the uids of the selected rows
  86. */
  87. QStringList currentSelection() const;
  88. /**
  89. * @brief Getting the UIDs for all rows
  90. * @return a QStringList with the uids for all rows
  91. */
  92. QStringList uidsForAllRows() const;
  93. bool filterActive();
  94. void setTableSectionSize(int);
  95. int tableSectionSize();
  96. public Q_SLOTS:
  97. /**
  98. * @brief slot is called if the selection of the tableview is changed
  99. * Within this slot the signal signalSelectionChanged is emitted
  100. */
  101. void onSelectionChanged();
  102. /**
  103. * @brief Updates the query which is used for displaying the table content
  104. * @param uids the uids of the table entries which shall be displayed
  105. */
  106. void onUpdateQuery(const QStringList &uids);
  107. protected Q_SLOTS:
  108. /**
  109. * @brief Called when the underlying database changes
  110. */
  111. void onDatabaseChanged();
  112. /**
  113. * @brief Called when the text of the ctkSearchBox has changed
  114. */
  115. void onFilterChanged();
  116. /**
  117. * @brief Called if a new instance was added to the database
  118. */
  119. void onInstanceAdded();
  120. void selectAll();
  121. Q_SIGNALS:
  122. /**
  123. * @brief Is emitted when the selection in the tableview has changed
  124. * @param uids the list of uids of the selected objects
  125. */
  126. void selectionChanged(const QStringList &uids);
  127. /**
  128. * @brief Is emitted when the data selection has changed
  129. */
  130. void selectionChanged(const QItemSelection&,const QItemSelection&);
  131. /**
  132. * @brief Is emitted when the query text has changed
  133. * @param uids the list of uids of the objects included in the query
  134. */
  135. void queryChanged(const QStringList &uids);
  136. void doubleClicked(const QModelIndex&);
  137. protected:
  138. QScopedPointer<ctkDICOMTableViewPrivate> d_ptr;
  139. Q_DECLARE_PRIVATE(ctkDICOMTableView)
  140. Q_DISABLE_COPY(ctkDICOMTableView)
  141. };
  142. #endif // __ctkDICOMTableView_h