author | zautrix <zautrix> | 2005-08-05 19:27:34 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-08-05 19:27:34 (UTC) |
commit | 78ae7e3faed42b510f4f0a60007115756cd06128 (patch) (unidiff) | |
tree | 16947ed0eda107673cb6b437e772a6194861548d | |
parent | 7c639808d3d78e323857e0a110237e6d77bf04c8 (diff) | |
download | kdepimpi-78ae7e3faed42b510f4f0a60007115756cd06128.zip kdepimpi-78ae7e3faed42b510f4f0a60007115756cd06128.tar.gz kdepimpi-78ae7e3faed42b510f4f0a60007115756cd06128.tar.bz2 |
fixes
-rw-r--r-- | bin/kdepim/WhatsNew.txt | 5 | ||||
-rw-r--r-- | desktop/rpm/kdepim_rpm | 2 | ||||
-rw-r--r-- | korganizer/journalentry.cpp | 4 | ||||
-rw-r--r-- | korganizer/koagenda.cpp | 6 | ||||
-rw-r--r-- | korganizer/koagenda.h | 2 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 4 | ||||
-rw-r--r-- | version | 2 |
7 files changed, 18 insertions, 7 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt index d0b2880..f4b3ddb 100644 --- a/bin/kdepim/WhatsNew.txt +++ b/bin/kdepim/WhatsNew.txt | |||
@@ -1,305 +1,310 @@ | |||
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.1.19 ************ | ||
4 | |||
5 | Fixed a crash in journal view and a crash in setting a todo to stopped when KO/Pi saved the file when "stop todo" dialog was shown. | ||
6 | Fixed a minor problem with the marcus bains line (whatever that is). | ||
7 | |||
3 | ********** VERSION 2.1.18 ************ | 8 | ********** VERSION 2.1.18 ************ |
4 | 9 | ||
5 | Pi-Sync mode: | 10 | Pi-Sync mode: |
6 | The "Write back file" status dialog was updated too often such that writing back the file on the Z was very slow. Fixed. | 11 | The "Write back file" status dialog was updated too often such that writing back the file on the Z was very slow. Fixed. |
7 | 12 | ||
8 | KO/Pi: | 13 | KO/Pi: |
9 | Fixed a layout problem on the Z 5500 with the calender box right of the location box in the event/todo editor. Thanks to Andrew, who found, reported and fixed this problem ( I did not get that problem - it was working on my 5500 ). | 14 | Fixed a layout problem on the Z 5500 with the calender box right of the location box in the event/todo editor. Thanks to Andrew, who found, reported and fixed this problem ( I did not get that problem - it was working on my 5500 ). |
10 | 15 | ||
11 | Fixed a problem when (imported or added from other applications) events or todos did have attachments. | 16 | Fixed a problem when (imported or added from other applications) events or todos did have attachments. |
12 | Fixed a really ugly and hidden problem in the management of the parent/child relationchip of todos. | 17 | Fixed a really ugly and hidden problem in the management of the parent/child relationchip of todos. |
13 | 18 | ||
14 | 19 | ||
15 | ********** VERSION 2.1.17 ************ | 20 | ********** VERSION 2.1.17 ************ |
16 | 21 | ||
17 | KO/Pi: | 22 | KO/Pi: |
18 | Added option to display times in What's Next View on two lines. | 23 | Added option to display times in What's Next View on two lines. |
19 | (Useful for display on the Zaurus with 240x320 screen) | 24 | (Useful for display on the Zaurus with 240x320 screen) |
20 | Removed "Allday" for allday events of one day duration in What's Next View. | 25 | Removed "Allday" for allday events of one day duration in What's Next View. |
21 | Added date range for allday events of more than one day duration in What's Next View. | 26 | Added date range for allday events of more than one day duration in What's Next View. |
22 | Fixed two problems in the data importing from Outlook: | 27 | Fixed two problems in the data importing from Outlook: |
23 | Fixed the duplicated import if the summary, location or description had whitespaces at the end. | 28 | Fixed the duplicated import if the summary, location or description had whitespaces at the end. |
24 | Fixed a problem importing certain recurrence rules. | 29 | Fixed a problem importing certain recurrence rules. |
25 | 30 | ||
26 | A journal in an ics file may have no dtStart value (as files from KNotes, which stores its notes in an ics journal file). | 31 | A journal in an ics file may have no dtStart value (as files from KNotes, which stores its notes in an ics journal file). |
27 | If now a journal has no dtStart value the dtStart value is set to the created value of the journal when loading the file. That makes it possible to view and edit "notes" from KNotes. Simply add another Resource in KO/Pi which is a copy of the ics file from KNotes. You will find the "notes" in KO/Pi as a journal entry on the date you created it. | 32 | If now a journal has no dtStart value the dtStart value is set to the created value of the journal when loading the file. That makes it possible to view and edit "notes" from KNotes. Simply add another Resource in KO/Pi which is a copy of the ics file from KNotes. You will find the "notes" in KO/Pi as a journal entry on the date you created it. |
28 | 33 | ||
29 | And some minor fixes in KO/Pi. | 34 | And some minor fixes in KO/Pi. |
30 | 35 | ||
31 | Fixed a crash on the desktop when closing KO/Pi after accessing adressbook data (Linux + Windows ). | 36 | Fixed a crash on the desktop when closing KO/Pi after accessing adressbook data (Linux + Windows ). |
32 | 37 | ||
33 | 38 | ||
34 | ********** VERSION 2.1.16 ************ | 39 | ********** VERSION 2.1.16 ************ |
35 | 40 | ||
36 | Fixed a problem with the menu bar in KO/Pi and using the "Menu" hardware key on the Zaurus. | 41 | Fixed a problem with the menu bar in KO/Pi and using the "Menu" hardware key on the Zaurus. |
37 | Added columns for datetime in todo view: Last modified, created and last modified subtodo | 42 | Added columns for datetime in todo view: Last modified, created and last modified subtodo |
38 | Fixed a bug in agenda view displaying recurring multiday events which are longer than two days. | 43 | Fixed a bug in agenda view displaying recurring multiday events which are longer than two days. |
39 | Made conflict detection up to 4 times faster. | 44 | Made conflict detection up to 4 times faster. |
40 | 45 | ||
41 | ********** VERSION 2.1.15 ************ | 46 | ********** VERSION 2.1.15 ************ |
42 | 47 | ||
43 | Fixed two layout problems on the Z: | 48 | Fixed two layout problems on the Z: |
44 | Made the with of the newly added buttons on the Quick-Todo smaller. | 49 | Made the with of the newly added buttons on the Quick-Todo smaller. |
45 | Made listweek layout in 2 columns on the Z760 in portait screen and full menubar visible. | 50 | Made listweek layout in 2 columns on the Z760 in portait screen and full menubar visible. |
46 | 51 | ||
47 | 52 | ||
48 | ********** VERSION 2.1.14 ************ | 53 | ********** VERSION 2.1.14 ************ |
49 | 54 | ||
50 | Added some buttons to the KO/Pi Quick-todo line to make it possible to quickly access some todo view layout settings like display all flat/open/close and hide/show running/done. | 55 | Added some buttons to the KO/Pi Quick-todo line to make it possible to quickly access some todo view layout settings like display all flat/open/close and hide/show running/done. |
51 | Added a button to add a subtodo quickly. | 56 | Added a button to add a subtodo quickly. |
52 | 57 | ||
53 | Added a possibility to search for conflicting events. (In the Action menu. Keyboard shortcut "q", shift+q or ctrl +q ). | 58 | Added a possibility to search for conflicting events. (In the Action menu. Keyboard shortcut "q", shift+q or ctrl +q ). |
54 | Added an option to change the layout of the list week to column mode. | 59 | Added an option to change the layout of the list week to column mode. |
55 | 60 | ||
56 | Fixed some usability problems in pi-sync mode by adding some progress information about file transfer. | 61 | Fixed some usability problems in pi-sync mode by adding some progress information about file transfer. |
57 | 62 | ||
58 | Fixed pi-sync problems with the new multi calendar feature. | 63 | Fixed pi-sync problems with the new multi calendar feature. |
59 | Now pi-sync behaviour should be: | 64 | Now pi-sync behaviour should be: |
60 | 1) Local sends file request ( as usual ) | 65 | 1) Local sends file request ( as usual ) |
61 | 2) Remote sends file which contains data of all enabled ( the calendar where the "eye" column is checked ) calendars. | 66 | 2) Remote sends file which contains data of all enabled ( the calendar where the "eye" column is checked ) calendars. |
62 | 3) Local syncs with data, adds new entries to default calendar and sends file back ( as usual ). | 67 | 3) Local syncs with data, adds new entries to default calendar and sends file back ( as usual ). |
63 | If the data which local receives contains entries which are on disabled calendars on local this entries are updated and not added as duplicates to the default calendar. | 68 | If the data which local receives contains entries which are on disabled calendars on local this entries are updated and not added as duplicates to the default calendar. |
64 | 4) Remote updates the data and adds new entries to default calendar. Readonly entries are not changed on remote. | 69 | 4) Remote updates the data and adds new entries to default calendar. Readonly entries are not changed on remote. |
65 | If the data which remote receives contains entries which are on disabled calendars on remote this entries are updated and not added as duplicates to the default calendar. | 70 | If the data which remote receives contains entries which are on disabled calendars on remote this entries are updated and not added as duplicates to the default calendar. |
66 | 71 | ||
67 | Summary: | 72 | Summary: |
68 | No new item ( new created after the last sync ) in a disabled calendar is propagated to the sync partner. Readonly items are synced and added/changed on the sync partner if it is not readonly on the sync partner. | 73 | No new item ( new created after the last sync ) in a disabled calendar is propagated to the sync partner. Readonly items are synced and added/changed on the sync partner if it is not readonly on the sync partner. |
69 | If you have different calendars on remote and local and some of them disabled you may get some "strange" bahaviour. | 74 | If you have different calendars on remote and local and some of them disabled you may get some "strange" bahaviour. |
70 | Well, the syncing has become quite complicated ... you should have no problems if you enable all calendars. | 75 | Well, the syncing has become quite complicated ... you should have no problems if you enable all calendars. |
71 | 76 | ||
72 | ********** VERSION 2.1.13 ************ | 77 | ********** VERSION 2.1.13 ************ |
73 | 78 | ||
74 | Fixed a problem in KA/Pi search. | 79 | Fixed a problem in KA/Pi search. |
75 | Fixed some minor problems in KO/Pi. | 80 | Fixed some minor problems in KO/Pi. |
76 | Added calendar selection possibility to the todo view popup and to the event/todo/journal editor. | 81 | Added calendar selection possibility to the todo view popup and to the event/todo/journal editor. |
77 | 82 | ||
78 | Fixed memory usage problems in KA/Pi: | 83 | Fixed memory usage problems in KA/Pi: |
79 | When loading data KA/Pi did load the file data twice. | 84 | When loading data KA/Pi did load the file data twice. |
80 | Example: | 85 | Example: |
81 | A 600k file did consume 1200k memory during loading process. | 86 | A 600k file did consume 1200k memory during loading process. |
82 | This is fixed, it does now consume only 600k during loading process. | 87 | This is fixed, it does now consume only 600k during loading process. |
83 | When saving data KA/Pi did consume a lot of memory for the data parsing during the save process. | 88 | When saving data KA/Pi did consume a lot of memory for the data parsing during the save process. |
84 | This is fixed. | 89 | This is fixed. |
85 | Example: | 90 | Example: |
86 | Before saving a 600k file KA/Pi did consume 21.7 Meg of Ram. | 91 | Before saving a 600k file KA/Pi did consume 21.7 Meg of Ram. |
87 | When saving KA/Pi did consume 28.6 Meg of Ram. That causes a crash on the Zaurus because there was no memeory left in the system. | 92 | When saving KA/Pi did consume 28.6 Meg of Ram. That causes a crash on the Zaurus because there was no memeory left in the system. |
88 | Now KA/Pi is consuming on saving the same data 22.0 Meg of Ram during the save process. | 93 | Now KA/Pi is consuming on saving the same data 22.0 Meg of Ram during the save process. |
89 | Note: The memory usage of KA/Pi after the data is loaded/saved has not changed. | 94 | Note: The memory usage of KA/Pi after the data is loaded/saved has not changed. |
90 | The saving of data may be a bit slower now. | 95 | The saving of data may be a bit slower now. |
91 | 96 | ||
92 | Fixed memory usage problems in KO/Pi: | 97 | Fixed memory usage problems in KO/Pi: |
93 | When KO/Pi did save the data to file, it did not release the used buffers after saving. | 98 | When KO/Pi did save the data to file, it did not release the used buffers after saving. |
94 | The used buffer was released after saving the next time, but there was new buffer space allocated again on that save operation. | 99 | The used buffer was released after saving the next time, but there was new buffer space allocated again on that save operation. |
95 | This is fixed. | 100 | This is fixed. |
96 | Example: | 101 | Example: |
97 | When saving a 400k file KO/Pi do now use 400k less memory now. | 102 | When saving a 400k file KO/Pi do now use 400k less memory now. |
98 | 103 | ||
99 | Optimized memory usage in KO/Pi Agenda view: | 104 | Optimized memory usage in KO/Pi Agenda view: |
100 | KO/Pi is storing some paint information in extra buffers for faster repainting of the agenda view. | 105 | KO/Pi is storing some paint information in extra buffers for faster repainting of the agenda view. |
101 | These buffers were not made smaller (i.e. downsized) because of performance reasons. | 106 | These buffers were not made smaller (i.e. downsized) because of performance reasons. |
102 | The handling of these buffers are now much smarter: | 107 | The handling of these buffers are now much smarter: |
103 | Two (of six) buffers are removed completely. | 108 | Two (of six) buffers are removed completely. |
104 | The remaing four buffers are now downsized after not using the agenda view for 45 seconds. | 109 | The remaing four buffers are now downsized after not using the agenda view for 45 seconds. |
105 | Such that the memory usage of KO/Pi is smaller now in general ( because 2 buffers are removed) and is much smaller when not using the agenda view. That is very important when using fastload for KO/Pi. | 110 | Such that the memory usage of KO/Pi is smaller now in general ( because 2 buffers are removed) and is much smaller when not using the agenda view. That is very important when using fastload for KO/Pi. |
106 | 111 | ||
107 | Worst case example ( for a maximum size agenda content): | 112 | Worst case example ( for a maximum size agenda content): |
108 | When resizing the agenda content to a large scale, KO/Pi did use 17Meg of mem ( and did not use less memory until it was stopped). Now KO/Pi is using on the same operation only 14.3 Meg of mem and after 45 seconds not using the agenda view it uses only 9.4 Meg of mem. | 113 | When resizing the agenda content to a large scale, KO/Pi did use 17Meg of mem ( and did not use less memory until it was stopped). Now KO/Pi is using on the same operation only 14.3 Meg of mem and after 45 seconds not using the agenda view it uses only 9.4 Meg of mem. |
109 | 114 | ||
110 | When switching to an unused Agenda view now KO/Pi is upizing the buffers again. This takes less than a second. Such that switching to Agenda view (after not using it for more than 45 seconds) is now a bit slower. | 115 | When switching to an unused Agenda view now KO/Pi is upizing the buffers again. This takes less than a second. Such that switching to Agenda view (after not using it for more than 45 seconds) is now a bit slower. |
111 | 116 | ||
112 | Summary: | 117 | Summary: |
113 | Many memory wasting problems of KA/Pi and KO/Pi fixed such that it is better to use on the Zaurus. | 118 | Many memory wasting problems of KA/Pi and KO/Pi fixed such that it is better to use on the Zaurus. |
114 | 119 | ||
115 | ********** VERSION 2.1.12 ************ | 120 | ********** VERSION 2.1.12 ************ |
116 | 121 | ||
117 | KO/Pi: | 122 | KO/Pi: |
118 | Many small usability fixes, e.g. rearranged the popup menus such that they are better to use on the Zaurus. | 123 | Many small usability fixes, e.g. rearranged the popup menus such that they are better to use on the Zaurus. |
119 | Fixed a problem with the month view when file was saved but KO/Pi was not the active window. | 124 | Fixed a problem with the month view when file was saved but KO/Pi was not the active window. |
120 | Fixed some problems in the resource config dialog (e.g. added a warning if you set all calendars to read-only). | 125 | Fixed some problems in the resource config dialog (e.g. added a warning if you set all calendars to read-only). |
121 | Fixed some other small problems. | 126 | Fixed some other small problems. |
122 | 127 | ||
123 | ********** VERSION 2.1.11 ************ | 128 | ********** VERSION 2.1.11 ************ |
124 | 129 | ||
125 | KO/Pi: | 130 | KO/Pi: |
126 | Because we can have many calendars now in KO/Pi we can have more than one journal entry per day. | 131 | Because we can have many calendars now in KO/Pi we can have more than one journal entry per day. |
127 | Added features to handle (and add ) more than one journal entry per day. | 132 | Added features to handle (and add ) more than one journal entry per day. |
128 | Added option for a journal title. | 133 | Added option for a journal title. |
129 | 134 | ||
130 | Added info about the calendar, the item belongs to, to the event/todo/journal viewer. | 135 | Added info about the calendar, the item belongs to, to the event/todo/journal viewer. |
131 | Fixed a problem of the alarm of completed recurring todos. | 136 | Fixed a problem of the alarm of completed recurring todos. |
132 | Added to the event/todo editor to set quickly the category of an item. | 137 | Added to the event/todo editor to set quickly the category of an item. |
133 | 138 | ||
134 | 139 | ||
135 | Fixed some problems when calling KO/Pi or KA/Pi from the alarm applet. | 140 | Fixed some problems when calling KO/Pi or KA/Pi from the alarm applet. |
136 | 141 | ||
137 | Added KA/Pi multi sync to the multi sync called from the alarm applet. | 142 | Added KA/Pi multi sync to the multi sync called from the alarm applet. |
138 | 143 | ||
139 | ********** VERSION 2.1.10 ************ | 144 | ********** VERSION 2.1.10 ************ |
140 | 145 | ||
141 | KO/Pi: | 146 | KO/Pi: |
142 | Importing Birthdays will now create another file resource "Birthdays" and import the birthday data from KA/Pi into that file. | 147 | Importing Birthdays will now create another file resource "Birthdays" and import the birthday data from KA/Pi into that file. |
143 | When a multidayevent is selected in monthview all occurences of this event in the monthview are now hightlighted. | 148 | When a multidayevent is selected in monthview all occurences of this event in the monthview are now hightlighted. |
144 | Fixed a bug in searching for a small timerange, i.e. one day. | 149 | Fixed a bug in searching for a small timerange, i.e. one day. |
145 | 150 | ||
146 | KA/Pi: | 151 | KA/Pi: |
147 | Fixed two problems in csv export. | 152 | Fixed two problems in csv export. |
148 | Fixed problems when calling the contact selection dialog from KO/Pi or OM/Pi. | 153 | Fixed problems when calling the contact selection dialog from KO/Pi or OM/Pi. |
149 | 154 | ||
150 | ********** VERSION 2.1.9 ************ | 155 | ********** VERSION 2.1.9 ************ |
151 | 156 | ||
152 | KO/Pi: | 157 | KO/Pi: |
153 | Fixed some problems of the new search options in the search dialog. | 158 | Fixed some problems of the new search options in the search dialog. |
154 | Fixed some problems in the new resource config options. | 159 | Fixed some problems in the new resource config options. |
155 | Changed the recurrence edit of events and todos such that the recurrence edit page now is notified about a change of the start date on the first page. | 160 | Changed the recurrence edit of events and todos such that the recurrence edit page now is notified about a change of the start date on the first page. |
156 | Fixed a problem creating new events in the agenda view if at the day/time is already an agenda item shown: | 161 | Fixed a problem creating new events in the agenda view if at the day/time is already an agenda item shown: |
157 | Now you can click on the bottom/top of an allday agenda item or on the left/right side of an agenda item to get the "new todo/new event" popup. | 162 | Now you can click on the bottom/top of an allday agenda item or on the left/right side of an agenda item to get the "new todo/new event" popup. |
158 | 163 | ||
159 | Fixed a problem in recurrence range in syncing with DTM. | 164 | Fixed a problem in recurrence range in syncing with DTM. |
160 | 165 | ||
161 | KA/Pi: | 166 | KA/Pi: |
162 | Made it posiible to show in the contact overview the details of all data available for that contact( e.g. office, spouse, children, nickname ...) | 167 | Made it posiible to show in the contact overview the details of all data available for that contact( e.g. office, spouse, children, nickname ...) |
163 | 168 | ||
164 | PwM/Pi: | 169 | PwM/Pi: |
165 | Added "sec" to the timeout config settings to make it clear the timeout values are seconds. | 170 | Added "sec" to the timeout config settings to make it clear the timeout values are seconds. |
166 | 171 | ||
167 | ********** VERSION 2.1.8 ************ | 172 | ********** VERSION 2.1.8 ************ |
168 | 173 | ||
169 | KO/Pi: | 174 | KO/Pi: |
170 | Added info about the completion state of a todo in the ListView/Searchdialog. | 175 | Added info about the completion state of a todo in the ListView/Searchdialog. |
171 | If in TodoView is selected "do not show compledted todos" then completed todos are not shown in the ListView as well. | 176 | If in TodoView is selected "do not show compledted todos" then completed todos are not shown in the ListView as well. |
172 | Fixed some updating problems when changing the filter. | 177 | Fixed some updating problems when changing the filter. |
173 | 178 | ||
174 | KA/Pi: | 179 | KA/Pi: |
175 | In the addressee selection dialog now the formatted name is shown, if not empty. | 180 | In the addressee selection dialog now the formatted name is shown, if not empty. |
176 | Added a column "category" to the addressee selection dialog to make it possible to sort addressees after category. | 181 | Added a column "category" to the addressee selection dialog to make it possible to sort addressees after category. |
177 | Now in the addressee selection dialog a selected contact is remove with a single click from the selected list. | 182 | Now in the addressee selection dialog a selected contact is remove with a single click from the selected list. |
178 | 183 | ||
179 | Fixed in the file selector on the Zaurus the problem that symbolic links to files/dirs were ignored. | 184 | Fixed in the file selector on the Zaurus the problem that symbolic links to files/dirs were ignored. |
180 | Fixed the sorting for size in the file selector on the Z. | 185 | Fixed the sorting for size in the file selector on the Z. |
181 | 186 | ||
182 | Changed the color selection dialog on the Zaurus to a more user friendly version. | 187 | Changed the color selection dialog on the Zaurus to a more user friendly version. |
183 | 188 | ||
184 | ********** VERSION 2.1.7 ************ | 189 | ********** VERSION 2.1.7 ************ |
185 | 190 | ||
186 | KO/Pi: | 191 | KO/Pi: |
187 | Fixed several problems in the new Resource handling. | 192 | Fixed several problems in the new Resource handling. |
188 | Added more options to the search dialog. | 193 | Added more options to the search dialog. |
189 | Fixed a problem in the Month view. | 194 | Fixed a problem in the Month view. |
190 | Added more options to the dialog when setting a todo to stopped. | 195 | Added more options to the dialog when setting a todo to stopped. |
191 | 196 | ||
192 | Fixed two small problems in KO/Pi Alarm applet. | 197 | Fixed two small problems in KO/Pi Alarm applet. |
193 | 198 | ||
194 | ********** VERSION 2.1.6 ************ | 199 | ********** VERSION 2.1.6 ************ |
195 | 200 | ||
196 | This release is for testing only. | 201 | This release is for testing only. |
197 | 202 | ||
198 | KO/Pi: | 203 | KO/Pi: |
199 | Added to the list view (the list view is used in search dialog as well) the possibility to print it. | 204 | Added to the list view (the list view is used in search dialog as well) the possibility to print it. |
200 | Added to the list view the possibility to hide entries, if you do not want to print all entries of the list view. | 205 | Added to the list view the possibility to hide entries, if you do not want to print all entries of the list view. |
201 | Added to the list view the possibility to add all subtodos of selected todos to an export/beam. | 206 | Added to the list view the possibility to add all subtodos of selected todos to an export/beam. |
202 | Added to the search dialog the possibility to make an additive search such that you can get a better list for export/printout. | 207 | Added to the search dialog the possibility to make an additive search such that you can get a better list for export/printout. |
203 | Added to the search dialog the possibility to hide the checkboxes such that there is more space for the list view on the Zaurus. | 208 | Added to the search dialog the possibility to hide the checkboxes such that there is more space for the list view on the Zaurus. |
204 | Fixed a problem in the AlarmTimer Applet: Now utf8 messages are displayed properly. | 209 | Fixed a problem in the AlarmTimer Applet: Now utf8 messages are displayed properly. |
205 | 210 | ||
206 | Added support for multiple calendar files in KO/Pi. Only local ical (*.ics) files are supported as calendars. | 211 | Added support for multiple calendar files in KO/Pi. Only local ical (*.ics) files are supported as calendars. |
207 | In the sync profile config it is still missing to specify a particular calendar to sync with this profile. That setting will be added later. | 212 | In the sync profile config it is still missing to specify a particular calendar to sync with this profile. That setting will be added later. |
208 | Now on every sync the set of calendars is synced which are enabled in the resource view. | 213 | Now on every sync the set of calendars is synced which are enabled in the resource view. |
209 | 214 | ||
210 | A calendar is enabled in the resource view if the "eye" column is checked. | 215 | A calendar is enabled in the resource view if the "eye" column is checked. |
211 | You can set a calendar to be the default for new items( "+" column ). | 216 | You can set a calendar to be the default for new items( "+" column ). |
212 | You can tell KO/Pi to ignore all alarm of a calendar ( "bell" column ) and you can set it readonly. | 217 | You can tell KO/Pi to ignore all alarm of a calendar ( "bell" column ) and you can set it readonly. |
213 | To find out how to add a new calendar and how to remove a calendar is left as an exercise to the reader ... | 218 | To find out how to add a new calendar and how to remove a calendar is left as an exercise to the reader ... |
214 | 219 | ||
215 | 220 | ||
216 | ********** VERSION 2.1.5 ************ | 221 | ********** VERSION 2.1.5 ************ |
217 | 222 | ||
218 | This is the new stable version. | 223 | This is the new stable version. |
219 | Bugfix: | 224 | Bugfix: |
220 | Fixed a problem with agenda popup on the desktop in KO/Pi. | 225 | Fixed a problem with agenda popup on the desktop in KO/Pi. |
221 | Fixed a crash when reloading file, e.g. after a passive pi-sync synchronization. | 226 | Fixed a crash when reloading file, e.g. after a passive pi-sync synchronization. |
222 | Added config option to not display completed todos in agenda view. | 227 | Added config option to not display completed todos in agenda view. |
223 | Addressee view is now using the formatted name, if defined. | 228 | Addressee view is now using the formatted name, if defined. |
224 | That makes it possible to display "lastname, firstname" in that view now. | 229 | That makes it possible to display "lastname, firstname" in that view now. |
225 | To set the formatted name for all contacts, please use menu: | 230 | To set the formatted name for all contacts, please use menu: |
226 | Edit->Change->Set formatted name. | 231 | Edit->Change->Set formatted name. |
227 | Fixed the bug in KA/Pi that is was not possible to add images to a contact on Windows. | 232 | Fixed the bug in KA/Pi that is was not possible to add images to a contact on Windows. |
228 | 233 | ||
229 | ********** VERSION 2.1.4 ************ | 234 | ********** VERSION 2.1.4 ************ |
230 | 235 | ||
231 | Fixed two more bugs in the KA/Pi CSV import dialog: | 236 | Fixed two more bugs in the KA/Pi CSV import dialog: |
232 | Made it possible to read multi-line fields and import it to the "Note" field. | 237 | Made it possible to read multi-line fields and import it to the "Note" field. |
233 | Fixed a problem in mapping custom fields, whatever a custem field is... | 238 | Fixed a problem in mapping custom fields, whatever a custem field is... |
234 | 239 | ||
235 | ********** VERSION 2.1.3 ************ | 240 | ********** VERSION 2.1.3 ************ |
236 | 241 | ||
237 | Changed the menu structure of the alarm applet: | 242 | Changed the menu structure of the alarm applet: |
238 | Moved "Simulate" to " Play Beeps" submenu and re-added "Todo List". | 243 | Moved "Simulate" to " Play Beeps" submenu and re-added "Todo List". |
239 | 244 | ||
240 | Fixed several problems in the KA/Pi CSV import dialog: | 245 | Fixed several problems in the KA/Pi CSV import dialog: |
241 | Added "Category", made codec configureable and made it possible to map many fields to the "Note" field. | 246 | Added "Category", made codec configureable and made it possible to map many fields to the "Note" field. |
242 | 247 | ||
243 | 248 | ||
244 | ********** VERSION 2.1.2 ************ | 249 | ********** VERSION 2.1.2 ************ |
245 | 250 | ||
246 | Fixed a problem closing the alarm dialog on Zaurus with "OK" button. | 251 | Fixed a problem closing the alarm dialog on Zaurus with "OK" button. |
247 | 252 | ||
248 | Fixed a problem when importing data from Outlook with mutiple categories set. | 253 | Fixed a problem when importing data from Outlook with mutiple categories set. |
249 | 254 | ||
250 | Changed display of days in datenavigator: | 255 | Changed display of days in datenavigator: |
251 | Birthdays are now blue, not dark green. | 256 | Birthdays are now blue, not dark green. |
252 | When todo view is shown, no birtdays are shown and days with due todos are shown blue. | 257 | When todo view is shown, no birtdays are shown and days with due todos are shown blue. |
253 | When journal view is shown, only holidays are shown and days with journals are blue. | 258 | When journal view is shown, only holidays are shown and days with journals are blue. |
254 | 259 | ||
255 | Added Backup options to global config: | 260 | Added Backup options to global config: |
256 | You can create now x-daily backups for KO/Pi, KA/Pi (for file resources only, file resource is the standard type) and PwM/Pi ( all files you will open ). | 261 | You can create now x-daily backups for KO/Pi, KA/Pi (for file resources only, file resource is the standard type) and PwM/Pi ( all files you will open ). |
257 | It is recommended to use another HDD/Memory card for the backup directory. If (very useful on the Zaurus) the specified backup directory does not exist you are asked if you want to try again to create a backup. That makes it possible to insert your memory card in the Zaurus and then trying again. | 262 | It is recommended to use another HDD/Memory card for the backup directory. If (very useful on the Zaurus) the specified backup directory does not exist you are asked if you want to try again to create a backup. That makes it possible to insert your memory card in the Zaurus and then trying again. |
258 | The backup is created when the application wants to save for the first time on a backup-day. You can specify the amount of backups and the day interval of backups. | 263 | The backup is created when the application wants to save for the first time on a backup-day. You can specify the amount of backups and the day interval of backups. |
259 | 264 | ||
260 | ********** VERSION 2.1.1 ************ | 265 | ********** VERSION 2.1.1 ************ |
261 | 266 | ||
262 | Stable release 2.1.1! | 267 | Stable release 2.1.1! |
263 | 268 | ||
264 | KO/Pi: | 269 | KO/Pi: |
265 | Fixed one problem in the layout of the edit dialogs on the Zaurus with 640x480 display. | 270 | Fixed one problem in the layout of the edit dialogs on the Zaurus with 640x480 display. |
266 | 271 | ||
267 | ********** VERSION 2.1.0 ************ | 272 | ********** VERSION 2.1.0 ************ |
268 | 273 | ||
269 | Stable release 2.1.0! | 274 | Stable release 2.1.0! |
270 | 275 | ||
271 | Summary of changes/fixes compared to version 2.0.6: | 276 | Summary of changes/fixes compared to version 2.0.6: |
272 | 277 | ||
273 | Many bugs of version 2.0.6 fixed. | 278 | Many bugs of version 2.0.6 fixed. |
274 | Most of them were small bugs, but some of them were important. | 279 | Most of them were small bugs, but some of them were important. |
275 | It is recommended to use version 2.1.0 and not version 2.0.6. | 280 | It is recommended to use version 2.1.0 and not version 2.0.6. |
276 | 281 | ||
277 | Important changes: | 282 | Important changes: |
278 | 283 | ||
279 | Added recurring todos to KO/Pi. | 284 | Added recurring todos to KO/Pi. |
280 | 285 | ||
281 | Added global application font settings (for all KDE-Pim/Pi apps) to the general settings. | 286 | Added global application font settings (for all KDE-Pim/Pi apps) to the general settings. |
282 | 287 | ||
283 | Made Passwordmanager PwM/Pi more userfriendly: Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more. | 288 | Made Passwordmanager PwM/Pi more userfriendly: Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more. |
284 | 289 | ||
285 | Datenavigator can now display many months. Very useful on the desktop. | 290 | Datenavigator can now display many months. Very useful on the desktop. |
286 | 291 | ||
287 | KO/Pi alarm applet changed: Made buttons in alarm dialog much bigger and other usebility enhancements. | 292 | KO/Pi alarm applet changed: Made buttons in alarm dialog much bigger and other usebility enhancements. |
288 | 293 | ||
289 | Made alarm sound working on Linux desktop. | 294 | Made alarm sound working on Linux desktop. |
290 | 295 | ||
291 | Made KO/Pi and KA/Pi running from a memory stick. Please read storage HowTo for details. | 296 | Made KO/Pi and KA/Pi running from a memory stick. Please read storage HowTo for details. |
292 | 297 | ||
293 | Added timetracking feature in KO/Pi todo view. Please read timetraker HowTo for details. | 298 | Added timetracking feature in KO/Pi todo view. Please read timetraker HowTo for details. |
294 | 299 | ||
295 | Many other usebility enhancements. | 300 | Many other usebility enhancements. |
296 | Special thanks to Ben for his suggestions! | 301 | Special thanks to Ben for his suggestions! |
297 | 302 | ||
298 | You can find the complete changelog | 303 | You can find the complete changelog |
299 | from version 1.7.7 to 2.1.0 | 304 | from version 1.7.7 to 2.1.0 |
300 | in the source package or on | 305 | in the source package or on |
301 | 306 | ||
302 | http://www.pi-sync.net/html/changelog.html | 307 | http://www.pi-sync.net/html/changelog.html |
303 | 308 | ||
304 | 309 | ||
305 | 310 | ||
diff --git a/desktop/rpm/kdepim_rpm b/desktop/rpm/kdepim_rpm index 133d0d1..a29e4ea 100644 --- a/desktop/rpm/kdepim_rpm +++ b/desktop/rpm/kdepim_rpm | |||
@@ -1,84 +1,84 @@ | |||
1 | Summary: A collection of PIM programs | 1 | Summary: A collection of PIM programs |
2 | Name: KDE-Pim-Pi | 2 | Name: KDE-Pim-Pi |
3 | Version: 2.1.18 | 3 | Version: 2.1.19 |
4 | Release: SuSE_9.2 | 4 | Release: SuSE_9.2 |
5 | Copyright:GPL | 5 | Copyright:GPL |
6 | Group: Productivity/Pim | 6 | Group: Productivity/Pim |
7 | Source:http://sourceforge.net/projects/kdepimpi/ | 7 | Source:http://sourceforge.net/projects/kdepimpi/ |
8 | URL:http://sourceforge.net/projects/kdepimpi/ | 8 | URL:http://sourceforge.net/projects/kdepimpi/ |
9 | Packager: zautrix | 9 | Packager: zautrix |
10 | 10 | ||
11 | %description | 11 | %description |
12 | This package contains the platform-independent PIM programs from | 12 | This package contains the platform-independent PIM programs from |
13 | www.pi-sync.info, compiled for SuSE 9.2: | 13 | www.pi-sync.info, compiled for SuSE 9.2: |
14 | KTimeTacker/Pi | 14 | KTimeTacker/Pi |
15 | KPhone/Pi | 15 | KPhone/Pi |
16 | KAddressbook/Pi | 16 | KAddressbook/Pi |
17 | KOrganizer/Pi | 17 | KOrganizer/Pi |
18 | PasswordManager/Pi | 18 | PasswordManager/Pi |
19 | KOPieMail/Pi | 19 | KOPieMail/Pi |
20 | 20 | ||
21 | These applications do not need anything from the KDE-desktop | 21 | These applications do not need anything from the KDE-desktop |
22 | at all to run on Linux. However, there is a dependency from | 22 | at all to run on Linux. However, there is a dependency from |
23 | two KDE libs, because a small command line program is included | 23 | two KDE libs, because a small command line program is included |
24 | to make it possible to sync with the KDE-desktop applications. | 24 | to make it possible to sync with the KDE-desktop applications. |
25 | 25 | ||
26 | These applications are independent from the KDE-desktop | 26 | These applications are independent from the KDE-desktop |
27 | environment. That means, nothing of your existing | 27 | environment. That means, nothing of your existing |
28 | KDE-desktop setup will be changed, or any data | 28 | KDE-desktop setup will be changed, or any data |
29 | (calendar-addressbook) used by the KDE-desktop | 29 | (calendar-addressbook) used by the KDE-desktop |
30 | applications will be changed or accessed. | 30 | applications will be changed or accessed. |
31 | These applications stores their data and config in | 31 | These applications stores their data and config in |
32 | $HOME/kdepim/ | 32 | $HOME/kdepim/ |
33 | However, because the same file format is used, | 33 | However, because the same file format is used, |
34 | an easy exchange of data with the KDE-desktop | 34 | an easy exchange of data with the KDE-desktop |
35 | is possible. | 35 | is possible. |
36 | A small command line program is included | 36 | A small command line program is included |
37 | to make it possible to sync with the KDE-desktop applications. | 37 | to make it possible to sync with the KDE-desktop applications. |
38 | You do not need to call this program from the commandline, | 38 | You do not need to call this program from the commandline, |
39 | it is called from the KDE-Pim/Pi apps when you choose there: | 39 | it is called from the KDE-Pim/Pi apps when you choose there: |
40 | Sync with KDE_Desktop. | 40 | Sync with KDE_Desktop. |
41 | If something is going wrong, please start the | 41 | If something is going wrong, please start the |
42 | KDE-Pim/Pi program itself from the console to get detailed output. | 42 | KDE-Pim/Pi program itself from the console to get detailed output. |
43 | 43 | ||
44 | After installation, you should have a | 44 | After installation, you should have a |
45 | PIM-pi | 45 | PIM-pi |
46 | folder in your KDE start menu, where you can | 46 | folder in your KDE start menu, where you can |
47 | start the applications from. | 47 | start the applications from. |
48 | 48 | ||
49 | These programs makes it possible to sync your Zaurus easily | 49 | These programs makes it possible to sync your Zaurus easily |
50 | (with the KDE-Pim/Pi programs running on the Zaurus) | 50 | (with the KDE-Pim/Pi programs running on the Zaurus) |
51 | with the KDE-desktop calendar/addressbook data. | 51 | with the KDE-desktop calendar/addressbook data. |
52 | If you want to use that, you have to update your | 52 | If you want to use that, you have to update your |
53 | KDE-desktop to version 3.3.0 or higher. | 53 | KDE-desktop to version 3.3.0 or higher. |
54 | SuSE 9.2 contains KDE 3.3.0 such that no update is needed. | 54 | SuSE 9.2 contains KDE 3.3.0 such that no update is needed. |
55 | Actually - after the (non difficult) configuration is set up - | 55 | Actually - after the (non difficult) configuration is set up - |
56 | with two mouseklicks on the Zaurus, | 56 | with two mouseklicks on the Zaurus, |
57 | the Zaurus syncs with the corresponding KDE-Pim/Pi | 57 | the Zaurus syncs with the corresponding KDE-Pim/Pi |
58 | program on the Linux Desktop which syncs automatically | 58 | program on the Linux Desktop which syncs automatically |
59 | with the KDE-desktop data. | 59 | with the KDE-desktop data. |
60 | 60 | ||
61 | If you want to use the KDE-desktop calendar/addressbook applications, | 61 | If you want to use the KDE-desktop calendar/addressbook applications, |
62 | just install these apps in this package and use them as a syncing tool for the | 62 | just install these apps in this package and use them as a syncing tool for the |
63 | Zaurus <-> KDE-desktop sync. | 63 | Zaurus <-> KDE-desktop sync. |
64 | The sync requires a network connection from your Zaurus to | 64 | The sync requires a network connection from your Zaurus to |
65 | the PC. A detailed Sync HowTo is available in the | 65 | the PC. A detailed Sync HowTo is available in the |
66 | Help menu of the applications. | 66 | Help menu of the applications. |
67 | 67 | ||
68 | These applications makes it also possible, that you can sync | 68 | These applications makes it also possible, that you can sync |
69 | (or just export the data to) your mobile phone with your | 69 | (or just export the data to) your mobile phone with your |
70 | data of the KDE-desktop calendar/addressbook applications. | 70 | data of the KDE-desktop calendar/addressbook applications. |
71 | This is tested and working for Nokia mobile phones, | 71 | This is tested and working for Nokia mobile phones, |
72 | it may work with others as well. | 72 | it may work with others as well. |
73 | (More info about that: -> Sync HowTo) | 73 | (More info about that: -> Sync HowTo) |
74 | 74 | ||
75 | NOTE: | 75 | NOTE: |
76 | When using SuSE 9.1 you have to update your KDE to 3.3.x | 76 | When using SuSE 9.1 you have to update your KDE to 3.3.x |
77 | and you have to make an online update in SuSE 9.1 to make it | 77 | and you have to make an online update in SuSE 9.1 to make it |
78 | possible to get the infrared connection working, such that | 78 | possible to get the infrared connection working, such that |
79 | you can sync your (Nokia) mobile phone via infrared. | 79 | you can sync your (Nokia) mobile phone via infrared. |
80 | 80 | ||
81 | %files | 81 | %files |
82 | /opt/kde3/share/applnk/PIM-pi/ | 82 | /opt/kde3/share/applnk/PIM-pi/ |
83 | /opt/kdepimpi/ | 83 | /opt/kdepimpi/ |
84 | /usr/lib/libmicro* | 84 | /usr/lib/libmicro* |
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp index 5fc3f2f..7f6f221 100644 --- a/korganizer/journalentry.cpp +++ b/korganizer/journalentry.cpp | |||
@@ -1,371 +1,373 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 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 | // | 24 | // |
25 | // Journal Entry | 25 | // Journal Entry |
26 | 26 | ||
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qvbox.h> | 29 | #include <qvbox.h> |
30 | #include <qfile.h> | 30 | #include <qfile.h> |
31 | #include <qdir.h> | 31 | #include <qdir.h> |
32 | #include <qtextstream.h> | 32 | #include <qtextstream.h> |
33 | #include <qtextcodec.h> | 33 | #include <qtextcodec.h> |
34 | #include <qpixmap.h> | 34 | #include <qpixmap.h> |
35 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | #include <qapplication.h> | 36 | #include <qapplication.h> |
37 | 37 | ||
38 | #include <kdebug.h> | 38 | #include <kdebug.h> |
39 | #include <kglobal.h> | 39 | #include <kglobal.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <ktextedit.h> | 41 | #include <ktextedit.h> |
42 | #include <kfiledialog.h> | 42 | #include <kfiledialog.h> |
43 | #include <kmessagebox.h> | 43 | #include <kmessagebox.h> |
44 | #include "koprefs.h" | 44 | #include "koprefs.h" |
45 | #include <klineedit.h> | 45 | #include <klineedit.h> |
46 | #include <kdialog.h> | 46 | #include <kdialog.h> |
47 | #include "kolocationbox.h" | 47 | #include "kolocationbox.h" |
48 | 48 | ||
49 | #include <libkcal/journal.h> | 49 | #include <libkcal/journal.h> |
50 | #include <libkcal/calendarresources.h> | 50 | #include <libkcal/calendarresources.h> |
51 | #include <libkcal/resourcecalendar.h> | 51 | #include <libkcal/resourcecalendar.h> |
52 | #include <kresources/resourceselectdialog.h> | 52 | #include <kresources/resourceselectdialog.h> |
53 | 53 | ||
54 | #include "journalentry.h" | 54 | #include "journalentry.h" |
55 | //#include "journalentry.moc" | 55 | //#include "journalentry.moc" |
56 | #ifndef DESKTOP_VERSION | 56 | #ifndef DESKTOP_VERSION |
57 | #include <qpe/qpeapplication.h> | 57 | #include <qpe/qpeapplication.h> |
58 | #endif | 58 | #endif |
59 | JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : | 59 | JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : |
60 | QFrame(parent) | 60 | QFrame(parent) |
61 | { | 61 | { |
62 | 62 | ||
63 | int fac = 5; | 63 | int fac = 5; |
64 | heiHint = QApplication::desktop()->height(); | 64 | heiHint = QApplication::desktop()->height(); |
65 | if ( heiHint > 800 ) | 65 | if ( heiHint > 800 ) |
66 | fac += 2; | 66 | fac += 2; |
67 | heiHint = heiHint / fac; | 67 | heiHint = heiHint / fac; |
68 | 68 | ||
69 | showOnlyMode = false; | 69 | showOnlyMode = false; |
70 | mCalendar = calendar; | 70 | mCalendar = calendar; |
71 | mJournal = 0; | 71 | mJournal = 0; |
72 | visibleMode = true; | 72 | visibleMode = true; |
73 | QHBox * vb = new QHBox ( this ); | 73 | QHBox * vb = new QHBox ( this ); |
74 | QPixmap iconp; | 74 | QPixmap iconp; |
75 | vb->setMargin ( KDialog::marginHint()-1 ); | 75 | vb->setMargin ( KDialog::marginHint()-1 ); |
76 | QPushButton * toggleJournal = new QPushButton( vb ); | 76 | QPushButton * toggleJournal = new QPushButton( vb ); |
77 | iconp = SmallIcon("1updownarrow"); | 77 | iconp = SmallIcon("1updownarrow"); |
78 | toggleJournal->setPixmap (iconp ) ; | 78 | toggleJournal->setPixmap (iconp ) ; |
79 | QLabel* textLabel = new QLabel(" "+i18n("Title: "),vb); | 79 | QLabel* textLabel = new QLabel(" "+i18n("Title: "),vb); |
80 | mTitle = new KOLocationBox(TRUE, vb, 30); | 80 | mTitle = new KOLocationBox(TRUE, vb, 30); |
81 | mTitle->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Fixed ,FALSE) ); | 81 | mTitle->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Fixed ,FALSE) ); |
82 | mCalendarBox = new QComboBox(vb); | 82 | mCalendarBox = new QComboBox(vb); |
83 | mCalendarBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Fixed ,FALSE) ); | 83 | mCalendarBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Fixed ,FALSE) ); |
84 | #ifndef DESKTOP_VERSION | 84 | #ifndef DESKTOP_VERSION |
85 | mTitle->setSizeLimit( 8 ); | 85 | mTitle->setSizeLimit( 8 ); |
86 | mCalendarBox->setSizeLimit( 8 ); | 86 | mCalendarBox->setSizeLimit( 8 ); |
87 | #endif | 87 | #endif |
88 | vb->setStretchFactor ( mTitle, 8 ); | 88 | vb->setStretchFactor ( mTitle, 8 ); |
89 | int limit = 3; | 89 | int limit = 3; |
90 | if ( QApplication::desktop()->width() < 640 ) | 90 | if ( QApplication::desktop()->width() < 640 ) |
91 | limit = 6; | 91 | limit = 6; |
92 | vb->setStretchFactor ( mCalendarBox, limit ); | 92 | vb->setStretchFactor ( mCalendarBox, limit ); |
93 | //mTitleLabel->setMargin(0); | 93 | //mTitleLabel->setMargin(0); |
94 | //mTitleLabel->setAlignment(AlignCenter); | 94 | //mTitleLabel->setAlignment(AlignCenter); |
95 | QPushButton * loadTemplate = new QPushButton( vb ); | 95 | QPushButton * loadTemplate = new QPushButton( vb ); |
96 | QPushButton * saveTemplate = new QPushButton( vb ); | 96 | QPushButton * saveTemplate = new QPushButton( vb ); |
97 | if ( QApplication::desktop()->width() < 321 ) | 97 | if ( QApplication::desktop()->width() < 321 ) |
98 | iconp = SmallIcon("fileexport16"); | 98 | iconp = SmallIcon("fileexport16"); |
99 | else | 99 | else |
100 | iconp = SmallIcon("fileexport"); | 100 | iconp = SmallIcon("fileexport"); |
101 | saveTemplate->setPixmap (iconp ) ; | 101 | saveTemplate->setPixmap (iconp ) ; |
102 | int size = saveTemplate->sizeHint().height(); | 102 | int size = saveTemplate->sizeHint().height(); |
103 | if ( QApplication::desktop()->width() < 321 ) | 103 | if ( QApplication::desktop()->width() < 321 ) |
104 | iconp = SmallIcon("fileimport16"); | 104 | iconp = SmallIcon("fileimport16"); |
105 | else | 105 | else |
106 | iconp = SmallIcon("fileimport"); | 106 | iconp = SmallIcon("fileimport"); |
107 | loadTemplate->setPixmap (iconp ) ; | 107 | loadTemplate->setPixmap (iconp ) ; |
108 | loadTemplate->setFixedSize( size, size ); | 108 | loadTemplate->setFixedSize( size, size ); |
109 | saveTemplate->setFixedSize( size, size ); | 109 | saveTemplate->setFixedSize( size, size ); |
110 | int widwid = size; | 110 | int widwid = size; |
111 | if ( QApplication::desktop()->width() < 320 ) | 111 | if ( QApplication::desktop()->width() < 320 ) |
112 | widwid = size/2+1; | 112 | widwid = size/2+1; |
113 | toggleJournal->setFixedSize( widwid , size ); | 113 | toggleJournal->setFixedSize( widwid , size ); |
114 | mTitle->setFixedHeight( size+4); | 114 | mTitle->setFixedHeight( size+4); |
115 | mCalendarBox->setFixedHeight( size+4); | 115 | mCalendarBox->setFixedHeight( size+4); |
116 | mEditor = new KTextEdit(this); | 116 | mEditor = new KTextEdit(this); |
117 | #ifndef DESKTOP_VERSION | 117 | #ifndef DESKTOP_VERSION |
118 | QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold ); | 118 | QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold ); |
119 | #endif | 119 | #endif |
120 | mMaxWidDiff = 3*size - 2*frameWidth() - textLabel->sizeHint().width(); | 120 | mMaxWidDiff = 3*size - 2*frameWidth() - textLabel->sizeHint().width(); |
121 | mDeskWid = QApplication::desktop()->width(); | 121 | mDeskWid = QApplication::desktop()->width(); |
122 | int maxwid = mDeskWid - mMaxWidDiff; | 122 | int maxwid = mDeskWid - mMaxWidDiff; |
123 | if ( QApplication::desktop()->width() < 640 ) { | 123 | if ( QApplication::desktop()->width() < 640 ) { |
124 | mTitle->setMaximumWidth( maxwid/2 +20 ); | 124 | mTitle->setMaximumWidth( maxwid/2 +20 ); |
125 | mCalendarBox->setMaximumWidth( maxwid/2 -20); | 125 | mCalendarBox->setMaximumWidth( maxwid/2 -20); |
126 | } else { | 126 | } else { |
127 | mTitle->setMaximumWidth( (maxwid/4)*3); | 127 | mTitle->setMaximumWidth( (maxwid/4)*3); |
128 | mCalendarBox->setMaximumWidth( maxwid/2 ); | 128 | mCalendarBox->setMaximumWidth( maxwid/2 ); |
129 | } | 129 | } |
130 | //mCalendarBox->setMaximumWidth( maxwid/2 -20 ); | 130 | //mCalendarBox->setMaximumWidth( maxwid/2 -20 ); |
131 | mEditor->setWordWrap( KTextEdit::WidgetWidth ); | 131 | mEditor->setWordWrap( KTextEdit::WidgetWidth ); |
132 | QBoxLayout *topLayout = new QVBoxLayout(this); | 132 | QBoxLayout *topLayout = new QVBoxLayout(this); |
133 | topLayout->addWidget(vb); | 133 | topLayout->addWidget(vb); |
134 | topLayout->addWidget(mEditor); | 134 | topLayout->addWidget(mEditor); |
135 | mEditor->installEventFilter(this); | 135 | mEditor->installEventFilter(this); |
136 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); | 136 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); |
137 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); | 137 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); |
138 | connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) ); | 138 | connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) ); |
139 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); | 139 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); |
140 | mTitle->lineEdit ()->setText(""); | 140 | mTitle->lineEdit ()->setText(""); |
141 | } | 141 | } |
142 | 142 | ||
143 | JournalEntry::~JournalEntry() | 143 | JournalEntry::~JournalEntry() |
144 | { | 144 | { |
145 | //qDebug("JournalEntry::~JournalEntry() "); | 145 | //qDebug("JournalEntry::~JournalEntry() "); |
146 | } | 146 | } |
147 | void JournalEntry::resizeEvent(QResizeEvent* e ) | 147 | void JournalEntry::resizeEvent(QResizeEvent* e ) |
148 | { | 148 | { |
149 | #ifndef DESKTOP_VERSION | 149 | #ifndef DESKTOP_VERSION |
150 | 150 | ||
151 | if ( mDeskWid != QApplication::desktop()->width() ) { | 151 | if ( mDeskWid != QApplication::desktop()->width() ) { |
152 | mDeskWid == QApplication::desktop()->width(); | 152 | mDeskWid == QApplication::desktop()->width(); |
153 | int maxwid = mDeskWid - mMaxWidDiff; | 153 | int maxwid = mDeskWid - mMaxWidDiff; |
154 | if ( QApplication::desktop()->width() < 640 ) { | 154 | if ( QApplication::desktop()->width() < 640 ) { |
155 | mTitle->setMaximumWidth( maxwid/2 +20 ); | 155 | mTitle->setMaximumWidth( maxwid/2 +20 ); |
156 | mCalendarBox->setMaximumWidth( maxwid/2 -20); | 156 | mCalendarBox->setMaximumWidth( maxwid/2 -20); |
157 | } | 157 | } |
158 | else { | 158 | else { |
159 | mTitle->setMaximumWidth( (maxwid/4)*3); | 159 | mTitle->setMaximumWidth( (maxwid/4)*3); |
160 | mCalendarBox->setMaximumWidth( maxwid/2 ); | 160 | mCalendarBox->setMaximumWidth( maxwid/2 ); |
161 | } | 161 | } |
162 | //mCalendarBox->setMaximumWidth( maxwid/2 -20 ); | 162 | //mCalendarBox->setMaximumWidth( maxwid/2 -20 ); |
163 | } | 163 | } |
164 | //setMaximumWidth( QApplication::desktop()->width() ); | 164 | //setMaximumWidth( QApplication::desktop()->width() ); |
165 | //qDebug("MAXXX %d ", QApplication::desktop()->width()); | 165 | //qDebug("MAXXX %d ", QApplication::desktop()->width()); |
166 | #endif | 166 | #endif |
167 | QFrame::resizeEvent( e ); | 167 | QFrame::resizeEvent( e ); |
168 | } | 168 | } |
169 | QSize JournalEntry::sizeHint() const | 169 | QSize JournalEntry::sizeHint() const |
170 | { | 170 | { |
171 | return QSize ( 240, heiHint ); | 171 | return QSize ( 240, heiHint ); |
172 | } | 172 | } |
173 | void JournalEntry::slotSaveTemplate() | 173 | void JournalEntry::slotSaveTemplate() |
174 | { | 174 | { |
175 | QString fileName =locateLocal( "templates", "journals" ); | 175 | QString fileName =locateLocal( "templates", "journals" ); |
176 | QDir t_dir; | 176 | QDir t_dir; |
177 | if ( !t_dir.exists(fileName) ) | 177 | if ( !t_dir.exists(fileName) ) |
178 | t_dir.mkdir ( fileName ); | 178 | t_dir.mkdir ( fileName ); |
179 | fileName += "/journal"; | 179 | fileName += "/journal"; |
180 | fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Journal template"), this ); | 180 | fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Journal template"), this ); |
181 | if ( fileName.length() == 0 ) | 181 | if ( fileName.length() == 0 ) |
182 | return; | 182 | return; |
183 | 183 | ||
184 | QFile fileIn( fileName ); | 184 | QFile fileIn( fileName ); |
185 | if (!fileIn.open( IO_WriteOnly ) ) { | 185 | if (!fileIn.open( IO_WriteOnly ) ) { |
186 | KMessageBox::error( this, i18n("Error saving template file\n '%1'.") | 186 | KMessageBox::error( this, i18n("Error saving template file\n '%1'.") |
187 | .arg( fileName ) ); | 187 | .arg( fileName ) ); |
188 | return; | 188 | return; |
189 | } | 189 | } |
190 | // QString text; | 190 | // QString text; |
191 | QTextStream tsIn( &fileIn ); | 191 | QTextStream tsIn( &fileIn ); |
192 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); | 192 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); |
193 | tsIn << mEditor->text(); | 193 | tsIn << mEditor->text(); |
194 | fileIn.close(); | 194 | fileIn.close(); |
195 | } | 195 | } |
196 | void JournalEntry::slotLoadTemplate() | 196 | void JournalEntry::slotLoadTemplate() |
197 | { | 197 | { |
198 | QString fileName =locateLocal( "templates", "journals" ); | 198 | QString fileName =locateLocal( "templates", "journals" ); |
199 | QDir t_dir; | 199 | QDir t_dir; |
200 | if ( !t_dir.exists(fileName) ) | 200 | if ( !t_dir.exists(fileName) ) |
201 | t_dir.mkdir ( fileName ); | 201 | t_dir.mkdir ( fileName ); |
202 | fileName += "/journal"; | 202 | fileName += "/journal"; |
203 | fileName = KFileDialog::getOpenFileName( fileName , i18n("Insert Journal template"), this ); | 203 | fileName = KFileDialog::getOpenFileName( fileName , i18n("Insert Journal template"), this ); |
204 | if ( fileName.length() == 0 ) | 204 | if ( fileName.length() == 0 ) |
205 | return; | 205 | return; |
206 | QFile fileIn( fileName ); | 206 | QFile fileIn( fileName ); |
207 | if (!fileIn.open( IO_ReadOnly ) ) { | 207 | if (!fileIn.open( IO_ReadOnly ) ) { |
208 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") | 208 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") |
209 | .arg( fileName ) ); | 209 | .arg( fileName ) ); |
210 | return; | 210 | return; |
211 | } | 211 | } |
212 | QTextStream tsIn( &fileIn ); | 212 | QTextStream tsIn( &fileIn ); |
213 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); | 213 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); |
214 | QString text = tsIn.read(); | 214 | QString text = tsIn.read(); |
215 | fileIn.close(); | 215 | fileIn.close(); |
216 | int line, col; | 216 | int line, col; |
217 | mEditor->getCursorPosition (& line, & col ); | 217 | mEditor->getCursorPosition (& line, & col ); |
218 | mEditor-> insertAt ( text, line, col, true ); | 218 | mEditor-> insertAt ( text, line, col, true ); |
219 | //mEditor->setIgnoreMark( true ); | 219 | //mEditor->setIgnoreMark( true ); |
220 | } | 220 | } |
221 | void JournalEntry::setDate(const QDate &date) | 221 | void JournalEntry::setDate(const QDate &date) |
222 | { | 222 | { |
223 | showOnlyMode = false; | 223 | showOnlyMode = false; |
224 | writeJournal(); | 224 | writeJournal(); |
225 | mDate = date; | 225 | mDate = date; |
226 | fillCalendar( mCalendar->defaultCalendar() ); | 226 | fillCalendar( mCalendar->defaultCalendar() ); |
227 | } | 227 | } |
228 | void JournalEntry::fillCalendar( int setToID ) | 228 | void JournalEntry::fillCalendar( int setToID ) |
229 | { | 229 | { |
230 | mCalendarBox->clear(); | 230 | mCalendarBox->clear(); |
231 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 231 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
232 | int std = 0; | 232 | int std = 0; |
233 | int count = 0; | 233 | int count = 0; |
234 | while ( kkf ) { | 234 | while ( kkf ) { |
235 | if ( (!kkf->mErrorOnLoad &&! kkf->isReadOnly) || setToID == kkf->mCalNumber ) { | 235 | if ( (!kkf->mErrorOnLoad &&! kkf->isReadOnly) || setToID == kkf->mCalNumber ) { |
236 | if ( setToID ) { | 236 | if ( setToID ) { |
237 | if ( kkf->mCalNumber == setToID ) | 237 | if ( kkf->mCalNumber == setToID ) |
238 | std = count; | 238 | std = count; |
239 | } else { | 239 | } else { |
240 | if ( kkf->isStandard ) { | 240 | if ( kkf->isStandard ) { |
241 | std = count; | 241 | std = count; |
242 | } | 242 | } |
243 | } | 243 | } |
244 | ++count; | 244 | ++count; |
245 | mCalendarBox->insertItem( kkf->mName ); | 245 | mCalendarBox->insertItem( kkf->mName ); |
246 | } | 246 | } |
247 | kkf = KOPrefs::instance()->mCalendars.next(); | 247 | kkf = KOPrefs::instance()->mCalendars.next(); |
248 | } | 248 | } |
249 | mCalendarBox->setCurrentItem( std ); | 249 | mCalendarBox->setCurrentItem( std ); |
250 | } | 250 | } |
251 | 251 | ||
252 | void JournalEntry::toggleShowJournal() | 252 | void JournalEntry::toggleShowJournal() |
253 | { | 253 | { |
254 | if ( mEditor->text().isEmpty() && mTitle->currentText ().isEmpty() ) | ||
255 | return; | ||
254 | if (!mEditor->text().isEmpty() || !mTitle->currentText ().isEmpty()) | 256 | if (!mEditor->text().isEmpty() || !mTitle->currentText ().isEmpty()) |
255 | flushEntry(); | 257 | flushEntry(); |
256 | if ( showOnlyMode ) | 258 | if ( showOnlyMode ) |
257 | emit showJournalOnly( 0 ); | 259 | emit showJournalOnly( 0 ); |
258 | else { | 260 | else { |
259 | // we have to protect mJournal from deleting if mJournal has empty text | 261 | // we have to protect mJournal from deleting if mJournal has empty text |
260 | visibleMode = false; // set to true via :setShowOnly() | 262 | visibleMode = false; // set to true via :setShowOnly() |
261 | emit showJournalOnly( mJournal ); | 263 | emit showJournalOnly( mJournal ); |
262 | //QTimer::singleShot( 0, this, SLOT( setVisibleOn() ) ); | 264 | //QTimer::singleShot( 0, this, SLOT( setVisibleOn() ) ); |
263 | } | 265 | } |
264 | } | 266 | } |
265 | void JournalEntry::setVisibleOn() | 267 | void JournalEntry::setVisibleOn() |
266 | { | 268 | { |
267 | visibleMode = true; | 269 | visibleMode = true; |
268 | } | 270 | } |
269 | void JournalEntry::setShowOnly() | 271 | void JournalEntry::setShowOnly() |
270 | { | 272 | { |
271 | showOnlyMode = true; | 273 | showOnlyMode = true; |
272 | if ( mTitle->currentText().isEmpty() ) | 274 | if ( mTitle->currentText().isEmpty() ) |
273 | mTitle->setFocus(); | 275 | mTitle->setFocus(); |
274 | else | 276 | else |
275 | mEditor->setFocus(); | 277 | mEditor->setFocus(); |
276 | } | 278 | } |
277 | void JournalEntry::setJournal(Journal *journal, bool saveJournal ) | 279 | void JournalEntry::setJournal(Journal *journal, bool saveJournal ) |
278 | { | 280 | { |
279 | if ( saveJournal ) | 281 | if ( saveJournal ) |
280 | writeJournal(); | 282 | writeJournal(); |
281 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); | 283 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); |
282 | 284 | ||
283 | mJournal = journal; | 285 | mJournal = journal; |
284 | if ( journal->isReadOnly() ) | 286 | if ( journal->isReadOnly() ) |
285 | mTitle->lineEdit ()->setText(mJournal->summary()+" ("+i18n("readonly")+")"); | 287 | mTitle->lineEdit ()->setText(mJournal->summary()+" ("+i18n("readonly")+")"); |
286 | else | 288 | else |
287 | mTitle->lineEdit ()->setText(mJournal->summary()); | 289 | mTitle->lineEdit ()->setText(mJournal->summary()); |
288 | mEditor->setText(mJournal->description()); | 290 | mEditor->setText(mJournal->description()); |
289 | mTitle->setEnabled (!journal->isReadOnly() ); | 291 | mTitle->setEnabled (!journal->isReadOnly() ); |
290 | mEditor->setReadOnly ( journal->isReadOnly() ); | 292 | mEditor->setReadOnly ( journal->isReadOnly() ); |
291 | mCalendarBox->setEnabled (!journal->isReadOnly() ); | 293 | mCalendarBox->setEnabled (!journal->isReadOnly() ); |
292 | fillCalendar( mJournal->calID() ); | 294 | fillCalendar( mJournal->calID() ); |
293 | } | 295 | } |
294 | 296 | ||
295 | Journal *JournalEntry::journal() const | 297 | Journal *JournalEntry::journal() const |
296 | { | 298 | { |
297 | return mJournal; | 299 | return mJournal; |
298 | } | 300 | } |
299 | 301 | ||
300 | 302 | ||
301 | void JournalEntry::clear() | 303 | void JournalEntry::clear() |
302 | { | 304 | { |
303 | mJournal = 0; | 305 | mJournal = 0; |
304 | mEditor->setText(""); | 306 | mEditor->setText(""); |
305 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); | 307 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); |
306 | mTitle->lineEdit ()->setText(""); | 308 | mTitle->lineEdit ()->setText(""); |
307 | } | 309 | } |
308 | 310 | ||
309 | bool JournalEntry::eventFilter( QObject *o, QEvent *e ) | 311 | bool JournalEntry::eventFilter( QObject *o, QEvent *e ) |
310 | { | 312 | { |
311 | // kdDebug() << "JournalEntry::event received " << e->type() << endl; | 313 | // kdDebug() << "JournalEntry::event received " << e->type() << endl; |
312 | 314 | ||
313 | if ( e->type() == QEvent::FocusOut ) { | 315 | if ( e->type() == QEvent::FocusOut ) { |
314 | writeJournal(); | 316 | writeJournal(); |
315 | } | 317 | } |
316 | if ( e->type() == QEvent::KeyPress ) { | 318 | if ( e->type() == QEvent::KeyPress ) { |
317 | QKeyEvent * k = (QKeyEvent *) e; | 319 | QKeyEvent * k = (QKeyEvent *) e; |
318 | if ( k->state() == Qt::ControlButton ) { | 320 | if ( k->state() == Qt::ControlButton ) { |
319 | k->ignore(); | 321 | k->ignore(); |
320 | //return true; | 322 | //return true; |
321 | } | 323 | } |
322 | } | 324 | } |
323 | 325 | ||
324 | return QFrame::eventFilter( o, e ); // standard event processing | 326 | return QFrame::eventFilter( o, e ); // standard event processing |
325 | } | 327 | } |
326 | 328 | ||
327 | void JournalEntry::writeJournal() | 329 | void JournalEntry::writeJournal() |
328 | { | 330 | { |
329 | if ( !visibleMode ) return; | 331 | if ( !visibleMode ) return; |
330 | if ( !mTitle->isEnabled() ) return; | 332 | if ( !mTitle->isEnabled() ) return; |
331 | if (mEditor->text().isEmpty() && mTitle->currentText().isEmpty()) { | 333 | if (mEditor->text().isEmpty() && mTitle->currentText().isEmpty()) { |
332 | if ( mJournal ) { | 334 | if ( mJournal ) { |
333 | Journal* j = mJournal; | 335 | Journal* j = mJournal; |
334 | mJournal = 0; | 336 | mJournal = 0; |
335 | bool conf = KOPrefs::instance()->mConfirm; | 337 | bool conf = KOPrefs::instance()->mConfirm; |
336 | KOPrefs::instance()->mConfirm = false; | 338 | KOPrefs::instance()->mConfirm = false; |
337 | emit deleteJournal(j); | 339 | emit deleteJournal(j); |
338 | KOPrefs::instance()->mConfirm = conf; | 340 | KOPrefs::instance()->mConfirm = conf; |
339 | } | 341 | } |
340 | return; | 342 | return; |
341 | } | 343 | } |
342 | 344 | ||
343 | // kdDebug() << "JournalEntry::writeJournal()..." << endl; | 345 | // kdDebug() << "JournalEntry::writeJournal()..." << endl; |
344 | 346 | ||
345 | if (!mJournal) { | 347 | if (!mJournal) { |
346 | mJournal = new Journal; | 348 | mJournal = new Journal; |
347 | mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); | 349 | mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); |
348 | mCalendar->addJournal(mJournal); | 350 | mCalendar->addJournal(mJournal); |
349 | } | 351 | } |
350 | if ( mJournal->description() != mEditor->text() ) { | 352 | if ( mJournal->description() != mEditor->text() ) { |
351 | mJournal->setDescription(mEditor->text()); | 353 | mJournal->setDescription(mEditor->text()); |
352 | } | 354 | } |
353 | if ( mJournal->summary() != mTitle->currentText() ) { | 355 | if ( mJournal->summary() != mTitle->currentText() ) { |
354 | mJournal->setSummary(mTitle->currentText()); | 356 | mJournal->setSummary(mTitle->currentText()); |
355 | mTitle->save(KOLocationBox::SUMMARYJOURNAL); | 357 | mTitle->save(KOLocationBox::SUMMARYJOURNAL); |
356 | } | 358 | } |
357 | int id = KOPrefs::instance()->getCalendarID( mCalendarBox->currentText() ); | 359 | int id = KOPrefs::instance()->getCalendarID( mCalendarBox->currentText() ); |
358 | if ( mJournal->calID() != id ) { | 360 | if ( mJournal->calID() != id ) { |
359 | mJournal->setCalID( id ); | 361 | mJournal->setCalID( id ); |
360 | } | 362 | } |
361 | } | 363 | } |
362 | 364 | ||
363 | void JournalEntry::flushEntry() | 365 | void JournalEntry::flushEntry() |
364 | { | 366 | { |
365 | writeJournal(); | 367 | writeJournal(); |
366 | } | 368 | } |
367 | void JournalEntry::keyPressEvent ( QKeyEvent * e ) | 369 | void JournalEntry::keyPressEvent ( QKeyEvent * e ) |
368 | { | 370 | { |
369 | e->ignore(); | 371 | e->ignore(); |
370 | 372 | ||
371 | } | 373 | } |
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index c738f7e..7e9fa71 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -1,2268 +1,2272 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | Marcus Bains line. | 5 | Marcus Bains line. |
6 | Copyright (c) 2001 Ali Rahimi | 6 | Copyright (c) 2001 Ali Rahimi |
7 | 7 | ||
8 | This program is free software; you can redistribute it and/or modify | 8 | This program is free software; you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by | 9 | it under the terms of the GNU General Public License as published by |
10 | the Free Software Foundation; either version 2 of the License, or | 10 | the Free Software Foundation; either version 2 of the License, or |
11 | (at your option) any later version. | 11 | (at your option) any later version. |
12 | 12 | ||
13 | This program is distributed in the hope that it will be useful, | 13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. | 16 | GNU General Public License for more details. |
17 | 17 | ||
18 | You should have received a copy of the GNU General Public License | 18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software | 19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 | 21 | ||
22 | As a special exception, permission is given to link this program | 22 | As a special exception, permission is given to link this program |
23 | with any edition of Qt, and distribute the resulting executable, | 23 | with any edition of Qt, and distribute the resulting executable, |
24 | without including the source code for Qt in the source distribution. | 24 | without including the source code for Qt in the source distribution. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #ifndef _WIN32_ | 27 | #ifndef _WIN32_ |
28 | #define protected public | 28 | #define protected public |
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | #undef protected | 30 | #undef protected |
31 | #endif | 31 | #endif |
32 | #include <qintdict.h> | 32 | #include <qintdict.h> |
33 | #include <qdatetime.h> | 33 | #include <qdatetime.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | #include <qpopupmenu.h> | 35 | #include <qpopupmenu.h> |
36 | #include <qcursor.h> | 36 | #include <qcursor.h> |
37 | #include <qpainter.h> | 37 | #include <qpainter.h> |
38 | 38 | ||
39 | #include <kdebug.h> | 39 | #include <kdebug.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <kiconloader.h> | 41 | #include <kiconloader.h> |
42 | #include <kglobal.h> | 42 | #include <kglobal.h> |
43 | 43 | ||
44 | #include "koagendaitem.h" | 44 | #include "koagendaitem.h" |
45 | #include "koprefs.h" | 45 | #include "koprefs.h" |
46 | #include "koglobals.h" | 46 | #include "koglobals.h" |
47 | 47 | ||
48 | #include "koagenda.h" | 48 | #include "koagenda.h" |
49 | 49 | ||
50 | #include <libkcal/event.h> | 50 | #include <libkcal/event.h> |
51 | #include <libkcal/todo.h> | 51 | #include <libkcal/todo.h> |
52 | 52 | ||
53 | #ifndef DESKTOP_VERSION | 53 | #ifndef DESKTOP_VERSION |
54 | #include <qpe/qpeapplication.h> | 54 | #include <qpe/qpeapplication.h> |
55 | #endif | 55 | #endif |
56 | 56 | ||
57 | //extern bool globalFlagBlockPainting; | 57 | //extern bool globalFlagBlockPainting; |
58 | extern int globalFlagBlockAgenda; | 58 | extern int globalFlagBlockAgenda; |
59 | extern int globalFlagBlockAgendaItemPaint; | 59 | extern int globalFlagBlockAgendaItemPaint; |
60 | extern int globalFlagBlockAgendaItemUpdate; | 60 | extern int globalFlagBlockAgendaItemUpdate; |
61 | extern int globalFlagBlockStartup; | 61 | extern int globalFlagBlockStartup; |
62 | 62 | ||
63 | 63 | ||
64 | //////////////////////////////////////////////////////////////////////////// | 64 | //////////////////////////////////////////////////////////////////////////// |
65 | MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) | 65 | MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) |
66 | : QFrame(_agenda->viewport(),name), agenda(_agenda) | 66 | : QFrame(_agenda->viewport(),name), agenda(_agenda) |
67 | { | 67 | { |
68 | setLineWidth(0); | 68 | setLineWidth(0); |
69 | setMargin(0); | 69 | setMargin(0); |
70 | setBackgroundColor(Qt::red); | 70 | setBackgroundColor(Qt::red); |
71 | minutes = new QTimer(this); | 71 | minutes = new QTimer(this); |
72 | connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); | 72 | connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); |
73 | minutes->start(0, true); | 73 | minutes->start(0, true); |
74 | mTimeBox = new QLabel(this); | 74 | mTimeBox = new QLabel(this); |
75 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); | 75 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); |
76 | QPalette pal = mTimeBox->palette(); | 76 | QPalette pal = mTimeBox->palette(); |
77 | pal.setColor(QColorGroup::Foreground, Qt::red); | 77 | pal.setColor(QColorGroup::Foreground, Qt::red); |
78 | mTimeBox->setPalette(pal); | 78 | mTimeBox->setPalette(pal); |
79 | //mTimeBox->setAutoMask(true); | 79 | //mTimeBox->setAutoMask(true); |
80 | 80 | ||
81 | agenda->addChild(mTimeBox); | 81 | agenda->addChild(mTimeBox); |
82 | 82 | ||
83 | oldToday = -1; | 83 | oldToday = -1; |
84 | } | 84 | } |
85 | 85 | ||
86 | MarcusBains::~MarcusBains() | 86 | MarcusBains::~MarcusBains() |
87 | { | 87 | { |
88 | //delete minutes; | 88 | //delete minutes; |
89 | } | 89 | } |
90 | 90 | void MarcusBains::hideMe() | |
91 | { | ||
92 | hide(); mTimeBox->hide(); | ||
93 | } | ||
91 | int MarcusBains::todayColumn() | 94 | int MarcusBains::todayColumn() |
92 | { | 95 | { |
93 | QDate currentDate = QDate::currentDate(); | 96 | QDate currentDate = QDate::currentDate(); |
94 | 97 | ||
95 | DateList dateList = agenda->dateList(); | 98 | DateList dateList = agenda->dateList(); |
96 | DateList::ConstIterator it; | 99 | DateList::ConstIterator it; |
97 | int col = 0; | 100 | int col = 0; |
98 | for(it = dateList.begin(); it != dateList.end(); ++it) { | 101 | for(it = dateList.begin(); it != dateList.end(); ++it) { |
99 | if((*it) == currentDate) | 102 | if((*it) == currentDate) |
100 | return KOGlobals::self()->reverseLayout() ? | 103 | return KOGlobals::self()->reverseLayout() ? |
101 | agenda->columns() - 1 - col : col; | 104 | agenda->columns() - 1 - col : col; |
102 | ++col; | 105 | ++col; |
103 | } | 106 | } |
104 | 107 | ||
105 | return -1; | 108 | return -1; |
106 | } | 109 | } |
107 | void MarcusBains::updateLoc() | 110 | void MarcusBains::updateLoc() |
108 | { | 111 | { |
109 | updateLocation(); | 112 | updateLocation(); |
110 | } | 113 | } |
111 | void MarcusBains::updateLocation(bool recalculate) | 114 | void MarcusBains::updateLocation(bool recalculate) |
112 | { | 115 | { |
113 | 116 | ||
114 | QTime tim = QTime::currentTime(); | 117 | QTime tim = QTime::currentTime(); |
115 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); | 118 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); |
116 | if((tim.hour() == 0) && (oldTime.hour()==23)) | 119 | if((tim.hour() == 0) && (oldTime.hour()==23)) |
117 | recalculate = true; | 120 | recalculate = true; |
118 | 121 | ||
119 | int mins = tim.hour()*60 + tim.minute(); | 122 | int mins = tim.hour()*60 + tim.minute(); |
120 | int minutesPerCell = 24 * 60 / agenda->rows(); | 123 | int minutesPerCell = 24 * 60 / agenda->rows(); |
121 | int y = mins*agenda->gridSpacingY()/minutesPerCell; | 124 | int y = mins*agenda->gridSpacingY()/minutesPerCell; |
122 | int today = recalculate ? todayColumn() : oldToday; | 125 | int today = recalculate ? todayColumn() : oldToday; |
123 | int x = agenda->gridSpacingX()*today; | 126 | int x = agenda->gridSpacingX()*today; |
124 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); | 127 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); |
125 | 128 | ||
126 | oldTime = tim; | 129 | oldTime = tim; |
127 | oldToday = today; | 130 | oldToday = today; |
128 | 131 | ||
129 | if(disabled || (today<0)) { | 132 | if(disabled || (today<0)) { |
130 | hide(); mTimeBox->hide(); | 133 | hide(); mTimeBox->hide(); |
131 | return; | 134 | return; |
132 | } else { | 135 | } else { |
133 | show(); mTimeBox->show(); | 136 | show(); mTimeBox->show(); |
134 | } | 137 | } |
135 | 138 | ||
136 | if(recalculate) | 139 | if(recalculate) |
137 | setFixedSize(agenda->gridSpacingX(),1); | 140 | setFixedSize(agenda->gridSpacingX(),1); |
138 | agenda->moveChild(this, x, y); | 141 | agenda->moveChild(this, x, y); |
139 | raise(); | 142 | raise(); |
140 | 143 | ||
141 | if(recalculate) | 144 | if(recalculate) |
142 | //mTimeBox->setFont(QFont("helvetica",10)); | 145 | //mTimeBox->setFont(QFont("helvetica",10)); |
143 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); | 146 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); |
144 | 147 | ||
145 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); | 148 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); |
146 | mTimeBox->adjustSize(); | 149 | mTimeBox->adjustSize(); |
147 | // the -2 below is there because there is a bug in this program | 150 | // the -2 below is there because there is a bug in this program |
148 | // somewhere, where the last column of this widget is a few pixels | 151 | // somewhere, where the last column of this widget is a few pixels |
149 | // narrower than the other columns. | 152 | // narrower than the other columns. |
150 | int offs = (today==agenda->columns()-1) ? -4 : 0; | 153 | int offs = (today==agenda->columns()-1) ? -4 : 0; |
151 | agenda->moveChild(mTimeBox, | 154 | agenda->moveChild(mTimeBox, |
152 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, | 155 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, |
153 | y-mTimeBox->height()); | 156 | y-mTimeBox->height()); |
154 | mTimeBox->raise(); | 157 | mTimeBox->raise(); |
155 | //mTimeBox->setAutoMask(true); | 158 | //mTimeBox->setAutoMask(true); |
156 | int secs = QTime::currentTime().second(); | 159 | int secs = QTime::currentTime().second(); |
157 | minutes->start( (60 - secs +1)*1000 ,true); | 160 | minutes->start( (60 - secs +1)*1000 ,true); |
158 | } | 161 | } |
159 | 162 | ||
160 | 163 | ||
161 | //////////////////////////////////////////////////////////////////////////// | 164 | //////////////////////////////////////////////////////////////////////////// |
162 | 165 | ||
163 | 166 | ||
164 | /* | 167 | /* |
165 | Create an agenda widget with rows rows and columns columns. | 168 | Create an agenda widget with rows rows and columns columns. |
166 | */ | 169 | */ |
167 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, | 170 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, |
168 | const char *name,WFlags f) : | 171 | const char *name,WFlags f) : |
169 | QScrollView(parent,name,f) | 172 | QScrollView(parent,name,f) |
170 | { | 173 | { |
171 | 174 | ||
172 | mAllAgendaPopup = 0; | 175 | mAllAgendaPopup = 0; |
173 | mColumns = columns; | 176 | mColumns = columns; |
174 | mRows = rows; | 177 | mRows = rows; |
175 | mGridSpacingY = rowSize; | 178 | mGridSpacingY = rowSize; |
176 | mAllDayMode = false; | 179 | mAllDayMode = false; |
177 | #ifndef DESKTOP_VERSION | 180 | #ifndef DESKTOP_VERSION |
178 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 181 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
179 | #endif | 182 | #endif |
180 | mHolidayMask = 0; | 183 | mHolidayMask = 0; |
181 | init(); | 184 | init(); |
182 | connect ( this, SIGNAL (contentsMoving ( int , int ) ), this, SLOT ( slotContentMove(int,int)) ); | 185 | connect ( this, SIGNAL (contentsMoving ( int , int ) ), this, SLOT ( slotContentMove(int,int)) ); |
183 | } | 186 | } |
184 | 187 | ||
185 | /* | 188 | /* |
186 | Create an agenda widget with columns columns and one row. This is used for | 189 | Create an agenda widget with columns columns and one row. This is used for |
187 | all-day events. | 190 | all-day events. |
188 | */ | 191 | */ |
189 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : | 192 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : |
190 | QScrollView(parent,name,f) | 193 | QScrollView(parent,name,f) |
191 | { | 194 | { |
192 | mAllAgendaPopup = 0; | 195 | mAllAgendaPopup = 0; |
193 | blockResize = false; | 196 | blockResize = false; |
194 | mColumns = columns; | 197 | mColumns = columns; |
195 | mRows = 1; | 198 | mRows = 1; |
196 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); | 199 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); |
197 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 200 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
198 | mAllDayMode = true; | 201 | mAllDayMode = true; |
199 | #ifndef DESKTOP_VERSION | 202 | #ifndef DESKTOP_VERSION |
200 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 203 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
201 | #endif | 204 | #endif |
202 | mHolidayMask = 0; | 205 | mHolidayMask = 0; |
203 | init(); | 206 | init(); |
204 | } | 207 | } |
205 | 208 | ||
206 | 209 | ||
207 | KOAgenda::~KOAgenda() | 210 | KOAgenda::~KOAgenda() |
208 | { | 211 | { |
209 | if(mMarcusBains) delete mMarcusBains; | 212 | if(mMarcusBains) delete mMarcusBains; |
210 | 213 | ||
211 | } | 214 | } |
212 | 215 | ||
213 | Incidence *KOAgenda::selectedIncidence() const | 216 | Incidence *KOAgenda::selectedIncidence() const |
214 | { | 217 | { |
215 | return (mSelectedItem ? mSelectedItem->incidence() : 0); | 218 | return (mSelectedItem ? mSelectedItem->incidence() : 0); |
216 | } | 219 | } |
217 | 220 | ||
218 | 221 | ||
219 | QDate KOAgenda::selectedIncidenceDate() const | 222 | QDate KOAgenda::selectedIncidenceDate() const |
220 | { | 223 | { |
221 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); | 224 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); |
222 | } | 225 | } |
223 | 226 | ||
224 | 227 | ||
225 | void KOAgenda::init() | 228 | void KOAgenda::init() |
226 | { | 229 | { |
227 | mPopupTimer = new QTimer(this); | 230 | mPopupTimer = new QTimer(this); |
228 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); | 231 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); |
229 | 232 | ||
230 | mNewItemPopup = new QPopupMenu( this ); | 233 | mNewItemPopup = new QPopupMenu( this ); |
231 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); | 234 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); |
232 | QString pathString = ""; | 235 | QString pathString = ""; |
233 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { | 236 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { |
234 | if ( QApplication::desktop()->width() < 480 ) | 237 | if ( QApplication::desktop()->width() < 480 ) |
235 | pathString += "icons16/"; | 238 | pathString += "icons16/"; |
236 | } else | 239 | } else |
237 | pathString += "iconsmini/"; | 240 | pathString += "iconsmini/"; |
238 | 241 | ||
239 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); | 242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); |
240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); | 243 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); |
241 | mNewItemPopup->insertSeparator ( ); | 244 | mNewItemPopup->insertSeparator ( ); |
242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); | 245 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); |
243 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); | 246 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); |
244 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); | 247 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); |
245 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); | 248 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); |
246 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); | 249 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); |
247 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); | 250 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); |
248 | #ifndef _WIN32_ | 251 | #ifndef _WIN32_ |
249 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase | 252 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase |
250 | viewport()->setWFlags ( wflags); | 253 | viewport()->setWFlags ( wflags); |
251 | #endif | 254 | #endif |
252 | mGridSpacingX = 80; | 255 | mGridSpacingX = 80; |
253 | mResizeBorderWidth = 8; | 256 | mResizeBorderWidth = 8; |
254 | mScrollBorderWidth = 8; | 257 | mScrollBorderWidth = 8; |
255 | mScrollDelay = 30; | 258 | mScrollDelay = 30; |
256 | mScrollOffset = 10; | 259 | mScrollOffset = 10; |
257 | mPaintPixmap.resize( 20,20); | 260 | mPaintPixmap.resize( 20,20); |
258 | //enableClipper(true); | 261 | //enableClipper(true); |
259 | 262 | ||
260 | // Grab key strokes for keyboard navigation of agenda. Seems to have no | 263 | // Grab key strokes for keyboard navigation of agenda. Seems to have no |
261 | // effect. Has to be fixed. | 264 | // effect. Has to be fixed. |
262 | setFocusPolicy(WheelFocus); | 265 | setFocusPolicy(WheelFocus); |
263 | 266 | ||
264 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); | 267 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); |
265 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); | 268 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); |
266 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); | 269 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); |
267 | 270 | ||
268 | mStartCellX = 0; | 271 | mStartCellX = 0; |
269 | mStartCellY = 0; | 272 | mStartCellY = 0; |
270 | mCurrentCellX = 0; | 273 | mCurrentCellX = 0; |
271 | mCurrentCellY = 0; | 274 | mCurrentCellY = 0; |
272 | 275 | ||
273 | mSelectionCellX = 0; | 276 | mSelectionCellX = 0; |
274 | mSelectionYTop = 0; | 277 | mSelectionYTop = 0; |
275 | mSelectionHeight = 0; | 278 | mSelectionHeight = 0; |
276 | 279 | ||
277 | mOldLowerScrollValue = -1; | 280 | mOldLowerScrollValue = -1; |
278 | mOldUpperScrollValue = -1; | 281 | mOldUpperScrollValue = -1; |
279 | 282 | ||
280 | mClickedItem = 0; | 283 | mClickedItem = 0; |
281 | 284 | ||
282 | mActionItem = 0; | 285 | mActionItem = 0; |
283 | mActionType = NOP; | 286 | mActionType = NOP; |
284 | mItemMoved = false; | 287 | mItemMoved = false; |
285 | 288 | ||
286 | mSelectedItem = 0; | 289 | mSelectedItem = 0; |
287 | 290 | ||
288 | // mItems.setAutoDelete(true); | 291 | // mItems.setAutoDelete(true); |
289 | 292 | ||
290 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 293 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
291 | 294 | ||
292 | viewport()->update(); | 295 | viewport()->update(); |
293 | 296 | ||
294 | setMinimumSize(30, 1); | 297 | setMinimumSize(30, 1); |
295 | // setMaximumHeight(mGridSpacingY * mRows + 5); | 298 | // setMaximumHeight(mGridSpacingY * mRows + 5); |
296 | 299 | ||
297 | // Disable horizontal scrollbar. This is a hack. The geometry should be | 300 | // Disable horizontal scrollbar. This is a hack. The geometry should be |
298 | // controlled in a way that the contents horizontally always fits. Then it is | 301 | // controlled in a way that the contents horizontally always fits. Then it is |
299 | // not necessary to turn off the scrollbar. | 302 | // not necessary to turn off the scrollbar. |
300 | setHScrollBarMode(AlwaysOff); | 303 | setHScrollBarMode(AlwaysOff); |
301 | if ( ! mAllDayMode ) | 304 | if ( ! mAllDayMode ) |
302 | setVScrollBarMode(AlwaysOn); | 305 | setVScrollBarMode(AlwaysOn); |
303 | else | 306 | else |
304 | setVScrollBarMode(AlwaysOff); | 307 | setVScrollBarMode(AlwaysOff); |
305 | 308 | ||
306 | setStartHour(KOPrefs::instance()->mDayBegins); | 309 | setStartHour(KOPrefs::instance()->mDayBegins); |
307 | 310 | ||
308 | calculateWorkingHours(); | 311 | calculateWorkingHours(); |
309 | 312 | ||
310 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), | 313 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), |
311 | SLOT(checkScrollBoundaries(int))); | 314 | SLOT(checkScrollBoundaries(int))); |
312 | 315 | ||
313 | // Create the Marcus Bains line. | 316 | // Create the Marcus Bains line. |
314 | if(mAllDayMode) | 317 | if(mAllDayMode) |
315 | mMarcusBains = 0; | 318 | mMarcusBains = 0; |
316 | else { | 319 | else { |
317 | mMarcusBains = new MarcusBains(this); | 320 | mMarcusBains = new MarcusBains(this); |
318 | addChild(mMarcusBains); | 321 | addChild(mMarcusBains); |
319 | } | 322 | } |
320 | mPopupKind = 0; | 323 | mPopupKind = 0; |
321 | mPopupItem = 0; | 324 | mPopupItem = 0; |
322 | mInvalidPixmap = false; | 325 | mInvalidPixmap = false; |
323 | 326 | ||
324 | } | 327 | } |
325 | 328 | ||
326 | void KOAgenda::shrinkPixmap() | 329 | void KOAgenda::shrinkPixmap() |
327 | { | 330 | { |
328 | mPaintPixmap.resize( 20,20); | 331 | mPaintPixmap.resize( 20,20); |
329 | mInvalidPixmap = true; | 332 | mInvalidPixmap = true; |
330 | } | 333 | } |
331 | void KOAgenda::slotContentMove(int,int) | 334 | void KOAgenda::slotContentMove(int,int) |
332 | { | 335 | { |
333 | emit sendPing(); | 336 | emit sendPing(); |
334 | if ( mActionType == NOP ) | 337 | if ( mActionType == NOP ) |
335 | slotClearSelection(); | 338 | slotClearSelection(); |
336 | if ( mSelectedItem && !mActionItem ) { | 339 | if ( mSelectedItem && !mActionItem ) { |
337 | deselectItem(); | 340 | deselectItem(); |
338 | emit incidenceSelected( 0 ); | 341 | emit incidenceSelected( 0 ); |
339 | } | 342 | } |
340 | } | 343 | } |
341 | void KOAgenda::clear() | 344 | void KOAgenda::clear() |
342 | { | 345 | { |
343 | KOAgendaItem *item; | 346 | KOAgendaItem *item; |
344 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 347 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
345 | mUnusedItems.append( item ); | 348 | mUnusedItems.append( item ); |
346 | //item->hide(); | 349 | //item->hide(); |
347 | } | 350 | } |
348 | mItems.clear(); | 351 | mItems.clear(); |
349 | mSelectedItem = 0; | 352 | mSelectedItem = 0; |
350 | clearSelection(); | 353 | clearSelection(); |
351 | } | 354 | } |
352 | 355 | ||
353 | void KOAgenda::clearSelection() | 356 | void KOAgenda::clearSelection() |
354 | { | 357 | { |
355 | mSelectionCellX = 0; | 358 | mSelectionCellX = 0; |
356 | mSelectionYTop = 0; | 359 | mSelectionYTop = 0; |
357 | mSelectionHeight = 0; | 360 | mSelectionHeight = 0; |
358 | } | 361 | } |
359 | 362 | ||
360 | void KOAgenda::marcus_bains() | 363 | void KOAgenda::marcus_bains() |
361 | { | 364 | { |
362 | if(mMarcusBains) mMarcusBains->updateLocation(true); | 365 | if(mMarcusBains) mMarcusBains->updateLocation(true); |
363 | } | 366 | } |
364 | 367 | ||
365 | 368 | ||
366 | void KOAgenda::changeColumns(int columns) | 369 | void KOAgenda::changeColumns(int columns) |
367 | { | 370 | { |
368 | if (columns == 0) { | 371 | if (columns == 0) { |
369 | qDebug("KOAgenda::changeColumns() called with argument 0 "); | 372 | qDebug("KOAgenda::changeColumns() called with argument 0 "); |
370 | return; | 373 | return; |
371 | } | 374 | } |
372 | clear(); | 375 | clear(); |
373 | mColumns = columns; | 376 | mColumns = columns; |
374 | computeSizes(); | 377 | computeSizes(); |
378 | if(mMarcusBains) mMarcusBains->hideMe(); | ||
375 | } | 379 | } |
376 | 380 | ||
377 | /* | 381 | /* |
378 | This is the eventFilter function, which gets all events from the KOAgendaItems | 382 | This is the eventFilter function, which gets all events from the KOAgendaItems |
379 | contained in the agenda. It has to handle moving and resizing for all items. | 383 | contained in the agenda. It has to handle moving and resizing for all items. |
380 | */ | 384 | */ |
381 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) | 385 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) |
382 | { | 386 | { |
383 | // kdDebug() << "KOAgenda::eventFilter" << endl; | 387 | // kdDebug() << "KOAgenda::eventFilter" << endl; |
384 | switch(event->type()) { | 388 | switch(event->type()) { |
385 | case QEvent::MouseButtonPress: | 389 | case QEvent::MouseButtonPress: |
386 | case QEvent::MouseButtonDblClick: | 390 | case QEvent::MouseButtonDblClick: |
387 | case QEvent::MouseButtonRelease: | 391 | case QEvent::MouseButtonRelease: |
388 | case QEvent::MouseMove: | 392 | case QEvent::MouseMove: |
389 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); | 393 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); |
390 | 394 | ||
391 | case (QEvent::Leave): | 395 | case (QEvent::Leave): |
392 | if (!mActionItem) | 396 | if (!mActionItem) |
393 | setCursor(arrowCursor); | 397 | setCursor(arrowCursor); |
394 | return true; | 398 | return true; |
395 | 399 | ||
396 | default: | 400 | default: |
397 | return QScrollView::eventFilter(object,event); | 401 | return QScrollView::eventFilter(object,event); |
398 | } | 402 | } |
399 | } | 403 | } |
400 | void KOAgenda::popupMenu() | 404 | void KOAgenda::popupMenu() |
401 | { | 405 | { |
402 | mPopupTimer->stop(); | 406 | mPopupTimer->stop(); |
403 | if ( mPopupKind == 1 || mPopupKind == 3 ) { | 407 | if ( mPopupKind == 1 || mPopupKind == 3 ) { |
404 | if (mActionItem ) { | 408 | if (mActionItem ) { |
405 | endItemAction(); | 409 | endItemAction(); |
406 | } | 410 | } |
407 | mLeftMouseDown = false; // no more leftMouse computation | 411 | mLeftMouseDown = false; // no more leftMouse computation |
408 | if (mPopupItem) { | 412 | if (mPopupItem) { |
409 | //mClickedItem = mPopupItem; | 413 | //mClickedItem = mPopupItem; |
410 | selectItem(mPopupItem); | 414 | selectItem(mPopupItem); |
411 | if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) | 415 | if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) |
412 | mAllAgendaPopup->installEventFilter( this ); | 416 | mAllAgendaPopup->installEventFilter( this ); |
413 | emit showIncidencePopupSignal(mPopupItem->incidence()); | 417 | emit showIncidencePopupSignal(mPopupItem->incidence()); |
414 | 418 | ||
415 | } | 419 | } |
416 | } else if ( mPopupKind == 2 || mPopupKind == 4 ) { | 420 | } else if ( mPopupKind == 2 || mPopupKind == 4 ) { |
417 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action | 421 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action |
418 | endSelectAction( false ); // do not emit new event signal | 422 | endSelectAction( false ); // do not emit new event signal |
419 | mLeftMouseDown = false; // no more leftMouse computation | 423 | mLeftMouseDown = false; // no more leftMouse computation |
420 | } | 424 | } |
421 | if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) | 425 | if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) |
422 | mNewItemPopup->installEventFilter( this ); | 426 | mNewItemPopup->installEventFilter( this ); |
423 | mNewItemPopup->popup( mPopupPos); | 427 | mNewItemPopup->popup( mPopupPos); |
424 | 428 | ||
425 | } | 429 | } |
426 | mLeftMouseDown = false; | 430 | mLeftMouseDown = false; |
427 | mPopupItem = 0; | 431 | mPopupItem = 0; |
428 | mPopupKind = 0; | 432 | mPopupKind = 0; |
429 | } | 433 | } |
430 | void KOAgenda::categoryChanged(Incidence * inc) | 434 | void KOAgenda::categoryChanged(Incidence * inc) |
431 | { | 435 | { |
432 | KOAgendaItem *item; | 436 | KOAgendaItem *item; |
433 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 437 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
434 | if ( item->incidence() == inc ) { | 438 | if ( item->incidence() == inc ) { |
435 | item->initColor (); | 439 | item->initColor (); |
436 | item->updateItem(); | 440 | item->updateItem(); |
437 | } | 441 | } |
438 | } | 442 | } |
439 | } | 443 | } |
440 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | 444 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) |
441 | { | 445 | { |
442 | 446 | ||
443 | if ( mInvalidPixmap ) { | 447 | if ( mInvalidPixmap ) { |
444 | mInvalidPixmap = false; | 448 | mInvalidPixmap = false; |
445 | qDebug("KO: Upsizing Pixmaps "); | 449 | qDebug("KO: Upsizing Pixmaps "); |
446 | computeSizes(); | 450 | computeSizes(); |
447 | emit updateViewSignal(); | 451 | emit updateViewSignal(); |
448 | return true; | 452 | return true; |
449 | } | 453 | } |
450 | emit sendPing(); | 454 | emit sendPing(); |
451 | static int startX = 0; | 455 | static int startX = 0; |
452 | static int startY = 0; | 456 | static int startY = 0; |
453 | int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); | 457 | int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); |
454 | static bool blockMoving = true; | 458 | static bool blockMoving = true; |
455 | 459 | ||
456 | //qDebug("KOAgenda::eventFilter_mous "); | 460 | //qDebug("KOAgenda::eventFilter_mous "); |
457 | if ( object == mNewItemPopup ) { | 461 | if ( object == mNewItemPopup ) { |
458 | //qDebug("mNewItemPopup "); | 462 | //qDebug("mNewItemPopup "); |
459 | if ( me->type() == QEvent::MouseButtonRelease ) { | 463 | if ( me->type() == QEvent::MouseButtonRelease ) { |
460 | mNewItemPopup->removeEventFilter( this ); | 464 | mNewItemPopup->removeEventFilter( this ); |
461 | int dX = me->globalPos().x() - mPopupPos.x();; | 465 | int dX = me->globalPos().x() - mPopupPos.x();; |
462 | if ( dX < 0 ) | 466 | if ( dX < 0 ) |
463 | dX = -dX; | 467 | dX = -dX; |
464 | int dY = me->globalPos().y() - mPopupPos.y(); | 468 | int dY = me->globalPos().y() - mPopupPos.y(); |
465 | if ( dY < 0 ) | 469 | if ( dY < 0 ) |
466 | dY = -dY; | 470 | dY = -dY; |
467 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 471 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
468 | mNewItemPopup->hide(); | 472 | mNewItemPopup->hide(); |
469 | } | 473 | } |
470 | } | 474 | } |
471 | return true; | 475 | return true; |
472 | } | 476 | } |
473 | if ( object == mAllAgendaPopup ) { | 477 | if ( object == mAllAgendaPopup ) { |
474 | //qDebug(" mAllAgendaPopup "); | 478 | //qDebug(" mAllAgendaPopup "); |
475 | if ( me->type() == QEvent::MouseButtonRelease ) { | 479 | if ( me->type() == QEvent::MouseButtonRelease ) { |
476 | mAllAgendaPopup->removeEventFilter( this ); | 480 | mAllAgendaPopup->removeEventFilter( this ); |
477 | int dX = me->globalPos().x() - mPopupPos.x();; | 481 | int dX = me->globalPos().x() - mPopupPos.x();; |
478 | if ( dX < 0 ) | 482 | if ( dX < 0 ) |
479 | dX = -dX; | 483 | dX = -dX; |
480 | int dY = me->globalPos().y() - mPopupPos.y(); | 484 | int dY = me->globalPos().y() - mPopupPos.y(); |
481 | if ( dY < 0 ) | 485 | if ( dY < 0 ) |
482 | dY = -dY; | 486 | dY = -dY; |
483 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 487 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
484 | mAllAgendaPopup->hide(); | 488 | mAllAgendaPopup->hide(); |
485 | } | 489 | } |
486 | } | 490 | } |
487 | return true; | 491 | return true; |
488 | } | 492 | } |
489 | QPoint viewportPos; | 493 | QPoint viewportPos; |
490 | if (object != viewport()) { | 494 | if (object != viewport()) { |
491 | blockmoveDist = blockmoveDist*2; | 495 | blockmoveDist = blockmoveDist*2; |
492 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); | 496 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); |
493 | } else { | 497 | } else { |
494 | viewportPos = me->pos(); | 498 | viewportPos = me->pos(); |
495 | } | 499 | } |
496 | bool objIsNotViewport = (object != viewport()); | 500 | bool objIsNotViewport = (object != viewport()); |
497 | bool leftButt = false; | 501 | bool leftButt = false; |
498 | #ifdef DESKTOP_VERSION | 502 | #ifdef DESKTOP_VERSION |
499 | leftButt = (me->button() == LeftButton); | 503 | leftButt = (me->button() == LeftButton); |
500 | #endif | 504 | #endif |
501 | switch (me->type()) { | 505 | switch (me->type()) { |
502 | case QEvent::MouseButtonPress: | 506 | case QEvent::MouseButtonPress: |
503 | if (me->button() == LeftButton) { | 507 | if (me->button() == LeftButton) { |
504 | mPopupTimer->start( 600 ); | 508 | mPopupTimer->start( 600 ); |
505 | mLeftMouseDown = true; | 509 | mLeftMouseDown = true; |
506 | } | 510 | } |
507 | blockMoving = true; | 511 | blockMoving = true; |
508 | startX = viewportPos.x(); | 512 | startX = viewportPos.x(); |
509 | startY = viewportPos.y(); | 513 | startY = viewportPos.y(); |
510 | mPopupPos = me->globalPos(); | 514 | mPopupPos = me->globalPos(); |
511 | if ( objIsNotViewport && !leftButt ) { | 515 | if ( objIsNotViewport && !leftButt ) { |
512 | KOAgendaItem * tempItem = (KOAgendaItem *)object; | 516 | KOAgendaItem * tempItem = (KOAgendaItem *)object; |
513 | if (mAllDayMode) { | 517 | if (mAllDayMode) { |
514 | if ( tempItem->height() > 10 ) { | 518 | if ( tempItem->height() > 10 ) { |
515 | int minV = tempItem->height()/4; | 519 | int minV = tempItem->height()/4; |
516 | if ( minV > (blockmoveDist/2)-2 ) { | 520 | if ( minV > (blockmoveDist/2)-2 ) { |
517 | if ( minV > blockmoveDist ) | 521 | if ( minV > blockmoveDist ) |
518 | minV = blockmoveDist; | 522 | minV = blockmoveDist; |
519 | else | 523 | else |
520 | minV = (blockmoveDist/2); | 524 | minV = (blockmoveDist/2); |
521 | } | 525 | } |
522 | bool border = false; | 526 | bool border = false; |
523 | int diff = tempItem->y() - viewportPos.y(); | 527 | int diff = tempItem->y() - viewportPos.y(); |
524 | if ( diff < 0 ) | 528 | if ( diff < 0 ) |
525 | diff *= -1; | 529 | diff *= -1; |
526 | if ( diff < minV ) { | 530 | if ( diff < minV ) { |
527 | border = true; | 531 | border = true; |
528 | objIsNotViewport = false; | 532 | objIsNotViewport = false; |
529 | } | 533 | } |
530 | if ( ! border ) { | 534 | if ( ! border ) { |
531 | diff = tempItem->y() + tempItem->height()- viewportPos.y(); | 535 | diff = tempItem->y() + tempItem->height()- viewportPos.y(); |
532 | if ( diff < 0 ) | 536 | if ( diff < 0 ) |
533 | diff *= -1; | 537 | diff *= -1; |
534 | if ( diff < minV ) { | 538 | if ( diff < minV ) { |
535 | border = true; | 539 | border = true; |
536 | objIsNotViewport = false; | 540 | objIsNotViewport = false; |
537 | } | 541 | } |
538 | } | 542 | } |
539 | } | 543 | } |
540 | } else { // not allday | 544 | } else { // not allday |
541 | if ( tempItem->width() > 10 ) { | 545 | if ( tempItem->width() > 10 ) { |
542 | int minH = tempItem->width()/4; | 546 | int minH = tempItem->width()/4; |
543 | if ( minH > (blockmoveDist/2)-2 ) { | 547 | if ( minH > (blockmoveDist/2)-2 ) { |
544 | if ( minH > blockmoveDist ) | 548 | if ( minH > blockmoveDist ) |
545 | minH = blockmoveDist; | 549 | minH = blockmoveDist; |
546 | else | 550 | else |
547 | minH = (blockmoveDist/2); | 551 | minH = (blockmoveDist/2); |
548 | } | 552 | } |
549 | bool border = false; | 553 | bool border = false; |
550 | int diff = tempItem->x() - viewportPos.x(); | 554 | int diff = tempItem->x() - viewportPos.x(); |
551 | if ( diff < 0 ) | 555 | if ( diff < 0 ) |
552 | diff *= -1; | 556 | diff *= -1; |
553 | if ( diff < minH ) { | 557 | if ( diff < minH ) { |
554 | border = true; | 558 | border = true; |
555 | objIsNotViewport = false; | 559 | objIsNotViewport = false; |
556 | } | 560 | } |
557 | if ( ! border ) { | 561 | if ( ! border ) { |
558 | diff = tempItem->x() + tempItem->width() - viewportPos.x(); | 562 | diff = tempItem->x() + tempItem->width() - viewportPos.x(); |
559 | if ( diff < 0 ) | 563 | if ( diff < 0 ) |
560 | diff *= -1; | 564 | diff *= -1; |
561 | if ( diff < minH ) { | 565 | if ( diff < minH ) { |
562 | border = true; | 566 | border = true; |
563 | objIsNotViewport = false; | 567 | objIsNotViewport = false; |
564 | } | 568 | } |
565 | } | 569 | } |
566 | } | 570 | } |
567 | } | 571 | } |
568 | } | 572 | } |
569 | if ( objIsNotViewport ) { | 573 | if ( objIsNotViewport ) { |
570 | mPopupItem = (KOAgendaItem *)object; | 574 | mPopupItem = (KOAgendaItem *)object; |
571 | mPopupKind = 1; | 575 | mPopupKind = 1; |
572 | if (me->button() == RightButton) { | 576 | if (me->button() == RightButton) { |
573 | mPopupKind = 3; | 577 | mPopupKind = 3; |
574 | popupMenu(); | 578 | popupMenu(); |
575 | } else if (me->button() == LeftButton) { | 579 | } else if (me->button() == LeftButton) { |
576 | mActionItem = (KOAgendaItem *)object; | 580 | mActionItem = (KOAgendaItem *)object; |
577 | if (mActionItem) { | 581 | if (mActionItem) { |
578 | emit signalClearSelection(); | 582 | emit signalClearSelection(); |
579 | slotClearSelection(); | 583 | slotClearSelection(); |
580 | selectItem(mActionItem); | 584 | selectItem(mActionItem); |
581 | Incidence *incidence = mActionItem->incidence(); | 585 | Incidence *incidence = mActionItem->incidence(); |
582 | if ( incidence->isReadOnly() /*|| incidence->doesRecur() */) { | 586 | if ( incidence->isReadOnly() /*|| incidence->doesRecur() */) { |
583 | mActionItem = 0; | 587 | mActionItem = 0; |
584 | } else { | 588 | } else { |
585 | startItemAction(viewportPos); | 589 | startItemAction(viewportPos); |
586 | } | 590 | } |
587 | } | 591 | } |
588 | } | 592 | } |
589 | } else { // ---------- viewport() | 593 | } else { // ---------- viewport() |
590 | mPopupItem = 0; | 594 | mPopupItem = 0; |
591 | mPopupKind = 2; | 595 | mPopupKind = 2; |
592 | selectItem(0); | 596 | selectItem(0); |
593 | mActionItem = 0; | 597 | mActionItem = 0; |
594 | if (me->button() == RightButton) { | 598 | if (me->button() == RightButton) { |
595 | int x,y; | 599 | int x,y; |
596 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 600 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
597 | int gx,gy; | 601 | int gx,gy; |
598 | contentsToGrid(x,y,gx,gy); | 602 | contentsToGrid(x,y,gx,gy); |
599 | mCurrentCellX = gx; | 603 | mCurrentCellX = gx; |
600 | mCurrentCellY = gy; | 604 | mCurrentCellY = gy; |
601 | mStartCellX = gx; | 605 | mStartCellX = gx; |
602 | mStartCellY = gy; | 606 | mStartCellY = gy; |
603 | mPopupKind = 4; | 607 | mPopupKind = 4; |
604 | popupMenu(); | 608 | popupMenu(); |
605 | } else if (me->button() == LeftButton) { | 609 | } else if (me->button() == LeftButton) { |
606 | setCursor(arrowCursor); | 610 | setCursor(arrowCursor); |
607 | startSelectAction(viewportPos); | 611 | startSelectAction(viewportPos); |
608 | } | 612 | } |
609 | } | 613 | } |
610 | break; | 614 | break; |
611 | 615 | ||
612 | case QEvent::MouseButtonRelease: | 616 | case QEvent::MouseButtonRelease: |
613 | if (me->button() == LeftButton ) { | 617 | if (me->button() == LeftButton ) { |
614 | mPopupTimer->stop(); | 618 | mPopupTimer->stop(); |
615 | } | 619 | } |
616 | if (object != viewport()) { | 620 | if (object != viewport()) { |
617 | if (me->button() == LeftButton && mLeftMouseDown) { | 621 | if (me->button() == LeftButton && mLeftMouseDown) { |
618 | if (mActionItem) { | 622 | if (mActionItem) { |
619 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 623 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
620 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); | 624 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); |
621 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { | 625 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { |
622 | mScrollUpTimer.stop(); | 626 | mScrollUpTimer.stop(); |
623 | mScrollDownTimer.stop(); | 627 | mScrollDownTimer.stop(); |
624 | mActionItem->resetMove(); | 628 | mActionItem->resetMove(); |
625 | placeSubCells( mActionItem ); | 629 | placeSubCells( mActionItem ); |
626 | // emit startDragSignal( mActionItem->incidence() ); | 630 | // emit startDragSignal( mActionItem->incidence() ); |
627 | setCursor( arrowCursor ); | 631 | setCursor( arrowCursor ); |
628 | mActionItem = 0; | 632 | mActionItem = 0; |
629 | mActionType = NOP; | 633 | mActionType = NOP; |
630 | mItemMoved = 0; | 634 | mItemMoved = 0; |
631 | mLeftMouseDown = false; | 635 | mLeftMouseDown = false; |
632 | return true; | 636 | return true; |
633 | } | 637 | } |
634 | endItemAction(); | 638 | endItemAction(); |
635 | } | 639 | } |
636 | } | 640 | } |
637 | 641 | ||
638 | } else { // ---------- viewport() | 642 | } else { // ---------- viewport() |
639 | if (me->button() == LeftButton && mLeftMouseDown ) { //left click | 643 | if (me->button() == LeftButton && mLeftMouseDown ) { //left click |
640 | endSelectAction( true ); // emit new event signal | 644 | endSelectAction( true ); // emit new event signal |
641 | } | 645 | } |
642 | } | 646 | } |
643 | if (me->button() == LeftButton) | 647 | if (me->button() == LeftButton) |
644 | mLeftMouseDown = false; | 648 | mLeftMouseDown = false; |
645 | 649 | ||
646 | break; | 650 | break; |
647 | 651 | ||
648 | case QEvent::MouseMove: | 652 | case QEvent::MouseMove: |
649 | //qDebug("mm "); | 653 | //qDebug("mm "); |
650 | if ( !mLeftMouseDown ) | 654 | if ( !mLeftMouseDown ) |
651 | return false; | 655 | return false; |
652 | if ( blockMoving ) { | 656 | if ( blockMoving ) { |
653 | int dX, dY; | 657 | int dX, dY; |
654 | dX = startX - viewportPos.x(); | 658 | dX = startX - viewportPos.x(); |
655 | if ( dX < 0 ) | 659 | if ( dX < 0 ) |
656 | dX = -dX; | 660 | dX = -dX; |
657 | dY = viewportPos.y() - startY; | 661 | dY = viewportPos.y() - startY; |
658 | if ( dY < 0 ) | 662 | if ( dY < 0 ) |
659 | dY = -dY; | 663 | dY = -dY; |
660 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); | 664 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); |
661 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 665 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
662 | blockMoving = false; | 666 | blockMoving = false; |
663 | } | 667 | } |
664 | } | 668 | } |
665 | if ( ! blockMoving ) | 669 | if ( ! blockMoving ) |
666 | mPopupTimer->stop(); | 670 | mPopupTimer->stop(); |
667 | if (object != viewport()) { | 671 | if (object != viewport()) { |
668 | KOAgendaItem *moveItem = (KOAgendaItem *)object; | 672 | KOAgendaItem *moveItem = (KOAgendaItem *)object; |
669 | if (!moveItem->incidence()->isReadOnly() ) { | 673 | if (!moveItem->incidence()->isReadOnly() ) { |
670 | if (!mActionItem) | 674 | if (!mActionItem) |
671 | setNoActionCursor(moveItem,viewportPos); | 675 | setNoActionCursor(moveItem,viewportPos); |
672 | else { | 676 | else { |
673 | if ( !blockMoving ) | 677 | if ( !blockMoving ) |
674 | performItemAction(viewportPos); | 678 | performItemAction(viewportPos); |
675 | } | 679 | } |
676 | } | 680 | } |
677 | } else { // ---------- viewport() | 681 | } else { // ---------- viewport() |
678 | mPopupPos = viewport()->mapToGlobal( me->pos() ); | 682 | mPopupPos = viewport()->mapToGlobal( me->pos() ); |
679 | if ( mActionType == SELECT ) { | 683 | if ( mActionType == SELECT ) { |
680 | performSelectAction( viewportPos ); | 684 | performSelectAction( viewportPos ); |
681 | } | 685 | } |
682 | } | 686 | } |
683 | break; | 687 | break; |
684 | 688 | ||
685 | case QEvent::MouseButtonDblClick: | 689 | case QEvent::MouseButtonDblClick: |
686 | mPopupTimer->stop(); | 690 | mPopupTimer->stop(); |
687 | if (object == viewport()) { | 691 | if (object == viewport()) { |
688 | selectItem(0); | 692 | selectItem(0); |
689 | int x,y; | 693 | int x,y; |
690 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 694 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
691 | int gx,gy; | 695 | int gx,gy; |
692 | contentsToGrid(x,y,gx,gy); | 696 | contentsToGrid(x,y,gx,gy); |
693 | emit newEventSignal(gx,gy); | 697 | emit newEventSignal(gx,gy); |
694 | } else { | 698 | } else { |
695 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; | 699 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; |
696 | selectItem(doubleClickedItem); | 700 | selectItem(doubleClickedItem); |
697 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 701 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
698 | emit editIncidenceSignal(doubleClickedItem->incidence()); | 702 | emit editIncidenceSignal(doubleClickedItem->incidence()); |
699 | else | 703 | else |
700 | emit showIncidenceSignal(doubleClickedItem->incidence()); | 704 | emit showIncidenceSignal(doubleClickedItem->incidence()); |
701 | } | 705 | } |
702 | break; | 706 | break; |
703 | 707 | ||
704 | default: | 708 | default: |
705 | break; | 709 | break; |
706 | } | 710 | } |
707 | return true; | 711 | return true; |
708 | 712 | ||
709 | } | 713 | } |
710 | 714 | ||
711 | void KOAgenda::newItem( int item ) | 715 | void KOAgenda::newItem( int item ) |
712 | { | 716 | { |
713 | if ( item == 1 ) { //new event | 717 | if ( item == 1 ) { //new event |
714 | newEventSignal(mStartCellX ,mStartCellY ); | 718 | newEventSignal(mStartCellX ,mStartCellY ); |
715 | } else | 719 | } else |
716 | if ( item == 2 ) { //new event | 720 | if ( item == 2 ) { //new event |
717 | newTodoSignal(mStartCellX ,mStartCellY ); | 721 | newTodoSignal(mStartCellX ,mStartCellY ); |
718 | } else | 722 | } else |
719 | { | 723 | { |
720 | emit showDateView( item, mStartCellX ); | 724 | emit showDateView( item, mStartCellX ); |
721 | // 3Day view | 725 | // 3Day view |
722 | // 4Week view | 726 | // 4Week view |
723 | // 5Month view | 727 | // 5Month view |
724 | // 6Journal view | 728 | // 6Journal view |
725 | } | 729 | } |
726 | } | 730 | } |
727 | void KOAgenda::slotClearSelection() | 731 | void KOAgenda::slotClearSelection() |
728 | { | 732 | { |
729 | if (mSelectionHeight) { | 733 | if (mSelectionHeight) { |
730 | int selectionX = mSelectionCellX * mGridSpacingX; | 734 | int selectionX = mSelectionCellX * mGridSpacingX; |
731 | int top = mSelectionYTop - 2 *mGridSpacingY; | 735 | int top = mSelectionYTop - 2 *mGridSpacingY; |
732 | int hei = mSelectionHeight + 4 *mGridSpacingY; | 736 | int hei = mSelectionHeight + 4 *mGridSpacingY; |
733 | clearSelection(); | 737 | clearSelection(); |
734 | repaintContents( selectionX, top, | 738 | repaintContents( selectionX, top, |
735 | mGridSpacingX, hei ,false ); | 739 | mGridSpacingX, hei ,false ); |
736 | } | 740 | } |
737 | 741 | ||
738 | } | 742 | } |
739 | void KOAgenda::startSelectAction(QPoint viewportPos) | 743 | void KOAgenda::startSelectAction(QPoint viewportPos) |
740 | { | 744 | { |
741 | 745 | ||
742 | emit signalClearSelection(); | 746 | emit signalClearSelection(); |
743 | slotClearSelection(); | 747 | slotClearSelection(); |
744 | 748 | ||
745 | mActionType = SELECT; | 749 | mActionType = SELECT; |
746 | 750 | ||
747 | int x,y; | 751 | int x,y; |
748 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 752 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
749 | int gx,gy; | 753 | int gx,gy; |
750 | contentsToGrid(x,y,gx,gy); | 754 | contentsToGrid(x,y,gx,gy); |
751 | 755 | ||
752 | mStartCellX = gx; | 756 | mStartCellX = gx; |
753 | mStartCellY = gy; | 757 | mStartCellY = gy; |
754 | mCurrentCellX = gx; | 758 | mCurrentCellX = gx; |
755 | mCurrentCellY = gy; | 759 | mCurrentCellY = gy; |
756 | 760 | ||
757 | // Store new selection | 761 | // Store new selection |
758 | mSelectionCellX = gx; | 762 | mSelectionCellX = gx; |
759 | mSelectionYTop = gy * mGridSpacingY; | 763 | mSelectionYTop = gy * mGridSpacingY; |
760 | mSelectionHeight = mGridSpacingY; | 764 | mSelectionHeight = mGridSpacingY; |
761 | 765 | ||
762 | // Paint new selection | 766 | // Paint new selection |
763 | repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop, | 767 | repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop, |
764 | mGridSpacingX-1, mSelectionHeight ); | 768 | mGridSpacingX-1, mSelectionHeight ); |
765 | } | 769 | } |
766 | 770 | ||
767 | void KOAgenda::performSelectAction(QPoint viewportPos) | 771 | void KOAgenda::performSelectAction(QPoint viewportPos) |
768 | { | 772 | { |
769 | int x,y; | 773 | int x,y; |
770 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 774 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
771 | int gx,gy; | 775 | int gx,gy; |
772 | contentsToGrid(x,y,gx,gy); | 776 | contentsToGrid(x,y,gx,gy); |
773 | 777 | ||
774 | QPoint clipperPos = clipper()-> | 778 | QPoint clipperPos = clipper()-> |
775 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 779 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
776 | 780 | ||
777 | // Scroll if cursor was moved to upper or lower end of agenda. | 781 | // Scroll if cursor was moved to upper or lower end of agenda. |
778 | if (clipperPos.y() < mScrollBorderWidth) { | 782 | if (clipperPos.y() < mScrollBorderWidth) { |
779 | mScrollUpTimer.start(mScrollDelay); | 783 | mScrollUpTimer.start(mScrollDelay); |
780 | } else if (visibleHeight() - clipperPos.y() < | 784 | } else if (visibleHeight() - clipperPos.y() < |
781 | mScrollBorderWidth) { | 785 | mScrollBorderWidth) { |
782 | mScrollDownTimer.start(mScrollDelay); | 786 | mScrollDownTimer.start(mScrollDelay); |
783 | } else { | 787 | } else { |
784 | mScrollUpTimer.stop(); | 788 | mScrollUpTimer.stop(); |
785 | mScrollDownTimer.stop(); | 789 | mScrollDownTimer.stop(); |
786 | } | 790 | } |
787 | 791 | ||
788 | if ( gy > mCurrentCellY ) { | 792 | if ( gy > mCurrentCellY ) { |
789 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 793 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
790 | 794 | ||
791 | 795 | ||
792 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 796 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
793 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 797 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
794 | mGridSpacingX, mSelectionYTop, | 798 | mGridSpacingX, mSelectionYTop, |
795 | mGridSpacingX, mSelectionHeight , false); | 799 | mGridSpacingX, mSelectionHeight , false); |
796 | 800 | ||
797 | mCurrentCellY = gy; | 801 | mCurrentCellY = gy; |
798 | } else if ( gy < mCurrentCellY ) { | 802 | } else if ( gy < mCurrentCellY ) { |
799 | if ( gy >= mStartCellY ) { | 803 | if ( gy >= mStartCellY ) { |
800 | int selectionHeight = mSelectionHeight; | 804 | int selectionHeight = mSelectionHeight; |
801 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 805 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
802 | 806 | ||
803 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 807 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
804 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 808 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
805 | mGridSpacingX, mSelectionYTop, | 809 | mGridSpacingX, mSelectionYTop, |
806 | mGridSpacingX, selectionHeight,false ); | 810 | mGridSpacingX, selectionHeight,false ); |
807 | 811 | ||
808 | mCurrentCellY = gy; | 812 | mCurrentCellY = gy; |
809 | } else { | 813 | } else { |
810 | } | 814 | } |
811 | } | 815 | } |
812 | } | 816 | } |
813 | 817 | ||
814 | void KOAgenda::endSelectAction( bool emitNewEvent ) | 818 | void KOAgenda::endSelectAction( bool emitNewEvent ) |
815 | { | 819 | { |
816 | mActionType = NOP; | 820 | mActionType = NOP; |
817 | mScrollUpTimer.stop(); | 821 | mScrollUpTimer.stop(); |
818 | mScrollDownTimer.stop(); | 822 | mScrollDownTimer.stop(); |
819 | 823 | ||
820 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 824 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
821 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) { | 825 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) { |
822 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 826 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
823 | } | 827 | } |
824 | } | 828 | } |
825 | 829 | ||
826 | void KOAgenda::startItemAction(QPoint viewportPos) | 830 | void KOAgenda::startItemAction(QPoint viewportPos) |
827 | { | 831 | { |
828 | int x,y; | 832 | int x,y; |
829 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 833 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
830 | int gx,gy; | 834 | int gx,gy; |
831 | contentsToGrid(x,y,gx,gy); | 835 | contentsToGrid(x,y,gx,gy); |
832 | 836 | ||
833 | mStartCellX = gx; | 837 | mStartCellX = gx; |
834 | mStartCellY = gy; | 838 | mStartCellY = gy; |
835 | mCurrentCellX = gx; | 839 | mCurrentCellX = gx; |
836 | mCurrentCellY = gy; | 840 | mCurrentCellY = gy; |
837 | 841 | ||
838 | if (mAllDayMode) { | 842 | if (mAllDayMode) { |
839 | int gridDistanceX = (x - gx * mGridSpacingX); | 843 | int gridDistanceX = (x - gx * mGridSpacingX); |
840 | if (gridDistanceX < mResizeBorderWidth && | 844 | if (gridDistanceX < mResizeBorderWidth && |
841 | mActionItem->cellX() == mCurrentCellX) { | 845 | mActionItem->cellX() == mCurrentCellX) { |
842 | mActionType = RESIZELEFT; | 846 | mActionType = RESIZELEFT; |
843 | setCursor(sizeHorCursor); | 847 | setCursor(sizeHorCursor); |
844 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 848 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
845 | mActionItem->cellXWidth() == mCurrentCellX) { | 849 | mActionItem->cellXWidth() == mCurrentCellX) { |
846 | mActionType = RESIZERIGHT; | 850 | mActionType = RESIZERIGHT; |
847 | setCursor(sizeHorCursor); | 851 | setCursor(sizeHorCursor); |
848 | } else { | 852 | } else { |
849 | mActionType = MOVE; | 853 | mActionType = MOVE; |
850 | mActionItem->startMove(); | 854 | mActionItem->startMove(); |
851 | setCursor(sizeAllCursor); | 855 | setCursor(sizeAllCursor); |
852 | } | 856 | } |
853 | } else { | 857 | } else { |
854 | int gridDistanceY = (y - gy * mGridSpacingY); | 858 | int gridDistanceY = (y - gy * mGridSpacingY); |
855 | bool allowResize = ( mActionItem->incidence()->typeID() != todoID ); | 859 | bool allowResize = ( mActionItem->incidence()->typeID() != todoID ); |
856 | if (allowResize && gridDistanceY < mResizeBorderWidth && | 860 | if (allowResize && gridDistanceY < mResizeBorderWidth && |
857 | mActionItem->cellYTop() == mCurrentCellY && | 861 | mActionItem->cellYTop() == mCurrentCellY && |
858 | !mActionItem->firstMultiItem()) { | 862 | !mActionItem->firstMultiItem()) { |
859 | mActionType = RESIZETOP; | 863 | mActionType = RESIZETOP; |
860 | setCursor(sizeVerCursor); | 864 | setCursor(sizeVerCursor); |
861 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 865 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
862 | mActionItem->cellYBottom() == mCurrentCellY && | 866 | mActionItem->cellYBottom() == mCurrentCellY && |
863 | !mActionItem->lastMultiItem()) { | 867 | !mActionItem->lastMultiItem()) { |
864 | mActionType = RESIZEBOTTOM; | 868 | mActionType = RESIZEBOTTOM; |
865 | setCursor(sizeVerCursor); | 869 | setCursor(sizeVerCursor); |
866 | } else { | 870 | } else { |
867 | mActionType = MOVE; | 871 | mActionType = MOVE; |
868 | mActionItem->startMove(); | 872 | mActionItem->startMove(); |
869 | setCursor(sizeAllCursor); | 873 | setCursor(sizeAllCursor); |
870 | } | 874 | } |
871 | } | 875 | } |
872 | } | 876 | } |
873 | 877 | ||
874 | void KOAgenda::performItemAction(QPoint viewportPos) | 878 | void KOAgenda::performItemAction(QPoint viewportPos) |
875 | { | 879 | { |
876 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 880 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
877 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 881 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
878 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 882 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
879 | // point = clipper()->mapFromGlobal(point); | 883 | // point = clipper()->mapFromGlobal(point); |
880 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 884 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
881 | // kdDebug() << "visible height: " << visibleHeight() << endl; | 885 | // kdDebug() << "visible height: " << visibleHeight() << endl; |
882 | int x,y; | 886 | int x,y; |
883 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 887 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
884 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 888 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
885 | int gx,gy; | 889 | int gx,gy; |
886 | contentsToGrid(x,y,gx,gy); | 890 | contentsToGrid(x,y,gx,gy); |
887 | QPoint clipperPos = clipper()-> | 891 | QPoint clipperPos = clipper()-> |
888 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 892 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
889 | 893 | ||
890 | // Cursor left active agenda area. | 894 | // Cursor left active agenda area. |
891 | // This starts a drag. | 895 | // This starts a drag. |
892 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ | 896 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ |
893 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { | 897 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { |
894 | if ( mActionType == MOVE ) { | 898 | if ( mActionType == MOVE ) { |
895 | mScrollUpTimer.stop(); | 899 | mScrollUpTimer.stop(); |
896 | mScrollDownTimer.stop(); | 900 | mScrollDownTimer.stop(); |
897 | mActionItem->resetMove(); | 901 | mActionItem->resetMove(); |
898 | placeSubCells( mActionItem ); | 902 | placeSubCells( mActionItem ); |
899 | // emit startDragSignal( mActionItem->incidence() ); | 903 | // emit startDragSignal( mActionItem->incidence() ); |
900 | setCursor( arrowCursor ); | 904 | setCursor( arrowCursor ); |
901 | mActionItem = 0; | 905 | mActionItem = 0; |
902 | mActionType = NOP; | 906 | mActionType = NOP; |
903 | mItemMoved = 0; | 907 | mItemMoved = 0; |
904 | return; | 908 | return; |
905 | } | 909 | } |
906 | } else { | 910 | } else { |
907 | switch ( mActionType ) { | 911 | switch ( mActionType ) { |
908 | case MOVE: | 912 | case MOVE: |
909 | setCursor( sizeAllCursor ); | 913 | setCursor( sizeAllCursor ); |
910 | break; | 914 | break; |
911 | case RESIZETOP: | 915 | case RESIZETOP: |
912 | case RESIZEBOTTOM: | 916 | case RESIZEBOTTOM: |
913 | setCursor( sizeVerCursor ); | 917 | setCursor( sizeVerCursor ); |
914 | break; | 918 | break; |
915 | case RESIZELEFT: | 919 | case RESIZELEFT: |
916 | case RESIZERIGHT: | 920 | case RESIZERIGHT: |
917 | setCursor( sizeHorCursor ); | 921 | setCursor( sizeHorCursor ); |
918 | break; | 922 | break; |
919 | default: | 923 | default: |
920 | setCursor( arrowCursor ); | 924 | setCursor( arrowCursor ); |
921 | } | 925 | } |
922 | } | 926 | } |
923 | 927 | ||
924 | // Scroll if item was moved to upper or lower end of agenda. | 928 | // Scroll if item was moved to upper or lower end of agenda. |
925 | if (clipperPos.y() < mScrollBorderWidth) { | 929 | if (clipperPos.y() < mScrollBorderWidth) { |
926 | mScrollUpTimer.start(mScrollDelay); | 930 | mScrollUpTimer.start(mScrollDelay); |
927 | } else if (visibleHeight() - clipperPos.y() < | 931 | } else if (visibleHeight() - clipperPos.y() < |
928 | mScrollBorderWidth) { | 932 | mScrollBorderWidth) { |
929 | mScrollDownTimer.start(mScrollDelay); | 933 | mScrollDownTimer.start(mScrollDelay); |
930 | } else { | 934 | } else { |
931 | mScrollUpTimer.stop(); | 935 | mScrollUpTimer.stop(); |
932 | mScrollDownTimer.stop(); | 936 | mScrollDownTimer.stop(); |
933 | } | 937 | } |
934 | 938 | ||
935 | // Move or resize item if necessary | 939 | // Move or resize item if necessary |
936 | if (mCurrentCellX != gx || mCurrentCellY != gy) { | 940 | if (mCurrentCellX != gx || mCurrentCellY != gy) { |
937 | mItemMoved = true; | 941 | mItemMoved = true; |
938 | mActionItem->raise(); | 942 | mActionItem->raise(); |
939 | if (mActionType == MOVE) { | 943 | if (mActionType == MOVE) { |
940 | // Move all items belonging to a multi item | 944 | // Move all items belonging to a multi item |
941 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); | 945 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); |
942 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); | 946 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); |
943 | if (!moveItem) moveItem = mActionItem; | 947 | if (!moveItem) moveItem = mActionItem; |
944 | while (moveItem) { | 948 | while (moveItem) { |
945 | int dy; | 949 | int dy; |
946 | if (isMultiItem) dy = 0; | 950 | if (isMultiItem) dy = 0; |
947 | else dy = gy - mCurrentCellY; | 951 | else dy = gy - mCurrentCellY; |
948 | moveItem->moveRelative(gx - mCurrentCellX,dy); | 952 | moveItem->moveRelative(gx - mCurrentCellX,dy); |
949 | int x,y; | 953 | int x,y; |
950 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); | 954 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); |
951 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), | 955 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), |
952 | mGridSpacingY * moveItem->cellHeight()); | 956 | mGridSpacingY * moveItem->cellHeight()); |
953 | moveItem->raise(); | 957 | moveItem->raise(); |
954 | moveChild(moveItem,x,y); | 958 | moveChild(moveItem,x,y); |
955 | moveItem = moveItem->nextMultiItem(); | 959 | moveItem = moveItem->nextMultiItem(); |
956 | } | 960 | } |
957 | } else if (mActionType == RESIZETOP) { | 961 | } else if (mActionType == RESIZETOP) { |
958 | if (mCurrentCellY <= mActionItem->cellYBottom()) { | 962 | if (mCurrentCellY <= mActionItem->cellYBottom()) { |
959 | mActionItem->expandTop(gy - mCurrentCellY); | 963 | mActionItem->expandTop(gy - mCurrentCellY); |
960 | mActionItem->resize(mActionItem->width(), | 964 | mActionItem->resize(mActionItem->width(), |
961 | mGridSpacingY * mActionItem->cellHeight()); | 965 | mGridSpacingY * mActionItem->cellHeight()); |
962 | int x,y; | 966 | int x,y; |
963 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); | 967 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); |
964 | //moveChild(mActionItem,childX(mActionItem),y); | 968 | //moveChild(mActionItem,childX(mActionItem),y); |
965 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); | 969 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); |
966 | } | 970 | } |
967 | } else if (mActionType == RESIZEBOTTOM) { | 971 | } else if (mActionType == RESIZEBOTTOM) { |
968 | if (mCurrentCellY >= mActionItem->cellYTop()) { | 972 | if (mCurrentCellY >= mActionItem->cellYTop()) { |
969 | mActionItem->expandBottom(gy - mCurrentCellY); | 973 | mActionItem->expandBottom(gy - mCurrentCellY); |
970 | mActionItem->resize(mActionItem->width(), | 974 | mActionItem->resize(mActionItem->width(), |
971 | mGridSpacingY * mActionItem->cellHeight()); | 975 | mGridSpacingY * mActionItem->cellHeight()); |
972 | } | 976 | } |
973 | } else if (mActionType == RESIZELEFT) { | 977 | } else if (mActionType == RESIZELEFT) { |
974 | if (mCurrentCellX <= mActionItem->cellXWidth()) { | 978 | if (mCurrentCellX <= mActionItem->cellXWidth()) { |
975 | mActionItem->expandLeft(gx - mCurrentCellX); | 979 | mActionItem->expandLeft(gx - mCurrentCellX); |
976 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 980 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
977 | mActionItem->height()); | 981 | mActionItem->height()); |
978 | int x,y; | 982 | int x,y; |
979 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); | 983 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); |
980 | moveChild(mActionItem,x,childY(mActionItem)); | 984 | moveChild(mActionItem,x,childY(mActionItem)); |
981 | } | 985 | } |
982 | } else if (mActionType == RESIZERIGHT) { | 986 | } else if (mActionType == RESIZERIGHT) { |
983 | if (mCurrentCellX >= mActionItem->cellX()) { | 987 | if (mCurrentCellX >= mActionItem->cellX()) { |
984 | mActionItem->expandRight(gx - mCurrentCellX); | 988 | mActionItem->expandRight(gx - mCurrentCellX); |
985 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 989 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
986 | mActionItem->height()); | 990 | mActionItem->height()); |
987 | } | 991 | } |
988 | } | 992 | } |
989 | mCurrentCellX = gx; | 993 | mCurrentCellX = gx; |
990 | mCurrentCellY = gy; | 994 | mCurrentCellY = gy; |
991 | } | 995 | } |
992 | } | 996 | } |
993 | 997 | ||
994 | void KOAgenda::endItemAction() | 998 | void KOAgenda::endItemAction() |
995 | { | 999 | { |
996 | 1000 | ||
997 | if ( mItemMoved ) { | 1001 | if ( mItemMoved ) { |
998 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); | 1002 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); |
999 | if ( !placeItem ) { | 1003 | if ( !placeItem ) { |
1000 | placeItem = mActionItem; | 1004 | placeItem = mActionItem; |
1001 | } | 1005 | } |
1002 | if ( placeItem->incidence()->doesRecur() ) { | 1006 | if ( placeItem->incidence()->doesRecur() ) { |
1003 | Incidence* oldInc = placeItem->incidence(); | 1007 | Incidence* oldInc = placeItem->incidence(); |
1004 | placeItem->recreateIncidence(); | 1008 | placeItem->recreateIncidence(); |
1005 | emit addToCalSignal(placeItem->incidence(), oldInc ); | 1009 | emit addToCalSignal(placeItem->incidence(), oldInc ); |
1006 | } | 1010 | } |
1007 | int type = mActionType; | 1011 | int type = mActionType; |
1008 | if ( mAllDayMode ) | 1012 | if ( mAllDayMode ) |
1009 | type = -1; | 1013 | type = -1; |
1010 | KOAgendaItem *modifiedItem = placeItem; | 1014 | KOAgendaItem *modifiedItem = placeItem; |
1011 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); | 1015 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); |
1012 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); | 1016 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); |
1013 | KOAgendaItem *item; | 1017 | KOAgendaItem *item; |
1014 | 1018 | ||
1015 | if ( placeItem->incidence()->typeID() == todoID ) { | 1019 | if ( placeItem->incidence()->typeID() == todoID ) { |
1016 | mSelectedItem = 0; | 1020 | mSelectedItem = 0; |
1017 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); | 1021 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); |
1018 | modifiedItem->mLastMoveXPos = mCurrentCellX; | 1022 | modifiedItem->mLastMoveXPos = mCurrentCellX; |
1019 | emit itemModified( modifiedItem, mActionType ); | 1023 | emit itemModified( modifiedItem, mActionType ); |
1020 | } | 1024 | } |
1021 | else { | 1025 | else { |
1022 | 1026 | ||
1023 | 1027 | ||
1024 | globalFlagBlockAgendaItemPaint = 1; | 1028 | globalFlagBlockAgendaItemPaint = 1; |
1025 | for ( item=oldconflictItems.first(); item != 0; | 1029 | for ( item=oldconflictItems.first(); item != 0; |
1026 | item=oldconflictItems.next() ) { | 1030 | item=oldconflictItems.next() ) { |
1027 | placeSubCells(item); | 1031 | placeSubCells(item); |
1028 | } | 1032 | } |
1029 | while ( placeItem ) { | 1033 | while ( placeItem ) { |
1030 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 1034 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
1031 | oldconflictItems = placeItem->conflictItems(); | 1035 | oldconflictItems = placeItem->conflictItems(); |
1032 | for ( item=oldconflictItems.first(); item != 0; | 1036 | for ( item=oldconflictItems.first(); item != 0; |
1033 | item=oldconflictItems.next() ) { | 1037 | item=oldconflictItems.next() ) { |
1034 | placeSubCells(item); | 1038 | placeSubCells(item); |
1035 | } | 1039 | } |
1036 | placeSubCells( placeItem ); | 1040 | placeSubCells( placeItem ); |
1037 | placeItem = placeItem->nextMultiItem(); | 1041 | placeItem = placeItem->nextMultiItem(); |
1038 | } | 1042 | } |
1039 | globalFlagBlockAgendaItemPaint = 0; | 1043 | globalFlagBlockAgendaItemPaint = 0; |
1040 | for ( item=oldconflictItems.first(); item != 0; | 1044 | for ( item=oldconflictItems.first(); item != 0; |
1041 | item=oldconflictItems.next() ) { | 1045 | item=oldconflictItems.next() ) { |
1042 | globalFlagBlockAgendaItemUpdate = 0; | 1046 | globalFlagBlockAgendaItemUpdate = 0; |
1043 | item->repaintMe(); | 1047 | item->repaintMe(); |
1044 | globalFlagBlockAgendaItemUpdate = 1; | 1048 | globalFlagBlockAgendaItemUpdate = 1; |
1045 | item->repaint( false ); | 1049 | item->repaint( false ); |
1046 | } | 1050 | } |
1047 | placeItem = modifiedItem; | 1051 | placeItem = modifiedItem; |
1048 | 1052 | ||
1049 | while ( placeItem ) { | 1053 | while ( placeItem ) { |
1050 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 1054 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
1051 | globalFlagBlockAgendaItemUpdate = 0; | 1055 | globalFlagBlockAgendaItemUpdate = 0; |
1052 | placeItem->repaintMe(); | 1056 | placeItem->repaintMe(); |
1053 | globalFlagBlockAgendaItemUpdate = 1; | 1057 | globalFlagBlockAgendaItemUpdate = 1; |
1054 | placeItem->repaint(false); | 1058 | placeItem->repaint(false); |
1055 | placeItem = placeItem->nextMultiItem(); | 1059 | placeItem = placeItem->nextMultiItem(); |
1056 | } | 1060 | } |
1057 | emit itemModified( modifiedItem, mActionType ); | 1061 | emit itemModified( modifiedItem, mActionType ); |
1058 | 1062 | ||
1059 | 1063 | ||
1060 | placeItem = modifiedItem; | 1064 | placeItem = modifiedItem; |
1061 | while ( placeItem ) { | 1065 | while ( placeItem ) { |
1062 | oldconflictItems = placeItem->conflictItems(); | 1066 | oldconflictItems = placeItem->conflictItems(); |
1063 | for ( item=oldconflictItems.first(); item != 0; | 1067 | for ( item=oldconflictItems.first(); item != 0; |
1064 | item=oldconflictItems.next() ) { | 1068 | item=oldconflictItems.next() ) { |
1065 | placeSubCells(item); | 1069 | placeSubCells(item); |
1066 | } | 1070 | } |
1067 | placeSubCells( placeItem ); | 1071 | placeSubCells( placeItem ); |
1068 | placeItem = placeItem->nextMultiItem(); | 1072 | placeItem = placeItem->nextMultiItem(); |
1069 | 1073 | ||
1070 | } | 1074 | } |
1071 | placeItem = modifiedItem; | 1075 | placeItem = modifiedItem; |
1072 | while ( placeItem ) { | 1076 | while ( placeItem ) { |
1073 | oldconflictItems = placeItem->conflictItems(); | 1077 | oldconflictItems = placeItem->conflictItems(); |
1074 | for ( item=oldconflictItems.first(); item != 0; | 1078 | for ( item=oldconflictItems.first(); item != 0; |
1075 | item=oldconflictItems.next() ) { | 1079 | item=oldconflictItems.next() ) { |
1076 | globalFlagBlockAgendaItemUpdate = 0; | 1080 | globalFlagBlockAgendaItemUpdate = 0; |
1077 | item->repaintMe(); | 1081 | item->repaintMe(); |
1078 | globalFlagBlockAgendaItemUpdate = 1; | 1082 | globalFlagBlockAgendaItemUpdate = 1; |
1079 | item->repaint(false); | 1083 | item->repaint(false); |
1080 | } | 1084 | } |
1081 | placeItem = placeItem->nextMultiItem(); | 1085 | placeItem = placeItem->nextMultiItem(); |
1082 | } | 1086 | } |
1083 | /* | 1087 | /* |
1084 | 1088 | ||
1085 | oldconflictItems = modifiedItem->conflictItems(); | 1089 | oldconflictItems = modifiedItem->conflictItems(); |
1086 | for ( item=oldconflictItems.first(); item != 0; | 1090 | for ( item=oldconflictItems.first(); item != 0; |
1087 | item=oldconflictItems.next() ) { | 1091 | item=oldconflictItems.next() ) { |
1088 | globalFlagBlockAgendaItemUpdate = 0; | 1092 | globalFlagBlockAgendaItemUpdate = 0; |
1089 | item->paintMe(false); | 1093 | item->paintMe(false); |
1090 | globalFlagBlockAgendaItemUpdate = 1; | 1094 | globalFlagBlockAgendaItemUpdate = 1; |
1091 | item->repaint(false); | 1095 | item->repaint(false); |
1092 | } | 1096 | } |
1093 | */ | 1097 | */ |
1094 | 1098 | ||
1095 | 1099 | ||
1096 | } | 1100 | } |
1097 | 1101 | ||
1098 | } | 1102 | } |
1099 | if ( mActionItem ) | 1103 | if ( mActionItem ) |
1100 | emit incidenceSelected( mActionItem->incidence() ); | 1104 | emit incidenceSelected( mActionItem->incidence() ); |
1101 | mScrollUpTimer.stop(); | 1105 | mScrollUpTimer.stop(); |
1102 | mScrollDownTimer.stop(); | 1106 | mScrollDownTimer.stop(); |
1103 | setCursor( arrowCursor ); | 1107 | setCursor( arrowCursor ); |
1104 | mActionItem = 0; | 1108 | mActionItem = 0; |
1105 | mActionType = NOP; | 1109 | mActionType = NOP; |
1106 | mItemMoved = 0; | 1110 | mItemMoved = 0; |
1107 | 1111 | ||
1108 | } | 1112 | } |
1109 | 1113 | ||
1110 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) | 1114 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) |
1111 | { | 1115 | { |
1112 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 1116 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
1113 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 1117 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
1114 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 1118 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
1115 | // point = clipper()->mapFromGlobal(point); | 1119 | // point = clipper()->mapFromGlobal(point); |
1116 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 1120 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
1117 | 1121 | ||
1118 | int x,y; | 1122 | int x,y; |
1119 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 1123 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
1120 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 1124 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
1121 | int gx,gy; | 1125 | int gx,gy; |
1122 | contentsToGrid(x,y,gx,gy); | 1126 | contentsToGrid(x,y,gx,gy); |
1123 | 1127 | ||
1124 | // Change cursor to resize cursor if appropriate | 1128 | // Change cursor to resize cursor if appropriate |
1125 | if (mAllDayMode) { | 1129 | if (mAllDayMode) { |
1126 | int gridDistanceX = (x - gx * mGridSpacingX); | 1130 | int gridDistanceX = (x - gx * mGridSpacingX); |
1127 | if (gridDistanceX < mResizeBorderWidth && | 1131 | if (gridDistanceX < mResizeBorderWidth && |
1128 | moveItem->cellX() == gx) { | 1132 | moveItem->cellX() == gx) { |
1129 | setCursor(sizeHorCursor); | 1133 | setCursor(sizeHorCursor); |
1130 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 1134 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
1131 | moveItem->cellXWidth() == gx) { | 1135 | moveItem->cellXWidth() == gx) { |
1132 | setCursor(sizeHorCursor); | 1136 | setCursor(sizeHorCursor); |
1133 | } else { | 1137 | } else { |
1134 | setCursor(arrowCursor); | 1138 | setCursor(arrowCursor); |
1135 | } | 1139 | } |
1136 | } else { | 1140 | } else { |
1137 | int gridDistanceY = (y - gy * mGridSpacingY); | 1141 | int gridDistanceY = (y - gy * mGridSpacingY); |
1138 | if (gridDistanceY < mResizeBorderWidth && | 1142 | if (gridDistanceY < mResizeBorderWidth && |
1139 | moveItem->cellYTop() == gy && | 1143 | moveItem->cellYTop() == gy && |
1140 | !moveItem->firstMultiItem()) { | 1144 | !moveItem->firstMultiItem()) { |
1141 | setCursor(sizeVerCursor); | 1145 | setCursor(sizeVerCursor); |
1142 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 1146 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
1143 | moveItem->cellYBottom() == gy && | 1147 | moveItem->cellYBottom() == gy && |
1144 | !moveItem->lastMultiItem()) { | 1148 | !moveItem->lastMultiItem()) { |
1145 | setCursor(sizeVerCursor); | 1149 | setCursor(sizeVerCursor); |
1146 | } else { | 1150 | } else { |
1147 | setCursor(arrowCursor); | 1151 | setCursor(arrowCursor); |
1148 | } | 1152 | } |
1149 | } | 1153 | } |
1150 | } | 1154 | } |
1151 | 1155 | ||
1152 | 1156 | ||
1153 | /* | 1157 | /* |
1154 | Place item in cell and take care that multiple items using the same cell do | 1158 | Place item in cell and take care that multiple items using the same cell do |
1155 | not overlap. This method is not yet optimal. It doesn´t use the maximum space | 1159 | not overlap. This method is not yet optimal. It doesn´t use the maximum space |
1156 | it can get in all cases. | 1160 | it can get in all cases. |
1157 | At the moment the method has a bug: When an item is placed only the sub cell | 1161 | At the moment the method has a bug: When an item is placed only the sub cell |
1158 | widths of the items are changed, which are within the Y region the item to | 1162 | widths of the items are changed, which are within the Y region the item to |
1159 | place spans. When the sub cell width change of one of this items affects a | 1163 | place spans. When the sub cell width change of one of this items affects a |
1160 | cell, where other items are, which do not overlap in Y with the item to place, | 1164 | cell, where other items are, which do not overlap in Y with the item to place, |
1161 | the display gets corrupted, although the corruption looks quite nice. | 1165 | the display gets corrupted, although the corruption looks quite nice. |
1162 | */ | 1166 | */ |
1163 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) | 1167 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) |
1164 | { | 1168 | { |
1165 | 1169 | ||
1166 | QPtrList<KOAgendaItem> conflictItems; | 1170 | QPtrList<KOAgendaItem> conflictItems; |
1167 | int maxSubCells = 0; | 1171 | int maxSubCells = 0; |
1168 | QIntDict<KOAgendaItem> subCellDict(7); | 1172 | QIntDict<KOAgendaItem> subCellDict(7); |
1169 | 1173 | ||
1170 | KOAgendaItem *item; | 1174 | KOAgendaItem *item; |
1171 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1175 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1172 | if (item != placeItem) { | 1176 | if (item != placeItem) { |
1173 | if (placeItem->cellX() <= item->cellXWidth() && | 1177 | if (placeItem->cellX() <= item->cellXWidth() && |
1174 | placeItem->cellXWidth() >= item->cellX()) { | 1178 | placeItem->cellXWidth() >= item->cellX()) { |
1175 | if ((placeItem->cellYTop() <= item->cellYBottom()) && | 1179 | if ((placeItem->cellYTop() <= item->cellYBottom()) && |
1176 | (placeItem->cellYBottom() >= item->cellYTop())) { | 1180 | (placeItem->cellYBottom() >= item->cellYTop())) { |
1177 | conflictItems.append(item); | 1181 | conflictItems.append(item); |
1178 | if (item->subCells() > maxSubCells) | 1182 | if (item->subCells() > maxSubCells) |
1179 | maxSubCells = item->subCells(); | 1183 | maxSubCells = item->subCells(); |
1180 | subCellDict.insert(item->subCell(),item); | 1184 | subCellDict.insert(item->subCell(),item); |
1181 | } | 1185 | } |
1182 | } | 1186 | } |
1183 | } | 1187 | } |
1184 | } | 1188 | } |
1185 | 1189 | ||
1186 | if (conflictItems.count() > 0) { | 1190 | if (conflictItems.count() > 0) { |
1187 | // Look for unused sub cell and insert item | 1191 | // Look for unused sub cell and insert item |
1188 | int i; | 1192 | int i; |
1189 | for(i=0;i<maxSubCells;++i) { | 1193 | for(i=0;i<maxSubCells;++i) { |
1190 | if (!subCellDict.find(i)) { | 1194 | if (!subCellDict.find(i)) { |
1191 | placeItem->setSubCell(i); | 1195 | placeItem->setSubCell(i); |
1192 | break; | 1196 | break; |
1193 | } | 1197 | } |
1194 | } | 1198 | } |
1195 | if (i == maxSubCells) { | 1199 | if (i == maxSubCells) { |
1196 | placeItem->setSubCell(maxSubCells); | 1200 | placeItem->setSubCell(maxSubCells); |
1197 | maxSubCells++; // add new item to number of sub cells | 1201 | maxSubCells++; // add new item to number of sub cells |
1198 | } | 1202 | } |
1199 | 1203 | ||
1200 | // Prepare for sub cell geometry adjustment | 1204 | // Prepare for sub cell geometry adjustment |
1201 | int newSubCellWidth; | 1205 | int newSubCellWidth; |
1202 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; | 1206 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; |
1203 | else newSubCellWidth = mGridSpacingX / maxSubCells; | 1207 | else newSubCellWidth = mGridSpacingX / maxSubCells; |
1204 | conflictItems.append(placeItem); | 1208 | conflictItems.append(placeItem); |
1205 | 1209 | ||
1206 | 1210 | ||
1207 | // Adjust sub cell geometry of all direct conflict items | 1211 | // Adjust sub cell geometry of all direct conflict items |
1208 | for ( item=conflictItems.first(); item != 0; | 1212 | for ( item=conflictItems.first(); item != 0; |
1209 | item=conflictItems.next() ) { | 1213 | item=conflictItems.next() ) { |
1210 | item->setSubCells(maxSubCells); | 1214 | item->setSubCells(maxSubCells); |
1211 | if (mAllDayMode) { | 1215 | if (mAllDayMode) { |
1212 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1216 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1213 | } else { | 1217 | } else { |
1214 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1218 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1215 | } | 1219 | } |
1216 | int x,y; | 1220 | int x,y; |
1217 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1221 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1218 | if (mAllDayMode) { | 1222 | if (mAllDayMode) { |
1219 | y += item->subCell() * newSubCellWidth; | 1223 | y += item->subCell() * newSubCellWidth; |
1220 | } else { | 1224 | } else { |
1221 | x += item->subCell() * newSubCellWidth; | 1225 | x += item->subCell() * newSubCellWidth; |
1222 | } | 1226 | } |
1223 | moveChild(item,x,y); | 1227 | moveChild(item,x,y); |
1224 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); | 1228 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); |
1225 | //item->updateItem(); | 1229 | //item->updateItem(); |
1226 | } | 1230 | } |
1227 | // Adjust sub cell geometry of all conflict items of all conflict items | 1231 | // Adjust sub cell geometry of all conflict items of all conflict items |
1228 | for ( item=conflictItems.first(); item != 0; | 1232 | for ( item=conflictItems.first(); item != 0; |
1229 | item=conflictItems.next() ) { | 1233 | item=conflictItems.next() ) { |
1230 | if ( placeItem != item ) { | 1234 | if ( placeItem != item ) { |
1231 | KOAgendaItem *item2; | 1235 | KOAgendaItem *item2; |
1232 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); | 1236 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); |
1233 | for ( item2=conflictItems2.first(); item2 != 0; | 1237 | for ( item2=conflictItems2.first(); item2 != 0; |
1234 | item2=conflictItems2.next() ) { | 1238 | item2=conflictItems2.next() ) { |
1235 | if ( item2->subCells() != maxSubCells) { | 1239 | if ( item2->subCells() != maxSubCells) { |
1236 | item2->setSubCells(maxSubCells); | 1240 | item2->setSubCells(maxSubCells); |
1237 | if (mAllDayMode) { | 1241 | if (mAllDayMode) { |
1238 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); | 1242 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); |
1239 | } else { | 1243 | } else { |
1240 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); | 1244 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); |
1241 | } | 1245 | } |
1242 | int x,y; | 1246 | int x,y; |
1243 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); | 1247 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); |
1244 | if (mAllDayMode) { | 1248 | if (mAllDayMode) { |
1245 | y += item2->subCell() * newSubCellWidth; | 1249 | y += item2->subCell() * newSubCellWidth; |
1246 | } else { | 1250 | } else { |
1247 | x += item2->subCell() * newSubCellWidth; | 1251 | x += item2->subCell() * newSubCellWidth; |
1248 | } | 1252 | } |
1249 | moveChild(item2,x,y); | 1253 | moveChild(item2,x,y); |
1250 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); | 1254 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); |
1251 | } | 1255 | } |
1252 | } | 1256 | } |
1253 | } | 1257 | } |
1254 | } | 1258 | } |
1255 | } else { | 1259 | } else { |
1256 | placeItem->setSubCell(0); | 1260 | placeItem->setSubCell(0); |
1257 | placeItem->setSubCells(1); | 1261 | placeItem->setSubCells(1); |
1258 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); | 1262 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); |
1259 | else placeItem->resize(mGridSpacingX,placeItem->height()); | 1263 | else placeItem->resize(mGridSpacingX,placeItem->height()); |
1260 | int x,y; | 1264 | int x,y; |
1261 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); | 1265 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); |
1262 | moveChild(placeItem,x,y); | 1266 | moveChild(placeItem,x,y); |
1263 | } | 1267 | } |
1264 | placeItem->setConflictItems(conflictItems); | 1268 | placeItem->setConflictItems(conflictItems); |
1265 | // for ( item=conflictItems.first(); item != 0; | 1269 | // for ( item=conflictItems.first(); item != 0; |
1266 | // item=conflictItems.next() ) { | 1270 | // item=conflictItems.next() ) { |
1267 | // //item->updateItem(); | 1271 | // //item->updateItem(); |
1268 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); | 1272 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); |
1269 | // } | 1273 | // } |
1270 | // placeItem->updateItem(); | 1274 | // placeItem->updateItem(); |
1271 | } | 1275 | } |
1272 | 1276 | ||
1273 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | 1277 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) |
1274 | { | 1278 | { |
1275 | if ( globalFlagBlockAgenda ) | 1279 | if ( globalFlagBlockAgenda ) |
1276 | return; | 1280 | return; |
1277 | 1281 | ||
1278 | if ( mInvalidPixmap ) { | 1282 | if ( mInvalidPixmap ) { |
1279 | mInvalidPixmap = false; | 1283 | mInvalidPixmap = false; |
1280 | qDebug("KO: Upsizing Pixmaps "); | 1284 | qDebug("KO: Upsizing Pixmaps "); |
1281 | computeSizes(); | 1285 | computeSizes(); |
1282 | emit updateViewSignal(); | 1286 | emit updateViewSignal(); |
1283 | return; | 1287 | return; |
1284 | } | 1288 | } |
1285 | if ( ! mAllDayMode ) { | 1289 | if ( ! mAllDayMode ) { |
1286 | // currently not working for | 1290 | // currently not working for |
1287 | 1291 | ||
1288 | //qDebug("KOAgenda::drawContents "); | 1292 | //qDebug("KOAgenda::drawContents "); |
1289 | #if 0 | 1293 | #if 0 |
1290 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { | 1294 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { |
1291 | qDebug("WAU "); | 1295 | qDebug("WAU "); |
1292 | drawContentsToPainter(); | 1296 | drawContentsToPainter(); |
1293 | } | 1297 | } |
1294 | #endif | 1298 | #endif |
1295 | QPaintDevice* pd = p->device(); | 1299 | QPaintDevice* pd = p->device(); |
1296 | p->end(); | 1300 | p->end(); |
1297 | int vx, vy; | 1301 | int vx, vy; |
1298 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1302 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1299 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1303 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1300 | mSelectionCellX * mGridSpacingX; | 1304 | mSelectionCellX * mGridSpacingX; |
1301 | contentsToViewport ( cx, cy, vx,vy); | 1305 | contentsToViewport ( cx, cy, vx,vy); |
1302 | //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; | 1306 | //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; |
1303 | 1307 | ||
1304 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { | 1308 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { |
1305 | if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1309 | if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1306 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { | 1310 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { |
1307 | 1311 | ||
1308 | int vxSel, vySel; | 1312 | int vxSel, vySel; |
1309 | contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); | 1313 | contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); |
1310 | int off = mSelectionHeight; | 1314 | int off = mSelectionHeight; |
1311 | if ( vySel < 0 ) | 1315 | if ( vySel < 0 ) |
1312 | off += vySel; | 1316 | off += vySel; |
1313 | //qDebug("OFF %d %d %d", off,vySel, vy ); | 1317 | //qDebug("OFF %d %d %d", off,vySel, vy ); |
1314 | bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); | 1318 | bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); |
1315 | } else { | 1319 | } else { |
1316 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1320 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1317 | } | 1321 | } |
1318 | } | 1322 | } |
1319 | if ( mSelectionHeight > 0 ) { | 1323 | if ( mSelectionHeight > 0 ) { |
1320 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1324 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1321 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1325 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1322 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1326 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1323 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1327 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1324 | // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1328 | // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1325 | int hei = mSelectionHeight; | 1329 | int hei = mSelectionHeight; |
1326 | int offset = 0; | 1330 | int offset = 0; |
1327 | while ( hei > 0 ) { | 1331 | while ( hei > 0 ) { |
1328 | int p_hei = 5; | 1332 | int p_hei = 5; |
1329 | if ( hei < 5 ) p_hei = hei; | 1333 | if ( hei < 5 ) p_hei = hei; |
1330 | hei -= 5; | 1334 | hei -= 5; |
1331 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); | 1335 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); |
1332 | offset += 5; | 1336 | offset += 5; |
1333 | } | 1337 | } |
1334 | } | 1338 | } |
1335 | } | 1339 | } |
1336 | p->begin( pd ); | 1340 | p->begin( pd ); |
1337 | } else { | 1341 | } else { |
1338 | #if 0 | 1342 | #if 0 |
1339 | qDebug("mCurPixWid %d %d ",mCurPixWid, contentsWidth() ); | 1343 | qDebug("mCurPixWid %d %d ",mCurPixWid, contentsWidth() ); |
1340 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { | 1344 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { |
1341 | qDebug("WAUWAU "); | 1345 | qDebug("WAUWAU "); |
1342 | drawContentsToPainter(); | 1346 | drawContentsToPainter(); |
1343 | } | 1347 | } |
1344 | #endif | 1348 | #endif |
1345 | QPaintDevice* pd = p->device(); | 1349 | QPaintDevice* pd = p->device(); |
1346 | p->end(); | 1350 | p->end(); |
1347 | int vx, vy; | 1351 | int vx, vy; |
1348 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1352 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1349 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1353 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1350 | mSelectionCellX * mGridSpacingX; | 1354 | mSelectionCellX * mGridSpacingX; |
1351 | contentsToViewport ( cx, cy, vx,vy); | 1355 | contentsToViewport ( cx, cy, vx,vy); |
1352 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; | 1356 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; |
1353 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) | 1357 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) |
1354 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1358 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1355 | 1359 | ||
1356 | if ( mSelectionHeight > 0 ) { | 1360 | if ( mSelectionHeight > 0 ) { |
1357 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1361 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1358 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1362 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1359 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1363 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1360 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1364 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1361 | //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1365 | //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1362 | int hei = mSelectionHeight; | 1366 | int hei = mSelectionHeight; |
1363 | int offset = 0; | 1367 | int offset = 0; |
1364 | while ( hei > 0 ) { | 1368 | while ( hei > 0 ) { |
1365 | int p_hei = 5; | 1369 | int p_hei = 5; |
1366 | if ( hei < 5 ) p_hei = hei; | 1370 | if ( hei < 5 ) p_hei = hei; |
1367 | hei -= 5; | 1371 | hei -= 5; |
1368 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); | 1372 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); |
1369 | offset += 5; | 1373 | offset += 5; |
1370 | } | 1374 | } |
1371 | } | 1375 | } |
1372 | } | 1376 | } |
1373 | p->begin( pd ); | 1377 | p->begin( pd ); |
1374 | } | 1378 | } |
1375 | 1379 | ||
1376 | } | 1380 | } |
1377 | 1381 | ||
1378 | void KOAgenda::finishUpdate() | 1382 | void KOAgenda::finishUpdate() |
1379 | { | 1383 | { |
1380 | 1384 | ||
1381 | KOAgendaItem *item; | 1385 | KOAgendaItem *item; |
1382 | globalFlagBlockAgendaItemPaint = 1; | 1386 | globalFlagBlockAgendaItemPaint = 1; |
1383 | // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems | 1387 | // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems |
1384 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1388 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1385 | if ( !item->checkLayout() ) { | 1389 | if ( !item->checkLayout() ) { |
1386 | //qDebug(" conflictitem found "); | 1390 | //qDebug(" conflictitem found "); |
1387 | int newSubCellWidth; | 1391 | int newSubCellWidth; |
1388 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); | 1392 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); |
1389 | else newSubCellWidth = mGridSpacingX / item->subCells(); | 1393 | else newSubCellWidth = mGridSpacingX / item->subCells(); |
1390 | 1394 | ||
1391 | if (mAllDayMode) { | 1395 | if (mAllDayMode) { |
1392 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1396 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1393 | } else { | 1397 | } else { |
1394 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1398 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1395 | } | 1399 | } |
1396 | int x,y; | 1400 | int x,y; |
1397 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1401 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1398 | if (mAllDayMode) { | 1402 | if (mAllDayMode) { |
1399 | y += item->subCell() * newSubCellWidth; | 1403 | y += item->subCell() * newSubCellWidth; |
1400 | } else { | 1404 | } else { |
1401 | x += item->subCell() * newSubCellWidth; | 1405 | x += item->subCell() * newSubCellWidth; |
1402 | } | 1406 | } |
1403 | moveChild(item,x,y); | 1407 | moveChild(item,x,y); |
1404 | } | 1408 | } |
1405 | } | 1409 | } |
1406 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1410 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1407 | if ( !item->isVisible() ) | 1411 | if ( !item->isVisible() ) |
1408 | item->show(); | 1412 | item->show(); |
1409 | 1413 | ||
1410 | } | 1414 | } |
1411 | globalFlagBlockAgendaItemUpdate = 0; | 1415 | globalFlagBlockAgendaItemUpdate = 0; |
1412 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1416 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1413 | item->repaintMe( ); | 1417 | item->repaintMe( ); |
1414 | } | 1418 | } |
1415 | globalFlagBlockAgendaItemUpdate = 1; | 1419 | globalFlagBlockAgendaItemUpdate = 1; |
1416 | qApp->processEvents(); | 1420 | qApp->processEvents(); |
1417 | globalFlagBlockAgendaItemPaint = 0; | 1421 | globalFlagBlockAgendaItemPaint = 0; |
1418 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1422 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1419 | item->repaint( false ); | 1423 | item->repaint( false ); |
1420 | } | 1424 | } |
1421 | marcus_bains(); | 1425 | marcus_bains(); |
1422 | } | 1426 | } |
1423 | 1427 | ||
1424 | /* | 1428 | /* |
1425 | Draw grid in the background of the agenda. | 1429 | Draw grid in the background of the agenda. |
1426 | */ | 1430 | */ |
1427 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) | 1431 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) |
1428 | { | 1432 | { |
1429 | 1433 | ||
1430 | 1434 | ||
1431 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) | 1435 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) |
1432 | return; | 1436 | return; |
1433 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) | 1437 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) |
1434 | return; | 1438 | return; |
1435 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); | 1439 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); |
1436 | if ( ch < 1 ) | 1440 | if ( ch < 1 ) |
1437 | ch = 1; | 1441 | ch = 1; |
1438 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { | 1442 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { |
1439 | mPaintPixmap.resize( contentsWidth()+42, ch ); | 1443 | mPaintPixmap.resize( contentsWidth()+42, ch ); |
1440 | } | 1444 | } |
1441 | mCurPixWid = contentsWidth(); | 1445 | mCurPixWid = contentsWidth(); |
1442 | mCurPixHei = ch; | 1446 | mCurPixHei = ch; |
1443 | if ( mHighlightPixmap.width() < mGridSpacingX-1 ) { | 1447 | if ( mHighlightPixmap.width() < mGridSpacingX-1 ) { |
1444 | mHighlightPixmap.resize( mGridSpacingX-1, 5 ); | 1448 | mHighlightPixmap.resize( mGridSpacingX-1, 5 ); |
1445 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); | 1449 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); |
1446 | } | 1450 | } |
1447 | mPixPainter.begin( &mPaintPixmap) ; | 1451 | mPixPainter.begin( &mPaintPixmap) ; |
1448 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); | 1452 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); |
1449 | QPainter * p ; | 1453 | QPainter * p ; |
1450 | if (paint == 0) { | 1454 | if (paint == 0) { |
1451 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); | 1455 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); |
1452 | p = &mPixPainter; | 1456 | p = &mPixPainter; |
1453 | } | 1457 | } |
1454 | else | 1458 | else |
1455 | p = paint ; | 1459 | p = paint ; |
1456 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); | 1460 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); |
1457 | 1461 | ||
1458 | //--cx;++cw; | 1462 | //--cx;++cw; |
1459 | int lGridSpacingY = mGridSpacingY*2; | 1463 | int lGridSpacingY = mGridSpacingY*2; |
1460 | int selDay; | 1464 | int selDay; |
1461 | QDate curDate = QDate::currentDate(); | 1465 | QDate curDate = QDate::currentDate(); |
1462 | if ( !backgroundOnly ) { | 1466 | if ( !backgroundOnly ) { |
1463 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 1467 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
1464 | { | 1468 | { |
1465 | if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) { | 1469 | if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) { |
1466 | int x1 = cx; | 1470 | int x1 = cx; |
1467 | int y1 = 0; | 1471 | int y1 = 0; |
1468 | if (y1 < cy) y1 = cy; | 1472 | if (y1 < cy) y1 = cy; |
1469 | int x2 = cx+cw-1; | 1473 | int x2 = cx+cw-1; |
1470 | int y2 = contentsHeight(); | 1474 | int y2 = contentsHeight(); |
1471 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1475 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1472 | if (x2 >= x1 && y2 >= y1) { | 1476 | if (x2 >= x1 && y2 >= y1) { |
1473 | int gxStart = selDay; | 1477 | int gxStart = selDay; |
1474 | int gxEnd = gxStart ; | 1478 | int gxEnd = gxStart ; |
1475 | int xStart = KOGlobals::self()->reverseLayout() ? | 1479 | int xStart = KOGlobals::self()->reverseLayout() ? |
1476 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1480 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1477 | gxStart*mGridSpacingX; | 1481 | gxStart*mGridSpacingX; |
1478 | if (xStart < x1) xStart = x1; | 1482 | if (xStart < x1) xStart = x1; |
1479 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1483 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1480 | (mColumns - gxStart)*mGridSpacingX-1 : | 1484 | (mColumns - gxStart)*mGridSpacingX-1 : |
1481 | (gxStart+1)*mGridSpacingX-1; | 1485 | (gxStart+1)*mGridSpacingX-1; |
1482 | if (xEnd > x2) xEnd = x2; | 1486 | if (xEnd > x2) xEnd = x2; |
1483 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1487 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1484 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1488 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1485 | KOPrefs::instance()->mAgendaBgColor.light()); | 1489 | KOPrefs::instance()->mAgendaBgColor.light()); |
1486 | else | 1490 | else |
1487 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1491 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1488 | KOPrefs::instance()->mAgendaBgColor.dark()); | 1492 | KOPrefs::instance()->mAgendaBgColor.dark()); |
1489 | 1493 | ||
1490 | } | 1494 | } |
1491 | } | 1495 | } |
1492 | } | 1496 | } |
1493 | } | 1497 | } |
1494 | // Highlight working hours | 1498 | // Highlight working hours |
1495 | 1499 | ||
1496 | if ( !backgroundOnly ) | 1500 | if ( !backgroundOnly ) |
1497 | if (mWorkingHoursEnable) { | 1501 | if (mWorkingHoursEnable) { |
1498 | int x1 = cx; | 1502 | int x1 = cx; |
1499 | int y1 = mWorkingHoursYTop; | 1503 | int y1 = mWorkingHoursYTop; |
1500 | if (y1 < cy) y1 = cy; | 1504 | if (y1 < cy) y1 = cy; |
1501 | int x2 = cx+cw-1; | 1505 | int x2 = cx+cw-1; |
1502 | // int x2 = mGridSpacingX * 5 - 1; | 1506 | // int x2 = mGridSpacingX * 5 - 1; |
1503 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; | 1507 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; |
1504 | int y2 = mWorkingHoursYBottom; | 1508 | int y2 = mWorkingHoursYBottom; |
1505 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1509 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1506 | 1510 | ||
1507 | if (x2 >= x1 && y2 >= y1) { | 1511 | if (x2 >= x1 && y2 >= y1) { |
1508 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); | 1512 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); |
1509 | int gxStart = x1/mGridSpacingX; | 1513 | int gxStart = x1/mGridSpacingX; |
1510 | int gxEnd = x2/mGridSpacingX; | 1514 | int gxEnd = x2/mGridSpacingX; |
1511 | while(gxStart <= gxEnd) { | 1515 | while(gxStart <= gxEnd) { |
1512 | if (gxStart < int(mHolidayMask->count()) && | 1516 | if (gxStart < int(mHolidayMask->count()) && |
1513 | !mHolidayMask->at(gxStart)) { | 1517 | !mHolidayMask->at(gxStart)) { |
1514 | int xStart = KOGlobals::self()->reverseLayout() ? | 1518 | int xStart = KOGlobals::self()->reverseLayout() ? |
1515 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1519 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1516 | gxStart*mGridSpacingX; | 1520 | gxStart*mGridSpacingX; |
1517 | if (xStart < x1) xStart = x1; | 1521 | if (xStart < x1) xStart = x1; |
1518 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1522 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1519 | (mColumns - gxStart)*mGridSpacingX-1 : | 1523 | (mColumns - gxStart)*mGridSpacingX-1 : |
1520 | (gxStart+1)*mGridSpacingX-1; | 1524 | (gxStart+1)*mGridSpacingX-1; |
1521 | if (xEnd > x2) xEnd = x2; | 1525 | if (xEnd > x2) xEnd = x2; |
1522 | if ( mSelectedDates[gxStart] == curDate && KOPrefs::instance()->mHighlightCurrentDay ) { | 1526 | if ( mSelectedDates[gxStart] == curDate && KOPrefs::instance()->mHighlightCurrentDay ) { |
1523 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1527 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1524 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1528 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1525 | KOPrefs::instance()->mWorkingHoursColor.light()); | 1529 | KOPrefs::instance()->mWorkingHoursColor.light()); |
1526 | else | 1530 | else |
1527 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1531 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1528 | KOPrefs::instance()->mWorkingHoursColor.dark()); | 1532 | KOPrefs::instance()->mWorkingHoursColor.dark()); |
1529 | } else { | 1533 | } else { |
1530 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1534 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1531 | KOPrefs::instance()->mWorkingHoursColor); | 1535 | KOPrefs::instance()->mWorkingHoursColor); |
1532 | } | 1536 | } |
1533 | } | 1537 | } |
1534 | ++gxStart; | 1538 | ++gxStart; |
1535 | } | 1539 | } |
1536 | } | 1540 | } |
1537 | } | 1541 | } |
1538 | /* | 1542 | /* |
1539 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1543 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1540 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1544 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1541 | mSelectionCellX * mGridSpacingX; | 1545 | mSelectionCellX * mGridSpacingX; |
1542 | 1546 | ||
1543 | // Draw selection | 1547 | // Draw selection |
1544 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1548 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1545 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1549 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1546 | // TODO: paint only part within cx,cy,cw,ch | 1550 | // TODO: paint only part within cx,cy,cw,ch |
1547 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, | 1551 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, |
1548 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); | 1552 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); |
1549 | } | 1553 | } |
1550 | */ | 1554 | */ |
1551 | // Draw vertical lines of grid | 1555 | // Draw vertical lines of grid |
1552 | 1556 | ||
1553 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; | 1557 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; |
1554 | if ( mGridSpacingX > 0 ) { | 1558 | if ( mGridSpacingX > 0 ) { |
1555 | while (x < cx + cw) { | 1559 | while (x < cx + cw) { |
1556 | p->drawLine(x,cy,x,cy+ch); | 1560 | p->drawLine(x,cy,x,cy+ch); |
1557 | x+=mGridSpacingX; | 1561 | x+=mGridSpacingX; |
1558 | } | 1562 | } |
1559 | } | 1563 | } |
1560 | // Draw horizontal lines of grid | 1564 | // Draw horizontal lines of grid |
1561 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; | 1565 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; |
1562 | if ( lGridSpacingY > 0 ) { | 1566 | if ( lGridSpacingY > 0 ) { |
1563 | while (y < cy + ch) { | 1567 | while (y < cy + ch) { |
1564 | p->setPen( SolidLine ); | 1568 | p->setPen( SolidLine ); |
1565 | p->drawLine(cx,y,cx+cw,y); | 1569 | p->drawLine(cx,y,cx+cw,y); |
1566 | y+=lGridSpacingY; | 1570 | y+=lGridSpacingY; |
1567 | p->setPen( DotLine ); | 1571 | p->setPen( DotLine ); |
1568 | p->drawLine(cx,y,cx+cw,y); | 1572 | p->drawLine(cx,y,cx+cw,y); |
1569 | y+=lGridSpacingY; | 1573 | y+=lGridSpacingY; |
1570 | } | 1574 | } |
1571 | p->setPen( SolidLine ); | 1575 | p->setPen( SolidLine ); |
1572 | } | 1576 | } |
1573 | mPixPainter.end() ; | 1577 | mPixPainter.end() ; |
1574 | } | 1578 | } |
1575 | 1579 | ||
1576 | /* | 1580 | /* |
1577 | Convert srcollview contents coordinates to agenda grid coordinates. | 1581 | Convert srcollview contents coordinates to agenda grid coordinates. |
1578 | */ | 1582 | */ |
1579 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) | 1583 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) |
1580 | { | 1584 | { |
1581 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : | 1585 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : |
1582 | x/mGridSpacingX; | 1586 | x/mGridSpacingX; |
1583 | gy = y/mGridSpacingY; | 1587 | gy = y/mGridSpacingY; |
1584 | } | 1588 | } |
1585 | 1589 | ||
1586 | /* | 1590 | /* |
1587 | Convert agenda grid coordinates to scrollview contents coordinates. | 1591 | Convert agenda grid coordinates to scrollview contents coordinates. |
1588 | */ | 1592 | */ |
1589 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) | 1593 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) |
1590 | { | 1594 | { |
1591 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: | 1595 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: |
1592 | gx*mGridSpacingX; | 1596 | gx*mGridSpacingX; |
1593 | y = gy*mGridSpacingY; | 1597 | y = gy*mGridSpacingY; |
1594 | } | 1598 | } |
1595 | 1599 | ||
1596 | 1600 | ||
1597 | /* | 1601 | /* |
1598 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into | 1602 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into |
1599 | the grid. | 1603 | the grid. |
1600 | */ | 1604 | */ |
1601 | int KOAgenda::timeToY(const QTime &time) | 1605 | int KOAgenda::timeToY(const QTime &time) |
1602 | { | 1606 | { |
1603 | int minutesPerCell = 24 * 60 / mRows; | 1607 | int minutesPerCell = 24 * 60 / mRows; |
1604 | int timeMinutes = time.hour() * 60 + time.minute(); | 1608 | int timeMinutes = time.hour() * 60 + time.minute(); |
1605 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; | 1609 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; |
1606 | return Y; | 1610 | return Y; |
1607 | } | 1611 | } |
1608 | 1612 | ||
1609 | 1613 | ||
1610 | /* | 1614 | /* |
1611 | Return time corresponding to cell y coordinate. Coordinates are rounded to | 1615 | Return time corresponding to cell y coordinate. Coordinates are rounded to |
1612 | fit into the grid. | 1616 | fit into the grid. |
1613 | */ | 1617 | */ |
1614 | QTime KOAgenda::gyToTime(int gy) | 1618 | QTime KOAgenda::gyToTime(int gy) |
1615 | { | 1619 | { |
1616 | 1620 | ||
1617 | int secondsPerCell = 24 * 60 * 60/ mRows; | 1621 | int secondsPerCell = 24 * 60 * 60/ mRows; |
1618 | 1622 | ||
1619 | int timeSeconds = secondsPerCell * gy; | 1623 | int timeSeconds = secondsPerCell * gy; |
1620 | 1624 | ||
1621 | QTime time( 0, 0, 0 ); | 1625 | QTime time( 0, 0, 0 ); |
1622 | if ( timeSeconds < 24 * 60 * 60 ) { | 1626 | if ( timeSeconds < 24 * 60 * 60 ) { |
1623 | time = time.addSecs(timeSeconds); | 1627 | time = time.addSecs(timeSeconds); |
1624 | } else { | 1628 | } else { |
1625 | time.setHMS( 23, 59, 59 ); | 1629 | time.setHMS( 23, 59, 59 ); |
1626 | } | 1630 | } |
1627 | 1631 | ||
1628 | return time; | 1632 | return time; |
1629 | } | 1633 | } |
1630 | 1634 | ||
1631 | void KOAgenda::setStartHour(int startHour) | 1635 | void KOAgenda::setStartHour(int startHour) |
1632 | { | 1636 | { |
1633 | int startCell = startHour * mRows / 24; | 1637 | int startCell = startHour * mRows / 24; |
1634 | setContentsPos(0,startCell * gridSpacingY()); | 1638 | setContentsPos(0,startCell * gridSpacingY()); |
1635 | } | 1639 | } |
1636 | QTime KOAgenda::getEndTime() | 1640 | QTime KOAgenda::getEndTime() |
1637 | { | 1641 | { |
1638 | int tim = (contentsY ()+viewport()->height())*24/contentsHeight (); | 1642 | int tim = (contentsY ()+viewport()->height())*24/contentsHeight (); |
1639 | if ( tim > 23 ) | 1643 | if ( tim > 23 ) |
1640 | return QTime ( 23,59,59); | 1644 | return QTime ( 23,59,59); |
1641 | return QTime ( tim,0,0); | 1645 | return QTime ( tim,0,0); |
1642 | } | 1646 | } |
1643 | void KOAgenda::hideUnused() | 1647 | void KOAgenda::hideUnused() |
1644 | { | 1648 | { |
1645 | // experimental only | 1649 | // experimental only |
1646 | // return; | 1650 | // return; |
1647 | KOAgendaItem *item; | 1651 | KOAgendaItem *item; |
1648 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { | 1652 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { |
1649 | item->hide(); | 1653 | item->hide(); |
1650 | } | 1654 | } |
1651 | } | 1655 | } |
1652 | 1656 | ||
1653 | 1657 | ||
1654 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) | 1658 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) |
1655 | { | 1659 | { |
1656 | 1660 | ||
1657 | KOAgendaItem *fi; | 1661 | KOAgendaItem *fi; |
1658 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { | 1662 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { |
1659 | if ( fi->incidence() == event ) { | 1663 | if ( fi->incidence() == event ) { |
1660 | mUnusedItems.remove(); | 1664 | mUnusedItems.remove(); |
1661 | fi->init( event, qd ); | 1665 | fi->init( event, qd ); |
1662 | return fi; | 1666 | return fi; |
1663 | } | 1667 | } |
1664 | } | 1668 | } |
1665 | fi=mUnusedItems.first(); | 1669 | fi=mUnusedItems.first(); |
1666 | if ( fi ) { | 1670 | if ( fi ) { |
1667 | mUnusedItems.remove(); | 1671 | mUnusedItems.remove(); |
1668 | fi->init( event, qd ); | 1672 | fi->init( event, qd ); |
1669 | return fi; | 1673 | return fi; |
1670 | } | 1674 | } |
1671 | // qDebug("new KOAgendaItem "); | 1675 | // qDebug("new KOAgendaItem "); |
1672 | 1676 | ||
1673 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); | 1677 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); |
1674 | agendaItem->installEventFilter(this); | 1678 | agendaItem->installEventFilter(this); |
1675 | addChild(agendaItem,0,0); | 1679 | addChild(agendaItem,0,0); |
1676 | return agendaItem; | 1680 | return agendaItem; |
1677 | } | 1681 | } |
1678 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) | 1682 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) |
1679 | { | 1683 | { |
1680 | KOAgendaItem *item; | 1684 | KOAgendaItem *item; |
1681 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1685 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1682 | if ( item->incidence() == todo ) { | 1686 | if ( item->incidence() == todo ) { |
1683 | mItems.remove(); | 1687 | mItems.remove(); |
1684 | return item; | 1688 | return item; |
1685 | } | 1689 | } |
1686 | } | 1690 | } |
1687 | return 0; | 1691 | return 0; |
1688 | } | 1692 | } |
1689 | 1693 | ||
1690 | 1694 | ||
1691 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) | 1695 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) |
1692 | { | 1696 | { |
1693 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| | 1697 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| |
1694 | KOAgendaItem *item; | 1698 | KOAgendaItem *item; |
1695 | item = getItemForTodo ( todo ); | 1699 | item = getItemForTodo ( todo ); |
1696 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); | 1700 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); |
1697 | if ( item ) { | 1701 | if ( item ) { |
1698 | blockSignals( true ); | 1702 | blockSignals( true ); |
1699 | //qDebug("item found "); | 1703 | //qDebug("item found "); |
1700 | item->hide(); | 1704 | item->hide(); |
1701 | item->setCellX(-2, -1 ); | 1705 | item->setCellX(-2, -1 ); |
1702 | item->select(false); | 1706 | item->select(false); |
1703 | mUnusedItems.append( item ); | 1707 | mUnusedItems.append( item ); |
1704 | mItems.remove( item ); | 1708 | mItems.remove( item ); |
1705 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1709 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1706 | KOAgendaItem *itemit; | 1710 | KOAgendaItem *itemit; |
1707 | //globalFlagBlockAgendaItemPaint = 1; | 1711 | //globalFlagBlockAgendaItemPaint = 1; |
1708 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1712 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1709 | itemit=oldconflictItems.next() ) { | 1713 | itemit=oldconflictItems.next() ) { |
1710 | if ( itemit != item ) | 1714 | if ( itemit != item ) |
1711 | placeSubCells(itemit); | 1715 | placeSubCells(itemit); |
1712 | } | 1716 | } |
1713 | qApp->processEvents(); | 1717 | qApp->processEvents(); |
1714 | //globalFlagBlockAgendaItemPaint = 0; | 1718 | //globalFlagBlockAgendaItemPaint = 0; |
1715 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1719 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1716 | itemit=oldconflictItems.next() ) { | 1720 | itemit=oldconflictItems.next() ) { |
1717 | globalFlagBlockAgendaItemUpdate = 0; | 1721 | globalFlagBlockAgendaItemUpdate = 0; |
1718 | if ( itemit != item ) | 1722 | if ( itemit != item ) |
1719 | itemit->repaintMe(); | 1723 | itemit->repaintMe(); |
1720 | globalFlagBlockAgendaItemUpdate = 1; | 1724 | globalFlagBlockAgendaItemUpdate = 1; |
1721 | //qDebug("sigleshot "); | 1725 | //qDebug("sigleshot "); |
1722 | QTimer::singleShot( 0, itemit, SLOT ( repaintItem() )); | 1726 | QTimer::singleShot( 0, itemit, SLOT ( repaintItem() )); |
1723 | //itemit->repaint( false ); repaintItem() | 1727 | //itemit->repaint( false ); repaintItem() |
1724 | } | 1728 | } |
1725 | blockSignals( false ); | 1729 | blockSignals( false ); |
1726 | } | 1730 | } |
1727 | if ( remove ) { | 1731 | if ( remove ) { |
1728 | //qDebug("remove****************************************** "); | 1732 | //qDebug("remove****************************************** "); |
1729 | return; | 1733 | return; |
1730 | } | 1734 | } |
1731 | if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) | 1735 | if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) |
1732 | return; | 1736 | return; |
1733 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); | 1737 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); |
1734 | QDate currentDate = QDate::currentDate(); | 1738 | QDate currentDate = QDate::currentDate(); |
1735 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < currentDate)&& ( KOPrefs::instance()->mShowTodoInAgenda ); | 1739 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < currentDate)&& ( KOPrefs::instance()->mShowTodoInAgenda ); |
1736 | QDateTime dt; | 1740 | QDateTime dt; |
1737 | if ( todo->hasCompletedDate() ) | 1741 | if ( todo->hasCompletedDate() ) |
1738 | dt = todo->completed(); | 1742 | dt = todo->completed(); |
1739 | else | 1743 | else |
1740 | dt = todo->dtDue(); | 1744 | dt = todo->dtDue(); |
1741 | if ( overdue ) { | 1745 | if ( overdue ) { |
1742 | days += todo->dtDue().date().daysTo( currentDate ); | 1746 | days += todo->dtDue().date().daysTo( currentDate ); |
1743 | } | 1747 | } |
1744 | else | 1748 | else |
1745 | currentDate = dt.date(); | 1749 | currentDate = dt.date(); |
1746 | 1750 | ||
1747 | if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { | 1751 | if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { |
1748 | if ( ! mAllDayMode ) return; | 1752 | if ( ! mAllDayMode ) return; |
1749 | // aldayagenda | 1753 | // aldayagenda |
1750 | globalFlagBlockAgendaItemPaint = 1; | 1754 | globalFlagBlockAgendaItemPaint = 1; |
1751 | item = insertAllDayItem(todo, currentDate,days, days); | 1755 | item = insertAllDayItem(todo, currentDate,days, days); |
1752 | item->show(); | 1756 | item->show(); |
1753 | 1757 | ||
1754 | } | 1758 | } |
1755 | else { | 1759 | else { |
1756 | if ( mAllDayMode ) return; | 1760 | if ( mAllDayMode ) return; |
1757 | // mAgenda | 1761 | // mAgenda |
1758 | globalFlagBlockAgendaItemPaint = 1; | 1762 | globalFlagBlockAgendaItemPaint = 1; |
1759 | int endY = timeToY(dt.time()) - 1; | 1763 | int endY = timeToY(dt.time()) - 1; |
1760 | int hi = 12/KOPrefs::instance()->mHourSize; | 1764 | int hi = 12/KOPrefs::instance()->mHourSize; |
1761 | int startY = endY - 1-hi; | 1765 | int startY = endY - 1-hi; |
1762 | item = insertItem(todo,currentDate,days,startY,endY); | 1766 | item = insertItem(todo,currentDate,days,startY,endY); |
1763 | item->show(); | 1767 | item->show(); |
1764 | } | 1768 | } |
1765 | qApp->processEvents(); | 1769 | qApp->processEvents(); |
1766 | globalFlagBlockAgendaItemPaint = 0; | 1770 | globalFlagBlockAgendaItemPaint = 0; |
1767 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1771 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1768 | KOAgendaItem *itemit; | 1772 | KOAgendaItem *itemit; |
1769 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1773 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1770 | itemit=oldconflictItems.next() ) { | 1774 | itemit=oldconflictItems.next() ) { |
1771 | globalFlagBlockAgendaItemUpdate = 0; | 1775 | globalFlagBlockAgendaItemUpdate = 0; |
1772 | itemit->repaintMe(); | 1776 | itemit->repaintMe(); |
1773 | globalFlagBlockAgendaItemUpdate = 1; | 1777 | globalFlagBlockAgendaItemUpdate = 1; |
1774 | itemit->repaint(); | 1778 | itemit->repaint(); |
1775 | } | 1779 | } |
1776 | globalFlagBlockAgendaItemUpdate = 0; | 1780 | globalFlagBlockAgendaItemUpdate = 0; |
1777 | item->repaintMe(); | 1781 | item->repaintMe(); |
1778 | globalFlagBlockAgendaItemUpdate = 1; | 1782 | globalFlagBlockAgendaItemUpdate = 1; |
1779 | item->repaint(); | 1783 | item->repaint(); |
1780 | } | 1784 | } |
1781 | /* | 1785 | /* |
1782 | Insert KOAgendaItem into agenda. | 1786 | Insert KOAgendaItem into agenda. |
1783 | */ | 1787 | */ |
1784 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) | 1788 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) |
1785 | { | 1789 | { |
1786 | if (mAllDayMode) { | 1790 | if (mAllDayMode) { |
1787 | qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); | 1791 | qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); |
1788 | return 0; | 1792 | return 0; |
1789 | } | 1793 | } |
1790 | 1794 | ||
1791 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1795 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1792 | //agendaItem->setFrameStyle(WinPanel|Raised); | 1796 | //agendaItem->setFrameStyle(WinPanel|Raised); |
1793 | 1797 | ||
1794 | int YSize = YBottom - YTop + 1; | 1798 | int YSize = YBottom - YTop + 1; |
1795 | if (YSize < 0) { | 1799 | if (YSize < 0) { |
1796 | YSize = 1; | 1800 | YSize = 1; |
1797 | } | 1801 | } |
1798 | int iheight = mGridSpacingY * YSize; | 1802 | int iheight = mGridSpacingY * YSize; |
1799 | 1803 | ||
1800 | agendaItem->resize(mGridSpacingX,iheight ); | 1804 | agendaItem->resize(mGridSpacingX,iheight ); |
1801 | agendaItem->setCellXY(X,YTop,YBottom); | 1805 | agendaItem->setCellXY(X,YTop,YBottom); |
1802 | agendaItem->setCellXWidth(X); | 1806 | agendaItem->setCellXWidth(X); |
1803 | 1807 | ||
1804 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); | 1808 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); |
1805 | mItems.append(agendaItem); | 1809 | mItems.append(agendaItem); |
1806 | 1810 | ||
1807 | placeSubCells(agendaItem); | 1811 | placeSubCells(agendaItem); |
1808 | 1812 | ||
1809 | //agendaItem->show(); | 1813 | //agendaItem->show(); |
1810 | 1814 | ||
1811 | 1815 | ||
1812 | return agendaItem; | 1816 | return agendaItem; |
1813 | } | 1817 | } |
1814 | 1818 | ||
1815 | 1819 | ||
1816 | /* | 1820 | /* |
1817 | Insert all-day KOAgendaItem into agenda. | 1821 | Insert all-day KOAgendaItem into agenda. |
1818 | */ | 1822 | */ |
1819 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) | 1823 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) |
1820 | { | 1824 | { |
1821 | if (!mAllDayMode) { | 1825 | if (!mAllDayMode) { |
1822 | return 0; | 1826 | return 0; |
1823 | } | 1827 | } |
1824 | 1828 | ||
1825 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1829 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1826 | 1830 | ||
1827 | agendaItem->setCellXY(XBegin,0,0); | 1831 | agendaItem->setCellXY(XBegin,0,0); |
1828 | agendaItem->setCellXWidth(XEnd); | 1832 | agendaItem->setCellXWidth(XEnd); |
1829 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); | 1833 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); |
1830 | 1834 | ||
1831 | //addChild(agendaItem,XBegin*mGridSpacingX,0); | 1835 | //addChild(agendaItem,XBegin*mGridSpacingX,0); |
1832 | mItems.append(agendaItem); | 1836 | mItems.append(agendaItem); |
1833 | 1837 | ||
1834 | placeSubCells(agendaItem); | 1838 | placeSubCells(agendaItem); |
1835 | 1839 | ||
1836 | //agendaItem->show(); | 1840 | //agendaItem->show(); |
1837 | 1841 | ||
1838 | return agendaItem; | 1842 | return agendaItem; |
1839 | } | 1843 | } |
1840 | 1844 | ||
1841 | 1845 | ||
1842 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, | 1846 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, |
1843 | int YTop,int YBottom) | 1847 | int YTop,int YBottom) |
1844 | { | 1848 | { |
1845 | if (mAllDayMode) { | 1849 | if (mAllDayMode) { |
1846 | ; | 1850 | ; |
1847 | return; | 1851 | return; |
1848 | } | 1852 | } |
1849 | 1853 | ||
1850 | int cellX,cellYTop,cellYBottom; | 1854 | int cellX,cellYTop,cellYBottom; |
1851 | QString newtext; | 1855 | QString newtext; |
1852 | int width = XEnd - XBegin + 1; | 1856 | int width = XEnd - XBegin + 1; |
1853 | int count = 0; | 1857 | int count = 0; |
1854 | KOAgendaItem *current = 0; | 1858 | KOAgendaItem *current = 0; |
1855 | QPtrList<KOAgendaItem> multiItems; | 1859 | QPtrList<KOAgendaItem> multiItems; |
1856 | for (cellX = XBegin;cellX <= XEnd;++cellX) { | 1860 | for (cellX = XBegin;cellX <= XEnd;++cellX) { |
1857 | if (cellX == XBegin) cellYTop = YTop; | 1861 | if (cellX == XBegin) cellYTop = YTop; |
1858 | else cellYTop = 0; | 1862 | else cellYTop = 0; |
1859 | if (cellX == XEnd) cellYBottom = YBottom; | 1863 | if (cellX == XEnd) cellYBottom = YBottom; |
1860 | else cellYBottom = rows() - 1; | 1864 | else cellYBottom = rows() - 1; |
1861 | newtext = QString("(%1/%2): ").arg(++count).arg(width); | 1865 | newtext = QString("(%1/%2): ").arg(++count).arg(width); |
1862 | newtext.append(event->summary()); | 1866 | newtext.append(event->summary()); |
1863 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); | 1867 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); |
1864 | current->setText(newtext); | 1868 | current->setText(newtext); |
1865 | multiItems.append(current); | 1869 | multiItems.append(current); |
1866 | } | 1870 | } |
1867 | 1871 | ||
1868 | KOAgendaItem *next = 0; | 1872 | KOAgendaItem *next = 0; |
1869 | KOAgendaItem *last = multiItems.last(); | 1873 | KOAgendaItem *last = multiItems.last(); |
1870 | KOAgendaItem *first = multiItems.first(); | 1874 | KOAgendaItem *first = multiItems.first(); |
1871 | KOAgendaItem *setFirst,*setLast; | 1875 | KOAgendaItem *setFirst,*setLast; |
1872 | current = first; | 1876 | current = first; |
1873 | while (current) { | 1877 | while (current) { |
1874 | next = multiItems.next(); | 1878 | next = multiItems.next(); |
1875 | if (current == first) setFirst = 0; | 1879 | if (current == first) setFirst = 0; |
1876 | else setFirst = first; | 1880 | else setFirst = first; |
1877 | if (current == last) setLast = 0; | 1881 | if (current == last) setLast = 0; |
1878 | else setLast = last; | 1882 | else setLast = last; |
1879 | 1883 | ||
1880 | current->setMultiItem(setFirst,next,setLast); | 1884 | current->setMultiItem(setFirst,next,setLast); |
1881 | current = next; | 1885 | current = next; |
1882 | } | 1886 | } |
1883 | } | 1887 | } |
1884 | 1888 | ||
1885 | 1889 | ||
1886 | //QSizePolicy KOAgenda::sizePolicy() const | 1890 | //QSizePolicy KOAgenda::sizePolicy() const |
1887 | //{ | 1891 | //{ |
1888 | // Thought this would make the all-day event agenda minimum size and the | 1892 | // Thought this would make the all-day event agenda minimum size and the |
1889 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter | 1893 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter |
1890 | // don´t seem to think that an Expanding widget needs more space than a | 1894 | // don´t seem to think that an Expanding widget needs more space than a |
1891 | // Preferred one. | 1895 | // Preferred one. |
1892 | // But it doesn´t hurt, so it stays. | 1896 | // But it doesn´t hurt, so it stays. |
1893 | // if (mAllDayMode) { | 1897 | // if (mAllDayMode) { |
1894 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); | 1898 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); |
1895 | // } else { | 1899 | // } else { |
1896 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); | 1900 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); |
1897 | // } | 1901 | // } |
1898 | //} | 1902 | //} |
1899 | void KOAgenda::finishResize ( ) | 1903 | void KOAgenda::finishResize ( ) |
1900 | { | 1904 | { |
1901 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); | 1905 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); |
1902 | if ( globalFlagBlockAgenda == 0 ) { | 1906 | if ( globalFlagBlockAgenda == 0 ) { |
1903 | finishUpdate(); | 1907 | finishUpdate(); |
1904 | //qDebug("finishUpdate() called "); | 1908 | //qDebug("finishUpdate() called "); |
1905 | } | 1909 | } |
1906 | } | 1910 | } |
1907 | /* | 1911 | /* |
1908 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. | 1912 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. |
1909 | */ | 1913 | */ |
1910 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) | 1914 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) |
1911 | { | 1915 | { |
1912 | mSelectionHeight = 0; | 1916 | mSelectionHeight = 0; |
1913 | mResizeTimer.start( 150 , true ); | 1917 | mResizeTimer.start( 150 , true ); |
1914 | computeSizes(); | 1918 | computeSizes(); |
1915 | return; | 1919 | return; |
1916 | 1920 | ||
1917 | } | 1921 | } |
1918 | void KOAgenda::computeSizes() | 1922 | void KOAgenda::computeSizes() |
1919 | { | 1923 | { |
1920 | if ( globalFlagBlockStartup ) | 1924 | if ( globalFlagBlockStartup ) |
1921 | return; | 1925 | return; |
1922 | int frameOffset = frameWidth() * 2 +1; | 1926 | int frameOffset = frameWidth() * 2 +1; |
1923 | if (mAllDayMode) { | 1927 | if (mAllDayMode) { |
1924 | mGridSpacingX = (width()-frameOffset) / mColumns; | 1928 | mGridSpacingX = (width()-frameOffset) / mColumns; |
1925 | mGridSpacingY = height() - 2 * frameWidth() - 1; | 1929 | mGridSpacingY = height() - 2 * frameWidth() - 1; |
1926 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); | 1930 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); |
1927 | // mGridSpacingY = height(); | 1931 | // mGridSpacingY = height(); |
1928 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1932 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1929 | 1933 | ||
1930 | KOAgendaItem *item; | 1934 | KOAgendaItem *item; |
1931 | int subCellWidth; | 1935 | int subCellWidth; |
1932 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1936 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1933 | subCellWidth = mGridSpacingY / item->subCells(); | 1937 | subCellWidth = mGridSpacingY / item->subCells(); |
1934 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); | 1938 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); |
1935 | moveChild(item,KOGlobals::self()->reverseLayout() ? | 1939 | moveChild(item,KOGlobals::self()->reverseLayout() ? |
1936 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1940 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1937 | item->cellX() * mGridSpacingX, | 1941 | item->cellX() * mGridSpacingX, |
1938 | item->subCell() * subCellWidth); | 1942 | item->subCell() * subCellWidth); |
1939 | } | 1943 | } |
1940 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; | 1944 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; |
1941 | } else { | 1945 | } else { |
1942 | mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; | 1946 | mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; |
1943 | if (height() > mGridSpacingY * mRows + 1 ) { | 1947 | if (height() > mGridSpacingY * mRows + 1 ) { |
1944 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; | 1948 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; |
1945 | mGridSpacingY = KOPrefs::instance()->mHourSize ; | 1949 | mGridSpacingY = KOPrefs::instance()->mHourSize ; |
1946 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1950 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1947 | emit resizedSignal(); | 1951 | emit resizedSignal(); |
1948 | } else | 1952 | } else |
1949 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1953 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1950 | KOAgendaItem *item; | 1954 | KOAgendaItem *item; |
1951 | int subCellWidth; | 1955 | int subCellWidth; |
1952 | 1956 | ||
1953 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1957 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1954 | subCellWidth = mGridSpacingX / item->subCells(); | 1958 | subCellWidth = mGridSpacingX / item->subCells(); |
1955 | item->resize(subCellWidth,item->height()); | 1959 | item->resize(subCellWidth,item->height()); |
1956 | moveChild(item,(KOGlobals::self()->reverseLayout() ? | 1960 | moveChild(item,(KOGlobals::self()->reverseLayout() ? |
1957 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1961 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1958 | item->cellX() * mGridSpacingX) + | 1962 | item->cellX() * mGridSpacingX) + |
1959 | item->subCell() * subCellWidth,childY(item)); | 1963 | item->subCell() * subCellWidth,childY(item)); |
1960 | } | 1964 | } |
1961 | } | 1965 | } |
1962 | int cw = contentsWidth(); | 1966 | int cw = contentsWidth(); |
1963 | int ch = contentsHeight(); | 1967 | int ch = contentsHeight(); |
1964 | if ( mAllDayMode ) { | 1968 | if ( mAllDayMode ) { |
1965 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); | 1969 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); |
1966 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) { | 1970 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) { |
1967 | //qDebug("paintPixAll->resize "); | 1971 | //qDebug("paintPixAll->resize "); |
1968 | paintPixAll->resize( cw, ch ); | 1972 | paintPixAll->resize( cw, ch ); |
1969 | } | 1973 | } |
1970 | } else { | 1974 | } else { |
1971 | QPixmap* paintPix = KOAgendaItem::paintPix(); | 1975 | QPixmap* paintPix = KOAgendaItem::paintPix(); |
1972 | if ( paintPix->width() < cw || paintPix->height() < ch ) { | 1976 | if ( paintPix->width() < cw || paintPix->height() < ch ) { |
1973 | //qDebug("paintPix->resize "); | 1977 | //qDebug("paintPix->resize "); |
1974 | paintPix->resize( cw , ch ); | 1978 | paintPix->resize( cw , ch ); |
1975 | } | 1979 | } |
1976 | } | 1980 | } |
1977 | 1981 | ||
1978 | checkScrollBoundaries(); | 1982 | checkScrollBoundaries(); |
1979 | drawContentsToPainter(); | 1983 | drawContentsToPainter(); |
1980 | viewport()->repaint(false); | 1984 | viewport()->repaint(false); |
1981 | } | 1985 | } |
1982 | 1986 | ||
1983 | void KOAgenda::scrollUp() | 1987 | void KOAgenda::scrollUp() |
1984 | { | 1988 | { |
1985 | scrollBy(0,-mScrollOffset); | 1989 | scrollBy(0,-mScrollOffset); |
1986 | } | 1990 | } |
1987 | 1991 | ||
1988 | 1992 | ||
1989 | void KOAgenda::scrollDown() | 1993 | void KOAgenda::scrollDown() |
1990 | { | 1994 | { |
1991 | scrollBy(0,mScrollOffset); | 1995 | scrollBy(0,mScrollOffset); |
1992 | } | 1996 | } |
1993 | 1997 | ||
1994 | void KOAgenda::popupAlarm() | 1998 | void KOAgenda::popupAlarm() |
1995 | { | 1999 | { |
1996 | if (!mClickedItem) { | 2000 | if (!mClickedItem) { |
1997 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); | 2001 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); |
1998 | return; | 2002 | return; |
1999 | } | 2003 | } |
2000 | // TODO: deal correctly with multiple alarms | 2004 | // TODO: deal correctly with multiple alarms |
2001 | Alarm* alarm; | 2005 | Alarm* alarm; |
2002 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); | 2006 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); |
2003 | for(alarm=list.first();alarm;alarm=list.next()) { | 2007 | for(alarm=list.first();alarm;alarm=list.next()) { |
2004 | alarm->toggleAlarm(); | 2008 | alarm->toggleAlarm(); |
2005 | } | 2009 | } |
2006 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); | 2010 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); |
2007 | mClickedItem->paintMe( true ); | 2011 | mClickedItem->paintMe( true ); |
2008 | mClickedItem->repaint( false ); | 2012 | mClickedItem->repaint( false ); |
2009 | } | 2013 | } |
2010 | 2014 | ||
2011 | /* | 2015 | /* |
2012 | Calculates the minimum width | 2016 | Calculates the minimum width |
2013 | */ | 2017 | */ |
2014 | int KOAgenda::minimumWidth() const | 2018 | int KOAgenda::minimumWidth() const |
2015 | { | 2019 | { |
2016 | // TODO:: develop a way to dynamically determine the minimum width | 2020 | // TODO:: develop a way to dynamically determine the minimum width |
2017 | int min = 100; | 2021 | int min = 100; |
2018 | 2022 | ||
2019 | return min; | 2023 | return min; |
2020 | } | 2024 | } |
2021 | 2025 | ||
2022 | void KOAgenda::updateConfig() | 2026 | void KOAgenda::updateConfig() |
2023 | { | 2027 | { |
2024 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) | 2028 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) |
2025 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); | 2029 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); |
2026 | if ( mAllDayMode ) { | 2030 | if ( mAllDayMode ) { |
2027 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; | 2031 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; |
2028 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 2032 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
2029 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); | 2033 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); |
2030 | // setMaximumHeight( mGridSpacingY+1 ); | 2034 | // setMaximumHeight( mGridSpacingY+1 ); |
2031 | viewport()->repaint( false ); | 2035 | viewport()->repaint( false ); |
2032 | //setFixedHeight( mGridSpacingY+1 ); | 2036 | //setFixedHeight( mGridSpacingY+1 ); |
2033 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); | 2037 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); |
2034 | } | 2038 | } |
2035 | else { | 2039 | else { |
2036 | mGridSpacingY = KOPrefs::instance()->mHourSize; | 2040 | mGridSpacingY = KOPrefs::instance()->mHourSize; |
2037 | calculateWorkingHours(); | 2041 | calculateWorkingHours(); |
2038 | } | 2042 | } |
2039 | } | 2043 | } |
2040 | 2044 | ||
2041 | void KOAgenda::checkScrollBoundaries() | 2045 | void KOAgenda::checkScrollBoundaries() |
2042 | { | 2046 | { |
2043 | // Invalidate old values to force update | 2047 | // Invalidate old values to force update |
2044 | mOldLowerScrollValue = -1; | 2048 | mOldLowerScrollValue = -1; |
2045 | mOldUpperScrollValue = -1; | 2049 | mOldUpperScrollValue = -1; |
2046 | 2050 | ||
2047 | checkScrollBoundaries(verticalScrollBar()->value()); | 2051 | checkScrollBoundaries(verticalScrollBar()->value()); |
2048 | } | 2052 | } |
2049 | 2053 | ||
2050 | void KOAgenda::checkScrollBoundaries(int v) | 2054 | void KOAgenda::checkScrollBoundaries(int v) |
2051 | { | 2055 | { |
2052 | if ( mGridSpacingY == 0 ) | 2056 | if ( mGridSpacingY == 0 ) |
2053 | return; | 2057 | return; |
2054 | int yMin = v/mGridSpacingY; | 2058 | int yMin = v/mGridSpacingY; |
2055 | int yMax = (v+visibleHeight())/mGridSpacingY; | 2059 | int yMax = (v+visibleHeight())/mGridSpacingY; |
2056 | 2060 | ||
2057 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; | 2061 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; |
2058 | 2062 | ||
2059 | if (yMin != mOldLowerScrollValue) { | 2063 | if (yMin != mOldLowerScrollValue) { |
2060 | mOldLowerScrollValue = yMin; | 2064 | mOldLowerScrollValue = yMin; |
2061 | emit lowerYChanged(yMin); | 2065 | emit lowerYChanged(yMin); |
2062 | } | 2066 | } |
2063 | if (yMax != mOldUpperScrollValue) { | 2067 | if (yMax != mOldUpperScrollValue) { |
2064 | mOldUpperScrollValue = yMax; | 2068 | mOldUpperScrollValue = yMax; |
2065 | emit upperYChanged(yMax); | 2069 | emit upperYChanged(yMax); |
2066 | } | 2070 | } |
2067 | } | 2071 | } |
2068 | 2072 | ||
2069 | void KOAgenda::deselectItem() | 2073 | void KOAgenda::deselectItem() |
2070 | { | 2074 | { |
2071 | if (mSelectedItem.isNull()) return; | 2075 | if (mSelectedItem.isNull()) return; |
2072 | mSelectedItem->select(false); | 2076 | mSelectedItem->select(false); |
2073 | mSelectedItem = 0; | 2077 | mSelectedItem = 0; |
2074 | } | 2078 | } |
2075 | 2079 | ||
2076 | void KOAgenda::selectItem(KOAgendaItem *item) | 2080 | void KOAgenda::selectItem(KOAgendaItem *item) |
2077 | { | 2081 | { |
2078 | if ((KOAgendaItem *)mSelectedItem == item) return; | 2082 | if ((KOAgendaItem *)mSelectedItem == item) return; |
2079 | deselectItem(); | 2083 | deselectItem(); |
2080 | if (item == 0) { | 2084 | if (item == 0) { |
2081 | emit incidenceSelected( 0 ); | 2085 | emit incidenceSelected( 0 ); |
2082 | return; | 2086 | return; |
2083 | } | 2087 | } |
2084 | mSelectedItem = item; | 2088 | mSelectedItem = item; |
2085 | mSelectedItem->select(); | 2089 | mSelectedItem->select(); |
2086 | emit incidenceSelected( mSelectedItem->incidence() ); | 2090 | emit incidenceSelected( mSelectedItem->incidence() ); |
2087 | } | 2091 | } |
2088 | 2092 | ||
2089 | // This function seems never be called. | 2093 | // This function seems never be called. |
2090 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) | 2094 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) |
2091 | { | 2095 | { |
2092 | switch(kev->key()) { | 2096 | switch(kev->key()) { |
2093 | case Key_PageDown: | 2097 | case Key_PageDown: |
2094 | verticalScrollBar()->addPage(); | 2098 | verticalScrollBar()->addPage(); |
2095 | break; | 2099 | break; |
2096 | case Key_PageUp: | 2100 | case Key_PageUp: |
2097 | verticalScrollBar()->subtractPage(); | 2101 | verticalScrollBar()->subtractPage(); |
2098 | break; | 2102 | break; |
2099 | case Key_Down: | 2103 | case Key_Down: |
2100 | verticalScrollBar()->addLine(); | 2104 | verticalScrollBar()->addLine(); |
2101 | break; | 2105 | break; |
2102 | case Key_Up: | 2106 | case Key_Up: |
2103 | verticalScrollBar()->subtractLine(); | 2107 | verticalScrollBar()->subtractLine(); |
2104 | break; | 2108 | break; |
2105 | default: | 2109 | default: |
2106 | ; | 2110 | ; |
2107 | } | 2111 | } |
2108 | } | 2112 | } |
2109 | 2113 | ||
2110 | void KOAgenda::calculateWorkingHours() | 2114 | void KOAgenda::calculateWorkingHours() |
2111 | { | 2115 | { |
2112 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; | 2116 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; |
2113 | mWorkingHoursEnable = !mAllDayMode; | 2117 | mWorkingHoursEnable = !mAllDayMode; |
2114 | 2118 | ||
2115 | mWorkingHoursYTop = mGridSpacingY * | 2119 | mWorkingHoursYTop = mGridSpacingY * |
2116 | KOPrefs::instance()->mWorkingHoursStart * 4; | 2120 | KOPrefs::instance()->mWorkingHoursStart * 4; |
2117 | mWorkingHoursYBottom = mGridSpacingY * | 2121 | mWorkingHoursYBottom = mGridSpacingY * |
2118 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; | 2122 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; |
2119 | } | 2123 | } |
2120 | 2124 | ||
2121 | 2125 | ||
2122 | DateList KOAgenda::dateList() const | 2126 | DateList KOAgenda::dateList() const |
2123 | { | 2127 | { |
2124 | return mSelectedDates; | 2128 | return mSelectedDates; |
2125 | } | 2129 | } |
2126 | 2130 | ||
2127 | void KOAgenda::setDateList(const DateList &selectedDates) | 2131 | void KOAgenda::setDateList(const DateList &selectedDates) |
2128 | { | 2132 | { |
2129 | mSelectedDates = selectedDates; | 2133 | mSelectedDates = selectedDates; |
2130 | } | 2134 | } |
2131 | 2135 | ||
2132 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) | 2136 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) |
2133 | { | 2137 | { |
2134 | mHolidayMask = mask; | 2138 | mHolidayMask = mask; |
2135 | 2139 | ||
2136 | /* | 2140 | /* |
2137 | kdDebug() << "HolidayMask: "; | 2141 | kdDebug() << "HolidayMask: "; |
2138 | for(uint i=0;i<mask->count();++i) { | 2142 | for(uint i=0;i<mask->count();++i) { |
2139 | kdDebug() << (mask->at(i) ? "*" : "o"); | 2143 | kdDebug() << (mask->at(i) ? "*" : "o"); |
2140 | } | 2144 | } |
2141 | kdDebug() << endl; | 2145 | kdDebug() << endl; |
2142 | */ | 2146 | */ |
2143 | } | 2147 | } |
2144 | 2148 | ||
2145 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) | 2149 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) |
2146 | { | 2150 | { |
2147 | 2151 | ||
2148 | QScrollView::contentsMousePressEvent(event); | 2152 | QScrollView::contentsMousePressEvent(event); |
2149 | } | 2153 | } |
2150 | 2154 | ||
2151 | void KOAgenda::storePosition() | 2155 | void KOAgenda::storePosition() |
2152 | { | 2156 | { |
2153 | //mContentPosition | 2157 | //mContentPosition |
2154 | int max = mGridSpacingY*4*24; | 2158 | int max = mGridSpacingY*4*24; |
2155 | if ( contentsY() < 5 && max > viewport()->height()*3/2 ) | 2159 | if ( contentsY() < 5 && max > viewport()->height()*3/2 ) |
2156 | mContentPosition = 0; | 2160 | mContentPosition = 0; |
2157 | else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) | 2161 | else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) |
2158 | mContentPosition = -1.0; | 2162 | mContentPosition = -1.0; |
2159 | else | 2163 | else |
2160 | mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); | 2164 | mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); |
2161 | //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); | 2165 | //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); |
2162 | 2166 | ||
2163 | } | 2167 | } |
2164 | void KOAgenda::restorePosition() | 2168 | void KOAgenda::restorePosition() |
2165 | { | 2169 | { |
2166 | int posY; | 2170 | int posY; |
2167 | int max = mGridSpacingY*4*24; | 2171 | int max = mGridSpacingY*4*24; |
2168 | if ( mContentPosition < 0 ) | 2172 | if ( mContentPosition < 0 ) |
2169 | posY = max-viewport()->height(); | 2173 | posY = max-viewport()->height(); |
2170 | else | 2174 | else |
2171 | if ( mContentPosition == 0 ) | 2175 | if ( mContentPosition == 0 ) |
2172 | posY = 0; | 2176 | posY = 0; |
2173 | else | 2177 | else |
2174 | posY = (max/mContentPosition)-(viewport()->height()/2); | 2178 | posY = (max/mContentPosition)-(viewport()->height()/2); |
2175 | setContentsPos (0, posY ); | 2179 | setContentsPos (0, posY ); |
2176 | //qDebug("posY %d hei %d", posY, max); | 2180 | //qDebug("posY %d hei %d", posY, max); |
2177 | 2181 | ||
2178 | } | 2182 | } |
2179 | void KOAgenda::moveChild( QWidget *w, int x , int y ) | 2183 | void KOAgenda::moveChild( QWidget *w, int x , int y ) |
2180 | { | 2184 | { |
2181 | ++x; | 2185 | ++x; |
2182 | QScrollView::moveChild( w, x , y ); | 2186 | QScrollView::moveChild( w, x , y ); |
2183 | } | 2187 | } |
2184 | #include <qmessagebox.h> | 2188 | #include <qmessagebox.h> |
2185 | #ifdef DESKTOP_VERSION | 2189 | #ifdef DESKTOP_VERSION |
2186 | #include <qprinter.h> | 2190 | #include <qprinter.h> |
2187 | #include <qpainter.h> | 2191 | #include <qpainter.h> |
2188 | #include <qpaintdevicemetrics.h> | 2192 | #include <qpaintdevicemetrics.h> |
2189 | 2193 | ||
2190 | #endif | 2194 | #endif |
2191 | void KOAgenda::printSelection() | 2195 | void KOAgenda::printSelection() |
2192 | { | 2196 | { |
2193 | #ifdef DESKTOP_VERSION | 2197 | #ifdef DESKTOP_VERSION |
2194 | if ( mStartCellY == mCurrentCellY ) { | 2198 | if ( mStartCellY == mCurrentCellY ) { |
2195 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2199 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2196 | i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), | 2200 | i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), |
2197 | i18n("OK"), 0, 0, | 2201 | i18n("OK"), 0, 0, |
2198 | 0, 1 ); | 2202 | 0, 1 ); |
2199 | return; | 2203 | return; |
2200 | } | 2204 | } |
2201 | 2205 | ||
2202 | float dx, dy; | 2206 | float dx, dy; |
2203 | int x,y,w,h; | 2207 | int x,y,w,h; |
2204 | x= 0; | 2208 | x= 0; |
2205 | w= contentsWidth()+2; | 2209 | w= contentsWidth()+2; |
2206 | // h= contentsHeight(); | 2210 | // h= contentsHeight(); |
2207 | y = mGridSpacingY*mStartCellY; | 2211 | y = mGridSpacingY*mStartCellY; |
2208 | h = mGridSpacingY*(mCurrentCellY+1)-y+2; | 2212 | h = mGridSpacingY*(mCurrentCellY+1)-y+2; |
2209 | 2213 | ||
2210 | //return; | 2214 | //return; |
2211 | QPrinter* printer = new QPrinter(); | 2215 | QPrinter* printer = new QPrinter(); |
2212 | if ( !printer->setup()) { | 2216 | if ( !printer->setup()) { |
2213 | delete printer; | 2217 | delete printer; |
2214 | return; | 2218 | return; |
2215 | } | 2219 | } |
2216 | QPainter p( printer ); | 2220 | QPainter p( printer ); |
2217 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); | 2221 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); |
2218 | QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); | 2222 | QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); |
2219 | //date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); | 2223 | //date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); |
2220 | int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); | 2224 | int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); |
2221 | // p.drawText( 0, 0, date ); | 2225 | // p.drawText( 0, 0, date ); |
2222 | int offset = m.width()/8; | 2226 | int offset = m.width()/8; |
2223 | // compute the scale | 2227 | // compute the scale |
2224 | dx = ((float) m.width()-offset) / (float)w; | 2228 | dx = ((float) m.width()-offset) / (float)w; |
2225 | dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; | 2229 | dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; |
2226 | float scale; | 2230 | float scale; |
2227 | // scale to fit the width or height of the paper | 2231 | // scale to fit the width or height of the paper |
2228 | if ( dx < dy ) | 2232 | if ( dx < dy ) |
2229 | scale = dx; | 2233 | scale = dx; |
2230 | else | 2234 | else |
2231 | scale = dy; | 2235 | scale = dy; |
2232 | // set the scale | 2236 | // set the scale |
2233 | p.drawText( offset* scale, offset* scale*3/4, date ); | 2237 | p.drawText( offset* scale, offset* scale*3/4, date ); |
2234 | 2238 | ||
2235 | int selDay; | 2239 | int selDay; |
2236 | float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); | 2240 | float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); |
2237 | float startX = 1; | 2241 | float startX = 1; |
2238 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 2242 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
2239 | { | 2243 | { |
2240 | QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); | 2244 | QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); |
2241 | p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) ); | 2245 | p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) ); |
2242 | p.drawText( offset* scale+startX, (offset+hei)* scale, text ); | 2246 | p.drawText( offset* scale+startX, (offset+hei)* scale, text ); |
2243 | startX += widOffset; | 2247 | startX += widOffset; |
2244 | 2248 | ||
2245 | } | 2249 | } |
2246 | p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale)); | 2250 | p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale)); |
2247 | p.scale( scale, scale ); | 2251 | p.scale( scale, scale ); |
2248 | p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale ); | 2252 | p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale ); |
2249 | // now printing with y offset: 2 hei | 2253 | // now printing with y offset: 2 hei |
2250 | // p.translate( 0, -y*scale); | 2254 | // p.translate( 0, -y*scale); |
2251 | 2255 | ||
2252 | drawContentsToPainter(&p, true ); | 2256 | drawContentsToPainter(&p, true ); |
2253 | globalFlagBlockAgendaItemUpdate = false; | 2257 | globalFlagBlockAgendaItemUpdate = false; |
2254 | KOAgendaItem *item; | 2258 | KOAgendaItem *item; |
2255 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 2259 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
2256 | item->select(false); | 2260 | item->select(false); |
2257 | item->paintMe( false, &p ); | 2261 | item->paintMe( false, &p ); |
2258 | } | 2262 | } |
2259 | globalFlagBlockAgendaItemUpdate = true; | 2263 | globalFlagBlockAgendaItemUpdate = true; |
2260 | p.end(); | 2264 | p.end(); |
2261 | delete printer; | 2265 | delete printer; |
2262 | #else | 2266 | #else |
2263 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2267 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2264 | i18n("Not supported \non PDA!\n"), | 2268 | i18n("Not supported \non PDA!\n"), |
2265 | i18n("OK"), 0, 0, | 2269 | i18n("OK"), 0, 0, |
2266 | 0, 1 ); | 2270 | 0, 1 ); |
2267 | #endif | 2271 | #endif |
2268 | } | 2272 | } |
diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h index 86cf2f4..59e7472 100644 --- a/korganizer/koagenda.h +++ b/korganizer/koagenda.h | |||
@@ -1,307 +1,307 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 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 | #ifndef KOAGENDA_H | 23 | #ifndef KOAGENDA_H |
24 | #define KOAGENDA_H | 24 | #define KOAGENDA_H |
25 | 25 | ||
26 | #include <qscrollview.h> | 26 | #include <qscrollview.h> |
27 | #include <qtimer.h> | 27 | #include <qtimer.h> |
28 | #include <qmemarray.h> | 28 | #include <qmemarray.h> |
29 | #include <qpainter.h> | 29 | #include <qpainter.h> |
30 | #include <qpixmap.h> | 30 | #include <qpixmap.h> |
31 | #include <qguardedptr.h> | 31 | #include <qguardedptr.h> |
32 | 32 | ||
33 | #include "koagendaitem.h" | 33 | #include "koagendaitem.h" |
34 | #include "koeventview.h" | 34 | #include "koeventview.h" |
35 | 35 | ||
36 | class QPopupMenu; | 36 | class QPopupMenu; |
37 | class QTime; | 37 | class QTime; |
38 | class KConfig; | 38 | class KConfig; |
39 | class QFrame; | 39 | class QFrame; |
40 | class KOAgenda; | 40 | class KOAgenda; |
41 | class KCal::Event; | 41 | class KCal::Event; |
42 | class KCal::Todo; | 42 | class KCal::Todo; |
43 | 43 | ||
44 | using namespace KCal; | 44 | using namespace KCal; |
45 | 45 | ||
46 | class MarcusBains : public QFrame { | 46 | class MarcusBains : public QFrame { |
47 | Q_OBJECT | 47 | Q_OBJECT |
48 | public: | 48 | public: |
49 | MarcusBains(KOAgenda *agenda=0,const char *name=0); | 49 | MarcusBains(KOAgenda *agenda=0,const char *name=0); |
50 | virtual ~MarcusBains(); | 50 | virtual ~MarcusBains(); |
51 | 51 | void hideMe(); | |
52 | public slots: | 52 | public slots: |
53 | void updateLocation(bool recalculate=false); | 53 | void updateLocation(bool recalculate=false); |
54 | void updateLoc(); | 54 | void updateLoc(); |
55 | 55 | ||
56 | private: | 56 | private: |
57 | int todayColumn(); | 57 | int todayColumn(); |
58 | QTimer *minutes; | 58 | QTimer *minutes; |
59 | QLabel *mTimeBox; | 59 | QLabel *mTimeBox; |
60 | KOAgenda *agenda; | 60 | KOAgenda *agenda; |
61 | QTime oldTime; | 61 | QTime oldTime; |
62 | int oldToday; | 62 | int oldToday; |
63 | }; | 63 | }; |
64 | 64 | ||
65 | 65 | ||
66 | class KOAgenda : public QScrollView | 66 | class KOAgenda : public QScrollView |
67 | { | 67 | { |
68 | Q_OBJECT | 68 | Q_OBJECT |
69 | public: | 69 | public: |
70 | enum MouseActionType { NOP, MOVE, SELECT, | 70 | enum MouseActionType { NOP, MOVE, SELECT, |
71 | RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT }; | 71 | RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT }; |
72 | 72 | ||
73 | KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0, | 73 | KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0, |
74 | const char * name=0, WFlags f=0 ); | 74 | const char * name=0, WFlags f=0 ); |
75 | KOAgenda ( int columns, QWidget * parent=0, | 75 | KOAgenda ( int columns, QWidget * parent=0, |
76 | const char * name=0, WFlags f=0 ); | 76 | const char * name=0, WFlags f=0 ); |
77 | virtual ~KOAgenda(); | 77 | virtual ~KOAgenda(); |
78 | bool mInvalidPixmap; | 78 | bool mInvalidPixmap; |
79 | 79 | ||
80 | Incidence *selectedIncidence() const; | 80 | Incidence *selectedIncidence() const; |
81 | QDate selectedIncidenceDate() const; | 81 | QDate selectedIncidenceDate() const; |
82 | 82 | ||
83 | virtual bool eventFilter ( QObject *, QEvent * ); | 83 | virtual bool eventFilter ( QObject *, QEvent * ); |
84 | 84 | ||
85 | void contentsToGrid (int x, int y, int& gx, int& gy); | 85 | void contentsToGrid (int x, int y, int& gx, int& gy); |
86 | void gridToContents (int gx, int gy, int& x, int& y); | 86 | void gridToContents (int gx, int gy, int& x, int& y); |
87 | 87 | ||
88 | int timeToY (const QTime &time); | 88 | int timeToY (const QTime &time); |
89 | QTime gyToTime (int y); | 89 | QTime gyToTime (int y); |
90 | 90 | ||
91 | void setStartHour(int startHour); | 91 | void setStartHour(int startHour); |
92 | 92 | ||
93 | KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom); | 93 | KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom); |
94 | KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd); | 94 | KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd); |
95 | void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, | 95 | void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, |
96 | int YTop,int YBottom); | 96 | int YTop,int YBottom); |
97 | 97 | ||
98 | void changeColumns(int columns); | 98 | void changeColumns(int columns); |
99 | 99 | ||
100 | int columns() { return mColumns; } | 100 | int columns() { return mColumns; } |
101 | int rows() { return mRows; } | 101 | int rows() { return mRows; } |
102 | 102 | ||
103 | int gridSpacingX() const { return mGridSpacingX; } | 103 | int gridSpacingX() const { return mGridSpacingX; } |
104 | int gridSpacingY() const { return mGridSpacingY; } | 104 | int gridSpacingY() const { return mGridSpacingY; } |
105 | 105 | ||
106 | // virtual QSizePolicy sizePolicy() const; | 106 | // virtual QSizePolicy sizePolicy() const; |
107 | 107 | ||
108 | void clear(); | 108 | void clear(); |
109 | 109 | ||
110 | void clearSelection(); | 110 | void clearSelection(); |
111 | void hideUnused(); | 111 | void hideUnused(); |
112 | 112 | ||
113 | /** Calculates the minimum width */ | 113 | /** Calculates the minimum width */ |
114 | virtual int minimumWidth() const; | 114 | virtual int minimumWidth() const; |
115 | /** Update configuration from preference settings */ | 115 | /** Update configuration from preference settings */ |
116 | void updateConfig(); | 116 | void updateConfig(); |
117 | 117 | ||
118 | void checkScrollBoundaries(); | 118 | void checkScrollBoundaries(); |
119 | 119 | ||
120 | void setHolidayMask(QMemArray<bool> *); | 120 | void setHolidayMask(QMemArray<bool> *); |
121 | void setDateList(const DateList &selectedDates); | 121 | void setDateList(const DateList &selectedDates); |
122 | DateList dateList() const; | 122 | DateList dateList() const; |
123 | void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false); | 123 | void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false); |
124 | void finishUpdate(); | 124 | void finishUpdate(); |
125 | void printSelection(); | 125 | void printSelection(); |
126 | void storePosition(); | 126 | void storePosition(); |
127 | void restorePosition(); | 127 | void restorePosition(); |
128 | void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; } | 128 | void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; } |
129 | void shrinkPixmap(); | 129 | void shrinkPixmap(); |
130 | QTime getEndTime(); | 130 | QTime getEndTime(); |
131 | 131 | ||
132 | public slots: | 132 | public slots: |
133 | void slotContentMove(int,int); | 133 | void slotContentMove(int,int); |
134 | void categoryChanged(Incidence * inc); | 134 | void categoryChanged(Incidence * inc); |
135 | void slotClearSelection(); | 135 | void slotClearSelection(); |
136 | void popupMenu(); | 136 | void popupMenu(); |
137 | void newItem( int ); | 137 | void newItem( int ); |
138 | void moveChild( QWidget *, int, int ); | 138 | void moveChild( QWidget *, int, int ); |
139 | void scrollUp(); | 139 | void scrollUp(); |
140 | void scrollDown(); | 140 | void scrollDown(); |
141 | void updateTodo( Todo * t, int , bool ); | 141 | void updateTodo( Todo * t, int , bool ); |
142 | void popupAlarm(); | 142 | void popupAlarm(); |
143 | 143 | ||
144 | void checkScrollBoundaries(int); | 144 | void checkScrollBoundaries(int); |
145 | 145 | ||
146 | /** Deselect selected items. This function does not emit any signals. */ | 146 | /** Deselect selected items. This function does not emit any signals. */ |
147 | void deselectItem(); | 147 | void deselectItem(); |
148 | /** Select item. If the argument is 0, the currently selected item gets | 148 | /** Select item. If the argument is 0, the currently selected item gets |
149 | deselected. This function emits the itemSelected(bool) signal to inform | 149 | deselected. This function emits the itemSelected(bool) signal to inform |
150 | about selection/deseelction of events. */ | 150 | about selection/deseelction of events. */ |
151 | void selectItem(KOAgendaItem *); | 151 | void selectItem(KOAgendaItem *); |
152 | void finishResize(); | 152 | void finishResize(); |
153 | 153 | ||
154 | signals: | 154 | signals: |
155 | void signalClearSelection(); | 155 | void signalClearSelection(); |
156 | void showDateView( int, int); | 156 | void showDateView( int, int); |
157 | void newEventSignal(); | 157 | void newEventSignal(); |
158 | void newEventSignal(int gx,int gy); | 158 | void newEventSignal(int gx,int gy); |
159 | void newTodoSignal(int gx,int gy); | 159 | void newTodoSignal(int gx,int gy); |
160 | void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); | 160 | void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); |
161 | void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); | 161 | void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); |
162 | void newStartSelectSignal(); | 162 | void newStartSelectSignal(); |
163 | void showIncidenceSignal(Incidence *); | 163 | void showIncidenceSignal(Incidence *); |
164 | void editIncidenceSignal(Incidence *); | 164 | void editIncidenceSignal(Incidence *); |
165 | void deleteIncidenceSignal(Incidence *); | 165 | void deleteIncidenceSignal(Incidence *); |
166 | void showIncidencePopupSignal(Incidence *); | 166 | void showIncidencePopupSignal(Incidence *); |
167 | 167 | ||
168 | void itemModified(KOAgendaItem *item, int ); | 168 | void itemModified(KOAgendaItem *item, int ); |
169 | void incidenceSelected(Incidence *); | 169 | void incidenceSelected(Incidence *); |
170 | 170 | ||
171 | void lowerYChanged(int); | 171 | void lowerYChanged(int); |
172 | void upperYChanged(int); | 172 | void upperYChanged(int); |
173 | 173 | ||
174 | void startDragSignal(Incidence *); | 174 | void startDragSignal(Incidence *); |
175 | void addToCalSignal(Incidence *, Incidence *); | 175 | void addToCalSignal(Incidence *, Incidence *); |
176 | void resizedSignal(); | 176 | void resizedSignal(); |
177 | void updateViewSignal(); | 177 | void updateViewSignal(); |
178 | void sendPing(); | 178 | void sendPing(); |
179 | 179 | ||
180 | protected: | 180 | protected: |
181 | KOEventPopupMenu * mAllAgendaPopup; | 181 | KOEventPopupMenu * mAllAgendaPopup; |
182 | QPainter mPixPainter; | 182 | QPainter mPixPainter; |
183 | QPixmap mPaintPixmap; | 183 | QPixmap mPaintPixmap; |
184 | QPixmap mHighlightPixmap; | 184 | QPixmap mHighlightPixmap; |
185 | void drawContents(QPainter *p,int cx, int cy, int cw, int ch); | 185 | void drawContents(QPainter *p,int cx, int cy, int cw, int ch); |
186 | virtual void resizeEvent ( QResizeEvent * ); | 186 | virtual void resizeEvent ( QResizeEvent * ); |
187 | 187 | ||
188 | /** Handles mouse events. Called from eventFilter */ | 188 | /** Handles mouse events. Called from eventFilter */ |
189 | virtual bool eventFilter_mouse ( QObject *, QMouseEvent * ); | 189 | virtual bool eventFilter_mouse ( QObject *, QMouseEvent * ); |
190 | 190 | ||
191 | /** Start selecting time span. */ | 191 | /** Start selecting time span. */ |
192 | void startSelectAction(QPoint viewportPos); | 192 | void startSelectAction(QPoint viewportPos); |
193 | 193 | ||
194 | /** Select time span. */ | 194 | /** Select time span. */ |
195 | void performSelectAction(QPoint viewportPos); | 195 | void performSelectAction(QPoint viewportPos); |
196 | 196 | ||
197 | /** Emd selecting time span. */ | 197 | /** Emd selecting time span. */ |
198 | void endSelectAction( bool emitNewEvent = false ); | 198 | void endSelectAction( bool emitNewEvent = false ); |
199 | 199 | ||
200 | /** Start moving/resizing agenda item */ | 200 | /** Start moving/resizing agenda item */ |
201 | void startItemAction(QPoint viewportPos); | 201 | void startItemAction(QPoint viewportPos); |
202 | 202 | ||
203 | /** Move/resize agenda item */ | 203 | /** Move/resize agenda item */ |
204 | void performItemAction(QPoint viewportPos); | 204 | void performItemAction(QPoint viewportPos); |
205 | 205 | ||
206 | /** End moving/resizing agenda item */ | 206 | /** End moving/resizing agenda item */ |
207 | void endItemAction(); | 207 | void endItemAction(); |
208 | 208 | ||
209 | /** Set cursor, when no item action is in progress */ | 209 | /** Set cursor, when no item action is in progress */ |
210 | void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos); | 210 | void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos); |
211 | 211 | ||
212 | /** Place agenda item in agenda and adjust other cells if necessary */ | 212 | /** Place agenda item in agenda and adjust other cells if necessary */ |
213 | void placeSubCells(KOAgendaItem *placeItem); | 213 | void placeSubCells(KOAgendaItem *placeItem); |
214 | 214 | ||
215 | /** Process the keyevent, including the ignored keyevents of eventwidgets. | 215 | /** Process the keyevent, including the ignored keyevents of eventwidgets. |
216 | * Implements pgup/pgdn and cursor key navigation in the view. | 216 | * Implements pgup/pgdn and cursor key navigation in the view. |
217 | */ | 217 | */ |
218 | void keyPressEvent( QKeyEvent * ); | 218 | void keyPressEvent( QKeyEvent * ); |
219 | 219 | ||
220 | void calculateWorkingHours(); | 220 | void calculateWorkingHours(); |
221 | 221 | ||
222 | virtual void contentsMousePressEvent ( QMouseEvent * ); | 222 | virtual void contentsMousePressEvent ( QMouseEvent * ); |
223 | 223 | ||
224 | private: | 224 | private: |
225 | void init(); | 225 | void init(); |
226 | void marcus_bains(); | 226 | void marcus_bains(); |
227 | bool mAllDayMode; | 227 | bool mAllDayMode; |
228 | bool blockResize; | 228 | bool blockResize; |
229 | bool mLeftMouseDown; | 229 | bool mLeftMouseDown; |
230 | KOAgendaItem *mPopupItem; | 230 | KOAgendaItem *mPopupItem; |
231 | QTimer* mPopupTimer; | 231 | QTimer* mPopupTimer; |
232 | int mPopupKind; | 232 | int mPopupKind; |
233 | QPoint mPopupPos; | 233 | QPoint mPopupPos; |
234 | QTimer mResizeTimer; | 234 | QTimer mResizeTimer; |
235 | double mContentPosition; | 235 | double mContentPosition; |
236 | 236 | ||
237 | // Width and height of agenda cells | 237 | // Width and height of agenda cells |
238 | int mGridSpacingX; | 238 | int mGridSpacingX; |
239 | int mGridSpacingY; | 239 | int mGridSpacingY; |
240 | 240 | ||
241 | // size of border, where mouse action will resize the KOAgendaItem | 241 | // size of border, where mouse action will resize the KOAgendaItem |
242 | int mResizeBorderWidth; | 242 | int mResizeBorderWidth; |
243 | 243 | ||
244 | // size of border, where mouse mve will cause a scroll of the agenda | 244 | // size of border, where mouse mve will cause a scroll of the agenda |
245 | int mScrollBorderWidth; | 245 | int mScrollBorderWidth; |
246 | int mScrollDelay; | 246 | int mScrollDelay; |
247 | int mScrollOffset; | 247 | int mScrollOffset; |
248 | 248 | ||
249 | QTimer mScrollUpTimer; | 249 | QTimer mScrollUpTimer; |
250 | QTimer mScrollDownTimer; | 250 | QTimer mScrollDownTimer; |
251 | 251 | ||
252 | // Number of Columns/Rows of agenda grid | 252 | // Number of Columns/Rows of agenda grid |
253 | int mColumns; | 253 | int mColumns; |
254 | int mRows; | 254 | int mRows; |
255 | 255 | ||
256 | // Cells to store Move and Resize coordiantes | 256 | // Cells to store Move and Resize coordiantes |
257 | int mStartCellX; | 257 | int mStartCellX; |
258 | int mStartCellY; | 258 | int mStartCellY; |
259 | int mCurrentCellX; | 259 | int mCurrentCellX; |
260 | int mCurrentCellY; | 260 | int mCurrentCellY; |
261 | 261 | ||
262 | // Working Hour coordiantes | 262 | // Working Hour coordiantes |
263 | bool mWorkingHoursEnable; | 263 | bool mWorkingHoursEnable; |
264 | int mWorkingHoursYTop; | 264 | int mWorkingHoursYTop; |
265 | int mWorkingHoursYBottom; | 265 | int mWorkingHoursYBottom; |
266 | 266 | ||
267 | // Selection | 267 | // Selection |
268 | int mSelectionCellX; | 268 | int mSelectionCellX; |
269 | int mSelectionYTop; | 269 | int mSelectionYTop; |
270 | int mSelectionHeight; | 270 | int mSelectionHeight; |
271 | 271 | ||
272 | // List of dates to be displayed | 272 | // List of dates to be displayed |
273 | DateList mSelectedDates; | 273 | DateList mSelectedDates; |
274 | 274 | ||
275 | // The KOAgendaItem, which has been right-clicked last | 275 | // The KOAgendaItem, which has been right-clicked last |
276 | KOAgendaItem *mClickedItem; | 276 | KOAgendaItem *mClickedItem; |
277 | 277 | ||
278 | // The KOAgendaItem, which is being moved/resized | 278 | // The KOAgendaItem, which is being moved/resized |
279 | QGuardedPtr<KOAgendaItem> mActionItem; | 279 | QGuardedPtr<KOAgendaItem> mActionItem; |
280 | 280 | ||
281 | // Currently selected item | 281 | // Currently selected item |
282 | QGuardedPtr<KOAgendaItem> mSelectedItem; | 282 | QGuardedPtr<KOAgendaItem> mSelectedItem; |
283 | 283 | ||
284 | // The Marcus Bains Line widget. | 284 | // The Marcus Bains Line widget. |
285 | MarcusBains *mMarcusBains; | 285 | MarcusBains *mMarcusBains; |
286 | void computeSizes(); | 286 | void computeSizes(); |
287 | 287 | ||
288 | MouseActionType mActionType; | 288 | MouseActionType mActionType; |
289 | 289 | ||
290 | bool mItemMoved; | 290 | bool mItemMoved; |
291 | 291 | ||
292 | // List of all Items contained in agenda | 292 | // List of all Items contained in agenda |
293 | QPtrList<KOAgendaItem> mItems; | 293 | QPtrList<KOAgendaItem> mItems; |
294 | QPtrList<KOAgendaItem> mUnusedItems; | 294 | QPtrList<KOAgendaItem> mUnusedItems; |
295 | KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport); | 295 | KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport); |
296 | QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems | 296 | QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems |
297 | QPopupMenu *mNewItemPopup; | 297 | QPopupMenu *mNewItemPopup; |
298 | 298 | ||
299 | int mOldLowerScrollValue; | 299 | int mOldLowerScrollValue; |
300 | int mOldUpperScrollValue; | 300 | int mOldUpperScrollValue; |
301 | KOAgendaItem * getItemForTodo ( Todo * todo ); | 301 | KOAgendaItem * getItemForTodo ( Todo * todo ); |
302 | QMemArray<bool> *mHolidayMask; | 302 | QMemArray<bool> *mHolidayMask; |
303 | int mCurPixWid; | 303 | int mCurPixWid; |
304 | int mCurPixHei; | 304 | int mCurPixHei; |
305 | }; | 305 | }; |
306 | 306 | ||
307 | #endif // KOAGENDA_H | 307 | #endif // KOAGENDA_H |
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index f46a103..82c0f4c 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -1,1724 +1,1724 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 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 <qlayout.h> | 24 | #include <qlayout.h> |
25 | #include <qheader.h> | 25 | #include <qheader.h> |
26 | #include <qcursor.h> | 26 | #include <qcursor.h> |
27 | #include <qwhatsthis.h> | 27 | #include <qwhatsthis.h> |
28 | #include <qdialog.h> | 28 | #include <qdialog.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qpushbutton.h> | 30 | #include <qpushbutton.h> |
31 | 31 | ||
32 | #include <qinputdialog.h> | 32 | #include <qinputdialog.h> |
33 | 33 | ||
34 | #include <qvbox.h> | 34 | #include <qvbox.h> |
35 | #include <kdebug.h> | 35 | #include <kdebug.h> |
36 | #include "koprefs.h" | 36 | #include "koprefs.h" |
37 | #include <klocale.h> | 37 | #include <klocale.h> |
38 | #include <kglobal.h> | 38 | #include <kglobal.h> |
39 | #include <kdateedit.h> | 39 | #include <kdateedit.h> |
40 | #include "ktimeedit.h" | 40 | #include "ktimeedit.h" |
41 | #include <kiconloader.h> | 41 | #include <kiconloader.h> |
42 | #include <kmessagebox.h> | 42 | #include <kmessagebox.h> |
43 | 43 | ||
44 | #include <libkcal/icaldrag.h> | 44 | #include <libkcal/icaldrag.h> |
45 | #include <libkcal/vcaldrag.h> | 45 | #include <libkcal/vcaldrag.h> |
46 | #include <libkcal/calfilter.h> | 46 | #include <libkcal/calfilter.h> |
47 | #include <libkcal/dndfactory.h> | 47 | #include <libkcal/dndfactory.h> |
48 | #include <libkcal/calendarresources.h> | 48 | #include <libkcal/calendarresources.h> |
49 | #include <libkcal/resourcecalendar.h> | 49 | #include <libkcal/resourcecalendar.h> |
50 | #include <kresources/resourceselectdialog.h> | 50 | #include <kresources/resourceselectdialog.h> |
51 | #include <libkcal/kincidenceformatter.h> | 51 | #include <libkcal/kincidenceformatter.h> |
52 | #ifndef DESKTOP_VERSION | 52 | #ifndef DESKTOP_VERSION |
53 | #include <qpe/qpeapplication.h> | 53 | #include <qpe/qpeapplication.h> |
54 | #else | 54 | #else |
55 | #include <qapplication.h> | 55 | #include <qapplication.h> |
56 | #endif | 56 | #endif |
57 | #ifndef KORG_NOPRINTER | 57 | #ifndef KORG_NOPRINTER |
58 | #include "calprinter.h" | 58 | #include "calprinter.h" |
59 | #endif | 59 | #endif |
60 | #include "docprefs.h" | 60 | #include "docprefs.h" |
61 | 61 | ||
62 | #include "kotodoview.h" | 62 | #include "kotodoview.h" |
63 | using namespace KOrg; | 63 | using namespace KOrg; |
64 | 64 | ||
65 | 65 | ||
66 | KOStartTodoPrefs::KOStartTodoPrefs( QString sum, QWidget *parent, const char *name ) : | 66 | KOStartTodoPrefs::KOStartTodoPrefs( QString sum, QWidget *parent, const char *name ) : |
67 | QDialog( parent, name, true ) | 67 | QDialog( parent, name, true ) |
68 | { | 68 | { |
69 | mStopAll = true; | 69 | mStopAll = true; |
70 | setCaption( i18n("Start todo") ); | 70 | setCaption( i18n("Start todo") ); |
71 | QVBoxLayout* lay = new QVBoxLayout( this ); | 71 | QVBoxLayout* lay = new QVBoxLayout( this ); |
72 | lay->setSpacing( 3 ); | 72 | lay->setSpacing( 3 ); |
73 | lay->setMargin( 3 ); | 73 | lay->setMargin( 3 ); |
74 | QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( sum ), this ); | 74 | QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( sum ), this ); |
75 | lay->addWidget( lab ); | 75 | lay->addWidget( lab ); |
76 | lab->setAlignment( AlignCenter ); | 76 | lab->setAlignment( AlignCenter ); |
77 | 77 | ||
78 | QPushButton * ok = new QPushButton( i18n("Start this todo\nand stop all running"), this ); | 78 | QPushButton * ok = new QPushButton( i18n("Start this todo\nand stop all running"), this ); |
79 | lay->addWidget( ok ); | 79 | lay->addWidget( ok ); |
80 | ok->setDefault( true ); | 80 | ok->setDefault( true ); |
81 | QPushButton * start = new QPushButton( i18n("Start todo"), this ); | 81 | QPushButton * start = new QPushButton( i18n("Start todo"), this ); |
82 | lay->addWidget( start ); | 82 | lay->addWidget( start ); |
83 | QPushButton * cancel = new QPushButton( i18n("Cancel - do not start"), this ); | 83 | QPushButton * cancel = new QPushButton( i18n("Cancel - do not start"), this ); |
84 | lay->addWidget( cancel ); | 84 | lay->addWidget( cancel ); |
85 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 85 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
86 | connect ( start,SIGNAL(clicked() ),this , SLOT ( doStop() ) ); | 86 | connect ( start,SIGNAL(clicked() ),this , SLOT ( doStop() ) ); |
87 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 87 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
88 | resize( sizeHint() ); | 88 | resize( sizeHint() ); |
89 | 89 | ||
90 | } | 90 | } |
91 | void KOStartTodoPrefs::doStop() | 91 | void KOStartTodoPrefs::doStop() |
92 | { | 92 | { |
93 | mStopAll = false; | 93 | mStopAll = false; |
94 | accept(); | 94 | accept(); |
95 | } | 95 | } |
96 | KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) : | 96 | KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) : |
97 | QDialog( parent, name, true ) | 97 | QDialog( parent, name, true ) |
98 | { | 98 | { |
99 | mTodo = todo; | 99 | mTodo = todo; |
100 | setCaption( i18n("Stop todo") ); | 100 | setCaption( i18n("Stop todo") ); |
101 | QVBoxLayout* lay = new QVBoxLayout( this ); | 101 | QVBoxLayout* lay = new QVBoxLayout( this ); |
102 | lay->setSpacing( 3 ); | 102 | lay->setSpacing( 3 ); |
103 | lay->setMargin( 3 ); | 103 | lay->setMargin( 3 ); |
104 | QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( todo->summary() ), this ); | 104 | QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( todo->summary() ), this ); |
105 | lay->addWidget( lab ); | 105 | lay->addWidget( lab ); |
106 | lab->setAlignment( AlignHCenter ); | 106 | lab->setAlignment( AlignHCenter ); |
107 | lab = new QLabel( i18n("Additional Comment:"), this ); | 107 | lab = new QLabel( i18n("Additional Comment:"), this ); |
108 | lay->addWidget( lab ); | 108 | lay->addWidget( lab ); |
109 | mComment = new QLineEdit( this ); | 109 | mComment = new QLineEdit( this ); |
110 | lay->addWidget( mComment ); | 110 | lay->addWidget( mComment ); |
111 | QHBox * start = new QHBox ( this ); | 111 | QHBox * start = new QHBox ( this ); |
112 | lay->addWidget( start ); | 112 | lay->addWidget( start ); |
113 | lab = new QLabel( i18n("Start:"), start ); | 113 | lab = new QLabel( i18n("Start:"), start ); |
114 | QHBox * end = new QHBox ( this ); | 114 | QHBox * end = new QHBox ( this ); |
115 | lay->addWidget( end ); | 115 | lay->addWidget( end ); |
116 | lab = new QLabel( i18n("End:"), end ); | 116 | lab = new QLabel( i18n("End:"), end ); |
117 | sde = new KDateEdit( start ); | 117 | sde = new KDateEdit( start ); |
118 | ste = new KOTimeEdit( start ); | 118 | ste = new KOTimeEdit( start ); |
119 | connect ( sde,SIGNAL(setTimeTo( QTime ) ),ste , SLOT ( setTime(QTime ) ) ); | 119 | connect ( sde,SIGNAL(setTimeTo( QTime ) ),ste , SLOT ( setTime(QTime ) ) ); |
120 | ede = new KDateEdit( end ); | 120 | ede = new KDateEdit( end ); |
121 | ete = new KOTimeEdit(end ); | 121 | ete = new KOTimeEdit(end ); |
122 | connect ( ede,SIGNAL(setTimeTo( QTime ) ),ete , SLOT ( setTime(QTime ) ) ); | 122 | connect ( ede,SIGNAL(setTimeTo( QTime ) ),ete , SLOT ( setTime(QTime ) ) ); |
123 | sde->setDate( mTodo->runStart().date() ); | 123 | sde->setDate( mTodo->runStart().date() ); |
124 | ste->setTime( mTodo->runStart().time() ); | 124 | ste->setTime( mTodo->runStart().time() ); |
125 | ede->setDate( QDate::currentDate()); | 125 | ede->setDate( QDate::currentDate()); |
126 | ete->setTime( QTime::currentTime() ); | 126 | ete->setTime( QTime::currentTime() ); |
127 | QPushButton * ok = new QPushButton( i18n("Stop and save"), this ); | 127 | QPushButton * ok = new QPushButton( i18n("Stop and save"), this ); |
128 | lay->addWidget( ok ); | 128 | lay->addWidget( ok ); |
129 | ok->setDefault( true ); | 129 | ok->setDefault( true ); |
130 | QPushButton * cancel = new QPushButton( i18n("Continue running"), this ); | 130 | QPushButton * cancel = new QPushButton( i18n("Continue running"), this ); |
131 | lay->addWidget( cancel ); | 131 | lay->addWidget( cancel ); |
132 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 132 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
133 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 133 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
134 | ok = new QPushButton( i18n("Stop - do not save"), this ); | 134 | ok = new QPushButton( i18n("Stop - do not save"), this ); |
135 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( doNotSave() ) ); | 135 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( doNotSave() ) ); |
136 | lay->addWidget( ok ); | 136 | lay->addWidget( ok ); |
137 | if (QApplication::desktop()->width() < 320 ) | 137 | if (QApplication::desktop()->width() < 320 ) |
138 | resize( 240, sizeHint().height() ); | 138 | resize( 240, sizeHint().height() ); |
139 | else | 139 | else |
140 | resize( 320, sizeHint().height() ); | 140 | resize( 320, sizeHint().height() ); |
141 | 141 | ||
142 | } | 142 | } |
143 | 143 | ||
144 | void KOStopTodoPrefs::accept() | 144 | void KOStopTodoPrefs::accept() |
145 | { | 145 | { |
146 | QDateTime start = QDateTime( sde->date(), ste->getTime() ); | 146 | QDateTime start = QDateTime( sde->date(), ste->getTime() ); |
147 | QDateTime stop = QDateTime( ede->date(), ete->getTime() ); | 147 | QDateTime stop = QDateTime( ede->date(), ete->getTime() ); |
148 | if ( start > stop ) { | 148 | if ( start > stop ) { |
149 | KMessageBox::sorry(this, | 149 | KMessageBox::sorry(this, |
150 | i18n("The start time is\nafter the end time!"), | 150 | i18n("The start time is\nafter the end time!"), |
151 | i18n("Time mismatch!")); | 151 | i18n("Time mismatch!")); |
152 | return; | 152 | return; |
153 | } | 153 | } |
154 | mTodo->saveRunningInfo( mComment->text(), start, stop ); | 154 | mTodo->saveRunningInfo( mComment->text(), start, stop ); |
155 | QDialog::accept(); | 155 | QDialog::accept(); |
156 | } | 156 | } |
157 | void KOStopTodoPrefs::doNotSave() | 157 | void KOStopTodoPrefs::doNotSave() |
158 | { | 158 | { |
159 | int result = KMessageBox::warningContinueCancel(this, | 159 | int result = KMessageBox::warningContinueCancel(this, |
160 | i18n("Do you really want to set\nthe state to stopped\nwithout saving the data?"),mTodo->summary(),i18n("Yes, stop todo") ); | 160 | i18n("Do you really want to set\nthe state to stopped\nwithout saving the data?"),mTodo->summary(),i18n("Yes, stop todo") ); |
161 | if (result != KMessageBox::Continue) return; | 161 | if (result != KMessageBox::Continue) return; |
162 | mTodo->stopRunning(); | 162 | mTodo->stopRunning(); |
163 | QDialog::accept(); | 163 | QDialog::accept(); |
164 | } | 164 | } |
165 | 165 | ||
166 | 166 | ||
167 | class KOTodoViewWhatsThis :public QWhatsThis | 167 | class KOTodoViewWhatsThis :public QWhatsThis |
168 | { | 168 | { |
169 | public: | 169 | public: |
170 | KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; | 170 | KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; |
171 | 171 | ||
172 | protected: | 172 | protected: |
173 | virtual QString text( const QPoint& p) | 173 | virtual QString text( const QPoint& p) |
174 | { | 174 | { |
175 | return _view->getWhatsThisText(p) ; | 175 | return _view->getWhatsThisText(p) ; |
176 | } | 176 | } |
177 | private: | 177 | private: |
178 | QWidget* _wid; | 178 | QWidget* _wid; |
179 | KOTodoView * _view; | 179 | KOTodoView * _view; |
180 | }; | 180 | }; |
181 | 181 | ||
182 | KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, | 182 | KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, |
183 | const char *name) : | 183 | const char *name) : |
184 | KListView(parent,name) | 184 | KListView(parent,name) |
185 | { | 185 | { |
186 | mName = QString ( name ); | 186 | mName = QString ( name ); |
187 | mCalendar = calendar; | 187 | mCalendar = calendar; |
188 | #ifndef DESKTOP_VERSION | 188 | #ifndef DESKTOP_VERSION |
189 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); | 189 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); |
190 | #endif | 190 | #endif |
191 | mOldCurrent = 0; | 191 | mOldCurrent = 0; |
192 | mMousePressed = false; | 192 | mMousePressed = false; |
193 | 193 | ||
194 | setAcceptDrops(true); | 194 | setAcceptDrops(true); |
195 | viewport()->setAcceptDrops(true); | 195 | viewport()->setAcceptDrops(true); |
196 | int size = 16; | 196 | int size = 16; |
197 | if (qApp->desktop()->width() < 300 ) | 197 | if (qApp->desktop()->width() < 300 ) |
198 | size = 12; | 198 | size = 12; |
199 | setTreeStepSize( size + 6 ); | 199 | setTreeStepSize( size + 6 ); |
200 | 200 | ||
201 | } | 201 | } |
202 | 202 | ||
203 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) | 203 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) |
204 | { | 204 | { |
205 | #ifndef KORG_NODND | 205 | #ifndef KORG_NODND |
206 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; | 206 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; |
207 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 207 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
208 | !QTextDrag::canDecode( e ) ) { | 208 | !QTextDrag::canDecode( e ) ) { |
209 | e->ignore(); | 209 | e->ignore(); |
210 | return; | 210 | return; |
211 | } | 211 | } |
212 | 212 | ||
213 | mOldCurrent = currentItem(); | 213 | mOldCurrent = currentItem(); |
214 | #endif | 214 | #endif |
215 | } | 215 | } |
216 | 216 | ||
217 | 217 | ||
218 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) | 218 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) |
219 | { | 219 | { |
220 | #ifndef KORG_NODND | 220 | #ifndef KORG_NODND |
221 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; | 221 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; |
222 | 222 | ||
223 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 223 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
224 | !QTextDrag::canDecode( e ) ) { | 224 | !QTextDrag::canDecode( e ) ) { |
225 | e->ignore(); | 225 | e->ignore(); |
226 | return; | 226 | return; |
227 | } | 227 | } |
228 | 228 | ||
229 | e->accept(); | 229 | e->accept(); |
230 | #endif | 230 | #endif |
231 | } | 231 | } |
232 | 232 | ||
233 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) | 233 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) |
234 | { | 234 | { |
235 | #ifndef KORG_NODND | 235 | #ifndef KORG_NODND |
236 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; | 236 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; |
237 | 237 | ||
238 | setCurrentItem(mOldCurrent); | 238 | setCurrentItem(mOldCurrent); |
239 | setSelected(mOldCurrent,true); | 239 | setSelected(mOldCurrent,true); |
240 | #endif | 240 | #endif |
241 | } | 241 | } |
242 | 242 | ||
243 | void KOTodoListView::contentsDropEvent(QDropEvent *e) | 243 | void KOTodoListView::contentsDropEvent(QDropEvent *e) |
244 | { | 244 | { |
245 | #ifndef KORG_NODND | 245 | #ifndef KORG_NODND |
246 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; | 246 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; |
247 | 247 | ||
248 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 248 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
249 | !QTextDrag::canDecode( e ) ) { | 249 | !QTextDrag::canDecode( e ) ) { |
250 | e->ignore(); | 250 | e->ignore(); |
251 | return; | 251 | return; |
252 | } | 252 | } |
253 | 253 | ||
254 | DndFactory factory( mCalendar ); | 254 | DndFactory factory( mCalendar ); |
255 | Todo *todo = factory.createDropTodo(e); | 255 | Todo *todo = factory.createDropTodo(e); |
256 | 256 | ||
257 | if (todo) { | 257 | if (todo) { |
258 | e->acceptAction(); | 258 | e->acceptAction(); |
259 | 259 | ||
260 | KOTodoViewItem *destination = | 260 | KOTodoViewItem *destination = |
261 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); | 261 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); |
262 | Todo *destinationEvent = 0; | 262 | Todo *destinationEvent = 0; |
263 | if (destination) destinationEvent = destination->todo(); | 263 | if (destination) destinationEvent = destination->todo(); |
264 | 264 | ||
265 | Todo *existingTodo = mCalendar->todo(todo->uid()); | 265 | Todo *existingTodo = mCalendar->todo(todo->uid()); |
266 | 266 | ||
267 | if(existingTodo) { | 267 | if(existingTodo) { |
268 | Incidence *to = destinationEvent; | 268 | Incidence *to = destinationEvent; |
269 | while(to) { | 269 | while(to) { |
270 | if (to->uid() == todo->uid()) { | 270 | if (to->uid() == todo->uid()) { |
271 | KMessageBox::sorry(this, | 271 | KMessageBox::sorry(this, |
272 | i18n("Cannot move Todo to itself\nor a child of itself"), | 272 | i18n("Cannot move Todo to itself\nor a child of itself"), |
273 | i18n("Drop Todo")); | 273 | i18n("Drop Todo")); |
274 | delete todo; | 274 | delete todo; |
275 | return; | 275 | return; |
276 | } | 276 | } |
277 | to = to->relatedTo(); | 277 | to = to->relatedTo(); |
278 | } | 278 | } |
279 | internalDrop = true; | 279 | internalDrop = true; |
280 | if ( destinationEvent ) | 280 | if ( destinationEvent ) |
281 | reparentTodoSignal( destinationEvent, existingTodo ); | 281 | reparentTodoSignal( destinationEvent, existingTodo ); |
282 | else | 282 | else |
283 | unparentTodoSignal(existingTodo); | 283 | unparentTodoSignal(existingTodo); |
284 | delete todo; | 284 | delete todo; |
285 | } else { | 285 | } else { |
286 | mCalendar->addTodo(todo); | 286 | mCalendar->addTodo(todo); |
287 | emit todoDropped(todo, KOGlobals::EVENTADDED); | 287 | emit todoDropped(todo, KOGlobals::EVENTADDED); |
288 | if ( destinationEvent ) | 288 | if ( destinationEvent ) |
289 | reparentTodoSignal( destinationEvent, todo ); | 289 | reparentTodoSignal( destinationEvent, todo ); |
290 | } | 290 | } |
291 | } | 291 | } |
292 | else { | 292 | else { |
293 | QString text; | 293 | QString text; |
294 | if (QTextDrag::decode(e,text)) { | 294 | if (QTextDrag::decode(e,text)) { |
295 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); | 295 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); |
296 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); | 296 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); |
297 | qDebug("Dropped : " + text); | 297 | qDebug("Dropped : " + text); |
298 | QStringList emails = QStringList::split(",",text); | 298 | QStringList emails = QStringList::split(",",text); |
299 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 299 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
300 | int pos = (*it).find("<"); | 300 | int pos = (*it).find("<"); |
301 | QString name = (*it).left(pos); | 301 | QString name = (*it).left(pos); |
302 | QString email = (*it).mid(pos); | 302 | QString email = (*it).mid(pos); |
303 | if (!email.isEmpty() && todoi) { | 303 | if (!email.isEmpty() && todoi) { |
304 | todoi->todo()->addAttendee(new Attendee(name,email)); | 304 | todoi->todo()->addAttendee(new Attendee(name,email)); |
305 | } | 305 | } |
306 | } | 306 | } |
307 | } | 307 | } |
308 | else { | 308 | else { |
309 | qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); | 309 | qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); |
310 | e->ignore(); | 310 | e->ignore(); |
311 | } | 311 | } |
312 | } | 312 | } |
313 | #endif | 313 | #endif |
314 | } | 314 | } |
315 | void KOTodoListView::wheelEvent (QWheelEvent *e) | 315 | void KOTodoListView::wheelEvent (QWheelEvent *e) |
316 | { | 316 | { |
317 | QListView::wheelEvent (e); | 317 | QListView::wheelEvent (e); |
318 | } | 318 | } |
319 | 319 | ||
320 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) | 320 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) |
321 | { | 321 | { |
322 | 322 | ||
323 | QPoint p(contentsToViewport(e->pos())); | 323 | QPoint p(contentsToViewport(e->pos())); |
324 | QListViewItem *i = itemAt(p); | 324 | QListViewItem *i = itemAt(p); |
325 | bool rootClicked = true; | 325 | bool rootClicked = true; |
326 | if (i) { | 326 | if (i) { |
327 | // if the user clicked into the root decoration of the item, don't | 327 | // if the user clicked into the root decoration of the item, don't |
328 | // try to start a drag! | 328 | // try to start a drag! |
329 | int X = p.x(); | 329 | int X = p.x(); |
330 | //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); | 330 | //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); |
331 | if (X > header()->sectionPos(0) + | 331 | if (X > header()->sectionPos(0) + |
332 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + | 332 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + |
333 | itemMargin() +i->height()|| | 333 | itemMargin() +i->height()|| |
334 | X < header()->sectionPos(0)) { | 334 | X < header()->sectionPos(0)) { |
335 | rootClicked = false; | 335 | rootClicked = false; |
336 | } | 336 | } |
337 | } else { | 337 | } else { |
338 | rootClicked = false; | 338 | rootClicked = false; |
339 | } | 339 | } |
340 | #ifndef KORG_NODND | 340 | #ifndef KORG_NODND |
341 | mMousePressed = false; | 341 | mMousePressed = false; |
342 | if (! rootClicked && !( e->button() == RightButton) ) { | 342 | if (! rootClicked && !( e->button() == RightButton) ) { |
343 | mPressPos = e->pos(); | 343 | mPressPos = e->pos(); |
344 | mMousePressed = true; | 344 | mMousePressed = true; |
345 | } else { | 345 | } else { |
346 | mMousePressed = false; | 346 | mMousePressed = false; |
347 | } | 347 | } |
348 | #endif | 348 | #endif |
349 | //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); | 349 | //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); |
350 | #ifndef DESKTOP_VERSION | 350 | #ifndef DESKTOP_VERSION |
351 | if (!( e->button() == RightButton && rootClicked) ) | 351 | if (!( e->button() == RightButton && rootClicked) ) |
352 | QListView::contentsMousePressEvent(e); | 352 | QListView::contentsMousePressEvent(e); |
353 | #else | 353 | #else |
354 | QListView::contentsMousePressEvent(e); | 354 | QListView::contentsMousePressEvent(e); |
355 | #endif | 355 | #endif |
356 | } | 356 | } |
357 | void KOTodoListView::paintEvent(QPaintEvent* e) | 357 | void KOTodoListView::paintEvent(QPaintEvent* e) |
358 | { | 358 | { |
359 | emit paintNeeded(); | 359 | emit paintNeeded(); |
360 | QListView::paintEvent( e); | 360 | QListView::paintEvent( e); |
361 | } | 361 | } |
362 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) | 362 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) |
363 | { | 363 | { |
364 | 364 | ||
365 | #ifndef KORG_NODND | 365 | #ifndef KORG_NODND |
366 | //QListView::contentsMouseMoveEvent(e); | 366 | //QListView::contentsMouseMoveEvent(e); |
367 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > | 367 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > |
368 | QApplication::startDragDistance()*3) { | 368 | QApplication::startDragDistance()*3) { |
369 | mMousePressed = false; | 369 | mMousePressed = false; |
370 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); | 370 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); |
371 | if (item) { | 371 | if (item) { |
372 | DndFactory factory( mCalendar ); | 372 | DndFactory factory( mCalendar ); |
373 | ICalDrag *vd = factory.createDrag( | 373 | ICalDrag *vd = factory.createDrag( |
374 | ((KOTodoViewItem *)item)->todo(),viewport()); | 374 | ((KOTodoViewItem *)item)->todo(),viewport()); |
375 | internalDrop = false; | 375 | internalDrop = false; |
376 | // we cannot do any senseful here, because the DnD is still broken in Qt | 376 | // we cannot do any senseful here, because the DnD is still broken in Qt |
377 | if (vd->drag()) { | 377 | if (vd->drag()) { |
378 | if ( !internalDrop ) { | 378 | if ( !internalDrop ) { |
379 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); | 379 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); |
380 | qDebug("Dnd: External move: Delete drag source "); | 380 | qDebug("Dnd: External move: Delete drag source "); |
381 | } else | 381 | } else |
382 | qDebug("Dnd: Internal move "); | 382 | qDebug("Dnd: Internal move "); |
383 | 383 | ||
384 | } else { | 384 | } else { |
385 | if ( !internalDrop ) { | 385 | if ( !internalDrop ) { |
386 | qDebug("Dnd: External Copy"); | 386 | qDebug("Dnd: External Copy"); |
387 | } else | 387 | } else |
388 | qDebug("DnD: Internal copy: Copy pending"); | 388 | qDebug("DnD: Internal copy: Copy pending"); |
389 | } | 389 | } |
390 | } | 390 | } |
391 | } | 391 | } |
392 | #endif | 392 | #endif |
393 | } | 393 | } |
394 | void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) | 394 | void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) |
395 | { | 395 | { |
396 | if ( !e->isAutoRepeat() ) { | 396 | if ( !e->isAutoRepeat() ) { |
397 | mFlagKeyPressed = false; | 397 | mFlagKeyPressed = false; |
398 | } | 398 | } |
399 | } | 399 | } |
400 | 400 | ||
401 | 401 | ||
402 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | 402 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) |
403 | { | 403 | { |
404 | qApp->processEvents(); | 404 | qApp->processEvents(); |
405 | if ( !isVisible() ) { | 405 | if ( !isVisible() ) { |
406 | e->ignore(); | 406 | e->ignore(); |
407 | return; | 407 | return; |
408 | } | 408 | } |
409 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 409 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
410 | e->ignore(); | 410 | e->ignore(); |
411 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 411 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
412 | return; | 412 | return; |
413 | } | 413 | } |
414 | if (! e->isAutoRepeat() ) | 414 | if (! e->isAutoRepeat() ) |
415 | mFlagKeyPressed = true; | 415 | mFlagKeyPressed = true; |
416 | QListViewItem* cn; | 416 | QListViewItem* cn; |
417 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { | 417 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { |
418 | cn = currentItem(); | 418 | cn = currentItem(); |
419 | if ( cn ) { | 419 | if ( cn ) { |
420 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 420 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
421 | if ( ci ){ | 421 | if ( ci ){ |
422 | if ( e->state() == ShiftButton ) | 422 | if ( e->state() == ShiftButton ) |
423 | ci->setOn( false ); | 423 | ci->setOn( false ); |
424 | else | 424 | else |
425 | ci->setOn( true ); | 425 | ci->setOn( true ); |
426 | cn = cn->itemBelow(); | 426 | cn = cn->itemBelow(); |
427 | if ( cn ) { | 427 | if ( cn ) { |
428 | setCurrentItem ( cn ); | 428 | setCurrentItem ( cn ); |
429 | ensureItemVisible ( cn ); | 429 | ensureItemVisible ( cn ); |
430 | } | 430 | } |
431 | 431 | ||
432 | } | 432 | } |
433 | } | 433 | } |
434 | 434 | ||
435 | e->accept(); | 435 | e->accept(); |
436 | return; | 436 | return; |
437 | } | 437 | } |
438 | 438 | ||
439 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { | 439 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { |
440 | switch ( e->key() ) { | 440 | switch ( e->key() ) { |
441 | case Qt::Key_Down: | 441 | case Qt::Key_Down: |
442 | case Qt::Key_Up: | 442 | case Qt::Key_Up: |
443 | QListView::keyPressEvent ( e ); | 443 | QListView::keyPressEvent ( e ); |
444 | e->accept(); | 444 | e->accept(); |
445 | break; | 445 | break; |
446 | case Qt::Key_Left: | 446 | case Qt::Key_Left: |
447 | case Qt::Key_Right: | 447 | case Qt::Key_Right: |
448 | QListView::keyPressEvent ( e ); | 448 | QListView::keyPressEvent ( e ); |
449 | e->accept(); | 449 | e->accept(); |
450 | return; | 450 | return; |
451 | break; | 451 | break; |
452 | default: | 452 | default: |
453 | e->ignore(); | 453 | e->ignore(); |
454 | break; | 454 | break; |
455 | } | 455 | } |
456 | return; | 456 | return; |
457 | } | 457 | } |
458 | e->ignore(); | 458 | e->ignore(); |
459 | } | 459 | } |
460 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) | 460 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) |
461 | { | 461 | { |
462 | QListView::contentsMouseReleaseEvent(e); | 462 | QListView::contentsMouseReleaseEvent(e); |
463 | mMousePressed = false; | 463 | mMousePressed = false; |
464 | } | 464 | } |
465 | 465 | ||
466 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 466 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
467 | { | 467 | { |
468 | if (!e) return; | 468 | if (!e) return; |
469 | 469 | ||
470 | QPoint vp = contentsToViewport(e->pos()); | 470 | QPoint vp = contentsToViewport(e->pos()); |
471 | 471 | ||
472 | QListViewItem *item = itemAt(vp); | 472 | QListViewItem *item = itemAt(vp); |
473 | 473 | ||
474 | emit double_Clicked(item); | 474 | emit double_Clicked(item); |
475 | if (!item) return; | 475 | if (!item) return; |
476 | 476 | ||
477 | emit doubleClicked(item,vp,0); | 477 | emit doubleClicked(item,vp,0); |
478 | } | 478 | } |
479 | 479 | ||
480 | ///////////////////////////////////////////////////////////////////////////// | 480 | ///////////////////////////////////////////////////////////////////////////// |
481 | 481 | ||
482 | KOQuickTodo::KOQuickTodo(QWidget *parent) : | 482 | KOQuickTodo::KOQuickTodo(QWidget *parent) : |
483 | QLineEdit(parent) | 483 | QLineEdit(parent) |
484 | { | 484 | { |
485 | setText(i18n("Click to add new Todo")); | 485 | setText(i18n("Click to add new Todo")); |
486 | } | 486 | } |
487 | 487 | ||
488 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) | 488 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) |
489 | { | 489 | { |
490 | if ( text()==i18n("Click to add new Todo") ) | 490 | if ( text()==i18n("Click to add new Todo") ) |
491 | setText(""); | 491 | setText(""); |
492 | QLineEdit::focusInEvent(ev); | 492 | QLineEdit::focusInEvent(ev); |
493 | } | 493 | } |
494 | 494 | ||
495 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) | 495 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) |
496 | { | 496 | { |
497 | setText(i18n("Click to add new Todo")); | 497 | setText(i18n("Click to add new Todo")); |
498 | QLineEdit::focusOutEvent(ev); | 498 | QLineEdit::focusOutEvent(ev); |
499 | } | 499 | } |
500 | 500 | ||
501 | ///////////////////////////////////////////////////////////////////////////// | 501 | ///////////////////////////////////////////////////////////////////////////// |
502 | 502 | ||
503 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | 503 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : |
504 | KOrg::BaseView(calendar,parent,name) | 504 | KOrg::BaseView(calendar,parent,name) |
505 | { | 505 | { |
506 | mCategoryPopupMenu = 0; | 506 | mCategoryPopupMenu = 0; |
507 | mPendingUpdateBeforeRepaint = false; | 507 | mPendingUpdateBeforeRepaint = false; |
508 | isFlatDisplay = false; | 508 | isFlatDisplay = false; |
509 | mNavigator = 0; | 509 | mNavigator = 0; |
510 | QBoxLayout *topLayout = new QVBoxLayout(this); | 510 | QBoxLayout *topLayout = new QVBoxLayout(this); |
511 | mName = QString ( name ); | 511 | mName = QString ( name ); |
512 | mBlockUpdate = false; | 512 | mBlockUpdate = false; |
513 | mQuickBar = new QWidget( this ); | 513 | mQuickBar = new QWidget( this ); |
514 | topLayout->addWidget(mQuickBar); | 514 | topLayout->addWidget(mQuickBar); |
515 | 515 | ||
516 | mQuickAdd = new KOQuickTodo(mQuickBar); | 516 | mQuickAdd = new KOQuickTodo(mQuickBar); |
517 | QBoxLayout *quickLayout = new QHBoxLayout(mQuickBar); | 517 | QBoxLayout *quickLayout = new QHBoxLayout(mQuickBar); |
518 | quickLayout->addWidget( mQuickAdd ); | 518 | quickLayout->addWidget( mQuickAdd ); |
519 | mNewSubBut = new QPushButton( "sub",mQuickBar ); | 519 | mNewSubBut = new QPushButton( "sub",mQuickBar ); |
520 | QPushButton * s_done = new QPushButton( "D",mQuickBar ); | 520 | QPushButton * s_done = new QPushButton( "D",mQuickBar ); |
521 | QPushButton * s_run = new QPushButton( "R",mQuickBar ); | 521 | QPushButton * s_run = new QPushButton( "R",mQuickBar ); |
522 | QPushButton * allopen = new QPushButton( "O",mQuickBar ); | 522 | QPushButton * allopen = new QPushButton( "O",mQuickBar ); |
523 | QPushButton * allclose = new QPushButton( "C",mQuickBar ); | 523 | QPushButton * allclose = new QPushButton( "C",mQuickBar ); |
524 | QPushButton * flat = new QPushButton( "F",mQuickBar ); | 524 | QPushButton * flat = new QPushButton( "F",mQuickBar ); |
525 | 525 | ||
526 | int fixwid = mQuickAdd->sizeHint().height(); | 526 | int fixwid = mQuickAdd->sizeHint().height(); |
527 | int fixhei = fixwid; | 527 | int fixhei = fixwid; |
528 | if ( QApplication::desktop()->width() > 800 ) | 528 | if ( QApplication::desktop()->width() > 800 ) |
529 | fixwid = (fixwid*3)/2; | 529 | fixwid = (fixwid*3)/2; |
530 | connect ( flat, SIGNAL ( clicked()), SLOT ( setAllFlat())); | 530 | connect ( flat, SIGNAL ( clicked()), SLOT ( setAllFlat())); |
531 | connect ( allopen, SIGNAL ( clicked()), SLOT ( setAllOpen())); | 531 | connect ( allopen, SIGNAL ( clicked()), SLOT ( setAllOpen())); |
532 | connect ( allclose, SIGNAL ( clicked()), SLOT ( setAllClose())); | 532 | connect ( allclose, SIGNAL ( clicked()), SLOT ( setAllClose())); |
533 | s_done->setPixmap( SmallIcon("greenhook16")); | 533 | s_done->setPixmap( SmallIcon("greenhook16")); |
534 | connect ( s_done, SIGNAL ( clicked()), SLOT ( toggleCompleted())); | 534 | connect ( s_done, SIGNAL ( clicked()), SLOT ( toggleCompleted())); |
535 | s_run->setPixmap( SmallIcon("ko16old")); | 535 | s_run->setPixmap( SmallIcon("ko16old")); |
536 | connect ( s_run, SIGNAL ( clicked()), SLOT ( toggleRunning())); | 536 | connect ( s_run, SIGNAL ( clicked()), SLOT ( toggleRunning())); |
537 | 537 | ||
538 | connect ( mNewSubBut, SIGNAL ( clicked()), SLOT ( newSubTodo())); | 538 | connect ( mNewSubBut, SIGNAL ( clicked()), SLOT ( newSubTodo())); |
539 | 539 | ||
540 | mNewSubBut->setFixedWidth(mNewSubBut->sizeHint().width() ); | 540 | mNewSubBut->setFixedWidth(mNewSubBut->sizeHint().width() ); |
541 | mNewSubBut->setEnabled( false ); | 541 | mNewSubBut->setEnabled( false ); |
542 | flat->setFixedWidth( fixwid ); | 542 | flat->setFixedWidth( fixwid ); |
543 | s_done->setFixedWidth( fixwid ); | 543 | s_done->setFixedWidth( fixwid ); |
544 | allopen->setFixedWidth( fixwid ); | 544 | allopen->setFixedWidth( fixwid ); |
545 | allclose->setFixedWidth( fixwid ); | 545 | allclose->setFixedWidth( fixwid ); |
546 | s_run->setFixedWidth( fixwid ); | 546 | s_run->setFixedWidth( fixwid ); |
547 | 547 | ||
548 | flat->setFixedHeight(fixhei ); | 548 | flat->setFixedHeight(fixhei ); |
549 | s_done->setFixedHeight(fixhei ); | 549 | s_done->setFixedHeight(fixhei ); |
550 | allopen->setFixedHeight(fixhei ); | 550 | allopen->setFixedHeight(fixhei ); |
551 | allclose->setFixedHeight(fixhei ); | 551 | allclose->setFixedHeight(fixhei ); |
552 | s_run->setFixedHeight(fixhei ); | 552 | s_run->setFixedHeight(fixhei ); |
553 | mNewSubBut->setFixedHeight(fixhei ); | 553 | mNewSubBut->setFixedHeight(fixhei ); |
554 | 554 | ||
555 | quickLayout->addWidget( mNewSubBut ); | 555 | quickLayout->addWidget( mNewSubBut ); |
556 | quickLayout->addWidget( s_done ); | 556 | quickLayout->addWidget( s_done ); |
557 | quickLayout->addWidget( s_run ); | 557 | quickLayout->addWidget( s_run ); |
558 | quickLayout->addWidget( allopen ); | 558 | quickLayout->addWidget( allopen ); |
559 | quickLayout->addWidget( allclose ); | 559 | quickLayout->addWidget( allclose ); |
560 | quickLayout->addWidget( flat ); | 560 | quickLayout->addWidget( flat ); |
561 | 561 | ||
562 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickBar->hide(); | 562 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickBar->hide(); |
563 | 563 | ||
564 | mTodoListView = new KOTodoListView(calendar,this, name ); | 564 | mTodoListView = new KOTodoListView(calendar,this, name ); |
565 | topLayout->addWidget(mTodoListView); | 565 | topLayout->addWidget(mTodoListView); |
566 | //mTodoListView->header()->setMaximumHeight(30); | 566 | //mTodoListView->header()->setMaximumHeight(30); |
567 | mTodoListView->setRootIsDecorated(true); | 567 | mTodoListView->setRootIsDecorated(true); |
568 | mTodoListView->setAllColumnsShowFocus(true); | 568 | mTodoListView->setAllColumnsShowFocus(true); |
569 | 569 | ||
570 | mTodoListView->setShowSortIndicator(true); | 570 | mTodoListView->setShowSortIndicator(true); |
571 | 571 | ||
572 | mTodoListView->addColumn(i18n("Todo")); | 572 | mTodoListView->addColumn(i18n("Todo")); |
573 | mTodoListView->addColumn(i18n("Prio")); | 573 | mTodoListView->addColumn(i18n("Prio")); |
574 | mTodoListView->setColumnAlignment(1,AlignHCenter); | 574 | mTodoListView->setColumnAlignment(1,AlignHCenter); |
575 | mTodoListView->addColumn(i18n("Complete")); | 575 | mTodoListView->addColumn(i18n("Complete")); |
576 | mTodoListView->setColumnAlignment(2,AlignCenter); | 576 | mTodoListView->setColumnAlignment(2,AlignCenter); |
577 | 577 | ||
578 | mTodoListView->addColumn(i18n("Due Date")); | 578 | mTodoListView->addColumn(i18n("Due Date")); |
579 | mTodoListView->setColumnAlignment(3,AlignLeft); | 579 | mTodoListView->setColumnAlignment(3,AlignLeft); |
580 | mTodoListView->addColumn(i18n("Due Time")); | 580 | mTodoListView->addColumn(i18n("Due Time")); |
581 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 581 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
582 | 582 | ||
583 | mTodoListView->addColumn(i18n("Start Date")); | 583 | mTodoListView->addColumn(i18n("Start Date")); |
584 | mTodoListView->setColumnAlignment(5,AlignLeft); | 584 | mTodoListView->setColumnAlignment(5,AlignLeft); |
585 | mTodoListView->addColumn(i18n("Start Time")); | 585 | mTodoListView->addColumn(i18n("Start Time")); |
586 | mTodoListView->setColumnAlignment(6,AlignHCenter); | 586 | mTodoListView->setColumnAlignment(6,AlignHCenter); |
587 | 587 | ||
588 | //mTodoListView->addColumn(i18n("Cancelled")); | 588 | //mTodoListView->addColumn(i18n("Cancelled")); |
589 | mTodoListView->addColumn(i18n("Categories")); | 589 | mTodoListView->addColumn(i18n("Categories")); |
590 | mTodoListView->addColumn(i18n("Calendar")); | 590 | mTodoListView->addColumn(i18n("Calendar")); |
591 | mTodoListView->addColumn(i18n("Last Modified")); | 591 | mTodoListView->addColumn(i18n("Last Modified")); |
592 | mTodoListView->addColumn(i18n("Created")); | 592 | mTodoListView->addColumn(i18n("Created")); |
593 | mTodoListView->addColumn(i18n("Last Modified Sub")); | 593 | mTodoListView->addColumn(i18n("Last Modified Sub")); |
594 | #if 0 | 594 | #if 0 |
595 | mTodoListView->addColumn(i18n("Sort Id")); | 595 | mTodoListView->addColumn(i18n("Sort Id")); |
596 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 596 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
597 | #endif | 597 | #endif |
598 | 598 | ||
599 | mTodoListView->setMinimumHeight( 60 ); | 599 | mTodoListView->setMinimumHeight( 60 ); |
600 | mTodoListView->setItemsRenameable( true ); | 600 | mTodoListView->setItemsRenameable( true ); |
601 | mTodoListView->setRenameable( 0 ); | 601 | mTodoListView->setRenameable( 0 ); |
602 | mTodoListView->setColumnWidth( 0, 120 ); | 602 | mTodoListView->setColumnWidth( 0, 120 ); |
603 | int iii = 0; | 603 | int iii = 0; |
604 | for ( iii = 0; iii< 12 ; ++iii ) | 604 | for ( iii = 0; iii< 12 ; ++iii ) |
605 | mTodoListView->setColumnWidthMode( iii, QListView::Manual ); | 605 | mTodoListView->setColumnWidthMode( iii, QListView::Manual ); |
606 | 606 | ||
607 | 607 | ||
608 | mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); | 608 | mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); |
609 | 609 | ||
610 | mPriorityPopupMenu = new QPopupMenu(this); | 610 | mPriorityPopupMenu = new QPopupMenu(this); |
611 | for (int i = 1; i <= 5; i++) { | 611 | for (int i = 1; i <= 5; i++) { |
612 | QString label = QString ("%1").arg (i); | 612 | QString label = QString ("%1").arg (i); |
613 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; | 613 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; |
614 | } | 614 | } |
615 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); | 615 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); |
616 | 616 | ||
617 | mPercentageCompletedPopupMenu = new QPopupMenu(this); | 617 | mPercentageCompletedPopupMenu = new QPopupMenu(this); |
618 | for (int i = 0; i <= 100; i+=20) { | 618 | for (int i = 0; i <= 100; i+=20) { |
619 | QString label = QString ("%1 %").arg (i); | 619 | QString label = QString ("%1 %").arg (i); |
620 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; | 620 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; |
621 | } | 621 | } |
622 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); | 622 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); |
623 | 623 | ||
624 | 624 | ||
625 | mCategoryPopupMenu = new QPopupMenu (this); | 625 | mCategoryPopupMenu = new QPopupMenu (this); |
626 | mCategoryPopupMenu->setCheckable (true); | 626 | mCategoryPopupMenu->setCheckable (true); |
627 | connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); | 627 | connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); |
628 | connect (mCategoryPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCategories ())); | 628 | connect (mCategoryPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCategories ())); |
629 | 629 | ||
630 | mCalPopupMenu = new QPopupMenu (this); | 630 | mCalPopupMenu = new QPopupMenu (this); |
631 | mCalPopupMenu->setCheckable (true); | 631 | mCalPopupMenu->setCheckable (true); |
632 | connect (mCalPopupMenu, SIGNAL (activated (int)), SLOT (changedCal (int))); | 632 | connect (mCalPopupMenu, SIGNAL (activated (int)), SLOT (changedCal (int))); |
633 | connect (mCalPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCal ())); | 633 | connect (mCalPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCal ())); |
634 | 634 | ||
635 | 635 | ||
636 | 636 | ||
637 | 637 | ||
638 | mItemPopupMenu = new QPopupMenu(this); | 638 | mItemPopupMenu = new QPopupMenu(this); |
639 | mItemPopupMenu->insertItem(i18n("Show"), this, | 639 | mItemPopupMenu->insertItem(i18n("Show"), this, |
640 | SLOT (showTodo())); | 640 | SLOT (showTodo())); |
641 | mItemPopupMenu->insertItem(i18n("Edit..."), this, | 641 | mItemPopupMenu->insertItem(i18n("Edit..."), this, |
642 | SLOT (editTodo())); | 642 | SLOT (editTodo())); |
643 | mItemPopupMenu->insertItem( i18n("Delete..."), this, | 643 | mItemPopupMenu->insertItem( i18n("Delete..."), this, |
644 | SLOT (deleteTodo())); | 644 | SLOT (deleteTodo())); |
645 | mItemPopupMenu->insertItem( i18n("Clone..."), this, | 645 | mItemPopupMenu->insertItem( i18n("Clone..."), this, |
646 | SLOT (cloneTodo())); | 646 | SLOT (cloneTodo())); |
647 | mItemPopupMenu->insertItem( i18n("Move..."), this, | 647 | mItemPopupMenu->insertItem( i18n("Move..."), this, |
648 | SLOT (moveTodo())); | 648 | SLOT (moveTodo())); |
649 | #ifndef DESKTOP_VERSION | 649 | #ifndef DESKTOP_VERSION |
650 | mItemPopupMenu->insertItem( i18n("Beam..."), this, | 650 | mItemPopupMenu->insertItem( i18n("Beam..."), this, |
651 | SLOT (beamTodo())); | 651 | SLOT (beamTodo())); |
652 | #endif | 652 | #endif |
653 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, | 653 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, |
654 | SLOT (cancelTodo())); | 654 | SLOT (cancelTodo())); |
655 | mItemPopupMenu->insertItem( i18n("Categories"), mCategoryPopupMenu); | 655 | mItemPopupMenu->insertItem( i18n("Categories"), mCategoryPopupMenu); |
656 | mItemPopupMenu->insertItem( i18n("Calendar"), mCalPopupMenu); | 656 | mItemPopupMenu->insertItem( i18n("Calendar"), mCalPopupMenu); |
657 | mItemPopupMenu->insertSeparator(); | 657 | mItemPopupMenu->insertSeparator(); |
658 | mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, | 658 | mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, |
659 | SLOT (toggleRunningItem())); | 659 | SLOT (toggleRunningItem())); |
660 | mItemPopupMenu->insertSeparator(); | 660 | mItemPopupMenu->insertSeparator(); |
661 | /* | 661 | /* |
662 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, | 662 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, |
663 | SLOT (newTodo())); | 663 | SLOT (newTodo())); |
664 | */ | 664 | */ |
665 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, | 665 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, |
666 | SLOT (newSubTodo())); | 666 | SLOT (newSubTodo())); |
667 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, | 667 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, |
668 | SLOT (unparentTodo()),0,21); | 668 | SLOT (unparentTodo()),0,21); |
669 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, | 669 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, |
670 | SLOT (reparentTodo()),0,22); | 670 | SLOT (reparentTodo()),0,22); |
671 | mItemPopupMenu->insertSeparator(); | 671 | mItemPopupMenu->insertSeparator(); |
672 | #if 0 | 672 | #if 0 |
673 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed..."), | 673 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed..."), |
674 | this, SLOT( purgeCompleted() ) ); | 674 | this, SLOT( purgeCompleted() ) ); |
675 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), | 675 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), |
676 | this, SLOT( toggleCompleted() ),0, 33 ); | 676 | this, SLOT( toggleCompleted() ),0, 33 ); |
677 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 677 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
678 | this, SLOT( toggleQuickTodo() ),0, 34 ); | 678 | this, SLOT( toggleQuickTodo() ),0, 34 ); |
679 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 679 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
680 | this, SLOT( toggleRunning() ),0, 35 ); | 680 | this, SLOT( toggleRunning() ),0, 35 ); |
681 | 681 | ||
682 | #endif | 682 | #endif |
683 | mPopupMenu = new QPopupMenu(this); | 683 | mPopupMenu = new QPopupMenu(this); |
684 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, | 684 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, |
685 | SLOT (newTodo()),0,1); | 685 | SLOT (newTodo()),0,1); |
686 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed..."), | 686 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed..."), |
687 | this, SLOT(purgeCompleted()),0,2); | 687 | this, SLOT(purgeCompleted()),0,2); |
688 | mPopupMenu->insertItem(i18n("Show Completed"), | 688 | mPopupMenu->insertItem(i18n("Show Completed"), |
689 | this, SLOT( toggleCompleted() ),0,3 ); | 689 | this, SLOT( toggleCompleted() ),0,3 ); |
690 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 690 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
691 | this, SLOT( toggleRunning() ),0,5 ); | 691 | this, SLOT( toggleRunning() ),0,5 ); |
692 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), | 692 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), |
693 | this, SLOT( setAllOpen() ),0,6 ); | 693 | this, SLOT( setAllOpen() ),0,6 ); |
694 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), | 694 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), |
695 | this, SLOT( setAllClose() ),0,7 ); | 695 | this, SLOT( setAllClose() ),0,7 ); |
696 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), | 696 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), |
697 | this, SLOT( setAllFlat() ),0,8 ); | 697 | this, SLOT( setAllFlat() ),0,8 ); |
698 | mPopupMenu->insertSeparator(); | 698 | mPopupMenu->insertSeparator(); |
699 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 699 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
700 | this, SLOT( toggleQuickTodo() ),0,4 ); | 700 | this, SLOT( toggleQuickTodo() ),0,4 ); |
701 | mDocPrefs = new DocPrefs( name ); | 701 | mDocPrefs = new DocPrefs( name ); |
702 | 702 | ||
703 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); | 703 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); |
704 | mPopupMenu->setCheckable( true ); | 704 | mPopupMenu->setCheckable( true ); |
705 | mItemPopupMenu->setCheckable( true ); | 705 | mItemPopupMenu->setCheckable( true ); |
706 | 706 | ||
707 | 707 | ||
708 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 708 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
709 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 709 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
710 | 710 | ||
711 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 711 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
712 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 712 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
713 | 713 | ||
714 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 714 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
715 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 715 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
716 | 716 | ||
717 | 717 | ||
718 | // Double clicking conflicts with opening/closing the subtree | 718 | // Double clicking conflicts with opening/closing the subtree |
719 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), | 719 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), |
720 | SLOT( editItem( QListViewItem *) ) ); | 720 | SLOT( editItem( QListViewItem *) ) ); |
721 | /* | 721 | /* |
722 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, | 722 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, |
723 | const QPoint &,int ) ), | 723 | const QPoint &,int ) ), |
724 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 724 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
725 | */ | 725 | */ |
726 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, | 726 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, |
727 | const QPoint &,int ) ), | 727 | const QPoint &,int ) ), |
728 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 728 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
729 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), | 729 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), |
730 | SLOT( itemClicked( QListViewItem * ) ) ); | 730 | SLOT( itemClicked( QListViewItem * ) ) ); |
731 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), | 731 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), |
732 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); | 732 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); |
733 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 733 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
734 | SLOT( updateView() ) ); | 734 | SLOT( updateView() ) ); |
735 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 735 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
736 | SLOT( todoModified(Todo *, int) ) ); | 736 | SLOT( todoModified(Todo *, int) ) ); |
737 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), | 737 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), |
738 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 738 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
739 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), | 739 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), |
740 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 740 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
741 | connect( mTodoListView, SIGNAL( paintNeeded() ), | 741 | connect( mTodoListView, SIGNAL( paintNeeded() ), |
742 | SLOT( paintNeeded()) ); | 742 | SLOT( paintNeeded()) ); |
743 | 743 | ||
744 | #if 0 | 744 | #if 0 |
745 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), | 745 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), |
746 | SLOT(selectionChanged(QListViewItem *))); | 746 | SLOT(selectionChanged(QListViewItem *))); |
747 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), | 747 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), |
748 | SLOT(selectionChanged(QListViewItem *))); | 748 | SLOT(selectionChanged(QListViewItem *))); |
749 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), | 749 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), |
750 | SLOT(selectionChanged(QListViewItem *))); | 750 | SLOT(selectionChanged(QListViewItem *))); |
751 | #endif | 751 | #endif |
752 | 752 | ||
753 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); | 753 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); |
754 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); | 754 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); |
755 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); | 755 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); |
756 | 756 | ||
757 | connect( mTodoListView, SIGNAL(selectionChanged() ), | 757 | connect( mTodoListView, SIGNAL(selectionChanged() ), |
758 | SLOT( processSelectionChange() ) ); | 758 | SLOT( processSelectionChange() ) ); |
759 | connect( mQuickAdd, SIGNAL( returnPressed () ), | 759 | connect( mQuickAdd, SIGNAL( returnPressed () ), |
760 | SLOT( addQuickTodo() ) ); | 760 | SLOT( addQuickTodo() ) ); |
761 | 761 | ||
762 | } | 762 | } |
763 | 763 | ||
764 | KOTodoView::~KOTodoView() | 764 | KOTodoView::~KOTodoView() |
765 | { | 765 | { |
766 | 766 | ||
767 | #if QT_VERSION >= 0x030000 | 767 | #if QT_VERSION >= 0x030000 |
768 | 768 | ||
769 | #else | 769 | #else |
770 | delete mKOTodoViewWhatsThis; | 770 | delete mKOTodoViewWhatsThis; |
771 | #endif | 771 | #endif |
772 | 772 | ||
773 | delete mDocPrefs; | 773 | delete mDocPrefs; |
774 | } | 774 | } |
775 | QString KOTodoView::getWhatsThisText(QPoint p) | 775 | QString KOTodoView::getWhatsThisText(QPoint p) |
776 | { | 776 | { |
777 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); | 777 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); |
778 | if ( item ) | 778 | if ( item ) |
779 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), | 779 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), |
780 | KOPrefs::instance()->mWTshowDetails, | 780 | KOPrefs::instance()->mWTshowDetails, |
781 | KOPrefs::instance()->mWTshowCreated, | 781 | KOPrefs::instance()->mWTshowCreated, |
782 | KOPrefs::instance()->mWTshowChanged); | 782 | KOPrefs::instance()->mWTshowChanged); |
783 | return i18n("That is the todo view" ); | 783 | return i18n("That is the todo view" ); |
784 | 784 | ||
785 | } | 785 | } |
786 | 786 | ||
787 | void KOTodoView::jumpToDate () | 787 | void KOTodoView::jumpToDate () |
788 | { | 788 | { |
789 | // if (mActiveItem) { | 789 | // if (mActiveItem) { |
790 | // mActiveItem->todo()); | 790 | // mActiveItem->todo()); |
791 | // if ( mActiveItem->todo()->hasDueDate() ) | 791 | // if ( mActiveItem->todo()->hasDueDate() ) |
792 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); | 792 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); |
793 | } | 793 | } |
794 | void KOTodoView::paintNeeded() | 794 | void KOTodoView::paintNeeded() |
795 | { | 795 | { |
796 | if ( mPendingUpdateBeforeRepaint ) { | 796 | if ( mPendingUpdateBeforeRepaint ) { |
797 | updateView(); | 797 | updateView(); |
798 | mPendingUpdateBeforeRepaint = false; | 798 | mPendingUpdateBeforeRepaint = false; |
799 | } | 799 | } |
800 | } | 800 | } |
801 | void KOTodoView::paintEvent(QPaintEvent * pevent) | 801 | void KOTodoView::paintEvent(QPaintEvent * pevent) |
802 | { | 802 | { |
803 | if ( mPendingUpdateBeforeRepaint ) { | 803 | if ( mPendingUpdateBeforeRepaint ) { |
804 | updateView(); | 804 | updateView(); |
805 | mPendingUpdateBeforeRepaint = false; | 805 | mPendingUpdateBeforeRepaint = false; |
806 | } | 806 | } |
807 | KOrg::BaseView::paintEvent( pevent); | 807 | KOrg::BaseView::paintEvent( pevent); |
808 | } | 808 | } |
809 | 809 | ||
810 | void KOTodoView::updateView() | 810 | void KOTodoView::updateView() |
811 | { | 811 | { |
812 | pendingSubtodo = 0; | 812 | pendingSubtodo = 0; |
813 | if ( mBlockUpdate ) { | 813 | if ( mBlockUpdate ) { |
814 | return; | 814 | return; |
815 | } | 815 | } |
816 | if ( !isVisible() ) { | 816 | if ( !isVisible() ) { |
817 | mPendingUpdateBeforeRepaint = true; | 817 | mPendingUpdateBeforeRepaint = true; |
818 | return; | 818 | return; |
819 | } | 819 | } |
820 | //qDebug("KOTodoView::updateView() %x", this); | 820 | //qDebug("KOTodoView::updateView() %x", this); |
821 | if ( isFlatDisplay ) { | 821 | if ( isFlatDisplay ) { |
822 | displayAllFlat(); | 822 | displayAllFlat(); |
823 | return; | 823 | return; |
824 | } | 824 | } |
825 | storeCurrentItem(); | 825 | storeCurrentItem(); |
826 | //qDebug("update "); | 826 | //qDebug("update "); |
827 | // kdDebug() << "KOTodoView::updateView()" << endl; | 827 | // kdDebug() << "KOTodoView::updateView()" << endl; |
828 | QFont fo = KOPrefs::instance()->mTodoViewFont; | 828 | QFont fo = KOPrefs::instance()->mTodoViewFont; |
829 | 829 | ||
830 | 830 | ||
831 | mTodoListView->clear(); | 831 | mTodoListView->clear(); |
832 | if ( mName == "todolistsmall" ) { | 832 | if ( mName == "todolistsmall" ) { |
833 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { | 833 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { |
834 | int ps = fo.pointSize() -2; | 834 | int ps = fo.pointSize() -2; |
835 | if ( ps > 12 ) | 835 | if ( ps > 12 ) |
836 | ps -= 2; | 836 | ps -= 2; |
837 | fo.setPointSize( ps ); | 837 | fo.setPointSize( ps ); |
838 | } | 838 | } |
839 | } | 839 | } |
840 | 840 | ||
841 | mTodoListView->setFont( fo ); | 841 | mTodoListView->setFont( fo ); |
842 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); | 842 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); |
843 | //mTodoListView->header()->setMaximumHeight(fm.height()); | 843 | //mTodoListView->header()->setMaximumHeight(fm.height()); |
844 | QPtrList<Todo> todoList = calendar()->todos(); | 844 | QPtrList<Todo> todoList = calendar()->todos(); |
845 | 845 | ||
846 | /* | 846 | /* |
847 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; | 847 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; |
848 | Event *t; | 848 | Event *t; |
849 | for(t = todoList.first(); t; t = todoList.next()) { | 849 | for(t = todoList.first(); t; t = todoList.next()) { |
850 | kdDebug() << " " << t->getSummary() << endl; | 850 | kdDebug() << " " << t->getSummary() << endl; |
851 | 851 | ||
852 | if (t->getRelatedTo()) { | 852 | if (t->getRelatedTo()) { |
853 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; | 853 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; |
854 | } | 854 | } |
855 | 855 | ||
856 | QPtrList<Event> l = t->getRelations(); | 856 | QPtrList<Event> l = t->getRelations(); |
857 | Event *c; | 857 | Event *c; |
858 | for(c=l.first();c;c=l.next()) { | 858 | for(c=l.first();c;c=l.next()) { |
859 | kdDebug() << " - relation: " << c->getSummary() << endl; | 859 | kdDebug() << " - relation: " << c->getSummary() << endl; |
860 | } | 860 | } |
861 | } | 861 | } |
862 | */ | 862 | */ |
863 | 863 | ||
864 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a | 864 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a |
865 | // specific order of events. That means that we have to generate parent items | 865 | // specific order of events. That means that we have to generate parent items |
866 | // recursively for proper hierarchical display of Todos. | 866 | // recursively for proper hierarchical display of Todos. |
867 | mTodoMap.clear(); | 867 | mTodoMap.clear(); |
868 | Todo *todo; | 868 | Todo *todo; |
869 | todo = todoList.first();// todo; todo = todoList.next()) { | 869 | todo = todoList.first();// todo; todo = todoList.next()) { |
870 | while ( todo ) { | 870 | while ( todo ) { |
871 | bool next = true; | 871 | bool next = true; |
872 | // qDebug("todo %s ", todo->summary().latin1()); | 872 | // qDebug("todo %s ", todo->summary().latin1()); |
873 | Incidence *incidence = todo->relatedTo(); | 873 | Incidence *incidence = todo->relatedTo(); |
874 | while ( incidence ) { | 874 | while ( incidence ) { |
875 | if ( incidence->typeID() == todoID ) { | 875 | if ( incidence->typeID() == todoID ) { |
876 | //qDebug("related %s ",incidence->summary().latin1() ); | 876 | //qDebug("related %s ",incidence->summary().latin1() ); |
877 | if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { | 877 | if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { |
878 | //qDebug("related not found "); | 878 | //qDebug("related not found "); |
879 | todoList.remove( ); | 879 | todoList.remove( ); |
880 | todo = todoList.current(); | 880 | todo = todoList.current(); |
881 | next = false; | 881 | next = false; |
882 | incidence = 0; | 882 | incidence = 0; |
883 | 883 | ||
884 | } else { | 884 | } else { |
885 | //qDebug("related found "); | 885 | //qDebug("related found "); |
886 | incidence = incidence->relatedTo(); | 886 | incidence = incidence->relatedTo(); |
887 | } | 887 | } |
888 | } else | 888 | } else |
889 | incidence = 0; | 889 | incidence = 0; |
890 | } | 890 | } |
891 | if ( next ) | 891 | if ( next ) |
892 | todo = todoList.next(); | 892 | todo = todoList.next(); |
893 | } | 893 | } |
894 | 894 | ||
895 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 895 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
896 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) | 896 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) |
897 | { | 897 | { |
898 | insertTodoItem(todo); | 898 | insertTodoItem(todo); |
899 | } | 899 | } |
900 | } | 900 | } |
901 | // Restore opened/closed state | 901 | // Restore opened/closed state |
902 | mTodoListView->blockSignals( true ); | 902 | mTodoListView->blockSignals( true ); |
903 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); | 903 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); |
904 | mTodoListView->blockSignals( false ); | 904 | mTodoListView->blockSignals( false ); |
905 | resetCurrentItem(); | 905 | resetCurrentItem(); |
906 | } | 906 | } |
907 | 907 | ||
908 | void KOTodoView::storeCurrentItem() | 908 | void KOTodoView::storeCurrentItem() |
909 | { | 909 | { |
910 | mCurItem = 0; | 910 | mCurItem = 0; |
911 | mCurItemRootParent = 0; | 911 | mCurItemRootParent = 0; |
912 | mCurItemParent = 0; | 912 | mCurItemParent = 0; |
913 | mCurItemAbove = 0; | 913 | mCurItemAbove = 0; |
914 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 914 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
915 | if (mActiveItem) { | 915 | if (mActiveItem) { |
916 | mCurItem = mActiveItem->todo(); | 916 | mCurItem = mActiveItem->todo(); |
917 | KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); | 917 | KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); |
918 | if ( activeItemAbove ) | 918 | if ( activeItemAbove ) |
919 | mCurItemAbove = activeItemAbove->todo(); | 919 | mCurItemAbove = activeItemAbove->todo(); |
920 | mCurItemRootParent = mCurItem; | 920 | mCurItemRootParent = mCurItem; |
921 | mCurItemParent = mCurItemRootParent->relatedTo(); | 921 | mCurItemParent = mCurItemRootParent->relatedTo(); |
922 | while ( mCurItemRootParent->relatedTo() != 0 ) | 922 | while ( mCurItemRootParent->relatedTo() != 0 ) |
923 | mCurItemRootParent = mCurItemRootParent->relatedTo(); | 923 | mCurItemRootParent = mCurItemRootParent->relatedTo(); |
924 | } | 924 | } |
925 | mActiveItem = 0; | 925 | mActiveItem = 0; |
926 | } | 926 | } |
927 | 927 | ||
928 | void KOTodoView::resetCurrentItem() | 928 | void KOTodoView::resetCurrentItem() |
929 | { | 929 | { |
930 | //mTodoListView->setFocus(); | 930 | //mTodoListView->setFocus(); |
931 | KOTodoViewItem* foundItem = 0; | 931 | KOTodoViewItem* foundItem = 0; |
932 | KOTodoViewItem* foundItemRoot = 0; | 932 | KOTodoViewItem* foundItemRoot = 0; |
933 | KOTodoViewItem* foundItemParent = 0; | 933 | KOTodoViewItem* foundItemParent = 0; |
934 | KOTodoViewItem* foundItemAbove = 0; | 934 | KOTodoViewItem* foundItemAbove = 0; |
935 | if ( mTodoListView->firstChild () ) { | 935 | if ( mTodoListView->firstChild () ) { |
936 | if ( mCurItem ) { | 936 | if ( mCurItem ) { |
937 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); | 937 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); |
938 | while ( item ) { | 938 | while ( item ) { |
939 | if ( item->todo() == mCurItem ) { | 939 | if ( item->todo() == mCurItem ) { |
940 | foundItem = item; | 940 | foundItem = item; |
941 | break; | 941 | break; |
942 | } else if ( item->todo() == mCurItemAbove ) { | 942 | } else if ( item->todo() == mCurItemAbove ) { |
943 | foundItemAbove = item; | 943 | foundItemAbove = item; |
944 | 944 | ||
945 | } | 945 | } |
946 | if ( item->todo() == mCurItemRootParent ) { | 946 | if ( item->todo() == mCurItemRootParent ) { |
947 | foundItemRoot = item; | 947 | foundItemRoot = item; |
948 | } | 948 | } |
949 | if ( item->todo() == mCurItemParent ) { | 949 | if ( item->todo() == mCurItemParent ) { |
950 | foundItemParent = item; | 950 | foundItemParent = item; |
951 | } | 951 | } |
952 | item = (KOTodoViewItem*)item->itemBelow(); | 952 | item = (KOTodoViewItem*)item->itemBelow(); |
953 | } | 953 | } |
954 | if ( ! foundItem ) { | 954 | if ( ! foundItem ) { |
955 | if ( foundItemParent ) { | 955 | if ( foundItemParent ) { |
956 | foundItem = foundItemParent; | 956 | foundItem = foundItemParent; |
957 | } else { | 957 | } else { |
958 | if ( foundItemRoot ) | 958 | if ( foundItemRoot ) |
959 | foundItem = foundItemRoot; | 959 | foundItem = foundItemRoot; |
960 | else | 960 | else |
961 | foundItem = foundItemAbove; | 961 | foundItem = foundItemAbove; |
962 | } | 962 | } |
963 | } | 963 | } |
964 | } | 964 | } |
965 | if ( foundItem ) { | 965 | if ( foundItem ) { |
966 | mTodoListView->setSelected ( foundItem, true ); | 966 | mTodoListView->setSelected ( foundItem, true ); |
967 | mTodoListView->setCurrentItem( foundItem ); | 967 | mTodoListView->setCurrentItem( foundItem ); |
968 | mTodoListView->ensureItemVisible( foundItem ); | 968 | mTodoListView->ensureItemVisible( foundItem ); |
969 | } else { | 969 | } else { |
970 | if ( mTodoListView->firstChild () ) { | 970 | if ( mTodoListView->firstChild () ) { |
971 | mTodoListView->setSelected ( mTodoListView->firstChild (), true ); | 971 | mTodoListView->setSelected ( mTodoListView->firstChild (), true ); |
972 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); | 972 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); |
973 | } | 973 | } |
974 | } | 974 | } |
975 | } | 975 | } |
976 | processSelectionChange(); | 976 | processSelectionChange(); |
977 | QTimer::singleShot( 100, this, SLOT ( resetFocusToList() )); | 977 | QTimer::singleShot( 100, this, SLOT ( resetFocusToList() )); |
978 | } | 978 | } |
979 | void KOTodoView::resetFocusToList() | 979 | void KOTodoView::resetFocusToList() |
980 | { | 980 | { |
981 | topLevelWidget()->setActiveWindow(); | 981 | topLevelWidget()->setActiveWindow(); |
982 | mTodoListView->setFocus(); | 982 | mTodoListView->setFocus(); |
983 | } | 983 | } |
984 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; | 984 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; |
985 | bool KOTodoView::checkTodo( Todo * todo ) | 985 | bool KOTodoView::checkTodo( Todo * todo ) |
986 | { | 986 | { |
987 | 987 | ||
988 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) | 988 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) |
989 | return false; | 989 | return false; |
990 | if ( !todo->isCompleted() ) { | 990 | if ( !todo->isCompleted() ) { |
991 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) | 991 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) |
992 | return true; | 992 | return true; |
993 | } | 993 | } |
994 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { | 994 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { |
995 | if ( todo->hasStartDate() ) | 995 | if ( todo->hasStartDate() ) |
996 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) | 996 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) |
997 | return false; | 997 | return false; |
998 | if ( todo->hasDueDate() ) | 998 | if ( todo->hasDueDate() ) |
999 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) | 999 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) |
1000 | return false; | 1000 | return false; |
1001 | } | 1001 | } |
1002 | return true; | 1002 | return true; |
1003 | } | 1003 | } |
1004 | 1004 | ||
1005 | void KOTodoView::restoreItemState( QListViewItem *item ) | 1005 | void KOTodoView::restoreItemState( QListViewItem *item ) |
1006 | { | 1006 | { |
1007 | pendingSubtodo = 0; | 1007 | pendingSubtodo = 0; |
1008 | while( item ) { | 1008 | while( item ) { |
1009 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1009 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1010 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); | 1010 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); |
1011 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); | 1011 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); |
1012 | item = item->nextSibling(); | 1012 | item = item->nextSibling(); |
1013 | } | 1013 | } |
1014 | } | 1014 | } |
1015 | 1015 | ||
1016 | 1016 | ||
1017 | QMap<Todo *,KOTodoViewItem *>::ConstIterator | 1017 | QMap<Todo *,KOTodoViewItem *>::ConstIterator |
1018 | KOTodoView::insertTodoItem(Todo *todo) | 1018 | KOTodoView::insertTodoItem(Todo *todo) |
1019 | { | 1019 | { |
1020 | 1020 | ||
1021 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; | 1021 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; |
1022 | // TODO: Check, if dynmaic cast is necessary | 1022 | // TODO: Check, if dynmaic cast is necessary |
1023 | 1023 | ||
1024 | pendingSubtodo = 0; | 1024 | pendingSubtodo = 0; |
1025 | Incidence *incidence = todo->relatedTo(); | 1025 | Incidence *incidence = todo->relatedTo(); |
1026 | while ( incidence && !incidence->calEnabled() ) | 1026 | while ( incidence && !incidence->calEnabled() ) |
1027 | incidence = incidence->relatedTo(); | 1027 | incidence = incidence->relatedTo(); |
1028 | if (incidence && incidence->typeID() == todoID ) { | 1028 | if (incidence && incidence->typeID() == todoID ) { |
1029 | Todo *relatedTodo = static_cast<Todo *>(incidence); | 1029 | Todo *relatedTodo = static_cast<Todo *>(incidence); |
1030 | 1030 | ||
1031 | // kdDebug() << " has Related" << endl; | 1031 | // kdDebug() << " has Related" << endl; |
1032 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 1032 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
1033 | itemIterator = mTodoMap.find(relatedTodo); | 1033 | itemIterator = mTodoMap.find(relatedTodo); |
1034 | if (itemIterator == mTodoMap.end()) { | 1034 | if (itemIterator == mTodoMap.end()) { |
1035 | // kdDebug() << " related not yet in list" << endl; | 1035 | // kdDebug() << " related not yet in list" << endl; |
1036 | itemIterator = insertTodoItem (relatedTodo); | 1036 | itemIterator = insertTodoItem (relatedTodo); |
1037 | } | 1037 | } |
1038 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem | 1038 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem |
1039 | // and one into the map. Sure finding is more easy but why? -zecke | 1039 | // and one into the map. Sure finding is more easy but why? -zecke |
1040 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); | 1040 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); |
1041 | return mTodoMap.insert(todo,todoItem); | 1041 | return mTodoMap.insert(todo,todoItem); |
1042 | } else { | 1042 | } else { |
1043 | // kdDebug() << " no Related" << endl; | 1043 | // kdDebug() << " no Related" << endl; |
1044 | // see above -zecke | 1044 | // see above -zecke |
1045 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 1045 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
1046 | return mTodoMap.insert(todo,todoItem); | 1046 | return mTodoMap.insert(todo,todoItem); |
1047 | } | 1047 | } |
1048 | } | 1048 | } |
1049 | 1049 | ||
1050 | 1050 | ||
1051 | void KOTodoView::updateConfig() | 1051 | void KOTodoView::updateConfig() |
1052 | { | 1052 | { |
1053 | updateView(); | 1053 | updateView(); |
1054 | mTodoListView->repaintContents(); | 1054 | mTodoListView->repaintContents(); |
1055 | } | 1055 | } |
1056 | 1056 | ||
1057 | QPtrList<Incidence> KOTodoView::selectedIncidences() | 1057 | QPtrList<Incidence> KOTodoView::selectedIncidences() |
1058 | { | 1058 | { |
1059 | QPtrList<Incidence> selected; | 1059 | QPtrList<Incidence> selected; |
1060 | 1060 | ||
1061 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 1061 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
1062 | // if (!item) item = mActiveItem; | 1062 | // if (!item) item = mActiveItem; |
1063 | if (item) selected.append(item->todo()); | 1063 | if (item) selected.append(item->todo()); |
1064 | 1064 | ||
1065 | return selected; | 1065 | return selected; |
1066 | } | 1066 | } |
1067 | 1067 | ||
1068 | QPtrList<Todo> KOTodoView::selectedTodos() | 1068 | QPtrList<Todo> KOTodoView::selectedTodos() |
1069 | { | 1069 | { |
1070 | QPtrList<Todo> selected; | 1070 | QPtrList<Todo> selected; |
1071 | 1071 | ||
1072 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 1072 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
1073 | // if (!item) item = mActiveItem; | 1073 | // if (!item) item = mActiveItem; |
1074 | if (item) selected.append(item->todo()); | 1074 | if (item) selected.append(item->todo()); |
1075 | 1075 | ||
1076 | return selected; | 1076 | return selected; |
1077 | } | 1077 | } |
1078 | 1078 | ||
1079 | void KOTodoView::changeEventDisplay(Event *, int) | 1079 | void KOTodoView::changeEventDisplay(Event *, int) |
1080 | { | 1080 | { |
1081 | updateView(); | 1081 | updateView(); |
1082 | } | 1082 | } |
1083 | 1083 | ||
1084 | void KOTodoView::showDates(const QDate &, const QDate &) | 1084 | void KOTodoView::showDates(const QDate &, const QDate &) |
1085 | { | 1085 | { |
1086 | } | 1086 | } |
1087 | 1087 | ||
1088 | void KOTodoView::showEvents(QPtrList<Event>) | 1088 | void KOTodoView::showEvents(QPtrList<Event>) |
1089 | { | 1089 | { |
1090 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; | 1090 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; |
1091 | } | 1091 | } |
1092 | 1092 | ||
1093 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1093 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1094 | const QDate &td) | 1094 | const QDate &td) |
1095 | { | 1095 | { |
1096 | #ifndef KORG_NOPRINTER | 1096 | #ifndef KORG_NOPRINTER |
1097 | calPrinter->preview(CalPrinter::Todolist, fd, td); | 1097 | calPrinter->preview(CalPrinter::Todolist, fd, td); |
1098 | #endif | 1098 | #endif |
1099 | } | 1099 | } |
1100 | 1100 | ||
1101 | void KOTodoView::editItem(QListViewItem *item ) | 1101 | void KOTodoView::editItem(QListViewItem *item ) |
1102 | { | 1102 | { |
1103 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); | 1103 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); |
1104 | } | 1104 | } |
1105 | 1105 | ||
1106 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) | 1106 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) |
1107 | { | 1107 | { |
1108 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); | 1108 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); |
1109 | } | 1109 | } |
1110 | 1110 | ||
1111 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) | 1111 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) |
1112 | { | 1112 | { |
1113 | pendingSubtodo = 0; | 1113 | pendingSubtodo = 0; |
1114 | mActiveItem = (KOTodoViewItem *)item; | 1114 | mActiveItem = (KOTodoViewItem *)item; |
1115 | if (item) { | 1115 | if (item) { |
1116 | switch (column){ | 1116 | switch (column){ |
1117 | case 1: | 1117 | case 1: |
1118 | mPriorityPopupMenu->popup(QCursor::pos ()); break; | 1118 | mPriorityPopupMenu->popup(QCursor::pos ()); break; |
1119 | case 2: | 1119 | case 2: |
1120 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; | 1120 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; |
1121 | case 3: | 1121 | case 3: |
1122 | moveTodo(); | 1122 | moveTodo(); |
1123 | break; | 1123 | break; |
1124 | case 7: | 1124 | case 7: |
1125 | mCategoryPopupMenu->popup(QCursor::pos ()); break; | 1125 | mCategoryPopupMenu->popup(QCursor::pos ()); break; |
1126 | case 8: | 1126 | case 8: |
1127 | mCalPopupMenu->popup(QCursor::pos ()); break; | 1127 | mCalPopupMenu->popup(QCursor::pos ()); break; |
1128 | default: | 1128 | default: |
1129 | mItemPopupMenu->popup(QCursor::pos()); | 1129 | mItemPopupMenu->popup(QCursor::pos()); |
1130 | } | 1130 | } |
1131 | } else mPopupMenu->popup(QCursor::pos()); | 1131 | } else mPopupMenu->popup(QCursor::pos()); |
1132 | } | 1132 | } |
1133 | void KOTodoView::newTodo() | 1133 | void KOTodoView::newTodo() |
1134 | { | 1134 | { |
1135 | emit newTodoSignal(); | 1135 | emit newTodoSignal(); |
1136 | } | 1136 | } |
1137 | 1137 | ||
1138 | void KOTodoView::newSubTodo() | 1138 | void KOTodoView::newSubTodo() |
1139 | { | 1139 | { |
1140 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1140 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1141 | if (mActiveItem) { | 1141 | if (mActiveItem) { |
1142 | if ( mQuickAdd->isVisible() && !mQuickAdd->text().isEmpty() && mQuickAdd->text() != i18n("Click to add new Todo") ) { | 1142 | if ( mQuickAdd->isVisible() && !mQuickAdd->text().isEmpty() && mQuickAdd->text() != i18n("Click to add new Todo") ) { |
1143 | addQuickTodoPar( mActiveItem->todo()); | 1143 | addQuickTodoPar( mActiveItem->todo()); |
1144 | } else | 1144 | } else |
1145 | emit newSubTodoSignal(mActiveItem->todo()); | 1145 | emit newSubTodoSignal(mActiveItem->todo()); |
1146 | } | 1146 | } |
1147 | } | 1147 | } |
1148 | void KOTodoView::unparentTodo() | 1148 | void KOTodoView::unparentTodo() |
1149 | { | 1149 | { |
1150 | if (mActiveItem) { | 1150 | if (mActiveItem) { |
1151 | emit unparentTodoSignal(mActiveItem->todo()); | 1151 | emit unparentTodoSignal(mActiveItem->todo()); |
1152 | } | 1152 | } |
1153 | } | 1153 | } |
1154 | 1154 | ||
1155 | void KOTodoView::reparentTodo() | 1155 | void KOTodoView::reparentTodo() |
1156 | { | 1156 | { |
1157 | if (mActiveItem) { | 1157 | if (mActiveItem) { |
1158 | topLevelWidget()->setCaption(i18n("Click on new parent item")); | 1158 | topLevelWidget()->setCaption(i18n("Click on new parent item")); |
1159 | pendingSubtodo = mActiveItem; | 1159 | pendingSubtodo = mActiveItem; |
1160 | } | 1160 | } |
1161 | } | 1161 | } |
1162 | void KOTodoView::editTodo() | 1162 | void KOTodoView::editTodo() |
1163 | { | 1163 | { |
1164 | if (mActiveItem) { | 1164 | if (mActiveItem) { |
1165 | emit editTodoSignal(mActiveItem->todo()); | 1165 | emit editTodoSignal(mActiveItem->todo()); |
1166 | } | 1166 | } |
1167 | } | 1167 | } |
1168 | void KOTodoView::cloneTodo() | 1168 | void KOTodoView::cloneTodo() |
1169 | { | 1169 | { |
1170 | if (mActiveItem) { | 1170 | if (mActiveItem) { |
1171 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); | 1171 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); |
1172 | } | 1172 | } |
1173 | } | 1173 | } |
1174 | void KOTodoView::cancelTodo() | 1174 | void KOTodoView::cancelTodo() |
1175 | { | 1175 | { |
1176 | if (mActiveItem) { | 1176 | if (mActiveItem) { |
1177 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); | 1177 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); |
1178 | } | 1178 | } |
1179 | } | 1179 | } |
1180 | void KOTodoView::moveTodo() | 1180 | void KOTodoView::moveTodo() |
1181 | { | 1181 | { |
1182 | if (mActiveItem) { | 1182 | if (mActiveItem) { |
1183 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); | 1183 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); |
1184 | } | 1184 | } |
1185 | } | 1185 | } |
1186 | void KOTodoView::beamTodo() | 1186 | void KOTodoView::beamTodo() |
1187 | { | 1187 | { |
1188 | if (mActiveItem) { | 1188 | if (mActiveItem) { |
1189 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); | 1189 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); |
1190 | } | 1190 | } |
1191 | } | 1191 | } |
1192 | 1192 | ||
1193 | 1193 | ||
1194 | void KOTodoView::showTodo() | 1194 | void KOTodoView::showTodo() |
1195 | { | 1195 | { |
1196 | if (mActiveItem) { | 1196 | if (mActiveItem) { |
1197 | emit showTodoSignal(mActiveItem->todo()); | 1197 | emit showTodoSignal(mActiveItem->todo()); |
1198 | } | 1198 | } |
1199 | } | 1199 | } |
1200 | 1200 | ||
1201 | void KOTodoView::deleteTodo() | 1201 | void KOTodoView::deleteTodo() |
1202 | { | 1202 | { |
1203 | if (mActiveItem) { | 1203 | if (mActiveItem) { |
1204 | emit deleteTodoSignal(mActiveItem->todo()); | 1204 | emit deleteTodoSignal(mActiveItem->todo()); |
1205 | } | 1205 | } |
1206 | } | 1206 | } |
1207 | 1207 | ||
1208 | void KOTodoView::setNewPriority(int index) | 1208 | void KOTodoView::setNewPriority(int index) |
1209 | { | 1209 | { |
1210 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1210 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1211 | mActiveItem->todo()->setPriority(mPriority[index]); | 1211 | mActiveItem->todo()->setPriority(mPriority[index]); |
1212 | mActiveItem->construct(); | 1212 | mActiveItem->construct(); |
1213 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); | 1213 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); |
1214 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1214 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1215 | } | 1215 | } |
1216 | processSelectionChange(); | 1216 | processSelectionChange(); |
1217 | } | 1217 | } |
1218 | 1218 | ||
1219 | void KOTodoView::setNewPercentage(int index) | 1219 | void KOTodoView::setNewPercentage(int index) |
1220 | { | 1220 | { |
1221 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1221 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1222 | 1222 | ||
1223 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { | 1223 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { |
1224 | mActiveItem->setOn( true ); | 1224 | mActiveItem->setOn( true ); |
1225 | processSelectionChange(); | 1225 | processSelectionChange(); |
1226 | return; | 1226 | return; |
1227 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { | 1227 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { |
1228 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); | 1228 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); |
1229 | if ( par && par->isOn() ) | 1229 | if ( par && par->isOn() ) |
1230 | par->setOn( false ); | 1230 | par->setOn( false ); |
1231 | } | 1231 | } |
1232 | if (mPercentage[index] == 100) { | 1232 | if (mPercentage[index] == 100) { |
1233 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); | 1233 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); |
1234 | } else { | 1234 | } else { |
1235 | mActiveItem->todo()->setCompleted(false); | 1235 | mActiveItem->todo()->setCompleted(false); |
1236 | } | 1236 | } |
1237 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); | 1237 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); |
1238 | mActiveItem->construct(); | 1238 | mActiveItem->construct(); |
1239 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); | 1239 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); |
1240 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1240 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1241 | } | 1241 | } |
1242 | processSelectionChange(); | 1242 | processSelectionChange(); |
1243 | } | 1243 | } |
1244 | 1244 | ||
1245 | void KOTodoView::fillCategories () | 1245 | void KOTodoView::fillCategories () |
1246 | { | 1246 | { |
1247 | mCategoryPopupMenu->clear(); | 1247 | mCategoryPopupMenu->clear(); |
1248 | if ( ! mActiveItem ) return; | 1248 | if ( ! mActiveItem ) return; |
1249 | QStringList checkedCategories = mActiveItem->todo()->categories (); | 1249 | QStringList checkedCategories = mActiveItem->todo()->categories (); |
1250 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); | 1250 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); |
1251 | it != KOPrefs::instance()->mCustomCategories.end (); | 1251 | it != KOPrefs::instance()->mCustomCategories.end (); |
1252 | ++it) { | 1252 | ++it) { |
1253 | int index = mCategoryPopupMenu->insertItem (*it); | 1253 | int index = mCategoryPopupMenu->insertItem (*it); |
1254 | mCategory[index] = *it; | 1254 | mCategory[index] = *it; |
1255 | if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true); | 1255 | if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true); |
1256 | } | 1256 | } |
1257 | } | 1257 | } |
1258 | void KOTodoView::fillCal () | 1258 | void KOTodoView::fillCal () |
1259 | { | 1259 | { |
1260 | mCalPopupMenu->clear(); | 1260 | mCalPopupMenu->clear(); |
1261 | if (!mActiveItem) return; | 1261 | if (!mActiveItem) return; |
1262 | bool readO = mActiveItem->todo()->isReadOnly(); | 1262 | bool readO = mActiveItem->todo()->isReadOnly(); |
1263 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 1263 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
1264 | while ( kkf ) { | 1264 | while ( kkf ) { |
1265 | int index = mCalPopupMenu->insertItem( kkf->mName, kkf->mCalNumber); | 1265 | int index = mCalPopupMenu->insertItem( kkf->mName, kkf->mCalNumber); |
1266 | if ( kkf->mErrorOnLoad || kkf->isReadOnly || readO ) | 1266 | if ( kkf->mErrorOnLoad || kkf->isReadOnly || readO ) |
1267 | mCalPopupMenu->setItemEnabled( index, false ); | 1267 | mCalPopupMenu->setItemEnabled( index, false ); |
1268 | mCalPopupMenu->setItemChecked (index, kkf->mCalNumber == mActiveItem->todo()->calID()); | 1268 | mCalPopupMenu->setItemChecked (index, kkf->mCalNumber == mActiveItem->todo()->calID()); |
1269 | kkf = KOPrefs::instance()->mCalendars.next(); | 1269 | kkf = KOPrefs::instance()->mCalendars.next(); |
1270 | } | 1270 | } |
1271 | } | 1271 | } |
1272 | void KOTodoView::changedCal (int index ) | 1272 | void KOTodoView::changedCal (int index ) |
1273 | { | 1273 | { |
1274 | if (!mActiveItem) return; | 1274 | if (!mActiveItem) return; |
1275 | mActiveItem->todo()->setCalID( index ); | 1275 | mActiveItem->todo()->setCalID( index ); |
1276 | mActiveItem->construct(); | 1276 | mActiveItem->construct(); |
1277 | } | 1277 | } |
1278 | void KOTodoView::changedCategories(int index) | 1278 | void KOTodoView::changedCategories(int index) |
1279 | { | 1279 | { |
1280 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1280 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1281 | QStringList categories = mActiveItem->todo()->categories (); | 1281 | QStringList categories = mActiveItem->todo()->categories (); |
1282 | QString colcat = categories.first(); | 1282 | QString colcat = categories.first(); |
1283 | if (categories.find (mCategory[index]) != categories.end ()) | 1283 | if (categories.find (mCategory[index]) != categories.end ()) |
1284 | categories.remove (mCategory[index]); | 1284 | categories.remove (mCategory[index]); |
1285 | else | 1285 | else |
1286 | categories.insert (categories.end(), mCategory[index]); | 1286 | categories.insert (categories.end(), mCategory[index]); |
1287 | categories.sort (); | 1287 | categories.sort (); |
1288 | if ( !colcat.isEmpty() ) { | 1288 | if ( !colcat.isEmpty() ) { |
1289 | if ( categories.find ( colcat ) != categories.end () ) { | 1289 | if ( categories.find ( colcat ) != categories.end () ) { |
1290 | categories.remove( colcat ); | 1290 | categories.remove( colcat ); |
1291 | categories.prepend( colcat ); | 1291 | categories.prepend( colcat ); |
1292 | } | 1292 | } |
1293 | } | 1293 | } |
1294 | mActiveItem->todo()->setCategories (categories); | 1294 | mActiveItem->todo()->setCategories (categories); |
1295 | mActiveItem->construct(); | 1295 | mActiveItem->construct(); |
1296 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1296 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1297 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); | 1297 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); |
1298 | } | 1298 | } |
1299 | } | 1299 | } |
1300 | void KOTodoView::itemDoubleClicked(QListViewItem *item) | 1300 | void KOTodoView::itemDoubleClicked(QListViewItem *item) |
1301 | { | 1301 | { |
1302 | if ( pendingSubtodo != 0 ) { | 1302 | if ( pendingSubtodo != 0 ) { |
1303 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1303 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
1304 | } | 1304 | } |
1305 | pendingSubtodo = 0; | 1305 | pendingSubtodo = 0; |
1306 | //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); | 1306 | //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); |
1307 | int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); | 1307 | int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); |
1308 | //qDebug("ROW %d ", row); | 1308 | //qDebug("ROW %d ", row); |
1309 | if (!item) { | 1309 | if (!item) { |
1310 | newTodo(); | 1310 | newTodo(); |
1311 | return; | 1311 | return; |
1312 | } else { | 1312 | } else { |
1313 | if ( row == 1 ) { | 1313 | if ( row == 1 ) { |
1314 | mActiveItem = (KOTodoViewItem *) item; | 1314 | mActiveItem = (KOTodoViewItem *) item; |
1315 | newSubTodo(); | 1315 | newSubTodo(); |
1316 | return; | 1316 | return; |
1317 | } | 1317 | } |
1318 | if ( row == 5 || row == 6 || row == 2) { | 1318 | if ( row == 5 || row == 6 || row == 2) { |
1319 | mActiveItem = (KOTodoViewItem *) item; | 1319 | mActiveItem = (KOTodoViewItem *) item; |
1320 | Todo * t = mActiveItem->todo(); | 1320 | Todo * t = mActiveItem->todo(); |
1321 | if ( t->isRunning() ) { | 1321 | if ( t->isRunning() ) { |
1322 | if ( t->runTime() < 15) { | 1322 | if ( t->runTime() < 15) { |
1323 | t->stopRunning(); | 1323 | t->stopRunning(); |
1324 | mActiveItem->construct(); | 1324 | mActiveItem->construct(); |
1325 | topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!")); | 1325 | topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!")); |
1326 | return; | 1326 | return; |
1327 | } | 1327 | } |
1328 | else | 1328 | else |
1329 | toggleRunningItem(); | 1329 | toggleRunningItem(); |
1330 | return; | 1330 | return; |
1331 | } else { | 1331 | } else { |
1332 | t->setRunning( true ); | 1332 | t->setRunning( true ); |
1333 | mActiveItem->construct(); | 1333 | mActiveItem->construct(); |
1334 | topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!")); | 1334 | topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!")); |
1335 | return; | 1335 | return; |
1336 | } | 1336 | } |
1337 | } | 1337 | } |
1338 | } | 1338 | } |
1339 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 1339 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
1340 | editItem( item ); | 1340 | editItem( item ); |
1341 | else | 1341 | else |
1342 | showItem( item , QPoint(), 0 ); | 1342 | showItem( item , QPoint(), 0 ); |
1343 | } | 1343 | } |
1344 | void KOTodoView::toggleRunningItem() | 1344 | void KOTodoView::toggleRunningItem() |
1345 | { | 1345 | { |
1346 | // qDebug("KOTodoView::toggleRunning() "); | 1346 | // qDebug("KOTodoView::toggleRunning() "); |
1347 | if ( ! mActiveItem ) | 1347 | if ( ! mActiveItem ) |
1348 | return; | 1348 | return; |
1349 | Todo * t = mActiveItem->todo(); | 1349 | Todo * t = mActiveItem->todo(); |
1350 | if ( t->isRunning() ) { | 1350 | if ( t->isRunning() ) { |
1351 | KOStopTodoPrefs tp ( t, this ); | 1351 | KOStopTodoPrefs tp ( t, this ); |
1352 | if (QApplication::desktop()->width() <= 800 ){ | 1352 | if (QApplication::desktop()->width() <= 800 ){ |
1353 | int wid = tp.width(); | 1353 | int wid = tp.width(); |
1354 | int hei = tp.height(); | 1354 | int hei = tp.height(); |
1355 | int xx = (QApplication::desktop()->width()-wid)/2; | 1355 | int xx = (QApplication::desktop()->width()-wid)/2; |
1356 | int yy = (QApplication::desktop()->height()-hei)/2; | 1356 | int yy = (QApplication::desktop()->height()-hei)/2; |
1357 | tp.setGeometry( xx,yy,wid,hei ); | 1357 | tp.setGeometry( xx,yy,wid,hei ); |
1358 | } | 1358 | } |
1359 | tp.exec(); | 1359 | tp.exec(); |
1360 | mActiveItem->construct(); | 1360 | updateTodo ( t, 0 ); |
1361 | } else { | 1361 | } else { |
1362 | KOStartTodoPrefs tp ( t->summary(), this ); | 1362 | KOStartTodoPrefs tp ( t->summary(), this ); |
1363 | if (QApplication::desktop()->width() <= 800 ){ | 1363 | if (QApplication::desktop()->width() <= 800 ){ |
1364 | int wid = tp.width(); | 1364 | int wid = tp.width(); |
1365 | int hei = tp.height(); | 1365 | int hei = tp.height(); |
1366 | int xx = (QApplication::desktop()->width()-wid)/2; | 1366 | int xx = (QApplication::desktop()->width()-wid)/2; |
1367 | int yy = (QApplication::desktop()->height()-hei)/2; | 1367 | int yy = (QApplication::desktop()->height()-hei)/2; |
1368 | tp.setGeometry( xx,yy,wid,hei ); | 1368 | tp.setGeometry( xx,yy,wid,hei ); |
1369 | } | 1369 | } |
1370 | if ( !tp.exec() ) return; | 1370 | if ( !tp.exec() ) return; |
1371 | if ( tp.stopAll() ) { | 1371 | if ( tp.stopAll() ) { |
1372 | mCalendar->stopAllTodos(); | 1372 | mCalendar->stopAllTodos(); |
1373 | t->setRunning( true ); | 1373 | t->setRunning( true ); |
1374 | updateView(); | 1374 | updateView(); |
1375 | } else { | 1375 | } else { |
1376 | t->setRunning( true ); | 1376 | t->setRunning( true ); |
1377 | mActiveItem->construct(); | 1377 | updateTodo ( t, 0 ); |
1378 | } | 1378 | } |
1379 | } | 1379 | } |
1380 | } | 1380 | } |
1381 | 1381 | ||
1382 | void KOTodoView::itemClicked(QListViewItem *item) | 1382 | void KOTodoView::itemClicked(QListViewItem *item) |
1383 | { | 1383 | { |
1384 | //qDebug("KOTodoView::itemClicked %d", item); | 1384 | //qDebug("KOTodoView::itemClicked %d", item); |
1385 | if (!item) { | 1385 | if (!item) { |
1386 | if ( pendingSubtodo != 0 ) { | 1386 | if ( pendingSubtodo != 0 ) { |
1387 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1387 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
1388 | } | 1388 | } |
1389 | pendingSubtodo = 0; | 1389 | pendingSubtodo = 0; |
1390 | return; | 1390 | return; |
1391 | } | 1391 | } |
1392 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1392 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1393 | if ( pendingSubtodo != 0 ) { | 1393 | if ( pendingSubtodo != 0 ) { |
1394 | bool allowReparent = true; | 1394 | bool allowReparent = true; |
1395 | QListViewItem *par = item; | 1395 | QListViewItem *par = item; |
1396 | while ( par ) { | 1396 | while ( par ) { |
1397 | if ( par == pendingSubtodo ) { | 1397 | if ( par == pendingSubtodo ) { |
1398 | allowReparent = false; | 1398 | allowReparent = false; |
1399 | break; | 1399 | break; |
1400 | } | 1400 | } |
1401 | par = par->parent(); | 1401 | par = par->parent(); |
1402 | } | 1402 | } |
1403 | if ( !allowReparent ) { | 1403 | if ( !allowReparent ) { |
1404 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); | 1404 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); |
1405 | pendingSubtodo = 0; | 1405 | pendingSubtodo = 0; |
1406 | } else { | 1406 | } else { |
1407 | Todo* newParent = todoItem->todo(); | 1407 | Todo* newParent = todoItem->todo(); |
1408 | Todo* newSub = pendingSubtodo->todo(); | 1408 | Todo* newSub = pendingSubtodo->todo(); |
1409 | pendingSubtodo = 0; | 1409 | pendingSubtodo = 0; |
1410 | emit reparentTodoSignal( newParent,newSub ); | 1410 | emit reparentTodoSignal( newParent,newSub ); |
1411 | return; | 1411 | return; |
1412 | } | 1412 | } |
1413 | } | 1413 | } |
1414 | 1414 | ||
1415 | } | 1415 | } |
1416 | 1416 | ||
1417 | void KOTodoView::setDocumentId( const QString &id ) | 1417 | void KOTodoView::setDocumentId( const QString &id ) |
1418 | { | 1418 | { |
1419 | 1419 | ||
1420 | mDocPrefs->setDoc( id ); | 1420 | mDocPrefs->setDoc( id ); |
1421 | } | 1421 | } |
1422 | 1422 | ||
1423 | void KOTodoView::itemStateChanged( QListViewItem *item ) | 1423 | void KOTodoView::itemStateChanged( QListViewItem *item ) |
1424 | { | 1424 | { |
1425 | if (!item) return; | 1425 | if (!item) return; |
1426 | 1426 | ||
1427 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1427 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1428 | 1428 | ||
1429 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; | 1429 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; |
1430 | 1430 | ||
1431 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); | 1431 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); |
1432 | } | 1432 | } |
1433 | 1433 | ||
1434 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const | 1434 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const |
1435 | { | 1435 | { |
1436 | mTodoListView->saveLayout(config,group); | 1436 | mTodoListView->saveLayout(config,group); |
1437 | } | 1437 | } |
1438 | 1438 | ||
1439 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) | 1439 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) |
1440 | { | 1440 | { |
1441 | mTodoListView->restoreLayout(config,group); | 1441 | mTodoListView->restoreLayout(config,group); |
1442 | } | 1442 | } |
1443 | 1443 | ||
1444 | void KOTodoView::processSelectionChange() | 1444 | void KOTodoView::processSelectionChange() |
1445 | { | 1445 | { |
1446 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; | 1446 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; |
1447 | 1447 | ||
1448 | KOTodoViewItem *item = | 1448 | KOTodoViewItem *item = |
1449 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); | 1449 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); |
1450 | 1450 | ||
1451 | if ( !item ) { | 1451 | if ( !item ) { |
1452 | emit incidenceSelected( 0 ); | 1452 | emit incidenceSelected( 0 ); |
1453 | mNewSubBut->setEnabled( false ); | 1453 | mNewSubBut->setEnabled( false ); |
1454 | } else { | 1454 | } else { |
1455 | emit incidenceSelected( item->todo() ); | 1455 | emit incidenceSelected( item->todo() ); |
1456 | mNewSubBut->setEnabled( true ); | 1456 | mNewSubBut->setEnabled( true ); |
1457 | } | 1457 | } |
1458 | } | 1458 | } |
1459 | 1459 | ||
1460 | void KOTodoView::modified(bool b) | 1460 | void KOTodoView::modified(bool b) |
1461 | { | 1461 | { |
1462 | emit isModified(b); | 1462 | emit isModified(b); |
1463 | } | 1463 | } |
1464 | void KOTodoView::setTodoModified( Todo* todo ) | 1464 | void KOTodoView::setTodoModified( Todo* todo ) |
1465 | { | 1465 | { |
1466 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); | 1466 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); |
1467 | } | 1467 | } |
1468 | void KOTodoView::clearSelection() | 1468 | void KOTodoView::clearSelection() |
1469 | { | 1469 | { |
1470 | mTodoListView->selectAll( false ); | 1470 | mTodoListView->selectAll( false ); |
1471 | } | 1471 | } |
1472 | void KOTodoView::setAllOpen() | 1472 | void KOTodoView::setAllOpen() |
1473 | { | 1473 | { |
1474 | if ( isFlatDisplay ) { | 1474 | if ( isFlatDisplay ) { |
1475 | isFlatDisplay = false; | 1475 | isFlatDisplay = false; |
1476 | mPopupMenu->setItemChecked( 8,false ); | 1476 | mPopupMenu->setItemChecked( 8,false ); |
1477 | updateView(); | 1477 | updateView(); |
1478 | } else { | 1478 | } else { |
1479 | storeCurrentItem(); | 1479 | storeCurrentItem(); |
1480 | } | 1480 | } |
1481 | setOpen(mTodoListView->firstChild(), true); | 1481 | setOpen(mTodoListView->firstChild(), true); |
1482 | resetCurrentItem(); | 1482 | resetCurrentItem(); |
1483 | } | 1483 | } |
1484 | void KOTodoView::setAllClose() | 1484 | void KOTodoView::setAllClose() |
1485 | { | 1485 | { |
1486 | if ( isFlatDisplay ) { | 1486 | if ( isFlatDisplay ) { |
1487 | isFlatDisplay = false; | 1487 | isFlatDisplay = false; |
1488 | mPopupMenu->setItemChecked( 8,false ); | 1488 | mPopupMenu->setItemChecked( 8,false ); |
1489 | updateView(); | 1489 | updateView(); |
1490 | } else { | 1490 | } else { |
1491 | storeCurrentItem(); | 1491 | storeCurrentItem(); |
1492 | } | 1492 | } |
1493 | setOpen(mTodoListView->firstChild(), false); | 1493 | setOpen(mTodoListView->firstChild(), false); |
1494 | resetCurrentItem(); | 1494 | resetCurrentItem(); |
1495 | } | 1495 | } |
1496 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) | 1496 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) |
1497 | { | 1497 | { |
1498 | 1498 | ||
1499 | while ( item ) { | 1499 | while ( item ) { |
1500 | setOpen( item->firstChild(), setOpenI ); | 1500 | setOpen( item->firstChild(), setOpenI ); |
1501 | item->setOpen( setOpenI ); | 1501 | item->setOpen( setOpenI ); |
1502 | item = item->nextSibling(); | 1502 | item = item->nextSibling(); |
1503 | } | 1503 | } |
1504 | } | 1504 | } |
1505 | 1505 | ||
1506 | void KOTodoView::displayAllFlat() | 1506 | void KOTodoView::displayAllFlat() |
1507 | { | 1507 | { |
1508 | storeCurrentItem(); | 1508 | storeCurrentItem(); |
1509 | pendingSubtodo = 0; | 1509 | pendingSubtodo = 0; |
1510 | if ( mBlockUpdate ) { | 1510 | if ( mBlockUpdate ) { |
1511 | return; | 1511 | return; |
1512 | } | 1512 | } |
1513 | mPopupMenu->setItemChecked( 8,true ); | 1513 | mPopupMenu->setItemChecked( 8,true ); |
1514 | isFlatDisplay = true; | 1514 | isFlatDisplay = true; |
1515 | QPtrList<Todo> todoList = calendar()->todos(); | 1515 | QPtrList<Todo> todoList = calendar()->todos(); |
1516 | mTodoMap.clear(); | 1516 | mTodoMap.clear(); |
1517 | mTodoListView->clear(); | 1517 | mTodoListView->clear(); |
1518 | Todo *todo; | 1518 | Todo *todo; |
1519 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 1519 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
1520 | if ( checkTodo( todo ) ) { | 1520 | if ( checkTodo( todo ) ) { |
1521 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 1521 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
1522 | mTodoMap.insert(todo,todoItem); | 1522 | mTodoMap.insert(todo,todoItem); |
1523 | } | 1523 | } |
1524 | } | 1524 | } |
1525 | resetCurrentItem(); | 1525 | resetCurrentItem(); |
1526 | } | 1526 | } |
1527 | 1527 | ||
1528 | void KOTodoView::setAllFlat() | 1528 | void KOTodoView::setAllFlat() |
1529 | { | 1529 | { |
1530 | if ( isFlatDisplay ) { | 1530 | if ( isFlatDisplay ) { |
1531 | isFlatDisplay = false; | 1531 | isFlatDisplay = false; |
1532 | mPopupMenu->setItemChecked( 8,false ); | 1532 | mPopupMenu->setItemChecked( 8,false ); |
1533 | updateView(); | 1533 | updateView(); |
1534 | return; | 1534 | return; |
1535 | } | 1535 | } |
1536 | displayAllFlat(); | 1536 | displayAllFlat(); |
1537 | } | 1537 | } |
1538 | 1538 | ||
1539 | void KOTodoView::purgeCompleted() | 1539 | void KOTodoView::purgeCompleted() |
1540 | { | 1540 | { |
1541 | emit purgeCompletedSignal(); | 1541 | emit purgeCompletedSignal(); |
1542 | 1542 | ||
1543 | } | 1543 | } |
1544 | void KOTodoView::toggleQuickTodo() | 1544 | void KOTodoView::toggleQuickTodo() |
1545 | { | 1545 | { |
1546 | if ( mQuickBar->isVisible() ) { | 1546 | if ( mQuickBar->isVisible() ) { |
1547 | mQuickBar->hide(); | 1547 | mQuickBar->hide(); |
1548 | KOPrefs::instance()->mEnableQuickTodo = false; | 1548 | KOPrefs::instance()->mEnableQuickTodo = false; |
1549 | } | 1549 | } |
1550 | else { | 1550 | else { |
1551 | mQuickBar->show(); | 1551 | mQuickBar->show(); |
1552 | KOPrefs::instance()->mEnableQuickTodo = true; | 1552 | KOPrefs::instance()->mEnableQuickTodo = true; |
1553 | } | 1553 | } |
1554 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 1554 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
1555 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 1555 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
1556 | } | 1556 | } |
1557 | 1557 | ||
1558 | void KOTodoView::toggleRunning() | 1558 | void KOTodoView::toggleRunning() |
1559 | { | 1559 | { |
1560 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; | 1560 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; |
1561 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 1561 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
1562 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 1562 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
1563 | updateView(); | 1563 | updateView(); |
1564 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 1564 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
1565 | topLevelWidget()->setCaption(i18n("Hide not Running")); | 1565 | topLevelWidget()->setCaption(i18n("Hide not Running")); |
1566 | else | 1566 | else |
1567 | topLevelWidget()->setCaption(i18n("Show not Running")); | 1567 | topLevelWidget()->setCaption(i18n("Show not Running")); |
1568 | } | 1568 | } |
1569 | 1569 | ||
1570 | void KOTodoView::toggleCompleted() | 1570 | void KOTodoView::toggleCompleted() |
1571 | { | 1571 | { |
1572 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; | 1572 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; |
1573 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 1573 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
1574 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 1574 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
1575 | updateView(); | 1575 | updateView(); |
1576 | if ( KOPrefs::instance()->mShowCompletedTodo ) | 1576 | if ( KOPrefs::instance()->mShowCompletedTodo ) |
1577 | topLevelWidget()->setCaption(i18n("Show Completed")); | 1577 | topLevelWidget()->setCaption(i18n("Show Completed")); |
1578 | else | 1578 | else |
1579 | topLevelWidget()->setCaption(i18n("Hide Completed")); | 1579 | topLevelWidget()->setCaption(i18n("Hide Completed")); |
1580 | } | 1580 | } |
1581 | 1581 | ||
1582 | void KOTodoView::addQuickTodo() | 1582 | void KOTodoView::addQuickTodo() |
1583 | { | 1583 | { |
1584 | addQuickTodoPar( 0 ); | 1584 | addQuickTodoPar( 0 ); |
1585 | } | 1585 | } |
1586 | void KOTodoView::addQuickTodoPar( Todo * parentTodo) | 1586 | void KOTodoView::addQuickTodoPar( Todo * parentTodo) |
1587 | { | 1587 | { |
1588 | Todo *todo = new Todo(); | 1588 | Todo *todo = new Todo(); |
1589 | todo->setSummary(mQuickAdd->text()); | 1589 | todo->setSummary(mQuickAdd->text()); |
1590 | todo->setOrganizer(KOPrefs::instance()->email()); | 1590 | todo->setOrganizer(KOPrefs::instance()->email()); |
1591 | if ( parentTodo ) { | 1591 | if ( parentTodo ) { |
1592 | todo->setRelatedTo(parentTodo); | 1592 | todo->setRelatedTo(parentTodo); |
1593 | 1593 | ||
1594 | todo->setCategories (parentTodo->categoriesStr ()); | 1594 | todo->setCategories (parentTodo->categoriesStr ()); |
1595 | todo->setSecrecy (parentTodo->secrecy ()); | 1595 | todo->setSecrecy (parentTodo->secrecy ()); |
1596 | if ( parentTodo->priority() < 3 ) | 1596 | if ( parentTodo->priority() < 3 ) |
1597 | todo->setPriority( parentTodo->priority() ); | 1597 | todo->setPriority( parentTodo->priority() ); |
1598 | todo->setCalID( parentTodo->calID() ); | 1598 | todo->setCalID( parentTodo->calID() ); |
1599 | } else { | 1599 | } else { |
1600 | CalFilter * cf = mCalendar->filter(); | 1600 | CalFilter * cf = mCalendar->filter(); |
1601 | if ( cf ) { | 1601 | if ( cf ) { |
1602 | if ( cf->isEnabled()&& cf->showCategories()) { | 1602 | if ( cf->isEnabled()&& cf->showCategories()) { |
1603 | todo->setCategories(cf->categoryList()); | 1603 | todo->setCategories(cf->categoryList()); |
1604 | } | 1604 | } |
1605 | if ( cf->isEnabled() ) | 1605 | if ( cf->isEnabled() ) |
1606 | todo->setSecrecy( cf->getSecrecy()); | 1606 | todo->setSecrecy( cf->getSecrecy()); |
1607 | } | 1607 | } |
1608 | } | 1608 | } |
1609 | mCalendar->addTodo(todo); | 1609 | mCalendar->addTodo(todo); |
1610 | mQuickAdd->setText(""); | 1610 | mQuickAdd->setText(""); |
1611 | todoModified (todo, KOGlobals::EVENTADDED ); | 1611 | todoModified (todo, KOGlobals::EVENTADDED ); |
1612 | updateView(); | 1612 | updateView(); |
1613 | 1613 | ||
1614 | } | 1614 | } |
1615 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) | 1615 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) |
1616 | { | 1616 | { |
1617 | // e->ignore(); | 1617 | // e->ignore(); |
1618 | //return; | 1618 | //return; |
1619 | if ( !isVisible() ) { | 1619 | if ( !isVisible() ) { |
1620 | e->ignore(); | 1620 | e->ignore(); |
1621 | return; | 1621 | return; |
1622 | } | 1622 | } |
1623 | switch ( e->key() ) { | 1623 | switch ( e->key() ) { |
1624 | case Qt::Key_Down: | 1624 | case Qt::Key_Down: |
1625 | case Qt::Key_Up: | 1625 | case Qt::Key_Up: |
1626 | // KOrg::BaseView::keyPressEvent ( e ); | 1626 | // KOrg::BaseView::keyPressEvent ( e ); |
1627 | e->ignore(); | 1627 | e->ignore(); |
1628 | break; | 1628 | break; |
1629 | 1629 | ||
1630 | case Qt::Key_Q: | 1630 | case Qt::Key_Q: |
1631 | 1631 | ||
1632 | 1632 | ||
1633 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) { | 1633 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) { |
1634 | e->ignore(); | 1634 | e->ignore(); |
1635 | break; | 1635 | break; |
1636 | } | 1636 | } |
1637 | toggleQuickTodo(); | 1637 | toggleQuickTodo(); |
1638 | break; | 1638 | break; |
1639 | case Qt::Key_U: | 1639 | case Qt::Key_U: |
1640 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1640 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1641 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1641 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1642 | unparentTodo(); | 1642 | unparentTodo(); |
1643 | e->accept(); | 1643 | e->accept(); |
1644 | } else | 1644 | } else |
1645 | e->ignore(); | 1645 | e->ignore(); |
1646 | break; | 1646 | break; |
1647 | case Qt::Key_S: | 1647 | case Qt::Key_S: |
1648 | if ( e->state() == Qt::ControlButton ) { | 1648 | if ( e->state() == Qt::ControlButton ) { |
1649 | e->ignore(); | 1649 | e->ignore(); |
1650 | break; | 1650 | break; |
1651 | } | 1651 | } |
1652 | if ( e->state() == Qt::ShiftButton ) { | 1652 | if ( e->state() == Qt::ShiftButton ) { |
1653 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1653 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1654 | reparentTodo(); | 1654 | reparentTodo(); |
1655 | e->accept(); | 1655 | e->accept(); |
1656 | } else | 1656 | } else |
1657 | e->ignore(); | 1657 | e->ignore(); |
1658 | break; | 1658 | break; |
1659 | case Qt::Key_P: | 1659 | case Qt::Key_P: |
1660 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1660 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1661 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1661 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1662 | if ( pendingSubtodo ) | 1662 | if ( pendingSubtodo ) |
1663 | itemClicked(mActiveItem); | 1663 | itemClicked(mActiveItem); |
1664 | e->accept(); | 1664 | e->accept(); |
1665 | } else | 1665 | } else |
1666 | e->ignore(); | 1666 | e->ignore(); |
1667 | break; | 1667 | break; |
1668 | case Qt::Key_Escape: | 1668 | case Qt::Key_Escape: |
1669 | if ( pendingSubtodo ) { | 1669 | if ( pendingSubtodo ) { |
1670 | itemClicked(0); | 1670 | itemClicked(0); |
1671 | e->accept(); | 1671 | e->accept(); |
1672 | } else | 1672 | } else |
1673 | e->ignore(); | 1673 | e->ignore(); |
1674 | break; | 1674 | break; |
1675 | default: | 1675 | default: |
1676 | e->ignore(); | 1676 | e->ignore(); |
1677 | } | 1677 | } |
1678 | 1678 | ||
1679 | if ( true ) { | 1679 | if ( true ) { |
1680 | if ( e->key() == Qt::Key_I ) { | 1680 | if ( e->key() == Qt::Key_I ) { |
1681 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); | 1681 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); |
1682 | if ( cn ) { | 1682 | if ( cn ) { |
1683 | mActiveItem = cn; | 1683 | mActiveItem = cn; |
1684 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 1684 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
1685 | if ( ci ){ | 1685 | if ( ci ){ |
1686 | showTodo(); | 1686 | showTodo(); |
1687 | cn = (KOTodoViewItem*)cn->itemBelow(); | 1687 | cn = (KOTodoViewItem*)cn->itemBelow(); |
1688 | if ( cn ) { | 1688 | if ( cn ) { |
1689 | mTodoListView->setCurrentItem ( cn ); | 1689 | mTodoListView->setCurrentItem ( cn ); |
1690 | mTodoListView->ensureItemVisible ( cn ); | 1690 | mTodoListView->ensureItemVisible ( cn ); |
1691 | } | 1691 | } |
1692 | 1692 | ||
1693 | } | 1693 | } |
1694 | } | 1694 | } |
1695 | e->accept(); | 1695 | e->accept(); |
1696 | 1696 | ||
1697 | } | 1697 | } |
1698 | 1698 | ||
1699 | } | 1699 | } |
1700 | 1700 | ||
1701 | } | 1701 | } |
1702 | void KOTodoView::updateTodo( Todo * t, int type ) | 1702 | void KOTodoView::updateTodo( Todo * t, int type ) |
1703 | { | 1703 | { |
1704 | if ( mBlockUpdate) | 1704 | if ( mBlockUpdate) |
1705 | return; | 1705 | return; |
1706 | 1706 | ||
1707 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 1707 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
1708 | itemIterator = mTodoMap.find(t); | 1708 | itemIterator = mTodoMap.find(t); |
1709 | if (itemIterator != mTodoMap.end()) { | 1709 | if (itemIterator != mTodoMap.end()) { |
1710 | (*itemIterator)->construct(); | 1710 | (*itemIterator)->construct(); |
1711 | } else { | 1711 | } else { |
1712 | if ( type == KOGlobals::EVENTADDED ) { | 1712 | if ( type == KOGlobals::EVENTADDED ) { |
1713 | insertTodoItem( t ); | 1713 | insertTodoItem( t ); |
1714 | } | 1714 | } |
1715 | } | 1715 | } |
1716 | 1716 | ||
1717 | } | 1717 | } |
1718 | 1718 | ||
1719 | void KOTodoView::todoModified(Todo * t , int p ) | 1719 | void KOTodoView::todoModified(Todo * t , int p ) |
1720 | { | 1720 | { |
1721 | mBlockUpdate = true; | 1721 | mBlockUpdate = true; |
1722 | emit todoModifiedSignal ( t, p ); | 1722 | emit todoModifiedSignal ( t, p ); |
1723 | mBlockUpdate = false; | 1723 | mBlockUpdate = false; |
1724 | } | 1724 | } |
@@ -1 +1 @@ | |||
version = "2.1.18"; | version = "2.1.19"; | ||