summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-08-01 11:37:35 (UTC)
committer zautrix <zautrix>2004-08-01 11:37:35 (UTC)
commite954cc1e29b129982e4d07c4f490d7e881597374 (patch) (unidiff)
tree29e7bdcf20952b813637083596102f7e7b080567
parent8a394f316feb828954d69480553f85c9c0f4b353 (diff)
downloadkdepimpi-e954cc1e29b129982e4d07c4f490d7e881597374.zip
kdepimpi-e954cc1e29b129982e4d07c4f490d7e881597374.tar.gz
kdepimpi-e954cc1e29b129982e4d07c4f490d7e881597374.tar.bz2
Made sync code more readable by using defines
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--Makefile30
-rw-r--r--korganizer/calendarview.cpp47
-rw-r--r--libkcal/sharpformat.cpp15
-rw-r--r--libkcal/syncdefines.h22
-rw-r--r--libkdepim/ksyncprofile.h10
5 files changed, 62 insertions, 62 deletions
diff --git a/Makefile b/Makefile
index 826e70e..19c57e5 100644
--- a/Makefile
+++ b/Makefile
@@ -1,299 +1,279 @@
1DISTPATH = $(shell pwd) 1DISTPATH = $(shell pwd)
2DISTDIR = $(shell basename $(DISTPATH)) 2DISTDIR = $(shell basename $(DISTPATH))
3 3
4 4
5ifeq ($(PLATFORM) , zaurus) 5ifeq ($(PLATFORM) , zaurus)
6 BUILD_NO_LDAP_PLUGIN=1 6 BUILD_NO_LDAP_PLUGIN=1
7endif 7endif
8 8
9ifneq ($(PLATFORM) , zaurus) 9ifneq ($(PLATFORM) , zaurus)
10 BUILD_NO_SHARP_PLUGIN=1 10 BUILD_NO_SHARP_PLUGIN=1
11endif 11endif
12 12
13SUBDIRS_MICROKDE = \ 13SUBDIRS_MICROKDE = \
14 libical/src/libical \ 14 libical/src/libical \
15 libical/src/libicalss \ 15 libical/src/libicalss \
16 qtcompat \ 16 qtcompat \
17 microkde \ 17 microkde \
18 libkcal \ 18 libkcal \
19 libkdepim \ 19 libkdepim \
20 kabc \ 20 kabc \
21 kabc/formats/binary \ 21 kabc/formats/binary \
22 kabc/plugins/file \ 22 kabc/plugins/file \
23 kabc/plugins/dir \ 23 kabc/plugins/dir \
24 korganizer \ 24 korganizer \
25 kalarmd \ 25 kalarmd \
26 kaddressbook 26 kaddressbook
27 27
28SUBDIRS_QTOPIA_PLUGIN = \ 28SUBDIRS_QTOPIA_PLUGIN = \
29 kabc/converter/qtopia \ 29 kabc/plugins/qtopia
30 kabc/plugins/qtopia \
31 kaddressbook/xxport/qtopia
32 30
33SUBDIRS_OPIE_PLUGIN = \ 31SUBDIRS_OPIE_PLUGIN = \
34 kabc/converter/opie \ 32 kabc/plugins/opie
35 kabc/plugins/opie \
36 kaddressbook/xxport/opie
37 33
38SUBDIRS_SHARP_PLUGIN = \ 34SUBDIRS_SHARP_PLUGIN = \
39 kabc/converter/sharpdtm \ 35 kabc/plugins/sharpdtm
40 kabc/plugins/sharpdtm \
41 kaddressbook/xxport/sharpdtm
42 36
43SUBDIRS_LDAP_PLUGIN = \ 37SUBDIRS_LDAP_PLUGIN = \
44 kabc/plugins/ldap 38 kabc/plugins/ldap
45 39
46SUBDIRS_MICROMAIL = \ 40SUBDIRS_MICROMAIL = \
47 kmicromail/libetpan \ 41 kmicromail/libetpan \
48 kmicromail/libmailwrapper \ 42 kmicromail/libmailwrapper \
49 kmicromail 43 kmicromail
50 44
51SUBDIRS = \ 45SUBDIRS = \
52 $(SUBDIRS_MICROKDE) \ 46 $(SUBDIRS_MICROKDE) \
53 $(SUBDIRS_QTOPIA_PLUGIN) \ 47 $(SUBDIRS_QTOPIA_PLUGIN) \
54 $(SUBDIRS_OPIE_PLUGIN) \ 48 $(SUBDIRS_OPIE_PLUGIN) \
55 $(SUBDIRS_SHARP_PLUGIN) \ 49 $(SUBDIRS_SHARP_PLUGIN) \
56 $(SUBDIRS_LDAP_PLUGIN) \ 50 $(SUBDIRS_LDAP_PLUGIN) \
57 $(SUBDIRS_MICROMAIL) 51 $(SUBDIRS_MICROMAIL)
58 52
59 53
60all: build_microkde \ 54all: build_microkde \
61 build_qtopia_plugin \ 55 build_qtopia_plugin \
62 build_opie_plugin \ 56 build_opie_plugin \
63 build_sharp_plugin \ 57 build_sharp_plugin \
64 build_ldap_plugin \ 58 build_ldap_plugin \
65 build_micromail 59 build_micromail
66 60
67 61
68build_microkde: variable_test tmake 62build_microkde: variable_test tmake
69 for i in $(SUBDIRS_MICROKDE); do pushd $$i; \ 63 for i in $(SUBDIRS_MICROKDE); do pushd $$i; \
70 make -f Makefile$(PLATFORM) || exit 1; popd; \ 64 make -f Makefile$(PLATFORM) || exit 1; popd; \
71 done 65 done
72 66
73build_qtopia_plugin: build_microkde 67build_qtopia_plugin: build_microkde
74 for i in $(SUBDIRS_QTOPIA_PLUGIN); do pushd $$i; \ 68 for i in $(SUBDIRS_QTOPIA_PLUGIN); do pushd $$i; \
75 make -f Makefile$(PLATFORM) || exit 1; popd; \ 69 make -f Makefile$(PLATFORM) || exit 1; popd; \
76 done 70 done
77 71
78build_opie_plugin: build_microkde 72build_opie_plugin: build_microkde
79 ifdef BUILD_NO_OPIE_PLUGIN 73 ifdef BUILD_NO_OPIE_PLUGIN
80 @echo ---> opie plugin not build. 74 @echo ---> opie plugin not build.
81 else 75 else
82 for i in $(SUBDIRS_OPIE_PLUGIN); do pushd $$i; \ 76 for i in $(SUBDIRS_OPIE_PLUGIN); do pushd $$i; \
83 make -f Makefile$(PLATFORM) || exit 1; popd; \ 77 make -f Makefile$(PLATFORM) || exit 1; popd; \
84 done 78 done
85 endif 79 endif
86 80
87build_sharp_plugin: build_microkde 81build_sharp_plugin: build_microkde
88 ifdef BUILD_NO_SHARP_PLUGIN 82 ifdef BUILD_NO_SHARP_PLUGIN
89 @echo ---> ldap plugin not build. 83 @echo ---> ldap plugin not build.
90 else 84 else
91 for i in $(SUBDIRS_SHARP_PLUGIN); do pushd $$i; \ 85 for i in $(SUBDIRS_SHARP_PLUGIN); do pushd $$i; \
92 make -f Makefile$(PLATFORM) || exit 1; popd; \ 86 make -f Makefile$(PLATFORM) || exit 1; popd; \
93 done 87 done
94 endif 88 endif
95 89
96build_ldap_plugin: build_microkde 90build_ldap_plugin: build_microkde
97 ifdef BUILD_NO_LDAP_PLUGIN 91 ifdef BUILD_NO_LDAP_PLUGIN
98 @echo ---> ldap plugin not build. 92 @echo ---> ldap plugin not build.
99 else 93 else
100 for i in $(SUBDIRS_LDAP_PLUGIN); do pushd $$i; \ 94 for i in $(SUBDIRS_LDAP_PLUGIN); do pushd $$i; \
101 make -f Makefile$(PLATFORM) || exit 1; popd; \ 95 make -f Makefile$(PLATFORM) || exit 1; popd; \
102 done 96 done
103 endif 97 endif
104 98
105 99
106build_micromail: build_microkde 100build_micromail: build_microkde
107 ifdef BUILD_NO_MICROMAIL 101 ifdef BUILD_NO_MICROMAIL
108 @echo ---> micromail not build. 102 @echo ---> micromail not build.
109 else 103 else
110 for i in $(SUBDIRS_MICROMAIL); do pushd $$i; \ 104 for i in $(SUBDIRS_MICROMAIL); do pushd $$i; \
111 make -f Makefile$(PLATFORM) || exit 1; popd; \ 105 make -f Makefile$(PLATFORM) || exit 1; popd; \
112 done 106 done
113 endif 107 endif
114 108
115 109
116variable_info: 110variable_info:
117 @echo -------------------------------------- 111 @echo --------------------------------------
118 @echo KDEPIM buildsystem, variableinfo... 112 @echo KDEPIM buildsystem, variableinfo...
119 @echo QTDIR=$(QTDIR) 113 @echo QTDIR=$(QTDIR)
120 @echo QPEDIR=$(QPEDIR) 114 @echo QPEDIR=$(QPEDIR)
121 @echo OPIEDIR=$(OPIEDIR) 115 @echo OPIEDIR=$(OPIEDIR)
122 @echo PLATFORM=$(PLATFORM) 116 @echo PLATFORM=$(PLATFORM)
123 @echo RELEASE_DEBUG=$(RELEASE_DEBUG) 117 @echo RELEASE_DEBUG=$(RELEASE_DEBUG)
124 @echo BUILD_NO_MICROMAIL=$(BUILD_NO_MICROMAIL) 118 @echo BUILD_NO_MICROMAIL=$(BUILD_NO_MICROMAIL)
125 @echo BUILD_NO_LDAP_PLUGIN=$(BUILD_NO_LDAP_PLUGIN) 119 @echo BUILD_NO_LDAP_PLUGIN=$(BUILD_NO_LDAP_PLUGIN)
126 @echo BUILD_NO_OPIE_PLUGIN=$(BUILD_NO_OPIE_PLUGIN) 120 @echo BUILD_NO_OPIE_PLUGIN=$(BUILD_NO_OPIE_PLUGIN)
127 @echo BUILD_NO_SHARP_PLUGIN=$(BUILD_NO_SHARP_PLUGIN) 121 @echo BUILD_NO_SHARP_PLUGIN=$(BUILD_NO_SHARP_PLUGIN)
128 ifndef BUILD_NO_SHARP_PLUGIN 122 ifndef BUILD_NO_SHARP_PLUGIN
129 @echo SHARPDTMSDK=$(SHARPDTMSDK) 123 @echo SHARPDTMSDK=$(SHARPDTMSDK)
130 endif 124 endif
131 @echo -------------------------------------- 125 @echo --------------------------------------
132 126
133variable_test: variable_info 127variable_test: variable_info
134 @echo KDEPIM buildsystem, variablecheck... 128 @echo KDEPIM buildsystem, variablecheck...
135 ifndef PLATFORM 129 ifndef PLATFORM
136 @echo PLATFORM is not defined. 130 @echo PLATFORM is not defined.
137 $(error PLATFORM is not defined) 131 $(error PLATFORM is not defined)
138 endif 132 endif
139 ifdef BUILD_NO_LDAP_PLUGIN 133 ifdef BUILD_NO_LDAP_PLUGIN
140 @echo LDAP PLUGIN will not be build, because BUILD_NO_LDAP_PLUGIN is set to $(BUILD_NO_LDAP_PLUGIN) 134 @echo LDAP PLUGIN will not be build, because BUILD_NO_LDAP_PLUGIN is set to $(BUILD_NO_LDAP_PLUGIN)
141 endif 135 endif
142 ifdef BUILD_NO_OPIE_PLUGIN 136 ifdef BUILD_NO_OPIE_PLUGIN
143 @echo OPIE PLUGIN will not be build, because BUILD_NO_OPIE_PLUGIN is set to $(BUILD_NO_OPIE_PLUGIN) 137 @echo OPIE PLUGIN will not be build, because BUILD_NO_OPIE_PLUGIN is set to $(BUILD_NO_OPIE_PLUGIN)
144 endif 138 endif
145 ifdef BUILD_NO_MICROMAIL 139 ifdef BUILD_NO_MICROMAIL
146 @echo MICROMAIL will not be build, because BUILD_NO_MICROMAIL is set to $(BUILD_NO_MICROMAIL) 140 @echo MICROMAIL will not be build, because BUILD_NO_MICROMAIL is set to $(BUILD_NO_MICROMAIL)
147 endif 141 endif
148 ifdef BUILD_NO_SHARP_PLUGIN 142 ifdef BUILD_NO_SHARP_PLUGIN
149 @echo SHARP PLUGIN will not be build, because BUILD_NO_SHARP_PLUGIN is set to $(BUILD_NO_SHARP_PLUGIN) 143 @echo SHARP PLUGIN will not be build, because BUILD_NO_SHARP_PLUGIN is set to $(BUILD_NO_SHARP_PLUGIN)
150 else 144 else
151 ifndef SHARPDTMSDK 145 ifndef SHARPDTMSDK
152 @echo SHARP PLUGIN can not be build, because SHARPDTMSDK is set to $(SHARPDTMSDK) 146 @echo SHARP PLUGIN can not be build, because SHARPDTMSDK is set to $(SHARPDTMSDK)
153 $(error SHARPDTMSDK is not defined) 147 $(error SHARPDTMSDK is not defined)
154 endif 148 endif
155 endif 149 endif
156 @echo -------------------------------------- 150 @echo --------------------------------------
157 151
158 152
159objects: 153objects:
160 for i in $(SUBDIRS); do mkdir -p $$i/obj/$(PLATFORM); done 154 for i in $(SUBDIRS); do mkdir -p $$i/obj/$(PLATFORM); done
161 for i in $(SUBDIRS); do mkdir -p $$i/moc/$(PLATFORM); done 155 for i in $(SUBDIRS); do mkdir -p $$i/moc/$(PLATFORM); done
162 mkdir -p libical/lib/$(PLATFORM) 156 mkdir -p libical/lib/$(PLATFORM)
163 157
164clean: 158clean:
165 rm -f libical/lib/$(PLATFORM)/*; 159 rm -f libical/lib/$(PLATFORM)/*;
166 for i in $(SUBDIRS); do pushd $$i; make clean; rm -f *~;\ 160 for i in $(SUBDIRS); do pushd $$i; make clean; rm -f *~;\
167 rm -f obj/$(PLATFORM)/*; rm -f moc/$(PLATFORM)/*; rm Makefile$(PLATFORM); popd; \ 161 rm -f obj/$(PLATFORM)/*; rm -f moc/$(PLATFORM)/*; rm Makefile$(PLATFORM); popd; \
168 done 162 done
169install: 163install:
170 cd bin/kdepim; make install 164 cd bin/kdepim; make install
171 cp db2file/db2file $(QPEDIR)/bin/db2file 165 cp db2file/db2file $(QPEDIR)/bin/db2file
172 cp korganizer/korganizer.desktop $(QPEDIR)/apps/Pim/korganizer.desktop 166 cp korganizer/korganizer.desktop $(QPEDIR)/apps/Pim/korganizer.desktop
173 cp kaddressbook/kaddressbook.desktop $(QPEDIR)/apps/Pim/kaddressbook.desktop 167 cp kaddressbook/kaddressbook.desktop $(QPEDIR)/apps/Pim/kaddressbook.desktop
174 cp kmicromail/kmicromail.desktop $(QPEDIR)/apps/Pim/kmicromail.desktop 168 cp kmicromail/kmicromail.desktop $(QPEDIR)/apps/Pim/kmicromail.desktop
175 169
176dist: 170dist:
177 @echo Dont forget to do "make install" before "make dist" 171 @echo Dont forget to do "make install" before "make dist"
178 rm -f *arm.ipk 172 rm -f *arm.ipk
179 rm -f *~ 173 rm -f *~
180 cd ..; tar czf kdepim.src.tar.gz --exclude=obj --exclude=moc kdepim 174 cd ..; tar czf kdepim.src.tar.gz --exclude=obj --exclude=moc kdepim
181 ./mkipks kmicrokdelibs.control 175 ./mkipks kmicrokdelibs.control
182 ./mkipks korganizer.control 176 ./mkipks korganizer.control
183 ./mkipks kaddressbook.control 177 ./mkipks kaddressbook.control
184 ifndef BUILD_NO_MICROMAIL 178 ifndef BUILD_NO_MICROMAIL
185 ./mkipks kopiemail.control 179 ./mkipks kopiemail.control
186 endif 180 endif
187 ./mkipks korganizer-alarm.control 181 ./mkipks korganizer-alarm.control
188 182
189tmake: objects \ 183tmake: objects \
190 qtcompat/Makefile$(PLATFORM) \ 184 qtcompat/Makefile$(PLATFORM) \
191 microkde/Makefile$(PLATFORM) \ 185 microkde/Makefile$(PLATFORM) \
192 libkcal/Makefile$(PLATFORM) \ 186 libkcal/Makefile$(PLATFORM) \
193 libkdepim/Makefile$(PLATFORM) \ 187 libkdepim/Makefile$(PLATFORM) \
194 korganizer/Makefile$(PLATFORM) \ 188 korganizer/Makefile$(PLATFORM) \
195 kalarmd/Makefile$(PLATFORM) \ 189 kalarmd/Makefile$(PLATFORM) \
196 libical/src/libical/Makefile$(PLATFORM) \ 190 libical/src/libical/Makefile$(PLATFORM) \
197 libical/src/libicalss/Makefile$(PLATFORM) \ 191 libical/src/libicalss/Makefile$(PLATFORM) \
198 kabc/Makefile$(PLATFORM) \ 192 kabc/Makefile$(PLATFORM) \
199 kabc/converter/opie/Makefile$(PLATFORM) \
200 kabc/converter/qtopia/Makefile$(PLATFORM) \
201 kabc/converter/sharpdtm/Makefile$(PLATFORM) \
202 kabc/formats/binary/Makefile$(PLATFORM) \ 193 kabc/formats/binary/Makefile$(PLATFORM) \
203 kabc/plugins/file/Makefile$(PLATFORM) \ 194 kabc/plugins/file/Makefile$(PLATFORM) \
204 kabc/plugins/dir/Makefile$(PLATFORM) \ 195 kabc/plugins/dir/Makefile$(PLATFORM) \
205 kabc/plugins/ldap/Makefile$(PLATFORM) \ 196 kabc/plugins/ldap/Makefile$(PLATFORM) \
206 kabc/plugins/opie/Makefile$(PLATFORM) \ 197 kabc/plugins/opie/Makefile$(PLATFORM) \
207 kabc/plugins/qtopia/Makefile$(PLATFORM) \ 198 kabc/plugins/qtopia/Makefile$(PLATFORM) \
208 kabc/plugins/sharpdtm/Makefile$(PLATFORM) \ 199 kabc/plugins/sharpdtm/Makefile$(PLATFORM) \
209 kaddressbook/xxport/opie/Makefile$(PLATFORM) \ 200 kaddressbook/xxport/opie/Makefile$(PLATFORM) \
210 kaddressbook/xxport/qtopia/Makefile$(PLATFORM) \ 201 kaddressbook/xxport/qtopia/Makefile$(PLATFORM) \
211 kaddressbook/xxport/sharpdtm/Makefile$(PLATFORM) \ 202 kaddressbook/xxport/sharpdtm/Makefile$(PLATFORM) \
212 kaddressbook/Makefile$(PLATFORM) \ 203 kaddressbook/Makefile$(PLATFORM) \
213 kmicromail/Makefile$(PLATFORM) \ 204 kmicromail/Makefile$(PLATFORM) \
214 kmicromail/libetpan/Makefile$(PLATFORM) \ 205 kmicromail/libetpan/Makefile$(PLATFORM) \
215 kmicromail/libmailwrapper/Makefile$(PLATFORM) 206 kmicromail/libmailwrapper/Makefile$(PLATFORM)
216
217 207
218 208
219 209
220qtcompat/Makefile$(PLATFORM): qtcompat/qtcompat.pro 210qtcompat/Makefile$(PLATFORM): qtcompat/qtcompat.pro
221 cd qtcompat; tmake "CONFIG+=$(RELEASE_DEBUG)" qtcompat.pro -o Makefile$(PLATFORM) 211 cd qtcompat; tmake "CONFIG+=$(RELEASE_DEBUG)" qtcompat.pro -o Makefile$(PLATFORM)
222 212
223microkde/Makefile$(PLATFORM): microkde/microkdeE.pro 213microkde/Makefile$(PLATFORM): microkde/microkdeE.pro
224 cd microkde; tmake "CONFIG+=$(RELEASE_DEBUG)" microkdeE.pro -o Makefile$(PLATFORM) 214 cd microkde; tmake "CONFIG+=$(RELEASE_DEBUG)" microkdeE.pro -o Makefile$(PLATFORM)
225 215
226libkcal/Makefile$(PLATFORM): libkcal/libkcalE.pro 216libkcal/Makefile$(PLATFORM): libkcal/libkcalE.pro
227 cd libkcal; tmake "CONFIG+=$(RELEASE_DEBUG)" libkcalE.pro -o Makefile$(PLATFORM) 217 cd libkcal; tmake "CONFIG+=$(RELEASE_DEBUG)" libkcalE.pro -o Makefile$(PLATFORM)
228 218
229 219
230libkdepim/Makefile$(PLATFORM): libkdepim/libkdepimE.pro 220libkdepim/Makefile$(PLATFORM): libkdepim/libkdepimE.pro
231 cd libkdepim; tmake "CONFIG+=$(RELEASE_DEBUG)" libkdepimE.pro -o Makefile$(PLATFORM) 221 cd libkdepim; tmake "CONFIG+=$(RELEASE_DEBUG)" libkdepimE.pro -o Makefile$(PLATFORM)
232 222
233kalarmd/Makefile$(PLATFORM): kalarmd/kalarmdE.pro 223kalarmd/Makefile$(PLATFORM): kalarmd/kalarmdE.pro
234 cd kalarmd; tmake "CONFIG+=$(RELEASE_DEBUG)" kalarmdE.pro -o Makefile$(PLATFORM) 224 cd kalarmd; tmake "CONFIG+=$(RELEASE_DEBUG)" kalarmdE.pro -o Makefile$(PLATFORM)
235 225
236korganizer/Makefile$(PLATFORM): korganizer/korganizerE.pro 226korganizer/Makefile$(PLATFORM): korganizer/korganizerE.pro
237 cd korganizer; tmake "CONFIG+=$(RELEASE_DEBUG)" korganizerE.pro -o Makefile$(PLATFORM) 227 cd korganizer; tmake "CONFIG+=$(RELEASE_DEBUG)" korganizerE.pro -o Makefile$(PLATFORM)
238 228
239libical/src/libical/Makefile$(PLATFORM): libical/src/libical/libicalE.pro 229libical/src/libical/Makefile$(PLATFORM): libical/src/libical/libicalE.pro
240 cd libical/src/libical; tmake "CONFIG+=$(RELEASE_DEBUG)" libicalE.pro -o Makefile$(PLATFORM) 230 cd libical/src/libical; tmake "CONFIG+=$(RELEASE_DEBUG)" libicalE.pro -o Makefile$(PLATFORM)
241 231
242libical/src/libicalss/Makefile$(PLATFORM): libical/src/libicalss/libicalssE.pro 232libical/src/libicalss/Makefile$(PLATFORM): libical/src/libicalss/libicalssE.pro
243 cd libical/src/libicalss; tmake "CONFIG+=$(RELEASE_DEBUG)" libicalssE.pro -o Makefile$(PLATFORM) 233 cd libical/src/libicalss; tmake "CONFIG+=$(RELEASE_DEBUG)" libicalssE.pro -o Makefile$(PLATFORM)
244 234
245kabc/Makefile$(PLATFORM): kabc/kabcE.pro 235kabc/Makefile$(PLATFORM): kabc/kabcE.pro
246 cd kabc; tmake "CONFIG+=$(RELEASE_DEBUG)" kabcE.pro -o Makefile$(PLATFORM) 236 cd kabc; tmake "CONFIG+=$(RELEASE_DEBUG)" kabcE.pro -o Makefile$(PLATFORM)
247 237
248kabc/converter/opie/Makefile$(PLATFORM): kabc/converter/opie/opieE.pro
249 cd kabc/converter/opie; tmake "CONFIG+=$(RELEASE_DEBUG)" opieE.pro -o Makefile$(PLATFORM)
250
251kabc/converter/qtopia/Makefile$(PLATFORM): kabc/converter/qtopia/qtopiaE.pro
252 cd kabc/converter/qtopia; tmake "CONFIG+=$(RELEASE_DEBUG)" qtopiaE.pro -o Makefile$(PLATFORM)
253
254kabc/converter/sharpdtm/Makefile$(PLATFORM): kabc/converter/sharpdtm/sharpdtmE.pro
255 cd kabc/converter/sharpdtm; tmake "CONFIG+=$(RELEASE_DEBUG)" sharpdtmE.pro -o Makefile$(PLATFORM)
256
257
258kabc/formats/binary/Makefile$(PLATFORM): kabc/formats/binary/kabcformat_binaryE.pro 238kabc/formats/binary/Makefile$(PLATFORM): kabc/formats/binary/kabcformat_binaryE.pro
259 cd kabc/formats/binary; tmake "CONFIG+=$(RELEASE_DEBUG)" kabcformat_binaryE.pro -o Makefile$(PLATFORM) 239 cd kabc/formats/binary; tmake "CONFIG+=$(RELEASE_DEBUG)" kabcformat_binaryE.pro -o Makefile$(PLATFORM)
260 240
261kabc/plugins/file/Makefile$(PLATFORM): kabc/plugins/file/fileE.pro 241kabc/plugins/file/Makefile$(PLATFORM): kabc/plugins/file/fileE.pro
262 cd kabc/plugins/file; tmake "CONFIG+=$(RELEASE_DEBUG)" fileE.pro -o Makefile$(PLATFORM) 242 cd kabc/plugins/file; tmake "CONFIG+=$(RELEASE_DEBUG)" fileE.pro -o Makefile$(PLATFORM)
263 243
264kabc/plugins/dir/Makefile$(PLATFORM): kabc/plugins/dir/dirE.pro 244kabc/plugins/dir/Makefile$(PLATFORM): kabc/plugins/dir/dirE.pro
265 cd kabc/plugins/dir; tmake "CONFIG+=$(RELEASE_DEBUG)" dirE.pro -o Makefile$(PLATFORM) 245 cd kabc/plugins/dir; tmake "CONFIG+=$(RELEASE_DEBUG)" dirE.pro -o Makefile$(PLATFORM)
266 246
267kabc/plugins/ldap/Makefile$(PLATFORM): kabc/plugins/ldap/ldapE.pro 247kabc/plugins/ldap/Makefile$(PLATFORM): kabc/plugins/ldap/ldapE.pro
268 cd kabc/plugins/ldap; tmake "CONFIG+=$(RELEASE_DEBUG)" ldapE.pro -o Makefile$(PLATFORM) 248 cd kabc/plugins/ldap; tmake "CONFIG+=$(RELEASE_DEBUG)" ldapE.pro -o Makefile$(PLATFORM)
269 249
270kabc/plugins/opie/Makefile$(PLATFORM): kabc/plugins/opie/opieE.pro 250kabc/plugins/opie/Makefile$(PLATFORM): kabc/plugins/opie/opieE.pro
271 cd kabc/plugins/opie; tmake "CONFIG+=$(RELEASE_DEBUG)" opieE.pro -o Makefile$(PLATFORM) 251 cd kabc/plugins/opie; tmake "CONFIG+=$(RELEASE_DEBUG)" opieE.pro -o Makefile$(PLATFORM)
272 252
273kabc/plugins/qtopia/Makefile$(PLATFORM): kabc/plugins/qtopia/qtopiaE.pro 253kabc/plugins/qtopia/Makefile$(PLATFORM): kabc/plugins/qtopia/qtopiaE.pro
274 cd kabc/plugins/qtopia; tmake "CONFIG+=$(RELEASE_DEBUG)" qtopiaE.pro -o Makefile$(PLATFORM) 254 cd kabc/plugins/qtopia; tmake "CONFIG+=$(RELEASE_DEBUG)" qtopiaE.pro -o Makefile$(PLATFORM)
275 255
276kabc/plugins/sharpdtm/Makefile$(PLATFORM): kabc/plugins/sharpdtm/sharpdtmE.pro 256kabc/plugins/sharpdtm/Makefile$(PLATFORM): kabc/plugins/sharpdtm/sharpdtmE.pro
277 cd kabc/plugins/sharpdtm; tmake "CONFIG+=$(RELEASE_DEBUG)" sharpdtmE.pro -o Makefile$(PLATFORM) 257 cd kabc/plugins/sharpdtm; tmake "CONFIG+=$(RELEASE_DEBUG)" sharpdtmE.pro -o Makefile$(PLATFORM)
278 258
279kaddressbook/xxport/opie/Makefile$(PLATFORM): kaddressbook/xxport/opie/opieE.pro 259kaddressbook/xxport/opie/Makefile$(PLATFORM): kaddressbook/xxport/opie/opieE.pro
280 cd kaddressbook/xxport/opie; tmake "CONFIG+=$(RELEASE_DEBUG)" opieE.pro -o Makefile$(PLATFORM) 260 cd kaddressbook/xxport/opie; tmake "CONFIG+=$(RELEASE_DEBUG)" opieE.pro -o Makefile$(PLATFORM)
281 261
282kaddressbook/xxport/qtopia/Makefile$(PLATFORM): kaddressbook/xxport/qtopia/qtopiaE.pro 262kaddressbook/xxport/qtopia/Makefile$(PLATFORM): kaddressbook/xxport/qtopia/qtopiaE.pro
283 cd kaddressbook/xxport/qtopia; tmake "CONFIG+=$(RELEASE_DEBUG)" qtopiaE.pro -o Makefile$(PLATFORM) 263 cd kaddressbook/xxport/qtopia; tmake "CONFIG+=$(RELEASE_DEBUG)" qtopiaE.pro -o Makefile$(PLATFORM)
284 264
285kaddressbook/xxport/sharpdtm/Makefile$(PLATFORM): kaddressbook/xxport/sharpdtm/sharpdtmE.pro 265kaddressbook/xxport/sharpdtm/Makefile$(PLATFORM): kaddressbook/xxport/sharpdtm/sharpdtmE.pro
286 cd kaddressbook/xxport/sharpdtm; tmake "CONFIG+=$(RELEASE_DEBUG)" sharpdtmE.pro -o Makefile$(PLATFORM) 266 cd kaddressbook/xxport/sharpdtm; tmake "CONFIG+=$(RELEASE_DEBUG)" sharpdtmE.pro -o Makefile$(PLATFORM)
287 267
288 268
289kaddressbook/Makefile$(PLATFORM): kaddressbook/kaddressbookE.pro 269kaddressbook/Makefile$(PLATFORM): kaddressbook/kaddressbookE.pro
290 cd kaddressbook; tmake "CONFIG+=$(RELEASE_DEBUG)" kaddressbookE.pro -o Makefile$(PLATFORM) 270 cd kaddressbook; tmake "CONFIG+=$(RELEASE_DEBUG)" kaddressbookE.pro -o Makefile$(PLATFORM)
291 271
292kmicromail/Makefile$(PLATFORM): kmicromail/kmicromailE.pro 272kmicromail/Makefile$(PLATFORM): kmicromail/kmicromailE.pro
293 cd kmicromail; tmake "CONFIG+=$(RELEASE_DEBUG)" kmicromailE.pro -o Makefile$(PLATFORM) 273 cd kmicromail; tmake "CONFIG+=$(RELEASE_DEBUG)" kmicromailE.pro -o Makefile$(PLATFORM)
294 274
295kmicromail/libetpan/Makefile$(PLATFORM): kmicromail/libetpan/libetpanE.pro 275kmicromail/libetpan/Makefile$(PLATFORM): kmicromail/libetpan/libetpanE.pro
296 cd kmicromail/libetpan; tmake "CONFIG+=$(RELEASE_DEBUG)" libetpanE.pro -o Makefile$(PLATFORM) 276 cd kmicromail/libetpan; tmake "CONFIG+=$(RELEASE_DEBUG)" libetpanE.pro -o Makefile$(PLATFORM)
297 277
298kmicromail/libmailwrapper/Makefile$(PLATFORM): kmicromail/libmailwrapper/libmailwrapperE.pro 278kmicromail/libmailwrapper/Makefile$(PLATFORM): kmicromail/libmailwrapper/libmailwrapperE.pro
299 cd kmicromail/libmailwrapper; tmake "CONFIG+=$(RELEASE_DEBUG)" libmailwrapperE.pro -o Makefile$(PLATFORM) 279 cd kmicromail/libmailwrapper; tmake "CONFIG+=$(RELEASE_DEBUG)" libmailwrapperE.pro -o Makefile$(PLATFORM)
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 58b3d70..fd68dc4 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,3502 +1,3503 @@
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 "kosyncprefsdialog.h" 61#include "kosyncprefsdialog.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 66
67#include <libkcal/vcaldrag.h> 67#include <libkcal/vcaldrag.h>
68#include <libkcal/icaldrag.h> 68#include <libkcal/icaldrag.h>
69#include <libkcal/icalformat.h> 69#include <libkcal/icalformat.h>
70#include <libkcal/vcalformat.h> 70#include <libkcal/vcalformat.h>
71#include <libkcal/scheduler.h> 71#include <libkcal/scheduler.h>
72#include <libkcal/calendarlocal.h> 72#include <libkcal/calendarlocal.h>
73#include <libkcal/journal.h> 73#include <libkcal/journal.h>
74#include <libkcal/calfilter.h> 74#include <libkcal/calfilter.h>
75#include <libkcal/attendee.h> 75#include <libkcal/attendee.h>
76#include <libkcal/dndfactory.h> 76#include <libkcal/dndfactory.h>
77#include <libkcal/freebusy.h> 77#include <libkcal/freebusy.h>
78#include <libkcal/filestorage.h> 78#include <libkcal/filestorage.h>
79#include <libkcal/calendarresources.h> 79#include <libkcal/calendarresources.h>
80#include <libkcal/qtopiaformat.h> 80#include <libkcal/qtopiaformat.h>
81#include "../kalarmd/alarmdialog.h" 81#include "../kalarmd/alarmdialog.h"
82 82
83#ifndef DESKTOP_VERSION 83#ifndef DESKTOP_VERSION
84#include <libkcal/sharpformat.h> 84#include <libkcal/sharpformat.h>
85#endif 85#endif
86#ifndef KORG_NOMAIL 86#ifndef KORG_NOMAIL
87#include "komailclient.h" 87#include "komailclient.h"
88#endif 88#endif
89#ifndef KORG_NOPRINTER 89#ifndef KORG_NOPRINTER
90#include "calprinter.h" 90#include "calprinter.h"
91#endif 91#endif
92#ifndef KORG_NOPLUGINS 92#ifndef KORG_NOPLUGINS
93#include "kocore.h" 93#include "kocore.h"
94#endif 94#endif
95#include "koeventeditor.h" 95#include "koeventeditor.h"
96#include "kotodoeditor.h" 96#include "kotodoeditor.h"
97#include "koprefs.h" 97#include "koprefs.h"
98#include "koeventviewerdialog.h" 98#include "koeventviewerdialog.h"
99#include "publishdialog.h" 99#include "publishdialog.h"
100#include "kofilterview.h" 100#include "kofilterview.h"
101#include "koglobals.h" 101#include "koglobals.h"
102#include "koviewmanager.h" 102#include "koviewmanager.h"
103#include "koagendaview.h" 103#include "koagendaview.h"
104#include "kodialogmanager.h" 104#include "kodialogmanager.h"
105#include "outgoingdialog.h" 105#include "outgoingdialog.h"
106#include "incomingdialog.h" 106#include "incomingdialog.h"
107#include "statusdialog.h" 107#include "statusdialog.h"
108#include "kdatenavigator.h" 108#include "kdatenavigator.h"
109#include "kotodoview.h" 109#include "kotodoview.h"
110#include "datenavigator.h" 110#include "datenavigator.h"
111#include "resourceview.h" 111#include "resourceview.h"
112#include "navigatorbar.h" 112#include "navigatorbar.h"
113#include "searchdialog.h" 113#include "searchdialog.h"
114#include "mainwindow.h" 114#include "mainwindow.h"
115 115
116#include "calendarview.h" 116#include "calendarview.h"
117#ifndef DESKTOP_VERSION 117#ifndef DESKTOP_VERSION
118#include <qtopia/alarmserver.h> 118#include <qtopia/alarmserver.h>
119#endif 119#endif
120#ifndef _WIN32_ 120#ifndef _WIN32_
121#include <stdlib.h> 121#include <stdlib.h>
122#include <stdio.h> 122#include <stdio.h>
123#include <unistd.h> 123#include <unistd.h>
124#else 124#else
125#include <qprocess.h> 125#include <qprocess.h>
126#endif 126#endif
127using namespace KOrg; 127using namespace KOrg;
128using namespace KCal; 128using namespace KCal;
129extern int globalFlagBlockAgenda; 129extern int globalFlagBlockAgenda;
130extern int globalFlagBlockStartup; 130extern int globalFlagBlockStartup;
131 131
132#define SYNC_MODE_NORMAL 0 132
133#define SYNC_MODE_SHARP 1
134#define SYNC_MODE_QTOPIA 2
135 133
136class KOBeamPrefs : public QDialog 134class KOBeamPrefs : public QDialog
137{ 135{
138 public: 136 public:
139 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 137 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
140 QDialog( parent, name, true ) 138 QDialog( parent, name, true )
141 { 139 {
142 setCaption( i18n("Beam Options") ); 140 setCaption( i18n("Beam Options") );
143 QVBoxLayout* lay = new QVBoxLayout( this ); 141 QVBoxLayout* lay = new QVBoxLayout( this );
144 lay->setSpacing( 3 ); 142 lay->setSpacing( 3 );
145 lay->setMargin( 3 ); 143 lay->setMargin( 3 );
146 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 144 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
147 lay->addWidget( format ); 145 lay->addWidget( format );
148 format->setExclusive ( true ) ; 146 format->setExclusive ( true ) ;
149 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 147 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
150 lay->addWidget( time ); time->setExclusive ( true ) ; 148 lay->addWidget( time ); time->setExclusive ( true ) ;
151 vcal = new QRadioButton(" vCalendar ", format ); 149 vcal = new QRadioButton(" vCalendar ", format );
152 ical = new QRadioButton(" iCalendar ", format ); 150 ical = new QRadioButton(" iCalendar ", format );
153 vcal->setChecked( true ); 151 vcal->setChecked( true );
154 tz = new QRadioButton(i18n(" With timezone "), time ); 152 tz = new QRadioButton(i18n(" With timezone "), time );
155 local = new QRadioButton(i18n(" Local time "), time ); 153 local = new QRadioButton(i18n(" Local time "), time );
156 tz->setChecked( true ); 154 tz->setChecked( true );
157 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 155 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
158 lay->addWidget( ok ); 156 lay->addWidget( ok );
159 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 157 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
160 lay->addWidget( cancel ); 158 lay->addWidget( cancel );
161 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 159 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
162 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 160 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
163 resize( 200, 200 ); 161 resize( 200, 200 );
164 } 162 }
165 163
166 bool beamVcal() { return vcal->isChecked(); } 164 bool beamVcal() { return vcal->isChecked(); }
167 bool beamLocal() { return local->isChecked(); } 165 bool beamLocal() { return local->isChecked(); }
168private: 166private:
169 QRadioButton* vcal, *ical, *local, *tz; 167 QRadioButton* vcal, *ical, *local, *tz;
170}; 168};
171class KOCatPrefs : public QDialog 169class KOCatPrefs : public QDialog
172{ 170{
173 public: 171 public:
174 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 172 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
175 QDialog( parent, name, true ) 173 QDialog( parent, name, true )
176 { 174 {
177 setCaption( i18n("Manage new Categories") ); 175 setCaption( i18n("Manage new Categories") );
178 QVBoxLayout* lay = new QVBoxLayout( this ); 176 QVBoxLayout* lay = new QVBoxLayout( this );
179 lay->setSpacing( 3 ); 177 lay->setSpacing( 3 );
180 lay->setMargin( 3 ); 178 lay->setMargin( 3 );
181 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 ); 179 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 );
182 lay->addWidget( lab ); 180 lay->addWidget( lab );
183 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 181 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
184 lay->addWidget( format ); 182 lay->addWidget( format );
185 format->setExclusive ( true ) ; 183 format->setExclusive ( true ) ;
186 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 184 addCatBut = new QRadioButton(i18n("Add to category list"), format );
187 new QRadioButton(i18n("Remove from Events/Todos"), format ); 185 new QRadioButton(i18n("Remove from Events/Todos"), format );
188 addCatBut->setChecked( true ); 186 addCatBut->setChecked( true );
189 QPushButton * ok = new QPushButton( i18n("OK"), this ); 187 QPushButton * ok = new QPushButton( i18n("OK"), this );
190 lay->addWidget( ok ); 188 lay->addWidget( ok );
191 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 189 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
192 lay->addWidget( cancel ); 190 lay->addWidget( cancel );
193 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 191 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
194 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 192 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
195 resize( 200, 200 ); 193 resize( 200, 200 );
196 } 194 }
197 195
198 bool addCat() { return addCatBut->isChecked(); } 196 bool addCat() { return addCatBut->isChecked(); }
199private: 197private:
200 QRadioButton* addCatBut; 198 QRadioButton* addCatBut;
201}; 199};
202 200
203 201
204 202
205CalendarView::CalendarView( CalendarResources *calendar, 203CalendarView::CalendarView( CalendarResources *calendar,
206 QWidget *parent, const char *name ) 204 QWidget *parent, const char *name )
207 : CalendarViewBase( parent, name ), 205 : CalendarViewBase( parent, name ),
208 mCalendar( calendar ), 206 mCalendar( calendar ),
209 mResourceManager( calendar->resourceManager() ) 207 mResourceManager( calendar->resourceManager() )
210{ 208{
211 209
212 mEventEditor = 0; 210 mEventEditor = 0;
213 mTodoEditor = 0; 211 mTodoEditor = 0;
214 212
215 init(); 213 init();
216} 214}
217 215
218CalendarView::CalendarView( Calendar *calendar, 216CalendarView::CalendarView( Calendar *calendar,
219 QWidget *parent, const char *name ) 217 QWidget *parent, const char *name )
220 : CalendarViewBase( parent, name ), 218 : CalendarViewBase( parent, name ),
221 mCalendar( calendar ), 219 mCalendar( calendar ),
222 mResourceManager( 0 ) 220 mResourceManager( 0 )
223{ 221{
224 222
225 mEventEditor = 0; 223 mEventEditor = 0;
226 mTodoEditor = 0; 224 mTodoEditor = 0;
227 init();} 225 init();}
228 226
229void CalendarView::init() 227void CalendarView::init()
230{ 228{
231 beamDialog = new KOBeamPrefs(); 229 beamDialog = new KOBeamPrefs();
232 mDatePickerMode = 0; 230 mDatePickerMode = 0;
233 mCurrentSyncDevice = ""; 231 mCurrentSyncDevice = "";
234 writeLocale(); 232 writeLocale();
235 mViewManager = new KOViewManager( this ); 233 mViewManager = new KOViewManager( this );
236 mDialogManager = new KODialogManager( this ); 234 mDialogManager = new KODialogManager( this );
237 mEventViewerDialog = 0; 235 mEventViewerDialog = 0;
238 mModified = false; 236 mModified = false;
239 mReadOnly = false; 237 mReadOnly = false;
240 mSelectedIncidence = 0; 238 mSelectedIncidence = 0;
241 mSyncProfiles.setAutoDelete(true); 239 mSyncProfiles.setAutoDelete(true);
242 mCalPrinter = 0; 240 mCalPrinter = 0;
243 mFilters.setAutoDelete(true); 241 mFilters.setAutoDelete(true);
244 242
245 mCalendar->registerObserver( this ); 243 mCalendar->registerObserver( this );
246 // TODO: Make sure that view is updated, when calendar is changed. 244 // TODO: Make sure that view is updated, when calendar is changed.
247 245
248 mStorage = new FileStorage( mCalendar ); 246 mStorage = new FileStorage( mCalendar );
249 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 247 mNavigator = new DateNavigator( this, "datevav", mViewManager );
250 248
251 QBoxLayout *topLayout = (QBoxLayout*)layout(); 249 QBoxLayout *topLayout = (QBoxLayout*)layout();
252#ifndef KORG_NOSPLITTER 250#ifndef KORG_NOSPLITTER
253 // create the main layout frames. 251 // create the main layout frames.
254 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 252 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
255 topLayout->addWidget(mPanner); 253 topLayout->addWidget(mPanner);
256 254
257 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 255 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
258 "CalendarView::LeftFrame"); 256 "CalendarView::LeftFrame");
259 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 257 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
260 258
261 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, 259 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE,
262 "CalendarView::DateNavigator", QDate::currentDate() ); 260 "CalendarView::DateNavigator", QDate::currentDate() );
263 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 261 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
264 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 262 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
265 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 263 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
266 264
267#ifdef KORG_NORESOURCEVIEW 265#ifdef KORG_NORESOURCEVIEW
268 mResourceView = 0; 266 mResourceView = 0;
269#else 267#else
270 if ( mResourceManager ) { 268 if ( mResourceManager ) {
271 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 269 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
272 mResourceView->updateView(); 270 mResourceView->updateView();
273 connect( mResourceView, SIGNAL( resourcesChanged() ), 271 connect( mResourceView, SIGNAL( resourcesChanged() ),
274 SLOT( updateView() ) ); 272 SLOT( updateView() ) );
275 } else { 273 } else {
276 mResourceView = 0; 274 mResourceView = 0;
277 } 275 }
278#endif 276#endif
279 QWidget *rightBox = new QWidget( mPanner ); 277 QWidget *rightBox = new QWidget( mPanner );
280 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 278 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
281 279
282 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 280 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
283 rightLayout->addWidget( mNavigatorBar ); 281 rightLayout->addWidget( mNavigatorBar );
284 282
285 mRightFrame = new QWidgetStack( rightBox ); 283 mRightFrame = new QWidgetStack( rightBox );
286 rightLayout->addWidget( mRightFrame, 1 ); 284 rightLayout->addWidget( mRightFrame, 1 );
287 285
288 mLeftFrame = mLeftSplitter; 286 mLeftFrame = mLeftSplitter;
289#else 287#else
290 QWidget *mainBox = new QWidget( this ); 288 QWidget *mainBox = new QWidget( this );
291 QWidget *leftFrame = new QWidget( mainBox ); 289 QWidget *leftFrame = new QWidget( mainBox );
292 290
293 QBoxLayout * mainBoxLayout; 291 QBoxLayout * mainBoxLayout;
294 QBoxLayout * leftFrameLayout; 292 QBoxLayout * leftFrameLayout;
295 if ( KOPrefs::instance()->mVerticalScreen ) { 293 if ( KOPrefs::instance()->mVerticalScreen ) {
296 mainBoxLayout = new QVBoxLayout(mainBox); 294 mainBoxLayout = new QVBoxLayout(mainBox);
297 leftFrameLayout = new QHBoxLayout(leftFrame ); 295 leftFrameLayout = new QHBoxLayout(leftFrame );
298 } else { 296 } else {
299 mainBoxLayout = new QHBoxLayout(mainBox); 297 mainBoxLayout = new QHBoxLayout(mainBox);
300 leftFrameLayout = new QVBoxLayout(leftFrame ); 298 leftFrameLayout = new QVBoxLayout(leftFrame );
301 } 299 }
302 topLayout->addWidget( mainBox ); 300 topLayout->addWidget( mainBox );
303 mainBoxLayout->addWidget (leftFrame); 301 mainBoxLayout->addWidget (leftFrame);
304 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, 302 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE,
305 "CalendarView::DateNavigator", QDate::currentDate()); 303 "CalendarView::DateNavigator", QDate::currentDate());
306 // mDateNavigator->blockSignals( true ); 304 // mDateNavigator->blockSignals( true );
307 leftFrameLayout->addWidget( mDateNavigator ); 305 leftFrameLayout->addWidget( mDateNavigator );
308 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); 306 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView");
309 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist"); 307 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist");
310 308
311 if ( QApplication::desktop()->width() < 480 ) { 309 if ( QApplication::desktop()->width() < 480 ) {
312 leftFrameLayout->addWidget(mFilterView); 310 leftFrameLayout->addWidget(mFilterView);
313 leftFrameLayout->addWidget(mTodoList, 2 ); 311 leftFrameLayout->addWidget(mTodoList, 2 );
314 312
315 } else { 313 } else {
316 leftFrameLayout->addWidget(mTodoList,2 ); 314 leftFrameLayout->addWidget(mTodoList,2 );
317 leftFrameLayout->addWidget(mFilterView ); 315 leftFrameLayout->addWidget(mFilterView );
318 } 316 }
319 mFilterView->hide(); 317 mFilterView->hide();
320 QWidget *rightBox = new QWidget( mainBox ); 318 QWidget *rightBox = new QWidget( mainBox );
321 mainBoxLayout->addWidget ( rightBox, 10 ); 319 mainBoxLayout->addWidget ( rightBox, 10 );
322 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 320 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
323 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 321 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
324 mRightFrame = new QWidgetStack( rightBox ); 322 mRightFrame = new QWidgetStack( rightBox );
325 rightLayout->addWidget( mNavigatorBar ); 323 rightLayout->addWidget( mNavigatorBar );
326 rightLayout->addWidget( mRightFrame, 10 ); 324 rightLayout->addWidget( mRightFrame, 10 );
327 325
328 mLeftFrame = leftFrame; 326 mLeftFrame = leftFrame;
329 if ( KOPrefs::instance()->mVerticalScreen ) { 327 if ( KOPrefs::instance()->mVerticalScreen ) {
330 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 328 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
331 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 329 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
332 } else { 330 } else {
333 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 331 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
334 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 332 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
335 } 333 }
336 334
337 //qDebug("Calendarview Size %d %d ", width(), height()); 335 //qDebug("Calendarview Size %d %d ", width(), height());
338#endif 336#endif
339 337
340 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 338 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
341 SLOT( showDates( const KCal::DateList & ) ) ); 339 SLOT( showDates( const KCal::DateList & ) ) );
342 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 340 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
343 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 341 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
344 342
345 connect( mNavigatorBar, SIGNAL( goPrevYear() ), 343 connect( mNavigatorBar, SIGNAL( goPrevYear() ),
346 mNavigator, SLOT( selectPreviousYear() ) ); 344 mNavigator, SLOT( selectPreviousYear() ) );
347 connect( mNavigatorBar, SIGNAL( goNextYear() ), 345 connect( mNavigatorBar, SIGNAL( goNextYear() ),
348 mNavigator, SLOT( selectNextYear() ) ); 346 mNavigator, SLOT( selectNextYear() ) );
349 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), 347 connect( mNavigatorBar, SIGNAL( goPrevMonth() ),
350 mNavigator, SLOT( selectPreviousMonth() ) ); 348 mNavigator, SLOT( selectPreviousMonth() ) );
351 connect( mNavigatorBar, SIGNAL( goNextMonth() ), 349 connect( mNavigatorBar, SIGNAL( goNextMonth() ),
352 mNavigator, SLOT( selectNextMonth() ) ); 350 mNavigator, SLOT( selectNextMonth() ) );
353 351
354 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 352 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
355 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); 353 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) );
356 354
357 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 355 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
358 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 356 mNavigator, SLOT( selectWeek( const QDate & ) ) );
359 357
360 connect( mDateNavigator, SIGNAL( goPrevYear() ), 358 connect( mDateNavigator, SIGNAL( goPrevYear() ),
361 mNavigator, SLOT( selectPreviousYear() ) ); 359 mNavigator, SLOT( selectPreviousYear() ) );
362 connect( mDateNavigator, SIGNAL( goNextYear() ), 360 connect( mDateNavigator, SIGNAL( goNextYear() ),
363 mNavigator, SLOT( selectNextYear() ) ); 361 mNavigator, SLOT( selectNextYear() ) );
364 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 362 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
365 mNavigator, SLOT( selectPreviousMonth() ) ); 363 mNavigator, SLOT( selectPreviousMonth() ) );
366 connect( mDateNavigator, SIGNAL( goNextMonth() ), 364 connect( mDateNavigator, SIGNAL( goNextMonth() ),
367 mNavigator, SLOT( selectNextMonth() ) ); 365 mNavigator, SLOT( selectNextMonth() ) );
368 366
369 connect( mDateNavigator, SIGNAL( goPrevious() ), 367 connect( mDateNavigator, SIGNAL( goPrevious() ),
370 mNavigator, SLOT( selectPrevious() ) ); 368 mNavigator, SLOT( selectPrevious() ) );
371 connect( mDateNavigator, SIGNAL( goNext() ), 369 connect( mDateNavigator, SIGNAL( goNext() ),
372 mNavigator, SLOT( selectNext() ) ); 370 mNavigator, SLOT( selectNext() ) );
373 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 371 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
374 mNavigator, SLOT( slotMonthSelect( int ) ) ); 372 mNavigator, SLOT( slotMonthSelect( int ) ) );
375 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), 373 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ),
376 mNavigator, SLOT( slotMonthSelect( int ) ) ); 374 mNavigator, SLOT( slotMonthSelect( int ) ) );
377 375
378 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 376 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
379 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 377 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
380 378
381 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 379 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
382 SLOT( eventAdded( Event *) ) ); 380 SLOT( eventAdded( Event *) ) );
383 381
384 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 382 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
385 383
386 connect( this, SIGNAL( configChanged() ), 384 connect( this, SIGNAL( configChanged() ),
387 mDateNavigator, SLOT( updateConfig() ) ); 385 mDateNavigator, SLOT( updateConfig() ) );
388 386
389 connect( mTodoList, SIGNAL( newTodoSignal() ), 387 connect( mTodoList, SIGNAL( newTodoSignal() ),
390 SLOT( newTodo() ) ); 388 SLOT( newTodo() ) );
391 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 389 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
392 SLOT( newSubTodo( Todo * ) ) ); 390 SLOT( newSubTodo( Todo * ) ) );
393 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 391 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
394 SLOT( editTodo( Todo * ) ) ); 392 SLOT( editTodo( Todo * ) ) );
395 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 393 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
396 SLOT( showTodo( Todo *) ) ); 394 SLOT( showTodo( Todo *) ) );
397 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 395 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
398 SLOT( deleteTodo( Todo *) ) ); 396 SLOT( deleteTodo( Todo *) ) );
399 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 397 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
400 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 398 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
401 SLOT( purgeCompleted() ) ); 399 SLOT( purgeCompleted() ) );
402 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 400 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
403 SIGNAL( todoModified( Todo *, int ) ) ); 401 SIGNAL( todoModified( Todo *, int ) ) );
404 402
405 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 403 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
406 this, SLOT ( cloneIncidence( Incidence * ) ) ); 404 this, SLOT ( cloneIncidence( Incidence * ) ) );
407 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 405 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
408 this, SLOT (cancelIncidence( Incidence * ) ) ); 406 this, SLOT (cancelIncidence( Incidence * ) ) );
409 407
410 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 408 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
411 this, SLOT ( moveIncidence( Incidence * ) ) ); 409 this, SLOT ( moveIncidence( Incidence * ) ) );
412 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 410 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
413 this, SLOT ( beamIncidence( Incidence * ) ) ); 411 this, SLOT ( beamIncidence( Incidence * ) ) );
414 412
415 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 413 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
416 this, SLOT ( todo_unsub( Todo * ) ) ); 414 this, SLOT ( todo_unsub( Todo * ) ) );
417 415
418 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 416 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
419 SLOT( updateTodo( Todo *, int ) ) ); 417 SLOT( updateTodo( Todo *, int ) ) );
420 connect( this, SIGNAL( todoModified( Todo *, int )), this, 418 connect( this, SIGNAL( todoModified( Todo *, int )), this,
421 SLOT( changeTodoDisplay( Todo *, int ) ) ); 419 SLOT( changeTodoDisplay( Todo *, int ) ) );
422 420
423 421
424 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 422 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
425 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 423 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
426 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 424 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
427 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 425 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
428 426
429 427
430 428
431 429
432 430
433 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 431 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
434 SLOT(checkClipboard())); 432 SLOT(checkClipboard()));
435 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 433 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
436 SLOT( processTodoListSelection( Incidence * ) ) ); 434 SLOT( processTodoListSelection( Incidence * ) ) );
437 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 435 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
438 436
439 // kdDebug() << "CalendarView::CalendarView() done" << endl; 437 // kdDebug() << "CalendarView::CalendarView() done" << endl;
440 438
441 mDateFrame = new QVBox(0,0,WType_Popup); 439 mDateFrame = new QVBox(0,0,WType_Popup);
442 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 440 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
443 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 441 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
444 mDateFrame->setLineWidth(3); 442 mDateFrame->setLineWidth(3);
445 mDateFrame->hide(); 443 mDateFrame->hide();
446 mDateFrame->setCaption( i18n( "Pick a date to display")); 444 mDateFrame->setCaption( i18n( "Pick a date to display"));
447 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 445 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
448 446
449 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 447 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
450 448
451 mEventEditor = mDialogManager->getEventEditor(); 449 mEventEditor = mDialogManager->getEventEditor();
452 mTodoEditor = mDialogManager->getTodoEditor(); 450 mTodoEditor = mDialogManager->getTodoEditor();
453 451
454 mFlagEditDescription = false; 452 mFlagEditDescription = false;
455 453
456 mSuspendTimer = new QTimer( this ); 454 mSuspendTimer = new QTimer( this );
457 mAlarmTimer = new QTimer( this ); 455 mAlarmTimer = new QTimer( this );
458 mRecheckAlarmTimer = new QTimer( this ); 456 mRecheckAlarmTimer = new QTimer( this );
459 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 457 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
460 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 458 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
461 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 459 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
462 mAlarmDialog = new AlarmDialog( this ); 460 mAlarmDialog = new AlarmDialog( this );
463 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 461 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
464 mAlarmDialog->setServerNotification( false ); 462 mAlarmDialog->setServerNotification( false );
465 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 463 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
466} 464}
467 465
468 466
469CalendarView::~CalendarView() 467CalendarView::~CalendarView()
470{ 468{
471 // kdDebug() << "~CalendarView()" << endl; 469 // kdDebug() << "~CalendarView()" << endl;
472 //qDebug("CalendarView::~CalendarView() "); 470 //qDebug("CalendarView::~CalendarView() ");
473 delete mDialogManager; 471 delete mDialogManager;
474 delete mViewManager; 472 delete mViewManager;
475 delete mStorage; 473 delete mStorage;
476 delete mDateFrame ; 474 delete mDateFrame ;
477 delete beamDialog; 475 delete beamDialog;
478 //kdDebug() << "~CalendarView() done" << endl; 476 //kdDebug() << "~CalendarView() done" << endl;
479} 477}
480void CalendarView::timerAlarm() 478void CalendarView::timerAlarm()
481{ 479{
482 //qDebug("CalendarView::timerAlarm() "); 480 //qDebug("CalendarView::timerAlarm() ");
483 computeAlarm(mAlarmNotification ); 481 computeAlarm(mAlarmNotification );
484} 482}
485 483
486void CalendarView::suspendAlarm() 484void CalendarView::suspendAlarm()
487{ 485{
488 //qDebug(" CalendarView::suspendAlarm() "); 486 //qDebug(" CalendarView::suspendAlarm() ");
489 computeAlarm(mSuspendAlarmNotification ); 487 computeAlarm(mSuspendAlarmNotification );
490 488
491} 489}
492 490
493void CalendarView::startAlarm( QString mess , QString filename) 491void CalendarView::startAlarm( QString mess , QString filename)
494{ 492{
495 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 493 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
496 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 494 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
497 495
498} 496}
499 497
500void CalendarView::checkNextTimerAlarm() 498void CalendarView::checkNextTimerAlarm()
501{ 499{
502 mCalendar->checkAlarmForIncidence( 0, true ); 500 mCalendar->checkAlarmForIncidence( 0, true );
503} 501}
504 502
505void CalendarView::computeAlarm( QString msg ) 503void CalendarView::computeAlarm( QString msg )
506{ 504{
507 505
508 QString mess = msg; 506 QString mess = msg;
509 QString mAlarmMessage = mess.mid( 9 ); 507 QString mAlarmMessage = mess.mid( 9 );
510 QString filename = MainWindow::resourcePath(); 508 QString filename = MainWindow::resourcePath();
511 filename += "koalarm.wav"; 509 filename += "koalarm.wav";
512 QString tempfilename; 510 QString tempfilename;
513 if ( mess.left( 13 ) == "suspend_alarm") { 511 if ( mess.left( 13 ) == "suspend_alarm") {
514 bool error = false; 512 bool error = false;
515 int len = mess.mid( 13 ).find("+++"); 513 int len = mess.mid( 13 ).find("+++");
516 if ( len < 2 ) 514 if ( len < 2 )
517 error = true; 515 error = true;
518 else { 516 else {
519 tempfilename = mess.mid( 13, len ); 517 tempfilename = mess.mid( 13, len );
520 if ( !QFile::exists( tempfilename ) ) 518 if ( !QFile::exists( tempfilename ) )
521 error = true; 519 error = true;
522 } 520 }
523 if ( ! error ) { 521 if ( ! error ) {
524 filename = tempfilename; 522 filename = tempfilename;
525 } 523 }
526 mAlarmMessage = mess.mid( 13+len+3 ); 524 mAlarmMessage = mess.mid( 13+len+3 );
527 //qDebug("suspend file %s ",tempfilename.latin1() ); 525 //qDebug("suspend file %s ",tempfilename.latin1() );
528 startAlarm( mAlarmMessage, filename); 526 startAlarm( mAlarmMessage, filename);
529 return; 527 return;
530 } 528 }
531 if ( mess.left( 11 ) == "timer_alarm") { 529 if ( mess.left( 11 ) == "timer_alarm") {
532 //mTimerTime = 0; 530 //mTimerTime = 0;
533 startAlarm( mess.mid( 11 ), filename ); 531 startAlarm( mess.mid( 11 ), filename );
534 return; 532 return;
535 } 533 }
536 if ( mess.left( 10 ) == "proc_alarm") { 534 if ( mess.left( 10 ) == "proc_alarm") {
537 bool error = false; 535 bool error = false;
538 int len = mess.mid( 10 ).find("+++"); 536 int len = mess.mid( 10 ).find("+++");
539 if ( len < 2 ) 537 if ( len < 2 )
540 error = true; 538 error = true;
541 else { 539 else {
542 tempfilename = mess.mid( 10, len ); 540 tempfilename = mess.mid( 10, len );
543 if ( !QFile::exists( tempfilename ) ) 541 if ( !QFile::exists( tempfilename ) )
544 error = true; 542 error = true;
545 } 543 }
546 if ( error ) { 544 if ( error ) {
547 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 545 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
548 mAlarmMessage += mess.mid( 10+len+3+9 ); 546 mAlarmMessage += mess.mid( 10+len+3+9 );
549 } else { 547 } else {
550 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 548 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
551 //qDebug("-----system command %s ",tempfilename.latin1() ); 549 //qDebug("-----system command %s ",tempfilename.latin1() );
552#ifndef _WIN32_ 550#ifndef _WIN32_
553 if ( vfork () == 0 ) { 551 if ( vfork () == 0 ) {
554 execl ( tempfilename.latin1(), 0 ); 552 execl ( tempfilename.latin1(), 0 );
555 return; 553 return;
556 } 554 }
557#else 555#else
558 QProcess* p = new QProcess(); 556 QProcess* p = new QProcess();
559 p->addArgument( tempfilename.latin1() ); 557 p->addArgument( tempfilename.latin1() );
560 p->start(); 558 p->start();
561 return; 559 return;
562#endif 560#endif
563 561
564 return; 562 return;
565 } 563 }
566 564
567 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 565 //qDebug("+++++++system command %s ",tempfilename.latin1() );
568 } 566 }
569 if ( mess.left( 11 ) == "audio_alarm") { 567 if ( mess.left( 11 ) == "audio_alarm") {
570 bool error = false; 568 bool error = false;
571 int len = mess.mid( 11 ).find("+++"); 569 int len = mess.mid( 11 ).find("+++");
572 if ( len < 2 ) 570 if ( len < 2 )
573 error = true; 571 error = true;
574 else { 572 else {
575 tempfilename = mess.mid( 11, len ); 573 tempfilename = mess.mid( 11, len );
576 if ( !QFile::exists( tempfilename ) ) 574 if ( !QFile::exists( tempfilename ) )
577 error = true; 575 error = true;
578 } 576 }
579 if ( ! error ) { 577 if ( ! error ) {
580 filename = tempfilename; 578 filename = tempfilename;
581 } 579 }
582 mAlarmMessage = mess.mid( 11+len+3+9 ); 580 mAlarmMessage = mess.mid( 11+len+3+9 );
583 //qDebug("audio file command %s ",tempfilename.latin1() ); 581 //qDebug("audio file command %s ",tempfilename.latin1() );
584 } 582 }
585 if ( mess.left( 9 ) == "cal_alarm") { 583 if ( mess.left( 9 ) == "cal_alarm") {
586 mAlarmMessage = mess.mid( 9 ) ; 584 mAlarmMessage = mess.mid( 9 ) ;
587 } 585 }
588 586
589 startAlarm( mAlarmMessage, filename ); 587 startAlarm( mAlarmMessage, filename );
590 588
591 589
592} 590}
593 591
594void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 592void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
595{ 593{
596 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 594 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
597 595
598 mSuspendAlarmNotification = noti; 596 mSuspendAlarmNotification = noti;
599 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 597 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
600 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 598 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
601 mSuspendTimer->start( ms , true ); 599 mSuspendTimer->start( ms , true );
602 600
603} 601}
604 602
605void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 603void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
606{ 604{
607 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 605 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
608 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 606 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
609#ifndef DESKTOP_VERSION 607#ifndef DESKTOP_VERSION
610 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 608 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
611#endif 609#endif
612 return; 610 return;
613 } 611 }
614 int maxSec; 612 int maxSec;
615 //maxSec = 5; //testing only 613 //maxSec = 5; //testing only
616 maxSec = 86400+3600; // one day+1hour 614 maxSec = 86400+3600; // one day+1hour
617 mAlarmNotification = noti; 615 mAlarmNotification = noti;
618 int sec = QDateTime::currentDateTime().secsTo( qdt ); 616 int sec = QDateTime::currentDateTime().secsTo( qdt );
619 if ( sec > maxSec ) { 617 if ( sec > maxSec ) {
620 mRecheckAlarmTimer->start( maxSec * 1000 ); 618 mRecheckAlarmTimer->start( maxSec * 1000 );
621 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 619 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
622 return; 620 return;
623 } else { 621 } else {
624 mRecheckAlarmTimer->stop(); 622 mRecheckAlarmTimer->stop();
625 } 623 }
626 //qDebug("Alarm timer started with secs: %d ", sec); 624 //qDebug("Alarm timer started with secs: %d ", sec);
627 mAlarmTimer->start( sec *1000 , true ); 625 mAlarmTimer->start( sec *1000 , true );
628 626
629} 627}
630// called by mRecheckAlarmTimer to get next alarm 628// called by mRecheckAlarmTimer to get next alarm
631// we need this, because a QTimer has only a max range of 25 days 629// we need this, because a QTimer has only a max range of 25 days
632void CalendarView::recheckTimerAlarm() 630void CalendarView::recheckTimerAlarm()
633{ 631{
634 mAlarmTimer->stop(); 632 mAlarmTimer->stop();
635 mRecheckAlarmTimer->stop(); 633 mRecheckAlarmTimer->stop();
636 mCalendar->checkAlarmForIncidence( 0, true ); 634 mCalendar->checkAlarmForIncidence( 0, true );
637} 635}
638void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 636void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
639{ 637{
640 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 638 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
641 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 639 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
642#ifndef DESKTOP_VERSION 640#ifndef DESKTOP_VERSION
643 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 641 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
644#endif 642#endif
645 return; 643 return;
646 } 644 }
647 mAlarmTimer->stop(); 645 mAlarmTimer->stop();
648} 646}
649void CalendarView::selectWeekNum ( int num ) 647void CalendarView::selectWeekNum ( int num )
650{ 648{
651 dateNavigator()->selectWeek( num ); 649 dateNavigator()->selectWeek( num );
652 mViewManager->showWeekView(); 650 mViewManager->showWeekView();
653} 651}
654KOViewManager *CalendarView::viewManager() 652KOViewManager *CalendarView::viewManager()
655{ 653{
656 return mViewManager; 654 return mViewManager;
657} 655}
658 656
659KODialogManager *CalendarView::dialogManager() 657KODialogManager *CalendarView::dialogManager()
660{ 658{
661 return mDialogManager; 659 return mDialogManager;
662} 660}
663 661
664QDate CalendarView::startDate() 662QDate CalendarView::startDate()
665{ 663{
666 DateList dates = mNavigator->selectedDates(); 664 DateList dates = mNavigator->selectedDates();
667 665
668 return dates.first(); 666 return dates.first();
669} 667}
670 668
671QDate CalendarView::endDate() 669QDate CalendarView::endDate()
672{ 670{
673 DateList dates = mNavigator->selectedDates(); 671 DateList dates = mNavigator->selectedDates();
674 672
675 return dates.last(); 673 return dates.last();
676} 674}
677 675
678 676
679void CalendarView::createPrinter() 677void CalendarView::createPrinter()
680{ 678{
681#ifndef KORG_NOPRINTER 679#ifndef KORG_NOPRINTER
682 if (!mCalPrinter) { 680 if (!mCalPrinter) {
683 mCalPrinter = new CalPrinter(this, mCalendar); 681 mCalPrinter = new CalPrinter(this, mCalendar);
684 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 682 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
685 } 683 }
686#endif 684#endif
687} 685}
688 686
689void CalendarView::confSync() 687void CalendarView::confSync()
690{ 688{
691 static KOSyncPrefsDialog* sp = 0; 689 static KOSyncPrefsDialog* sp = 0;
692 if ( ! sp ) { 690 if ( ! sp ) {
693 sp = new KOSyncPrefsDialog( this, "syncprefs", true ); 691 sp = new KOSyncPrefsDialog( this, "syncprefs", true );
694 } 692 }
695 sp->usrReadConfig(); 693 sp->usrReadConfig();
696#ifndef DESKTOP_VERSION 694#ifndef DESKTOP_VERSION
697 sp->showMaximized(); 695 sp->showMaximized();
698#else 696#else
699 sp->show(); 697 sp->show();
700#endif 698#endif
701 sp->exec(); 699 sp->exec();
702 700
703} 701}
704 702
705 703
706//KOPrefs::instance()->mWriteBackFile 704//KOPrefs::instance()->mWriteBackFile
707//KOPrefs::instance()->mWriteBackExistingOnly 705//KOPrefs::instance()->mWriteBackExistingOnly
708 706
709// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 707// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
710// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 708// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
711// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 709// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
712// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 710// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
713// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 711// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
714// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 712// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
715 713
716int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 714int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
717{ 715{
718 716
719 //void setZaurusId(int id); 717 //void setZaurusId(int id);
720 // int zaurusId() const; 718 // int zaurusId() const;
721 // void setZaurusUid(int id); 719 // void setZaurusUid(int id);
722 // int zaurusUid() const; 720 // int zaurusUid() const;
723 // void setZaurusStat(int id); 721 // void setZaurusStat(int id);
724 // int zaurusStat() const; 722 // int zaurusStat() const;
725 // 0 equal 723 // 0 equal
726 // 1 take local 724 // 1 take local
727 // 2 take remote 725 // 2 take remote
728 // 3 cancel 726 // 3 cancel
729 QDateTime lastSync = mLastCalendarSync; 727 QDateTime lastSync = mLastCalendarSync;
730 if ( mGlobalSyncMode == SYNC_MODE_SHARP ) { 728 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
731 bool remCh, locCh; 729 bool remCh, locCh;
732 remCh = ( remote->zaurusUid() != local->zaurusUid() ); 730 remCh = ( remote->zaurusUid() != local->zaurusUid() );
733 locCh = ( local->zaurusStat() != local->revision() ); 731 locCh = ( local->lastModified() > mLastCalendarSync );
734 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); 732 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() );
735 if ( !remCh && ! locCh ) { 733 if ( !remCh && ! locCh ) {
736 //qDebug("both not changed "); 734 //qDebug("both not changed ");
737 lastSync = local->lastModified().addDays(1); 735 lastSync = local->lastModified().addDays(1);
738 } else { 736 } else {
739 if ( locCh ) { 737 if ( locCh ) {
740 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() ); 738 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() );
741 lastSync = local->lastModified().addDays( -1 ); 739 lastSync = local->lastModified().addDays( -1 );
742 if ( !remCh ) 740 if ( !remCh )
743 remote->setLastModified( lastSync.addDays( -1 ) ); 741 remote->setLastModified( lastSync.addDays( -1 ) );
744 } else { 742 } else {
745 //qDebug(" not loc changed "); 743 //qDebug(" not loc changed ");
746 lastSync = local->lastModified().addDays( 1 ); 744 lastSync = local->lastModified().addDays( 1 );
747 if ( remCh ) 745 if ( remCh )
748 remote->setLastModified( lastSync.addDays( 1 ) ); 746 remote->setLastModified( lastSync.addDays( 1 ) );
749 747
750 } 748 }
751 } 749 }
752 full = true; 750 full = true;
753 if ( mode < 3 ) 751 if ( mode < SYNC_PREF_ASK )
754 mode = 3; 752 mode = SYNC_PREF_ASK;
755 } else { 753 } else {
756 if ( local->lastModified() == remote->lastModified() ) 754 if ( local->lastModified() == remote->lastModified() )
757 if ( local->revision() == remote->revision() ) 755 if ( local->revision() == remote->revision() )
758 return 0; 756 return 0;
759 757
760 } 758 }
761 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 759 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
762 760
763 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); 761 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision());
764 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 762 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
765 //full = true; //debug only 763 //full = true; //debug only
766 if ( full ) { 764 if ( full ) {
767 bool equ = false; 765 bool equ = false;
768 if ( local->type() == "Event" ) { 766 if ( local->type() == "Event" ) {
769 equ = (*((Event*) local) == *((Event*) remote)); 767 equ = (*((Event*) local) == *((Event*) remote));
770 } 768 }
771 else if ( local->type() =="Todo" ) 769 else if ( local->type() =="Todo" )
772 equ = (*((Todo*) local) == (*(Todo*) remote)); 770 equ = (*((Todo*) local) == (*(Todo*) remote));
773 else if ( local->type() =="Journal" ) 771 else if ( local->type() =="Journal" )
774 equ = (*((Journal*) local) == *((Journal*) remote)); 772 equ = (*((Journal*) local) == *((Journal*) remote));
775 if ( equ ) { 773 if ( equ ) {
776 //qDebug("equal "); 774 //qDebug("equal ");
777 if ( mGlobalSyncMode == SYNC_MODE_SHARP ) { 775 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
778 local->setZaurusUid( remote->zaurusUid() ); 776 local->setZaurusUid( remote->zaurusUid() );
779 } 777 }
780 if ( mode < 4 ) 778 if ( mode < SYNC_PREF_FORCE_LOCAL )
781 return 0; 779 return 0;
782 780
783 }//else //debug only 781 }//else //debug only
784 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 782 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
785 } 783 }
786 int result; 784 int result;
787 bool localIsNew; 785 bool localIsNew;
788 if ( full && mode < 2 ) 786 if ( full && mode < SYNC_PREF_NEWEST )
789 mode = 3; 787 mode = SYNC_PREF_ASK;
790 788
791 switch( mode ) { 789 switch( mode ) {
792 case 0: 790 case SYNC_PREF_LOCAL:
793 if ( lastSync > remote->lastModified() ) 791 if ( lastSync > remote->lastModified() )
794 return 1; 792 return 1;
795 if ( lastSync > local->lastModified() ) 793 if ( lastSync > local->lastModified() )
796 return 2; 794 return 2;
797 return 1; 795 return 1;
798 break; 796 break;
799 case 1: 797 case SYNC_PREF_REMOTE:
800 if ( lastSync > remote->lastModified() ) 798 if ( lastSync > remote->lastModified() )
801 return 1; 799 return 1;
802 if ( lastSync > local->lastModified() ) 800 if ( lastSync > local->lastModified() )
803 return 2; 801 return 2;
804 return 2; 802 return 2;
805 break; 803 break;
806 case 2: 804 case SYNC_PREF_NEWEST:
807 if ( local->lastModified() > remote->lastModified() ) 805 if ( local->lastModified() > remote->lastModified() )
808 return 1; 806 return 1;
809 else 807 else
810 return 2; 808 return 2;
811 break; 809 break;
812 case 3: 810 case SYNC_PREF_ASK:
813 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 811 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
814 if ( lastSync > remote->lastModified() ) 812 if ( lastSync > remote->lastModified() )
815 return 1; 813 return 1;
816 if ( lastSync > local->lastModified() ) 814 if ( lastSync > local->lastModified() )
817 return 2; 815 return 2;
818 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 816 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
819 localIsNew = local->lastModified() > remote->lastModified(); 817 localIsNew = local->lastModified() > remote->lastModified();
820 if ( localIsNew ) 818 if ( localIsNew )
821 getEventViewerDialog()->setColorMode( 1 ); 819 getEventViewerDialog()->setColorMode( 1 );
822 else 820 else
823 getEventViewerDialog()->setColorMode( 2 ); 821 getEventViewerDialog()->setColorMode( 2 );
824 getEventViewerDialog()->setIncidence(local); 822 getEventViewerDialog()->setIncidence(local);
825 if ( localIsNew ) 823 if ( localIsNew )
826 getEventViewerDialog()->setColorMode( 2 ); 824 getEventViewerDialog()->setColorMode( 2 );
827 else 825 else
828 getEventViewerDialog()->setColorMode( 1 ); 826 getEventViewerDialog()->setColorMode( 1 );
829 getEventViewerDialog()->addIncidence(remote); 827 getEventViewerDialog()->addIncidence(remote);
830 getEventViewerDialog()->setColorMode( 0 ); 828 getEventViewerDialog()->setColorMode( 0 );
831 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 829 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
832 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 830 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
833 getEventViewerDialog()->showMe(); 831 getEventViewerDialog()->showMe();
834 result = getEventViewerDialog()->executeS( localIsNew ); 832 result = getEventViewerDialog()->executeS( localIsNew );
835 return result; 833 return result;
836 834
837 break; 835 break;
838 case 4: 836 case SYNC_PREF_FORCE_LOCAL:
839 return 1; 837 return 1;
840 break; 838 break;
841 case 5: 839 case SYNC_PREF_FORCE_REMOTE:
842 return 2; 840 return 2;
843 break; 841 break;
844 842
845 default: 843 default:
844 // SYNC_PREF_TAKE_BOTH not implemented
846 break; 845 break;
847 } 846 }
848 return 0; 847 return 0;
849} 848}
850Event* CalendarView::getLastSyncEvent() 849Event* CalendarView::getLastSyncEvent()
851{ 850{
852 Event* lse; 851 Event* lse;
853 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 852 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
854 lse = mCalendar->event( "last-syncEvent-device-"+mCurrentSyncDevice ); 853 lse = mCalendar->event( "last-syncEvent-device-"+mCurrentSyncDevice );
855 if (!lse) { 854 if (!lse) {
856 lse = new Event(); 855 lse = new Event();
857 lse->setUid( "last-syncEvent-device-"+mCurrentSyncDevice ); 856 lse->setUid( "last-syncEvent-device-"+mCurrentSyncDevice );
858 lse->setSummary(mCurrentSyncDevice + i18n(" - sync event")); 857 lse->setSummary(mCurrentSyncDevice + i18n(" - sync event"));
859 lse->setDtStart( mLastCalendarSync ); 858 lse->setDtStart( mLastCalendarSync );
860 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 859 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
861 lse->setCategories( i18n("SyncEvent") ); 860 lse->setCategories( i18n("SyncEvent") );
862 lse->setReadOnly( true ); 861 lse->setReadOnly( true );
863 mCalendar->addEvent( lse ); 862 mCalendar->addEvent( lse );
864 } 863 }
865 864
866 return lse; 865 return lse;
867 866
868} 867}
869void CalendarView::checkSharpEvent( Event* lastSync, Incidence* toDelete ) 868void CalendarView::checkSharpEvent( Event* lastSync, Incidence* toDelete )
870{ 869{
871 if ( ! lastSync ) 870 if ( ! lastSync )
872 return; 871 return;
873 if ( toDelete->zaurusId() < 0 ) 872 if ( toDelete->zaurusId() < 0 )
874 return; 873 return;
875 if ( toDelete->type() == "Journal" ) 874 if ( toDelete->type() == "Journal" )
876 return; 875 return;
877 QString des = lastSync->description(); 876 QString des = lastSync->description();
878 QString pref = "e"; 877 QString pref = "e";
879 if ( toDelete->type() == "Todo" ) 878 if ( toDelete->type() == "Todo" )
880 pref = "t"; 879 pref = "t";
881 des += pref+ QString::number ( toDelete->zaurusId() ) + ","; 880 des += pref+ QString::number ( toDelete->zaurusId() ) + ",";
882 lastSync->setReadOnly( false ); 881 lastSync->setReadOnly( false );
883 lastSync->setDescription( des ); 882 lastSync->setDescription( des );
884 lastSync->setReadOnly( true ); 883 lastSync->setReadOnly( true );
885 884
886} 885}
887bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 886bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
888{ 887{
889 bool syncOK = true; 888 bool syncOK = true;
890 int addedEvent = 0; 889 int addedEvent = 0;
891 int addedEventR = 0; 890 int addedEventR = 0;
892 int deletedEventR = 0; 891 int deletedEventR = 0;
893 int deletedEventL = 0; 892 int deletedEventL = 0;
894 int changedLocal = 0; 893 int changedLocal = 0;
895 int changedRemote = 0; 894 int changedRemote = 0;
896 //QPtrList<Event> el = local->rawEvents(); 895 //QPtrList<Event> el = local->rawEvents();
897 Event* eventR; 896 Event* eventR;
898 QString uid; 897 QString uid;
899 int take; 898 int take;
900 Event* eventL; 899 Event* eventL;
901 Event* eventRSync; 900 Event* eventRSync;
902 Event* eventLSync; 901 Event* eventLSync;
903 Event* eventRSyncSharp = remote->event( "last-syncEvent-device-Sharp-DTM"); 902 Event* eventRSyncSharp = remote->event( "last-syncEvent-device-Sharp-DTM");
904 Event* eventLSyncSharp = local->event( "last-syncEvent-device-Sharp-DTM"); 903 Event* eventLSyncSharp = local->event( "last-syncEvent-device-Sharp-DTM");
905 bool fullDateRange = false; 904 bool fullDateRange = false;
906 mLastCalendarSync = QDateTime::currentDateTime(); 905 mLastCalendarSync = QDateTime::currentDateTime();
907 QDateTime modifiedCalendar = mLastCalendarSync;; 906 QDateTime modifiedCalendar = mLastCalendarSync;;
908 eventR = remote->event("last-syncEvent-device-"+mCurrentSyncName ); 907 eventR = remote->event("last-syncEvent-device-"+mCurrentSyncName );
909 if ( eventR ) { 908 if ( eventR ) {
910 eventRSync = (Event*) eventR->clone(); 909 eventRSync = (Event*) eventR->clone();
911 remote->deleteEvent(eventR ); 910 remote->deleteEvent(eventR );
912 911
913 } else { 912 } else {
914 fullDateRange = true; 913 fullDateRange = true;
915 eventRSync = new Event(); 914 eventRSync = new Event();
916 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 915 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
917 eventRSync->setUid("last-syncEvent-device-"+mCurrentSyncName ); 916 eventRSync->setUid("last-syncEvent-device-"+mCurrentSyncName );
918 eventRSync->setDtStart( mLastCalendarSync ); 917 eventRSync->setDtStart( mLastCalendarSync );
919 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 918 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
920 eventRSync->setCategories( i18n("SyncEvent") ); 919 eventRSync->setCategories( i18n("SyncEvent") );
921 } 920 }
922 eventLSync = getLastSyncEvent(); 921 eventLSync = getLastSyncEvent();
923 if ( eventLSync->dtStart() == mLastCalendarSync ) 922 if ( eventLSync->dtStart() == mLastCalendarSync )
924 fullDateRange = true; 923 fullDateRange = true;
925 924
926 if ( ! fullDateRange ) { 925 if ( ! fullDateRange ) {
927 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 926 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
928 927
929 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 928 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
930 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 929 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
931 fullDateRange = true; 930 fullDateRange = true;
932 } 931 }
933 } 932 }
934 if ( fullDateRange ) 933 if ( fullDateRange )
935 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 934 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
936 else 935 else
937 mLastCalendarSync = eventLSync->dtStart(); 936 mLastCalendarSync = eventLSync->dtStart();
938 // for resyncing if own file has changed 937 // for resyncing if own file has changed
939 if ( mCurrentSyncDevice == "deleteaftersync" ) { 938 if ( mCurrentSyncDevice == "deleteaftersync" ) {
940 mLastCalendarSync = loadedFileVersion; 939 mLastCalendarSync = loadedFileVersion;
941 qDebug("setting mLastCalendarSync "); 940 qDebug("setting mLastCalendarSync ");
942 } 941 }
943 //qDebug("*************************** "); 942 //qDebug("*************************** ");
944 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); 943 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() );
945 QPtrList<Incidence> er = remote->rawIncidences(); 944 QPtrList<Incidence> er = remote->rawIncidences();
946 Incidence* inR = er.first(); 945 Incidence* inR = er.first();
947 Incidence* inL; 946 Incidence* inL;
948 QProgressBar bar( er.count(),0 ); 947 QProgressBar bar( er.count(),0 );
949 bar.setCaption (i18n("Syncing - close to abort!") ); 948 bar.setCaption (i18n("Syncing - close to abort!") );
950 949
951 int w = 300; 950 int w = 300;
952 if ( QApplication::desktop()->width() < 320 ) 951 if ( QApplication::desktop()->width() < 320 )
953 w = 220; 952 w = 220;
954 int h = bar.sizeHint().height() ; 953 int h = bar.sizeHint().height() ;
955 int dw = QApplication::desktop()->width(); 954 int dw = QApplication::desktop()->width();
956 int dh = QApplication::desktop()->height(); 955 int dh = QApplication::desktop()->height();
957 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 956 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
958 bar.show(); 957 bar.show();
959 int modulo = (er.count()/10)+1; 958 int modulo = (er.count()/10)+1;
960 int incCounter = 0; 959 int incCounter = 0;
961 while ( inR ) { 960 while ( inR ) {
962 if ( ! bar.isVisible() ) 961 if ( ! bar.isVisible() )
963 return false; 962 return false;
964 if ( incCounter % modulo == 0 ) 963 if ( incCounter % modulo == 0 )
965 bar.setProgress( incCounter ); 964 bar.setProgress( incCounter );
966 ++incCounter; 965 ++incCounter;
967 uid = inR->uid(); 966 uid = inR->uid();
968 bool skipIncidence = false; 967 bool skipIncidence = false;
969 if ( uid.left(21) == QString("last-syncEvent-device") ) 968 if ( uid.left(21) == QString("last-syncEvent-device") )
970 skipIncidence = true; 969 skipIncidence = true;
971 970
972 qApp->processEvents(); 971 qApp->processEvents();
973 if ( !skipIncidence ) { 972 if ( !skipIncidence ) {
974 inL = local->incidence( uid ); 973 inL = local->incidence( uid );
975 if ( inL ) { // maybe conflict - same uid in both calendars 974 if ( inL ) { // maybe conflict - same uid in both calendars
976 int maxrev = inL->revision(); 975 int maxrev = inL->revision();
977 if ( maxrev < inR->revision() ) 976 if ( maxrev < inR->revision() )
978 maxrev = inR->revision(); 977 maxrev = inR->revision();
979 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 978 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
980 //qDebug("take %d %s ", take, inL->summary().latin1()); 979 //qDebug("take %d %s ", take, inL->summary().latin1());
981 if ( take == 3 ) 980 if ( take == 3 )
982 return false; 981 return false;
983 if ( take == 1 ) {// take local 982 if ( take == 1 ) {// take local
984 inL->setZaurusUid( inR->zaurusUid() ); 983 inL->setZaurusUid( inR->zaurusUid() );
985 remote->deleteIncidence( inR ); 984 remote->deleteIncidence( inR );
986 if ( inL->revision() < maxrev ) 985 if ( inL->revision() < maxrev )
987 inL->setRevision( maxrev ); 986 inL->setRevision( maxrev );
988 remote->addIncidence( inL->clone() ); 987 remote->addIncidence( inL->clone() );
989 ++changedRemote; 988 ++changedRemote;
990 } else { 989 } else {
991 if ( inR->revision() < maxrev ) 990 if ( inR->revision() < maxrev )
992 inR->setRevision( maxrev ); 991 inR->setRevision( maxrev );
993 local->deleteIncidence( inL ); 992 local->deleteIncidence( inL );
994 local->addIncidence( inR->clone() ); 993 local->addIncidence( inR->clone() );
995 ++changedLocal; 994 ++changedLocal;
996 } 995 }
997 } 996 }
998 } else { // no conflict 997 } else { // no conflict
999 if ( mGlobalSyncMode == SYNC_MODE_SHARP ) { 998 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1000 QString des = eventLSync->description(); 999 QString des = eventLSync->description();
1001 QString pref = "e"; 1000 QString pref = "e";
1002 if ( inR->type() == "Todo" ) 1001 if ( inR->type() == "Todo" )
1003 pref = "t"; 1002 pref = "t";
1004 if ( des.find(pref+QString::number( inR->zaurusId() ) +"," ) >= 0 && mode != 5) { // delete it 1003 if ( des.find(pref+QString::number( inR->zaurusId() ) +"," ) >= 0 && mode != 5) { // delete it
1005 inR->setZaurusStat( -3 ); 1004 inR->setZaurusStat( SYNC_TEMPSTATE_DELETE );
1006 //remote->deleteIncidence( inR ); 1005 //remote->deleteIncidence( inR );
1007 ++deletedEventR; 1006 ++deletedEventR;
1008 } else { 1007 } else {
1009 inR->setLastModified( modifiedCalendar ); 1008 inR->setLastModified( modifiedCalendar );
1010 local->addIncidence( inR->clone() ); 1009 local->addIncidence( inR->clone() );
1011 ++addedEvent; 1010 ++addedEvent;
1012 } 1011 }
1013 } else { 1012 } else {
1014 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1013 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1015 inR->setLastModified( modifiedCalendar ); 1014 inR->setLastModified( modifiedCalendar );
1016 local->addIncidence( inR->clone() ); 1015 local->addIncidence( inR->clone() );
1017 ++addedEvent; 1016 ++addedEvent;
1018 } else { 1017 } else {
1019 checkSharpEvent(eventRSyncSharp, inR); 1018 checkSharpEvent(eventRSyncSharp, inR);
1020 remote->deleteIncidence( inR ); 1019 remote->deleteIncidence( inR );
1021 ++deletedEventR; 1020 ++deletedEventR;
1022 } 1021 }
1023 } 1022 }
1024 } 1023 }
1025 } 1024 }
1026 inR = er.next(); 1025 inR = er.next();
1027 } 1026 }
1028 QPtrList<Incidence> el = local->rawIncidences(); 1027 QPtrList<Incidence> el = local->rawIncidences();
1029 inL = el.first(); 1028 inL = el.first();
1030 modulo = (el.count()/10)+1; 1029 modulo = (el.count()/10)+1;
1031 bar.setCaption (i18n("Add / remove events") ); 1030 bar.setCaption (i18n("Add / remove events") );
1032 bar.setTotalSteps ( el.count() ) ; 1031 bar.setTotalSteps ( el.count() ) ;
1033 bar.show(); 1032 bar.show();
1034 incCounter = 0; 1033 incCounter = 0;
1035 1034
1036 while ( inL ) { 1035 while ( inL ) {
1037 1036
1038 qApp->processEvents(); 1037 qApp->processEvents();
1039 if ( ! bar.isVisible() ) 1038 if ( ! bar.isVisible() )
1040 return false; 1039 return false;
1041 if ( incCounter % modulo == 0 ) 1040 if ( incCounter % modulo == 0 )
1042 bar.setProgress( incCounter ); 1041 bar.setProgress( incCounter );
1043 ++incCounter; 1042 ++incCounter;
1044 uid = inL->uid(); 1043 uid = inL->uid();
1045 bool skipIncidence = false; 1044 bool skipIncidence = false;
1046 if ( uid.left(21) == QString("last-syncEvent-device") ) 1045 if ( uid.left(21) == QString("last-syncEvent-device") )
1047 skipIncidence = true; 1046 skipIncidence = true;
1048 if ( mGlobalSyncMode == SYNC_MODE_SHARP && inL->type() == "Journal" ) 1047 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1049 skipIncidence = true; 1048 skipIncidence = true;
1050 if ( !skipIncidence ) { 1049 if ( !skipIncidence ) {
1051 inR = remote->incidence( uid ); 1050 inR = remote->incidence( uid );
1052 if ( ! inR ) { 1051 if ( ! inR ) {
1053 if ( mGlobalSyncMode == SYNC_MODE_SHARP ) { 1052 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1054 if ( inL->zaurusId() >= 0 && mode != 4 ) { 1053 if ( inL->zaurusId() >= 0 && mode != 4 ) {
1055 local->deleteIncidence( inL ); 1054 local->deleteIncidence( inL );
1056 ++deletedEventL; 1055 ++deletedEventL;
1057 } else { 1056 } else {
1058 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1057 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1059 inL->setZaurusId( -1 ); 1058 inL->setZaurusId( -1 );
1060 ++addedEventR; 1059 ++addedEventR;
1061 inL->setLastModified( modifiedCalendar ); 1060 inL->setLastModified( modifiedCalendar );
1062 remote->addIncidence( inL->clone() ); 1061 remote->addIncidence( inL->clone() );
1063 } 1062 }
1064 } 1063 }
1065 } else { 1064 } else {
1066 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1065 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1067 checkSharpEvent(eventLSyncSharp, inL); 1066 checkSharpEvent(eventLSyncSharp, inL);
1068 local->deleteIncidence( inL ); 1067 local->deleteIncidence( inL );
1069 ++deletedEventL; 1068 ++deletedEventL;
1070 } else { 1069 } else {
1071 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1070 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1072 ++addedEventR; 1071 ++addedEventR;
1073 inL->setLastModified( modifiedCalendar ); 1072 inL->setLastModified( modifiedCalendar );
1074 remote->addIncidence( inL->clone() ); 1073 remote->addIncidence( inL->clone() );
1075 } 1074 }
1076 } 1075 }
1077 } 1076 }
1078 } 1077 }
1079 } 1078 }
1080 inL = el.next(); 1079 inL = el.next();
1081 } 1080 }
1082 1081
1083 bar.hide(); 1082 bar.hide();
1084 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1083 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1085 eventLSync->setReadOnly( false ); 1084 eventLSync->setReadOnly( false );
1086 eventLSync->setDtStart( mLastCalendarSync ); 1085 eventLSync->setDtStart( mLastCalendarSync );
1087 eventRSync->setDtStart( mLastCalendarSync ); 1086 eventRSync->setDtStart( mLastCalendarSync );
1088 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1087 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1089 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1088 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1090 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1089 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1091 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1090 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1092 eventLSync->setReadOnly( true ); 1091 eventLSync->setReadOnly( true );
1093 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 1092 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
1094 remote->addEvent( eventRSync ); 1093 remote->addEvent( eventRSync );
1095 QString mes; 1094 QString mes;
1096 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 ); 1095 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 );
1097 if ( KOPrefs::instance()->mShowSyncSummary ) { 1096 if ( KOPrefs::instance()->mShowSyncSummary ) {
1098 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); 1097 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
1099 } 1098 }
1100 qDebug( mes ); 1099 qDebug( mes );
1101 mCalendar->checkAlarmForIncidence( 0, true ); 1100 mCalendar->checkAlarmForIncidence( 0, true );
1102 return syncOK; 1101 return syncOK;
1103} 1102}
1104 1103
1105void CalendarView::setSyncDevice( QString s ) 1104void CalendarView::setSyncDevice( QString s )
1106{ 1105{
1107 mCurrentSyncDevice= s; 1106 mCurrentSyncDevice= s;
1108} 1107}
1109void CalendarView::setSyncName( QString s ) 1108void CalendarView::setSyncName( QString s )
1110{ 1109{
1111 mCurrentSyncName= s; 1110 mCurrentSyncName= s;
1112} 1111}
1113bool CalendarView::syncCalendar(QString filename, int mode) 1112bool CalendarView::syncCalendar(QString filename, int mode)
1114{ 1113{
1115 mGlobalSyncMode = SYNC_MODE_NORMAL; 1114 mGlobalSyncMode = SYNC_MODE_NORMAL;
1116 CalendarLocal* calendar = new CalendarLocal(); 1115 CalendarLocal* calendar = new CalendarLocal();
1117 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1116 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1118 FileStorage* storage = new FileStorage( calendar ); 1117 FileStorage* storage = new FileStorage( calendar );
1119 bool syncOK = false; 1118 bool syncOK = false;
1120 storage->setFileName( filename ); 1119 storage->setFileName( filename );
1121 // qDebug("loading ... "); 1120 // qDebug("loading ... ");
1122 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 1121 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
1123 getEventViewerDialog()->setSyncMode( true ); 1122 getEventViewerDialog()->setSyncMode( true );
1124 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1123 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1125 getEventViewerDialog()->setSyncMode( false ); 1124 getEventViewerDialog()->setSyncMode( false );
1126 if ( syncOK ) { 1125 if ( syncOK ) {
1127 if ( KOPrefs::instance()->mWriteBackFile ) 1126 if ( KOPrefs::instance()->mWriteBackFile )
1128 { 1127 {
1129 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1128 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1130 storage->save(); 1129 storage->save();
1131 } 1130 }
1132 } 1131 }
1133 setModified( true ); 1132 setModified( true );
1134 } 1133 }
1135 delete storage; 1134 delete storage;
1136 delete calendar; 1135 delete calendar;
1137 if ( syncOK ) 1136 if ( syncOK )
1138 updateView(); 1137 updateView();
1139 return syncOK; 1138 return syncOK;
1140} 1139}
1141void CalendarView::syncSharp() 1140void CalendarView::syncSharp()
1142{ 1141{
1143#ifndef DESKTOP_VERSION 1142#ifndef DESKTOP_VERSION
1144 mGlobalSyncMode = SYNC_MODE_SHARP; 1143 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1145 //mCurrentSyncDevice = "sharp-DTM"; 1144 //mCurrentSyncDevice = "sharp-DTM";
1146 if ( KOPrefs::instance()->mAskForPreferences ) 1145 if ( KOPrefs::instance()->mAskForPreferences )
1147 edit_sync_options(); 1146 edit_sync_options();
1148 qApp->processEvents(); 1147 qApp->processEvents();
1149 CalendarLocal* calendar = new CalendarLocal(); 1148 CalendarLocal* calendar = new CalendarLocal();
1150 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1149 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1151 bool syncOK = false; 1150 bool syncOK = false;
1152 SharpFormat sharpFormat; 1151 SharpFormat sharpFormat;
1153 if ( sharpFormat.load( calendar, mCalendar ) ) { 1152 if ( sharpFormat.load( calendar, mCalendar ) ) {
1154 getEventViewerDialog()->setSyncMode( true ); 1153 getEventViewerDialog()->setSyncMode( true );
1155 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1154 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1156 getEventViewerDialog()->setSyncMode( false ); 1155 getEventViewerDialog()->setSyncMode( false );
1157 qApp->processEvents(); 1156 qApp->processEvents();
1158 if ( syncOK ) { 1157 if ( syncOK ) {
1159 if ( KOPrefs::instance()->mWriteBackFile ) 1158 if ( KOPrefs::instance()->mWriteBackFile )
1160 { 1159 {
1161 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1160 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1162 Incidence* inc = iL.first(); 1161 Incidence* inc = iL.first();
1162 /* obsolete
1163 while ( inc ) { 1163 while ( inc ) {
1164 inc->setZaurusStat( inc->revision () ); 1164 inc->setZaurusStat( inc->revision () );
1165 inc = iL.next(); 1165 inc = iL.next();
1166 } 1166 }
1167 */
1167 // pending: clean last sync event description 1168 // pending: clean last sync event description
1168 sharpFormat.save(calendar); 1169 sharpFormat.save(calendar);
1169 iL = calendar->rawIncidences(); 1170 iL = calendar->rawIncidences();
1170 inc = iL.first(); 1171 inc = iL.first();
1171 Incidence* loc; 1172 Incidence* loc;
1172 while ( inc ) { 1173 while ( inc ) {
1173 if ( inc->zaurusStat() == -4 ) { 1174 if ( inc->zaurusStat() == SYNC_TEMPSTATE_NEW_ID ) {
1174 loc = mCalendar->incidence(inc->uid() ); 1175 loc = mCalendar->incidence(inc->uid() );
1175 if ( loc ) { 1176 if ( loc ) {
1176 loc->setZaurusId( inc->zaurusId() ); 1177 loc->setZaurusId( inc->zaurusId() );
1177 loc->setZaurusUid( inc->zaurusUid() ); 1178 loc->setZaurusUid( inc->zaurusUid() );
1178 } 1179 }
1179 } 1180 }
1180 inc = iL.next(); 1181 inc = iL.next();
1181 } 1182 }
1182 Incidence* lse = getLastSyncEvent(); 1183 Incidence* lse = getLastSyncEvent();
1183 if ( lse ) { 1184 if ( lse ) {
1184 lse->setReadOnly( false ); 1185 lse->setReadOnly( false );
1185 lse->setDescription( "" ); 1186 lse->setDescription( "" );
1186 lse->setReadOnly( true ); 1187 lse->setReadOnly( true );
1187 } 1188 }
1188 } 1189 }
1189 } 1190 }
1190 setModified( true ); 1191 setModified( true );
1191 } else { 1192 } else {
1192 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1193 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1193 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1194 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1194 question, i18n("Ok")) ; 1195 question, i18n("Ok")) ;
1195 1196
1196 } 1197 }
1197 delete calendar; 1198 delete calendar;
1198 updateView(); 1199 updateView();
1199 return ;//syncOK; 1200 return ;//syncOK;
1200#endif 1201#endif
1201} 1202}
1202 1203
1203 1204
1204#include <kabc/stdaddressbook.h> 1205#include <kabc/stdaddressbook.h>
1205bool CalendarView::importBday() 1206bool CalendarView::importBday()
1206{ 1207{
1207 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1208 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1208 KABC::AddressBook::Iterator it; 1209 KABC::AddressBook::Iterator it;
1209 int count = 0; 1210 int count = 0;
1210 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1211 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1211 ++count; 1212 ++count;
1212 } 1213 }
1213 QProgressBar bar(count,0 ); 1214 QProgressBar bar(count,0 );
1214 int w = 300; 1215 int w = 300;
1215 if ( QApplication::desktop()->width() < 320 ) 1216 if ( QApplication::desktop()->width() < 320 )
1216 w = 220; 1217 w = 220;
1217 int h = bar.sizeHint().height() ; 1218 int h = bar.sizeHint().height() ;
1218 int dw = QApplication::desktop()->width(); 1219 int dw = QApplication::desktop()->width();
1219 int dh = QApplication::desktop()->height(); 1220 int dh = QApplication::desktop()->height();
1220 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1221 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1221 bar.show(); 1222 bar.show();
1222 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1223 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1223 qApp->processEvents(); 1224 qApp->processEvents();
1224 count = 0; 1225 count = 0;
1225 int addCount = 0; 1226 int addCount = 0;
1226 KCal::Attendee* a = 0; 1227 KCal::Attendee* a = 0;
1227 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1228 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1228 if ( ! bar.isVisible() ) 1229 if ( ! bar.isVisible() )
1229 return false; 1230 return false;
1230 bar.setProgress( count++ ); 1231 bar.setProgress( count++ );
1231 qApp->processEvents(); 1232 qApp->processEvents();
1232 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1233 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1233 if ( (*it).birthday().date().isValid() ){ 1234 if ( (*it).birthday().date().isValid() ){
1234 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1235 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1235 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1236 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1236 ++addCount; 1237 ++addCount;
1237 } 1238 }
1238 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1239 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1239 if ( anni.isValid() ){ 1240 if ( anni.isValid() ){
1240 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1241 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1241 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1242 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1242 ++addCount; 1243 ++addCount;
1243 } 1244 }
1244 } 1245 }
1245 updateView(); 1246 updateView();
1246 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1247 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1247 return true; 1248 return true;
1248} 1249}
1249 1250
1250bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1251bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1251{ 1252{
1252 //qDebug("addAnni "); 1253 //qDebug("addAnni ");
1253 Event * ev = new Event(); 1254 Event * ev = new Event();
1254 if ( a ) { 1255 if ( a ) {
1255 ev->addAttendee( a ); 1256 ev->addAttendee( a );
1256 } 1257 }
1257 QString kind; 1258 QString kind;
1258 if ( birthday ) 1259 if ( birthday )
1259 kind = i18n( "Birthday" ); 1260 kind = i18n( "Birthday" );
1260 else 1261 else
1261 kind = i18n( "Anniversary" ); 1262 kind = i18n( "Anniversary" );
1262 ev->setSummary( name + " - " + kind ); 1263 ev->setSummary( name + " - " + kind );
1263 ev->setOrganizer( "nobody@nowhere" ); 1264 ev->setOrganizer( "nobody@nowhere" );
1264 ev->setCategories( kind ); 1265 ev->setCategories( kind );
1265 ev->setDtStart( QDateTime(date) ); 1266 ev->setDtStart( QDateTime(date) );
1266 ev->setDtEnd( QDateTime(date) ); 1267 ev->setDtEnd( QDateTime(date) );
1267 ev->setFloats( true ); 1268 ev->setFloats( true );
1268 Recurrence * rec = ev->recurrence(); 1269 Recurrence * rec = ev->recurrence();
1269 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1270 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1270 rec->addYearlyNum( date.month() ); 1271 rec->addYearlyNum( date.month() );
1271 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1272 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1272 delete ev; 1273 delete ev;
1273 return false; 1274 return false;
1274 } 1275 }
1275 return true; 1276 return true;
1276 1277
1277} 1278}
1278bool CalendarView::importQtopia( const QString &categories, 1279bool CalendarView::importQtopia( const QString &categories,
1279 const QString &datebook, 1280 const QString &datebook,
1280 const QString &todolist ) 1281 const QString &todolist )
1281{ 1282{
1282 1283
1283 QtopiaFormat qtopiaFormat; 1284 QtopiaFormat qtopiaFormat;
1284 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1285 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1285 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1286 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1286 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1287 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1287 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1288 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1288 1289
1289 updateView(); 1290 updateView();
1290 return true; 1291 return true;
1291 1292
1292#if 0 1293#if 0
1293 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1294 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1294 mCurrentSyncDevice = "qtopia-XML"; 1295 mCurrentSyncDevice = "qtopia-XML";
1295 if ( KOPrefs::instance()->mAskForPreferences ) 1296 if ( KOPrefs::instance()->mAskForPreferences )
1296 edit_sync_options(); 1297 edit_sync_options();
1297 qApp->processEvents(); 1298 qApp->processEvents();
1298 CalendarLocal* calendar = new CalendarLocal(); 1299 CalendarLocal* calendar = new CalendarLocal();
1299 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1300 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1300 bool syncOK = false; 1301 bool syncOK = false;
1301 QtopiaFormat qtopiaFormat; 1302 QtopiaFormat qtopiaFormat;
1302 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1303 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1303 bool loadOk = true; 1304 bool loadOk = true;
1304 if ( !categories.isEmpty() ) 1305 if ( !categories.isEmpty() )
1305 loadOk = qtopiaFormat.load( calendar, categories ); 1306 loadOk = qtopiaFormat.load( calendar, categories );
1306 if ( loadOk && !datebook.isEmpty() ) 1307 if ( loadOk && !datebook.isEmpty() )
1307 loadOk = qtopiaFormat.load( calendar, datebook ); 1308 loadOk = qtopiaFormat.load( calendar, datebook );
1308 if ( loadOk && !todolist.isEmpty() ) 1309 if ( loadOk && !todolist.isEmpty() )
1309 loadOk = qtopiaFormat.load( calendar, todolist ); 1310 loadOk = qtopiaFormat.load( calendar, todolist );
1310 1311
1311 if ( loadOk ) { 1312 if ( loadOk ) {
1312 getEventViewerDialog()->setSyncMode( true ); 1313 getEventViewerDialog()->setSyncMode( true );
1313 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1314 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1314 getEventViewerDialog()->setSyncMode( false ); 1315 getEventViewerDialog()->setSyncMode( false );
1315 qApp->processEvents(); 1316 qApp->processEvents();
1316 if ( syncOK ) { 1317 if ( syncOK ) {
1317 if ( KOPrefs::instance()->mWriteBackFile ) 1318 if ( KOPrefs::instance()->mWriteBackFile )
1318 { 1319 {
1319 // write back XML file 1320 // write back XML file
1320 1321
1321 } 1322 }
1322 setModified( true ); 1323 setModified( true );
1323 } 1324 }
1324 } else { 1325 } else {
1325 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1326 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1326 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1327 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1327 question, i18n("Ok")) ; 1328 question, i18n("Ok")) ;
1328 } 1329 }
1329 delete calendar; 1330 delete calendar;
1330 updateView(); 1331 updateView();
1331 return syncOK; 1332 return syncOK;
1332 1333
1333 1334
1334#endif 1335#endif
1335 1336
1336} 1337}
1337 1338
1338void CalendarView::setSyncEventsReadOnly() 1339void CalendarView::setSyncEventsReadOnly()
1339{ 1340{
1340 Event * ev; 1341 Event * ev;
1341 QPtrList<Event> eL = mCalendar->rawEvents(); 1342 QPtrList<Event> eL = mCalendar->rawEvents();
1342 ev = eL.first(); 1343 ev = eL.first();
1343 while ( ev ) { 1344 while ( ev ) {
1344 if ( ev->uid().left(21) == QString("last-syncEvent-device") ) 1345 if ( ev->uid().left(21) == QString("last-syncEvent-device") )
1345 ev->setReadOnly( true ); 1346 ev->setReadOnly( true );
1346 ev = eL.next(); 1347 ev = eL.next();
1347 } 1348 }
1348} 1349}
1349bool CalendarView::openCalendar(QString filename, bool merge) 1350bool CalendarView::openCalendar(QString filename, bool merge)
1350{ 1351{
1351 1352
1352 if (filename.isEmpty()) { 1353 if (filename.isEmpty()) {
1353 return false; 1354 return false;
1354 } 1355 }
1355 1356
1356 if (!QFile::exists(filename)) { 1357 if (!QFile::exists(filename)) {
1357 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1358 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1358 return false; 1359 return false;
1359 } 1360 }
1360 1361
1361 globalFlagBlockAgenda = 1; 1362 globalFlagBlockAgenda = 1;
1362 if (!merge) mCalendar->close(); 1363 if (!merge) mCalendar->close();
1363 1364
1364 mStorage->setFileName( filename ); 1365 mStorage->setFileName( filename );
1365 1366
1366 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) { 1367 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) {
1367 if ( merge ) ;//setModified( true ); 1368 if ( merge ) ;//setModified( true );
1368 else { 1369 else {
1369 //setModified( true ); 1370 //setModified( true );
1370 mViewManager->setDocumentId( filename ); 1371 mViewManager->setDocumentId( filename );
1371 mDialogManager->setDocumentId( filename ); 1372 mDialogManager->setDocumentId( filename );
1372 mTodoList->setDocumentId( filename ); 1373 mTodoList->setDocumentId( filename );
1373 } 1374 }
1374 globalFlagBlockAgenda = 2; 1375 globalFlagBlockAgenda = 2;
1375 // if ( getLastSyncEvent() ) 1376 // if ( getLastSyncEvent() )
1376 // getLastSyncEvent()->setReadOnly( true ); 1377 // getLastSyncEvent()->setReadOnly( true );
1377 mCalendar->reInitAlarmSettings(); 1378 mCalendar->reInitAlarmSettings();
1378 setSyncEventsReadOnly(); 1379 setSyncEventsReadOnly();
1379 updateUnmanagedViews(); 1380 updateUnmanagedViews();
1380 updateView(); 1381 updateView();
1381 if ( filename != MainWindow::defaultFileName() ) 1382 if ( filename != MainWindow::defaultFileName() )
1382 saveCalendar( MainWindow::defaultFileName() ); 1383 saveCalendar( MainWindow::defaultFileName() );
1383 loadedFileVersion = QDateTime::currentDateTime(); 1384 loadedFileVersion = QDateTime::currentDateTime();
1384 return true; 1385 return true;
1385 } else { 1386 } else {
1386 // while failing to load, the calendar object could 1387 // while failing to load, the calendar object could
1387 // have become partially populated. Clear it out. 1388 // have become partially populated. Clear it out.
1388 if ( !merge ) mCalendar->close(); 1389 if ( !merge ) mCalendar->close();
1389 1390
1390 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1391 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1391 1392
1392 globalFlagBlockAgenda = 2; 1393 globalFlagBlockAgenda = 2;
1393 updateView(); 1394 updateView();
1394 } 1395 }
1395 return false; 1396 return false;
1396} 1397}
1397void CalendarView::setLoadedFileVersion(QDateTime dt) 1398void CalendarView::setLoadedFileVersion(QDateTime dt)
1398{ 1399{
1399 loadedFileVersion = dt; 1400 loadedFileVersion = dt;
1400} 1401}
1401bool CalendarView::checkFileChanged(QString fn) 1402bool CalendarView::checkFileChanged(QString fn)
1402{ 1403{
1403 QFileInfo finf ( fn ); 1404 QFileInfo finf ( fn );
1404 if ( !finf.exists() ) 1405 if ( !finf.exists() )
1405 return true; 1406 return true;
1406 QDateTime dt = finf.lastModified (); 1407 QDateTime dt = finf.lastModified ();
1407 if ( dt <= loadedFileVersion ) 1408 if ( dt <= loadedFileVersion )
1408 return false; 1409 return false;
1409 return true; 1410 return true;
1410 1411
1411} 1412}
1412bool CalendarView::checkFileVersion(QString fn) 1413bool CalendarView::checkFileVersion(QString fn)
1413{ 1414{
1414 QFileInfo finf ( fn ); 1415 QFileInfo finf ( fn );
1415 if ( !finf.exists() ) 1416 if ( !finf.exists() )
1416 return true; 1417 return true;
1417 QDateTime dt = finf.lastModified (); 1418 QDateTime dt = finf.lastModified ();
1418 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1419 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1419 //qDebug("file on disk version %s",dt.toString().latin1()); 1420 //qDebug("file on disk version %s",dt.toString().latin1());
1420 if ( dt <= loadedFileVersion ) 1421 if ( dt <= loadedFileVersion )
1421 return true; 1422 return true;
1422 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, false)) , 1423 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, false)) ,
1423 i18n("KO/Pi Warning"),i18n("Overwrite"), 1424 i18n("KO/Pi Warning"),i18n("Overwrite"),
1424 i18n("Sync+save")); 1425 i18n("Sync+save"));
1425 1426
1426 if ( km == KMessageBox::Cancel ) 1427 if ( km == KMessageBox::Cancel )
1427 return false; 1428 return false;
1428 if ( km == KMessageBox::Yes ) 1429 if ( km == KMessageBox::Yes )
1429 return true; 1430 return true;
1430 1431
1431 setSyncDevice("deleteaftersync" ); 1432 setSyncDevice("deleteaftersync" );
1432 KOPrefs::instance()->mAskForPreferences = true; 1433 KOPrefs::instance()->mAskForPreferences = true;
1433 KOPrefs::instance()->mSyncAlgoPrefs = 3; 1434 KOPrefs::instance()->mSyncAlgoPrefs = 3;
1434 KOPrefs::instance()->mWriteBackFile = false; 1435 KOPrefs::instance()->mWriteBackFile = false;
1435 KOPrefs::instance()->mWriteBackExistingOnly = false; 1436 KOPrefs::instance()->mWriteBackExistingOnly = false;
1436 KOPrefs::instance()->mShowSyncSummary = false; 1437 KOPrefs::instance()->mShowSyncSummary = false;
1437 syncCalendar( fn, 3 ); 1438 syncCalendar( fn, 3 );
1438 Event * e = getLastSyncEvent(); 1439 Event * e = getLastSyncEvent();
1439 mCalendar->deleteEvent ( e ); 1440 mCalendar->deleteEvent ( e );
1440 updateView(); 1441 updateView();
1441 return true; 1442 return true;
1442} 1443}
1443 1444
1444bool CalendarView::saveCalendar( QString filename ) 1445bool CalendarView::saveCalendar( QString filename )
1445{ 1446{
1446 1447
1447 // Store back all unsaved data into calendar object 1448 // Store back all unsaved data into calendar object
1448 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1449 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1449 if ( mViewManager->currentView() ) 1450 if ( mViewManager->currentView() )
1450 mViewManager->currentView()->flushView(); 1451 mViewManager->currentView()->flushView();
1451 1452
1452 //mStorage->setFileName( filename ); 1453 //mStorage->setFileName( filename );
1453 1454
1454 mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1455 mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1455 mStorage->setFileName( filename ); 1456 mStorage->setFileName( filename );
1456 bool success; 1457 bool success;
1457 success = mStorage->save(); 1458 success = mStorage->save();
1458 if ( !success ) { 1459 if ( !success ) {
1459 return false; 1460 return false;
1460 } 1461 }
1461 1462
1462 return true; 1463 return true;
1463} 1464}
1464 1465
1465void CalendarView::closeCalendar() 1466void CalendarView::closeCalendar()
1466{ 1467{
1467 1468
1468 // child windows no longer valid 1469 // child windows no longer valid
1469 emit closingDown(); 1470 emit closingDown();
1470 1471
1471 mCalendar->close(); 1472 mCalendar->close();
1472 setModified(false); 1473 setModified(false);
1473 updateView(); 1474 updateView();
1474} 1475}
1475 1476
1476void CalendarView::archiveCalendar() 1477void CalendarView::archiveCalendar()
1477{ 1478{
1478 mDialogManager->showArchiveDialog(); 1479 mDialogManager->showArchiveDialog();
1479} 1480}
1480 1481
1481 1482
1482void CalendarView::readSettings() 1483void CalendarView::readSettings()
1483{ 1484{
1484 1485
1485 1486
1486 // mViewManager->showAgendaView(); 1487 // mViewManager->showAgendaView();
1487 QString str; 1488 QString str;
1488 //qDebug("CalendarView::readSettings() "); 1489 //qDebug("CalendarView::readSettings() ");
1489 // read settings from the KConfig, supplying reasonable 1490 // read settings from the KConfig, supplying reasonable
1490 // defaults where none are to be found 1491 // defaults where none are to be found
1491 KConfig *config = KOGlobals::config(); 1492 KConfig *config = KOGlobals::config();
1492#ifndef KORG_NOSPLITTER 1493#ifndef KORG_NOSPLITTER
1493 config->setGroup("KOrganizer Geometry"); 1494 config->setGroup("KOrganizer Geometry");
1494 1495
1495 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1496 QValueList<int> sizes = config->readIntListEntry("Separator1");
1496 if (sizes.count() != 2) { 1497 if (sizes.count() != 2) {
1497 sizes << mDateNavigator->minimumSizeHint().width(); 1498 sizes << mDateNavigator->minimumSizeHint().width();
1498 sizes << 300; 1499 sizes << 300;
1499 } 1500 }
1500 mPanner->setSizes(sizes); 1501 mPanner->setSizes(sizes);
1501 1502
1502 sizes = config->readIntListEntry("Separator2"); 1503 sizes = config->readIntListEntry("Separator2");
1503 if ( ( mResourceView && sizes.count() == 4 ) || 1504 if ( ( mResourceView && sizes.count() == 4 ) ||
1504 ( !mResourceView && sizes.count() == 3 ) ) { 1505 ( !mResourceView && sizes.count() == 3 ) ) {
1505 mLeftSplitter->setSizes(sizes); 1506 mLeftSplitter->setSizes(sizes);
1506 } 1507 }
1507#endif 1508#endif
1508 globalFlagBlockAgenda = 1; 1509 globalFlagBlockAgenda = 1;
1509 mViewManager->showAgendaView(); 1510 mViewManager->showAgendaView();
1510 //mViewManager->readSettings( config ); 1511 //mViewManager->readSettings( config );
1511 mTodoList->restoreLayout(config,QString("Todo Layout")); 1512 mTodoList->restoreLayout(config,QString("Todo Layout"));
1512 readFilterSettings(config); 1513 readFilterSettings(config);
1513 config->setGroup( "Views" ); 1514 config->setGroup( "Views" );
1514 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1515 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1515 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1516 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1516 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1517 else if ( dateCount == 7 ) mNavigator->selectWeek();
1517 else mNavigator->selectDates( dateCount ); 1518 else mNavigator->selectDates( dateCount );
1518 // mViewManager->readSettings( config ); 1519 // mViewManager->readSettings( config );
1519 updateConfig(); 1520 updateConfig();
1520 globalFlagBlockAgenda = 2; 1521 globalFlagBlockAgenda = 2;
1521 mViewManager->readSettings( config ); 1522 mViewManager->readSettings( config );
1522#ifdef DESKTOP_VERSION 1523#ifdef DESKTOP_VERSION
1523 config->setGroup("WidgetLayout"); 1524 config->setGroup("WidgetLayout");
1524 QStringList list; 1525 QStringList list;
1525 list = config->readListEntry("MainLayout"); 1526 list = config->readListEntry("MainLayout");
1526 int x,y,w,h; 1527 int x,y,w,h;
1527 if ( ! list.isEmpty() ) { 1528 if ( ! list.isEmpty() ) {
1528 x = list[0].toInt(); 1529 x = list[0].toInt();
1529 y = list[1].toInt(); 1530 y = list[1].toInt();
1530 w = list[2].toInt(); 1531 w = list[2].toInt();
1531 h = list[3].toInt(); 1532 h = list[3].toInt();
1532 topLevelWidget()->setGeometry(x,y,w,h); 1533 topLevelWidget()->setGeometry(x,y,w,h);
1533 1534
1534 } else { 1535 } else {
1535 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1536 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1536 } 1537 }
1537 list = config->readListEntry("EditEventLayout"); 1538 list = config->readListEntry("EditEventLayout");
1538 if ( ! list.isEmpty() ) { 1539 if ( ! list.isEmpty() ) {
1539 x = list[0].toInt(); 1540 x = list[0].toInt();
1540 y = list[1].toInt(); 1541 y = list[1].toInt();
1541 w = list[2].toInt(); 1542 w = list[2].toInt();
1542 h = list[3].toInt(); 1543 h = list[3].toInt();
1543 mEventEditor->setGeometry(x,y,w,h); 1544 mEventEditor->setGeometry(x,y,w,h);
1544 1545
1545 } 1546 }
1546 list = config->readListEntry("EditTodoLayout"); 1547 list = config->readListEntry("EditTodoLayout");
1547 if ( ! list.isEmpty() ) { 1548 if ( ! list.isEmpty() ) {
1548 x = list[0].toInt(); 1549 x = list[0].toInt();
1549 y = list[1].toInt(); 1550 y = list[1].toInt();
1550 w = list[2].toInt(); 1551 w = list[2].toInt();
1551 h = list[3].toInt(); 1552 h = list[3].toInt();
1552 mTodoEditor->setGeometry(x,y,w,h); 1553 mTodoEditor->setGeometry(x,y,w,h);
1553 1554
1554 } 1555 }
1555 list = config->readListEntry("ViewerLayout"); 1556 list = config->readListEntry("ViewerLayout");
1556 if ( ! list.isEmpty() ) { 1557 if ( ! list.isEmpty() ) {
1557 x = list[0].toInt(); 1558 x = list[0].toInt();
1558 y = list[1].toInt(); 1559 y = list[1].toInt();
1559 w = list[2].toInt(); 1560 w = list[2].toInt();
1560 h = list[3].toInt(); 1561 h = list[3].toInt();
1561 getEventViewerDialog()->setGeometry(x,y,w,h); 1562 getEventViewerDialog()->setGeometry(x,y,w,h);
1562 } 1563 }
1563#endif 1564#endif
1564 1565
1565 1566
1566 // pending read sync settings; 1567 // pending read sync settings;
1567 mSyncProfileNames.clear(); 1568 mSyncProfileNames.clear();
1568 mSyncProfileNames << "Profile_1"; 1569 mSyncProfileNames << "Profile_1";
1569 mSyncProfileNames << "Profile_2"; 1570 mSyncProfileNames << "Profile_2";
1570 mSyncProfileNames << "Profile_3"; 1571 mSyncProfileNames << "Profile_3";
1571 mSyncProfileNames << "Profile_4"; 1572 mSyncProfileNames << "Profile_4";
1572 mSyncProfileNames << "Profile_5"; 1573 mSyncProfileNames << "Profile_5";
1573 KSyncProfile* temp = new KSyncProfile (); 1574 KSyncProfile* temp = new KSyncProfile ();
1574 temp->setName("Profile_1" ); 1575 temp->setName("Profile_1" );
1575 mSyncProfiles.append( temp ); 1576 mSyncProfiles.append( temp );
1576 temp = new KSyncProfile (); 1577 temp = new KSyncProfile ();
1577 temp->setName("Profile_2" ); 1578 temp->setName("Profile_2" );
1578 mSyncProfiles.append( temp ); 1579 mSyncProfiles.append( temp );
1579 temp = new KSyncProfile (); 1580 temp = new KSyncProfile ();
1580 temp->setName("Profile_3" ); 1581 temp->setName("Profile_3" );
1581 mSyncProfiles.append( temp ); 1582 mSyncProfiles.append( temp );
1582 temp = new KSyncProfile (); 1583 temp = new KSyncProfile ();
1583 temp->setName("Profile_4" ); 1584 temp->setName("Profile_4" );
1584 mSyncProfiles.append( temp ); 1585 mSyncProfiles.append( temp );
1585 temp = new KSyncProfile (); 1586 temp = new KSyncProfile ();
1586 temp->setName("Profile_5" ); 1587 temp->setName("Profile_5" );
1587 mSyncProfiles.append( temp ); 1588 mSyncProfiles.append( temp );
1588} 1589}
1589 1590
1590 1591
1591void CalendarView::writeSettings() 1592void CalendarView::writeSettings()
1592{ 1593{
1593 // kdDebug() << "CalendarView::writeSettings" << endl; 1594 // kdDebug() << "CalendarView::writeSettings" << endl;
1594 1595
1595 KConfig *config = KOGlobals::config(); 1596 KConfig *config = KOGlobals::config();
1596 1597
1597#ifndef KORG_NOSPLITTER 1598#ifndef KORG_NOSPLITTER
1598 config->setGroup("KOrganizer Geometry"); 1599 config->setGroup("KOrganizer Geometry");
1599 1600
1600 QValueList<int> list = mPanner->sizes(); 1601 QValueList<int> list = mPanner->sizes();
1601 config->writeEntry("Separator1",list); 1602 config->writeEntry("Separator1",list);
1602 1603
1603 list = mLeftSplitter->sizes(); 1604 list = mLeftSplitter->sizes();
1604 config->writeEntry("Separator2",list); 1605 config->writeEntry("Separator2",list);
1605#endif 1606#endif
1606 1607
1607 mViewManager->writeSettings( config ); 1608 mViewManager->writeSettings( config );
1608 mTodoList->saveLayout(config,QString("Todo Layout")); 1609 mTodoList->saveLayout(config,QString("Todo Layout"));
1609 mDialogManager->writeSettings( config ); 1610 mDialogManager->writeSettings( config );
1610 //KOPrefs::instance()->usrWriteConfig(); 1611 //KOPrefs::instance()->usrWriteConfig();
1611 KOPrefs::instance()->writeConfig(); 1612 KOPrefs::instance()->writeConfig();
1612 1613
1613 writeFilterSettings(config); 1614 writeFilterSettings(config);
1614 1615
1615 config->setGroup( "Views" ); 1616 config->setGroup( "Views" );
1616 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1617 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1617 1618
1618#ifdef DESKTOP_VERSION 1619#ifdef DESKTOP_VERSION
1619 config->setGroup("WidgetLayout"); 1620 config->setGroup("WidgetLayout");
1620 QStringList list ;//= config->readListEntry("MainLayout"); 1621 QStringList list ;//= config->readListEntry("MainLayout");
1621 int x,y,w,h; 1622 int x,y,w,h;
1622 QWidget* wid; 1623 QWidget* wid;
1623 wid = topLevelWidget(); 1624 wid = topLevelWidget();
1624 x = wid->geometry().x(); 1625 x = wid->geometry().x();
1625 y = wid->geometry().y(); 1626 y = wid->geometry().y();
1626 w = wid->width(); 1627 w = wid->width();
1627 h = wid->height(); 1628 h = wid->height();
1628 list.clear(); 1629 list.clear();
1629 list << QString::number( x ); 1630 list << QString::number( x );
1630 list << QString::number( y ); 1631 list << QString::number( y );
1631 list << QString::number( w ); 1632 list << QString::number( w );
1632 list << QString::number( h ); 1633 list << QString::number( h );
1633 config->writeEntry("MainLayout",list ); 1634 config->writeEntry("MainLayout",list );
1634 1635
1635 wid = mEventEditor; 1636 wid = mEventEditor;
1636 x = wid->geometry().x(); 1637 x = wid->geometry().x();
1637 y = wid->geometry().y(); 1638 y = wid->geometry().y();
1638 w = wid->width(); 1639 w = wid->width();
1639 h = wid->height(); 1640 h = wid->height();
1640 list.clear(); 1641 list.clear();
1641 list << QString::number( x ); 1642 list << QString::number( x );
1642 list << QString::number( y ); 1643 list << QString::number( y );
1643 list << QString::number( w ); 1644 list << QString::number( w );
1644 list << QString::number( h ); 1645 list << QString::number( h );
1645 config->writeEntry("EditEventLayout",list ); 1646 config->writeEntry("EditEventLayout",list );
1646 1647
1647 wid = mTodoEditor; 1648 wid = mTodoEditor;
1648 x = wid->geometry().x(); 1649 x = wid->geometry().x();
1649 y = wid->geometry().y(); 1650 y = wid->geometry().y();
1650 w = wid->width(); 1651 w = wid->width();
1651 h = wid->height(); 1652 h = wid->height();
1652 list.clear(); 1653 list.clear();
1653 list << QString::number( x ); 1654 list << QString::number( x );
1654 list << QString::number( y ); 1655 list << QString::number( y );
1655 list << QString::number( w ); 1656 list << QString::number( w );
1656 list << QString::number( h ); 1657 list << QString::number( h );
1657 config->writeEntry("EditTodoLayout",list ); 1658 config->writeEntry("EditTodoLayout",list );
1658 wid = getEventViewerDialog(); 1659 wid = getEventViewerDialog();
1659 x = wid->geometry().x(); 1660 x = wid->geometry().x();
1660 y = wid->geometry().y(); 1661 y = wid->geometry().y();
1661 w = wid->width(); 1662 w = wid->width();
1662 h = wid->height(); 1663 h = wid->height();
1663 list.clear(); 1664 list.clear();
1664 list << QString::number( x ); 1665 list << QString::number( x );
1665 list << QString::number( y ); 1666 list << QString::number( y );
1666 list << QString::number( w ); 1667 list << QString::number( w );
1667 list << QString::number( h ); 1668 list << QString::number( h );
1668 config->writeEntry("ViewerLayout",list ); 1669 config->writeEntry("ViewerLayout",list );
1669 wid = mDialogManager->getSearchDialog(); 1670 wid = mDialogManager->getSearchDialog();
1670 if ( wid ) { 1671 if ( wid ) {
1671 x = wid->geometry().x(); 1672 x = wid->geometry().x();
1672 y = wid->geometry().y(); 1673 y = wid->geometry().y();
1673 w = wid->width(); 1674 w = wid->width();
1674 h = wid->height(); 1675 h = wid->height();
1675 list.clear(); 1676 list.clear();
1676 list << QString::number( x ); 1677 list << QString::number( x );
1677 list << QString::number( y ); 1678 list << QString::number( y );
1678 list << QString::number( w ); 1679 list << QString::number( w );
1679 list << QString::number( h ); 1680 list << QString::number( h );
1680 config->writeEntry("SearchLayout",list ); 1681 config->writeEntry("SearchLayout",list );
1681 } 1682 }
1682#endif 1683#endif
1683 1684
1684 1685
1685 config->sync(); 1686 config->sync();
1686} 1687}
1687 1688
1688void CalendarView::readFilterSettings(KConfig *config) 1689void CalendarView::readFilterSettings(KConfig *config)
1689{ 1690{
1690 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 1691 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
1691 1692
1692 mFilters.clear(); 1693 mFilters.clear();
1693 1694
1694 config->setGroup("General"); 1695 config->setGroup("General");
1695 QStringList filterList = config->readListEntry("CalendarFilters"); 1696 QStringList filterList = config->readListEntry("CalendarFilters");
1696 1697
1697 QStringList::ConstIterator it = filterList.begin(); 1698 QStringList::ConstIterator it = filterList.begin();
1698 QStringList::ConstIterator end = filterList.end(); 1699 QStringList::ConstIterator end = filterList.end();
1699 while(it != end) { 1700 while(it != end) {
1700 // kdDebug() << " filter: " << (*it) << endl; 1701 // kdDebug() << " filter: " << (*it) << endl;
1701 1702
1702 CalFilter *filter; 1703 CalFilter *filter;
1703 filter = new CalFilter(*it); 1704 filter = new CalFilter(*it);
1704 config->setGroup("Filter_" + (*it)); 1705 config->setGroup("Filter_" + (*it));
1705 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 1706 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
1706 filter->setCriteria(config->readNumEntry("Criteria",0)); 1707 filter->setCriteria(config->readNumEntry("Criteria",0));
1707 filter->setCategoryList(config->readListEntry("CategoryList")); 1708 filter->setCategoryList(config->readListEntry("CategoryList"));
1708 mFilters.append(filter); 1709 mFilters.append(filter);
1709 1710
1710 ++it; 1711 ++it;
1711 } 1712 }
1712 1713
1713 if (mFilters.count() == 0) { 1714 if (mFilters.count() == 0) {
1714 CalFilter *filter = new CalFilter(i18n("Default")); 1715 CalFilter *filter = new CalFilter(i18n("Default"));
1715 mFilters.append(filter); 1716 mFilters.append(filter);
1716 } 1717 }
1717 mFilterView->updateFilters(); 1718 mFilterView->updateFilters();
1718 config->setGroup("FilterView"); 1719 config->setGroup("FilterView");
1719 1720
1720 mFilterView->blockSignals(true); 1721 mFilterView->blockSignals(true);
1721 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 1722 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
1722 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 1723 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
1723 mFilterView->blockSignals(false); 1724 mFilterView->blockSignals(false);
1724 // We do it manually to avoid it being done twice by the above calls 1725 // We do it manually to avoid it being done twice by the above calls
1725 updateFilter(); 1726 updateFilter();
1726} 1727}
1727 1728
1728void CalendarView::writeFilterSettings(KConfig *config) 1729void CalendarView::writeFilterSettings(KConfig *config)
1729{ 1730{
1730 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 1731 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
1731 1732
1732 QStringList filterList; 1733 QStringList filterList;
1733 1734
1734 CalFilter *filter = mFilters.first(); 1735 CalFilter *filter = mFilters.first();
1735 while(filter) { 1736 while(filter) {
1736 // kdDebug() << " fn: " << filter->name() << endl; 1737 // kdDebug() << " fn: " << filter->name() << endl;
1737 filterList << filter->name(); 1738 filterList << filter->name();
1738 config->setGroup("Filter_" + filter->name()); 1739 config->setGroup("Filter_" + filter->name());
1739 config->writeEntry("Criteria",filter->criteria()); 1740 config->writeEntry("Criteria",filter->criteria());
1740 config->writeEntry("CategoryList",filter->categoryList()); 1741 config->writeEntry("CategoryList",filter->categoryList());
1741 filter = mFilters.next(); 1742 filter = mFilters.next();
1742 } 1743 }
1743 config->setGroup("General"); 1744 config->setGroup("General");
1744 config->writeEntry("CalendarFilters",filterList); 1745 config->writeEntry("CalendarFilters",filterList);
1745 1746
1746 config->setGroup("FilterView"); 1747 config->setGroup("FilterView");
1747 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 1748 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
1748 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 1749 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
1749} 1750}
1750 1751
1751 1752
1752void CalendarView::goToday() 1753void CalendarView::goToday()
1753{ 1754{
1754 mNavigator->selectToday(); 1755 mNavigator->selectToday();
1755} 1756}
1756 1757
1757void CalendarView::goNext() 1758void CalendarView::goNext()
1758{ 1759{
1759 mNavigator->selectNext(); 1760 mNavigator->selectNext();
1760} 1761}
1761 1762
1762void CalendarView::goPrevious() 1763void CalendarView::goPrevious()
1763{ 1764{
1764 mNavigator->selectPrevious(); 1765 mNavigator->selectPrevious();
1765} 1766}
1766void CalendarView::goNextMonth() 1767void CalendarView::goNextMonth()
1767{ 1768{
1768 mNavigator->selectNextMonth(); 1769 mNavigator->selectNextMonth();
1769} 1770}
1770 1771
1771void CalendarView::goPreviousMonth() 1772void CalendarView::goPreviousMonth()
1772{ 1773{
1773 mNavigator->selectPreviousMonth(); 1774 mNavigator->selectPreviousMonth();
1774} 1775}
1775void CalendarView::writeLocale() 1776void CalendarView::writeLocale()
1776{ 1777{
1777 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 1778 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
1778 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 1779 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
1779 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 1780 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
1780 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 1781 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
1781 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 1782 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
1782 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 1783 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
1783 dummy = KOPrefs::instance()->mUserDateFormatShort; 1784 dummy = KOPrefs::instance()->mUserDateFormatShort;
1784 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 1785 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
1785 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 1786 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
1786 KOPrefs::instance()->mDaylightsavingStart, 1787 KOPrefs::instance()->mDaylightsavingStart,
1787 KOPrefs::instance()->mDaylightsavingEnd ); 1788 KOPrefs::instance()->mDaylightsavingEnd );
1788 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); 1789 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId );
1789} 1790}
1790void CalendarView::updateConfig() 1791void CalendarView::updateConfig()
1791{ 1792{
1792 writeLocale(); 1793 writeLocale();
1793 if ( KOPrefs::instance()->mUseAppColors ) 1794 if ( KOPrefs::instance()->mUseAppColors )
1794 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 1795 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
1795 emit configChanged(); 1796 emit configChanged();
1796 mTodoList->updateConfig(); 1797 mTodoList->updateConfig();
1797 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 1798 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
1798 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1799 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1799 // To make the "fill window" configurations work 1800 // To make the "fill window" configurations work
1800 //mViewManager->raiseCurrentView(); 1801 //mViewManager->raiseCurrentView();
1801} 1802}
1802 1803
1803 1804
1804void CalendarView::eventChanged(Event *event) 1805void CalendarView::eventChanged(Event *event)
1805{ 1806{
1806 changeEventDisplay(event,KOGlobals::EVENTEDITED); 1807 changeEventDisplay(event,KOGlobals::EVENTEDITED);
1807 //updateUnmanagedViews(); 1808 //updateUnmanagedViews();
1808} 1809}
1809 1810
1810void CalendarView::eventAdded(Event *event) 1811void CalendarView::eventAdded(Event *event)
1811{ 1812{
1812 changeEventDisplay(event,KOGlobals::EVENTADDED); 1813 changeEventDisplay(event,KOGlobals::EVENTADDED);
1813} 1814}
1814 1815
1815void CalendarView::eventToBeDeleted(Event *) 1816void CalendarView::eventToBeDeleted(Event *)
1816{ 1817{
1817 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 1818 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
1818} 1819}
1819 1820
1820void CalendarView::eventDeleted() 1821void CalendarView::eventDeleted()
1821{ 1822{
1822 changeEventDisplay(0,KOGlobals::EVENTDELETED); 1823 changeEventDisplay(0,KOGlobals::EVENTDELETED);
1823} 1824}
1824void CalendarView::changeTodoDisplay(Todo *which, int action) 1825void CalendarView::changeTodoDisplay(Todo *which, int action)
1825{ 1826{
1826 changeIncidenceDisplay((Incidence *)which, action); 1827 changeIncidenceDisplay((Incidence *)which, action);
1827} 1828}
1828void CalendarView::checkZaurusId( int id, bool todo ) 1829void CalendarView::checkZaurusId( int id, bool todo )
1829{ 1830{
1830 if ( id >= 0 ) { 1831 if ( id >= 0 ) {
1831 Incidence* lse = mCalendar->event( "last-syncEvent-device-Sharp-DTM"); 1832 Incidence* lse = mCalendar->event( "last-syncEvent-device-Sharp-DTM");
1832 if ( lse ) { 1833 if ( lse ) {
1833 QString des = lse->description(); 1834 QString des = lse->description();
1834 QString pref = "e"; 1835 QString pref = "e";
1835 if ( todo ) 1836 if ( todo )
1836 pref = "t"; 1837 pref = "t";
1837 des += pref+ QString::number ( id ) + ","; 1838 des += pref+ QString::number ( id ) + ",";
1838 lse->setReadOnly( false ); 1839 lse->setReadOnly( false );
1839 lse->setDescription( des ); 1840 lse->setDescription( des );
1840 lse->setReadOnly( true ); 1841 lse->setReadOnly( true );
1841 } 1842 }
1842 } 1843 }
1843} 1844}
1844void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 1845void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
1845{ 1846{
1846 updateUnmanagedViews(); 1847 updateUnmanagedViews();
1847 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 1848 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
1848 if ( action == KOGlobals::EVENTDELETED ) { //delete 1849 if ( action == KOGlobals::EVENTDELETED ) { //delete
1849 mCalendar->checkAlarmForIncidence( 0, true ); 1850 mCalendar->checkAlarmForIncidence( 0, true );
1850 if ( mEventViewerDialog ) 1851 if ( mEventViewerDialog )
1851 mEventViewerDialog->hide(); 1852 mEventViewerDialog->hide();
1852 } 1853 }
1853 else 1854 else
1854 mCalendar->checkAlarmForIncidence( which , false ); 1855 mCalendar->checkAlarmForIncidence( which , false );
1855} 1856}
1856 1857
1857// most of the changeEventDisplays() right now just call the view's 1858// most of the changeEventDisplays() right now just call the view's
1858// total update mode, but they SHOULD be recoded to be more refresh-efficient. 1859// total update mode, but they SHOULD be recoded to be more refresh-efficient.
1859void CalendarView::changeEventDisplay(Event *which, int action) 1860void CalendarView::changeEventDisplay(Event *which, int action)
1860{ 1861{
1861 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 1862 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
1862 changeIncidenceDisplay((Incidence *)which, action); 1863 changeIncidenceDisplay((Incidence *)which, action);
1863 mDateNavigator->updateView(); 1864 mDateNavigator->updateView();
1864 //mDialogManager->updateSearchDialog(); 1865 //mDialogManager->updateSearchDialog();
1865 1866
1866 if (which) { 1867 if (which) {
1867 // If there is an event view visible update the display 1868 // If there is an event view visible update the display
1868 mViewManager->currentView()->changeEventDisplay(which,action); 1869 mViewManager->currentView()->changeEventDisplay(which,action);
1869 // TODO: check, if update needed 1870 // TODO: check, if update needed
1870 // if (which->getTodoStatus()) { 1871 // if (which->getTodoStatus()) {
1871 mTodoList->updateView(); 1872 mTodoList->updateView();
1872 // } 1873 // }
1873 } else { 1874 } else {
1874 mViewManager->currentView()->updateView(); 1875 mViewManager->currentView()->updateView();
1875 } 1876 }
1876} 1877}
1877 1878
1878 1879
1879void CalendarView::updateTodoViews() 1880void CalendarView::updateTodoViews()
1880{ 1881{
1881 1882
1882 mTodoList->updateView(); 1883 mTodoList->updateView();
1883 mViewManager->currentView()->updateView(); 1884 mViewManager->currentView()->updateView();
1884 1885
1885} 1886}
1886 1887
1887 1888
1888void CalendarView::updateView(const QDate &start, const QDate &end) 1889void CalendarView::updateView(const QDate &start, const QDate &end)
1889{ 1890{
1890 mTodoList->updateView(); 1891 mTodoList->updateView();
1891 mViewManager->updateView(start, end); 1892 mViewManager->updateView(start, end);
1892 //mDateNavigator->updateView(); 1893 //mDateNavigator->updateView();
1893} 1894}
1894 1895
1895void CalendarView::updateView() 1896void CalendarView::updateView()
1896{ 1897{
1897 DateList tmpList = mNavigator->selectedDates(); 1898 DateList tmpList = mNavigator->selectedDates();
1898 1899
1899 // We assume that the navigator only selects consecutive days. 1900 // We assume that the navigator only selects consecutive days.
1900 updateView( tmpList.first(), tmpList.last() ); 1901 updateView( tmpList.first(), tmpList.last() );
1901} 1902}
1902 1903
1903void CalendarView::updateUnmanagedViews() 1904void CalendarView::updateUnmanagedViews()
1904{ 1905{
1905 mDateNavigator->updateDayMatrix(); 1906 mDateNavigator->updateDayMatrix();
1906} 1907}
1907 1908
1908int CalendarView::msgItemDelete() 1909int CalendarView::msgItemDelete()
1909{ 1910{
1910 return KMessageBox::warningContinueCancel(this, 1911 return KMessageBox::warningContinueCancel(this,
1911 i18n("This item will be\npermanently deleted."), 1912 i18n("This item will be\npermanently deleted."),
1912 i18n("KO/Pi Confirmation"),i18n("Delete")); 1913 i18n("KO/Pi Confirmation"),i18n("Delete"));
1913} 1914}
1914 1915
1915 1916
1916void CalendarView::edit_cut() 1917void CalendarView::edit_cut()
1917{ 1918{
1918 Event *anEvent=0; 1919 Event *anEvent=0;
1919 1920
1920 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 1921 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
1921 1922
1922 if (mViewManager->currentView()->isEventView()) { 1923 if (mViewManager->currentView()->isEventView()) {
1923 if ( incidence && incidence->type() == "Event" ) { 1924 if ( incidence && incidence->type() == "Event" ) {
1924 anEvent = static_cast<Event *>(incidence); 1925 anEvent = static_cast<Event *>(incidence);
1925 } 1926 }
1926 } 1927 }
1927 1928
1928 if (!anEvent) { 1929 if (!anEvent) {
1929 KNotifyClient::beep(); 1930 KNotifyClient::beep();
1930 return; 1931 return;
1931 } 1932 }
1932 DndFactory factory( mCalendar ); 1933 DndFactory factory( mCalendar );
1933 factory.cutEvent(anEvent); 1934 factory.cutEvent(anEvent);
1934 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 1935 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
1935} 1936}
1936 1937
1937void CalendarView::edit_copy() 1938void CalendarView::edit_copy()
1938{ 1939{
1939 Event *anEvent=0; 1940 Event *anEvent=0;
1940 1941
1941 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 1942 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
1942 1943
1943 if (mViewManager->currentView()->isEventView()) { 1944 if (mViewManager->currentView()->isEventView()) {
1944 if ( incidence && incidence->type() == "Event" ) { 1945 if ( incidence && incidence->type() == "Event" ) {
1945 anEvent = static_cast<Event *>(incidence); 1946 anEvent = static_cast<Event *>(incidence);
1946 } 1947 }
1947 } 1948 }
1948 1949
1949 if (!anEvent) { 1950 if (!anEvent) {
1950 KNotifyClient::beep(); 1951 KNotifyClient::beep();
1951 return; 1952 return;
1952 } 1953 }
1953 DndFactory factory( mCalendar ); 1954 DndFactory factory( mCalendar );
1954 factory.copyEvent(anEvent); 1955 factory.copyEvent(anEvent);
1955} 1956}
1956 1957
1957void CalendarView::edit_paste() 1958void CalendarView::edit_paste()
1958{ 1959{
1959 QDate date = mNavigator->selectedDates().first(); 1960 QDate date = mNavigator->selectedDates().first();
1960 1961
1961 DndFactory factory( mCalendar ); 1962 DndFactory factory( mCalendar );
1962 Event *pastedEvent = factory.pasteEvent( date ); 1963 Event *pastedEvent = factory.pasteEvent( date );
1963 1964
1964 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 1965 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
1965} 1966}
1966 1967
1967void CalendarView::edit_options() 1968void CalendarView::edit_options()
1968{ 1969{
1969 mDialogManager->showOptionsDialog(); 1970 mDialogManager->showOptionsDialog();
1970 //writeSettings(); 1971 //writeSettings();
1971} 1972}
1972void CalendarView::edit_sync_options() 1973void CalendarView::edit_sync_options()
1973{ 1974{
1974 //mDialogManager->showSyncOptions(); 1975 //mDialogManager->showSyncOptions();
1975 //KOPrefs::instance()->mSyncAlgoPrefs 1976 //KOPrefs::instance()->mSyncAlgoPrefs
1976 QDialog dia( this, "dia", true ); 1977 QDialog dia( this, "dia", true );
1977 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 1978 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
1978 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 1979 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
1979 QVBoxLayout lay ( &dia ); 1980 QVBoxLayout lay ( &dia );
1980 lay.setSpacing( 2 ); 1981 lay.setSpacing( 2 );
1981 lay.setMargin( 3 ); 1982 lay.setMargin( 3 );
1982 lay.addWidget(&gr); 1983 lay.addWidget(&gr);
1983 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 1984 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
1984 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 1985 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
1985 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 1986 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
1986 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 1987 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
1987 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 1988 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
1988 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 1989 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
1989 //QRadioButton both( i18n("Take both on conflict"), &gr ); 1990 //QRadioButton both( i18n("Take both on conflict"), &gr );
1990 QPushButton pb ( "OK", &dia); 1991 QPushButton pb ( "OK", &dia);
1991 lay.addWidget( &pb ); 1992 lay.addWidget( &pb );
1992 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 1993 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1993 switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { 1994 switch ( KOPrefs::instance()->mSyncAlgoPrefs ) {
1994 case 0: 1995 case 0:
1995 loc.setChecked( true); 1996 loc.setChecked( true);
1996 break; 1997 break;
1997 case 1: 1998 case 1:
1998 rem.setChecked( true ); 1999 rem.setChecked( true );
1999 break; 2000 break;
2000 case 2: 2001 case 2:
2001 newest.setChecked( true); 2002 newest.setChecked( true);
2002 break; 2003 break;
2003 case 3: 2004 case 3:
2004 ask.setChecked( true); 2005 ask.setChecked( true);
2005 break; 2006 break;
2006 case 4: 2007 case 4:
2007 f_loc.setChecked( true); 2008 f_loc.setChecked( true);
2008 break; 2009 break;
2009 case 5: 2010 case 5:
2010 f_rem.setChecked( true); 2011 f_rem.setChecked( true);
2011 break; 2012 break;
2012 case 6: 2013 case 6:
2013 // both.setChecked( true); 2014 // both.setChecked( true);
2014 break; 2015 break;
2015 default: 2016 default:
2016 break; 2017 break;
2017 } 2018 }
2018 if ( dia.exec() ) { 2019 if ( dia.exec() ) {
2019 KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 2020 KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
2020 } 2021 }
2021 2022
2022} 2023}
2023 2024
2024void CalendarView::slotSelectPickerDate( QDate d) 2025void CalendarView::slotSelectPickerDate( QDate d)
2025{ 2026{
2026 mDateFrame->hide(); 2027 mDateFrame->hide();
2027 if ( mDatePickerMode == 1 ) { 2028 if ( mDatePickerMode == 1 ) {
2028 mNavigator->slotDaySelect( d ); 2029 mNavigator->slotDaySelect( d );
2029 } else if ( mDatePickerMode == 2 ) { 2030 } else if ( mDatePickerMode == 2 ) {
2030 if ( mMoveIncidence->type() == "Todo" ) { 2031 if ( mMoveIncidence->type() == "Todo" ) {
2031 Todo * to = (Todo *) mMoveIncidence; 2032 Todo * to = (Todo *) mMoveIncidence;
2032 QTime tim; 2033 QTime tim;
2033 if ( to->hasDueDate() ) 2034 if ( to->hasDueDate() )
2034 tim = to->dtDue().time(); 2035 tim = to->dtDue().time();
2035 else { 2036 else {
2036 tim = QTime ( 0,0,0 ); 2037 tim = QTime ( 0,0,0 );
2037 to->setFloats( true ); 2038 to->setFloats( true );
2038 to->setHasDueDate( true ); 2039 to->setHasDueDate( true );
2039 } 2040 }
2040 QDateTime dt ( d,tim ); 2041 QDateTime dt ( d,tim );
2041 to->setDtDue( dt ); 2042 to->setDtDue( dt );
2042 todoChanged( to ); 2043 todoChanged( to );
2043 } else { 2044 } else {
2044 QTime tim = mMoveIncidence->dtStart().time(); 2045 QTime tim = mMoveIncidence->dtStart().time();
2045 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2046 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2046 QDateTime dt ( d,tim ); 2047 QDateTime dt ( d,tim );
2047 mMoveIncidence->setDtStart( dt ); 2048 mMoveIncidence->setDtStart( dt );
2048 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2049 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2049 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2050 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2050 } 2051 }
2051 2052
2052 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2053 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2053 } 2054 }
2054} 2055}
2055 2056
2056void CalendarView::removeCategories() 2057void CalendarView::removeCategories()
2057{ 2058{
2058 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2059 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2059 QStringList catList = KOPrefs::instance()->mCustomCategories; 2060 QStringList catList = KOPrefs::instance()->mCustomCategories;
2060 QStringList catIncList; 2061 QStringList catIncList;
2061 QStringList newCatList; 2062 QStringList newCatList;
2062 Incidence* inc = incList.first(); 2063 Incidence* inc = incList.first();
2063 int i; 2064 int i;
2064 int count = 0; 2065 int count = 0;
2065 while ( inc ) { 2066 while ( inc ) {
2066 newCatList.clear(); 2067 newCatList.clear();
2067 catIncList = inc->categories() ; 2068 catIncList = inc->categories() ;
2068 for( i = 0; i< catIncList.count(); ++i ) { 2069 for( i = 0; i< catIncList.count(); ++i ) {
2069 if ( catList.contains (catIncList[i])) 2070 if ( catList.contains (catIncList[i]))
2070 newCatList.append( catIncList[i] ); 2071 newCatList.append( catIncList[i] );
2071 } 2072 }
2072 newCatList.sort(); 2073 newCatList.sort();
2073 inc->setCategories( newCatList.join(",") ); 2074 inc->setCategories( newCatList.join(",") );
2074 inc = incList.next(); 2075 inc = incList.next();
2075 } 2076 }
2076} 2077}
2077 2078
2078int CalendarView::addCategories() 2079int CalendarView::addCategories()
2079{ 2080{
2080 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2081 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2081 QStringList catList = KOPrefs::instance()->mCustomCategories; 2082 QStringList catList = KOPrefs::instance()->mCustomCategories;
2082 QStringList catIncList; 2083 QStringList catIncList;
2083 Incidence* inc = incList.first(); 2084 Incidence* inc = incList.first();
2084 int i; 2085 int i;
2085 int count = 0; 2086 int count = 0;
2086 while ( inc ) { 2087 while ( inc ) {
2087 catIncList = inc->categories() ; 2088 catIncList = inc->categories() ;
2088 for( i = 0; i< catIncList.count(); ++i ) { 2089 for( i = 0; i< catIncList.count(); ++i ) {
2089 if ( !catList.contains (catIncList[i])) { 2090 if ( !catList.contains (catIncList[i])) {
2090 catList.append( catIncList[i] ); 2091 catList.append( catIncList[i] );
2091 //qDebug("add cat %s ", catIncList[i].latin1()); 2092 //qDebug("add cat %s ", catIncList[i].latin1());
2092 ++count; 2093 ++count;
2093 } 2094 }
2094 } 2095 }
2095 inc = incList.next(); 2096 inc = incList.next();
2096 } 2097 }
2097 catList.sort(); 2098 catList.sort();
2098 KOPrefs::instance()->mCustomCategories = catList; 2099 KOPrefs::instance()->mCustomCategories = catList;
2099 return count; 2100 return count;
2100} 2101}
2101 2102
2102void CalendarView::manageCategories() 2103void CalendarView::manageCategories()
2103{ 2104{
2104 KOCatPrefs* cp = new KOCatPrefs(); 2105 KOCatPrefs* cp = new KOCatPrefs();
2105 cp->show(); 2106 cp->show();
2106 int w =cp->sizeHint().width() ; 2107 int w =cp->sizeHint().width() ;
2107 int h = cp->sizeHint().height() ; 2108 int h = cp->sizeHint().height() ;
2108 int dw = QApplication::desktop()->width(); 2109 int dw = QApplication::desktop()->width();
2109 int dh = QApplication::desktop()->height(); 2110 int dh = QApplication::desktop()->height();
2110 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2111 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2111 if ( !cp->exec() ) { 2112 if ( !cp->exec() ) {
2112 delete cp; 2113 delete cp;
2113 return; 2114 return;
2114 } 2115 }
2115 int count = 0; 2116 int count = 0;
2116 if ( cp->addCat() ) { 2117 if ( cp->addCat() ) {
2117 count = addCategories(); 2118 count = addCategories();
2118 if ( count ) { 2119 if ( count ) {
2119 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2120 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2120 writeSettings(); 2121 writeSettings();
2121 } 2122 }
2122 } else { 2123 } else {
2123 removeCategories(); 2124 removeCategories();
2124 updateView(); 2125 updateView();
2125 } 2126 }
2126 delete cp; 2127 delete cp;
2127} 2128}
2128 2129
2129void CalendarView::beamIncidence(Incidence * Inc) 2130void CalendarView::beamIncidence(Incidence * Inc)
2130{ 2131{
2131 QPtrList<Incidence> delSel ; 2132 QPtrList<Incidence> delSel ;
2132 delSel.append(Inc); 2133 delSel.append(Inc);
2133 beamIncidenceList( delSel ); 2134 beamIncidenceList( delSel );
2134} 2135}
2135void CalendarView::beamCalendar() 2136void CalendarView::beamCalendar()
2136{ 2137{
2137 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2138 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2138 //qDebug("beamCalendar() "); 2139 //qDebug("beamCalendar() ");
2139 beamIncidenceList( delSel ); 2140 beamIncidenceList( delSel );
2140} 2141}
2141void CalendarView::beamFilteredCalendar() 2142void CalendarView::beamFilteredCalendar()
2142{ 2143{
2143 QPtrList<Incidence> delSel = mCalendar->incidences(); 2144 QPtrList<Incidence> delSel = mCalendar->incidences();
2144 //qDebug("beamFilteredCalendar() "); 2145 //qDebug("beamFilteredCalendar() ");
2145 beamIncidenceList( delSel ); 2146 beamIncidenceList( delSel );
2146} 2147}
2147void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2148void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2148{ 2149{
2149 if ( beamDialog->exec () == QDialog::Rejected ) 2150 if ( beamDialog->exec () == QDialog::Rejected )
2150 return; 2151 return;
2151 2152
2152 QString fn = "/tmp/kopibeamfile"; 2153 QString fn = "/tmp/kopibeamfile";
2153 QString mes; 2154 QString mes;
2154 bool createbup = true; 2155 bool createbup = true;
2155 if ( createbup ) { 2156 if ( createbup ) {
2156 QString description = "\n"; 2157 QString description = "\n";
2157 CalendarLocal* cal = new CalendarLocal(); 2158 CalendarLocal* cal = new CalendarLocal();
2158 if ( beamDialog->beamLocal() ) 2159 if ( beamDialog->beamLocal() )
2159 cal->setLocalTime(); 2160 cal->setLocalTime();
2160 else 2161 else
2161 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 2162 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
2162 Incidence *incidence = delSel.first(); 2163 Incidence *incidence = delSel.first();
2163 bool addText = false; 2164 bool addText = false;
2164 if ( delSel.count() < 10 ) 2165 if ( delSel.count() < 10 )
2165 addText = true; 2166 addText = true;
2166 else { 2167 else {
2167 description.sprintf(i18n(" %d items?"),delSel.count() ); 2168 description.sprintf(i18n(" %d items?"),delSel.count() );
2168 } 2169 }
2169 while ( incidence ) { 2170 while ( incidence ) {
2170 Incidence *in = incidence->clone(); 2171 Incidence *in = incidence->clone();
2171 if ( addText ) 2172 if ( addText )
2172 description += in->summary() + "\n"; 2173 description += in->summary() + "\n";
2173 cal->addIncidence( in ); 2174 cal->addIncidence( in );
2174 incidence = delSel.next(); 2175 incidence = delSel.next();
2175 } 2176 }
2176 if ( beamDialog->beamVcal() ) { 2177 if ( beamDialog->beamVcal() ) {
2177 fn += ".vcs"; 2178 fn += ".vcs";
2178 FileStorage storage( cal, fn, new VCalFormat ); 2179 FileStorage storage( cal, fn, new VCalFormat );
2179 storage.save(); 2180 storage.save();
2180 } else { 2181 } else {
2181 fn += ".ics"; 2182 fn += ".ics";
2182 FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 2183 FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
2183 storage.save(); 2184 storage.save();
2184 } 2185 }
2185 delete cal; 2186 delete cal;
2186 mes = i18n("KO/Pi: Ready for beaming"); 2187 mes = i18n("KO/Pi: Ready for beaming");
2187 setCaption(mes); 2188 setCaption(mes);
2188 2189
2189#ifndef DESKTOP_VERSION 2190#ifndef DESKTOP_VERSION
2190 Ir *ir = new Ir( this ); 2191 Ir *ir = new Ir( this );
2191 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2192 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2192 ir->send( fn, description, "text/x-vCalendar" ); 2193 ir->send( fn, description, "text/x-vCalendar" );
2193#endif 2194#endif
2194 } 2195 }
2195} 2196}
2196void CalendarView::beamDone( Ir *ir ) 2197void CalendarView::beamDone( Ir *ir )
2197{ 2198{
2198#ifndef DESKTOP_VERSION 2199#ifndef DESKTOP_VERSION
2199 delete ir; 2200 delete ir;
2200#endif 2201#endif
2201} 2202}
2202 2203
2203void CalendarView::moveIncidence(Incidence * inc ) 2204void CalendarView::moveIncidence(Incidence * inc )
2204{ 2205{
2205 if ( !inc ) return; 2206 if ( !inc ) return;
2206 // qDebug("showDatePickerForIncidence( ) "); 2207 // qDebug("showDatePickerForIncidence( ) ");
2207 if ( mDateFrame->isVisible() ) 2208 if ( mDateFrame->isVisible() )
2208 mDateFrame->hide(); 2209 mDateFrame->hide();
2209 else { 2210 else {
2210 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; 2211 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
2211 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; 2212 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
2212 int dw = QApplication::desktop()->width(); 2213 int dw = QApplication::desktop()->width();
2213 int dh = QApplication::desktop()->height(); 2214 int dh = QApplication::desktop()->height();
2214 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2215 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2215 mDateFrame->show(); 2216 mDateFrame->show();
2216 } 2217 }
2217 mDatePickerMode = 2; 2218 mDatePickerMode = 2;
2218 mMoveIncidence = inc ; 2219 mMoveIncidence = inc ;
2219 QDate da; 2220 QDate da;
2220 if ( mMoveIncidence->type() == "Todo" ) { 2221 if ( mMoveIncidence->type() == "Todo" ) {
2221 Todo * to = (Todo *) mMoveIncidence; 2222 Todo * to = (Todo *) mMoveIncidence;
2222 if ( to->hasDueDate() ) 2223 if ( to->hasDueDate() )
2223 da = to->dtDue().date(); 2224 da = to->dtDue().date();
2224 else 2225 else
2225 da = QDate::currentDate(); 2226 da = QDate::currentDate();
2226 } else { 2227 } else {
2227 da = mMoveIncidence->dtStart().date(); 2228 da = mMoveIncidence->dtStart().date();
2228 } 2229 }
2229 mDatePicker->setDate( da ); 2230 mDatePicker->setDate( da );
2230} 2231}
2231void CalendarView::showDatePicker( ) 2232void CalendarView::showDatePicker( )
2232{ 2233{
2233 //qDebug("CalendarView::showDatePicker( ) "); 2234 //qDebug("CalendarView::showDatePicker( ) ");
2234 if ( mDateFrame->isVisible() ) 2235 if ( mDateFrame->isVisible() )
2235 mDateFrame->hide(); 2236 mDateFrame->hide();
2236 else { 2237 else {
2237 int w =mDatePicker->sizeHint().width() ; 2238 int w =mDatePicker->sizeHint().width() ;
2238 int h = mDatePicker->sizeHint().height() ; 2239 int h = mDatePicker->sizeHint().height() ;
2239 int dw = QApplication::desktop()->width(); 2240 int dw = QApplication::desktop()->width();
2240 int dh = QApplication::desktop()->height(); 2241 int dh = QApplication::desktop()->height();
2241 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2242 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2242 mDateFrame->show(); 2243 mDateFrame->show();
2243 } 2244 }
2244 mDatePickerMode = 1; 2245 mDatePickerMode = 1;
2245 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2246 mDatePicker->setDate( mNavigator->selectedDates().first() );
2246} 2247}
2247 2248
2248void CalendarView::showEventEditor() 2249void CalendarView::showEventEditor()
2249{ 2250{
2250#ifdef DESKTOP_VERSION 2251#ifdef DESKTOP_VERSION
2251 mEventEditor->show(); 2252 mEventEditor->show();
2252#else 2253#else
2253 mEventEditor->showMaximized(); 2254 mEventEditor->showMaximized();
2254#endif 2255#endif
2255} 2256}
2256void CalendarView::showTodoEditor() 2257void CalendarView::showTodoEditor()
2257{ 2258{
2258#ifdef DESKTOP_VERSION 2259#ifdef DESKTOP_VERSION
2259 mTodoEditor->show(); 2260 mTodoEditor->show();
2260#else 2261#else
2261 mTodoEditor->showMaximized(); 2262 mTodoEditor->showMaximized();
2262#endif 2263#endif
2263} 2264}
2264void CalendarView::cancelIncidence(Incidence * inc ) 2265void CalendarView::cancelIncidence(Incidence * inc )
2265{ 2266{
2266 inc->setCancelled( ! inc->cancelled() ); 2267 inc->setCancelled( ! inc->cancelled() );
2267 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2268 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2268 updateView(); 2269 updateView();
2269} 2270}
2270void CalendarView::cloneIncidence(Incidence * orgInc ) 2271void CalendarView::cloneIncidence(Incidence * orgInc )
2271{ 2272{
2272 Incidence * newInc = orgInc->clone(); 2273 Incidence * newInc = orgInc->clone();
2273 newInc->recreate(); 2274 newInc->recreate();
2274 2275
2275 if ( newInc->type() == "Todo" ) { 2276 if ( newInc->type() == "Todo" ) {
2276 Todo* t = (Todo*) newInc; 2277 Todo* t = (Todo*) newInc;
2277 mTodoEditor->editTodo( t ); 2278 mTodoEditor->editTodo( t );
2278 showTodoEditor(); 2279 showTodoEditor();
2279 if ( mTodoEditor->exec() ) { 2280 if ( mTodoEditor->exec() ) {
2280 mCalendar->addTodo( t ); 2281 mCalendar->addTodo( t );
2281 updateView(); 2282 updateView();
2282 } else { 2283 } else {
2283 delete t; 2284 delete t;
2284 } 2285 }
2285 } 2286 }
2286 else { 2287 else {
2287 Event* e = (Event*) newInc; 2288 Event* e = (Event*) newInc;
2288 mEventEditor->editEvent( e ); 2289 mEventEditor->editEvent( e );
2289 showEventEditor(); 2290 showEventEditor();
2290 if ( mEventEditor->exec() ) { 2291 if ( mEventEditor->exec() ) {
2291 mCalendar->addEvent( e ); 2292 mCalendar->addEvent( e );
2292 updateView(); 2293 updateView();
2293 } else { 2294 } else {
2294 delete e; 2295 delete e;
2295 } 2296 }
2296 } 2297 }
2297} 2298}
2298 2299
2299void CalendarView::newEvent() 2300void CalendarView::newEvent()
2300{ 2301{
2301 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2302 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2302 KOAgendaView *aView = mViewManager->agendaView(); 2303 KOAgendaView *aView = mViewManager->agendaView();
2303 if (aView) { 2304 if (aView) {
2304 if (aView->selectionStart().isValid()) { 2305 if (aView->selectionStart().isValid()) {
2305 if (aView->selectedIsAllDay()) { 2306 if (aView->selectedIsAllDay()) {
2306 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2307 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2307 } else { 2308 } else {
2308 newEvent(aView->selectionStart(),aView->selectionEnd()); 2309 newEvent(aView->selectionStart(),aView->selectionEnd());
2309 } 2310 }
2310 return; 2311 return;
2311 } 2312 }
2312 } 2313 }
2313 2314
2314 QDate date = mNavigator->selectedDates().first(); 2315 QDate date = mNavigator->selectedDates().first();
2315 QDateTime current = QDateTime::currentDateTime(); 2316 QDateTime current = QDateTime::currentDateTime();
2316 if ( date <= current.date() ) { 2317 if ( date <= current.date() ) {
2317 int hour = current.time().hour() +1; 2318 int hour = current.time().hour() +1;
2318 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2319 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2319 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2320 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2320 } else 2321 } else
2321 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2322 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2322 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2323 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2323 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2324 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2324} 2325}
2325 2326
2326void CalendarView::newEvent(QDateTime fh) 2327void CalendarView::newEvent(QDateTime fh)
2327{ 2328{
2328 newEvent(fh, 2329 newEvent(fh,
2329 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2330 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2330} 2331}
2331 2332
2332void CalendarView::newEvent(QDate dt) 2333void CalendarView::newEvent(QDate dt)
2333{ 2334{
2334 newEvent(QDateTime(dt, QTime(0,0,0)), 2335 newEvent(QDateTime(dt, QTime(0,0,0)),
2335 QDateTime(dt, QTime(0,0,0)), true); 2336 QDateTime(dt, QTime(0,0,0)), true);
2336} 2337}
2337 2338
2338void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2339void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2339{ 2340{
2340 2341
2341 mEventEditor->newEvent(fromHint,toHint,allDay); 2342 mEventEditor->newEvent(fromHint,toHint,allDay);
2342 if ( mFilterView->filtersEnabled() ) { 2343 if ( mFilterView->filtersEnabled() ) {
2343 CalFilter *filter = mFilterView->selectedFilter(); 2344 CalFilter *filter = mFilterView->selectedFilter();
2344 if (filter && filter->showCategories()) { 2345 if (filter && filter->showCategories()) {
2345 mEventEditor->setCategories(filter->categoryList().join(",") ); 2346 mEventEditor->setCategories(filter->categoryList().join(",") );
2346 } 2347 }
2347 if ( filter ) 2348 if ( filter )
2348 mEventEditor->setSecrecy( filter->getSecrecy() ); 2349 mEventEditor->setSecrecy( filter->getSecrecy() );
2349 } 2350 }
2350 showEventEditor(); 2351 showEventEditor();
2351} 2352}
2352void CalendarView::todoAdded(Todo * t) 2353void CalendarView::todoAdded(Todo * t)
2353{ 2354{
2354 2355
2355 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2356 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2356 updateTodoViews(); 2357 updateTodoViews();
2357} 2358}
2358void CalendarView::todoChanged(Todo * t) 2359void CalendarView::todoChanged(Todo * t)
2359{ 2360{
2360 emit todoModified( t, 4 ); 2361 emit todoModified( t, 4 );
2361 // updateTodoViews(); 2362 // updateTodoViews();
2362} 2363}
2363void CalendarView::todoToBeDeleted(Todo *) 2364void CalendarView::todoToBeDeleted(Todo *)
2364{ 2365{
2365 //qDebug("todoToBeDeleted(Todo *) "); 2366 //qDebug("todoToBeDeleted(Todo *) ");
2366 updateTodoViews(); 2367 updateTodoViews();
2367} 2368}
2368void CalendarView::todoDeleted() 2369void CalendarView::todoDeleted()
2369{ 2370{
2370 //qDebug(" todoDeleted()"); 2371 //qDebug(" todoDeleted()");
2371 updateTodoViews(); 2372 updateTodoViews();
2372} 2373}
2373 2374
2374 2375
2375 2376
2376void CalendarView::newTodo() 2377void CalendarView::newTodo()
2377{ 2378{
2378 2379
2379 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); 2380 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true);
2380 if ( mFilterView->filtersEnabled() ) { 2381 if ( mFilterView->filtersEnabled() ) {
2381 CalFilter *filter = mFilterView->selectedFilter(); 2382 CalFilter *filter = mFilterView->selectedFilter();
2382 if (filter && filter->showCategories()) { 2383 if (filter && filter->showCategories()) {
2383 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2384 mTodoEditor->setCategories(filter->categoryList().join(",") );
2384 } 2385 }
2385 if ( filter ) 2386 if ( filter )
2386 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2387 mTodoEditor->setSecrecy( filter->getSecrecy() );
2387 } 2388 }
2388 showTodoEditor(); 2389 showTodoEditor();
2389} 2390}
2390 2391
2391void CalendarView::newSubTodo() 2392void CalendarView::newSubTodo()
2392{ 2393{
2393 Todo *todo = selectedTodo(); 2394 Todo *todo = selectedTodo();
2394 if ( todo ) newSubTodo( todo ); 2395 if ( todo ) newSubTodo( todo );
2395} 2396}
2396 2397
2397void CalendarView::newSubTodo(Todo *parentEvent) 2398void CalendarView::newSubTodo(Todo *parentEvent)
2398{ 2399{
2399 2400
2400 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); 2401 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true);
2401 showTodoEditor(); 2402 showTodoEditor();
2402} 2403}
2403 2404
2404void CalendarView::newFloatingEvent() 2405void CalendarView::newFloatingEvent()
2405{ 2406{
2406 DateList tmpList = mNavigator->selectedDates(); 2407 DateList tmpList = mNavigator->selectedDates();
2407 QDate date = tmpList.first(); 2408 QDate date = tmpList.first();
2408 2409
2409 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2410 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2410 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2411 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2411} 2412}
2412 2413
2413 2414
2414void CalendarView::editEvent( Event *event ) 2415void CalendarView::editEvent( Event *event )
2415{ 2416{
2416 2417
2417 if ( !event ) return; 2418 if ( !event ) return;
2418 if ( event->isReadOnly() ) { 2419 if ( event->isReadOnly() ) {
2419 showEvent( event ); 2420 showEvent( event );
2420 return; 2421 return;
2421 } 2422 }
2422 mEventEditor->editEvent( event , mFlagEditDescription); 2423 mEventEditor->editEvent( event , mFlagEditDescription);
2423 showEventEditor(); 2424 showEventEditor();
2424} 2425}
2425void CalendarView::editJournal( Journal *jour ) 2426void CalendarView::editJournal( Journal *jour )
2426{ 2427{
2427 if ( !jour ) return; 2428 if ( !jour ) return;
2428 mDialogManager->hideSearchDialog(); 2429 mDialogManager->hideSearchDialog();
2429 mViewManager->showJournalView(); 2430 mViewManager->showJournalView();
2430 mNavigator->slotDaySelect( jour->dtStart().date() ); 2431 mNavigator->slotDaySelect( jour->dtStart().date() );
2431} 2432}
2432void CalendarView::editTodo( Todo *todo ) 2433void CalendarView::editTodo( Todo *todo )
2433{ 2434{
2434 if ( !todo ) return; 2435 if ( !todo ) return;
2435 2436
2436 if ( todo->isReadOnly() ) { 2437 if ( todo->isReadOnly() ) {
2437 showTodo( todo ); 2438 showTodo( todo );
2438 return; 2439 return;
2439 } 2440 }
2440 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2441 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2441 showTodoEditor(); 2442 showTodoEditor();
2442 2443
2443} 2444}
2444 2445
2445KOEventViewerDialog* CalendarView::getEventViewerDialog() 2446KOEventViewerDialog* CalendarView::getEventViewerDialog()
2446{ 2447{
2447 if ( !mEventViewerDialog ) { 2448 if ( !mEventViewerDialog ) {
2448 mEventViewerDialog = new KOEventViewerDialog(this); 2449 mEventViewerDialog = new KOEventViewerDialog(this);
2449 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2450 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2450 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2451 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2451 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2452 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2452 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2453 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2453 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2454 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2454 viewManager(), SLOT( showAgendaView( bool ) ) ); 2455 viewManager(), SLOT( showAgendaView( bool ) ) );
2455 mEventViewerDialog->resize( 640, 480 ); 2456 mEventViewerDialog->resize( 640, 480 );
2456 2457
2457 } 2458 }
2458 return mEventViewerDialog; 2459 return mEventViewerDialog;
2459} 2460}
2460void CalendarView::showEvent(Event *event) 2461void CalendarView::showEvent(Event *event)
2461{ 2462{
2462 getEventViewerDialog()->setEvent(event); 2463 getEventViewerDialog()->setEvent(event);
2463 getEventViewerDialog()->showMe(); 2464 getEventViewerDialog()->showMe();
2464} 2465}
2465 2466
2466void CalendarView::showTodo(Todo *event) 2467void CalendarView::showTodo(Todo *event)
2467{ 2468{
2468 getEventViewerDialog()->setTodo(event); 2469 getEventViewerDialog()->setTodo(event);
2469 getEventViewerDialog()->showMe(); 2470 getEventViewerDialog()->showMe();
2470} 2471}
2471void CalendarView::showJournal( Journal *jour ) 2472void CalendarView::showJournal( Journal *jour )
2472{ 2473{
2473 getEventViewerDialog()->setJournal(jour); 2474 getEventViewerDialog()->setJournal(jour);
2474 getEventViewerDialog()->showMe(); 2475 getEventViewerDialog()->showMe();
2475 2476
2476} 2477}
2477// void CalendarView::todoModified (Todo *event, int changed) 2478// void CalendarView::todoModified (Todo *event, int changed)
2478// { 2479// {
2479// // if (mDialogList.find (event) != mDialogList.end ()) { 2480// // if (mDialogList.find (event) != mDialogList.end ()) {
2480// // kdDebug() << "Todo modified and open" << endl; 2481// // kdDebug() << "Todo modified and open" << endl;
2481// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2482// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2482// // temp->modified (changed); 2483// // temp->modified (changed);
2483 2484
2484// // } 2485// // }
2485 2486
2486// mViewManager->updateView(); 2487// mViewManager->updateView();
2487// } 2488// }
2488 2489
2489void CalendarView::appointment_show() 2490void CalendarView::appointment_show()
2490{ 2491{
2491 Event *anEvent = 0; 2492 Event *anEvent = 0;
2492 2493
2493 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2494 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2494 2495
2495 if (mViewManager->currentView()->isEventView()) { 2496 if (mViewManager->currentView()->isEventView()) {
2496 if ( incidence && incidence->type() == "Event" ) { 2497 if ( incidence && incidence->type() == "Event" ) {
2497 anEvent = static_cast<Event *>(incidence); 2498 anEvent = static_cast<Event *>(incidence);
2498 } 2499 }
2499 } 2500 }
2500 2501
2501 if (!anEvent) { 2502 if (!anEvent) {
2502 KNotifyClient::beep(); 2503 KNotifyClient::beep();
2503 return; 2504 return;
2504 } 2505 }
2505 2506
2506 showEvent(anEvent); 2507 showEvent(anEvent);
2507} 2508}
2508 2509
2509void CalendarView::appointment_edit() 2510void CalendarView::appointment_edit()
2510{ 2511{
2511 Event *anEvent = 0; 2512 Event *anEvent = 0;
2512 2513
2513 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2514 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2514 2515
2515 if (mViewManager->currentView()->isEventView()) { 2516 if (mViewManager->currentView()->isEventView()) {
2516 if ( incidence && incidence->type() == "Event" ) { 2517 if ( incidence && incidence->type() == "Event" ) {
2517 anEvent = static_cast<Event *>(incidence); 2518 anEvent = static_cast<Event *>(incidence);
2518 } 2519 }
2519 } 2520 }
2520 2521
2521 if (!anEvent) { 2522 if (!anEvent) {
2522 KNotifyClient::beep(); 2523 KNotifyClient::beep();
2523 return; 2524 return;
2524 } 2525 }
2525 2526
2526 editEvent(anEvent); 2527 editEvent(anEvent);
2527} 2528}
2528 2529
2529void CalendarView::appointment_delete() 2530void CalendarView::appointment_delete()
2530{ 2531{
2531 Event *anEvent = 0; 2532 Event *anEvent = 0;
2532 2533
2533 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2534 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2534 2535
2535 if (mViewManager->currentView()->isEventView()) { 2536 if (mViewManager->currentView()->isEventView()) {
2536 if ( incidence && incidence->type() == "Event" ) { 2537 if ( incidence && incidence->type() == "Event" ) {
2537 anEvent = static_cast<Event *>(incidence); 2538 anEvent = static_cast<Event *>(incidence);
2538 } 2539 }
2539 } 2540 }
2540 2541
2541 if (!anEvent) { 2542 if (!anEvent) {
2542 KNotifyClient::beep(); 2543 KNotifyClient::beep();
2543 return; 2544 return;
2544 } 2545 }
2545 2546
2546 deleteEvent(anEvent); 2547 deleteEvent(anEvent);
2547} 2548}
2548 2549
2549void CalendarView::todo_unsub(Todo *anTodo ) 2550void CalendarView::todo_unsub(Todo *anTodo )
2550{ 2551{
2551 // Todo *anTodo = selectedTodo(); 2552 // Todo *anTodo = selectedTodo();
2552 if (!anTodo) return; 2553 if (!anTodo) return;
2553 if (!anTodo->relatedTo()) return; 2554 if (!anTodo->relatedTo()) return;
2554 anTodo->relatedTo()->removeRelation(anTodo); 2555 anTodo->relatedTo()->removeRelation(anTodo);
2555 anTodo->setRelatedTo(0); 2556 anTodo->setRelatedTo(0);
2556 anTodo->updated(); 2557 anTodo->updated();
2557 anTodo->setRelatedToUid(""); 2558 anTodo->setRelatedToUid("");
2558 setModified(true); 2559 setModified(true);
2559 updateView(); 2560 updateView();
2560} 2561}
2561 2562
2562void CalendarView::deleteTodo(Todo *todo) 2563void CalendarView::deleteTodo(Todo *todo)
2563{ 2564{
2564 if (!todo) { 2565 if (!todo) {
2565 KNotifyClient::beep(); 2566 KNotifyClient::beep();
2566 return; 2567 return;
2567 } 2568 }
2568 if (KOPrefs::instance()->mConfirm) { 2569 if (KOPrefs::instance()->mConfirm) {
2569 switch (msgItemDelete()) { 2570 switch (msgItemDelete()) {
2570 case KMessageBox::Continue: // OK 2571 case KMessageBox::Continue: // OK
2571 if (!todo->relations().isEmpty()) { 2572 if (!todo->relations().isEmpty()) {
2572 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2573 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2573 i18n("Delete To-Do")); 2574 i18n("Delete To-Do"));
2574 } else { 2575 } else {
2575 checkZaurusId( todo->zaurusId(), true ); 2576 checkZaurusId( todo->zaurusId(), true );
2576 calendar()->deleteTodo(todo); 2577 calendar()->deleteTodo(todo);
2577 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2578 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2578 updateView(); 2579 updateView();
2579 } 2580 }
2580 break; 2581 break;
2581 } // switch 2582 } // switch
2582 } else { 2583 } else {
2583 if (!todo->relations().isEmpty()) { 2584 if (!todo->relations().isEmpty()) {
2584 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2585 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2585 i18n("Delete To-Do")); 2586 i18n("Delete To-Do"));
2586 } else { 2587 } else {
2587 checkZaurusId( todo->zaurusId(), true ); 2588 checkZaurusId( todo->zaurusId(), true );
2588 mCalendar->deleteTodo(todo); 2589 mCalendar->deleteTodo(todo);
2589 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2590 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2590 updateView(); 2591 updateView();
2591 } 2592 }
2592 } 2593 }
2593 emit updateSearchDialog(); 2594 emit updateSearchDialog();
2594} 2595}
2595void CalendarView::deleteJournal(Journal *jour) 2596void CalendarView::deleteJournal(Journal *jour)
2596{ 2597{
2597 if (!jour) { 2598 if (!jour) {
2598 KNotifyClient::beep(); 2599 KNotifyClient::beep();
2599 return; 2600 return;
2600 } 2601 }
2601 if (KOPrefs::instance()->mConfirm) { 2602 if (KOPrefs::instance()->mConfirm) {
2602 switch (msgItemDelete()) { 2603 switch (msgItemDelete()) {
2603 case KMessageBox::Continue: // OK 2604 case KMessageBox::Continue: // OK
2604 calendar()->deleteJournal(jour); 2605 calendar()->deleteJournal(jour);
2605 updateView(); 2606 updateView();
2606 break; 2607 break;
2607 } // switch 2608 } // switch
2608 } else { 2609 } else {
2609 calendar()->deleteJournal(jour);; 2610 calendar()->deleteJournal(jour);;
2610 updateView(); 2611 updateView();
2611 } 2612 }
2612 emit updateSearchDialog(); 2613 emit updateSearchDialog();
2613} 2614}
2614 2615
2615void CalendarView::deleteEvent(Event *anEvent) 2616void CalendarView::deleteEvent(Event *anEvent)
2616{ 2617{
2617 if (!anEvent) { 2618 if (!anEvent) {
2618 KNotifyClient::beep(); 2619 KNotifyClient::beep();
2619 return; 2620 return;
2620 } 2621 }
2621 2622
2622 if (anEvent->recurrence()->doesRecur()) { 2623 if (anEvent->recurrence()->doesRecur()) {
2623 QDate itemDate = mViewManager->currentSelectionDate(); 2624 QDate itemDate = mViewManager->currentSelectionDate();
2624 int km; 2625 int km;
2625 if (!itemDate.isValid()) { 2626 if (!itemDate.isValid()) {
2626 //kdDebug() << "Date Not Valid" << endl; 2627 //kdDebug() << "Date Not Valid" << endl;
2627 if (KOPrefs::instance()->mConfirm) { 2628 if (KOPrefs::instance()->mConfirm) {
2628 km = KMessageBox::warningContinueCancel(this,anEvent->summary() + 2629 km = KMessageBox::warningContinueCancel(this,anEvent->summary() +
2629 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 2630 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
2630 i18n("KO/Pi Confirmation"),i18n("Delete All")); 2631 i18n("KO/Pi Confirmation"),i18n("Delete All"));
2631 if ( km == KMessageBox::Continue ) 2632 if ( km == KMessageBox::Continue )
2632 km = KMessageBox::No; // No = all below 2633 km = KMessageBox::No; // No = all below
2633 } else 2634 } else
2634 km = KMessageBox::No; 2635 km = KMessageBox::No;
2635 } else { 2636 } else {
2636 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + 2637 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() +
2637 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 2638 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
2638 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 2639 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
2639 i18n("KO/Pi Confirmation"),i18n("Current"), 2640 i18n("KO/Pi Confirmation"),i18n("Current"),
2640 i18n("All")); 2641 i18n("All"));
2641 } 2642 }
2642 switch(km) { 2643 switch(km) {
2643 2644
2644 case KMessageBox::No: // Continue // all 2645 case KMessageBox::No: // Continue // all
2645 //qDebug("KMessageBox::No "); 2646 //qDebug("KMessageBox::No ");
2646 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2647 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2647 schedule(Scheduler::Cancel,anEvent); 2648 schedule(Scheduler::Cancel,anEvent);
2648 2649
2649 checkZaurusId( anEvent->zaurusId()); 2650 checkZaurusId( anEvent->zaurusId());
2650 mCalendar->deleteEvent(anEvent); 2651 mCalendar->deleteEvent(anEvent);
2651 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 2652 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
2652 break; 2653 break;
2653 2654
2654 // Disabled because it does not work 2655 // Disabled because it does not work
2655 //#if 0 2656 //#if 0
2656 case KMessageBox::Yes: // just this one 2657 case KMessageBox::Yes: // just this one
2657 //QDate qd = mNavigator->selectedDates().first(); 2658 //QDate qd = mNavigator->selectedDates().first();
2658 //if (!qd.isValid()) { 2659 //if (!qd.isValid()) {
2659 // kdDebug() << "no date selected, or invalid date" << endl; 2660 // kdDebug() << "no date selected, or invalid date" << endl;
2660 // KNotifyClient::beep(); 2661 // KNotifyClient::beep();
2661 // return; 2662 // return;
2662 //} 2663 //}
2663 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 2664 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
2664 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 2665 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
2665 anEvent->addExDate(itemDate); 2666 anEvent->addExDate(itemDate);
2666 int duration = anEvent->recurrence()->duration(); 2667 int duration = anEvent->recurrence()->duration();
2667 if ( duration > 0 ) { 2668 if ( duration > 0 ) {
2668 anEvent->recurrence()->setDuration( duration - 1 ); 2669 anEvent->recurrence()->setDuration( duration - 1 );
2669 } 2670 }
2670 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 2671 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
2671 } 2672 }
2672 break; 2673 break;
2673 //#endif 2674 //#endif
2674 } // switch 2675 } // switch
2675 } else { 2676 } else {
2676 if (KOPrefs::instance()->mConfirm) { 2677 if (KOPrefs::instance()->mConfirm) {
2677 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + 2678 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() +
2678 i18n("\nAre you sure you want\nto delete this event?"), 2679 i18n("\nAre you sure you want\nto delete this event?"),
2679 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 2680 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
2680 case KMessageBox::Continue: // OK 2681 case KMessageBox::Continue: // OK
2681 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2682 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2682 schedule(Scheduler::Cancel,anEvent); 2683 schedule(Scheduler::Cancel,anEvent);
2683 checkZaurusId( anEvent->zaurusId()); 2684 checkZaurusId( anEvent->zaurusId());
2684 mCalendar->deleteEvent(anEvent); 2685 mCalendar->deleteEvent(anEvent);
2685 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2686 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2686 break; 2687 break;
2687 } // switch 2688 } // switch
2688 } else { 2689 } else {
2689 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2690 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2690 schedule(Scheduler::Cancel,anEvent); 2691 schedule(Scheduler::Cancel,anEvent);
2691 checkZaurusId( anEvent->zaurusId()); 2692 checkZaurusId( anEvent->zaurusId());
2692 mCalendar->deleteEvent(anEvent); 2693 mCalendar->deleteEvent(anEvent);
2693 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2694 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2694 } 2695 }
2695 } // if-else 2696 } // if-else
2696 emit updateSearchDialog(); 2697 emit updateSearchDialog();
2697} 2698}
2698 2699
2699bool CalendarView::deleteEvent(const QString &uid) 2700bool CalendarView::deleteEvent(const QString &uid)
2700{ 2701{
2701 Event *ev = mCalendar->event(uid); 2702 Event *ev = mCalendar->event(uid);
2702 if (ev) { 2703 if (ev) {
2703 deleteEvent(ev); 2704 deleteEvent(ev);
2704 return true; 2705 return true;
2705 } else { 2706 } else {
2706 return false; 2707 return false;
2707 } 2708 }
2708} 2709}
2709 2710
2710/*****************************************************************************/ 2711/*****************************************************************************/
2711 2712
2712void CalendarView::action_mail() 2713void CalendarView::action_mail()
2713{ 2714{
2714#ifndef KORG_NOMAIL 2715#ifndef KORG_NOMAIL
2715 KOMailClient mailClient; 2716 KOMailClient mailClient;
2716 2717
2717 Incidence *incidence = currentSelection(); 2718 Incidence *incidence = currentSelection();
2718 2719
2719 if (!incidence) { 2720 if (!incidence) {
2720 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2721 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2721 return; 2722 return;
2722 } 2723 }
2723 if(incidence->attendeeCount() == 0 ) { 2724 if(incidence->attendeeCount() == 0 ) {
2724 KMessageBox::sorry(this, 2725 KMessageBox::sorry(this,
2725 i18n("Can't generate mail:\nNo attendees defined.\n")); 2726 i18n("Can't generate mail:\nNo attendees defined.\n"));
2726 return; 2727 return;
2727 } 2728 }
2728 2729
2729 CalendarLocal cal_tmp; 2730 CalendarLocal cal_tmp;
2730 Event *event = 0; 2731 Event *event = 0;
2731 Event *ev = 0; 2732 Event *ev = 0;
2732 if ( incidence && incidence->type() == "Event" ) { 2733 if ( incidence && incidence->type() == "Event" ) {
2733 event = static_cast<Event *>(incidence); 2734 event = static_cast<Event *>(incidence);
2734 ev = new Event(*event); 2735 ev = new Event(*event);
2735 cal_tmp.addEvent(ev); 2736 cal_tmp.addEvent(ev);
2736 } 2737 }
2737 ICalFormat mForm( KOPrefs::instance()->mUseQuicksave); 2738 ICalFormat mForm( KOPrefs::instance()->mUseQuicksave);
2738 QString attachment = mForm.toString( &cal_tmp ); 2739 QString attachment = mForm.toString( &cal_tmp );
2739 if (ev) delete(ev); 2740 if (ev) delete(ev);
2740 2741
2741 mailClient.mailAttendees(currentSelection(), attachment); 2742 mailClient.mailAttendees(currentSelection(), attachment);
2742 2743
2743#endif 2744#endif
2744 2745
2745#if 0 2746#if 0
2746 Event *anEvent = 0; 2747 Event *anEvent = 0;
2747 if (mViewManager->currentView()->isEventView()) { 2748 if (mViewManager->currentView()->isEventView()) {
2748 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 2749 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
2749 } 2750 }
2750 2751
2751 if (!anEvent) { 2752 if (!anEvent) {
2752 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2753 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2753 return; 2754 return;
2754 } 2755 }
2755 if(anEvent->attendeeCount() == 0 ) { 2756 if(anEvent->attendeeCount() == 0 ) {
2756 KMessageBox::sorry(this, 2757 KMessageBox::sorry(this,
2757 i18n("Can't generate mail:\nNo attendees defined.\n")); 2758 i18n("Can't generate mail:\nNo attendees defined.\n"));
2758 return; 2759 return;
2759 } 2760 }
2760 2761
2761 mailobject.emailEvent(anEvent); 2762 mailobject.emailEvent(anEvent);
2762#endif 2763#endif
2763} 2764}
2764 2765
2765 2766
2766void CalendarView::schedule_publish(Incidence *incidence) 2767void CalendarView::schedule_publish(Incidence *incidence)
2767{ 2768{
2768 Event *event = 0; 2769 Event *event = 0;
2769 Todo *todo = 0; 2770 Todo *todo = 0;
2770 2771
2771 if (incidence == 0) { 2772 if (incidence == 0) {
2772 incidence = mViewManager->currentView()->selectedIncidences().first(); 2773 incidence = mViewManager->currentView()->selectedIncidences().first();
2773 if (incidence == 0) { 2774 if (incidence == 0) {
2774 incidence = mTodoList->selectedIncidences().first(); 2775 incidence = mTodoList->selectedIncidences().first();
2775 } 2776 }
2776 } 2777 }
2777 if ( incidence && incidence->type() == "Event" ) { 2778 if ( incidence && incidence->type() == "Event" ) {
2778 event = static_cast<Event *>(incidence); 2779 event = static_cast<Event *>(incidence);
2779 } else { 2780 } else {
2780 if ( incidence && incidence->type() == "Todo" ) { 2781 if ( incidence && incidence->type() == "Todo" ) {
2781 todo = static_cast<Todo *>(incidence); 2782 todo = static_cast<Todo *>(incidence);
2782 } 2783 }
2783 } 2784 }
2784 2785
2785 if (!event && !todo) { 2786 if (!event && !todo) {
2786 KMessageBox::sorry(this,i18n("No event selected.")); 2787 KMessageBox::sorry(this,i18n("No event selected."));
2787 return; 2788 return;
2788 } 2789 }
2789 2790
2790 PublishDialog *publishdlg = new PublishDialog(); 2791 PublishDialog *publishdlg = new PublishDialog();
2791 if (incidence->attendeeCount()>0) { 2792 if (incidence->attendeeCount()>0) {
2792 QPtrList<Attendee> attendees = incidence->attendees(); 2793 QPtrList<Attendee> attendees = incidence->attendees();
2793 attendees.first(); 2794 attendees.first();
2794 while ( attendees.current()!=0 ) { 2795 while ( attendees.current()!=0 ) {
2795 publishdlg->addAttendee(attendees.current()); 2796 publishdlg->addAttendee(attendees.current());
2796 attendees.next(); 2797 attendees.next();
2797 } 2798 }
2798 } 2799 }
2799 bool send = true; 2800 bool send = true;
2800 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 2801 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
2801 if ( publishdlg->exec() != QDialog::Accepted ) 2802 if ( publishdlg->exec() != QDialog::Accepted )
2802 send = false; 2803 send = false;
2803 } 2804 }
2804 if ( send ) { 2805 if ( send ) {
2805 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2806 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2806 if ( event ) { 2807 if ( event ) {
2807 Event *ev = new Event(*event); 2808 Event *ev = new Event(*event);
2808 ev->registerObserver(0); 2809 ev->registerObserver(0);
2809 ev->clearAttendees(); 2810 ev->clearAttendees();
2810 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 2811 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
2811 delete(ev); 2812 delete(ev);
2812 } 2813 }
2813 } else { 2814 } else {
2814 if ( todo ) { 2815 if ( todo ) {
2815 Todo *ev = new Todo(*todo); 2816 Todo *ev = new Todo(*todo);
2816 ev->registerObserver(0); 2817 ev->registerObserver(0);
2817 ev->clearAttendees(); 2818 ev->clearAttendees();
2818 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 2819 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
2819 delete(ev); 2820 delete(ev);
2820 } 2821 }
2821 } 2822 }
2822 } 2823 }
2823 } 2824 }
2824 delete publishdlg; 2825 delete publishdlg;
2825} 2826}
2826 2827
2827void CalendarView::schedule_request(Incidence *incidence) 2828void CalendarView::schedule_request(Incidence *incidence)
2828{ 2829{
2829 schedule(Scheduler::Request,incidence); 2830 schedule(Scheduler::Request,incidence);
2830} 2831}
2831 2832
2832void CalendarView::schedule_refresh(Incidence *incidence) 2833void CalendarView::schedule_refresh(Incidence *incidence)
2833{ 2834{
2834 schedule(Scheduler::Refresh,incidence); 2835 schedule(Scheduler::Refresh,incidence);
2835} 2836}
2836 2837
2837void CalendarView::schedule_cancel(Incidence *incidence) 2838void CalendarView::schedule_cancel(Incidence *incidence)
2838{ 2839{
2839 schedule(Scheduler::Cancel,incidence); 2840 schedule(Scheduler::Cancel,incidence);
2840} 2841}
2841 2842
2842void CalendarView::schedule_add(Incidence *incidence) 2843void CalendarView::schedule_add(Incidence *incidence)
2843{ 2844{
2844 schedule(Scheduler::Add,incidence); 2845 schedule(Scheduler::Add,incidence);
2845} 2846}
2846 2847
2847void CalendarView::schedule_reply(Incidence *incidence) 2848void CalendarView::schedule_reply(Incidence *incidence)
2848{ 2849{
2849 schedule(Scheduler::Reply,incidence); 2850 schedule(Scheduler::Reply,incidence);
2850} 2851}
2851 2852
2852void CalendarView::schedule_counter(Incidence *incidence) 2853void CalendarView::schedule_counter(Incidence *incidence)
2853{ 2854{
2854 schedule(Scheduler::Counter,incidence); 2855 schedule(Scheduler::Counter,incidence);
2855} 2856}
2856 2857
2857void CalendarView::schedule_declinecounter(Incidence *incidence) 2858void CalendarView::schedule_declinecounter(Incidence *incidence)
2858{ 2859{
2859 schedule(Scheduler::Declinecounter,incidence); 2860 schedule(Scheduler::Declinecounter,incidence);
2860} 2861}
2861 2862
2862void CalendarView::schedule_publish_freebusy(int daysToPublish) 2863void CalendarView::schedule_publish_freebusy(int daysToPublish)
2863{ 2864{
2864 QDateTime start = QDateTime::currentDateTime(); 2865 QDateTime start = QDateTime::currentDateTime();
2865 QDateTime end = start.addDays(daysToPublish); 2866 QDateTime end = start.addDays(daysToPublish);
2866 2867
2867 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 2868 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
2868 freebusy->setOrganizer(KOPrefs::instance()->email()); 2869 freebusy->setOrganizer(KOPrefs::instance()->email());
2869 2870
2870 2871
2871 PublishDialog *publishdlg = new PublishDialog(); 2872 PublishDialog *publishdlg = new PublishDialog();
2872 if ( publishdlg->exec() == QDialog::Accepted ) { 2873 if ( publishdlg->exec() == QDialog::Accepted ) {
2873 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2874 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2874 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 2875 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
2875 delete(freebusy); 2876 delete(freebusy);
2876 } 2877 }
2877 } 2878 }
2878 delete publishdlg; 2879 delete publishdlg;
2879} 2880}
2880 2881
2881void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 2882void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
2882{ 2883{
2883 Event *event = 0; 2884 Event *event = 0;
2884 Todo *todo = 0; 2885 Todo *todo = 0;
2885 2886
2886 if (incidence == 0) { 2887 if (incidence == 0) {
2887 incidence = mViewManager->currentView()->selectedIncidences().first(); 2888 incidence = mViewManager->currentView()->selectedIncidences().first();
2888 if (incidence == 0) { 2889 if (incidence == 0) {
2889 incidence = mTodoList->selectedIncidences().first(); 2890 incidence = mTodoList->selectedIncidences().first();
2890 } 2891 }
2891 } 2892 }
2892 if ( incidence && incidence->type() == "Event" ) { 2893 if ( incidence && incidence->type() == "Event" ) {
2893 event = static_cast<Event *>(incidence); 2894 event = static_cast<Event *>(incidence);
2894 } 2895 }
2895 if ( incidence && incidence->type() == "Todo" ) { 2896 if ( incidence && incidence->type() == "Todo" ) {
2896 todo = static_cast<Todo *>(incidence); 2897 todo = static_cast<Todo *>(incidence);
2897 } 2898 }
2898 2899
2899 if (!event && !todo) { 2900 if (!event && !todo) {
2900 KMessageBox::sorry(this,i18n("No event selected.")); 2901 KMessageBox::sorry(this,i18n("No event selected."));
2901 return; 2902 return;
2902 } 2903 }
2903 2904
2904 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 2905 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
2905 KMessageBox::sorry(this,i18n("The event has no attendees.")); 2906 KMessageBox::sorry(this,i18n("The event has no attendees."));
2906 return; 2907 return;
2907 } 2908 }
2908 2909
2909 Event *ev = 0; 2910 Event *ev = 0;
2910 if (event) ev = new Event(*event); 2911 if (event) ev = new Event(*event);
2911 Todo *to = 0; 2912 Todo *to = 0;
2912 if (todo) to = new Todo(*todo); 2913 if (todo) to = new Todo(*todo);
2913 2914
2914 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 2915 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
2915 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 2916 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
2916 if (!me) { 2917 if (!me) {
2917 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 2918 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
2918 return; 2919 return;
2919 } 2920 }
2920 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 2921 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
2921 StatusDialog *statdlg = new StatusDialog(this); 2922 StatusDialog *statdlg = new StatusDialog(this);
2922 if (!statdlg->exec()==QDialog::Accepted) return; 2923 if (!statdlg->exec()==QDialog::Accepted) return;
2923 me->setStatus( statdlg->status() ); 2924 me->setStatus( statdlg->status() );
2924 delete(statdlg); 2925 delete(statdlg);
2925 } 2926 }
2926 Attendee *menew = new Attendee(*me); 2927 Attendee *menew = new Attendee(*me);
2927 if (ev) { 2928 if (ev) {
2928 ev->clearAttendees(); 2929 ev->clearAttendees();
2929 ev->addAttendee(menew,false); 2930 ev->addAttendee(menew,false);
2930 } else { 2931 } else {
2931 if (to) { 2932 if (to) {
2932 todo->clearAttendees(); 2933 todo->clearAttendees();
2933 todo->addAttendee(menew,false); 2934 todo->addAttendee(menew,false);
2934 } 2935 }
2935 } 2936 }
2936 } 2937 }
2937 2938
2938 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2939 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2939 if (ev) { 2940 if (ev) {
2940 if ( !dlg->addMessage(ev,method) ) delete(ev); 2941 if ( !dlg->addMessage(ev,method) ) delete(ev);
2941 } else { 2942 } else {
2942 if (to) { 2943 if (to) {
2943 if ( !dlg->addMessage(to,method) ) delete(to); 2944 if ( !dlg->addMessage(to,method) ) delete(to);
2944 } 2945 }
2945 } 2946 }
2946} 2947}
2947 2948
2948void CalendarView::openAddressbook() 2949void CalendarView::openAddressbook()
2949{ 2950{
2950 KRun::runCommand("kaddressbook"); 2951 KRun::runCommand("kaddressbook");
2951} 2952}
2952 2953
2953void CalendarView::setModified(bool modified) 2954void CalendarView::setModified(bool modified)
2954{ 2955{
2955 if ( modified ) 2956 if ( modified )
2956 emit signalmodified(); 2957 emit signalmodified();
2957 if (mModified != modified) { 2958 if (mModified != modified) {
2958 mModified = modified; 2959 mModified = modified;
2959 emit modifiedChanged(mModified); 2960 emit modifiedChanged(mModified);
2960 } 2961 }
2961} 2962}
2962 2963
2963bool CalendarView::isReadOnly() 2964bool CalendarView::isReadOnly()
2964{ 2965{
2965 return mReadOnly; 2966 return mReadOnly;
2966} 2967}
2967 2968
2968void CalendarView::setReadOnly(bool readOnly) 2969void CalendarView::setReadOnly(bool readOnly)
2969{ 2970{
2970 if (mReadOnly != readOnly) { 2971 if (mReadOnly != readOnly) {
2971 mReadOnly = readOnly; 2972 mReadOnly = readOnly;
2972 emit readOnlyChanged(mReadOnly); 2973 emit readOnlyChanged(mReadOnly);
2973 } 2974 }
2974} 2975}
2975 2976
2976bool CalendarView::isModified() 2977bool CalendarView::isModified()
2977{ 2978{
2978 return mModified; 2979 return mModified;
2979} 2980}
2980 2981
2981void CalendarView::printSetup() 2982void CalendarView::printSetup()
2982{ 2983{
2983#ifndef KORG_NOPRINTER 2984#ifndef KORG_NOPRINTER
2984 createPrinter(); 2985 createPrinter();
2985 2986
2986 mCalPrinter->setupPrinter(); 2987 mCalPrinter->setupPrinter();
2987#endif 2988#endif
2988} 2989}
2989 2990
2990void CalendarView::print() 2991void CalendarView::print()
2991{ 2992{
2992#ifndef KORG_NOPRINTER 2993#ifndef KORG_NOPRINTER
2993 createPrinter(); 2994 createPrinter();
2994 2995
2995 DateList tmpDateList = mNavigator->selectedDates(); 2996 DateList tmpDateList = mNavigator->selectedDates();
2996 mCalPrinter->print(CalPrinter::Month, 2997 mCalPrinter->print(CalPrinter::Month,
2997 tmpDateList.first(), tmpDateList.last()); 2998 tmpDateList.first(), tmpDateList.last());
2998#endif 2999#endif
2999} 3000}
3000 3001
3001void CalendarView::printPreview() 3002void CalendarView::printPreview()
3002{ 3003{
3003#ifndef KORG_NOPRINTER 3004#ifndef KORG_NOPRINTER
3004 kdDebug() << "CalendarView::printPreview()" << endl; 3005 kdDebug() << "CalendarView::printPreview()" << endl;
3005 3006
3006 createPrinter(); 3007 createPrinter();
3007 3008
3008 DateList tmpDateList = mNavigator->selectedDates(); 3009 DateList tmpDateList = mNavigator->selectedDates();
3009 3010
3010 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3011 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3011 tmpDateList.last()); 3012 tmpDateList.last());
3012#endif 3013#endif
3013} 3014}
3014 3015
3015void CalendarView::exportICalendar() 3016void CalendarView::exportICalendar()
3016{ 3017{
3017 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3018 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3018 3019
3019 // Force correct extension 3020 // Force correct extension
3020 if (filename.right(4) != ".ics") filename += ".ics"; 3021 if (filename.right(4) != ".ics") filename += ".ics";
3021 3022
3022 FileStorage storage( mCalendar, filename, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 3023 FileStorage storage( mCalendar, filename, new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
3023 storage.save(); 3024 storage.save();
3024} 3025}
3025 3026
3026bool CalendarView::exportVCalendar( QString filename ) 3027bool CalendarView::exportVCalendar( QString filename )
3027{ 3028{
3028 if (mCalendar->journals().count() > 0) { 3029 if (mCalendar->journals().count() > 0) {
3029 int result = KMessageBox::warningContinueCancel(this, 3030 int result = KMessageBox::warningContinueCancel(this,
3030 i18n("The journal entries can not be\nexported to a vCalendar file."), 3031 i18n("The journal entries can not be\nexported to a vCalendar file."),
3031 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3032 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3032 true); 3033 true);
3033 if (result != KMessageBox::Continue) return false; 3034 if (result != KMessageBox::Continue) return false;
3034 } 3035 }
3035 3036
3036 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3037 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3037 3038
3038 // Force correct extension 3039 // Force correct extension
3039 if (filename.right(4) != ".vcs") filename += ".vcs"; 3040 if (filename.right(4) != ".vcs") filename += ".vcs";
3040 3041
3041 FileStorage storage( mCalendar, filename, new VCalFormat ); 3042 FileStorage storage( mCalendar, filename, new VCalFormat );
3042 return storage.save(); 3043 return storage.save();
3043 3044
3044} 3045}
3045 3046
3046void CalendarView::eventUpdated(Incidence *) 3047void CalendarView::eventUpdated(Incidence *)
3047{ 3048{
3048 setModified(); 3049 setModified();
3049 // Don't call updateView here. The code, which has caused the update of the 3050 // Don't call updateView here. The code, which has caused the update of the
3050 // event is responsible for updating the view. 3051 // event is responsible for updating the view.
3051 // updateView(); 3052 // updateView();
3052} 3053}
3053 3054
3054void CalendarView::adaptNavigationUnits() 3055void CalendarView::adaptNavigationUnits()
3055{ 3056{
3056 if (mViewManager->currentView()->isEventView()) { 3057 if (mViewManager->currentView()->isEventView()) {
3057 int days = mViewManager->currentView()->currentDateCount(); 3058 int days = mViewManager->currentView()->currentDateCount();
3058 if (days == 1) { 3059 if (days == 1) {
3059 emit changeNavStringPrev(i18n("&Previous Day")); 3060 emit changeNavStringPrev(i18n("&Previous Day"));
3060 emit changeNavStringNext(i18n("&Next Day")); 3061 emit changeNavStringNext(i18n("&Next Day"));
3061 } else { 3062 } else {
3062 emit changeNavStringPrev(i18n("&Previous Week")); 3063 emit changeNavStringPrev(i18n("&Previous Week"));
3063 emit changeNavStringNext(i18n("&Next Week")); 3064 emit changeNavStringNext(i18n("&Next Week"));
3064 } 3065 }
3065 } 3066 }
3066} 3067}
3067 3068
3068void CalendarView::processMainViewSelection( Incidence *incidence ) 3069void CalendarView::processMainViewSelection( Incidence *incidence )
3069{ 3070{
3070 if ( incidence ) mTodoList->clearSelection(); 3071 if ( incidence ) mTodoList->clearSelection();
3071 processIncidenceSelection( incidence ); 3072 processIncidenceSelection( incidence );
3072} 3073}
3073 3074
3074void CalendarView::processTodoListSelection( Incidence *incidence ) 3075void CalendarView::processTodoListSelection( Incidence *incidence )
3075{ 3076{
3076 if ( incidence && mViewManager->currentView() ) { 3077 if ( incidence && mViewManager->currentView() ) {
3077 mViewManager->currentView()->clearSelection(); 3078 mViewManager->currentView()->clearSelection();
3078 } 3079 }
3079 processIncidenceSelection( incidence ); 3080 processIncidenceSelection( incidence );
3080} 3081}
3081 3082
3082void CalendarView::processIncidenceSelection( Incidence *incidence ) 3083void CalendarView::processIncidenceSelection( Incidence *incidence )
3083{ 3084{
3084 if ( incidence == mSelectedIncidence ) return; 3085 if ( incidence == mSelectedIncidence ) return;
3085 3086
3086 mSelectedIncidence = incidence; 3087 mSelectedIncidence = incidence;
3087 3088
3088 emit incidenceSelected( mSelectedIncidence ); 3089 emit incidenceSelected( mSelectedIncidence );
3089 3090
3090 if ( incidence && incidence->type() == "Event" ) { 3091 if ( incidence && incidence->type() == "Event" ) {
3091 Event *event = static_cast<Event *>( incidence ); 3092 Event *event = static_cast<Event *>( incidence );
3092 if ( event->organizer() == KOPrefs::instance()->email() ) { 3093 if ( event->organizer() == KOPrefs::instance()->email() ) {
3093 emit organizerEventsSelected( true ); 3094 emit organizerEventsSelected( true );
3094 } else { 3095 } else {
3095 emit organizerEventsSelected(false); 3096 emit organizerEventsSelected(false);
3096 } 3097 }
3097 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3098 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3098 KOPrefs::instance()->email() ) ) { 3099 KOPrefs::instance()->email() ) ) {
3099 emit groupEventsSelected( true ); 3100 emit groupEventsSelected( true );
3100 } else { 3101 } else {
3101 emit groupEventsSelected(false); 3102 emit groupEventsSelected(false);
3102 } 3103 }
3103 return; 3104 return;
3104 } else { 3105 } else {
3105 if ( incidence && incidence->type() == "Todo" ) { 3106 if ( incidence && incidence->type() == "Todo" ) {
3106 emit todoSelected( true ); 3107 emit todoSelected( true );
3107 Todo *event = static_cast<Todo *>( incidence ); 3108 Todo *event = static_cast<Todo *>( incidence );
3108 if ( event->organizer() == KOPrefs::instance()->email() ) { 3109 if ( event->organizer() == KOPrefs::instance()->email() ) {
3109 emit organizerEventsSelected( true ); 3110 emit organizerEventsSelected( true );
3110 } else { 3111 } else {
3111 emit organizerEventsSelected(false); 3112 emit organizerEventsSelected(false);
3112 } 3113 }
3113 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3114 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3114 KOPrefs::instance()->email() ) ) { 3115 KOPrefs::instance()->email() ) ) {
3115 emit groupEventsSelected( true ); 3116 emit groupEventsSelected( true );
3116 } else { 3117 } else {
3117 emit groupEventsSelected(false); 3118 emit groupEventsSelected(false);
3118 } 3119 }
3119 return; 3120 return;
3120 } else { 3121 } else {
3121 emit todoSelected( false ); 3122 emit todoSelected( false );
3122 emit organizerEventsSelected(false); 3123 emit organizerEventsSelected(false);
3123 emit groupEventsSelected(false); 3124 emit groupEventsSelected(false);
3124 } 3125 }
3125 return; 3126 return;
3126 } 3127 }
3127 3128
3128 /* if ( incidence && incidence->type() == "Todo" ) { 3129 /* if ( incidence && incidence->type() == "Todo" ) {
3129 emit todoSelected( true ); 3130 emit todoSelected( true );
3130 } else { 3131 } else {
3131 emit todoSelected( false ); 3132 emit todoSelected( false );
3132 }*/ 3133 }*/
3133} 3134}
3134 3135
3135 3136
3136void CalendarView::checkClipboard() 3137void CalendarView::checkClipboard()
3137{ 3138{
3138#ifndef KORG_NODND 3139#ifndef KORG_NODND
3139 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3140 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3140 emit pasteEnabled(true); 3141 emit pasteEnabled(true);
3141 } else { 3142 } else {
3142 emit pasteEnabled(false); 3143 emit pasteEnabled(false);
3143 } 3144 }
3144#endif 3145#endif
3145} 3146}
3146 3147
3147void CalendarView::showDates(const DateList &selectedDates) 3148void CalendarView::showDates(const DateList &selectedDates)
3148{ 3149{
3149 // kdDebug() << "CalendarView::selectDates()" << endl; 3150 // kdDebug() << "CalendarView::selectDates()" << endl;
3150 3151
3151 if ( mViewManager->currentView() ) { 3152 if ( mViewManager->currentView() ) {
3152 updateView( selectedDates.first(), selectedDates.last() ); 3153 updateView( selectedDates.first(), selectedDates.last() );
3153 } else { 3154 } else {
3154 mViewManager->showAgendaView(); 3155 mViewManager->showAgendaView();
3155 } 3156 }
3156 3157
3157 QString selDates; 3158 QString selDates;
3158 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); 3159 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true);
3159 if (selectedDates.first() < selectedDates.last() ) 3160 if (selectedDates.first() < selectedDates.last() )
3160 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3161 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3161 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3162 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3162 3163
3163} 3164}
3164 3165
3165void CalendarView::editFilters() 3166void CalendarView::editFilters()
3166{ 3167{
3167 // kdDebug() << "CalendarView::editFilters()" << endl; 3168 // kdDebug() << "CalendarView::editFilters()" << endl;
3168 3169
3169 CalFilter *filter = mFilters.first(); 3170 CalFilter *filter = mFilters.first();
3170 while(filter) { 3171 while(filter) {
3171 kdDebug() << " Filter: " << filter->name() << endl; 3172 kdDebug() << " Filter: " << filter->name() << endl;
3172 filter = mFilters.next(); 3173 filter = mFilters.next();
3173 } 3174 }
3174 3175
3175 mDialogManager->showFilterEditDialog(&mFilters); 3176 mDialogManager->showFilterEditDialog(&mFilters);
3176} 3177}
3177void CalendarView::toggleFilter() 3178void CalendarView::toggleFilter()
3178{ 3179{
3179 showFilter(! mFilterView->isVisible()); 3180 showFilter(! mFilterView->isVisible());
3180} 3181}
3181 3182
3182void CalendarView::selectFilter( int fil ) 3183void CalendarView::selectFilter( int fil )
3183{ 3184{
3184 mFilterView->setSelectedFilter( fil ); 3185 mFilterView->setSelectedFilter( fil );
3185} 3186}
3186void CalendarView::showFilter(bool visible) 3187void CalendarView::showFilter(bool visible)
3187{ 3188{
3188 if (visible) mFilterView->show(); 3189 if (visible) mFilterView->show();
3189 else mFilterView->hide(); 3190 else mFilterView->hide();
3190} 3191}
3191void CalendarView::toggleFilerEnabled( ) 3192void CalendarView::toggleFilerEnabled( )
3192{ 3193{
3193 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3194 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3194 if ( !mFilterView->filtersEnabled() ) 3195 if ( !mFilterView->filtersEnabled() )
3195 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3196 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3196 3197
3197} 3198}
3198void CalendarView::updateFilter() 3199void CalendarView::updateFilter()
3199{ 3200{
3200 CalFilter *filter = mFilterView->selectedFilter(); 3201 CalFilter *filter = mFilterView->selectedFilter();
3201 if (filter) { 3202 if (filter) {
3202 if (mFilterView->filtersEnabled()) { 3203 if (mFilterView->filtersEnabled()) {
3203 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); 3204 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() );
3204 filter->setEnabled(true); 3205 filter->setEnabled(true);
3205 } 3206 }
3206 else filter->setEnabled(false); 3207 else filter->setEnabled(false);
3207 mCalendar->setFilter(filter); 3208 mCalendar->setFilter(filter);
3208 updateView(); 3209 updateView();
3209 } 3210 }
3210} 3211}
3211 3212
3212void CalendarView::filterEdited() 3213void CalendarView::filterEdited()
3213{ 3214{
3214 mFilterView->updateFilters(); 3215 mFilterView->updateFilters();
3215 updateFilter(); 3216 updateFilter();
3216 writeSettings(); 3217 writeSettings();
3217} 3218}
3218 3219
3219 3220
3220void CalendarView::takeOverEvent() 3221void CalendarView::takeOverEvent()
3221{ 3222{
3222 Incidence *incidence = currentSelection(); 3223 Incidence *incidence = currentSelection();
3223 3224
3224 if (!incidence) return; 3225 if (!incidence) return;
3225 3226
3226 incidence->setOrganizer(KOPrefs::instance()->email()); 3227 incidence->setOrganizer(KOPrefs::instance()->email());
3227 incidence->recreate(); 3228 incidence->recreate();
3228 incidence->setReadOnly(false); 3229 incidence->setReadOnly(false);
3229 3230
3230 updateView(); 3231 updateView();
3231} 3232}
3232 3233
3233void CalendarView::takeOverCalendar() 3234void CalendarView::takeOverCalendar()
3234{ 3235{
3235 // TODO: Create Calendar::allIncidences() function and use it here 3236 // TODO: Create Calendar::allIncidences() function and use it here
3236 3237
3237 QPtrList<Event> events = mCalendar->events(); 3238 QPtrList<Event> events = mCalendar->events();
3238 for(uint i=0; i<events.count(); ++i) { 3239 for(uint i=0; i<events.count(); ++i) {
3239 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3240 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3240 events.at(i)->recreate(); 3241 events.at(i)->recreate();
3241 events.at(i)->setReadOnly(false); 3242 events.at(i)->setReadOnly(false);
3242 } 3243 }
3243 3244
3244 QPtrList<Todo> todos = mCalendar->todos(); 3245 QPtrList<Todo> todos = mCalendar->todos();
3245 for(uint i=0; i<todos.count(); ++i) { 3246 for(uint i=0; i<todos.count(); ++i) {
3246 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3247 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3247 todos.at(i)->recreate(); 3248 todos.at(i)->recreate();
3248 todos.at(i)->setReadOnly(false); 3249 todos.at(i)->setReadOnly(false);
3249 } 3250 }
3250 3251
3251 QPtrList<Journal> journals = mCalendar->journals(); 3252 QPtrList<Journal> journals = mCalendar->journals();
3252 for(uint i=0; i<journals.count(); ++i) { 3253 for(uint i=0; i<journals.count(); ++i) {
3253 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3254 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3254 journals.at(i)->recreate(); 3255 journals.at(i)->recreate();
3255 journals.at(i)->setReadOnly(false); 3256 journals.at(i)->setReadOnly(false);
3256 } 3257 }
3257 3258
3258 updateView(); 3259 updateView();
3259} 3260}
3260 3261
3261void CalendarView::showIntro() 3262void CalendarView::showIntro()
3262{ 3263{
3263 kdDebug() << "To be implemented." << endl; 3264 kdDebug() << "To be implemented." << endl;
3264} 3265}
3265 3266
3266QWidgetStack *CalendarView::viewStack() 3267QWidgetStack *CalendarView::viewStack()
3267{ 3268{
3268 return mRightFrame; 3269 return mRightFrame;
3269} 3270}
3270 3271
3271QWidget *CalendarView::leftFrame() 3272QWidget *CalendarView::leftFrame()
3272{ 3273{
3273 return mLeftFrame; 3274 return mLeftFrame;
3274} 3275}
3275 3276
3276DateNavigator *CalendarView::dateNavigator() 3277DateNavigator *CalendarView::dateNavigator()
3277{ 3278{
3278 return mNavigator; 3279 return mNavigator;
3279} 3280}
3280 3281
3281KDateNavigator* CalendarView::dateNavigatorWidget() 3282KDateNavigator* CalendarView::dateNavigatorWidget()
3282{ 3283{
3283 return mDateNavigator; 3284 return mDateNavigator;
3284} 3285}
3285void CalendarView::toggleDateNavigatorWidget() 3286void CalendarView::toggleDateNavigatorWidget()
3286{ 3287{
3287 if (mDateNavigator->isVisible()) 3288 if (mDateNavigator->isVisible())
3288 mDateNavigator->hide(); 3289 mDateNavigator->hide();
3289 else 3290 else
3290 mDateNavigator->show(); 3291 mDateNavigator->show();
3291} 3292}
3292void CalendarView::addView(KOrg::BaseView *view) 3293void CalendarView::addView(KOrg::BaseView *view)
3293{ 3294{
3294 mViewManager->addView(view); 3295 mViewManager->addView(view);
3295} 3296}
3296 3297
3297void CalendarView::showView(KOrg::BaseView *view) 3298void CalendarView::showView(KOrg::BaseView *view)
3298{ 3299{
3299 mViewManager->showView(view, mLeftFrame->isVisible()); 3300 mViewManager->showView(view, mLeftFrame->isVisible());
3300} 3301}
3301 3302
3302Incidence *CalendarView::currentSelection() 3303Incidence *CalendarView::currentSelection()
3303{ 3304{
3304 return mViewManager->currentSelection(); 3305 return mViewManager->currentSelection();
3305} 3306}
3306void CalendarView::toggleAllDaySize() 3307void CalendarView::toggleAllDaySize()
3307{ 3308{
3308 /* 3309 /*
3309 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3310 if ( KOPrefs::instance()->mAllDaySize > 47 )
3310 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3311 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3311 else 3312 else
3312 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3313 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3313 */ 3314 */
3314 viewManager()->agendaView()->toggleAllDay(); 3315 viewManager()->agendaView()->toggleAllDay();
3315} 3316}
3316void CalendarView::toggleExpand() 3317void CalendarView::toggleExpand()
3317{ 3318{
3318 // if ( mLeftFrame->isHidden() ) { 3319 // if ( mLeftFrame->isHidden() ) {
3319 // mLeftFrame->show(); 3320 // mLeftFrame->show();
3320 // emit calendarViewExpanded( false ); 3321 // emit calendarViewExpanded( false );
3321 // } else { 3322 // } else {
3322 // mLeftFrame->hide(); 3323 // mLeftFrame->hide();
3323 // emit calendarViewExpanded( true ); 3324 // emit calendarViewExpanded( true );
3324 // } 3325 // }
3325 3326
3326 globalFlagBlockAgenda = 1; 3327 globalFlagBlockAgenda = 1;
3327 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3328 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3328 globalFlagBlockAgenda = 5; 3329 globalFlagBlockAgenda = 5;
3329 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3330 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3330 //mViewManager->showView( 0, true ); 3331 //mViewManager->showView( 0, true );
3331} 3332}
3332 3333
3333void CalendarView::calendarModified( bool modified, Calendar * ) 3334void CalendarView::calendarModified( bool modified, Calendar * )
3334{ 3335{
3335 setModified( modified ); 3336 setModified( modified );
3336} 3337}
3337 3338
3338Todo *CalendarView::selectedTodo() 3339Todo *CalendarView::selectedTodo()
3339{ 3340{
3340 Incidence *incidence = currentSelection(); 3341 Incidence *incidence = currentSelection();
3341 if ( incidence && incidence->type() == "Todo" ) { 3342 if ( incidence && incidence->type() == "Todo" ) {
3342 return static_cast<Todo *>( incidence ); 3343 return static_cast<Todo *>( incidence );
3343 } 3344 }
3344 3345
3345 incidence = mTodoList->selectedIncidences().first(); 3346 incidence = mTodoList->selectedIncidences().first();
3346 if ( incidence && incidence->type() == "Todo" ) { 3347 if ( incidence && incidence->type() == "Todo" ) {
3347 return static_cast<Todo *>( incidence ); 3348 return static_cast<Todo *>( incidence );
3348 } 3349 }
3349 3350
3350 return 0; 3351 return 0;
3351} 3352}
3352 3353
3353void CalendarView::dialogClosing(Incidence *in) 3354void CalendarView::dialogClosing(Incidence *in)
3354{ 3355{
3355 // mDialogList.remove(in); 3356 // mDialogList.remove(in);
3356} 3357}
3357 3358
3358void CalendarView::showIncidence() 3359void CalendarView::showIncidence()
3359{ 3360{
3360 Incidence *incidence = currentSelection(); 3361 Incidence *incidence = currentSelection();
3361 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3362 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3362 if ( incidence ) { 3363 if ( incidence ) {
3363 ShowIncidenceVisitor v; 3364 ShowIncidenceVisitor v;
3364 v.act( incidence, this ); 3365 v.act( incidence, this );
3365 } 3366 }
3366} 3367}
3367void CalendarView::editIncidenceDescription() 3368void CalendarView::editIncidenceDescription()
3368{ 3369{
3369 mFlagEditDescription = true; 3370 mFlagEditDescription = true;
3370 editIncidence(); 3371 editIncidence();
3371 mFlagEditDescription = false; 3372 mFlagEditDescription = false;
3372} 3373}
3373void CalendarView::editIncidence() 3374void CalendarView::editIncidence()
3374{ 3375{
3375 // qDebug("editIncidence() "); 3376 // qDebug("editIncidence() ");
3376 Incidence *incidence = currentSelection(); 3377 Incidence *incidence = currentSelection();
3377 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3378 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3378 if ( incidence ) { 3379 if ( incidence ) {
3379 EditIncidenceVisitor v; 3380 EditIncidenceVisitor v;
3380 v.act( incidence, this ); 3381 v.act( incidence, this );
3381 } 3382 }
3382} 3383}
3383 3384
3384void CalendarView::deleteIncidence() 3385void CalendarView::deleteIncidence()
3385{ 3386{
3386 Incidence *incidence = currentSelection(); 3387 Incidence *incidence = currentSelection();
3387 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3388 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3388 if ( incidence ) { 3389 if ( incidence ) {
3389 deleteIncidence(incidence); 3390 deleteIncidence(incidence);
3390 } 3391 }
3391} 3392}
3392 3393
3393void CalendarView::showIncidence(Incidence *incidence) 3394void CalendarView::showIncidence(Incidence *incidence)
3394{ 3395{
3395 if ( incidence ) { 3396 if ( incidence ) {
3396 ShowIncidenceVisitor v; 3397 ShowIncidenceVisitor v;
3397 v.act( incidence, this ); 3398 v.act( incidence, this );
3398 } 3399 }
3399} 3400}
3400 3401
3401void CalendarView::editIncidence(Incidence *incidence) 3402void CalendarView::editIncidence(Incidence *incidence)
3402{ 3403{
3403 if ( incidence ) { 3404 if ( incidence ) {
3404 3405
3405 EditIncidenceVisitor v; 3406 EditIncidenceVisitor v;
3406 v.act( incidence, this ); 3407 v.act( incidence, this );
3407 3408
3408 } 3409 }
3409} 3410}
3410 3411
3411void CalendarView::deleteIncidence(Incidence *incidence) 3412void CalendarView::deleteIncidence(Incidence *incidence)
3412{ 3413{
3413 //qDebug(" CalendarView::deleteIncidence "); 3414 //qDebug(" CalendarView::deleteIncidence ");
3414 if ( incidence ) { 3415 if ( incidence ) {
3415 DeleteIncidenceVisitor v; 3416 DeleteIncidenceVisitor v;
3416 v.act( incidence, this ); 3417 v.act( incidence, this );
3417 } 3418 }
3418} 3419}
3419 3420
3420 3421
3421void CalendarView::lookForOutgoingMessages() 3422void CalendarView::lookForOutgoingMessages()
3422{ 3423{
3423 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3424 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3424 ogd->loadMessages(); 3425 ogd->loadMessages();
3425} 3426}
3426 3427
3427void CalendarView::lookForIncomingMessages() 3428void CalendarView::lookForIncomingMessages()
3428{ 3429{
3429 IncomingDialog *icd = mDialogManager->incomingDialog(); 3430 IncomingDialog *icd = mDialogManager->incomingDialog();
3430 icd->retrieve(); 3431 icd->retrieve();
3431} 3432}
3432 3433
3433bool CalendarView::removeCompletedSubTodos( Todo* t ) 3434bool CalendarView::removeCompletedSubTodos( Todo* t )
3434{ 3435{
3435 bool deleteTodo = true; 3436 bool deleteTodo = true;
3436 QPtrList<Incidence> subTodos; 3437 QPtrList<Incidence> subTodos;
3437 Incidence *aTodo; 3438 Incidence *aTodo;
3438 subTodos = t->relations(); 3439 subTodos = t->relations();
3439 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3440 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3440 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3441 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3441 deleteTodo = false; 3442 deleteTodo = false;
3442 } 3443 }
3443 if ( deleteTodo ) { 3444 if ( deleteTodo ) {
3444 if ( t->isCompleted() ) { 3445 if ( t->isCompleted() ) {
3445 checkZaurusId( t->zaurusId(), true ); 3446 checkZaurusId( t->zaurusId(), true );
3446 mCalendar->deleteTodo( t ); 3447 mCalendar->deleteTodo( t );
3447 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3448 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3448 } 3449 }
3449 else 3450 else
3450 deleteTodo = false; 3451 deleteTodo = false;
3451 } 3452 }
3452 return deleteTodo; 3453 return deleteTodo;
3453 3454
3454} 3455}
3455void CalendarView::purgeCompleted() 3456void CalendarView::purgeCompleted()
3456{ 3457{
3457 int result = KMessageBox::warningContinueCancel(this, 3458 int result = KMessageBox::warningContinueCancel(this,
3458 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3459 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3459 3460
3460 if (result == KMessageBox::Continue) { 3461 if (result == KMessageBox::Continue) {
3461 3462
3462 QPtrList<Todo> todoCal; 3463 QPtrList<Todo> todoCal;
3463 QPtrList<Todo> rootTodos; 3464 QPtrList<Todo> rootTodos;
3464 //QPtrList<Incidence> rel; 3465 //QPtrList<Incidence> rel;
3465 Todo *aTodo;//, *rTodo; 3466 Todo *aTodo;//, *rTodo;
3466 Incidence *rIncidence; 3467 Incidence *rIncidence;
3467 bool childDelete = false; 3468 bool childDelete = false;
3468 bool deletedOne = true; 3469 bool deletedOne = true;
3469 todoCal = calendar()->todos(); 3470 todoCal = calendar()->todos();
3470 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3471 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3471 if ( !aTodo->relatedTo() ) 3472 if ( !aTodo->relatedTo() )
3472 rootTodos.append( aTodo ); 3473 rootTodos.append( aTodo );
3473 } 3474 }
3474 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3475 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3475 removeCompletedSubTodos( aTodo ); 3476 removeCompletedSubTodos( aTodo );
3476 } 3477 }
3477 3478
3478 updateView(); 3479 updateView();
3479 } 3480 }
3480} 3481}
3481 3482
3482void CalendarView::slotCalendarChanged() 3483void CalendarView::slotCalendarChanged()
3483{ 3484{
3484 ; 3485 ;
3485} 3486}
3486 3487
3487NavigatorBar *CalendarView::navigatorBar() 3488NavigatorBar *CalendarView::navigatorBar()
3488{ 3489{
3489 return mNavigatorBar; 3490 return mNavigatorBar;
3490} 3491}
3491 3492
3492 3493
3493 3494
3494void CalendarView::keyPressEvent ( QKeyEvent *e) 3495void CalendarView::keyPressEvent ( QKeyEvent *e)
3495{ 3496{
3496 //qDebug(" alendarView::keyPressEvent "); 3497 //qDebug(" alendarView::keyPressEvent ");
3497 e->ignore(); 3498 e->ignore();
3498} 3499}
3499 3500
3500//#include "calendarview.moc" 3501//#include "calendarview.moc"
3501 3502
3502//#include "calendarviewbase.moc" 3503//#include "calendarviewbase.moc"
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp
index f83f72e..973f19d 100644
--- a/libkcal/sharpformat.cpp
+++ b/libkcal/sharpformat.cpp
@@ -1,1007 +1,1008 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 3
4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include <qdatetime.h> 22#include <qdatetime.h>
23#include <qstring.h> 23#include <qstring.h>
24#include <qapplication.h> 24#include <qapplication.h>
25#include <qptrlist.h> 25#include <qptrlist.h>
26#include <qregexp.h> 26#include <qregexp.h>
27#include <qmessagebox.h> 27#include <qmessagebox.h>
28#include <qclipboard.h> 28#include <qclipboard.h>
29#include <qfile.h> 29#include <qfile.h>
30#include <qtextstream.h> 30#include <qtextstream.h>
31#include <qtextcodec.h> 31#include <qtextcodec.h>
32#include <qxml.h> 32#include <qxml.h>
33#include <qlabel.h> 33#include <qlabel.h>
34 34
35#include <kdebug.h> 35#include <kdebug.h>
36#include <klocale.h> 36#include <klocale.h>
37#include <kglobal.h> 37#include <kglobal.h>
38 38
39#include "calendar.h" 39#include "calendar.h"
40#include "alarm.h" 40#include "alarm.h"
41#include "recurrence.h" 41#include "recurrence.h"
42#include "calendarlocal.h" 42#include "calendarlocal.h"
43 43
44#include "sharpformat.h" 44#include "sharpformat.h"
45#include "syncdefines.h"
45 46
46using namespace KCal; 47using namespace KCal;
47 48
48//CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY 49//CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY
49// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 50// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
50 51
51//ARSD silentalarm = 0 52//ARSD silentalarm = 0
52// 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly 53// 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly
53// 12 RFRQ 54// 12 RFRQ
54// 13 RPOS pos = 4. monday in month 55// 13 RPOS pos = 4. monday in month
55// 14 RDYS days: 1 mon/ 2 tue .. 64 sun 56// 14 RDYS days: 1 mon/ 2 tue .. 64 sun
56// 15 REND 0 = no end/ 1 = end 57// 15 REND 0 = no end/ 1 = end
57// 16 REDT rec end dt 58// 16 REDT rec end dt
58//ALSD 59//ALSD
59//ALED 60//ALED
60//MDAY 61//MDAY
61 62
62class SharpParser : public QObject 63class SharpParser : public QObject
63{ 64{
64 public: 65 public:
65 SharpParser( Calendar *calendar ) : mCalendar( calendar ) { 66 SharpParser( Calendar *calendar ) : mCalendar( calendar ) {
66 oldCategories = 0; 67 oldCategories = 0;
67 } 68 }
68 69
69 bool startElement( Calendar *existingCalendar, const QStringList & attList, QString qName ) 70 bool startElement( Calendar *existingCalendar, const QStringList & attList, QString qName )
70 { 71 {
71 int i = 1; 72 int i = 1;
72 bool skip = true; 73 bool skip = true;
73 int max = attList.count() -2; 74 int max = attList.count() -2;
74 while ( i < max ) { 75 while ( i < max ) {
75 if ( !attList[i].isEmpty() ) { 76 if ( !attList[i].isEmpty() ) {
76 skip = false; 77 skip = false;
77 break; 78 break;
78 } 79 }
79 ++i ; 80 ++i ;
80 } 81 }
81 if ( skip ) 82 if ( skip )
82 return false; 83 return false;
83 ulong cSum = SharpFormat::getCsum(attList ); 84 ulong cSum = SharpFormat::getCsum(attList );
84 85
85 if ( qName == "Event" ) { 86 if ( qName == "Event" ) {
86 Event *event; 87 Event *event;
87 event = existingCalendar->event( attList[0].toInt() ); 88 event = existingCalendar->event( attList[0].toInt() );
88 if ( event ) 89 if ( event )
89 event = (Event*)event->clone(); 90 event = (Event*)event->clone();
90 else 91 else
91 event = new Event; 92 event = new Event;
92 event->setZaurusId( attList[0].toInt() ); 93 event->setZaurusId( attList[0].toInt() );
93 event->setZaurusUid( cSum ); 94 event->setZaurusUid( cSum );
94 event->setZaurusStat( -2 ); 95 event->setZaurusStat(SYNC_TEMPSTATE_NEW_EXTERNAL );
95 96
96 event->setSummary( attList[2] ); 97 event->setSummary( attList[2] );
97 event->setLocation( attList[3] ); 98 event->setLocation( attList[3] );
98 event->setDescription( attList[4] ); 99 event->setDescription( attList[4] );
99 if ( attList[7] == "1" ) { 100 if ( attList[7] == "1" ) {
100 event->setDtStart( QDateTime(fromString( attList[17]+"000000", false ).date(),QTime(0,0,0 ) )); 101 event->setDtStart( QDateTime(fromString( attList[17]+"000000", false ).date(),QTime(0,0,0 ) ));
101 event->setDtEnd( QDateTime(fromString( attList[18]+"000000", false ).date(),QTime(0,0,0 ))); 102 event->setDtEnd( QDateTime(fromString( attList[18]+"000000", false ).date(),QTime(0,0,0 )));
102 event->setFloats( true ); 103 event->setFloats( true );
103 } else { 104 } else {
104 event->setFloats( false ); 105 event->setFloats( false );
105 event->setDtStart( fromString( attList[5] ) ); 106 event->setDtStart( fromString( attList[5] ) );
106 event->setDtEnd( fromString( attList[6] )); 107 event->setDtEnd( fromString( attList[6] ));
107 } 108 }
108 109
109 QString rtype = attList[11]; 110 QString rtype = attList[11];
110 if ( rtype != "255" ) { 111 if ( rtype != "255" ) {
111 // qDebug("recurs "); 112 // qDebug("recurs ");
112 QDate startDate = event->dtStart().date(); 113 QDate startDate = event->dtStart().date();
113 114
114 QString freqStr = attList[12]; 115 QString freqStr = attList[12];
115 int freq = freqStr.toInt(); 116 int freq = freqStr.toInt();
116 117
117 QString hasEndDateStr = attList[15] ; 118 QString hasEndDateStr = attList[15] ;
118 bool hasEndDate = hasEndDateStr == "1"; 119 bool hasEndDate = hasEndDateStr == "1";
119 120
120 QString endDateStr = attList[16]; 121 QString endDateStr = attList[16];
121 QDate endDate = fromString( endDateStr ).date(); 122 QDate endDate = fromString( endDateStr ).date();
122 123
123 QString weekDaysStr = attList[14]; 124 QString weekDaysStr = attList[14];
124 uint weekDaysNum = weekDaysStr.toInt(); 125 uint weekDaysNum = weekDaysStr.toInt();
125 126
126 QBitArray weekDays( 7 ); 127 QBitArray weekDays( 7 );
127 int i; 128 int i;
128 int bb = 1; 129 int bb = 1;
129 for( i = 1; i <= 7; ++i ) { 130 for( i = 1; i <= 7; ++i ) {
130 weekDays.setBit( i - 1, ( bb & weekDaysNum )); 131 weekDays.setBit( i - 1, ( bb & weekDaysNum ));
131 bb = 2 << (i-1); 132 bb = 2 << (i-1);
132 //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); 133 //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) );
133 } 134 }
134 // qDebug("next "); 135 // qDebug("next ");
135 QString posStr = attList[13]; 136 QString posStr = attList[13];
136 int pos = posStr.toInt(); 137 int pos = posStr.toInt();
137 Recurrence *r = event->recurrence(); 138 Recurrence *r = event->recurrence();
138 139
139 if ( rtype == "0" ) { 140 if ( rtype == "0" ) {
140 if ( hasEndDate ) r->setDaily( freq, endDate ); 141 if ( hasEndDate ) r->setDaily( freq, endDate );
141 else r->setDaily( freq, -1 ); 142 else r->setDaily( freq, -1 );
142 } else if ( rtype == "1" ) { 143 } else if ( rtype == "1" ) {
143 if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); 144 if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate );
144 else r->setWeekly( freq, weekDays, -1 ); 145 else r->setWeekly( freq, weekDays, -1 );
145 } else if ( rtype == "3" ) { 146 } else if ( rtype == "3" ) {
146 if ( hasEndDate ) 147 if ( hasEndDate )
147 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); 148 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate );
148 else 149 else
149 r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); 150 r->setMonthly( Recurrence::rMonthlyDay, freq, -1 );
150 r->addMonthlyDay( startDate.day() ); 151 r->addMonthlyDay( startDate.day() );
151 } else if ( rtype == "2" ) { 152 } else if ( rtype == "2" ) {
152 if ( hasEndDate ) 153 if ( hasEndDate )
153 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); 154 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate );
154 else 155 else
155 r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); 156 r->setMonthly( Recurrence::rMonthlyPos, freq, -1 );
156 QBitArray days( 7 ); 157 QBitArray days( 7 );
157 days.fill( false ); 158 days.fill( false );
158 days.setBit( startDate.dayOfWeek() - 1 ); 159 days.setBit( startDate.dayOfWeek() - 1 );
159 r->addMonthlyPos( pos, days ); 160 r->addMonthlyPos( pos, days );
160 } else if ( rtype == "4" ) { 161 } else if ( rtype == "4" ) {
161 if ( hasEndDate ) 162 if ( hasEndDate )
162 r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); 163 r->setYearly( Recurrence::rYearlyMonth, freq, endDate );
163 else 164 else
164 r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); 165 r->setYearly( Recurrence::rYearlyMonth, freq, -1 );
165 r->addYearlyNum( startDate.month() ); 166 r->addYearlyNum( startDate.month() );
166 } 167 }
167 } 168 }
168 169
169 QString categoryList = attList[1] ; 170 QString categoryList = attList[1] ;
170 event->setCategories( lookupCategories( categoryList ) ); 171 event->setCategories( lookupCategories( categoryList ) );
171 172
172 // strange 0 semms to mean: alarm enabled 173 // strange 0 semms to mean: alarm enabled
173 if ( attList[8] == "0" ) { 174 if ( attList[8] == "0" ) {
174 Alarm *alarm; 175 Alarm *alarm;
175 if ( event->alarms().count() > 0 ) 176 if ( event->alarms().count() > 0 )
176 alarm = event->alarms().first(); 177 alarm = event->alarms().first();
177 else { 178 else {
178 alarm = new Alarm( event ); 179 alarm = new Alarm( event );
179 event->addAlarm( alarm ); 180 event->addAlarm( alarm );
180 } 181 }
181 alarm->setType( Alarm::Audio ); 182 alarm->setType( Alarm::Audio );
182 alarm->setEnabled( true ); 183 alarm->setEnabled( true );
183 int alarmOffset = attList[9].toInt(); 184 int alarmOffset = attList[9].toInt();
184 alarm->setStartOffset( alarmOffset * -60 ); 185 alarm->setStartOffset( alarmOffset * -60 );
185 } 186 }
186 187
187 mCalendar->addEvent( event); 188 mCalendar->addEvent( event);
188 } else if ( qName == "Todo" ) { 189 } else if ( qName == "Todo" ) {
189 Todo *todo; 190 Todo *todo;
190 191
191 todo = existingCalendar->todo( attList[0].toInt() ); 192 todo = existingCalendar->todo( attList[0].toInt() );
192 if (todo ) 193 if (todo )
193 todo = (Todo*)todo->clone(); 194 todo = (Todo*)todo->clone();
194 else 195 else
195 todo = new Todo; 196 todo = new Todo;
196 197
197//CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1 198//CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1
198// 0 1 2 3 4 5 6 7 8 199// 0 1 2 3 4 5 6 7 8
199//1,,,,,1,4,Loch zumachen,"" 200//1,,,,,1,4,Loch zumachen,""
200//3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" " 201//3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" "
201//2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes 202//2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes
202 203
203 todo->setZaurusId( attList[0].toInt() ); 204 todo->setZaurusId( attList[0].toInt() );
204 todo->setZaurusUid( cSum ); 205 todo->setZaurusUid( cSum );
205 todo->setZaurusStat( -2 ); 206 todo->setZaurusStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
206 207
207 todo->setSummary( attList[7] ); 208 todo->setSummary( attList[7] );
208 todo->setDescription( attList[8]); 209 todo->setDescription( attList[8]);
209 210
210 int priority = attList[6].toInt(); 211 int priority = attList[6].toInt();
211 if ( priority == 0 ) priority = 3; 212 if ( priority == 0 ) priority = 3;
212 todo->setPriority( priority ); 213 todo->setPriority( priority );
213 214
214 QString categoryList = attList[1]; 215 QString categoryList = attList[1];
215 todo->setCategories( lookupCategories( categoryList ) ); 216 todo->setCategories( lookupCategories( categoryList ) );
216 217
217 218
218 219
219 QString hasDateStr = attList[3]; // due 220 QString hasDateStr = attList[3]; // due
220 if ( !hasDateStr.isEmpty() ) { 221 if ( !hasDateStr.isEmpty() ) {
221 if ( hasDateStr.right(6) == "000000" ) { 222 if ( hasDateStr.right(6) == "000000" ) {
222 todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) ); 223 todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) );
223 todo->setFloats( true ); 224 todo->setFloats( true );
224 } 225 }
225 else { 226 else {
226 todo->setDtDue( fromString( hasDateStr ) ); 227 todo->setDtDue( fromString( hasDateStr ) );
227 todo->setFloats( false ); 228 todo->setFloats( false );
228 } 229 }
229 230
230 todo->setHasDueDate( true ); 231 todo->setHasDueDate( true );
231 } 232 }
232 hasDateStr = attList[2];//start 233 hasDateStr = attList[2];//start
233 if ( !hasDateStr.isEmpty() ) { 234 if ( !hasDateStr.isEmpty() ) {
234 235
235 todo->setDtStart( fromString( hasDateStr ) ); 236 todo->setDtStart( fromString( hasDateStr ) );
236 todo->setHasStartDate( true); 237 todo->setHasStartDate( true);
237 } else 238 } else
238 todo->setHasStartDate( false ); 239 todo->setHasStartDate( false );
239 hasDateStr = attList[4];//completed 240 hasDateStr = attList[4];//completed
240 if ( !hasDateStr.isEmpty() ) { 241 if ( !hasDateStr.isEmpty() ) {
241 todo->setCompleted(fromString( hasDateStr ) ); 242 todo->setCompleted(fromString( hasDateStr ) );
242 } 243 }
243 QString completedStr = attList[5]; 244 QString completedStr = attList[5];
244 if ( completedStr == "0" ) 245 if ( completedStr == "0" )
245 todo->setCompleted( true ); 246 todo->setCompleted( true );
246 else 247 else
247 todo->setCompleted( false ); 248 todo->setCompleted( false );
248 mCalendar->addTodo( todo ); 249 mCalendar->addTodo( todo );
249 250
250 } else if ( qName == "Category" ) { 251 } else if ( qName == "Category" ) {
251 /* 252 /*
252 QString id = attributes.value( "id" ); 253 QString id = attributes.value( "id" );
253 QString name = attributes.value( "name" ); 254 QString name = attributes.value( "name" );
254 setCategory( id, name ); 255 setCategory( id, name );
255 */ 256 */
256 } 257 }
257 //qDebug("end "); 258 //qDebug("end ");
258 return true; 259 return true;
259 } 260 }
260 261
261 262
262 void setCategoriesList ( QStringList * c ) 263 void setCategoriesList ( QStringList * c )
263 { 264 {
264 oldCategories = c; 265 oldCategories = c;
265 } 266 }
266 267
267 QDateTime fromString ( QString s, bool useTz = true ) { 268 QDateTime fromString ( QString s, bool useTz = true ) {
268 QDateTime dt; 269 QDateTime dt;
269 int y,m,t,h,min,sec; 270 int y,m,t,h,min,sec;
270 y = s.mid(0,4).toInt(); 271 y = s.mid(0,4).toInt();
271 m = s.mid(4,2).toInt(); 272 m = s.mid(4,2).toInt();
272 t = s.mid(6,2).toInt(); 273 t = s.mid(6,2).toInt();
273 h = s.mid(9,2).toInt(); 274 h = s.mid(9,2).toInt();
274 min = s.mid(11,2).toInt(); 275 min = s.mid(11,2).toInt();
275 sec = s.mid(13,2).toInt(); 276 sec = s.mid(13,2).toInt();
276 dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); 277 dt = QDateTime(QDate(y,m,t), QTime(h,min,sec));
277 int offset = KGlobal::locale()->localTimeOffset( dt ); 278 int offset = KGlobal::locale()->localTimeOffset( dt );
278 if ( useTz ) 279 if ( useTz )
279 dt = dt.addSecs ( offset*60); 280 dt = dt.addSecs ( offset*60);
280 return dt; 281 return dt;
281 282
282 } 283 }
283 protected: 284 protected:
284 QDateTime toDateTime( const QString &value ) 285 QDateTime toDateTime( const QString &value )
285 { 286 {
286 QDateTime dt; 287 QDateTime dt;
287 dt.setTime_t( value.toUInt() ); 288 dt.setTime_t( value.toUInt() );
288 289
289 return dt; 290 return dt;
290 } 291 }
291 292
292 QStringList lookupCategories( const QString &categoryList ) 293 QStringList lookupCategories( const QString &categoryList )
293 { 294 {
294 QStringList categoryIds = QStringList::split( ";", categoryList ); 295 QStringList categoryIds = QStringList::split( ";", categoryList );
295 QStringList categories; 296 QStringList categories;
296 QStringList::ConstIterator it; 297 QStringList::ConstIterator it;
297 for( it = categoryIds.begin(); it != categoryIds.end(); ++it ) { 298 for( it = categoryIds.begin(); it != categoryIds.end(); ++it ) {
298 QString cate = category( *it ); 299 QString cate = category( *it );
299 if ( oldCategories ) { 300 if ( oldCategories ) {
300 if ( ! oldCategories->contains( cate ) ) 301 if ( ! oldCategories->contains( cate ) )
301 oldCategories->append( cate ); 302 oldCategories->append( cate );
302 } 303 }
303 categories.append(cate ); 304 categories.append(cate );
304 } 305 }
305 return categories; 306 return categories;
306 } 307 }
307 308
308 private: 309 private:
309 Calendar *mCalendar; 310 Calendar *mCalendar;
310 QStringList * oldCategories; 311 QStringList * oldCategories;
311 static QString category( const QString &id ) 312 static QString category( const QString &id )
312 { 313 {
313 QMap<QString,QString>::ConstIterator it = mCategoriesMap.find( id ); 314 QMap<QString,QString>::ConstIterator it = mCategoriesMap.find( id );
314 if ( it == mCategoriesMap.end() ) return id; 315 if ( it == mCategoriesMap.end() ) return id;
315 else return *it; 316 else return *it;
316 } 317 }
317 318
318 static void setCategory( const QString &id, const QString &name ) 319 static void setCategory( const QString &id, const QString &name )
319 { 320 {
320 mCategoriesMap.insert( id, name ); 321 mCategoriesMap.insert( id, name );
321 } 322 }
322 323
323 static QMap<QString,QString> mCategoriesMap; 324 static QMap<QString,QString> mCategoriesMap;
324}; 325};
325 326
326QMap<QString,QString> SharpParser::mCategoriesMap; 327QMap<QString,QString> SharpParser::mCategoriesMap;
327 328
328SharpFormat::SharpFormat() 329SharpFormat::SharpFormat()
329{ 330{
330 mCategories = 0; 331 mCategories = 0;
331} 332}
332 333
333SharpFormat::~SharpFormat() 334SharpFormat::~SharpFormat()
334{ 335{
335} 336}
336ulong SharpFormat::getCsum( const QStringList & attList) 337ulong SharpFormat::getCsum( const QStringList & attList)
337{ 338{
338 int max = attList.count() -1; 339 int max = attList.count() -1;
339 ulong cSum = 0; 340 ulong cSum = 0;
340 int j,k,i; 341 int j,k,i;
341 int add; 342 int add;
342 for ( i = 1; i < max ; ++i ) { 343 for ( i = 1; i < max ; ++i ) {
343 QString s = attList[i]; 344 QString s = attList[i];
344 if ( ! s.isEmpty() ){ 345 if ( ! s.isEmpty() ){
345 j = s.length(); 346 j = s.length();
346 for ( k = 0; k < j; ++k ) { 347 for ( k = 0; k < j; ++k ) {
347 int mul = k +1; 348 int mul = k +1;
348 add = s[k].unicode (); 349 add = s[k].unicode ();
349 if ( k < 16 ) 350 if ( k < 16 )
350 mul = mul * mul; 351 mul = mul * mul;
351 add = add * mul *i*i*i; 352 add = add * mul *i*i*i;
352 cSum += add; 353 cSum += add;
353 } 354 }
354 } 355 }
355 } 356 }
356 return cSum; 357 return cSum;
357 358
358} 359}
359#include <stdlib.h> 360#include <stdlib.h>
360#define DEBUGMODE false 361#define DEBUGMODE false
361bool SharpFormat::load( Calendar *calendar, Calendar *existngCal ) 362bool SharpFormat::load( Calendar *calendar, Calendar *existngCal )
362{ 363{
363 364
364 365
365 bool debug = DEBUGMODE; 366 bool debug = DEBUGMODE;
366 //debug = true; 367 //debug = true;
367 QString text; 368 QString text;
368 QString codec = "utf8"; 369 QString codec = "utf8";
369 QLabel status ( i18n("Reading events ..."), 0 ); 370 QLabel status ( i18n("Reading events ..."), 0 );
370 371
371 int w = status.sizeHint().width()+20 ; 372 int w = status.sizeHint().width()+20 ;
372 if ( w < 200 ) w = 200; 373 if ( w < 200 ) w = 200;
373 int h = status.sizeHint().height()+20 ; 374 int h = status.sizeHint().height()+20 ;
374 int dw = QApplication::desktop()->width(); 375 int dw = QApplication::desktop()->width();
375 int dh = QApplication::desktop()->height(); 376 int dh = QApplication::desktop()->height();
376 status.setCaption(i18n("Reading DTM Data") ); 377 status.setCaption(i18n("Reading DTM Data") );
377 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 378 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
378 status.show(); 379 status.show();
379 status.raise(); 380 status.raise();
380 qApp->processEvents(); 381 qApp->processEvents();
381 QString fileName; 382 QString fileName;
382 if ( ! debug ) { 383 if ( ! debug ) {
383 fileName = "/tmp/kopitempout"; 384 fileName = "/tmp/kopitempout";
384 QString command ="db2file datebook -r -c "+ codec + " > " + fileName; 385 QString command ="db2file datebook -r -c "+ codec + " > " + fileName;
385 system ( command.latin1() ); 386 system ( command.latin1() );
386 } else { 387 } else {
387 fileName = "/tmp/events.txt"; 388 fileName = "/tmp/events.txt";
388 389
389 } 390 }
390 QFile file( fileName ); 391 QFile file( fileName );
391 if (!file.open( IO_ReadOnly ) ) { 392 if (!file.open( IO_ReadOnly ) ) {
392 return false; 393 return false;
393 394
394 } 395 }
395 QTextStream ts( &file ); 396 QTextStream ts( &file );
396 ts.setCodec( QTextCodec::codecForName("utf8") ); 397 ts.setCodec( QTextCodec::codecForName("utf8") );
397 text = ts.read(); 398 text = ts.read();
398 file.close(); 399 file.close();
399 status.setText( i18n("Processing events ...") ); 400 status.setText( i18n("Processing events ...") );
400 status.raise(); 401 status.raise();
401 qApp->processEvents(); 402 qApp->processEvents();
402 fromString2Cal( calendar, existngCal, text, "Event" ); 403 fromString2Cal( calendar, existngCal, text, "Event" );
403 status.setText( i18n("Reading todos ...") ); 404 status.setText( i18n("Reading todos ...") );
404 qApp->processEvents(); 405 qApp->processEvents();
405 if ( ! debug ) { 406 if ( ! debug ) {
406 fileName = "/tmp/kopitempout"; 407 fileName = "/tmp/kopitempout";
407 QString command = "db2file todo -r -c " + codec+ " > " + fileName; 408 QString command = "db2file todo -r -c " + codec+ " > " + fileName;
408 system ( command.latin1() ); 409 system ( command.latin1() );
409 } else { 410 } else {
410 fileName = "/tmp/todo.txt"; 411 fileName = "/tmp/todo.txt";
411 } 412 }
412 file.setName( fileName ); 413 file.setName( fileName );
413 if (!file.open( IO_ReadOnly ) ) { 414 if (!file.open( IO_ReadOnly ) ) {
414 return false; 415 return false;
415 416
416 } 417 }
417 ts.setDevice( &file ); 418 ts.setDevice( &file );
418 text = ts.read(); 419 text = ts.read();
419 file.close(); 420 file.close();
420 421
421 status.setText( i18n("Processing todos ...") ); 422 status.setText( i18n("Processing todos ...") );
422 status.raise(); 423 status.raise();
423 qApp->processEvents(); 424 qApp->processEvents();
424 fromString2Cal( calendar, existngCal, text, "Todo" ); 425 fromString2Cal( calendar, existngCal, text, "Todo" );
425 return true; 426 return true;
426} 427}
427int SharpFormat::getNumFromRecord( QString answer, Incidence* inc ) 428int SharpFormat::getNumFromRecord( QString answer, Incidence* inc )
428{ 429{
429 int retval = -1; 430 int retval = -1;
430 QStringList templist; 431 QStringList templist;
431 QString tempString; 432 QString tempString;
432 int start = 0; 433 int start = 0;
433 int len = answer.length(); 434 int len = answer.length();
434 int end = answer.find ("\n",start)+1; 435 int end = answer.find ("\n",start)+1;
435 bool ok = true; 436 bool ok = true;
436 start = end; 437 start = end;
437 int ccc = 0; 438 int ccc = 0;
438 while ( start > 0 ) { 439 while ( start > 0 ) {
439 templist.clear(); 440 templist.clear();
440 ok = true; 441 ok = true;
441 int loopCount = 0; 442 int loopCount = 0;
442 while ( ok ) { 443 while ( ok ) {
443 ++loopCount; 444 ++loopCount;
444 if ( loopCount > 25 ) { 445 if ( loopCount > 25 ) {
445 qDebug("KO: Error in while loop"); 446 qDebug("KO: Error in while loop");
446 ok = false; 447 ok = false;
447 start = 0; 448 start = 0;
448 break; 449 break;
449 } 450 }
450 if ( ok ) 451 if ( ok )
451 tempString = getPart( answer, ok, start ); 452 tempString = getPart( answer, ok, start );
452 if ( start >= len || start == 0 ) { 453 if ( start >= len || start == 0 ) {
453 start = 0; 454 start = 0;
454 ok = false; 455 ok = false;
455 } 456 }
456 if ( tempString.right(1) =="\n" ) 457 if ( tempString.right(1) =="\n" )
457 tempString = tempString.left( tempString.length()-1); 458 tempString = tempString.left( tempString.length()-1);
458 459
459 templist.append( tempString ); 460 templist.append( tempString );
460 } 461 }
461 ++ccc; 462 ++ccc;
462 if ( ccc == 2 && loopCount < 25 ) { 463 if ( ccc == 2 && loopCount < 25 ) {
463 start = 0; 464 start = 0;
464 bool ok; 465 bool ok;
465 int newnum = templist[0].toInt( &ok ); 466 int newnum = templist[0].toInt( &ok );
466 if ( ok && newnum > 0) { 467 if ( ok && newnum > 0) {
467 retval = newnum; 468 retval = newnum;
468 inc->setZaurusId( newnum ); 469 inc->setZaurusId( newnum );
469 inc->setZaurusUid( getCsum( templist ) ); 470 inc->setZaurusUid( getCsum( templist ) );
470 inc->setZaurusStat( -4 ); 471 inc->setZaurusStat( SYNC_TEMPSTATE_NEW_ID );
471 } 472 }
472 } 473 }
473 } 474 }
474 //qDebug("getNumFromRecord returning : %d ", retval); 475 //qDebug("getNumFromRecord returning : %d ", retval);
475 return retval; 476 return retval;
476} 477}
477bool SharpFormat::save( Calendar *calendar) 478bool SharpFormat::save( Calendar *calendar)
478{ 479{
479 480
480 QLabel status ( i18n("Processing/adding events ..."), 0 ); 481 QLabel status ( i18n("Processing/adding events ..."), 0 );
481 int w = status.sizeHint().width()+20 ; 482 int w = status.sizeHint().width()+20 ;
482 if ( w < 200 ) w = 200; 483 if ( w < 200 ) w = 200;
483 int h = status.sizeHint().height()+20 ; 484 int h = status.sizeHint().height()+20 ;
484 int dw = QApplication::desktop()->width(); 485 int dw = QApplication::desktop()->width();
485 int dh = QApplication::desktop()->height(); 486 int dh = QApplication::desktop()->height();
486 status.setCaption(i18n("Writing DTM Data") ); 487 status.setCaption(i18n("Writing DTM Data") );
487 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 488 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
488 status.show(); 489 status.show();
489 status.raise(); 490 status.raise();
490 qApp->processEvents(); 491 qApp->processEvents();
491 bool debug = DEBUGMODE; 492 bool debug = DEBUGMODE;
492 QString codec = "utf8"; 493 QString codec = "utf8";
493 QString answer; 494 QString answer;
494 QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n"; 495 QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n";
495 QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n"; 496 QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n";
496 QString command; 497 QString command;
497 QPtrList<Event> er = calendar->rawEvents(); 498 QPtrList<Event> er = calendar->rawEvents();
498 Event* ev = er.first(); 499 Event* ev = er.first();
499 QString fileName = "/tmp/kopitempout"; 500 QString fileName = "/tmp/kopitempout";
500 int i = 0; 501 int i = 0;
501 QString changeString = ePrefix; 502 QString changeString = ePrefix;
502 QString deleteString = ePrefix; 503 QString deleteString = ePrefix;
503 bool deleteEnt = false; 504 bool deleteEnt = false;
504 bool changeEnt = false; 505 bool changeEnt = false;
505 QString message = i18n("Processing event # "); 506 QString message = i18n("Processing event # ");
506 int procCount = 0; 507 int procCount = 0;
507 while ( ev ) { 508 while ( ev ) {
508 //qDebug("i %d ", ++i); 509 //qDebug("i %d ", ++i);
509 if ( ev->zaurusStat() != -2 ) { 510 if ( ev->zaurusStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
510 status.setText ( message + QString::number ( ++procCount ) ); 511 status.setText ( message + QString::number ( ++procCount ) );
511 qApp->processEvents(); 512 qApp->processEvents();
512 QString eString = getEventString( ev ); 513 QString eString = getEventString( ev );
513 if ( ev->zaurusStat() == -3 ) { // delete 514 if ( ev->zaurusStat() == SYNC_TEMPSTATE_DELETE ) { // delete
514 // deleting empty strings does not work. 515 // deleting empty strings does not work.
515 // we write first and x and then delete the record with the x 516 // we write first and x and then delete the record with the x
516 eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); 517 eString = eString.replace( QRegExp(",\"\""),",\"x\"" );
517 changeString += eString + "\n"; 518 changeString += eString + "\n";
518 deleteString += eString + "\n"; 519 deleteString += eString + "\n";
519 deleteEnt = true; 520 deleteEnt = true;
520 changeEnt = true; 521 changeEnt = true;
521 } 522 }
522 else if ( ev->zaurusId() == -1 ) { // add new 523 else if ( ev->zaurusId() == -1 ) { // add new
523 command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; 524 command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
524 system ( command.utf8() ); 525 system ( command.utf8() );
525 QFile file( fileName ); 526 QFile file( fileName );
526 if (!file.open( IO_ReadOnly ) ) { 527 if (!file.open( IO_ReadOnly ) ) {
527 return false; 528 return false;
528 529
529 } 530 }
530 QTextStream ts( &file ); 531 QTextStream ts( &file );
531 ts.setCodec( QTextCodec::codecForName("utf8") ); 532 ts.setCodec( QTextCodec::codecForName("utf8") );
532 answer = ts.read(); 533 answer = ts.read();
533 file.close(); 534 file.close();
534 //qDebug("answer \n%s ", answer.latin1()); 535 //qDebug("answer \n%s ", answer.latin1());
535 getNumFromRecord( answer, ev ) ; 536 getNumFromRecord( answer, ev ) ;
536 537
537 } 538 }
538 else { // change existing 539 else { // change existing
539 //qDebug("canging %d %d",ev->zaurusStat() ,ev->zaurusId() ); 540 //qDebug("canging %d %d",ev->zaurusStat() ,ev->zaurusId() );
540 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; 541 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
541 changeString += eString + "\n"; 542 changeString += eString + "\n";
542 changeEnt = true; 543 changeEnt = true;
543 544
544 } 545 }
545 } 546 }
546 ev = er.next(); 547 ev = er.next();
547 } 548 }
548 status.setText ( i18n("Changing events ...") ); 549 status.setText ( i18n("Changing events ...") );
549 qApp->processEvents(); 550 qApp->processEvents();
550 //qDebug("changing... "); 551 //qDebug("changing... ");
551 if ( changeEnt ) { 552 if ( changeEnt ) {
552 QFile file( fileName ); 553 QFile file( fileName );
553 if (!file.open( IO_WriteOnly ) ) { 554 if (!file.open( IO_WriteOnly ) ) {
554 return false; 555 return false;
555 556
556 } 557 }
557 QTextStream ts( &file ); 558 QTextStream ts( &file );
558 ts.setCodec( QTextCodec::codecForName("utf8") ); 559 ts.setCodec( QTextCodec::codecForName("utf8") );
559 ts << changeString ; 560 ts << changeString ;
560 file.close(); 561 file.close();
561 command = "db2file datebook -w -g -c " + codec+ " < "+ fileName; 562 command = "db2file datebook -w -g -c " + codec+ " < "+ fileName;
562 system ( command.latin1() ); 563 system ( command.latin1() );
563 //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); 564 //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1());
564 565
565 } 566 }
566 status.setText ( i18n("Deleting events ...") ); 567 status.setText ( i18n("Deleting events ...") );
567 qApp->processEvents(); 568 qApp->processEvents();
568 //qDebug("deleting... "); 569 //qDebug("deleting... ");
569 if ( deleteEnt ) { 570 if ( deleteEnt ) {
570 QFile file( fileName ); 571 QFile file( fileName );
571 if (!file.open( IO_WriteOnly ) ) { 572 if (!file.open( IO_WriteOnly ) ) {
572 return false; 573 return false;
573 574
574 } 575 }
575 QTextStream ts( &file ); 576 QTextStream ts( &file );
576 ts.setCodec( QTextCodec::codecForName("utf8") ); 577 ts.setCodec( QTextCodec::codecForName("utf8") );
577 ts << deleteString; 578 ts << deleteString;
578 file.close(); 579 file.close();
579 command = "db2file datebook -d -c " + codec+ " < "+ fileName; 580 command = "db2file datebook -d -c " + codec+ " < "+ fileName;
580 system ( command.latin1() ); 581 system ( command.latin1() );
581 // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); 582 // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1());
582 } 583 }
583 584
584 585
585 changeString = tPrefix; 586 changeString = tPrefix;
586 deleteString = tPrefix; 587 deleteString = tPrefix;
587 status.setText ( i18n("Processing todos ...") ); 588 status.setText ( i18n("Processing todos ...") );
588 qApp->processEvents(); 589 qApp->processEvents();
589 QPtrList<Todo> tl = calendar->rawTodos(); 590 QPtrList<Todo> tl = calendar->rawTodos();
590 Todo* to = tl.first(); 591 Todo* to = tl.first();
591 i = 0; 592 i = 0;
592 message = i18n("Processing todo # "); 593 message = i18n("Processing todo # ");
593 procCount = 0; 594 procCount = 0;
594 while ( to ) { 595 while ( to ) {
595 if ( to->zaurusStat() != -2 ) { 596 if ( to->zaurusStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
596 status.setText ( message + QString::number ( ++procCount ) ); 597 status.setText ( message + QString::number ( ++procCount ) );
597 qApp->processEvents(); 598 qApp->processEvents();
598 QString eString = getTodoString( to ); 599 QString eString = getTodoString( to );
599 if ( to->zaurusStat() == -3 ) { // delete 600 if ( to->zaurusStat() == SYNC_TEMPSTATE_DELETE ) { // delete
600 // deleting empty strings does not work. 601 // deleting empty strings does not work.
601 // we write first and x and then delete the record with the x 602 // we write first and x and then delete the record with the x
602 eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); 603 eString = eString.replace( QRegExp(",\"\""),",\"x\"" );
603 changeString += eString + "\n"; 604 changeString += eString + "\n";
604 deleteString += eString + "\n"; 605 deleteString += eString + "\n";
605 deleteEnt = true; 606 deleteEnt = true;
606 changeEnt = true; 607 changeEnt = true;
607 } 608 }
608 else if ( to->zaurusId() == -1 ) { // add new 609 else if ( to->zaurusId() == -1 ) { // add new
609 command = "(echo \"" + tPrefix + eString + "\" ) | db2file todo -w -g -c " + codec+ " > "+ fileName; 610 command = "(echo \"" + tPrefix + eString + "\" ) | db2file todo -w -g -c " + codec+ " > "+ fileName;
610 system ( command.utf8() ); 611 system ( command.utf8() );
611 QFile file( fileName ); 612 QFile file( fileName );
612 if (!file.open( IO_ReadOnly ) ) { 613 if (!file.open( IO_ReadOnly ) ) {
613 return false; 614 return false;
614 615
615 } 616 }
616 QTextStream ts( &file ); 617 QTextStream ts( &file );
617 ts.setCodec( QTextCodec::codecForName("utf8") ); 618 ts.setCodec( QTextCodec::codecForName("utf8") );
618 answer = ts.read(); 619 answer = ts.read();
619 file.close(); 620 file.close();
620 //qDebug("answer \n%s ", answer.latin1()); 621 //qDebug("answer \n%s ", answer.latin1());
621 getNumFromRecord( answer, to ) ; 622 getNumFromRecord( answer, to ) ;
622 623
623 } 624 }
624 else { // change existing 625 else { // change existing
625 //qDebug("canging %d %d",to->zaurusStat() ,to->zaurusId() ); 626 //qDebug("canging %d %d",to->zaurusStat() ,to->zaurusId() );
626 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; 627 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
627 changeString += eString + "\n"; 628 changeString += eString + "\n";
628 changeEnt = true; 629 changeEnt = true;
629 630
630 } 631 }
631 } 632 }
632 633
633 to = tl.next(); 634 to = tl.next();
634 } 635 }
635 status.setText ( i18n("Changing todos ...") ); 636 status.setText ( i18n("Changing todos ...") );
636 qApp->processEvents(); 637 qApp->processEvents();
637 //qDebug("changing... "); 638 //qDebug("changing... ");
638 if ( changeEnt ) { 639 if ( changeEnt ) {
639 QFile file( fileName ); 640 QFile file( fileName );
640 if (!file.open( IO_WriteOnly ) ) { 641 if (!file.open( IO_WriteOnly ) ) {
641 return false; 642 return false;
642 643
643 } 644 }
644 QTextStream ts( &file ); 645 QTextStream ts( &file );
645 ts.setCodec( QTextCodec::codecForName("utf8") ); 646 ts.setCodec( QTextCodec::codecForName("utf8") );
646 ts << changeString ; 647 ts << changeString ;
647 file.close(); 648 file.close();
648 command = "db2file todo -w -g -c " + codec+ " < "+ fileName; 649 command = "db2file todo -w -g -c " + codec+ " < "+ fileName;
649 system ( command.latin1() ); 650 system ( command.latin1() );
650 //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); 651 //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1());
651 652
652 } 653 }
653 status.setText ( i18n("Deleting todos ...") ); 654 status.setText ( i18n("Deleting todos ...") );
654 qApp->processEvents(); 655 qApp->processEvents();
655 //qDebug("deleting... "); 656 //qDebug("deleting... ");
656 if ( deleteEnt ) { 657 if ( deleteEnt ) {
657 QFile file( fileName ); 658 QFile file( fileName );
658 if (!file.open( IO_WriteOnly ) ) { 659 if (!file.open( IO_WriteOnly ) ) {
659 return false; 660 return false;
660 661
661 } 662 }
662 QTextStream ts( &file ); 663 QTextStream ts( &file );
663 ts.setCodec( QTextCodec::codecForName("utf8") ); 664 ts.setCodec( QTextCodec::codecForName("utf8") );
664 ts << deleteString; 665 ts << deleteString;
665 file.close(); 666 file.close();
666 command = "db2file todo -d -c " + codec+ " < "+ fileName; 667 command = "db2file todo -d -c " + codec+ " < "+ fileName;
667 system ( command.latin1() ); 668 system ( command.latin1() );
668 // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); 669 // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1());
669 } 670 }
670 671
671 return true; 672 return true;
672} 673}
673QString SharpFormat::dtToString( const QDateTime& dti, bool useTZ ) 674QString SharpFormat::dtToString( const QDateTime& dti, bool useTZ )
674{ 675{
675 QString datestr; 676 QString datestr;
676 QString timestr; 677 QString timestr;
677 int offset = KGlobal::locale()->localTimeOffset( dti ); 678 int offset = KGlobal::locale()->localTimeOffset( dti );
678 QDateTime dt; 679 QDateTime dt;
679 if (useTZ) 680 if (useTZ)
680 dt = dti.addSecs ( -(offset*60)); 681 dt = dti.addSecs ( -(offset*60));
681 else 682 else
682 dt = dti; 683 dt = dti;
683 if(dt.date().isValid()){ 684 if(dt.date().isValid()){
684 const QDate& date = dt.date(); 685 const QDate& date = dt.date();
685 datestr.sprintf("%04d%02d%02d", 686 datestr.sprintf("%04d%02d%02d",
686 date.year(), date.month(), date.day()); 687 date.year(), date.month(), date.day());
687 } 688 }
688 if(dt.time().isValid()){ 689 if(dt.time().isValid()){
689 const QTime& time = dt.time(); 690 const QTime& time = dt.time();
690 timestr.sprintf("T%02d%02d%02d", 691 timestr.sprintf("T%02d%02d%02d",
691 time.hour(), time.minute(), time.second()); 692 time.hour(), time.minute(), time.second());
692 } 693 }
693 return datestr + timestr; 694 return datestr + timestr;
694} 695}
695QString SharpFormat::getEventString( Event* event ) 696QString SharpFormat::getEventString( Event* event )
696{ 697{
697 QStringList list; 698 QStringList list;
698 list.append( QString::number(event->zaurusId() ) ); 699 list.append( QString::number(event->zaurusId() ) );
699 list.append( event->categories().join(",") ); 700 list.append( event->categories().join(",") );
700 if ( !event->summary().isEmpty() ) 701 if ( !event->summary().isEmpty() )
701 list.append( event->summary() ); 702 list.append( event->summary() );
702 else 703 else
703 list.append("" ); 704 list.append("" );
704 if ( !event->location().isEmpty() ) 705 if ( !event->location().isEmpty() )
705 list.append( event->location() ); 706 list.append( event->location() );
706 else 707 else
707 list.append("" ); 708 list.append("" );
708 if ( !event->description().isEmpty() ) 709 if ( !event->description().isEmpty() )
709 list.append( event->description() ); 710 list.append( event->description() );
710 else 711 else
711 list.append( "" ); 712 list.append( "" );
712 if ( event->doesFloat () ) { 713 if ( event->doesFloat () ) {
713 list.append( dtToString( QDateTime(event->dtStart().date(), QTime(0,0,0)), false )); 714 list.append( dtToString( QDateTime(event->dtStart().date(), QTime(0,0,0)), false ));
714 list.append( dtToString( QDateTime(event->dtEnd().date(),QTime(23,59,59)), false )); //6 715 list.append( dtToString( QDateTime(event->dtEnd().date(),QTime(23,59,59)), false )); //6
715 list.append( "1" ); 716 list.append( "1" );
716 717
717 } 718 }
718 else { 719 else {
719 list.append( dtToString( event->dtStart()) ); 720 list.append( dtToString( event->dtStart()) );
720 list.append( dtToString( event->dtEnd()) ); //6 721 list.append( dtToString( event->dtEnd()) ); //6
721 list.append( "0" ); 722 list.append( "0" );
722 } 723 }
723 bool noAlarm = true; 724 bool noAlarm = true;
724 if ( event->alarms().count() > 0 ) { 725 if ( event->alarms().count() > 0 ) {
725 Alarm * al = event->alarms().first(); 726 Alarm * al = event->alarms().first();
726 if ( al->enabled() ) { 727 if ( al->enabled() ) {
727 noAlarm = false; 728 noAlarm = false;
728 list.append( "0" ); // yes, 0 == alarm 729 list.append( "0" ); // yes, 0 == alarm
729 list.append( QString::number( al->startOffset().asSeconds()/(-60) ) ); 730 list.append( QString::number( al->startOffset().asSeconds()/(-60) ) );
730 if ( al->type() == Alarm::Audio ) 731 if ( al->type() == Alarm::Audio )
731 list.append( "1" ); // type audio 732 list.append( "1" ); // type audio
732 else 733 else
733 list.append( "0" ); // type silent 734 list.append( "0" ); // type silent
734 } 735 }
735 } 736 }
736 if ( noAlarm ) { 737 if ( noAlarm ) {
737 list.append( "1" ); // yes, 1 == no alarm 738 list.append( "1" ); // yes, 1 == no alarm
738 list.append( "0" ); // no alarm offset 739 list.append( "0" ); // no alarm offset
739 list.append( "1" ); // type 740 list.append( "1" ); // type
740 } 741 }
741 // next is: 11 742 // next is: 11
742 // next is: 11-16 are recurrence 743 // next is: 11-16 are recurrence
743 Recurrence* rec = event->recurrence(); 744 Recurrence* rec = event->recurrence();
744 745
745 bool writeEndDate = false; 746 bool writeEndDate = false;
746 switch ( rec->doesRecur() ) 747 switch ( rec->doesRecur() )
747 { 748 {
748 case Recurrence::rDaily: // 0 749 case Recurrence::rDaily: // 0
749 list.append( "0" ); 750 list.append( "0" );
750 list.append( QString::number( rec->frequency() ));//12 751 list.append( QString::number( rec->frequency() ));//12
751 list.append( "0" ); 752 list.append( "0" );
752 list.append( "0" ); 753 list.append( "0" );
753 writeEndDate = true; 754 writeEndDate = true;
754 break; 755 break;
755 case Recurrence::rWeekly:// 1 756 case Recurrence::rWeekly:// 1
756 list.append( "1" ); 757 list.append( "1" );
757 list.append( QString::number( rec->frequency()) );//12 758 list.append( QString::number( rec->frequency()) );//12
758 list.append( "0" ); 759 list.append( "0" );
759 { 760 {
760 int days = 0; 761 int days = 0;
761 QBitArray weekDays = rec->days(); 762 QBitArray weekDays = rec->days();
762 int i; 763 int i;
763 for( i = 1; i <= 7; ++i ) { 764 for( i = 1; i <= 7; ++i ) {
764 if ( weekDays[i-1] ) { 765 if ( weekDays[i-1] ) {
765 days += 1 << (i-1); 766 days += 1 << (i-1);
766 } 767 }
767 } 768 }
768 list.append( QString::number( days ) ); 769 list.append( QString::number( days ) );
769 } 770 }
770 //pending weekdays 771 //pending weekdays
771 writeEndDate = true; 772 writeEndDate = true;
772 773
773 break; 774 break;
774 case Recurrence::rMonthlyPos:// 2 775 case Recurrence::rMonthlyPos:// 2
775 list.append( "2" ); 776 list.append( "2" );
776 list.append( QString::number( rec->frequency()) );//12 777 list.append( QString::number( rec->frequency()) );//12
777 778
778 writeEndDate = true; 779 writeEndDate = true;
779 { 780 {
780 int count = 1; 781 int count = 1;
781 QPtrList<Recurrence::rMonthPos> rmp; 782 QPtrList<Recurrence::rMonthPos> rmp;
782 rmp = rec->monthPositions(); 783 rmp = rec->monthPositions();
783 if ( rmp.first()->negative ) 784 if ( rmp.first()->negative )
784 count = 5 - rmp.first()->rPos - 1; 785 count = 5 - rmp.first()->rPos - 1;
785 else 786 else
786 count = rmp.first()->rPos - 1; 787 count = rmp.first()->rPos - 1;
787 list.append( QString::number( count ) ); 788 list.append( QString::number( count ) );
788 789
789 } 790 }
790 791
791 list.append( "0" ); 792 list.append( "0" );
792 break; 793 break;
793 case Recurrence::rMonthlyDay:// 3 794 case Recurrence::rMonthlyDay:// 3
794 list.append( "3" ); 795 list.append( "3" );
795 list.append( QString::number( rec->frequency()) );//12 796 list.append( QString::number( rec->frequency()) );//12
796 list.append( "0" ); 797 list.append( "0" );
797 list.append( "0" ); 798 list.append( "0" );
798 writeEndDate = true; 799 writeEndDate = true;
799 break; 800 break;
800 case Recurrence::rYearlyMonth://4 801 case Recurrence::rYearlyMonth://4
801 list.append( "4" ); 802 list.append( "4" );
802 list.append( QString::number( rec->frequency()) );//12 803 list.append( QString::number( rec->frequency()) );//12
803 list.append( "0" ); 804 list.append( "0" );
804 list.append( "0" ); 805 list.append( "0" );
805 writeEndDate = true; 806 writeEndDate = true;
806 break; 807 break;
807 808
808 default: 809 default:
809 list.append( "255" ); 810 list.append( "255" );
810 list.append( QString() ); 811 list.append( QString() );
811 list.append( "0" ); 812 list.append( "0" );
812 list.append( QString() ); 813 list.append( QString() );
813 list.append( "0" ); 814 list.append( "0" );
814 list.append( "20991231T000000" ); 815 list.append( "20991231T000000" );
815 break; 816 break;
816 } 817 }
817 if ( writeEndDate ) { 818 if ( writeEndDate ) {
818 819
819 if ( rec->endDate().isValid() ) { // 15 + 16 820 if ( rec->endDate().isValid() ) { // 15 + 16
820 list.append( "1" ); 821 list.append( "1" );
821 list.append( dtToString( rec->endDate()) ); 822 list.append( dtToString( rec->endDate()) );
822 } else { 823 } else {
823 list.append( "0" ); 824 list.append( "0" );
824 list.append( "20991231T000000" ); 825 list.append( "20991231T000000" );
825 } 826 }
826 827
827 } 828 }
828 if ( event->doesFloat () ) { 829 if ( event->doesFloat () ) {
829 list.append( dtToString( event->dtStart(), false ).left( 8 )); 830 list.append( dtToString( event->dtStart(), false ).left( 8 ));
830 list.append( dtToString( event->dtEnd(), false ).left( 8 )); //6 831 list.append( dtToString( event->dtEnd(), false ).left( 8 )); //6
831 832
832 } 833 }
833 else { 834 else {
834 list.append( QString() ); 835 list.append( QString() );
835 list.append( QString() ); 836 list.append( QString() );
836 837
837 } 838 }
838 if (event->dtStart().date() == event->dtEnd().date() ) 839 if (event->dtStart().date() == event->dtEnd().date() )
839 list.append( "0" ); 840 list.append( "0" );
840 else 841 else
841 list.append( "1" ); 842 list.append( "1" );
842 843
843 844
844 for(QStringList::Iterator it=list.begin(); 845 for(QStringList::Iterator it=list.begin();
845 it!=list.end(); ++it){ 846 it!=list.end(); ++it){
846 QString& s = (*it); 847 QString& s = (*it);
847 s.replace(QRegExp("\""), "\"\""); 848 s.replace(QRegExp("\""), "\"\"");
848 if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ 849 if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){
849 s.prepend('\"'); 850 s.prepend('\"');
850 s.append('\"'); 851 s.append('\"');
851 } else if(s.isEmpty() && !s.isNull()){ 852 } else if(s.isEmpty() && !s.isNull()){
852 s = "\"\""; 853 s = "\"\"";
853 } 854 }
854 } 855 }
855 return list.join(","); 856 return list.join(",");
856 857
857 858
858} 859}
859QString SharpFormat::getTodoString( Todo* todo ) 860QString SharpFormat::getTodoString( Todo* todo )
860{ 861{
861 QStringList list; 862 QStringList list;
862 list.append( QString::number( todo->zaurusId() ) ); 863 list.append( QString::number( todo->zaurusId() ) );
863 list.append( todo->categories().join(",") ); 864 list.append( todo->categories().join(",") );
864 865
865 if ( todo->hasStartDate() ) { 866 if ( todo->hasStartDate() ) {
866 list.append( dtToString( todo->dtStart()) ); 867 list.append( dtToString( todo->dtStart()) );
867 } else 868 } else
868 list.append( QString() ); 869 list.append( QString() );
869 870
870 if ( todo->hasDueDate() ) { 871 if ( todo->hasDueDate() ) {
871 QTime tim; 872 QTime tim;
872 if ( todo->doesFloat()) { 873 if ( todo->doesFloat()) {
873 list.append( dtToString( QDateTime(todo->dtDue().date(),QTime( 0,0,0 )), false)) ; 874 list.append( dtToString( QDateTime(todo->dtDue().date(),QTime( 0,0,0 )), false)) ;
874 } else { 875 } else {
875 list.append( dtToString(todo->dtDue() ) ); 876 list.append( dtToString(todo->dtDue() ) );
876 } 877 }
877 } else 878 } else
878 list.append( QString() ); 879 list.append( QString() );
879 880
880 if ( todo->isCompleted() ) { 881 if ( todo->isCompleted() ) {
881 list.append( dtToString( todo->completed()) ); 882 list.append( dtToString( todo->completed()) );
882 list.append( "0" ); // yes 0 == completed 883 list.append( "0" ); // yes 0 == completed
883 } else { 884 } else {
884 list.append( dtToString( todo->completed()) ); 885 list.append( dtToString( todo->completed()) );
885 list.append( "1" ); 886 list.append( "1" );
886 } 887 }
887 list.append( QString::number( todo->priority() )); 888 list.append( QString::number( todo->priority() ));
888 if( ! todo->summary().isEmpty() ) 889 if( ! todo->summary().isEmpty() )
889 list.append( todo->summary() ); 890 list.append( todo->summary() );
890 else 891 else
891 list.append( "" ); 892 list.append( "" );
892 if (! todo->description().isEmpty() ) 893 if (! todo->description().isEmpty() )
893 list.append( todo->description() ); 894 list.append( todo->description() );
894 else 895 else
895 list.append( "" ); 896 list.append( "" );
896 for(QStringList::Iterator it=list.begin(); 897 for(QStringList::Iterator it=list.begin();
897 it!=list.end(); ++it){ 898 it!=list.end(); ++it){
898 QString& s = (*it); 899 QString& s = (*it);
899 s.replace(QRegExp("\""), "\"\""); 900 s.replace(QRegExp("\""), "\"\"");
900 if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ 901 if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){
901 s.prepend('\"'); 902 s.prepend('\"');
902 s.append('\"'); 903 s.append('\"');
903 } else if(s.isEmpty() && !s.isNull()){ 904 } else if(s.isEmpty() && !s.isNull()){
904 s = "\"\""; 905 s = "\"\"";
905 } 906 }
906 } 907 }
907 return list.join(","); 908 return list.join(",");
908} 909}
909QString SharpFormat::getPart( const QString & text, bool &ok, int &start ) 910QString SharpFormat::getPart( const QString & text, bool &ok, int &start )
910{ 911{
911 //qDebug("start %d ", start); 912 //qDebug("start %d ", start);
912 913
913 QString retval =""; 914 QString retval ="";
914 if ( text.at(start) == '"' ) { 915 if ( text.at(start) == '"' ) {
915 if ( text.mid( start,2) == "\"\"" && !( text.mid( start+2,1) == "\"")) { 916 if ( text.mid( start,2) == "\"\"" && !( text.mid( start+2,1) == "\"")) {
916 start = start +2; 917 start = start +2;
917 if ( text.mid( start,1) == "," ) { 918 if ( text.mid( start,1) == "," ) {
918 start += 1; 919 start += 1;
919 } 920 }
920 retval = ""; 921 retval = "";
921 if ( text.mid( start,1) == "\n" ) { 922 if ( text.mid( start,1) == "\n" ) {
922 start += 1; 923 start += 1;
923 ok = false; 924 ok = false;
924 } 925 }
925 return retval; 926 return retval;
926 } 927 }
927 int hk = start+1; 928 int hk = start+1;
928 hk = text.find ('"',hk); 929 hk = text.find ('"',hk);
929 while ( text.at(hk+1) == '"' ) 930 while ( text.at(hk+1) == '"' )
930 hk = text.find ('"',hk+2); 931 hk = text.find ('"',hk+2);
931 retval = text.mid( start+1, hk-start-1); 932 retval = text.mid( start+1, hk-start-1);
932 start = hk+1; 933 start = hk+1;
933 retval.replace( QRegExp("\"\""), "\""); 934 retval.replace( QRegExp("\"\""), "\"");
934 if ( text.mid( start,1) == "," ) { 935 if ( text.mid( start,1) == "," ) {
935 start += 1; 936 start += 1;
936 } 937 }
937 if ( text.mid( start,1) == "\n" ) { 938 if ( text.mid( start,1) == "\n" ) {
938 start += 1; 939 start += 1;
939 ok = false; 940 ok = false;
940 } 941 }
941 //qDebug("retval***%s*** ",retval.latin1() ); 942 //qDebug("retval***%s*** ",retval.latin1() );
942 return retval; 943 return retval;
943 944
944 } else { 945 } else {
945 int nl = text.find ("\n",start); 946 int nl = text.find ("\n",start);
946 int kom = text.find (',',start); 947 int kom = text.find (',',start);
947 if ( kom < nl ) { 948 if ( kom < nl ) {
948 // qDebug("kom < nl %d ", kom); 949 // qDebug("kom < nl %d ", kom);
949 retval = text.mid(start, kom-start); 950 retval = text.mid(start, kom-start);
950 start = kom+1; 951 start = kom+1;
951 return retval; 952 return retval;
952 } else { 953 } else {
953 if ( nl == kom ) { 954 if ( nl == kom ) {
954 // qDebug(" nl == kom "); 955 // qDebug(" nl == kom ");
955 start = 0; 956 start = 0;
956 ok = false; 957 ok = false;
957 return "0"; 958 return "0";
958 } 959 }
959 // qDebug(" nl < kom ", nl); 960 // qDebug(" nl < kom ", nl);
960 retval = text.mid( start, nl-start); 961 retval = text.mid( start, nl-start);
961 ok = false; 962 ok = false;
962 start = nl+1; 963 start = nl+1;
963 return retval; 964 return retval;
964 } 965 }
965 } 966 }
966} 967}
967bool SharpFormat::fromString( Calendar *calendar, const QString & text) 968bool SharpFormat::fromString( Calendar *calendar, const QString & text)
968{ 969{
969 return false; 970 return false;
970} 971}
971bool SharpFormat::fromString2Cal( Calendar *calendar,Calendar *existingCalendar, const QString & text, const QString & type) 972bool SharpFormat::fromString2Cal( Calendar *calendar,Calendar *existingCalendar, const QString & text, const QString & type)
972{ 973{
973 // qDebug("test %s ", text.latin1()); 974 // qDebug("test %s ", text.latin1());
974 QStringList templist; 975 QStringList templist;
975 QString tempString; 976 QString tempString;
976 int start = 0; 977 int start = 0;
977 int len = text.length(); 978 int len = text.length();
978 int end = text.find ("\n",start)+1; 979 int end = text.find ("\n",start)+1;
979 bool ok = true; 980 bool ok = true;
980 start = end; 981 start = end;
981 SharpParser handler( calendar ); 982 SharpParser handler( calendar );
982 handler.setCategoriesList( mCategories ); 983 handler.setCategoriesList( mCategories );
983 while ( start > 0 ) { 984 while ( start > 0 ) {
984 templist.clear(); 985 templist.clear();
985 ok = true; 986 ok = true;
986 while ( ok ) { 987 while ( ok ) {
987 tempString = getPart( text, ok, start ); 988 tempString = getPart( text, ok, start );
988 if ( start >= len || start == 0 ) { 989 if ( start >= len || start == 0 ) {
989 start = 0; 990 start = 0;
990 ok = false; 991 ok = false;
991 } 992 }
992 if ( tempString.right(1) =="\n" ) 993 if ( tempString.right(1) =="\n" )
993 tempString = tempString.left( tempString.length()-1); 994 tempString = tempString.left( tempString.length()-1);
994 //if ( ok ) 995 //if ( ok )
995 templist.append( tempString ); 996 templist.append( tempString );
996 //qDebug("%d ---%s---", templist.count(),tempString.latin1() ); 997 //qDebug("%d ---%s---", templist.count(),tempString.latin1() );
997 } 998 }
998 handler.startElement( existingCalendar, templist, type ); 999 handler.startElement( existingCalendar, templist, type );
999 } 1000 }
1000 1001
1001 return false; 1002 return false;
1002} 1003}
1003 1004
1004QString SharpFormat::toString( Calendar * ) 1005QString SharpFormat::toString( Calendar * )
1005{ 1006{
1006 return QString::null; 1007 return QString::null;
1007} 1008}
diff --git a/libkcal/syncdefines.h b/libkcal/syncdefines.h
new file mode 100644
index 0000000..57642ec
--- a/dev/null
+++ b/libkcal/syncdefines.h
@@ -0,0 +1,22 @@
1
2#ifndef _KSYNC_DEFINES_H_
3#define _KSYNC_DEFINES_H_
4
5#define SYNC_PREF_LOCAL 0
6#define SYNC_PREF_REMOTE 1
7#define SYNC_PREF_NEWEST 2
8#define SYNC_PREF_ASK 3
9#define SYNC_PREF_FORCE_LOCAL 4
10#define SYNC_PREF_FORCE_REMOTE 5
11#define SYNC_PREF_TAKE_BOTH 6
12
13#define SYNC_MODE_NORMAL 0
14#define SYNC_MODE_EXTERNAL 1
15
16#define SYNC_TEMPSTATE_INITIAL 0
17#define SYNC_TEMPSTATE_NEW_EXTERNAL -2
18#define SYNC_TEMPSTATE_DELETE -3
19#define SYNC_TEMPSTATE_NEW_ID -4
20
21
22#endif
diff --git a/libkdepim/ksyncprofile.h b/libkdepim/ksyncprofile.h
index 238ffad..3f7f1ac 100644
--- a/libkdepim/ksyncprofile.h
+++ b/libkdepim/ksyncprofile.h
@@ -1,106 +1,102 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> 3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef _KSYNCPROFILE_H 20#ifndef _KSYNCPROFILE_H
21#define _KSYNCPROFILE_H 21#define _KSYNCPROFILE_H
22 22
23#include <qptrlist.h> 23#include <qptrlist.h>
24#include <qcolor.h> 24#include <qcolor.h>
25#include <qfont.h> 25#include <qfont.h>
26#include <qstringlist.h> 26#include <qstringlist.h>
27#include <qobject.h> 27#include <qobject.h>
28#include <qstring.h> 28#include <qstring.h>
29 29
30#define SYNC_PREF_LOCAL 0 30#include <libkcal/syncdefines.h>
31#define SYNC_PREF_REMOTE 1 31
32#define SYNC_PREF_NEWEST 2 32
33#define SYNC_PREF_ASK 3
34#define SYNC_PREF_FORCE_LOCAL 4
35#define SYNC_PREF_FORCE_REMOTE 5
36#define SYNC_PREF_TAKE_BOTH 6
37 33
38class KConfig; 34class KConfig;
39 35
40/** 36/**
41 @short Class for storing a preferences setting 37 @short Class for storing a preferences setting
42 @author Cornelius Schumacher 38 @author Cornelius Schumacher
43 @see KPref 39 @see KPref
44 40
45 This class represents one preferences setting as used by @ref KPrefs. 41 This class represents one preferences setting as used by @ref KPrefs.
46 Subclasses of KPrefsItem implement storage functions for a certain type of 42 Subclasses of KPrefsItem implement storage functions for a certain type of
47 setting. Normally you don't have to use this class directly. Use the special 43 setting. Normally you don't have to use this class directly. Use the special
48 addItem() functions of KPrefs instead. If you subclass this class you will 44 addItem() functions of KPrefs instead. If you subclass this class you will
49 have to register instances with the function KPrefs::addItem(). 45 have to register instances with the function KPrefs::addItem().
50*/ 46*/
51class KSyncProfile : public QObject { 47class KSyncProfile : public QObject {
52 public: 48 public:
53 KSyncProfile( const char * name = 0); 49 KSyncProfile( const char * name = 0);
54 ~KSyncProfile() ; 50 ~KSyncProfile() ;
55 51
56 KSyncProfile* clone(); 52 KSyncProfile* clone();
57 void setDefault(); 53 void setDefault();
58 void readConfig(KConfig *); 54 void readConfig(KConfig *);
59 void writeConfig(KConfig *); 55 void writeConfig(KConfig *);
60 void setName( const QString& n ) {mName = n;} 56 void setName( const QString& n ) {mName = n;}
61 QString getName( ) { return mName;} 57 QString getName( ) { return mName;}
62 void setPreSyncCommand( const QString& n ) {mPreSyncCommand = n;} 58 void setPreSyncCommand( const QString& n ) {mPreSyncCommand = n;}
63 QString getPreSyncCommand( ) { return mPreSyncCommand; } 59 QString getPreSyncCommand( ) { return mPreSyncCommand; }
64 void setPostSyncCommand( const QString& n ) {mPostSyncCommand = n;} 60 void setPostSyncCommand( const QString& n ) {mPostSyncCommand = n;}
65 QString getPostSyncCommand( ) { return mPostSyncCommand;} 61 QString getPostSyncCommand( ) { return mPostSyncCommand;}
66 62
67 void setLocalTempFile( const QString& n ) { mLocalTempFile= n;} 63 void setLocalTempFile( const QString& n ) { mLocalTempFile= n;}
68 QString getLocalTempFile( ) { return mLocalTempFile;} 64 QString getLocalTempFile( ) { return mLocalTempFile;}
69 void setRemoteFileName( const QString& n ) { mRemoteFileName = n;} 65 void setRemoteFileName( const QString& n ) { mRemoteFileName = n;}
70 QString getRemoteFileName( ) { return mRemoteFileName;} 66 QString getRemoteFileName( ) { return mRemoteFileName;}
71 /* 67 /*
72 void set( const QString& n ) { = n;} 68 void set( const QString& n ) { = n;}
73 QString get( ) { return ;} 69 QString get( ) { return ;}
74 */ 70 */
75 71
76 void setShowSummaryAfterSync( bool b ) { mShowSummaryAfterSync = b;} 72 void setShowSummaryAfterSync( bool b ) { mShowSummaryAfterSync = b;}
77 bool getShowSummaryAfterSync( ) { return mShowSummaryAfterSync ;} 73 bool getShowSummaryAfterSync( ) { return mShowSummaryAfterSync ;}
78 void setAskForPreferences( bool b ) { mAskForPreferences= b;} 74 void setAskForPreferences( bool b ) { mAskForPreferences= b;}
79 bool getAskForPreferences( ) { return mAskForPreferences;} 75 bool getAskForPreferences( ) { return mAskForPreferences;}
80 void setWriteBackExisting( bool b ) { mWriteBackExisting = b;} 76 void setWriteBackExisting( bool b ) { mWriteBackExisting = b;}
81 bool getWriteBackExisting( ) { return mWriteBackExisting;} 77 bool getWriteBackExisting( ) { return mWriteBackExisting;}
82 void setWriteBackFile( bool b ) { mWriteBackFile= b;} 78 void setWriteBackFile( bool b ) { mWriteBackFile= b;}
83 bool getWriteBackFile( ) { return mWriteBackFile;} 79 bool getWriteBackFile( ) { return mWriteBackFile;}
84 void setIncludeInRingSync( bool b ) {mIncludeInRingSync = b;} 80 void setIncludeInRingSync( bool b ) {mIncludeInRingSync = b;}
85 bool getIncludeInRingSync( ) { return mIncludeInRingSync;} 81 bool getIncludeInRingSync( ) { return mIncludeInRingSync;}
86 void setSyncPrefs( int n ) { mSyncPrefs= n;} 82 void setSyncPrefs( int n ) { mSyncPrefs= n;}
87 int getSyncPrefs( ) { return mSyncPrefs;} 83 int getSyncPrefs( ) { return mSyncPrefs;}
88 void setIsLocalFileSync( bool b ) { mIsLocalFileSync= b;} 84 void setIsLocalFileSync( bool b ) { mIsLocalFileSync= b;}
89 bool getIsLocalFileSync( ) { return mIsLocalFileSync;} 85 bool getIsLocalFileSync( ) { return mIsLocalFileSync;}
90 86
91 private: 87 private:
92 QString mName; 88 QString mName;
93 QString mPreSyncCommand; 89 QString mPreSyncCommand;
94 QString mPostSyncCommand; 90 QString mPostSyncCommand;
95 QString mLocalTempFile; 91 QString mLocalTempFile;
96 QString mRemoteFileName; 92 QString mRemoteFileName;
97 bool mIncludeInRingSync; 93 bool mIncludeInRingSync;
98 int mSyncPrefs; 94 int mSyncPrefs;
99 bool mWriteBackFile; 95 bool mWriteBackFile;
100 bool mWriteBackExisting; 96 bool mWriteBackExisting;
101 bool mAskForPreferences; 97 bool mAskForPreferences;
102 bool mShowSummaryAfterSync; 98 bool mShowSummaryAfterSync;
103 bool mIsLocalFileSync; 99 bool mIsLocalFileSync;
104}; 100};
105 101
106#endif 102#endif