KDEUI
kdatetable.h
Go to the documentation of this file.
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 (C) 2007 John Layt <john@layt.net> 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 Boston, MA 02110-1301, USA. 00020 */ 00021 00022 #ifndef KDATETABLE_H 00023 #define KDATETABLE_H 00024 00025 #include <kdeui_export.h> 00026 00027 #include <QtGui/QValidator> 00028 #include <QtGui/QLineEdit> 00029 #include <QtCore/QDateTime> 00030 00031 #include <klocale.h> 00032 00033 class KMenu; 00034 class KCalendarSystem; 00035 class KColorScheme; 00036 00041 class KDEUI_EXPORT KPopupFrame : public QFrame 00042 { 00043 Q_OBJECT 00044 protected: 00048 virtual void keyPressEvent( QKeyEvent *e ); 00049 00050 public Q_SLOTS: 00055 void close( int r ); 00056 00057 public: 00061 KPopupFrame( QWidget *parent = 0 ); 00062 00066 ~KPopupFrame(); 00067 00075 void setMainWidget( QWidget* m ); 00076 00081 virtual void resizeEvent( QResizeEvent *resize ); 00082 00086 void popup( const QPoint &pos ); 00087 00091 int exec( const QPoint &p ); 00092 00096 int exec( int x, int y ); 00097 00098 Q_SIGNALS: 00099 void leaveModality(); 00100 00101 private: 00102 class KPopupFramePrivate; 00103 friend class KPopupFramePrivate; 00104 KPopupFramePrivate * const d; 00105 00106 Q_DISABLE_COPY( KPopupFrame ) 00107 }; 00108 00112 class KDEUI_EXPORT KDateValidator : public QValidator 00113 { 00114 public: 00115 KDateValidator( QWidget *parent = 0 ); 00116 virtual State validate( QString &text, int &e ) const; 00117 virtual void fixup ( QString &input ) const; 00118 State date( const QString &text, QDate &date ) const; 00119 private: 00120 class KDateValidatorPrivate; 00121 friend class KDateValidatorPrivate; 00122 KDateValidatorPrivate * const d; 00123 }; 00124 00139 class KDEUI_EXPORT KDateTable : public QWidget 00140 { 00141 Q_OBJECT 00142 Q_PROPERTY( QDate date READ date WRITE setDate ) 00143 //FIXME Q_PROPERTY( KCalendarSystem calendar READ calendar WRITE setCalendar USER true ) 00144 Q_PROPERTY( bool popupMenu READ popupMenuEnabled WRITE setPopupMenuEnabled ) 00145 00146 public: 00150 explicit KDateTable( QWidget* parent = 0 ); 00151 00155 explicit KDateTable( const QDate&, QWidget *parent = 0 ); 00156 00160 ~KDateTable(); 00161 00169 virtual QSize sizeHint() const; 00170 00174 void setFontSize( int size ); 00175 00179 bool setDate( const QDate &date ); 00180 00181 // KDE5 remove the const & from the returned QDate 00185 const QDate &date() const; 00186 00192 const KCalendarSystem *calendar() const; 00193 00201 bool setCalendar( KCalendarSystem *calendar = 0 ); 00202 00210 bool setCalendar( const QString &calendarType ); 00211 00220 bool setCalendarSystem( KLocale::CalendarSystem calendarSystem ); 00221 00228 void setPopupMenuEnabled( bool enable ); 00229 00233 bool popupMenuEnabled() const; 00234 00235 enum BackgroundMode { NoBgMode = 0, RectangleMode, CircleMode }; 00236 00241 void setCustomDatePainting( const QDate &date, const QColor &fgColor, 00242 BackgroundMode bgMode = NoBgMode, const QColor &bgColor = QColor() ); 00243 00247 void unsetCustomDatePainting( const QDate &date ); 00248 00249 protected: 00254 virtual int posFromDate( const QDate &date ); 00255 00260 virtual QDate dateFromPos( int pos ); 00261 00262 virtual void paintEvent( QPaintEvent *e ); 00263 00267 virtual void mousePressEvent( QMouseEvent *e ); 00268 virtual void wheelEvent( QWheelEvent *e ); 00269 virtual void keyPressEvent( QKeyEvent *e ); 00270 virtual void focusInEvent( QFocusEvent *e ); 00271 virtual void focusOutEvent( QFocusEvent *e ); 00272 00276 virtual bool event(QEvent *e); 00277 00278 Q_SIGNALS: 00282 void dateChanged( const QDate &date ); 00283 00290 void dateChanged( const QDate &cur, const QDate &old ); 00291 00295 void tableClicked(); 00296 00302 void aboutToShowContextMenu( KMenu *menu, const QDate &date ); 00303 00304 private: 00305 Q_PRIVATE_SLOT( d, void nextMonth() ) 00306 Q_PRIVATE_SLOT( d, void previousMonth() ) 00307 Q_PRIVATE_SLOT( d, void beginningOfMonth() ) 00308 Q_PRIVATE_SLOT( d, void endOfMonth() ) 00309 Q_PRIVATE_SLOT( d, void beginningOfWeek() ) 00310 Q_PRIVATE_SLOT( d, void endOfWeek() ) 00311 00312 private: 00313 class KDateTablePrivate; 00314 friend class KDateTablePrivate; 00315 KDateTablePrivate * const d; 00316 00317 void init( const QDate &date ); 00318 void initAccels(); 00319 void paintCell( QPainter *painter, int row, int col, const KColorScheme &colorScheme ); 00320 00321 Q_DISABLE_COPY( KDateTable ) 00322 }; 00323 00324 #endif // KDATETABLE_H
KDE 4.6 API Reference