File indexing completed on 2025-01-05 03:51:06
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 1997-04-21 0007 * Description : A date selection widget. 0008 * 0009 * SPDX-FileCopyrightText: 2011-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0010 * SPDX-FileCopyrightText: 1997 by Tim D. Gilman <tdgilman at best dot org> 0011 * SPDX-FileCopyrightText: 1998-2001 by Mirko Boehm <mirko at kde dot org> 0012 * SPDX-FileCopyrightText: 2007 by John Layt <john at layt dot net> 0013 * 0014 * SPDX-License-Identifier: GPL-2.0-or-later 0015 * 0016 * ============================================================ */ 0017 0018 #ifndef DIGIKAM_DDATE_PICKER_PRIVATE_H 0019 #define DIGIKAM_DDATE_PICKER_PRIVATE_H 0020 0021 // Qt includes 0022 0023 #include <QDate> 0024 #include <QLineEdit> 0025 #include <QValidator> 0026 #include <QApplication> 0027 #include <QComboBox> 0028 #include <QToolButton> 0029 #include <QBoxLayout> 0030 #include <QSize> 0031 0032 // Local includes 0033 0034 #include "ddatepicker.h" 0035 0036 namespace Digikam 0037 { 0038 0039 class Q_DECL_HIDDEN DatePickerValidator : public QValidator 0040 { 0041 Q_OBJECT 0042 0043 public: 0044 0045 explicit DatePickerValidator(DDatePicker* const parent); 0046 0047 State validate(QString& text, int&) const override; 0048 0049 private: 0050 0051 DDatePicker* m_picker; 0052 }; 0053 0054 // ------------------------------------------------------------------------------ 0055 0056 class Q_DECL_HIDDEN DatePickerYearSelector : public QLineEdit 0057 { 0058 Q_OBJECT 0059 0060 public: 0061 0062 explicit DatePickerYearSelector(const QDate& currentDate, QWidget* const parent = nullptr); 0063 0064 int year() const; 0065 void setYear(int year); 0066 0067 public Q_SLOTS: 0068 0069 void yearEnteredSlot(); 0070 0071 Q_SIGNALS: 0072 0073 void closeMe(int); 0074 0075 protected: 0076 0077 QIntValidator* val; 0078 int result; 0079 0080 private: 0081 0082 QDate oldDate; 0083 0084 Q_DISABLE_COPY(DatePickerYearSelector) 0085 }; 0086 0087 // ------------------------------------------------------------------------------ 0088 0089 class Q_DECL_HIDDEN DDatePicker::Private 0090 { 0091 public: 0092 0093 explicit Private(DDatePicker* const qq); 0094 0095 void fillWeeksCombo(); 0096 QDate validDateInYearMonth(int year, int month); 0097 0098 public: 0099 0100 /// the date table 0101 DDatePicker* q; 0102 0103 QToolButton* closeButton; 0104 QComboBox* selectWeek; 0105 QToolButton* todayButton; 0106 QBoxLayout* navigationLayout; 0107 0108 /// the year forward button 0109 QToolButton* yearForward; 0110 0111 /// the year backward button 0112 QToolButton* yearBackward; 0113 0114 /// the month forward button 0115 QToolButton* monthForward; 0116 0117 /// the month backward button 0118 QToolButton* monthBackward; 0119 0120 /// the button for selecting the month directly 0121 QToolButton* selectMonth; 0122 0123 /// the button for selecting the year directly 0124 QToolButton* selectYear; 0125 0126 /// the line edit to enter the date directly 0127 QLineEdit* line; 0128 0129 /// the validator for the line edit: 0130 DatePickerValidator* val; 0131 0132 /// the date table 0133 DDateTable* table; 0134 0135 /// the widest month string in pixels: 0136 QSize maxMonthRect; 0137 0138 /// the font size for the widget 0139 int fontsize; 0140 }; 0141 0142 } // namespace Digikam 0143 0144 #endif // DIGIKAM_DDATE_PICKER_PRIVATE_H