author | zautrix <zautrix> | 2004-10-28 21:22:05 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-28 21:22:05 (UTC) |
commit | 1b8d173d880e8f681bca88220bdd806a95d3c2a0 (patch) (unidiff) | |
tree | b01436fec9a5c50f188657ca33ebb6905a81dbb7 | |
parent | 43f40fe1bbc57d3b57d2a715accb51a7c8e473e1 (diff) | |
download | kdepimpi-1b8d173d880e8f681bca88220bdd806a95d3c2a0.zip kdepimpi-1b8d173d880e8f681bca88220bdd806a95d3c2a0.tar.gz kdepimpi-1b8d173d880e8f681bca88220bdd806a95d3c2a0.tar.bz2 |
fixed sync
-rw-r--r-- | bin/kdepim/MultiSyncHowTo.txt | 435 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 6 |
2 files changed, 175 insertions, 266 deletions
diff --git a/bin/kdepim/MultiSyncHowTo.txt b/bin/kdepim/MultiSyncHowTo.txt index 25e5be8..3591eb9 100644 --- a/bin/kdepim/MultiSyncHowTo.txt +++ b/bin/kdepim/MultiSyncHowTo.txt | |||
@@ -1,294 +1,203 @@ | |||
1 | Multi Sync HowTo | ||
1 | 2 | ||
2 | HAS TO BE WRITTEN | 3 | With KDE-Pim/Pi you can sync several devices |
4 | "in one go". That means you choose on one device | ||
5 | (where everything is confgured in the right way) | ||
6 | "Multiple Sync" and all devices will be synced. | ||
7 | All devices must be reachable via network. | ||
3 | 8 | ||
4 | Sync HowTo Zaurus <-> KDE | 9 | In this HowTo we will give an explicit example what to set up |
10 | and how configure. | ||
5 | 11 | ||
12 | We assume, that we have four devices which should be synced: | ||
13 | A Sharp Zaurus PDA with KDE-Pim/Pi installed.. | ||
14 | A Windows laptop with KDE-Pim/Pi installed. | ||
15 | A Linux Desktop with KDE installed. | ||
16 | A Linux Laptop with KDE installed. | ||
6 | 17 | ||
7 | This is a | 18 | NOTE: Your KDE version must be 3.3.0 or higher for sncing with. |
8 | Sync HowTo Zaurus <-> K-Desktop Environment(KDE) | 19 | Please read KDE Sync HowTo how to update your SuSE 9.1 to KDE 3.3.x |
9 | using the KDE-Pim/Pi applications | 20 | (KDE Sync HowTo is available in the help menu of KO/Pi and KA/Pi). |
10 | KAddressbook/Pi (KA/Pi) and KOrganizer/Pi (KO/Pi) | ||
11 | on the Zaurus (Z). | ||
12 | 21 | ||
13 | You can now easily sync your Z with the | 22 | The Zaurus is connected to the Linux Desktop via USB cable. |
14 | PIM data of the KDE. | ||
15 | (addressbook and calendar data). | ||
16 | You need to install the desktop versions | ||
17 | of KA/Pi+KO/Pi on the desktop. | ||
18 | You need KDE version 3.3.0 or higher on your desktop. | ||
19 | You need KA/Pi+KO/Pi version 1.9.11 or higher on the desktop | ||
20 | and on the Z. | ||
21 | 23 | ||
22 | NOTE: Almost the same procedure will make it possible to | 24 | All calendar addressbook data should be synced with the other devices. |
23 | sync KA/Pi+KO/Pi running on Windows with KDE via network. | 25 | That means in particular, that the calendar/address data of KDE on |
26 | the Linux laptop and desktop is synced with the other devices. | ||
24 | 27 | ||
25 | The setup+sync procedure is: | 28 | First we have to install the needed programs, |
29 | then we have to configure the programs. | ||
26 | 30 | ||
27 | 0) How the syncing works | 31 | ***************************************** |
28 | 1) Installing KA/Pi+KO/Pi on the Z | 32 | (1) Installing the programs: |
29 | 2) Installing desktop version of KA/Pi+KO/Pi on the desktop | 33 | ***************************************** |
30 | 3) Connection your Z to the desktop via network | ||
31 | (network connection can be set up via USB cable or (W)Lan | ||
32 | 4) Configuring KA/Pi+KO/Pi on Z for Sync | ||
33 | 5) Enable remote sync in KA/Pi+KO/Pi on the desktop | ||
34 | 6) Sync | ||
35 | 34 | ||
36 | ***************************************************** | 35 | Download the files from |
37 | 0) How the syncing works | ||
38 | ***************************************************** | ||
39 | |||
40 | After setting up everything, the following actions will | ||
41 | be performed when syncing: | ||
42 | User enables "remote pi-sync" on desktop. | ||
43 | User chooses "sync with configured desktop profile" on the Z. | ||
44 | Z sends sync request via network to configured IP/port/password. | ||
45 | KO/Pi on desktop detects sync request and syncs with KDE (configurable!). | ||
46 | A window pops up, that KO/Pi on desktop is in "remote syncing mode". | ||
47 | If a conflict occurs when syncing KO/PI<->KDE on the desktop, | ||
48 | automatically the newest entry is choosen. | ||
49 | (To avoid the need of user interaction) | ||
50 | KO/Pi on desktop sends synced file to Zaurus. | ||
51 | KO/Pi on desktop is in "waiting mode" to get synced file back. | ||
52 | Zaurus is syncing it's own calendar with the received file. | ||
53 | Here can be some user interaction needed, i.e. | ||
54 | if the sync profile is configured as | ||
55 | "ask for every entry on conflict" and a conflict occurs. | ||
56 | Zaurus sends back synced file to desktop. | ||
57 | Syncing on Zaurus is complete now. | ||
58 | KO/Pi on desktop gets back synced file. | ||
59 | KO/Pi on desktop removes all entries in its own calendar and | ||
60 | reloads the synced file. | ||
61 | KO/Pi on desktop syncs with KDE. | ||
62 | After syncing with KDE is finished, KO/Pi closes | ||
63 | the "remote syncing mode" window and displays | ||
64 | a "syncing complete" message in the headline. | ||
65 | |||
66 | The actual syncing KO/Pi on desktop <-> KDE is | ||
67 | performed by a small command line tool "kdecaldump", | ||
68 | which writes/reads the complete KDE calendar resources to | ||
69 | a file/from a file. | ||
70 | KO/Pi tags changed entries such that an unchanged entry | ||
71 | is not changed in KDE by kdecaldump. That is important for | ||
72 | calendar entries in KDE, stored in a "disconnected IMAP" calendar resource. | ||
73 | |||
74 | |||
75 | Same way is KA/Pi working. | ||
76 | |||
77 | |||
78 | ***************************************************** | ||
79 | 1) Installing KA/Pi+KO/Pi on the Z | ||
80 | ***************************************************** | ||
81 | |||
82 | Download latest version of KA/Pi+KO/Pi from | ||
83 | http://sourceforge.net/projects/kdepimpi/ | 36 | http://sourceforge.net/projects/kdepimpi/ |
84 | Project KDE/Pim. | 37 | project name KDE/Pim. |
85 | Direct link is: | 38 | Download the latest release. |
86 | http://sourceforge.net/project/showfiles.php?group_id=104103&package_id=112604 | 39 | You will find in every file a ReadMe, |
87 | Click on the version number to read the release notes/change log. | 40 | where you can read how to install. |
88 | Choose there the right precompiled package for your Z: | 41 | (a) Installing KDE-Pim/Pi on the Windows laptop: |
89 | For Sharp ROM | 42 | Download file kdepim_X.X.X_for_Windows.exe.zip |
90 | -File: kdepim_1.x.xx_for_SharpROM.ipk.zip | 43 | (b) Installing KDE-Pim/Pi on the Linux laptop and desktop: |
91 | For Open Zaurus ROM: | 44 | Download file KDE-Pim-Pi-1.9.10-SuSE9.1.i586.rpm.zip |
92 | -File: kdepim_1.x.xx_for_OZ-gcc3xx.ipk.zip | 45 | (c) Installing KDE-Pim/Pi on the Sharp Zaurus PDA: |
93 | If unsure, choose: | 46 | Depending on your Rom: |
94 | -File: kdepim_1.x.xx_for_SharpROM.ipk.zip | 47 | Download file kdepim_X.X.X_for_SharpROM.ipk.zip |
95 | 48 | or file kdepim_X.X.X_for_OZ-gcc3xx.ipk.zip for OpenZaurus users. | |
96 | Unzip the file and install the packages as usual on your Z. | 49 | If unsure, download kdepim_X.X.X_for_SharpROM.ipk.zip |
97 | In order to intstall KA/Pi+KO/Pi on your Z, | 50 | |
98 | you need to install the following files: | 51 | We assume that we have now on every device KDE-Pim/Pi installed. |
99 | kmicrokdelibs_1.x.xx_arm.ipk | 52 | To learn more about syncing, please read now the |
100 | kaddressbook_1.x.xx_arm.ipk | 53 | Sync HowTo |
101 | korganizer_1.x.xx_arm.ipk | 54 | KDE Sync HowTo |
102 | 55 | available in the help menu of KO/Pi and KA/Pi. | |
103 | ***************************************************** | 56 | |
104 | 2) Installing desktop version of KA/Pi+KO/Pi on the desktop | 57 | |
105 | ***************************************************** | 58 | ***************************************** |
59 | (2) Configuring KDE-Pim/Pi for Multiple sync: | ||
60 | ***************************************** | ||
61 | |||
62 | In mutiple sync, we have one aktive sync device and many | ||
63 | other passive sync devices. | ||
64 | |||
65 | We use the Linux desktop as the active sync device. | ||
66 | But there is no limitation. In general, you can choose | ||
67 | any device as active sync device. | ||
68 | The Zaurus is connected to the Linux Desktop via USB cable. | ||
69 | Please read the KDE Sync HowTo to know how to set up this connection. | ||
70 | |||
71 | We assume, that the devices have the following IP numbers: | ||
72 | Windows laptop: 192.168.0.40 | ||
73 | Linux laptop: 192.168.0.88 | ||
74 | Zaurus: 192.168.129.201 | ||
75 | Linux desktop: 192.168.0.99 | ||
76 | |||
77 | ***************************************** | ||
78 | (2a) Configuring the passive sync devices: | ||
79 | ***************************************** | ||
80 | |||
81 | (i) Windows laptop: 192.168.0.40: Name: XP | ||
82 | Start KO/Pi | ||
83 | Choose menu: Synchronize - Enable PiSync | ||
84 | Leave port as the default 9197. | ||
85 | Choose password xyz. | ||
86 | Click OK. | ||
87 | |||
88 | (ii) Linux laptop: 192.168.0.88: Name: BUG | ||
89 | Start KO/Pi | ||
90 | Choose menu: Synchronize - Enable PiSync | ||
91 | Leave port as the default 9197. | ||
92 | Check the box "Automatically sync with KDE-Desktop when receiving sync request". | ||
93 | Choose password xyz. | ||
94 | Click OK. | ||
95 | |||
96 | (iii) Zaurus: 192.168.129.201: Name: Z760 | ||
97 | Start KO/Pi | ||
98 | Choose menu: Synchronize - Enable PiSync | ||
99 | Leave port as the default 9197. | ||
100 | Choose password xyz. | ||
101 | Click OK. | ||
102 | |||
103 | The configuration of the passive sync devices is done. | ||
104 | |||
105 | ***************************************** | ||
106 | (2b) Configuring the aktive sync device: | ||
107 | ***************************************** | ||
108 | |||
109 | Linux desktop: 192.168.0.99: Name: K7 | ||
110 | Start KO/Pi | ||
111 | Choose menu: Synchronize - Configure... | ||
112 | |||
113 | Set "Local device name" to "K7" | ||
114 | |||
115 | Choose profile: KDE_Desktop | ||
116 | Check "Include in multiple calendar sync". | ||
117 | |||
118 | Create new profile. | ||
119 | Set name from "noName" to "XP". | ||
120 | Check "Include in multiple calendar sync". | ||
121 | Set "Profile kind" to "Pi-sync". | ||
122 | Set Calendar: Password for remote access to "xyz" | ||
123 | Set Calendar: Remote IP address to "192.168.0.40" | ||
124 | Do not change: Calendar: Remote port number | ||
125 | |||
126 | Create new profile. | ||
127 | Set name from "noName" to "BUG". | ||
128 | Check "Include in multiple calendar sync". | ||
129 | Set "Profile kind" to "Pi-sync". | ||
130 | Set Calendar: Password for remote access to "xyz" | ||
131 | Set Calendar: Remote IP address to "192.168.0.88" | ||
132 | Do not change: Calendar: Remote port number | ||
133 | |||
134 | |||
135 | Create new profile. | ||
136 | Set name from "noName" to "Z760". | ||
137 | Check "Include in multiple calendar sync". | ||
138 | Set "Profile kind" to "Pi-sync". | ||
139 | Set Calendar: Password for remote access to "xyz" | ||
140 | Set Calendar: Remote IP address to "192.168.129.201" | ||
141 | Do not change: Calendar: Remote port number | ||
142 | |||
143 | Click on OK in the sync config dialog to save settings. | ||
106 | 144 | ||
107 | Precompiled packages are available for SuSE 9.1. | ||
108 | Choose on the above download location: | ||
109 | File: KDE-Pim-Pi-1.9.11-SuSE9.1.i586.rpm | ||
110 | Download file and install it on console with | ||
111 | su | ||
112 | rpm -ihv KDE-Pim-Pi-1.9.11-SuSE9.1.i586.rpm | ||
113 | (NOTE:update with rpm -Uhv KDE-Pim-Pi-1.9.11-SuSE9.1.i586.rpm) | ||
114 | NOTE for users of SuSE 9.1: | ||
115 | You need KDE version 3.3.0 or higher on your desktop. | ||
116 | Plese make an online update in SuSE (YAST), then update | ||
117 | your KDE to version 3.3.0 or higher. | ||
118 | You can find links to updated precompiled versions of KDE | ||
119 | for SuSE 9.1 on the SusE web site, | ||
120 | a direct link is for example: | ||
121 | ftp://ftp.gwdg.de/pub/linux/suse/ftp.suse.com/suse/i386/supplementary/KDE/update_for_9.1 | ||
122 | HOWTO UPDATE KDE: | ||
123 | Download there the packages in "base". | ||
124 | And the needed package for your language in "internationalization". | ||
125 | Put all downloaded files in one "installation" directory. | ||
126 | Open console and go to the downloaded "installation" directory. | ||
127 | Do there a | ||
128 | su | ||
129 | and then perform a test for the update: | ||
130 | rpm -Uhv --test *.rpm | ||
131 | |||
132 | If no dependencies are shown, you can do the actual update with | ||
133 | rpm -Uhv *.rpm | ||
134 | |||
135 | If there are missing dependencies, you can resolve them by | ||
136 | - download the needed updated KDE package from the | ||
137 | "applications" or from the "development" folder on the server. | ||
138 | - adding a needed rpm package from the SuSE install DVD | ||
139 | - remove the package that has dependencies from your "installation" directory. | ||
140 | |||
141 | Do the | ||
142 | rpm -Uhv --test *.rpm | ||
143 | until you get no dependencies and no errors, then do a | ||
144 | rpm -Uhv *.rpm | ||
145 | Run | ||
146 | SuSEconfig | ||
147 | after installing with rpm is finished. | ||
148 | Restart KDE. | ||
149 | 145 | ||
150 | ***************************************************** | 146 | ***************************************************** |
151 | 3) Connection your Z to the desktop via network | 147 | 3) Test Setup |
152 | (network connection can be set up via USB cable or (W)Lan | ||
153 | ***************************************************** | 148 | ***************************************************** |
154 | 149 | ||
155 | a) Connection via network cable/(W)Lan cards | 150 | Choose menu: Synchronize - XP |
156 | Connect your desktop to the network. | 151 | Now the Windows laptop should be syncronized. |
157 | Set up networking on the Z. | ||
158 | Make sure, you can ping the desktop from Z. | ||
159 | b) Connection via USB cable:(is working for Z 7x0 and Z5500) | ||
160 | (i) Open console on desktop and type | ||
161 | su | ||
162 | tail -f /var/log/messages | ||
163 | (ii) Connect your Z with the USB cable to your desktop | ||
164 | You should get as output in the above console | ||
165 | something like this: | ||
166 | ("BUG" is the name of the desktop computer!) | ||
167 | Oct 26 12:49:37 BUG kernel: usb 2-2: new full speed USB device using address 2 | ||
168 | Oct 26 12:49:37 BUG kernel: usb 2-2: Product: SL-C860 | ||
169 | Oct 26 12:49:37 BUG kernel: usb 2-2: Manufacturer: Sharp | ||
170 | Oct 26 12:49:37 BUG /etc/hotplug/usb.agent[22659]: need a device for this command | ||
171 | Oct 26 12:49:43 BUG kernel: usb0: register usbnet at usb-0000:00:1d.0-2, Sharp Zaurus, PXA-2xx based | ||
172 | Oct 26 12:49:43 BUG kernel: usbcore: registered new driver usbnet | ||
173 | You see in the 5. line ("BUG kernel: usb0: register"), that usb device usb0 is used. | ||
174 | (iii) Create a network startup entry in /etc/sysconfig/network | ||
175 | Depending of the number X of the used usb device, create a file | ||
176 | /etc/sysconfig/network/ifcfg-usbX | ||
177 | (in our case /etc/sysconfig/network/ifcfg-usb0 ) | ||
178 | with the following content: | ||
179 | # usbX config for Zaurus | ||
180 | IPADDR='192.168.129.200' | ||
181 | NETMASK='255.255.255.0' | ||
182 | NETWORK='192.168.129.0' | ||
183 | BROADCAST='192.168.129.255' | ||
184 | STARTMODE='hotplug' | ||
185 | (iv) Disconnect the Z and connect the Z again to the desktop. | ||
186 | Now you should be able to ping the Z from the desktop, try in console on desktop: | ||
187 | ping 192.168.129.201 | ||
188 | Now you should be able to ping the desktop from the Z, try in console on Z: | ||
189 | ping 192.168.129.200 | ||
190 | |||
191 | Now you will get a network connection automatically, | ||
192 | if you connect your Z to the desktop via the USB cable. | ||
193 | |||
194 | |||
195 | In the following, we assume, that | ||
196 | the desktop has the IP address: 192.168.129.200 | ||
197 | and that | ||
198 | the Z has the IP address: 192.168.129.201 | ||
199 | |||
200 | ***************************************************** | ||
201 | 4) Configuring KA/Pi+KO/Pi on Z for Sync | ||
202 | ***************************************************** | ||
203 | 152 | ||
204 | Start KO/Pi on the Z. | 153 | Choose menu: Synchronize - Z760 |
205 | Choose Menu: Synchronize - Configure | 154 | Now the Zaurus should be syncronized. |
206 | Fill in name for "Local device name:", e.g. "Z760" | ||
207 | Click on "New profile" | ||
208 | Set name of "Profile:", e.g. "BUG". | ||
209 | (that is the above name of the desktop computer) | ||
210 | Choose "Profile kind": Pi-Sync. | ||
211 | Set "Password for remote access", e.g. "xyz" for | ||
212 | Calendar and Addressbook. | ||
213 | Set Remote IP address to 192.168.129.200 for | ||
214 | Calendar and Addressbook. | ||
215 | (Note: That is the IP address of the desktop!). | ||
216 | The "Remote port number" is 9197/9198 for | ||
217 | Calendar and Addressbook. | ||
218 | You do not have to change the | ||
219 | "Remote port number" or any other settings. | ||
220 | Click "OK" button to save your settings. | ||
221 | |||
222 | Now you have configured KA/Pi+KO/Pi sync on the Z, | ||
223 | no need to configure anything in KA/Pi. | ||
224 | 155 | ||
156 | Choose menu: Synchronize - BUG | ||
157 | Now the Linux laptop (and KDE there) should be syncronized. | ||
225 | 158 | ||
226 | ***************************************************** | 159 | Choose menu: Synchronize - KDE_Desktop |
227 | 5) Enable remote sync in KA/Pi+KO/Pi on the desktop | 160 | Now KDE on the Linux desptop (your device you are syncing from) |
228 | ***************************************************** | 161 | should be syncronized with KO/Pi. |
229 | 162 | ||
230 | Start KO/Pi on the desktop. | ||
231 | Do a "test" sync with KDE, choose menu: | ||
232 | Synchronize - KDE_Desktop | ||
233 | After syncing, you should have the same data in KDE | ||
234 | and in KO/Pi. | ||
235 | NOTE: | ||
236 | The KO/Pi version 1.9.10 had the bug, that on the first | ||
237 | sync with KDE, all data in KDE was deleted. | ||
238 | DO NOT USE VERSION 1.9.10! | ||
239 | |||
240 | The bevaviour on the first sync is | ||
241 | (in versions >= 1.9.11) | ||
242 | that no data is deleted, the data in KO/Pi and in | ||
243 | KDE is merged into one calendar. | ||
244 | |||
245 | When the first sync was ok, please choose menu: | ||
246 | Synchronize - Enable Pi-sync | ||
247 | Fill in the values for port ("9197" in our examle) | ||
248 | and for the password ( "xyz" in our example) | ||
249 | that you did configure on the Z for that computer. | ||
250 | Enable "Automatically start at application start" | ||
251 | and "Automatically sync with KDE-Desktop when receiving sync request" | ||
252 | by checking the two boxes. | ||
253 | Close KO/Pi. | ||
254 | |||
255 | Configure / test KA/Pi on the desktop in the same way. | ||
256 | Fill in the right value for the port (9198 in our examle) | ||
257 | in KA/Pi! | ||
258 | 163 | ||
259 | ***************************************************** | 164 | ***************************************************** |
260 | 6) Sync | 165 | 4) Sync all devices |
261 | ***************************************************** | 166 | ***************************************************** |
262 | 167 | ||
263 | After configuring everything as above, you have to do | 168 | Choose menu: Synchronize - Multiple Sync |
264 | the following, if you want to sync your Zaurus with KDE: | ||
265 | (It syncs will all resources in KDE, that are not "readonly"). | ||
266 | 169 | ||
267 | Start KO/Pi on the desktop. | 170 | Watch the devices interchanging the calendar data ... |
268 | If Kontact or KOrganizer is running, save the calendar! | ||
269 | Connect the Z with the USB cable to your desktop. | ||
270 | (Or to the local network). | ||
271 | Choose on the Z the menu: | ||
272 | Syncronize - <your name for the desktop sync profile> | ||
273 | ( that was "BUG" in our example ). | ||
274 | That's all. | ||
275 | 171 | ||
276 | Do the same with KA/Pi. | 172 | Wait until you get the message in the KO/Pi header: |
277 | 173 | ||
278 | NOTE: | 174 | 4 profiles synced. Multiple sync complete! |
279 | If an appointment/addressee is created on the Z, it is added to the | ||
280 | standard resource in KDE. | ||
281 | |||
282 | If you have todos with subtodos in your calendar, you will get on | ||
283 | every sync (after you restartet KOrganizer or Kontact in KDE) | ||
284 | the message "xx items changed on local", where | ||
285 | xx is greater or equal to the number of todos. | ||
286 | That behaviour is caused by a bug in KDE. | ||
287 | (In KDE, everytime a subtodo is loaded, | ||
288 | it's "last modified" settings are set to the current time - ouch!) | ||
289 | I hope I can fix this bug in KDE soon. | ||
290 | 175 | ||
176 | NOTE: | ||
177 | If you want to test syncing, you may get wrong results, | ||
178 | if the clocks of the synced devices have too much difference. | ||
179 | |||
180 | Example: Your clocks have a difference of 2 minutes. | ||
181 | You sync. | ||
182 | You edit an appointment on two devices. | ||
183 | You sync again. | ||
184 | You should get a conflict - but you do not get it. | ||
185 | The reason is: On one device the "last modified" | ||
186 | datetime entry of the editet appointment is before the | ||
187 | last sync event datetime on the local device. | ||
188 | Such that the rule is: | ||
189 | If you have a clock difference of X seconds, you may get | ||
190 | wrong results, if you edit the same event within that | ||
191 | X seconds on two devices. | ||
192 | Same is valid for creating a new event, of course. | ||
193 | If creation datetime is before the last sync, it is assumed that there was | ||
194 | an existing event on the local device and the newly created remote | ||
195 | event is deleted. | ||
291 | 196 | ||
292 | 197 | ||
198 | ***************************************************** | ||
199 | 5) Sync KA/Pi | ||
200 | ***************************************************** | ||
293 | 201 | ||
202 | Setup KA/Pi in the same way like KO/Pi. | ||
294 | 203 | ||
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 59bf615..59f3b40 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,2507 +1,2507 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Requires the Qt and KDE widget libraries, available at no cost at | 4 | Requires the Qt and KDE widget libraries, available at no cost at |
5 | http://www.troll.no and http://www.kde.org respectively | 5 | http://www.troll.no and http://www.kde.org respectively |
6 | 6 | ||
7 | Copyright (c) 1997, 1998, 1999 | 7 | Copyright (c) 1997, 1998, 1999 |
8 | Preston Brown (preston.brown@yale.edu) | 8 | Preston Brown (preston.brown@yale.edu) |
9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) | 9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) |
10 | Ian Dawes (iadawes@globalserve.net) | 10 | Ian Dawes (iadawes@globalserve.net) |
11 | Laszlo Boloni (boloni@cs.purdue.edu) | 11 | Laszlo Boloni (boloni@cs.purdue.edu) |
12 | 12 | ||
13 | Copyright (c) 2000, 2001, 2002 | 13 | Copyright (c) 2000, 2001, 2002 |
14 | Cornelius Schumacher <schumacher@kde.org> | 14 | Cornelius Schumacher <schumacher@kde.org> |
15 | 15 | ||
16 | This program is free software; you can redistribute it and/or modify | 16 | This program is free software; you can redistribute it and/or modify |
17 | it under the terms of the GNU General Public License as published by | 17 | it under the terms of the GNU General Public License as published by |
18 | the Free Software Foundation; either version 2 of the License, or | 18 | the Free Software Foundation; either version 2 of the License, or |
19 | (at your option) any later version. | 19 | (at your option) any later version. |
20 | 20 | ||
21 | This program is distributed in the hope that it will be useful, | 21 | This program is distributed in the hope that it will be useful, |
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
24 | GNU General Public License for more details. | 24 | GNU General Public License for more details. |
25 | 25 | ||
26 | You should have received a copy of the GNU General Public License | 26 | You should have received a copy of the GNU General Public License |
27 | along with this program; if not, write to the Free Software | 27 | along with this program; if not, write to the Free Software |
28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qradiobutton.h> | 34 | #include <qradiobutton.h> |
35 | #include <qbuttongroup.h> | 35 | #include <qbuttongroup.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qclipboard.h> | 37 | #include <qclipboard.h> |
38 | #include <qcursor.h> | 38 | #include <qcursor.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qprogressbar.h> | 40 | #include <qprogressbar.h> |
41 | #include <qmultilineedit.h> | 41 | #include <qmultilineedit.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qwidgetstack.h> | 43 | #include <qwidgetstack.h> |
44 | #include <qptrlist.h> | 44 | #include <qptrlist.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qgroupbox.h> | 46 | #include <qgroupbox.h> |
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #ifndef KORG_NOSPLITTER | 49 | #ifndef KORG_NOSPLITTER |
50 | #include <qsplitter.h> | 50 | #include <qsplitter.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #include <kglobal.h> | 53 | #include <kglobal.h> |
54 | #include <kdebug.h> | 54 | #include <kdebug.h> |
55 | #include <kstandarddirs.h> | 55 | #include <kstandarddirs.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | #include <kmessagebox.h> | 57 | #include <kmessagebox.h> |
58 | #include <knotifyclient.h> | 58 | #include <knotifyclient.h> |
59 | #include <kconfig.h> | 59 | #include <kconfig.h> |
60 | 60 | ||
61 | #include <libkdepim/ksyncprefsdialog.h> | 61 | #include <libkdepim/ksyncprefsdialog.h> |
62 | #include <krun.h> | 62 | #include <krun.h> |
63 | #include <kdirwatch.h> | 63 | #include <kdirwatch.h> |
64 | #include <libkdepim/kdatepicker.h> | 64 | #include <libkdepim/kdatepicker.h> |
65 | #include <libkdepim/ksyncprofile.h> | 65 | #include <libkdepim/ksyncprofile.h> |
66 | #include <libkdepim/kpimglobalprefs.h> | 66 | #include <libkdepim/kpimglobalprefs.h> |
67 | 67 | ||
68 | #include <libkcal/vcaldrag.h> | 68 | #include <libkcal/vcaldrag.h> |
69 | #include <libkcal/icaldrag.h> | 69 | #include <libkcal/icaldrag.h> |
70 | #include <libkcal/icalformat.h> | 70 | #include <libkcal/icalformat.h> |
71 | #include <libkcal/vcalformat.h> | 71 | #include <libkcal/vcalformat.h> |
72 | #include <libkcal/scheduler.h> | 72 | #include <libkcal/scheduler.h> |
73 | #include <libkcal/calendarlocal.h> | 73 | #include <libkcal/calendarlocal.h> |
74 | #include <libkcal/journal.h> | 74 | #include <libkcal/journal.h> |
75 | #include <libkcal/calfilter.h> | 75 | #include <libkcal/calfilter.h> |
76 | #include <libkcal/attendee.h> | 76 | #include <libkcal/attendee.h> |
77 | #include <libkcal/dndfactory.h> | 77 | #include <libkcal/dndfactory.h> |
78 | #include <libkcal/freebusy.h> | 78 | #include <libkcal/freebusy.h> |
79 | #include <libkcal/filestorage.h> | 79 | #include <libkcal/filestorage.h> |
80 | #include <libkcal/calendarresources.h> | 80 | #include <libkcal/calendarresources.h> |
81 | #include <libkcal/qtopiaformat.h> | 81 | #include <libkcal/qtopiaformat.h> |
82 | #include "../kalarmd/alarmdialog.h" | 82 | #include "../kalarmd/alarmdialog.h" |
83 | 83 | ||
84 | #ifndef DESKTOP_VERSION | 84 | #ifndef DESKTOP_VERSION |
85 | #include <libkcal/sharpformat.h> | 85 | #include <libkcal/sharpformat.h> |
86 | #include <externalapphandler.h> | 86 | #include <externalapphandler.h> |
87 | #endif | 87 | #endif |
88 | #include <libkcal/phoneformat.h> | 88 | #include <libkcal/phoneformat.h> |
89 | #ifndef KORG_NOMAIL | 89 | #ifndef KORG_NOMAIL |
90 | #include "komailclient.h" | 90 | #include "komailclient.h" |
91 | #endif | 91 | #endif |
92 | #ifndef KORG_NOPRINTER | 92 | #ifndef KORG_NOPRINTER |
93 | #include "calprinter.h" | 93 | #include "calprinter.h" |
94 | #endif | 94 | #endif |
95 | #ifndef KORG_NOPLUGINS | 95 | #ifndef KORG_NOPLUGINS |
96 | #include "kocore.h" | 96 | #include "kocore.h" |
97 | #endif | 97 | #endif |
98 | #include "koeventeditor.h" | 98 | #include "koeventeditor.h" |
99 | #include "kotodoeditor.h" | 99 | #include "kotodoeditor.h" |
100 | #include "koprefs.h" | 100 | #include "koprefs.h" |
101 | #include "koeventviewerdialog.h" | 101 | #include "koeventviewerdialog.h" |
102 | #include "publishdialog.h" | 102 | #include "publishdialog.h" |
103 | #include "kofilterview.h" | 103 | #include "kofilterview.h" |
104 | #include "koglobals.h" | 104 | #include "koglobals.h" |
105 | #include "koviewmanager.h" | 105 | #include "koviewmanager.h" |
106 | #include "koagendaview.h" | 106 | #include "koagendaview.h" |
107 | #include "kodialogmanager.h" | 107 | #include "kodialogmanager.h" |
108 | #include "outgoingdialog.h" | 108 | #include "outgoingdialog.h" |
109 | #include "incomingdialog.h" | 109 | #include "incomingdialog.h" |
110 | #include "statusdialog.h" | 110 | #include "statusdialog.h" |
111 | #include "kdatenavigator.h" | 111 | #include "kdatenavigator.h" |
112 | #include "kotodoview.h" | 112 | #include "kotodoview.h" |
113 | #include "datenavigator.h" | 113 | #include "datenavigator.h" |
114 | #include "resourceview.h" | 114 | #include "resourceview.h" |
115 | #include "navigatorbar.h" | 115 | #include "navigatorbar.h" |
116 | #include "searchdialog.h" | 116 | #include "searchdialog.h" |
117 | #include "mainwindow.h" | 117 | #include "mainwindow.h" |
118 | 118 | ||
119 | #include "calendarview.h" | 119 | #include "calendarview.h" |
120 | #ifndef DESKTOP_VERSION | 120 | #ifndef DESKTOP_VERSION |
121 | #include <qtopia/alarmserver.h> | 121 | #include <qtopia/alarmserver.h> |
122 | #endif | 122 | #endif |
123 | #ifndef _WIN32_ | 123 | #ifndef _WIN32_ |
124 | #include <stdlib.h> | 124 | #include <stdlib.h> |
125 | #include <stdio.h> | 125 | #include <stdio.h> |
126 | #include <unistd.h> | 126 | #include <unistd.h> |
127 | #else | 127 | #else |
128 | #include <qprocess.h> | 128 | #include <qprocess.h> |
129 | #endif | 129 | #endif |
130 | 130 | ||
131 | #ifdef DESKTOP_VERSION | 131 | #ifdef DESKTOP_VERSION |
132 | #include <kabc/stdaddressbook.h> | 132 | #include <kabc/stdaddressbook.h> |
133 | #endif | 133 | #endif |
134 | using namespace KOrg; | 134 | using namespace KOrg; |
135 | using namespace KCal; | 135 | using namespace KCal; |
136 | extern int globalFlagBlockAgenda; | 136 | extern int globalFlagBlockAgenda; |
137 | extern int globalFlagBlockStartup; | 137 | extern int globalFlagBlockStartup; |
138 | 138 | ||
139 | 139 | ||
140 | 140 | ||
141 | class KOBeamPrefs : public QDialog | 141 | class KOBeamPrefs : public QDialog |
142 | { | 142 | { |
143 | public: | 143 | public: |
144 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 144 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
145 | QDialog( parent, name, true ) | 145 | QDialog( parent, name, true ) |
146 | { | 146 | { |
147 | setCaption( i18n("Beam Options") ); | 147 | setCaption( i18n("Beam Options") ); |
148 | QVBoxLayout* lay = new QVBoxLayout( this ); | 148 | QVBoxLayout* lay = new QVBoxLayout( this ); |
149 | lay->setSpacing( 3 ); | 149 | lay->setSpacing( 3 ); |
150 | lay->setMargin( 3 ); | 150 | lay->setMargin( 3 ); |
151 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 151 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
152 | lay->addWidget( format ); | 152 | lay->addWidget( format ); |
153 | format->setExclusive ( true ) ; | 153 | format->setExclusive ( true ) ; |
154 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 154 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
155 | lay->addWidget( time ); time->setExclusive ( true ) ; | 155 | lay->addWidget( time ); time->setExclusive ( true ) ; |
156 | vcal = new QRadioButton(" vCalendar ", format ); | 156 | vcal = new QRadioButton(" vCalendar ", format ); |
157 | ical = new QRadioButton(" iCalendar ", format ); | 157 | ical = new QRadioButton(" iCalendar ", format ); |
158 | vcal->setChecked( true ); | 158 | vcal->setChecked( true ); |
159 | tz = new QRadioButton(i18n(" With timezone "), time ); | 159 | tz = new QRadioButton(i18n(" With timezone "), time ); |
160 | local = new QRadioButton(i18n(" Local time "), time ); | 160 | local = new QRadioButton(i18n(" Local time "), time ); |
161 | tz->setChecked( true ); | 161 | tz->setChecked( true ); |
162 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 162 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
163 | lay->addWidget( ok ); | 163 | lay->addWidget( ok ); |
164 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 164 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
165 | lay->addWidget( cancel ); | 165 | lay->addWidget( cancel ); |
166 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 166 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
167 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 167 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
168 | resize( 200, 200 ); | 168 | resize( 200, 200 ); |
169 | } | 169 | } |
170 | 170 | ||
171 | bool beamVcal() { return vcal->isChecked(); } | 171 | bool beamVcal() { return vcal->isChecked(); } |
172 | bool beamLocal() { return local->isChecked(); } | 172 | bool beamLocal() { return local->isChecked(); } |
173 | private: | 173 | private: |
174 | QRadioButton* vcal, *ical, *local, *tz; | 174 | QRadioButton* vcal, *ical, *local, *tz; |
175 | }; | 175 | }; |
176 | class KOCatPrefs : public QDialog | 176 | class KOCatPrefs : public QDialog |
177 | { | 177 | { |
178 | public: | 178 | public: |
179 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 179 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
180 | QDialog( parent, name, true ) | 180 | QDialog( parent, name, true ) |
181 | { | 181 | { |
182 | setCaption( i18n("Manage new Categories") ); | 182 | setCaption( i18n("Manage new Categories") ); |
183 | QVBoxLayout* lay = new QVBoxLayout( this ); | 183 | QVBoxLayout* lay = new QVBoxLayout( this ); |
184 | lay->setSpacing( 3 ); | 184 | lay->setSpacing( 3 ); |
185 | lay->setMargin( 3 ); | 185 | lay->setMargin( 3 ); |
186 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 186 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
187 | lay->addWidget( lab ); | 187 | lay->addWidget( lab ); |
188 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 188 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
189 | lay->addWidget( format ); | 189 | lay->addWidget( format ); |
190 | format->setExclusive ( true ) ; | 190 | format->setExclusive ( true ) ; |
191 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 191 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
192 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 192 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
193 | addCatBut->setChecked( true ); | 193 | addCatBut->setChecked( true ); |
194 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 194 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
195 | lay->addWidget( ok ); | 195 | lay->addWidget( ok ); |
196 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 196 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
197 | lay->addWidget( cancel ); | 197 | lay->addWidget( cancel ); |
198 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 198 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
199 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 199 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
200 | resize( 200, 200 ); | 200 | resize( 200, 200 ); |
201 | } | 201 | } |
202 | 202 | ||
203 | bool addCat() { return addCatBut->isChecked(); } | 203 | bool addCat() { return addCatBut->isChecked(); } |
204 | private: | 204 | private: |
205 | QRadioButton* addCatBut; | 205 | QRadioButton* addCatBut; |
206 | }; | 206 | }; |
207 | 207 | ||
208 | 208 | ||
209 | 209 | ||
210 | CalendarView::CalendarView( CalendarResources *calendar, | 210 | CalendarView::CalendarView( CalendarResources *calendar, |
211 | QWidget *parent, const char *name ) | 211 | QWidget *parent, const char *name ) |
212 | : CalendarViewBase( parent, name ), | 212 | : CalendarViewBase( parent, name ), |
213 | mCalendar( calendar ), | 213 | mCalendar( calendar ), |
214 | mResourceManager( calendar->resourceManager() ) | 214 | mResourceManager( calendar->resourceManager() ) |
215 | { | 215 | { |
216 | 216 | ||
217 | mEventEditor = 0; | 217 | mEventEditor = 0; |
218 | mTodoEditor = 0; | 218 | mTodoEditor = 0; |
219 | 219 | ||
220 | init(); | 220 | init(); |
221 | } | 221 | } |
222 | 222 | ||
223 | CalendarView::CalendarView( Calendar *calendar, | 223 | CalendarView::CalendarView( Calendar *calendar, |
224 | QWidget *parent, const char *name ) | 224 | QWidget *parent, const char *name ) |
225 | : CalendarViewBase( parent, name ), | 225 | : CalendarViewBase( parent, name ), |
226 | mCalendar( calendar ), | 226 | mCalendar( calendar ), |
227 | mResourceManager( 0 ) | 227 | mResourceManager( 0 ) |
228 | { | 228 | { |
229 | 229 | ||
230 | mEventEditor = 0; | 230 | mEventEditor = 0; |
231 | mTodoEditor = 0; | 231 | mTodoEditor = 0; |
232 | init();} | 232 | init();} |
233 | 233 | ||
234 | void CalendarView::init() | 234 | void CalendarView::init() |
235 | { | 235 | { |
236 | beamDialog = new KOBeamPrefs(); | 236 | beamDialog = new KOBeamPrefs(); |
237 | mDatePickerMode = 0; | 237 | mDatePickerMode = 0; |
238 | mCurrentSyncDevice = ""; | 238 | mCurrentSyncDevice = ""; |
239 | writeLocale(); | 239 | writeLocale(); |
240 | mViewManager = new KOViewManager( this ); | 240 | mViewManager = new KOViewManager( this ); |
241 | mDialogManager = new KODialogManager( this ); | 241 | mDialogManager = new KODialogManager( this ); |
242 | mEventViewerDialog = 0; | 242 | mEventViewerDialog = 0; |
243 | mModified = false; | 243 | mModified = false; |
244 | mReadOnly = false; | 244 | mReadOnly = false; |
245 | mSelectedIncidence = 0; | 245 | mSelectedIncidence = 0; |
246 | mCalPrinter = 0; | 246 | mCalPrinter = 0; |
247 | mFilters.setAutoDelete(true); | 247 | mFilters.setAutoDelete(true); |
248 | 248 | ||
249 | mCalendar->registerObserver( this ); | 249 | mCalendar->registerObserver( this ); |
250 | // TODO: Make sure that view is updated, when calendar is changed. | 250 | // TODO: Make sure that view is updated, when calendar is changed. |
251 | 251 | ||
252 | mStorage = new FileStorage( mCalendar ); | 252 | mStorage = new FileStorage( mCalendar ); |
253 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 253 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
254 | 254 | ||
255 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 255 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
256 | #ifndef KORG_NOSPLITTER | 256 | #ifndef KORG_NOSPLITTER |
257 | // create the main layout frames. | 257 | // create the main layout frames. |
258 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 258 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
259 | topLayout->addWidget(mPanner); | 259 | topLayout->addWidget(mPanner); |
260 | 260 | ||
261 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 261 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
262 | "CalendarView::LeftFrame"); | 262 | "CalendarView::LeftFrame"); |
263 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 263 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
264 | 264 | ||
265 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, | 265 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, |
266 | "CalendarView::DateNavigator", QDate::currentDate() ); | 266 | "CalendarView::DateNavigator", QDate::currentDate() ); |
267 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 267 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
268 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 268 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
269 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 269 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
270 | 270 | ||
271 | #ifdef KORG_NORESOURCEVIEW | 271 | #ifdef KORG_NORESOURCEVIEW |
272 | mResourceView = 0; | 272 | mResourceView = 0; |
273 | #else | 273 | #else |
274 | if ( mResourceManager ) { | 274 | if ( mResourceManager ) { |
275 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 275 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
276 | mResourceView->updateView(); | 276 | mResourceView->updateView(); |
277 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 277 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
278 | SLOT( updateView() ) ); | 278 | SLOT( updateView() ) ); |
279 | } else { | 279 | } else { |
280 | mResourceView = 0; | 280 | mResourceView = 0; |
281 | } | 281 | } |
282 | #endif | 282 | #endif |
283 | QWidget *rightBox = new QWidget( mPanner ); | 283 | QWidget *rightBox = new QWidget( mPanner ); |
284 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 284 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
285 | 285 | ||
286 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 286 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
287 | rightLayout->addWidget( mNavigatorBar ); | 287 | rightLayout->addWidget( mNavigatorBar ); |
288 | 288 | ||
289 | mRightFrame = new QWidgetStack( rightBox ); | 289 | mRightFrame = new QWidgetStack( rightBox ); |
290 | rightLayout->addWidget( mRightFrame, 1 ); | 290 | rightLayout->addWidget( mRightFrame, 1 ); |
291 | 291 | ||
292 | mLeftFrame = mLeftSplitter; | 292 | mLeftFrame = mLeftSplitter; |
293 | #else | 293 | #else |
294 | QWidget *mainBox = new QWidget( this ); | 294 | QWidget *mainBox = new QWidget( this ); |
295 | QWidget *leftFrame = new QWidget( mainBox ); | 295 | QWidget *leftFrame = new QWidget( mainBox ); |
296 | 296 | ||
297 | QBoxLayout * mainBoxLayout; | 297 | QBoxLayout * mainBoxLayout; |
298 | QBoxLayout * leftFrameLayout; | 298 | QBoxLayout * leftFrameLayout; |
299 | if ( KOPrefs::instance()->mVerticalScreen ) { | 299 | if ( KOPrefs::instance()->mVerticalScreen ) { |
300 | mainBoxLayout = new QVBoxLayout(mainBox); | 300 | mainBoxLayout = new QVBoxLayout(mainBox); |
301 | leftFrameLayout = new QHBoxLayout(leftFrame ); | 301 | leftFrameLayout = new QHBoxLayout(leftFrame ); |
302 | } else { | 302 | } else { |
303 | mainBoxLayout = new QHBoxLayout(mainBox); | 303 | mainBoxLayout = new QHBoxLayout(mainBox); |
304 | leftFrameLayout = new QVBoxLayout(leftFrame ); | 304 | leftFrameLayout = new QVBoxLayout(leftFrame ); |
305 | } | 305 | } |
306 | topLayout->addWidget( mainBox ); | 306 | topLayout->addWidget( mainBox ); |
307 | mainBoxLayout->addWidget (leftFrame); | 307 | mainBoxLayout->addWidget (leftFrame); |
308 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, | 308 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, |
309 | "CalendarView::DateNavigator", QDate::currentDate()); | 309 | "CalendarView::DateNavigator", QDate::currentDate()); |
310 | // mDateNavigator->blockSignals( true ); | 310 | // mDateNavigator->blockSignals( true ); |
311 | leftFrameLayout->addWidget( mDateNavigator ); | 311 | leftFrameLayout->addWidget( mDateNavigator ); |
312 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); | 312 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); |
313 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); | 313 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); |
314 | 314 | ||
315 | if ( QApplication::desktop()->width() < 480 ) { | 315 | if ( QApplication::desktop()->width() < 480 ) { |
316 | leftFrameLayout->addWidget(mFilterView); | 316 | leftFrameLayout->addWidget(mFilterView); |
317 | leftFrameLayout->addWidget(mTodoList, 2 ); | 317 | leftFrameLayout->addWidget(mTodoList, 2 ); |
318 | 318 | ||
319 | } else { | 319 | } else { |
320 | leftFrameLayout->addWidget(mTodoList,2 ); | 320 | leftFrameLayout->addWidget(mTodoList,2 ); |
321 | leftFrameLayout->addWidget(mFilterView ); | 321 | leftFrameLayout->addWidget(mFilterView ); |
322 | } | 322 | } |
323 | mFilterView->hide(); | 323 | mFilterView->hide(); |
324 | QWidget *rightBox = new QWidget( mainBox ); | 324 | QWidget *rightBox = new QWidget( mainBox ); |
325 | mainBoxLayout->addWidget ( rightBox, 10 ); | 325 | mainBoxLayout->addWidget ( rightBox, 10 ); |
326 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 326 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
327 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 327 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
328 | mRightFrame = new QWidgetStack( rightBox ); | 328 | mRightFrame = new QWidgetStack( rightBox ); |
329 | rightLayout->addWidget( mNavigatorBar ); | 329 | rightLayout->addWidget( mNavigatorBar ); |
330 | rightLayout->addWidget( mRightFrame, 10 ); | 330 | rightLayout->addWidget( mRightFrame, 10 ); |
331 | 331 | ||
332 | mLeftFrame = leftFrame; | 332 | mLeftFrame = leftFrame; |
333 | if ( KOPrefs::instance()->mVerticalScreen ) { | 333 | if ( KOPrefs::instance()->mVerticalScreen ) { |
334 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 334 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
335 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 335 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
336 | } else { | 336 | } else { |
337 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 337 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
338 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 338 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
339 | } | 339 | } |
340 | 340 | ||
341 | //qDebug("Calendarview Size %d %d ", width(), height()); | 341 | //qDebug("Calendarview Size %d %d ", width(), height()); |
342 | #endif | 342 | #endif |
343 | 343 | ||
344 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 344 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
345 | SLOT( showDates( const KCal::DateList & ) ) ); | 345 | SLOT( showDates( const KCal::DateList & ) ) ); |
346 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 346 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
347 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 347 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
348 | 348 | ||
349 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), | 349 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), |
350 | mNavigator, SLOT( selectPreviousYear() ) ); | 350 | mNavigator, SLOT( selectPreviousYear() ) ); |
351 | connect( mNavigatorBar, SIGNAL( goNextYear() ), | 351 | connect( mNavigatorBar, SIGNAL( goNextYear() ), |
352 | mNavigator, SLOT( selectNextYear() ) ); | 352 | mNavigator, SLOT( selectNextYear() ) ); |
353 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), | 353 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), |
354 | mNavigator, SLOT( selectPreviousMonth() ) ); | 354 | mNavigator, SLOT( selectPreviousMonth() ) ); |
355 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), | 355 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), |
356 | mNavigator, SLOT( selectNextMonth() ) ); | 356 | mNavigator, SLOT( selectNextMonth() ) ); |
357 | 357 | ||
358 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 358 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
359 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); | 359 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); |
360 | 360 | ||
361 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 361 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
362 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 362 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
363 | 363 | ||
364 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 364 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
365 | mNavigator, SLOT( selectPreviousYear() ) ); | 365 | mNavigator, SLOT( selectPreviousYear() ) ); |
366 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 366 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
367 | mNavigator, SLOT( selectNextYear() ) ); | 367 | mNavigator, SLOT( selectNextYear() ) ); |
368 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 368 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
369 | mNavigator, SLOT( selectPreviousMonth() ) ); | 369 | mNavigator, SLOT( selectPreviousMonth() ) ); |
370 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 370 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
371 | mNavigator, SLOT( selectNextMonth() ) ); | 371 | mNavigator, SLOT( selectNextMonth() ) ); |
372 | 372 | ||
373 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 373 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
374 | mNavigator, SLOT( selectPrevious() ) ); | 374 | mNavigator, SLOT( selectPrevious() ) ); |
375 | connect( mDateNavigator, SIGNAL( goNext() ), | 375 | connect( mDateNavigator, SIGNAL( goNext() ), |
376 | mNavigator, SLOT( selectNext() ) ); | 376 | mNavigator, SLOT( selectNext() ) ); |
377 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 377 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
378 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 378 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
379 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), | 379 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), |
380 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 380 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
381 | 381 | ||
382 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 382 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
383 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 383 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
384 | 384 | ||
385 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), | 385 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), |
386 | SLOT( eventAdded( Event *) ) ); | 386 | SLOT( eventAdded( Event *) ) ); |
387 | 387 | ||
388 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 388 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
389 | 389 | ||
390 | connect( this, SIGNAL( configChanged() ), | 390 | connect( this, SIGNAL( configChanged() ), |
391 | mDateNavigator, SLOT( updateConfig() ) ); | 391 | mDateNavigator, SLOT( updateConfig() ) ); |
392 | 392 | ||
393 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 393 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
394 | SLOT( newTodo() ) ); | 394 | SLOT( newTodo() ) ); |
395 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 395 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
396 | SLOT( newSubTodo( Todo * ) ) ); | 396 | SLOT( newSubTodo( Todo * ) ) ); |
397 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 397 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
398 | SLOT( editTodo( Todo * ) ) ); | 398 | SLOT( editTodo( Todo * ) ) ); |
399 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 399 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
400 | SLOT( showTodo( Todo *) ) ); | 400 | SLOT( showTodo( Todo *) ) ); |
401 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 401 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
402 | SLOT( deleteTodo( Todo *) ) ); | 402 | SLOT( deleteTodo( Todo *) ) ); |
403 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 403 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
404 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 404 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
405 | SLOT( purgeCompleted() ) ); | 405 | SLOT( purgeCompleted() ) ); |
406 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 406 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
407 | SIGNAL( todoModified( Todo *, int ) ) ); | 407 | SIGNAL( todoModified( Todo *, int ) ) ); |
408 | 408 | ||
409 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 409 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
410 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 410 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
411 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 411 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
412 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 412 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
413 | 413 | ||
414 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 414 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
415 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 415 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
416 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 416 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
417 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 417 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
418 | 418 | ||
419 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 419 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
420 | this, SLOT ( todo_unsub( Todo * ) ) ); | 420 | this, SLOT ( todo_unsub( Todo * ) ) ); |
421 | 421 | ||
422 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 422 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
423 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 423 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
424 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 424 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
425 | SLOT( updateTodo( Todo *, int ) ) ); | 425 | SLOT( updateTodo( Todo *, int ) ) ); |
426 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 426 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
427 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 427 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
428 | 428 | ||
429 | 429 | ||
430 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 430 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
431 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 431 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
432 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 432 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
433 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 433 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
434 | 434 | ||
435 | 435 | ||
436 | 436 | ||
437 | 437 | ||
438 | 438 | ||
439 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 439 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
440 | SLOT(checkClipboard())); | 440 | SLOT(checkClipboard())); |
441 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 441 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
442 | SLOT( processTodoListSelection( Incidence * ) ) ); | 442 | SLOT( processTodoListSelection( Incidence * ) ) ); |
443 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 443 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
444 | 444 | ||
445 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 445 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
446 | 446 | ||
447 | mDateFrame = new QVBox(0,0,WType_Popup); | 447 | mDateFrame = new QVBox(0,0,WType_Popup); |
448 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 448 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
449 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 449 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
450 | mDateFrame->setLineWidth(3); | 450 | mDateFrame->setLineWidth(3); |
451 | mDateFrame->hide(); | 451 | mDateFrame->hide(); |
452 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 452 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
453 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 453 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
454 | 454 | ||
455 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 455 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
456 | 456 | ||
457 | mEventEditor = mDialogManager->getEventEditor(); | 457 | mEventEditor = mDialogManager->getEventEditor(); |
458 | mTodoEditor = mDialogManager->getTodoEditor(); | 458 | mTodoEditor = mDialogManager->getTodoEditor(); |
459 | 459 | ||
460 | mFlagEditDescription = false; | 460 | mFlagEditDescription = false; |
461 | 461 | ||
462 | mSuspendTimer = new QTimer( this ); | 462 | mSuspendTimer = new QTimer( this ); |
463 | mAlarmTimer = new QTimer( this ); | 463 | mAlarmTimer = new QTimer( this ); |
464 | mRecheckAlarmTimer = new QTimer( this ); | 464 | mRecheckAlarmTimer = new QTimer( this ); |
465 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 465 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
466 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 466 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
467 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 467 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
468 | mAlarmDialog = new AlarmDialog( this ); | 468 | mAlarmDialog = new AlarmDialog( this ); |
469 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 469 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
470 | mAlarmDialog->setServerNotification( false ); | 470 | mAlarmDialog->setServerNotification( false ); |
471 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 471 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
472 | 472 | ||
473 | 473 | ||
474 | #ifndef DESKTOP_VERSION | 474 | #ifndef DESKTOP_VERSION |
475 | //US listen for arriving address resultsets | 475 | //US listen for arriving address resultsets |
476 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 476 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
477 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 477 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
478 | #endif | 478 | #endif |
479 | 479 | ||
480 | } | 480 | } |
481 | 481 | ||
482 | 482 | ||
483 | CalendarView::~CalendarView() | 483 | CalendarView::~CalendarView() |
484 | { | 484 | { |
485 | // kdDebug() << "~CalendarView()" << endl; | 485 | // kdDebug() << "~CalendarView()" << endl; |
486 | //qDebug("CalendarView::~CalendarView() "); | 486 | //qDebug("CalendarView::~CalendarView() "); |
487 | delete mDialogManager; | 487 | delete mDialogManager; |
488 | delete mViewManager; | 488 | delete mViewManager; |
489 | delete mStorage; | 489 | delete mStorage; |
490 | delete mDateFrame ; | 490 | delete mDateFrame ; |
491 | delete beamDialog; | 491 | delete beamDialog; |
492 | //kdDebug() << "~CalendarView() done" << endl; | 492 | //kdDebug() << "~CalendarView() done" << endl; |
493 | } | 493 | } |
494 | void CalendarView::timerAlarm() | 494 | void CalendarView::timerAlarm() |
495 | { | 495 | { |
496 | //qDebug("CalendarView::timerAlarm() "); | 496 | //qDebug("CalendarView::timerAlarm() "); |
497 | computeAlarm(mAlarmNotification ); | 497 | computeAlarm(mAlarmNotification ); |
498 | } | 498 | } |
499 | 499 | ||
500 | void CalendarView::suspendAlarm() | 500 | void CalendarView::suspendAlarm() |
501 | { | 501 | { |
502 | //qDebug(" CalendarView::suspendAlarm() "); | 502 | //qDebug(" CalendarView::suspendAlarm() "); |
503 | computeAlarm(mSuspendAlarmNotification ); | 503 | computeAlarm(mSuspendAlarmNotification ); |
504 | 504 | ||
505 | } | 505 | } |
506 | 506 | ||
507 | void CalendarView::startAlarm( QString mess , QString filename) | 507 | void CalendarView::startAlarm( QString mess , QString filename) |
508 | { | 508 | { |
509 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 509 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
510 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 510 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
511 | 511 | ||
512 | } | 512 | } |
513 | 513 | ||
514 | void CalendarView::checkNextTimerAlarm() | 514 | void CalendarView::checkNextTimerAlarm() |
515 | { | 515 | { |
516 | mCalendar->checkAlarmForIncidence( 0, true ); | 516 | mCalendar->checkAlarmForIncidence( 0, true ); |
517 | } | 517 | } |
518 | 518 | ||
519 | void CalendarView::computeAlarm( QString msg ) | 519 | void CalendarView::computeAlarm( QString msg ) |
520 | { | 520 | { |
521 | 521 | ||
522 | QString mess = msg; | 522 | QString mess = msg; |
523 | QString mAlarmMessage = mess.mid( 9 ); | 523 | QString mAlarmMessage = mess.mid( 9 ); |
524 | QString filename = MainWindow::resourcePath(); | 524 | QString filename = MainWindow::resourcePath(); |
525 | filename += "koalarm.wav"; | 525 | filename += "koalarm.wav"; |
526 | QString tempfilename; | 526 | QString tempfilename; |
527 | if ( mess.left( 13 ) == "suspend_alarm") { | 527 | if ( mess.left( 13 ) == "suspend_alarm") { |
528 | bool error = false; | 528 | bool error = false; |
529 | int len = mess.mid( 13 ).find("+++"); | 529 | int len = mess.mid( 13 ).find("+++"); |
530 | if ( len < 2 ) | 530 | if ( len < 2 ) |
531 | error = true; | 531 | error = true; |
532 | else { | 532 | else { |
533 | tempfilename = mess.mid( 13, len ); | 533 | tempfilename = mess.mid( 13, len ); |
534 | if ( !QFile::exists( tempfilename ) ) | 534 | if ( !QFile::exists( tempfilename ) ) |
535 | error = true; | 535 | error = true; |
536 | } | 536 | } |
537 | if ( ! error ) { | 537 | if ( ! error ) { |
538 | filename = tempfilename; | 538 | filename = tempfilename; |
539 | } | 539 | } |
540 | mAlarmMessage = mess.mid( 13+len+3 ); | 540 | mAlarmMessage = mess.mid( 13+len+3 ); |
541 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 541 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
542 | startAlarm( mAlarmMessage, filename); | 542 | startAlarm( mAlarmMessage, filename); |
543 | return; | 543 | return; |
544 | } | 544 | } |
545 | if ( mess.left( 11 ) == "timer_alarm") { | 545 | if ( mess.left( 11 ) == "timer_alarm") { |
546 | //mTimerTime = 0; | 546 | //mTimerTime = 0; |
547 | startAlarm( mess.mid( 11 ), filename ); | 547 | startAlarm( mess.mid( 11 ), filename ); |
548 | return; | 548 | return; |
549 | } | 549 | } |
550 | if ( mess.left( 10 ) == "proc_alarm") { | 550 | if ( mess.left( 10 ) == "proc_alarm") { |
551 | bool error = false; | 551 | bool error = false; |
552 | int len = mess.mid( 10 ).find("+++"); | 552 | int len = mess.mid( 10 ).find("+++"); |
553 | if ( len < 2 ) | 553 | if ( len < 2 ) |
554 | error = true; | 554 | error = true; |
555 | else { | 555 | else { |
556 | tempfilename = mess.mid( 10, len ); | 556 | tempfilename = mess.mid( 10, len ); |
557 | if ( !QFile::exists( tempfilename ) ) | 557 | if ( !QFile::exists( tempfilename ) ) |
558 | error = true; | 558 | error = true; |
559 | } | 559 | } |
560 | if ( error ) { | 560 | if ( error ) { |
561 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 561 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
562 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 562 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
563 | } else { | 563 | } else { |
564 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 564 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
565 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 565 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
566 | #ifndef _WIN32_ | 566 | #ifndef _WIN32_ |
567 | if ( vfork () == 0 ) { | 567 | if ( vfork () == 0 ) { |
568 | execl ( tempfilename.latin1(), 0 ); | 568 | execl ( tempfilename.latin1(), 0 ); |
569 | return; | 569 | return; |
570 | } | 570 | } |
571 | #else | 571 | #else |
572 | QProcess* p = new QProcess(); | 572 | QProcess* p = new QProcess(); |
573 | p->addArgument( tempfilename.latin1() ); | 573 | p->addArgument( tempfilename.latin1() ); |
574 | p->start(); | 574 | p->start(); |
575 | return; | 575 | return; |
576 | #endif | 576 | #endif |
577 | 577 | ||
578 | return; | 578 | return; |
579 | } | 579 | } |
580 | 580 | ||
581 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 581 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
582 | } | 582 | } |
583 | if ( mess.left( 11 ) == "audio_alarm") { | 583 | if ( mess.left( 11 ) == "audio_alarm") { |
584 | bool error = false; | 584 | bool error = false; |
585 | int len = mess.mid( 11 ).find("+++"); | 585 | int len = mess.mid( 11 ).find("+++"); |
586 | if ( len < 2 ) | 586 | if ( len < 2 ) |
587 | error = true; | 587 | error = true; |
588 | else { | 588 | else { |
589 | tempfilename = mess.mid( 11, len ); | 589 | tempfilename = mess.mid( 11, len ); |
590 | if ( !QFile::exists( tempfilename ) ) | 590 | if ( !QFile::exists( tempfilename ) ) |
591 | error = true; | 591 | error = true; |
592 | } | 592 | } |
593 | if ( ! error ) { | 593 | if ( ! error ) { |
594 | filename = tempfilename; | 594 | filename = tempfilename; |
595 | } | 595 | } |
596 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 596 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
597 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 597 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
598 | } | 598 | } |
599 | if ( mess.left( 9 ) == "cal_alarm") { | 599 | if ( mess.left( 9 ) == "cal_alarm") { |
600 | mAlarmMessage = mess.mid( 9 ) ; | 600 | mAlarmMessage = mess.mid( 9 ) ; |
601 | } | 601 | } |
602 | 602 | ||
603 | startAlarm( mAlarmMessage, filename ); | 603 | startAlarm( mAlarmMessage, filename ); |
604 | 604 | ||
605 | 605 | ||
606 | } | 606 | } |
607 | 607 | ||
608 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 608 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
609 | { | 609 | { |
610 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 610 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
611 | 611 | ||
612 | mSuspendAlarmNotification = noti; | 612 | mSuspendAlarmNotification = noti; |
613 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 613 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
614 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 614 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
615 | mSuspendTimer->start( ms , true ); | 615 | mSuspendTimer->start( ms , true ); |
616 | 616 | ||
617 | } | 617 | } |
618 | 618 | ||
619 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 619 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
620 | { | 620 | { |
621 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 621 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
622 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 622 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
623 | #ifndef DESKTOP_VERSION | 623 | #ifndef DESKTOP_VERSION |
624 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 624 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
625 | #endif | 625 | #endif |
626 | return; | 626 | return; |
627 | } | 627 | } |
628 | int maxSec; | 628 | int maxSec; |
629 | //maxSec = 5; //testing only | 629 | //maxSec = 5; //testing only |
630 | maxSec = 86400+3600; // one day+1hour | 630 | maxSec = 86400+3600; // one day+1hour |
631 | mAlarmNotification = noti; | 631 | mAlarmNotification = noti; |
632 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 632 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
633 | if ( sec > maxSec ) { | 633 | if ( sec > maxSec ) { |
634 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 634 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
635 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 635 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
636 | return; | 636 | return; |
637 | } else { | 637 | } else { |
638 | mRecheckAlarmTimer->stop(); | 638 | mRecheckAlarmTimer->stop(); |
639 | } | 639 | } |
640 | //qDebug("Alarm timer started with secs: %d ", sec); | 640 | //qDebug("Alarm timer started with secs: %d ", sec); |
641 | mAlarmTimer->start( sec *1000 , true ); | 641 | mAlarmTimer->start( sec *1000 , true ); |
642 | 642 | ||
643 | } | 643 | } |
644 | // called by mRecheckAlarmTimer to get next alarm | 644 | // called by mRecheckAlarmTimer to get next alarm |
645 | // we need this, because a QTimer has only a max range of 25 days | 645 | // we need this, because a QTimer has only a max range of 25 days |
646 | void CalendarView::recheckTimerAlarm() | 646 | void CalendarView::recheckTimerAlarm() |
647 | { | 647 | { |
648 | mAlarmTimer->stop(); | 648 | mAlarmTimer->stop(); |
649 | mRecheckAlarmTimer->stop(); | 649 | mRecheckAlarmTimer->stop(); |
650 | mCalendar->checkAlarmForIncidence( 0, true ); | 650 | mCalendar->checkAlarmForIncidence( 0, true ); |
651 | } | 651 | } |
652 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 652 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
653 | { | 653 | { |
654 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 654 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
655 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 655 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
656 | #ifndef DESKTOP_VERSION | 656 | #ifndef DESKTOP_VERSION |
657 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 657 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
658 | #endif | 658 | #endif |
659 | return; | 659 | return; |
660 | } | 660 | } |
661 | mAlarmTimer->stop(); | 661 | mAlarmTimer->stop(); |
662 | } | 662 | } |
663 | void CalendarView::selectWeekNum ( int num ) | 663 | void CalendarView::selectWeekNum ( int num ) |
664 | { | 664 | { |
665 | dateNavigator()->selectWeek( num ); | 665 | dateNavigator()->selectWeek( num ); |
666 | mViewManager->showWeekView(); | 666 | mViewManager->showWeekView(); |
667 | } | 667 | } |
668 | KOViewManager *CalendarView::viewManager() | 668 | KOViewManager *CalendarView::viewManager() |
669 | { | 669 | { |
670 | return mViewManager; | 670 | return mViewManager; |
671 | } | 671 | } |
672 | 672 | ||
673 | KODialogManager *CalendarView::dialogManager() | 673 | KODialogManager *CalendarView::dialogManager() |
674 | { | 674 | { |
675 | return mDialogManager; | 675 | return mDialogManager; |
676 | } | 676 | } |
677 | 677 | ||
678 | QDate CalendarView::startDate() | 678 | QDate CalendarView::startDate() |
679 | { | 679 | { |
680 | DateList dates = mNavigator->selectedDates(); | 680 | DateList dates = mNavigator->selectedDates(); |
681 | 681 | ||
682 | return dates.first(); | 682 | return dates.first(); |
683 | } | 683 | } |
684 | 684 | ||
685 | QDate CalendarView::endDate() | 685 | QDate CalendarView::endDate() |
686 | { | 686 | { |
687 | DateList dates = mNavigator->selectedDates(); | 687 | DateList dates = mNavigator->selectedDates(); |
688 | 688 | ||
689 | return dates.last(); | 689 | return dates.last(); |
690 | } | 690 | } |
691 | 691 | ||
692 | 692 | ||
693 | void CalendarView::createPrinter() | 693 | void CalendarView::createPrinter() |
694 | { | 694 | { |
695 | #ifndef KORG_NOPRINTER | 695 | #ifndef KORG_NOPRINTER |
696 | if (!mCalPrinter) { | 696 | if (!mCalPrinter) { |
697 | mCalPrinter = new CalPrinter(this, mCalendar); | 697 | mCalPrinter = new CalPrinter(this, mCalendar); |
698 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 698 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
699 | } | 699 | } |
700 | #endif | 700 | #endif |
701 | } | 701 | } |
702 | 702 | ||
703 | 703 | ||
704 | //KOPrefs::instance()->mWriteBackFile | 704 | //KOPrefs::instance()->mWriteBackFile |
705 | //KOPrefs::instance()->mWriteBackExistingOnly | 705 | //KOPrefs::instance()->mWriteBackExistingOnly |
706 | 706 | ||
707 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 707 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
708 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 708 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
709 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 709 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
710 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 710 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
711 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 711 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
712 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 712 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
713 | 713 | ||
714 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 714 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
715 | { | 715 | { |
716 | 716 | ||
717 | // 0 equal | 717 | // 0 equal |
718 | // 1 take local | 718 | // 1 take local |
719 | // 2 take remote | 719 | // 2 take remote |
720 | // 3 cancel | 720 | // 3 cancel |
721 | QDateTime lastSync = mLastCalendarSync; | 721 | QDateTime lastSync = mLastCalendarSync; |
722 | QDateTime localMod = local->lastModified(); | 722 | QDateTime localMod = local->lastModified(); |
723 | QDateTime remoteMod = remote->lastModified(); | 723 | QDateTime remoteMod = remote->lastModified(); |
724 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 724 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
725 | bool remCh, locCh; | 725 | bool remCh, locCh; |
726 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 726 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
727 | //if ( remCh ) | 727 | //if ( remCh ) |
728 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 728 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
729 | locCh = ( localMod > mLastCalendarSync ); | 729 | locCh = ( localMod > mLastCalendarSync ); |
730 | if ( !remCh && ! locCh ) { | 730 | if ( !remCh && ! locCh ) { |
731 | //qDebug("both not changed "); | 731 | //qDebug("both not changed "); |
732 | lastSync = localMod.addDays(1); | 732 | lastSync = localMod.addDays(1); |
733 | if ( mode <= SYNC_PREF_ASK ) | 733 | if ( mode <= SYNC_PREF_ASK ) |
734 | return 0; | 734 | return 0; |
735 | } else { | 735 | } else { |
736 | if ( locCh ) { | 736 | if ( locCh ) { |
737 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 737 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
738 | lastSync = localMod.addDays( -1 ); | 738 | lastSync = localMod.addDays( -1 ); |
739 | if ( !remCh ) | 739 | if ( !remCh ) |
740 | remoteMod = ( lastSync.addDays( -1 ) ); | 740 | remoteMod = ( lastSync.addDays( -1 ) ); |
741 | } else { | 741 | } else { |
742 | //qDebug(" not loc changed "); | 742 | //qDebug(" not loc changed "); |
743 | lastSync = localMod.addDays( 1 ); | 743 | lastSync = localMod.addDays( 1 ); |
744 | if ( remCh ) | 744 | if ( remCh ) |
745 | remoteMod =( lastSync.addDays( 1 ) ); | 745 | remoteMod =( lastSync.addDays( 1 ) ); |
746 | 746 | ||
747 | } | 747 | } |
748 | } | 748 | } |
749 | full = true; | 749 | full = true; |
750 | if ( mode < SYNC_PREF_ASK ) | 750 | if ( mode < SYNC_PREF_ASK ) |
751 | mode = SYNC_PREF_ASK; | 751 | mode = SYNC_PREF_ASK; |
752 | } else { | 752 | } else { |
753 | if ( localMod == remoteMod ) | 753 | if ( localMod == remoteMod ) |
754 | // if ( local->revision() == remote->revision() ) | 754 | // if ( local->revision() == remote->revision() ) |
755 | return 0; | 755 | return 0; |
756 | 756 | ||
757 | } | 757 | } |
758 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 758 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
759 | 759 | ||
760 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 760 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
761 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 761 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
762 | //full = true; //debug only | 762 | //full = true; //debug only |
763 | if ( full ) { | 763 | if ( full ) { |
764 | bool equ = false; | 764 | bool equ = false; |
765 | if ( local->type() == "Event" ) { | 765 | if ( local->type() == "Event" ) { |
766 | equ = (*((Event*) local) == *((Event*) remote)); | 766 | equ = (*((Event*) local) == *((Event*) remote)); |
767 | } | 767 | } |
768 | else if ( local->type() =="Todo" ) | 768 | else if ( local->type() =="Todo" ) |
769 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 769 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
770 | else if ( local->type() =="Journal" ) | 770 | else if ( local->type() =="Journal" ) |
771 | equ = (*((Journal*) local) == *((Journal*) remote)); | 771 | equ = (*((Journal*) local) == *((Journal*) remote)); |
772 | if ( equ ) { | 772 | if ( equ ) { |
773 | //qDebug("equal "); | 773 | //qDebug("equal "); |
774 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 774 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
775 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 775 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
776 | } | 776 | } |
777 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 777 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
778 | return 0; | 778 | return 0; |
779 | 779 | ||
780 | }//else //debug only | 780 | }//else //debug only |
781 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 781 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
782 | } | 782 | } |
783 | int result; | 783 | int result; |
784 | bool localIsNew; | 784 | bool localIsNew; |
785 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); | 785 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); |
786 | 786 | ||
787 | if ( full && mode < SYNC_PREF_NEWEST ) | 787 | if ( full && mode < SYNC_PREF_NEWEST ) |
788 | mode = SYNC_PREF_ASK; | 788 | mode = SYNC_PREF_ASK; |
789 | 789 | ||
790 | switch( mode ) { | 790 | switch( mode ) { |
791 | case SYNC_PREF_LOCAL: | 791 | case SYNC_PREF_LOCAL: |
792 | if ( lastSync > remoteMod ) | 792 | if ( lastSync > remoteMod ) |
793 | return 1; | 793 | return 1; |
794 | if ( lastSync > localMod ) | 794 | if ( lastSync > localMod ) |
795 | return 2; | 795 | return 2; |
796 | return 1; | 796 | return 1; |
797 | break; | 797 | break; |
798 | case SYNC_PREF_REMOTE: | 798 | case SYNC_PREF_REMOTE: |
799 | if ( lastSync > remoteMod ) | 799 | if ( lastSync > remoteMod ) |
800 | return 1; | 800 | return 1; |
801 | if ( lastSync > localMod ) | 801 | if ( lastSync > localMod ) |
802 | return 2; | 802 | return 2; |
803 | return 2; | 803 | return 2; |
804 | break; | 804 | break; |
805 | case SYNC_PREF_NEWEST: | 805 | case SYNC_PREF_NEWEST: |
806 | if ( localMod > remoteMod ) | 806 | if ( localMod > remoteMod ) |
807 | return 1; | 807 | return 1; |
808 | else | 808 | else |
809 | return 2; | 809 | return 2; |
810 | break; | 810 | break; |
811 | case SYNC_PREF_ASK: | 811 | case SYNC_PREF_ASK: |
812 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 812 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
813 | if ( lastSync > remoteMod ) | 813 | if ( lastSync > remoteMod ) |
814 | return 1; | 814 | return 1; |
815 | if ( lastSync > localMod ) | 815 | if ( lastSync > localMod ) |
816 | return 2; | 816 | return 2; |
817 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 817 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
818 | localIsNew = localMod >= remoteMod; | 818 | localIsNew = localMod >= remoteMod; |
819 | if ( localIsNew ) | 819 | if ( localIsNew ) |
820 | getEventViewerDialog()->setColorMode( 1 ); | 820 | getEventViewerDialog()->setColorMode( 1 ); |
821 | else | 821 | else |
822 | getEventViewerDialog()->setColorMode( 2 ); | 822 | getEventViewerDialog()->setColorMode( 2 ); |
823 | getEventViewerDialog()->setIncidence(local); | 823 | getEventViewerDialog()->setIncidence(local); |
824 | if ( localIsNew ) | 824 | if ( localIsNew ) |
825 | getEventViewerDialog()->setColorMode( 2 ); | 825 | getEventViewerDialog()->setColorMode( 2 ); |
826 | else | 826 | else |
827 | getEventViewerDialog()->setColorMode( 1 ); | 827 | getEventViewerDialog()->setColorMode( 1 ); |
828 | getEventViewerDialog()->addIncidence(remote); | 828 | getEventViewerDialog()->addIncidence(remote); |
829 | getEventViewerDialog()->setColorMode( 0 ); | 829 | getEventViewerDialog()->setColorMode( 0 ); |
830 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 830 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
831 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 831 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
832 | getEventViewerDialog()->showMe(); | 832 | getEventViewerDialog()->showMe(); |
833 | result = getEventViewerDialog()->executeS( localIsNew ); | 833 | result = getEventViewerDialog()->executeS( localIsNew ); |
834 | return result; | 834 | return result; |
835 | 835 | ||
836 | break; | 836 | break; |
837 | case SYNC_PREF_FORCE_LOCAL: | 837 | case SYNC_PREF_FORCE_LOCAL: |
838 | return 1; | 838 | return 1; |
839 | break; | 839 | break; |
840 | case SYNC_PREF_FORCE_REMOTE: | 840 | case SYNC_PREF_FORCE_REMOTE: |
841 | return 2; | 841 | return 2; |
842 | break; | 842 | break; |
843 | 843 | ||
844 | default: | 844 | default: |
845 | // SYNC_PREF_TAKE_BOTH not implemented | 845 | // SYNC_PREF_TAKE_BOTH not implemented |
846 | break; | 846 | break; |
847 | } | 847 | } |
848 | return 0; | 848 | return 0; |
849 | } | 849 | } |
850 | Event* CalendarView::getLastSyncEvent() | 850 | Event* CalendarView::getLastSyncEvent() |
851 | { | 851 | { |
852 | Event* lse; | 852 | Event* lse; |
853 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 853 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
854 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 854 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
855 | if (!lse) { | 855 | if (!lse) { |
856 | lse = new Event(); | 856 | lse = new Event(); |
857 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 857 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
858 | QString sum = ""; | 858 | QString sum = ""; |
859 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 859 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
860 | sum = "E: "; | 860 | sum = "E: "; |
861 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 861 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
862 | lse->setDtStart( mLastCalendarSync ); | 862 | lse->setDtStart( mLastCalendarSync ); |
863 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 863 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
864 | lse->setCategories( i18n("SyncEvent") ); | 864 | lse->setCategories( i18n("SyncEvent") ); |
865 | lse->setReadOnly( true ); | 865 | lse->setReadOnly( true ); |
866 | mCalendar->addEvent( lse ); | 866 | mCalendar->addEvent( lse ); |
867 | } | 867 | } |
868 | 868 | ||
869 | return lse; | 869 | return lse; |
870 | 870 | ||
871 | } | 871 | } |
872 | 872 | ||
873 | // we check, if the to delete event has a id for a profile | 873 | // we check, if the to delete event has a id for a profile |
874 | // if yes, we set this id in the profile to delete | 874 | // if yes, we set this id in the profile to delete |
875 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 875 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
876 | { | 876 | { |
877 | if ( lastSync.count() == 0 ) { | 877 | if ( lastSync.count() == 0 ) { |
878 | //qDebug(" lastSync.count() == 0"); | 878 | //qDebug(" lastSync.count() == 0"); |
879 | return; | 879 | return; |
880 | } | 880 | } |
881 | if ( toDelete->type() == "Journal" ) | 881 | if ( toDelete->type() == "Journal" ) |
882 | return; | 882 | return; |
883 | 883 | ||
884 | Event* eve = lastSync.first(); | 884 | Event* eve = lastSync.first(); |
885 | 885 | ||
886 | while ( eve ) { | 886 | while ( eve ) { |
887 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 887 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
888 | if ( !id.isEmpty() ) { | 888 | if ( !id.isEmpty() ) { |
889 | QString des = eve->description(); | 889 | QString des = eve->description(); |
890 | QString pref = "e"; | 890 | QString pref = "e"; |
891 | if ( toDelete->type() == "Todo" ) | 891 | if ( toDelete->type() == "Todo" ) |
892 | pref = "t"; | 892 | pref = "t"; |
893 | des += pref+ id + ","; | 893 | des += pref+ id + ","; |
894 | eve->setReadOnly( false ); | 894 | eve->setReadOnly( false ); |
895 | eve->setDescription( des ); | 895 | eve->setDescription( des ); |
896 | //qDebug("setdes %s ", des.latin1()); | 896 | //qDebug("setdes %s ", des.latin1()); |
897 | eve->setReadOnly( true ); | 897 | eve->setReadOnly( true ); |
898 | } | 898 | } |
899 | eve = lastSync.next(); | 899 | eve = lastSync.next(); |
900 | } | 900 | } |
901 | 901 | ||
902 | } | 902 | } |
903 | void CalendarView::checkExternalId( Incidence * inc ) | 903 | void CalendarView::checkExternalId( Incidence * inc ) |
904 | { | 904 | { |
905 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 905 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
906 | checkExternSyncEvent( lastSync, inc ); | 906 | checkExternSyncEvent( lastSync, inc ); |
907 | 907 | ||
908 | } | 908 | } |
909 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 909 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
910 | { | 910 | { |
911 | bool syncOK = true; | 911 | bool syncOK = true; |
912 | int addedEvent = 0; | 912 | int addedEvent = 0; |
913 | int addedEventR = 0; | 913 | int addedEventR = 0; |
914 | int deletedEventR = 0; | 914 | int deletedEventR = 0; |
915 | int deletedEventL = 0; | 915 | int deletedEventL = 0; |
916 | int changedLocal = 0; | 916 | int changedLocal = 0; |
917 | int changedRemote = 0; | 917 | int changedRemote = 0; |
918 | //QPtrList<Event> el = local->rawEvents(); | 918 | //QPtrList<Event> el = local->rawEvents(); |
919 | Event* eventR; | 919 | Event* eventR; |
920 | QString uid; | 920 | QString uid; |
921 | int take; | 921 | int take; |
922 | Event* eventL; | 922 | Event* eventL; |
923 | Event* eventRSync; | 923 | Event* eventRSync; |
924 | Event* eventLSync; | 924 | Event* eventLSync; |
925 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 925 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
926 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 926 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
927 | bool fullDateRange = false; | 927 | bool fullDateRange = false; |
928 | local->resetTempSyncStat(); | 928 | local->resetTempSyncStat(); |
929 | mLastCalendarSync = QDateTime::currentDateTime(); | 929 | mLastCalendarSync = QDateTime::currentDateTime(); |
930 | if ( mSyncManager->syncWithDesktop() ) { | 930 | if ( mSyncManager->syncWithDesktop() ) { |
931 | remote->resetPilotStat(1); | 931 | remote->resetPilotStat(1); |
932 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 932 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
933 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 933 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
934 | qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 934 | qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
935 | } else { | 935 | } else { |
936 | qDebug("ERROR: KSyncManager::mRequestedSyncEvent has invalid datatime "); | 936 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
937 | } | 937 | } |
938 | } | 938 | } |
939 | QDateTime modifiedCalendar = mLastCalendarSync;; | 939 | QDateTime modifiedCalendar = mLastCalendarSync; |
940 | eventLSync = getLastSyncEvent(); | 940 | eventLSync = getLastSyncEvent(); |
941 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 941 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
942 | if ( eventR ) { | 942 | if ( eventR ) { |
943 | eventRSync = (Event*) eventR->clone(); | 943 | eventRSync = (Event*) eventR->clone(); |
944 | remote->deleteEvent(eventR ); | 944 | remote->deleteEvent(eventR ); |
945 | 945 | ||
946 | } else { | 946 | } else { |
947 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 947 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
948 | eventRSync = (Event*)eventLSync->clone(); | 948 | eventRSync = (Event*)eventLSync->clone(); |
949 | } else { | 949 | } else { |
950 | fullDateRange = true; | 950 | fullDateRange = true; |
951 | eventRSync = new Event(); | 951 | eventRSync = new Event(); |
952 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 952 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
953 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 953 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
954 | eventRSync->setDtStart( mLastCalendarSync ); | 954 | eventRSync->setDtStart( mLastCalendarSync ); |
955 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 955 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
956 | eventRSync->setCategories( i18n("SyncEvent") ); | 956 | eventRSync->setCategories( i18n("SyncEvent") ); |
957 | } | 957 | } |
958 | } | 958 | } |
959 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 959 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
960 | fullDateRange = true; | 960 | fullDateRange = true; |
961 | 961 | ||
962 | if ( ! fullDateRange ) { | 962 | if ( ! fullDateRange ) { |
963 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 963 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
964 | 964 | ||
965 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 965 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
966 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 966 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
967 | fullDateRange = true; | 967 | fullDateRange = true; |
968 | } | 968 | } |
969 | } | 969 | } |
970 | if ( mSyncManager->syncWithDesktop() ) { | 970 | if ( mSyncManager->syncWithDesktop() ) { |
971 | fullDateRange = ( eventLSync->dtStart() == mLastCalendarSync ); | 971 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
972 | } | 972 | } |
973 | if ( fullDateRange ) | 973 | if ( fullDateRange ) |
974 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 974 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
975 | else | 975 | else |
976 | mLastCalendarSync = eventLSync->dtStart(); | 976 | mLastCalendarSync = eventLSync->dtStart(); |
977 | // for resyncing if own file has changed | 977 | // for resyncing if own file has changed |
978 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 978 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
979 | mLastCalendarSync = loadedFileVersion; | 979 | mLastCalendarSync = loadedFileVersion; |
980 | //qDebug("setting mLastCalendarSync "); | 980 | //qDebug("setting mLastCalendarSync "); |
981 | } | 981 | } |
982 | //qDebug("*************************** "); | 982 | //qDebug("*************************** "); |
983 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 983 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
984 | QPtrList<Incidence> er = remote->rawIncidences(); | 984 | QPtrList<Incidence> er = remote->rawIncidences(); |
985 | Incidence* inR = er.first(); | 985 | Incidence* inR = er.first(); |
986 | Incidence* inL; | 986 | Incidence* inL; |
987 | QProgressBar bar( er.count(),0 ); | 987 | QProgressBar bar( er.count(),0 ); |
988 | bar.setCaption (i18n("Syncing - close to abort!") ); | 988 | bar.setCaption (i18n("Syncing - close to abort!") ); |
989 | 989 | ||
990 | int w = 300; | 990 | int w = 300; |
991 | if ( QApplication::desktop()->width() < 320 ) | 991 | if ( QApplication::desktop()->width() < 320 ) |
992 | w = 220; | 992 | w = 220; |
993 | int h = bar.sizeHint().height() ; | 993 | int h = bar.sizeHint().height() ; |
994 | int dw = QApplication::desktop()->width(); | 994 | int dw = QApplication::desktop()->width(); |
995 | int dh = QApplication::desktop()->height(); | 995 | int dh = QApplication::desktop()->height(); |
996 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 996 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
997 | bar.show(); | 997 | bar.show(); |
998 | int modulo = (er.count()/10)+1; | 998 | int modulo = (er.count()/10)+1; |
999 | int incCounter = 0; | 999 | int incCounter = 0; |
1000 | while ( inR ) { | 1000 | while ( inR ) { |
1001 | if ( ! bar.isVisible() ) | 1001 | if ( ! bar.isVisible() ) |
1002 | return false; | 1002 | return false; |
1003 | if ( incCounter % modulo == 0 ) | 1003 | if ( incCounter % modulo == 0 ) |
1004 | bar.setProgress( incCounter ); | 1004 | bar.setProgress( incCounter ); |
1005 | ++incCounter; | 1005 | ++incCounter; |
1006 | uid = inR->uid(); | 1006 | uid = inR->uid(); |
1007 | bool skipIncidence = false; | 1007 | bool skipIncidence = false; |
1008 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1008 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1009 | skipIncidence = true; | 1009 | skipIncidence = true; |
1010 | QString idS; | 1010 | QString idS; |
1011 | qApp->processEvents(); | 1011 | qApp->processEvents(); |
1012 | if ( !skipIncidence ) { | 1012 | if ( !skipIncidence ) { |
1013 | inL = local->incidence( uid ); | 1013 | inL = local->incidence( uid ); |
1014 | if ( inL ) { // maybe conflict - same uid in both calendars | 1014 | if ( inL ) { // maybe conflict - same uid in both calendars |
1015 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1015 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1016 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1016 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1017 | if ( take == 3 ) | 1017 | if ( take == 3 ) |
1018 | return false; | 1018 | return false; |
1019 | if ( take == 1 ) {// take local ********************** | 1019 | if ( take == 1 ) {// take local ********************** |
1020 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1020 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1021 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1021 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1022 | else | 1022 | else |
1023 | idS = inR->IDStr(); | 1023 | idS = inR->IDStr(); |
1024 | remote->deleteIncidence( inR ); | 1024 | remote->deleteIncidence( inR ); |
1025 | inR = inL->clone(); | 1025 | inR = inL->clone(); |
1026 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1026 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1027 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1027 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1028 | inR->setIDStr( idS ); | 1028 | inR->setIDStr( idS ); |
1029 | remote->addIncidence( inR ); | 1029 | remote->addIncidence( inR ); |
1030 | if ( mSyncManager->syncWithDesktop() ) | 1030 | if ( mSyncManager->syncWithDesktop() ) |
1031 | inR->setPilotId( 2 ); | 1031 | inR->setPilotId( 2 ); |
1032 | ++changedRemote; | 1032 | ++changedRemote; |
1033 | } else {// take remote ********************** | 1033 | } else {// take remote ********************** |
1034 | idS = inL->IDStr(); | 1034 | idS = inL->IDStr(); |
1035 | int pid = inL->pilotId(); | 1035 | int pid = inL->pilotId(); |
1036 | local->deleteIncidence( inL ); | 1036 | local->deleteIncidence( inL ); |
1037 | inL = inR->clone(); | 1037 | inL = inR->clone(); |
1038 | if ( mSyncManager->syncWithDesktop() ) | 1038 | if ( mSyncManager->syncWithDesktop() ) |
1039 | inL->setPilotId( pid ); | 1039 | inL->setPilotId( pid ); |
1040 | inL->setIDStr( idS ); | 1040 | inL->setIDStr( idS ); |
1041 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1041 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1042 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1042 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1043 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1043 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1044 | } | 1044 | } |
1045 | local->addIncidence( inL ); | 1045 | local->addIncidence( inL ); |
1046 | ++changedLocal; | 1046 | ++changedLocal; |
1047 | } | 1047 | } |
1048 | } | 1048 | } |
1049 | } else { // no conflict ********** add or delete remote | 1049 | } else { // no conflict ********** add or delete remote |
1050 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1050 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1051 | QString des = eventLSync->description(); | 1051 | QString des = eventLSync->description(); |
1052 | QString pref = "e"; | 1052 | QString pref = "e"; |
1053 | if ( inR->type() == "Todo" ) | 1053 | if ( inR->type() == "Todo" ) |
1054 | pref = "t"; | 1054 | pref = "t"; |
1055 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1055 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1056 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1056 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1057 | //remote->deleteIncidence( inR ); | 1057 | //remote->deleteIncidence( inR ); |
1058 | ++deletedEventR; | 1058 | ++deletedEventR; |
1059 | } else { | 1059 | } else { |
1060 | inR->setLastModified( modifiedCalendar ); | 1060 | inR->setLastModified( modifiedCalendar ); |
1061 | inL = inR->clone(); | 1061 | inL = inR->clone(); |
1062 | inL->setIDStr( ":" ); | 1062 | inL->setIDStr( ":" ); |
1063 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1063 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1064 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1064 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1065 | local->addIncidence( inL ); | 1065 | local->addIncidence( inL ); |
1066 | ++addedEvent; | 1066 | ++addedEvent; |
1067 | } | 1067 | } |
1068 | } else { | 1068 | } else { |
1069 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1069 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1070 | inR->setLastModified( modifiedCalendar ); | 1070 | inR->setLastModified( modifiedCalendar ); |
1071 | inL = inR->clone(); | 1071 | inL = inR->clone(); |
1072 | inL->setIDStr( ":" ); | 1072 | inL->setIDStr( ":" ); |
1073 | local->addIncidence( inL ); | 1073 | local->addIncidence( inL ); |
1074 | ++addedEvent; | 1074 | ++addedEvent; |
1075 | } else { | 1075 | } else { |
1076 | checkExternSyncEvent(eventRSyncSharp, inR); | 1076 | checkExternSyncEvent(eventRSyncSharp, inR); |
1077 | remote->deleteIncidence( inR ); | 1077 | remote->deleteIncidence( inR ); |
1078 | ++deletedEventR; | 1078 | ++deletedEventR; |
1079 | } | 1079 | } |
1080 | } | 1080 | } |
1081 | } | 1081 | } |
1082 | } | 1082 | } |
1083 | inR = er.next(); | 1083 | inR = er.next(); |
1084 | } | 1084 | } |
1085 | QPtrList<Incidence> el = local->rawIncidences(); | 1085 | QPtrList<Incidence> el = local->rawIncidences(); |
1086 | inL = el.first(); | 1086 | inL = el.first(); |
1087 | modulo = (el.count()/10)+1; | 1087 | modulo = (el.count()/10)+1; |
1088 | bar.setCaption (i18n("Add / remove events") ); | 1088 | bar.setCaption (i18n("Add / remove events") ); |
1089 | bar.setTotalSteps ( el.count() ) ; | 1089 | bar.setTotalSteps ( el.count() ) ; |
1090 | bar.show(); | 1090 | bar.show(); |
1091 | incCounter = 0; | 1091 | incCounter = 0; |
1092 | 1092 | ||
1093 | while ( inL ) { | 1093 | while ( inL ) { |
1094 | 1094 | ||
1095 | qApp->processEvents(); | 1095 | qApp->processEvents(); |
1096 | if ( ! bar.isVisible() ) | 1096 | if ( ! bar.isVisible() ) |
1097 | return false; | 1097 | return false; |
1098 | if ( incCounter % modulo == 0 ) | 1098 | if ( incCounter % modulo == 0 ) |
1099 | bar.setProgress( incCounter ); | 1099 | bar.setProgress( incCounter ); |
1100 | ++incCounter; | 1100 | ++incCounter; |
1101 | uid = inL->uid(); | 1101 | uid = inL->uid(); |
1102 | bool skipIncidence = false; | 1102 | bool skipIncidence = false; |
1103 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1103 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1104 | skipIncidence = true; | 1104 | skipIncidence = true; |
1105 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1105 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1106 | skipIncidence = true; | 1106 | skipIncidence = true; |
1107 | if ( !skipIncidence ) { | 1107 | if ( !skipIncidence ) { |
1108 | inR = remote->incidence( uid ); | 1108 | inR = remote->incidence( uid ); |
1109 | if ( ! inR ) { // no conflict ********** add or delete local | 1109 | if ( ! inR ) { // no conflict ********** add or delete local |
1110 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1110 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1111 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1111 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1112 | checkExternSyncEvent(eventLSyncSharp, inL); | 1112 | checkExternSyncEvent(eventLSyncSharp, inL); |
1113 | local->deleteIncidence( inL ); | 1113 | local->deleteIncidence( inL ); |
1114 | ++deletedEventL; | 1114 | ++deletedEventL; |
1115 | } else { | 1115 | } else { |
1116 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1116 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1117 | inL->removeID(mCurrentSyncDevice ); | 1117 | inL->removeID(mCurrentSyncDevice ); |
1118 | ++addedEventR; | 1118 | ++addedEventR; |
1119 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1119 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1120 | inL->setLastModified( modifiedCalendar ); | 1120 | inL->setLastModified( modifiedCalendar ); |
1121 | inR = inL->clone(); | 1121 | inR = inL->clone(); |
1122 | inR->setIDStr( ":" ); | 1122 | inR->setIDStr( ":" ); |
1123 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1123 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1124 | remote->addIncidence( inR ); | 1124 | remote->addIncidence( inR ); |
1125 | } | 1125 | } |
1126 | } | 1126 | } |
1127 | } else { | 1127 | } else { |
1128 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1128 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1129 | checkExternSyncEvent(eventLSyncSharp, inL); | 1129 | checkExternSyncEvent(eventLSyncSharp, inL); |
1130 | local->deleteIncidence( inL ); | 1130 | local->deleteIncidence( inL ); |
1131 | ++deletedEventL; | 1131 | ++deletedEventL; |
1132 | } else { | 1132 | } else { |
1133 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1133 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1134 | ++addedEventR; | 1134 | ++addedEventR; |
1135 | inL->setLastModified( modifiedCalendar ); | 1135 | inL->setLastModified( modifiedCalendar ); |
1136 | inR = inL->clone(); | 1136 | inR = inL->clone(); |
1137 | inR->setIDStr( ":" ); | 1137 | inR->setIDStr( ":" ); |
1138 | remote->addIncidence( inR ); | 1138 | remote->addIncidence( inR ); |
1139 | } | 1139 | } |
1140 | } | 1140 | } |
1141 | } | 1141 | } |
1142 | } | 1142 | } |
1143 | } | 1143 | } |
1144 | inL = el.next(); | 1144 | inL = el.next(); |
1145 | } | 1145 | } |
1146 | int delFut = 0; | 1146 | int delFut = 0; |
1147 | int remRem = 0; | 1147 | int remRem = 0; |
1148 | if ( mSyncManager->mWriteBackInFuture ) { | 1148 | if ( mSyncManager->mWriteBackInFuture ) { |
1149 | er = remote->rawIncidences(); | 1149 | er = remote->rawIncidences(); |
1150 | remRem = er.count(); | 1150 | remRem = er.count(); |
1151 | inR = er.first(); | 1151 | inR = er.first(); |
1152 | QDateTime dt; | 1152 | QDateTime dt; |
1153 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1153 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1154 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); | 1154 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); |
1155 | while ( inR ) { | 1155 | while ( inR ) { |
1156 | if ( inR->type() == "Todo" ) { | 1156 | if ( inR->type() == "Todo" ) { |
1157 | Todo * t = (Todo*)inR; | 1157 | Todo * t = (Todo*)inR; |
1158 | if ( t->hasDueDate() ) | 1158 | if ( t->hasDueDate() ) |
1159 | dt = t->dtDue(); | 1159 | dt = t->dtDue(); |
1160 | else | 1160 | else |
1161 | dt = cur.addSecs( 62 ); | 1161 | dt = cur.addSecs( 62 ); |
1162 | } | 1162 | } |
1163 | else if (inR->type() == "Event" ) { | 1163 | else if (inR->type() == "Event" ) { |
1164 | bool ok; | 1164 | bool ok; |
1165 | dt = inR->getNextOccurence( cur, &ok ); | 1165 | dt = inR->getNextOccurence( cur, &ok ); |
1166 | if ( !ok ) | 1166 | if ( !ok ) |
1167 | dt = cur.addSecs( -62 ); | 1167 | dt = cur.addSecs( -62 ); |
1168 | } | 1168 | } |
1169 | else | 1169 | else |
1170 | dt = inR->dtStart(); | 1170 | dt = inR->dtStart(); |
1171 | if ( dt < cur || dt > end ) { | 1171 | if ( dt < cur || dt > end ) { |
1172 | remote->deleteIncidence( inR ); | 1172 | remote->deleteIncidence( inR ); |
1173 | ++delFut; | 1173 | ++delFut; |
1174 | } | 1174 | } |
1175 | inR = er.next(); | 1175 | inR = er.next(); |
1176 | } | 1176 | } |
1177 | } | 1177 | } |
1178 | bar.hide(); | 1178 | bar.hide(); |
1179 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1179 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1180 | eventLSync->setReadOnly( false ); | 1180 | eventLSync->setReadOnly( false ); |
1181 | eventLSync->setDtStart( mLastCalendarSync ); | 1181 | eventLSync->setDtStart( mLastCalendarSync ); |
1182 | eventRSync->setDtStart( mLastCalendarSync ); | 1182 | eventRSync->setDtStart( mLastCalendarSync ); |
1183 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1183 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1184 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1184 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1185 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1185 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1186 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1186 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1187 | eventLSync->setReadOnly( true ); | 1187 | eventLSync->setReadOnly( true ); |
1188 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1188 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1189 | remote->addEvent( eventRSync ); | 1189 | remote->addEvent( eventRSync ); |
1190 | else | 1190 | else |
1191 | delete eventRSync; | 1191 | delete eventRSync; |
1192 | QString mes; | 1192 | QString mes; |
1193 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); | 1193 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); |
1194 | QString delmess; | 1194 | QString delmess; |
1195 | if ( delFut ) { | 1195 | if ( delFut ) { |
1196 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1196 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1197 | mes += delmess; | 1197 | mes += delmess; |
1198 | } | 1198 | } |
1199 | mes = i18n("Local calendar changed!\n") +mes; | 1199 | mes = i18n("Local calendar changed!\n") +mes; |
1200 | mCalendar->checkAlarmForIncidence( 0, true ); | 1200 | mCalendar->checkAlarmForIncidence( 0, true ); |
1201 | qDebug( mes ); | 1201 | qDebug( mes ); |
1202 | if ( mSyncManager->mShowSyncSummary ) { | 1202 | if ( mSyncManager->mShowSyncSummary ) { |
1203 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1203 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1204 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1204 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1205 | qDebug("cancelled "); | 1205 | qDebug("cancelled "); |
1206 | return false; | 1206 | return false; |
1207 | } | 1207 | } |
1208 | } | 1208 | } |
1209 | return syncOK; | 1209 | return syncOK; |
1210 | } | 1210 | } |
1211 | 1211 | ||
1212 | void CalendarView::setSyncDevice( QString s ) | 1212 | void CalendarView::setSyncDevice( QString s ) |
1213 | { | 1213 | { |
1214 | mCurrentSyncDevice= s; | 1214 | mCurrentSyncDevice= s; |
1215 | } | 1215 | } |
1216 | void CalendarView::setSyncName( QString s ) | 1216 | void CalendarView::setSyncName( QString s ) |
1217 | { | 1217 | { |
1218 | mCurrentSyncName= s; | 1218 | mCurrentSyncName= s; |
1219 | } | 1219 | } |
1220 | bool CalendarView::syncCalendar(QString filename, int mode) | 1220 | bool CalendarView::syncCalendar(QString filename, int mode) |
1221 | { | 1221 | { |
1222 | //qDebug("syncCalendar %s ", filename.latin1()); | 1222 | //qDebug("syncCalendar %s ", filename.latin1()); |
1223 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1223 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1224 | CalendarLocal* calendar = new CalendarLocal(); | 1224 | CalendarLocal* calendar = new CalendarLocal(); |
1225 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1225 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1226 | FileStorage* storage = new FileStorage( calendar ); | 1226 | FileStorage* storage = new FileStorage( calendar ); |
1227 | bool syncOK = false; | 1227 | bool syncOK = false; |
1228 | storage->setFileName( filename ); | 1228 | storage->setFileName( filename ); |
1229 | // qDebug("loading ... "); | 1229 | // qDebug("loading ... "); |
1230 | if ( storage->load() ) { | 1230 | if ( storage->load() ) { |
1231 | getEventViewerDialog()->setSyncMode( true ); | 1231 | getEventViewerDialog()->setSyncMode( true ); |
1232 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1232 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1233 | getEventViewerDialog()->setSyncMode( false ); | 1233 | getEventViewerDialog()->setSyncMode( false ); |
1234 | if ( syncOK ) { | 1234 | if ( syncOK ) { |
1235 | if ( mSyncManager->mWriteBackFile ) | 1235 | if ( mSyncManager->mWriteBackFile ) |
1236 | { | 1236 | { |
1237 | storage->setSaveFormat( new ICalFormat() ); | 1237 | storage->setSaveFormat( new ICalFormat() ); |
1238 | storage->save(); | 1238 | storage->save(); |
1239 | } | 1239 | } |
1240 | } | 1240 | } |
1241 | setModified( true ); | 1241 | setModified( true ); |
1242 | } | 1242 | } |
1243 | delete storage; | 1243 | delete storage; |
1244 | delete calendar; | 1244 | delete calendar; |
1245 | if ( syncOK ) | 1245 | if ( syncOK ) |
1246 | updateView(); | 1246 | updateView(); |
1247 | return syncOK; | 1247 | return syncOK; |
1248 | } | 1248 | } |
1249 | 1249 | ||
1250 | void CalendarView::syncExternal( int mode ) | 1250 | void CalendarView::syncExternal( int mode ) |
1251 | { | 1251 | { |
1252 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1252 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1253 | 1253 | ||
1254 | qApp->processEvents(); | 1254 | qApp->processEvents(); |
1255 | CalendarLocal* calendar = new CalendarLocal(); | 1255 | CalendarLocal* calendar = new CalendarLocal(); |
1256 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1256 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1257 | bool syncOK = false; | 1257 | bool syncOK = false; |
1258 | bool loadSuccess = false; | 1258 | bool loadSuccess = false; |
1259 | PhoneFormat* phoneFormat = 0; | 1259 | PhoneFormat* phoneFormat = 0; |
1260 | emit tempDisableBR(true); | 1260 | emit tempDisableBR(true); |
1261 | #ifndef DESKTOP_VERSION | 1261 | #ifndef DESKTOP_VERSION |
1262 | SharpFormat* sharpFormat = 0; | 1262 | SharpFormat* sharpFormat = 0; |
1263 | if ( mode == 0 ) { // sharp | 1263 | if ( mode == 0 ) { // sharp |
1264 | sharpFormat = new SharpFormat () ; | 1264 | sharpFormat = new SharpFormat () ; |
1265 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1265 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1266 | 1266 | ||
1267 | } else | 1267 | } else |
1268 | #endif | 1268 | #endif |
1269 | if ( mode == 1 ) { // phone | 1269 | if ( mode == 1 ) { // phone |
1270 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1270 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1271 | mSyncManager->mPhoneDevice, | 1271 | mSyncManager->mPhoneDevice, |
1272 | mSyncManager->mPhoneConnection, | 1272 | mSyncManager->mPhoneConnection, |
1273 | mSyncManager->mPhoneModel); | 1273 | mSyncManager->mPhoneModel); |
1274 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1274 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1275 | 1275 | ||
1276 | } else { | 1276 | } else { |
1277 | emit tempDisableBR(false); | 1277 | emit tempDisableBR(false); |
1278 | return; | 1278 | return; |
1279 | } | 1279 | } |
1280 | if ( loadSuccess ) { | 1280 | if ( loadSuccess ) { |
1281 | getEventViewerDialog()->setSyncMode( true ); | 1281 | getEventViewerDialog()->setSyncMode( true ); |
1282 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1282 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1283 | getEventViewerDialog()->setSyncMode( false ); | 1283 | getEventViewerDialog()->setSyncMode( false ); |
1284 | qApp->processEvents(); | 1284 | qApp->processEvents(); |
1285 | if ( syncOK ) { | 1285 | if ( syncOK ) { |
1286 | if ( mSyncManager->mWriteBackFile ) | 1286 | if ( mSyncManager->mWriteBackFile ) |
1287 | { | 1287 | { |
1288 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1288 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1289 | Incidence* inc = iL.first(); | 1289 | Incidence* inc = iL.first(); |
1290 | if ( phoneFormat ) { | 1290 | if ( phoneFormat ) { |
1291 | while ( inc ) { | 1291 | while ( inc ) { |
1292 | inc->removeID(mCurrentSyncDevice); | 1292 | inc->removeID(mCurrentSyncDevice); |
1293 | inc = iL.next(); | 1293 | inc = iL.next(); |
1294 | } | 1294 | } |
1295 | } | 1295 | } |
1296 | #ifndef DESKTOP_VERSION | 1296 | #ifndef DESKTOP_VERSION |
1297 | if ( sharpFormat ) | 1297 | if ( sharpFormat ) |
1298 | sharpFormat->save(calendar); | 1298 | sharpFormat->save(calendar); |
1299 | #endif | 1299 | #endif |
1300 | if ( phoneFormat ) | 1300 | if ( phoneFormat ) |
1301 | phoneFormat->save(calendar); | 1301 | phoneFormat->save(calendar); |
1302 | iL = calendar->rawIncidences(); | 1302 | iL = calendar->rawIncidences(); |
1303 | inc = iL.first(); | 1303 | inc = iL.first(); |
1304 | Incidence* loc; | 1304 | Incidence* loc; |
1305 | while ( inc ) { | 1305 | while ( inc ) { |
1306 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1306 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1307 | loc = mCalendar->incidence(inc->uid() ); | 1307 | loc = mCalendar->incidence(inc->uid() ); |
1308 | if ( loc ) { | 1308 | if ( loc ) { |
1309 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1309 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1310 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1310 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1311 | } | 1311 | } |
1312 | } | 1312 | } |
1313 | inc = iL.next(); | 1313 | inc = iL.next(); |
1314 | } | 1314 | } |
1315 | Incidence* lse = getLastSyncEvent(); | 1315 | Incidence* lse = getLastSyncEvent(); |
1316 | if ( lse ) { | 1316 | if ( lse ) { |
1317 | lse->setReadOnly( false ); | 1317 | lse->setReadOnly( false ); |
1318 | lse->setDescription( "" ); | 1318 | lse->setDescription( "" ); |
1319 | lse->setReadOnly( true ); | 1319 | lse->setReadOnly( true ); |
1320 | } | 1320 | } |
1321 | } | 1321 | } |
1322 | } else { | 1322 | } else { |
1323 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1323 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1324 | } | 1324 | } |
1325 | setModified( true ); | 1325 | setModified( true ); |
1326 | } else { | 1326 | } else { |
1327 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1327 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1328 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1328 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1329 | question, i18n("Ok")) ; | 1329 | question, i18n("Ok")) ; |
1330 | 1330 | ||
1331 | } | 1331 | } |
1332 | delete calendar; | 1332 | delete calendar; |
1333 | updateView(); | 1333 | updateView(); |
1334 | emit tempDisableBR(false); | 1334 | emit tempDisableBR(false); |
1335 | return ;//syncOK; | 1335 | return ;//syncOK; |
1336 | 1336 | ||
1337 | } | 1337 | } |
1338 | 1338 | ||
1339 | bool CalendarView::importBday() | 1339 | bool CalendarView::importBday() |
1340 | { | 1340 | { |
1341 | #ifndef KORG_NOKABC | 1341 | #ifndef KORG_NOKABC |
1342 | 1342 | ||
1343 | #ifdef DESKTOP_VERSION | 1343 | #ifdef DESKTOP_VERSION |
1344 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1344 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1345 | KABC::AddressBook::Iterator it; | 1345 | KABC::AddressBook::Iterator it; |
1346 | int count = 0; | 1346 | int count = 0; |
1347 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1347 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1348 | ++count; | 1348 | ++count; |
1349 | } | 1349 | } |
1350 | QProgressBar bar(count,0 ); | 1350 | QProgressBar bar(count,0 ); |
1351 | int w = 300; | 1351 | int w = 300; |
1352 | if ( QApplication::desktop()->width() < 320 ) | 1352 | if ( QApplication::desktop()->width() < 320 ) |
1353 | w = 220; | 1353 | w = 220; |
1354 | int h = bar.sizeHint().height() ; | 1354 | int h = bar.sizeHint().height() ; |
1355 | int dw = QApplication::desktop()->width(); | 1355 | int dw = QApplication::desktop()->width(); |
1356 | int dh = QApplication::desktop()->height(); | 1356 | int dh = QApplication::desktop()->height(); |
1357 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1357 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1358 | bar.show(); | 1358 | bar.show(); |
1359 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1359 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1360 | qApp->processEvents(); | 1360 | qApp->processEvents(); |
1361 | count = 0; | 1361 | count = 0; |
1362 | int addCount = 0; | 1362 | int addCount = 0; |
1363 | KCal::Attendee* a = 0; | 1363 | KCal::Attendee* a = 0; |
1364 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1364 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1365 | if ( ! bar.isVisible() ) | 1365 | if ( ! bar.isVisible() ) |
1366 | return false; | 1366 | return false; |
1367 | bar.setProgress( count++ ); | 1367 | bar.setProgress( count++ ); |
1368 | qApp->processEvents(); | 1368 | qApp->processEvents(); |
1369 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1369 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1370 | if ( (*it).birthday().date().isValid() ){ | 1370 | if ( (*it).birthday().date().isValid() ){ |
1371 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1371 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1372 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1372 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1373 | ++addCount; | 1373 | ++addCount; |
1374 | } | 1374 | } |
1375 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1375 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1376 | if ( anni.isValid() ){ | 1376 | if ( anni.isValid() ){ |
1377 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1377 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1378 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1378 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1379 | ++addCount; | 1379 | ++addCount; |
1380 | } | 1380 | } |
1381 | } | 1381 | } |
1382 | updateView(); | 1382 | updateView(); |
1383 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1383 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1384 | #else //DESKTOP_VERSION | 1384 | #else //DESKTOP_VERSION |
1385 | 1385 | ||
1386 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1386 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1387 | // the result should now arrive through method insertBirthdays | 1387 | // the result should now arrive through method insertBirthdays |
1388 | 1388 | ||
1389 | #endif //DESKTOP_VERSION | 1389 | #endif //DESKTOP_VERSION |
1390 | 1390 | ||
1391 | #endif //KORG_NOKABC | 1391 | #endif //KORG_NOKABC |
1392 | 1392 | ||
1393 | 1393 | ||
1394 | return true; | 1394 | return true; |
1395 | } | 1395 | } |
1396 | 1396 | ||
1397 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1397 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1398 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1398 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1399 | const QStringList& anniversaryList, const QStringList& realNameList, | 1399 | const QStringList& anniversaryList, const QStringList& realNameList, |
1400 | const QStringList& emailList, const QStringList& assembledNameList, | 1400 | const QStringList& emailList, const QStringList& assembledNameList, |
1401 | const QStringList& uidList) | 1401 | const QStringList& uidList) |
1402 | { | 1402 | { |
1403 | qDebug("CalendarView::insertBirthdays"); | 1403 | qDebug("CalendarView::insertBirthdays"); |
1404 | if (uid == this->name()) | 1404 | if (uid == this->name()) |
1405 | { | 1405 | { |
1406 | int count = birthdayList.count(); | 1406 | int count = birthdayList.count(); |
1407 | int addCount = 0; | 1407 | int addCount = 0; |
1408 | KCal::Attendee* a = 0; | 1408 | KCal::Attendee* a = 0; |
1409 | 1409 | ||
1410 | qDebug("CalView 1 %i", count); | 1410 | qDebug("CalView 1 %i", count); |
1411 | 1411 | ||
1412 | QProgressBar bar(count,0 ); | 1412 | QProgressBar bar(count,0 ); |
1413 | int w = 300; | 1413 | int w = 300; |
1414 | if ( QApplication::desktop()->width() < 320 ) | 1414 | if ( QApplication::desktop()->width() < 320 ) |
1415 | w = 220; | 1415 | w = 220; |
1416 | int h = bar.sizeHint().height() ; | 1416 | int h = bar.sizeHint().height() ; |
1417 | int dw = QApplication::desktop()->width(); | 1417 | int dw = QApplication::desktop()->width(); |
1418 | int dh = QApplication::desktop()->height(); | 1418 | int dh = QApplication::desktop()->height(); |
1419 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1419 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1420 | bar.show(); | 1420 | bar.show(); |
1421 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1421 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1422 | qApp->processEvents(); | 1422 | qApp->processEvents(); |
1423 | 1423 | ||
1424 | QDate birthday; | 1424 | QDate birthday; |
1425 | QDate anniversary; | 1425 | QDate anniversary; |
1426 | QString realName; | 1426 | QString realName; |
1427 | QString email; | 1427 | QString email; |
1428 | QString assembledName; | 1428 | QString assembledName; |
1429 | QString uid; | 1429 | QString uid; |
1430 | bool ok = true; | 1430 | bool ok = true; |
1431 | for ( int i = 0; i < count; i++) | 1431 | for ( int i = 0; i < count; i++) |
1432 | { | 1432 | { |
1433 | if ( ! bar.isVisible() ) | 1433 | if ( ! bar.isVisible() ) |
1434 | return; | 1434 | return; |
1435 | bar.setProgress( i ); | 1435 | bar.setProgress( i ); |
1436 | qApp->processEvents(); | 1436 | qApp->processEvents(); |
1437 | 1437 | ||
1438 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1438 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1439 | if (!ok) { | 1439 | if (!ok) { |
1440 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1440 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1441 | } | 1441 | } |
1442 | 1442 | ||
1443 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1443 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1444 | if (!ok) { | 1444 | if (!ok) { |
1445 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1445 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1446 | } | 1446 | } |
1447 | realName = realNameList[i]; | 1447 | realName = realNameList[i]; |
1448 | email = emailList[i]; | 1448 | email = emailList[i]; |
1449 | assembledName = assembledNameList[i]; | 1449 | assembledName = assembledNameList[i]; |
1450 | uid = uidList[i]; | 1450 | uid = uidList[i]; |
1451 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); | 1451 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); |
1452 | 1452 | ||
1453 | if ( birthday.isValid() ){ | 1453 | if ( birthday.isValid() ){ |
1454 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1454 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1455 | KCal::Attendee::ReqParticipant,uid) ; | 1455 | KCal::Attendee::ReqParticipant,uid) ; |
1456 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1456 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1457 | ++addCount; | 1457 | ++addCount; |
1458 | } | 1458 | } |
1459 | 1459 | ||
1460 | if ( anniversary.isValid() ){ | 1460 | if ( anniversary.isValid() ){ |
1461 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1461 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1462 | KCal::Attendee::ReqParticipant,uid) ; | 1462 | KCal::Attendee::ReqParticipant,uid) ; |
1463 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1463 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1464 | ++addCount; | 1464 | ++addCount; |
1465 | } | 1465 | } |
1466 | } | 1466 | } |
1467 | 1467 | ||
1468 | updateView(); | 1468 | updateView(); |
1469 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1469 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1470 | 1470 | ||
1471 | } | 1471 | } |
1472 | 1472 | ||
1473 | } | 1473 | } |
1474 | 1474 | ||
1475 | 1475 | ||
1476 | 1476 | ||
1477 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1477 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1478 | { | 1478 | { |
1479 | //qDebug("addAnni "); | 1479 | //qDebug("addAnni "); |
1480 | Event * ev = new Event(); | 1480 | Event * ev = new Event(); |
1481 | if ( a ) { | 1481 | if ( a ) { |
1482 | ev->addAttendee( a ); | 1482 | ev->addAttendee( a ); |
1483 | } | 1483 | } |
1484 | QString kind; | 1484 | QString kind; |
1485 | if ( birthday ) | 1485 | if ( birthday ) |
1486 | kind = i18n( "Birthday" ); | 1486 | kind = i18n( "Birthday" ); |
1487 | else | 1487 | else |
1488 | kind = i18n( "Anniversary" ); | 1488 | kind = i18n( "Anniversary" ); |
1489 | ev->setSummary( name + " - " + kind ); | 1489 | ev->setSummary( name + " - " + kind ); |
1490 | ev->setOrganizer(a->email()); | 1490 | ev->setOrganizer(a->email()); |
1491 | ev->setCategories( kind ); | 1491 | ev->setCategories( kind ); |
1492 | ev->setDtStart( QDateTime(date) ); | 1492 | ev->setDtStart( QDateTime(date) ); |
1493 | ev->setDtEnd( QDateTime(date) ); | 1493 | ev->setDtEnd( QDateTime(date) ); |
1494 | ev->setFloats( true ); | 1494 | ev->setFloats( true ); |
1495 | Recurrence * rec = ev->recurrence(); | 1495 | Recurrence * rec = ev->recurrence(); |
1496 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1496 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1497 | rec->addYearlyNum( date.month() ); | 1497 | rec->addYearlyNum( date.month() ); |
1498 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1498 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1499 | delete ev; | 1499 | delete ev; |
1500 | return false; | 1500 | return false; |
1501 | } | 1501 | } |
1502 | return true; | 1502 | return true; |
1503 | 1503 | ||
1504 | } | 1504 | } |
1505 | bool CalendarView::importQtopia( const QString &categories, | 1505 | bool CalendarView::importQtopia( const QString &categories, |
1506 | const QString &datebook, | 1506 | const QString &datebook, |
1507 | const QString &todolist ) | 1507 | const QString &todolist ) |
1508 | { | 1508 | { |
1509 | 1509 | ||
1510 | QtopiaFormat qtopiaFormat; | 1510 | QtopiaFormat qtopiaFormat; |
1511 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1511 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1512 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1512 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1513 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1513 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1514 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1514 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1515 | 1515 | ||
1516 | updateView(); | 1516 | updateView(); |
1517 | return true; | 1517 | return true; |
1518 | 1518 | ||
1519 | #if 0 | 1519 | #if 0 |
1520 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1520 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1521 | mCurrentSyncDevice = "qtopia-XML"; | 1521 | mCurrentSyncDevice = "qtopia-XML"; |
1522 | if ( mSyncManager->mAskForPreferences ) | 1522 | if ( mSyncManager->mAskForPreferences ) |
1523 | edit_sync_options(); | 1523 | edit_sync_options(); |
1524 | qApp->processEvents(); | 1524 | qApp->processEvents(); |
1525 | CalendarLocal* calendar = new CalendarLocal(); | 1525 | CalendarLocal* calendar = new CalendarLocal(); |
1526 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1526 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1527 | bool syncOK = false; | 1527 | bool syncOK = false; |
1528 | QtopiaFormat qtopiaFormat; | 1528 | QtopiaFormat qtopiaFormat; |
1529 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1529 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1530 | bool loadOk = true; | 1530 | bool loadOk = true; |
1531 | if ( !categories.isEmpty() ) | 1531 | if ( !categories.isEmpty() ) |
1532 | loadOk = qtopiaFormat.load( calendar, categories ); | 1532 | loadOk = qtopiaFormat.load( calendar, categories ); |
1533 | if ( loadOk && !datebook.isEmpty() ) | 1533 | if ( loadOk && !datebook.isEmpty() ) |
1534 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1534 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1535 | if ( loadOk && !todolist.isEmpty() ) | 1535 | if ( loadOk && !todolist.isEmpty() ) |
1536 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1536 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1537 | 1537 | ||
1538 | if ( loadOk ) { | 1538 | if ( loadOk ) { |
1539 | getEventViewerDialog()->setSyncMode( true ); | 1539 | getEventViewerDialog()->setSyncMode( true ); |
1540 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1540 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1541 | getEventViewerDialog()->setSyncMode( false ); | 1541 | getEventViewerDialog()->setSyncMode( false ); |
1542 | qApp->processEvents(); | 1542 | qApp->processEvents(); |
1543 | if ( syncOK ) { | 1543 | if ( syncOK ) { |
1544 | if ( mSyncManager->mWriteBackFile ) | 1544 | if ( mSyncManager->mWriteBackFile ) |
1545 | { | 1545 | { |
1546 | // write back XML file | 1546 | // write back XML file |
1547 | 1547 | ||
1548 | } | 1548 | } |
1549 | setModified( true ); | 1549 | setModified( true ); |
1550 | } | 1550 | } |
1551 | } else { | 1551 | } else { |
1552 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1552 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1553 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1553 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1554 | question, i18n("Ok")) ; | 1554 | question, i18n("Ok")) ; |
1555 | } | 1555 | } |
1556 | delete calendar; | 1556 | delete calendar; |
1557 | updateView(); | 1557 | updateView(); |
1558 | return syncOK; | 1558 | return syncOK; |
1559 | 1559 | ||
1560 | 1560 | ||
1561 | #endif | 1561 | #endif |
1562 | 1562 | ||
1563 | } | 1563 | } |
1564 | 1564 | ||
1565 | void CalendarView::setSyncEventsReadOnly() | 1565 | void CalendarView::setSyncEventsReadOnly() |
1566 | { | 1566 | { |
1567 | Event * ev; | 1567 | Event * ev; |
1568 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1568 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1569 | ev = eL.first(); | 1569 | ev = eL.first(); |
1570 | while ( ev ) { | 1570 | while ( ev ) { |
1571 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1571 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1572 | ev->setReadOnly( true ); | 1572 | ev->setReadOnly( true ); |
1573 | ev = eL.next(); | 1573 | ev = eL.next(); |
1574 | } | 1574 | } |
1575 | } | 1575 | } |
1576 | bool CalendarView::openCalendar(QString filename, bool merge) | 1576 | bool CalendarView::openCalendar(QString filename, bool merge) |
1577 | { | 1577 | { |
1578 | 1578 | ||
1579 | if (filename.isEmpty()) { | 1579 | if (filename.isEmpty()) { |
1580 | return false; | 1580 | return false; |
1581 | } | 1581 | } |
1582 | 1582 | ||
1583 | if (!QFile::exists(filename)) { | 1583 | if (!QFile::exists(filename)) { |
1584 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1584 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1585 | return false; | 1585 | return false; |
1586 | } | 1586 | } |
1587 | 1587 | ||
1588 | globalFlagBlockAgenda = 1; | 1588 | globalFlagBlockAgenda = 1; |
1589 | if (!merge) mCalendar->close(); | 1589 | if (!merge) mCalendar->close(); |
1590 | 1590 | ||
1591 | mStorage->setFileName( filename ); | 1591 | mStorage->setFileName( filename ); |
1592 | 1592 | ||
1593 | if ( mStorage->load() ) { | 1593 | if ( mStorage->load() ) { |
1594 | if ( merge ) ;//setModified( true ); | 1594 | if ( merge ) ;//setModified( true ); |
1595 | else { | 1595 | else { |
1596 | //setModified( true ); | 1596 | //setModified( true ); |
1597 | mViewManager->setDocumentId( filename ); | 1597 | mViewManager->setDocumentId( filename ); |
1598 | mDialogManager->setDocumentId( filename ); | 1598 | mDialogManager->setDocumentId( filename ); |
1599 | mTodoList->setDocumentId( filename ); | 1599 | mTodoList->setDocumentId( filename ); |
1600 | } | 1600 | } |
1601 | globalFlagBlockAgenda = 2; | 1601 | globalFlagBlockAgenda = 2; |
1602 | // if ( getLastSyncEvent() ) | 1602 | // if ( getLastSyncEvent() ) |
1603 | // getLastSyncEvent()->setReadOnly( true ); | 1603 | // getLastSyncEvent()->setReadOnly( true ); |
1604 | mCalendar->reInitAlarmSettings(); | 1604 | mCalendar->reInitAlarmSettings(); |
1605 | setSyncEventsReadOnly(); | 1605 | setSyncEventsReadOnly(); |
1606 | updateUnmanagedViews(); | 1606 | updateUnmanagedViews(); |
1607 | updateView(); | 1607 | updateView(); |
1608 | if ( filename != MainWindow::defaultFileName() ) { | 1608 | if ( filename != MainWindow::defaultFileName() ) { |
1609 | saveCalendar( MainWindow::defaultFileName() ); | 1609 | saveCalendar( MainWindow::defaultFileName() ); |
1610 | } else { | 1610 | } else { |
1611 | QFileInfo finf ( MainWindow::defaultFileName()); | 1611 | QFileInfo finf ( MainWindow::defaultFileName()); |
1612 | if ( finf.exists() ) { | 1612 | if ( finf.exists() ) { |
1613 | setLoadedFileVersion( finf.lastModified () ); | 1613 | setLoadedFileVersion( finf.lastModified () ); |
1614 | } | 1614 | } |
1615 | } | 1615 | } |
1616 | return true; | 1616 | return true; |
1617 | } else { | 1617 | } else { |
1618 | // while failing to load, the calendar object could | 1618 | // while failing to load, the calendar object could |
1619 | // have become partially populated. Clear it out. | 1619 | // have become partially populated. Clear it out. |
1620 | if ( !merge ) { | 1620 | if ( !merge ) { |
1621 | mCalendar->close(); | 1621 | mCalendar->close(); |
1622 | mViewManager->setDocumentId( filename ); | 1622 | mViewManager->setDocumentId( filename ); |
1623 | mDialogManager->setDocumentId( filename ); | 1623 | mDialogManager->setDocumentId( filename ); |
1624 | mTodoList->setDocumentId( filename ); | 1624 | mTodoList->setDocumentId( filename ); |
1625 | } | 1625 | } |
1626 | 1626 | ||
1627 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1627 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1628 | 1628 | ||
1629 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1629 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1630 | globalFlagBlockAgenda = 2; | 1630 | globalFlagBlockAgenda = 2; |
1631 | mCalendar->reInitAlarmSettings(); | 1631 | mCalendar->reInitAlarmSettings(); |
1632 | setSyncEventsReadOnly(); | 1632 | setSyncEventsReadOnly(); |
1633 | updateUnmanagedViews(); | 1633 | updateUnmanagedViews(); |
1634 | updateView(); | 1634 | updateView(); |
1635 | } | 1635 | } |
1636 | return false; | 1636 | return false; |
1637 | } | 1637 | } |
1638 | void CalendarView::showOpenError() | 1638 | void CalendarView::showOpenError() |
1639 | { | 1639 | { |
1640 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1640 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1641 | } | 1641 | } |
1642 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1642 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1643 | { | 1643 | { |
1644 | loadedFileVersion = dt; | 1644 | loadedFileVersion = dt; |
1645 | } | 1645 | } |
1646 | bool CalendarView::checkFileChanged(QString fn) | 1646 | bool CalendarView::checkFileChanged(QString fn) |
1647 | { | 1647 | { |
1648 | QFileInfo finf ( fn ); | 1648 | QFileInfo finf ( fn ); |
1649 | if ( !finf.exists() ) | 1649 | if ( !finf.exists() ) |
1650 | return true; | 1650 | return true; |
1651 | QDateTime dt = finf.lastModified (); | 1651 | QDateTime dt = finf.lastModified (); |
1652 | if ( dt <= loadedFileVersion ) | 1652 | if ( dt <= loadedFileVersion ) |
1653 | return false; | 1653 | return false; |
1654 | return true; | 1654 | return true; |
1655 | 1655 | ||
1656 | } | 1656 | } |
1657 | void CalendarView::watchSavedFile() | 1657 | void CalendarView::watchSavedFile() |
1658 | { | 1658 | { |
1659 | QFileInfo finf ( MainWindow::defaultFileName()); | 1659 | QFileInfo finf ( MainWindow::defaultFileName()); |
1660 | if ( !finf.exists() ) | 1660 | if ( !finf.exists() ) |
1661 | return; | 1661 | return; |
1662 | QDateTime dt = finf.lastModified (); | 1662 | QDateTime dt = finf.lastModified (); |
1663 | if ( dt < loadedFileVersion ) { | 1663 | if ( dt < loadedFileVersion ) { |
1664 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1664 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1665 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1665 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1666 | return; | 1666 | return; |
1667 | } | 1667 | } |
1668 | loadedFileVersion = dt; | 1668 | loadedFileVersion = dt; |
1669 | } | 1669 | } |
1670 | 1670 | ||
1671 | bool CalendarView::checkFileVersion(QString fn) | 1671 | bool CalendarView::checkFileVersion(QString fn) |
1672 | { | 1672 | { |
1673 | QFileInfo finf ( fn ); | 1673 | QFileInfo finf ( fn ); |
1674 | if ( !finf.exists() ) | 1674 | if ( !finf.exists() ) |
1675 | return true; | 1675 | return true; |
1676 | QDateTime dt = finf.lastModified (); | 1676 | QDateTime dt = finf.lastModified (); |
1677 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1677 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1678 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1678 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1679 | if ( dt <= loadedFileVersion ) | 1679 | if ( dt <= loadedFileVersion ) |
1680 | return true; | 1680 | return true; |
1681 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 1681 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
1682 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1682 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1683 | i18n("Sync+save")); | 1683 | i18n("Sync+save")); |
1684 | 1684 | ||
1685 | if ( km == KMessageBox::Cancel ) | 1685 | if ( km == KMessageBox::Cancel ) |
1686 | return false; | 1686 | return false; |
1687 | if ( km == KMessageBox::Yes ) | 1687 | if ( km == KMessageBox::Yes ) |
1688 | return true; | 1688 | return true; |
1689 | 1689 | ||
1690 | setSyncDevice("deleteaftersync" ); | 1690 | setSyncDevice("deleteaftersync" ); |
1691 | mSyncManager->mAskForPreferences = true; | 1691 | mSyncManager->mAskForPreferences = true; |
1692 | mSyncManager->mSyncAlgoPrefs = 3; | 1692 | mSyncManager->mSyncAlgoPrefs = 3; |
1693 | mSyncManager->mWriteBackFile = false; | 1693 | mSyncManager->mWriteBackFile = false; |
1694 | mSyncManager->mWriteBackExistingOnly = false; | 1694 | mSyncManager->mWriteBackExistingOnly = false; |
1695 | mSyncManager->mShowSyncSummary = false; | 1695 | mSyncManager->mShowSyncSummary = false; |
1696 | syncCalendar( fn, 3 ); | 1696 | syncCalendar( fn, 3 ); |
1697 | Event * e = getLastSyncEvent(); | 1697 | Event * e = getLastSyncEvent(); |
1698 | mCalendar->deleteEvent ( e ); | 1698 | mCalendar->deleteEvent ( e ); |
1699 | updateView(); | 1699 | updateView(); |
1700 | return true; | 1700 | return true; |
1701 | } | 1701 | } |
1702 | 1702 | ||
1703 | bool CalendarView::saveCalendar( QString filename ) | 1703 | bool CalendarView::saveCalendar( QString filename ) |
1704 | { | 1704 | { |
1705 | 1705 | ||
1706 | // Store back all unsaved data into calendar object | 1706 | // Store back all unsaved data into calendar object |
1707 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1707 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1708 | if ( mViewManager->currentView() ) | 1708 | if ( mViewManager->currentView() ) |
1709 | mViewManager->currentView()->flushView(); | 1709 | mViewManager->currentView()->flushView(); |
1710 | 1710 | ||
1711 | 1711 | ||
1712 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1712 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1713 | mStorage->setSaveFormat( new ICalFormat() ); | 1713 | mStorage->setSaveFormat( new ICalFormat() ); |
1714 | mStorage->setFileName( filename ); | 1714 | mStorage->setFileName( filename ); |
1715 | bool success; | 1715 | bool success; |
1716 | success = mStorage->save(); | 1716 | success = mStorage->save(); |
1717 | if ( !success ) { | 1717 | if ( !success ) { |
1718 | return false; | 1718 | return false; |
1719 | } | 1719 | } |
1720 | if ( filename == MainWindow::defaultFileName() ) { | 1720 | if ( filename == MainWindow::defaultFileName() ) { |
1721 | setLoadedFileVersion( lfv ); | 1721 | setLoadedFileVersion( lfv ); |
1722 | watchSavedFile(); | 1722 | watchSavedFile(); |
1723 | } | 1723 | } |
1724 | return true; | 1724 | return true; |
1725 | } | 1725 | } |
1726 | 1726 | ||
1727 | void CalendarView::closeCalendar() | 1727 | void CalendarView::closeCalendar() |
1728 | { | 1728 | { |
1729 | 1729 | ||
1730 | // child windows no longer valid | 1730 | // child windows no longer valid |
1731 | emit closingDown(); | 1731 | emit closingDown(); |
1732 | 1732 | ||
1733 | mCalendar->close(); | 1733 | mCalendar->close(); |
1734 | setModified(false); | 1734 | setModified(false); |
1735 | updateView(); | 1735 | updateView(); |
1736 | } | 1736 | } |
1737 | 1737 | ||
1738 | void CalendarView::archiveCalendar() | 1738 | void CalendarView::archiveCalendar() |
1739 | { | 1739 | { |
1740 | mDialogManager->showArchiveDialog(); | 1740 | mDialogManager->showArchiveDialog(); |
1741 | } | 1741 | } |
1742 | 1742 | ||
1743 | 1743 | ||
1744 | void CalendarView::readSettings() | 1744 | void CalendarView::readSettings() |
1745 | { | 1745 | { |
1746 | 1746 | ||
1747 | 1747 | ||
1748 | // mViewManager->showAgendaView(); | 1748 | // mViewManager->showAgendaView(); |
1749 | QString str; | 1749 | QString str; |
1750 | //qDebug("CalendarView::readSettings() "); | 1750 | //qDebug("CalendarView::readSettings() "); |
1751 | // read settings from the KConfig, supplying reasonable | 1751 | // read settings from the KConfig, supplying reasonable |
1752 | // defaults where none are to be found | 1752 | // defaults where none are to be found |
1753 | KConfig *config = KOGlobals::config(); | 1753 | KConfig *config = KOGlobals::config(); |
1754 | #ifndef KORG_NOSPLITTER | 1754 | #ifndef KORG_NOSPLITTER |
1755 | config->setGroup("KOrganizer Geometry"); | 1755 | config->setGroup("KOrganizer Geometry"); |
1756 | 1756 | ||
1757 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1757 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1758 | if (sizes.count() != 2) { | 1758 | if (sizes.count() != 2) { |
1759 | sizes << mDateNavigator->minimumSizeHint().width(); | 1759 | sizes << mDateNavigator->minimumSizeHint().width(); |
1760 | sizes << 300; | 1760 | sizes << 300; |
1761 | } | 1761 | } |
1762 | mPanner->setSizes(sizes); | 1762 | mPanner->setSizes(sizes); |
1763 | 1763 | ||
1764 | sizes = config->readIntListEntry("Separator2"); | 1764 | sizes = config->readIntListEntry("Separator2"); |
1765 | if ( ( mResourceView && sizes.count() == 4 ) || | 1765 | if ( ( mResourceView && sizes.count() == 4 ) || |
1766 | ( !mResourceView && sizes.count() == 3 ) ) { | 1766 | ( !mResourceView && sizes.count() == 3 ) ) { |
1767 | mLeftSplitter->setSizes(sizes); | 1767 | mLeftSplitter->setSizes(sizes); |
1768 | } | 1768 | } |
1769 | #endif | 1769 | #endif |
1770 | globalFlagBlockAgenda = 1; | 1770 | globalFlagBlockAgenda = 1; |
1771 | mViewManager->showAgendaView(); | 1771 | mViewManager->showAgendaView(); |
1772 | //mViewManager->readSettings( config ); | 1772 | //mViewManager->readSettings( config ); |
1773 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1773 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1774 | readFilterSettings(config); | 1774 | readFilterSettings(config); |
1775 | config->setGroup( "Views" ); | 1775 | config->setGroup( "Views" ); |
1776 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1776 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1777 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1777 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1778 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1778 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1779 | else mNavigator->selectDates( dateCount ); | 1779 | else mNavigator->selectDates( dateCount ); |
1780 | // mViewManager->readSettings( config ); | 1780 | // mViewManager->readSettings( config ); |
1781 | updateConfig(); | 1781 | updateConfig(); |
1782 | globalFlagBlockAgenda = 2; | 1782 | globalFlagBlockAgenda = 2; |
1783 | mViewManager->readSettings( config ); | 1783 | mViewManager->readSettings( config ); |
1784 | #ifdef DESKTOP_VERSION | 1784 | #ifdef DESKTOP_VERSION |
1785 | config->setGroup("WidgetLayout"); | 1785 | config->setGroup("WidgetLayout"); |
1786 | QStringList list; | 1786 | QStringList list; |
1787 | list = config->readListEntry("MainLayout"); | 1787 | list = config->readListEntry("MainLayout"); |
1788 | int x,y,w,h; | 1788 | int x,y,w,h; |
1789 | if ( ! list.isEmpty() ) { | 1789 | if ( ! list.isEmpty() ) { |
1790 | x = list[0].toInt(); | 1790 | x = list[0].toInt(); |
1791 | y = list[1].toInt(); | 1791 | y = list[1].toInt(); |
1792 | w = list[2].toInt(); | 1792 | w = list[2].toInt(); |
1793 | h = list[3].toInt(); | 1793 | h = list[3].toInt(); |
1794 | topLevelWidget()->setGeometry(x,y,w,h); | 1794 | topLevelWidget()->setGeometry(x,y,w,h); |
1795 | 1795 | ||
1796 | } else { | 1796 | } else { |
1797 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1797 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1798 | } | 1798 | } |
1799 | list = config->readListEntry("EditEventLayout"); | 1799 | list = config->readListEntry("EditEventLayout"); |
1800 | if ( ! list.isEmpty() ) { | 1800 | if ( ! list.isEmpty() ) { |
1801 | x = list[0].toInt(); | 1801 | x = list[0].toInt(); |
1802 | y = list[1].toInt(); | 1802 | y = list[1].toInt(); |
1803 | w = list[2].toInt(); | 1803 | w = list[2].toInt(); |
1804 | h = list[3].toInt(); | 1804 | h = list[3].toInt(); |
1805 | mEventEditor->setGeometry(x,y,w,h); | 1805 | mEventEditor->setGeometry(x,y,w,h); |
1806 | 1806 | ||
1807 | } | 1807 | } |
1808 | list = config->readListEntry("EditTodoLayout"); | 1808 | list = config->readListEntry("EditTodoLayout"); |
1809 | if ( ! list.isEmpty() ) { | 1809 | if ( ! list.isEmpty() ) { |
1810 | x = list[0].toInt(); | 1810 | x = list[0].toInt(); |
1811 | y = list[1].toInt(); | 1811 | y = list[1].toInt(); |
1812 | w = list[2].toInt(); | 1812 | w = list[2].toInt(); |
1813 | h = list[3].toInt(); | 1813 | h = list[3].toInt(); |
1814 | mTodoEditor->setGeometry(x,y,w,h); | 1814 | mTodoEditor->setGeometry(x,y,w,h); |
1815 | 1815 | ||
1816 | } | 1816 | } |
1817 | list = config->readListEntry("ViewerLayout"); | 1817 | list = config->readListEntry("ViewerLayout"); |
1818 | if ( ! list.isEmpty() ) { | 1818 | if ( ! list.isEmpty() ) { |
1819 | x = list[0].toInt(); | 1819 | x = list[0].toInt(); |
1820 | y = list[1].toInt(); | 1820 | y = list[1].toInt(); |
1821 | w = list[2].toInt(); | 1821 | w = list[2].toInt(); |
1822 | h = list[3].toInt(); | 1822 | h = list[3].toInt(); |
1823 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1823 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1824 | } | 1824 | } |
1825 | #endif | 1825 | #endif |
1826 | 1826 | ||
1827 | } | 1827 | } |
1828 | 1828 | ||
1829 | 1829 | ||
1830 | void CalendarView::writeSettings() | 1830 | void CalendarView::writeSettings() |
1831 | { | 1831 | { |
1832 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1832 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1833 | 1833 | ||
1834 | KConfig *config = KOGlobals::config(); | 1834 | KConfig *config = KOGlobals::config(); |
1835 | 1835 | ||
1836 | #ifndef KORG_NOSPLITTER | 1836 | #ifndef KORG_NOSPLITTER |
1837 | config->setGroup("KOrganizer Geometry"); | 1837 | config->setGroup("KOrganizer Geometry"); |
1838 | 1838 | ||
1839 | QValueList<int> list = mPanner->sizes(); | 1839 | QValueList<int> list = mPanner->sizes(); |
1840 | config->writeEntry("Separator1",list); | 1840 | config->writeEntry("Separator1",list); |
1841 | 1841 | ||
1842 | list = mLeftSplitter->sizes(); | 1842 | list = mLeftSplitter->sizes(); |
1843 | config->writeEntry("Separator2",list); | 1843 | config->writeEntry("Separator2",list); |
1844 | #endif | 1844 | #endif |
1845 | 1845 | ||
1846 | mViewManager->writeSettings( config ); | 1846 | mViewManager->writeSettings( config ); |
1847 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1847 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1848 | mDialogManager->writeSettings( config ); | 1848 | mDialogManager->writeSettings( config ); |
1849 | //KOPrefs::instance()->usrWriteConfig(); | 1849 | //KOPrefs::instance()->usrWriteConfig(); |
1850 | KOPrefs::instance()->writeConfig(); | 1850 | KOPrefs::instance()->writeConfig(); |
1851 | 1851 | ||
1852 | writeFilterSettings(config); | 1852 | writeFilterSettings(config); |
1853 | 1853 | ||
1854 | config->setGroup( "Views" ); | 1854 | config->setGroup( "Views" ); |
1855 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1855 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1856 | 1856 | ||
1857 | #ifdef DESKTOP_VERSION | 1857 | #ifdef DESKTOP_VERSION |
1858 | config->setGroup("WidgetLayout"); | 1858 | config->setGroup("WidgetLayout"); |
1859 | QStringList list ;//= config->readListEntry("MainLayout"); | 1859 | QStringList list ;//= config->readListEntry("MainLayout"); |
1860 | int x,y,w,h; | 1860 | int x,y,w,h; |
1861 | QWidget* wid; | 1861 | QWidget* wid; |
1862 | wid = topLevelWidget(); | 1862 | wid = topLevelWidget(); |
1863 | x = wid->geometry().x(); | 1863 | x = wid->geometry().x(); |
1864 | y = wid->geometry().y(); | 1864 | y = wid->geometry().y(); |
1865 | w = wid->width(); | 1865 | w = wid->width(); |
1866 | h = wid->height(); | 1866 | h = wid->height(); |
1867 | list.clear(); | 1867 | list.clear(); |
1868 | list << QString::number( x ); | 1868 | list << QString::number( x ); |
1869 | list << QString::number( y ); | 1869 | list << QString::number( y ); |
1870 | list << QString::number( w ); | 1870 | list << QString::number( w ); |
1871 | list << QString::number( h ); | 1871 | list << QString::number( h ); |
1872 | config->writeEntry("MainLayout",list ); | 1872 | config->writeEntry("MainLayout",list ); |
1873 | 1873 | ||
1874 | wid = mEventEditor; | 1874 | wid = mEventEditor; |
1875 | x = wid->geometry().x(); | 1875 | x = wid->geometry().x(); |
1876 | y = wid->geometry().y(); | 1876 | y = wid->geometry().y(); |
1877 | w = wid->width(); | 1877 | w = wid->width(); |
1878 | h = wid->height(); | 1878 | h = wid->height(); |
1879 | list.clear(); | 1879 | list.clear(); |
1880 | list << QString::number( x ); | 1880 | list << QString::number( x ); |
1881 | list << QString::number( y ); | 1881 | list << QString::number( y ); |
1882 | list << QString::number( w ); | 1882 | list << QString::number( w ); |
1883 | list << QString::number( h ); | 1883 | list << QString::number( h ); |
1884 | config->writeEntry("EditEventLayout",list ); | 1884 | config->writeEntry("EditEventLayout",list ); |
1885 | 1885 | ||
1886 | wid = mTodoEditor; | 1886 | wid = mTodoEditor; |
1887 | x = wid->geometry().x(); | 1887 | x = wid->geometry().x(); |
1888 | y = wid->geometry().y(); | 1888 | y = wid->geometry().y(); |
1889 | w = wid->width(); | 1889 | w = wid->width(); |
1890 | h = wid->height(); | 1890 | h = wid->height(); |
1891 | list.clear(); | 1891 | list.clear(); |
1892 | list << QString::number( x ); | 1892 | list << QString::number( x ); |
1893 | list << QString::number( y ); | 1893 | list << QString::number( y ); |
1894 | list << QString::number( w ); | 1894 | list << QString::number( w ); |
1895 | list << QString::number( h ); | 1895 | list << QString::number( h ); |
1896 | config->writeEntry("EditTodoLayout",list ); | 1896 | config->writeEntry("EditTodoLayout",list ); |
1897 | wid = getEventViewerDialog(); | 1897 | wid = getEventViewerDialog(); |
1898 | x = wid->geometry().x(); | 1898 | x = wid->geometry().x(); |
1899 | y = wid->geometry().y(); | 1899 | y = wid->geometry().y(); |
1900 | w = wid->width(); | 1900 | w = wid->width(); |
1901 | h = wid->height(); | 1901 | h = wid->height(); |
1902 | list.clear(); | 1902 | list.clear(); |
1903 | list << QString::number( x ); | 1903 | list << QString::number( x ); |
1904 | list << QString::number( y ); | 1904 | list << QString::number( y ); |
1905 | list << QString::number( w ); | 1905 | list << QString::number( w ); |
1906 | list << QString::number( h ); | 1906 | list << QString::number( h ); |
1907 | config->writeEntry("ViewerLayout",list ); | 1907 | config->writeEntry("ViewerLayout",list ); |
1908 | wid = mDialogManager->getSearchDialog(); | 1908 | wid = mDialogManager->getSearchDialog(); |
1909 | if ( wid ) { | 1909 | if ( wid ) { |
1910 | x = wid->geometry().x(); | 1910 | x = wid->geometry().x(); |
1911 | y = wid->geometry().y(); | 1911 | y = wid->geometry().y(); |
1912 | w = wid->width(); | 1912 | w = wid->width(); |
1913 | h = wid->height(); | 1913 | h = wid->height(); |
1914 | list.clear(); | 1914 | list.clear(); |
1915 | list << QString::number( x ); | 1915 | list << QString::number( x ); |
1916 | list << QString::number( y ); | 1916 | list << QString::number( y ); |
1917 | list << QString::number( w ); | 1917 | list << QString::number( w ); |
1918 | list << QString::number( h ); | 1918 | list << QString::number( h ); |
1919 | config->writeEntry("SearchLayout",list ); | 1919 | config->writeEntry("SearchLayout",list ); |
1920 | } | 1920 | } |
1921 | #endif | 1921 | #endif |
1922 | 1922 | ||
1923 | 1923 | ||
1924 | config->sync(); | 1924 | config->sync(); |
1925 | } | 1925 | } |
1926 | 1926 | ||
1927 | void CalendarView::readFilterSettings(KConfig *config) | 1927 | void CalendarView::readFilterSettings(KConfig *config) |
1928 | { | 1928 | { |
1929 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1929 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1930 | 1930 | ||
1931 | mFilters.clear(); | 1931 | mFilters.clear(); |
1932 | 1932 | ||
1933 | config->setGroup("General"); | 1933 | config->setGroup("General"); |
1934 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1934 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1935 | 1935 | ||
1936 | QStringList::ConstIterator it = filterList.begin(); | 1936 | QStringList::ConstIterator it = filterList.begin(); |
1937 | QStringList::ConstIterator end = filterList.end(); | 1937 | QStringList::ConstIterator end = filterList.end(); |
1938 | while(it != end) { | 1938 | while(it != end) { |
1939 | // kdDebug() << " filter: " << (*it) << endl; | 1939 | // kdDebug() << " filter: " << (*it) << endl; |
1940 | 1940 | ||
1941 | CalFilter *filter; | 1941 | CalFilter *filter; |
1942 | filter = new CalFilter(*it); | 1942 | filter = new CalFilter(*it); |
1943 | config->setGroup("Filter_" + (*it)); | 1943 | config->setGroup("Filter_" + (*it)); |
1944 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1944 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1945 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1945 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1946 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1946 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1947 | mFilters.append(filter); | 1947 | mFilters.append(filter); |
1948 | 1948 | ||
1949 | ++it; | 1949 | ++it; |
1950 | } | 1950 | } |
1951 | 1951 | ||
1952 | if (mFilters.count() == 0) { | 1952 | if (mFilters.count() == 0) { |
1953 | CalFilter *filter = new CalFilter(i18n("Default")); | 1953 | CalFilter *filter = new CalFilter(i18n("Default")); |
1954 | mFilters.append(filter); | 1954 | mFilters.append(filter); |
1955 | } | 1955 | } |
1956 | mFilterView->updateFilters(); | 1956 | mFilterView->updateFilters(); |
1957 | config->setGroup("FilterView"); | 1957 | config->setGroup("FilterView"); |
1958 | 1958 | ||
1959 | mFilterView->blockSignals(true); | 1959 | mFilterView->blockSignals(true); |
1960 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 1960 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
1961 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 1961 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
1962 | mFilterView->blockSignals(false); | 1962 | mFilterView->blockSignals(false); |
1963 | // We do it manually to avoid it being done twice by the above calls | 1963 | // We do it manually to avoid it being done twice by the above calls |
1964 | updateFilter(); | 1964 | updateFilter(); |
1965 | } | 1965 | } |
1966 | 1966 | ||
1967 | void CalendarView::writeFilterSettings(KConfig *config) | 1967 | void CalendarView::writeFilterSettings(KConfig *config) |
1968 | { | 1968 | { |
1969 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 1969 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
1970 | 1970 | ||
1971 | QStringList filterList; | 1971 | QStringList filterList; |
1972 | 1972 | ||
1973 | CalFilter *filter = mFilters.first(); | 1973 | CalFilter *filter = mFilters.first(); |
1974 | while(filter) { | 1974 | while(filter) { |
1975 | // kdDebug() << " fn: " << filter->name() << endl; | 1975 | // kdDebug() << " fn: " << filter->name() << endl; |
1976 | filterList << filter->name(); | 1976 | filterList << filter->name(); |
1977 | config->setGroup("Filter_" + filter->name()); | 1977 | config->setGroup("Filter_" + filter->name()); |
1978 | config->writeEntry("Criteria",filter->criteria()); | 1978 | config->writeEntry("Criteria",filter->criteria()); |
1979 | config->writeEntry("CategoryList",filter->categoryList()); | 1979 | config->writeEntry("CategoryList",filter->categoryList()); |
1980 | filter = mFilters.next(); | 1980 | filter = mFilters.next(); |
1981 | } | 1981 | } |
1982 | config->setGroup("General"); | 1982 | config->setGroup("General"); |
1983 | config->writeEntry("CalendarFilters",filterList); | 1983 | config->writeEntry("CalendarFilters",filterList); |
1984 | 1984 | ||
1985 | config->setGroup("FilterView"); | 1985 | config->setGroup("FilterView"); |
1986 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 1986 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
1987 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 1987 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
1988 | } | 1988 | } |
1989 | 1989 | ||
1990 | 1990 | ||
1991 | void CalendarView::goToday() | 1991 | void CalendarView::goToday() |
1992 | { | 1992 | { |
1993 | mNavigator->selectToday(); | 1993 | mNavigator->selectToday(); |
1994 | } | 1994 | } |
1995 | 1995 | ||
1996 | void CalendarView::goNext() | 1996 | void CalendarView::goNext() |
1997 | { | 1997 | { |
1998 | mNavigator->selectNext(); | 1998 | mNavigator->selectNext(); |
1999 | } | 1999 | } |
2000 | 2000 | ||
2001 | void CalendarView::goPrevious() | 2001 | void CalendarView::goPrevious() |
2002 | { | 2002 | { |
2003 | mNavigator->selectPrevious(); | 2003 | mNavigator->selectPrevious(); |
2004 | } | 2004 | } |
2005 | void CalendarView::goNextMonth() | 2005 | void CalendarView::goNextMonth() |
2006 | { | 2006 | { |
2007 | mNavigator->selectNextMonth(); | 2007 | mNavigator->selectNextMonth(); |
2008 | } | 2008 | } |
2009 | 2009 | ||
2010 | void CalendarView::goPreviousMonth() | 2010 | void CalendarView::goPreviousMonth() |
2011 | { | 2011 | { |
2012 | mNavigator->selectPreviousMonth(); | 2012 | mNavigator->selectPreviousMonth(); |
2013 | } | 2013 | } |
2014 | void CalendarView::writeLocale() | 2014 | void CalendarView::writeLocale() |
2015 | { | 2015 | { |
2016 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 2016 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
2017 | #if 0 | 2017 | #if 0 |
2018 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 2018 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
2019 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 2019 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
2020 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 2020 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
2021 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 2021 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
2022 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 2022 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
2023 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 2023 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
2024 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 2024 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2025 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2025 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2026 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2026 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2027 | KOPrefs::instance()->mDaylightsavingStart, | 2027 | KOPrefs::instance()->mDaylightsavingStart, |
2028 | KOPrefs::instance()->mDaylightsavingEnd ); | 2028 | KOPrefs::instance()->mDaylightsavingEnd ); |
2029 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); | 2029 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); |
2030 | #endif | 2030 | #endif |
2031 | } | 2031 | } |
2032 | void CalendarView::updateConfig() | 2032 | void CalendarView::updateConfig() |
2033 | { | 2033 | { |
2034 | writeLocale(); | 2034 | writeLocale(); |
2035 | if ( KOPrefs::instance()->mUseAppColors ) | 2035 | if ( KOPrefs::instance()->mUseAppColors ) |
2036 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2036 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2037 | emit configChanged(); | 2037 | emit configChanged(); |
2038 | mTodoList->updateConfig(); | 2038 | mTodoList->updateConfig(); |
2039 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2039 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2040 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2040 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2041 | // To make the "fill window" configurations work | 2041 | // To make the "fill window" configurations work |
2042 | //mViewManager->raiseCurrentView(); | 2042 | //mViewManager->raiseCurrentView(); |
2043 | } | 2043 | } |
2044 | 2044 | ||
2045 | 2045 | ||
2046 | void CalendarView::eventChanged(Event *event) | 2046 | void CalendarView::eventChanged(Event *event) |
2047 | { | 2047 | { |
2048 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2048 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2049 | //updateUnmanagedViews(); | 2049 | //updateUnmanagedViews(); |
2050 | } | 2050 | } |
2051 | 2051 | ||
2052 | void CalendarView::eventAdded(Event *event) | 2052 | void CalendarView::eventAdded(Event *event) |
2053 | { | 2053 | { |
2054 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2054 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2055 | } | 2055 | } |
2056 | 2056 | ||
2057 | void CalendarView::eventToBeDeleted(Event *) | 2057 | void CalendarView::eventToBeDeleted(Event *) |
2058 | { | 2058 | { |
2059 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2059 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2060 | } | 2060 | } |
2061 | 2061 | ||
2062 | void CalendarView::eventDeleted() | 2062 | void CalendarView::eventDeleted() |
2063 | { | 2063 | { |
2064 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2064 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2065 | } | 2065 | } |
2066 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2066 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2067 | { | 2067 | { |
2068 | changeIncidenceDisplay((Incidence *)which, action); | 2068 | changeIncidenceDisplay((Incidence *)which, action); |
2069 | mDateNavigator->updateView(); //LR | 2069 | mDateNavigator->updateView(); //LR |
2070 | //mDialogManager->updateSearchDialog(); | 2070 | //mDialogManager->updateSearchDialog(); |
2071 | 2071 | ||
2072 | if (which) { | 2072 | if (which) { |
2073 | mViewManager->updateWNview(); | 2073 | mViewManager->updateWNview(); |
2074 | //mTodoList->updateView(); | 2074 | //mTodoList->updateView(); |
2075 | } | 2075 | } |
2076 | 2076 | ||
2077 | } | 2077 | } |
2078 | 2078 | ||
2079 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2079 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2080 | { | 2080 | { |
2081 | updateUnmanagedViews(); | 2081 | updateUnmanagedViews(); |
2082 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2082 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2083 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2083 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2084 | mCalendar->checkAlarmForIncidence( 0, true ); | 2084 | mCalendar->checkAlarmForIncidence( 0, true ); |
2085 | if ( mEventViewerDialog ) | 2085 | if ( mEventViewerDialog ) |
2086 | mEventViewerDialog->hide(); | 2086 | mEventViewerDialog->hide(); |
2087 | } | 2087 | } |
2088 | else | 2088 | else |
2089 | mCalendar->checkAlarmForIncidence( which , false ); | 2089 | mCalendar->checkAlarmForIncidence( which , false ); |
2090 | } | 2090 | } |
2091 | 2091 | ||
2092 | // most of the changeEventDisplays() right now just call the view's | 2092 | // most of the changeEventDisplays() right now just call the view's |
2093 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2093 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2094 | void CalendarView::changeEventDisplay(Event *which, int action) | 2094 | void CalendarView::changeEventDisplay(Event *which, int action) |
2095 | { | 2095 | { |
2096 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2096 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2097 | changeIncidenceDisplay((Incidence *)which, action); | 2097 | changeIncidenceDisplay((Incidence *)which, action); |
2098 | mDateNavigator->updateView(); | 2098 | mDateNavigator->updateView(); |
2099 | //mDialogManager->updateSearchDialog(); | 2099 | //mDialogManager->updateSearchDialog(); |
2100 | 2100 | ||
2101 | if (which) { | 2101 | if (which) { |
2102 | // If there is an event view visible update the display | 2102 | // If there is an event view visible update the display |
2103 | mViewManager->currentView()->changeEventDisplay(which,action); | 2103 | mViewManager->currentView()->changeEventDisplay(which,action); |
2104 | // TODO: check, if update needed | 2104 | // TODO: check, if update needed |
2105 | // if (which->getTodoStatus()) { | 2105 | // if (which->getTodoStatus()) { |
2106 | mTodoList->updateView(); | 2106 | mTodoList->updateView(); |
2107 | // } | 2107 | // } |
2108 | } else { | 2108 | } else { |
2109 | mViewManager->currentView()->updateView(); | 2109 | mViewManager->currentView()->updateView(); |
2110 | } | 2110 | } |
2111 | } | 2111 | } |
2112 | 2112 | ||
2113 | 2113 | ||
2114 | void CalendarView::updateTodoViews() | 2114 | void CalendarView::updateTodoViews() |
2115 | { | 2115 | { |
2116 | 2116 | ||
2117 | mTodoList->updateView(); | 2117 | mTodoList->updateView(); |
2118 | mViewManager->currentView()->updateView(); | 2118 | mViewManager->currentView()->updateView(); |
2119 | 2119 | ||
2120 | } | 2120 | } |
2121 | 2121 | ||
2122 | 2122 | ||
2123 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2123 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2124 | { | 2124 | { |
2125 | mTodoList->updateView(); | 2125 | mTodoList->updateView(); |
2126 | mViewManager->updateView(start, end); | 2126 | mViewManager->updateView(start, end); |
2127 | //mDateNavigator->updateView(); | 2127 | //mDateNavigator->updateView(); |
2128 | } | 2128 | } |
2129 | 2129 | ||
2130 | void CalendarView::updateView() | 2130 | void CalendarView::updateView() |
2131 | { | 2131 | { |
2132 | DateList tmpList = mNavigator->selectedDates(); | 2132 | DateList tmpList = mNavigator->selectedDates(); |
2133 | 2133 | ||
2134 | // We assume that the navigator only selects consecutive days. | 2134 | // We assume that the navigator only selects consecutive days. |
2135 | updateView( tmpList.first(), tmpList.last() ); | 2135 | updateView( tmpList.first(), tmpList.last() ); |
2136 | } | 2136 | } |
2137 | 2137 | ||
2138 | void CalendarView::updateUnmanagedViews() | 2138 | void CalendarView::updateUnmanagedViews() |
2139 | { | 2139 | { |
2140 | mDateNavigator->updateDayMatrix(); | 2140 | mDateNavigator->updateDayMatrix(); |
2141 | } | 2141 | } |
2142 | 2142 | ||
2143 | int CalendarView::msgItemDelete() | 2143 | int CalendarView::msgItemDelete() |
2144 | { | 2144 | { |
2145 | return KMessageBox::warningContinueCancel(this, | 2145 | return KMessageBox::warningContinueCancel(this, |
2146 | i18n("This item will be\npermanently deleted."), | 2146 | i18n("This item will be\npermanently deleted."), |
2147 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2147 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2148 | } | 2148 | } |
2149 | 2149 | ||
2150 | 2150 | ||
2151 | void CalendarView::edit_cut() | 2151 | void CalendarView::edit_cut() |
2152 | { | 2152 | { |
2153 | Event *anEvent=0; | 2153 | Event *anEvent=0; |
2154 | 2154 | ||
2155 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2155 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2156 | 2156 | ||
2157 | if (mViewManager->currentView()->isEventView()) { | 2157 | if (mViewManager->currentView()->isEventView()) { |
2158 | if ( incidence && incidence->type() == "Event" ) { | 2158 | if ( incidence && incidence->type() == "Event" ) { |
2159 | anEvent = static_cast<Event *>(incidence); | 2159 | anEvent = static_cast<Event *>(incidence); |
2160 | } | 2160 | } |
2161 | } | 2161 | } |
2162 | 2162 | ||
2163 | if (!anEvent) { | 2163 | if (!anEvent) { |
2164 | KNotifyClient::beep(); | 2164 | KNotifyClient::beep(); |
2165 | return; | 2165 | return; |
2166 | } | 2166 | } |
2167 | DndFactory factory( mCalendar ); | 2167 | DndFactory factory( mCalendar ); |
2168 | factory.cutEvent(anEvent); | 2168 | factory.cutEvent(anEvent); |
2169 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2169 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2170 | } | 2170 | } |
2171 | 2171 | ||
2172 | void CalendarView::edit_copy() | 2172 | void CalendarView::edit_copy() |
2173 | { | 2173 | { |
2174 | Event *anEvent=0; | 2174 | Event *anEvent=0; |
2175 | 2175 | ||
2176 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2176 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2177 | 2177 | ||
2178 | if (mViewManager->currentView()->isEventView()) { | 2178 | if (mViewManager->currentView()->isEventView()) { |
2179 | if ( incidence && incidence->type() == "Event" ) { | 2179 | if ( incidence && incidence->type() == "Event" ) { |
2180 | anEvent = static_cast<Event *>(incidence); | 2180 | anEvent = static_cast<Event *>(incidence); |
2181 | } | 2181 | } |
2182 | } | 2182 | } |
2183 | 2183 | ||
2184 | if (!anEvent) { | 2184 | if (!anEvent) { |
2185 | KNotifyClient::beep(); | 2185 | KNotifyClient::beep(); |
2186 | return; | 2186 | return; |
2187 | } | 2187 | } |
2188 | DndFactory factory( mCalendar ); | 2188 | DndFactory factory( mCalendar ); |
2189 | factory.copyEvent(anEvent); | 2189 | factory.copyEvent(anEvent); |
2190 | } | 2190 | } |
2191 | 2191 | ||
2192 | void CalendarView::edit_paste() | 2192 | void CalendarView::edit_paste() |
2193 | { | 2193 | { |
2194 | QDate date = mNavigator->selectedDates().first(); | 2194 | QDate date = mNavigator->selectedDates().first(); |
2195 | 2195 | ||
2196 | DndFactory factory( mCalendar ); | 2196 | DndFactory factory( mCalendar ); |
2197 | Event *pastedEvent = factory.pasteEvent( date ); | 2197 | Event *pastedEvent = factory.pasteEvent( date ); |
2198 | 2198 | ||
2199 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2199 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2200 | } | 2200 | } |
2201 | 2201 | ||
2202 | void CalendarView::edit_options() | 2202 | void CalendarView::edit_options() |
2203 | { | 2203 | { |
2204 | mDialogManager->showOptionsDialog(); | 2204 | mDialogManager->showOptionsDialog(); |
2205 | //writeSettings(); | 2205 | //writeSettings(); |
2206 | } | 2206 | } |
2207 | 2207 | ||
2208 | void CalendarView::slotSelectPickerDate( QDate d) | 2208 | void CalendarView::slotSelectPickerDate( QDate d) |
2209 | { | 2209 | { |
2210 | mDateFrame->hide(); | 2210 | mDateFrame->hide(); |
2211 | if ( mDatePickerMode == 1 ) { | 2211 | if ( mDatePickerMode == 1 ) { |
2212 | mNavigator->slotDaySelect( d ); | 2212 | mNavigator->slotDaySelect( d ); |
2213 | } else if ( mDatePickerMode == 2 ) { | 2213 | } else if ( mDatePickerMode == 2 ) { |
2214 | if ( mMoveIncidence->type() == "Todo" ) { | 2214 | if ( mMoveIncidence->type() == "Todo" ) { |
2215 | Todo * to = (Todo *) mMoveIncidence; | 2215 | Todo * to = (Todo *) mMoveIncidence; |
2216 | QTime tim; | 2216 | QTime tim; |
2217 | if ( to->hasDueDate() ) | 2217 | if ( to->hasDueDate() ) |
2218 | tim = to->dtDue().time(); | 2218 | tim = to->dtDue().time(); |
2219 | else { | 2219 | else { |
2220 | tim = QTime ( 0,0,0 ); | 2220 | tim = QTime ( 0,0,0 ); |
2221 | to->setFloats( true ); | 2221 | to->setFloats( true ); |
2222 | to->setHasDueDate( true ); | 2222 | to->setHasDueDate( true ); |
2223 | } | 2223 | } |
2224 | QDateTime dt ( d,tim ); | 2224 | QDateTime dt ( d,tim ); |
2225 | to->setDtDue( dt ); | 2225 | to->setDtDue( dt ); |
2226 | todoChanged( to ); | 2226 | todoChanged( to ); |
2227 | } else { | 2227 | } else { |
2228 | QTime tim = mMoveIncidence->dtStart().time(); | 2228 | QTime tim = mMoveIncidence->dtStart().time(); |
2229 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2229 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2230 | QDateTime dt ( d,tim ); | 2230 | QDateTime dt ( d,tim ); |
2231 | mMoveIncidence->setDtStart( dt ); | 2231 | mMoveIncidence->setDtStart( dt ); |
2232 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2232 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2233 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2233 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2234 | } | 2234 | } |
2235 | 2235 | ||
2236 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2236 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2237 | } | 2237 | } |
2238 | } | 2238 | } |
2239 | 2239 | ||
2240 | void CalendarView::removeCategories() | 2240 | void CalendarView::removeCategories() |
2241 | { | 2241 | { |
2242 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2242 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2243 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2243 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2244 | QStringList catIncList; | 2244 | QStringList catIncList; |
2245 | QStringList newCatList; | 2245 | QStringList newCatList; |
2246 | Incidence* inc = incList.first(); | 2246 | Incidence* inc = incList.first(); |
2247 | int i; | 2247 | int i; |
2248 | int count = 0; | 2248 | int count = 0; |
2249 | while ( inc ) { | 2249 | while ( inc ) { |
2250 | newCatList.clear(); | 2250 | newCatList.clear(); |
2251 | catIncList = inc->categories() ; | 2251 | catIncList = inc->categories() ; |
2252 | for( i = 0; i< catIncList.count(); ++i ) { | 2252 | for( i = 0; i< catIncList.count(); ++i ) { |
2253 | if ( catList.contains (catIncList[i])) | 2253 | if ( catList.contains (catIncList[i])) |
2254 | newCatList.append( catIncList[i] ); | 2254 | newCatList.append( catIncList[i] ); |
2255 | } | 2255 | } |
2256 | newCatList.sort(); | 2256 | newCatList.sort(); |
2257 | inc->setCategories( newCatList.join(",") ); | 2257 | inc->setCategories( newCatList.join(",") ); |
2258 | inc = incList.next(); | 2258 | inc = incList.next(); |
2259 | } | 2259 | } |
2260 | } | 2260 | } |
2261 | 2261 | ||
2262 | int CalendarView::addCategories() | 2262 | int CalendarView::addCategories() |
2263 | { | 2263 | { |
2264 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2264 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2265 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2265 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2266 | QStringList catIncList; | 2266 | QStringList catIncList; |
2267 | Incidence* inc = incList.first(); | 2267 | Incidence* inc = incList.first(); |
2268 | int i; | 2268 | int i; |
2269 | int count = 0; | 2269 | int count = 0; |
2270 | while ( inc ) { | 2270 | while ( inc ) { |
2271 | catIncList = inc->categories() ; | 2271 | catIncList = inc->categories() ; |
2272 | for( i = 0; i< catIncList.count(); ++i ) { | 2272 | for( i = 0; i< catIncList.count(); ++i ) { |
2273 | if ( !catList.contains (catIncList[i])) { | 2273 | if ( !catList.contains (catIncList[i])) { |
2274 | catList.append( catIncList[i] ); | 2274 | catList.append( catIncList[i] ); |
2275 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2275 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2276 | ++count; | 2276 | ++count; |
2277 | } | 2277 | } |
2278 | } | 2278 | } |
2279 | inc = incList.next(); | 2279 | inc = incList.next(); |
2280 | } | 2280 | } |
2281 | catList.sort(); | 2281 | catList.sort(); |
2282 | KOPrefs::instance()->mCustomCategories = catList; | 2282 | KOPrefs::instance()->mCustomCategories = catList; |
2283 | return count; | 2283 | return count; |
2284 | } | 2284 | } |
2285 | 2285 | ||
2286 | void CalendarView::manageCategories() | 2286 | void CalendarView::manageCategories() |
2287 | { | 2287 | { |
2288 | KOCatPrefs* cp = new KOCatPrefs(); | 2288 | KOCatPrefs* cp = new KOCatPrefs(); |
2289 | cp->show(); | 2289 | cp->show(); |
2290 | int w =cp->sizeHint().width() ; | 2290 | int w =cp->sizeHint().width() ; |
2291 | int h = cp->sizeHint().height() ; | 2291 | int h = cp->sizeHint().height() ; |
2292 | int dw = QApplication::desktop()->width(); | 2292 | int dw = QApplication::desktop()->width(); |
2293 | int dh = QApplication::desktop()->height(); | 2293 | int dh = QApplication::desktop()->height(); |
2294 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2294 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2295 | if ( !cp->exec() ) { | 2295 | if ( !cp->exec() ) { |
2296 | delete cp; | 2296 | delete cp; |
2297 | return; | 2297 | return; |
2298 | } | 2298 | } |
2299 | int count = 0; | 2299 | int count = 0; |
2300 | if ( cp->addCat() ) { | 2300 | if ( cp->addCat() ) { |
2301 | count = addCategories(); | 2301 | count = addCategories(); |
2302 | if ( count ) { | 2302 | if ( count ) { |
2303 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2303 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2304 | writeSettings(); | 2304 | writeSettings(); |
2305 | } | 2305 | } |
2306 | } else { | 2306 | } else { |
2307 | removeCategories(); | 2307 | removeCategories(); |
2308 | updateView(); | 2308 | updateView(); |
2309 | } | 2309 | } |
2310 | delete cp; | 2310 | delete cp; |
2311 | } | 2311 | } |
2312 | 2312 | ||
2313 | void CalendarView::beamIncidence(Incidence * Inc) | 2313 | void CalendarView::beamIncidence(Incidence * Inc) |
2314 | { | 2314 | { |
2315 | QPtrList<Incidence> delSel ; | 2315 | QPtrList<Incidence> delSel ; |
2316 | delSel.append(Inc); | 2316 | delSel.append(Inc); |
2317 | beamIncidenceList( delSel ); | 2317 | beamIncidenceList( delSel ); |
2318 | } | 2318 | } |
2319 | void CalendarView::beamCalendar() | 2319 | void CalendarView::beamCalendar() |
2320 | { | 2320 | { |
2321 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2321 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2322 | //qDebug("beamCalendar() "); | 2322 | //qDebug("beamCalendar() "); |
2323 | beamIncidenceList( delSel ); | 2323 | beamIncidenceList( delSel ); |
2324 | } | 2324 | } |
2325 | void CalendarView::beamFilteredCalendar() | 2325 | void CalendarView::beamFilteredCalendar() |
2326 | { | 2326 | { |
2327 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2327 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2328 | //qDebug("beamFilteredCalendar() "); | 2328 | //qDebug("beamFilteredCalendar() "); |
2329 | beamIncidenceList( delSel ); | 2329 | beamIncidenceList( delSel ); |
2330 | } | 2330 | } |
2331 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2331 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2332 | { | 2332 | { |
2333 | if ( beamDialog->exec () == QDialog::Rejected ) | 2333 | if ( beamDialog->exec () == QDialog::Rejected ) |
2334 | return; | 2334 | return; |
2335 | #ifdef DESKTOP_VERSION | 2335 | #ifdef DESKTOP_VERSION |
2336 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2336 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2337 | #else | 2337 | #else |
2338 | QString fn = "/tmp/kopibeamfile"; | 2338 | QString fn = "/tmp/kopibeamfile"; |
2339 | #endif | 2339 | #endif |
2340 | QString mes; | 2340 | QString mes; |
2341 | bool createbup = true; | 2341 | bool createbup = true; |
2342 | if ( createbup ) { | 2342 | if ( createbup ) { |
2343 | QString description = "\n"; | 2343 | QString description = "\n"; |
2344 | CalendarLocal* cal = new CalendarLocal(); | 2344 | CalendarLocal* cal = new CalendarLocal(); |
2345 | if ( beamDialog->beamLocal() ) | 2345 | if ( beamDialog->beamLocal() ) |
2346 | cal->setLocalTime(); | 2346 | cal->setLocalTime(); |
2347 | else | 2347 | else |
2348 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2348 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2349 | Incidence *incidence = delSel.first(); | 2349 | Incidence *incidence = delSel.first(); |
2350 | bool addText = false; | 2350 | bool addText = false; |
2351 | if ( delSel.count() < 10 ) | 2351 | if ( delSel.count() < 10 ) |
2352 | addText = true; | 2352 | addText = true; |
2353 | else { | 2353 | else { |
2354 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2354 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2355 | } | 2355 | } |
2356 | while ( incidence ) { | 2356 | while ( incidence ) { |
2357 | Incidence *in = incidence->clone(); | 2357 | Incidence *in = incidence->clone(); |
2358 | if ( ! in->summary().isEmpty() ) { | 2358 | if ( ! in->summary().isEmpty() ) { |
2359 | in->setDescription(""); | 2359 | in->setDescription(""); |
2360 | } else { | 2360 | } else { |
2361 | in->setSummary( in->description().left(20)); | 2361 | in->setSummary( in->description().left(20)); |
2362 | in->setDescription(""); | 2362 | in->setDescription(""); |
2363 | } | 2363 | } |
2364 | if ( addText ) | 2364 | if ( addText ) |
2365 | description += in->summary() + "\n"; | 2365 | description += in->summary() + "\n"; |
2366 | cal->addIncidence( in ); | 2366 | cal->addIncidence( in ); |
2367 | incidence = delSel.next(); | 2367 | incidence = delSel.next(); |
2368 | } | 2368 | } |
2369 | if ( beamDialog->beamVcal() ) { | 2369 | if ( beamDialog->beamVcal() ) { |
2370 | fn += ".vcs"; | 2370 | fn += ".vcs"; |
2371 | FileStorage storage( cal, fn, new VCalFormat ); | 2371 | FileStorage storage( cal, fn, new VCalFormat ); |
2372 | storage.save(); | 2372 | storage.save(); |
2373 | } else { | 2373 | } else { |
2374 | fn += ".ics"; | 2374 | fn += ".ics"; |
2375 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2375 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2376 | storage.save(); | 2376 | storage.save(); |
2377 | } | 2377 | } |
2378 | delete cal; | 2378 | delete cal; |
2379 | mes = i18n("KO/Pi: Ready for beaming"); | 2379 | mes = i18n("KO/Pi: Ready for beaming"); |
2380 | topLevelWidget()->setCaption(mes); | 2380 | topLevelWidget()->setCaption(mes); |
2381 | KApplication::convert2latin1( fn ); | 2381 | KApplication::convert2latin1( fn ); |
2382 | #ifndef DESKTOP_VERSION | 2382 | #ifndef DESKTOP_VERSION |
2383 | Ir *ir = new Ir( this ); | 2383 | Ir *ir = new Ir( this ); |
2384 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2384 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2385 | ir->send( fn, description, "text/x-vCalendar" ); | 2385 | ir->send( fn, description, "text/x-vCalendar" ); |
2386 | #endif | 2386 | #endif |
2387 | } | 2387 | } |
2388 | } | 2388 | } |
2389 | void CalendarView::beamDone( Ir *ir ) | 2389 | void CalendarView::beamDone( Ir *ir ) |
2390 | { | 2390 | { |
2391 | #ifndef DESKTOP_VERSION | 2391 | #ifndef DESKTOP_VERSION |
2392 | delete ir; | 2392 | delete ir; |
2393 | #endif | 2393 | #endif |
2394 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2394 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2395 | topLevelWidget()->raise(); | 2395 | topLevelWidget()->raise(); |
2396 | } | 2396 | } |
2397 | 2397 | ||
2398 | void CalendarView::moveIncidence(Incidence * inc ) | 2398 | void CalendarView::moveIncidence(Incidence * inc ) |
2399 | { | 2399 | { |
2400 | if ( !inc ) return; | 2400 | if ( !inc ) return; |
2401 | // qDebug("showDatePickerForIncidence( ) "); | 2401 | // qDebug("showDatePickerForIncidence( ) "); |
2402 | if ( mDateFrame->isVisible() ) | 2402 | if ( mDateFrame->isVisible() ) |
2403 | mDateFrame->hide(); | 2403 | mDateFrame->hide(); |
2404 | else { | 2404 | else { |
2405 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2405 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2406 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2406 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2407 | int dw = QApplication::desktop()->width(); | 2407 | int dw = QApplication::desktop()->width(); |
2408 | int dh = QApplication::desktop()->height(); | 2408 | int dh = QApplication::desktop()->height(); |
2409 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2409 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2410 | mDateFrame->show(); | 2410 | mDateFrame->show(); |
2411 | } | 2411 | } |
2412 | mDatePickerMode = 2; | 2412 | mDatePickerMode = 2; |
2413 | mMoveIncidence = inc ; | 2413 | mMoveIncidence = inc ; |
2414 | QDate da; | 2414 | QDate da; |
2415 | if ( mMoveIncidence->type() == "Todo" ) { | 2415 | if ( mMoveIncidence->type() == "Todo" ) { |
2416 | Todo * to = (Todo *) mMoveIncidence; | 2416 | Todo * to = (Todo *) mMoveIncidence; |
2417 | if ( to->hasDueDate() ) | 2417 | if ( to->hasDueDate() ) |
2418 | da = to->dtDue().date(); | 2418 | da = to->dtDue().date(); |
2419 | else | 2419 | else |
2420 | da = QDate::currentDate(); | 2420 | da = QDate::currentDate(); |
2421 | } else { | 2421 | } else { |
2422 | da = mMoveIncidence->dtStart().date(); | 2422 | da = mMoveIncidence->dtStart().date(); |
2423 | } | 2423 | } |
2424 | mDatePicker->setDate( da ); | 2424 | mDatePicker->setDate( da ); |
2425 | } | 2425 | } |
2426 | void CalendarView::showDatePicker( ) | 2426 | void CalendarView::showDatePicker( ) |
2427 | { | 2427 | { |
2428 | //qDebug("CalendarView::showDatePicker( ) "); | 2428 | //qDebug("CalendarView::showDatePicker( ) "); |
2429 | if ( mDateFrame->isVisible() ) | 2429 | if ( mDateFrame->isVisible() ) |
2430 | mDateFrame->hide(); | 2430 | mDateFrame->hide(); |
2431 | else { | 2431 | else { |
2432 | int w =mDatePicker->sizeHint().width() ; | 2432 | int w =mDatePicker->sizeHint().width() ; |
2433 | int h = mDatePicker->sizeHint().height() ; | 2433 | int h = mDatePicker->sizeHint().height() ; |
2434 | int dw = QApplication::desktop()->width(); | 2434 | int dw = QApplication::desktop()->width(); |
2435 | int dh = QApplication::desktop()->height(); | 2435 | int dh = QApplication::desktop()->height(); |
2436 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2436 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2437 | mDateFrame->show(); | 2437 | mDateFrame->show(); |
2438 | } | 2438 | } |
2439 | mDatePickerMode = 1; | 2439 | mDatePickerMode = 1; |
2440 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2440 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2441 | } | 2441 | } |
2442 | 2442 | ||
2443 | void CalendarView::showEventEditor() | 2443 | void CalendarView::showEventEditor() |
2444 | { | 2444 | { |
2445 | #ifdef DESKTOP_VERSION | 2445 | #ifdef DESKTOP_VERSION |
2446 | mEventEditor->show(); | 2446 | mEventEditor->show(); |
2447 | #else | 2447 | #else |
2448 | mEventEditor->showMaximized(); | 2448 | mEventEditor->showMaximized(); |
2449 | #endif | 2449 | #endif |
2450 | } | 2450 | } |
2451 | void CalendarView::showTodoEditor() | 2451 | void CalendarView::showTodoEditor() |
2452 | { | 2452 | { |
2453 | #ifdef DESKTOP_VERSION | 2453 | #ifdef DESKTOP_VERSION |
2454 | mTodoEditor->show(); | 2454 | mTodoEditor->show(); |
2455 | #else | 2455 | #else |
2456 | mTodoEditor->showMaximized(); | 2456 | mTodoEditor->showMaximized(); |
2457 | #endif | 2457 | #endif |
2458 | } | 2458 | } |
2459 | 2459 | ||
2460 | void CalendarView::cloneIncidence() | 2460 | void CalendarView::cloneIncidence() |
2461 | { | 2461 | { |
2462 | Incidence *incidence = currentSelection(); | 2462 | Incidence *incidence = currentSelection(); |
2463 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2463 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2464 | if ( incidence ) { | 2464 | if ( incidence ) { |
2465 | cloneIncidence(incidence); | 2465 | cloneIncidence(incidence); |
2466 | } | 2466 | } |
2467 | } | 2467 | } |
2468 | void CalendarView::moveIncidence() | 2468 | void CalendarView::moveIncidence() |
2469 | { | 2469 | { |
2470 | Incidence *incidence = currentSelection(); | 2470 | Incidence *incidence = currentSelection(); |
2471 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2471 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2472 | if ( incidence ) { | 2472 | if ( incidence ) { |
2473 | moveIncidence(incidence); | 2473 | moveIncidence(incidence); |
2474 | } | 2474 | } |
2475 | } | 2475 | } |
2476 | void CalendarView::beamIncidence() | 2476 | void CalendarView::beamIncidence() |
2477 | { | 2477 | { |
2478 | Incidence *incidence = currentSelection(); | 2478 | Incidence *incidence = currentSelection(); |
2479 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2479 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2480 | if ( incidence ) { | 2480 | if ( incidence ) { |
2481 | beamIncidence(incidence); | 2481 | beamIncidence(incidence); |
2482 | } | 2482 | } |
2483 | } | 2483 | } |
2484 | void CalendarView::toggleCancelIncidence() | 2484 | void CalendarView::toggleCancelIncidence() |
2485 | { | 2485 | { |
2486 | Incidence *incidence = currentSelection(); | 2486 | Incidence *incidence = currentSelection(); |
2487 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2487 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2488 | if ( incidence ) { | 2488 | if ( incidence ) { |
2489 | cancelIncidence(incidence); | 2489 | cancelIncidence(incidence); |
2490 | } | 2490 | } |
2491 | } | 2491 | } |
2492 | 2492 | ||
2493 | 2493 | ||
2494 | void CalendarView::cancelIncidence(Incidence * inc ) | 2494 | void CalendarView::cancelIncidence(Incidence * inc ) |
2495 | { | 2495 | { |
2496 | inc->setCancelled( ! inc->cancelled() ); | 2496 | inc->setCancelled( ! inc->cancelled() ); |
2497 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2497 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2498 | updateView(); | 2498 | updateView(); |
2499 | } | 2499 | } |
2500 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2500 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2501 | { | 2501 | { |
2502 | Incidence * newInc = orgInc->clone(); | 2502 | Incidence * newInc = orgInc->clone(); |
2503 | newInc->recreate(); | 2503 | newInc->recreate(); |
2504 | 2504 | ||
2505 | if ( newInc->type() == "Todo" ) { | 2505 | if ( newInc->type() == "Todo" ) { |
2506 | Todo* t = (Todo*) newInc; | 2506 | Todo* t = (Todo*) newInc; |
2507 | mTodoEditor->editTodo( t ); | 2507 | mTodoEditor->editTodo( t ); |