-rw-r--r-- | bin/kdepim/WhatsNew.txt | 2 | ||||
-rw-r--r-- | libkdepim/kdatepicker.cpp | 12 | ||||
-rw-r--r-- | libkdepim/kdatepicker.h | 2 |
3 files changed, 15 insertions, 1 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt index 3d8edfc..62c8447 100644 --- a/bin/kdepim/WhatsNew.txt +++ b/bin/kdepim/WhatsNew.txt | |||
@@ -1,200 +1,202 @@ | |||
1 | Info about the changes in new versions of KDE-Pim/Pi | 1 | Info about the changes in new versions of KDE-Pim/Pi |
2 | 2 | ||
3 | ********** VERSION 2.0.8 ************ | 3 | ********** VERSION 2.0.8 ************ |
4 | 4 | ||
5 | Fixed a problem in dependency info in the ipk files for the Zaurus. | 5 | Fixed a problem in dependency info in the ipk files for the Zaurus. |
6 | 6 | ||
7 | Added icon for the stealth new week view and made navigation more user friendly in monthview by adding a prev/next week button to the navigator bar. | 7 | Added icon for the stealth new week view and made navigation more user friendly in monthview by adding a prev/next week button to the navigator bar. |
8 | 8 | ||
9 | Added a "go today" button to the datepicker. | ||
10 | |||
9 | 11 | ||
10 | ********** VERSION 2.0.7 ************ | 12 | ********** VERSION 2.0.7 ************ |
11 | 13 | ||
12 | Added global application font settings | 14 | Added global application font settings |
13 | (for all KDE-Pim/Pi apps) to the general settings. | 15 | (for all KDE-Pim/Pi apps) to the general settings. |
14 | 16 | ||
15 | Fixed a problem in OM/Pi when trying to login to some IMAP servers | 17 | Fixed a problem in OM/Pi when trying to login to some IMAP servers |
16 | (like the IMAP server of Apple: mail.mac.com ) | 18 | (like the IMAP server of Apple: mail.mac.com ) |
17 | 19 | ||
18 | Added recurring todos to KO/Pi. | 20 | Added recurring todos to KO/Pi. |
19 | 21 | ||
20 | 22 | ||
21 | ********** VERSION 2.0.6 ************ | 23 | ********** VERSION 2.0.6 ************ |
22 | 24 | ||
23 | Some bugfixes in the pi-sync mode. | 25 | Some bugfixes in the pi-sync mode. |
24 | Added German translation for pi-sync mode. | 26 | Added German translation for pi-sync mode. |
25 | 27 | ||
26 | KO/Pi: | 28 | KO/Pi: |
27 | Made the todolist using alternate background. | 29 | Made the todolist using alternate background. |
28 | 30 | ||
29 | Other minor fixes in KO/Pi. | 31 | Other minor fixes in KO/Pi. |
30 | 32 | ||
31 | 33 | ||
32 | ********** VERSION 2.0.5 ************ | 34 | ********** VERSION 2.0.5 ************ |
33 | 35 | ||
34 | Bugfixes in KO/Pi. | 36 | Bugfixes in KO/Pi. |
35 | 37 | ||
36 | ********** VERSION 2.0.4 ************ | 38 | ********** VERSION 2.0.4 ************ |
37 | 39 | ||
38 | KO/Pi: | 40 | KO/Pi: |
39 | Fixed problem loading translations for summary/location edit boxes in event/todo editor. | 41 | Fixed problem loading translations for summary/location edit boxes in event/todo editor. |
40 | 42 | ||
41 | Added a general "select week number" to the toolbar. | 43 | Added a general "select week number" to the toolbar. |
42 | 44 | ||
43 | Fixed some small problem of the new features introduced in version 2.0.3. | 45 | Fixed some small problem of the new features introduced in version 2.0.3. |
44 | 46 | ||
45 | Made it possible to specify one specific category as category color, | 47 | Made it possible to specify one specific category as category color, |
46 | if more than one categories are selected. | 48 | if more than one categories are selected. |
47 | 49 | ||
48 | Fixed a bug in saving colors for categories with non-ascii characters. | 50 | Fixed a bug in saving colors for categories with non-ascii characters. |
49 | (Like, e.g. German Umlauts). | 51 | (Like, e.g. German Umlauts). |
50 | Propably you have to set your colors again for those categories. | 52 | Propably you have to set your colors again for those categories. |
51 | 53 | ||
52 | 54 | ||
53 | ********** VERSION 2.0.3 ************ | 55 | ********** VERSION 2.0.3 ************ |
54 | 56 | ||
55 | KO/Pi: | 57 | KO/Pi: |
56 | Added feature for changing alarm settings for many items at once: | 58 | Added feature for changing alarm settings for many items at once: |
57 | Open list view (or search dialog), select the desired items and choose in | 59 | Open list view (or search dialog), select the desired items and choose in |
58 | the popup menu: Set alarm for selected... | 60 | the popup menu: Set alarm for selected... |
59 | 61 | ||
60 | Added to the event/todo viewer the option to send an email to | 62 | Added to the event/todo viewer the option to send an email to |
61 | all attendees or all selected (with RSVP) attendees. | 63 | all attendees or all selected (with RSVP) attendees. |
62 | 64 | ||
63 | Made the week-month mode changing in month view faster. | 65 | Made the week-month mode changing in month view faster. |
64 | 66 | ||
65 | Made month view better useable with keyboard. | 67 | Made month view better useable with keyboard. |
66 | Now TAB key jumps to next cell with an event/todo. | 68 | Now TAB key jumps to next cell with an event/todo. |
67 | Scroll in cell with coursor keys, scroll in time (next week) with | 69 | Scroll in cell with coursor keys, scroll in time (next week) with |
68 | Shift/Control + coursorkeys. | 70 | Shift/Control + coursorkeys. |
69 | 71 | ||
70 | Fixed bug that the todo view flat mode was reset after first view update. | 72 | Fixed bug that the todo view flat mode was reset after first view update. |
71 | 73 | ||
72 | If a todo is displayed closed in the todo view, | 74 | If a todo is displayed closed in the todo view, |
73 | it is now displayed in overdue/due today color depending on the subtodos overdue/due today properties. | 75 | it is now displayed in overdue/due today color depending on the subtodos overdue/due today properties. |
74 | 76 | ||
75 | Added info about the numbers of years to the caption (title) information about a birthday event. | 77 | Added info about the numbers of years to the caption (title) information about a birthday event. |
76 | 78 | ||
77 | Made completion date in todo editor editable. | 79 | Made completion date in todo editor editable. |
78 | 80 | ||
79 | Added possibility to save/load templates for journals. | 81 | Added possibility to save/load templates for journals. |
80 | (Which is just a simple "save text to file" or "insert text from file". | 82 | (Which is just a simple "save text to file" or "insert text from file". |
81 | 83 | ||
82 | ********** VERSION 2.0.2 ************ | 84 | ********** VERSION 2.0.2 ************ |
83 | 85 | ||
84 | KO/Pi: | 86 | KO/Pi: |
85 | Fixed the layout problem of the day label buttons | 87 | Fixed the layout problem of the day label buttons |
86 | of the agenda view introduced in version 2.0.1. | 88 | of the agenda view introduced in version 2.0.1. |
87 | 89 | ||
88 | Added WhatsThis support for the todo view and the list view. | 90 | Added WhatsThis support for the todo view and the list view. |
89 | 91 | ||
90 | Added a quite useful feature to the montview. | 92 | Added a quite useful feature to the montview. |
91 | Just click on the week numbers on the left. | 93 | Just click on the week numbers on the left. |
92 | And in the top right corner of month view/agenda view | 94 | And in the top right corner of month view/agenda view |
93 | there is now a "week number quick selector". | 95 | there is now a "week number quick selector". |
94 | (Click on the black triangle). | 96 | (Click on the black triangle). |
95 | 97 | ||
96 | Made the quite difficult timezone change in KO/Pi easy. | 98 | Made the quite difficult timezone change in KO/Pi easy. |
97 | 99 | ||
98 | OM/Pi: | 100 | OM/Pi: |
99 | Fixed too small icons on desktop. | 101 | Fixed too small icons on desktop. |
100 | Fixed non visible icons in mainwindow on Z with fastload enabled. | 102 | Fixed non visible icons in mainwindow on Z with fastload enabled. |
101 | Added signature file setting to smtp account config. | 103 | Added signature file setting to smtp account config. |
102 | And the signature can be edited and saved in the edit mail dialog. | 104 | And the signature can be edited and saved in the edit mail dialog. |
103 | That does mean: | 105 | That does mean: |
104 | Simply edit the signature for the selected smtp account in the | 106 | Simply edit the signature for the selected smtp account in the |
105 | edit new mail dialog and press the "save signature" button there. | 107 | edit new mail dialog and press the "save signature" button there. |
106 | Then the signature is saved to the file specified in the smtp account settings. | 108 | Then the signature is saved to the file specified in the smtp account settings. |
107 | If there is no file specified, it is saved automatically to the file | 109 | If there is no file specified, it is saved automatically to the file |
108 | kdepim/apps/kopiemail/<accountname>.sig. | 110 | kdepim/apps/kopiemail/<accountname>.sig. |
109 | 111 | ||
110 | 112 | ||
111 | 113 | ||
112 | ********** VERSION 2.0.1 ************ | 114 | ********** VERSION 2.0.1 ************ |
113 | 115 | ||
114 | Oooops ... I forgot to test on the Zaurus 5500 ... | 116 | Oooops ... I forgot to test on the Zaurus 5500 ... |
115 | 117 | ||
116 | Fixed many problems of new (english) strings (and german translations) | 118 | Fixed many problems of new (english) strings (and german translations) |
117 | introduced in the latest versions, where the text was not fitting on the | 119 | introduced in the latest versions, where the text was not fitting on the |
118 | 240x320 display of the Zaurus 5500. | 120 | 240x320 display of the Zaurus 5500. |
119 | 121 | ||
120 | KO/Pi: | 122 | KO/Pi: |
121 | Added a popup menu ( press pen and hold to get popup ) to the agenda view | 123 | Added a popup menu ( press pen and hold to get popup ) to the agenda view |
122 | with many useful items (add event/todo, show next week, two weeks, month, journal). | 124 | with many useful items (add event/todo, show next week, two weeks, month, journal). |
123 | 125 | ||
124 | Added items to the todolist popup menu for: | 126 | Added items to the todolist popup menu for: |
125 | Display all opened, all closed or all todos flat. | 127 | Display all opened, all closed or all todos flat. |
126 | The "flat" view makes is possible to sort all todos after ,e.g., prio or date. | 128 | The "flat" view makes is possible to sort all todos after ,e.g., prio or date. |
127 | Made the reparenting of todos on the desktop possible via Drag&Drop. | 129 | Made the reparenting of todos on the desktop possible via Drag&Drop. |
128 | Fixed several bugs in setting the completed datetime for todos. | 130 | Fixed several bugs in setting the completed datetime for todos. |
129 | Added info about completed datetime of todos to the todo viewer. | 131 | Added info about completed datetime of todos to the todo viewer. |
130 | Now displaying a completed todo (with completed datetime set) in the agenda view | 132 | Now displaying a completed todo (with completed datetime set) in the agenda view |
131 | at the time of the completion. Such that now it is possible to see in the agenda view | 133 | at the time of the completion. Such that now it is possible to see in the agenda view |
132 | when what todo was completed. | 134 | when what todo was completed. |
133 | Fixed behaviour of automatic setting completion of todos with sub-todos/parent todos. | 135 | Fixed behaviour of automatic setting completion of todos with sub-todos/parent todos. |
134 | Now the behaviour is: | 136 | Now the behaviour is: |
135 | Setting a parent to complete sets all (sub)childs to complete. | 137 | Setting a parent to complete sets all (sub)childs to complete. |
136 | Setting a parent to uncomplete does not change the childs. | 138 | Setting a parent to uncomplete does not change the childs. |
137 | Setting a child to uncomplete sets all parent to uncomplete. | 139 | Setting a child to uncomplete sets all parent to uncomplete. |
138 | Setting a child to complete does not change the parents. | 140 | Setting a child to complete does not change the parents. |
139 | 141 | ||
140 | Smart updating and double buffering of the daymatrix. | 142 | Smart updating and double buffering of the daymatrix. |
141 | Showing holidays in the day matrix. | 143 | Showing holidays in the day matrix. |
142 | Many other small performance updates. | 144 | Many other small performance updates. |
143 | 145 | ||
144 | Made day labels in agenda clickable. By clicking a label, the day is displayed in single day mode. | 146 | Made day labels in agenda clickable. By clicking a label, the day is displayed in single day mode. |
145 | 147 | ||
146 | Now the translation file usertranslation.txt is supposed to be in utf8 format. | 148 | Now the translation file usertranslation.txt is supposed to be in utf8 format. |
147 | If you want to translate a language from western europe, just change the germantranslation.txt file. Please read the updated Usertranslation HowTo in KO/Pi Help menu. | 149 | If you want to translate a language from western europe, just change the germantranslation.txt file. Please read the updated Usertranslation HowTo in KO/Pi Help menu. |
148 | 150 | ||
149 | 151 | ||
150 | ********** VERSION 2.0.0 ************ | 152 | ********** VERSION 2.0.0 ************ |
151 | 153 | ||
152 | Stable release 2.0.0! | 154 | Stable release 2.0.0! |
153 | 155 | ||
154 | KO/Pi: | 156 | KO/Pi: |
155 | Fixed problem in edit dialog recreation at startup. | 157 | Fixed problem in edit dialog recreation at startup. |
156 | Made "toggle view*" menu items enabled context sensitive. | 158 | Made "toggle view*" menu items enabled context sensitive. |
157 | Changed agenda size menu to items 1-10. | 159 | Changed agenda size menu to items 1-10. |
158 | Made it possible to change agenda size quickly by pressing mouse on timelabels in agenda view and move mouse up/down. | 160 | Made it possible to change agenda size quickly by pressing mouse on timelabels in agenda view and move mouse up/down. |
159 | Usebility enhancements in the KO/Pi menus. | 161 | Usebility enhancements in the KO/Pi menus. |
160 | Birthday import now adds year to summary. | 162 | Birthday import now adds year to summary. |
161 | What's Next view shows age in years for birthday. | 163 | What's Next view shows age in years for birthday. |
162 | 164 | ||
163 | OM/Pi: | 165 | OM/Pi: |
164 | Added three info lines to display subject, from and to of selected mails. | 166 | Added three info lines to display subject, from and to of selected mails. |
165 | 167 | ||
166 | KA/Pi: | 168 | KA/Pi: |
167 | Fixed jump bar behaviour on Zaurus. | 169 | Fixed jump bar behaviour on Zaurus. |
168 | Now KA/Pi search field supports searching for a range of starting characters. | 170 | Now KA/Pi search field supports searching for a range of starting characters. |
169 | E.g. to search for all contact beginning with b to n, type | 171 | E.g. to search for all contact beginning with b to n, type |
170 | b-n | 172 | b-n |
171 | in the search field. | 173 | in the search field. |
172 | 174 | ||
173 | ********** VERSION 1.9.20 ************ | 175 | ********** VERSION 1.9.20 ************ |
174 | 176 | ||
175 | KO/Pi: | 177 | KO/Pi: |
176 | Added for the "dislplay one day" agenda mode | 178 | Added for the "dislplay one day" agenda mode |
177 | info in the caption and in the day lables: | 179 | info in the caption and in the day lables: |
178 | Now it is displayed, if the selected day is from "day before yesterday" | 180 | Now it is displayed, if the selected day is from "day before yesterday" |
179 | to "day after tomorrow". | 181 | to "day after tomorrow". |
180 | Made it possible to delete a Todo, which has sub-todos. | 182 | Made it possible to delete a Todo, which has sub-todos. |
181 | Fixed two small problems in the todo view. | 183 | Fixed two small problems in the todo view. |
182 | Added missing German translation for filter edit and print dialog. | 184 | Added missing German translation for filter edit and print dialog. |
183 | Made search dialog closeable by cancel key. | 185 | Made search dialog closeable by cancel key. |
184 | 186 | ||
185 | Made it possible to select in the date picker the (ligt grey ) | 187 | Made it possible to select in the date picker the (ligt grey ) |
186 | dates of the prev./next month with the mouse. | 188 | dates of the prev./next month with the mouse. |
187 | 189 | ||
188 | OM/Pi: | 190 | OM/Pi: |
189 | "Delete mail" icon in main window now deletes all selected mails. | 191 | "Delete mail" icon in main window now deletes all selected mails. |
190 | Fixed the problem, that the state flag of imap mails was ignored. | 192 | Fixed the problem, that the state flag of imap mails was ignored. |
191 | Now mails with "FLAG_SEEN" on the imap server get no icon in the list view | 193 | Now mails with "FLAG_SEEN" on the imap server get no icon in the list view |
192 | to indecate that they are already seen. | 194 | to indecate that they are already seen. |
193 | Fixed the problem that the body of some mails was not displayed in the | 195 | Fixed the problem that the body of some mails was not displayed in the |
194 | mail viewer when fetching them from the imap server directly to read them. | 196 | mail viewer when fetching them from the imap server directly to read them. |
195 | Made it (configurable) possible to show the "To:" field in the list view. | 197 | Made it (configurable) possible to show the "To:" field in the list view. |
196 | Added to the mail viewer the option "View Source" to make it possible to see the raw mail data. | 198 | Added to the mail viewer the option "View Source" to make it possible to see the raw mail data. |
197 | Added a "Download Mail" button to the mail viewer to quickly download the viewed mail to the | 199 | Added a "Download Mail" button to the mail viewer to quickly download the viewed mail to the |
198 | local storage folder (specified in account settings) of the account of the mail. | 200 | local storage folder (specified in account settings) of the account of the mail. |
199 | Removed some memory leaks in OM/Pi. | 201 | Removed some memory leaks in OM/Pi. |
200 | 202 | ||
diff --git a/libkdepim/kdatepicker.cpp b/libkdepim/kdatepicker.cpp index c13734f..77793c4 100644 --- a/libkdepim/kdatepicker.cpp +++ b/libkdepim/kdatepicker.cpp | |||
@@ -1,364 +1,374 @@ | |||
1 | /* -*- C++ -*- | 1 | /* -*- C++ -*- |
2 | This file is part of the KDE libraries | 2 | This file is part of the KDE libraries |
3 | Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org) | 3 | Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org) |
4 | (C) 1998-2001 Mirko Boehm (mirko@kde.org) | 4 | (C) 1998-2001 Mirko Boehm (mirko@kde.org) |
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include "kdatepicker.h" | 21 | #include "kdatepicker.h" |
22 | #include <kglobal.h> | 22 | #include <kglobal.h> |
23 | #include <kapplication.h> | 23 | #include <kapplication.h> |
24 | #include <klocale.h> | 24 | #include <klocale.h> |
25 | #include <kiconloader.h> | 25 | #include <kiconloader.h> |
26 | #include <qframe.h> | 26 | #include <qframe.h> |
27 | #include <qpainter.h> | 27 | #include <qpainter.h> |
28 | #include <qdialog.h> | 28 | #include <qdialog.h> |
29 | #include <qtoolbutton.h> | 29 | #include <qtoolbutton.h> |
30 | #include <qfont.h> | 30 | #include <qfont.h> |
31 | #include <qapplication.h> | 31 | #include <qapplication.h> |
32 | #include <qlineedit.h> | 32 | #include <qlineedit.h> |
33 | #include <qvalidator.h> | 33 | #include <qvalidator.h> |
34 | #include <kdebug.h> | 34 | #include <kdebug.h> |
35 | #include <knotifyclient.h> | 35 | #include <knotifyclient.h> |
36 | #include <kglobalsettings.h> | 36 | #include <kglobalsettings.h> |
37 | #include "kdatetbl.h" | 37 | #include "kdatetbl.h" |
38 | #include "kdateedit.h" | 38 | #include "kdateedit.h" |
39 | //#include "kdatepicker.moc" | 39 | //#include "kdatepicker.moc" |
40 | 40 | ||
41 | 41 | ||
42 | KDatePicker::KDatePicker(QWidget *parent, QDate dt, const char *name) | 42 | KDatePicker::KDatePicker(QWidget *parent, QDate dt, const char *name) |
43 | : QFrame(parent,name), | 43 | : QFrame(parent,name), |
44 | yearForward(new QToolButton(this)), | 44 | yearForward(new QToolButton(this)), |
45 | yearBackward(new QToolButton(this)), | 45 | yearBackward(new QToolButton(this)), |
46 | monthForward(new QToolButton(this)), | 46 | monthForward(new QToolButton(this)), |
47 | monthBackward(new QToolButton(this)), | 47 | monthBackward(new QToolButton(this)), |
48 | selectMonth(new QToolButton(this)), | 48 | selectMonth(new QToolButton(this)), |
49 | selectYear(new QToolButton(this)), | 49 | selectYear(new QToolButton(this)), |
50 | todayBut(new QToolButton(this)), | ||
50 | //line(new QLineEdit(this)), | 51 | //line(new QLineEdit(this)), |
51 | val(new KDateValidator(this)) | 52 | val(new KDateValidator(this)) |
52 | //table(new KDateTable(this)), | 53 | //table(new KDateTable(this)), |
53 | //fontsize(1) | 54 | //fontsize(1) |
54 | { | 55 | { |
55 | QFont fo = KGlobalSettings::generalFont(); | 56 | QFont fo = KGlobalSettings::generalFont(); |
56 | int add = 2; | 57 | int add = 2; |
57 | if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 ) | 58 | if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 ) |
58 | add += 4; | 59 | add += 4; |
59 | fo.setPointSize(fo.pointSize()+add ); | 60 | fo.setPointSize(fo.pointSize()+add ); |
60 | setFont( fo ); | 61 | setFont( fo ); |
61 | table = new KDateTable(this); | 62 | table = new KDateTable(this); |
62 | setFontSize(font().pointSize()); | 63 | setFontSize(font().pointSize()); |
63 | //line->setValidator(val); | 64 | //line->setValidator(val); |
64 | lineDate = new KDateEdit( this, "dateediipicker", true ); | 65 | lineDate = new KDateEdit( this, "dateediipicker", true ); |
65 | yearForward->setPixmap(SmallIcon("2rightarrowB")); | 66 | yearForward->setPixmap(SmallIcon("2rightarrowB")); |
66 | yearBackward->setPixmap(SmallIcon("2leftarrowB")); | 67 | yearBackward->setPixmap(SmallIcon("2leftarrowB")); |
67 | monthForward->setPixmap(SmallIcon("1rightarrowB")); | 68 | monthForward->setPixmap(SmallIcon("1rightarrowB")); |
68 | monthBackward->setPixmap(SmallIcon("1leftarrowB")); | 69 | monthBackward->setPixmap(SmallIcon("1leftarrowB")); |
70 | todayBut->setPixmap(SmallIcon("today")); | ||
69 | setDate(dt); // set button texts | 71 | setDate(dt); // set button texts |
70 | connect(table, SIGNAL(dateChanged(QDate)), SLOT(dateChangedSlot(QDate))); | 72 | connect(table, SIGNAL(dateChanged(QDate)), SLOT(dateChangedSlot(QDate))); |
71 | connect(table, SIGNAL(tableClicked()), SLOT(tableClickedSlot())); | 73 | connect(table, SIGNAL(tableClicked()), SLOT(tableClickedSlot())); |
72 | connect(monthForward, SIGNAL(clicked()), SLOT(monthForwardClicked())); | 74 | connect(monthForward, SIGNAL(clicked()), SLOT(monthForwardClicked())); |
73 | connect(monthBackward, SIGNAL(clicked()), SLOT(monthBackwardClicked())); | 75 | connect(monthBackward, SIGNAL(clicked()), SLOT(monthBackwardClicked())); |
74 | connect(yearForward, SIGNAL(clicked()), SLOT(yearForwardClicked())); | 76 | connect(yearForward, SIGNAL(clicked()), SLOT(yearForwardClicked())); |
75 | connect(yearBackward, SIGNAL(clicked()), SLOT(yearBackwardClicked())); | 77 | connect(yearBackward, SIGNAL(clicked()), SLOT(yearBackwardClicked())); |
76 | connect(selectMonth, SIGNAL(clicked()), SLOT(selectMonthClicked())); | 78 | connect(selectMonth, SIGNAL(clicked()), SLOT(selectMonthClicked())); |
77 | connect(selectYear, SIGNAL(clicked()), SLOT(selectYearClicked())); | 79 | connect(selectYear, SIGNAL(clicked()), SLOT(selectYearClicked())); |
80 | connect(todayBut, SIGNAL(clicked()), SLOT(goToday())); | ||
78 | //connect(line, SIGNAL(returnPressed()), SLOT(lineEnterPressed())); | 81 | //connect(line, SIGNAL(returnPressed()), SLOT(lineEnterPressed())); |
79 | connect(lineDate, SIGNAL(dateChanged(QDate)), SLOT(slotSetDate(QDate))); | 82 | connect(lineDate, SIGNAL(dateChanged(QDate)), SLOT(slotSetDate(QDate))); |
80 | connect(lineDate, SIGNAL(returnPressed()), SLOT(lineEnterPressed())); | 83 | connect(lineDate, SIGNAL(returnPressed()), SLOT(lineEnterPressed())); |
81 | table->setFocus(); | 84 | table->setFocus(); |
82 | 85 | ||
83 | } | 86 | } |
84 | 87 | ||
85 | KDatePicker::~KDatePicker() | 88 | KDatePicker::~KDatePicker() |
86 | { | 89 | { |
87 | } | 90 | } |
88 | 91 | ||
89 | void | 92 | void |
90 | KDatePicker::resizeEvent(QResizeEvent*) | 93 | KDatePicker::resizeEvent(QResizeEvent*) |
91 | { | 94 | { |
92 | QWidget *buttons[] = { | 95 | QWidget *buttons[] = { |
93 | yearBackward, | 96 | yearBackward, |
94 | monthBackward, | 97 | monthBackward, |
95 | selectMonth, | 98 | selectMonth, |
96 | selectYear, | 99 | selectYear, |
97 | monthForward, | 100 | monthForward, |
98 | yearForward }; | 101 | yearForward }; |
99 | const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]); | 102 | const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]); |
100 | QSize sizes[NoOfButtons]; | 103 | QSize sizes[NoOfButtons]; |
101 | int buttonHeight=0; | 104 | int buttonHeight=0; |
102 | int count; | 105 | int count; |
103 | int w; | 106 | int w; |
104 | int x=0; | 107 | int x=0; |
105 | // ----- calculate button row height: | 108 | // ----- calculate button row height: |
106 | for(count=0; count<NoOfButtons; ++count) { | 109 | for(count=0; count<NoOfButtons; ++count) { |
107 | int xS = buttons[count]->sizeHint().width(); | 110 | int xS = buttons[count]->sizeHint().width(); |
108 | int yS = buttons[count]->sizeHint().height(); | 111 | int yS = buttons[count]->sizeHint().height(); |
109 | if ( QApplication::desktop()->width() < 320 ) | 112 | if ( QApplication::desktop()->width() < 320 ) |
110 | sizes[count]=QSize ( xS+4, yS ); | 113 | sizes[count]=QSize ( xS+4, yS ); |
111 | else | 114 | else |
112 | sizes[count]=QSize ( xS+10, yS ); | 115 | sizes[count]=QSize ( xS+10, yS ); |
113 | 116 | ||
114 | buttonHeight=QMAX(buttonHeight, sizes[count].height()); | 117 | buttonHeight=QMAX(buttonHeight, sizes[count].height()); |
115 | } | 118 | } |
116 | buttonHeight += 10; | 119 | buttonHeight += 10; |
117 | // ----- calculate size of the month button: | 120 | // ----- calculate size of the month button: |
118 | w=0; | 121 | w=0; |
119 | for(count=0; count<NoOfButtons; ++count) { | 122 | for(count=0; count<NoOfButtons; ++count) { |
120 | if(buttons[count]!=selectMonth) | 123 | if(buttons[count]!=selectMonth) |
121 | { | 124 | { |
122 | w+=sizes[count].width(); | 125 | w+=sizes[count].width(); |
123 | } else { | 126 | } else { |
124 | x=count; | 127 | x=count; |
125 | } | 128 | } |
126 | } | 129 | } |
127 | sizes[x].setWidth(width()-w); // stretch the month button | 130 | sizes[x].setWidth(width()-w); // stretch the month button |
128 | // ----- place the buttons: | 131 | // ----- place the buttons: |
129 | x=0; | 132 | x=0; |
130 | for(count=0; count<NoOfButtons; ++count) | 133 | for(count=0; count<NoOfButtons; ++count) |
131 | { | 134 | { |
132 | w=sizes[count].width(); | 135 | w=sizes[count].width(); |
133 | buttons[count]->setGeometry(x, 0, w, buttonHeight); | 136 | buttons[count]->setGeometry(x, 0, w, buttonHeight); |
134 | x+=w; | 137 | x+=w; |
135 | } | 138 | } |
136 | // ----- place the line edit for direct input: | 139 | // ----- place the line edit for direct input: |
137 | sizes[0]=lineDate->sizeHint(); | 140 | sizes[0]=lineDate->sizeHint(); |
138 | //line->setGeometry(0, height()-sizes[0].height(), width(), sizes[0].height()); | 141 | //line->setGeometry(0, height()-sizes[0].height(), width(), sizes[0].height()); |
139 | lineDate->setGeometry(0, height()-sizes[0].height(), width(), sizes[0].height()); | 142 | int todaywid = todayBut->sizeHint().width(); |
143 | todayBut->setGeometry(0, height()-sizes[0].height(),todaywid, sizes[0].height()); | ||
144 | lineDate->setGeometry(0+todaywid, height()-sizes[0].height(), width()-todaywid, sizes[0].height()); | ||
140 | // ----- adjust the table: | 145 | // ----- adjust the table: |
141 | table->setGeometry(0, buttonHeight, width(), | 146 | table->setGeometry(0, buttonHeight, width(), |
142 | height()-buttonHeight-sizes[0].height()); | 147 | height()-buttonHeight-sizes[0].height()); |
143 | } | 148 | } |
144 | 149 | ||
145 | void | 150 | void |
146 | KDatePicker::dateChangedSlot(QDate date) | 151 | KDatePicker::dateChangedSlot(QDate date) |
147 | { | 152 | { |
148 | lineDate->setDate( date );//(KGlobal::locale()->formatDate(date, true)); | 153 | lineDate->setDate( date );//(KGlobal::locale()->formatDate(date, true)); |
149 | //line->setText(KGlobal::locale()->formatDate(date, true)); | 154 | //line->setText(KGlobal::locale()->formatDate(date, true)); |
150 | emit(dateChanged(date)); | 155 | emit(dateChanged(date)); |
151 | } | 156 | } |
152 | 157 | ||
153 | void | 158 | void |
154 | KDatePicker::tableClickedSlot() | 159 | KDatePicker::tableClickedSlot() |
155 | { | 160 | { |
156 | 161 | ||
157 | emit(dateSelected(table->getDate())); | 162 | emit(dateSelected(table->getDate())); |
158 | emit(tableClicked()); | 163 | emit(tableClicked()); |
159 | } | 164 | } |
160 | 165 | ||
161 | const QDate& | 166 | const QDate& |
162 | KDatePicker::getDate() const | 167 | KDatePicker::getDate() const |
163 | { | 168 | { |
164 | return table->getDate(); | 169 | return table->getDate(); |
165 | } | 170 | } |
166 | 171 | ||
167 | const QDate & | 172 | const QDate & |
168 | KDatePicker::date() const | 173 | KDatePicker::date() const |
169 | { | 174 | { |
170 | return table->getDate(); | 175 | return table->getDate(); |
171 | } | 176 | } |
172 | 177 | ||
178 | void KDatePicker::goToday() | ||
179 | { | ||
180 | slotSetDate( QDate::currentDate() ); | ||
181 | |||
182 | } | ||
173 | void KDatePicker::slotSetDate( QDate date ) | 183 | void KDatePicker::slotSetDate( QDate date ) |
174 | { | 184 | { |
175 | 185 | ||
176 | if(date.isValid()) { | 186 | if(date.isValid()) { |
177 | QString temp; | 187 | QString temp; |
178 | // ----- | 188 | // ----- |
179 | table->setDate(date); | 189 | table->setDate(date); |
180 | selectMonth->setText(KGlobal::locale()->monthName(date.month(), false)); | 190 | selectMonth->setText(KGlobal::locale()->monthName(date.month(), false)); |
181 | temp.setNum(date.year()); | 191 | temp.setNum(date.year()); |
182 | selectYear->setText(temp); | 192 | selectYear->setText(temp); |
183 | //line->setText(KGlobal::locale()->formatDate(date, true)); | 193 | //line->setText(KGlobal::locale()->formatDate(date, true)); |
184 | lineDate->setDate( date ); | 194 | lineDate->setDate( date ); |
185 | } | 195 | } |
186 | 196 | ||
187 | } | 197 | } |
188 | bool | 198 | bool |
189 | KDatePicker::setDate(const QDate& date) | 199 | KDatePicker::setDate(const QDate& date) |
190 | { | 200 | { |
191 | table->setFocus(); | 201 | table->setFocus(); |
192 | if(date.isValid()) { | 202 | if(date.isValid()) { |
193 | QString temp; | 203 | QString temp; |
194 | // ----- | 204 | // ----- |
195 | table->setDate(date); | 205 | table->setDate(date); |
196 | selectMonth->setText(KGlobal::locale()->monthName(date.month(), false)); | 206 | selectMonth->setText(KGlobal::locale()->monthName(date.month(), false)); |
197 | temp.setNum(date.year()); | 207 | temp.setNum(date.year()); |
198 | selectYear->setText(temp); | 208 | selectYear->setText(temp); |
199 | //line->setText(KGlobal::locale()->formatDate(date, true)); | 209 | //line->setText(KGlobal::locale()->formatDate(date, true)); |
200 | lineDate->setDate( date ); | 210 | lineDate->setDate( date ); |
201 | return true; | 211 | return true; |
202 | } else { | 212 | } else { |
203 | 213 | ||
204 | return false; | 214 | return false; |
205 | } | 215 | } |
206 | 216 | ||
207 | 217 | ||
208 | } | 218 | } |
209 | 219 | ||
210 | void | 220 | void |
211 | KDatePicker::monthForwardClicked() | 221 | KDatePicker::monthForwardClicked() |
212 | { | 222 | { |
213 | QDate temp=table->getDate(); | 223 | QDate temp=table->getDate(); |
214 | int day=temp.day(); | 224 | int day=temp.day(); |
215 | // ----- | 225 | // ----- |
216 | if(temp.month()==12) { | 226 | if(temp.month()==12) { |
217 | temp.setYMD(temp.year()+1, 1, 1); | 227 | temp.setYMD(temp.year()+1, 1, 1); |
218 | } else { | 228 | } else { |
219 | temp.setYMD(temp.year(), temp.month()+1, 1); | 229 | temp.setYMD(temp.year(), temp.month()+1, 1); |
220 | } | 230 | } |
221 | if(temp.daysInMonth()<day) { | 231 | if(temp.daysInMonth()<day) { |
222 | temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); | 232 | temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); |
223 | } else { | 233 | } else { |
224 | temp.setYMD(temp.year(), temp.month(), day); | 234 | temp.setYMD(temp.year(), temp.month(), day); |
225 | } | 235 | } |
226 | // assert(temp.isValid()); | 236 | // assert(temp.isValid()); |
227 | setDate(temp); | 237 | setDate(temp); |
228 | } | 238 | } |
229 | 239 | ||
230 | void | 240 | void |
231 | KDatePicker::monthBackwardClicked() | 241 | KDatePicker::monthBackwardClicked() |
232 | { | 242 | { |
233 | QDate temp=table->getDate(); | 243 | QDate temp=table->getDate(); |
234 | int day=temp.day(); | 244 | int day=temp.day(); |
235 | // ----- | 245 | // ----- |
236 | if(temp.month()==1) | 246 | if(temp.month()==1) |
237 | { | 247 | { |
238 | temp.setYMD(temp.year()-1, 12, 1); | 248 | temp.setYMD(temp.year()-1, 12, 1); |
239 | } else { | 249 | } else { |
240 | temp.setYMD(temp.year(), temp.month()-1, 1); | 250 | temp.setYMD(temp.year(), temp.month()-1, 1); |
241 | } | 251 | } |
242 | if(temp.daysInMonth()<day) | 252 | if(temp.daysInMonth()<day) |
243 | { | 253 | { |
244 | temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); | 254 | temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); |
245 | } else { | 255 | } else { |
246 | temp.setYMD(temp.year(), temp.month(), day); | 256 | temp.setYMD(temp.year(), temp.month(), day); |
247 | } | 257 | } |
248 | // assert(temp.isValid()); | 258 | // assert(temp.isValid()); |
249 | setDate(temp); | 259 | setDate(temp); |
250 | } | 260 | } |
251 | 261 | ||
252 | void | 262 | void |
253 | KDatePicker::yearForwardClicked() | 263 | KDatePicker::yearForwardClicked() |
254 | { | 264 | { |
255 | QDate temp=table->getDate(); | 265 | QDate temp=table->getDate(); |
256 | int day=temp.day(); | 266 | int day=temp.day(); |
257 | // ----- | 267 | // ----- |
258 | temp.setYMD(temp.year()+1, temp.month(), 1); | 268 | temp.setYMD(temp.year()+1, temp.month(), 1); |
259 | if(temp.daysInMonth()<day) | 269 | if(temp.daysInMonth()<day) |
260 | { | 270 | { |
261 | temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); | 271 | temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); |
262 | } else { | 272 | } else { |
263 | temp.setYMD(temp.year(), temp.month(), day); | 273 | temp.setYMD(temp.year(), temp.month(), day); |
264 | } | 274 | } |
265 | // assert(temp.isValid()); | 275 | // assert(temp.isValid()); |
266 | setDate(temp); | 276 | setDate(temp); |
267 | } | 277 | } |
268 | 278 | ||
269 | void | 279 | void |
270 | KDatePicker::yearBackwardClicked() | 280 | KDatePicker::yearBackwardClicked() |
271 | { | 281 | { |
272 | QDate temp=table->getDate(); | 282 | QDate temp=table->getDate(); |
273 | int day=temp.day(); | 283 | int day=temp.day(); |
274 | // ----- | 284 | // ----- |
275 | temp.setYMD(temp.year()-1, temp.month(), 1); | 285 | temp.setYMD(temp.year()-1, temp.month(), 1); |
276 | if(temp.daysInMonth()<day) | 286 | if(temp.daysInMonth()<day) |
277 | { | 287 | { |
278 | temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); | 288 | temp.setYMD(temp.year(), temp.month(), temp.daysInMonth()); |
279 | } else { | 289 | } else { |
280 | temp.setYMD(temp.year(), temp.month(), day); | 290 | temp.setYMD(temp.year(), temp.month(), day); |
281 | } | 291 | } |
282 | // assert(temp.isValid()); | 292 | // assert(temp.isValid()); |
283 | setDate(temp); | 293 | setDate(temp); |
284 | } | 294 | } |
285 | 295 | ||
286 | void | 296 | void |
287 | KDatePicker::selectMonthClicked() | 297 | KDatePicker::selectMonthClicked() |
288 | { | 298 | { |
289 | int month; | 299 | int month; |
290 | KPopupFrame* popup = new KPopupFrame(this); | 300 | KPopupFrame* popup = new KPopupFrame(this); |
291 | KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(popup); | 301 | KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(popup); |
292 | // ----- | 302 | // ----- |
293 | picker->resize(picker->sizeHint()); | 303 | picker->resize(picker->sizeHint()); |
294 | popup->setMainWidget(picker); | 304 | popup->setMainWidget(picker); |
295 | picker->setFocus(); | 305 | picker->setFocus(); |
296 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); | 306 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); |
297 | if(popup->exec(selectMonth->mapToGlobal(QPoint(0, selectMonth->height())))) | 307 | if(popup->exec(selectMonth->mapToGlobal(QPoint(0, selectMonth->height())))) |
298 | { | 308 | { |
299 | QDate date; | 309 | QDate date; |
300 | int day; | 310 | int day; |
301 | // ----- | 311 | // ----- |
302 | month=picker->getResult(); | 312 | month=picker->getResult(); |
303 | date=table->getDate(); | 313 | date=table->getDate(); |
304 | day=date.day(); | 314 | day=date.day(); |
305 | // ----- construct a valid date in this month: | 315 | // ----- construct a valid date in this month: |
306 | date.setYMD(date.year(), month, 1); | 316 | date.setYMD(date.year(), month, 1); |
307 | date.setYMD(date.year(), month, QMIN(day, date.daysInMonth())); | 317 | date.setYMD(date.year(), month, QMIN(day, date.daysInMonth())); |
308 | // ----- set this month | 318 | // ----- set this month |
309 | setDate(date); | 319 | setDate(date); |
310 | } else { | 320 | } else { |
311 | KNotifyClient::beep(); | 321 | KNotifyClient::beep(); |
312 | } | 322 | } |
313 | delete popup; | 323 | delete popup; |
314 | } | 324 | } |
315 | 325 | ||
316 | void | 326 | void |
317 | KDatePicker::selectYearClicked() | 327 | KDatePicker::selectYearClicked() |
318 | { | 328 | { |
319 | int year; | 329 | int year; |
320 | KPopupFrame* popup = new KPopupFrame(this); | 330 | KPopupFrame* popup = new KPopupFrame(this); |
321 | KDateInternalYearSelector* picker = new KDateInternalYearSelector(fontsize, popup); | 331 | KDateInternalYearSelector* picker = new KDateInternalYearSelector(fontsize, popup); |
322 | // ----- | 332 | // ----- |
323 | picker->resize(picker->sizeHint()); | 333 | picker->resize(picker->sizeHint()); |
324 | popup->setMainWidget(picker); | 334 | popup->setMainWidget(picker); |
325 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); | 335 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); |
326 | picker->setFocus(); | 336 | picker->setFocus(); |
327 | if(popup->exec(selectYear->mapToGlobal(QPoint(0, selectMonth->height())))) | 337 | if(popup->exec(selectYear->mapToGlobal(QPoint(0, selectMonth->height())))) |
328 | { | 338 | { |
329 | QDate date; | 339 | QDate date; |
330 | int day; | 340 | int day; |
331 | // ----- | 341 | // ----- |
332 | year=picker->getYear(); | 342 | year=picker->getYear(); |
333 | date=table->getDate(); | 343 | date=table->getDate(); |
334 | day=date.day(); | 344 | day=date.day(); |
335 | // ----- construct a valid date in this month: | 345 | // ----- construct a valid date in this month: |
336 | date.setYMD(year, date.month(), 1); | 346 | date.setYMD(year, date.month(), 1); |
337 | date.setYMD(year, date.month(), QMIN(day, date.daysInMonth())); | 347 | date.setYMD(year, date.month(), QMIN(day, date.daysInMonth())); |
338 | // ----- set this month | 348 | // ----- set this month |
339 | setDate(date); | 349 | setDate(date); |
340 | } else { | 350 | } else { |
341 | KNotifyClient::beep(); | 351 | KNotifyClient::beep(); |
342 | } | 352 | } |
343 | delete popup; | 353 | delete popup; |
344 | } | 354 | } |
345 | 355 | ||
346 | void | 356 | void |
347 | KDatePicker::setEnabled(bool enable) | 357 | KDatePicker::setEnabled(bool enable) |
348 | { | 358 | { |
349 | QWidget *widgets[]= { | 359 | QWidget *widgets[]= { |
350 | yearForward, yearBackward, monthForward, monthBackward, | 360 | yearForward, yearBackward, monthForward, monthBackward, |
351 | selectMonth, selectYear, | 361 | selectMonth, selectYear, |
352 | lineDate, table }; | 362 | lineDate, table }; |
353 | const int Size=sizeof(widgets)/sizeof(widgets[0]); | 363 | const int Size=sizeof(widgets)/sizeof(widgets[0]); |
354 | int count; | 364 | int count; |
355 | // ----- | 365 | // ----- |
356 | for(count=0; count<Size; ++count) | 366 | for(count=0; count<Size; ++count) |
357 | { | 367 | { |
358 | widgets[count]->setEnabled(enable); | 368 | widgets[count]->setEnabled(enable); |
359 | } | 369 | } |
360 | } | 370 | } |
361 | 371 | ||
362 | void | 372 | void |
363 | KDatePicker::lineEnterPressed() | 373 | KDatePicker::lineEnterPressed() |
364 | { | 374 | { |
diff --git a/libkdepim/kdatepicker.h b/libkdepim/kdatepicker.h index 6625357..3db9a89 100644 --- a/libkdepim/kdatepicker.h +++ b/libkdepim/kdatepicker.h | |||
@@ -1,181 +1,183 @@ | |||
1 | /* -*- C++ -*- | 1 | /* -*- C++ -*- |
2 | This file is part of the KDE libraries | 2 | This file is part of the KDE libraries |
3 | Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org) | 3 | Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org) |
4 | (C) 1998-2001 Mirko Boehm (mirko@kde.org) | 4 | (C) 1998-2001 Mirko Boehm (mirko@kde.org) |
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | #ifndef MICROKDE_KDATEPICKER_H | 20 | #ifndef MICROKDE_KDATEPICKER_H |
21 | #define MICROKDE_KDATEPICKER_H | 21 | #define MICROKDE_KDATEPICKER_H |
22 | #include <qdatetime.h> | 22 | #include <qdatetime.h> |
23 | #include <qframe.h> | 23 | #include <qframe.h> |
24 | #include <qevent.h> | 24 | #include <qevent.h> |
25 | 25 | ||
26 | class QLineEdit; | 26 | class QLineEdit; |
27 | class QToolButton; | 27 | class QToolButton; |
28 | class KDateValidator; | 28 | class KDateValidator; |
29 | class KDateTable; | 29 | class KDateTable; |
30 | class KDateEdit; | 30 | class KDateEdit; |
31 | 31 | ||
32 | /** | 32 | /** |
33 | * Provides a widget for calendar date input. | 33 | * Provides a widget for calendar date input. |
34 | * | 34 | * |
35 | * Different from the | 35 | * Different from the |
36 | * previous versions, it now emits two types of signals, either | 36 | * previous versions, it now emits two types of signals, either |
37 | * @ref dateSelected() or @ref dateEntered() (see documentation for both | 37 | * @ref dateSelected() or @ref dateEntered() (see documentation for both |
38 | * signals). | 38 | * signals). |
39 | * | 39 | * |
40 | * A line edit has been added in the newer versions to allow the user | 40 | * A line edit has been added in the newer versions to allow the user |
41 | * to select a date directly by entering numbers like 19990101 | 41 | * to select a date directly by entering numbers like 19990101 |
42 | * or 990101. | 42 | * or 990101. |
43 | * | 43 | * |
44 | * @image kdatepicker.png KDatePicker | 44 | * @image kdatepicker.png KDatePicker |
45 | * | 45 | * |
46 | * @version $Id$ | 46 | * @version $Id$ |
47 | * @author Tim Gilman, Mirko Boehm | 47 | * @author Tim Gilman, Mirko Boehm |
48 | * | 48 | * |
49 | * @short A date selection widget. | 49 | * @short A date selection widget. |
50 | **/ | 50 | **/ |
51 | class KDatePicker: public QFrame | 51 | class KDatePicker: public QFrame |
52 | { | 52 | { |
53 | Q_OBJECT | 53 | Q_OBJECT |
54 | public: | 54 | public: |
55 | /** The usual constructor. The given date will be displayed | 55 | /** The usual constructor. The given date will be displayed |
56 | * initially. | 56 | * initially. |
57 | **/ | 57 | **/ |
58 | KDatePicker(QWidget *parent=0, | 58 | KDatePicker(QWidget *parent=0, |
59 | QDate=QDate::currentDate(), | 59 | QDate=QDate::currentDate(), |
60 | const char *name=0); | 60 | const char *name=0); |
61 | /** | 61 | /** |
62 | * The destructor. | 62 | * The destructor. |
63 | **/ | 63 | **/ |
64 | virtual ~KDatePicker(); | 64 | virtual ~KDatePicker(); |
65 | 65 | ||
66 | /** The size hint for date pickers. The size hint recommends the | 66 | /** The size hint for date pickers. The size hint recommends the |
67 | * minimum size of the widget so that all elements may be placed | 67 | * minimum size of the widget so that all elements may be placed |
68 | * without clipping. This sometimes looks ugly, so when using the | 68 | * without clipping. This sometimes looks ugly, so when using the |
69 | * size hint, try adding 28 to each of the reported numbers of | 69 | * size hint, try adding 28 to each of the reported numbers of |
70 | * pixels. | 70 | * pixels. |
71 | **/ | 71 | **/ |
72 | QSize sizeHint() const; | 72 | QSize sizeHint() const; |
73 | 73 | ||
74 | /** | 74 | /** |
75 | * Sets the date. | 75 | * Sets the date. |
76 | * | 76 | * |
77 | * @returns @p false and does not change anything | 77 | * @returns @p false and does not change anything |
78 | * if the date given is invalid. | 78 | * if the date given is invalid. |
79 | **/ | 79 | **/ |
80 | bool setDate(const QDate&); | 80 | bool setDate(const QDate&); |
81 | 81 | ||
82 | /** | 82 | /** |
83 | * Returns the selected date. | 83 | * Returns the selected date. |
84 | * @deprecated | 84 | * @deprecated |
85 | **/ | 85 | **/ |
86 | const QDate& getDate() const; | 86 | const QDate& getDate() const; |
87 | 87 | ||
88 | /** | 88 | /** |
89 | * @returns the selected date. | 89 | * @returns the selected date. |
90 | */ | 90 | */ |
91 | const QDate &date() const; | 91 | const QDate &date() const; |
92 | 92 | ||
93 | /** | 93 | /** |
94 | * Enables or disables the widget. | 94 | * Enables or disables the widget. |
95 | **/ | 95 | **/ |
96 | void setEnabled(bool); | 96 | void setEnabled(bool); |
97 | 97 | ||
98 | /** | 98 | /** |
99 | * Sets the font size of the widgets elements. | 99 | * Sets the font size of the widgets elements. |
100 | **/ | 100 | **/ |
101 | void setFontSize(int); | 101 | void setFontSize(int); |
102 | /** | 102 | /** |
103 | * Returns the font size of the widget elements. | 103 | * Returns the font size of the widget elements. |
104 | */ | 104 | */ |
105 | int fontSize() const | 105 | int fontSize() const |
106 | { return fontsize; } | 106 | { return fontsize; } |
107 | protected: | 107 | protected: |
108 | /// the resize event | 108 | /// the resize event |
109 | void resizeEvent(QResizeEvent*); | 109 | void resizeEvent(QResizeEvent*); |
110 | QToolButton *todayBut; | ||
110 | /// the year forward button | 111 | /// the year forward button |
111 | QToolButton *yearForward; | 112 | QToolButton *yearForward; |
112 | /// the year backward button | 113 | /// the year backward button |
113 | QToolButton *yearBackward; | 114 | QToolButton *yearBackward; |
114 | /// the month forward button | 115 | /// the month forward button |
115 | QToolButton *monthForward; | 116 | QToolButton *monthForward; |
116 | /// the month backward button | 117 | /// the month backward button |
117 | QToolButton *monthBackward; | 118 | QToolButton *monthBackward; |
118 | /// the button for selecting the month directly | 119 | /// the button for selecting the month directly |
119 | QToolButton *selectMonth; | 120 | QToolButton *selectMonth; |
120 | /// the button for selecting the year directly | 121 | /// the button for selecting the year directly |
121 | QToolButton *selectYear; | 122 | QToolButton *selectYear; |
122 | /// the line edit to enter the date directly | 123 | /// the line edit to enter the date directly |
123 | //QLineEdit *line; | 124 | //QLineEdit *line; |
124 | KDateEdit *lineDate; | 125 | KDateEdit *lineDate; |
125 | /// the validator for the line edit: | 126 | /// the validator for the line edit: |
126 | KDateValidator *val; | 127 | KDateValidator *val; |
127 | /// the date table | 128 | /// the date table |
128 | KDateTable *table; | 129 | KDateTable *table; |
129 | /// the size calculated during resize events | 130 | /// the size calculated during resize events |
130 | // QSize sizehint; | 131 | // QSize sizehint; |
131 | /// the widest month string in pixels: | 132 | /// the widest month string in pixels: |
132 | QSize maxMonthRect; | 133 | QSize maxMonthRect; |
133 | protected slots: | 134 | protected slots: |
134 | void dateChangedSlot(QDate); | 135 | void dateChangedSlot(QDate); |
135 | void tableClickedSlot(); | 136 | void tableClickedSlot(); |
136 | void monthForwardClicked(); | 137 | void monthForwardClicked(); |
137 | void monthBackwardClicked(); | 138 | void monthBackwardClicked(); |
138 | void yearForwardClicked(); | 139 | void yearForwardClicked(); |
139 | void yearBackwardClicked(); | 140 | void yearBackwardClicked(); |
140 | void selectMonthClicked(); | 141 | void selectMonthClicked(); |
141 | void selectYearClicked(); | 142 | void selectYearClicked(); |
142 | void lineEnterPressed(); | 143 | void lineEnterPressed(); |
143 | void slotSetDate(QDate); | 144 | void slotSetDate(QDate); |
145 | void goToday(); | ||
144 | signals: | 146 | signals: |
145 | /** This signal is emitted each time the selected date is changed. | 147 | /** This signal is emitted each time the selected date is changed. |
146 | * Usually, this does not mean that the date has been entered, | 148 | * Usually, this does not mean that the date has been entered, |
147 | * since the date also changes, for example, when another month is | 149 | * since the date also changes, for example, when another month is |
148 | * selected. | 150 | * selected. |
149 | * @see dateSelected | 151 | * @see dateSelected |
150 | */ | 152 | */ |
151 | void dateChanged(QDate); | 153 | void dateChanged(QDate); |
152 | /** This signal is emitted each time a day has been selected by | 154 | /** This signal is emitted each time a day has been selected by |
153 | * clicking on the table (hitting a day in the current month). It | 155 | * clicking on the table (hitting a day in the current month). It |
154 | * has the same meaning as dateSelected() in older versions of | 156 | * has the same meaning as dateSelected() in older versions of |
155 | * KDatePicker. | 157 | * KDatePicker. |
156 | */ | 158 | */ |
157 | void dateSelected(QDate); | 159 | void dateSelected(QDate); |
158 | /** This signal is emitted when enter is pressed and a VALID date | 160 | /** This signal is emitted when enter is pressed and a VALID date |
159 | * has been entered before into the line edit. Connect to both | 161 | * has been entered before into the line edit. Connect to both |
160 | * dateEntered() and dateSelected() to receive all events where the | 162 | * dateEntered() and dateSelected() to receive all events where the |
161 | * user really enters a date. | 163 | * user really enters a date. |
162 | */ | 164 | */ |
163 | void dateEntered(QDate); | 165 | void dateEntered(QDate); |
164 | /** This signal is emitted when the day has been selected by | 166 | /** This signal is emitted when the day has been selected by |
165 | * clicking on it in the table. | 167 | * clicking on it in the table. |
166 | */ | 168 | */ |
167 | void tableClicked(); | 169 | void tableClicked(); |
168 | 170 | ||
169 | private: | 171 | private: |
170 | /// the font size for the widget | 172 | /// the font size for the widget |
171 | int fontsize; | 173 | int fontsize; |
172 | 174 | ||
173 | protected: | 175 | protected: |
174 | virtual void virtual_hook( int id, void* data ); | 176 | virtual void virtual_hook( int id, void* data ); |
175 | private: | 177 | private: |
176 | class KDatePickerPrivate; | 178 | class KDatePickerPrivate; |
177 | KDatePickerPrivate *d; | 179 | KDatePickerPrivate *d; |
178 | void keyPressEvent ( QKeyEvent * ) ; | 180 | void keyPressEvent ( QKeyEvent * ) ; |
179 | }; | 181 | }; |
180 | 182 | ||
181 | #endif // KDATEPICKER_H | 183 | #endif // KDATEPICKER_H |