kplato

kptcalendarpanel.h
1/* This file is part of the KDE project
2 Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org)
3 (C) 1998-2001 Mirko Boehm (mirko@kde.org)
4 (C) 2004 Dag Andersen <danders@get2net.dk>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20*/
21
22/* This is based on KDatePicker. */
23
24#ifndef KPTCALENDARPANEL_H
25#define KPTCALENDARPANEL_H
26
27#include "kptmap.h"
28
29#include <tqdatetime.h>
30#include <tqframe.h>
31
32class TQLineEdit;
33class TQToolButton;
34
35namespace KPlato
36{
37
38class DateValidator;
39class DateTable;
40class Calendar;
41
46class CalendarPanel: public TQFrame
47{
48 TQ_OBJECT
49
50 TQ_PROPERTY( TQDate date READ date WRITE setDate)
51 TQ_PROPERTY( bool closeButton READ hasCloseButton WRITE setCloseButton )
52
53public:
57 CalendarPanel(TQWidget *parent=0, TQDate=TQDate::currentDate(), const char *name=0, WFlags f=0);
58
63 CalendarPanel( TQWidget *parent, const char *name );
64
68 virtual ~CalendarPanel();
69
76 TQSize sizeHint() const;
77
78 TQSize minimumSizeHint() const { return sizeHint(); }
85 bool setDate(const TQDate&);
86
91 const TQDate& getDate() const;
92
96 const TQDate &date() const;
97
101 void setEnabled(bool);
102
106 void setFontSize(int);
110 int fontSize() const
111 { return fontsize; }
112
121 void setCloseButton( bool enable );
122
127 bool hasCloseButton() const;
128
129 void setCalendar(Calendar *cal);
130
131 DateMap selectedDates();
132 IntMap selectedWeekdays();
133 WeekMap selectedWeeks();
134
135 DateMap markedDates();
136 IntMap markedWeekdays();
137 WeekMap markedWeeks();
138
139 void clear();
140
141 void markSelected(int state);
142
143protected:
145 virtual bool eventFilter(TQObject *o, TQEvent *e );
147 virtual void resizeEvent(TQResizeEvent*);
149 TQToolButton *yearForward;
151 TQToolButton *yearBackward;
153 TQToolButton *monthForward;
155 TQToolButton *monthBackward;
157 TQToolButton *selectMonth;
159 TQToolButton *selectYear;
161 TQLineEdit *line;
165 DateTable *table;
166 // the widest month string in pixels:
167 TQSize maxMonthRect;
168
169protected slots:
170 void dateChangedSlot(TQDate);
171 void tableClickedSlot();
172 void monthForwardClicked();
173 void monthBackwardClicked();
174 void yearForwardClicked();
175 void yearBackwardClicked();
176 void selectWeekClicked();
177 void selectMonthClicked();
178 void selectYearClicked();
179 void lineEnterPressed();
180
181 void slotWeekdaySelected(int day);
182 void slotWeekSelected(int week, int year);
183 void slotSelectionCleared();
184
185signals:
192 void dateChanged(TQDate);
196 void dateSelected(TQDate);
202 void dateEntered(TQDate);
207
208 void weekSelected(int week, int year);
209 void weekdaySelected(int day);
214
215private:
217 int fontsize;
218
219 bool m_selectedDays[7];
220
221protected:
222 virtual void virtual_hook( int id, void* data );
223private:
224 void init( const TQDate &dt );
225 class CalendarPanelPrivate;
226 CalendarPanelPrivate *d;
227 // calculate ISO 8601 week number
228 int weekOfYear(TQDate);
229};
230
231} //KPlato namespace
232
233#endif // CALENDARPANEL_H
TQSize sizeHint() const
The size hint for date pickers.
void setCloseButton(bool enable)
By calling this method with enable = true, CalendarPanel will show a little close-button in the upper...
void setFontSize(int)
Sets the font size of the widgets elements.
CalendarPanel(TQWidget *parent=0, TQDate=TQDate::currentDate(), const char *name=0, WFlags f=0)
The usual constructor.
const TQDate & date() const
virtual void resizeEvent(TQResizeEvent *)
the resize event
virtual ~CalendarPanel()
The destructor.
TQToolButton * monthForward
the month forward button
TQLineEdit * line
the line edit to enter the date directly
void dateSelected(TQDate)
This signal is emitted each time a day has been selected by clicking on the table (hitting a day in t...
TQToolButton * selectMonth
the button for selecting the month directly
int fontSize() const
Returns the font size of the widget elements.
void dateEntered(TQDate)
This signal is emitted when enter is pressed and a VALID date has been entered before into the line e...
TQToolButton * yearBackward
the year backward button
TQToolButton * selectYear
the button for selecting the year directly
bool setDate(const TQDate &)
Sets the date.
TQToolButton * yearForward
the year forward button
const TQDate & getDate() const
Returns the selected date.
void setEnabled(bool)
Enables or disables the widget.
virtual bool eventFilter(TQObject *o, TQEvent *e)
to catch move keyEvents when TQLineEdit has keyFocus
void dateChanged(TQDate)
This signal is emitted each time the selected date is changed.
TQToolButton * monthBackward
the month backward button
DateTable * table
the date table
void tableClicked()
This signal is emitted when the day has been selected by clicking on it in the table.
DateValidator * val
the validator for the line edit:
void selectionCleared()
All selections have been cleared.
Calendar defines the working and nonworking days and hours.
Validates user-entered dates.