kplato

kptcalendarpanel.h

00001 /* This file is part of the KDE project
00002     Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org)
00003               (C) 1998-2001 Mirko Boehm (mirko@kde.org)
00004               (C) 2004 Dag Andersen <danders@get2net.dk>
00005 
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 /* This is based on KDatePicker. */
00023 
00024 #ifndef KPTCALENDARPANEL_H
00025 #define KPTCALENDARPANEL_H
00026 
00027 #include "kptmap.h"
00028 
00029 #include <qdatetime.h>
00030 #include <qframe.h>
00031 
00032 class QLineEdit;
00033 class QToolButton;
00034 
00035 namespace KPlato
00036 {
00037 
00038 class DateValidator;
00039 class DateTable;
00040 class Calendar;
00041 
00046 class CalendarPanel: public QFrame
00047 {
00048     Q_OBJECT
00049     Q_PROPERTY( QDate date READ date WRITE setDate)
00050     Q_PROPERTY( bool closeButton READ hasCloseButton WRITE setCloseButton )
00051     
00052 public:
00056     CalendarPanel(QWidget *parent=0, QDate=QDate::currentDate(), const char *name=0, WFlags f=0);
00057     
00062     CalendarPanel( QWidget *parent, const char *name );
00063     
00067     virtual ~CalendarPanel();
00068     
00075     QSize sizeHint() const;
00076     
00077     QSize minimumSizeHint() const { return sizeHint(); }
00084     bool setDate(const QDate&);
00085     
00090     const QDate& getDate() const;
00091     
00095     const QDate &date() const;
00096     
00100     void setEnabled(bool);
00101     
00105     void setFontSize(int);
00109     int fontSize() const
00110         { return fontsize; }
00111     
00120     void setCloseButton( bool enable );
00121     
00126     bool hasCloseButton() const;
00127     
00128     void setCalendar(Calendar *cal);
00129     
00130     DateMap selectedDates();
00131     IntMap selectedWeekdays();
00132     WeekMap selectedWeeks();
00133     
00134     DateMap markedDates();
00135     IntMap markedWeekdays();
00136     WeekMap markedWeeks();
00137     
00138     void clear();
00139     
00140     void markSelected(int state);
00141     
00142 protected:
00144     virtual bool eventFilter(QObject *o, QEvent *e );
00146     virtual void resizeEvent(QResizeEvent*);
00148     QToolButton *yearForward;
00150     QToolButton *yearBackward;
00152     QToolButton *monthForward;
00154     QToolButton *monthBackward;
00156     QToolButton *selectMonth;
00158     QToolButton *selectYear;
00160     QLineEdit *line;
00162     DateValidator *val;
00164     DateTable *table;
00165     // the widest month string in pixels:
00166     QSize maxMonthRect;
00167 
00168 protected slots:
00169     void dateChangedSlot(QDate);
00170     void tableClickedSlot();
00171     void monthForwardClicked();
00172     void monthBackwardClicked();
00173     void yearForwardClicked();
00174     void yearBackwardClicked();
00175     void selectWeekClicked();
00176     void selectMonthClicked();
00177     void selectYearClicked();
00178     void lineEnterPressed();
00179     
00180     void slotWeekdaySelected(int day);
00181     void slotWeekSelected(int week, int year);
00182     void slotSelectionCleared();
00183   
00184 signals:
00191     void dateChanged(QDate);
00195     void dateSelected(QDate);
00201     void dateEntered(QDate);
00205     void tableClicked();
00206     
00207     void weekSelected(int week, int year);
00208     void weekdaySelected(int day);
00212     void selectionCleared();
00213   
00214 private:
00216     int fontsize;
00217     
00218     bool m_selectedDays[7];
00219     
00220 protected:
00221     virtual void virtual_hook( int id, void* data );
00222 private:
00223     void init( const QDate &dt );
00224     class CalendarPanelPrivate;
00225     CalendarPanelPrivate *d;
00226     // calculate ISO 8601 week number
00227     int weekOfYear(QDate);
00228 };
00229 
00230 }  //KPlato namespace
00231 
00232 #endif //  CALENDARPANEL_H
KDE Home | KDE Accessibility Home | Description of Access Keys