Warning, file /office/skrooge/skgbasegui/kdateedit.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 This file is part of libkdepim. 0003 0004 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 0005 Copyright (c) 2002 David Jarvie <software@astrojar.org.uk> 0006 Copyright (c) 2004 Tobias Koenig <tokoe@kde.org> 0007 0008 This library is free software; you can redistribute it and/or 0009 modify it under the terms of the GNU Library General Public 0010 License as published by the Free Software Foundation; either 0011 version 2 of the License, or (at your option) any later version. 0012 0013 This library is distributed in the hope that it will be useful, 0014 but WITHOUT ANY WARRANTY; without even the implied warranty of 0015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0016 Library General Public License for more details. 0017 0018 You should have received a copy of the GNU Library General Public License 0019 along with this library; see the file COPYING.LIB. If not, write to 0020 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0021 Boston, MA 02110-1301, USA. 0022 */ 0023 0024 #ifndef KDEPIM_KDATEEDIT_H 0025 #define KDEPIM_KDATEEDIT_H 0026 0027 #include "kdatepickerpopup.h" 0028 0029 #include <qcombobox.h> 0030 #include <qdatetime.h> 0031 #include <qevent.h> 0032 #include <qmap.h> 0033 0034 #include "skgbasegui_export.h" 0035 0036 class QEvent; 0037 0038 namespace KPIM 0039 { 0040 0041 /** 0042 A date editing widget that consists of an editable combo box. 0043 The combo box contains the date in text form, and clicking the combo 0044 box arrow will display a 'popup' style date picker. 0045 0046 This widget also supports advanced features like allowing the user 0047 to type in the day name to get the date. The following keywords 0048 are supported (in the native language): tomorrow, yesterday, today, 0049 monday, tuesday, wednesday, thursday, friday, saturday, sunday. 0050 0051 @author Cornelius Schumacher <schumacher@kde.org> 0052 @author Mike Pilone <mpilone@slac.com> 0053 @author David Jarvie <software@astrojar.org.uk> 0054 @author Tobias Koenig <tokoe@kde.org> 0055 */ 0056 class SKGBASEGUI_EXPORT KDateEdit : public QComboBox // krazy:exclude=qclasses 0057 { 0058 Q_OBJECT 0059 Q_PROPERTY(QDate date READ date WRITE setDate NOTIFY dateChanged) 0060 0061 public: 0062 explicit KDateEdit(QWidget* iParent); 0063 ~KDateEdit() override; 0064 0065 /** 0066 @return The date entered. This date could be invalid, 0067 you have to check validity yourself. 0068 */ 0069 QDate date() const; 0070 0071 /** 0072 Sets whether the widget is read-only for the user. If read-only, the 0073 date pop-up is inactive, and the displayed date cannot be edited. 0074 0075 @param readOnly True to set the widget read-only, false to set it read-write. 0076 */ 0077 void setReadOnly(bool readOnly); 0078 0079 /** 0080 @return True if the widget is read-only, false if read-write. 0081 */ 0082 bool isReadOnly() const; 0083 0084 void showPopup() override; 0085 0086 Q_SIGNALS: 0087 /** 0088 This signal is emitted whenever the user has entered a new date. 0089 When the user changes the date by editing the line edit field, 0090 the signal is not emitted until focus leaves the line edit field. 0091 The passed date can be invalid. 0092 */ 0093 // cppcheck-suppress passedByValue 0094 void dateEntered(QDate date); 0095 0096 /** 0097 This signal is emitted whenever the user modifies the date. 0098 The passed date can be invalid. 0099 */ 0100 // cppcheck-suppress passedByValue 0101 void dateChanged(QDate date); 0102 0103 public Q_SLOTS: 0104 /** 0105 Sets the date. 0106 0107 @param iDate The new date to display. This date must be valid or 0108 it will not be set 0109 */ 0110 // cppcheck-suppress passedByValue 0111 void setDate(QDate iDate); 0112 0113 protected Q_SLOTS: 0114 void lineEnterPressed(); 0115 void slotTextChanged(const QString& /*unused*/); 0116 void dateSelected(QDate /*iDate*/); 0117 0118 protected: 0119 bool eventFilter(QObject* /*watched*/ /*iObject*/, QEvent* /*iEvent*/ /*event*/) override; 0120 void focusOutEvent(QFocusEvent* /*e*/) override; 0121 void keyPressEvent(QKeyEvent* /*e*/) override; 0122 0123 /** 0124 Sets the date, without altering the display. 0125 This method is used internally to set the widget's date value. 0126 As a virtual method, it allows derived classes to perform additional 0127 validation on the date value before it is set. Derived classes should 0128 return true if QDate::isValid(@p date) returns false. 0129 0130 @param iDate The new date to set. 0131 @return True if the date was set, false if it was considered invalid and 0132 remains unchanged. 0133 */ 0134 // cppcheck-suppress passedByValue 0135 virtual bool assignDate(QDate iDate); 0136 0137 /** 0138 Fills the keyword map. Reimplement it if you want additional keywords. 0139 */ 0140 void setupKeywords(); 0141 0142 private: 0143 QDate parseDate(bool* replaced = nullptr) const; 0144 void updateView(); 0145 0146 KDatePickerPopup* mPopup; 0147 0148 QDate mDate; 0149 bool mReadOnly; 0150 bool mTextChanged; 0151 QString mAlternativeDateFormatToUse; 0152 0153 QMap<QString, int> mKeywordMap; 0154 }; 0155 0156 } // namespace KPIM 0157 0158 #endif 0159