-rw-r--r-- | bin/kdepim/WhatsNew.txt | 4 | ||||
-rw-r--r-- | korganizer/datenavigatorcontainer.cpp | 6 | ||||
-rw-r--r-- | korganizer/kdatenavigator.cpp | 2 | ||||
-rw-r--r-- | korganizer/kodaymatrix.cpp | 32 | ||||
-rw-r--r-- | korganizer/kodaymatrix.h | 1 |
5 files changed, 37 insertions, 8 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt index 6bc6be9..680f633 100644 --- a/bin/kdepim/WhatsNew.txt +++ b/bin/kdepim/WhatsNew.txt | |||
@@ -1,238 +1,242 @@ | |||
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.24 ************ | ||
4 | |||
5 | Fixed again a lot of small bugs. | ||
6 | |||
3 | ********** VERSION 2.0.23 ************ | 7 | ********** VERSION 2.0.23 ************ |
4 | 8 | ||
5 | Fixed again a lot of small and strange bugs, e.g. the missing toolbar of KA/Pi after a new installation. | 9 | Fixed again a lot of small and strange bugs, e.g. the missing toolbar of KA/Pi after a new installation. |
6 | Fixed the (agenda) layout of KO/Pi on 5500er. | 10 | Fixed the (agenda) layout of KO/Pi on 5500er. |
7 | Some usebility enhancements (e.g. reselection the current item of the todo view after some changes). | 11 | Some usebility enhancements (e.g. reselection the current item of the todo view after some changes). |
8 | 12 | ||
9 | ********** VERSION 2.0.22 ************ | 13 | ********** VERSION 2.0.22 ************ |
10 | 14 | ||
11 | KO/Pi: | 15 | KO/Pi: |
12 | Fix for creating events/todos via the abgenda context menu. | 16 | Fix for creating events/todos via the abgenda context menu. |
13 | Added option to split toolbar to 3 toolbars. | 17 | Added option to split toolbar to 3 toolbars. |
14 | (Toolbar moving s disabled for this option due to a bug in Qt somewhere). | 18 | (Toolbar moving s disabled for this option due to a bug in Qt somewhere). |
15 | Added option to show one small filter-view-toolbar. | 19 | Added option to show one small filter-view-toolbar. |
16 | Added a print option to the desktop version: | 20 | Added a print option to the desktop version: |
17 | Now you can print out the view of the "Event Viewer". | 21 | Now you can print out the view of the "Event Viewer". |
18 | That means you can print all data of one particular event/todo. | 22 | That means you can print all data of one particular event/todo. |
19 | Added scaling options to printout of Event Viewer and What'sNext View. | 23 | Added scaling options to printout of Event Viewer and What'sNext View. |
20 | Fixed some problems in the month view in "week start sunday" mode. | 24 | Fixed some problems in the month view in "week start sunday" mode. |
21 | KA/Pi: | 25 | KA/Pi: |
22 | Added two more config options. | 26 | Added two more config options. |
23 | Fixed resizing problem of address request dialog when orientation was switched. | 27 | Fixed resizing problem of address request dialog when orientation was switched. |
24 | Cleaned up the menu structure. | 28 | Cleaned up the menu structure. |
25 | Fixed some more problems. | 29 | Fixed some more problems. |
26 | 30 | ||
27 | Fixed the annoying problem that scrolling continued after the key was released in KO/Pi Monthview and the KA/Pi views. | 31 | Fixed the annoying problem that scrolling continued after the key was released in KO/Pi Monthview and the KA/Pi views. |
28 | 32 | ||
29 | And, this is a really cool option (Ben did suggest it): | 33 | And, this is a really cool option (Ben did suggest it): |
30 | Now KO/Pi and KA/Pi can be run from a USB stick: | 34 | Now KO/Pi and KA/Pi can be run from a USB stick: |
31 | All data is read from and written to the stick. | 35 | All data is read from and written to the stick. |
32 | You can enable this in the global configure option TAB with: | 36 | You can enable this in the global configure option TAB with: |
33 | Save using LOCAL storage. | 37 | Save using LOCAL storage. |
34 | Just put KDE-Pim/Pi on a memory stick and you can access all your PIM data on every computer with Windows XP. It will work with the ME and Linux versions as well. I will put a memory stick version for teh next stable release online. | 38 | Just put KDE-Pim/Pi on a memory stick and you can access all your PIM data on every computer with Windows XP. It will work with the ME and Linux versions as well. I will put a memory stick version for teh next stable release online. |
35 | 39 | ||
36 | ********** VERSION 2.0.21 ************ | 40 | ********** VERSION 2.0.21 ************ |
37 | 41 | ||
38 | Fixed another SMTP problem in OM/Pi. | 42 | Fixed another SMTP problem in OM/Pi. |
39 | Some small changed in the new datenavigator in KO/Pi. | 43 | Some small changed in the new datenavigator in KO/Pi. |
40 | Changed default setting for new filter in KA/Pi to "exclude categories". | 44 | Changed default setting for new filter in KA/Pi to "exclude categories". |
41 | Changed the default font size for 640x480 display . | 45 | Changed the default font size for 640x480 display . |
42 | Changed popup menu behaviour in agenda and list view. | 46 | Changed popup menu behaviour in agenda and list view. |
43 | Fixed some layout problems of the date label size in the month view. | 47 | Fixed some layout problems of the date label size in the month view. |
44 | Made month view update faster. | 48 | Made month view update faster. |
45 | Made first datenavigator repainting faster. | 49 | Made first datenavigator repainting faster. |
46 | Changed the title of the event/todo edit dialogs. | 50 | Changed the title of the event/todo edit dialogs. |
47 | Timelabels in agenga changed from 22:00 to 22 oo. ( the oo higher, of course). | 51 | Timelabels in agenga changed from 22:00 to 22 oo. ( the oo higher, of course). |
48 | Many small usebility fixes in KO/Pi. | 52 | Many small usebility fixes in KO/Pi. |
49 | Pressing the "Calendar" button on the Z switches now to the next view in KO/Pi. | 53 | Pressing the "Calendar" button on the Z switches now to the next view in KO/Pi. |
50 | The set of possible "next views" are the views you have toolbar buttons for. | 54 | The set of possible "next views" are the views you have toolbar buttons for. |
51 | 55 | ||
52 | Made alarm sound working on Linux. | 56 | Made alarm sound working on Linux. |
53 | 57 | ||
54 | KO/Pi alarm applet changed: | 58 | KO/Pi alarm applet changed: |
55 | Made buttons in alarm dialog much bigger. | 59 | Made buttons in alarm dialog much bigger. |
56 | Made setting of timer more user friendly by showing the actual timer fire time and making the buttons in the timer settings much bigger. | 60 | Made setting of timer more user friendly by showing the actual timer fire time and making the buttons in the timer settings much bigger. |
57 | The goal was it to make it possible to use a finger tip ( and not the stylus ) on the touchscreen to adjust the settings. | 61 | The goal was it to make it possible to use a finger tip ( and not the stylus ) on the touchscreen to adjust the settings. |
58 | 62 | ||
59 | And because this version is realeased at Easter, I added an Easter-egg: | 63 | And because this version is realeased at Easter, I added an Easter-egg: |
60 | With a new undocumented command you can get a message box about the next alarm. | 64 | With a new undocumented command you can get a message box about the next alarm. |
61 | Good luck to find it! | 65 | Good luck to find it! |
62 | 66 | ||
63 | 67 | ||
64 | 68 | ||
65 | ********** VERSION 2.0.20 ************ | 69 | ********** VERSION 2.0.20 ************ |
66 | 70 | ||
67 | Two small fixes in OM/Pi. | 71 | Two small fixes in OM/Pi. |
68 | 72 | ||
69 | Better resizing of the new datenavigator in KO/Pi. | 73 | Better resizing of the new datenavigator in KO/Pi. |
70 | 74 | ||
71 | ********** VERSION 2.0.19 ************ | 75 | ********** VERSION 2.0.19 ************ |
72 | KO/Pi: | 76 | KO/Pi: |
73 | Enhancements and bugfixes in the new datenavigator. | 77 | Enhancements and bugfixes in the new datenavigator. |
74 | Bugfix in this changelog: | 78 | Bugfix in this changelog: |
75 | The datenavigator was changed in version 2.0.18, not the datepicker. | 79 | The datenavigator was changed in version 2.0.18, not the datepicker. |
76 | 80 | ||
77 | ********** VERSION 2.0.18 ************ | 81 | ********** VERSION 2.0.18 ************ |
78 | KO/Pi: | 82 | KO/Pi: |
79 | Fixed some minor problems. | 83 | Fixed some minor problems. |
80 | Cleaned up the KO/Pi config dialog. | 84 | Cleaned up the KO/Pi config dialog. |
81 | Fixed problem moving events in aganda view. | 85 | Fixed problem moving events in aganda view. |
82 | Made datepicker scaleable, i.e. if the datenavigator shows now a | 86 | Made datepicker scaleable, i.e. if the datenavigator shows now a |
83 | datenavigator matrix depending on its size. | 87 | datenavigator matrix depending on its size. |
84 | Birthdays are now displayed green in the datenavigator. | 88 | Birthdays are now displayed green in the datenavigator. |
85 | What'sThis Help in datenavigator shows all events of the day. | 89 | What'sThis Help in datenavigator shows all events of the day. |
86 | 90 | ||
87 | OM/Pi: | 91 | OM/Pi: |
88 | Updated the backend mail library to the latest version. | 92 | Updated the backend mail library to the latest version. |
89 | Please backup your mail before using this version. | 93 | Please backup your mail before using this version. |
90 | 94 | ||
91 | ********** VERSION 2.0.17 ************ | 95 | ********** VERSION 2.0.17 ************ |
92 | 96 | ||
93 | KO/Pi: | 97 | KO/Pi: |
94 | Tooltips in month view were not sorted. Fixed. | 98 | Tooltips in month view were not sorted. Fixed. |
95 | Daylabel in agenda view ( for display of one day ) was too short. Fixed. | 99 | Daylabel in agenda view ( for display of one day ) was too short. Fixed. |
96 | Conflict display dialog for syncing was not on top of other windows. Fixed. | 100 | Conflict display dialog for syncing was not on top of other windows. Fixed. |
97 | Fixed some minor problems. | 101 | Fixed some minor problems. |
98 | 102 | ||
99 | Fixed an endless loop when importing vcs file with RESOURCES entry. | 103 | Fixed an endless loop when importing vcs file with RESOURCES entry. |
100 | 104 | ||
101 | ********** VERSION 2.0.16 ************ | 105 | ********** VERSION 2.0.16 ************ |
102 | OM/Pi: | 106 | OM/Pi: |
103 | Fixed the SMTP account setting the option. | 107 | Fixed the SMTP account setting the option. |
104 | Fixed something in mail sending. | 108 | Fixed something in mail sending. |
105 | 109 | ||
106 | KO/Pi: | 110 | KO/Pi: |
107 | Added possibility to export selected events/todos as vcal file. | 111 | Added possibility to export selected events/todos as vcal file. |
108 | 112 | ||
109 | ********** VERSION 2.0.15 ************ | 113 | ********** VERSION 2.0.15 ************ |
110 | 114 | ||
111 | PwM/Pi: | 115 | PwM/Pi: |
112 | Added keyboard shorcuts for | 116 | Added keyboard shorcuts for |
113 | - toggling summary view (space bar) | 117 | - toggling summary view (space bar) |
114 | - delete item (delete + backspace key) | 118 | - delete item (delete + backspace key) |
115 | - add new item ( i + n key) | 119 | - add new item ( i + n key) |
116 | Fixed length of info in the title. | 120 | Fixed length of info in the title. |
117 | 121 | ||
118 | KO/Pi-KA/Pi: | 122 | KO/Pi-KA/Pi: |
119 | Changed "ME" menu bar entry to an icon. | 123 | Changed "ME" menu bar entry to an icon. |
120 | 124 | ||
121 | KO/Pi: | 125 | KO/Pi: |
122 | Fixed two minor bugs in displaying todos. | 126 | Fixed two minor bugs in displaying todos. |
123 | If in month view a cell is selected, the key shortcut "d" shows now that date. | 127 | If in month view a cell is selected, the key shortcut "d" shows now that date. |
124 | Added complete info for a todo in month view as an icon left of the text. | 128 | Added complete info for a todo in month view as an icon left of the text. |
125 | Fixed problems of displaying data when "<" or ">" are used in summary/location/description. | 129 | Fixed problems of displaying data when "<" or ">" are used in summary/location/description. |
126 | Fixed problem of search dialog size when switching displays. | 130 | Fixed problem of search dialog size when switching displays. |
127 | Cancel key now closes date picker. | 131 | Cancel key now closes date picker. |
128 | Rearranged KO/Pi file menu structure. | 132 | Rearranged KO/Pi file menu structure. |
129 | 133 | ||
130 | OM/Pi: | 134 | OM/Pi: |
131 | Added to the SMTP account setting the option | 135 | Added to the SMTP account setting the option |
132 | "No secure connection". | 136 | "No secure connection". |
133 | You have to configure your SMTP accounts again, sorry. | 137 | You have to configure your SMTP accounts again, sorry. |
134 | 138 | ||
135 | KA/Pi: | 139 | KA/Pi: |
136 | Added support for importing quoted-printable. | 140 | Added support for importing quoted-printable. |
137 | Support was added by Peter P.. Thanks, Peter! | 141 | Support was added by Peter P.. Thanks, Peter! |
138 | 142 | ||
139 | 143 | ||
140 | ********** VERSION 2.0.14 ************ | 144 | ********** VERSION 2.0.14 ************ |
141 | 145 | ||
142 | Made Passwordmanager PwM/Pi more userfriendly: | 146 | Made Passwordmanager PwM/Pi more userfriendly: |
143 | Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more. | 147 | Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more. |
144 | Fixed bug in KO/Pi todo printing. | 148 | Fixed bug in KO/Pi todo printing. |
145 | Made Qtopia calendar import possible on desktop . | 149 | Made Qtopia calendar import possible on desktop . |
146 | 150 | ||
147 | ********** VERSION 2.0.13 ************ | 151 | ********** VERSION 2.0.13 ************ |
148 | 152 | ||
149 | Fixed a problem in the addressee select dialog and made it more user friendly by adding a minimize splitter. | 153 | Fixed a problem in the addressee select dialog and made it more user friendly by adding a minimize splitter. |
150 | 154 | ||
151 | In the search dialog you can switch now the focus from search line edit to the list view by pressing key "arrow down". | 155 | In the search dialog you can switch now the focus from search line edit to the list view by pressing key "arrow down". |
152 | 156 | ||
153 | OM/Pi: | 157 | OM/Pi: |
154 | Fixed a refresh problem of outgoing/sent/sendfailed folders after sending mails. | 158 | Fixed a refresh problem of outgoing/sent/sendfailed folders after sending mails. |
155 | Added missing German translation. | 159 | Added missing German translation. |
156 | Added warning if path is specified in local folder settings of account config. | 160 | Added warning if path is specified in local folder settings of account config. |
157 | 161 | ||
158 | ********** VERSION 2.0.12 ************ | 162 | ********** VERSION 2.0.12 ************ |
159 | 163 | ||
160 | KO/Pi: | 164 | KO/Pi: |
161 | Fixed a bug in todo start/due date handling for non recurring todos with a start and due date. | 165 | Fixed a bug in todo start/due date handling for non recurring todos with a start and due date. |
162 | Fixed some layout problems in the KO/Pi agenda view when there were many conflicting itmes. | 166 | Fixed some layout problems in the KO/Pi agenda view when there were many conflicting itmes. |
163 | Fixed several problems of the keyboard focus in the desktop versions when opening the search dialog/event viewer. | 167 | Fixed several problems of the keyboard focus in the desktop versions when opening the search dialog/event viewer. |
164 | 168 | ||
165 | Fixed problem in pi-sync mode when wrong password was sent. | 169 | Fixed problem in pi-sync mode when wrong password was sent. |
166 | 170 | ||
167 | OM/Pi: | 171 | OM/Pi: |
168 | Fixed a crash when displaying mails with "Show mail as html" was checked in the config. | 172 | Fixed a crash when displaying mails with "Show mail as html" was checked in the config. |
169 | Added a check before displaying the mail if the mail is in html format, if "Show mail as html" is enabled. | 173 | Added a check before displaying the mail if the mail is in html format, if "Show mail as html" is enabled. |
170 | 174 | ||
171 | ********** VERSION 2.0.11 ************ | 175 | ********** VERSION 2.0.11 ************ |
172 | 176 | ||
173 | Fixed some problems in pi-sync mode | 177 | Fixed some problems in pi-sync mode |
174 | (e.g. details of events were not synced properly) | 178 | (e.g. details of events were not synced properly) |
175 | 179 | ||
176 | ********** VERSION 2.0.10 ************ | 180 | ********** VERSION 2.0.10 ************ |
177 | 181 | ||
178 | KO/Pi: | 182 | KO/Pi: |
179 | In the desktop versions the context menu in the search dialog was broken after introducing the What'sThis info for the list view. | 183 | In the desktop versions the context menu in the search dialog was broken after introducing the What'sThis info for the list view. |
180 | This is fixed. | 184 | This is fixed. |
181 | Changed the search dialog a bit to make it more user friendly. | 185 | Changed the search dialog a bit to make it more user friendly. |
182 | (E.g.: Removed message box about "no items found" and set key focus to search line edit after search). | 186 | (E.g.: Removed message box about "no items found" and set key focus to search line edit after search). |
183 | 187 | ||
184 | Added config option to hide the week number in KO/Pi toolbar. | 188 | Added config option to hide the week number in KO/Pi toolbar. |
185 | 189 | ||
186 | ********** VERSION 2.0.9 ************ | 190 | ********** VERSION 2.0.9 ************ |
187 | 191 | ||
188 | Made month view icons for multiday events a bit nicer. | 192 | Made month view icons for multiday events a bit nicer. |
189 | Some minor fixes in KO/Pi | 193 | Some minor fixes in KO/Pi |
190 | (e.g. go to today did not work for new week view properly). | 194 | (e.g. go to today did not work for new week view properly). |
191 | 195 | ||
192 | 196 | ||
193 | ********** VERSION 2.0.8 ************ | 197 | ********** VERSION 2.0.8 ************ |
194 | 198 | ||
195 | Fixed a problem in dependency info in the ipk files for the Zaurus. | 199 | Fixed a problem in dependency info in the ipk files for the Zaurus. |
196 | 200 | ||
197 | 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. | 201 | 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. |
198 | 202 | ||
199 | Added a "go today" button to the datepicker. | 203 | Added a "go today" button to the datepicker. |
200 | 204 | ||
201 | Added "created" and "last modified" to event/todo viewer (and What'sThis viewer) | 205 | Added "created" and "last modified" to event/todo viewer (and What'sThis viewer) |
202 | and made it configureable to show these values. | 206 | and made it configureable to show these values. |
203 | 207 | ||
204 | Fixed a problem for events (from external iCal files) that do have a duration but no end date. | 208 | Fixed a problem for events (from external iCal files) that do have a duration but no end date. |
205 | 209 | ||
206 | 210 | ||
207 | ********** VERSION 2.0.7 ************ | 211 | ********** VERSION 2.0.7 ************ |
208 | 212 | ||
209 | Added global application font settings | 213 | Added global application font settings |
210 | (for all KDE-Pim/Pi apps) to the general settings. | 214 | (for all KDE-Pim/Pi apps) to the general settings. |
211 | 215 | ||
212 | Fixed a problem in OM/Pi when trying to login to some IMAP servers | 216 | Fixed a problem in OM/Pi when trying to login to some IMAP servers |
213 | (like the IMAP server of Apple: mail.mac.com ) | 217 | (like the IMAP server of Apple: mail.mac.com ) |
214 | 218 | ||
215 | Added recurring todos to KO/Pi. | 219 | Added recurring todos to KO/Pi. |
216 | 220 | ||
217 | 221 | ||
218 | ********** VERSION 2.0.6 ************ | 222 | ********** VERSION 2.0.6 ************ |
219 | 223 | ||
220 | Stable release 2.0.6! | 224 | Stable release 2.0.6! |
221 | 225 | ||
222 | Some bugfixes in the pi-sync mode. | 226 | Some bugfixes in the pi-sync mode. |
223 | Added German translation for pi-sync mode. | 227 | Added German translation for pi-sync mode. |
224 | 228 | ||
225 | KO/Pi: | 229 | KO/Pi: |
226 | Made the todolist using alternate background. | 230 | Made the todolist using alternate background. |
227 | 231 | ||
228 | Other minor fixes in KO/Pi. | 232 | Other minor fixes in KO/Pi. |
229 | 233 | ||
230 | 234 | ||
231 | You can find the complete changelog | 235 | You can find the complete changelog |
232 | from version 1.7.7 to 2.0.5 | 236 | from version 1.7.7 to 2.0.5 |
233 | in the source package or on | 237 | in the source package or on |
234 | 238 | ||
235 | http://www.pi-sync.net/html/changelog.html | 239 | http://www.pi-sync.net/html/changelog.html |
236 | 240 | ||
237 | 241 | ||
238 | 242 | ||
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp index 92abae6..e57daa4 100644 --- a/korganizer/datenavigatorcontainer.cpp +++ b/korganizer/datenavigatorcontainer.cpp | |||
@@ -42,398 +42,402 @@ DateNavigatorContainer::DateNavigatorContainer( QWidget *parent, | |||
42 | { | 42 | { |
43 | mResizeEnabled = false; | 43 | mResizeEnabled = false; |
44 | mExtraViews.setAutoDelete( true ); | 44 | mExtraViews.setAutoDelete( true ); |
45 | 45 | ||
46 | mNavigatorView = new KDateNavigator( this, name ); | 46 | mNavigatorView = new KDateNavigator( this, name ); |
47 | mNavigatorView->hide(); | 47 | mNavigatorView->hide(); |
48 | connectNavigatorView( mNavigatorView ); | 48 | connectNavigatorView( mNavigatorView ); |
49 | //setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 49 | //setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
50 | mLastDisplayedDN = 0; | 50 | mLastDisplayedDN = 0; |
51 | mUpdateTimer; | 51 | mUpdateTimer; |
52 | mUpdateTimer = new QTimer( this ); | 52 | mUpdateTimer = new QTimer( this ); |
53 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( checkUpdateDayMatrixDates() )); | 53 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( checkUpdateDayMatrixDates() )); |
54 | mFirstSelectedDate = QDate::currentDate(); | 54 | mFirstSelectedDate = QDate::currentDate(); |
55 | mSelectedDateCount = 1; | 55 | mSelectedDateCount = 1; |
56 | } | 56 | } |
57 | 57 | ||
58 | DateNavigatorContainer::~DateNavigatorContainer() | 58 | DateNavigatorContainer::~DateNavigatorContainer() |
59 | { | 59 | { |
60 | } | 60 | } |
61 | 61 | ||
62 | void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v ) | 62 | void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v ) |
63 | { | 63 | { |
64 | connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ), | 64 | connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ), |
65 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); | 65 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); |
66 | #if 0 | 66 | #if 0 |
67 | connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ), | 67 | connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ), |
68 | SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) ); | 68 | SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) ); |
69 | connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ), | 69 | connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ), |
70 | SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) ); | 70 | SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) ); |
71 | #endif | 71 | #endif |
72 | connect( v, SIGNAL( weekClicked( const QDate & ) ), | 72 | connect( v, SIGNAL( weekClicked( const QDate & ) ), |
73 | SIGNAL( weekClicked( const QDate & ) ) ); | 73 | SIGNAL( weekClicked( const QDate & ) ) ); |
74 | connect( v, SIGNAL( showMonth( const QDate & ) ), | 74 | connect( v, SIGNAL( showMonth( const QDate & ) ), |
75 | SIGNAL( showMonth( const QDate & ) ) ); | 75 | SIGNAL( showMonth( const QDate & ) ) ); |
76 | 76 | ||
77 | connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) ); | 77 | connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) ); |
78 | connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) ); | 78 | connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) ); |
79 | 79 | ||
80 | connect( v, SIGNAL( goNextMonth() ), SLOT( slotgoNextMonth() ) ); | 80 | connect( v, SIGNAL( goNextMonth() ), SLOT( slotgoNextMonth() ) ); |
81 | connect( v, SIGNAL( goPrevMonth() ), SLOT( slotgoPrevMonth() ) ); | 81 | connect( v, SIGNAL( goPrevMonth() ), SLOT( slotgoPrevMonth() ) ); |
82 | connect( v, SIGNAL( goNextYear() ), SLOT( slotgoNextYear() ) ); | 82 | connect( v, SIGNAL( goNextYear() ), SLOT( slotgoNextYear() ) ); |
83 | connect( v, SIGNAL( goPrevYear() ), SLOT( slotgoPrevYear() ) ); | 83 | connect( v, SIGNAL( goPrevYear() ), SLOT( slotgoPrevYear() ) ); |
84 | 84 | ||
85 | connect( v, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); | 85 | connect( v, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); |
86 | } | 86 | } |
87 | void DateNavigatorContainer::slotgoNextYear() | 87 | void DateNavigatorContainer::slotgoNextYear() |
88 | { | 88 | { |
89 | jumpMonth( 12 ); | 89 | jumpMonth( 12 ); |
90 | emit goNextYear(); | 90 | emit goNextYear(); |
91 | 91 | ||
92 | } | 92 | } |
93 | void DateNavigatorContainer::slotgoPrevYear() | 93 | void DateNavigatorContainer::slotgoPrevYear() |
94 | { | 94 | { |
95 | jumpMonth( -12 ); | 95 | jumpMonth( -12 ); |
96 | emit goPrevYear(); | 96 | emit goPrevYear(); |
97 | 97 | ||
98 | } | 98 | } |
99 | void DateNavigatorContainer::slotgoPrevMonth() | 99 | void DateNavigatorContainer::slotgoPrevMonth() |
100 | { | 100 | { |
101 | jumpMonth( -1 ); | 101 | jumpMonth( -1 ); |
102 | emit goPrevMonth(); | 102 | emit goPrevMonth(); |
103 | 103 | ||
104 | } | 104 | } |
105 | void DateNavigatorContainer::slotgoNextMonth() | 105 | void DateNavigatorContainer::slotgoNextMonth() |
106 | { | 106 | { |
107 | jumpMonth( 1 ); | 107 | jumpMonth( 1 ); |
108 | emit goNextMonth(); | 108 | emit goNextMonth(); |
109 | } | 109 | } |
110 | void DateNavigatorContainer::jumpMonth( int month ) | 110 | void DateNavigatorContainer::jumpMonth( int month ) |
111 | { | 111 | { |
112 | 112 | ||
113 | QDate baseDate = mNavigatorView->baseDate(); | 113 | QDate baseDate = mNavigatorView->baseDate(); |
114 | computeMonthSelected( baseDate.month() + month, false ); | 114 | computeMonthSelected( baseDate.month() + month, false ); |
115 | } | 115 | } |
116 | void DateNavigatorContainer::slotMonthSelected( int month ) | 116 | void DateNavigatorContainer::slotMonthSelected( int month ) |
117 | { | 117 | { |
118 | computeMonthSelected( month, true ); | 118 | computeMonthSelected( month, true ); |
119 | } | 119 | } |
120 | void DateNavigatorContainer::computeMonthSelected( int month , bool forceEmit ) | 120 | void DateNavigatorContainer::computeMonthSelected( int month , bool forceEmit ) |
121 | { | 121 | { |
122 | //qDebug("slotMonthSelected %d ", month); | 122 | //qDebug("slotMonthSelected %d ", month); |
123 | QDate baseDate = mNavigatorView->baseDate(); | 123 | QDate baseDate = mNavigatorView->baseDate(); |
124 | if ( baseDate.month() == month ) | 124 | if ( baseDate.month() == month ) |
125 | return; | 125 | return; |
126 | //qDebug("month %d %d ",baseDate.month(),month); | 126 | //qDebug("month %d %d ",baseDate.month(),month); |
127 | QDate date = QDate ( baseDate.year(), baseDate.month() , 15 ); | 127 | QDate date = QDate ( baseDate.year(), baseDate.month() , 15 ); |
128 | date = date.addDays( -(baseDate.month()-month ) *30 ); | 128 | date = date.addDays( -(baseDate.month()-month ) *30 ); |
129 | QDate newBase = QDate ( date.year(), date.month() ,1 ); | 129 | QDate newBase = QDate ( date.year(), date.month() ,1 ); |
130 | 130 | ||
131 | //qDebug("NEW BASE %s", newBase.toString().latin1()); | 131 | //qDebug("NEW BASE %s", newBase.toString().latin1()); |
132 | mNavigatorView->setBaseDate( newBase ); | 132 | mNavigatorView->setBaseDate( newBase ); |
133 | QDate last = lastAvailableDate(); | 133 | QDate last = lastAvailableDate(); |
134 | QDate first = firstAvailableDate(); | 134 | QDate first = firstAvailableDate(); |
135 | 135 | ||
136 | QDate selFirst = mFirstSelectedDate; | 136 | QDate selFirst = mFirstSelectedDate; |
137 | QDate selLast = selFirst.addDays( mSelectedDateCount-1 ); | 137 | QDate selLast = selFirst.addDays( mSelectedDateCount-1 ); |
138 | if ( selFirst >= first && selLast <= last ) { | 138 | if ( selFirst >= first && selLast <= last ) { |
139 | setBaseDates(); | 139 | setBaseDates(); |
140 | if ( forceEmit ) | 140 | if ( forceEmit ) |
141 | updateDayMatrixDates(); | 141 | updateDayMatrixDates(); |
142 | } | 142 | } |
143 | else { | 143 | else { |
144 | setBaseDates(); | 144 | setBaseDates(); |
145 | if ( forceEmit ) | 145 | if ( forceEmit ) |
146 | updateDayMatrixDates(); | 146 | updateDayMatrixDates(); |
147 | if ( forceEmit ) | 147 | if ( forceEmit ) |
148 | emit monthSelected( month ); | 148 | emit monthSelected( month ); |
149 | } | 149 | } |
150 | } | 150 | } |
151 | void DateNavigatorContainer::setCalendar( Calendar *cal ) | 151 | void DateNavigatorContainer::setCalendar( Calendar *cal ) |
152 | { | 152 | { |
153 | mCalendar = cal; | 153 | mCalendar = cal; |
154 | mNavigatorView->setCalendar( cal ); | 154 | mNavigatorView->setCalendar( cal ); |
155 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { | 155 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { |
156 | KDateNavigator *n = mExtraViews.at( i ); | 156 | KDateNavigator *n = mExtraViews.at( i ); |
157 | n->setCalendar( cal ); | 157 | n->setCalendar( cal ); |
158 | } | 158 | } |
159 | } | 159 | } |
160 | void DateNavigatorContainer::checkUpdateDayMatrixDates() | 160 | void DateNavigatorContainer::checkUpdateDayMatrixDates() |
161 | { | 161 | { |
162 | //qDebug("KODNC: wid %d hei %d ", width(), height()); | 162 | //qDebug("KODNC: wid %d hei %d ", width(), height()); |
163 | mUpdateTimer->stop(); | 163 | mUpdateTimer->stop(); |
164 | //return; | 164 | //return; |
165 | if ( width() < 3 || height() < 3 ) | 165 | if ( width() < 3 || height() < 3 ) |
166 | return; | 166 | return; |
167 | static int lastWid = 0; | 167 | static int lastWid = 0; |
168 | static int lastHei = 0; | 168 | static int lastHei = 0; |
169 | if ( lastWid == width() && height() == lastHei ) { | 169 | if ( lastWid == width() && height() == lastHei ) { |
170 | qDebug("KODNC: No layout computing needed. "); | 170 | qDebug("KODNC: No layout computing needed. "); |
171 | } else { | 171 | } else { |
172 | lastWid = width(); | 172 | lastWid = width(); |
173 | lastHei = height(); | 173 | lastHei = height(); |
174 | 174 | ||
175 | QSize minSize = mNavigatorView->yourSizeHint(); | 175 | QSize minSize = mNavigatorView->yourSizeHint(); |
176 | 176 | ||
177 | int verticalCount = size().height() / minSize.height(); | 177 | int verticalCount = size().height() / minSize.height(); |
178 | int horizontalCount = size().width() / minSize.width(); | 178 | int horizontalCount = size().width() / minSize.width(); |
179 | //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() ); | 179 | //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() ); |
180 | //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); | 180 | //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); |
181 | bool fontchange = false; | 181 | bool fontchange = false; |
182 | if ( horizontalCount == 1) | 182 | if ( horizontalCount == 1) |
183 | horizontalCount = size().width() / mNavigatorView->yourFullSizeHint().width(); | 183 | horizontalCount = size().width() / mNavigatorView->yourFullSizeHint().width(); |
184 | QFont fo; | 184 | QFont fo; |
185 | if ( horizontalCount != mHorizontalCount || | 185 | if ( horizontalCount != mHorizontalCount || |
186 | verticalCount != mVerticalCount ) { | 186 | verticalCount != mVerticalCount ) { |
187 | uint count = horizontalCount * verticalCount; | 187 | uint count = horizontalCount * verticalCount; |
188 | if ( count == 0 ) { | 188 | if ( count == 0 ) { |
189 | bool ok; | 189 | bool ok; |
190 | fo = mNavigatorView->yourFontHint( size() , &ok ); | 190 | fo = mNavigatorView->yourFontHint( size() , &ok ); |
191 | //mNavigatorView->resize( size() ); | 191 | //mNavigatorView->resize( size() ); |
192 | //if ( ! ok ) | 192 | //if ( ! ok ) |
193 | // return; | 193 | // return; |
194 | int butt = 2; | 194 | int butt = 2; |
195 | horizontalCount = size().width() / mNavigatorView->sizeHintTwoButtons( ).width(); | 195 | horizontalCount = size().width() / mNavigatorView->sizeHintTwoButtons( ).width(); |
196 | if ( horizontalCount <= 1 ) | 196 | if ( horizontalCount <= 1 ) |
197 | minSize = mNavigatorView->sizeHintTwoButtons( 4 ); | 197 | minSize = mNavigatorView->sizeHintTwoButtons( 4 ); |
198 | else | 198 | else |
199 | minSize = mNavigatorView->sizeHintTwoButtons(); | 199 | minSize = mNavigatorView->sizeHintTwoButtons(); |
200 | verticalCount = size().height() / minSize.height(); | 200 | verticalCount = size().height() / minSize.height(); |
201 | horizontalCount = size().width() / minSize.width(); | 201 | horizontalCount = size().width() / minSize.width(); |
202 | if ( horizontalCount == 0 ) | 202 | if ( horizontalCount == 0 ) |
203 | horizontalCount = 1; | 203 | horizontalCount = 1; |
204 | if ( verticalCount == 0 ) | 204 | if ( verticalCount == 0 ) |
205 | verticalCount = 1; | 205 | verticalCount = 1; |
206 | fontchange = true; | 206 | fontchange = true; |
207 | count = horizontalCount * verticalCount; | 207 | count = horizontalCount * verticalCount; |
208 | } else { | 208 | } else { |
209 | if ( mNavigatorView->fontChanged() ) { | 209 | if ( mNavigatorView->fontChanged() ) { |
210 | fontchange = true; | 210 | fontchange = true; |
211 | fo = KOPrefs::instance()->mDateNavigatorFont; | 211 | fo = KOPrefs::instance()->mDateNavigatorFont; |
212 | mNavigatorView->changeFont( fo ); | 212 | mNavigatorView->changeFont( fo ); |
213 | mNavigatorView->unsetFontChanged(); | 213 | mNavigatorView->unsetFontChanged(); |
214 | } | 214 | } |
215 | } | 215 | } |
216 | mLastDisplayedDN = horizontalCount*verticalCount-1; | 216 | mLastDisplayedDN = horizontalCount*verticalCount-1; |
217 | while ( count > ( mExtraViews.count() + 1 ) ) { | 217 | while ( count > ( mExtraViews.count() + 1 ) ) { |
218 | KDateNavigator *n = new KDateNavigator( this ); | 218 | KDateNavigator *n = new KDateNavigator( this ); |
219 | n->setMonthSignalOffset ( mExtraViews.count()+1 ); | 219 | n->setMonthSignalOffset ( mExtraViews.count()+1 ); |
220 | mExtraViews.append( n ); | 220 | mExtraViews.append( n ); |
221 | n->setCalendar( mCalendar ); | 221 | n->setCalendar( mCalendar ); |
222 | connectNavigatorView( n ); | 222 | connectNavigatorView( n ); |
223 | // n->show(); | 223 | // n->show(); |
224 | } | 224 | } |
225 | 225 | ||
226 | setBaseDates(); | 226 | setBaseDates(); |
227 | if ( fontchange ) { | 227 | if ( fontchange ) { |
228 | //mNavigatorView->changeFont( fo ); | 228 | //mNavigatorView->changeFont( fo ); |
229 | uint i; | 229 | uint i; |
230 | for( i = 0; i < mExtraViews.count(); ++i ) { | 230 | for( i = 0; i < mExtraViews.count(); ++i ) { |
231 | KDateNavigator *view = mExtraViews.at( i ); | 231 | KDateNavigator *view = mExtraViews.at( i ); |
232 | view->changeFont( fo ); | 232 | view->changeFont( fo ); |
233 | } | 233 | } |
234 | } | 234 | } |
235 | mHorizontalCount = horizontalCount; | 235 | mHorizontalCount = horizontalCount; |
236 | mVerticalCount = verticalCount; | 236 | mVerticalCount = verticalCount; |
237 | 237 | ||
238 | } | 238 | } |
239 | if ( mNavigatorView->fontChanged() && ! fontchange ) { | 239 | if ( mNavigatorView->fontChanged() && ! fontchange ) { |
240 | qDebug("KDNC: Resetting all fonts "); | 240 | qDebug("KDNC: Resetting all fonts "); |
241 | fo = KOPrefs::instance()->mDateNavigatorFont; | 241 | fo = KOPrefs::instance()->mDateNavigatorFont; |
242 | mNavigatorView->changeFont( fo ); | 242 | mNavigatorView->changeFont( fo ); |
243 | mNavigatorView->unsetFontChanged(); | 243 | mNavigatorView->unsetFontChanged(); |
244 | uint i; | 244 | uint i; |
245 | for( i = 0; i < mExtraViews.count(); ++i ) { | 245 | for( i = 0; i < mExtraViews.count(); ++i ) { |
246 | KDateNavigator *view = mExtraViews.at( i ); | 246 | KDateNavigator *view = mExtraViews.at( i ); |
247 | view->changeFont( fo ); | 247 | view->changeFont( fo ); |
248 | } | 248 | } |
249 | } | 249 | } |
250 | int theight = height() / mVerticalCount; | 250 | int theight = height() / mVerticalCount; |
251 | int twidth = width() / mHorizontalCount; | 251 | int twidth = width() / mHorizontalCount; |
252 | 252 | ||
253 | NavigatorBar *bar = mNavigatorView->navigatorBar(); | 253 | NavigatorBar *bar = mNavigatorView->navigatorBar(); |
254 | if ( mHorizontalCount > 1 ) bar->showButtons( true, false ); | 254 | if ( mHorizontalCount > 1 ) bar->showButtons( true, false ); |
255 | else bar->showButtons( true, true ); | 255 | else bar->showButtons( true, true ); |
256 | 256 | ||
257 | mNavigatorView->setGeometry(0, | 257 | mNavigatorView->setGeometry(0, |
258 | 0, twidth, theight ); | 258 | 0, twidth, theight ); |
259 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { | 259 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { |
260 | int x = ( i + 1 ) % mHorizontalCount; | 260 | int x = ( i + 1 ) % mHorizontalCount; |
261 | int y = ( i + 1 ) / mHorizontalCount; | 261 | int y = ( i + 1 ) / mHorizontalCount; |
262 | 262 | ||
263 | KDateNavigator *view = mExtraViews.at( i ); | 263 | KDateNavigator *view = mExtraViews.at( i ); |
264 | bar = view->navigatorBar(); | 264 | bar = view->navigatorBar(); |
265 | if ( y > 0 ) bar->showButtons( false, false ); | 265 | if ( y > 0 ) bar->showButtons( false, false ); |
266 | else { | 266 | else { |
267 | if ( x + 1 == mHorizontalCount ) bar->showButtons( false, true ); | 267 | if ( x + 1 == mHorizontalCount ) bar->showButtons( false, true ); |
268 | else bar->showButtons( false, false ); | 268 | else bar->showButtons( false, false ); |
269 | } | 269 | } |
270 | view->setGeometry( x * twidth, | 270 | view->setGeometry( x * twidth, |
271 | y * theight, twidth, theight ); | 271 | y * theight, twidth, theight ); |
272 | } | 272 | } |
273 | int iii = 0; | 273 | int iii = 0; |
274 | int ccc = mHorizontalCount * mVerticalCount; | 274 | int ccc = mHorizontalCount * mVerticalCount; |
275 | mNavigatorView->show(); | 275 | mNavigatorView->show(); |
276 | while ( iii < ( mExtraViews.count() ) ) { | 276 | while ( iii < ( mExtraViews.count() ) ) { |
277 | if ( iii < ccc-1 ) | 277 | if ( iii < ccc-1 ) |
278 | mExtraViews.at( iii )->show(); | 278 | mExtraViews.at( iii )->show(); |
279 | else | 279 | else |
280 | mExtraViews.at( iii )->hide(); | 280 | mExtraViews.at( iii )->hide(); |
281 | ++iii; | 281 | ++iii; |
282 | } | 282 | } |
283 | } | 283 | } |
284 | 284 | ||
285 | QDate last = lastAvailableDate(); | 285 | QDate last = lastAvailableDate(); |
286 | QDate first = firstAvailableDate(); | 286 | QDate first = firstAvailableDate(); |
287 | 287 | ||
288 | QDate selFirst = mFirstSelectedDate; | 288 | QDate selFirst = mFirstSelectedDate; |
289 | QDate selLast = selFirst.addDays( mSelectedDateCount-1 ); | 289 | QDate selLast = selFirst.addDays( mSelectedDateCount-1 ); |
290 | if ( selFirst >= first && selLast <= last ) { | 290 | if ( selFirst >= first && selLast <= last ) { |
291 | updateDayMatrixDates(); | 291 | updateDayMatrixDates(); |
292 | } | 292 | } |
293 | else { | 293 | else { |
294 | updateDayMatrixDates(); | 294 | updateDayMatrixDates(); |
295 | emit monthSelected( mFirstSelectedDate.month() ); | 295 | emit monthSelected( mFirstSelectedDate.month() ); |
296 | } | 296 | } |
297 | } | 297 | } |
298 | void DateNavigatorContainer::updateDayMatrixDates() | 298 | void DateNavigatorContainer::updateDayMatrixDates() |
299 | { | 299 | { |
300 | QDate fDate = mFirstSelectedDate; | 300 | QDate fDate = mFirstSelectedDate; |
301 | QDate lDate = fDate.addDays( mSelectedDateCount - 1 ); | 301 | QDate lDate = fDate.addDays( mSelectedDateCount - 1 ); |
302 | mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate ); | 302 | mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate ); |
303 | mNavigatorView->dayMatrix()->repaint( false ); | 303 | mNavigatorView->dayMatrix()->repaint( false ); |
304 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { | 304 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { |
305 | KDateNavigator *n = mExtraViews.at( i ); | 305 | KDateNavigator *n = mExtraViews.at( i ); |
306 | if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) { | 306 | if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) { |
307 | n->dayMatrix()->repaint( false ); | 307 | n->dayMatrix()->repaint( false ); |
308 | } | 308 | } |
309 | } | 309 | } |
310 | } | 310 | } |
311 | 311 | ||
312 | void DateNavigatorContainer::updateDayMatrix() | 312 | void DateNavigatorContainer::updateDayMatrix() |
313 | { | 313 | { |
314 | mNavigatorView->updateDayMatrix(); | 314 | mNavigatorView->updateDayMatrix(); |
315 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { | 315 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { |
316 | KDateNavigator *n = mExtraViews.at( i ); | 316 | KDateNavigator *n = mExtraViews.at( i ); |
317 | n->updateDayMatrix(); | 317 | n->updateDayMatrix(); |
318 | } | 318 | } |
319 | } | 319 | } |
320 | 320 | ||
321 | void DateNavigatorContainer::updateToday() | 321 | void DateNavigatorContainer::updateToday() |
322 | { | 322 | { |
323 | qDebug("DateNavigatorContainer::updateToday() NOT IMPL "); | 323 | qDebug("DateNavigatorContainer::updateToday() NOT IMPL "); |
324 | #if 0 | 324 | #if 0 |
325 | mNavigatorView->updateToday(); | 325 | mNavigatorView->updateToday(); |
326 | KDateNavigator *n; | 326 | KDateNavigator *n; |
327 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 327 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
328 | n->updateToday(); | 328 | n->updateToday(); |
329 | } | 329 | } |
330 | #endif | 330 | #endif |
331 | } | 331 | } |
332 | 332 | ||
333 | void DateNavigatorContainer::updateView() | 333 | void DateNavigatorContainer::updateView() |
334 | { | 334 | { |
335 | mNavigatorView->updateView(); | 335 | mNavigatorView->updateView(); |
336 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { | 336 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { |
337 | KDateNavigator *n = mExtraViews.at( i ); | 337 | KDateNavigator *n = mExtraViews.at( i ); |
338 | n->updateView(); | 338 | n->updateView(); |
339 | } | 339 | } |
340 | } | 340 | } |
341 | 341 | ||
342 | void DateNavigatorContainer::updateConfig() | 342 | void DateNavigatorContainer::updateConfig() |
343 | { | 343 | { |
344 | mNavigatorView->updateConfig(); | 344 | mNavigatorView->updateConfig(); |
345 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { | 345 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { |
346 | KDateNavigator *n = mExtraViews.at( i ); | 346 | KDateNavigator *n = mExtraViews.at( i ); |
347 | n->updateConfig(); | 347 | n->updateConfig(); |
348 | } | 348 | } |
349 | } | 349 | } |
350 | QDate DateNavigatorContainer::lastAvailableDate() const | 350 | QDate DateNavigatorContainer::lastAvailableDate() const |
351 | { | 351 | { |
352 | QDate date = mNavigatorView->baseDate(); | 352 | QDate date = mNavigatorView->baseDate(); |
353 | QDate last = QDate ( date.year(), date.month(), date.daysInMonth() ); | 353 | QDate last = QDate ( date.year(), date.month(), date.daysInMonth() ); |
354 | int iii = mLastDisplayedDN; | 354 | int iii = mLastDisplayedDN; |
355 | if ( mLastDisplayedDN ) | 355 | if ( mLastDisplayedDN ) |
356 | last = last.addDays( 1); | 356 | last = last.addDays( 1); |
357 | while ( iii ) { | 357 | while ( iii ) { |
358 | last = last.addDays( last.daysInMonth ()); | 358 | last = last.addDays( last.daysInMonth ()); |
359 | //qDebug("DATE %s ", last.toString().latin1() ); | 359 | //qDebug("DATE %s ", last.toString().latin1() ); |
360 | --iii; | 360 | --iii; |
361 | } | 361 | } |
362 | if ( mLastDisplayedDN ) | 362 | if ( mLastDisplayedDN ) |
363 | last = last.addDays( -1); | 363 | last = last.addDays( -1); |
364 | return last; | 364 | return last; |
365 | } | 365 | } |
366 | QDate DateNavigatorContainer::firstAvailableDate() const | 366 | QDate DateNavigatorContainer::firstAvailableDate() const |
367 | { | 367 | { |
368 | return QDate ( mNavigatorView->baseDate().year(), mNavigatorView->baseDate().month(), 1 ); | 368 | return QDate ( mNavigatorView->baseDate().year(), mNavigatorView->baseDate().month(), 1 ); |
369 | } | 369 | } |
370 | void DateNavigatorContainer::selectDates( const DateList &dateList ) | 370 | void DateNavigatorContainer::selectDates( const DateList &dateList ) |
371 | { | 371 | { |
372 | mFirstSelectedDate = dateList.first() ; | 372 | mFirstSelectedDate = dateList.first() ; |
373 | mSelectedDateCount = dateList.count() ; | 373 | mSelectedDateCount = dateList.count() ; |
374 | if ( !mLastDisplayedDN ) { | 374 | if ( !mLastDisplayedDN ) { |
375 | mNavigatorView->selectDates( dateList ); | 375 | mNavigatorView->selectDates( dateList ); |
376 | return; | 376 | return; |
377 | } | 377 | } |
378 | QDate fDate = dateList.first(); | 378 | QDate fDate = dateList.first(); |
379 | QDate lDate = dateList.last(); | 379 | QDate lDate = dateList.last(); |
380 | //qDebug("%s %s ", lastAvailableDate().toString().latin1(), firstAvailableDate().toString().latin1() ); | 380 | //qDebug("%s %s ", lastAvailableDate().toString().latin1(), firstAvailableDate().toString().latin1() ); |
381 | //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() ); | 381 | //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() ); |
382 | if ( lDate <= lastAvailableDate() && firstAvailableDate() <= fDate) { | 382 | if ( lDate <= lastAvailableDate() && firstAvailableDate() <= fDate) { |
383 | updateDayMatrixDates(); | 383 | updateDayMatrixDates(); |
384 | return; | 384 | return; |
385 | } | 385 | } |
386 | mNavigatorView->selectDates( dateList ); | 386 | mNavigatorView->selectDates( dateList ); |
387 | setBaseDates(); | 387 | setBaseDates(); |
388 | if ( mLastDisplayedDN ) { | 388 | if ( mLastDisplayedDN ) { |
389 | KDateNavigator *view = mExtraViews.at( 0 ); | 389 | KDateNavigator *view = mExtraViews.at( 0 ); |
390 | view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); | 390 | view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); |
391 | view->dayMatrix()->repaint( false ); | 391 | view->dayMatrix()->repaint( false ); |
392 | if ( mLastDisplayedDN > 1 ) { | 392 | if ( mLastDisplayedDN > 1 ) { |
393 | KDateNavigator *view = mExtraViews.at( 1 ); | 393 | KDateNavigator *view = mExtraViews.at( 1 ); |
394 | view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); | 394 | view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); |
395 | view->dayMatrix()->repaint( false ); | 395 | view->dayMatrix()->repaint( false ); |
396 | } | 396 | } |
397 | } | 397 | } |
398 | } | 398 | } |
399 | 399 | ||
400 | void DateNavigatorContainer::setBaseDates() | 400 | void DateNavigatorContainer::setBaseDates() |
401 | { | 401 | { |
402 | QDate baseDate = mNavigatorView->baseDate(); | 402 | QDate baseDate = mNavigatorView->baseDate(); |
403 | bool doRepaint = true; | 403 | bool doRepaint = true; |
404 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { | 404 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { |
405 | KDateNavigator *n = mExtraViews.at( i ); | 405 | KDateNavigator *n = mExtraViews.at( i ); |
406 | baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 ); | 406 | baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 ); |
407 | n->setBaseDate( baseDate, doRepaint ); | 407 | n->setBaseDate( baseDate, doRepaint ); |
408 | } | 408 | } |
409 | } | 409 | } |
410 | void DateNavigatorContainer::setResizeEnabled() | 410 | void DateNavigatorContainer::setResizeEnabled() |
411 | { | 411 | { |
412 | mResizeEnabled = true; | 412 | mResizeEnabled = true; |
413 | //qDebug("DateNavigatorContainer::setResizeEnabled "); | 413 | //qDebug("DateNavigatorContainer::setResizeEnabled "); |
414 | checkUpdateDayMatrixDates(); | 414 | checkUpdateDayMatrixDates(); |
415 | } | 415 | } |
416 | void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) | 416 | void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) |
417 | { | 417 | { |
418 | 418 | ||
419 | //qDebug("DateNavigatorContainer::resizeEvent %d %d ", width(), height()); | 419 | //qDebug("DateNavigatorContainer::resizeEvent %d %d ", width(), height()); |
420 | //qDebug("COUNT %d ", mExtraViews.count()); | 420 | //qDebug("COUNT %d ", mExtraViews.count()); |
421 | if ( ! mResizeEnabled ) { | 421 | if ( ! mResizeEnabled ) { |
422 | //qDebug("NOT ResizeEnabled"); | 422 | //qDebug("NOT ResizeEnabled"); |
423 | return; | 423 | return; |
424 | } | 424 | } |
425 | else | 425 | else |
426 | mUpdateTimer->start( 250 ); | 426 | #ifdef DESKTOP_VERSION |
427 | mUpdateTimer->start( 100 ); | ||
428 | #else | ||
429 | mUpdateTimer->start( 50 ); | ||
430 | #endif | ||
427 | 431 | ||
428 | //updateDayMatrixDates(); | 432 | //updateDayMatrixDates(); |
429 | } | 433 | } |
430 | 434 | ||
431 | QSize DateNavigatorContainer::minimumSizeHint() const | 435 | QSize DateNavigatorContainer::minimumSizeHint() const |
432 | { | 436 | { |
433 | return mNavigatorView->minimumSizeHint(); | 437 | return mNavigatorView->minimumSizeHint(); |
434 | } | 438 | } |
435 | 439 | ||
436 | QSize DateNavigatorContainer::sizeHint() const | 440 | QSize DateNavigatorContainer::sizeHint() const |
437 | { | 441 | { |
438 | return mNavigatorView->yourSizeHint(); | 442 | return mNavigatorView->yourSizeHint(); |
439 | } | 443 | } |
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp index 1d09f40..5aa1c9b 100644 --- a/korganizer/kdatenavigator.cpp +++ b/korganizer/kdatenavigator.cpp | |||
@@ -1,467 +1,467 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program 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 | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qkeycode.h> | 25 | #include <qkeycode.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qtimer.h> | 27 | #include <qtimer.h> |
28 | #include <qframe.h> | 28 | #include <qframe.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qapplication.h> | 30 | #include <qapplication.h> |
31 | 31 | ||
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #include <kglobal.h> | 34 | #include <kglobal.h> |
35 | 35 | ||
36 | #include "koglobals.h" | 36 | #include "koglobals.h" |
37 | #include "koprefs.h" | 37 | #include "koprefs.h" |
38 | #ifndef KORG_NOPLUGINS | 38 | #ifndef KORG_NOPLUGINS |
39 | #include "kocore.h" | 39 | #include "kocore.h" |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | #include <kcalendarsystem.h> | 42 | #include <kcalendarsystem.h> |
43 | 43 | ||
44 | #include "navigatorbar.h" | 44 | #include "navigatorbar.h" |
45 | 45 | ||
46 | #include "kdatenavigator.h" | 46 | #include "kdatenavigator.h" |
47 | 47 | ||
48 | KDateNavigator::KDateNavigator( QWidget *parent, const char *name ) | 48 | KDateNavigator::KDateNavigator( QWidget *parent, const char *name ) |
49 | : QFrame(parent, name), | 49 | : QFrame(parent, name), |
50 | updateTimer(0L) | 50 | updateTimer(0L) |
51 | { | 51 | { |
52 | setFrameStyle(QFrame::NoFrame); | 52 | setFrameStyle(QFrame::NoFrame); |
53 | QDate startDate = QDate::currentDate(); | 53 | QDate startDate = QDate::currentDate(); |
54 | QGridLayout *topLayout = new QGridLayout(this,8,8); | 54 | QGridLayout *topLayout = new QGridLayout(this,8,8); |
55 | 55 | ||
56 | if (! startDate.isValid()) { | 56 | if (! startDate.isValid()) { |
57 | qDebug("KDateNavigator::invalid startdate "); | 57 | qDebug("KDateNavigator::invalid startdate "); |
58 | startDate = QDate::currentDate(); | 58 | startDate = QDate::currentDate(); |
59 | } | 59 | } |
60 | mMonthSignalOffset = 0; | 60 | mMonthSignalOffset = 0; |
61 | mSelectedDates.append(startDate); | 61 | mSelectedDates.append(startDate); |
62 | m_MthYr = startDate; | 62 | m_MthYr = startDate; |
63 | m_bShowWeekNums = true; | 63 | m_bShowWeekNums = true; |
64 | setFont( KOPrefs::instance()->mDateNavigatorFont ); | 64 | setFont( KOPrefs::instance()->mDateNavigatorFont ); |
65 | mNavigatorBar = new NavigatorBar( startDate, this ); | 65 | mNavigatorBar = new NavigatorBar( startDate, this ); |
66 | topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 ); | 66 | topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 ); |
67 | //mNavigatorBar->resize( 1,1); | 67 | //mNavigatorBar->resize( 1,1); |
68 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); | 68 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); |
69 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); | 69 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); |
70 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); | 70 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); |
71 | connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); | 71 | connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); |
72 | connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); | 72 | connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); |
73 | 73 | ||
74 | // get the day of the week on the first day | 74 | // get the day of the week on the first day |
75 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); | 75 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); |
76 | m_fstDayOfWk = dayone.dayOfWeek(); | 76 | m_fstDayOfWk = dayone.dayOfWeek(); |
77 | 77 | ||
78 | int i; | 78 | int i; |
79 | 79 | ||
80 | // Set up the heading fields. | 80 | // Set up the heading fields. |
81 | for( i = 0; i < 7; i++ ) { | 81 | for( i = 0; i < 7; i++ ) { |
82 | headings[i] = new QLabel("",this); | 82 | headings[i] = new QLabel("",this); |
83 | //headings[i]->setFont(QFont("Arial", 10, QFont::Bold)); | 83 | //headings[i]->setFont(QFont("Arial", 10, QFont::Bold)); |
84 | headings[i]->setAlignment(AlignCenter); | 84 | headings[i]->setAlignment(AlignCenter); |
85 | headings[i]->installEventFilter(this); | 85 | headings[i]->installEventFilter(this); |
86 | 86 | ||
87 | topLayout->addWidget(headings[i],1,i+1); | 87 | topLayout->addWidget(headings[i],1,i+1); |
88 | } | 88 | } |
89 | 89 | ||
90 | // Create the weeknumber labels | 90 | // Create the weeknumber labels |
91 | for( i = 0; i < 6; i++ ) { | 91 | for( i = 0; i < 6; i++ ) { |
92 | weeknos[i] = new QLabel(this); | 92 | weeknos[i] = new QLabel(this); |
93 | weeknos[i]->setAlignment(AlignCenter); | 93 | weeknos[i]->setAlignment(AlignCenter ); |
94 | //weeknos[i]->setFont(QFont("Arial", 10)); | 94 | //weeknos[i]->setFont(QFont("Arial", 10)); |
95 | if(!m_bShowWeekNums) { | 95 | if(!m_bShowWeekNums) { |
96 | weeknos[i]->hide(); | 96 | weeknos[i]->hide(); |
97 | } | 97 | } |
98 | weeknos[i]->installEventFilter(this); | 98 | weeknos[i]->installEventFilter(this); |
99 | 99 | ||
100 | topLayout->addWidget(weeknos[i],i+2,0); | 100 | topLayout->addWidget(weeknos[i],i+2,0); |
101 | } | 101 | } |
102 | 102 | ||
103 | daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix"); | 103 | daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix"); |
104 | daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 104 | daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); |
105 | daymatrix->setLineWidth(1); | 105 | daymatrix->setLineWidth(1); |
106 | 106 | ||
107 | connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), | 107 | connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), |
108 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); | 108 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); |
109 | 109 | ||
110 | connect( daymatrix, SIGNAL( eventDropped( Event * ) ), | 110 | connect( daymatrix, SIGNAL( eventDropped( Event * ) ), |
111 | SIGNAL( eventDropped( Event * ) ) ); | 111 | SIGNAL( eventDropped( Event * ) ) ); |
112 | 112 | ||
113 | topLayout->addMultiCellWidget(daymatrix,2,7,1,7); | 113 | topLayout->addMultiCellWidget(daymatrix,2,7,1,7); |
114 | 114 | ||
115 | // read settings from configuration file. | 115 | // read settings from configuration file. |
116 | updateConfig(); | 116 | updateConfig(); |
117 | enableRollover(FollowMonth); | 117 | enableRollover(FollowMonth); |
118 | mySizeHint = sizeHintTwoButtons(); | 118 | mySizeHint = sizeHintTwoButtons(); |
119 | myFullSizeHint = sizeHintTwoButtons( 4 ); | 119 | myFullSizeHint = sizeHintTwoButtons( 4 ); |
120 | mFontChanged = false; | 120 | mFontChanged = false; |
121 | //resize ( 3,3 ); | 121 | //resize ( 3,3 ); |
122 | 122 | ||
123 | } | 123 | } |
124 | void KDateNavigator::changeFont ( QFont fo ) | 124 | void KDateNavigator::changeFont ( QFont fo ) |
125 | { | 125 | { |
126 | setFont( fo ); | 126 | setFont( fo ); |
127 | mNavigatorBar->resetFont( fo ); | 127 | mNavigatorBar->resetFont( fo ); |
128 | } | 128 | } |
129 | QFont KDateNavigator::yourFontHint( QSize si , bool *b) | 129 | QFont KDateNavigator::yourFontHint( QSize si , bool *b) |
130 | { | 130 | { |
131 | QFont fo = KOPrefs::instance()->mDateNavigatorFont; | 131 | QFont fo = KOPrefs::instance()->mDateNavigatorFont; |
132 | *b = false; | 132 | *b = false; |
133 | int fontPoint = fo.pointSize(); | 133 | int fontPoint = fo.pointSize(); |
134 | while ( fontPoint > 5 ) { | 134 | while ( fontPoint > 5 ) { |
135 | --fontPoint; | 135 | --fontPoint; |
136 | fo.setPointSize( fontPoint ); | 136 | fo.setPointSize( fontPoint ); |
137 | setFont( fo ); | 137 | setFont( fo ); |
138 | mFontChanged = true; | 138 | mFontChanged = true; |
139 | mNavigatorBar->resetFont( fo ); | 139 | mNavigatorBar->resetFont( fo ); |
140 | QSize sh = sizeHintTwoButtons( 2 ); | 140 | QSize sh = sizeHintTwoButtons( 2 ); |
141 | //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() ); | 141 | //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() ); |
142 | if ( si.width() > sh.width() && si.height() > sh.height()) { | 142 | if ( si.width() > sh.width() && si.height() > sh.height()) { |
143 | if ( si.width() / sh.width() == 1 ) { | 143 | if ( si.width() / sh.width() == 1 ) { |
144 | if ( si.width() < sizeHintTwoButtons( 4 ).width()) | 144 | if ( si.width() < sizeHintTwoButtons( 4 ).width()) |
145 | continue; | 145 | continue; |
146 | } | 146 | } |
147 | *b = true; | 147 | *b = true; |
148 | //qDebug("fooooooooooooooooooooooouuuuund "); | 148 | //qDebug("fooooooooooooooooooooooouuuuund "); |
149 | break; | 149 | break; |
150 | } | 150 | } |
151 | } | 151 | } |
152 | //qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() ); | 152 | //qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() ); |
153 | return fo; | 153 | return fo; |
154 | } | 154 | } |
155 | QSize KDateNavigator::sizeHint() const | 155 | QSize KDateNavigator::sizeHint() const |
156 | { | 156 | { |
157 | QFontMetrics fm ( font() ); | 157 | QFontMetrics fm ( font() ); |
158 | QSize day = daymatrix->sizeHint(); | 158 | QSize day = daymatrix->sizeHint(); |
159 | QSize nav = mNavigatorBar->sizeHint(); | 159 | QSize nav = mNavigatorBar->sizeHint(); |
160 | int wid = fm.width( "30") + day.width()+3; | 160 | int wid = fm.width( "30") + day.width()+3; |
161 | int hei = fm.height() +day.height()+nav.height()+2; | 161 | int hei = fm.height() +day.height()+nav.height()+2; |
162 | if ( wid < nav.width() ) | 162 | if ( wid < nav.width() ) |
163 | wid = nav.width() ; | 163 | wid = nav.width() ; |
164 | //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); | 164 | //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); |
165 | return QSize ( wid, hei ); | 165 | return QSize ( wid, hei ); |
166 | } | 166 | } |
167 | QSize KDateNavigator::sizeHintTwoButtons( int butnum ) const | 167 | QSize KDateNavigator::sizeHintTwoButtons( int butnum ) const |
168 | { | 168 | { |
169 | QFontMetrics fm ( font() ); | 169 | QFontMetrics fm ( font() ); |
170 | QSize day = daymatrix->sizeHint(); | 170 | QSize day = daymatrix->sizeHint(); |
171 | QSize nav = mNavigatorBar->sizeHintTwoButtons( butnum ); | 171 | QSize nav = mNavigatorBar->sizeHintTwoButtons( butnum ); |
172 | int wid = fm.width( "30") + day.width()+3; | 172 | int wid = fm.width( "30") + day.width()+3; |
173 | int hei = fm.height() +day.height()+nav.height()+2; | 173 | int hei = fm.height() +day.height()+nav.height()+2; |
174 | if ( wid < nav.width() ) | 174 | if ( wid < nav.width() ) |
175 | wid = nav.width() ; | 175 | wid = nav.width() ; |
176 | //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); | 176 | //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); |
177 | return QSize ( wid, hei ); | 177 | return QSize ( wid, hei ); |
178 | } | 178 | } |
179 | void KDateNavigator::slotMonthSelected( int m ) | 179 | void KDateNavigator::slotMonthSelected( int m ) |
180 | { | 180 | { |
181 | if ( m_MthYr.month() <= mMonthSignalOffset) | 181 | if ( m_MthYr.month() <= mMonthSignalOffset) |
182 | m += 12; | 182 | m += 12; |
183 | //qDebug("%d mMonthSignalOffset %d emit %d", m, mMonthSignalOffset, m - mMonthSignalOffset); | 183 | //qDebug("%d mMonthSignalOffset %d emit %d", m, mMonthSignalOffset, m - mMonthSignalOffset); |
184 | emit monthSelected( m - mMonthSignalOffset ); | 184 | emit monthSelected( m - mMonthSignalOffset ); |
185 | 185 | ||
186 | } | 186 | } |
187 | void KDateNavigator::setCalendar( Calendar *cal ) | 187 | void KDateNavigator::setCalendar( Calendar *cal ) |
188 | { | 188 | { |
189 | daymatrix->setCalendar( cal ); | 189 | daymatrix->setCalendar( cal ); |
190 | } | 190 | } |
191 | 191 | ||
192 | void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true | 192 | void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true |
193 | { | 193 | { |
194 | m_MthYr = date; | 194 | m_MthYr = date; |
195 | //qDebug("KDateNavigator::setBaseDate %s ", date.toString().latin1()); | 195 | //qDebug("KDateNavigator::setBaseDate %s ", date.toString().latin1()); |
196 | 196 | ||
197 | updateDates(); | 197 | updateDates(); |
198 | updateView(); | 198 | updateView(); |
199 | 199 | ||
200 | KCal::DateList dates; | 200 | KCal::DateList dates; |
201 | dates.append( date ); | 201 | dates.append( date ); |
202 | mNavigatorBar->selectDates( dates ); | 202 | mNavigatorBar->selectDates( dates ); |
203 | 203 | ||
204 | daymatrix->clearSelection(); | 204 | daymatrix->clearSelection(); |
205 | if ( doRepaint ) | 205 | if ( doRepaint ) |
206 | daymatrix->repaint( false ); | 206 | daymatrix->repaint( false ); |
207 | } | 207 | } |
208 | 208 | ||
209 | void KDateNavigator::enableRollover(RolloverType r) | 209 | void KDateNavigator::enableRollover(RolloverType r) |
210 | { | 210 | { |
211 | switch(r) | 211 | switch(r) |
212 | { | 212 | { |
213 | case None : | 213 | case None : |
214 | if (updateTimer) | 214 | if (updateTimer) |
215 | { | 215 | { |
216 | updateTimer->stop(); | 216 | updateTimer->stop(); |
217 | delete updateTimer; | 217 | delete updateTimer; |
218 | updateTimer=0L; | 218 | updateTimer=0L; |
219 | } | 219 | } |
220 | break; | 220 | break; |
221 | case FollowDay : | 221 | case FollowDay : |
222 | case FollowMonth : | 222 | case FollowMonth : |
223 | if (!updateTimer) | 223 | if (!updateTimer) |
224 | { | 224 | { |
225 | updateTimer = new QTimer(this); | 225 | updateTimer = new QTimer(this); |
226 | QObject::connect(updateTimer,SIGNAL(timeout()), | 226 | QObject::connect(updateTimer,SIGNAL(timeout()), |
227 | this,SLOT(possiblyPastMidnight())); | 227 | this,SLOT(possiblyPastMidnight())); |
228 | } | 228 | } |
229 | updateTimer->start(0,true); | 229 | updateTimer->start(0,true); |
230 | lastDayChecked = QDate::currentDate(); | 230 | lastDayChecked = QDate::currentDate(); |
231 | } | 231 | } |
232 | updateRollover=r; | 232 | updateRollover=r; |
233 | } | 233 | } |
234 | 234 | ||
235 | 235 | ||
236 | KDateNavigator::~KDateNavigator() | 236 | KDateNavigator::~KDateNavigator() |
237 | { | 237 | { |
238 | } | 238 | } |
239 | 239 | ||
240 | 240 | ||
241 | void KDateNavigator::passedMidnight() | 241 | void KDateNavigator::passedMidnight() |
242 | { | 242 | { |
243 | QDate today = QDate::currentDate(); | 243 | QDate today = QDate::currentDate(); |
244 | bool emitMonth = false; | 244 | bool emitMonth = false; |
245 | 245 | ||
246 | if (today.month() != lastDayChecked.month()) | 246 | if (today.month() != lastDayChecked.month()) |
247 | { | 247 | { |
248 | if (updateRollover==FollowMonth && | 248 | if (updateRollover==FollowMonth && |
249 | daymatrix->isEndOfMonth()) { | 249 | daymatrix->isEndOfMonth()) { |
250 | goNextMonth(); | 250 | goNextMonth(); |
251 | emitMonth=true; | 251 | emitMonth=true; |
252 | } | 252 | } |
253 | } | 253 | } |
254 | daymatrix->recalculateToday(); | 254 | daymatrix->recalculateToday(); |
255 | daymatrix->repaint( false ); | 255 | daymatrix->repaint( false ); |
256 | emit dayPassed(today); | 256 | emit dayPassed(today); |
257 | if (emitMonth) { emit monthPassed(today); } | 257 | if (emitMonth) { emit monthPassed(today); } |
258 | } | 258 | } |
259 | 259 | ||
260 | /* slot */ void KDateNavigator::possiblyPastMidnight() | 260 | /* slot */ void KDateNavigator::possiblyPastMidnight() |
261 | { | 261 | { |
262 | if (lastDayChecked!=QDate::currentDate()) | 262 | if (lastDayChecked!=QDate::currentDate()) |
263 | { | 263 | { |
264 | passedMidnight(); | 264 | passedMidnight(); |
265 | lastDayChecked=QDate::currentDate(); | 265 | lastDayChecked=QDate::currentDate(); |
266 | } | 266 | } |
267 | // Set the timer to go off 1 second after midnight | 267 | // Set the timer to go off 1 second after midnight |
268 | // or after 8 minutes, whichever comes first. | 268 | // or after 8 minutes, whichever comes first. |
269 | if (updateTimer) | 269 | if (updateTimer) |
270 | { | 270 | { |
271 | QTime now = QTime::currentTime(); | 271 | QTime now = QTime::currentTime(); |
272 | QTime midnight = QTime(23,59,59); | 272 | QTime midnight = QTime(23,59,59); |
273 | int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000); | 273 | int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000); |
274 | 274 | ||
275 | // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait)) | 275 | // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait)) |
276 | //.arg(now.toString()).arg(midnight.toString())); | 276 | //.arg(now.toString()).arg(midnight.toString())); |
277 | 277 | ||
278 | updateTimer->stop(); | 278 | updateTimer->stop(); |
279 | updateTimer->start(msecsWait,true); | 279 | updateTimer->start(msecsWait,true); |
280 | } | 280 | } |
281 | } | 281 | } |
282 | 282 | ||
283 | void KDateNavigator::updateDates() | 283 | void KDateNavigator::updateDates() |
284 | { | 284 | { |
285 | // Find the first day of the week of the current month. | 285 | // Find the first day of the week of the current month. |
286 | //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr ); | 286 | //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr ); |
287 | QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() ); | 287 | QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() ); |
288 | int d2 = KOGlobals::self()->calendarSystem()->day( dayone ); | 288 | int d2 = KOGlobals::self()->calendarSystem()->day( dayone ); |
289 | //int di = d1 - d2 + 1; | 289 | //int di = d1 - d2 + 1; |
290 | dayone = dayone.addDays( -d2 + 1 ); | 290 | dayone = dayone.addDays( -d2 + 1 ); |
291 | 291 | ||
292 | int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone ); | 292 | int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone ); |
293 | 293 | ||
294 | // If month begins on Monday and Monday is first day of week, | 294 | // If month begins on Monday and Monday is first day of week, |
295 | // month should begin on second line. Sunday doesn't have this problem. | 295 | // month should begin on second line. Sunday doesn't have this problem. |
296 | int nextLine = ( ( m_fstDayOfWkCalsys == 1) && | 296 | int nextLine = ( ( m_fstDayOfWkCalsys == 1) && |
297 | ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0; | 297 | ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0; |
298 | 298 | ||
299 | // update the matrix dates | 299 | // update the matrix dates |
300 | int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine; | 300 | int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine; |
301 | 301 | ||
302 | 302 | ||
303 | daymatrix->updateView(dayone.addDays(index)); | 303 | daymatrix->updateView(dayone.addDays(index)); |
304 | //each updateDates is followed by an updateView -> repaint is issued there ! | 304 | //each updateDates is followed by an updateView -> repaint is issued there ! |
305 | // daymatrix->repaint(); | 305 | // daymatrix->repaint(); |
306 | } | 306 | } |
307 | 307 | ||
308 | void KDateNavigator::updateDayMatrix() | 308 | void KDateNavigator::updateDayMatrix() |
309 | { | 309 | { |
310 | daymatrix->updateView(); | 310 | daymatrix->updateView(); |
311 | //daymatrix->repaint(); | 311 | //daymatrix->repaint(); |
312 | } | 312 | } |
313 | 313 | ||
314 | 314 | ||
315 | void KDateNavigator::updateView() | 315 | void KDateNavigator::updateView() |
316 | { | 316 | { |
317 | 317 | ||
318 | setUpdatesEnabled( false ); | 318 | setUpdatesEnabled( false ); |
319 | 319 | ||
320 | int i; | 320 | int i; |
321 | 321 | ||
322 | // kdDebug() << "updateView() -> daymatrix->updateView()" << endl; | 322 | // kdDebug() << "updateView() -> daymatrix->updateView()" << endl; |
323 | daymatrix->updateView(); | 323 | daymatrix->updateView(); |
324 | int sub = 4; | 324 | int sub = 4; |
325 | if ( ! KGlobal::locale()->weekStartsMonday() ) | 325 | if ( ! KGlobal::locale()->weekStartsMonday() ) |
326 | --sub; | 326 | --sub; |
327 | // set the week numbers. | 327 | // set the week numbers. |
328 | for(i = 0; i < 6; i++) { | 328 | for(i = 0; i < 6; i++) { |
329 | // remember, according to ISO 8601, the first week of the year is the | 329 | // remember, according to ISO 8601, the first week of the year is the |
330 | // first week that contains a thursday. Thus we must subtract off 4, | 330 | // first week that contains a thursday. Thus we must subtract off 4, |
331 | // not just 1. | 331 | // not just 1. |
332 | 332 | ||
333 | //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear(); | 333 | //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear(); |
334 | int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-sub))); | 334 | int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-sub))); |
335 | int weekNo; | 335 | int weekNo; |
336 | if (dayOfYear % 7 != 0) | 336 | if (dayOfYear % 7 != 0) |
337 | weekNo = (dayOfYear / 7 + 1); | 337 | weekNo = (dayOfYear / 7 + 1); |
338 | else | 338 | else |
339 | weekNo = (dayOfYear / 7); | 339 | weekNo = (dayOfYear / 7); |
340 | weeknos[i]->setText(QString::number( weekNo )); | 340 | weeknos[i]->setText(QString::number( weekNo )); |
341 | } | 341 | } |
342 | 342 | ||
343 | setUpdatesEnabled( true ); | 343 | setUpdatesEnabled( true ); |
344 | // kdDebug() << "updateView() -> repaint()" << endl; | 344 | // kdDebug() << "updateView() -> repaint()" << endl; |
345 | repaint(); | 345 | repaint(); |
346 | // daymatrix->repaint(); | 346 | // daymatrix->repaint(); |
347 | } | 347 | } |
348 | 348 | ||
349 | void KDateNavigator::updateConfig() | 349 | void KDateNavigator::updateConfig() |
350 | { | 350 | { |
351 | int day; | 351 | int day; |
352 | for(int i=0; i<7; i++) { | 352 | for(int i=0; i<7; i++) { |
353 | // take the first letter of the day name to be the abbreviation | 353 | // take the first letter of the day name to be the abbreviation |
354 | if (KGlobal::locale()->weekStartsMonday()) { | 354 | if (KGlobal::locale()->weekStartsMonday()) { |
355 | day = i+1; | 355 | day = i+1; |
356 | } else { | 356 | } else { |
357 | if (i==0) day = 7; | 357 | if (i==0) day = 7; |
358 | else day = i; | 358 | else day = i; |
359 | } | 359 | } |
360 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day, | 360 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day, |
361 | true ); | 361 | true ); |
362 | if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 ); | 362 | if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 ); |
363 | headings[i]->setText( dayName ); | 363 | headings[i]->setText( dayName ); |
364 | } | 364 | } |
365 | updateDates(); | 365 | updateDates(); |
366 | updateView(); | 366 | updateView(); |
367 | } | 367 | } |
368 | 368 | ||
369 | void KDateNavigator::setShowWeekNums(bool enabled) | 369 | void KDateNavigator::setShowWeekNums(bool enabled) |
370 | { | 370 | { |
371 | qDebug("KDateNavigator::setShowWeekNums***************************** "); | 371 | qDebug("KDateNavigator::setShowWeekNums***************************** "); |
372 | m_bShowWeekNums = enabled; | 372 | m_bShowWeekNums = enabled; |
373 | for(int i=0; i<6; i++) { | 373 | for(int i=0; i<6; i++) { |
374 | if(enabled) | 374 | if(enabled) |
375 | weeknos[i]->show(); | 375 | weeknos[i]->show(); |
376 | else | 376 | else |
377 | weeknos[i]->hide(); | 377 | weeknos[i]->hide(); |
378 | } | 378 | } |
379 | resize(size()); | 379 | resize(size()); |
380 | } | 380 | } |
381 | 381 | ||
382 | void KDateNavigator::selectDates(const DateList& dateList) | 382 | void KDateNavigator::selectDates(const DateList& dateList) |
383 | { | 383 | { |
384 | 384 | ||
385 | if (dateList.count() > 0) { | 385 | if (dateList.count() > 0) { |
386 | mNavigatorBar->selectDates( dateList ); | 386 | mNavigatorBar->selectDates( dateList ); |
387 | mSelectedDates = dateList; | 387 | mSelectedDates = dateList; |
388 | 388 | ||
389 | // set our record of the month and year that this datetbl is | 389 | // set our record of the month and year that this datetbl is |
390 | // displaying. | 390 | // displaying. |
391 | m_MthYr = mSelectedDates.first(); | 391 | m_MthYr = mSelectedDates.first(); |
392 | 392 | ||
393 | 393 | ||
394 | // set our record of the first day of the week of the current | 394 | // set our record of the first day of the week of the current |
395 | // month. This needs to be done before calling dayToIndex, since it | 395 | // month. This needs to be done before calling dayToIndex, since it |
396 | // relies on this information being up to date. | 396 | // relies on this information being up to date. |
397 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); | 397 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); |
398 | m_fstDayOfWk = dayone.dayOfWeek(); | 398 | m_fstDayOfWk = dayone.dayOfWeek(); |
399 | 399 | ||
400 | updateDates(); | 400 | updateDates(); |
401 | 401 | ||
402 | daymatrix->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); | 402 | daymatrix->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); |
403 | 403 | ||
404 | updateView(); | 404 | updateView(); |
405 | } | 405 | } |
406 | } | 406 | } |
407 | 407 | ||
408 | int KDateNavigator::dayNum(int row, int col) | 408 | int KDateNavigator::dayNum(int row, int col) |
409 | { | 409 | { |
410 | return 7 * (row - 1) + (col + 1) - m_fstDayOfWk; | 410 | return 7 * (row - 1) + (col + 1) - m_fstDayOfWk; |
411 | } | 411 | } |
412 | 412 | ||
413 | int KDateNavigator::dayToIndex(int dayNum) | 413 | int KDateNavigator::dayToIndex(int dayNum) |
414 | { | 414 | { |
415 | int row, col; | 415 | int row, col; |
416 | 416 | ||
417 | row = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) / 7; | 417 | row = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) / 7; |
418 | if (KGlobal::locale()->weekStartsMonday() && (m_fstDayOfWk == 1)) | 418 | if (KGlobal::locale()->weekStartsMonday() && (m_fstDayOfWk == 1)) |
419 | row++; | 419 | row++; |
420 | col = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) % 7; | 420 | col = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) % 7; |
421 | return row * 7 + col; | 421 | return row * 7 + col; |
422 | } | 422 | } |
423 | 423 | ||
424 | void KDateNavigator::wheelEvent (QWheelEvent *e) | 424 | void KDateNavigator::wheelEvent (QWheelEvent *e) |
425 | { | 425 | { |
426 | if(e->delta()>0) emit goPrevious(); | 426 | if(e->delta()>0) emit goPrevious(); |
427 | else emit goNext(); | 427 | else emit goNext(); |
428 | 428 | ||
429 | e->accept(); | 429 | e->accept(); |
430 | } | 430 | } |
431 | 431 | ||
432 | bool KDateNavigator::eventFilter (QObject *o,QEvent *e) | 432 | bool KDateNavigator::eventFilter (QObject *o,QEvent *e) |
433 | { | 433 | { |
434 | if (e->type() == QEvent::MouseButtonPress) { | 434 | if (e->type() == QEvent::MouseButtonPress) { |
435 | int i; | 435 | int i; |
436 | for(i=0;i<6;++i) { | 436 | for(i=0;i<6;++i) { |
437 | if (o == weeknos[i]) { | 437 | if (o == weeknos[i]) { |
438 | QDate weekstart = daymatrix->getDate(i*7); | 438 | QDate weekstart = daymatrix->getDate(i*7); |
439 | emit weekClicked(weekstart); | 439 | emit weekClicked(weekstart); |
440 | break; | 440 | break; |
441 | } | 441 | } |
442 | } | 442 | } |
443 | for(i=0;i<7;++i) { | 443 | for(i=0;i<7;++i) { |
444 | if (o == headings[i]) { | 444 | if (o == headings[i]) { |
445 | KCal::DateList selDays; | 445 | KCal::DateList selDays; |
446 | QDate date = daymatrix->getDate(14); | 446 | QDate date = daymatrix->getDate(14); |
447 | emit showMonth(date ); | 447 | emit showMonth(date ); |
448 | #if 0 | 448 | #if 0 |
449 | int dio = date.daysInMonth(); | 449 | int dio = date.daysInMonth(); |
450 | int j; | 450 | int j; |
451 | int ye = date.year(); | 451 | int ye = date.year(); |
452 | int mo = date.month(); | 452 | int mo = date.month(); |
453 | for ( j = 1; j <= dio; ++j ) { | 453 | for ( j = 1; j <= dio; ++j ) { |
454 | selDays.append( QDate( ye, mo, j ) ); | 454 | selDays.append( QDate( ye, mo, j ) ); |
455 | } | 455 | } |
456 | emit datesSelected( selDays ); | 456 | emit datesSelected( selDays ); |
457 | #endif | 457 | #endif |
458 | break; | 458 | break; |
459 | } | 459 | } |
460 | } | 460 | } |
461 | return true; | 461 | return true; |
462 | } else { | 462 | } else { |
463 | return false; | 463 | return false; |
464 | } | 464 | } |
465 | } | 465 | } |
466 | 466 | ||
467 | //#include "kdatenavigator.moc" | 467 | //#include "kdatenavigator.moc" |
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index 8affe50..c7e1b45 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -1,974 +1,994 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> | 3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> |
4 | Parts of the source code have been copied from kdpdatebutton.cpp | 4 | Parts of the source code have been copied from kdpdatebutton.cpp |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source ode for Qt in the source distribution. | 22 | without including the source ode for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <qevent.h> | 25 | #include <qevent.h> |
26 | #include <qpainter.h> | 26 | #include <qpainter.h> |
27 | #include <qptrlist.h> | 27 | #include <qptrlist.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | #include <qwhatsthis.h> | 29 | #include <qwhatsthis.h> |
30 | 30 | ||
31 | #include <kglobal.h> | 31 | #include <kglobal.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | 34 | ||
35 | #include <libkcal/vcaldrag.h> | 35 | #include <libkcal/vcaldrag.h> |
36 | #include <libkcal/icaldrag.h> | 36 | #include <libkcal/icaldrag.h> |
37 | #include <libkcal/dndfactory.h> | 37 | #include <libkcal/dndfactory.h> |
38 | #include <libkcal/calendarresources.h> | 38 | #include <libkcal/calendarresources.h> |
39 | #include <libkcal/resourcecalendar.h> | 39 | #include <libkcal/resourcecalendar.h> |
40 | #include <kresources/resourceselectdialog.h> | 40 | #include <kresources/resourceselectdialog.h> |
41 | 41 | ||
42 | #include <kcalendarsystem.h> | 42 | #include <kcalendarsystem.h> |
43 | 43 | ||
44 | #ifndef KORG_NOPLUGINS | 44 | #ifndef KORG_NOPLUGINS |
45 | #include "kocore.h" | 45 | #include "kocore.h" |
46 | #endif | 46 | #endif |
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | #include "koglobals.h" | 48 | #include "koglobals.h" |
49 | 49 | ||
50 | #include "kodaymatrix.h" | 50 | #include "kodaymatrix.h" |
51 | 51 | ||
52 | // ============================================================================ | 52 | // ============================================================================ |
53 | // D Y N A M I C T I P | 53 | // D Y N A M I C T I P |
54 | // ============================================================================ | 54 | // ============================================================================ |
55 | 55 | ||
56 | DynamicTip::DynamicTip( QWidget * parent ) | 56 | DynamicTip::DynamicTip( QWidget * parent ) |
57 | : QToolTip( parent ) | 57 | : QToolTip( parent ) |
58 | { | 58 | { |
59 | matrix = (KODayMatrix*)parent; | 59 | matrix = (KODayMatrix*)parent; |
60 | } | 60 | } |
61 | 61 | ||
62 | class KODaymatrixWhatsThis :public QWhatsThis | 62 | class KODaymatrixWhatsThis :public QWhatsThis |
63 | { | 63 | { |
64 | public: | 64 | public: |
65 | KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { ;}; | 65 | KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { ;}; |
66 | ~KODaymatrixWhatsThis() { ; }; | 66 | ~KODaymatrixWhatsThis() { ; }; |
67 | 67 | ||
68 | protected: | 68 | protected: |
69 | virtual QString text( const QPoint& p ) | 69 | virtual QString text( const QPoint& p ) |
70 | { | 70 | { |
71 | return _view->getWhatsThisText( p ) ; | 71 | return _view->getWhatsThisText( p ) ; |
72 | } | 72 | } |
73 | private: | 73 | private: |
74 | KODayMatrix * _view; | 74 | KODayMatrix * _view; |
75 | }; | 75 | }; |
76 | 76 | ||
77 | void DynamicTip::maybeTip( const QPoint &pos ) | 77 | void DynamicTip::maybeTip( const QPoint &pos ) |
78 | { | 78 | { |
79 | //calculate which cell of the matrix the mouse is in | 79 | //calculate which cell of the matrix the mouse is in |
80 | QRect sz = matrix->frameRect(); | 80 | QRect sz = matrix->frameRect(); |
81 | int dheight = sz.height()*7 / 42; | 81 | int dheight = sz.height()*7 / 42; |
82 | int dwidth = sz.width() / 7; | 82 | int dwidth = sz.width() / 7; |
83 | int row = pos.y()/dheight; | 83 | int row = pos.y()/dheight; |
84 | int col = pos.x()/dwidth; | 84 | int col = pos.x()/dwidth; |
85 | 85 | ||
86 | QRect rct(col*dwidth, row*dheight, dwidth, dheight); | 86 | QRect rct(col*dwidth, row*dheight, dwidth, dheight); |
87 | 87 | ||
88 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << | 88 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << |
89 | // col << "][" << row << "] => " <<(col+row*7) << endl; | 89 | // col << "][" << row << "] => " <<(col+row*7) << endl; |
90 | 90 | ||
91 | //show holiday names only | 91 | //show holiday names only |
92 | QString str = matrix->getHolidayLabel(col+row*7); | 92 | QString str = matrix->getHolidayLabel(col+row*7); |
93 | if (str.isEmpty()) return; | 93 | if (str.isEmpty()) return; |
94 | tip(rct, str); | 94 | tip(rct, str); |
95 | } | 95 | } |
96 | 96 | ||
97 | 97 | ||
98 | // ============================================================================ | 98 | // ============================================================================ |
99 | // K O D A Y M A T R I X | 99 | // K O D A Y M A T R I X |
100 | // ============================================================================ | 100 | // ============================================================================ |
101 | 101 | ||
102 | const int KODayMatrix::NOSELECTION = -1000; | 102 | const int KODayMatrix::NOSELECTION = -1000; |
103 | const int KODayMatrix::NUMDAYS = 42; | 103 | const int KODayMatrix::NUMDAYS = 42; |
104 | 104 | ||
105 | KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) | 105 | KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) |
106 | : QFrame( parent, name , Qt::WRepaintNoErase ), mCalendar( 0 ) | 106 | : QFrame( parent, name , Qt::WRepaintNoErase ), mCalendar( 0 ) |
107 | 107 | ||
108 | #if 0 | 108 | #if 0 |
109 | KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : | 109 | KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : |
110 | QFrame(parent, name) | 110 | QFrame(parent, name) |
111 | #endif | 111 | #endif |
112 | { | 112 | { |
113 | oldW = 0; | ||
114 | oldH = 0; | ||
115 | myPix.resize( 150, 120 ); | ||
113 | mRedrawNeeded = true; | 116 | mRedrawNeeded = true; |
114 | mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this); | 117 | mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this); |
115 | mPendingUpdateBeforeRepaint = false; | 118 | mPendingUpdateBeforeRepaint = false; |
116 | mouseDown = false; | 119 | mouseDown = false; |
117 | // initialize dynamic arrays | 120 | // initialize dynamic arrays |
118 | bDays.resize ( NUMDAYS ); | 121 | bDays.resize ( NUMDAYS ); |
119 | hDays.resize ( NUMDAYS );; | 122 | hDays.resize ( NUMDAYS ); |
120 | eDays.resize ( NUMDAYS );; | 123 | eDays.resize ( NUMDAYS ); |
121 | days = new QDate[NUMDAYS]; | 124 | days = new QDate[NUMDAYS]; |
122 | daylbls = new QString[NUMDAYS]; | 125 | daylbls = new QString[NUMDAYS]; |
123 | //events = new int[NUMDAYS]; | 126 | //events = new int[NUMDAYS]; |
124 | mToolTip = new DynamicTip(this); | 127 | mToolTip = new DynamicTip(this); |
125 | 128 | ||
126 | // set default values used for drawing the matrix | 129 | // set default values used for drawing the matrix |
127 | mDefaultBackColor = palette().active().base(); | 130 | mDefaultBackColor = palette().active().base(); |
128 | mDefaultTextColor = palette().active().foreground(); | 131 | mDefaultTextColor = palette().active().foreground(); |
129 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); | 132 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); |
130 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); | 133 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); |
131 | mSelectedDaysColor = QColor("white"); | 134 | mSelectedDaysColor = QColor("white"); |
132 | mTodayMarginWidth = 2; | 135 | mTodayMarginWidth = 2; |
133 | mSelEnd = mSelStart = NOSELECTION; | 136 | mSelEnd = mSelStart = NOSELECTION; |
134 | 137 | ||
135 | setAcceptDrops(true); | 138 | setAcceptDrops(true); |
136 | //setFont( QFont("Arial", 10) ); | 139 | //setFont( QFont("Arial", 10) ); |
137 | 140 | ||
138 | mUpdateTimer = new QTimer( this ); | 141 | mUpdateTimer = new QTimer( this ); |
139 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); | 142 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); |
140 | mRepaintTimer = new QTimer( this ); | 143 | mRepaintTimer = new QTimer( this ); |
141 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); | 144 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); |
142 | mDayChanged = false; | 145 | mDayChanged = false; |
143 | updateView(); | 146 | updateView(); |
144 | } | 147 | } |
145 | QString KODayMatrix::getWhatsThisText( QPoint p ) | 148 | QString KODayMatrix::getWhatsThisText( QPoint p ) |
146 | { | 149 | { |
147 | 150 | ||
148 | int tmp = getDayIndexFrom(p.x(), p.y()); | 151 | int tmp = getDayIndexFrom(p.x(), p.y()); |
149 | if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar ) | 152 | if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar ) |
150 | return QString(); | 153 | return QString(); |
151 | QDate mDate = days[tmp]; | 154 | QDate mDate = days[tmp]; |
152 | QPtrList<Event> eventlist = mCalendar->events(mDate); | 155 | QPtrList<Event> eventlist = mCalendar->events(mDate); |
153 | Event *event; | 156 | Event *event; |
154 | QStringList mToolTip; | 157 | QStringList mToolTip; |
155 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 158 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
156 | QString mToolTipText; | 159 | QString mToolTipText; |
157 | QString text; | 160 | QString text; |
158 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day | 161 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day |
159 | if (event->isMultiDay()) { | 162 | if (event->isMultiDay()) { |
160 | QString prefix = "<->";multiday = 2; | 163 | QString prefix = "<->";multiday = 2; |
161 | QString time; | 164 | QString time; |
162 | if ( event->doesRecur() ) { | 165 | if ( event->doesRecur() ) { |
163 | if ( event->recursOn( mDate) ) { | 166 | if ( event->recursOn( mDate) ) { |
164 | prefix ="->" ;multiday = 1; | 167 | prefix ="->" ;multiday = 1; |
165 | } | 168 | } |
166 | else { | 169 | else { |
167 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 170 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
168 | if ( event->recursOn( mDate.addDays( -days)) ) { | 171 | if ( event->recursOn( mDate.addDays( -days)) ) { |
169 | prefix ="<-" ;multiday = 3; | 172 | prefix ="<-" ;multiday = 3; |
170 | } | 173 | } |
171 | } | 174 | } |
172 | } else { | 175 | } else { |
173 | if (mDate == event->dtStart().date()) { | 176 | if (mDate == event->dtStart().date()) { |
174 | prefix ="->" ;multiday = 1; | 177 | prefix ="->" ;multiday = 1; |
175 | } else if (mDate == event->dtEnd().date()) { | 178 | } else if (mDate == event->dtEnd().date()) { |
176 | prefix ="<-" ;multiday = 3; | 179 | prefix ="<-" ;multiday = 3; |
177 | } | 180 | } |
178 | } | 181 | } |
179 | if ( !event->doesFloat() ) { | 182 | if ( !event->doesFloat() ) { |
180 | if ( mDate == event->dtStart().date () ) | 183 | if ( mDate == event->dtStart().date () ) |
181 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 184 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
182 | else if ( mDate == event->dtEnd().date () ) | 185 | else if ( mDate == event->dtEnd().date () ) |
183 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 186 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
184 | 187 | ||
185 | } | 188 | } |
186 | text = time + event->summary(); | 189 | text = time + event->summary(); |
187 | mToolTipText += prefix + text; | 190 | mToolTipText += prefix + text; |
188 | } else { | 191 | } else { |
189 | if (event->doesFloat()) { | 192 | if (event->doesFloat()) { |
190 | text = event->summary(); | 193 | text = event->summary(); |
191 | mToolTipText += text; | 194 | mToolTipText += text; |
192 | } | 195 | } |
193 | else { | 196 | else { |
194 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 197 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
195 | text += " " + event->summary(); | 198 | text += " " + event->summary(); |
196 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 199 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
197 | } | 200 | } |
198 | } | 201 | } |
199 | if ( !event->location().isEmpty() ) | 202 | if ( !event->location().isEmpty() ) |
200 | mToolTipText += " (" + event->location() + ")"; | 203 | mToolTipText += " (" + event->location() + ")"; |
201 | #if QT_VERSION >= 0x030000 | 204 | #if QT_VERSION >= 0x030000 |
202 | mToolTipText.replace( '<' , "<" ); | 205 | mToolTipText.replace( '<' , "<" ); |
203 | mToolTipText.replace( '>' , ">" ); | 206 | mToolTipText.replace( '>' , ">" ); |
204 | #else | 207 | #else |
205 | if ( mToolTipText.find ('<') >= 0 ) { | 208 | if ( mToolTipText.find ('<') >= 0 ) { |
206 | mToolTipText.replace( QRegExp("<") , "<" ); | 209 | mToolTipText.replace( QRegExp("<") , "<" ); |
207 | } | 210 | } |
208 | if ( mToolTipText.find ('>') >= 0 ) { | 211 | if ( mToolTipText.find ('>') >= 0 ) { |
209 | mToolTipText.replace( QRegExp(">") , ">" ); | 212 | mToolTipText.replace( QRegExp(">") , ">" ); |
210 | } | 213 | } |
211 | #endif | 214 | #endif |
212 | //qDebug("TTT: %s ", mToolTipText.latin1()); | 215 | //qDebug("TTT: %s ", mToolTipText.latin1()); |
213 | mToolTip.append( mToolTipText ); | 216 | mToolTip.append( mToolTipText ); |
214 | } | 217 | } |
215 | mToolTip.sort(); | 218 | mToolTip.sort(); |
216 | return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); | 219 | return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); |
217 | } | 220 | } |
218 | void KODayMatrix::setCalendar( Calendar *cal ) | 221 | void KODayMatrix::setCalendar( Calendar *cal ) |
219 | { | 222 | { |
220 | mCalendar = cal; | 223 | mCalendar = cal; |
221 | 224 | ||
222 | setAcceptDrops( mCalendar ); | 225 | setAcceptDrops( mCalendar ); |
223 | 226 | ||
224 | updateEvents(); | 227 | updateEvents(); |
225 | } | 228 | } |
226 | 229 | ||
227 | QColor KODayMatrix::getShadedColor(QColor color) | 230 | QColor KODayMatrix::getShadedColor(QColor color) |
228 | { | 231 | { |
229 | QColor shaded; | 232 | QColor shaded; |
230 | int h=0; | 233 | int h=0; |
231 | int s=0; | 234 | int s=0; |
232 | int v=0; | 235 | int v=0; |
233 | color.hsv(&h,&s,&v); | 236 | color.hsv(&h,&s,&v); |
234 | s = s/4; | 237 | s = s/4; |
235 | v = 192+v/4; | 238 | v = 192+v/4; |
236 | shaded.setHsv(h,s,v); | 239 | shaded.setHsv(h,s,v); |
237 | 240 | ||
238 | return shaded; | 241 | return shaded; |
239 | } | 242 | } |
240 | 243 | ||
241 | KODayMatrix::~KODayMatrix() | 244 | KODayMatrix::~KODayMatrix() |
242 | { | 245 | { |
243 | // delete mKODaymatrixWhatsThis; | 246 | // delete mKODaymatrixWhatsThis; |
244 | delete [] days; | 247 | delete [] days; |
245 | delete [] daylbls; | 248 | delete [] daylbls; |
246 | //delete [] events; | 249 | //delete [] events; |
247 | delete mToolTip; | 250 | delete mToolTip; |
248 | } | 251 | } |
249 | 252 | ||
250 | /* | 253 | /* |
251 | void KODayMatrix::setStartDate(QDate start) | 254 | void KODayMatrix::setStartDate(QDate start) |
252 | { | 255 | { |
253 | updateView(start); | 256 | updateView(start); |
254 | } | 257 | } |
255 | */ | 258 | */ |
256 | 259 | ||
257 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) | 260 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) |
258 | { | 261 | { |
259 | 262 | ||
260 | if (mSelStart == NOSELECTION) { | 263 | if (mSelStart == NOSELECTION) { |
261 | return; | 264 | return; |
262 | } | 265 | } |
263 | 266 | ||
264 | //cope with selection being out of matrix limits at top (< 0) | 267 | //cope with selection being out of matrix limits at top (< 0) |
265 | int i0 = mSelStart; | 268 | int i0 = mSelStart; |
266 | if (i0 < 0) { | 269 | if (i0 < 0) { |
267 | for (int i = i0; i < 0; i++) { | 270 | for (int i = i0; i < 0; i++) { |
268 | selDays.append(days[0].addDays(i)); | 271 | selDays.append(days[0].addDays(i)); |
269 | } | 272 | } |
270 | i0 = 0; | 273 | i0 = 0; |
271 | } | 274 | } |
272 | 275 | ||
273 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) | 276 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) |
274 | if (mSelEnd > NUMDAYS-1) { | 277 | if (mSelEnd > NUMDAYS-1) { |
275 | for (int i = i0; i <= NUMDAYS-1; i++) { | 278 | for (int i = i0; i <= NUMDAYS-1; i++) { |
276 | selDays.append(days[i]); | 279 | selDays.append(days[i]); |
277 | } | 280 | } |
278 | for (int i = NUMDAYS; i < mSelEnd; i++) { | 281 | for (int i = NUMDAYS; i < mSelEnd; i++) { |
279 | selDays.append(days[0].addDays(i)); | 282 | selDays.append(days[0].addDays(i)); |
280 | } | 283 | } |
281 | 284 | ||
282 | // apply normal routine to selection being entirely within matrix limits | 285 | // apply normal routine to selection being entirely within matrix limits |
283 | } else { | 286 | } else { |
284 | for (int i = i0; i <= mSelEnd; i++) { | 287 | for (int i = i0; i <= mSelEnd; i++) { |
285 | selDays.append(days[i]); | 288 | selDays.append(days[i]); |
286 | } | 289 | } |
287 | } | 290 | } |
288 | } | 291 | } |
289 | 292 | ||
290 | bool KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) | 293 | bool KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) |
291 | { | 294 | { |
292 | mRedrawNeeded = true; | 295 | mRedrawNeeded = true; |
293 | bool noSel = (mSelEnd == NOSELECTION && mSelStart == NOSELECTION ); | 296 | bool noSel = (mSelEnd == NOSELECTION && mSelStart == NOSELECTION ); |
294 | mSelStart = startdate.daysTo(start); | 297 | mSelStart = startdate.daysTo(start); |
295 | if ( mSelStart < 0 ) | 298 | if ( mSelStart < 0 ) |
296 | mSelStart = 0; | 299 | mSelStart = 0; |
297 | mSelEnd = startdate.daysTo(end); | 300 | mSelEnd = startdate.daysTo(end); |
298 | if ( mSelEnd > NUMDAYS-1 ) | 301 | if ( mSelEnd > NUMDAYS-1 ) |
299 | mSelEnd = NUMDAYS-1; | 302 | mSelEnd = NUMDAYS-1; |
300 | if ( mSelEnd < 0 || mSelStart > NUMDAYS-1 ) { | 303 | if ( mSelEnd < 0 || mSelStart > NUMDAYS-1 ) { |
301 | clearSelection(); | 304 | clearSelection(); |
302 | if ( noSel ) | 305 | if ( noSel ) |
303 | return false; | 306 | return false; |
304 | } | 307 | } |
305 | 308 | ||
306 | return true; | 309 | return true; |
307 | } | 310 | } |
308 | void KODayMatrix::clearSelection() | 311 | void KODayMatrix::clearSelection() |
309 | { | 312 | { |
310 | mSelEnd = mSelStart = NOSELECTION; | 313 | mSelEnd = mSelStart = NOSELECTION; |
311 | } | 314 | } |
312 | 315 | ||
313 | 316 | ||
314 | void KODayMatrix::recalculateToday() | 317 | void KODayMatrix::recalculateToday() |
315 | { | 318 | { |
316 | today = -1; | 319 | today = -1; |
317 | for (int i=0; i<NUMDAYS; i++) { | 320 | for (int i=0; i<NUMDAYS; i++) { |
318 | //events[i] = 0; | 321 | //events[i] = 0; |
319 | days[i] = startdate.addDays(i); | 322 | days[i] = startdate.addDays(i); |
320 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); | 323 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); |
321 | 324 | ||
322 | // if today is in the currently displayed month, hilight today | 325 | // if today is in the currently displayed month, hilight today |
323 | if (days[i].year() == QDate::currentDate().year() && | 326 | if (days[i].year() == QDate::currentDate().year() && |
324 | days[i].month() == QDate::currentDate().month() && | 327 | days[i].month() == QDate::currentDate().month() && |
325 | days[i].day() == QDate::currentDate().day()) { | 328 | days[i].day() == QDate::currentDate().day()) { |
326 | today = i; | 329 | today = i; |
327 | } | 330 | } |
328 | } | 331 | } |
329 | // qDebug(QString("Today is visible at %1.").arg(today)); | 332 | // qDebug(QString("Today is visible at %1.").arg(today)); |
330 | } | 333 | } |
331 | 334 | ||
332 | void KODayMatrix::updateView() | 335 | void KODayMatrix::updateView() |
333 | { | 336 | { |
334 | updateView(startdate); | 337 | updateView(startdate); |
335 | } | 338 | } |
336 | void KODayMatrix::repaintViewTimed() | 339 | void KODayMatrix::repaintViewTimed() |
337 | { | 340 | { |
341 | mRedrawNeeded = true; | ||
342 | bDays.fill( false); | ||
343 | hDays.fill( false); | ||
344 | eDays.fill( false); | ||
338 | mRepaintTimer->stop(); | 345 | mRepaintTimer->stop(); |
339 | repaint(false); | 346 | repaint(false); |
340 | } | 347 | } |
341 | void KODayMatrix::updateViewTimed() | 348 | void KODayMatrix::updateViewTimed() |
342 | { | 349 | { |
343 | mUpdateTimer->stop(); | 350 | mUpdateTimer->stop(); |
344 | if ( !mCalendar ) { | 351 | if ( !mCalendar ) { |
345 | qDebug("NOT CAL "); | 352 | qDebug("NOT CAL "); |
346 | return; | 353 | return; |
347 | } | 354 | } |
348 | //qDebug("KODayMatrix::updateViewTimed "); | 355 | //qDebug("KODayMatrix::updateViewTimed "); |
349 | for(int i = 0; i < NUMDAYS; i++) { | 356 | for(int i = 0; i < NUMDAYS; i++) { |
350 | // if events are set for the day then remember to draw it bold | 357 | // if events are set for the day then remember to draw it bold |
351 | QPtrList<Event> eventlist = mCalendar->events(days[i]); | 358 | QPtrList<Event> eventlist = mCalendar->events(days[i]); |
352 | Event *event; | 359 | Event *event; |
353 | int numEvents = eventlist.count(); | 360 | int numEvents = eventlist.count(); |
354 | QString holiStr = ""; | 361 | QString holiStr = ""; |
355 | bDays.clearBit(i); | 362 | bDays.clearBit(i); |
356 | hDays.clearBit(i); | 363 | hDays.clearBit(i); |
357 | eDays.clearBit(i); | 364 | eDays.clearBit(i); |
358 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 365 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
359 | ushort recurType = event->recurrence()->doesRecur(); | 366 | ushort recurType = event->recurrence()->doesRecur(); |
360 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || | 367 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || |
361 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { | 368 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { |
362 | numEvents--; | 369 | numEvents--; |
363 | } | 370 | } |
364 | if ( event->isHoliday()) { | 371 | if ( event->isHoliday()) { |
365 | hDays.setBit(i); | 372 | hDays.setBit(i); |
366 | if ( !holiStr.isEmpty() ) | 373 | if ( !holiStr.isEmpty() ) |
367 | holiStr += "\n"; | 374 | holiStr += "\n"; |
368 | holiStr += event->summary(); | 375 | holiStr += event->summary(); |
369 | if ( !event->location().isEmpty() ) | 376 | if ( !event->location().isEmpty() ) |
370 | holiStr += " (" + event->location() + ")"; | 377 | holiStr += " (" + event->location() + ")"; |
371 | } | 378 | } |
372 | if ( event->isBirthday()) { | 379 | if ( event->isBirthday()) { |
373 | if ( !holiStr.isEmpty() ) | 380 | if ( !holiStr.isEmpty() ) |
374 | holiStr += "\n"; | 381 | holiStr += "\n"; |
375 | holiStr += i18n("Birthday") + ": "+event->summary(); | 382 | holiStr += i18n("Birthday") + ": "+event->summary(); |
376 | if ( !event->location().isEmpty() ) | 383 | if ( !event->location().isEmpty() ) |
377 | holiStr += " (" + event->location() + ")"; | 384 | holiStr += " (" + event->location() + ")"; |
378 | bDays.setBit(i); | 385 | bDays.setBit(i); |
379 | } | 386 | } |
380 | } | 387 | } |
381 | if ( numEvents ) | 388 | if ( numEvents ) |
382 | eDays.setBit(i); | 389 | eDays.setBit(i); |
383 | //if it is a holy day then draw it red. Sundays are consider holidays, too | 390 | //if it is a holy day then draw it red. Sundays are consider holidays, too |
384 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || | 391 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || |
385 | !holiStr.isEmpty()) { | 392 | !holiStr.isEmpty()) { |
386 | mHolidays[i] = holiStr; | 393 | mHolidays[i] = holiStr; |
387 | } else { | 394 | } else { |
388 | mHolidays[i] = QString::null; | 395 | mHolidays[i] = QString::null; |
389 | } | 396 | } |
390 | } | 397 | } |
391 | mRedrawNeeded = true; | 398 | mRedrawNeeded = true; |
392 | if ( ! mPendingUpdateBeforeRepaint ) | 399 | if ( ! mPendingUpdateBeforeRepaint ) |
393 | repaint(false); | 400 | repaint(false); |
394 | } | 401 | } |
395 | void KODayMatrix::updateView(QDate actdate) | 402 | void KODayMatrix::updateView(QDate actdate) |
396 | { | 403 | { |
397 | 404 | ||
398 | if ( ! actdate.isValid() ) { | 405 | if ( ! actdate.isValid() ) { |
399 | //qDebug("date not valid "); | 406 | //qDebug("date not valid "); |
400 | return; | 407 | return; |
401 | } | 408 | } |
402 | mDayChanged = false; | 409 | mDayChanged = false; |
403 | //flag to indicate if the starting day of the matrix has changed by this call | 410 | //flag to indicate if the starting day of the matrix has changed by this call |
404 | //mDayChanged = false; | 411 | //mDayChanged = false; |
405 | // if a new startdate is to be set then apply Cornelius's calculation | 412 | // if a new startdate is to be set then apply Cornelius's calculation |
406 | // of the first day to be shown | 413 | // of the first day to be shown |
407 | if (actdate != startdate) { | 414 | if (actdate != startdate) { |
408 | // reset index of selection according to shift of starting date from startdate to actdate | 415 | // reset index of selection according to shift of starting date from startdate to actdate |
409 | if (mSelStart != NOSELECTION) { | 416 | if (mSelStart != NOSELECTION) { |
410 | int tmp = actdate.daysTo(startdate); | 417 | int tmp = actdate.daysTo(startdate); |
411 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; | 418 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; |
412 | // shift selection if new one would be visible at least partly ! | 419 | // shift selection if new one would be visible at least partly ! |
413 | 420 | ||
414 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { | 421 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { |
415 | // nested if is required for next X display pushed from a different month - correction required | 422 | // nested if is required for next X display pushed from a different month - correction required |
416 | // otherwise, for month forward and backward, it must be avoided | 423 | // otherwise, for month forward and backward, it must be avoided |
417 | if( mSelStart > NUMDAYS || mSelStart < 0 ) | 424 | if( mSelStart > NUMDAYS || mSelStart < 0 ) |
418 | mSelStart = mSelStart + tmp; | 425 | mSelStart = mSelStart + tmp; |
419 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) | 426 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) |
420 | mSelEnd = mSelEnd + tmp; | 427 | mSelEnd = mSelEnd + tmp; |
421 | } | 428 | } |
422 | } | 429 | } |
423 | startdate = actdate; | 430 | startdate = actdate; |
424 | mDayChanged = true; | 431 | mDayChanged = true; |
425 | recalculateToday(); | 432 | recalculateToday(); |
426 | mRedrawNeeded = true; | 433 | mRedrawNeeded = true; |
427 | } | 434 | } |
428 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); | 435 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); |
429 | if ( !isVisible() ) { | 436 | if ( !isVisible() ) { |
430 | mPendingUpdateBeforeRepaint = true; | 437 | mPendingUpdateBeforeRepaint = true; |
431 | } else { | 438 | } else { |
432 | #ifdef DESKTOP_VERSION | 439 | #ifdef DESKTOP_VERSION |
433 | //mRepaintTimer->start( 100 ); | 440 | //mRepaintTimer->start( 100 ); |
434 | //updateViewTimed(); | 441 | //updateViewTimed(); |
435 | mUpdateTimer->start( 50 ); | 442 | mUpdateTimer->start( 50 ); |
436 | #else | 443 | #else |
437 | mRepaintTimer->start( 350 ); | 444 | mRepaintTimer->start( 350 ); |
438 | mUpdateTimer->start( 1200 ); | 445 | mUpdateTimer->start( 1200 ); |
439 | #endif | 446 | #endif |
440 | } | 447 | } |
441 | } | 448 | } |
442 | void KODayMatrix::updateEvents() | 449 | void KODayMatrix::updateEvents() |
443 | { | 450 | { |
444 | if ( !mCalendar ) return; | 451 | if ( !mCalendar ) return; |
445 | 452 | ||
446 | for( int i = 0; i < NUMDAYS; i++ ) { | 453 | for( int i = 0; i < NUMDAYS; i++ ) { |
447 | // if events are set for the day then remember to draw it bold | 454 | // if events are set for the day then remember to draw it bold |
448 | QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); | 455 | QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); |
449 | int numEvents = eventlist.count(); | 456 | int numEvents = eventlist.count(); |
450 | Event *event; | 457 | Event *event; |
451 | for( event = eventlist.first(); event != 0;event=eventlist.next()) { | 458 | for( event = eventlist.first(); event != 0;event=eventlist.next()) { |
452 | ushort recurType = event->doesRecur(); | 459 | ushort recurType = event->doesRecur(); |
453 | 460 | ||
454 | if ( ( recurType == Recurrence::rDaily && | 461 | if ( ( recurType == Recurrence::rDaily && |
455 | !KOPrefs::instance()->mDailyRecur ) || | 462 | !KOPrefs::instance()->mDailyRecur ) || |
456 | ( recurType == Recurrence::rWeekly && | 463 | ( recurType == Recurrence::rWeekly && |
457 | !KOPrefs::instance()->mWeeklyRecur ) ) { | 464 | !KOPrefs::instance()->mWeeklyRecur ) ) { |
458 | numEvents--; | 465 | numEvents--; |
459 | } | 466 | } |
460 | } | 467 | } |
461 | if ( numEvents ) | 468 | if ( numEvents ) |
462 | eDays.setBit(i); | 469 | eDays.setBit(i); |
463 | else | 470 | else |
464 | eDays.clearBit(i); | 471 | eDays.clearBit(i); |
465 | } | 472 | } |
466 | } | 473 | } |
467 | 474 | ||
468 | const QDate& KODayMatrix::getDate(int offset) | 475 | const QDate& KODayMatrix::getDate(int offset) |
469 | { | 476 | { |
470 | if (offset < 0 || offset > NUMDAYS-1) { | 477 | if (offset < 0 || offset > NUMDAYS-1) { |
471 | qDebug("Wrong offset2 %d", offset); | 478 | qDebug("Wrong offset2 %d", offset); |
472 | return days[0]; | 479 | return days[0]; |
473 | } | 480 | } |
474 | return days[offset]; | 481 | return days[offset]; |
475 | } | 482 | } |
476 | 483 | ||
477 | QString KODayMatrix::getHolidayLabel(int offset) | 484 | QString KODayMatrix::getHolidayLabel(int offset) |
478 | { | 485 | { |
479 | if (offset < 0 || offset > NUMDAYS-1) { | 486 | if (offset < 0 || offset > NUMDAYS-1) { |
480 | qDebug("Wrong offset1 %d", offset); | 487 | qDebug("Wrong offset1 %d", offset); |
481 | return QString(); | 488 | return QString(); |
482 | } | 489 | } |
483 | return mHolidays[offset]; | 490 | return mHolidays[offset]; |
484 | } | 491 | } |
485 | 492 | ||
486 | int KODayMatrix::getDayIndexFrom(int x, int y) | 493 | int KODayMatrix::getDayIndexFrom(int x, int y) |
487 | { | 494 | { |
488 | int colModulo = (width()-2) % 7; | 495 | int colModulo = (width()-2) % 7; |
489 | int rowModulo = (height()-2) % 6; | 496 | int rowModulo = (height()-2) % 6; |
490 | #if 0 | 497 | #if 0 |
491 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? | 498 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? |
492 | 6 - x/daysize.width() : x/daysize.width()); | 499 | 6 - x/daysize.width() : x/daysize.width()); |
493 | #endif | 500 | #endif |
494 | int xVal = (x-colModulo/2-2)/daysize.width(); | 501 | int xVal = (x-colModulo/2-2)/daysize.width(); |
495 | int yVal = (y-rowModulo/2-2)/daysize.height(); | 502 | int yVal = (y-rowModulo/2-2)/daysize.height(); |
496 | 503 | ||
497 | 504 | ||
498 | return 7*(yVal) + xVal; | 505 | return 7*(yVal) + xVal; |
499 | 506 | ||
500 | } | 507 | } |
501 | 508 | ||
502 | // ---------------------------------------------------------------------------- | 509 | // ---------------------------------------------------------------------------- |
503 | // M O U S E E V E N T H A N D L I N G | 510 | // M O U S E E V E N T H A N D L I N G |
504 | // ---------------------------------------------------------------------------- | 511 | // ---------------------------------------------------------------------------- |
505 | 512 | ||
506 | void KODayMatrix::mousePressEvent (QMouseEvent* e) | 513 | void KODayMatrix::mousePressEvent (QMouseEvent* e) |
507 | { | 514 | { |
508 | 515 | ||
509 | if ( e->button() == LeftButton ) | 516 | if ( e->button() == LeftButton ) |
510 | mouseDown = true; | 517 | mouseDown = true; |
511 | mSelStart = getDayIndexFrom(e->x(), e->y()); | 518 | mSelStart = getDayIndexFrom(e->x(), e->y()); |
512 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; | 519 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; |
513 | mSelInit = mSelStart; | 520 | mSelInit = mSelStart; |
514 | mSelEnd = mSelStart; | 521 | mSelEnd = mSelStart; |
515 | mRedrawNeeded = true; | 522 | mRedrawNeeded = true; |
516 | repaint(false); | 523 | repaint(false); |
517 | } | 524 | } |
518 | 525 | ||
519 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) | 526 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) |
520 | { | 527 | { |
521 | mRedrawNeeded = true; | 528 | mRedrawNeeded = true; |
522 | if ( e->button() == LeftButton ) | 529 | if ( e->button() == LeftButton ) |
523 | if ( ! mouseDown ) { | 530 | if ( ! mouseDown ) { |
524 | return; | 531 | return; |
525 | } | 532 | } |
526 | else | 533 | else |
527 | mouseDown = false; | 534 | mouseDown = false; |
528 | int tmp = getDayIndexFrom(e->x(), e->y()); | 535 | int tmp = getDayIndexFrom(e->x(), e->y()); |
529 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 536 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
530 | 537 | ||
531 | if (mSelInit > tmp) { | 538 | if (mSelInit > tmp) { |
532 | mSelEnd = mSelInit; | 539 | mSelEnd = mSelInit; |
533 | if (tmp != mSelStart) { | 540 | if (tmp != mSelStart) { |
534 | mSelStart = tmp; | 541 | mSelStart = tmp; |
535 | repaint(false); | 542 | repaint(false); |
536 | } | 543 | } |
537 | } else { | 544 | } else { |
538 | mSelStart = mSelInit; | 545 | mSelStart = mSelInit; |
539 | 546 | ||
540 | //repaint only if selection has changed | 547 | //repaint only if selection has changed |
541 | if (tmp != mSelEnd) { | 548 | if (tmp != mSelEnd) { |
542 | mSelEnd = tmp; | 549 | mSelEnd = tmp; |
543 | repaint(false); | 550 | repaint(false); |
544 | } | 551 | } |
545 | } | 552 | } |
546 | 553 | ||
547 | DateList daylist; | 554 | DateList daylist; |
548 | if ( mSelStart < 0 ) | 555 | if ( mSelStart < 0 ) |
549 | mSelStart = 0; | 556 | mSelStart = 0; |
550 | for (int i = mSelStart; i <= mSelEnd; i++) { | 557 | for (int i = mSelStart; i <= mSelEnd; i++) { |
551 | daylist.append(days[i]); | 558 | daylist.append(days[i]); |
552 | } | 559 | } |
553 | emit selected((const DateList)daylist); | 560 | emit selected((const DateList)daylist); |
554 | 561 | ||
555 | } | 562 | } |
556 | 563 | ||
557 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) | 564 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) |
558 | { | 565 | { |
559 | if ( ! mouseDown ) { | 566 | if ( ! mouseDown ) { |
560 | return; | 567 | return; |
561 | } | 568 | } |
562 | mRedrawNeeded = true; | 569 | mRedrawNeeded = true; |
563 | int tmp = getDayIndexFrom(e->x(), e->y()); | 570 | int tmp = getDayIndexFrom(e->x(), e->y()); |
564 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 571 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
565 | 572 | ||
566 | if (mSelInit > tmp) { | 573 | if (mSelInit > tmp) { |
567 | mSelEnd = mSelInit; | 574 | mSelEnd = mSelInit; |
568 | if (tmp != mSelStart) { | 575 | if (tmp != mSelStart) { |
569 | mSelStart = tmp; | 576 | mSelStart = tmp; |
570 | repaint(false); | 577 | repaint(false); |
571 | } | 578 | } |
572 | } else { | 579 | } else { |
573 | mSelStart = mSelInit; | 580 | mSelStart = mSelInit; |
574 | 581 | ||
575 | //repaint only if selection has changed | 582 | //repaint only if selection has changed |
576 | if (tmp != mSelEnd) { | 583 | if (tmp != mSelEnd) { |
577 | mSelEnd = tmp; | 584 | mSelEnd = tmp; |
578 | repaint(false); | 585 | repaint(false); |
579 | } | 586 | } |
580 | } | 587 | } |
581 | } | 588 | } |
582 | 589 | ||
583 | // ---------------------------------------------------------------------------- | 590 | // ---------------------------------------------------------------------------- |
584 | // D R A G ' N D R O P H A N D L I N G | 591 | // D R A G ' N D R O P H A N D L I N G |
585 | // ---------------------------------------------------------------------------- | 592 | // ---------------------------------------------------------------------------- |
586 | 593 | ||
587 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) | 594 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) |
588 | { | 595 | { |
589 | #ifndef KORG_NODND | 596 | #ifndef KORG_NODND |
590 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 597 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
591 | e->ignore(); | 598 | e->ignore(); |
592 | return; | 599 | return; |
593 | } | 600 | } |
594 | 601 | ||
595 | // some visual feedback | 602 | // some visual feedback |
596 | // oldPalette = palette(); | 603 | // oldPalette = palette(); |
597 | // setPalette(my_HilitePalette); | 604 | // setPalette(my_HilitePalette); |
598 | // update(); | 605 | // update(); |
599 | #endif | 606 | #endif |
600 | } | 607 | } |
601 | 608 | ||
602 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) | 609 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) |
603 | { | 610 | { |
604 | #ifndef KORG_NODND | 611 | #ifndef KORG_NODND |
605 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 612 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
606 | e->ignore(); | 613 | e->ignore(); |
607 | return; | 614 | return; |
608 | } | 615 | } |
609 | 616 | ||
610 | e->accept(); | 617 | e->accept(); |
611 | #endif | 618 | #endif |
612 | } | 619 | } |
613 | 620 | ||
614 | void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) | 621 | void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) |
615 | { | 622 | { |
616 | #ifndef KORG_NODND | 623 | #ifndef KORG_NODND |
617 | // setPalette(oldPalette); | 624 | // setPalette(oldPalette); |
618 | // update(); | 625 | // update(); |
619 | #endif | 626 | #endif |
620 | } | 627 | } |
621 | 628 | ||
622 | void KODayMatrix::dropEvent(QDropEvent *e) | 629 | void KODayMatrix::dropEvent(QDropEvent *e) |
623 | { | 630 | { |
624 | #ifndef KORG_NODND | 631 | #ifndef KORG_NODND |
625 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; | 632 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; |
626 | 633 | ||
627 | if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 634 | if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
628 | e->ignore(); | 635 | e->ignore(); |
629 | return; | 636 | return; |
630 | } | 637 | } |
631 | 638 | ||
632 | DndFactory factory( mCalendar ); | 639 | DndFactory factory( mCalendar ); |
633 | Event *event = factory.createDrop(e); | 640 | Event *event = factory.createDrop(e); |
634 | 641 | ||
635 | if (event) { | 642 | if (event) { |
636 | e->acceptAction(); | 643 | e->acceptAction(); |
637 | 644 | ||
638 | Event *existingEvent = mCalendar->event(event->uid()); | 645 | Event *existingEvent = mCalendar->event(event->uid()); |
639 | 646 | ||
640 | if(existingEvent) { | 647 | if(existingEvent) { |
641 | // uniquify event | 648 | // uniquify event |
642 | event->recreate(); | 649 | event->recreate(); |
643 | /* | 650 | /* |
644 | KMessageBox::sorry(this, | 651 | KMessageBox::sorry(this, |
645 | i18n("Event already exists in this calendar."), | 652 | i18n("Event already exists in this calendar."), |
646 | i18n("Drop Event")); | 653 | i18n("Drop Event")); |
647 | delete event; | 654 | delete event; |
648 | return; | 655 | return; |
649 | */ | 656 | */ |
650 | } | 657 | } |
651 | // kdDebug() << "Drop new Event" << endl; | 658 | // kdDebug() << "Drop new Event" << endl; |
652 | // Adjust date | 659 | // Adjust date |
653 | QDateTime start = event->dtStart(); | 660 | QDateTime start = event->dtStart(); |
654 | QDateTime end = event->dtEnd(); | 661 | QDateTime end = event->dtEnd(); |
655 | int duration = start.daysTo(end); | 662 | int duration = start.daysTo(end); |
656 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); | 663 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); |
657 | 664 | ||
658 | start.setDate(days[idx]); | 665 | start.setDate(days[idx]); |
659 | end.setDate(days[idx].addDays(duration)); | 666 | end.setDate(days[idx].addDays(duration)); |
660 | 667 | ||
661 | event->setDtStart(start); | 668 | event->setDtStart(start); |
662 | event->setDtEnd(end); | 669 | event->setDtEnd(end); |
663 | mCalendar->addEvent(event); | 670 | mCalendar->addEvent(event); |
664 | 671 | ||
665 | emit eventDropped(event); | 672 | emit eventDropped(event); |
666 | } else { | 673 | } else { |
667 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; | 674 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; |
668 | e->ignore(); | 675 | e->ignore(); |
669 | } | 676 | } |
670 | #endif | 677 | #endif |
671 | } | 678 | } |
672 | 679 | ||
673 | // ---------------------------------------------------------------------------- | 680 | // ---------------------------------------------------------------------------- |
674 | // P A I N T E V E N T H A N D L I N G | 681 | // P A I N T E V E N T H A N D L I N G |
675 | // ---------------------------------------------------------------------------- | 682 | // ---------------------------------------------------------------------------- |
676 | 683 | ||
677 | void KODayMatrix::paintEvent(QPaintEvent * pevent) | 684 | void KODayMatrix::paintEvent(QPaintEvent * pevent) |
678 | { | 685 | { |
679 | 686 | ||
680 | if ( width() <= 0 || height() <= 0 ) | 687 | if ( width() <= 0 || height() <= 0 ) |
681 | return; | 688 | return; |
682 | if ( mPendingUpdateBeforeRepaint ) { | 689 | if ( mPendingUpdateBeforeRepaint ) { |
683 | updateViewTimed(); | 690 | updateViewTimed(); |
684 | mPendingUpdateBeforeRepaint = false; | 691 | mPendingUpdateBeforeRepaint = false; |
685 | } | 692 | } |
693 | #if 0 | ||
686 | if ( myPix.width() != width() || myPix.height()!=height() ) { | 694 | if ( myPix.width() != width() || myPix.height()!=height() ) { |
687 | myPix.resize(size() ); | 695 | myPix.resize(size() ); |
688 | mRedrawNeeded = true; | 696 | mRedrawNeeded = true; |
689 | } | 697 | } |
690 | 698 | #endif | |
699 | if ( oldW != width() || oldH !=height() ) | ||
700 | mRedrawNeeded = true; | ||
701 | |||
702 | oldH = height() ; | ||
703 | oldW = width(); | ||
704 | if ( myPix.width() < width() || myPix.height() < height() ) { | ||
705 | myPix.resize(size() ); | ||
706 | mRedrawNeeded = true; | ||
707 | |||
708 | } | ||
709 | |||
691 | if ( mRedrawNeeded ) { | 710 | if ( mRedrawNeeded ) { |
692 | //qDebug("REDRAW "); | 711 | //qDebug("REDRAW "); |
693 | QPainter p(&myPix); | 712 | QPainter p(&myPix); |
694 | p.setFont(font()); | 713 | p.setFont(font()); |
695 | 714 | ||
696 | 715 | ||
697 | int dheight = daysize.height(); | 716 | int dheight = daysize.height(); |
698 | int dwidth = daysize.width(); | 717 | int dwidth = daysize.width(); |
699 | int row,col; | 718 | int row,col; |
700 | int selw, selh; | 719 | int selw, selh; |
701 | int xyOff = frameWidth(); | 720 | int xyOff = frameWidth(); |
702 | int colModulo = (width()-2) % 7; | 721 | int colModulo = (width()-2) % 7; |
703 | int rowModulo = (height()-2) % 6; | 722 | int rowModulo = (height()-2) % 6; |
704 | //qDebug("col %d row %d ",colModulo,rowModulo ); | 723 | //qDebug("col %d row %d ",colModulo,rowModulo ); |
705 | 724 | ||
706 | bool isRTL = KOGlobals::self()->reverseLayout(); | 725 | bool isRTL = KOGlobals::self()->reverseLayout(); |
707 | 726 | ||
708 | // draw background and topleft frame | 727 | // draw background and topleft frame |
709 | p.fillRect(0,0,width(),height(), mDefaultBackColor); | 728 | p.fillRect(0,0,width(),height(), mDefaultBackColor); |
710 | p.setPen(mDefaultTextColor); | 729 | p.setPen(mDefaultTextColor); |
711 | p.drawRect(0, 0, width(), height()); | 730 | p.drawRect(0, 0, width(), height()); |
712 | int mSelStartT = mSelStart; | 731 | int mSelStartT = mSelStart; |
713 | int mSelEndT = mSelEnd; | 732 | int mSelEndT = mSelEnd; |
714 | if ( mSelEndT >= NUMDAYS ) | 733 | if ( mSelEndT >= NUMDAYS ) |
715 | mSelEndT = NUMDAYS-1; | 734 | mSelEndT = NUMDAYS-1; |
716 | // draw selected days with highlighted background color | 735 | // draw selected days with highlighted background color |
717 | if (mSelStart != NOSELECTION) { | 736 | if (mSelStart != NOSELECTION) { |
718 | bool skip = false; | 737 | bool skip = false; |
719 | if ( ! mouseDown ) { | 738 | if ( ! mouseDown ) { |
720 | int mo = days[20].month(); | 739 | int mo = days[20].month(); |
721 | //qDebug("-- %d %d ", mSelStartT, mSelEndT); | 740 | //qDebug("-- %d %d ", mSelStartT, mSelEndT); |
722 | //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); | 741 | //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); |
723 | int startMo = days[mSelStartT].month(); | 742 | int startMo = days[mSelStartT].month(); |
724 | int endMo = days[mSelEndT].month(); | 743 | int endMo = days[mSelEndT].month(); |
725 | if ( startMo == 12 && mo == 1 && endMo <= 2 ) | 744 | if ( startMo == 12 && mo == 1 && endMo <= 2 ) |
726 | startMo = 1; | 745 | startMo = 1; |
727 | if ( endMo == 1 && mo == 12 ) | 746 | if ( endMo == 1 && mo == 12 ) |
728 | endMo = 12; | 747 | endMo = 12; |
729 | if ( mo == 12 && startMo == 1 ) | 748 | if ( mo == 12 && startMo == 1 ) |
730 | startMo = 13; | 749 | startMo = 13; |
731 | if ( (startMo > mo || endMo < mo) ) { | 750 | if ( (startMo > mo || endMo < mo) ) { |
732 | skip = true; | 751 | skip = true; |
733 | } else { | 752 | } else { |
734 | if ( days[mSelStartT].month() != mo ) { | 753 | if ( days[mSelStartT].month() != mo ) { |
735 | int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); | 754 | int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); |
736 | mSelStartT += add +1; | 755 | mSelStartT += add +1; |
737 | } | 756 | } |
738 | if ( days[mSelEndT].month() != mo ) { | 757 | if ( days[mSelEndT].month() != mo ) { |
739 | int sub = days[mSelEndT].day(); | 758 | int sub = days[mSelEndT].day(); |
740 | mSelEndT -= sub ; | 759 | mSelEndT -= sub ; |
741 | } | 760 | } |
742 | } | 761 | } |
743 | } | 762 | } |
744 | //qDebug("SKIP %d ", skip); | 763 | //qDebug("SKIP %d ", skip); |
745 | if ( ! skip ) { | 764 | if ( ! skip ) { |
746 | row = mSelStartT/7; | 765 | row = mSelStartT/7; |
747 | col = mSelStartT -row*7; | 766 | col = mSelStartT -row*7; |
748 | QColor selcol = KOPrefs::instance()->mHighlightColor; | 767 | QColor selcol = KOPrefs::instance()->mHighlightColor; |
749 | int addCol = 0; | 768 | int addCol = 0; |
750 | int addRow = 0; | 769 | int addRow = 0; |
751 | int addRow2 = 0; | 770 | int addRow2 = 0; |
752 | int addCol2 = 0; | 771 | int addCol2 = 0; |
753 | if (row == mSelEndT/7) { | 772 | if (row == mSelEndT/7) { |
754 | if ( rowModulo ) { | 773 | if ( rowModulo ) { |
755 | if ( row >= 6 - rowModulo ) | 774 | if ( row >= 6 - rowModulo ) |
756 | addRow = row - 5 + rowModulo; | 775 | addRow = row - 5 + rowModulo; |
757 | } | 776 | } |
758 | if ( colModulo ) { | 777 | if ( colModulo ) { |
759 | int colt1 = mSelEndT%7; | 778 | int colt1 = mSelEndT%7; |
760 | //qDebug("colt1 %d ", colt1 ); | 779 | //qDebug("colt1 %d ", colt1 ); |
761 | if ( colt1 >= 7 - colModulo ) | 780 | if ( colt1 >= 7 - colModulo ) |
762 | addCol = colt1 - 7 + colModulo+1; | 781 | addCol = colt1 - 7 + colModulo+1; |
763 | int colt = mSelStartT%7; | 782 | int colt = mSelStartT%7; |
764 | if ( colt >= 7 - colModulo ) | 783 | if ( colt >= 7 - colModulo ) |
765 | addCol2 = colt - 7 + colModulo; | 784 | addCol2 = colt - 7 + colModulo; |
766 | addCol -= addCol2; | 785 | addCol -= addCol2; |
767 | //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 ); | 786 | //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 ); |
768 | } | 787 | } |
769 | // Single row selection | 788 | // Single row selection |
770 | //if ( row == 0) | 789 | //if ( row == 0) |
771 | // addRow = 1; | 790 | // addRow = 1; |
772 | p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2, | 791 | p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2, |
773 | row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol); | 792 | row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol); |
774 | } else { | 793 | } else { |
775 | // draw first row to the right | 794 | // draw first row to the right |
776 | if ( colModulo ) { | 795 | if ( colModulo ) { |
777 | if ( col >= 7 - colModulo ) | 796 | if ( col >= 7 - colModulo ) |
778 | addCol2 = col - 7 + colModulo; | 797 | addCol2 = col - 7 + colModulo; |
779 | } | 798 | } |
780 | if ( rowModulo ) { | 799 | if ( rowModulo ) { |
781 | if ( row >= 6 - rowModulo ) | 800 | if ( row >= 6 - rowModulo ) |
782 | addRow = row - 5 + rowModulo; | 801 | addRow = row - 5 + rowModulo; |
783 | } | 802 | } |
784 | //if ( row == 0) | 803 | //if ( row == 0) |
785 | // addRow = 1; | 804 | // addRow = 1; |
786 | int drawWid = width()-(col*dwidth+1+addCol2)-1; | 805 | int drawWid = width()-(col*dwidth+1+addCol2)-1; |
787 | p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, drawWid, | 806 | p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, drawWid, |
788 | dheight+1, selcol); | 807 | dheight+1, selcol); |
789 | // draw full block till last line | 808 | // draw full block till last line |
790 | selh = mSelEndT/7-row; | 809 | selh = mSelEndT/7-row; |
791 | addRow = 0; | 810 | addRow = 0; |
792 | if ( rowModulo ) { | 811 | if ( rowModulo ) { |
793 | if ( mSelEndT/7 >= 6 - rowModulo ) | 812 | if ( mSelEndT/7 >= 6 - rowModulo ) |
794 | addRow = mSelEndT/7 - 5 + rowModulo; | 813 | addRow = mSelEndT/7 - 5 + rowModulo; |
795 | } | 814 | } |
796 | //qDebug("%d %d %d ",selh, row, addRow ); | 815 | //qDebug("%d %d %d ",selh, row, addRow ); |
797 | int addrow2 = addRow-selh+1; | 816 | int addrow2 = addRow-selh+1; |
798 | if ( addrow2 < 0 ) | 817 | if ( addrow2 < 0 ) |
799 | addrow2 = 0; | 818 | addrow2 = 0; |
800 | if (selh > 1) { | 819 | if (selh > 1) { |
801 | p.fillRect(1, (row+1)*dheight+addrow2, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol); | 820 | p.fillRect(1, (row+1)*dheight+addrow2, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol); |
802 | } | 821 | } |
803 | // draw last block from left to mSelEndT | 822 | // draw last block from left to mSelEndT |
804 | selw = mSelEndT-7*(mSelEndT/7)+1; | 823 | selw = mSelEndT-7*(mSelEndT/7)+1; |
805 | //qDebug("esl %d ",selw ); | 824 | //qDebug("esl %d ",selw ); |
806 | int add = 0; | 825 | int add = 0; |
807 | if ( colModulo ) { | 826 | if ( colModulo ) { |
808 | add = 7 - colModulo; | 827 | add = 7 - colModulo; |
809 | if ( selw > add ) | 828 | if ( selw > add ) |
810 | add = selw - add; | 829 | add = selw - add; |
811 | else | 830 | else |
812 | add = 0; | 831 | add = 0; |
813 | } | 832 | } |
814 | //qDebug("add %d ", add); | 833 | //qDebug("add %d ", add); |
815 | p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow, | 834 | p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow, |
816 | selw*dwidth+add, dheight+1, selcol); | 835 | selw*dwidth+add, dheight+1, selcol); |
817 | } | 836 | } |
818 | } | 837 | } |
819 | } | 838 | } |
820 | 839 | ||
821 | // iterate over all days in the matrix and draw the day label in appropriate colors | 840 | // iterate over all days in the matrix and draw the day label in appropriate colors |
822 | QColor actcol = mDefaultTextColorShaded; | 841 | QColor actcol = mDefaultTextColorShaded; |
823 | p.setPen(actcol); | 842 | p.setPen(actcol); |
824 | QPen tmppen; | 843 | QPen tmppen; |
825 | for(int i = 0; i < NUMDAYS; i++) { | 844 | for(int i = 0; i < NUMDAYS; i++) { |
826 | row = i/7; | 845 | row = i/7; |
827 | col = isRTL ? 6-(i-row*7) : i-row*7; | 846 | col = isRTL ? 6-(i-row*7) : i-row*7; |
828 | 847 | ||
829 | // if it is the first day of a month switch color from normal to shaded and vice versa | 848 | // if it is the first day of a month switch color from normal to shaded and vice versa |
830 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { | 849 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { |
831 | if (actcol == mDefaultTextColorShaded) { | 850 | if (actcol == mDefaultTextColorShaded) { |
832 | actcol = mDefaultTextColor; | 851 | actcol = mDefaultTextColor; |
833 | } else { | 852 | } else { |
834 | actcol = mDefaultTextColorShaded; | 853 | actcol = mDefaultTextColorShaded; |
835 | } | 854 | } |
836 | p.setPen(actcol); | 855 | p.setPen(actcol); |
837 | } | 856 | } |
838 | if (actcol == mDefaultTextColorShaded) { | 857 | if (actcol == mDefaultTextColorShaded) { |
839 | if ( ! mouseDown ) { | 858 | if ( ! mouseDown ) { |
840 | continue; | 859 | continue; |
841 | } | 860 | } |
842 | } | 861 | } |
843 | //Reset pen color after selected days block | 862 | //Reset pen color after selected days block |
844 | if (i == mSelEndT+1) { | 863 | if (i == mSelEndT+1) { |
845 | p.setPen(actcol); | 864 | p.setPen(actcol); |
846 | } | 865 | } |
847 | 866 | ||
848 | // if today then draw rectangle around day | 867 | // if today then draw rectangle around day |
849 | if (today == i) { | 868 | if (today == i) { |
850 | tmppen = p.pen(); | 869 | tmppen = p.pen(); |
851 | QPen mTodayPen(p.pen()); | 870 | QPen mTodayPen(p.pen()); |
852 | if ( daysize.width() < 20 ) | 871 | if ( daysize.width() < 20 ) |
853 | mTodayPen.setWidth(1); | 872 | mTodayPen.setWidth(1); |
854 | else | 873 | else |
855 | mTodayPen.setWidth(mTodayMarginWidth); | 874 | mTodayPen.setWidth(mTodayMarginWidth); |
856 | //draw red rectangle for holidays | 875 | //draw red rectangle for holidays |
857 | if (!mHolidays[i].isNull()) { | 876 | if (!mHolidays[i].isNull()) { |
858 | if (actcol == mDefaultTextColor) { | 877 | if (actcol == mDefaultTextColor) { |
859 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); | 878 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); |
860 | } else { | 879 | } else { |
861 | mTodayPen.setColor(mHolidayColorShaded); | 880 | mTodayPen.setColor(mHolidayColorShaded); |
862 | } | 881 | } |
863 | } | 882 | } |
864 | //draw gray rectangle for today if in selection | 883 | //draw gray rectangle for today if in selection |
865 | if (i >= mSelStartT && i <= mSelEndT) { | 884 | if (i >= mSelStartT && i <= mSelEndT) { |
866 | QColor grey("grey"); | 885 | QColor grey("grey"); |
867 | mTodayPen.setColor(grey); | 886 | mTodayPen.setColor(grey); |
868 | } | 887 | } |
869 | p.setPen(mTodayPen); | 888 | p.setPen(mTodayPen); |
870 | 889 | ||
871 | 890 | ||
872 | int addCol = 0; | 891 | int addCol = 0; |
873 | int addRow = 0; | 892 | int addRow = 0; |
874 | if (rowModulo) { | 893 | if (rowModulo) { |
875 | if ( row >= 6 - rowModulo ) | 894 | if ( row >= 6 - rowModulo ) |
876 | addRow = row - 5 + rowModulo; | 895 | addRow = row - 5 + rowModulo; |
877 | } | 896 | } |
878 | if ( colModulo ) { | 897 | if ( colModulo ) { |
879 | if ( col >= 7 - colModulo ) | 898 | if ( col >= 7 - colModulo ) |
880 | addCol = col - 6 + colModulo-1; | 899 | addCol = col - 6 + colModulo-1; |
881 | } | 900 | } |
882 | 901 | ||
883 | addCol += 1; | 902 | addCol += 1; |
884 | if ( row == 0 ) | 903 | if ( row == 0 ) |
885 | addRow = 1; | 904 | addRow = 1; |
886 | p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth+1, dheight+1); | 905 | p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth+1, dheight+1); |
887 | p.setPen(tmppen); | 906 | p.setPen(tmppen); |
888 | } | 907 | } |
889 | 908 | ||
890 | // if any events are on that day then draw it using a bold font | 909 | // if any events are on that day then draw it using a bold font |
891 | if ( eDays.testBit(i) ) { | 910 | if ( eDays.testBit(i) ) { |
892 | QFont myFont = font(); | 911 | QFont myFont = font(); |
893 | myFont.setBold(true); | 912 | myFont.setBold(true); |
894 | p.setFont(myFont); | 913 | p.setFont(myFont); |
895 | } | 914 | } |
896 | 915 | ||
897 | // if it is a holiday then use the default holiday color | 916 | // if it is a holiday then use the default holiday color |
898 | if ( !mHolidays[i].isNull()) { | 917 | if ( !mHolidays[i].isNull()) { |
899 | if ( bDays.testBit(i) ) { | 918 | if ( bDays.testBit(i) ) { |
900 | if ( hDays.testBit(i) ) | 919 | if ( hDays.testBit(i) ) |
901 | p.setPen(QColor(Qt::green)); | 920 | p.setPen(QColor(Qt::green)); |
902 | else | 921 | else |
903 | p.setPen(QColor(Qt::green).dark()); | 922 | p.setPen(QColor(Qt::green).dark()); |
904 | } else { | 923 | } else { |
905 | if (actcol == mDefaultTextColor ) { | 924 | if (actcol == mDefaultTextColor ) { |
906 | p.setPen(KOPrefs::instance()->mHolidayColor); | 925 | p.setPen(KOPrefs::instance()->mHolidayColor); |
907 | } else { | 926 | } else { |
908 | p.setPen(mHolidayColorShaded); | 927 | p.setPen(mHolidayColorShaded); |
909 | } | 928 | } |
910 | } | 929 | } |
911 | } | 930 | } |
912 | 931 | ||
913 | // draw selected days with special color | 932 | // draw selected days with special color |
914 | // DO NOT specially highlight holidays in selection ! | 933 | // DO NOT specially highlight holidays in selection ! |
915 | if (i >= mSelStartT && i <= mSelEndT) { | 934 | if (i >= mSelStartT && i <= mSelEndT) { |
916 | ;//p.setPen(mSelectedDaysColor); | 935 | ;//p.setPen(mSelectedDaysColor); |
917 | } | 936 | } |
918 | 937 | ||
919 | int addCol = 0; | 938 | int addCol = 0; |
920 | int addRow = 0; | 939 | int addRow = 0; |
921 | if ( colModulo ) { | 940 | if ( colModulo ) { |
922 | if ( col >= 7 - colModulo ) | 941 | if ( col >= 7 - colModulo ) |
923 | addCol = col - 7 + colModulo; | 942 | addCol = col - 7 + colModulo; |
924 | } | 943 | } |
925 | if ( rowModulo ) { | 944 | if ( rowModulo ) { |
926 | if ( row >= 6 - rowModulo ) | 945 | if ( row >= 6 - rowModulo ) |
927 | addRow = row - 5 + rowModulo; | 946 | addRow = row - 5 + rowModulo; |
928 | } | 947 | } |
929 | //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow); | 948 | //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow); |
930 | ++addCol;//++addCol; | 949 | ++addCol;//++addCol; |
931 | if ( row == 0) | 950 | if ( row == 0) |
932 | addRow = 1; | 951 | addRow = 1; |
933 | p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight, | 952 | p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight, |
934 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); | 953 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); |
935 | 954 | ||
936 | // reset color to actual color | 955 | // reset color to actual color |
937 | if (!mHolidays[i].isNull()) { | 956 | if (!mHolidays[i].isNull()) { |
938 | p.setPen(actcol); | 957 | p.setPen(actcol); |
939 | } | 958 | } |
940 | // reset bold font to plain font | 959 | // reset bold font to plain font |
941 | if ( eDays.testBit(i)) { | 960 | if ( eDays.testBit(i)) { |
942 | QFont myFont = font(); | 961 | QFont myFont = font(); |
943 | myFont.setBold(false); | 962 | myFont.setBold(false); |
944 | p.setFont(myFont); | 963 | p.setFont(myFont); |
945 | } | 964 | } |
946 | } | 965 | } |
947 | } else { | 966 | } else { |
948 | //qDebug("NO redraw "); | 967 | //qDebug("NO redraw "); |
949 | } | 968 | } |
950 | bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); | 969 | |
970 | bitBlt (this, pevent->rect().topLeft(), &myPix , pevent->rect() ,CopyROP); | ||
951 | mRedrawNeeded = false; | 971 | mRedrawNeeded = false; |
952 | } | 972 | } |
953 | 973 | ||
954 | // ---------------------------------------------------------------------------- | 974 | // ---------------------------------------------------------------------------- |
955 | // R E SI Z E E V E N T H A N D L I N G | 975 | // R E SI Z E E V E N T H A N D L I N G |
956 | // ---------------------------------------------------------------------------- | 976 | // ---------------------------------------------------------------------------- |
957 | 977 | ||
958 | void KODayMatrix::resizeEvent(QResizeEvent *) | 978 | void KODayMatrix::resizeEvent(QResizeEvent *) |
959 | { | 979 | { |
960 | QRect sz = frameRect(); | 980 | QRect sz = frameRect(); |
961 | daysize.setHeight(sz.height()*7 / NUMDAYS); | 981 | daysize.setHeight(sz.height()*7 / NUMDAYS); |
962 | daysize.setWidth(sz.width() / 7); | 982 | daysize.setWidth(sz.width() / 7); |
963 | } | 983 | } |
964 | 984 | ||
965 | QSize KODayMatrix::sizeHint() const | 985 | QSize KODayMatrix::sizeHint() const |
966 | { | 986 | { |
967 | 987 | ||
968 | QFontMetrics fm ( font() ); | 988 | QFontMetrics fm ( font() ); |
969 | int wid = fm.width( "30") *7+3; | 989 | int wid = fm.width( "30") *7+3; |
970 | int hei = fm.height() * 6+3; | 990 | int hei = fm.height() * 6+3; |
971 | //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei); | 991 | //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei); |
972 | return QSize ( wid, hei ); | 992 | return QSize ( wid, hei ); |
973 | 993 | ||
974 | } | 994 | } |
diff --git a/korganizer/kodaymatrix.h b/korganizer/kodaymatrix.h index 731117c..d725ead 100644 --- a/korganizer/kodaymatrix.h +++ b/korganizer/kodaymatrix.h | |||
@@ -1,327 +1,328 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> | 3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program 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 | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef _KODAYMAT_H | 23 | #ifndef _KODAYMAT_H |
24 | #define _KODAYMAT_H | 24 | #define _KODAYMAT_H |
25 | 25 | ||
26 | #include <libkcal/calendar.h> | 26 | #include <libkcal/calendar.h> |
27 | 27 | ||
28 | #include <qstring.h> | 28 | #include <qstring.h> |
29 | #include <qframe.h> | 29 | #include <qframe.h> |
30 | #include <qcolor.h> | 30 | #include <qcolor.h> |
31 | #include <qpen.h> | 31 | #include <qpen.h> |
32 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
33 | #include <qtooltip.h> | 33 | #include <qtooltip.h> |
34 | #include <qpixmap.h> | 34 | #include <qpixmap.h> |
35 | #include <qbitarray.h> | 35 | #include <qbitarray.h> |
36 | #include <qmap.h> | 36 | #include <qmap.h> |
37 | 37 | ||
38 | class QDragEnterEvent; | 38 | class QDragEnterEvent; |
39 | class QDragMoveEvent; | 39 | class QDragMoveEvent; |
40 | class QDragLeaveEvent; | 40 | class QDragLeaveEvent; |
41 | class QDropEvent; | 41 | class QDropEvent; |
42 | 42 | ||
43 | class KODayMatrix; | 43 | class KODayMatrix; |
44 | class KODaymatrixWhatsThis; | 44 | class KODaymatrixWhatsThis; |
45 | 45 | ||
46 | using namespace KCal; | 46 | using namespace KCal; |
47 | 47 | ||
48 | 48 | ||
49 | /** | 49 | /** |
50 | * small helper class to dynamically show tooltips inside the day matrix. | 50 | * small helper class to dynamically show tooltips inside the day matrix. |
51 | * This class asks the day matrix object for a appropriate label which | 51 | * This class asks the day matrix object for a appropriate label which |
52 | * is in our special case the name of the holiday or null if this day is no holiday. | 52 | * is in our special case the name of the holiday or null if this day is no holiday. |
53 | */ | 53 | */ |
54 | class DynamicTip : public QToolTip | 54 | class DynamicTip : public QToolTip |
55 | { | 55 | { |
56 | public: | 56 | public: |
57 | 57 | ||
58 | /** | 58 | /** |
59 | * Constructor that expects a KODayMatrix object as parent. | 59 | * Constructor that expects a KODayMatrix object as parent. |
60 | * | 60 | * |
61 | * @param parent the parent KODayMatrix control. | 61 | * @param parent the parent KODayMatrix control. |
62 | */ | 62 | */ |
63 | DynamicTip(QWidget* parent ); | 63 | DynamicTip(QWidget* parent ); |
64 | 64 | ||
65 | protected: | 65 | protected: |
66 | 66 | ||
67 | /** | 67 | /** |
68 | * Qt's callback to ask the object to provide an approrpiate text for the | 68 | * Qt's callback to ask the object to provide an approrpiate text for the |
69 | * tooltip to be shown. | 69 | * tooltip to be shown. |
70 | * | 70 | * |
71 | * @param pos coordinates of the mouse. | 71 | * @param pos coordinates of the mouse. |
72 | */ | 72 | */ |
73 | void maybeTip( const QPoint & pos); | 73 | void maybeTip( const QPoint & pos); |
74 | 74 | ||
75 | private: | 75 | private: |
76 | 76 | ||
77 | /** the parent control this tooltip is designed for. */ | 77 | /** the parent control this tooltip is designed for. */ |
78 | KODayMatrix* matrix; | 78 | KODayMatrix* matrix; |
79 | }; | 79 | }; |
80 | 80 | ||
81 | /** | 81 | /** |
82 | * replacement for kdpdatebuton.cpp that used 42 widgets for the day matrix to be displayed. | 82 | * replacement for kdpdatebuton.cpp that used 42 widgets for the day matrix to be displayed. |
83 | * Cornelius thought this was a waste of memory and a lot of overhead. | 83 | * Cornelius thought this was a waste of memory and a lot of overhead. |
84 | * In addition the selection was not very intuitive so I decided to rewrite it using a QFrame | 84 | * In addition the selection was not very intuitive so I decided to rewrite it using a QFrame |
85 | * that draws the labels and allows for dragging selection while maintaining nearly full | 85 | * that draws the labels and allows for dragging selection while maintaining nearly full |
86 | * compatibility in behaviour with its predecessor. | 86 | * compatibility in behaviour with its predecessor. |
87 | * | 87 | * |
88 | * The following functionality has been changed: | 88 | * The following functionality has been changed: |
89 | * | 89 | * |
90 | * o when shifting events in the agenda view from one day to another the day matrix is updated now | 90 | * o when shifting events in the agenda view from one day to another the day matrix is updated now |
91 | * o TODO ET dragging an event to the matrix will MOVE not COPY the event to the new date. | 91 | * o TODO ET dragging an event to the matrix will MOVE not COPY the event to the new date. |
92 | * o no support for Ctrl+click to create groups of dates | 92 | * o no support for Ctrl+click to create groups of dates |
93 | * (This has not really been supported in the predecessor. It was not very intuitive nor was it | 93 | * (This has not really been supported in the predecessor. It was not very intuitive nor was it |
94 | * user friendly.) | 94 | * user friendly.) |
95 | * This feature has been replaced with dragging a selection on the matrix. The matrix will | 95 | * This feature has been replaced with dragging a selection on the matrix. The matrix will |
96 | * automatically choose the appropriate selection (e.g. you are not any longer able to select | 96 | * automatically choose the appropriate selection (e.g. you are not any longer able to select |
97 | * two distinct groups of date selections as in the old class) | 97 | * two distinct groups of date selections as in the old class) |
98 | * o now that you can select more then a week it can happen that not all selected days are | 98 | * o now that you can select more then a week it can happen that not all selected days are |
99 | * displayed in the matrix. However this is preferred to the alternative which would mean to | 99 | * displayed in the matrix. However this is preferred to the alternative which would mean to |
100 | * adjust the selection and leave some days undisplayed while scrolling through the months | 100 | * adjust the selection and leave some days undisplayed while scrolling through the months |
101 | * | 101 | * |
102 | * @short day matrix widget of the KDateNavigator | 102 | * @short day matrix widget of the KDateNavigator |
103 | * | 103 | * |
104 | * @author Eitzenberger Thomas | 104 | * @author Eitzenberger Thomas |
105 | */ | 105 | */ |
106 | class KODayMatrix: public QFrame { | 106 | class KODayMatrix: public QFrame { |
107 | 107 | ||
108 | Q_OBJECT | 108 | Q_OBJECT |
109 | 109 | ||
110 | public: | 110 | public: |
111 | 111 | ||
112 | /** constructor to create a day matrix widget. | 112 | /** constructor to create a day matrix widget. |
113 | * | 113 | * |
114 | * @param parent widget that is the parent of the day matrix. Normally this should | 114 | * @param parent widget that is the parent of the day matrix. Normally this should |
115 | * be a KDateNavigator | 115 | * be a KDateNavigator |
116 | * @param calendar instance of a calendar on which all calculations are based | 116 | * @param calendar instance of a calendar on which all calculations are based |
117 | * @param date start date of the matrix (is expected to be already fixed). It is | 117 | * @param date start date of the matrix (is expected to be already fixed). It is |
118 | * assumed that this date is the first week day to be shown in the matrix. | 118 | * assumed that this date is the first week day to be shown in the matrix. |
119 | * @param name name of the widget | 119 | * @param name name of the widget |
120 | */ | 120 | */ |
121 | KODayMatrix( QWidget *parent, const char *name ); | 121 | KODayMatrix( QWidget *parent, const char *name ); |
122 | //KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name ); | 122 | //KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name ); |
123 | 123 | ||
124 | /** destructor that deallocates all dynamically allocated private members. | 124 | /** destructor that deallocates all dynamically allocated private members. |
125 | */ | 125 | */ |
126 | ~KODayMatrix(); | 126 | ~KODayMatrix(); |
127 | 127 | ||
128 | /** updates the day matrix to start with the given date. Does all the necessary | 128 | /** updates the day matrix to start with the given date. Does all the necessary |
129 | * checks for holidays or events on a day and stores them for display later on. | 129 | * checks for holidays or events on a day and stores them for display later on. |
130 | * Does NOT update the view visually. Call repaint() for this. | 130 | * Does NOT update the view visually. Call repaint() for this. |
131 | * | 131 | * |
132 | * @param actdate recalculates the day matrix to show NUMDAYS starting from this | 132 | * @param actdate recalculates the day matrix to show NUMDAYS starting from this |
133 | * date. | 133 | * date. |
134 | */ | 134 | */ |
135 | void updateView(QDate actdate); | 135 | void updateView(QDate actdate); |
136 | void updateEvents(); | 136 | void updateEvents(); |
137 | 137 | ||
138 | /** returns the QDate object associated with day indexed by the | 138 | /** returns the QDate object associated with day indexed by the |
139 | * supplied offset. | 139 | * supplied offset. |
140 | */ | 140 | */ |
141 | const QDate& getDate(int offset); | 141 | const QDate& getDate(int offset); |
142 | void setCalendar( Calendar * ); | 142 | void setCalendar( Calendar * ); |
143 | /** returns the official name of this holy day or 0 if there is no label | 143 | /** returns the official name of this holy day or 0 if there is no label |
144 | * for this day. | 144 | * for this day. |
145 | */ | 145 | */ |
146 | QString getHolidayLabel(int offset); | 146 | QString getHolidayLabel(int offset); |
147 | 147 | ||
148 | /** adds all actual selected days from mSelStart to mSelEnd to the supplied | 148 | /** adds all actual selected days from mSelStart to mSelEnd to the supplied |
149 | * DateList. | 149 | * DateList. |
150 | */ | 150 | */ |
151 | void addSelectedDaysTo(DateList&); | 151 | void addSelectedDaysTo(DateList&); |
152 | 152 | ||
153 | /** sets the actual to be displayed selection in the day matrix starting from | 153 | /** sets the actual to be displayed selection in the day matrix starting from |
154 | * start and ending with end. Theview must be manually updated by calling | 154 | * start and ending with end. Theview must be manually updated by calling |
155 | * repaint. (?) | 155 | * repaint. (?) |
156 | */ | 156 | */ |
157 | bool setSelectedDaysFrom(const QDate& start, const QDate& end); | 157 | bool setSelectedDaysFrom(const QDate& start, const QDate& end); |
158 | void clearSelection(); | 158 | void clearSelection(); |
159 | 159 | ||
160 | /** Is today visible in the view? Keep this in sync with | 160 | /** Is today visible in the view? Keep this in sync with |
161 | * the values today (below) can take. | 161 | * the values today (below) can take. |
162 | */ | 162 | */ |
163 | bool isTodayVisible() const { return today>=0; } ; | 163 | bool isTodayVisible() const { return today>=0; } ; |
164 | 164 | ||
165 | /** If today is visible, then we can find out if today is | 165 | /** If today is visible, then we can find out if today is |
166 | * near the beginning or the end of the month. | 166 | * near the beginning or the end of the month. |
167 | * This is dependent on today remaining the index | 167 | * This is dependent on today remaining the index |
168 | * in the array of visible dates and going from | 168 | * in the array of visible dates and going from |
169 | * top left (0) to bottom right (41). | 169 | * top left (0) to bottom right (41). |
170 | */ | 170 | */ |
171 | bool isBeginningOfMonth() const { return today<=8; } ; | 171 | bool isBeginningOfMonth() const { return today<=8; } ; |
172 | bool isEndOfMonth() const { return today>=27; } ; | 172 | bool isEndOfMonth() const { return today>=27; } ; |
173 | QString getWhatsThisText( QPoint ) ; | 173 | QString getWhatsThisText( QPoint ) ; |
174 | QSize sizeHint() const; | 174 | QSize sizeHint() const; |
175 | QRect frameRect () const { int wid = frameWidth(); return QRect(0+wid,0+wid,width()-wid-wid,height()-wid-wid);} | 175 | QRect frameRect () const { int wid = frameWidth(); return QRect(0+wid,0+wid,width()-wid-wid,height()-wid-wid);} |
176 | public slots: | 176 | public slots: |
177 | /** Recalculates all the flags of the days in the matrix like holidays or events | 177 | /** Recalculates all the flags of the days in the matrix like holidays or events |
178 | * on a day (Actually calls above method with the actual startdate). | 178 | * on a day (Actually calls above method with the actual startdate). |
179 | */ | 179 | */ |
180 | void updateView(); | 180 | void updateView(); |
181 | void updateViewTimed(); | 181 | void updateViewTimed(); |
182 | void repaintViewTimed(); | 182 | void repaintViewTimed(); |
183 | 183 | ||
184 | /** | 184 | /** |
185 | * Calculate which square in the matrix should be | 185 | * Calculate which square in the matrix should be |
186 | * hilighted to indicate it's today. | 186 | * hilighted to indicate it's today. |
187 | */ | 187 | */ |
188 | void recalculateToday(); | 188 | void recalculateToday(); |
189 | 189 | ||
190 | /* | 190 | /* |
191 | void setStartDate(QDate); | 191 | void setStartDate(QDate); |
192 | */ | 192 | */ |
193 | 193 | ||
194 | signals: | 194 | signals: |
195 | 195 | ||
196 | /** emitted if the user selects a block of days with the mouse by dragging a rectangle | 196 | /** emitted if the user selects a block of days with the mouse by dragging a rectangle |
197 | * inside the matrix | 197 | * inside the matrix |
198 | * | 198 | * |
199 | * @param daylist list of days that have been selected by the user | 199 | * @param daylist list of days that have been selected by the user |
200 | */ | 200 | */ |
201 | void selected( const KCal::DateList &daylist ); | 201 | void selected( const KCal::DateList &daylist ); |
202 | 202 | ||
203 | /** emitted if the user has dropped an event inside the matrix | 203 | /** emitted if the user has dropped an event inside the matrix |
204 | * | 204 | * |
205 | * @param event the dropped calendar event | 205 | * @param event the dropped calendar event |
206 | */ | 206 | */ |
207 | void eventDropped(Event *event); | 207 | void eventDropped(Event *event); |
208 | 208 | ||
209 | protected: | 209 | protected: |
210 | 210 | ||
211 | void paintEvent(QPaintEvent *ev); | 211 | void paintEvent(QPaintEvent *ev); |
212 | 212 | ||
213 | void mousePressEvent (QMouseEvent* e); | 213 | void mousePressEvent (QMouseEvent* e); |
214 | 214 | ||
215 | void mouseReleaseEvent (QMouseEvent* e); | 215 | void mouseReleaseEvent (QMouseEvent* e); |
216 | 216 | ||
217 | void mouseMoveEvent (QMouseEvent* e); | 217 | void mouseMoveEvent (QMouseEvent* e); |
218 | 218 | ||
219 | void dragEnterEvent(QDragEnterEvent *); | 219 | void dragEnterEvent(QDragEnterEvent *); |
220 | 220 | ||
221 | void dragMoveEvent(QDragMoveEvent *); | 221 | void dragMoveEvent(QDragMoveEvent *); |
222 | 222 | ||
223 | void dragLeaveEvent(QDragLeaveEvent *); | 223 | void dragLeaveEvent(QDragLeaveEvent *); |
224 | 224 | ||
225 | void dropEvent(QDropEvent *); | 225 | void dropEvent(QDropEvent *); |
226 | 226 | ||
227 | void resizeEvent(QResizeEvent *); | 227 | void resizeEvent(QResizeEvent *); |
228 | 228 | ||
229 | private: | 229 | private: |
230 | int oldW, oldH; | ||
230 | bool mRedrawNeeded; | 231 | bool mRedrawNeeded; |
231 | KODaymatrixWhatsThis* mKODaymatrixWhatsThis; | 232 | KODaymatrixWhatsThis* mKODaymatrixWhatsThis; |
232 | bool mouseDown; | 233 | bool mouseDown; |
233 | QBitArray bDays; | 234 | QBitArray bDays; |
234 | QBitArray hDays; | 235 | QBitArray hDays; |
235 | QBitArray eDays; | 236 | QBitArray eDays; |
236 | QPixmap myPix; | 237 | QPixmap myPix; |
237 | QTimer* mUpdateTimer; | 238 | QTimer* mUpdateTimer; |
238 | QTimer* mRepaintTimer; | 239 | QTimer* mRepaintTimer; |
239 | bool mDayChanged; | 240 | bool mDayChanged; |
240 | bool mPendingUpdateBeforeRepaint; | 241 | bool mPendingUpdateBeforeRepaint; |
241 | 242 | ||
242 | /** returns the index of the day located at the matrix's widget (x,y) position. | 243 | /** returns the index of the day located at the matrix's widget (x,y) position. |
243 | * | 244 | * |
244 | * @param x horizontal coordinate | 245 | * @param x horizontal coordinate |
245 | * @param y vertical coordinate | 246 | * @param y vertical coordinate |
246 | */ | 247 | */ |
247 | int getDayIndexFrom(int x, int y); | 248 | int getDayIndexFrom(int x, int y); |
248 | 249 | ||
249 | /** calculates a "shaded" color from the supplied color object. | 250 | /** calculates a "shaded" color from the supplied color object. |
250 | * (Copied from Cornelius's kdpdatebutton.cpp) | 251 | * (Copied from Cornelius's kdpdatebutton.cpp) |
251 | * | 252 | * |
252 | * @param color source based on which a shaded color should be calculated. | 253 | * @param color source based on which a shaded color should be calculated. |
253 | */ | 254 | */ |
254 | QColor getShadedColor(QColor color); | 255 | QColor getShadedColor(QColor color); |
255 | 256 | ||
256 | /** number of days to be displayed. For now there is no support for any other number then 42. | 257 | /** number of days to be displayed. For now there is no support for any other number then 42. |
257 | so change it at your own risk :o) */ | 258 | so change it at your own risk :o) */ |
258 | static const int NUMDAYS; | 259 | static const int NUMDAYS; |
259 | 260 | ||
260 | /** calendar instance to be queried for holidays, events, ... */ | 261 | /** calendar instance to be queried for holidays, events, ... */ |
261 | Calendar *mCalendar; | 262 | Calendar *mCalendar; |
262 | 263 | ||
263 | /** starting date of the matrix */ | 264 | /** starting date of the matrix */ |
264 | QDate startdate; | 265 | QDate startdate; |
265 | 266 | ||
266 | /** array of day labels to optimeize drawing performance. */ | 267 | /** array of day labels to optimeize drawing performance. */ |
267 | QString *daylbls; | 268 | QString *daylbls; |
268 | 269 | ||
269 | /** array of days displayed to reduce memory consumption by | 270 | /** array of days displayed to reduce memory consumption by |
270 | subsequently calling QDate::addDays(). */ | 271 | subsequently calling QDate::addDays(). */ |
271 | QDate *days; | 272 | QDate *days; |
272 | 273 | ||
273 | /** array of storing the number of events on a given day. | 274 | /** array of storing the number of events on a given day. |
274 | * used for drawing a bold font if there is at least one event on that day. | 275 | * used for drawing a bold font if there is at least one event on that day. |
275 | */ | 276 | */ |
276 | //int *events; | 277 | //int *events; |
277 | 278 | ||
278 | /** stores holiday names of the days shown in the matrix. */ | 279 | /** stores holiday names of the days shown in the matrix. */ |
279 | QMap<int,QString> mHolidays; | 280 | QMap<int,QString> mHolidays; |
280 | 281 | ||
281 | /** indey of today or -1 if today is not visible in the matrix. */ | 282 | /** indey of today or -1 if today is not visible in the matrix. */ |
282 | int today; | 283 | int today; |
283 | 284 | ||
284 | /** index of day where dragged selection was initiated. | 285 | /** index of day where dragged selection was initiated. |
285 | used to detect "negative" timely selections */ | 286 | used to detect "negative" timely selections */ |
286 | int mSelInit; | 287 | int mSelInit; |
287 | 288 | ||
288 | /** if mSelStart has this value it indicates that there is no | 289 | /** if mSelStart has this value it indicates that there is no |
289 | actual selection in the matrix. */ | 290 | actual selection in the matrix. */ |
290 | static const int NOSELECTION; | 291 | static const int NOSELECTION; |
291 | 292 | ||
292 | /** index of first selected day. */ | 293 | /** index of first selected day. */ |
293 | int mSelStart; | 294 | int mSelStart; |
294 | 295 | ||
295 | /** index of last selected day. */ | 296 | /** index of last selected day. */ |
296 | int mSelEnd; | 297 | int mSelEnd; |
297 | 298 | ||
298 | /** dynamic tooltip to handle mouse dependent tips for each day in the matrix. */ | 299 | /** dynamic tooltip to handle mouse dependent tips for each day in the matrix. */ |
299 | DynamicTip* mToolTip; | 300 | DynamicTip* mToolTip; |
300 | 301 | ||
301 | 302 | ||
302 | /** default background colour of the matrix. */ | 303 | /** default background colour of the matrix. */ |
303 | QColor mDefaultBackColor; | 304 | QColor mDefaultBackColor; |
304 | 305 | ||
305 | /** default text color of the matrix. */ | 306 | /** default text color of the matrix. */ |
306 | QColor mDefaultTextColor; | 307 | QColor mDefaultTextColor; |
307 | 308 | ||
308 | /** default text color for days not in the actual month. */ | 309 | /** default text color for days not in the actual month. */ |
309 | QColor mDefaultTextColorShaded; | 310 | QColor mDefaultTextColorShaded; |
310 | 311 | ||
311 | /** default text color for holidays not in the actual month. */ | 312 | /** default text color for holidays not in the actual month. */ |
312 | QColor mHolidayColorShaded; | 313 | QColor mHolidayColorShaded; |
313 | 314 | ||
314 | /** text color for selected days. */ | 315 | /** text color for selected days. */ |
315 | QColor mSelectedDaysColor; | 316 | QColor mSelectedDaysColor; |
316 | 317 | ||
317 | /** default width of the frame drawn around today if it is visible in the matrix. */ | 318 | /** default width of the frame drawn around today if it is visible in the matrix. */ |
318 | int mTodayMarginWidth; | 319 | int mTodayMarginWidth; |
319 | 320 | ||
320 | /** stores actual size of each day in the widget so that I dont need to ask this data | 321 | /** stores actual size of each day in the widget so that I dont need to ask this data |
321 | * on every repaint. | 322 | * on every repaint. |
322 | */ | 323 | */ |
323 | QRect daysize; | 324 | QRect daysize; |
324 | 325 | ||
325 | }; | 326 | }; |
326 | 327 | ||
327 | #endif | 328 | #endif |