ctkDateRangeWidget.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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.commontk.org/LICENSE
  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 __ctkDateRangeWidget_h
  15. #define __ctkDateRangeWidget_h
  16. // Qt includes
  17. #include <QDateTimeEdit>
  18. // CTK includes
  19. #include <ctkPimpl.h>
  20. #include "ctkWidgetsExport.h"
  21. class ctkDateRangeWidgetPrivate;
  22. class QDateTime;
  23. ///
  24. /// ctkDateRangeWidget is a wrapper around a ctkDoubleRangeSlider and 2 QSpinBoxes
  25. /// \image html http://www.commontk.org/images/1/14/CtkDateRangeWidget.png
  26. /// \sa ctkSliderSpinBoxWidget, ctkDoubleRangeSlider, QSpinBox
  27. class CTK_WIDGETS_EXPORT ctkDateRangeWidget : public QWidget
  28. {
  29. Q_OBJECT
  30. // placeholder - not yet used
  31. Q_PROPERTY(bool includeTime READ includeTime WRITE setIncludeTime)
  32. public:
  33. /// Superclass typedef
  34. typedef QWidget Superclass;
  35. /// Constructor
  36. /// If \li parent is null, ctkDateRangeWidget will be a top-leve widget
  37. /// \note The \li parent can be set later using QWidget::setParent()
  38. explicit ctkDateRangeWidget(QWidget* parent = 0);
  39. /// Destructor
  40. virtual ~ctkDateRangeWidget();
  41. ///
  42. /// This property holds whether the date range includes time
  43. /// If tracking is disabled (the default), the widget only shows dates
  44. /// If includeTime is enabled the date widgets display time as well as date
  45. void setIncludeTime(bool includeTime);
  46. bool includeTime()const;
  47. ///
  48. /// Access the start and end date/times
  49. QDateTime startDateTime() const;
  50. QDateTime endDateTime() const;
  51. public slots:
  52. ///
  53. /// Reset the slider and spinbox to zero (value and position)
  54. void setStartDateTime(QDateTime start);
  55. void setEndDateTime(QDateTime end);
  56. ///
  57. /// Utility function that set the start and end values at once
  58. void setDateTimeRange(QDateTime start, QDateTime end);
  59. ///
  60. /// handle clicks on radio buttons
  61. void onAnyDate();
  62. void onToday();
  63. void onYesterday();
  64. void onLastWeek();
  65. void onLastMonth();
  66. void onSelectRange();
  67. signals:
  68. ///
  69. /// signals
  70. void startDateTimeChanged(QDateTime value);
  71. void endDateTimeChanged(QDateTime value);
  72. protected slots:
  73. ///
  74. /// None
  75. protected:
  76. ///
  77. /// None
  78. protected:
  79. QScopedPointer<ctkDateRangeWidgetPrivate> d_ptr;
  80. private:
  81. Q_DECLARE_PRIVATE(ctkDateRangeWidget);
  82. Q_DISABLE_COPY(ctkDateRangeWidget);
  83. };
  84. #endif