kdatepicker.h
00001 /* -*- C++ -*- 00002 This file is part of the KDE libraries 00003 Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org) 00004 (C) 1998-2001 Mirko Boehm (mirko@kde.org) 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 #ifndef KDATEPICKER_H 00021 #define KDATEPICKER_H 00022 #include <qdatetime.h> 00023 #include <qframe.h> 00024 #include <kdelibs_export.h> 00025 00026 class QLineEdit; 00027 class QToolButton; 00028 class KDateValidator; 00029 class KDateTable; 00030 00051 class KDEUI_EXPORT KDatePicker: public QFrame 00052 { 00053 Q_OBJECT 00054 Q_PROPERTY( QDate date READ date WRITE setDate) 00055 Q_PROPERTY( bool closeButton READ hasCloseButton WRITE setCloseButton ) 00056 Q_PROPERTY( int fontSize READ fontSize WRITE setFontSize ) 00057 00058 public: 00062 KDatePicker(QWidget *parent=0, 00063 QDate=QDate::currentDate(), 00064 const char *name=0); 00065 00070 KDatePicker(QWidget *parent, 00071 QDate, 00072 const char *name, 00073 WFlags f); // ### KDE 4.0: Merge 00074 00080 KDatePicker( QWidget *parent, const char *name ); 00081 00085 virtual ~KDatePicker(); 00086 00093 QSize sizeHint() const; 00094 00101 bool setDate(const QDate&); 00102 00107 const QDate& getDate() const KDE_DEPRECATED; 00108 00112 const QDate &date() const; 00113 00117 void setEnabled(bool); 00118 00124 KDateTable *dateTable() const { return table; } 00125 00129 void setFontSize(int); 00133 int fontSize() const 00134 { return fontsize; } 00135 00145 void setCloseButton( bool enable ); 00146 00152 bool hasCloseButton() const; 00153 00154 protected: 00156 virtual bool eventFilter(QObject *o, QEvent *e ); 00158 virtual void resizeEvent(QResizeEvent*); 00160 QToolButton *yearForward; 00162 QToolButton *yearBackward; 00164 QToolButton *monthForward; 00166 QToolButton *monthBackward; 00168 QToolButton *selectMonth; 00170 QToolButton *selectYear; 00172 QLineEdit *line; 00174 KDateValidator *val; 00176 KDateTable *table; 00178 // QSize sizehint; 00180 QSize maxMonthRect; 00181 protected slots: 00182 void dateChangedSlot(QDate); 00183 void tableClickedSlot(); 00184 void monthForwardClicked(); 00185 void monthBackwardClicked(); 00186 void yearForwardClicked(); 00187 void yearBackwardClicked(); 00192 void selectWeekClicked(); 00196 void selectMonthClicked(); 00200 void selectYearClicked(); 00204 void lineEnterPressed(); 00208 void todayButtonClicked(); 00212 void weekSelected(int); 00213 00214 signals: 00215 // ### KDE 4.0 Make all QDate parameters const references 00216 00223 void dateChanged(QDate); 00229 void dateSelected(QDate); 00235 void dateEntered(QDate); 00239 void tableClicked(); 00240 00241 private slots: 00242 void ensureSelectYearIsUp(); 00243 00244 private: 00246 int fontsize; 00247 00248 protected: 00249 virtual void virtual_hook( int id, void* data ); 00250 private: 00251 void init( const QDate &dt ); 00252 void fillWeeksCombo(const QDate &date); 00253 class KDatePickerPrivate; 00254 KDatePickerPrivate *d; 00255 }; 00256 00257 #endif // KDATEPICKER_H