summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--gammu/emb/common/service/gsmcal.c15
-rw-r--r--gammu/emb/common/service/gsmcal.h1
-rw-r--r--kaddressbook/kabcore.cpp6
-rw-r--r--korganizer/calendarview.cpp12
-rw-r--r--microkde/kapplication.cpp22
-rw-r--r--microkde/kapplication.h1
6 files changed, 50 insertions, 7 deletions
diff --git a/gammu/emb/common/service/gsmcal.c b/gammu/emb/common/service/gsmcal.c
index 0ea8e06..0375fee 100644
--- a/gammu/emb/common/service/gsmcal.c
+++ b/gammu/emb/common/service/gsmcal.c
@@ -1,512 +1,521 @@
1/* (c) 2002-2003 by Marcin Wiacek */ 1/* (c) 2002-2003 by Marcin Wiacek */
2 2
3#include <string.h> 3#include <string.h>
4 4
5#include "gsmcal.h" 5#include "gsmcal.h"
6#include "gsmmisc.h" 6#include "gsmmisc.h"
7#include "../misc/coding/coding.h" 7#include "../misc/coding/coding.h"
8 8
9bool IsCalendarNoteFromThePast(GSM_CalendarEntry *note) 9bool IsCalendarNoteFromThePast(GSM_CalendarEntry *note)
10{ 10{
11 bool Past = true; 11 bool Past = true;
12 int i; 12 int i;
13 GSM_DateTimeDT; 13 GSM_DateTimeDT;
14 14
15 GSM_GetCurrentDateTime (&DT); 15 GSM_GetCurrentDateTime (&DT);
16 for (i = 0; i < note->EntriesNum; i++) { 16 for (i = 0; i < note->EntriesNum; i++) {
17 switch (note->Entries[i].EntryType) { 17 switch (note->Entries[i].EntryType) {
18 case CAL_RECURRANCE: 18 case CAL_RECURRANCE:
19 Past = false; 19 Past = false;
20 break; 20 break;
21 case CAL_START_DATETIME : 21 case CAL_START_DATETIME :
22 if (note->Entries[i].Date.Year > DT.Year) Past = false; 22 if (note->Entries[i].Date.Year > DT.Year) Past = false;
23 if (note->Entries[i].Date.Year == DT.Year && 23 if (note->Entries[i].Date.Year == DT.Year &&
24 note->Entries[i].Date.Month > DT.Month) Past = false; 24 note->Entries[i].Date.Month > DT.Month) Past = false;
25 if (note->Entries[i].Date.Year == DT.Year && 25 if (note->Entries[i].Date.Year == DT.Year &&
26 note->Entries[i].Date.Month == DT.Month && 26 note->Entries[i].Date.Month == DT.Month &&
27 note->Entries[i].Date.Day > DT.Day) Past = false; 27 note->Entries[i].Date.Day > DT.Day) Past = false;
28 break; 28 break;
29 default: 29 default:
30 break; 30 break;
31 } 31 }
32 if (!Past) break; 32 if (!Past) break;
33 } 33 }
34 switch (note->Type) { 34 switch (note->Type) {
35 case GSM_CAL_BIRTHDAY: 35 case GSM_CAL_BIRTHDAY:
36 Past = false; 36 Past = false;
37 break; 37 break;
38 default: 38 default:
39 break; 39 break;
40 } 40 }
41 return Past; 41 return Past;
42} 42}
43 43
44void GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(GSM_CalendarEntry *entry, int *Text, int *Time, int *Alarm, int *Phone, int *Recurrance, int *EndTime, int *Location) 44void GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(GSM_CalendarEntry *entry, int *Text, int *Time, int *Alarm, int *Phone, int *Recurrance, int *EndTime, int *Location)
45{ 45{
46 int i; 46 int i;
47 47
48 *Text = -1; 48 *Text = -1;
49 *Time = -1; 49 *Time = -1;
50 *Alarm = -1; 50 *Alarm = -1;
51 *Phone = -1; 51 *Phone = -1;
52 *Recurrance= -1; 52 *Recurrance= -1;
53 *EndTime= -1; 53 *EndTime= -1;
54 *Location= -1; 54 *Location= -1;
55 for (i = 0; i < entry->EntriesNum; i++) { 55 for (i = 0; i < entry->EntriesNum; i++) {
56 switch (entry->Entries[i].EntryType) { 56 switch (entry->Entries[i].EntryType) {
57 case CAL_START_DATETIME : 57 case CAL_START_DATETIME :
58 if (*Time == -1) *Time = i; 58 if (*Time == -1) *Time = i;
59 break; 59 break;
60 case CAL_END_DATETIME : 60 case CAL_END_DATETIME :
61 if (*EndTime == -1) *EndTime = i; 61 if (*EndTime == -1) *EndTime = i;
62 break; 62 break;
63 case CAL_ALARM_DATETIME : 63 case CAL_ALARM_DATETIME :
64 case CAL_SILENT_ALARM_DATETIME: 64 case CAL_SILENT_ALARM_DATETIME:
65 if (*Alarm == -1) *Alarm = i; 65 if (*Alarm == -1) *Alarm = i;
66 break; 66 break;
67 case CAL_RECURRANCE: 67 case CAL_RECURRANCE:
68 if (*Recurrance == -1) *Recurrance = i; 68 if (*Recurrance == -1) *Recurrance = i;
69 break; 69 break;
70 case CAL_TEXT: 70 case CAL_TEXT:
71 *Text = i;
72 break;
73 case CAL_DESCRIPTION:
71 if (*Text == -1) *Text = i; 74 if (*Text == -1) *Text = i;
72 break; 75 break;
73 case CAL_PHONE: 76 case CAL_PHONE:
74 if (*Phone == -1) *Phone = i; 77 if (*Phone == -1) *Phone = i;
75 break; 78 break;
76 case CAL_LOCATION: 79 case CAL_LOCATION:
77 if (*Location == -1) *Location = i; 80 if (*Location == -1) *Location = i;
78 break; 81 break;
79 default: 82 default:
80 break; 83 break;
81 } 84 }
82 } 85 }
83} 86}
84 87
85GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note, bool header, GSM_VCalendarVersion Version) 88GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note, bool header, GSM_VCalendarVersion Version)
86{ 89{
87 int Text, Time, Alarm, Phone, Recurrance, EndTime, Location; 90 int Text, Time, Alarm, Phone, Recurrance, EndTime, Location;
88 char buffer[2000]; 91 char buffer[2000];
89 92
90 GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(note, &Text, &Time, &Alarm, &Phone, &Recurrance, &EndTime, &Location); 93 GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(note, &Text, &Time, &Alarm, &Phone, &Recurrance, &EndTime, &Location);
91 94
92 if (header) { 95 if (header) {
93 *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10); 96 *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10);
94 *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10); 97 *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10);
95 } 98 }
96 *Length+=sprintf(Buffer+(*Length), "BEGIN:VEVENT%c%c",13,10); 99 *Length+=sprintf(Buffer+(*Length), "BEGIN:VEVENT%c%c",13,10);
97 100
98 if (Version == Nokia_VCalendar) { 101 if (Version == Nokia_VCalendar) {
99 *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); 102 *Length+=sprintf(Buffer+(*Length), "CATEGORIES:");
100 switch (note->Type) { 103 switch (note->Type) {
101 case GSM_CAL_REMINDER: 104 case GSM_CAL_REMINDER:
102 *Length+=sprintf(Buffer+(*Length), "Reminder%c%c",13,10); 105 *Length+=sprintf(Buffer+(*Length), "Reminder%c%c",13,10);
103 break; 106 break;
104 case GSM_CAL_MEMO: 107 case GSM_CAL_MEMO:
105 *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); 108 *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10);
106 break; 109 break;
107 case GSM_CAL_CALL: 110 case GSM_CAL_CALL:
108 *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10); 111 *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10);
109 break; 112 break;
110 case GSM_CAL_BIRTHDAY: 113 case GSM_CAL_BIRTHDAY:
111 *Length+=sprintf(Buffer+(*Length), "Special Occasion%c%c",13,10); 114 *Length+=sprintf(Buffer+(*Length), "Special Occasion%c%c",13,10);
112 break; 115 break;
113 case GSM_CAL_MEETING: 116 case GSM_CAL_MEETING:
114 default: 117 default:
115 *Length+=sprintf(Buffer+(*Length), "MeetingDEF%c%c",13,10); 118 *Length+=sprintf(Buffer+(*Length), "MeetingDEF%c%c",13,10);
116 break; 119 break;
117 } 120 }
118 if (note->Type == GSM_CAL_CALL) { 121 if (note->Type == GSM_CAL_CALL) {
119 buffer[0] = 0; 122 buffer[0] = 0;
120 buffer[1] = 0; 123 buffer[1] = 0;
121 if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text); 124 if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text);
122 if (Text != -1) { 125 if (Text != -1) {
123 if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1); 126 if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1);
124 CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text); 127 CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text);
125 } 128 }
126 SaveVCALText(Buffer, Length, buffer, "SUMMARY"); 129 SaveVCALText(Buffer, Length, buffer, "SUMMARY");
127 } else { 130 } else {
128 SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); 131 SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY");
129 } 132 }
130 if (note->Type == GSM_CAL_MEETING && Location != -1) { 133 if (note->Type == GSM_CAL_MEETING && Location != -1) {
131 SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION"); 134 SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION");
132 } 135 }
133 136
134 if (Time == -1) return ERR_UNKNOWN; 137 if (Time == -1) return ERR_UNKNOWN;
135 SaveVCALDateTime(Buffer, Length, &note->Entries[Time].Date, "DTSTART"); 138 SaveVCALDateTime(Buffer, Length, &note->Entries[Time].Date, "DTSTART");
136 139
137 if (EndTime != -1) { 140 if (EndTime != -1) {
138 SaveVCALDateTime(Buffer, Length, &note->Entries[EndTime].Date, "DTEND"); 141 SaveVCALDateTime(Buffer, Length, &note->Entries[EndTime].Date, "DTEND");
139 } 142 }
140 143
141 if (Alarm != -1) { 144 if (Alarm != -1) {
142 if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) { 145 if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) {
143 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "DALARM"); 146 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "DALARM");
144 } else { 147 } else {
145 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "DALARM"); 148 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "DALARM");
146 } 149 }
147 } 150 }
148 151
149 /* Birthday is known to be recurranced */ 152 /* Birthday is known to be recurranced */
150 if (Recurrance != -1 && note->Type != GSM_CAL_BIRTHDAY) { 153 if (Recurrance != -1 && note->Type != GSM_CAL_BIRTHDAY) {
151 switch(note->Entries[Recurrance].Number/24) { 154 switch(note->Entries[Recurrance].Number/24) {
152 case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1 #0%c%c",13,10); break; 155 case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1 #0%c%c",13,10); break;
153 case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:W1 #0%c%c",13,10); break; 156 case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:W1 #0%c%c",13,10); break;
154 case 14 : *Length+=sprintf(Buffer+(*Length), "RRULE:W2 #0%c%c",13,10); break; 157 case 14 : *Length+=sprintf(Buffer+(*Length), "RRULE:W2 #0%c%c",13,10); break;
155 case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1 #0%c%c",13,10); break; 158 case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1 #0%c%c",13,10); break;
156 } 159 }
157 } 160 }
158 } else if (Version == Siemens_VCalendar) { 161 } else if (Version == Siemens_VCalendar) {
159 *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); 162 *Length+=sprintf(Buffer+(*Length), "CATEGORIES:");
160 switch (note->Type) { 163 switch (note->Type) {
161 case GSM_CAL_MEETING: 164 case GSM_CAL_MEETING:
162 *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10); 165 *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10);
163 break; 166 break;
164 case GSM_CAL_CALL: 167 case GSM_CAL_CALL:
165 *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10); 168 *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10);
166 break; 169 break;
167 case GSM_CAL_BIRTHDAY: 170 case GSM_CAL_BIRTHDAY:
168 *Length+=sprintf(Buffer+(*Length), "Anniversary%c%c",13,10); 171 *Length+=sprintf(Buffer+(*Length), "Anniversary%c%c",13,10);
169 break; 172 break;
170 case GSM_CAL_MEMO: 173 case GSM_CAL_MEMO:
171 default: 174 default:
172 *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); 175 *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10);
173 break; 176 break;
174 } 177 }
175 178
176 if (Time == -1) return ERR_UNKNOWN; 179 if (Time == -1) return ERR_UNKNOWN;
177 SaveVCALDateTime(Buffer, Length, &note->Entries[Time].Date, "DTSTART"); 180 SaveVCALDateTime(Buffer, Length, &note->Entries[Time].Date, "DTSTART");
178 181
179 if (Alarm != -1) { 182 if (Alarm != -1) {
180 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "DALARM"); 183 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "DALARM");
181 } 184 }
182 185
183 if (Recurrance != -1) { 186 if (Recurrance != -1) {
184 switch(note->Entries[Recurrance].Number/24) { 187 switch(note->Entries[Recurrance].Number/24) {
185 case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1%c%c",13,10);break; 188 case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1%c%c",13,10);break;
186 case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:D7%c%c",13,10);break; 189 case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:D7%c%c",13,10);break;
187 case 30 : *Length+=sprintf(Buffer+(*Length), "RRULE:MD1%c%c",13,10);break; 190 case 30 : *Length+=sprintf(Buffer+(*Length), "RRULE:MD1%c%c",13,10);break;
188 case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1%c%c",13,10);break; 191 case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1%c%c",13,10);break;
189 } 192 }
190 } 193 }
191 194
192 if (note->Type == GSM_CAL_CALL) { 195 if (note->Type == GSM_CAL_CALL) {
193 buffer[0] = 0; 196 buffer[0] = 0;
194 buffer[1] = 0; 197 buffer[1] = 0;
195 if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text); 198 if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text);
196 if (Text != -1) { 199 if (Text != -1) {
197 if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1); 200 if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1);
198 CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text); 201 CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text);
199 } 202 }
200 SaveVCALText(Buffer, Length, buffer, "DESCRIPTION"); 203 SaveVCALText(Buffer, Length, buffer, "SUMMARY");
201 } else { 204 } else {
202 SaveVCALText(Buffer, Length, note->Entries[Text].Text, "DESCRIPTION"); 205 SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY");
203 } 206 }
204 } else if (Version == SonyEricsson_VCalendar) { 207 } else if (Version == SonyEricsson_VCalendar) {
205 *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); 208 *Length+=sprintf(Buffer+(*Length), "CATEGORIES:");
206 switch (note->Type) { 209 switch (note->Type) {
207 case GSM_CAL_MEETING: 210 case GSM_CAL_MEETING:
208 *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10); 211 *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10);
209 break; 212 break;
210 case GSM_CAL_REMINDER: 213 case GSM_CAL_REMINDER:
211 *Length+=sprintf(Buffer+(*Length), "Date%c%c",13,10); 214 *Length+=sprintf(Buffer+(*Length), "Date%c%c",13,10);
212 break; 215 break;
213 case GSM_CAL_TRAVEL: 216 case GSM_CAL_TRAVEL:
214 *Length+=sprintf(Buffer+(*Length), "Travel%c%c",13,10); 217 *Length+=sprintf(Buffer+(*Length), "Travel%c%c",13,10);
215 break; 218 break;
216 case GSM_CAL_VACATION: 219 case GSM_CAL_VACATION:
217 *Length+=sprintf(Buffer+(*Length), "Vacation%c%c",13,10); 220 *Length+=sprintf(Buffer+(*Length), "Vacation%c%c",13,10);
218 break; 221 break;
219 case GSM_CAL_BIRTHDAY: 222 case GSM_CAL_BIRTHDAY:
220 *Length+=sprintf(Buffer+(*Length), "Anninversary%c%c",13,10); 223 *Length+=sprintf(Buffer+(*Length), "Anninversary%c%c",13,10);
221 break; 224 break;
222 case GSM_CAL_MEMO: 225 case GSM_CAL_MEMO:
223 default: 226 default:
224 *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); 227 *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10);
225 break; 228 break;
226 } 229 }
227 230
228 if (Time == -1) return ERR_UNKNOWN; 231 if (Time == -1) return ERR_UNKNOWN;
229 SaveVCALDateTime(Buffer, Length, &note->Entries[Time].Date, "DTSTART"); 232 SaveVCALDateTime(Buffer, Length, &note->Entries[Time].Date, "DTSTART");
230 233
231 if (EndTime != -1) { 234 if (EndTime != -1) {
232 SaveVCALDateTime(Buffer, Length, &note->Entries[EndTime].Date, "DTEND"); 235 SaveVCALDateTime(Buffer, Length, &note->Entries[EndTime].Date, "DTEND");
233 } 236 }
234 237
235 if (Alarm != -1) { 238 if (Alarm != -1) {
236 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "AALARM"); 239 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "AALARM");
237 } 240 }
238 241
239 SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); 242 SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY");
240 243
241 if (Location != -1) { 244 if (Location != -1) {
242 SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION"); 245 SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION");
243 } 246 }
244 } 247 }
245 248
246 *Length+=sprintf(Buffer+(*Length), "X-PILOTID:%d%c%c",note->Location,13,10); 249 *Length+=sprintf(Buffer+(*Length), "X-PILOTID:%d%c%c",note->Location,13,10);
247 *Length+=sprintf(Buffer+(*Length), "END:VEVENT%c%c",13,10); 250 *Length+=sprintf(Buffer+(*Length), "END:VEVENT%c%c",13,10);
248 if (header) *Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10); 251 if (header) *Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10);
249 252
250 return ERR_NONE; 253 return ERR_NONE;
251} 254}
252 255
253void GSM_ToDoFindDefaultTextTimeAlarmCompleted(GSM_ToDoEntry *entry, int *Text, int *Alarm, int *Completed, int *EndTime, int *Phone) 256void GSM_ToDoFindDefaultTextTimeAlarmCompleted(GSM_ToDoEntry *entry, int *Text, int *Alarm, int *Completed, int *EndTime, int *Phone)
254{ 257{
255 int i; 258 int i;
256 259
257 *Text = -1; 260 *Text = -1;
258 *EndTime= -1; 261 *EndTime= -1;
259 *Alarm = -1; 262 *Alarm = -1;
260 *Completed= -1; 263 *Completed= -1;
261 *Phone = -1; 264 *Phone = -1;
262 for (i = 0; i < entry->EntriesNum; i++) { 265 for (i = 0; i < entry->EntriesNum; i++) {
263 switch (entry->Entries[i].EntryType) { 266 switch (entry->Entries[i].EntryType) {
264 case TODO_END_DATETIME : 267 case TODO_END_DATETIME :
265 if (*EndTime == -1) *EndTime = i; 268 if (*EndTime == -1) *EndTime = i;
266 break; 269 break;
267 case TODO_ALARM_DATETIME : 270 case TODO_ALARM_DATETIME :
268 case TODO_SILENT_ALARM_DATETIME: 271 case TODO_SILENT_ALARM_DATETIME:
269 if (*Alarm == -1) *Alarm = i; 272 if (*Alarm == -1) *Alarm = i;
270 break; 273 break;
271 case TODO_TEXT: 274 case TODO_TEXT:
272 if (*Text == -1) *Text = i; 275 if (*Text == -1) *Text = i;
273 break; 276 break;
274 case TODO_COMPLETED: 277 case TODO_COMPLETED:
275 if (*Completed == -1) *Completed = i; 278 if (*Completed == -1) *Completed = i;
276 break; 279 break;
277 case TODO_PHONE: 280 case TODO_PHONE:
278 if (*Phone == -1) *Phone = i; 281 if (*Phone == -1) *Phone = i;
279 break; 282 break;
280 default: 283 default:
281 break; 284 break;
282 } 285 }
283 } 286 }
284} 287}
285 288
286GSM_Error GSM_EncodeVTODO(char *Buffer, int *Length, GSM_ToDoEntry *note, bool header, GSM_VToDoVersion Version) 289GSM_Error GSM_EncodeVTODO(char *Buffer, int *Length, GSM_ToDoEntry *note, bool header, GSM_VToDoVersion Version)
287{ 290{
288 int Text, Alarm, Completed, EndTime, Phone; 291 int Text, Alarm, Completed, EndTime, Phone;
289 292
290 GSM_ToDoFindDefaultTextTimeAlarmCompleted(note, &Text, &Alarm, &Completed, &EndTime, &Phone); 293 GSM_ToDoFindDefaultTextTimeAlarmCompleted(note, &Text, &Alarm, &Completed, &EndTime, &Phone);
291 294
292 if (header) { 295 if (header) {
293 *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10); 296 *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10);
294 *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10); 297 *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10);
295 } 298 }
296 299
297 *Length+=sprintf(Buffer+(*Length), "BEGIN:VTODO%c%c",13,10); 300 *Length+=sprintf(Buffer+(*Length), "BEGIN:VTODO%c%c",13,10);
298 301
299 if (Version == Nokia_VToDo) { 302 if (Version == Nokia_VToDo) {
300 if (Text == -1) return ERR_UNKNOWN; 303 if (Text == -1) return ERR_UNKNOWN;
301 SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); 304 SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY");
302 305
303 if (Completed == -1) { 306 if (Completed == -1) {
304 *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:0%c%c",13,10); 307 *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:0%c%c",13,10);
305 } else { 308 } else {
306 *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:100%c%c",13,10); 309 *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:100%c%c",13,10);
307 } 310 }
308 311
309 switch (note->Priority) { 312 switch (note->Priority) {
310 case GSM_Priority_Low: *Length+=sprintf(Buffer+(*Length), "PRIORITY:5%c%c",13,10); break; 313 case GSM_Priority_Low: *Length+=sprintf(Buffer+(*Length), "PRIORITY:5%c%c",13,10); break;
311 case GSM_Priority_Medium: *Length+=sprintf(Buffer+(*Length), "PRIORITY:3%c%c",13,10); break; 314 case GSM_Priority_Medium: *Length+=sprintf(Buffer+(*Length), "PRIORITY:3%c%c",13,10); break;
312 case GSM_Priority_High: *Length+=sprintf(Buffer+(*Length), "PRIORITY:1%c%c",13,10); break; 315 case GSM_Priority_High: *Length+=sprintf(Buffer+(*Length), "PRIORITY:1%c%c",13,10); break;
313 } 316 }
314 317
315 if (EndTime != -1) { 318 if (EndTime != -1) {
316 SaveVCALDateTime(Buffer, Length, &note->Entries[EndTime].Date, "DUE"); 319 SaveVCALDateTime(Buffer, Length, &note->Entries[EndTime].Date, "DUE");
317 } 320 }
318 321
319 if (Alarm != -1) { 322 if (Alarm != -1) {
320 if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) { 323 if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) {
321 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "DALARM"); 324 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "DALARM");
322 } else { 325 } else {
323 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "AALARM"); 326 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "AALARM");
324 } 327 }
325 } 328 }
326 } else if (Version == SonyEricsson_VToDo) { 329 } else if (Version == SonyEricsson_VToDo) {
327 if (Text == -1) return ERR_UNKNOWN; 330 if (Text == -1) return ERR_UNKNOWN;
328 SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); 331 SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY");
329 332
330 if (Completed == -1) { 333 if (Completed == -1) {
331 *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:0%c%c",13,10); 334 *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:0%c%c",13,10);
332 } else { 335 } else {
333 *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:100%c%c",13,10); 336 *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:100%c%c",13,10);
334 } 337 }
335 338
336 switch (note->Priority) { 339 switch (note->Priority) {
337 case GSM_Priority_Low: *Length+=sprintf(Buffer+(*Length), "PRIORITY:5%c%c",13,10); break; 340 case GSM_Priority_Low: *Length+=sprintf(Buffer+(*Length), "PRIORITY:5%c%c",13,10); break;
338 case GSM_Priority_Medium: *Length+=sprintf(Buffer+(*Length), "PRIORITY:3%c%c",13,10); break; 341 case GSM_Priority_Medium: *Length+=sprintf(Buffer+(*Length), "PRIORITY:3%c%c",13,10); break;
339 case GSM_Priority_High: *Length+=sprintf(Buffer+(*Length), "PRIORITY:1%c%c",13,10); break; 342 case GSM_Priority_High: *Length+=sprintf(Buffer+(*Length), "PRIORITY:1%c%c",13,10); break;
340 } 343 }
341 344
342 if (Alarm != -1) { 345 if (Alarm != -1) {
343 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "AALARM"); 346 SaveVCALDateTime(Buffer, Length, &note->Entries[Alarm].Date, "AALARM");
344 } 347 }
345 } 348 }
346 349
347 *Length+=sprintf(Buffer+(*Length), "X-PILOTID:%d%c%c",note->Location,13,10); 350 *Length+=sprintf(Buffer+(*Length), "X-PILOTID:%d%c%c",note->Location,13,10);
348 *Length+=sprintf(Buffer+(*Length), "END:VTODO%c%c",13,10); 351 *Length+=sprintf(Buffer+(*Length), "END:VTODO%c%c",13,10);
349 352
350 if (header) { 353 if (header) {
351 *Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10); 354 *Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10);
352 } 355 }
353 return ERR_NONE; 356 return ERR_NONE;
354} 357}
355 358
356GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_CalendarEntry *Calendar, GSM_ToDoEntry *ToDo, GSM_VCalendarVersion CalVer, GSM_VToDoVersion ToDoVer) 359GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_CalendarEntry *Calendar, GSM_ToDoEntry *ToDo, GSM_VCalendarVersion CalVer, GSM_VToDoVersion ToDoVer)
357{ 360{
358 unsigned char Line[2000],Buff[2000]; 361 unsigned char Line[2000],Buff[2000];
359 int Level = 0; 362 int Level = 0;
360 363
361 Calendar->EntriesNum = 0; 364 Calendar->EntriesNum = 0;
362 ToDo->EntriesNum = 0; 365 ToDo->EntriesNum = 0;
363 366
364 while (1) { 367 while (1) {
365 MyGetLine(Buffer, Pos, Line, strlen(Buffer)); 368 MyGetLine(Buffer, Pos, Line, strlen(Buffer));
366 if (strlen(Line) == 0) break; 369 if (strlen(Line) == 0) break;
367 switch (Level) { 370 switch (Level) {
368 case 0: 371 case 0:
369 if (strstr(Line,"BEGIN:VEVENT")) { 372 if (strstr(Line,"BEGIN:VEVENT")) {
370 Calendar->Type = GSM_CAL_MEMO; 373 Calendar->Type = GSM_CAL_MEMO;
371 Level = 1; 374 Level = 1;
372 } 375 }
373 if (strstr(Line,"BEGIN:VTODO")) { 376 if (strstr(Line,"BEGIN:VTODO")) {
374 ToDo->Priority = GSM_Priority_Medium; 377 ToDo->Priority = GSM_Priority_Medium;
375 Level = 2; 378 Level = 2;
376 } 379 }
377 break; 380 break;
378 case 1: /* Calendar note */ 381 case 1: /* Calendar note */
379 if (strstr(Line,"END:VEVENT")) { 382 if (strstr(Line,"END:VEVENT")) {
380 if (Calendar->EntriesNum == 0) return ERR_EMPTY; 383 if (Calendar->EntriesNum == 0) return ERR_EMPTY;
381 return ERR_NONE; 384 return ERR_NONE;
382 } 385 }
383 Calendar->Type = GSM_CAL_MEETING; 386 Calendar->Type = GSM_CAL_MEETING;
384 if (strstr(Line,"CATEGORIES:Reminder")) Calendar->Type = GSM_CAL_REMINDER; 387 if (strstr(Line,"CATEGORIES:Reminder")) Calendar->Type = GSM_CAL_REMINDER;
385 if (strstr(Line,"CATEGORIES:Date")) Calendar->Type = GSM_CAL_REMINDER;//SE 388 if (strstr(Line,"CATEGORIES:Date")) Calendar->Type = GSM_CAL_REMINDER;//SE
386 if (strstr(Line,"CATEGORIES:Travel")) Calendar->Type = GSM_CAL_TRAVEL; //SE 389 if (strstr(Line,"CATEGORIES:Travel")) Calendar->Type = GSM_CAL_TRAVEL; //SE
387 if (strstr(Line,"CATEGORIES:Vacation")) Calendar->Type = GSM_CAL_VACATION;//SE 390 if (strstr(Line,"CATEGORIES:Vacation")) Calendar->Type = GSM_CAL_VACATION;//SE
388 if (strstr(Line,"CATEGORIES:Miscellaneous")) Calendar->Type = GSM_CAL_MEMO; 391 if (strstr(Line,"CATEGORIES:Miscellaneous")) Calendar->Type = GSM_CAL_MEMO;
389 if (strstr(Line,"CATEGORIES:Phone Call")) Calendar->Type = GSM_CAL_CALL; 392 if (strstr(Line,"CATEGORIES:Phone Call")) Calendar->Type = GSM_CAL_CALL;
390 if (strstr(Line,"CATEGORIES:Special Occasion")) Calendar->Type = GSM_CAL_BIRTHDAY; 393 if (strstr(Line,"CATEGORIES:Special Occasion")) Calendar->Type = GSM_CAL_BIRTHDAY;
391 if (strstr(Line,"CATEGORIES:Anniversary")) Calendar->Type = GSM_CAL_BIRTHDAY; 394 if (strstr(Line,"CATEGORIES:Anniversary")) Calendar->Type = GSM_CAL_BIRTHDAY;
392 if (strstr(Line,"CATEGORIES:Meeting")) Calendar->Type = GSM_CAL_MEETING; 395 if (strstr(Line,"CATEGORIES:Meeting")) Calendar->Type = GSM_CAL_MEETING;
393 if (strstr(Line,"CATEGORIES:Appointment")) Calendar->Type = GSM_CAL_MEETING; 396 if (strstr(Line,"CATEGORIES:Appointment")) Calendar->Type = GSM_CAL_MEETING;
394 if (strstr(Line,"RRULE:D1")) { 397 if (strstr(Line,"RRULE:D1")) {
395 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; 398 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE;
396 Calendar->Entries[Calendar->EntriesNum].Number = 1*24; 399 Calendar->Entries[Calendar->EntriesNum].Number = 1*24;
397 Calendar->EntriesNum++; 400 Calendar->EntriesNum++;
398 } 401 }
399 if ((strstr(Line,"RRULE:W1")) || (strstr(Line,"RRULE:D7"))) { 402 if ((strstr(Line,"RRULE:W1")) || (strstr(Line,"RRULE:D7"))) {
400 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; 403 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE;
401 Calendar->Entries[Calendar->EntriesNum].Number = 7*24; 404 Calendar->Entries[Calendar->EntriesNum].Number = 7*24;
402 Calendar->EntriesNum++; 405 Calendar->EntriesNum++;
403 } 406 }
404 if (strstr(Line,"RRULE:W2")) { 407 if (strstr(Line,"RRULE:W2")) {
405 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; 408 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE;
406 Calendar->Entries[Calendar->EntriesNum].Number = 14*24; 409 Calendar->Entries[Calendar->EntriesNum].Number = 14*24;
407 Calendar->EntriesNum++; 410 Calendar->EntriesNum++;
408 } 411 }
409 if (strstr(Line,"RRULE:MD1")) { 412 if (strstr(Line,"RRULE:MD1")) {
410 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; 413 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE;
411 Calendar->Entries[Calendar->EntriesNum].Number = 30*24; 414 Calendar->Entries[Calendar->EntriesNum].Number = 30*24;
412 Calendar->EntriesNum++; 415 Calendar->EntriesNum++;
413 } 416 }
414 if (strstr(Line,"RRULE:YD1")) { 417 if (strstr(Line,"RRULE:YD1")) {
415 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; 418 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE;
416 Calendar->Entries[Calendar->EntriesNum].Number = 365*24; 419 Calendar->Entries[Calendar->EntriesNum].Number = 365*24;
417 Calendar->EntriesNum++; 420 Calendar->EntriesNum++;
418 } 421 }
419 if ((ReadVCALText(Line, "SUMMARY", Buff)) || (ReadVCALText(Line, "DESCRIPTION", Buff))) { 422 // LR
423 if ((ReadVCALText(Line, "SUMMARY", Buff)) ) {
420 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_TEXT; 424 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_TEXT;
421 CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); 425 CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff);
422 Calendar->EntriesNum++; 426 Calendar->EntriesNum++;
423 } 427 }
428 if (ReadVCALText(Line, "DESCRIPTION", Buff)) {
429 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_DESCRIPTION;
430 CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff);
431 Calendar->EntriesNum++;
432 }
424 if (ReadVCALText(Line, "LOCATION", Buff)) { 433 if (ReadVCALText(Line, "LOCATION", Buff)) {
425 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_LOCATION; 434 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_LOCATION;
426 CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); 435 CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff);
427 Calendar->EntriesNum++; 436 Calendar->EntriesNum++;
428 } 437 }
429 if (ReadVCALText(Line, "DTSTART", Buff)) { 438 if (ReadVCALText(Line, "DTSTART", Buff)) {
430 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_START_DATETIME; 439 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_START_DATETIME;
431 ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); 440 ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date);
432 Calendar->EntriesNum++; 441 Calendar->EntriesNum++;
433 } 442 }
434 if (ReadVCALText(Line, "DTEND", Buff)) { 443 if (ReadVCALText(Line, "DTEND", Buff)) {
435 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_END_DATETIME; 444 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_END_DATETIME;
436 ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); 445 ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date);
437 Calendar->EntriesNum++; 446 Calendar->EntriesNum++;
438 } 447 }
439 if (ReadVCALText(Line, "DALARM", Buff)) { 448 if (ReadVCALText(Line, "DALARM", Buff)) {
440 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_SILENT_ALARM_DATETIME; 449 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_SILENT_ALARM_DATETIME;
441 ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); 450 ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date);
442 Calendar->EntriesNum++; 451 Calendar->EntriesNum++;
443 } 452 }
444 if (ReadVCALText(Line, "AALARM", Buff)) { 453 if (ReadVCALText(Line, "AALARM", Buff)) {
445 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_ALARM_DATETIME; 454 Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_ALARM_DATETIME;
446 ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); 455 ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date);
447 Calendar->EntriesNum++; 456 Calendar->EntriesNum++;
448 } 457 }
449 break; 458 break;
450 case 2: /* ToDo note */ 459 case 2: /* ToDo note */
451 if (strstr(Line,"END:VTODO")) { 460 if (strstr(Line,"END:VTODO")) {
452 if (ToDo->EntriesNum == 0) return ERR_EMPTY; 461 if (ToDo->EntriesNum == 0) return ERR_EMPTY;
453 return ERR_NONE; 462 return ERR_NONE;
454 } 463 }
455 if (ReadVCALText(Line, "DUE", Buff)) { 464 if (ReadVCALText(Line, "DUE", Buff)) {
456 ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_END_DATETIME; 465 ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_END_DATETIME;
457 ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); 466 ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date);
458 ToDo->EntriesNum++; 467 ToDo->EntriesNum++;
459 } 468 }
460 if (ReadVCALText(Line, "DALARM", Buff)) { 469 if (ReadVCALText(Line, "DALARM", Buff)) {
461 ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_SILENT_ALARM_DATETIME; 470 ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_SILENT_ALARM_DATETIME;
462 ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); 471 ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date);
463 ToDo->EntriesNum++; 472 ToDo->EntriesNum++;
464 } 473 }
465 if (ReadVCALText(Line, "AALARM", Buff)) { 474 if (ReadVCALText(Line, "AALARM", Buff)) {
466 ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_ALARM_DATETIME; 475 ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_ALARM_DATETIME;
467 ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); 476 ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date);
468 ToDo->EntriesNum++; 477 ToDo->EntriesNum++;
469 } 478 }
470 if (ReadVCALText(Line, "SUMMARY", Buff)) { 479 if (ReadVCALText(Line, "SUMMARY", Buff)) {
471 ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_TEXT; 480 ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_TEXT;
472 CopyUnicodeString(ToDo->Entries[ToDo->EntriesNum].Text,Buff); 481 CopyUnicodeString(ToDo->Entries[ToDo->EntriesNum].Text,Buff);
473 ToDo->EntriesNum++; 482 ToDo->EntriesNum++;
474 } 483 }
475 if (ReadVCALText(Line, "PRIORITY", Buff)) { 484 if (ReadVCALText(Line, "PRIORITY", Buff)) {
476 if (ToDoVer == SonyEricsson_VToDo) { 485 if (ToDoVer == SonyEricsson_VToDo) {
477 ToDo->Priority = GSM_Priority_Medium; 486 ToDo->Priority = GSM_Priority_Medium;
478 if (atoi(DecodeUnicodeString(Buff))>3) ToDo->Priority = GSM_Priority_Low; 487 if (atoi(DecodeUnicodeString(Buff))>3) ToDo->Priority = GSM_Priority_Low;
479 if (atoi(DecodeUnicodeString(Buff))<3) ToDo->Priority = GSM_Priority_High; 488 if (atoi(DecodeUnicodeString(Buff))<3) ToDo->Priority = GSM_Priority_High;
480 dbgprintf("atoi is %i %s\n",atoi(DecodeUnicodeString(Buff)),DecodeUnicodeString(Buff)); 489 dbgprintf("atoi is %i %s\n",atoi(DecodeUnicodeString(Buff)),DecodeUnicodeString(Buff));
481 } else if (ToDoVer == Nokia_VToDo) { 490 } else if (ToDoVer == Nokia_VToDo) {
482 ToDo->Priority = GSM_Priority_Medium; 491 ToDo->Priority = GSM_Priority_Medium;
483 if (atoi(DecodeUnicodeString(Buff))>3) ToDo->Priority = GSM_Priority_Low; 492 if (atoi(DecodeUnicodeString(Buff))>3) ToDo->Priority = GSM_Priority_Low;
484 if (atoi(DecodeUnicodeString(Buff))<3) ToDo->Priority = GSM_Priority_High; 493 if (atoi(DecodeUnicodeString(Buff))<3) ToDo->Priority = GSM_Priority_High;
485 } 494 }
486 } 495 }
487 if (strstr(Line,"PERCENT-COMPLETE:100")) { 496 if (strstr(Line,"PERCENT-COMPLETE:100")) {
488 ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_COMPLETED; 497 ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_COMPLETED;
489 ToDo->Entries[ToDo->EntriesNum].Number = 1; 498 ToDo->Entries[ToDo->EntriesNum].Number = 1;
490 ToDo->EntriesNum++; 499 ToDo->EntriesNum++;
491 } 500 }
492 break; 501 break;
493 } 502 }
494 } 503 }
495 504
496 if (Calendar->EntriesNum == 0 && ToDo->EntriesNum == 0) return ERR_EMPTY; 505 if (Calendar->EntriesNum == 0 && ToDo->EntriesNum == 0) return ERR_EMPTY;
497 return ERR_NONE; 506 return ERR_NONE;
498} 507}
499 508
500GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note) 509GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note)
501{ 510{
502 *Length+=sprintf(Buffer+(*Length), "BEGIN:VNOTE%c%c",13,10); 511 *Length+=sprintf(Buffer+(*Length), "BEGIN:VNOTE%c%c",13,10);
503 *Length+=sprintf(Buffer+(*Length), "VERSION:1.1%c%c",13,10); 512 *Length+=sprintf(Buffer+(*Length), "VERSION:1.1%c%c",13,10);
504 SaveVCALText(Buffer, Length, Note->Text, "BODY"); 513 SaveVCALText(Buffer, Length, Note->Text, "BODY");
505 *Length+=sprintf(Buffer+(*Length), "END:VNOTE%c%c",13,10); 514 *Length+=sprintf(Buffer+(*Length), "END:VNOTE%c%c",13,10);
506 515
507 return ERR_NONE; 516 return ERR_NONE;
508} 517}
509 518
510/* How should editor hadle tabs in this file? Add editor commands here. 519/* How should editor hadle tabs in this file? Add editor commands here.
511 * vim: noexpandtab sw=8 ts=8 sts=8: 520 * vim: noexpandtab sw=8 ts=8 sts=8:
512 */ 521 */
diff --git a/gammu/emb/common/service/gsmcal.h b/gammu/emb/common/service/gsmcal.h
index 0a41b7b..c69fdbe 100644
--- a/gammu/emb/common/service/gsmcal.h
+++ b/gammu/emb/common/service/gsmcal.h
@@ -1,445 +1,446 @@
1/* (c) 2002-2004 by Marcin Wiacek */ 1/* (c) 2002-2004 by Marcin Wiacek */
2/* 5210 calendar IDs by Frederick Ros */ 2/* 5210 calendar IDs by Frederick Ros */
3 3
4#ifndef __gsm_cal_h 4#ifndef __gsm_cal_h
5#define __gsm_cal_h 5#define __gsm_cal_h
6 6
7#include "../gsmcomon.h" 7#include "../gsmcomon.h"
8 8
9/* ---------------------------- calendar ----------------------------------- */ 9/* ---------------------------- calendar ----------------------------------- */
10 10
11 #define GSM_CALENDAR_ENTRIES 16 11 #define GSM_CALENDAR_ENTRIES 16
12 #define MAX_CALENDAR_TEXT_LENGTH256 /* In 6310 max. 256 chars */ 12 #define MAX_CALENDAR_TEXT_LENGTH256 /* In 6310 max. 256 chars */
13 13
14/** 14/**
15 * Enum defines types of calendar notes 15 * Enum defines types of calendar notes
16 */ 16 */
17typedef enum { 17typedef enum {
18 /** 18 /**
19 * Reminder or Date 19 * Reminder or Date
20 */ 20 */
21 GSM_CAL_REMINDER=1, 21 GSM_CAL_REMINDER=1,
22 /** 22 /**
23 * Call 23 * Call
24 */ 24 */
25 GSM_CAL_CALL, 25 GSM_CAL_CALL,
26 /** 26 /**
27 * Meeting 27 * Meeting
28 */ 28 */
29 GSM_CAL_MEETING, 29 GSM_CAL_MEETING,
30 /** 30 /**
31 * Birthday or Anniversary or Special Occasion 31 * Birthday or Anniversary or Special Occasion
32 */ 32 */
33 GSM_CAL_BIRTHDAY, 33 GSM_CAL_BIRTHDAY,
34 /** 34 /**
35 * Memo or Miscellaneous 35 * Memo or Miscellaneous
36 */ 36 */
37 GSM_CAL_MEMO, 37 GSM_CAL_MEMO,
38 /** 38 /**
39 * Travel 39 * Travel
40 */ 40 */
41 GSM_CAL_TRAVEL, 41 GSM_CAL_TRAVEL,
42 /** 42 /**
43 * Vacation 43 * Vacation
44 */ 44 */
45 GSM_CAL_VACATION, 45 GSM_CAL_VACATION,
46 /** 46 /**
47 * Training - Athletism 47 * Training - Athletism
48 */ 48 */
49 GSM_CAL_T_ATHL, 49 GSM_CAL_T_ATHL,
50 /** 50 /**
51 * Training - Ball Games 51 * Training - Ball Games
52 */ 52 */
53 GSM_CAL_T_BALL, 53 GSM_CAL_T_BALL,
54 /** 54 /**
55 * Training - Cycling 55 * Training - Cycling
56 */ 56 */
57 GSM_CAL_T_CYCL, 57 GSM_CAL_T_CYCL,
58 /** 58 /**
59 * Training - Budo 59 * Training - Budo
60 */ 60 */
61 GSM_CAL_T_BUDO, 61 GSM_CAL_T_BUDO,
62 /** 62 /**
63 * Training - Dance 63 * Training - Dance
64 */ 64 */
65 GSM_CAL_T_DANC, 65 GSM_CAL_T_DANC,
66 /** 66 /**
67 * Training - Extreme Sports 67 * Training - Extreme Sports
68 */ 68 */
69 GSM_CAL_T_EXTR, 69 GSM_CAL_T_EXTR,
70 /** 70 /**
71 * Training - Football 71 * Training - Football
72 */ 72 */
73 GSM_CAL_T_FOOT, 73 GSM_CAL_T_FOOT,
74 /** 74 /**
75 * Training - Golf 75 * Training - Golf
76 */ 76 */
77 GSM_CAL_T_GOLF, 77 GSM_CAL_T_GOLF,
78 /** 78 /**
79 * Training - Gym 79 * Training - Gym
80 */ 80 */
81 GSM_CAL_T_GYM, 81 GSM_CAL_T_GYM,
82 /** 82 /**
83 * Training - Horse Race 83 * Training - Horse Race
84 */ 84 */
85 GSM_CAL_T_HORS, 85 GSM_CAL_T_HORS,
86 /** 86 /**
87 * Training - Hockey 87 * Training - Hockey
88 */ 88 */
89 GSM_CAL_T_HOCK, 89 GSM_CAL_T_HOCK,
90 /** 90 /**
91 * Training - Races 91 * Training - Races
92 */ 92 */
93 GSM_CAL_T_RACE, 93 GSM_CAL_T_RACE,
94 /** 94 /**
95 * Training - Rugby 95 * Training - Rugby
96 */ 96 */
97 GSM_CAL_T_RUGB, 97 GSM_CAL_T_RUGB,
98 /** 98 /**
99 * Training - Sailing 99 * Training - Sailing
100 */ 100 */
101 GSM_CAL_T_SAIL, 101 GSM_CAL_T_SAIL,
102 /** 102 /**
103 * Training - Street Games 103 * Training - Street Games
104 */ 104 */
105 GSM_CAL_T_STRE, 105 GSM_CAL_T_STRE,
106 /** 106 /**
107 * Training - Swimming 107 * Training - Swimming
108 */ 108 */
109 GSM_CAL_T_SWIM, 109 GSM_CAL_T_SWIM,
110 /** 110 /**
111 * Training - Tennis 111 * Training - Tennis
112 */ 112 */
113 GSM_CAL_T_TENN, 113 GSM_CAL_T_TENN,
114 /** 114 /**
115 * Training - Travels 115 * Training - Travels
116 */ 116 */
117 GSM_CAL_T_TRAV, 117 GSM_CAL_T_TRAV,
118 /** 118 /**
119 * Training - Winter Games 119 * Training - Winter Games
120 */ 120 */
121 GSM_CAL_T_WINT, 121 GSM_CAL_T_WINT,
122 /** 122 /**
123 * Alarm 123 * Alarm
124 */ 124 */
125 GSM_CAL_ALARM, 125 GSM_CAL_ALARM,
126 /** 126 /**
127 * Alarm repeating each day. 127 * Alarm repeating each day.
128 */ 128 */
129 GSM_CAL_DAILY_ALARM 129 GSM_CAL_DAILY_ALARM
130} GSM_CalendarNoteType; 130} GSM_CalendarNoteType;
131 131
132/** 132/**
133 * One value of calendar event. 133 * One value of calendar event.
134 */ 134 */
135typedef enum { 135typedef enum {
136 /** 136 /**
137 * Date and time of event start. 137 * Date and time of event start.
138 */ 138 */
139 CAL_START_DATETIME = 1, 139 CAL_START_DATETIME = 1,
140 /** 140 /**
141 * Date and time of event end. 141 * Date and time of event end.
142 */ 142 */
143 CAL_END_DATETIME, 143 CAL_END_DATETIME,
144 /** 144 /**
145 * Alarm date and time. 145 * Alarm date and time.
146 */ 146 */
147 CAL_ALARM_DATETIME, 147 CAL_ALARM_DATETIME,
148 /** 148 /**
149 * Date and time of silent alarm. 149 * Date and time of silent alarm.
150 */ 150 */
151 CAL_SILENT_ALARM_DATETIME, 151 CAL_SILENT_ALARM_DATETIME,
152 /** 152 /**
153 * Recurrance. 153 * Recurrance.
154 */ 154 */
155 CAL_RECURRANCE, 155 CAL_RECURRANCE,
156 /** 156 /**
157 * Text. 157 * Text.
158 */ 158 */
159 CAL_TEXT, 159 CAL_TEXT,
160 CAL_DESCRIPTION, // LR added
160 /** 161 /**
161 * Location. 162 * Location.
162 */ 163 */
163 CAL_LOCATION, 164 CAL_LOCATION,
164 /** 165 /**
165 * Phone number. 166 * Phone number.
166 */ 167 */
167 CAL_PHONE, 168 CAL_PHONE,
168 /** 169 /**
169 * Whether this entry is private. 170 * Whether this entry is private.
170 */ 171 */
171 CAL_PRIVATE, 172 CAL_PRIVATE,
172 /** 173 /**
173 * Related contact id. 174 * Related contact id.
174 */ 175 */
175 CAL_CONTACTID, 176 CAL_CONTACTID,
176 /** 177 /**
177 * Repeat each x'th day of week. 178 * Repeat each x'th day of week.
178 */ 179 */
179 CAL_REPEAT_DAYOFWEEK, 180 CAL_REPEAT_DAYOFWEEK,
180 /** 181 /**
181 * Repeat each x'th day of month. 182 * Repeat each x'th day of month.
182 */ 183 */
183 CAL_REPEAT_DAY, 184 CAL_REPEAT_DAY,
184 /** 185 /**
185 * Repeat x'th week of month. 186 * Repeat x'th week of month.
186 */ 187 */
187 CAL_REPEAT_WEEKOFMONTH, 188 CAL_REPEAT_WEEKOFMONTH,
188 /** 189 /**
189 * Repeat x'th month. 190 * Repeat x'th month.
190 */ 191 */
191 CAL_REPEAT_MONTH, 192 CAL_REPEAT_MONTH,
192 /** 193 /**
193 * Repeating frequency. 194 * Repeating frequency.
194 */ 195 */
195 CAL_REPEAT_FREQUENCY, 196 CAL_REPEAT_FREQUENCY,
196 /** 197 /**
197 * Repeating start. 198 * Repeating start.
198 */ 199 */
199 CAL_REPEAT_STARTDATE, 200 CAL_REPEAT_STARTDATE,
200 /** 201 /**
201 * Repeating end. 202 * Repeating end.
202 */ 203 */
203 CAL_REPEAT_STOPDATE 204 CAL_REPEAT_STOPDATE
204} GSM_CalendarType; 205} GSM_CalendarType;
205 206
206/** 207/**
207 * One value of calendar event. 208 * One value of calendar event.
208 */ 209 */
209typedef struct { 210typedef struct {
210 /** 211 /**
211 * Type of value. 212 * Type of value.
212 */ 213 */
213 GSM_CalendarTypeEntryType; 214 GSM_CalendarTypeEntryType;
214 /** 215 /**
215 * Text of value, if applicable. 216 * Text of value, if applicable.
216 */ 217 */
217 unsigned char Text[(MAX_CALENDAR_TEXT_LENGTH + 1)*2]; 218 unsigned char Text[(MAX_CALENDAR_TEXT_LENGTH + 1)*2];
218 /** 219 /**
219 * Date and time of value, if applicable. 220 * Date and time of value, if applicable.
220 */ 221 */
221 GSM_DateTime Date; 222 GSM_DateTime Date;
222 /** 223 /**
223 * Number of value, if applicable. 224 * Number of value, if applicable.
224 */ 225 */
225 unsigned int Number; 226 unsigned int Number;
226} GSM_SubCalendarEntry; 227} GSM_SubCalendarEntry;
227 228
228/** 229/**
229 * Calendar note values. 230 * Calendar note values.
230 */ 231 */
231typedef struct { 232typedef struct {
232 /** 233 /**
233 * Type of calendar note. 234 * Type of calendar note.
234 */ 235 */
235 GSM_CalendarNoteType Type; 236 GSM_CalendarNoteType Type;
236 /** 237 /**
237 * Location in memory. 238 * Location in memory.
238 */ 239 */
239 int Location; 240 int Location;
240 /** 241 /**
241 * Number of entries. 242 * Number of entries.
242 */ 243 */
243 int EntriesNum; 244 int EntriesNum;
244 /** 245 /**
245 * Values of entries. 246 * Values of entries.
246 */ 247 */
247 GSM_SubCalendarEntry Entries[GSM_CALENDAR_ENTRIES]; 248 GSM_SubCalendarEntry Entries[GSM_CALENDAR_ENTRIES];
248} GSM_CalendarEntry; 249} GSM_CalendarEntry;
249 250
250void GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(GSM_CalendarEntry *entry, int *Text, int *Time, int *Alarm, int *Phone, int *Recurrance, int *EndTime, int *Location); 251void GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(GSM_CalendarEntry *entry, int *Text, int *Time, int *Alarm, int *Phone, int *Recurrance, int *EndTime, int *Location);
251 252
252typedef enum { 253typedef enum {
253 Nokia_VCalendar = 1, 254 Nokia_VCalendar = 1,
254 Siemens_VCalendar, 255 Siemens_VCalendar,
255 SonyEricsson_VCalendar 256 SonyEricsson_VCalendar
256} GSM_VCalendarVersion; 257} GSM_VCalendarVersion;
257 258
258GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note, bool header, GSM_VCalendarVersion Version); 259GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note, bool header, GSM_VCalendarVersion Version);
259 260
260bool IsCalendarNoteFromThePast(GSM_CalendarEntry *note); 261bool IsCalendarNoteFromThePast(GSM_CalendarEntry *note);
261 262
262typedef struct { 263typedef struct {
263 /** 264 /**
264 * Monday = 1, Tuesday = 2,... 265 * Monday = 1, Tuesday = 2,...
265 */ 266 */
266 int StartDay; 267 int StartDay;
267 /** 268 /**
268 * 0 = no delete, 1 = after day,... 269 * 0 = no delete, 1 = after day,...
269 */ 270 */
270 int AutoDelete; 271 int AutoDelete;
271} GSM_CalendarSettings; 272} GSM_CalendarSettings;
272 273
273/** 274/**
274 * Structure used for returning calendar status. 275 * Structure used for returning calendar status.
275 */ 276 */
276typedef struct { 277typedef struct {
277 /** 278 /**
278 * Number of used positions. 279 * Number of used positions.
279 */ 280 */
280 int Used; 281 int Used;
281} GSM_CalendarStatus; 282} GSM_CalendarStatus;
282 283
283 284
284/* ------------------------------ to-do ------------------------------------ */ 285/* ------------------------------ to-do ------------------------------------ */
285 286
286 #define GSM_TODO_ENTRIES 7 287 #define GSM_TODO_ENTRIES 7
287 #define MAX_TODO_TEXT_LENGTH 50 /* Alcatel BE5 50 chars */ 288 #define MAX_TODO_TEXT_LENGTH 50 /* Alcatel BE5 50 chars */
288 289
289/** 290/**
290 * Types of to do values. In parenthesis is member of @ref GSM_SubToDoEntry, 291 * Types of to do values. In parenthesis is member of @ref GSM_SubToDoEntry,
291 * where value is stored. 292 * where value is stored.
292 */ 293 */
293typedef enum { 294typedef enum {
294 /** 295 /**
295 * Due date. (Date) 296 * Due date. (Date)
296 */ 297 */
297 TODO_END_DATETIME = 1, 298 TODO_END_DATETIME = 1,
298 /** 299 /**
299 * Whether is completed. (Number) 300 * Whether is completed. (Number)
300 */ 301 */
301 TODO_COMPLETED, 302 TODO_COMPLETED,
302 /** 303 /**
303 * When should alarm be fired (Date). 304 * When should alarm be fired (Date).
304 */ 305 */
305 TODO_ALARM_DATETIME, 306 TODO_ALARM_DATETIME,
306 /** 307 /**
307 * When should silent alarm be fired (Date). 308 * When should silent alarm be fired (Date).
308 */ 309 */
309 TODO_SILENT_ALARM_DATETIME, 310 TODO_SILENT_ALARM_DATETIME,
310 /** 311 /**
311 * Text of to do (Text). 312 * Text of to do (Text).
312 */ 313 */
313 TODO_TEXT, 314 TODO_TEXT,
314 /** 315 /**
315 * Whether entry is private (Number). 316 * Whether entry is private (Number).
316 */ 317 */
317 TODO_PRIVATE, 318 TODO_PRIVATE,
318 /** 319 /**
319 * Category of entry (Number). 320 * Category of entry (Number).
320 */ 321 */
321 TODO_CATEGORY, 322 TODO_CATEGORY,
322 /** 323 /**
323 * Related contact ID (Number). 324 * Related contact ID (Number).
324 */ 325 */
325 TODO_CONTACTID, 326 TODO_CONTACTID,
326 /** 327 /**
327 * Number to call (Text). 328 * Number to call (Text).
328 */ 329 */
329 TODO_PHONE 330 TODO_PHONE
330} GSM_ToDoType; 331} GSM_ToDoType;
331 332
332/** 333/**
333 * Priority of to do. 334 * Priority of to do.
334 */ 335 */
335typedef enum { 336typedef enum {
336 GSM_Priority_High = 1, 337 GSM_Priority_High = 1,
337 GSM_Priority_Medium, 338 GSM_Priority_Medium,
338 GSM_Priority_Low 339 GSM_Priority_Low
339} GSM_ToDo_Priority; 340} GSM_ToDo_Priority;
340 341
341/** 342/**
342 * Value of to do entry. 343 * Value of to do entry.
343 */ 344 */
344typedef struct { 345typedef struct {
345 /** 346 /**
346 * Type of entry. 347 * Type of entry.
347 */ 348 */
348 GSM_ToDoType EntryType; 349 GSM_ToDoType EntryType;
349 /** 350 /**
350 * Text of value, if appropriate, see @ref GSM_ToDoType. 351 * Text of value, if appropriate, see @ref GSM_ToDoType.
351 */ 352 */
352 unsigned char Text[(MAX_TODO_TEXT_LENGTH + 1)*2]; 353 unsigned char Text[(MAX_TODO_TEXT_LENGTH + 1)*2];
353 /** 354 /**
354 * Date of value, if appropriate, see @ref GSM_ToDoType. 355 * Date of value, if appropriate, see @ref GSM_ToDoType.
355 */ 356 */
356 GSM_DateTime Date; 357 GSM_DateTime Date;
357 /** 358 /**
358 * Number of value, if appropriate, see @ref GSM_ToDoType. 359 * Number of value, if appropriate, see @ref GSM_ToDoType.
359 */ 360 */
360 unsigned int Number; 361 unsigned int Number;
361} GSM_SubToDoEntry; 362} GSM_SubToDoEntry;
362 363
363/** 364/**
364 * To do entry. 365 * To do entry.
365 */ 366 */
366typedef struct { 367typedef struct {
367 /** 368 /**
368 * Priority of entry. 369 * Priority of entry.
369 */ 370 */
370 GSM_ToDo_Priority Priority; 371 GSM_ToDo_Priority Priority;
371 /** 372 /**
372 * Location in memory. 373 * Location in memory.
373 */ 374 */
374 int Location; 375 int Location;
375 /** 376 /**
376 * Number of entries. 377 * Number of entries.
377 */ 378 */
378 int EntriesNum; 379 int EntriesNum;
379 /** 380 /**
380 * Values of current entry. 381 * Values of current entry.
381 */ 382 */
382 GSM_SubToDoEntryEntries[GSM_TODO_ENTRIES]; 383 GSM_SubToDoEntryEntries[GSM_TODO_ENTRIES];
383} GSM_ToDoEntry; 384} GSM_ToDoEntry;
384 385
385void GSM_ToDoFindDefaultTextTimeAlarmCompleted(GSM_ToDoEntry *entry, int *Text, int *Alarm, int *Completed, int *EndTime, int *Phone); 386void GSM_ToDoFindDefaultTextTimeAlarmCompleted(GSM_ToDoEntry *entry, int *Text, int *Alarm, int *Completed, int *EndTime, int *Phone);
386 387
387typedef enum { 388typedef enum {
388 Nokia_VToDo = 1, 389 Nokia_VToDo = 1,
389 SonyEricsson_VToDo 390 SonyEricsson_VToDo
390} GSM_VToDoVersion; 391} GSM_VToDoVersion;
391 392
392GSM_Error GSM_EncodeVTODO(char *Buffer, int *Length, GSM_ToDoEntry *note, bool header, GSM_VToDoVersion Version); 393GSM_Error GSM_EncodeVTODO(char *Buffer, int *Length, GSM_ToDoEntry *note, bool header, GSM_VToDoVersion Version);
393 394
394/** 395/**
395 * Status of to do entries. 396 * Status of to do entries.
396 */ 397 */
397typedef struct { 398typedef struct {
398 /** 399 /**
399 * Number of used positions. 400 * Number of used positions.
400 */ 401 */
401 int Used; 402 int Used;
402} GSM_ToDoStatus; 403} GSM_ToDoStatus;
403 404
404/* --------------------------- note ---------------------------------------- */ 405/* --------------------------- note ---------------------------------------- */
405 406
406typedef struct { 407typedef struct {
407 int Location; 408 int Location;
408 char Text[3000*2]; 409 char Text[3000*2];
409} GSM_NoteEntry; 410} GSM_NoteEntry;
410 411
411GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note); 412GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note);
412 413
413/* --------------------------- alarm --------------------------------------- */ 414/* --------------------------- alarm --------------------------------------- */
414 415
415/** 416/**
416 * Alarm values. 417 * Alarm values.
417 */ 418 */
418typedef struct { 419typedef struct {
419 /** 420 /**
420 * Location where it is stored. 421 * Location where it is stored.
421 */ 422 */
422 int Location; 423 int Location;
423 /** 424 /**
424 * Date and time of alarm. 425 * Date and time of alarm.
425 */ 426 */
426 GSM_DateTime DateTime; 427 GSM_DateTime DateTime;
427 /** 428 /**
428 * Whether it repeats each day. 429 * Whether it repeats each day.
429 */ 430 */
430 bool Repeating; 431 bool Repeating;
431 /** 432 /**
432 * Text that is shown on display. 433 * Text that is shown on display.
433 */ 434 */
434 char Text[(MAX_CALENDAR_TEXT_LENGTH + 1) * 2]; 435 char Text[(MAX_CALENDAR_TEXT_LENGTH + 1) * 2];
435} GSM_Alarm; 436} GSM_Alarm;
436 437
437/* --------------------------- calendar & todo ----------------------------- */ 438/* --------------------------- calendar & todo ----------------------------- */
438 439
439GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_CalendarEntry *Calendar, GSM_ToDoEntry *ToDo, GSM_VCalendarVersion CalVer, GSM_VToDoVersion ToDoVer); 440GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_CalendarEntry *Calendar, GSM_ToDoEntry *ToDo, GSM_VCalendarVersion CalVer, GSM_VToDoVersion ToDoVer);
440 441
441#endif 442#endif
442 443
443/* How should editor hadle tabs in this file? Add editor commands here. 444/* How should editor hadle tabs in this file? Add editor commands here.
444 * vim: noexpandtab sw=8 ts=8 sts=8: 445 * vim: noexpandtab sw=8 ts=8 sts=8:
445 */ 446 */
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 47ed858..dae9cd2 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,2879 +1,2881 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/*s 24/*s
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include "kabcore.h" 31#include "kabcore.h"
32 32
33#include <stdaddressbook.h> 33#include <stdaddressbook.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kfiledialog.h> 35#include <kfiledialog.h>
36#include <qtimer.h> 36#include <qtimer.h>
37#include <qlabel.h> 37#include <qlabel.h>
38#include <qregexp.h> 38#include <qregexp.h>
39#include <qlineedit.h> 39#include <qlineedit.h>
40#include <qcheckbox.h> 40#include <qcheckbox.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qprogressbar.h> 42#include <qprogressbar.h>
43#include <libkdepim/phoneaccess.h> 43#include <libkdepim/phoneaccess.h>
44 44
45#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
46#include <qclipboard.h> 46#include <qclipboard.h>
47#include <qdir.h> 47#include <qdir.h>
48#include <qfile.h> 48#include <qfile.h>
49#include <qapplicaton.h> 49#include <qapplicaton.h>
50#include <qprogressbar.h> 50#include <qprogressbar.h>
51#include <qlayout.h> 51#include <qlayout.h>
52#include <qregexp.h> 52#include <qregexp.h>
53#include <qvbox.h> 53#include <qvbox.h>
54#include <kabc/addresseelist.h> 54#include <kabc/addresseelist.h>
55#include <kabc/errorhandler.h> 55#include <kabc/errorhandler.h>
56#include <kabc/resource.h> 56#include <kabc/resource.h>
57#include <kabc/vcardconverter.h> 57#include <kabc/vcardconverter.h>
58#include <kapplication.h> 58#include <kapplication.h>
59#include <kactionclasses.h> 59#include <kactionclasses.h>
60#include <kcmultidialog.h> 60#include <kcmultidialog.h>
61#include <kdebug.h> 61#include <kdebug.h>
62#include <kdeversion.h> 62#include <kdeversion.h>
63#include <kkeydialog.h> 63#include <kkeydialog.h>
64#include <kmessagebox.h> 64#include <kmessagebox.h>
65#include <kprinter.h> 65#include <kprinter.h>
66#include <kprotocolinfo.h> 66#include <kprotocolinfo.h>
67#include <kresources/selectdialog.h> 67#include <kresources/selectdialog.h>
68#include <kstandarddirs.h> 68#include <kstandarddirs.h>
69#include <ktempfile.h> 69#include <ktempfile.h>
70#include <kxmlguiclient.h> 70#include <kxmlguiclient.h>
71#include <kaboutdata.h> 71#include <kaboutdata.h>
72#include <libkdepim/categoryselectdialog.h> 72#include <libkdepim/categoryselectdialog.h>
73 73
74#include "addresseeutil.h" 74#include "addresseeutil.h"
75#include "addresseeeditordialog.h" 75#include "addresseeeditordialog.h"
76#include "extensionmanager.h" 76#include "extensionmanager.h"
77#include "kstdaction.h" 77#include "kstdaction.h"
78#include "kaddressbookservice.h" 78#include "kaddressbookservice.h"
79#include "ldapsearchdialog.h" 79#include "ldapsearchdialog.h"
80#include "printing/printingwizard.h" 80#include "printing/printingwizard.h"
81#else // KAB_EMBEDDED 81#else // KAB_EMBEDDED
82 82
83#include <kapplication.h> 83#include <kapplication.h>
84#include "KDGanttMinimizeSplitter.h" 84#include "KDGanttMinimizeSplitter.h"
85#include "kaddressbookmain.h" 85#include "kaddressbookmain.h"
86#include "kactioncollection.h" 86#include "kactioncollection.h"
87#include "addresseedialog.h" 87#include "addresseedialog.h"
88//US 88//US
89#include <addresseeview.h> 89#include <addresseeview.h>
90 90
91#include <qapp.h> 91#include <qapp.h>
92#include <qmenubar.h> 92#include <qmenubar.h>
93//#include <qtoolbar.h> 93//#include <qtoolbar.h>
94#include <qmessagebox.h> 94#include <qmessagebox.h>
95#include <kdebug.h> 95#include <kdebug.h>
96#include <kiconloader.h> // needed for SmallIcon 96#include <kiconloader.h> // needed for SmallIcon
97#include <kresources/kcmkresources.h> 97#include <kresources/kcmkresources.h>
98#include <ktoolbar.h> 98#include <ktoolbar.h>
99 99
100 100
101//#include <qlabel.h> 101//#include <qlabel.h>
102 102
103 103
104#ifndef DESKTOP_VERSION 104#ifndef DESKTOP_VERSION
105#include <qpe/ir.h> 105#include <qpe/ir.h>
106#include <qpe/qpemenubar.h> 106#include <qpe/qpemenubar.h>
107#include <qtopia/qcopenvelope_qws.h> 107#include <qtopia/qcopenvelope_qws.h>
108#else 108#else
109 109
110#include <qmenubar.h> 110#include <qmenubar.h>
111#endif 111#endif
112 112
113#endif // KAB_EMBEDDED 113#endif // KAB_EMBEDDED
114#include "kcmconfigs/kcmkabconfig.h" 114#include "kcmconfigs/kcmkabconfig.h"
115#include "kcmconfigs/kcmkdepimconfig.h" 115#include "kcmconfigs/kcmkdepimconfig.h"
116#include "kpimglobalprefs.h" 116#include "kpimglobalprefs.h"
117#include "externalapphandler.h" 117#include "externalapphandler.h"
118 118
119 119
120#include <kresources/selectdialog.h> 120#include <kresources/selectdialog.h>
121#include <kmessagebox.h> 121#include <kmessagebox.h>
122 122
123#include <picture.h> 123#include <picture.h>
124#include <resource.h> 124#include <resource.h>
125 125
126//US#include <qsplitter.h> 126//US#include <qsplitter.h>
127#include <qmap.h> 127#include <qmap.h>
128#include <qdir.h> 128#include <qdir.h>
129#include <qfile.h> 129#include <qfile.h>
130#include <qvbox.h> 130#include <qvbox.h>
131#include <qlayout.h> 131#include <qlayout.h>
132#include <qclipboard.h> 132#include <qclipboard.h>
133#include <qtextstream.h> 133#include <qtextstream.h>
134 134
135#include <libkdepim/categoryselectdialog.h> 135#include <libkdepim/categoryselectdialog.h>
136#include <kabc/vcardconverter.h> 136#include <kabc/vcardconverter.h>
137 137
138 138
139#include "addresseeutil.h" 139#include "addresseeutil.h"
140#include "undocmds.h" 140#include "undocmds.h"
141#include "addresseeeditordialog.h" 141#include "addresseeeditordialog.h"
142#include "viewmanager.h" 142#include "viewmanager.h"
143#include "details/detailsviewcontainer.h" 143#include "details/detailsviewcontainer.h"
144#include "kabprefs.h" 144#include "kabprefs.h"
145#include "xxportmanager.h" 145#include "xxportmanager.h"
146#include "incsearchwidget.h" 146#include "incsearchwidget.h"
147#include "jumpbuttonbar.h" 147#include "jumpbuttonbar.h"
148#include "extensionmanager.h" 148#include "extensionmanager.h"
149#include "addresseeconfig.h" 149#include "addresseeconfig.h"
150#include <kcmultidialog.h> 150#include <kcmultidialog.h>
151 151
152#ifdef _WIN32_ 152#ifdef _WIN32_
153 153
154#include "kaimportoldialog.h" 154#include "kaimportoldialog.h"
155#else 155#else
156#include <unistd.h> 156#include <unistd.h>
157#endif 157#endif
158// sync includes 158// sync includes
159#include <libkdepim/ksyncprofile.h> 159#include <libkdepim/ksyncprofile.h>
160#include <libkdepim/ksyncprefsdialog.h> 160#include <libkdepim/ksyncprefsdialog.h>
161 161
162class KAex2phonePrefs : public QDialog 162class KAex2phonePrefs : public QDialog
163{ 163{
164 public: 164 public:
165 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 165 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
166 QDialog( parent, name, true ) 166 QDialog( parent, name, true )
167 { 167 {
168 setCaption( i18n("Export to phone options") ); 168 setCaption( i18n("Export to phone options") );
169 QVBoxLayout* lay = new QVBoxLayout( this ); 169 QVBoxLayout* lay = new QVBoxLayout( this );
170 lay->setSpacing( 3 ); 170 lay->setSpacing( 3 );
171 lay->setMargin( 3 ); 171 lay->setMargin( 3 );
172 QLabel *lab; 172 QLabel *lab;
173 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 173 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
174 lab->setAlignment (AlignHCenter ); 174 lab->setAlignment (AlignHCenter );
175 QHBox* temphb; 175 QHBox* temphb;
176 temphb = new QHBox( this ); 176 temphb = new QHBox( this );
177 new QLabel( i18n("I/O device: "), temphb ); 177 new QLabel( i18n("I/O device: "), temphb );
178 mPhoneDevice = new QLineEdit( temphb); 178 mPhoneDevice = new QLineEdit( temphb);
179 lay->addWidget( temphb ); 179 lay->addWidget( temphb );
180 temphb = new QHBox( this ); 180 temphb = new QHBox( this );
181 new QLabel( i18n("Connection: "), temphb ); 181 new QLabel( i18n("Connection: "), temphb );
182 mPhoneConnection = new QLineEdit( temphb); 182 mPhoneConnection = new QLineEdit( temphb);
183 lay->addWidget( temphb ); 183 lay->addWidget( temphb );
184 temphb = new QHBox( this ); 184 temphb = new QHBox( this );
185 new QLabel( i18n("Model(opt.): "), temphb ); 185 new QLabel( i18n("Model(opt.): "), temphb );
186 mPhoneModel = new QLineEdit( temphb); 186 mPhoneModel = new QLineEdit( temphb);
187 lay->addWidget( temphb ); 187 lay->addWidget( temphb );
188 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 188 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
189 // lay->addWidget( mWriteToSim ); 189 // lay->addWidget( mWriteToSim );
190 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 190 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
191 lab->setAlignment (AlignHCenter ); 191 lab->setAlignment (AlignHCenter );
192 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 192 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
193 lay->addWidget( ok ); 193 lay->addWidget( ok );
194 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 194 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
195 lay->addWidget( cancel ); 195 lay->addWidget( cancel );
196 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 196 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
197 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 197 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
198 resize( 220, 240 ); 198 resize( 220, 240 );
199 199
200 } 200 }
201 201
202public: 202public:
203 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 203 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
204 QCheckBox* mWriteToSim; 204 QCheckBox* mWriteToSim;
205}; 205};
206 206
207bool pasteWithNewUid = true; 207bool pasteWithNewUid = true;
208 208
209#ifdef KAB_EMBEDDED 209#ifdef KAB_EMBEDDED
210KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 210KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
211 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 211 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
212 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 212 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
213 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 213 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
214#else //KAB_EMBEDDED 214#else //KAB_EMBEDDED
215KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 215KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
216 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 216 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
217 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 217 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
218 mReadWrite( readWrite ), mModified( false ) 218 mReadWrite( readWrite ), mModified( false )
219#endif //KAB_EMBEDDED 219#endif //KAB_EMBEDDED
220{ 220{
221 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 221 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
222 // syncManager->setBlockSave(false); 222 // syncManager->setBlockSave(false);
223 mExtensionBarSplitter = 0; 223 mExtensionBarSplitter = 0;
224 mIsPart = !parent->inherits( "KAddressBookMain" ); 224 mIsPart = !parent->inherits( "KAddressBookMain" );
225 225
226 mAddressBook = KABC::StdAddressBook::self(); 226 mAddressBook = KABC::StdAddressBook::self();
227 KABC::StdAddressBook::setAutomaticSave( false ); 227 KABC::StdAddressBook::setAutomaticSave( false );
228 228
229#ifndef KAB_EMBEDDED 229#ifndef KAB_EMBEDDED
230 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 230 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
231#endif //KAB_EMBEDDED 231#endif //KAB_EMBEDDED
232 232
233 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 233 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
234 SLOT( addressBookChanged() ) ); 234 SLOT( addressBookChanged() ) );
235 235
236#if 0 236#if 0
237 // LP moved to addressbook init method 237 // LP moved to addressbook init method
238 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 238 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
239 "X-Department", "KADDRESSBOOK" ); 239 "X-Department", "KADDRESSBOOK" );
240 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 240 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
241 "X-Profession", "KADDRESSBOOK" ); 241 "X-Profession", "KADDRESSBOOK" );
242 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 242 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
243 "X-AssistantsName", "KADDRESSBOOK" ); 243 "X-AssistantsName", "KADDRESSBOOK" );
244 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 244 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
245 "X-ManagersName", "KADDRESSBOOK" ); 245 "X-ManagersName", "KADDRESSBOOK" );
246 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 246 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
247 "X-SpousesName", "KADDRESSBOOK" ); 247 "X-SpousesName", "KADDRESSBOOK" );
248 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 248 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
249 "X-Office", "KADDRESSBOOK" ); 249 "X-Office", "KADDRESSBOOK" );
250 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 250 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
251 "X-IMAddress", "KADDRESSBOOK" ); 251 "X-IMAddress", "KADDRESSBOOK" );
252 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 252 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
253 "X-Anniversary", "KADDRESSBOOK" ); 253 "X-Anniversary", "KADDRESSBOOK" );
254 254
255 //US added this field to become compatible with Opie/qtopia addressbook 255 //US added this field to become compatible with Opie/qtopia addressbook
256 // values can be "female" or "male" or "". An empty field represents undefined. 256 // values can be "female" or "male" or "". An empty field represents undefined.
257 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 257 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
258 "X-Gender", "KADDRESSBOOK" ); 258 "X-Gender", "KADDRESSBOOK" );
259 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 259 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
260 "X-Children", "KADDRESSBOOK" ); 260 "X-Children", "KADDRESSBOOK" );
261 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 261 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
262 "X-FreeBusyUrl", "KADDRESSBOOK" ); 262 "X-FreeBusyUrl", "KADDRESSBOOK" );
263#endif 263#endif
264 initGUI(); 264 initGUI();
265 265
266 mIncSearchWidget->setFocus(); 266 mIncSearchWidget->setFocus();
267 267
268 268
269 connect( mViewManager, SIGNAL( selected( const QString& ) ), 269 connect( mViewManager, SIGNAL( selected( const QString& ) ),
270 SLOT( setContactSelected( const QString& ) ) ); 270 SLOT( setContactSelected( const QString& ) ) );
271 connect( mViewManager, SIGNAL( executed( const QString& ) ), 271 connect( mViewManager, SIGNAL( executed( const QString& ) ),
272 SLOT( executeContact( const QString& ) ) ); 272 SLOT( executeContact( const QString& ) ) );
273 273
274 connect( mViewManager, SIGNAL( deleteRequest( ) ), 274 connect( mViewManager, SIGNAL( deleteRequest( ) ),
275 SLOT( deleteContacts( ) ) ); 275 SLOT( deleteContacts( ) ) );
276 connect( mViewManager, SIGNAL( modified() ), 276 connect( mViewManager, SIGNAL( modified() ),
277 SLOT( setModified() ) ); 277 SLOT( setModified() ) );
278 278
279 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 279 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
280 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 280 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
281 281
282 connect( mXXPortManager, SIGNAL( modified() ), 282 connect( mXXPortManager, SIGNAL( modified() ),
283 SLOT( setModified() ) ); 283 SLOT( setModified() ) );
284 284
285 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 285 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
286 SLOT( incrementalSearch( const QString& ) ) ); 286 SLOT( incrementalSearch( const QString& ) ) );
287 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 287 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
288 mJumpButtonBar, SLOT( recreateButtons() ) ); 288 mJumpButtonBar, SLOT( recreateButtons() ) );
289 289
290 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 290 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
291 SLOT( sendMail( const QString& ) ) ); 291 SLOT( sendMail( const QString& ) ) );
292 292
293 293
294 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 294 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
295 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); 295 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
296 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 296 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
297 297
298 298
299#ifndef KAB_EMBEDDED 299#ifndef KAB_EMBEDDED
300 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 300 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
301 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 301 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
302 302
303 connect( mDetails, SIGNAL( browse( const QString& ) ), 303 connect( mDetails, SIGNAL( browse( const QString& ) ),
304 SLOT( browse( const QString& ) ) ); 304 SLOT( browse( const QString& ) ) );
305 305
306 306
307 mAddressBookService = new KAddressBookService( this ); 307 mAddressBookService = new KAddressBookService( this );
308 308
309#endif //KAB_EMBEDDED 309#endif //KAB_EMBEDDED
310 mEditorDialog = 0; 310 mEditorDialog = 0;
311 createAddresseeEditorDialog( this ); 311 createAddresseeEditorDialog( this );
312 setModified( false ); 312 setModified( false );
313} 313}
314 314
315KABCore::~KABCore() 315KABCore::~KABCore()
316{ 316{
317 // save(); 317 // save();
318 //saveSettings(); 318 //saveSettings();
319 //KABPrefs::instance()->writeConfig(); 319 //KABPrefs::instance()->writeConfig();
320 delete AddresseeConfig::instance(); 320 delete AddresseeConfig::instance();
321 mAddressBook = 0; 321 mAddressBook = 0;
322 KABC::StdAddressBook::close(); 322 KABC::StdAddressBook::close();
323 323
324 delete syncManager; 324 delete syncManager;
325 325
326} 326}
327 327
328void KABCore::recieve( QString fn ) 328void KABCore::recieve( QString fn )
329{ 329{
330 //qDebug("KABCore::recieve "); 330 //qDebug("KABCore::recieve ");
331 mAddressBook->importFromFile( fn, true ); 331 mAddressBook->importFromFile( fn, true );
332 mViewManager->refreshView(); 332 mViewManager->refreshView();
333 topLevelWidget()->raise(); 333 topLevelWidget()->raise();
334} 334}
335void KABCore::restoreSettings() 335void KABCore::restoreSettings()
336{ 336{
337 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 337 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
338 338
339 bool state; 339 bool state;
340 340
341 if (mMultipleViewsAtOnce) 341 if (mMultipleViewsAtOnce)
342 state = KABPrefs::instance()->mDetailsPageVisible; 342 state = KABPrefs::instance()->mDetailsPageVisible;
343 else 343 else
344 state = false; 344 state = false;
345 345
346 mActionDetails->setChecked( state ); 346 mActionDetails->setChecked( state );
347 setDetailsVisible( state ); 347 setDetailsVisible( state );
348 348
349 state = KABPrefs::instance()->mJumpButtonBarVisible; 349 state = KABPrefs::instance()->mJumpButtonBarVisible;
350 350
351 mActionJumpBar->setChecked( state ); 351 mActionJumpBar->setChecked( state );
352 setJumpButtonBarVisible( state ); 352 setJumpButtonBarVisible( state );
353/*US 353/*US
354 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 354 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
355 if ( splitterSize.count() == 0 ) { 355 if ( splitterSize.count() == 0 ) {
356 splitterSize.append( width() / 2 ); 356 splitterSize.append( width() / 2 );
357 splitterSize.append( width() / 2 ); 357 splitterSize.append( width() / 2 );
358 } 358 }
359 mMiniSplitter->setSizes( splitterSize ); 359 mMiniSplitter->setSizes( splitterSize );
360 if ( mExtensionBarSplitter ) { 360 if ( mExtensionBarSplitter ) {
361 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 361 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
362 if ( splitterSize.count() == 0 ) { 362 if ( splitterSize.count() == 0 ) {
363 splitterSize.append( width() / 2 ); 363 splitterSize.append( width() / 2 );
364 splitterSize.append( width() / 2 ); 364 splitterSize.append( width() / 2 );
365 } 365 }
366 mExtensionBarSplitter->setSizes( splitterSize ); 366 mExtensionBarSplitter->setSizes( splitterSize );
367 367
368 } 368 }
369*/ 369*/
370 mViewManager->restoreSettings(); 370 mViewManager->restoreSettings();
371 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 371 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
372 mExtensionManager->restoreSettings(); 372 mExtensionManager->restoreSettings();
373#ifdef DESKTOP_VERSION 373#ifdef DESKTOP_VERSION
374 int wid = width(); 374 int wid = width();
375 if ( wid < 10 ) 375 if ( wid < 10 )
376 wid = 400; 376 wid = 400;
377#else 377#else
378 int wid = QApplication::desktop()->width(); 378 int wid = QApplication::desktop()->width();
379 if ( wid < 640 ) 379 if ( wid < 640 )
380 wid = QApplication::desktop()->height(); 380 wid = QApplication::desktop()->height();
381#endif 381#endif
382 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 382 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
383 if ( true /*splitterSize.count() == 0*/ ) { 383 if ( true /*splitterSize.count() == 0*/ ) {
384 splitterSize.append( wid / 2 ); 384 splitterSize.append( wid / 2 );
385 splitterSize.append( wid / 2 ); 385 splitterSize.append( wid / 2 );
386 } 386 }
387 mMiniSplitter->setSizes( splitterSize ); 387 mMiniSplitter->setSizes( splitterSize );
388 if ( mExtensionBarSplitter ) { 388 if ( mExtensionBarSplitter ) {
389 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 389 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
390 if ( true /*splitterSize.count() == 0*/ ) { 390 if ( true /*splitterSize.count() == 0*/ ) {
391 splitterSize.append( wid / 2 ); 391 splitterSize.append( wid / 2 );
392 splitterSize.append( wid / 2 ); 392 splitterSize.append( wid / 2 );
393 } 393 }
394 mExtensionBarSplitter->setSizes( splitterSize ); 394 mExtensionBarSplitter->setSizes( splitterSize );
395 395
396 } 396 }
397 397
398 398
399} 399}
400 400
401void KABCore::saveSettings() 401void KABCore::saveSettings()
402{ 402{
403 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 403 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
404 if ( mExtensionBarSplitter ) 404 if ( mExtensionBarSplitter )
405 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 405 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
406 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 406 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
407 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 407 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
408#ifndef KAB_EMBEDDED 408#ifndef KAB_EMBEDDED
409 409
410 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 410 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
411 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 411 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
412#endif //KAB_EMBEDDED 412#endif //KAB_EMBEDDED
413 mExtensionManager->saveSettings(); 413 mExtensionManager->saveSettings();
414 mViewManager->saveSettings(); 414 mViewManager->saveSettings();
415 415
416 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 416 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
417} 417}
418 418
419KABC::AddressBook *KABCore::addressBook() const 419KABC::AddressBook *KABCore::addressBook() const
420{ 420{
421 return mAddressBook; 421 return mAddressBook;
422} 422}
423 423
424KConfig *KABCore::config() 424KConfig *KABCore::config()
425{ 425{
426#ifndef KAB_EMBEDDED 426#ifndef KAB_EMBEDDED
427 return KABPrefs::instance()->config(); 427 return KABPrefs::instance()->config();
428#else //KAB_EMBEDDED 428#else //KAB_EMBEDDED
429 return KABPrefs::instance()->getConfig(); 429 return KABPrefs::instance()->getConfig();
430#endif //KAB_EMBEDDED 430#endif //KAB_EMBEDDED
431} 431}
432 432
433KActionCollection *KABCore::actionCollection() const 433KActionCollection *KABCore::actionCollection() const
434{ 434{
435 return mGUIClient->actionCollection(); 435 return mGUIClient->actionCollection();
436} 436}
437 437
438KABC::Field *KABCore::currentSearchField() const 438KABC::Field *KABCore::currentSearchField() const
439{ 439{
440 if (mIncSearchWidget) 440 if (mIncSearchWidget)
441 return mIncSearchWidget->currentField(); 441 return mIncSearchWidget->currentField();
442 else 442 else
443 return 0; 443 return 0;
444} 444}
445 445
446QStringList KABCore::selectedUIDs() const 446QStringList KABCore::selectedUIDs() const
447{ 447{
448 return mViewManager->selectedUids(); 448 return mViewManager->selectedUids();
449} 449}
450 450
451KABC::Resource *KABCore::requestResource( QWidget *parent ) 451KABC::Resource *KABCore::requestResource( QWidget *parent )
452{ 452{
453 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 453 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
454 454
455 QPtrList<KRES::Resource> kresResources; 455 QPtrList<KRES::Resource> kresResources;
456 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 456 QPtrListIterator<KABC::Resource> resIt( kabcResources );
457 KABC::Resource *resource; 457 KABC::Resource *resource;
458 while ( ( resource = resIt.current() ) != 0 ) { 458 while ( ( resource = resIt.current() ) != 0 ) {
459 ++resIt; 459 ++resIt;
460 if ( !resource->readOnly() ) { 460 if ( !resource->readOnly() ) {
461 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 461 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
462 if ( res ) 462 if ( res )
463 kresResources.append( res ); 463 kresResources.append( res );
464 } 464 }
465 } 465 }
466 466
467 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 467 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
468 return static_cast<KABC::Resource*>( res ); 468 return static_cast<KABC::Resource*>( res );
469} 469}
470 470
471#ifndef KAB_EMBEDDED 471#ifndef KAB_EMBEDDED
472KAboutData *KABCore::createAboutData() 472KAboutData *KABCore::createAboutData()
473#else //KAB_EMBEDDED 473#else //KAB_EMBEDDED
474void KABCore::createAboutData() 474void KABCore::createAboutData()
475#endif //KAB_EMBEDDED 475#endif //KAB_EMBEDDED
476{ 476{
477#ifndef KAB_EMBEDDED 477#ifndef KAB_EMBEDDED
478 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 478 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
479 "3.1", I18N_NOOP( "The KDE Address Book" ), 479 "3.1", I18N_NOOP( "The KDE Address Book" ),
480 KAboutData::License_GPL_V2, 480 KAboutData::License_GPL_V2,
481 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 481 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
482 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 482 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
483 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 483 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
484 about->addAuthor( "Cornelius Schumacher", 484 about->addAuthor( "Cornelius Schumacher",
485 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 485 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
486 "schumacher@kde.org" ); 486 "schumacher@kde.org" );
487 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 487 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
488 "mpilone@slac.com" ); 488 "mpilone@slac.com" );
489 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 489 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
490 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 490 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
491 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 491 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
492 "michel@klaralvdalens-datakonsult.se" ); 492 "michel@klaralvdalens-datakonsult.se" );
493 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 493 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
494 "hansen@kde.org" ); 494 "hansen@kde.org" );
495 495
496 return about; 496 return about;
497#endif //KAB_EMBEDDED 497#endif //KAB_EMBEDDED
498 498
499 QString version; 499 QString version;
500#include <../version> 500#include <../version>
501 QMessageBox::about( this, "About KAddressbook/Pi", 501 QMessageBox::about( this, "About KAddressbook/Pi",
502 "KAddressbook/Platform-independent\n" 502 "KAddressbook/Platform-independent\n"
503 "(KA/Pi) " +version + " - " + 503 "(KA/Pi) " +version + " - " +
504#ifdef DESKTOP_VERSION 504#ifdef DESKTOP_VERSION
505 "Desktop Edition\n" 505 "Desktop Edition\n"
506#else 506#else
507 "PDA-Edition\n" 507 "PDA-Edition\n"
508 "for: Zaurus 5500 / 7x0 / 8x0\n" 508 "for: Zaurus 5500 / 7x0 / 8x0\n"
509#endif 509#endif
510 510
511 "(c) 2004 Ulf Schenk\n" 511 "(c) 2004 Ulf Schenk\n"
512 "(c) 2004 Lutz Rogowski\n" 512 "(c) 2004 Lutz Rogowski\n"
513 "(c) 1997-2003, The KDE PIM Team\n" 513 "(c) 1997-2003, The KDE PIM Team\n"
514 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 514 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
515 "Don Sanders Original author\n" 515 "Don Sanders Original author\n"
516 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 516 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
517 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 517 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
518 "Greg Stern DCOP interface\n" 518 "Greg Stern DCOP interface\n"
519 "Mark Westcot Contact pinning\n" 519 "Mark Westcot Contact pinning\n"
520 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 520 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
521 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 521 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
522#ifdef _WIN32_ 522#ifdef _WIN32_
523 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 523 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
524#endif 524#endif
525 ); 525 );
526} 526}
527 527
528void KABCore::setContactSelected( const QString &uid ) 528void KABCore::setContactSelected( const QString &uid )
529{ 529{
530 KABC::Addressee addr = mAddressBook->findByUid( uid ); 530 KABC::Addressee addr = mAddressBook->findByUid( uid );
531 if ( !mDetails->isHidden() ) 531 if ( !mDetails->isHidden() )
532 mDetails->setAddressee( addr ); 532 mDetails->setAddressee( addr );
533 533
534 if ( !addr.isEmpty() ) { 534 if ( !addr.isEmpty() ) {
535 emit contactSelected( addr.formattedName() ); 535 emit contactSelected( addr.formattedName() );
536 KABC::Picture pic = addr.photo(); 536 KABC::Picture pic = addr.photo();
537 if ( pic.isIntern() ) { 537 if ( pic.isIntern() ) {
538//US emit contactSelected( pic.data() ); 538//US emit contactSelected( pic.data() );
539//US instead use: 539//US instead use:
540 QPixmap px; 540 QPixmap px;
541 if (pic.data().isNull() != true) 541 if (pic.data().isNull() != true)
542 { 542 {
543 px.convertFromImage(pic.data()); 543 px.convertFromImage(pic.data());
544 } 544 }
545 545
546 emit contactSelected( px ); 546 emit contactSelected( px );
547 } 547 }
548 } 548 }
549 549
550 550
551 mExtensionManager->setSelectionChanged(); 551 mExtensionManager->setSelectionChanged();
552 552
553 // update the actions 553 // update the actions
554 bool selected = !uid.isEmpty(); 554 bool selected = !uid.isEmpty();
555 555
556 if ( mReadWrite ) { 556 if ( mReadWrite ) {
557 mActionCut->setEnabled( selected ); 557 mActionCut->setEnabled( selected );
558 mActionPaste->setEnabled( selected ); 558 mActionPaste->setEnabled( selected );
559 } 559 }
560 560
561 mActionCopy->setEnabled( selected ); 561 mActionCopy->setEnabled( selected );
562 mActionDelete->setEnabled( selected ); 562 mActionDelete->setEnabled( selected );
563 mActionEditAddressee->setEnabled( selected ); 563 mActionEditAddressee->setEnabled( selected );
564 mActionMail->setEnabled( selected ); 564 mActionMail->setEnabled( selected );
565 mActionMailVCard->setEnabled( selected ); 565 mActionMailVCard->setEnabled( selected );
566 //if (mActionBeam) 566 //if (mActionBeam)
567 //mActionBeam->setEnabled( selected ); 567 //mActionBeam->setEnabled( selected );
568 568
569 if (mActionBeamVCard) 569 if (mActionBeamVCard)
570 mActionBeamVCard->setEnabled( selected ); 570 mActionBeamVCard->setEnabled( selected );
571 571
572 mActionExport2phone->setEnabled( selected ); 572 mActionExport2phone->setEnabled( selected );
573 mActionWhoAmI->setEnabled( selected ); 573 mActionWhoAmI->setEnabled( selected );
574 mActionCategories->setEnabled( selected ); 574 mActionCategories->setEnabled( selected );
575} 575}
576 576
577void KABCore::sendMail() 577void KABCore::sendMail()
578{ 578{
579 sendMail( mViewManager->selectedEmails().join( ", " ) ); 579 sendMail( mViewManager->selectedEmails().join( ", " ) );
580} 580}
581 581
582void KABCore::sendMail( const QString& emaillist ) 582void KABCore::sendMail( const QString& emaillist )
583{ 583{
584 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 584 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
585 if (emaillist.contains(",") > 0) 585 if (emaillist.contains(",") > 0)
586 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 586 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
587 else 587 else
588 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 588 ExternalAppHandler::instance()->mailToOneContact( emaillist );
589} 589}
590 590
591 591
592 592
593void KABCore::mailVCard() 593void KABCore::mailVCard()
594{ 594{
595 QStringList uids = mViewManager->selectedUids(); 595 QStringList uids = mViewManager->selectedUids();
596 if ( !uids.isEmpty() ) 596 if ( !uids.isEmpty() )
597 mailVCard( uids ); 597 mailVCard( uids );
598} 598}
599 599
600void KABCore::mailVCard( const QStringList& uids ) 600void KABCore::mailVCard( const QStringList& uids )
601{ 601{
602 QStringList urls; 602 QStringList urls;
603 603
604// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 604// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
605 605
606 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 606 QString dirName = "/tmp/" + KApplication::randomString( 8 );
607 607
608 608
609 609
610 QDir().mkdir( dirName, true ); 610 QDir().mkdir( dirName, true );
611 611
612 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 612 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
613 KABC::Addressee a = mAddressBook->findByUid( *it ); 613 KABC::Addressee a = mAddressBook->findByUid( *it );
614 614
615 if ( a.isEmpty() ) 615 if ( a.isEmpty() )
616 continue; 616 continue;
617 617
618 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 618 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
619 619
620 QString fileName = dirName + "/" + name; 620 QString fileName = dirName + "/" + name;
621 621
622 QFile outFile(fileName); 622 QFile outFile(fileName);
623 623
624 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 624 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
625 KABC::VCardConverter converter; 625 KABC::VCardConverter converter;
626 QString vcard; 626 QString vcard;
627 627
628 converter.addresseeToVCard( a, vcard ); 628 converter.addresseeToVCard( a, vcard );
629 629
630 QTextStream t( &outFile ); // use a text stream 630 QTextStream t( &outFile ); // use a text stream
631 t.setEncoding( QTextStream::UnicodeUTF8 ); 631 t.setEncoding( QTextStream::UnicodeUTF8 );
632 t << vcard; 632 t << vcard;
633 633
634 outFile.close(); 634 outFile.close();
635 635
636 urls.append( fileName ); 636 urls.append( fileName );
637 } 637 }
638 } 638 }
639 639
640 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 640 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
641 641
642 642
643/*US 643/*US
644 kapp->invokeMailer( QString::null, QString::null, QString::null, 644 kapp->invokeMailer( QString::null, QString::null, QString::null,
645 QString::null, // subject 645 QString::null, // subject
646 QString::null, // body 646 QString::null, // body
647 QString::null, 647 QString::null,
648 urls ); // attachments 648 urls ); // attachments
649*/ 649*/
650 650
651} 651}
652 652
653/** 653/**
654 Beams the "WhoAmI contact. 654 Beams the "WhoAmI contact.
655*/ 655*/
656void KABCore::beamMySelf() 656void KABCore::beamMySelf()
657{ 657{
658 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 658 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
659 if (!a.isEmpty()) 659 if (!a.isEmpty())
660 { 660 {
661 QStringList uids; 661 QStringList uids;
662 uids << a.uid(); 662 uids << a.uid();
663 663
664 beamVCard(uids); 664 beamVCard(uids);
665 } else { 665 } else {
666 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 666 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
667 667
668 668
669 } 669 }
670} 670}
671 671
672void KABCore::export2phone() 672void KABCore::export2phone()
673{ 673{
674 674
675 KAex2phonePrefs ex2phone; 675 KAex2phonePrefs ex2phone;
676 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 676 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
677 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 677 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
678 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 678 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
679 679
680 if ( !ex2phone.exec() ) { 680 if ( !ex2phone.exec() ) {
681 return; 681 return;
682 } 682 }
683 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 683 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
684 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 684 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
685 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 685 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
686 686
687 687
688 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 688 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
689 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 689 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
690 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 690 KPimGlobalPrefs::instance()->mEx2PhoneModel );
691 691
692 QStringList uids = mViewManager->selectedUids(); 692 QStringList uids = mViewManager->selectedUids();
693 if ( uids.isEmpty() ) 693 if ( uids.isEmpty() )
694 return; 694 return;
695 695
696#ifdef _WIN32_ 696#ifdef _WIN32_
697 QString fileName = locateLocal("tmp", "phonefile.vcf"); 697 QString fileName = locateLocal("tmp", "phonefile.vcf");
698#else 698#else
699 QString fileName = "/tmp/phonefile.vcf"; 699 QString fileName = "/tmp/phonefile.vcf";
700#endif 700#endif
701 701
702 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 702 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
703 return; 703 return;
704 704
705 if ( PhoneAccess::writeToPhone( fileName ) ) 705 if ( PhoneAccess::writeToPhone( fileName ) )
706 qDebug("Export okay "); 706 qDebug("Export okay ");
707 else 707 else
708 qDebug("Error export contacts "); 708 qDebug("Error export contacts ");
709 709
710 710
711#if 0 711#if 0
712 712
713 setCaption( i18n("Writing to phone...")); 713 setCaption( i18n("Writing to phone..."));
714 if ( PhoneFormat::writeToPhone( cal ) ) 714 if ( PhoneFormat::writeToPhone( cal ) )
715 setCaption( i18n("Export to phone successful!")); 715 setCaption( i18n("Export to phone successful!"));
716 else 716 else
717 setCaption( i18n("Error exporting to phone!")); 717 setCaption( i18n("Error exporting to phone!"));
718#endif 718#endif
719 719
720 720
721} 721}
722void KABCore::beamVCard() 722void KABCore::beamVCard()
723{ 723{
724 QStringList uids = mViewManager->selectedUids(); 724 QStringList uids = mViewManager->selectedUids();
725 if ( !uids.isEmpty() ) 725 if ( !uids.isEmpty() )
726 beamVCard( uids ); 726 beamVCard( uids );
727} 727}
728 728
729 729
730void KABCore::beamVCard(const QStringList& uids) 730void KABCore::beamVCard(const QStringList& uids)
731{ 731{
732/*US 732/*US
733 QString beamFilename; 733 QString beamFilename;
734 Opie::OPimContact c; 734 Opie::OPimContact c;
735 if ( actionPersonal->isOn() ) { 735 if ( actionPersonal->isOn() ) {
736 beamFilename = addressbookPersonalVCardName(); 736 beamFilename = addressbookPersonalVCardName();
737 if ( !QFile::exists( beamFilename ) ) 737 if ( !QFile::exists( beamFilename ) )
738 return; // can't beam a non-existent file 738 return; // can't beam a non-existent file
739 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 739 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
740 beamFilename ); 740 beamFilename );
741 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 741 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
742 Opie::OPimContactAccess::List allList = access->allRecords(); 742 Opie::OPimContactAccess::List allList = access->allRecords();
743 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first 743 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first
744 c = *it; 744 c = *it;
745 745
746 delete access; 746 delete access;
747 } else { 747 } else {
748 unlink( beamfile ); // delete if exists 748 unlink( beamfile ); // delete if exists
749 mkdir("/tmp/obex/", 0755); 749 mkdir("/tmp/obex/", 0755);
750 c = m_abView -> currentEntry(); 750 c = m_abView -> currentEntry();
751 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 751 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
752 beamfile ); 752 beamfile );
753 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 753 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
754 access->add( c ); 754 access->add( c );
755 access->save(); 755 access->save();
756 delete access; 756 delete access;
757 757
758 beamFilename = beamfile; 758 beamFilename = beamfile;
759 } 759 }
760 760
761 owarn << "Beaming: " << beamFilename << oendl; 761 owarn << "Beaming: " << beamFilename << oendl;
762*/ 762*/
763 763
764#if 0 764#if 0
765 QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 765 QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
766 766
767 QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); 767 QString dirName = tmpdir + "/" + KApplication::randomString( 8 );
768 768
769 QString name = "contact.vcf"; 769 QString name = "contact.vcf";
770 770
771 QString fileName = dirName + "/" + name; 771 QString fileName = dirName + "/" + name;
772#endif 772#endif
773 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory 773 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory
774 // 774 //
775 QString fileName = "/tmp/kapibeamfile.vcf"; 775 QString fileName = "/tmp/kapibeamfile.vcf";
776 776
777 777
778 //QDir().mkdir( dirName, true ); 778 //QDir().mkdir( dirName, true );
779 779
780 780
781 KABC::VCardConverter converter; 781 KABC::VCardConverter converter;
782 QString description; 782 QString description;
783 QString datastream; 783 QString datastream;
784 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 784 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
785 KABC::Addressee a = mAddressBook->findByUid( *it ); 785 KABC::Addressee a = mAddressBook->findByUid( *it );
786 786
787 if ( a.isEmpty() ) 787 if ( a.isEmpty() )
788 continue; 788 continue;
789 789
790 if (description.isEmpty()) 790 if (description.isEmpty())
791 description = a.formattedName(); 791 description = a.formattedName();
792 792
793 QString vcard; 793 QString vcard;
794 converter.addresseeToVCard( a, vcard ); 794 converter.addresseeToVCard( a, vcard );
795 int start = 0; 795 int start = 0;
796 int next; 796 int next;
797 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 797 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
798 int semi = vcard.find(";", next); 798 int semi = vcard.find(";", next);
799 int dopp = vcard.find(":", next); 799 int dopp = vcard.find(":", next);
800 int sep; 800 int sep;
801 if ( semi < dopp && semi >= 0 ) 801 if ( semi < dopp && semi >= 0 )
802 sep = semi ; 802 sep = semi ;
803 else 803 else
804 sep = dopp; 804 sep = dopp;
805 datastream +=vcard.mid( start, next - start); 805 datastream +=vcard.mid( start, next - start);
806 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 806 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
807 start = sep; 807 start = sep;
808 } 808 }
809 datastream += vcard.mid( start,vcard.length() ); 809 datastream += vcard.mid( start,vcard.length() );
810 } 810 }
811#ifndef DESKTOP_VERSION 811#ifndef DESKTOP_VERSION
812 QFile outFile(fileName); 812 QFile outFile(fileName);
813 if ( outFile.open(IO_WriteOnly) ) { 813 if ( outFile.open(IO_WriteOnly) ) {
814 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 814 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
815 QTextStream t( &outFile ); // use a text stream 815 QTextStream t( &outFile ); // use a text stream
816 t.setEncoding( QTextStream::UnicodeUTF8 ); 816 //t.setEncoding( QTextStream::UnicodeUTF8 );
817 t <<datastream; 817 t.setEncoding( QTextStream::Latin1 );
818 t <<datastream.latin1();
818 outFile.close(); 819 outFile.close();
819 Ir *ir = new Ir( this ); 820 Ir *ir = new Ir( this );
820 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 821 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
821 ir->send( fileName, description, "text/x-vCard" ); 822 ir->send( fileName, description, "text/x-vCard" );
822 } else { 823 } else {
823 qDebug("Error open temp beam file "); 824 qDebug("Error open temp beam file ");
824 return; 825 return;
825 } 826 }
826#endif 827#endif
827 828
828} 829}
829 830
830void KABCore::beamDone( Ir *ir ) 831void KABCore::beamDone( Ir *ir )
831{ 832{
832#ifndef DESKTOP_VERSION 833#ifndef DESKTOP_VERSION
833 delete ir; 834 delete ir;
834#endif 835#endif
836 topLevelWidget()->raise();
835} 837}
836 838
837 839
838void KABCore::browse( const QString& url ) 840void KABCore::browse( const QString& url )
839{ 841{
840#ifndef KAB_EMBEDDED 842#ifndef KAB_EMBEDDED
841 kapp->invokeBrowser( url ); 843 kapp->invokeBrowser( url );
842#else //KAB_EMBEDDED 844#else //KAB_EMBEDDED
843 qDebug("KABCore::browse must be fixed"); 845 qDebug("KABCore::browse must be fixed");
844#endif //KAB_EMBEDDED 846#endif //KAB_EMBEDDED
845} 847}
846 848
847void KABCore::selectAllContacts() 849void KABCore::selectAllContacts()
848{ 850{
849 mViewManager->setSelected( QString::null, true ); 851 mViewManager->setSelected( QString::null, true );
850} 852}
851 853
852void KABCore::deleteContacts() 854void KABCore::deleteContacts()
853{ 855{
854 QStringList uidList = mViewManager->selectedUids(); 856 QStringList uidList = mViewManager->selectedUids();
855 deleteContacts( uidList ); 857 deleteContacts( uidList );
856} 858}
857 859
858void KABCore::deleteContacts( const QStringList &uids ) 860void KABCore::deleteContacts( const QStringList &uids )
859{ 861{
860 if ( uids.count() > 0 ) { 862 if ( uids.count() > 0 ) {
861 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 863 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
862 UndoStack::instance()->push( command ); 864 UndoStack::instance()->push( command );
863 RedoStack::instance()->clear(); 865 RedoStack::instance()->clear();
864 866
865 // now if we deleted anything, refresh 867 // now if we deleted anything, refresh
866 setContactSelected( QString::null ); 868 setContactSelected( QString::null );
867 setModified( true ); 869 setModified( true );
868 } 870 }
869} 871}
870 872
871void KABCore::copyContacts() 873void KABCore::copyContacts()
872{ 874{
873 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 875 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
874 876
875 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 877 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
876 878
877 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 879 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
878 880
879 QClipboard *cb = QApplication::clipboard(); 881 QClipboard *cb = QApplication::clipboard();
880 cb->setText( clipText ); 882 cb->setText( clipText );
881} 883}
882 884
883void KABCore::cutContacts() 885void KABCore::cutContacts()
884{ 886{
885 QStringList uidList = mViewManager->selectedUids(); 887 QStringList uidList = mViewManager->selectedUids();
886 888
887//US if ( uidList.size() > 0 ) { 889//US if ( uidList.size() > 0 ) {
888 if ( uidList.count() > 0 ) { 890 if ( uidList.count() > 0 ) {
889 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 891 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
890 UndoStack::instance()->push( command ); 892 UndoStack::instance()->push( command );
891 RedoStack::instance()->clear(); 893 RedoStack::instance()->clear();
892 894
893 setModified( true ); 895 setModified( true );
894 } 896 }
895} 897}
896 898
897void KABCore::pasteContacts() 899void KABCore::pasteContacts()
898{ 900{
899 QClipboard *cb = QApplication::clipboard(); 901 QClipboard *cb = QApplication::clipboard();
900 902
901 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 903 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
902 904
903 pasteContacts( list ); 905 pasteContacts( list );
904} 906}
905 907
906void KABCore::pasteContacts( KABC::Addressee::List &list ) 908void KABCore::pasteContacts( KABC::Addressee::List &list )
907{ 909{
908 KABC::Resource *resource = requestResource( this ); 910 KABC::Resource *resource = requestResource( this );
909 KABC::Addressee::List::Iterator it; 911 KABC::Addressee::List::Iterator it;
910 for ( it = list.begin(); it != list.end(); ++it ) 912 for ( it = list.begin(); it != list.end(); ++it )
911 (*it).setResource( resource ); 913 (*it).setResource( resource );
912 914
913 PwPasteCommand *command = new PwPasteCommand( this, list ); 915 PwPasteCommand *command = new PwPasteCommand( this, list );
914 UndoStack::instance()->push( command ); 916 UndoStack::instance()->push( command );
915 RedoStack::instance()->clear(); 917 RedoStack::instance()->clear();
916 918
917 setModified( true ); 919 setModified( true );
918} 920}
919 921
920void KABCore::setWhoAmI() 922void KABCore::setWhoAmI()
921{ 923{
922 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 924 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
923 925
924 if ( addrList.count() > 1 ) { 926 if ( addrList.count() > 1 ) {
925 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 927 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
926 return; 928 return;
927 } 929 }
928 930
929 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 931 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
930 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 932 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
931 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 933 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
932} 934}
933 935
934void KABCore::setCategories() 936void KABCore::setCategories()
935{ 937{
936 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 938 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
937 if ( !dlg.exec() ) 939 if ( !dlg.exec() )
938 return; 940 return;
939 941
940 bool merge = false; 942 bool merge = false;
941 QString msg = i18n( "Merge with existing categories?" ); 943 QString msg = i18n( "Merge with existing categories?" );
942 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 944 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
943 merge = true; 945 merge = true;
944 946
945 QStringList categories = dlg.selectedCategories(); 947 QStringList categories = dlg.selectedCategories();
946 948
947 QStringList uids = mViewManager->selectedUids(); 949 QStringList uids = mViewManager->selectedUids();
948 QStringList::Iterator it; 950 QStringList::Iterator it;
949 for ( it = uids.begin(); it != uids.end(); ++it ) { 951 for ( it = uids.begin(); it != uids.end(); ++it ) {
950 KABC::Addressee addr = mAddressBook->findByUid( *it ); 952 KABC::Addressee addr = mAddressBook->findByUid( *it );
951 if ( !addr.isEmpty() ) { 953 if ( !addr.isEmpty() ) {
952 if ( !merge ) 954 if ( !merge )
953 addr.setCategories( categories ); 955 addr.setCategories( categories );
954 else { 956 else {
955 QStringList addrCategories = addr.categories(); 957 QStringList addrCategories = addr.categories();
956 QStringList::Iterator catIt; 958 QStringList::Iterator catIt;
957 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 959 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
958 if ( !addrCategories.contains( *catIt ) ) 960 if ( !addrCategories.contains( *catIt ) )
959 addrCategories.append( *catIt ); 961 addrCategories.append( *catIt );
960 } 962 }
961 addr.setCategories( addrCategories ); 963 addr.setCategories( addrCategories );
962 } 964 }
963 965
964 mAddressBook->insertAddressee( addr ); 966 mAddressBook->insertAddressee( addr );
965 } 967 }
966 } 968 }
967 969
968 if ( uids.count() > 0 ) 970 if ( uids.count() > 0 )
969 setModified( true ); 971 setModified( true );
970} 972}
971 973
972void KABCore::setSearchFields( const KABC::Field::List &fields ) 974void KABCore::setSearchFields( const KABC::Field::List &fields )
973{ 975{
974 mIncSearchWidget->setFields( fields ); 976 mIncSearchWidget->setFields( fields );
975} 977}
976 978
977void KABCore::incrementalSearch( const QString& text ) 979void KABCore::incrementalSearch( const QString& text )
978{ 980{
979 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 981 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
980} 982}
981 983
982void KABCore::setModified() 984void KABCore::setModified()
983{ 985{
984 setModified( true ); 986 setModified( true );
985} 987}
986 988
987void KABCore::setModifiedWOrefresh() 989void KABCore::setModifiedWOrefresh()
988{ 990{
989 // qDebug("KABCore::setModifiedWOrefresh() "); 991 // qDebug("KABCore::setModifiedWOrefresh() ");
990 mModified = true; 992 mModified = true;
991 mActionSave->setEnabled( mModified ); 993 mActionSave->setEnabled( mModified );
992#ifdef DESKTOP_VERSION 994#ifdef DESKTOP_VERSION
993 mDetails->refreshView(); 995 mDetails->refreshView();
994#endif 996#endif
995 997
996} 998}
997void KABCore::setModified( bool modified ) 999void KABCore::setModified( bool modified )
998{ 1000{
999 mModified = modified; 1001 mModified = modified;
1000 mActionSave->setEnabled( mModified ); 1002 mActionSave->setEnabled( mModified );
1001 1003
1002 if ( modified ) 1004 if ( modified )
1003 mJumpButtonBar->recreateButtons(); 1005 mJumpButtonBar->recreateButtons();
1004 1006
1005 mViewManager->refreshView(); 1007 mViewManager->refreshView();
1006 mDetails->refreshView(); 1008 mDetails->refreshView();
1007 1009
1008} 1010}
1009 1011
1010bool KABCore::modified() const 1012bool KABCore::modified() const
1011{ 1013{
1012 return mModified; 1014 return mModified;
1013} 1015}
1014 1016
1015void KABCore::contactModified( const KABC::Addressee &addr ) 1017void KABCore::contactModified( const KABC::Addressee &addr )
1016{ 1018{
1017 1019
1018 Command *command = 0; 1020 Command *command = 0;
1019 QString uid; 1021 QString uid;
1020 1022
1021 // check if it exists already 1023 // check if it exists already
1022 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1024 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1023 if ( origAddr.isEmpty() ) 1025 if ( origAddr.isEmpty() )
1024 command = new PwNewCommand( mAddressBook, addr ); 1026 command = new PwNewCommand( mAddressBook, addr );
1025 else { 1027 else {
1026 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1028 command = new PwEditCommand( mAddressBook, origAddr, addr );
1027 uid = addr.uid(); 1029 uid = addr.uid();
1028 } 1030 }
1029 1031
1030 UndoStack::instance()->push( command ); 1032 UndoStack::instance()->push( command );
1031 RedoStack::instance()->clear(); 1033 RedoStack::instance()->clear();
1032 1034
1033 setModified( true ); 1035 setModified( true );
1034} 1036}
1035 1037
1036void KABCore::newContact() 1038void KABCore::newContact()
1037{ 1039{
1038 1040
1039 1041
1040 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1042 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1041 1043
1042 QPtrList<KRES::Resource> kresResources; 1044 QPtrList<KRES::Resource> kresResources;
1043 QPtrListIterator<KABC::Resource> it( kabcResources ); 1045 QPtrListIterator<KABC::Resource> it( kabcResources );
1044 KABC::Resource *resource; 1046 KABC::Resource *resource;
1045 while ( ( resource = it.current() ) != 0 ) { 1047 while ( ( resource = it.current() ) != 0 ) {
1046 ++it; 1048 ++it;
1047 if ( !resource->readOnly() ) { 1049 if ( !resource->readOnly() ) {
1048 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1050 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1049 if ( res ) 1051 if ( res )
1050 kresResources.append( res ); 1052 kresResources.append( res );
1051 } 1053 }
1052 } 1054 }
1053 1055
1054 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1056 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1055 resource = static_cast<KABC::Resource*>( res ); 1057 resource = static_cast<KABC::Resource*>( res );
1056 1058
1057 if ( resource ) { 1059 if ( resource ) {
1058 KABC::Addressee addr; 1060 KABC::Addressee addr;
1059 addr.setResource( resource ); 1061 addr.setResource( resource );
1060 mEditorDialog->setAddressee( addr ); 1062 mEditorDialog->setAddressee( addr );
1061 KApplication::execDialog ( mEditorDialog ); 1063 KApplication::execDialog ( mEditorDialog );
1062 1064
1063 } else 1065 } else
1064 return; 1066 return;
1065 1067
1066 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1068 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1067 1069
1068 1070
1069} 1071}
1070 1072
1071void KABCore::addEmail( QString aStr ) 1073void KABCore::addEmail( QString aStr )
1072{ 1074{
1073#ifndef KAB_EMBEDDED 1075#ifndef KAB_EMBEDDED
1074 QString fullName, email; 1076 QString fullName, email;
1075 1077
1076 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1078 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1077 1079
1078 // Try to lookup the addressee matching the email address 1080 // Try to lookup the addressee matching the email address
1079 bool found = false; 1081 bool found = false;
1080 QStringList emailList; 1082 QStringList emailList;
1081 KABC::AddressBook::Iterator it; 1083 KABC::AddressBook::Iterator it;
1082 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1084 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1083 emailList = (*it).emails(); 1085 emailList = (*it).emails();
1084 if ( emailList.contains( email ) > 0 ) { 1086 if ( emailList.contains( email ) > 0 ) {
1085 found = true; 1087 found = true;
1086 (*it).setNameFromString( fullName ); 1088 (*it).setNameFromString( fullName );
1087 editContact( (*it).uid() ); 1089 editContact( (*it).uid() );
1088 } 1090 }
1089 } 1091 }
1090 1092
1091 if ( !found ) { 1093 if ( !found ) {
1092 KABC::Addressee addr; 1094 KABC::Addressee addr;
1093 addr.setNameFromString( fullName ); 1095 addr.setNameFromString( fullName );
1094 addr.insertEmail( email, true ); 1096 addr.insertEmail( email, true );
1095 1097
1096 mAddressBook->insertAddressee( addr ); 1098 mAddressBook->insertAddressee( addr );
1097 mViewManager->refreshView( addr.uid() ); 1099 mViewManager->refreshView( addr.uid() );
1098 editContact( addr.uid() ); 1100 editContact( addr.uid() );
1099 } 1101 }
1100#else //KAB_EMBEDDED 1102#else //KAB_EMBEDDED
1101 qDebug("KABCore::addEmail finsih method"); 1103 qDebug("KABCore::addEmail finsih method");
1102#endif //KAB_EMBEDDED 1104#endif //KAB_EMBEDDED
1103} 1105}
1104 1106
1105void KABCore::importVCard( const KURL &url, bool showPreview ) 1107void KABCore::importVCard( const KURL &url, bool showPreview )
1106{ 1108{
1107 mXXPortManager->importVCard( url, showPreview ); 1109 mXXPortManager->importVCard( url, showPreview );
1108} 1110}
1109void KABCore::importFromOL() 1111void KABCore::importFromOL()
1110{ 1112{
1111#ifdef _WIN32_ 1113#ifdef _WIN32_
1112 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1114 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1113 idgl->exec(); 1115 idgl->exec();
1114 KABC::Addressee::List list = idgl->getAddressList(); 1116 KABC::Addressee::List list = idgl->getAddressList();
1115 if ( list.count() > 0 ) { 1117 if ( list.count() > 0 ) {
1116 KABC::Addressee::List listNew; 1118 KABC::Addressee::List listNew;
1117 KABC::Addressee::List listExisting; 1119 KABC::Addressee::List listExisting;
1118 KABC::Addressee::List::Iterator it; 1120 KABC::Addressee::List::Iterator it;
1119 KABC::AddressBook::Iterator iter; 1121 KABC::AddressBook::Iterator iter;
1120 for ( it = list.begin(); it != list.end(); ++it ) { 1122 for ( it = list.begin(); it != list.end(); ++it ) {
1121 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1123 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1122 listNew.append( (*it) ); 1124 listNew.append( (*it) );
1123 else 1125 else
1124 listExisting.append( (*it) ); 1126 listExisting.append( (*it) );
1125 } 1127 }
1126 if ( listExisting.count() > 0 ) 1128 if ( listExisting.count() > 0 )
1127 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1129 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1128 if ( listNew.count() > 0 ) { 1130 if ( listNew.count() > 0 ) {
1129 pasteWithNewUid = false; 1131 pasteWithNewUid = false;
1130 pasteContacts( listNew ); 1132 pasteContacts( listNew );
1131 pasteWithNewUid = true; 1133 pasteWithNewUid = true;
1132 } 1134 }
1133 } 1135 }
1134 delete idgl; 1136 delete idgl;
1135#endif 1137#endif
1136} 1138}
1137 1139
1138void KABCore::importVCard( const QString &vCard, bool showPreview ) 1140void KABCore::importVCard( const QString &vCard, bool showPreview )
1139{ 1141{
1140 mXXPortManager->importVCard( vCard, showPreview ); 1142 mXXPortManager->importVCard( vCard, showPreview );
1141} 1143}
1142 1144
1143//US added a second method without defaultparameter 1145//US added a second method without defaultparameter
1144void KABCore::editContact2() { 1146void KABCore::editContact2() {
1145 editContact( QString::null ); 1147 editContact( QString::null );
1146} 1148}
1147 1149
1148void KABCore::editContact( const QString &uid ) 1150void KABCore::editContact( const QString &uid )
1149{ 1151{
1150 1152
1151 if ( mExtensionManager->isQuickEditVisible() ) 1153 if ( mExtensionManager->isQuickEditVisible() )
1152 return; 1154 return;
1153 1155
1154 // First, locate the contact entry 1156 // First, locate the contact entry
1155 QString localUID = uid; 1157 QString localUID = uid;
1156 if ( localUID.isNull() ) { 1158 if ( localUID.isNull() ) {
1157 QStringList uidList = mViewManager->selectedUids(); 1159 QStringList uidList = mViewManager->selectedUids();
1158 if ( uidList.count() > 0 ) 1160 if ( uidList.count() > 0 )
1159 localUID = *( uidList.at( 0 ) ); 1161 localUID = *( uidList.at( 0 ) );
1160 } 1162 }
1161 1163
1162 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1164 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1163 if ( !addr.isEmpty() ) { 1165 if ( !addr.isEmpty() ) {
1164 mEditorDialog->setAddressee( addr ); 1166 mEditorDialog->setAddressee( addr );
1165 KApplication::execDialog ( mEditorDialog ); 1167 KApplication::execDialog ( mEditorDialog );
1166 } 1168 }
1167} 1169}
1168 1170
1169/** 1171/**
1170 Shows or edits the detail view for the given uid. If the uid is QString::null, 1172 Shows or edits the detail view for the given uid. If the uid is QString::null,
1171 the method will try to find a selected addressee in the view. 1173 the method will try to find a selected addressee in the view.
1172 */ 1174 */
1173void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1175void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1174{ 1176{
1175 if ( mMultipleViewsAtOnce ) 1177 if ( mMultipleViewsAtOnce )
1176 { 1178 {
1177 editContact( uid ); 1179 editContact( uid );
1178 } 1180 }
1179 else 1181 else
1180 { 1182 {
1181 setDetailsVisible( true ); 1183 setDetailsVisible( true );
1182 mActionDetails->setChecked(true); 1184 mActionDetails->setChecked(true);
1183 } 1185 }
1184 1186
1185} 1187}
1186 1188
1187void KABCore::save() 1189void KABCore::save()
1188{ 1190{
1189 if (syncManager->blockSave()) 1191 if (syncManager->blockSave())
1190 return; 1192 return;
1191 if ( !mModified ) 1193 if ( !mModified )
1192 return; 1194 return;
1193 1195
1194 syncManager->setBlockSave(true); 1196 syncManager->setBlockSave(true);
1195 QString text = i18n( "There was an error while attempting to save\n the " 1197 QString text = i18n( "There was an error while attempting to save\n the "
1196 "address book. Please check that some \nother application is " 1198 "address book. Please check that some \nother application is "
1197 "not using it. " ); 1199 "not using it. " );
1198 statusMessage(i18n("Saving addressbook ... ")); 1200 statusMessage(i18n("Saving addressbook ... "));
1199#ifndef KAB_EMBEDDED 1201#ifndef KAB_EMBEDDED
1200 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1202 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1201 if ( !b || !b->save() ) { 1203 if ( !b || !b->save() ) {
1202 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1204 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1203 } 1205 }
1204#else //KAB_EMBEDDED 1206#else //KAB_EMBEDDED
1205 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1207 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1206 if ( !b || !b->save() ) { 1208 if ( !b || !b->save() ) {
1207 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1209 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1208 } 1210 }
1209#endif //KAB_EMBEDDED 1211#endif //KAB_EMBEDDED
1210 1212
1211 statusMessage(i18n("Addressbook saved!")); 1213 statusMessage(i18n("Addressbook saved!"));
1212 setModified( false ); 1214 setModified( false );
1213 syncManager->setBlockSave(false); 1215 syncManager->setBlockSave(false);
1214} 1216}
1215 1217
1216void KABCore::statusMessage(QString mess , int time ) 1218void KABCore::statusMessage(QString mess , int time )
1217{ 1219{
1218 //topLevelWidget()->setCaption( mess ); 1220 //topLevelWidget()->setCaption( mess );
1219 // pending setting timer to revome message 1221 // pending setting timer to revome message
1220} 1222}
1221void KABCore::undo() 1223void KABCore::undo()
1222{ 1224{
1223 UndoStack::instance()->undo(); 1225 UndoStack::instance()->undo();
1224 1226
1225 // Refresh the view 1227 // Refresh the view
1226 mViewManager->refreshView(); 1228 mViewManager->refreshView();
1227} 1229}
1228 1230
1229void KABCore::redo() 1231void KABCore::redo()
1230{ 1232{
1231 RedoStack::instance()->redo(); 1233 RedoStack::instance()->redo();
1232 1234
1233 // Refresh the view 1235 // Refresh the view
1234 mViewManager->refreshView(); 1236 mViewManager->refreshView();
1235} 1237}
1236 1238
1237void KABCore::setJumpButtonBarVisible( bool visible ) 1239void KABCore::setJumpButtonBarVisible( bool visible )
1238{ 1240{
1239 if (mMultipleViewsAtOnce) 1241 if (mMultipleViewsAtOnce)
1240 { 1242 {
1241 if ( visible ) 1243 if ( visible )
1242 mJumpButtonBar->show(); 1244 mJumpButtonBar->show();
1243 else 1245 else
1244 mJumpButtonBar->hide(); 1246 mJumpButtonBar->hide();
1245 } 1247 }
1246 else 1248 else
1247 { 1249 {
1248 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1250 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1249 if (mViewManager->isVisible()) 1251 if (mViewManager->isVisible())
1250 { 1252 {
1251 if ( visible ) 1253 if ( visible )
1252 mJumpButtonBar->show(); 1254 mJumpButtonBar->show();
1253 else 1255 else
1254 mJumpButtonBar->hide(); 1256 mJumpButtonBar->hide();
1255 } 1257 }
1256 else 1258 else
1257 { 1259 {
1258 mJumpButtonBar->hide(); 1260 mJumpButtonBar->hide();
1259 } 1261 }
1260 } 1262 }
1261} 1263}
1262 1264
1263 1265
1264void KABCore::setDetailsToState() 1266void KABCore::setDetailsToState()
1265{ 1267{
1266 setDetailsVisible( mActionDetails->isChecked() ); 1268 setDetailsVisible( mActionDetails->isChecked() );
1267} 1269}
1268 1270
1269 1271
1270 1272
1271void KABCore::setDetailsVisible( bool visible ) 1273void KABCore::setDetailsVisible( bool visible )
1272{ 1274{
1273 if (visible && mDetails->isHidden()) 1275 if (visible && mDetails->isHidden())
1274 { 1276 {
1275 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1277 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1276 if ( addrList.count() > 0 ) 1278 if ( addrList.count() > 0 )
1277 mDetails->setAddressee( addrList[ 0 ] ); 1279 mDetails->setAddressee( addrList[ 0 ] );
1278 } 1280 }
1279 1281
1280 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1282 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1281 // the listview and the detailview. We do that by changing the splitbar size. 1283 // the listview and the detailview. We do that by changing the splitbar size.
1282 if (mMultipleViewsAtOnce) 1284 if (mMultipleViewsAtOnce)
1283 { 1285 {
1284 if ( visible ) 1286 if ( visible )
1285 mDetails->show(); 1287 mDetails->show();
1286 else 1288 else
1287 mDetails->hide(); 1289 mDetails->hide();
1288 } 1290 }
1289 else 1291 else
1290 { 1292 {
1291 if ( visible ) { 1293 if ( visible ) {
1292 mViewManager->hide(); 1294 mViewManager->hide();
1293 mDetails->show(); 1295 mDetails->show();
1294 } 1296 }
1295 else { 1297 else {
1296 mViewManager->show(); 1298 mViewManager->show();
1297 mDetails->hide(); 1299 mDetails->hide();
1298 } 1300 }
1299 setJumpButtonBarVisible( !visible ); 1301 setJumpButtonBarVisible( !visible );
1300 } 1302 }
1301 1303
1302} 1304}
1303 1305
1304void KABCore::extensionChanged( int id ) 1306void KABCore::extensionChanged( int id )
1305{ 1307{
1306 //change the details view only for non desktop systems 1308 //change the details view only for non desktop systems
1307#ifndef DESKTOP_VERSION 1309#ifndef DESKTOP_VERSION
1308 1310
1309 if (id == 0) 1311 if (id == 0)
1310 { 1312 {
1311 //the user disabled the extension. 1313 //the user disabled the extension.
1312 1314
1313 if (mMultipleViewsAtOnce) 1315 if (mMultipleViewsAtOnce)
1314 { // enable detailsview again 1316 { // enable detailsview again
1315 setDetailsVisible( true ); 1317 setDetailsVisible( true );
1316 mActionDetails->setChecked( true ); 1318 mActionDetails->setChecked( true );
1317 } 1319 }
1318 else 1320 else
1319 { //go back to the listview 1321 { //go back to the listview
1320 setDetailsVisible( false ); 1322 setDetailsVisible( false );
1321 mActionDetails->setChecked( false ); 1323 mActionDetails->setChecked( false );
1322 mActionDetails->setEnabled(true); 1324 mActionDetails->setEnabled(true);
1323 } 1325 }
1324 1326
1325 } 1327 }
1326 else 1328 else
1327 { 1329 {
1328 //the user enabled the extension. 1330 //the user enabled the extension.
1329 setDetailsVisible( false ); 1331 setDetailsVisible( false );
1330 mActionDetails->setChecked( false ); 1332 mActionDetails->setChecked( false );
1331 1333
1332 if (!mMultipleViewsAtOnce) 1334 if (!mMultipleViewsAtOnce)
1333 { 1335 {
1334 mActionDetails->setEnabled(false); 1336 mActionDetails->setEnabled(false);
1335 } 1337 }
1336 1338
1337 mExtensionManager->setSelectionChanged(); 1339 mExtensionManager->setSelectionChanged();
1338 1340
1339 } 1341 }
1340 1342
1341#endif// DESKTOP_VERSION 1343#endif// DESKTOP_VERSION
1342 1344
1343} 1345}
1344 1346
1345 1347
1346void KABCore::extensionModified( const KABC::Addressee::List &list ) 1348void KABCore::extensionModified( const KABC::Addressee::List &list )
1347{ 1349{
1348 1350
1349 if ( list.count() != 0 ) { 1351 if ( list.count() != 0 ) {
1350 KABC::Addressee::List::ConstIterator it; 1352 KABC::Addressee::List::ConstIterator it;
1351 for ( it = list.begin(); it != list.end(); ++it ) 1353 for ( it = list.begin(); it != list.end(); ++it )
1352 mAddressBook->insertAddressee( *it ); 1354 mAddressBook->insertAddressee( *it );
1353 if ( list.count() > 1 ) 1355 if ( list.count() > 1 )
1354 setModified(); 1356 setModified();
1355 else 1357 else
1356 setModifiedWOrefresh(); 1358 setModifiedWOrefresh();
1357 } 1359 }
1358 if ( list.count() == 0 ) 1360 if ( list.count() == 0 )
1359 mViewManager->refreshView(); 1361 mViewManager->refreshView();
1360 else 1362 else
1361 mViewManager->refreshView( list[ 0 ].uid() ); 1363 mViewManager->refreshView( list[ 0 ].uid() );
1362 1364
1363 1365
1364 1366
1365} 1367}
1366 1368
1367QString KABCore::getNameByPhone( const QString &phone ) 1369QString KABCore::getNameByPhone( const QString &phone )
1368{ 1370{
1369#ifndef KAB_EMBEDDED 1371#ifndef KAB_EMBEDDED
1370 QRegExp r( "[/*/-/ ]" ); 1372 QRegExp r( "[/*/-/ ]" );
1371 QString localPhone( phone ); 1373 QString localPhone( phone );
1372 1374
1373 bool found = false; 1375 bool found = false;
1374 QString ownerName = ""; 1376 QString ownerName = "";
1375 KABC::AddressBook::Iterator iter; 1377 KABC::AddressBook::Iterator iter;
1376 KABC::PhoneNumber::List::Iterator phoneIter; 1378 KABC::PhoneNumber::List::Iterator phoneIter;
1377 KABC::PhoneNumber::List phoneList; 1379 KABC::PhoneNumber::List phoneList;
1378 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1380 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1379 phoneList = (*iter).phoneNumbers(); 1381 phoneList = (*iter).phoneNumbers();
1380 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1382 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1381 ++phoneIter) { 1383 ++phoneIter) {
1382 // Get rid of separator chars so just the numbers are compared. 1384 // Get rid of separator chars so just the numbers are compared.
1383 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1385 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1384 ownerName = (*iter).formattedName(); 1386 ownerName = (*iter).formattedName();
1385 found = true; 1387 found = true;
1386 } 1388 }
1387 } 1389 }
1388 } 1390 }
1389 1391
1390 return ownerName; 1392 return ownerName;
1391#else //KAB_EMBEDDED 1393#else //KAB_EMBEDDED
1392 qDebug("KABCore::getNameByPhone finsih method"); 1394 qDebug("KABCore::getNameByPhone finsih method");
1393 return ""; 1395 return "";
1394#endif //KAB_EMBEDDED 1396#endif //KAB_EMBEDDED
1395 1397
1396} 1398}
1397 1399
1398void KABCore::openConfigDialog() 1400void KABCore::openConfigDialog()
1399{ 1401{
1400 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1402 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1401 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1403 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1402 ConfigureDialog->addModule(kabcfg ); 1404 ConfigureDialog->addModule(kabcfg );
1403 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1405 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1404 ConfigureDialog->addModule(kdelibcfg ); 1406 ConfigureDialog->addModule(kdelibcfg );
1405 1407
1406 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1408 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1407 this, SLOT( configurationChanged() ) ); 1409 this, SLOT( configurationChanged() ) );
1408 connect( ConfigureDialog, SIGNAL( okClicked() ), 1410 connect( ConfigureDialog, SIGNAL( okClicked() ),
1409 this, SLOT( configurationChanged() ) ); 1411 this, SLOT( configurationChanged() ) );
1410 saveSettings(); 1412 saveSettings();
1411#ifndef DESKTOP_VERSION 1413#ifndef DESKTOP_VERSION
1412 ConfigureDialog->showMaximized(); 1414 ConfigureDialog->showMaximized();
1413#endif 1415#endif
1414 if ( ConfigureDialog->exec() ) 1416 if ( ConfigureDialog->exec() )
1415 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1417 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1416 delete ConfigureDialog; 1418 delete ConfigureDialog;
1417} 1419}
1418 1420
1419void KABCore::openLDAPDialog() 1421void KABCore::openLDAPDialog()
1420{ 1422{
1421#ifndef KAB_EMBEDDED 1423#ifndef KAB_EMBEDDED
1422 if ( !mLdapSearchDialog ) { 1424 if ( !mLdapSearchDialog ) {
1423 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1425 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1424 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1426 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1425 SLOT( refreshView() ) ); 1427 SLOT( refreshView() ) );
1426 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1428 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1427 SLOT( setModified() ) ); 1429 SLOT( setModified() ) );
1428 } else 1430 } else
1429 mLdapSearchDialog->restoreSettings(); 1431 mLdapSearchDialog->restoreSettings();
1430 1432
1431 if ( mLdapSearchDialog->isOK() ) 1433 if ( mLdapSearchDialog->isOK() )
1432 mLdapSearchDialog->exec(); 1434 mLdapSearchDialog->exec();
1433#else //KAB_EMBEDDED 1435#else //KAB_EMBEDDED
1434 qDebug("KABCore::openLDAPDialog() finsih method"); 1436 qDebug("KABCore::openLDAPDialog() finsih method");
1435#endif //KAB_EMBEDDED 1437#endif //KAB_EMBEDDED
1436} 1438}
1437 1439
1438void KABCore::print() 1440void KABCore::print()
1439{ 1441{
1440#ifndef KAB_EMBEDDED 1442#ifndef KAB_EMBEDDED
1441 KPrinter printer; 1443 KPrinter printer;
1442 if ( !printer.setup( this ) ) 1444 if ( !printer.setup( this ) )
1443 return; 1445 return;
1444 1446
1445 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1447 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1446 mViewManager->selectedUids(), this ); 1448 mViewManager->selectedUids(), this );
1447 1449
1448 wizard.exec(); 1450 wizard.exec();
1449#else //KAB_EMBEDDED 1451#else //KAB_EMBEDDED
1450 qDebug("KABCore::print() finsih method"); 1452 qDebug("KABCore::print() finsih method");
1451#endif //KAB_EMBEDDED 1453#endif //KAB_EMBEDDED
1452 1454
1453} 1455}
1454 1456
1455 1457
1456void KABCore::addGUIClient( KXMLGUIClient *client ) 1458void KABCore::addGUIClient( KXMLGUIClient *client )
1457{ 1459{
1458 if ( mGUIClient ) 1460 if ( mGUIClient )
1459 mGUIClient->insertChildClient( client ); 1461 mGUIClient->insertChildClient( client );
1460 else 1462 else
1461 KMessageBox::error( this, "no KXMLGUICLient"); 1463 KMessageBox::error( this, "no KXMLGUICLient");
1462} 1464}
1463 1465
1464 1466
1465void KABCore::configurationChanged() 1467void KABCore::configurationChanged()
1466{ 1468{
1467 mExtensionManager->reconfigure(); 1469 mExtensionManager->reconfigure();
1468} 1470}
1469 1471
1470void KABCore::addressBookChanged() 1472void KABCore::addressBookChanged()
1471{ 1473{
1472/*US 1474/*US
1473 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1475 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1474 while ( it.current() ) { 1476 while ( it.current() ) {
1475 if ( it.current()->dirty() ) { 1477 if ( it.current()->dirty() ) {
1476 QString text = i18n( "Data has been changed externally. Unsaved " 1478 QString text = i18n( "Data has been changed externally. Unsaved "
1477 "changes will be lost." ); 1479 "changes will be lost." );
1478 KMessageBox::information( this, text ); 1480 KMessageBox::information( this, text );
1479 } 1481 }
1480 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1482 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1481 ++it; 1483 ++it;
1482 } 1484 }
1483*/ 1485*/
1484 if (mEditorDialog) 1486 if (mEditorDialog)
1485 { 1487 {
1486 if (mEditorDialog->dirty()) 1488 if (mEditorDialog->dirty())
1487 { 1489 {
1488 QString text = i18n( "Data has been changed externally. Unsaved " 1490 QString text = i18n( "Data has been changed externally. Unsaved "
1489 "changes will be lost." ); 1491 "changes will be lost." );
1490 KMessageBox::information( this, text ); 1492 KMessageBox::information( this, text );
1491 } 1493 }
1492 QString currentuid = mEditorDialog->addressee().uid(); 1494 QString currentuid = mEditorDialog->addressee().uid();
1493 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1495 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1494 } 1496 }
1495 mViewManager->refreshView(); 1497 mViewManager->refreshView();
1496// mDetails->refreshView(); 1498// mDetails->refreshView();
1497 1499
1498 1500
1499} 1501}
1500 1502
1501AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1503AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1502 const char *name ) 1504 const char *name )
1503{ 1505{
1504 1506
1505 if ( mEditorDialog == 0 ) { 1507 if ( mEditorDialog == 0 ) {
1506 mEditorDialog = new AddresseeEditorDialog( this, parent, 1508 mEditorDialog = new AddresseeEditorDialog( this, parent,
1507 name ? name : "editorDialog" ); 1509 name ? name : "editorDialog" );
1508 1510
1509 1511
1510 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1512 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1511 SLOT( contactModified( const KABC::Addressee& ) ) ); 1513 SLOT( contactModified( const KABC::Addressee& ) ) );
1512 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1514 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1513 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1515 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1514 } 1516 }
1515 1517
1516 return mEditorDialog; 1518 return mEditorDialog;
1517} 1519}
1518 1520
1519void KABCore::slotEditorDestroyed( const QString &uid ) 1521void KABCore::slotEditorDestroyed( const QString &uid )
1520{ 1522{
1521 //mEditorDict.remove( uid ); 1523 //mEditorDict.remove( uid );
1522} 1524}
1523 1525
1524void KABCore::initGUI() 1526void KABCore::initGUI()
1525{ 1527{
1526#ifndef KAB_EMBEDDED 1528#ifndef KAB_EMBEDDED
1527 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1529 QHBoxLayout *topLayout = new QHBoxLayout( this );
1528 topLayout->setSpacing( KDialogBase::spacingHint() ); 1530 topLayout->setSpacing( KDialogBase::spacingHint() );
1529 1531
1530 mExtensionBarSplitter = new QSplitter( this ); 1532 mExtensionBarSplitter = new QSplitter( this );
1531 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1533 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1532 1534
1533 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1535 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1534 1536
1535 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1537 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1536 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1538 mIncSearchWidget = new IncSearchWidget( viewSpace );
1537 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1539 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1538 SLOT( incrementalSearch( const QString& ) ) ); 1540 SLOT( incrementalSearch( const QString& ) ) );
1539 1541
1540 mViewManager = new ViewManager( this, viewSpace ); 1542 mViewManager = new ViewManager( this, viewSpace );
1541 viewSpace->setStretchFactor( mViewManager, 1 ); 1543 viewSpace->setStretchFactor( mViewManager, 1 );
1542 1544
1543 mDetails = new ViewContainer( mDetailsSplitter ); 1545 mDetails = new ViewContainer( mDetailsSplitter );
1544 1546
1545 mJumpButtonBar = new JumpButtonBar( this, this ); 1547 mJumpButtonBar = new JumpButtonBar( this, this );
1546 1548
1547 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1549 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1548 1550
1549 topLayout->addWidget( mExtensionBarSplitter ); 1551 topLayout->addWidget( mExtensionBarSplitter );
1550 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1552 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1551 topLayout->addWidget( mJumpButtonBar ); 1553 topLayout->addWidget( mJumpButtonBar );
1552 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1554 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1553 1555
1554 mXXPortManager = new XXPortManager( this, this ); 1556 mXXPortManager = new XXPortManager( this, this );
1555 1557
1556#else //KAB_EMBEDDED 1558#else //KAB_EMBEDDED
1557 //US initialize viewMenu before settingup viewmanager. 1559 //US initialize viewMenu before settingup viewmanager.
1558 // Viewmanager needs this menu to plugin submenues. 1560 // Viewmanager needs this menu to plugin submenues.
1559 viewMenu = new QPopupMenu( this ); 1561 viewMenu = new QPopupMenu( this );
1560 settingsMenu = new QPopupMenu( this ); 1562 settingsMenu = new QPopupMenu( this );
1561 //filterMenu = new QPopupMenu( this ); 1563 //filterMenu = new QPopupMenu( this );
1562 ImportMenu = new QPopupMenu( this ); 1564 ImportMenu = new QPopupMenu( this );
1563 ExportMenu = new QPopupMenu( this ); 1565 ExportMenu = new QPopupMenu( this );
1564 syncMenu = new QPopupMenu( this ); 1566 syncMenu = new QPopupMenu( this );
1565 changeMenu= new QPopupMenu( this ); 1567 changeMenu= new QPopupMenu( this );
1566 1568
1567//US since we have no splitter for the embedded system, setup 1569//US since we have no splitter for the embedded system, setup
1568// a layout with two frames. One left and one right. 1570// a layout with two frames. One left and one right.
1569 1571
1570 QBoxLayout *topLayout; 1572 QBoxLayout *topLayout;
1571 1573
1572 // = new QHBoxLayout( this ); 1574 // = new QHBoxLayout( this );
1573// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1575// QBoxLayout *topLayout = (QBoxLayout*)layout();
1574 1576
1575// QWidget *mainBox = new QWidget( this ); 1577// QWidget *mainBox = new QWidget( this );
1576// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1578// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1577 1579
1578#ifdef DESKTOP_VERSION 1580#ifdef DESKTOP_VERSION
1579 topLayout = new QHBoxLayout( this ); 1581 topLayout = new QHBoxLayout( this );
1580 1582
1581 1583
1582 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1584 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1583 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1585 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1584 1586
1585 topLayout->addWidget(mMiniSplitter ); 1587 topLayout->addWidget(mMiniSplitter );
1586 1588
1587 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1589 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1588 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1590 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1589 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1591 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1590 mDetails = new ViewContainer( mMiniSplitter ); 1592 mDetails = new ViewContainer( mMiniSplitter );
1591 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1593 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1592#else 1594#else
1593 if ( QApplication::desktop()->width() > 480 ) { 1595 if ( QApplication::desktop()->width() > 480 ) {
1594 topLayout = new QHBoxLayout( this ); 1596 topLayout = new QHBoxLayout( this );
1595 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1597 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1596 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1598 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1597 } else { 1599 } else {
1598 1600
1599 topLayout = new QHBoxLayout( this ); 1601 topLayout = new QHBoxLayout( this );
1600 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1602 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1601 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1603 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1602 } 1604 }
1603 1605
1604 topLayout->addWidget(mMiniSplitter ); 1606 topLayout->addWidget(mMiniSplitter );
1605 mViewManager = new ViewManager( this, mMiniSplitter ); 1607 mViewManager = new ViewManager( this, mMiniSplitter );
1606 mDetails = new ViewContainer( mMiniSplitter ); 1608 mDetails = new ViewContainer( mMiniSplitter );
1607 1609
1608 1610
1609 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1611 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1610#endif 1612#endif
1611 //eh->hide(); 1613 //eh->hide();
1612 // topLayout->addWidget(mExtensionManager ); 1614 // topLayout->addWidget(mExtensionManager );
1613 1615
1614 1616
1615/*US 1617/*US
1616#ifndef KAB_NOSPLITTER 1618#ifndef KAB_NOSPLITTER
1617 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1619 QHBoxLayout *topLayout = new QHBoxLayout( this );
1618//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1620//US topLayout->setSpacing( KDialogBase::spacingHint() );
1619 topLayout->setSpacing( 10 ); 1621 topLayout->setSpacing( 10 );
1620 1622
1621 mDetailsSplitter = new QSplitter( this ); 1623 mDetailsSplitter = new QSplitter( this );
1622 1624
1623 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1625 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1624 1626
1625 mViewManager = new ViewManager( this, viewSpace ); 1627 mViewManager = new ViewManager( this, viewSpace );
1626 viewSpace->setStretchFactor( mViewManager, 1 ); 1628 viewSpace->setStretchFactor( mViewManager, 1 );
1627 1629
1628 mDetails = new ViewContainer( mDetailsSplitter ); 1630 mDetails = new ViewContainer( mDetailsSplitter );
1629 1631
1630 topLayout->addWidget( mDetailsSplitter ); 1632 topLayout->addWidget( mDetailsSplitter );
1631 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1633 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1632#else //KAB_NOSPLITTER 1634#else //KAB_NOSPLITTER
1633 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1635 QHBoxLayout *topLayout = new QHBoxLayout( this );
1634//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1636//US topLayout->setSpacing( KDialogBase::spacingHint() );
1635 topLayout->setSpacing( 10 ); 1637 topLayout->setSpacing( 10 );
1636 1638
1637// mDetailsSplitter = new QSplitter( this ); 1639// mDetailsSplitter = new QSplitter( this );
1638 1640
1639 QVBox *viewSpace = new QVBox( this ); 1641 QVBox *viewSpace = new QVBox( this );
1640 1642
1641 mViewManager = new ViewManager( this, viewSpace ); 1643 mViewManager = new ViewManager( this, viewSpace );
1642 viewSpace->setStretchFactor( mViewManager, 1 ); 1644 viewSpace->setStretchFactor( mViewManager, 1 );
1643 1645
1644 mDetails = new ViewContainer( this ); 1646 mDetails = new ViewContainer( this );
1645 1647
1646 topLayout->addWidget( viewSpace ); 1648 topLayout->addWidget( viewSpace );
1647// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1649// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1648 topLayout->addWidget( mDetails ); 1650 topLayout->addWidget( mDetails );
1649#endif //KAB_NOSPLITTER 1651#endif //KAB_NOSPLITTER
1650*/ 1652*/
1651 1653
1652 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1654 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1653 syncManager->setBlockSave(false); 1655 syncManager->setBlockSave(false);
1654 1656
1655 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 1657 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
1656 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 1658 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
1657 syncManager->setDefaultFileName( sentSyncFile()); 1659 syncManager->setDefaultFileName( sentSyncFile());
1658 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1660 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1659 1661
1660#endif //KAB_EMBEDDED 1662#endif //KAB_EMBEDDED
1661 initActions(); 1663 initActions();
1662 1664
1663#ifdef KAB_EMBEDDED 1665#ifdef KAB_EMBEDDED
1664 addActionsManually(); 1666 addActionsManually();
1665 //US make sure the export and import menues are initialized before creating the xxPortManager. 1667 //US make sure the export and import menues are initialized before creating the xxPortManager.
1666 mXXPortManager = new XXPortManager( this, this ); 1668 mXXPortManager = new XXPortManager( this, this );
1667 1669
1668 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1670 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1669 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1671 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1670 // mActionQuit->plug ( mMainWindow->toolBar()); 1672 // mActionQuit->plug ( mMainWindow->toolBar());
1671 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1673 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1672 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1674 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1673 // mIncSearchWidget->hide(); 1675 // mIncSearchWidget->hide();
1674 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1676 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1675 SLOT( incrementalSearch( const QString& ) ) ); 1677 SLOT( incrementalSearch( const QString& ) ) );
1676 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); 1678 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) );
1677 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); 1679 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) );
1678 1680
1679 mJumpButtonBar = new JumpButtonBar( this, this ); 1681 mJumpButtonBar = new JumpButtonBar( this, this );
1680 1682
1681 topLayout->addWidget( mJumpButtonBar ); 1683 topLayout->addWidget( mJumpButtonBar );
1682//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1684//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1683 1685
1684// mMainWindow->getIconToolBar()->raise(); 1686// mMainWindow->getIconToolBar()->raise();
1685 1687
1686#endif //KAB_EMBEDDED 1688#endif //KAB_EMBEDDED
1687 1689
1688} 1690}
1689void KABCore::initActions() 1691void KABCore::initActions()
1690{ 1692{
1691//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1693//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1692 1694
1693#ifndef KAB_EMBEDDED 1695#ifndef KAB_EMBEDDED
1694 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1696 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1695 SLOT( clipboardDataChanged() ) ); 1697 SLOT( clipboardDataChanged() ) );
1696#endif //KAB_EMBEDDED 1698#endif //KAB_EMBEDDED
1697 1699
1698 // file menu 1700 // file menu
1699 if ( mIsPart ) { 1701 if ( mIsPart ) {
1700 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, 1702 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
1701 SLOT( sendMail() ), actionCollection(), 1703 SLOT( sendMail() ), actionCollection(),
1702 "kaddressbook_mail" ); 1704 "kaddressbook_mail" );
1703 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, 1705 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
1704 SLOT( print() ), actionCollection(), "kaddressbook_print" ); 1706 SLOT( print() ), actionCollection(), "kaddressbook_print" );
1705 1707
1706 } else { 1708 } else {
1707 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1709 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1708 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1710 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1709 } 1711 }
1710 1712
1711 1713
1712 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1714 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1713 SLOT( save() ), actionCollection(), "file_sync" ); 1715 SLOT( save() ), actionCollection(), "file_sync" );
1714 1716
1715 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1717 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1716 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1718 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1717 1719
1718 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1720 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1719 this, SLOT( mailVCard() ), 1721 this, SLOT( mailVCard() ),
1720 actionCollection(), "file_mail_vcard"); 1722 actionCollection(), "file_mail_vcard");
1721 1723
1722 mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, 1724 mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this,
1723 SLOT( export2phone() ), actionCollection(), 1725 SLOT( export2phone() ), actionCollection(),
1724 "kaddressbook_ex2phone" ); 1726 "kaddressbook_ex2phone" );
1725 1727
1726 mActionBeamVCard = 0; 1728 mActionBeamVCard = 0;
1727 mActionBeam = 0; 1729 mActionBeam = 0;
1728 1730
1729#ifndef DESKTOP_VERSION 1731#ifndef DESKTOP_VERSION
1730 if ( Ir::supported() ) { 1732 if ( Ir::supported() ) {
1731 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, 1733 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this,
1732 SLOT( beamVCard() ), actionCollection(), 1734 SLOT( beamVCard() ), actionCollection(),
1733 "kaddressbook_beam_vcard" ); 1735 "kaddressbook_beam_vcard" );
1734 1736
1735 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1737 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1736 SLOT( beamMySelf() ), actionCollection(), 1738 SLOT( beamMySelf() ), actionCollection(),
1737 "kaddressbook_beam_myself" ); 1739 "kaddressbook_beam_myself" );
1738 } 1740 }
1739#endif 1741#endif
1740 1742
1741 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1743 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1742 this, SLOT( editContact2() ), 1744 this, SLOT( editContact2() ),
1743 actionCollection(), "file_properties" ); 1745 actionCollection(), "file_properties" );
1744 1746
1745#ifdef KAB_EMBEDDED 1747#ifdef KAB_EMBEDDED
1746 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1748 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1747 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1749 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1748 mMainWindow, SLOT( exit() ), 1750 mMainWindow, SLOT( exit() ),
1749 actionCollection(), "quit" ); 1751 actionCollection(), "quit" );
1750#endif //KAB_EMBEDDED 1752#endif //KAB_EMBEDDED
1751 1753
1752 // edit menu 1754 // edit menu
1753 if ( mIsPart ) { 1755 if ( mIsPart ) {
1754 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1756 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1755 SLOT( copyContacts() ), actionCollection(), 1757 SLOT( copyContacts() ), actionCollection(),
1756 "kaddressbook_copy" ); 1758 "kaddressbook_copy" );
1757 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1759 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1758 SLOT( cutContacts() ), actionCollection(), 1760 SLOT( cutContacts() ), actionCollection(),
1759 "kaddressbook_cut" ); 1761 "kaddressbook_cut" );
1760 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1762 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1761 SLOT( pasteContacts() ), actionCollection(), 1763 SLOT( pasteContacts() ), actionCollection(),
1762 "kaddressbook_paste" ); 1764 "kaddressbook_paste" );
1763 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1765 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1764 SLOT( selectAllContacts() ), actionCollection(), 1766 SLOT( selectAllContacts() ), actionCollection(),
1765 "kaddressbook_select_all" ); 1767 "kaddressbook_select_all" );
1766 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1768 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1767 SLOT( undo() ), actionCollection(), 1769 SLOT( undo() ), actionCollection(),
1768 "kaddressbook_undo" ); 1770 "kaddressbook_undo" );
1769 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1771 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1770 this, SLOT( redo() ), actionCollection(), 1772 this, SLOT( redo() ), actionCollection(),
1771 "kaddressbook_redo" ); 1773 "kaddressbook_redo" );
1772 } else { 1774 } else {
1773 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1775 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1774 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1776 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1775 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1777 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1776 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1778 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1777 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1779 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1778 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1780 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1779 } 1781 }
1780 1782
1781 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1783 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1782 Key_Delete, this, SLOT( deleteContacts() ), 1784 Key_Delete, this, SLOT( deleteContacts() ),
1783 actionCollection(), "edit_delete" ); 1785 actionCollection(), "edit_delete" );
1784 1786
1785 mActionUndo->setEnabled( false ); 1787 mActionUndo->setEnabled( false );
1786 mActionRedo->setEnabled( false ); 1788 mActionRedo->setEnabled( false );
1787 1789
1788 // settings menu 1790 // settings menu
1789#ifdef KAB_EMBEDDED 1791#ifdef KAB_EMBEDDED
1790//US special menuentry to configure the addressbook resources. On KDE 1792//US special menuentry to configure the addressbook resources. On KDE
1791// you do that through the control center !!! 1793// you do that through the control center !!!
1792 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1794 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1793 SLOT( configureResources() ), actionCollection(), 1795 SLOT( configureResources() ), actionCollection(),
1794 "kaddressbook_configure_resources" ); 1796 "kaddressbook_configure_resources" );
1795#endif //KAB_EMBEDDED 1797#endif //KAB_EMBEDDED
1796 1798
1797 if ( mIsPart ) { 1799 if ( mIsPart ) {
1798 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1800 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1799 SLOT( openConfigDialog() ), actionCollection(), 1801 SLOT( openConfigDialog() ), actionCollection(),
1800 "kaddressbook_configure" ); 1802 "kaddressbook_configure" );
1801 1803
1802 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1804 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1803 this, SLOT( configureKeyBindings() ), actionCollection(), 1805 this, SLOT( configureKeyBindings() ), actionCollection(),
1804 "kaddressbook_configure_shortcuts" ); 1806 "kaddressbook_configure_shortcuts" );
1805#ifdef KAB_EMBEDDED 1807#ifdef KAB_EMBEDDED
1806 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1808 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1807 mActionConfigureToolbars->setEnabled( false ); 1809 mActionConfigureToolbars->setEnabled( false );
1808#endif //KAB_EMBEDDED 1810#endif //KAB_EMBEDDED
1809 1811
1810 } else { 1812 } else {
1811 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1813 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1812 1814
1813 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1815 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1814 } 1816 }
1815 1817
1816 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 1818 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
1817 actionCollection(), "options_show_jump_bar" ); 1819 actionCollection(), "options_show_jump_bar" );
1818 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 1820 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
1819 1821
1820 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 1822 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
1821 actionCollection(), "options_show_details" ); 1823 actionCollection(), "options_show_details" );
1822 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 1824 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
1823 1825
1824 // misc 1826 // misc
1825 // only enable LDAP lookup if we can handle the protocol 1827 // only enable LDAP lookup if we can handle the protocol
1826#ifndef KAB_EMBEDDED 1828#ifndef KAB_EMBEDDED
1827 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 1829 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
1828 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 1830 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
1829 this, SLOT( openLDAPDialog() ), actionCollection(), 1831 this, SLOT( openLDAPDialog() ), actionCollection(),
1830 "ldap_lookup" ); 1832 "ldap_lookup" );
1831 } 1833 }
1832#else //KAB_EMBEDDED 1834#else //KAB_EMBEDDED
1833 //qDebug("KABCore::initActions() LDAP has to be implemented"); 1835 //qDebug("KABCore::initActions() LDAP has to be implemented");
1834#endif //KAB_EMBEDDED 1836#endif //KAB_EMBEDDED
1835 1837
1836 1838
1837 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 1839 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
1838 SLOT( setWhoAmI() ), actionCollection(), 1840 SLOT( setWhoAmI() ), actionCollection(),
1839 "set_personal" ); 1841 "set_personal" );
1840 1842
1841 1843
1842 1844
1843 1845
1844 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 1846 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
1845 SLOT( setCategories() ), actionCollection(), 1847 SLOT( setCategories() ), actionCollection(),
1846 "edit_set_categories" ); 1848 "edit_set_categories" );
1847 1849
1848 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 1850 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
1849 SLOT( removeVoice() ), actionCollection(), 1851 SLOT( removeVoice() ), actionCollection(),
1850 "remove_voice" ); 1852 "remove_voice" );
1851 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 1853 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
1852 SLOT( importFromOL() ), actionCollection(), 1854 SLOT( importFromOL() ), actionCollection(),
1853 "import_OL" ); 1855 "import_OL" );
1854#ifdef KAB_EMBEDDED 1856#ifdef KAB_EMBEDDED
1855 mActionLicence = new KAction( i18n( "Licence" ), 0, 1857 mActionLicence = new KAction( i18n( "Licence" ), 0,
1856 this, SLOT( showLicence() ), actionCollection(), 1858 this, SLOT( showLicence() ), actionCollection(),
1857 "licence_about_data" ); 1859 "licence_about_data" );
1858 mActionFaq = new KAction( i18n( "Faq" ), 0, 1860 mActionFaq = new KAction( i18n( "Faq" ), 0,
1859 this, SLOT( faq() ), actionCollection(), 1861 this, SLOT( faq() ), actionCollection(),
1860 "faq_about_data" ); 1862 "faq_about_data" );
1861 mActionWN = new KAction( i18n( "What's New?" ), 0, 1863 mActionWN = new KAction( i18n( "What's New?" ), 0,
1862 this, SLOT( whatsnew() ), actionCollection(), 1864 this, SLOT( whatsnew() ), actionCollection(),
1863 "wn" ); 1865 "wn" );
1864 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, 1866 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0,
1865 this, SLOT( synchowto() ), actionCollection(), 1867 this, SLOT( synchowto() ), actionCollection(),
1866 "sync" ); 1868 "sync" );
1867 1869
1868 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 1870 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
1869 this, SLOT( createAboutData() ), actionCollection(), 1871 this, SLOT( createAboutData() ), actionCollection(),
1870 "kaddressbook_about_data" ); 1872 "kaddressbook_about_data" );
1871#endif //KAB_EMBEDDED 1873#endif //KAB_EMBEDDED
1872 1874
1873 clipboardDataChanged(); 1875 clipboardDataChanged();
1874 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1876 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1875 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1877 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1876} 1878}
1877 1879
1878//US we need this function, to plug all actions into the correct menues. 1880//US we need this function, to plug all actions into the correct menues.
1879// KDE uses a XML format to plug the actions, but we work her without this overhead. 1881// KDE uses a XML format to plug the actions, but we work her without this overhead.
1880void KABCore::addActionsManually() 1882void KABCore::addActionsManually()
1881{ 1883{
1882//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1884//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1883 1885
1884#ifdef KAB_EMBEDDED 1886#ifdef KAB_EMBEDDED
1885 QPopupMenu *fileMenu = new QPopupMenu( this ); 1887 QPopupMenu *fileMenu = new QPopupMenu( this );
1886 QPopupMenu *editMenu = new QPopupMenu( this ); 1888 QPopupMenu *editMenu = new QPopupMenu( this );
1887 QPopupMenu *helpMenu = new QPopupMenu( this ); 1889 QPopupMenu *helpMenu = new QPopupMenu( this );
1888 1890
1889 KToolBar* tb = mMainWindow->toolBar(); 1891 KToolBar* tb = mMainWindow->toolBar();
1890 1892
1891#ifdef DESKTOP_VERSION 1893#ifdef DESKTOP_VERSION
1892 QMenuBar* mb = mMainWindow->menuBar(); 1894 QMenuBar* mb = mMainWindow->menuBar();
1893 1895
1894 //US setup menubar. 1896 //US setup menubar.
1895 //Disable the following block if you do not want to have a menubar. 1897 //Disable the following block if you do not want to have a menubar.
1896 mb->insertItem( "&File", fileMenu ); 1898 mb->insertItem( "&File", fileMenu );
1897 mb->insertItem( "&Edit", editMenu ); 1899 mb->insertItem( "&Edit", editMenu );
1898 mb->insertItem( "&View", viewMenu ); 1900 mb->insertItem( "&View", viewMenu );
1899 mb->insertItem( "&Settings", settingsMenu ); 1901 mb->insertItem( "&Settings", settingsMenu );
1900 mb->insertItem( i18n("Synchronize"), syncMenu ); 1902 mb->insertItem( i18n("Synchronize"), syncMenu );
1901 mb->insertItem( "&Change selected", changeMenu ); 1903 mb->insertItem( "&Change selected", changeMenu );
1902 mb->insertItem( "&Help", helpMenu ); 1904 mb->insertItem( "&Help", helpMenu );
1903 mIncSearchWidget = new IncSearchWidget( tb ); 1905 mIncSearchWidget = new IncSearchWidget( tb );
1904 // tb->insertWidget(-1, 0, mIncSearchWidget); 1906 // tb->insertWidget(-1, 0, mIncSearchWidget);
1905 1907
1906#else 1908#else
1907 //US setup toolbar 1909 //US setup toolbar
1908 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 1910 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
1909 QPopupMenu *popupBarTB = new QPopupMenu( this ); 1911 QPopupMenu *popupBarTB = new QPopupMenu( this );
1910 menuBarTB->insertItem( "ME", popupBarTB); 1912 menuBarTB->insertItem( "ME", popupBarTB);
1911 tb->insertWidget(-1, 0, menuBarTB); 1913 tb->insertWidget(-1, 0, menuBarTB);
1912 mIncSearchWidget = new IncSearchWidget( tb ); 1914 mIncSearchWidget = new IncSearchWidget( tb );
1913 1915
1914 tb->enableMoving(false); 1916 tb->enableMoving(false);
1915 popupBarTB->insertItem( "&File", fileMenu ); 1917 popupBarTB->insertItem( "&File", fileMenu );
1916 popupBarTB->insertItem( "&Edit", editMenu ); 1918 popupBarTB->insertItem( "&Edit", editMenu );
1917 popupBarTB->insertItem( "&View", viewMenu ); 1919 popupBarTB->insertItem( "&View", viewMenu );
1918 popupBarTB->insertItem( "&Settings", settingsMenu ); 1920 popupBarTB->insertItem( "&Settings", settingsMenu );
1919 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 1921 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
1920 mViewManager->getFilterAction()->plug ( popupBarTB); 1922 mViewManager->getFilterAction()->plug ( popupBarTB);
1921 popupBarTB->insertItem( "&Change selected", changeMenu ); 1923 popupBarTB->insertItem( "&Change selected", changeMenu );
1922 popupBarTB->insertItem( "&Help", helpMenu ); 1924 popupBarTB->insertItem( "&Help", helpMenu );
1923 if (QApplication::desktop()->width() > 320 ) { 1925 if (QApplication::desktop()->width() > 320 ) {
1924 // mViewManager->getFilterAction()->plug ( tb); 1926 // mViewManager->getFilterAction()->plug ( tb);
1925 } 1927 }
1926#endif 1928#endif
1927 // mActionQuit->plug ( mMainWindow->toolBar()); 1929 // mActionQuit->plug ( mMainWindow->toolBar());
1928 1930
1929 1931
1930 1932
1931 //US Now connect the actions with the menue entries. 1933 //US Now connect the actions with the menue entries.
1932 mActionPrint->plug( fileMenu ); 1934 mActionPrint->plug( fileMenu );
1933 mActionMail->plug( fileMenu ); 1935 mActionMail->plug( fileMenu );
1934 fileMenu->insertSeparator(); 1936 fileMenu->insertSeparator();
1935 1937
1936 mActionNewContact->plug( fileMenu ); 1938 mActionNewContact->plug( fileMenu );
1937 mActionNewContact->plug( tb ); 1939 mActionNewContact->plug( tb );
1938 1940
1939 mActionEditAddressee->plug( fileMenu ); 1941 mActionEditAddressee->plug( fileMenu );
1940 if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 1942 if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
1941 (!KABPrefs::instance()->mMultipleViewsAtOnce )) 1943 (!KABPrefs::instance()->mMultipleViewsAtOnce ))
1942 mActionEditAddressee->plug( tb ); 1944 mActionEditAddressee->plug( tb );
1943 1945
1944 fileMenu->insertSeparator(); 1946 fileMenu->insertSeparator();
1945 mActionSave->plug( fileMenu ); 1947 mActionSave->plug( fileMenu );
1946 fileMenu->insertItem( "&Import", ImportMenu ); 1948 fileMenu->insertItem( "&Import", ImportMenu );
1947 fileMenu->insertItem( "&Export", ExportMenu ); 1949 fileMenu->insertItem( "&Export", ExportMenu );
1948 fileMenu->insertSeparator(); 1950 fileMenu->insertSeparator();
1949 mActionMailVCard->plug( fileMenu ); 1951 mActionMailVCard->plug( fileMenu );
1950#ifndef DESKTOP_VERSION 1952#ifndef DESKTOP_VERSION
1951 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); 1953 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu );
1952 if ( Ir::supported() ) mActionBeam->plug(fileMenu ); 1954 if ( Ir::supported() ) mActionBeam->plug(fileMenu );
1953#endif 1955#endif
1954 fileMenu->insertSeparator(); 1956 fileMenu->insertSeparator();
1955 mActionQuit->plug( fileMenu ); 1957 mActionQuit->plug( fileMenu );
1956#ifdef _WIN32_ 1958#ifdef _WIN32_
1957 mActionImportOL->plug( ImportMenu ); 1959 mActionImportOL->plug( ImportMenu );
1958#endif 1960#endif
1959 // edit menu 1961 // edit menu
1960 mActionUndo->plug( editMenu ); 1962 mActionUndo->plug( editMenu );
1961 mActionRedo->plug( editMenu ); 1963 mActionRedo->plug( editMenu );
1962 editMenu->insertSeparator(); 1964 editMenu->insertSeparator();
1963 mActionCut->plug( editMenu ); 1965 mActionCut->plug( editMenu );
1964 mActionCopy->plug( editMenu ); 1966 mActionCopy->plug( editMenu );
1965 mActionPaste->plug( editMenu ); 1967 mActionPaste->plug( editMenu );
1966 mActionDelete->plug( editMenu ); 1968 mActionDelete->plug( editMenu );
1967 editMenu->insertSeparator(); 1969 editMenu->insertSeparator();
1968 mActionSelectAll->plug( editMenu ); 1970 mActionSelectAll->plug( editMenu );
1969 1971
1970 mActionRemoveVoice->plug( changeMenu ); 1972 mActionRemoveVoice->plug( changeMenu );
1971 // settings menu 1973 // settings menu
1972//US special menuentry to configure the addressbook resources. On KDE 1974//US special menuentry to configure the addressbook resources. On KDE
1973// you do that through the control center !!! 1975// you do that through the control center !!!
1974 mActionConfigResources->plug( settingsMenu ); 1976 mActionConfigResources->plug( settingsMenu );
1975 settingsMenu->insertSeparator(); 1977 settingsMenu->insertSeparator();
1976 1978
1977 mActionConfigKAddressbook->plug( settingsMenu ); 1979 mActionConfigKAddressbook->plug( settingsMenu );
1978 1980
1979 if ( mIsPart ) { 1981 if ( mIsPart ) {
1980 mActionConfigShortcuts->plug( settingsMenu ); 1982 mActionConfigShortcuts->plug( settingsMenu );
1981 mActionConfigureToolbars->plug( settingsMenu ); 1983 mActionConfigureToolbars->plug( settingsMenu );
1982 1984
1983 } else { 1985 } else {
1984 mActionKeyBindings->plug( settingsMenu ); 1986 mActionKeyBindings->plug( settingsMenu );
1985 } 1987 }
1986 1988
1987 settingsMenu->insertSeparator(); 1989 settingsMenu->insertSeparator();
1988 1990
1989 mActionJumpBar->plug( settingsMenu ); 1991 mActionJumpBar->plug( settingsMenu );
1990 mActionDetails->plug( settingsMenu ); 1992 mActionDetails->plug( settingsMenu );
1991 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 1993 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
1992 mActionDetails->plug( tb ); 1994 mActionDetails->plug( tb );
1993 settingsMenu->insertSeparator(); 1995 settingsMenu->insertSeparator();
1994 1996
1995 mActionWhoAmI->plug( settingsMenu ); 1997 mActionWhoAmI->plug( settingsMenu );
1996 mActionCategories->plug( settingsMenu ); 1998 mActionCategories->plug( settingsMenu );
1997 1999
1998 2000
1999 mActionWN->plug( helpMenu ); 2001 mActionWN->plug( helpMenu );
2000 mActionSyncHowto->plug( helpMenu ); 2002 mActionSyncHowto->plug( helpMenu );
2001 mActionLicence->plug( helpMenu ); 2003 mActionLicence->plug( helpMenu );
2002 mActionFaq->plug( helpMenu ); 2004 mActionFaq->plug( helpMenu );
2003 mActionAboutKAddressbook->plug( helpMenu ); 2005 mActionAboutKAddressbook->plug( helpMenu );
2004 2006
2005 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2007 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2006 2008
2007 mActionSave->plug( tb ); 2009 mActionSave->plug( tb );
2008 mViewManager->getFilterAction()->plug ( tb); 2010 mViewManager->getFilterAction()->plug ( tb);
2009 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { 2011 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) {
2010 mActionUndo->plug( tb ); 2012 mActionUndo->plug( tb );
2011 mActionDelete->plug( tb ); 2013 mActionDelete->plug( tb );
2012 mActionRedo->plug( tb ); 2014 mActionRedo->plug( tb );
2013 } 2015 }
2014 } 2016 }
2015 //mActionQuit->plug ( tb ); 2017 //mActionQuit->plug ( tb );
2016 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2018 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2017 2019
2018 //US link the searchwidget first to this. 2020 //US link the searchwidget first to this.
2019 // The real linkage to the toolbar happens later. 2021 // The real linkage to the toolbar happens later.
2020//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2022//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2021//US tb->insertItem( mIncSearchWidget ); 2023//US tb->insertItem( mIncSearchWidget );
2022/*US 2024/*US
2023 mIncSearchWidget = new IncSearchWidget( tb ); 2025 mIncSearchWidget = new IncSearchWidget( tb );
2024 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2026 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2025 SLOT( incrementalSearch( const QString& ) ) ); 2027 SLOT( incrementalSearch( const QString& ) ) );
2026 2028
2027 mJumpButtonBar = new JumpButtonBar( this, this ); 2029 mJumpButtonBar = new JumpButtonBar( this, this );
2028 2030
2029//US topLayout->addWidget( mJumpButtonBar ); 2031//US topLayout->addWidget( mJumpButtonBar );
2030 this->layout()->add( mJumpButtonBar ); 2032 this->layout()->add( mJumpButtonBar );
2031*/ 2033*/
2032 2034
2033#endif //KAB_EMBEDDED 2035#endif //KAB_EMBEDDED
2034 2036
2035 mActionExport2phone->plug( ExportMenu ); 2037 mActionExport2phone->plug( ExportMenu );
2036 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2038 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2037 syncManager->fillSyncMenu(); 2039 syncManager->fillSyncMenu();
2038 2040
2039} 2041}
2040void KABCore::showLicence() 2042void KABCore::showLicence()
2041{ 2043{
2042 KApplication::showLicence(); 2044 KApplication::showLicence();
2043} 2045}
2044void KABCore::removeVoice() 2046void KABCore::removeVoice()
2045{ 2047{
2046 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) 2048 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No )
2047 return; 2049 return;
2048 KABC::Addressee::List list = mViewManager->selectedAddressees(); 2050 KABC::Addressee::List list = mViewManager->selectedAddressees();
2049 KABC::Addressee::List::Iterator it; 2051 KABC::Addressee::List::Iterator it;
2050 for ( it = list.begin(); it != list.end(); ++it ) { 2052 for ( it = list.begin(); it != list.end(); ++it ) {
2051 2053
2052 if ( (*it).removeVoice() ) 2054 if ( (*it).removeVoice() )
2053 contactModified((*it) ); 2055 contactModified((*it) );
2054 } 2056 }
2055} 2057}
2056 2058
2057 2059
2058 2060
2059void KABCore::clipboardDataChanged() 2061void KABCore::clipboardDataChanged()
2060{ 2062{
2061 2063
2062 if ( mReadWrite ) 2064 if ( mReadWrite )
2063 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2065 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2064 2066
2065} 2067}
2066 2068
2067void KABCore::updateActionMenu() 2069void KABCore::updateActionMenu()
2068{ 2070{
2069 UndoStack *undo = UndoStack::instance(); 2071 UndoStack *undo = UndoStack::instance();
2070 RedoStack *redo = RedoStack::instance(); 2072 RedoStack *redo = RedoStack::instance();
2071 2073
2072 if ( undo->isEmpty() ) 2074 if ( undo->isEmpty() )
2073 mActionUndo->setText( i18n( "Undo" ) ); 2075 mActionUndo->setText( i18n( "Undo" ) );
2074 else 2076 else
2075 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2077 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2076 2078
2077 mActionUndo->setEnabled( !undo->isEmpty() ); 2079 mActionUndo->setEnabled( !undo->isEmpty() );
2078 2080
2079 if ( !redo->top() ) 2081 if ( !redo->top() )
2080 mActionRedo->setText( i18n( "Redo" ) ); 2082 mActionRedo->setText( i18n( "Redo" ) );
2081 else 2083 else
2082 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2084 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2083 2085
2084 mActionRedo->setEnabled( !redo->isEmpty() ); 2086 mActionRedo->setEnabled( !redo->isEmpty() );
2085} 2087}
2086 2088
2087void KABCore::configureKeyBindings() 2089void KABCore::configureKeyBindings()
2088{ 2090{
2089#ifndef KAB_EMBEDDED 2091#ifndef KAB_EMBEDDED
2090 KKeyDialog::configure( actionCollection(), true ); 2092 KKeyDialog::configure( actionCollection(), true );
2091#else //KAB_EMBEDDED 2093#else //KAB_EMBEDDED
2092 qDebug("KABCore::configureKeyBindings() not implemented"); 2094 qDebug("KABCore::configureKeyBindings() not implemented");
2093#endif //KAB_EMBEDDED 2095#endif //KAB_EMBEDDED
2094} 2096}
2095 2097
2096#ifdef KAB_EMBEDDED 2098#ifdef KAB_EMBEDDED
2097void KABCore::configureResources() 2099void KABCore::configureResources()
2098{ 2100{
2099 KRES::KCMKResources dlg( this, "" , 0 ); 2101 KRES::KCMKResources dlg( this, "" , 0 );
2100 2102
2101 if ( !dlg.exec() ) 2103 if ( !dlg.exec() )
2102 return; 2104 return;
2103 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2105 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2104} 2106}
2105#endif //KAB_EMBEDDED 2107#endif //KAB_EMBEDDED
2106 2108
2107 2109
2108/* this method will be called through the QCop interface from Ko/Pi to select addresses 2110/* this method will be called through the QCop interface from Ko/Pi to select addresses
2109 * for the attendees list of an event. 2111 * for the attendees list of an event.
2110 */ 2112 */
2111void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2113void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2112{ 2114{
2113 QStringList nameList; 2115 QStringList nameList;
2114 QStringList emailList; 2116 QStringList emailList;
2115 QStringList uidList; 2117 QStringList uidList;
2116 2118
2117 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2119 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2118 uint i=0; 2120 uint i=0;
2119 for (i=0; i < list.count(); i++) 2121 for (i=0; i < list.count(); i++)
2120 { 2122 {
2121 nameList.append(list[i].realName()); 2123 nameList.append(list[i].realName());
2122 emailList.append(list[i].preferredEmail()); 2124 emailList.append(list[i].preferredEmail());
2123 uidList.append(list[i].uid()); 2125 uidList.append(list[i].uid());
2124 } 2126 }
2125 2127
2126 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2128 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2127 2129
2128} 2130}
2129 2131
2130/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2132/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2131 * to put them into the calendar. 2133 * to put them into the calendar.
2132 */ 2134 */
2133void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2135void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2134{ 2136{
2135 // qDebug("KABCore::requestForBirthdayList"); 2137 // qDebug("KABCore::requestForBirthdayList");
2136 QStringList birthdayList; 2138 QStringList birthdayList;
2137 QStringList anniversaryList; 2139 QStringList anniversaryList;
2138 QStringList realNameList; 2140 QStringList realNameList;
2139 QStringList preferredEmailList; 2141 QStringList preferredEmailList;
2140 QStringList assembledNameList; 2142 QStringList assembledNameList;
2141 QStringList uidList; 2143 QStringList uidList;
2142 2144
2143 KABC::AddressBook::Iterator it; 2145 KABC::AddressBook::Iterator it;
2144 2146
2145 int count = 0; 2147 int count = 0;
2146 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2148 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2147 ++count; 2149 ++count;
2148 } 2150 }
2149 QProgressBar bar(count,0 ); 2151 QProgressBar bar(count,0 );
2150 int w = 300; 2152 int w = 300;
2151 if ( QApplication::desktop()->width() < 320 ) 2153 if ( QApplication::desktop()->width() < 320 )
2152 w = 220; 2154 w = 220;
2153 int h = bar.sizeHint().height() ; 2155 int h = bar.sizeHint().height() ;
2154 int dw = QApplication::desktop()->width(); 2156 int dw = QApplication::desktop()->width();
2155 int dh = QApplication::desktop()->height(); 2157 int dh = QApplication::desktop()->height();
2156 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2158 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2157 bar.show(); 2159 bar.show();
2158 bar.setCaption (i18n("collecting birthdays - close to abort!") ); 2160 bar.setCaption (i18n("collecting birthdays - close to abort!") );
2159 qApp->processEvents(); 2161 qApp->processEvents();
2160 2162
2161 QDate bday; 2163 QDate bday;
2162 QString anni; 2164 QString anni;
2163 QString formattedbday; 2165 QString formattedbday;
2164 2166
2165 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2167 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2166 { 2168 {
2167 if ( ! bar.isVisible() ) 2169 if ( ! bar.isVisible() )
2168 return; 2170 return;
2169 bar.setProgress( count++ ); 2171 bar.setProgress( count++ );
2170 qApp->processEvents(); 2172 qApp->processEvents();
2171 bday = (*it).birthday().date(); 2173 bday = (*it).birthday().date();
2172 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2174 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2173 2175
2174 if ( bday.isValid() || !anni.isEmpty()) 2176 if ( bday.isValid() || !anni.isEmpty())
2175 { 2177 {
2176 if (bday.isValid()) 2178 if (bday.isValid())
2177 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2179 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2178 else 2180 else
2179 formattedbday = "NOTVALID"; 2181 formattedbday = "NOTVALID";
2180 if (anni.isEmpty()) 2182 if (anni.isEmpty())
2181 anni = "INVALID"; 2183 anni = "INVALID";
2182 2184
2183 birthdayList.append(formattedbday); 2185 birthdayList.append(formattedbday);
2184 anniversaryList.append(anni); //should be ISODate 2186 anniversaryList.append(anni); //should be ISODate
2185 realNameList.append((*it).realName()); 2187 realNameList.append((*it).realName());
2186 preferredEmailList.append((*it).preferredEmail()); 2188 preferredEmailList.append((*it).preferredEmail());
2187 assembledNameList.append((*it).assembledName()); 2189 assembledNameList.append((*it).assembledName());
2188 uidList.append((*it).uid()); 2190 uidList.append((*it).uid());
2189 2191
2190 qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); 2192 qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() );
2191 } 2193 }
2192 } 2194 }
2193 2195
2194 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2196 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2195 2197
2196} 2198}
2197 2199
2198/* this method will be called through the QCop interface from other apps to show details of a contact. 2200/* this method will be called through the QCop interface from other apps to show details of a contact.
2199 */ 2201 */
2200void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2202void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2201{ 2203{
2202 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2204 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2203 2205
2204 QString foundUid = QString::null; 2206 QString foundUid = QString::null;
2205 if ( ! uid.isEmpty() ) { 2207 if ( ! uid.isEmpty() ) {
2206 Addressee adrr = mAddressBook->findByUid( uid ); 2208 Addressee adrr = mAddressBook->findByUid( uid );
2207 if ( !adrr.isEmpty() ) { 2209 if ( !adrr.isEmpty() ) {
2208 foundUid = uid; 2210 foundUid = uid;
2209 } 2211 }
2210 if ( email == "sendbacklist" ) { 2212 if ( email == "sendbacklist" ) {
2211 //qDebug("ssssssssssssssssssssssend "); 2213 //qDebug("ssssssssssssssssssssssend ");
2212 QStringList nameList; 2214 QStringList nameList;
2213 QStringList emailList; 2215 QStringList emailList;
2214 QStringList uidList; 2216 QStringList uidList;
2215 nameList.append(adrr.realName()); 2217 nameList.append(adrr.realName());
2216 emailList = adrr.emails(); 2218 emailList = adrr.emails();
2217 uidList.append( adrr.preferredEmail()); 2219 uidList.append( adrr.preferredEmail());
2218 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2220 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2219 return; 2221 return;
2220 } 2222 }
2221 2223
2222 } 2224 }
2223 2225
2224 if ( email == "sendbacklist" ) 2226 if ( email == "sendbacklist" )
2225 return; 2227 return;
2226 if (foundUid.isEmpty()) 2228 if (foundUid.isEmpty())
2227 { 2229 {
2228 //find the uid of the person first 2230 //find the uid of the person first
2229 Addressee::List namelist; 2231 Addressee::List namelist;
2230 Addressee::List emaillist; 2232 Addressee::List emaillist;
2231 2233
2232 if (!name.isEmpty()) 2234 if (!name.isEmpty())
2233 namelist = mAddressBook->findByName( name ); 2235 namelist = mAddressBook->findByName( name );
2234 2236
2235 if (!email.isEmpty()) 2237 if (!email.isEmpty())
2236 emaillist = mAddressBook->findByEmail( email ); 2238 emaillist = mAddressBook->findByEmail( email );
2237 qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2239 qDebug("count %d %d ", namelist.count(),emaillist.count() );
2238 //check if we have a match in Namelist and Emaillist 2240 //check if we have a match in Namelist and Emaillist
2239 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2241 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2240 foundUid = emaillist[0].uid(); 2242 foundUid = emaillist[0].uid();
2241 } 2243 }
2242 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2244 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2243 foundUid = namelist[0].uid(); 2245 foundUid = namelist[0].uid();
2244 else 2246 else
2245 { 2247 {
2246 for (int i = 0; i < namelist.count(); i++) 2248 for (int i = 0; i < namelist.count(); i++)
2247 { 2249 {
2248 for (int j = 0; j < emaillist.count(); j++) 2250 for (int j = 0; j < emaillist.count(); j++)
2249 { 2251 {
2250 if (namelist[i] == emaillist[j]) 2252 if (namelist[i] == emaillist[j])
2251 { 2253 {
2252 foundUid = namelist[i].uid(); 2254 foundUid = namelist[i].uid();
2253 } 2255 }
2254 } 2256 }
2255 } 2257 }
2256 } 2258 }
2257 } 2259 }
2258 else 2260 else
2259 { 2261 {
2260 foundUid = uid; 2262 foundUid = uid;
2261 } 2263 }
2262 2264
2263 if (!foundUid.isEmpty()) 2265 if (!foundUid.isEmpty())
2264 { 2266 {
2265 2267
2266 // raise Ka/Pi if it is in the background 2268 // raise Ka/Pi if it is in the background
2267#ifndef DESKTOP_VERSION 2269#ifndef DESKTOP_VERSION
2268#ifndef KORG_NODCOP 2270#ifndef KORG_NODCOP
2269 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2271 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2270#endif 2272#endif
2271#endif 2273#endif
2272 2274
2273 mMainWindow->showMaximized(); 2275 mMainWindow->showMaximized();
2274 mMainWindow-> raise(); 2276 mMainWindow-> raise();
2275 2277
2276 mViewManager->setSelected( "", false); 2278 mViewManager->setSelected( "", false);
2277 mViewManager->refreshView( "" ); 2279 mViewManager->refreshView( "" );
2278 mViewManager->setSelected( foundUid, true ); 2280 mViewManager->setSelected( foundUid, true );
2279 mViewManager->refreshView( foundUid ); 2281 mViewManager->refreshView( foundUid );
2280 2282
2281 if ( !mMultipleViewsAtOnce ) 2283 if ( !mMultipleViewsAtOnce )
2282 { 2284 {
2283 setDetailsVisible( true ); 2285 setDetailsVisible( true );
2284 mActionDetails->setChecked(true); 2286 mActionDetails->setChecked(true);
2285 } 2287 }
2286 } 2288 }
2287} 2289}
2288 2290
2289void KABCore::whatsnew() 2291void KABCore::whatsnew()
2290{ 2292{
2291 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 2293 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
2292} 2294}
2293void KABCore::synchowto() 2295void KABCore::synchowto()
2294{ 2296{
2295 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 2297 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
2296} 2298}
2297 2299
2298void KABCore::faq() 2300void KABCore::faq()
2299{ 2301{
2300 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2302 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2301} 2303}
2302 2304
2303#include <libkcal/syncdefines.h> 2305#include <libkcal/syncdefines.h>
2304 2306
2305KABC::Addressee KABCore::getLastSyncAddressee() 2307KABC::Addressee KABCore::getLastSyncAddressee()
2306{ 2308{
2307 Addressee lse; 2309 Addressee lse;
2308 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2310 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2309 2311
2310 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2312 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2311 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2313 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2312 if (lse.isEmpty()) { 2314 if (lse.isEmpty()) {
2313 qDebug("Creating new last-syncAddressee "); 2315 qDebug("Creating new last-syncAddressee ");
2314 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2316 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2315 QString sum = ""; 2317 QString sum = "";
2316 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2318 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2317 sum = "E: "; 2319 sum = "E: ";
2318 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2320 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2319 lse.setRevision( mLastAddressbookSync ); 2321 lse.setRevision( mLastAddressbookSync );
2320 lse.setCategories( i18n("SyncEvent") ); 2322 lse.setCategories( i18n("SyncEvent") );
2321 mAddressBook->insertAddressee( lse ); 2323 mAddressBook->insertAddressee( lse );
2322 } 2324 }
2323 return lse; 2325 return lse;
2324} 2326}
2325int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2327int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2326{ 2328{
2327 2329
2328 //void setZaurusId(int id); 2330 //void setZaurusId(int id);
2329 // int zaurusId() const; 2331 // int zaurusId() const;
2330 // void setZaurusUid(int id); 2332 // void setZaurusUid(int id);
2331 // int zaurusUid() const; 2333 // int zaurusUid() const;
2332 // void setZaurusStat(int id); 2334 // void setZaurusStat(int id);
2333 // int zaurusStat() const; 2335 // int zaurusStat() const;
2334 // 0 equal 2336 // 0 equal
2335 // 1 take local 2337 // 1 take local
2336 // 2 take remote 2338 // 2 take remote
2337 // 3 cancel 2339 // 3 cancel
2338 QDateTime lastSync = mLastAddressbookSync; 2340 QDateTime lastSync = mLastAddressbookSync;
2339 QDateTime localMod = local->revision(); 2341 QDateTime localMod = local->revision();
2340 QDateTime remoteMod = remote->revision(); 2342 QDateTime remoteMod = remote->revision();
2341 2343
2342 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2344 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2343 2345
2344 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2346 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2345 bool remCh, locCh; 2347 bool remCh, locCh;
2346 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2348 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2347 2349
2348 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2350 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2349 locCh = ( localMod > mLastAddressbookSync ); 2351 locCh = ( localMod > mLastAddressbookSync );
2350 if ( !remCh && ! locCh ) { 2352 if ( !remCh && ! locCh ) {
2351 //qDebug("both not changed "); 2353 //qDebug("both not changed ");
2352 lastSync = localMod.addDays(1); 2354 lastSync = localMod.addDays(1);
2353 if ( mode <= SYNC_PREF_ASK ) 2355 if ( mode <= SYNC_PREF_ASK )
2354 return 0; 2356 return 0;
2355 } else { 2357 } else {
2356 if ( locCh ) { 2358 if ( locCh ) {
2357 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2359 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2358 lastSync = localMod.addDays( -1 ); 2360 lastSync = localMod.addDays( -1 );
2359 if ( !remCh ) 2361 if ( !remCh )
2360 remoteMod =( lastSync.addDays( -1 ) ); 2362 remoteMod =( lastSync.addDays( -1 ) );
2361 } else { 2363 } else {
2362 //qDebug(" not loc changed "); 2364 //qDebug(" not loc changed ");
2363 lastSync = localMod.addDays( 1 ); 2365 lastSync = localMod.addDays( 1 );
2364 if ( remCh ) 2366 if ( remCh )
2365 remoteMod =( lastSync.addDays( 1 ) ); 2367 remoteMod =( lastSync.addDays( 1 ) );
2366 2368
2367 } 2369 }
2368 } 2370 }
2369 full = true; 2371 full = true;
2370 if ( mode < SYNC_PREF_ASK ) 2372 if ( mode < SYNC_PREF_ASK )
2371 mode = SYNC_PREF_ASK; 2373 mode = SYNC_PREF_ASK;
2372 } else { 2374 } else {
2373 if ( localMod == remoteMod ) 2375 if ( localMod == remoteMod )
2374 return 0; 2376 return 0;
2375 2377
2376 } 2378 }
2377 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 2379 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
2378 2380
2379 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); 2381 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod);
2380 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 2382 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
2381 //full = true; //debug only 2383 //full = true; //debug only
2382 if ( full ) { 2384 if ( full ) {
2383 bool equ = ( (*local) == (*remote) ); 2385 bool equ = ( (*local) == (*remote) );
2384 if ( equ ) { 2386 if ( equ ) {
2385 //qDebug("equal "); 2387 //qDebug("equal ");
2386 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2388 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2387 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2389 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2388 } 2390 }
2389 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2391 if ( mode < SYNC_PREF_FORCE_LOCAL )
2390 return 0; 2392 return 0;
2391 2393
2392 }//else //debug only 2394 }//else //debug only
2393 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2395 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2394 } 2396 }
2395 int result; 2397 int result;
2396 bool localIsNew; 2398 bool localIsNew;
2397 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); 2399 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
2398 2400
2399 if ( full && mode < SYNC_PREF_NEWEST ) 2401 if ( full && mode < SYNC_PREF_NEWEST )
2400 mode = SYNC_PREF_ASK; 2402 mode = SYNC_PREF_ASK;
2401 2403
2402 switch( mode ) { 2404 switch( mode ) {
2403 case SYNC_PREF_LOCAL: 2405 case SYNC_PREF_LOCAL:
2404 if ( lastSync > remoteMod ) 2406 if ( lastSync > remoteMod )
2405 return 1; 2407 return 1;
2406 if ( lastSync > localMod ) 2408 if ( lastSync > localMod )
2407 return 2; 2409 return 2;
2408 return 1; 2410 return 1;
2409 break; 2411 break;
2410 case SYNC_PREF_REMOTE: 2412 case SYNC_PREF_REMOTE:
2411 if ( lastSync > remoteMod ) 2413 if ( lastSync > remoteMod )
2412 return 1; 2414 return 1;
2413 if ( lastSync > localMod ) 2415 if ( lastSync > localMod )
2414 return 2; 2416 return 2;
2415 return 2; 2417 return 2;
2416 break; 2418 break;
2417 case SYNC_PREF_NEWEST: 2419 case SYNC_PREF_NEWEST:
2418 if ( localMod > remoteMod ) 2420 if ( localMod > remoteMod )
2419 return 1; 2421 return 1;
2420 else 2422 else
2421 return 2; 2423 return 2;
2422 break; 2424 break;
2423 case SYNC_PREF_ASK: 2425 case SYNC_PREF_ASK:
2424 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2426 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2425 if ( lastSync > remoteMod ) 2427 if ( lastSync > remoteMod )
2426 return 1; 2428 return 1;
2427 if ( lastSync > localMod ) 2429 if ( lastSync > localMod )
2428 return 2; 2430 return 2;
2429 localIsNew = localMod >= remoteMod; 2431 localIsNew = localMod >= remoteMod;
2430 //qDebug("conflict! ************************************** "); 2432 //qDebug("conflict! ************************************** ");
2431 { 2433 {
2432 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2434 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2433 result = acd.executeD(localIsNew); 2435 result = acd.executeD(localIsNew);
2434 return result; 2436 return result;
2435 } 2437 }
2436 break; 2438 break;
2437 case SYNC_PREF_FORCE_LOCAL: 2439 case SYNC_PREF_FORCE_LOCAL:
2438 return 1; 2440 return 1;
2439 break; 2441 break;
2440 case SYNC_PREF_FORCE_REMOTE: 2442 case SYNC_PREF_FORCE_REMOTE:
2441 return 2; 2443 return 2;
2442 break; 2444 break;
2443 2445
2444 default: 2446 default:
2445 // SYNC_PREF_TAKE_BOTH not implemented 2447 // SYNC_PREF_TAKE_BOTH not implemented
2446 break; 2448 break;
2447 } 2449 }
2448 return 0; 2450 return 0;
2449} 2451}
2450 2452
2451 2453
2452bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2454bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2453{ 2455{
2454 bool syncOK = true; 2456 bool syncOK = true;
2455 int addedAddressee = 0; 2457 int addedAddressee = 0;
2456 int addedAddresseeR = 0; 2458 int addedAddresseeR = 0;
2457 int deletedAddresseeR = 0; 2459 int deletedAddresseeR = 0;
2458 int deletedAddresseeL = 0; 2460 int deletedAddresseeL = 0;
2459 int changedLocal = 0; 2461 int changedLocal = 0;
2460 int changedRemote = 0; 2462 int changedRemote = 0;
2461 2463
2462 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 2464 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2463 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2465 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2464 2466
2465 //QPtrList<Addressee> el = local->rawAddressees(); 2467 //QPtrList<Addressee> el = local->rawAddressees();
2466 Addressee addresseeR; 2468 Addressee addresseeR;
2467 QString uid; 2469 QString uid;
2468 int take; 2470 int take;
2469 Addressee addresseeL; 2471 Addressee addresseeL;
2470 Addressee addresseeRSync; 2472 Addressee addresseeRSync;
2471 Addressee addresseeLSync; 2473 Addressee addresseeLSync;
2472 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2474 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2473 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2475 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2474 bool fullDateRange = false; 2476 bool fullDateRange = false;
2475 local->resetTempSyncStat(); 2477 local->resetTempSyncStat();
2476 mLastAddressbookSync = QDateTime::currentDateTime(); 2478 mLastAddressbookSync = QDateTime::currentDateTime();
2477 QDateTime modifiedCalendar = mLastAddressbookSync;; 2479 QDateTime modifiedCalendar = mLastAddressbookSync;;
2478 addresseeLSync = getLastSyncAddressee(); 2480 addresseeLSync = getLastSyncAddressee();
2479 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2481 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
2480 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2482 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2481 if ( !addresseeR.isEmpty() ) { 2483 if ( !addresseeR.isEmpty() ) {
2482 addresseeRSync = addresseeR; 2484 addresseeRSync = addresseeR;
2483 remote->removeAddressee(addresseeR ); 2485 remote->removeAddressee(addresseeR );
2484 2486
2485 } else { 2487 } else {
2486 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2488 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2487 addresseeRSync = addresseeLSync ; 2489 addresseeRSync = addresseeLSync ;
2488 } else { 2490 } else {
2489 qDebug("FULLDATE 1"); 2491 qDebug("FULLDATE 1");
2490 fullDateRange = true; 2492 fullDateRange = true;
2491 Addressee newAdd; 2493 Addressee newAdd;
2492 addresseeRSync = newAdd; 2494 addresseeRSync = newAdd;
2493 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2495 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2494 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2496 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2495 addresseeRSync.setRevision( mLastAddressbookSync ); 2497 addresseeRSync.setRevision( mLastAddressbookSync );
2496 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2498 addresseeRSync.setCategories( i18n("SyncAddressee") );
2497 } 2499 }
2498 } 2500 }
2499 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2501 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2500 qDebug("FULLDATE 2"); 2502 qDebug("FULLDATE 2");
2501 fullDateRange = true; 2503 fullDateRange = true;
2502 } 2504 }
2503 if ( ! fullDateRange ) { 2505 if ( ! fullDateRange ) {
2504 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2506 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2505 2507
2506 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2508 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2507 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2509 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2508 fullDateRange = true; 2510 fullDateRange = true;
2509 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2511 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2510 } 2512 }
2511 } 2513 }
2512 // fullDateRange = true; // debug only! 2514 // fullDateRange = true; // debug only!
2513 if ( fullDateRange ) 2515 if ( fullDateRange )
2514 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2516 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2515 else 2517 else
2516 mLastAddressbookSync = addresseeLSync.revision(); 2518 mLastAddressbookSync = addresseeLSync.revision();
2517 // for resyncing if own file has changed 2519 // for resyncing if own file has changed
2518 // PENDING fixme later when implemented 2520 // PENDING fixme later when implemented
2519#if 0 2521#if 0
2520 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2522 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2521 mLastAddressbookSync = loadedFileVersion; 2523 mLastAddressbookSync = loadedFileVersion;
2522 qDebug("setting mLastAddressbookSync "); 2524 qDebug("setting mLastAddressbookSync ");
2523 } 2525 }
2524#endif 2526#endif
2525 2527
2526 //qDebug("*************************** "); 2528 //qDebug("*************************** ");
2527 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2529 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2528 QStringList er = remote->uidList(); 2530 QStringList er = remote->uidList();
2529 Addressee inR ;//= er.first(); 2531 Addressee inR ;//= er.first();
2530 Addressee inL; 2532 Addressee inL;
2531 2533
2532 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 2534 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
2533 2535
2534 int modulo = (er.count()/10)+1; 2536 int modulo = (er.count()/10)+1;
2535 int incCounter = 0; 2537 int incCounter = 0;
2536 while ( incCounter < er.count()) { 2538 while ( incCounter < er.count()) {
2537 if (syncManager->isProgressBarCanceled()) 2539 if (syncManager->isProgressBarCanceled())
2538 return false; 2540 return false;
2539 if ( incCounter % modulo == 0 ) 2541 if ( incCounter % modulo == 0 )
2540 syncManager->showProgressBar(incCounter); 2542 syncManager->showProgressBar(incCounter);
2541 2543
2542 uid = er[ incCounter ]; 2544 uid = er[ incCounter ];
2543 bool skipIncidence = false; 2545 bool skipIncidence = false;
2544 if ( uid.left(19) == QString("last-syncAddressee-") ) 2546 if ( uid.left(19) == QString("last-syncAddressee-") )
2545 skipIncidence = true; 2547 skipIncidence = true;
2546 QString idS,OidS; 2548 QString idS,OidS;
2547 qApp->processEvents(); 2549 qApp->processEvents();
2548 if ( !skipIncidence ) { 2550 if ( !skipIncidence ) {
2549 inL = local->findByUid( uid ); 2551 inL = local->findByUid( uid );
2550 inR = remote->findByUid( uid ); 2552 inR = remote->findByUid( uid );
2551 //inL.setResource( 0 ); 2553 //inL.setResource( 0 );
2552 //inR.setResource( 0 ); 2554 //inR.setResource( 0 );
2553 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2555 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2554 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2556 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2555 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { 2557 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) {
2556 //qDebug("take %d %s ", take, inL.summary().latin1()); 2558 //qDebug("take %d %s ", take, inL.summary().latin1());
2557 if ( take == 3 ) 2559 if ( take == 3 )
2558 return false; 2560 return false;
2559 if ( take == 1 ) {// take local 2561 if ( take == 1 ) {// take local
2560 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2562 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2561 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2563 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2562 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2564 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2563 local->insertAddressee( inL, false ); 2565 local->insertAddressee( inL, false );
2564 idS = inR.externalUID(); 2566 idS = inR.externalUID();
2565 OidS = inR.originalExternalUID(); 2567 OidS = inR.originalExternalUID();
2566 } 2568 }
2567 else 2569 else
2568 idS = inR.IDStr(); 2570 idS = inR.IDStr();
2569 remote->removeAddressee( inR ); 2571 remote->removeAddressee( inR );
2570 inR = inL; 2572 inR = inL;
2571 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2573 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2572 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2574 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2573 inR.setOriginalExternalUID( OidS ); 2575 inR.setOriginalExternalUID( OidS );
2574 inR.setExternalUID( idS ); 2576 inR.setExternalUID( idS );
2575 } else { 2577 } else {
2576 inR.setIDStr( idS ); 2578 inR.setIDStr( idS );
2577 } 2579 }
2578 inR.setResource( 0 ); 2580 inR.setResource( 0 );
2579 remote->insertAddressee( inR , false); 2581 remote->insertAddressee( inR , false);
2580 ++changedRemote; 2582 ++changedRemote;
2581 } else { // take == 2 take remote 2583 } else { // take == 2 take remote
2582 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2584 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2583 if ( inR.revision().date().year() < 2004 ) 2585 if ( inR.revision().date().year() < 2004 )
2584 inR.setRevision( modifiedCalendar ); 2586 inR.setRevision( modifiedCalendar );
2585 } 2587 }
2586 idS = inL.IDStr(); 2588 idS = inL.IDStr();
2587 local->removeAddressee( inL ); 2589 local->removeAddressee( inL );
2588 inL = inR; 2590 inL = inR;
2589 inL.setIDStr( idS ); 2591 inL.setIDStr( idS );
2590 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2592 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2591 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2593 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2592 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2594 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2593 } 2595 }
2594 inL.setResource( 0 ); 2596 inL.setResource( 0 );
2595 local->insertAddressee( inL , false ); 2597 local->insertAddressee( inL , false );
2596 ++changedLocal; 2598 ++changedLocal;
2597 } 2599 }
2598 } 2600 }
2599 } 2601 }
2600 } else { // no conflict 2602 } else { // no conflict
2601 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2603 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2602 QString des = addresseeLSync.note(); 2604 QString des = addresseeLSync.note();
2603 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2605 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2604 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2606 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2605 remote->insertAddressee( inR, false ); 2607 remote->insertAddressee( inR, false );
2606 ++deletedAddresseeR; 2608 ++deletedAddresseeR;
2607 } else { 2609 } else {
2608 inR.setRevision( modifiedCalendar ); 2610 inR.setRevision( modifiedCalendar );
2609 remote->insertAddressee( inR, false ); 2611 remote->insertAddressee( inR, false );
2610 inL = inR; 2612 inL = inR;
2611 inL.setResource( 0 ); 2613 inL.setResource( 0 );
2612 local->insertAddressee( inL , false); 2614 local->insertAddressee( inL , false);
2613 ++addedAddressee; 2615 ++addedAddressee;
2614 } 2616 }
2615 } else { 2617 } else {
2616 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 2618 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2617 inR.setRevision( modifiedCalendar ); 2619 inR.setRevision( modifiedCalendar );
2618 remote->insertAddressee( inR, false ); 2620 remote->insertAddressee( inR, false );
2619 inR.setResource( 0 ); 2621 inR.setResource( 0 );
2620 local->insertAddressee( inR, false ); 2622 local->insertAddressee( inR, false );
2621 ++addedAddressee; 2623 ++addedAddressee;
2622 } else { 2624 } else {
2623 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2625 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2624 remote->removeAddressee( inR ); 2626 remote->removeAddressee( inR );
2625 ++deletedAddresseeR; 2627 ++deletedAddresseeR;
2626 } 2628 }
2627 } 2629 }
2628 } 2630 }
2629 } 2631 }
2630 ++incCounter; 2632 ++incCounter;
2631 } 2633 }
2632 er.clear(); 2634 er.clear();
2633 QStringList el = local->uidList(); 2635 QStringList el = local->uidList();
2634 modulo = (el.count()/10)+1; 2636 modulo = (el.count()/10)+1;
2635 2637
2636 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 2638 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
2637 incCounter = 0; 2639 incCounter = 0;
2638 while ( incCounter < el.count()) { 2640 while ( incCounter < el.count()) {
2639 qApp->processEvents(); 2641 qApp->processEvents();
2640 if (syncManager->isProgressBarCanceled()) 2642 if (syncManager->isProgressBarCanceled())
2641 return false; 2643 return false;
2642 if ( incCounter % modulo == 0 ) 2644 if ( incCounter % modulo == 0 )
2643 syncManager->showProgressBar(incCounter); 2645 syncManager->showProgressBar(incCounter);
2644 uid = el[ incCounter ]; 2646 uid = el[ incCounter ];
2645 bool skipIncidence = false; 2647 bool skipIncidence = false;
2646 if ( uid.left(19) == QString("last-syncAddressee-") ) 2648 if ( uid.left(19) == QString("last-syncAddressee-") )
2647 skipIncidence = true; 2649 skipIncidence = true;
2648 if ( !skipIncidence ) { 2650 if ( !skipIncidence ) {
2649 inL = local->findByUid( uid ); 2651 inL = local->findByUid( uid );
2650 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2652 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2651 inR = remote->findByUid( uid ); 2653 inR = remote->findByUid( uid );
2652 if ( inR.isEmpty() ) { 2654 if ( inR.isEmpty() ) {
2653 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2655 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2654 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 2656 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
2655 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2657 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2656 local->removeAddressee( inL ); 2658 local->removeAddressee( inL );
2657 ++deletedAddresseeL; 2659 ++deletedAddresseeL;
2658 } else { 2660 } else {
2659 if ( ! syncManager->mWriteBackExistingOnly ) { 2661 if ( ! syncManager->mWriteBackExistingOnly ) {
2660 inL.removeID(mCurrentSyncDevice ); 2662 inL.removeID(mCurrentSyncDevice );
2661 ++addedAddresseeR; 2663 ++addedAddresseeR;
2662 inL.setRevision( modifiedCalendar ); 2664 inL.setRevision( modifiedCalendar );
2663 local->insertAddressee( inL, false ); 2665 local->insertAddressee( inL, false );
2664 inR = inL; 2666 inR = inL;
2665 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 2667 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
2666 inR.setResource( 0 ); 2668 inR.setResource( 0 );
2667 remote->insertAddressee( inR, false ); 2669 remote->insertAddressee( inR, false );
2668 } 2670 }
2669 } 2671 }
2670 } else { 2672 } else {
2671 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 2673 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
2672 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2674 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2673 local->removeAddressee( inL ); 2675 local->removeAddressee( inL );
2674 ++deletedAddresseeL; 2676 ++deletedAddresseeL;
2675 } else { 2677 } else {
2676 if ( ! syncManager->mWriteBackExistingOnly ) { 2678 if ( ! syncManager->mWriteBackExistingOnly ) {
2677 ++addedAddresseeR; 2679 ++addedAddresseeR;
2678 inL.setRevision( modifiedCalendar ); 2680 inL.setRevision( modifiedCalendar );
2679 local->insertAddressee( inL, false ); 2681 local->insertAddressee( inL, false );
2680 inR = inL; 2682 inR = inL;
2681 inR.setResource( 0 ); 2683 inR.setResource( 0 );
2682 remote->insertAddressee( inR, false ); 2684 remote->insertAddressee( inR, false );
2683 } 2685 }
2684 } 2686 }
2685 } 2687 }
2686 } 2688 }
2687 } 2689 }
2688 } 2690 }
2689 ++incCounter; 2691 ++incCounter;
2690 } 2692 }
2691 el.clear(); 2693 el.clear();
2692 syncManager->hideProgressBar(); 2694 syncManager->hideProgressBar();
2693 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 2695 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
2694 // get rid of micro seconds 2696 // get rid of micro seconds
2695 QTime t = mLastAddressbookSync.time(); 2697 QTime t = mLastAddressbookSync.time();
2696 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 2698 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
2697 addresseeLSync.setRevision( mLastAddressbookSync ); 2699 addresseeLSync.setRevision( mLastAddressbookSync );
2698 addresseeRSync.setRevision( mLastAddressbookSync ); 2700 addresseeRSync.setRevision( mLastAddressbookSync );
2699 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 2701 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
2700 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 2702 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
2701 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 2703 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
2702 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 2704 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
2703 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 2705 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
2704 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 2706 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
2705 addresseeRSync.setNote( "" ) ; 2707 addresseeRSync.setNote( "" ) ;
2706 addresseeLSync.setNote( "" ); 2708 addresseeLSync.setNote( "" );
2707 2709
2708 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 2710 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
2709 remote->insertAddressee( addresseeRSync, false ); 2711 remote->insertAddressee( addresseeRSync, false );
2710 local->insertAddressee( addresseeLSync, false ); 2712 local->insertAddressee( addresseeLSync, false );
2711 QString mes; 2713 QString mes;
2712 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"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); 2714 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"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR );
2713 if ( syncManager->mShowSyncSummary ) { 2715 if ( syncManager->mShowSyncSummary ) {
2714 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); 2716 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") );
2715 } 2717 }
2716 qDebug( mes ); 2718 qDebug( mes );
2717 return syncOK; 2719 return syncOK;
2718} 2720}
2719 2721
2720 2722
2721//this is a overwritten callbackmethods from the syncinterface 2723//this is a overwritten callbackmethods from the syncinterface
2722bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 2724bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
2723{ 2725{
2724 2726
2725 //pending prepare addresseeview for output 2727 //pending prepare addresseeview for output
2726 //pending detect, if remote file has REV field. if not switch to external sync 2728 //pending detect, if remote file has REV field. if not switch to external sync
2727 mGlobalSyncMode = SYNC_MODE_NORMAL; 2729 mGlobalSyncMode = SYNC_MODE_NORMAL;
2728 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2730 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2729 2731
2730 AddressBook abLocal(filename,"syncContact"); 2732 AddressBook abLocal(filename,"syncContact");
2731 bool syncOK = false; 2733 bool syncOK = false;
2732 if ( abLocal.load() ) { 2734 if ( abLocal.load() ) {
2733 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 2735 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
2734 bool external = false; 2736 bool external = false;
2735 bool isXML = false; 2737 bool isXML = false;
2736 if ( filename.right(4) == ".xml") { 2738 if ( filename.right(4) == ".xml") {
2737 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2739 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2738 isXML = true; 2740 isXML = true;
2739 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 2741 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
2740 } else { 2742 } else {
2741 external = !manager->mIsKapiFile; 2743 external = !manager->mIsKapiFile;
2742 if ( external ) { 2744 if ( external ) {
2743 qDebug("Setting vcf mode to external "); 2745 qDebug("Setting vcf mode to external ");
2744 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2746 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2745 AddressBook::Iterator it; 2747 AddressBook::Iterator it;
2746 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2748 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2747 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 2749 (*it).setID( mCurrentSyncDevice, (*it).uid() );
2748 (*it).computeCsum( mCurrentSyncDevice ); 2750 (*it).computeCsum( mCurrentSyncDevice );
2749 } 2751 }
2750 } 2752 }
2751 } 2753 }
2752 //AddressBook::Iterator it; 2754 //AddressBook::Iterator it;
2753 //QStringList vcards; 2755 //QStringList vcards;
2754 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2756 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2755 // qDebug("Name %s ", (*it).familyName().latin1()); 2757 // qDebug("Name %s ", (*it).familyName().latin1());
2756 //} 2758 //}
2757 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 2759 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
2758 if ( syncOK ) { 2760 if ( syncOK ) {
2759 if ( syncManager->mWriteBackFile ) 2761 if ( syncManager->mWriteBackFile )
2760 { 2762 {
2761 if ( external ) 2763 if ( external )
2762 abLocal.removeSyncAddressees( !isXML); 2764 abLocal.removeSyncAddressees( !isXML);
2763 qDebug("Saving remote AB "); 2765 qDebug("Saving remote AB ");
2764 if ( ! abLocal.saveAB()) 2766 if ( ! abLocal.saveAB())
2765 qDebug("Error writing back AB to file "); 2767 qDebug("Error writing back AB to file ");
2766 if ( isXML ) { 2768 if ( isXML ) {
2767 // afterwrite processing 2769 // afterwrite processing
2768 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2770 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2769 } 2771 }
2770 } 2772 }
2771 } 2773 }
2772 setModified(); 2774 setModified();
2773 2775
2774 } 2776 }
2775 if ( syncOK ) 2777 if ( syncOK )
2776 mViewManager->refreshView(); 2778 mViewManager->refreshView();
2777 return syncOK; 2779 return syncOK;
2778 2780
2779} 2781}
2780 2782
2781 2783
2782//this is a overwritten callbackmethods from the syncinterface 2784//this is a overwritten callbackmethods from the syncinterface
2783bool KABCore::syncExternal(KSyncManager* manager, QString resource) 2785bool KABCore::syncExternal(KSyncManager* manager, QString resource)
2784{ 2786{
2785 if ( resource == "phone" ) 2787 if ( resource == "phone" )
2786 return syncPhone(); 2788 return syncPhone();
2787 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2789 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2788 2790
2789 AddressBook abLocal( resource,"syncContact"); 2791 AddressBook abLocal( resource,"syncContact");
2790 bool syncOK = false; 2792 bool syncOK = false;
2791 if ( abLocal.load() ) { 2793 if ( abLocal.load() ) {
2792 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2794 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
2793 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2795 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2794 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 2796 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
2795 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2797 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2796 if ( syncOK ) { 2798 if ( syncOK ) {
2797 if ( syncManager->mWriteBackFile ) { 2799 if ( syncManager->mWriteBackFile ) {
2798 abLocal.removeSyncAddressees( false ); 2800 abLocal.removeSyncAddressees( false );
2799 abLocal.saveAB(); 2801 abLocal.saveAB();
2800 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2802 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2801 } 2803 }
2802 } 2804 }
2803 setModified(); 2805 setModified();
2804 } 2806 }
2805 if ( syncOK ) 2807 if ( syncOK )
2806 mViewManager->refreshView(); 2808 mViewManager->refreshView();
2807 return syncOK; 2809 return syncOK;
2808 2810
2809} 2811}
2810void KABCore::message( QString m ) 2812void KABCore::message( QString m )
2811{ 2813{
2812 2814
2813 topLevelWidget()->setCaption( m ); 2815 topLevelWidget()->setCaption( m );
2814 QTimer::singleShot( 15000, this , SLOT ( setCaptionBack())); 2816 QTimer::singleShot( 15000, this , SLOT ( setCaptionBack()));
2815} 2817}
2816bool KABCore::syncPhone() 2818bool KABCore::syncPhone()
2817{ 2819{
2818 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2820 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2819 QString fileName; 2821 QString fileName;
2820#ifdef _WIN32_ 2822#ifdef _WIN32_
2821 fileName = locateLocal("tmp", "phonefile.vcf"); 2823 fileName = locateLocal("tmp", "phonefile.vcf");
2822#else 2824#else
2823 fileName = "/tmp/phonefile.vcf"; 2825 fileName = "/tmp/phonefile.vcf";
2824#endif 2826#endif
2825 if ( !PhoneAccess::readFromPhone( fileName) ) { 2827 if ( !PhoneAccess::readFromPhone( fileName) ) {
2826 message(i18n("Phone access failed!")); 2828 message(i18n("Phone access failed!"));
2827 return false; 2829 return false;
2828 } 2830 }
2829 AddressBook abLocal( fileName,"syncContact"); 2831 AddressBook abLocal( fileName,"syncContact");
2830 bool syncOK = false; 2832 bool syncOK = false;
2831 { 2833 {
2832 abLocal.importFromFile( fileName ); 2834 abLocal.importFromFile( fileName );
2833 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2835 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
2834 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2836 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2835 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 2837 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
2836 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 2838 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
2837 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2839 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2838 if ( syncOK ) { 2840 if ( syncOK ) {
2839 if ( syncManager->mWriteBackFile ) { 2841 if ( syncManager->mWriteBackFile ) {
2840 abLocal.removeSyncAddressees( true ); 2842 abLocal.removeSyncAddressees( true );
2841 abLocal.saveABphone( fileName ); 2843 abLocal.saveABphone( fileName );
2842 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 2844 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
2843 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 2845 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
2844 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2846 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2845 } 2847 }
2846 } 2848 }
2847 setModified(); 2849 setModified();
2848 } 2850 }
2849 if ( syncOK ) 2851 if ( syncOK )
2850 mViewManager->refreshView(); 2852 mViewManager->refreshView();
2851 return syncOK; 2853 return syncOK;
2852} 2854}
2853void KABCore::getFile( bool success ) 2855void KABCore::getFile( bool success )
2854{ 2856{
2855 if ( ! success ) { 2857 if ( ! success ) {
2856 message( i18n("Error receiving file. Nothing changed!") ); 2858 message( i18n("Error receiving file. Nothing changed!") );
2857 return; 2859 return;
2858 } 2860 }
2859 mAddressBook->importFromFile( sentSyncFile() , false, true ); 2861 mAddressBook->importFromFile( sentSyncFile() , false, true );
2860 message( i18n("Pi-Sync successful!") ); 2862 message( i18n("Pi-Sync successful!") );
2861 mViewManager->refreshView(); 2863 mViewManager->refreshView();
2862} 2864}
2863void KABCore::syncFileRequest() 2865void KABCore::syncFileRequest()
2864{ 2866{
2865 mAddressBook->export2File( sentSyncFile() ); 2867 mAddressBook->export2File( sentSyncFile() );
2866} 2868}
2867QString KABCore::sentSyncFile() 2869QString KABCore::sentSyncFile()
2868{ 2870{
2869#ifdef _WIN32_ 2871#ifdef _WIN32_
2870 return locateLocal( "tmp", "copysyncab.vcf" ); 2872 return locateLocal( "tmp", "copysyncab.vcf" );
2871#else 2873#else
2872 return QString( "/tmp/copysyncab.vcf" ); 2874 return QString( "/tmp/copysyncab.vcf" );
2873#endif 2875#endif
2874} 2876}
2875 2877
2876void KABCore::setCaptionBack() 2878void KABCore::setCaptionBack()
2877{ 2879{
2878 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 2880 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
2879} 2881}
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 1f2c6da..3e0a27d 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -278,3445 +278,3453 @@ void CalendarView::init()
278 SLOT( updateView() ) ); 278 SLOT( updateView() ) );
279 } else { 279 } else {
280 mResourceView = 0; 280 mResourceView = 0;
281 } 281 }
282#endif 282#endif
283 QWidget *rightBox = new QWidget( mPanner ); 283 QWidget *rightBox = new QWidget( mPanner );
284 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 284 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
285 285
286 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 286 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
287 rightLayout->addWidget( mNavigatorBar ); 287 rightLayout->addWidget( mNavigatorBar );
288 288
289 mRightFrame = new QWidgetStack( rightBox ); 289 mRightFrame = new QWidgetStack( rightBox );
290 rightLayout->addWidget( mRightFrame, 1 ); 290 rightLayout->addWidget( mRightFrame, 1 );
291 291
292 mLeftFrame = mLeftSplitter; 292 mLeftFrame = mLeftSplitter;
293#else 293#else
294 QWidget *mainBox = new QWidget( this ); 294 QWidget *mainBox = new QWidget( this );
295 QWidget *leftFrame = new QWidget( mainBox ); 295 QWidget *leftFrame = new QWidget( mainBox );
296 296
297 QBoxLayout * mainBoxLayout; 297 QBoxLayout * mainBoxLayout;
298 QBoxLayout * leftFrameLayout; 298 QBoxLayout * leftFrameLayout;
299 if ( KOPrefs::instance()->mVerticalScreen ) { 299 if ( KOPrefs::instance()->mVerticalScreen ) {
300 mainBoxLayout = new QVBoxLayout(mainBox); 300 mainBoxLayout = new QVBoxLayout(mainBox);
301 leftFrameLayout = new QHBoxLayout(leftFrame ); 301 leftFrameLayout = new QHBoxLayout(leftFrame );
302 } else { 302 } else {
303 mainBoxLayout = new QHBoxLayout(mainBox); 303 mainBoxLayout = new QHBoxLayout(mainBox);
304 leftFrameLayout = new QVBoxLayout(leftFrame ); 304 leftFrameLayout = new QVBoxLayout(leftFrame );
305 } 305 }
306 topLayout->addWidget( mainBox ); 306 topLayout->addWidget( mainBox );
307 mainBoxLayout->addWidget (leftFrame); 307 mainBoxLayout->addWidget (leftFrame);
308 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, 308 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE,
309 "CalendarView::DateNavigator", QDate::currentDate()); 309 "CalendarView::DateNavigator", QDate::currentDate());
310 // mDateNavigator->blockSignals( true ); 310 // mDateNavigator->blockSignals( true );
311 leftFrameLayout->addWidget( mDateNavigator ); 311 leftFrameLayout->addWidget( mDateNavigator );
312 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); 312 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView");
313 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); 313 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall");
314 314
315 if ( QApplication::desktop()->width() < 480 ) { 315 if ( QApplication::desktop()->width() < 480 ) {
316 leftFrameLayout->addWidget(mFilterView); 316 leftFrameLayout->addWidget(mFilterView);
317 leftFrameLayout->addWidget(mTodoList, 2 ); 317 leftFrameLayout->addWidget(mTodoList, 2 );
318 318
319 } else { 319 } else {
320 leftFrameLayout->addWidget(mTodoList,2 ); 320 leftFrameLayout->addWidget(mTodoList,2 );
321 leftFrameLayout->addWidget(mFilterView ); 321 leftFrameLayout->addWidget(mFilterView );
322 } 322 }
323 mFilterView->hide(); 323 mFilterView->hide();
324 QWidget *rightBox = new QWidget( mainBox ); 324 QWidget *rightBox = new QWidget( mainBox );
325 mainBoxLayout->addWidget ( rightBox, 10 ); 325 mainBoxLayout->addWidget ( rightBox, 10 );
326 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 326 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
327 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 327 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
328 mRightFrame = new QWidgetStack( rightBox ); 328 mRightFrame = new QWidgetStack( rightBox );
329 rightLayout->addWidget( mNavigatorBar ); 329 rightLayout->addWidget( mNavigatorBar );
330 rightLayout->addWidget( mRightFrame, 10 ); 330 rightLayout->addWidget( mRightFrame, 10 );
331 331
332 mLeftFrame = leftFrame; 332 mLeftFrame = leftFrame;
333 if ( KOPrefs::instance()->mVerticalScreen ) { 333 if ( KOPrefs::instance()->mVerticalScreen ) {
334 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 334 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
335 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 335 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
336 } else { 336 } else {
337 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 337 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
338 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 338 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
339 } 339 }
340 340
341 //qDebug("Calendarview Size %d %d ", width(), height()); 341 //qDebug("Calendarview Size %d %d ", width(), height());
342#endif 342#endif
343 343
344 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 344 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
345 SLOT( showDates( const KCal::DateList & ) ) ); 345 SLOT( showDates( const KCal::DateList & ) ) );
346 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 346 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
347 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 347 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
348 348
349 connect( mNavigatorBar, SIGNAL( goPrevYear() ), 349 connect( mNavigatorBar, SIGNAL( goPrevYear() ),
350 mNavigator, SLOT( selectPreviousYear() ) ); 350 mNavigator, SLOT( selectPreviousYear() ) );
351 connect( mNavigatorBar, SIGNAL( goNextYear() ), 351 connect( mNavigatorBar, SIGNAL( goNextYear() ),
352 mNavigator, SLOT( selectNextYear() ) ); 352 mNavigator, SLOT( selectNextYear() ) );
353 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), 353 connect( mNavigatorBar, SIGNAL( goPrevMonth() ),
354 mNavigator, SLOT( selectPreviousMonth() ) ); 354 mNavigator, SLOT( selectPreviousMonth() ) );
355 connect( mNavigatorBar, SIGNAL( goNextMonth() ), 355 connect( mNavigatorBar, SIGNAL( goNextMonth() ),
356 mNavigator, SLOT( selectNextMonth() ) ); 356 mNavigator, SLOT( selectNextMonth() ) );
357 357
358 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 358 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
359 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); 359 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) );
360 360
361 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 361 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
362 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 362 mNavigator, SLOT( selectWeek( const QDate & ) ) );
363 363
364 connect( mDateNavigator, SIGNAL( goPrevYear() ), 364 connect( mDateNavigator, SIGNAL( goPrevYear() ),
365 mNavigator, SLOT( selectPreviousYear() ) ); 365 mNavigator, SLOT( selectPreviousYear() ) );
366 connect( mDateNavigator, SIGNAL( goNextYear() ), 366 connect( mDateNavigator, SIGNAL( goNextYear() ),
367 mNavigator, SLOT( selectNextYear() ) ); 367 mNavigator, SLOT( selectNextYear() ) );
368 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 368 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
369 mNavigator, SLOT( selectPreviousMonth() ) ); 369 mNavigator, SLOT( selectPreviousMonth() ) );
370 connect( mDateNavigator, SIGNAL( goNextMonth() ), 370 connect( mDateNavigator, SIGNAL( goNextMonth() ),
371 mNavigator, SLOT( selectNextMonth() ) ); 371 mNavigator, SLOT( selectNextMonth() ) );
372 372
373 connect( mDateNavigator, SIGNAL( goPrevious() ), 373 connect( mDateNavigator, SIGNAL( goPrevious() ),
374 mNavigator, SLOT( selectPrevious() ) ); 374 mNavigator, SLOT( selectPrevious() ) );
375 connect( mDateNavigator, SIGNAL( goNext() ), 375 connect( mDateNavigator, SIGNAL( goNext() ),
376 mNavigator, SLOT( selectNext() ) ); 376 mNavigator, SLOT( selectNext() ) );
377 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 377 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
378 mNavigator, SLOT( slotMonthSelect( int ) ) ); 378 mNavigator, SLOT( slotMonthSelect( int ) ) );
379 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), 379 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ),
380 mNavigator, SLOT( slotMonthSelect( int ) ) ); 380 mNavigator, SLOT( slotMonthSelect( int ) ) );
381 381
382 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 382 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
383 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 383 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
384 384
385 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 385 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
386 SLOT( eventAdded( Event *) ) ); 386 SLOT( eventAdded( Event *) ) );
387 387
388 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 388 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
389 389
390 connect( this, SIGNAL( configChanged() ), 390 connect( this, SIGNAL( configChanged() ),
391 mDateNavigator, SLOT( updateConfig() ) ); 391 mDateNavigator, SLOT( updateConfig() ) );
392 392
393 connect( mTodoList, SIGNAL( newTodoSignal() ), 393 connect( mTodoList, SIGNAL( newTodoSignal() ),
394 SLOT( newTodo() ) ); 394 SLOT( newTodo() ) );
395 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 395 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
396 SLOT( newSubTodo( Todo * ) ) ); 396 SLOT( newSubTodo( Todo * ) ) );
397 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 397 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
398 SLOT( editTodo( Todo * ) ) ); 398 SLOT( editTodo( Todo * ) ) );
399 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 399 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
400 SLOT( showTodo( Todo *) ) ); 400 SLOT( showTodo( Todo *) ) );
401 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 401 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
402 SLOT( deleteTodo( Todo *) ) ); 402 SLOT( deleteTodo( Todo *) ) );
403 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 403 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
404 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 404 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
405 SLOT( purgeCompleted() ) ); 405 SLOT( purgeCompleted() ) );
406 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 406 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
407 SIGNAL( todoModified( Todo *, int ) ) ); 407 SIGNAL( todoModified( Todo *, int ) ) );
408 408
409 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 409 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
410 this, SLOT ( cloneIncidence( Incidence * ) ) ); 410 this, SLOT ( cloneIncidence( Incidence * ) ) );
411 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 411 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
412 this, SLOT (cancelIncidence( Incidence * ) ) ); 412 this, SLOT (cancelIncidence( Incidence * ) ) );
413 413
414 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 414 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
415 this, SLOT ( moveIncidence( Incidence * ) ) ); 415 this, SLOT ( moveIncidence( Incidence * ) ) );
416 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 416 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
417 this, SLOT ( beamIncidence( Incidence * ) ) ); 417 this, SLOT ( beamIncidence( Incidence * ) ) );
418 418
419 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 419 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
420 this, SLOT ( todo_unsub( Todo * ) ) ); 420 this, SLOT ( todo_unsub( Todo * ) ) );
421 421
422 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 422 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
423 SLOT( updateTodo( Todo *, int ) ) ); 423 SLOT( updateTodo( Todo *, int ) ) );
424 connect( this, SIGNAL( todoModified( Todo *, int )), this, 424 connect( this, SIGNAL( todoModified( Todo *, int )), this,
425 SLOT( changeTodoDisplay( Todo *, int ) ) ); 425 SLOT( changeTodoDisplay( Todo *, int ) ) );
426 426
427 427
428 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 428 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
429 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 429 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
430 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 430 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
431 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 431 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
432 432
433 433
434 434
435 435
436 436
437 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 437 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
438 SLOT(checkClipboard())); 438 SLOT(checkClipboard()));
439 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 439 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
440 SLOT( processTodoListSelection( Incidence * ) ) ); 440 SLOT( processTodoListSelection( Incidence * ) ) );
441 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 441 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
442 442
443 // kdDebug() << "CalendarView::CalendarView() done" << endl; 443 // kdDebug() << "CalendarView::CalendarView() done" << endl;
444 444
445 mDateFrame = new QVBox(0,0,WType_Popup); 445 mDateFrame = new QVBox(0,0,WType_Popup);
446 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 446 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
447 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 447 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
448 mDateFrame->setLineWidth(3); 448 mDateFrame->setLineWidth(3);
449 mDateFrame->hide(); 449 mDateFrame->hide();
450 mDateFrame->setCaption( i18n( "Pick a date to display")); 450 mDateFrame->setCaption( i18n( "Pick a date to display"));
451 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 451 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
452 452
453 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 453 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
454 454
455 mEventEditor = mDialogManager->getEventEditor(); 455 mEventEditor = mDialogManager->getEventEditor();
456 mTodoEditor = mDialogManager->getTodoEditor(); 456 mTodoEditor = mDialogManager->getTodoEditor();
457 457
458 mFlagEditDescription = false; 458 mFlagEditDescription = false;
459 459
460 mSuspendTimer = new QTimer( this ); 460 mSuspendTimer = new QTimer( this );
461 mAlarmTimer = new QTimer( this ); 461 mAlarmTimer = new QTimer( this );
462 mRecheckAlarmTimer = new QTimer( this ); 462 mRecheckAlarmTimer = new QTimer( this );
463 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 463 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
464 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 464 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
465 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 465 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
466 mAlarmDialog = new AlarmDialog( this ); 466 mAlarmDialog = new AlarmDialog( this );
467 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 467 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
468 mAlarmDialog->setServerNotification( false ); 468 mAlarmDialog->setServerNotification( false );
469 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 469 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
470 470
471 471
472#ifndef DESKTOP_VERSION 472#ifndef DESKTOP_VERSION
473//US listen for arriving address resultsets 473//US listen for arriving address resultsets
474 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 474 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
475 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 475 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
476#endif 476#endif
477 477
478} 478}
479 479
480 480
481CalendarView::~CalendarView() 481CalendarView::~CalendarView()
482{ 482{
483 // kdDebug() << "~CalendarView()" << endl; 483 // kdDebug() << "~CalendarView()" << endl;
484 //qDebug("CalendarView::~CalendarView() "); 484 //qDebug("CalendarView::~CalendarView() ");
485 delete mDialogManager; 485 delete mDialogManager;
486 delete mViewManager; 486 delete mViewManager;
487 delete mStorage; 487 delete mStorage;
488 delete mDateFrame ; 488 delete mDateFrame ;
489 delete beamDialog; 489 delete beamDialog;
490 //kdDebug() << "~CalendarView() done" << endl; 490 //kdDebug() << "~CalendarView() done" << endl;
491} 491}
492void CalendarView::timerAlarm() 492void CalendarView::timerAlarm()
493{ 493{
494 //qDebug("CalendarView::timerAlarm() "); 494 //qDebug("CalendarView::timerAlarm() ");
495 computeAlarm(mAlarmNotification ); 495 computeAlarm(mAlarmNotification );
496} 496}
497 497
498void CalendarView::suspendAlarm() 498void CalendarView::suspendAlarm()
499{ 499{
500 //qDebug(" CalendarView::suspendAlarm() "); 500 //qDebug(" CalendarView::suspendAlarm() ");
501 computeAlarm(mSuspendAlarmNotification ); 501 computeAlarm(mSuspendAlarmNotification );
502 502
503} 503}
504 504
505void CalendarView::startAlarm( QString mess , QString filename) 505void CalendarView::startAlarm( QString mess , QString filename)
506{ 506{
507 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 507 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
508 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 508 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
509 509
510} 510}
511 511
512void CalendarView::checkNextTimerAlarm() 512void CalendarView::checkNextTimerAlarm()
513{ 513{
514 mCalendar->checkAlarmForIncidence( 0, true ); 514 mCalendar->checkAlarmForIncidence( 0, true );
515} 515}
516 516
517void CalendarView::computeAlarm( QString msg ) 517void CalendarView::computeAlarm( QString msg )
518{ 518{
519 519
520 QString mess = msg; 520 QString mess = msg;
521 QString mAlarmMessage = mess.mid( 9 ); 521 QString mAlarmMessage = mess.mid( 9 );
522 QString filename = MainWindow::resourcePath(); 522 QString filename = MainWindow::resourcePath();
523 filename += "koalarm.wav"; 523 filename += "koalarm.wav";
524 QString tempfilename; 524 QString tempfilename;
525 if ( mess.left( 13 ) == "suspend_alarm") { 525 if ( mess.left( 13 ) == "suspend_alarm") {
526 bool error = false; 526 bool error = false;
527 int len = mess.mid( 13 ).find("+++"); 527 int len = mess.mid( 13 ).find("+++");
528 if ( len < 2 ) 528 if ( len < 2 )
529 error = true; 529 error = true;
530 else { 530 else {
531 tempfilename = mess.mid( 13, len ); 531 tempfilename = mess.mid( 13, len );
532 if ( !QFile::exists( tempfilename ) ) 532 if ( !QFile::exists( tempfilename ) )
533 error = true; 533 error = true;
534 } 534 }
535 if ( ! error ) { 535 if ( ! error ) {
536 filename = tempfilename; 536 filename = tempfilename;
537 } 537 }
538 mAlarmMessage = mess.mid( 13+len+3 ); 538 mAlarmMessage = mess.mid( 13+len+3 );
539 //qDebug("suspend file %s ",tempfilename.latin1() ); 539 //qDebug("suspend file %s ",tempfilename.latin1() );
540 startAlarm( mAlarmMessage, filename); 540 startAlarm( mAlarmMessage, filename);
541 return; 541 return;
542 } 542 }
543 if ( mess.left( 11 ) == "timer_alarm") { 543 if ( mess.left( 11 ) == "timer_alarm") {
544 //mTimerTime = 0; 544 //mTimerTime = 0;
545 startAlarm( mess.mid( 11 ), filename ); 545 startAlarm( mess.mid( 11 ), filename );
546 return; 546 return;
547 } 547 }
548 if ( mess.left( 10 ) == "proc_alarm") { 548 if ( mess.left( 10 ) == "proc_alarm") {
549 bool error = false; 549 bool error = false;
550 int len = mess.mid( 10 ).find("+++"); 550 int len = mess.mid( 10 ).find("+++");
551 if ( len < 2 ) 551 if ( len < 2 )
552 error = true; 552 error = true;
553 else { 553 else {
554 tempfilename = mess.mid( 10, len ); 554 tempfilename = mess.mid( 10, len );
555 if ( !QFile::exists( tempfilename ) ) 555 if ( !QFile::exists( tempfilename ) )
556 error = true; 556 error = true;
557 } 557 }
558 if ( error ) { 558 if ( error ) {
559 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 559 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
560 mAlarmMessage += mess.mid( 10+len+3+9 ); 560 mAlarmMessage += mess.mid( 10+len+3+9 );
561 } else { 561 } else {
562 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 562 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
563 //qDebug("-----system command %s ",tempfilename.latin1() ); 563 //qDebug("-----system command %s ",tempfilename.latin1() );
564#ifndef _WIN32_ 564#ifndef _WIN32_
565 if ( vfork () == 0 ) { 565 if ( vfork () == 0 ) {
566 execl ( tempfilename.latin1(), 0 ); 566 execl ( tempfilename.latin1(), 0 );
567 return; 567 return;
568 } 568 }
569#else 569#else
570 QProcess* p = new QProcess(); 570 QProcess* p = new QProcess();
571 p->addArgument( tempfilename.latin1() ); 571 p->addArgument( tempfilename.latin1() );
572 p->start(); 572 p->start();
573 return; 573 return;
574#endif 574#endif
575 575
576 return; 576 return;
577 } 577 }
578 578
579 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 579 //qDebug("+++++++system command %s ",tempfilename.latin1() );
580 } 580 }
581 if ( mess.left( 11 ) == "audio_alarm") { 581 if ( mess.left( 11 ) == "audio_alarm") {
582 bool error = false; 582 bool error = false;
583 int len = mess.mid( 11 ).find("+++"); 583 int len = mess.mid( 11 ).find("+++");
584 if ( len < 2 ) 584 if ( len < 2 )
585 error = true; 585 error = true;
586 else { 586 else {
587 tempfilename = mess.mid( 11, len ); 587 tempfilename = mess.mid( 11, len );
588 if ( !QFile::exists( tempfilename ) ) 588 if ( !QFile::exists( tempfilename ) )
589 error = true; 589 error = true;
590 } 590 }
591 if ( ! error ) { 591 if ( ! error ) {
592 filename = tempfilename; 592 filename = tempfilename;
593 } 593 }
594 mAlarmMessage = mess.mid( 11+len+3+9 ); 594 mAlarmMessage = mess.mid( 11+len+3+9 );
595 //qDebug("audio file command %s ",tempfilename.latin1() ); 595 //qDebug("audio file command %s ",tempfilename.latin1() );
596 } 596 }
597 if ( mess.left( 9 ) == "cal_alarm") { 597 if ( mess.left( 9 ) == "cal_alarm") {
598 mAlarmMessage = mess.mid( 9 ) ; 598 mAlarmMessage = mess.mid( 9 ) ;
599 } 599 }
600 600
601 startAlarm( mAlarmMessage, filename ); 601 startAlarm( mAlarmMessage, filename );
602 602
603 603
604} 604}
605 605
606void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 606void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
607{ 607{
608 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 608 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
609 609
610 mSuspendAlarmNotification = noti; 610 mSuspendAlarmNotification = noti;
611 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 611 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
612 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 612 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
613 mSuspendTimer->start( ms , true ); 613 mSuspendTimer->start( ms , true );
614 614
615} 615}
616 616
617void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 617void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
618{ 618{
619 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 619 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
620 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 620 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
621#ifndef DESKTOP_VERSION 621#ifndef DESKTOP_VERSION
622 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 622 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
623#endif 623#endif
624 return; 624 return;
625 } 625 }
626 int maxSec; 626 int maxSec;
627 //maxSec = 5; //testing only 627 //maxSec = 5; //testing only
628 maxSec = 86400+3600; // one day+1hour 628 maxSec = 86400+3600; // one day+1hour
629 mAlarmNotification = noti; 629 mAlarmNotification = noti;
630 int sec = QDateTime::currentDateTime().secsTo( qdt ); 630 int sec = QDateTime::currentDateTime().secsTo( qdt );
631 if ( sec > maxSec ) { 631 if ( sec > maxSec ) {
632 mRecheckAlarmTimer->start( maxSec * 1000 ); 632 mRecheckAlarmTimer->start( maxSec * 1000 );
633 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 633 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
634 return; 634 return;
635 } else { 635 } else {
636 mRecheckAlarmTimer->stop(); 636 mRecheckAlarmTimer->stop();
637 } 637 }
638 //qDebug("Alarm timer started with secs: %d ", sec); 638 //qDebug("Alarm timer started with secs: %d ", sec);
639 mAlarmTimer->start( sec *1000 , true ); 639 mAlarmTimer->start( sec *1000 , true );
640 640
641} 641}
642// called by mRecheckAlarmTimer to get next alarm 642// called by mRecheckAlarmTimer to get next alarm
643// we need this, because a QTimer has only a max range of 25 days 643// we need this, because a QTimer has only a max range of 25 days
644void CalendarView::recheckTimerAlarm() 644void CalendarView::recheckTimerAlarm()
645{ 645{
646 mAlarmTimer->stop(); 646 mAlarmTimer->stop();
647 mRecheckAlarmTimer->stop(); 647 mRecheckAlarmTimer->stop();
648 mCalendar->checkAlarmForIncidence( 0, true ); 648 mCalendar->checkAlarmForIncidence( 0, true );
649} 649}
650void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 650void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
651{ 651{
652 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 652 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
653 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 653 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
654#ifndef DESKTOP_VERSION 654#ifndef DESKTOP_VERSION
655 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 655 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
656#endif 656#endif
657 return; 657 return;
658 } 658 }
659 mAlarmTimer->stop(); 659 mAlarmTimer->stop();
660} 660}
661void CalendarView::selectWeekNum ( int num ) 661void CalendarView::selectWeekNum ( int num )
662{ 662{
663 dateNavigator()->selectWeek( num ); 663 dateNavigator()->selectWeek( num );
664 mViewManager->showWeekView(); 664 mViewManager->showWeekView();
665} 665}
666KOViewManager *CalendarView::viewManager() 666KOViewManager *CalendarView::viewManager()
667{ 667{
668 return mViewManager; 668 return mViewManager;
669} 669}
670 670
671KODialogManager *CalendarView::dialogManager() 671KODialogManager *CalendarView::dialogManager()
672{ 672{
673 return mDialogManager; 673 return mDialogManager;
674} 674}
675 675
676QDate CalendarView::startDate() 676QDate CalendarView::startDate()
677{ 677{
678 DateList dates = mNavigator->selectedDates(); 678 DateList dates = mNavigator->selectedDates();
679 679
680 return dates.first(); 680 return dates.first();
681} 681}
682 682
683QDate CalendarView::endDate() 683QDate CalendarView::endDate()
684{ 684{
685 DateList dates = mNavigator->selectedDates(); 685 DateList dates = mNavigator->selectedDates();
686 686
687 return dates.last(); 687 return dates.last();
688} 688}
689 689
690 690
691void CalendarView::createPrinter() 691void CalendarView::createPrinter()
692{ 692{
693#ifndef KORG_NOPRINTER 693#ifndef KORG_NOPRINTER
694 if (!mCalPrinter) { 694 if (!mCalPrinter) {
695 mCalPrinter = new CalPrinter(this, mCalendar); 695 mCalPrinter = new CalPrinter(this, mCalendar);
696 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 696 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
697 } 697 }
698#endif 698#endif
699} 699}
700 700
701 701
702//KOPrefs::instance()->mWriteBackFile 702//KOPrefs::instance()->mWriteBackFile
703//KOPrefs::instance()->mWriteBackExistingOnly 703//KOPrefs::instance()->mWriteBackExistingOnly
704 704
705// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 705// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
706// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 706// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
707// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 707// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
708// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 708// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
709// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 709// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
710// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 710// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
711 711
712int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 712int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
713{ 713{
714 714
715 //void setZaurusId(int id); 715 //void setZaurusId(int id);
716 // int zaurusId() const; 716 // int zaurusId() const;
717 // void setZaurusUid(int id); 717 // void setZaurusUid(int id);
718 // int zaurusUid() const; 718 // int zaurusUid() const;
719 // void setZaurusStat(int id); 719 // void setZaurusStat(int id);
720 // int zaurusStat() const; 720 // int zaurusStat() const;
721 // 0 equal 721 // 0 equal
722 // 1 take local 722 // 1 take local
723 // 2 take remote 723 // 2 take remote
724 // 3 cancel 724 // 3 cancel
725 QDateTime lastSync = mLastCalendarSync; 725 QDateTime lastSync = mLastCalendarSync;
726 QDateTime localMod = local->lastModified(); 726 QDateTime localMod = local->lastModified();
727 QDateTime remoteMod = remote->lastModified(); 727 QDateTime remoteMod = remote->lastModified();
728 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 728 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
729 bool remCh, locCh; 729 bool remCh, locCh;
730 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 730 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
731 //if ( remCh ) 731 //if ( remCh )
732 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 732 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
733 locCh = ( localMod > mLastCalendarSync ); 733 locCh = ( localMod > mLastCalendarSync );
734 if ( !remCh && ! locCh ) { 734 if ( !remCh && ! locCh ) {
735 //qDebug("both not changed "); 735 //qDebug("both not changed ");
736 lastSync = localMod.addDays(1); 736 lastSync = localMod.addDays(1);
737 if ( mode <= SYNC_PREF_ASK ) 737 if ( mode <= SYNC_PREF_ASK )
738 return 0; 738 return 0;
739 } else { 739 } else {
740 if ( locCh ) { 740 if ( locCh ) {
741 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 741 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
742 lastSync = localMod.addDays( -1 ); 742 lastSync = localMod.addDays( -1 );
743 if ( !remCh ) 743 if ( !remCh )
744 remoteMod = ( lastSync.addDays( -1 ) ); 744 remoteMod = ( lastSync.addDays( -1 ) );
745 } else { 745 } else {
746 //qDebug(" not loc changed "); 746 //qDebug(" not loc changed ");
747 lastSync = localMod.addDays( 1 ); 747 lastSync = localMod.addDays( 1 );
748 if ( remCh ) 748 if ( remCh )
749 remoteMod =( lastSync.addDays( 1 ) ); 749 remoteMod =( lastSync.addDays( 1 ) );
750 750
751 } 751 }
752 } 752 }
753 full = true; 753 full = true;
754 if ( mode < SYNC_PREF_ASK ) 754 if ( mode < SYNC_PREF_ASK )
755 mode = SYNC_PREF_ASK; 755 mode = SYNC_PREF_ASK;
756 } else { 756 } else {
757 if ( localMod == remoteMod ) 757 if ( localMod == remoteMod )
758 if ( local->revision() == remote->revision() ) 758 if ( local->revision() == remote->revision() )
759 return 0; 759 return 0;
760 760
761 } 761 }
762 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 762 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
763 763
764 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 764 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
765 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 765 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
766 //full = true; //debug only 766 //full = true; //debug only
767 if ( full ) { 767 if ( full ) {
768 bool equ = false; 768 bool equ = false;
769 if ( local->type() == "Event" ) { 769 if ( local->type() == "Event" ) {
770 equ = (*((Event*) local) == *((Event*) remote)); 770 equ = (*((Event*) local) == *((Event*) remote));
771 } 771 }
772 else if ( local->type() =="Todo" ) 772 else if ( local->type() =="Todo" )
773 equ = (*((Todo*) local) == (*(Todo*) remote)); 773 equ = (*((Todo*) local) == (*(Todo*) remote));
774 else if ( local->type() =="Journal" ) 774 else if ( local->type() =="Journal" )
775 equ = (*((Journal*) local) == *((Journal*) remote)); 775 equ = (*((Journal*) local) == *((Journal*) remote));
776 if ( equ ) { 776 if ( equ ) {
777 //qDebug("equal "); 777 //qDebug("equal ");
778 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 778 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
779 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 779 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
780 } 780 }
781 if ( mode < SYNC_PREF_FORCE_LOCAL ) 781 if ( mode < SYNC_PREF_FORCE_LOCAL )
782 return 0; 782 return 0;
783 783
784 }//else //debug only 784 }//else //debug only
785 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 785 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
786 } 786 }
787 int result; 787 int result;
788 bool localIsNew; 788 bool localIsNew;
789 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); 789 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() );
790 790
791 if ( full && mode < SYNC_PREF_NEWEST ) 791 if ( full && mode < SYNC_PREF_NEWEST )
792 mode = SYNC_PREF_ASK; 792 mode = SYNC_PREF_ASK;
793 793
794 switch( mode ) { 794 switch( mode ) {
795 case SYNC_PREF_LOCAL: 795 case SYNC_PREF_LOCAL:
796 if ( lastSync > remoteMod ) 796 if ( lastSync > remoteMod )
797 return 1; 797 return 1;
798 if ( lastSync > localMod ) 798 if ( lastSync > localMod )
799 return 2; 799 return 2;
800 return 1; 800 return 1;
801 break; 801 break;
802 case SYNC_PREF_REMOTE: 802 case SYNC_PREF_REMOTE:
803 if ( lastSync > remoteMod ) 803 if ( lastSync > remoteMod )
804 return 1; 804 return 1;
805 if ( lastSync > localMod ) 805 if ( lastSync > localMod )
806 return 2; 806 return 2;
807 return 2; 807 return 2;
808 break; 808 break;
809 case SYNC_PREF_NEWEST: 809 case SYNC_PREF_NEWEST:
810 if ( localMod > remoteMod ) 810 if ( localMod > remoteMod )
811 return 1; 811 return 1;
812 else 812 else
813 return 2; 813 return 2;
814 break; 814 break;
815 case SYNC_PREF_ASK: 815 case SYNC_PREF_ASK:
816 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 816 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
817 if ( lastSync > remoteMod ) 817 if ( lastSync > remoteMod )
818 return 1; 818 return 1;
819 if ( lastSync > localMod ) 819 if ( lastSync > localMod )
820 return 2; 820 return 2;
821 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 821 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
822 localIsNew = localMod >= remoteMod; 822 localIsNew = localMod >= remoteMod;
823 if ( localIsNew ) 823 if ( localIsNew )
824 getEventViewerDialog()->setColorMode( 1 ); 824 getEventViewerDialog()->setColorMode( 1 );
825 else 825 else
826 getEventViewerDialog()->setColorMode( 2 ); 826 getEventViewerDialog()->setColorMode( 2 );
827 getEventViewerDialog()->setIncidence(local); 827 getEventViewerDialog()->setIncidence(local);
828 if ( localIsNew ) 828 if ( localIsNew )
829 getEventViewerDialog()->setColorMode( 2 ); 829 getEventViewerDialog()->setColorMode( 2 );
830 else 830 else
831 getEventViewerDialog()->setColorMode( 1 ); 831 getEventViewerDialog()->setColorMode( 1 );
832 getEventViewerDialog()->addIncidence(remote); 832 getEventViewerDialog()->addIncidence(remote);
833 getEventViewerDialog()->setColorMode( 0 ); 833 getEventViewerDialog()->setColorMode( 0 );
834 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 834 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
835 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 835 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
836 getEventViewerDialog()->showMe(); 836 getEventViewerDialog()->showMe();
837 result = getEventViewerDialog()->executeS( localIsNew ); 837 result = getEventViewerDialog()->executeS( localIsNew );
838 return result; 838 return result;
839 839
840 break; 840 break;
841 case SYNC_PREF_FORCE_LOCAL: 841 case SYNC_PREF_FORCE_LOCAL:
842 return 1; 842 return 1;
843 break; 843 break;
844 case SYNC_PREF_FORCE_REMOTE: 844 case SYNC_PREF_FORCE_REMOTE:
845 return 2; 845 return 2;
846 break; 846 break;
847 847
848 default: 848 default:
849 // SYNC_PREF_TAKE_BOTH not implemented 849 // SYNC_PREF_TAKE_BOTH not implemented
850 break; 850 break;
851 } 851 }
852 return 0; 852 return 0;
853} 853}
854Event* CalendarView::getLastSyncEvent() 854Event* CalendarView::getLastSyncEvent()
855{ 855{
856 Event* lse; 856 Event* lse;
857 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 857 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
858 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 858 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
859 if (!lse) { 859 if (!lse) {
860 lse = new Event(); 860 lse = new Event();
861 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 861 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
862 QString sum = ""; 862 QString sum = "";
863 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 863 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
864 sum = "E: "; 864 sum = "E: ";
865 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 865 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
866 lse->setDtStart( mLastCalendarSync ); 866 lse->setDtStart( mLastCalendarSync );
867 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 867 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
868 lse->setCategories( i18n("SyncEvent") ); 868 lse->setCategories( i18n("SyncEvent") );
869 lse->setReadOnly( true ); 869 lse->setReadOnly( true );
870 mCalendar->addEvent( lse ); 870 mCalendar->addEvent( lse );
871 } 871 }
872 872
873 return lse; 873 return lse;
874 874
875} 875}
876 876
877// we check, if the to delete event has a id for a profile 877// we check, if the to delete event has a id for a profile
878// if yes, we set this id in the profile to delete 878// if yes, we set this id in the profile to delete
879void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 879void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
880{ 880{
881 if ( lastSync.count() == 0 ) { 881 if ( lastSync.count() == 0 ) {
882 //qDebug(" lastSync.count() == 0"); 882 //qDebug(" lastSync.count() == 0");
883 return; 883 return;
884 } 884 }
885 if ( toDelete->type() == "Journal" ) 885 if ( toDelete->type() == "Journal" )
886 return; 886 return;
887 887
888 Event* eve = lastSync.first(); 888 Event* eve = lastSync.first();
889 889
890 while ( eve ) { 890 while ( eve ) {
891 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 891 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
892 if ( !id.isEmpty() ) { 892 if ( !id.isEmpty() ) {
893 QString des = eve->description(); 893 QString des = eve->description();
894 QString pref = "e"; 894 QString pref = "e";
895 if ( toDelete->type() == "Todo" ) 895 if ( toDelete->type() == "Todo" )
896 pref = "t"; 896 pref = "t";
897 des += pref+ id + ","; 897 des += pref+ id + ",";
898 eve->setReadOnly( false ); 898 eve->setReadOnly( false );
899 eve->setDescription( des ); 899 eve->setDescription( des );
900 //qDebug("setdes %s ", des.latin1()); 900 //qDebug("setdes %s ", des.latin1());
901 eve->setReadOnly( true ); 901 eve->setReadOnly( true );
902 } 902 }
903 eve = lastSync.next(); 903 eve = lastSync.next();
904 } 904 }
905 905
906} 906}
907void CalendarView::checkExternalId( Incidence * inc ) 907void CalendarView::checkExternalId( Incidence * inc )
908{ 908{
909 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 909 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
910 checkExternSyncEvent( lastSync, inc ); 910 checkExternSyncEvent( lastSync, inc );
911 911
912} 912}
913bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 913bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
914{ 914{
915 bool syncOK = true; 915 bool syncOK = true;
916 int addedEvent = 0; 916 int addedEvent = 0;
917 int addedEventR = 0; 917 int addedEventR = 0;
918 int deletedEventR = 0; 918 int deletedEventR = 0;
919 int deletedEventL = 0; 919 int deletedEventL = 0;
920 int changedLocal = 0; 920 int changedLocal = 0;
921 int changedRemote = 0; 921 int changedRemote = 0;
922 //QPtrList<Event> el = local->rawEvents(); 922 //QPtrList<Event> el = local->rawEvents();
923 Event* eventR; 923 Event* eventR;
924 QString uid; 924 QString uid;
925 int take; 925 int take;
926 Event* eventL; 926 Event* eventL;
927 Event* eventRSync; 927 Event* eventRSync;
928 Event* eventLSync; 928 Event* eventLSync;
929 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 929 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
930 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 930 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
931 bool fullDateRange = false; 931 bool fullDateRange = false;
932 local->resetTempSyncStat(); 932 local->resetTempSyncStat();
933 mLastCalendarSync = QDateTime::currentDateTime(); 933 mLastCalendarSync = QDateTime::currentDateTime();
934 QDateTime modifiedCalendar = mLastCalendarSync;; 934 QDateTime modifiedCalendar = mLastCalendarSync;;
935 eventLSync = getLastSyncEvent(); 935 eventLSync = getLastSyncEvent();
936 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 936 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
937 if ( eventR ) { 937 if ( eventR ) {
938 eventRSync = (Event*) eventR->clone(); 938 eventRSync = (Event*) eventR->clone();
939 remote->deleteEvent(eventR ); 939 remote->deleteEvent(eventR );
940 940
941 } else { 941 } else {
942 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 942 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
943 eventRSync = (Event*)eventLSync->clone(); 943 eventRSync = (Event*)eventLSync->clone();
944 } else { 944 } else {
945 fullDateRange = true; 945 fullDateRange = true;
946 eventRSync = new Event(); 946 eventRSync = new Event();
947 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 947 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
948 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 948 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
949 eventRSync->setDtStart( mLastCalendarSync ); 949 eventRSync->setDtStart( mLastCalendarSync );
950 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 950 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
951 eventRSync->setCategories( i18n("SyncEvent") ); 951 eventRSync->setCategories( i18n("SyncEvent") );
952 } 952 }
953 } 953 }
954 if ( eventLSync->dtStart() == mLastCalendarSync ) 954 if ( eventLSync->dtStart() == mLastCalendarSync )
955 fullDateRange = true; 955 fullDateRange = true;
956 956
957 if ( ! fullDateRange ) { 957 if ( ! fullDateRange ) {
958 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 958 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
959 959
960 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 960 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
961 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 961 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
962 fullDateRange = true; 962 fullDateRange = true;
963 } 963 }
964 } 964 }
965 if ( fullDateRange ) 965 if ( fullDateRange )
966 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 966 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
967 else 967 else
968 mLastCalendarSync = eventLSync->dtStart(); 968 mLastCalendarSync = eventLSync->dtStart();
969 // for resyncing if own file has changed 969 // for resyncing if own file has changed
970 if ( mCurrentSyncDevice == "deleteaftersync" ) { 970 if ( mCurrentSyncDevice == "deleteaftersync" ) {
971 mLastCalendarSync = loadedFileVersion; 971 mLastCalendarSync = loadedFileVersion;
972 qDebug("setting mLastCalendarSync "); 972 qDebug("setting mLastCalendarSync ");
973 } 973 }
974 //qDebug("*************************** "); 974 //qDebug("*************************** ");
975 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); 975 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() );
976 QPtrList<Incidence> er = remote->rawIncidences(); 976 QPtrList<Incidence> er = remote->rawIncidences();
977 Incidence* inR = er.first(); 977 Incidence* inR = er.first();
978 Incidence* inL; 978 Incidence* inL;
979 QProgressBar bar( er.count(),0 ); 979 QProgressBar bar( er.count(),0 );
980 bar.setCaption (i18n("Syncing - close to abort!") ); 980 bar.setCaption (i18n("Syncing - close to abort!") );
981 981
982 int w = 300; 982 int w = 300;
983 if ( QApplication::desktop()->width() < 320 ) 983 if ( QApplication::desktop()->width() < 320 )
984 w = 220; 984 w = 220;
985 int h = bar.sizeHint().height() ; 985 int h = bar.sizeHint().height() ;
986 int dw = QApplication::desktop()->width(); 986 int dw = QApplication::desktop()->width();
987 int dh = QApplication::desktop()->height(); 987 int dh = QApplication::desktop()->height();
988 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 988 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
989 bar.show(); 989 bar.show();
990 int modulo = (er.count()/10)+1; 990 int modulo = (er.count()/10)+1;
991 int incCounter = 0; 991 int incCounter = 0;
992 while ( inR ) { 992 while ( inR ) {
993 if ( ! bar.isVisible() ) 993 if ( ! bar.isVisible() )
994 return false; 994 return false;
995 if ( incCounter % modulo == 0 ) 995 if ( incCounter % modulo == 0 )
996 bar.setProgress( incCounter ); 996 bar.setProgress( incCounter );
997 ++incCounter; 997 ++incCounter;
998 uid = inR->uid(); 998 uid = inR->uid();
999 bool skipIncidence = false; 999 bool skipIncidence = false;
1000 if ( uid.left(15) == QString("last-syncEvent-") ) 1000 if ( uid.left(15) == QString("last-syncEvent-") )
1001 skipIncidence = true; 1001 skipIncidence = true;
1002 QString idS; 1002 QString idS;
1003 qApp->processEvents(); 1003 qApp->processEvents();
1004 if ( !skipIncidence ) { 1004 if ( !skipIncidence ) {
1005 inL = local->incidence( uid ); 1005 inL = local->incidence( uid );
1006 if ( inL ) { // maybe conflict - same uid in both calendars 1006 if ( inL ) { // maybe conflict - same uid in both calendars
1007 int maxrev = inL->revision(); 1007 int maxrev = inL->revision();
1008 if ( maxrev < inR->revision() ) 1008 if ( maxrev < inR->revision() )
1009 maxrev = inR->revision(); 1009 maxrev = inR->revision();
1010 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1010 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1011 //qDebug("take %d %s ", take, inL->summary().latin1()); 1011 //qDebug("take %d %s ", take, inL->summary().latin1());
1012 if ( take == 3 ) 1012 if ( take == 3 )
1013 return false; 1013 return false;
1014 if ( take == 1 ) {// take local 1014 if ( take == 1 ) {// take local
1015 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1015 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1016 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1016 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1017 else 1017 else
1018 idS = inR->IDStr(); 1018 idS = inR->IDStr();
1019 remote->deleteIncidence( inR ); 1019 remote->deleteIncidence( inR );
1020 if ( inL->revision() < maxrev ) 1020 if ( inL->revision() < maxrev )
1021 inL->setRevision( maxrev ); 1021 inL->setRevision( maxrev );
1022 inR = inL->clone(); 1022 inR = inL->clone();
1023 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1023 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1024 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1024 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1025 inR->setIDStr( idS ); 1025 inR->setIDStr( idS );
1026 remote->addIncidence( inR ); 1026 remote->addIncidence( inR );
1027 ++changedRemote; 1027 ++changedRemote;
1028 } else { 1028 } else {
1029 if ( inR->revision() < maxrev ) 1029 if ( inR->revision() < maxrev )
1030 inR->setRevision( maxrev ); 1030 inR->setRevision( maxrev );
1031 idS = inL->IDStr(); 1031 idS = inL->IDStr();
1032 local->deleteIncidence( inL ); 1032 local->deleteIncidence( inL );
1033 inL = inR->clone(); 1033 inL = inR->clone();
1034 inL->setIDStr( idS ); 1034 inL->setIDStr( idS );
1035 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1035 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1036 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1036 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1037 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1037 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1038 } 1038 }
1039 local->addIncidence( inL ); 1039 local->addIncidence( inL );
1040 ++changedLocal; 1040 ++changedLocal;
1041 } 1041 }
1042 } 1042 }
1043 } else { // no conflict 1043 } else { // no conflict
1044 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1044 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1045 QString des = eventLSync->description(); 1045 QString des = eventLSync->description();
1046 QString pref = "e"; 1046 QString pref = "e";
1047 if ( inR->type() == "Todo" ) 1047 if ( inR->type() == "Todo" )
1048 pref = "t"; 1048 pref = "t";
1049 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1049 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1050 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1050 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1051 //remote->deleteIncidence( inR ); 1051 //remote->deleteIncidence( inR );
1052 ++deletedEventR; 1052 ++deletedEventR;
1053 } else { 1053 } else {
1054 inR->setLastModified( modifiedCalendar ); 1054 inR->setLastModified( modifiedCalendar );
1055 inL = inR->clone(); 1055 inL = inR->clone();
1056 local->addIncidence( inL ); 1056 local->addIncidence( inL );
1057 ++addedEvent; 1057 ++addedEvent;
1058 } 1058 }
1059 } else { 1059 } else {
1060 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1060 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1061 inR->setLastModified( modifiedCalendar ); 1061 inR->setLastModified( modifiedCalendar );
1062 local->addIncidence( inR->clone() ); 1062 local->addIncidence( inR->clone() );
1063 ++addedEvent; 1063 ++addedEvent;
1064 } else { 1064 } else {
1065 checkExternSyncEvent(eventRSyncSharp, inR); 1065 checkExternSyncEvent(eventRSyncSharp, inR);
1066 remote->deleteIncidence( inR ); 1066 remote->deleteIncidence( inR );
1067 ++deletedEventR; 1067 ++deletedEventR;
1068 } 1068 }
1069 } 1069 }
1070 } 1070 }
1071 } 1071 }
1072 inR = er.next(); 1072 inR = er.next();
1073 } 1073 }
1074 QPtrList<Incidence> el = local->rawIncidences(); 1074 QPtrList<Incidence> el = local->rawIncidences();
1075 inL = el.first(); 1075 inL = el.first();
1076 modulo = (el.count()/10)+1; 1076 modulo = (el.count()/10)+1;
1077 bar.setCaption (i18n("Add / remove events") ); 1077 bar.setCaption (i18n("Add / remove events") );
1078 bar.setTotalSteps ( el.count() ) ; 1078 bar.setTotalSteps ( el.count() ) ;
1079 bar.show(); 1079 bar.show();
1080 incCounter = 0; 1080 incCounter = 0;
1081 1081
1082 while ( inL ) { 1082 while ( inL ) {
1083 1083
1084 qApp->processEvents(); 1084 qApp->processEvents();
1085 if ( ! bar.isVisible() ) 1085 if ( ! bar.isVisible() )
1086 return false; 1086 return false;
1087 if ( incCounter % modulo == 0 ) 1087 if ( incCounter % modulo == 0 )
1088 bar.setProgress( incCounter ); 1088 bar.setProgress( incCounter );
1089 ++incCounter; 1089 ++incCounter;
1090 uid = inL->uid(); 1090 uid = inL->uid();
1091 bool skipIncidence = false; 1091 bool skipIncidence = false;
1092 if ( uid.left(15) == QString("last-syncEvent-") ) 1092 if ( uid.left(15) == QString("last-syncEvent-") )
1093 skipIncidence = true; 1093 skipIncidence = true;
1094 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1094 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1095 skipIncidence = true; 1095 skipIncidence = true;
1096 if ( !skipIncidence ) { 1096 if ( !skipIncidence ) {
1097 inR = remote->incidence( uid ); 1097 inR = remote->incidence( uid );
1098 if ( ! inR ) { 1098 if ( ! inR ) {
1099 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1099 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1100 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1100 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1101 checkExternSyncEvent(eventLSyncSharp, inL); 1101 checkExternSyncEvent(eventLSyncSharp, inL);
1102 local->deleteIncidence( inL ); 1102 local->deleteIncidence( inL );
1103 ++deletedEventL; 1103 ++deletedEventL;
1104 } else { 1104 } else {
1105 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1105 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1106 inL->removeID(mCurrentSyncDevice ); 1106 inL->removeID(mCurrentSyncDevice );
1107 ++addedEventR; 1107 ++addedEventR;
1108 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1108 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1109 inL->setLastModified( modifiedCalendar ); 1109 inL->setLastModified( modifiedCalendar );
1110 inR = inL->clone(); 1110 inR = inL->clone();
1111 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1111 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1112 remote->addIncidence( inR ); 1112 remote->addIncidence( inR );
1113 } 1113 }
1114 } 1114 }
1115 } else { 1115 } else {
1116 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1116 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1117 checkExternSyncEvent(eventLSyncSharp, inL); 1117 checkExternSyncEvent(eventLSyncSharp, inL);
1118 local->deleteIncidence( inL ); 1118 local->deleteIncidence( inL );
1119 ++deletedEventL; 1119 ++deletedEventL;
1120 } else { 1120 } else {
1121 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1121 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1122 ++addedEventR; 1122 ++addedEventR;
1123 inL->setLastModified( modifiedCalendar ); 1123 inL->setLastModified( modifiedCalendar );
1124 remote->addIncidence( inL->clone() ); 1124 remote->addIncidence( inL->clone() );
1125 } 1125 }
1126 } 1126 }
1127 } 1127 }
1128 } 1128 }
1129 } 1129 }
1130 inL = el.next(); 1130 inL = el.next();
1131 } 1131 }
1132 int delFut = 0; 1132 int delFut = 0;
1133 if ( mSyncManager->mWriteBackInFuture ) { 1133 if ( mSyncManager->mWriteBackInFuture ) {
1134 er = remote->rawIncidences(); 1134 er = remote->rawIncidences();
1135 inR = er.first(); 1135 inR = er.first();
1136 QDateTime dt; 1136 QDateTime dt;
1137 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1137 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1138 QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); 1138 QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 );
1139 while ( inR ) { 1139 while ( inR ) {
1140 if ( inR->type() == "Todo" ) { 1140 if ( inR->type() == "Todo" ) {
1141 Todo * t = (Todo*)inR; 1141 Todo * t = (Todo*)inR;
1142 if ( t->hasDueDate() ) 1142 if ( t->hasDueDate() )
1143 dt = t->dtDue(); 1143 dt = t->dtDue();
1144 else 1144 else
1145 dt = cur.addSecs( 62 ); 1145 dt = cur.addSecs( 62 );
1146 } 1146 }
1147 else if (inR->type() == "Event" ) { 1147 else if (inR->type() == "Event" ) {
1148 bool ok; 1148 bool ok;
1149 dt = inR->getNextOccurence( cur, &ok ); 1149 dt = inR->getNextOccurence( cur, &ok );
1150 if ( !ok ) 1150 if ( !ok )
1151 dt = cur.addSecs( -62 ); 1151 dt = cur.addSecs( -62 );
1152 } 1152 }
1153 else 1153 else
1154 dt = inR->dtStart(); 1154 dt = inR->dtStart();
1155 if ( dt < cur || dt > end ) { 1155 if ( dt < cur || dt > end ) {
1156 remote->deleteIncidence( inR ); 1156 remote->deleteIncidence( inR );
1157 ++delFut; 1157 ++delFut;
1158 } 1158 }
1159 inR = er.next(); 1159 inR = er.next();
1160 } 1160 }
1161 } 1161 }
1162 bar.hide(); 1162 bar.hide();
1163 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1163 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1164 eventLSync->setReadOnly( false ); 1164 eventLSync->setReadOnly( false );
1165 eventLSync->setDtStart( mLastCalendarSync ); 1165 eventLSync->setDtStart( mLastCalendarSync );
1166 eventRSync->setDtStart( mLastCalendarSync ); 1166 eventRSync->setDtStart( mLastCalendarSync );
1167 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1167 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1168 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1168 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1169 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1169 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1170 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1170 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1171 eventLSync->setReadOnly( true ); 1171 eventLSync->setReadOnly( true );
1172 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 1172 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
1173 remote->addEvent( eventRSync ); 1173 remote->addEvent( eventRSync );
1174 QString mes; 1174 QString mes;
1175 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 ); 1175 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 );
1176 QString delmess; 1176 QString delmess;
1177 if ( delFut ) { 1177 if ( delFut ) {
1178 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, mSyncManager->mWriteBackInFuture ); 1178 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, mSyncManager->mWriteBackInFuture );
1179 mes += delmess; 1179 mes += delmess;
1180 } 1180 }
1181 if ( mSyncManager->mShowSyncSummary ) { 1181 if ( mSyncManager->mShowSyncSummary ) {
1182 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); 1182 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
1183 } 1183 }
1184 qDebug( mes ); 1184 qDebug( mes );
1185 mCalendar->checkAlarmForIncidence( 0, true ); 1185 mCalendar->checkAlarmForIncidence( 0, true );
1186 return syncOK; 1186 return syncOK;
1187} 1187}
1188 1188
1189void CalendarView::setSyncDevice( QString s ) 1189void CalendarView::setSyncDevice( QString s )
1190{ 1190{
1191 mCurrentSyncDevice= s; 1191 mCurrentSyncDevice= s;
1192} 1192}
1193void CalendarView::setSyncName( QString s ) 1193void CalendarView::setSyncName( QString s )
1194{ 1194{
1195 mCurrentSyncName= s; 1195 mCurrentSyncName= s;
1196} 1196}
1197bool CalendarView::syncCalendar(QString filename, int mode) 1197bool CalendarView::syncCalendar(QString filename, int mode)
1198{ 1198{
1199 //qDebug("syncCalendar %s ", filename.latin1()); 1199 //qDebug("syncCalendar %s ", filename.latin1());
1200 mGlobalSyncMode = SYNC_MODE_NORMAL; 1200 mGlobalSyncMode = SYNC_MODE_NORMAL;
1201 CalendarLocal* calendar = new CalendarLocal(); 1201 CalendarLocal* calendar = new CalendarLocal();
1202 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1202 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1203 FileStorage* storage = new FileStorage( calendar ); 1203 FileStorage* storage = new FileStorage( calendar );
1204 bool syncOK = false; 1204 bool syncOK = false;
1205 storage->setFileName( filename ); 1205 storage->setFileName( filename );
1206 // qDebug("loading ... "); 1206 // qDebug("loading ... ");
1207 if ( storage->load() ) { 1207 if ( storage->load() ) {
1208 getEventViewerDialog()->setSyncMode( true ); 1208 getEventViewerDialog()->setSyncMode( true );
1209 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1209 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1210 getEventViewerDialog()->setSyncMode( false ); 1210 getEventViewerDialog()->setSyncMode( false );
1211 if ( syncOK ) { 1211 if ( syncOK ) {
1212 if ( mSyncManager->mWriteBackFile ) 1212 if ( mSyncManager->mWriteBackFile )
1213 { 1213 {
1214 storage->setSaveFormat( new ICalFormat() ); 1214 storage->setSaveFormat( new ICalFormat() );
1215 storage->save(); 1215 storage->save();
1216 } 1216 }
1217 } 1217 }
1218 setModified( true ); 1218 setModified( true );
1219 } 1219 }
1220 delete storage; 1220 delete storage;
1221 delete calendar; 1221 delete calendar;
1222 if ( syncOK ) 1222 if ( syncOK )
1223 updateView(); 1223 updateView();
1224 return syncOK; 1224 return syncOK;
1225} 1225}
1226 1226
1227void CalendarView::syncExternal( int mode ) 1227void CalendarView::syncExternal( int mode )
1228{ 1228{
1229 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1229 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1230 1230
1231 qApp->processEvents(); 1231 qApp->processEvents();
1232 CalendarLocal* calendar = new CalendarLocal(); 1232 CalendarLocal* calendar = new CalendarLocal();
1233 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1233 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1234 bool syncOK = false; 1234 bool syncOK = false;
1235 bool loadSuccess = false; 1235 bool loadSuccess = false;
1236 PhoneFormat* phoneFormat = 0; 1236 PhoneFormat* phoneFormat = 0;
1237#ifndef DESKTOP_VERSION 1237#ifndef DESKTOP_VERSION
1238 SharpFormat* sharpFormat = 0; 1238 SharpFormat* sharpFormat = 0;
1239 if ( mode == 0 ) { // sharp 1239 if ( mode == 0 ) { // sharp
1240 sharpFormat = new SharpFormat () ; 1240 sharpFormat = new SharpFormat () ;
1241 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1241 loadSuccess = sharpFormat->load( calendar, mCalendar );
1242 1242
1243 } else 1243 } else
1244#endif 1244#endif
1245 if ( mode == 1 ) { // phone 1245 if ( mode == 1 ) { // phone
1246 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1246 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1247 mSyncManager->mPhoneDevice, 1247 mSyncManager->mPhoneDevice,
1248 mSyncManager->mPhoneConnection, 1248 mSyncManager->mPhoneConnection,
1249 mSyncManager->mPhoneModel); 1249 mSyncManager->mPhoneModel);
1250 loadSuccess = phoneFormat->load( calendar,mCalendar); 1250 loadSuccess = phoneFormat->load( calendar,mCalendar);
1251 1251
1252 } else 1252 } else
1253 return; 1253 return;
1254 if ( loadSuccess ) { 1254 if ( loadSuccess ) {
1255 getEventViewerDialog()->setSyncMode( true ); 1255 getEventViewerDialog()->setSyncMode( true );
1256 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1256 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1257 getEventViewerDialog()->setSyncMode( false ); 1257 getEventViewerDialog()->setSyncMode( false );
1258 qApp->processEvents(); 1258 qApp->processEvents();
1259 if ( syncOK ) { 1259 if ( syncOK ) {
1260 if ( mSyncManager->mWriteBackFile ) 1260 if ( mSyncManager->mWriteBackFile )
1261 { 1261 {
1262 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1262 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1263 Incidence* inc = iL.first(); 1263 Incidence* inc = iL.first();
1264 if ( phoneFormat ) { 1264 if ( phoneFormat ) {
1265 while ( inc ) { 1265 while ( inc ) {
1266 inc->removeID(mCurrentSyncDevice); 1266 inc->removeID(mCurrentSyncDevice);
1267 inc = iL.next(); 1267 inc = iL.next();
1268 } 1268 }
1269 } 1269 }
1270#ifndef DESKTOP_VERSION 1270#ifndef DESKTOP_VERSION
1271 if ( sharpFormat ) 1271 if ( sharpFormat )
1272 sharpFormat->save(calendar); 1272 sharpFormat->save(calendar);
1273#endif 1273#endif
1274 if ( phoneFormat ) 1274 if ( phoneFormat )
1275 phoneFormat->save(calendar); 1275 phoneFormat->save(calendar);
1276 iL = calendar->rawIncidences(); 1276 iL = calendar->rawIncidences();
1277 inc = iL.first(); 1277 inc = iL.first();
1278 Incidence* loc; 1278 Incidence* loc;
1279 while ( inc ) { 1279 while ( inc ) {
1280 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1280 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1281 loc = mCalendar->incidence(inc->uid() ); 1281 loc = mCalendar->incidence(inc->uid() );
1282 if ( loc ) { 1282 if ( loc ) {
1283 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1283 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1284 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1284 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1285 } 1285 }
1286 } 1286 }
1287 inc = iL.next(); 1287 inc = iL.next();
1288 } 1288 }
1289 Incidence* lse = getLastSyncEvent(); 1289 Incidence* lse = getLastSyncEvent();
1290 if ( lse ) { 1290 if ( lse ) {
1291 lse->setReadOnly( false ); 1291 lse->setReadOnly( false );
1292 lse->setDescription( "" ); 1292 lse->setDescription( "" );
1293 lse->setReadOnly( true ); 1293 lse->setReadOnly( true );
1294 } 1294 }
1295 } 1295 }
1296 } 1296 }
1297 setModified( true ); 1297 setModified( true );
1298 } else { 1298 } else {
1299 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1299 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1300 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1300 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1301 question, i18n("Ok")) ; 1301 question, i18n("Ok")) ;
1302 1302
1303 } 1303 }
1304 delete calendar; 1304 delete calendar;
1305 updateView(); 1305 updateView();
1306 return ;//syncOK; 1306 return ;//syncOK;
1307 1307
1308} 1308}
1309 1309
1310bool CalendarView::importBday() 1310bool CalendarView::importBday()
1311{ 1311{
1312#ifndef KORG_NOKABC 1312#ifndef KORG_NOKABC
1313 1313
1314#ifdef DESKTOP_VERSION 1314#ifdef DESKTOP_VERSION
1315 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1315 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1316 KABC::AddressBook::Iterator it; 1316 KABC::AddressBook::Iterator it;
1317 int count = 0; 1317 int count = 0;
1318 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1318 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1319 ++count; 1319 ++count;
1320 } 1320 }
1321 QProgressBar bar(count,0 ); 1321 QProgressBar bar(count,0 );
1322 int w = 300; 1322 int w = 300;
1323 if ( QApplication::desktop()->width() < 320 ) 1323 if ( QApplication::desktop()->width() < 320 )
1324 w = 220; 1324 w = 220;
1325 int h = bar.sizeHint().height() ; 1325 int h = bar.sizeHint().height() ;
1326 int dw = QApplication::desktop()->width(); 1326 int dw = QApplication::desktop()->width();
1327 int dh = QApplication::desktop()->height(); 1327 int dh = QApplication::desktop()->height();
1328 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1328 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1329 bar.show(); 1329 bar.show();
1330 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1330 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1331 qApp->processEvents(); 1331 qApp->processEvents();
1332 count = 0; 1332 count = 0;
1333 int addCount = 0; 1333 int addCount = 0;
1334 KCal::Attendee* a = 0; 1334 KCal::Attendee* a = 0;
1335 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1335 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1336 if ( ! bar.isVisible() ) 1336 if ( ! bar.isVisible() )
1337 return false; 1337 return false;
1338 bar.setProgress( count++ ); 1338 bar.setProgress( count++ );
1339 qApp->processEvents(); 1339 qApp->processEvents();
1340 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1340 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1341 if ( (*it).birthday().date().isValid() ){ 1341 if ( (*it).birthday().date().isValid() ){
1342 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1342 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1343 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1343 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1344 ++addCount; 1344 ++addCount;
1345 } 1345 }
1346 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1346 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1347 if ( anni.isValid() ){ 1347 if ( anni.isValid() ){
1348 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1348 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1349 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1349 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1350 ++addCount; 1350 ++addCount;
1351 } 1351 }
1352 } 1352 }
1353 updateView(); 1353 updateView();
1354 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1354 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1355#else //DESKTOP_VERSION 1355#else //DESKTOP_VERSION
1356 1356
1357 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1357 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1358 // the result should now arrive through method insertBirthdays 1358 // the result should now arrive through method insertBirthdays
1359 1359
1360#endif //DESKTOP_VERSION 1360#endif //DESKTOP_VERSION
1361 1361
1362#endif //KORG_NOKABC 1362#endif //KORG_NOKABC
1363 1363
1364 1364
1365 return true; 1365 return true;
1366} 1366}
1367 1367
1368// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1368// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1369void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1369void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1370 const QStringList& anniversaryList, const QStringList& realNameList, 1370 const QStringList& anniversaryList, const QStringList& realNameList,
1371 const QStringList& emailList, const QStringList& assembledNameList, 1371 const QStringList& emailList, const QStringList& assembledNameList,
1372 const QStringList& uidList) 1372 const QStringList& uidList)
1373{ 1373{
1374 qDebug("CalendarView::insertBirthdays"); 1374 qDebug("CalendarView::insertBirthdays");
1375 if (uid == this->name()) 1375 if (uid == this->name())
1376 { 1376 {
1377 int count = birthdayList.count(); 1377 int count = birthdayList.count();
1378 int addCount = 0; 1378 int addCount = 0;
1379 KCal::Attendee* a = 0; 1379 KCal::Attendee* a = 0;
1380 1380
1381 qDebug("CalView 1 %i", count); 1381 qDebug("CalView 1 %i", count);
1382 1382
1383 QProgressBar bar(count,0 ); 1383 QProgressBar bar(count,0 );
1384 int w = 300; 1384 int w = 300;
1385 if ( QApplication::desktop()->width() < 320 ) 1385 if ( QApplication::desktop()->width() < 320 )
1386 w = 220; 1386 w = 220;
1387 int h = bar.sizeHint().height() ; 1387 int h = bar.sizeHint().height() ;
1388 int dw = QApplication::desktop()->width(); 1388 int dw = QApplication::desktop()->width();
1389 int dh = QApplication::desktop()->height(); 1389 int dh = QApplication::desktop()->height();
1390 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1390 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1391 bar.show(); 1391 bar.show();
1392 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1392 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1393 qApp->processEvents(); 1393 qApp->processEvents();
1394 1394
1395 QDate birthday; 1395 QDate birthday;
1396 QDate anniversary; 1396 QDate anniversary;
1397 QString realName; 1397 QString realName;
1398 QString email; 1398 QString email;
1399 QString assembledName; 1399 QString assembledName;
1400 QString uid; 1400 QString uid;
1401 bool ok = true; 1401 bool ok = true;
1402 for ( int i = 0; i < count; i++) 1402 for ( int i = 0; i < count; i++)
1403 { 1403 {
1404 if ( ! bar.isVisible() ) 1404 if ( ! bar.isVisible() )
1405 return; 1405 return;
1406 bar.setProgress( i ); 1406 bar.setProgress( i );
1407 qApp->processEvents(); 1407 qApp->processEvents();
1408 1408
1409 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1409 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1410 if (!ok) { 1410 if (!ok) {
1411 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1411 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1412 } 1412 }
1413 1413
1414 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1414 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1415 if (!ok) { 1415 if (!ok) {
1416 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1416 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1417 } 1417 }
1418 realName = realNameList[i]; 1418 realName = realNameList[i];
1419 email = emailList[i]; 1419 email = emailList[i];
1420 assembledName = assembledNameList[i]; 1420 assembledName = assembledNameList[i];
1421 uid = uidList[i]; 1421 uid = uidList[i];
1422 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); 1422 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() );
1423 1423
1424 if ( birthday.isValid() ){ 1424 if ( birthday.isValid() ){
1425 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1425 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1426 KCal::Attendee::ReqParticipant,uid) ; 1426 KCal::Attendee::ReqParticipant,uid) ;
1427 if ( addAnniversary( birthday, assembledName, a, true ) ) 1427 if ( addAnniversary( birthday, assembledName, a, true ) )
1428 ++addCount; 1428 ++addCount;
1429 } 1429 }
1430 1430
1431 if ( anniversary.isValid() ){ 1431 if ( anniversary.isValid() ){
1432 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1432 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1433 KCal::Attendee::ReqParticipant,uid) ; 1433 KCal::Attendee::ReqParticipant,uid) ;
1434 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1434 if ( addAnniversary( anniversary, assembledName, a, false ) )
1435 ++addCount; 1435 ++addCount;
1436 } 1436 }
1437 } 1437 }
1438 1438
1439 updateView(); 1439 updateView();
1440 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1440 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1441 1441
1442 } 1442 }
1443 1443
1444} 1444}
1445 1445
1446 1446
1447 1447
1448bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1448bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1449{ 1449{
1450 //qDebug("addAnni "); 1450 //qDebug("addAnni ");
1451 Event * ev = new Event(); 1451 Event * ev = new Event();
1452 if ( a ) { 1452 if ( a ) {
1453 ev->addAttendee( a ); 1453 ev->addAttendee( a );
1454 } 1454 }
1455 QString kind; 1455 QString kind;
1456 if ( birthday ) 1456 if ( birthday )
1457 kind = i18n( "Birthday" ); 1457 kind = i18n( "Birthday" );
1458 else 1458 else
1459 kind = i18n( "Anniversary" ); 1459 kind = i18n( "Anniversary" );
1460 ev->setSummary( name + " - " + kind ); 1460 ev->setSummary( name + " - " + kind );
1461 ev->setOrganizer( "nobody@nowhere" ); 1461 ev->setOrganizer( "nobody@nowhere" );
1462 ev->setCategories( kind ); 1462 ev->setCategories( kind );
1463 ev->setDtStart( QDateTime(date) ); 1463 ev->setDtStart( QDateTime(date) );
1464 ev->setDtEnd( QDateTime(date) ); 1464 ev->setDtEnd( QDateTime(date) );
1465 ev->setFloats( true ); 1465 ev->setFloats( true );
1466 Recurrence * rec = ev->recurrence(); 1466 Recurrence * rec = ev->recurrence();
1467 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1467 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1468 rec->addYearlyNum( date.month() ); 1468 rec->addYearlyNum( date.month() );
1469 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1469 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1470 delete ev; 1470 delete ev;
1471 return false; 1471 return false;
1472 } 1472 }
1473 return true; 1473 return true;
1474 1474
1475} 1475}
1476bool CalendarView::importQtopia( const QString &categories, 1476bool CalendarView::importQtopia( const QString &categories,
1477 const QString &datebook, 1477 const QString &datebook,
1478 const QString &todolist ) 1478 const QString &todolist )
1479{ 1479{
1480 1480
1481 QtopiaFormat qtopiaFormat; 1481 QtopiaFormat qtopiaFormat;
1482 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1482 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1483 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1483 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1484 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1484 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1485 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1485 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1486 1486
1487 updateView(); 1487 updateView();
1488 return true; 1488 return true;
1489 1489
1490#if 0 1490#if 0
1491 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1491 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1492 mCurrentSyncDevice = "qtopia-XML"; 1492 mCurrentSyncDevice = "qtopia-XML";
1493 if ( mSyncManager->mAskForPreferences ) 1493 if ( mSyncManager->mAskForPreferences )
1494 edit_sync_options(); 1494 edit_sync_options();
1495 qApp->processEvents(); 1495 qApp->processEvents();
1496 CalendarLocal* calendar = new CalendarLocal(); 1496 CalendarLocal* calendar = new CalendarLocal();
1497 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1497 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1498 bool syncOK = false; 1498 bool syncOK = false;
1499 QtopiaFormat qtopiaFormat; 1499 QtopiaFormat qtopiaFormat;
1500 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1500 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1501 bool loadOk = true; 1501 bool loadOk = true;
1502 if ( !categories.isEmpty() ) 1502 if ( !categories.isEmpty() )
1503 loadOk = qtopiaFormat.load( calendar, categories ); 1503 loadOk = qtopiaFormat.load( calendar, categories );
1504 if ( loadOk && !datebook.isEmpty() ) 1504 if ( loadOk && !datebook.isEmpty() )
1505 loadOk = qtopiaFormat.load( calendar, datebook ); 1505 loadOk = qtopiaFormat.load( calendar, datebook );
1506 if ( loadOk && !todolist.isEmpty() ) 1506 if ( loadOk && !todolist.isEmpty() )
1507 loadOk = qtopiaFormat.load( calendar, todolist ); 1507 loadOk = qtopiaFormat.load( calendar, todolist );
1508 1508
1509 if ( loadOk ) { 1509 if ( loadOk ) {
1510 getEventViewerDialog()->setSyncMode( true ); 1510 getEventViewerDialog()->setSyncMode( true );
1511 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1511 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1512 getEventViewerDialog()->setSyncMode( false ); 1512 getEventViewerDialog()->setSyncMode( false );
1513 qApp->processEvents(); 1513 qApp->processEvents();
1514 if ( syncOK ) { 1514 if ( syncOK ) {
1515 if ( mSyncManager->mWriteBackFile ) 1515 if ( mSyncManager->mWriteBackFile )
1516 { 1516 {
1517 // write back XML file 1517 // write back XML file
1518 1518
1519 } 1519 }
1520 setModified( true ); 1520 setModified( true );
1521 } 1521 }
1522 } else { 1522 } else {
1523 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1523 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1524 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1524 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1525 question, i18n("Ok")) ; 1525 question, i18n("Ok")) ;
1526 } 1526 }
1527 delete calendar; 1527 delete calendar;
1528 updateView(); 1528 updateView();
1529 return syncOK; 1529 return syncOK;
1530 1530
1531 1531
1532#endif 1532#endif
1533 1533
1534} 1534}
1535 1535
1536void CalendarView::setSyncEventsReadOnly() 1536void CalendarView::setSyncEventsReadOnly()
1537{ 1537{
1538 Event * ev; 1538 Event * ev;
1539 QPtrList<Event> eL = mCalendar->rawEvents(); 1539 QPtrList<Event> eL = mCalendar->rawEvents();
1540 ev = eL.first(); 1540 ev = eL.first();
1541 while ( ev ) { 1541 while ( ev ) {
1542 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1542 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1543 ev->setReadOnly( true ); 1543 ev->setReadOnly( true );
1544 ev = eL.next(); 1544 ev = eL.next();
1545 } 1545 }
1546} 1546}
1547bool CalendarView::openCalendar(QString filename, bool merge) 1547bool CalendarView::openCalendar(QString filename, bool merge)
1548{ 1548{
1549 1549
1550 if (filename.isEmpty()) { 1550 if (filename.isEmpty()) {
1551 return false; 1551 return false;
1552 } 1552 }
1553 1553
1554 if (!QFile::exists(filename)) { 1554 if (!QFile::exists(filename)) {
1555 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1555 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1556 return false; 1556 return false;
1557 } 1557 }
1558 1558
1559 globalFlagBlockAgenda = 1; 1559 globalFlagBlockAgenda = 1;
1560 if (!merge) mCalendar->close(); 1560 if (!merge) mCalendar->close();
1561 1561
1562 mStorage->setFileName( filename ); 1562 mStorage->setFileName( filename );
1563 1563
1564 if ( mStorage->load() ) { 1564 if ( mStorage->load() ) {
1565 if ( merge ) ;//setModified( true ); 1565 if ( merge ) ;//setModified( true );
1566 else { 1566 else {
1567 //setModified( true ); 1567 //setModified( true );
1568 mViewManager->setDocumentId( filename ); 1568 mViewManager->setDocumentId( filename );
1569 mDialogManager->setDocumentId( filename ); 1569 mDialogManager->setDocumentId( filename );
1570 mTodoList->setDocumentId( filename ); 1570 mTodoList->setDocumentId( filename );
1571 } 1571 }
1572 globalFlagBlockAgenda = 2; 1572 globalFlagBlockAgenda = 2;
1573 // if ( getLastSyncEvent() ) 1573 // if ( getLastSyncEvent() )
1574 // getLastSyncEvent()->setReadOnly( true ); 1574 // getLastSyncEvent()->setReadOnly( true );
1575 mCalendar->reInitAlarmSettings(); 1575 mCalendar->reInitAlarmSettings();
1576 setSyncEventsReadOnly(); 1576 setSyncEventsReadOnly();
1577 updateUnmanagedViews(); 1577 updateUnmanagedViews();
1578 updateView(); 1578 updateView();
1579 if ( filename != MainWindow::defaultFileName() ) { 1579 if ( filename != MainWindow::defaultFileName() ) {
1580 saveCalendar( MainWindow::defaultFileName() ); 1580 saveCalendar( MainWindow::defaultFileName() );
1581 } else { 1581 } else {
1582 QFileInfo finf ( MainWindow::defaultFileName()); 1582 QFileInfo finf ( MainWindow::defaultFileName());
1583 if ( finf.exists() ) { 1583 if ( finf.exists() ) {
1584 setLoadedFileVersion( finf.lastModified () ); 1584 setLoadedFileVersion( finf.lastModified () );
1585 } 1585 }
1586 } 1586 }
1587 return true; 1587 return true;
1588 } else { 1588 } else {
1589 // while failing to load, the calendar object could 1589 // while failing to load, the calendar object could
1590 // have become partially populated. Clear it out. 1590 // have become partially populated. Clear it out.
1591 if ( !merge ) { 1591 if ( !merge ) {
1592 mCalendar->close(); 1592 mCalendar->close();
1593 mViewManager->setDocumentId( filename ); 1593 mViewManager->setDocumentId( filename );
1594 mDialogManager->setDocumentId( filename ); 1594 mDialogManager->setDocumentId( filename );
1595 mTodoList->setDocumentId( filename ); 1595 mTodoList->setDocumentId( filename );
1596 } 1596 }
1597 1597
1598 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1598 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1599 1599
1600 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1600 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1601 globalFlagBlockAgenda = 2; 1601 globalFlagBlockAgenda = 2;
1602 mCalendar->reInitAlarmSettings(); 1602 mCalendar->reInitAlarmSettings();
1603 setSyncEventsReadOnly(); 1603 setSyncEventsReadOnly();
1604 updateUnmanagedViews(); 1604 updateUnmanagedViews();
1605 updateView(); 1605 updateView();
1606 } 1606 }
1607 return false; 1607 return false;
1608} 1608}
1609void CalendarView::showOpenError() 1609void CalendarView::showOpenError()
1610{ 1610{
1611 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1611 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1612} 1612}
1613void CalendarView::setLoadedFileVersion(QDateTime dt) 1613void CalendarView::setLoadedFileVersion(QDateTime dt)
1614{ 1614{
1615 loadedFileVersion = dt; 1615 loadedFileVersion = dt;
1616} 1616}
1617bool CalendarView::checkFileChanged(QString fn) 1617bool CalendarView::checkFileChanged(QString fn)
1618{ 1618{
1619 QFileInfo finf ( fn ); 1619 QFileInfo finf ( fn );
1620 if ( !finf.exists() ) 1620 if ( !finf.exists() )
1621 return true; 1621 return true;
1622 QDateTime dt = finf.lastModified (); 1622 QDateTime dt = finf.lastModified ();
1623 if ( dt <= loadedFileVersion ) 1623 if ( dt <= loadedFileVersion )
1624 return false; 1624 return false;
1625 return true; 1625 return true;
1626 1626
1627} 1627}
1628void CalendarView::watchSavedFile() 1628void CalendarView::watchSavedFile()
1629{ 1629{
1630 QFileInfo finf ( MainWindow::defaultFileName()); 1630 QFileInfo finf ( MainWindow::defaultFileName());
1631 if ( !finf.exists() ) 1631 if ( !finf.exists() )
1632 return; 1632 return;
1633 QDateTime dt = finf.lastModified (); 1633 QDateTime dt = finf.lastModified ();
1634 if ( dt < loadedFileVersion ) { 1634 if ( dt < loadedFileVersion ) {
1635 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1635 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1636 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1636 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1637 return; 1637 return;
1638 } 1638 }
1639 loadedFileVersion = dt; 1639 loadedFileVersion = dt;
1640} 1640}
1641 1641
1642bool CalendarView::checkFileVersion(QString fn) 1642bool CalendarView::checkFileVersion(QString fn)
1643{ 1643{
1644 QFileInfo finf ( fn ); 1644 QFileInfo finf ( fn );
1645 if ( !finf.exists() ) 1645 if ( !finf.exists() )
1646 return true; 1646 return true;
1647 QDateTime dt = finf.lastModified (); 1647 QDateTime dt = finf.lastModified ();
1648 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1648 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1649 //qDebug("file on disk version %s",dt.toString().latin1()); 1649 //qDebug("file on disk version %s",dt.toString().latin1());
1650 if ( dt <= loadedFileVersion ) 1650 if ( dt <= loadedFileVersion )
1651 return true; 1651 return true;
1652 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 1652 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
1653 i18n("KO/Pi Warning"),i18n("Overwrite"), 1653 i18n("KO/Pi Warning"),i18n("Overwrite"),
1654 i18n("Sync+save")); 1654 i18n("Sync+save"));
1655 1655
1656 if ( km == KMessageBox::Cancel ) 1656 if ( km == KMessageBox::Cancel )
1657 return false; 1657 return false;
1658 if ( km == KMessageBox::Yes ) 1658 if ( km == KMessageBox::Yes )
1659 return true; 1659 return true;
1660 1660
1661 setSyncDevice("deleteaftersync" ); 1661 setSyncDevice("deleteaftersync" );
1662 mSyncManager->mAskForPreferences = true; 1662 mSyncManager->mAskForPreferences = true;
1663 mSyncManager->mSyncAlgoPrefs = 3; 1663 mSyncManager->mSyncAlgoPrefs = 3;
1664 mSyncManager->mWriteBackFile = false; 1664 mSyncManager->mWriteBackFile = false;
1665 mSyncManager->mWriteBackExistingOnly = false; 1665 mSyncManager->mWriteBackExistingOnly = false;
1666 mSyncManager->mShowSyncSummary = false; 1666 mSyncManager->mShowSyncSummary = false;
1667 syncCalendar( fn, 3 ); 1667 syncCalendar( fn, 3 );
1668 Event * e = getLastSyncEvent(); 1668 Event * e = getLastSyncEvent();
1669 mCalendar->deleteEvent ( e ); 1669 mCalendar->deleteEvent ( e );
1670 updateView(); 1670 updateView();
1671 return true; 1671 return true;
1672} 1672}
1673 1673
1674bool CalendarView::saveCalendar( QString filename ) 1674bool CalendarView::saveCalendar( QString filename )
1675{ 1675{
1676 1676
1677 // Store back all unsaved data into calendar object 1677 // Store back all unsaved data into calendar object
1678 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1678 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1679 if ( mViewManager->currentView() ) 1679 if ( mViewManager->currentView() )
1680 mViewManager->currentView()->flushView(); 1680 mViewManager->currentView()->flushView();
1681 1681
1682 1682
1683 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 1683 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1684 mStorage->setSaveFormat( new ICalFormat() ); 1684 mStorage->setSaveFormat( new ICalFormat() );
1685 mStorage->setFileName( filename ); 1685 mStorage->setFileName( filename );
1686 bool success; 1686 bool success;
1687 success = mStorage->save(); 1687 success = mStorage->save();
1688 if ( !success ) { 1688 if ( !success ) {
1689 return false; 1689 return false;
1690 } 1690 }
1691 if ( filename == MainWindow::defaultFileName() ) { 1691 if ( filename == MainWindow::defaultFileName() ) {
1692 setLoadedFileVersion( lfv ); 1692 setLoadedFileVersion( lfv );
1693 watchSavedFile(); 1693 watchSavedFile();
1694 } 1694 }
1695 return true; 1695 return true;
1696} 1696}
1697 1697
1698void CalendarView::closeCalendar() 1698void CalendarView::closeCalendar()
1699{ 1699{
1700 1700
1701 // child windows no longer valid 1701 // child windows no longer valid
1702 emit closingDown(); 1702 emit closingDown();
1703 1703
1704 mCalendar->close(); 1704 mCalendar->close();
1705 setModified(false); 1705 setModified(false);
1706 updateView(); 1706 updateView();
1707} 1707}
1708 1708
1709void CalendarView::archiveCalendar() 1709void CalendarView::archiveCalendar()
1710{ 1710{
1711 mDialogManager->showArchiveDialog(); 1711 mDialogManager->showArchiveDialog();
1712} 1712}
1713 1713
1714 1714
1715void CalendarView::readSettings() 1715void CalendarView::readSettings()
1716{ 1716{
1717 1717
1718 1718
1719 // mViewManager->showAgendaView(); 1719 // mViewManager->showAgendaView();
1720 QString str; 1720 QString str;
1721 //qDebug("CalendarView::readSettings() "); 1721 //qDebug("CalendarView::readSettings() ");
1722 // read settings from the KConfig, supplying reasonable 1722 // read settings from the KConfig, supplying reasonable
1723 // defaults where none are to be found 1723 // defaults where none are to be found
1724 KConfig *config = KOGlobals::config(); 1724 KConfig *config = KOGlobals::config();
1725#ifndef KORG_NOSPLITTER 1725#ifndef KORG_NOSPLITTER
1726 config->setGroup("KOrganizer Geometry"); 1726 config->setGroup("KOrganizer Geometry");
1727 1727
1728 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1728 QValueList<int> sizes = config->readIntListEntry("Separator1");
1729 if (sizes.count() != 2) { 1729 if (sizes.count() != 2) {
1730 sizes << mDateNavigator->minimumSizeHint().width(); 1730 sizes << mDateNavigator->minimumSizeHint().width();
1731 sizes << 300; 1731 sizes << 300;
1732 } 1732 }
1733 mPanner->setSizes(sizes); 1733 mPanner->setSizes(sizes);
1734 1734
1735 sizes = config->readIntListEntry("Separator2"); 1735 sizes = config->readIntListEntry("Separator2");
1736 if ( ( mResourceView && sizes.count() == 4 ) || 1736 if ( ( mResourceView && sizes.count() == 4 ) ||
1737 ( !mResourceView && sizes.count() == 3 ) ) { 1737 ( !mResourceView && sizes.count() == 3 ) ) {
1738 mLeftSplitter->setSizes(sizes); 1738 mLeftSplitter->setSizes(sizes);
1739 } 1739 }
1740#endif 1740#endif
1741 globalFlagBlockAgenda = 1; 1741 globalFlagBlockAgenda = 1;
1742 mViewManager->showAgendaView(); 1742 mViewManager->showAgendaView();
1743 //mViewManager->readSettings( config ); 1743 //mViewManager->readSettings( config );
1744 mTodoList->restoreLayout(config,QString("Todo Layout")); 1744 mTodoList->restoreLayout(config,QString("Todo Layout"));
1745 readFilterSettings(config); 1745 readFilterSettings(config);
1746 config->setGroup( "Views" ); 1746 config->setGroup( "Views" );
1747 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1747 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1748 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1748 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1749 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1749 else if ( dateCount == 7 ) mNavigator->selectWeek();
1750 else mNavigator->selectDates( dateCount ); 1750 else mNavigator->selectDates( dateCount );
1751 // mViewManager->readSettings( config ); 1751 // mViewManager->readSettings( config );
1752 updateConfig(); 1752 updateConfig();
1753 globalFlagBlockAgenda = 2; 1753 globalFlagBlockAgenda = 2;
1754 mViewManager->readSettings( config ); 1754 mViewManager->readSettings( config );
1755#ifdef DESKTOP_VERSION 1755#ifdef DESKTOP_VERSION
1756 config->setGroup("WidgetLayout"); 1756 config->setGroup("WidgetLayout");
1757 QStringList list; 1757 QStringList list;
1758 list = config->readListEntry("MainLayout"); 1758 list = config->readListEntry("MainLayout");
1759 int x,y,w,h; 1759 int x,y,w,h;
1760 if ( ! list.isEmpty() ) { 1760 if ( ! list.isEmpty() ) {
1761 x = list[0].toInt(); 1761 x = list[0].toInt();
1762 y = list[1].toInt(); 1762 y = list[1].toInt();
1763 w = list[2].toInt(); 1763 w = list[2].toInt();
1764 h = list[3].toInt(); 1764 h = list[3].toInt();
1765 topLevelWidget()->setGeometry(x,y,w,h); 1765 topLevelWidget()->setGeometry(x,y,w,h);
1766 1766
1767 } else { 1767 } else {
1768 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1768 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1769 } 1769 }
1770 list = config->readListEntry("EditEventLayout"); 1770 list = config->readListEntry("EditEventLayout");
1771 if ( ! list.isEmpty() ) { 1771 if ( ! list.isEmpty() ) {
1772 x = list[0].toInt(); 1772 x = list[0].toInt();
1773 y = list[1].toInt(); 1773 y = list[1].toInt();
1774 w = list[2].toInt(); 1774 w = list[2].toInt();
1775 h = list[3].toInt(); 1775 h = list[3].toInt();
1776 mEventEditor->setGeometry(x,y,w,h); 1776 mEventEditor->setGeometry(x,y,w,h);
1777 1777
1778 } 1778 }
1779 list = config->readListEntry("EditTodoLayout"); 1779 list = config->readListEntry("EditTodoLayout");
1780 if ( ! list.isEmpty() ) { 1780 if ( ! list.isEmpty() ) {
1781 x = list[0].toInt(); 1781 x = list[0].toInt();
1782 y = list[1].toInt(); 1782 y = list[1].toInt();
1783 w = list[2].toInt(); 1783 w = list[2].toInt();
1784 h = list[3].toInt(); 1784 h = list[3].toInt();
1785 mTodoEditor->setGeometry(x,y,w,h); 1785 mTodoEditor->setGeometry(x,y,w,h);
1786 1786
1787 } 1787 }
1788 list = config->readListEntry("ViewerLayout"); 1788 list = config->readListEntry("ViewerLayout");
1789 if ( ! list.isEmpty() ) { 1789 if ( ! list.isEmpty() ) {
1790 x = list[0].toInt(); 1790 x = list[0].toInt();
1791 y = list[1].toInt(); 1791 y = list[1].toInt();
1792 w = list[2].toInt(); 1792 w = list[2].toInt();
1793 h = list[3].toInt(); 1793 h = list[3].toInt();
1794 getEventViewerDialog()->setGeometry(x,y,w,h); 1794 getEventViewerDialog()->setGeometry(x,y,w,h);
1795 } 1795 }
1796#endif 1796#endif
1797 1797
1798} 1798}
1799 1799
1800 1800
1801void CalendarView::writeSettings() 1801void CalendarView::writeSettings()
1802{ 1802{
1803 // kdDebug() << "CalendarView::writeSettings" << endl; 1803 // kdDebug() << "CalendarView::writeSettings" << endl;
1804 1804
1805 KConfig *config = KOGlobals::config(); 1805 KConfig *config = KOGlobals::config();
1806 1806
1807#ifndef KORG_NOSPLITTER 1807#ifndef KORG_NOSPLITTER
1808 config->setGroup("KOrganizer Geometry"); 1808 config->setGroup("KOrganizer Geometry");
1809 1809
1810 QValueList<int> list = mPanner->sizes(); 1810 QValueList<int> list = mPanner->sizes();
1811 config->writeEntry("Separator1",list); 1811 config->writeEntry("Separator1",list);
1812 1812
1813 list = mLeftSplitter->sizes(); 1813 list = mLeftSplitter->sizes();
1814 config->writeEntry("Separator2",list); 1814 config->writeEntry("Separator2",list);
1815#endif 1815#endif
1816 1816
1817 mViewManager->writeSettings( config ); 1817 mViewManager->writeSettings( config );
1818 mTodoList->saveLayout(config,QString("Todo Layout")); 1818 mTodoList->saveLayout(config,QString("Todo Layout"));
1819 mDialogManager->writeSettings( config ); 1819 mDialogManager->writeSettings( config );
1820 //KOPrefs::instance()->usrWriteConfig(); 1820 //KOPrefs::instance()->usrWriteConfig();
1821 KOPrefs::instance()->writeConfig(); 1821 KOPrefs::instance()->writeConfig();
1822 1822
1823 writeFilterSettings(config); 1823 writeFilterSettings(config);
1824 1824
1825 config->setGroup( "Views" ); 1825 config->setGroup( "Views" );
1826 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1826 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1827 1827
1828#ifdef DESKTOP_VERSION 1828#ifdef DESKTOP_VERSION
1829 config->setGroup("WidgetLayout"); 1829 config->setGroup("WidgetLayout");
1830 QStringList list ;//= config->readListEntry("MainLayout"); 1830 QStringList list ;//= config->readListEntry("MainLayout");
1831 int x,y,w,h; 1831 int x,y,w,h;
1832 QWidget* wid; 1832 QWidget* wid;
1833 wid = topLevelWidget(); 1833 wid = topLevelWidget();
1834 x = wid->geometry().x(); 1834 x = wid->geometry().x();
1835 y = wid->geometry().y(); 1835 y = wid->geometry().y();
1836 w = wid->width(); 1836 w = wid->width();
1837 h = wid->height(); 1837 h = wid->height();
1838 list.clear(); 1838 list.clear();
1839 list << QString::number( x ); 1839 list << QString::number( x );
1840 list << QString::number( y ); 1840 list << QString::number( y );
1841 list << QString::number( w ); 1841 list << QString::number( w );
1842 list << QString::number( h ); 1842 list << QString::number( h );
1843 config->writeEntry("MainLayout",list ); 1843 config->writeEntry("MainLayout",list );
1844 1844
1845 wid = mEventEditor; 1845 wid = mEventEditor;
1846 x = wid->geometry().x(); 1846 x = wid->geometry().x();
1847 y = wid->geometry().y(); 1847 y = wid->geometry().y();
1848 w = wid->width(); 1848 w = wid->width();
1849 h = wid->height(); 1849 h = wid->height();
1850 list.clear(); 1850 list.clear();
1851 list << QString::number( x ); 1851 list << QString::number( x );
1852 list << QString::number( y ); 1852 list << QString::number( y );
1853 list << QString::number( w ); 1853 list << QString::number( w );
1854 list << QString::number( h ); 1854 list << QString::number( h );
1855 config->writeEntry("EditEventLayout",list ); 1855 config->writeEntry("EditEventLayout",list );
1856 1856
1857 wid = mTodoEditor; 1857 wid = mTodoEditor;
1858 x = wid->geometry().x(); 1858 x = wid->geometry().x();
1859 y = wid->geometry().y(); 1859 y = wid->geometry().y();
1860 w = wid->width(); 1860 w = wid->width();
1861 h = wid->height(); 1861 h = wid->height();
1862 list.clear(); 1862 list.clear();
1863 list << QString::number( x ); 1863 list << QString::number( x );
1864 list << QString::number( y ); 1864 list << QString::number( y );
1865 list << QString::number( w ); 1865 list << QString::number( w );
1866 list << QString::number( h ); 1866 list << QString::number( h );
1867 config->writeEntry("EditTodoLayout",list ); 1867 config->writeEntry("EditTodoLayout",list );
1868 wid = getEventViewerDialog(); 1868 wid = getEventViewerDialog();
1869 x = wid->geometry().x(); 1869 x = wid->geometry().x();
1870 y = wid->geometry().y(); 1870 y = wid->geometry().y();
1871 w = wid->width(); 1871 w = wid->width();
1872 h = wid->height(); 1872 h = wid->height();
1873 list.clear(); 1873 list.clear();
1874 list << QString::number( x ); 1874 list << QString::number( x );
1875 list << QString::number( y ); 1875 list << QString::number( y );
1876 list << QString::number( w ); 1876 list << QString::number( w );
1877 list << QString::number( h ); 1877 list << QString::number( h );
1878 config->writeEntry("ViewerLayout",list ); 1878 config->writeEntry("ViewerLayout",list );
1879 wid = mDialogManager->getSearchDialog(); 1879 wid = mDialogManager->getSearchDialog();
1880 if ( wid ) { 1880 if ( wid ) {
1881 x = wid->geometry().x(); 1881 x = wid->geometry().x();
1882 y = wid->geometry().y(); 1882 y = wid->geometry().y();
1883 w = wid->width(); 1883 w = wid->width();
1884 h = wid->height(); 1884 h = wid->height();
1885 list.clear(); 1885 list.clear();
1886 list << QString::number( x ); 1886 list << QString::number( x );
1887 list << QString::number( y ); 1887 list << QString::number( y );
1888 list << QString::number( w ); 1888 list << QString::number( w );
1889 list << QString::number( h ); 1889 list << QString::number( h );
1890 config->writeEntry("SearchLayout",list ); 1890 config->writeEntry("SearchLayout",list );
1891 } 1891 }
1892#endif 1892#endif
1893 1893
1894 1894
1895 config->sync(); 1895 config->sync();
1896} 1896}
1897 1897
1898void CalendarView::readFilterSettings(KConfig *config) 1898void CalendarView::readFilterSettings(KConfig *config)
1899{ 1899{
1900 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 1900 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
1901 1901
1902 mFilters.clear(); 1902 mFilters.clear();
1903 1903
1904 config->setGroup("General"); 1904 config->setGroup("General");
1905 QStringList filterList = config->readListEntry("CalendarFilters"); 1905 QStringList filterList = config->readListEntry("CalendarFilters");
1906 1906
1907 QStringList::ConstIterator it = filterList.begin(); 1907 QStringList::ConstIterator it = filterList.begin();
1908 QStringList::ConstIterator end = filterList.end(); 1908 QStringList::ConstIterator end = filterList.end();
1909 while(it != end) { 1909 while(it != end) {
1910 // kdDebug() << " filter: " << (*it) << endl; 1910 // kdDebug() << " filter: " << (*it) << endl;
1911 1911
1912 CalFilter *filter; 1912 CalFilter *filter;
1913 filter = new CalFilter(*it); 1913 filter = new CalFilter(*it);
1914 config->setGroup("Filter_" + (*it)); 1914 config->setGroup("Filter_" + (*it));
1915 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 1915 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
1916 filter->setCriteria(config->readNumEntry("Criteria",0)); 1916 filter->setCriteria(config->readNumEntry("Criteria",0));
1917 filter->setCategoryList(config->readListEntry("CategoryList")); 1917 filter->setCategoryList(config->readListEntry("CategoryList"));
1918 mFilters.append(filter); 1918 mFilters.append(filter);
1919 1919
1920 ++it; 1920 ++it;
1921 } 1921 }
1922 1922
1923 if (mFilters.count() == 0) { 1923 if (mFilters.count() == 0) {
1924 CalFilter *filter = new CalFilter(i18n("Default")); 1924 CalFilter *filter = new CalFilter(i18n("Default"));
1925 mFilters.append(filter); 1925 mFilters.append(filter);
1926 } 1926 }
1927 mFilterView->updateFilters(); 1927 mFilterView->updateFilters();
1928 config->setGroup("FilterView"); 1928 config->setGroup("FilterView");
1929 1929
1930 mFilterView->blockSignals(true); 1930 mFilterView->blockSignals(true);
1931 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 1931 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
1932 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 1932 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
1933 mFilterView->blockSignals(false); 1933 mFilterView->blockSignals(false);
1934 // We do it manually to avoid it being done twice by the above calls 1934 // We do it manually to avoid it being done twice by the above calls
1935 updateFilter(); 1935 updateFilter();
1936} 1936}
1937 1937
1938void CalendarView::writeFilterSettings(KConfig *config) 1938void CalendarView::writeFilterSettings(KConfig *config)
1939{ 1939{
1940 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 1940 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
1941 1941
1942 QStringList filterList; 1942 QStringList filterList;
1943 1943
1944 CalFilter *filter = mFilters.first(); 1944 CalFilter *filter = mFilters.first();
1945 while(filter) { 1945 while(filter) {
1946 // kdDebug() << " fn: " << filter->name() << endl; 1946 // kdDebug() << " fn: " << filter->name() << endl;
1947 filterList << filter->name(); 1947 filterList << filter->name();
1948 config->setGroup("Filter_" + filter->name()); 1948 config->setGroup("Filter_" + filter->name());
1949 config->writeEntry("Criteria",filter->criteria()); 1949 config->writeEntry("Criteria",filter->criteria());
1950 config->writeEntry("CategoryList",filter->categoryList()); 1950 config->writeEntry("CategoryList",filter->categoryList());
1951 filter = mFilters.next(); 1951 filter = mFilters.next();
1952 } 1952 }
1953 config->setGroup("General"); 1953 config->setGroup("General");
1954 config->writeEntry("CalendarFilters",filterList); 1954 config->writeEntry("CalendarFilters",filterList);
1955 1955
1956 config->setGroup("FilterView"); 1956 config->setGroup("FilterView");
1957 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 1957 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
1958 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 1958 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
1959} 1959}
1960 1960
1961 1961
1962void CalendarView::goToday() 1962void CalendarView::goToday()
1963{ 1963{
1964 mNavigator->selectToday(); 1964 mNavigator->selectToday();
1965} 1965}
1966 1966
1967void CalendarView::goNext() 1967void CalendarView::goNext()
1968{ 1968{
1969 mNavigator->selectNext(); 1969 mNavigator->selectNext();
1970} 1970}
1971 1971
1972void CalendarView::goPrevious() 1972void CalendarView::goPrevious()
1973{ 1973{
1974 mNavigator->selectPrevious(); 1974 mNavigator->selectPrevious();
1975} 1975}
1976void CalendarView::goNextMonth() 1976void CalendarView::goNextMonth()
1977{ 1977{
1978 mNavigator->selectNextMonth(); 1978 mNavigator->selectNextMonth();
1979} 1979}
1980 1980
1981void CalendarView::goPreviousMonth() 1981void CalendarView::goPreviousMonth()
1982{ 1982{
1983 mNavigator->selectPreviousMonth(); 1983 mNavigator->selectPreviousMonth();
1984} 1984}
1985void CalendarView::writeLocale() 1985void CalendarView::writeLocale()
1986{ 1986{
1987 //KPimGlobalPrefs::instance()->setGlobalConfig(); 1987 //KPimGlobalPrefs::instance()->setGlobalConfig();
1988#if 0 1988#if 0
1989 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 1989 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
1990 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 1990 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
1991 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 1991 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
1992 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 1992 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
1993 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 1993 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
1994 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 1994 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
1995 dummy = KOPrefs::instance()->mUserDateFormatShort; 1995 dummy = KOPrefs::instance()->mUserDateFormatShort;
1996 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 1996 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
1997 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 1997 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
1998 KOPrefs::instance()->mDaylightsavingStart, 1998 KOPrefs::instance()->mDaylightsavingStart,
1999 KOPrefs::instance()->mDaylightsavingEnd ); 1999 KOPrefs::instance()->mDaylightsavingEnd );
2000 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); 2000 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId );
2001#endif 2001#endif
2002} 2002}
2003void CalendarView::updateConfig() 2003void CalendarView::updateConfig()
2004{ 2004{
2005 writeLocale(); 2005 writeLocale();
2006 if ( KOPrefs::instance()->mUseAppColors ) 2006 if ( KOPrefs::instance()->mUseAppColors )
2007 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2007 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2008 emit configChanged(); 2008 emit configChanged();
2009 mTodoList->updateConfig(); 2009 mTodoList->updateConfig();
2010 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2010 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2011 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 2011 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
2012 // To make the "fill window" configurations work 2012 // To make the "fill window" configurations work
2013 //mViewManager->raiseCurrentView(); 2013 //mViewManager->raiseCurrentView();
2014} 2014}
2015 2015
2016 2016
2017void CalendarView::eventChanged(Event *event) 2017void CalendarView::eventChanged(Event *event)
2018{ 2018{
2019 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2019 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2020 //updateUnmanagedViews(); 2020 //updateUnmanagedViews();
2021} 2021}
2022 2022
2023void CalendarView::eventAdded(Event *event) 2023void CalendarView::eventAdded(Event *event)
2024{ 2024{
2025 changeEventDisplay(event,KOGlobals::EVENTADDED); 2025 changeEventDisplay(event,KOGlobals::EVENTADDED);
2026} 2026}
2027 2027
2028void CalendarView::eventToBeDeleted(Event *) 2028void CalendarView::eventToBeDeleted(Event *)
2029{ 2029{
2030 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2030 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2031} 2031}
2032 2032
2033void CalendarView::eventDeleted() 2033void CalendarView::eventDeleted()
2034{ 2034{
2035 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2035 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2036} 2036}
2037void CalendarView::changeTodoDisplay(Todo *which, int action) 2037void CalendarView::changeTodoDisplay(Todo *which, int action)
2038{ 2038{
2039 changeIncidenceDisplay((Incidence *)which, action); 2039 changeIncidenceDisplay((Incidence *)which, action);
2040 mDateNavigator->updateView(); //LR 2040 mDateNavigator->updateView(); //LR
2041 //mDialogManager->updateSearchDialog(); 2041 //mDialogManager->updateSearchDialog();
2042 2042
2043 if (which) { 2043 if (which) {
2044 mViewManager->updateWNview(); 2044 mViewManager->updateWNview();
2045 //mTodoList->updateView(); 2045 //mTodoList->updateView();
2046 } 2046 }
2047 2047
2048} 2048}
2049 2049
2050void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2050void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2051{ 2051{
2052 updateUnmanagedViews(); 2052 updateUnmanagedViews();
2053 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2053 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2054 if ( action == KOGlobals::EVENTDELETED ) { //delete 2054 if ( action == KOGlobals::EVENTDELETED ) { //delete
2055 mCalendar->checkAlarmForIncidence( 0, true ); 2055 mCalendar->checkAlarmForIncidence( 0, true );
2056 if ( mEventViewerDialog ) 2056 if ( mEventViewerDialog )
2057 mEventViewerDialog->hide(); 2057 mEventViewerDialog->hide();
2058 } 2058 }
2059 else 2059 else
2060 mCalendar->checkAlarmForIncidence( which , false ); 2060 mCalendar->checkAlarmForIncidence( which , false );
2061} 2061}
2062 2062
2063// most of the changeEventDisplays() right now just call the view's 2063// most of the changeEventDisplays() right now just call the view's
2064// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2064// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2065void CalendarView::changeEventDisplay(Event *which, int action) 2065void CalendarView::changeEventDisplay(Event *which, int action)
2066{ 2066{
2067 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2067 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2068 changeIncidenceDisplay((Incidence *)which, action); 2068 changeIncidenceDisplay((Incidence *)which, action);
2069 mDateNavigator->updateView(); 2069 mDateNavigator->updateView();
2070 //mDialogManager->updateSearchDialog(); 2070 //mDialogManager->updateSearchDialog();
2071 2071
2072 if (which) { 2072 if (which) {
2073 // If there is an event view visible update the display 2073 // If there is an event view visible update the display
2074 mViewManager->currentView()->changeEventDisplay(which,action); 2074 mViewManager->currentView()->changeEventDisplay(which,action);
2075 // TODO: check, if update needed 2075 // TODO: check, if update needed
2076 // if (which->getTodoStatus()) { 2076 // if (which->getTodoStatus()) {
2077 mTodoList->updateView(); 2077 mTodoList->updateView();
2078 // } 2078 // }
2079 } else { 2079 } else {
2080 mViewManager->currentView()->updateView(); 2080 mViewManager->currentView()->updateView();
2081 } 2081 }
2082} 2082}
2083 2083
2084 2084
2085void CalendarView::updateTodoViews() 2085void CalendarView::updateTodoViews()
2086{ 2086{
2087 2087
2088 mTodoList->updateView(); 2088 mTodoList->updateView();
2089 mViewManager->currentView()->updateView(); 2089 mViewManager->currentView()->updateView();
2090 2090
2091} 2091}
2092 2092
2093 2093
2094void CalendarView::updateView(const QDate &start, const QDate &end) 2094void CalendarView::updateView(const QDate &start, const QDate &end)
2095{ 2095{
2096 mTodoList->updateView(); 2096 mTodoList->updateView();
2097 mViewManager->updateView(start, end); 2097 mViewManager->updateView(start, end);
2098 //mDateNavigator->updateView(); 2098 //mDateNavigator->updateView();
2099} 2099}
2100 2100
2101void CalendarView::updateView() 2101void CalendarView::updateView()
2102{ 2102{
2103 DateList tmpList = mNavigator->selectedDates(); 2103 DateList tmpList = mNavigator->selectedDates();
2104 2104
2105 // We assume that the navigator only selects consecutive days. 2105 // We assume that the navigator only selects consecutive days.
2106 updateView( tmpList.first(), tmpList.last() ); 2106 updateView( tmpList.first(), tmpList.last() );
2107} 2107}
2108 2108
2109void CalendarView::updateUnmanagedViews() 2109void CalendarView::updateUnmanagedViews()
2110{ 2110{
2111 mDateNavigator->updateDayMatrix(); 2111 mDateNavigator->updateDayMatrix();
2112} 2112}
2113 2113
2114int CalendarView::msgItemDelete() 2114int CalendarView::msgItemDelete()
2115{ 2115{
2116 return KMessageBox::warningContinueCancel(this, 2116 return KMessageBox::warningContinueCancel(this,
2117 i18n("This item will be\npermanently deleted."), 2117 i18n("This item will be\npermanently deleted."),
2118 i18n("KO/Pi Confirmation"),i18n("Delete")); 2118 i18n("KO/Pi Confirmation"),i18n("Delete"));
2119} 2119}
2120 2120
2121 2121
2122void CalendarView::edit_cut() 2122void CalendarView::edit_cut()
2123{ 2123{
2124 Event *anEvent=0; 2124 Event *anEvent=0;
2125 2125
2126 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2126 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2127 2127
2128 if (mViewManager->currentView()->isEventView()) { 2128 if (mViewManager->currentView()->isEventView()) {
2129 if ( incidence && incidence->type() == "Event" ) { 2129 if ( incidence && incidence->type() == "Event" ) {
2130 anEvent = static_cast<Event *>(incidence); 2130 anEvent = static_cast<Event *>(incidence);
2131 } 2131 }
2132 } 2132 }
2133 2133
2134 if (!anEvent) { 2134 if (!anEvent) {
2135 KNotifyClient::beep(); 2135 KNotifyClient::beep();
2136 return; 2136 return;
2137 } 2137 }
2138 DndFactory factory( mCalendar ); 2138 DndFactory factory( mCalendar );
2139 factory.cutEvent(anEvent); 2139 factory.cutEvent(anEvent);
2140 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2140 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2141} 2141}
2142 2142
2143void CalendarView::edit_copy() 2143void CalendarView::edit_copy()
2144{ 2144{
2145 Event *anEvent=0; 2145 Event *anEvent=0;
2146 2146
2147 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2147 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2148 2148
2149 if (mViewManager->currentView()->isEventView()) { 2149 if (mViewManager->currentView()->isEventView()) {
2150 if ( incidence && incidence->type() == "Event" ) { 2150 if ( incidence && incidence->type() == "Event" ) {
2151 anEvent = static_cast<Event *>(incidence); 2151 anEvent = static_cast<Event *>(incidence);
2152 } 2152 }
2153 } 2153 }
2154 2154
2155 if (!anEvent) { 2155 if (!anEvent) {
2156 KNotifyClient::beep(); 2156 KNotifyClient::beep();
2157 return; 2157 return;
2158 } 2158 }
2159 DndFactory factory( mCalendar ); 2159 DndFactory factory( mCalendar );
2160 factory.copyEvent(anEvent); 2160 factory.copyEvent(anEvent);
2161} 2161}
2162 2162
2163void CalendarView::edit_paste() 2163void CalendarView::edit_paste()
2164{ 2164{
2165 QDate date = mNavigator->selectedDates().first(); 2165 QDate date = mNavigator->selectedDates().first();
2166 2166
2167 DndFactory factory( mCalendar ); 2167 DndFactory factory( mCalendar );
2168 Event *pastedEvent = factory.pasteEvent( date ); 2168 Event *pastedEvent = factory.pasteEvent( date );
2169 2169
2170 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2170 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2171} 2171}
2172 2172
2173void CalendarView::edit_options() 2173void CalendarView::edit_options()
2174{ 2174{
2175 mDialogManager->showOptionsDialog(); 2175 mDialogManager->showOptionsDialog();
2176 //writeSettings(); 2176 //writeSettings();
2177} 2177}
2178 2178
2179void CalendarView::slotSelectPickerDate( QDate d) 2179void CalendarView::slotSelectPickerDate( QDate d)
2180{ 2180{
2181 mDateFrame->hide(); 2181 mDateFrame->hide();
2182 if ( mDatePickerMode == 1 ) { 2182 if ( mDatePickerMode == 1 ) {
2183 mNavigator->slotDaySelect( d ); 2183 mNavigator->slotDaySelect( d );
2184 } else if ( mDatePickerMode == 2 ) { 2184 } else if ( mDatePickerMode == 2 ) {
2185 if ( mMoveIncidence->type() == "Todo" ) { 2185 if ( mMoveIncidence->type() == "Todo" ) {
2186 Todo * to = (Todo *) mMoveIncidence; 2186 Todo * to = (Todo *) mMoveIncidence;
2187 QTime tim; 2187 QTime tim;
2188 if ( to->hasDueDate() ) 2188 if ( to->hasDueDate() )
2189 tim = to->dtDue().time(); 2189 tim = to->dtDue().time();
2190 else { 2190 else {
2191 tim = QTime ( 0,0,0 ); 2191 tim = QTime ( 0,0,0 );
2192 to->setFloats( true ); 2192 to->setFloats( true );
2193 to->setHasDueDate( true ); 2193 to->setHasDueDate( true );
2194 } 2194 }
2195 QDateTime dt ( d,tim ); 2195 QDateTime dt ( d,tim );
2196 to->setDtDue( dt ); 2196 to->setDtDue( dt );
2197 todoChanged( to ); 2197 todoChanged( to );
2198 } else { 2198 } else {
2199 QTime tim = mMoveIncidence->dtStart().time(); 2199 QTime tim = mMoveIncidence->dtStart().time();
2200 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2200 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2201 QDateTime dt ( d,tim ); 2201 QDateTime dt ( d,tim );
2202 mMoveIncidence->setDtStart( dt ); 2202 mMoveIncidence->setDtStart( dt );
2203 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2203 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2204 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2204 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2205 } 2205 }
2206 2206
2207 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2207 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2208 } 2208 }
2209} 2209}
2210 2210
2211void CalendarView::removeCategories() 2211void CalendarView::removeCategories()
2212{ 2212{
2213 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2213 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2214 QStringList catList = KOPrefs::instance()->mCustomCategories; 2214 QStringList catList = KOPrefs::instance()->mCustomCategories;
2215 QStringList catIncList; 2215 QStringList catIncList;
2216 QStringList newCatList; 2216 QStringList newCatList;
2217 Incidence* inc = incList.first(); 2217 Incidence* inc = incList.first();
2218 int i; 2218 int i;
2219 int count = 0; 2219 int count = 0;
2220 while ( inc ) { 2220 while ( inc ) {
2221 newCatList.clear(); 2221 newCatList.clear();
2222 catIncList = inc->categories() ; 2222 catIncList = inc->categories() ;
2223 for( i = 0; i< catIncList.count(); ++i ) { 2223 for( i = 0; i< catIncList.count(); ++i ) {
2224 if ( catList.contains (catIncList[i])) 2224 if ( catList.contains (catIncList[i]))
2225 newCatList.append( catIncList[i] ); 2225 newCatList.append( catIncList[i] );
2226 } 2226 }
2227 newCatList.sort(); 2227 newCatList.sort();
2228 inc->setCategories( newCatList.join(",") ); 2228 inc->setCategories( newCatList.join(",") );
2229 inc = incList.next(); 2229 inc = incList.next();
2230 } 2230 }
2231} 2231}
2232 2232
2233int CalendarView::addCategories() 2233int CalendarView::addCategories()
2234{ 2234{
2235 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2235 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2236 QStringList catList = KOPrefs::instance()->mCustomCategories; 2236 QStringList catList = KOPrefs::instance()->mCustomCategories;
2237 QStringList catIncList; 2237 QStringList catIncList;
2238 Incidence* inc = incList.first(); 2238 Incidence* inc = incList.first();
2239 int i; 2239 int i;
2240 int count = 0; 2240 int count = 0;
2241 while ( inc ) { 2241 while ( inc ) {
2242 catIncList = inc->categories() ; 2242 catIncList = inc->categories() ;
2243 for( i = 0; i< catIncList.count(); ++i ) { 2243 for( i = 0; i< catIncList.count(); ++i ) {
2244 if ( !catList.contains (catIncList[i])) { 2244 if ( !catList.contains (catIncList[i])) {
2245 catList.append( catIncList[i] ); 2245 catList.append( catIncList[i] );
2246 //qDebug("add cat %s ", catIncList[i].latin1()); 2246 //qDebug("add cat %s ", catIncList[i].latin1());
2247 ++count; 2247 ++count;
2248 } 2248 }
2249 } 2249 }
2250 inc = incList.next(); 2250 inc = incList.next();
2251 } 2251 }
2252 catList.sort(); 2252 catList.sort();
2253 KOPrefs::instance()->mCustomCategories = catList; 2253 KOPrefs::instance()->mCustomCategories = catList;
2254 return count; 2254 return count;
2255} 2255}
2256 2256
2257void CalendarView::manageCategories() 2257void CalendarView::manageCategories()
2258{ 2258{
2259 KOCatPrefs* cp = new KOCatPrefs(); 2259 KOCatPrefs* cp = new KOCatPrefs();
2260 cp->show(); 2260 cp->show();
2261 int w =cp->sizeHint().width() ; 2261 int w =cp->sizeHint().width() ;
2262 int h = cp->sizeHint().height() ; 2262 int h = cp->sizeHint().height() ;
2263 int dw = QApplication::desktop()->width(); 2263 int dw = QApplication::desktop()->width();
2264 int dh = QApplication::desktop()->height(); 2264 int dh = QApplication::desktop()->height();
2265 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2265 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2266 if ( !cp->exec() ) { 2266 if ( !cp->exec() ) {
2267 delete cp; 2267 delete cp;
2268 return; 2268 return;
2269 } 2269 }
2270 int count = 0; 2270 int count = 0;
2271 if ( cp->addCat() ) { 2271 if ( cp->addCat() ) {
2272 count = addCategories(); 2272 count = addCategories();
2273 if ( count ) { 2273 if ( count ) {
2274 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2274 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2275 writeSettings(); 2275 writeSettings();
2276 } 2276 }
2277 } else { 2277 } else {
2278 removeCategories(); 2278 removeCategories();
2279 updateView(); 2279 updateView();
2280 } 2280 }
2281 delete cp; 2281 delete cp;
2282} 2282}
2283 2283
2284void CalendarView::beamIncidence(Incidence * Inc) 2284void CalendarView::beamIncidence(Incidence * Inc)
2285{ 2285{
2286 QPtrList<Incidence> delSel ; 2286 QPtrList<Incidence> delSel ;
2287 delSel.append(Inc); 2287 delSel.append(Inc);
2288 beamIncidenceList( delSel ); 2288 beamIncidenceList( delSel );
2289} 2289}
2290void CalendarView::beamCalendar() 2290void CalendarView::beamCalendar()
2291{ 2291{
2292 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2292 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2293 //qDebug("beamCalendar() "); 2293 //qDebug("beamCalendar() ");
2294 beamIncidenceList( delSel ); 2294 beamIncidenceList( delSel );
2295} 2295}
2296void CalendarView::beamFilteredCalendar() 2296void CalendarView::beamFilteredCalendar()
2297{ 2297{
2298 QPtrList<Incidence> delSel = mCalendar->incidences(); 2298 QPtrList<Incidence> delSel = mCalendar->incidences();
2299 //qDebug("beamFilteredCalendar() "); 2299 //qDebug("beamFilteredCalendar() ");
2300 beamIncidenceList( delSel ); 2300 beamIncidenceList( delSel );
2301} 2301}
2302void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2302void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2303{ 2303{
2304 if ( beamDialog->exec () == QDialog::Rejected ) 2304 if ( beamDialog->exec () == QDialog::Rejected )
2305 return; 2305 return;
2306 2306
2307 QString fn = "/tmp/kopibeamfile"; 2307 QString fn = "/tmp/kopibeamfile";
2308 QString mes; 2308 QString mes;
2309 bool createbup = true; 2309 bool createbup = true;
2310 if ( createbup ) { 2310 if ( createbup ) {
2311 QString description = "\n"; 2311 QString description = "\n";
2312 CalendarLocal* cal = new CalendarLocal(); 2312 CalendarLocal* cal = new CalendarLocal();
2313 if ( beamDialog->beamLocal() ) 2313 if ( beamDialog->beamLocal() )
2314 cal->setLocalTime(); 2314 cal->setLocalTime();
2315 else 2315 else
2316 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 2316 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
2317 Incidence *incidence = delSel.first(); 2317 Incidence *incidence = delSel.first();
2318 bool addText = false; 2318 bool addText = false;
2319 if ( delSel.count() < 10 ) 2319 if ( delSel.count() < 10 )
2320 addText = true; 2320 addText = true;
2321 else { 2321 else {
2322 description.sprintf(i18n(" %d items?"),delSel.count() ); 2322 description.sprintf(i18n(" %d items?"),delSel.count() );
2323 } 2323 }
2324 while ( incidence ) { 2324 while ( incidence ) {
2325 Incidence *in = incidence->clone(); 2325 Incidence *in = incidence->clone();
2326 if ( ! in->summary().isEmpty() ) {
2327 in->setDescription("");
2328 } else {
2329 in->setSummary( in->description().left(20));
2330 in->setDescription("");
2331 }
2326 if ( addText ) 2332 if ( addText )
2327 description += in->summary() + "\n"; 2333 description += in->summary() + "\n";
2328 cal->addIncidence( in ); 2334 cal->addIncidence( in );
2329 incidence = delSel.next(); 2335 incidence = delSel.next();
2330 } 2336 }
2331 if ( beamDialog->beamVcal() ) { 2337 if ( beamDialog->beamVcal() ) {
2332 fn += ".vcs"; 2338 fn += ".vcs";
2333 FileStorage storage( cal, fn, new VCalFormat ); 2339 FileStorage storage( cal, fn, new VCalFormat );
2334 storage.save(); 2340 storage.save();
2335 } else { 2341 } else {
2336 fn += ".ics"; 2342 fn += ".ics";
2337 FileStorage storage( cal, fn, new ICalFormat( ) ); 2343 FileStorage storage( cal, fn, new ICalFormat( ) );
2338 storage.save(); 2344 storage.save();
2339 } 2345 }
2340 delete cal; 2346 delete cal;
2341 mes = i18n("KO/Pi: Ready for beaming"); 2347 mes = i18n("KO/Pi: Ready for beaming");
2342 setCaption(mes); 2348 topLevelWidget()->setCaption(mes);
2343 2349 KApplication::convert2latin1( fn );
2344#ifndef DESKTOP_VERSION 2350#ifndef DESKTOP_VERSION
2345 Ir *ir = new Ir( this ); 2351 Ir *ir = new Ir( this );
2346 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2352 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2347 ir->send( fn, description, "text/x-vCalendar" ); 2353 ir->send( fn, description, "text/x-vCalendar" );
2348#endif 2354#endif
2349 } 2355 }
2350} 2356}
2351void CalendarView::beamDone( Ir *ir ) 2357void CalendarView::beamDone( Ir *ir )
2352{ 2358{
2353#ifndef DESKTOP_VERSION 2359#ifndef DESKTOP_VERSION
2354 delete ir; 2360 delete ir;
2355#endif 2361#endif
2362 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2363 topLevelWidget()->raise();
2356} 2364}
2357 2365
2358void CalendarView::moveIncidence(Incidence * inc ) 2366void CalendarView::moveIncidence(Incidence * inc )
2359{ 2367{
2360 if ( !inc ) return; 2368 if ( !inc ) return;
2361 // qDebug("showDatePickerForIncidence( ) "); 2369 // qDebug("showDatePickerForIncidence( ) ");
2362 if ( mDateFrame->isVisible() ) 2370 if ( mDateFrame->isVisible() )
2363 mDateFrame->hide(); 2371 mDateFrame->hide();
2364 else { 2372 else {
2365 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; 2373 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
2366 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; 2374 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
2367 int dw = QApplication::desktop()->width(); 2375 int dw = QApplication::desktop()->width();
2368 int dh = QApplication::desktop()->height(); 2376 int dh = QApplication::desktop()->height();
2369 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2377 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2370 mDateFrame->show(); 2378 mDateFrame->show();
2371 } 2379 }
2372 mDatePickerMode = 2; 2380 mDatePickerMode = 2;
2373 mMoveIncidence = inc ; 2381 mMoveIncidence = inc ;
2374 QDate da; 2382 QDate da;
2375 if ( mMoveIncidence->type() == "Todo" ) { 2383 if ( mMoveIncidence->type() == "Todo" ) {
2376 Todo * to = (Todo *) mMoveIncidence; 2384 Todo * to = (Todo *) mMoveIncidence;
2377 if ( to->hasDueDate() ) 2385 if ( to->hasDueDate() )
2378 da = to->dtDue().date(); 2386 da = to->dtDue().date();
2379 else 2387 else
2380 da = QDate::currentDate(); 2388 da = QDate::currentDate();
2381 } else { 2389 } else {
2382 da = mMoveIncidence->dtStart().date(); 2390 da = mMoveIncidence->dtStart().date();
2383 } 2391 }
2384 mDatePicker->setDate( da ); 2392 mDatePicker->setDate( da );
2385} 2393}
2386void CalendarView::showDatePicker( ) 2394void CalendarView::showDatePicker( )
2387{ 2395{
2388 //qDebug("CalendarView::showDatePicker( ) "); 2396 //qDebug("CalendarView::showDatePicker( ) ");
2389 if ( mDateFrame->isVisible() ) 2397 if ( mDateFrame->isVisible() )
2390 mDateFrame->hide(); 2398 mDateFrame->hide();
2391 else { 2399 else {
2392 int w =mDatePicker->sizeHint().width() ; 2400 int w =mDatePicker->sizeHint().width() ;
2393 int h = mDatePicker->sizeHint().height() ; 2401 int h = mDatePicker->sizeHint().height() ;
2394 int dw = QApplication::desktop()->width(); 2402 int dw = QApplication::desktop()->width();
2395 int dh = QApplication::desktop()->height(); 2403 int dh = QApplication::desktop()->height();
2396 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2404 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2397 mDateFrame->show(); 2405 mDateFrame->show();
2398 } 2406 }
2399 mDatePickerMode = 1; 2407 mDatePickerMode = 1;
2400 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2408 mDatePicker->setDate( mNavigator->selectedDates().first() );
2401} 2409}
2402 2410
2403void CalendarView::showEventEditor() 2411void CalendarView::showEventEditor()
2404{ 2412{
2405#ifdef DESKTOP_VERSION 2413#ifdef DESKTOP_VERSION
2406 mEventEditor->show(); 2414 mEventEditor->show();
2407#else 2415#else
2408 mEventEditor->showMaximized(); 2416 mEventEditor->showMaximized();
2409#endif 2417#endif
2410} 2418}
2411void CalendarView::showTodoEditor() 2419void CalendarView::showTodoEditor()
2412{ 2420{
2413#ifdef DESKTOP_VERSION 2421#ifdef DESKTOP_VERSION
2414 mTodoEditor->show(); 2422 mTodoEditor->show();
2415#else 2423#else
2416 mTodoEditor->showMaximized(); 2424 mTodoEditor->showMaximized();
2417#endif 2425#endif
2418} 2426}
2419 2427
2420void CalendarView::cloneIncidence() 2428void CalendarView::cloneIncidence()
2421{ 2429{
2422 Incidence *incidence = currentSelection(); 2430 Incidence *incidence = currentSelection();
2423 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2431 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2424 if ( incidence ) { 2432 if ( incidence ) {
2425 cloneIncidence(incidence); 2433 cloneIncidence(incidence);
2426 } 2434 }
2427} 2435}
2428void CalendarView::moveIncidence() 2436void CalendarView::moveIncidence()
2429{ 2437{
2430 Incidence *incidence = currentSelection(); 2438 Incidence *incidence = currentSelection();
2431 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2439 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2432 if ( incidence ) { 2440 if ( incidence ) {
2433 moveIncidence(incidence); 2441 moveIncidence(incidence);
2434 } 2442 }
2435} 2443}
2436void CalendarView::beamIncidence() 2444void CalendarView::beamIncidence()
2437{ 2445{
2438 Incidence *incidence = currentSelection(); 2446 Incidence *incidence = currentSelection();
2439 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2447 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2440 if ( incidence ) { 2448 if ( incidence ) {
2441 beamIncidence(incidence); 2449 beamIncidence(incidence);
2442 } 2450 }
2443} 2451}
2444void CalendarView::toggleCancelIncidence() 2452void CalendarView::toggleCancelIncidence()
2445{ 2453{
2446 Incidence *incidence = currentSelection(); 2454 Incidence *incidence = currentSelection();
2447 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2455 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2448 if ( incidence ) { 2456 if ( incidence ) {
2449 cancelIncidence(incidence); 2457 cancelIncidence(incidence);
2450 } 2458 }
2451} 2459}
2452 2460
2453 2461
2454void CalendarView::cancelIncidence(Incidence * inc ) 2462void CalendarView::cancelIncidence(Incidence * inc )
2455{ 2463{
2456 inc->setCancelled( ! inc->cancelled() ); 2464 inc->setCancelled( ! inc->cancelled() );
2457 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2465 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2458 updateView(); 2466 updateView();
2459} 2467}
2460void CalendarView::cloneIncidence(Incidence * orgInc ) 2468void CalendarView::cloneIncidence(Incidence * orgInc )
2461{ 2469{
2462 Incidence * newInc = orgInc->clone(); 2470 Incidence * newInc = orgInc->clone();
2463 newInc->recreate(); 2471 newInc->recreate();
2464 2472
2465 if ( newInc->type() == "Todo" ) { 2473 if ( newInc->type() == "Todo" ) {
2466 Todo* t = (Todo*) newInc; 2474 Todo* t = (Todo*) newInc;
2467 mTodoEditor->editTodo( t ); 2475 mTodoEditor->editTodo( t );
2468 showTodoEditor(); 2476 showTodoEditor();
2469 if ( mTodoEditor->exec() ) { 2477 if ( mTodoEditor->exec() ) {
2470 mCalendar->addTodo( t ); 2478 mCalendar->addTodo( t );
2471 updateView(); 2479 updateView();
2472 } else { 2480 } else {
2473 delete t; 2481 delete t;
2474 } 2482 }
2475 } 2483 }
2476 else { 2484 else {
2477 Event* e = (Event*) newInc; 2485 Event* e = (Event*) newInc;
2478 mEventEditor->editEvent( e ); 2486 mEventEditor->editEvent( e );
2479 showEventEditor(); 2487 showEventEditor();
2480 if ( mEventEditor->exec() ) { 2488 if ( mEventEditor->exec() ) {
2481 mCalendar->addEvent( e ); 2489 mCalendar->addEvent( e );
2482 updateView(); 2490 updateView();
2483 } else { 2491 } else {
2484 delete e; 2492 delete e;
2485 } 2493 }
2486 } 2494 }
2487} 2495}
2488 2496
2489void CalendarView::newEvent() 2497void CalendarView::newEvent()
2490{ 2498{
2491 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2499 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2492 KOAgendaView *aView = mViewManager->agendaView(); 2500 KOAgendaView *aView = mViewManager->agendaView();
2493 if (aView) { 2501 if (aView) {
2494 if (aView->selectionStart().isValid()) { 2502 if (aView->selectionStart().isValid()) {
2495 if (aView->selectedIsAllDay()) { 2503 if (aView->selectedIsAllDay()) {
2496 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2504 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2497 } else { 2505 } else {
2498 newEvent(aView->selectionStart(),aView->selectionEnd()); 2506 newEvent(aView->selectionStart(),aView->selectionEnd());
2499 } 2507 }
2500 return; 2508 return;
2501 } 2509 }
2502 } 2510 }
2503 2511
2504 QDate date = mNavigator->selectedDates().first(); 2512 QDate date = mNavigator->selectedDates().first();
2505 QDateTime current = QDateTime::currentDateTime(); 2513 QDateTime current = QDateTime::currentDateTime();
2506 if ( date <= current.date() ) { 2514 if ( date <= current.date() ) {
2507 int hour = current.time().hour() +1; 2515 int hour = current.time().hour() +1;
2508 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2516 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2509 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2517 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2510 } else 2518 } else
2511 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2519 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2512 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2520 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2513 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2521 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2514} 2522}
2515 2523
2516void CalendarView::newEvent(QDateTime fh) 2524void CalendarView::newEvent(QDateTime fh)
2517{ 2525{
2518 newEvent(fh, 2526 newEvent(fh,
2519 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2527 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2520} 2528}
2521 2529
2522void CalendarView::newEvent(QDate dt) 2530void CalendarView::newEvent(QDate dt)
2523{ 2531{
2524 newEvent(QDateTime(dt, QTime(0,0,0)), 2532 newEvent(QDateTime(dt, QTime(0,0,0)),
2525 QDateTime(dt, QTime(0,0,0)), true); 2533 QDateTime(dt, QTime(0,0,0)), true);
2526} 2534}
2527 2535
2528void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2536void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2529{ 2537{
2530 2538
2531 mEventEditor->newEvent(fromHint,toHint,allDay); 2539 mEventEditor->newEvent(fromHint,toHint,allDay);
2532 if ( mFilterView->filtersEnabled() ) { 2540 if ( mFilterView->filtersEnabled() ) {
2533 CalFilter *filter = mFilterView->selectedFilter(); 2541 CalFilter *filter = mFilterView->selectedFilter();
2534 if (filter && filter->showCategories()) { 2542 if (filter && filter->showCategories()) {
2535 mEventEditor->setCategories(filter->categoryList().join(",") ); 2543 mEventEditor->setCategories(filter->categoryList().join(",") );
2536 } 2544 }
2537 if ( filter ) 2545 if ( filter )
2538 mEventEditor->setSecrecy( filter->getSecrecy() ); 2546 mEventEditor->setSecrecy( filter->getSecrecy() );
2539 } 2547 }
2540 showEventEditor(); 2548 showEventEditor();
2541} 2549}
2542void CalendarView::todoAdded(Todo * t) 2550void CalendarView::todoAdded(Todo * t)
2543{ 2551{
2544 2552
2545 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2553 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2546 updateTodoViews(); 2554 updateTodoViews();
2547} 2555}
2548void CalendarView::todoChanged(Todo * t) 2556void CalendarView::todoChanged(Todo * t)
2549{ 2557{
2550 emit todoModified( t, 4 ); 2558 emit todoModified( t, 4 );
2551 // updateTodoViews(); 2559 // updateTodoViews();
2552} 2560}
2553void CalendarView::todoToBeDeleted(Todo *) 2561void CalendarView::todoToBeDeleted(Todo *)
2554{ 2562{
2555 //qDebug("todoToBeDeleted(Todo *) "); 2563 //qDebug("todoToBeDeleted(Todo *) ");
2556 updateTodoViews(); 2564 updateTodoViews();
2557} 2565}
2558void CalendarView::todoDeleted() 2566void CalendarView::todoDeleted()
2559{ 2567{
2560 //qDebug(" todoDeleted()"); 2568 //qDebug(" todoDeleted()");
2561 updateTodoViews(); 2569 updateTodoViews();
2562} 2570}
2563 2571
2564 2572
2565 2573
2566void CalendarView::newTodo() 2574void CalendarView::newTodo()
2567{ 2575{
2568 2576
2569 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); 2577 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true);
2570 if ( mFilterView->filtersEnabled() ) { 2578 if ( mFilterView->filtersEnabled() ) {
2571 CalFilter *filter = mFilterView->selectedFilter(); 2579 CalFilter *filter = mFilterView->selectedFilter();
2572 if (filter && filter->showCategories()) { 2580 if (filter && filter->showCategories()) {
2573 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2581 mTodoEditor->setCategories(filter->categoryList().join(",") );
2574 } 2582 }
2575 if ( filter ) 2583 if ( filter )
2576 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2584 mTodoEditor->setSecrecy( filter->getSecrecy() );
2577 } 2585 }
2578 showTodoEditor(); 2586 showTodoEditor();
2579} 2587}
2580 2588
2581void CalendarView::newSubTodo() 2589void CalendarView::newSubTodo()
2582{ 2590{
2583 Todo *todo = selectedTodo(); 2591 Todo *todo = selectedTodo();
2584 if ( todo ) newSubTodo( todo ); 2592 if ( todo ) newSubTodo( todo );
2585} 2593}
2586 2594
2587void CalendarView::newSubTodo(Todo *parentEvent) 2595void CalendarView::newSubTodo(Todo *parentEvent)
2588{ 2596{
2589 2597
2590 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); 2598 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true);
2591 showTodoEditor(); 2599 showTodoEditor();
2592} 2600}
2593 2601
2594void CalendarView::newFloatingEvent() 2602void CalendarView::newFloatingEvent()
2595{ 2603{
2596 DateList tmpList = mNavigator->selectedDates(); 2604 DateList tmpList = mNavigator->selectedDates();
2597 QDate date = tmpList.first(); 2605 QDate date = tmpList.first();
2598 2606
2599 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2607 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2600 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2608 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2601} 2609}
2602 2610
2603 2611
2604void CalendarView::editEvent( Event *event ) 2612void CalendarView::editEvent( Event *event )
2605{ 2613{
2606 2614
2607 if ( !event ) return; 2615 if ( !event ) return;
2608 if ( event->isReadOnly() ) { 2616 if ( event->isReadOnly() ) {
2609 showEvent( event ); 2617 showEvent( event );
2610 return; 2618 return;
2611 } 2619 }
2612 mEventEditor->editEvent( event , mFlagEditDescription); 2620 mEventEditor->editEvent( event , mFlagEditDescription);
2613 showEventEditor(); 2621 showEventEditor();
2614} 2622}
2615void CalendarView::editJournal( Journal *jour ) 2623void CalendarView::editJournal( Journal *jour )
2616{ 2624{
2617 if ( !jour ) return; 2625 if ( !jour ) return;
2618 mDialogManager->hideSearchDialog(); 2626 mDialogManager->hideSearchDialog();
2619 mViewManager->showJournalView(); 2627 mViewManager->showJournalView();
2620 mNavigator->slotDaySelect( jour->dtStart().date() ); 2628 mNavigator->slotDaySelect( jour->dtStart().date() );
2621} 2629}
2622void CalendarView::editTodo( Todo *todo ) 2630void CalendarView::editTodo( Todo *todo )
2623{ 2631{
2624 if ( !todo ) return; 2632 if ( !todo ) return;
2625 2633
2626 if ( todo->isReadOnly() ) { 2634 if ( todo->isReadOnly() ) {
2627 showTodo( todo ); 2635 showTodo( todo );
2628 return; 2636 return;
2629 } 2637 }
2630 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2638 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2631 showTodoEditor(); 2639 showTodoEditor();
2632 2640
2633} 2641}
2634 2642
2635KOEventViewerDialog* CalendarView::getEventViewerDialog() 2643KOEventViewerDialog* CalendarView::getEventViewerDialog()
2636{ 2644{
2637 if ( !mEventViewerDialog ) { 2645 if ( !mEventViewerDialog ) {
2638 mEventViewerDialog = new KOEventViewerDialog(this); 2646 mEventViewerDialog = new KOEventViewerDialog(this);
2639 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2647 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2640 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2648 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2641 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2649 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2642 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2650 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2643 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2651 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2644 viewManager(), SLOT( showAgendaView( bool ) ) ); 2652 viewManager(), SLOT( showAgendaView( bool ) ) );
2645 mEventViewerDialog->resize( 640, 480 ); 2653 mEventViewerDialog->resize( 640, 480 );
2646 2654
2647 } 2655 }
2648 return mEventViewerDialog; 2656 return mEventViewerDialog;
2649} 2657}
2650void CalendarView::showEvent(Event *event) 2658void CalendarView::showEvent(Event *event)
2651{ 2659{
2652 getEventViewerDialog()->setEvent(event); 2660 getEventViewerDialog()->setEvent(event);
2653 getEventViewerDialog()->showMe(); 2661 getEventViewerDialog()->showMe();
2654} 2662}
2655 2663
2656void CalendarView::showTodo(Todo *event) 2664void CalendarView::showTodo(Todo *event)
2657{ 2665{
2658 getEventViewerDialog()->setTodo(event); 2666 getEventViewerDialog()->setTodo(event);
2659 getEventViewerDialog()->showMe(); 2667 getEventViewerDialog()->showMe();
2660} 2668}
2661void CalendarView::showJournal( Journal *jour ) 2669void CalendarView::showJournal( Journal *jour )
2662{ 2670{
2663 getEventViewerDialog()->setJournal(jour); 2671 getEventViewerDialog()->setJournal(jour);
2664 getEventViewerDialog()->showMe(); 2672 getEventViewerDialog()->showMe();
2665 2673
2666} 2674}
2667// void CalendarView::todoModified (Todo *event, int changed) 2675// void CalendarView::todoModified (Todo *event, int changed)
2668// { 2676// {
2669// // if (mDialogList.find (event) != mDialogList.end ()) { 2677// // if (mDialogList.find (event) != mDialogList.end ()) {
2670// // kdDebug() << "Todo modified and open" << endl; 2678// // kdDebug() << "Todo modified and open" << endl;
2671// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2679// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2672// // temp->modified (changed); 2680// // temp->modified (changed);
2673 2681
2674// // } 2682// // }
2675 2683
2676// mViewManager->updateView(); 2684// mViewManager->updateView();
2677// } 2685// }
2678 2686
2679void CalendarView::appointment_show() 2687void CalendarView::appointment_show()
2680{ 2688{
2681 Event *anEvent = 0; 2689 Event *anEvent = 0;
2682 2690
2683 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2691 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2684 2692
2685 if (mViewManager->currentView()->isEventView()) { 2693 if (mViewManager->currentView()->isEventView()) {
2686 if ( incidence && incidence->type() == "Event" ) { 2694 if ( incidence && incidence->type() == "Event" ) {
2687 anEvent = static_cast<Event *>(incidence); 2695 anEvent = static_cast<Event *>(incidence);
2688 } 2696 }
2689 } 2697 }
2690 2698
2691 if (!anEvent) { 2699 if (!anEvent) {
2692 KNotifyClient::beep(); 2700 KNotifyClient::beep();
2693 return; 2701 return;
2694 } 2702 }
2695 2703
2696 showEvent(anEvent); 2704 showEvent(anEvent);
2697} 2705}
2698 2706
2699void CalendarView::appointment_edit() 2707void CalendarView::appointment_edit()
2700{ 2708{
2701 Event *anEvent = 0; 2709 Event *anEvent = 0;
2702 2710
2703 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2711 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2704 2712
2705 if (mViewManager->currentView()->isEventView()) { 2713 if (mViewManager->currentView()->isEventView()) {
2706 if ( incidence && incidence->type() == "Event" ) { 2714 if ( incidence && incidence->type() == "Event" ) {
2707 anEvent = static_cast<Event *>(incidence); 2715 anEvent = static_cast<Event *>(incidence);
2708 } 2716 }
2709 } 2717 }
2710 2718
2711 if (!anEvent) { 2719 if (!anEvent) {
2712 KNotifyClient::beep(); 2720 KNotifyClient::beep();
2713 return; 2721 return;
2714 } 2722 }
2715 2723
2716 editEvent(anEvent); 2724 editEvent(anEvent);
2717} 2725}
2718 2726
2719void CalendarView::appointment_delete() 2727void CalendarView::appointment_delete()
2720{ 2728{
2721 Event *anEvent = 0; 2729 Event *anEvent = 0;
2722 2730
2723 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2731 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2724 2732
2725 if (mViewManager->currentView()->isEventView()) { 2733 if (mViewManager->currentView()->isEventView()) {
2726 if ( incidence && incidence->type() == "Event" ) { 2734 if ( incidence && incidence->type() == "Event" ) {
2727 anEvent = static_cast<Event *>(incidence); 2735 anEvent = static_cast<Event *>(incidence);
2728 } 2736 }
2729 } 2737 }
2730 2738
2731 if (!anEvent) { 2739 if (!anEvent) {
2732 KNotifyClient::beep(); 2740 KNotifyClient::beep();
2733 return; 2741 return;
2734 } 2742 }
2735 2743
2736 deleteEvent(anEvent); 2744 deleteEvent(anEvent);
2737} 2745}
2738 2746
2739void CalendarView::todo_unsub(Todo *anTodo ) 2747void CalendarView::todo_unsub(Todo *anTodo )
2740{ 2748{
2741 // Todo *anTodo = selectedTodo(); 2749 // Todo *anTodo = selectedTodo();
2742 if (!anTodo) return; 2750 if (!anTodo) return;
2743 if (!anTodo->relatedTo()) return; 2751 if (!anTodo->relatedTo()) return;
2744 anTodo->relatedTo()->removeRelation(anTodo); 2752 anTodo->relatedTo()->removeRelation(anTodo);
2745 anTodo->setRelatedTo(0); 2753 anTodo->setRelatedTo(0);
2746 anTodo->updated(); 2754 anTodo->updated();
2747 anTodo->setRelatedToUid(""); 2755 anTodo->setRelatedToUid("");
2748 setModified(true); 2756 setModified(true);
2749 updateView(); 2757 updateView();
2750} 2758}
2751 2759
2752void CalendarView::deleteTodo(Todo *todo) 2760void CalendarView::deleteTodo(Todo *todo)
2753{ 2761{
2754 if (!todo) { 2762 if (!todo) {
2755 KNotifyClient::beep(); 2763 KNotifyClient::beep();
2756 return; 2764 return;
2757 } 2765 }
2758 if (KOPrefs::instance()->mConfirm) { 2766 if (KOPrefs::instance()->mConfirm) {
2759 switch (msgItemDelete()) { 2767 switch (msgItemDelete()) {
2760 case KMessageBox::Continue: // OK 2768 case KMessageBox::Continue: // OK
2761 if (!todo->relations().isEmpty()) { 2769 if (!todo->relations().isEmpty()) {
2762 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2770 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2763 i18n("Delete To-Do")); 2771 i18n("Delete To-Do"));
2764 } else { 2772 } else {
2765 checkExternalId( todo ); 2773 checkExternalId( todo );
2766 calendar()->deleteTodo(todo); 2774 calendar()->deleteTodo(todo);
2767 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2775 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2768 updateView(); 2776 updateView();
2769 } 2777 }
2770 break; 2778 break;
2771 } // switch 2779 } // switch
2772 } else { 2780 } else {
2773 if (!todo->relations().isEmpty()) { 2781 if (!todo->relations().isEmpty()) {
2774 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2782 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2775 i18n("Delete To-Do")); 2783 i18n("Delete To-Do"));
2776 } else { 2784 } else {
2777 checkExternalId( todo ); 2785 checkExternalId( todo );
2778 mCalendar->deleteTodo(todo); 2786 mCalendar->deleteTodo(todo);
2779 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2787 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2780 updateView(); 2788 updateView();
2781 } 2789 }
2782 } 2790 }
2783 emit updateSearchDialog(); 2791 emit updateSearchDialog();
2784} 2792}
2785void CalendarView::deleteJournal(Journal *jour) 2793void CalendarView::deleteJournal(Journal *jour)
2786{ 2794{
2787 if (!jour) { 2795 if (!jour) {
2788 KNotifyClient::beep(); 2796 KNotifyClient::beep();
2789 return; 2797 return;
2790 } 2798 }
2791 if (KOPrefs::instance()->mConfirm) { 2799 if (KOPrefs::instance()->mConfirm) {
2792 switch (msgItemDelete()) { 2800 switch (msgItemDelete()) {
2793 case KMessageBox::Continue: // OK 2801 case KMessageBox::Continue: // OK
2794 calendar()->deleteJournal(jour); 2802 calendar()->deleteJournal(jour);
2795 updateView(); 2803 updateView();
2796 break; 2804 break;
2797 } // switch 2805 } // switch
2798 } else { 2806 } else {
2799 calendar()->deleteJournal(jour);; 2807 calendar()->deleteJournal(jour);;
2800 updateView(); 2808 updateView();
2801 } 2809 }
2802 emit updateSearchDialog(); 2810 emit updateSearchDialog();
2803} 2811}
2804 2812
2805void CalendarView::deleteEvent(Event *anEvent) 2813void CalendarView::deleteEvent(Event *anEvent)
2806{ 2814{
2807 if (!anEvent) { 2815 if (!anEvent) {
2808 KNotifyClient::beep(); 2816 KNotifyClient::beep();
2809 return; 2817 return;
2810 } 2818 }
2811 2819
2812 if (anEvent->recurrence()->doesRecur()) { 2820 if (anEvent->recurrence()->doesRecur()) {
2813 QDate itemDate = mViewManager->currentSelectionDate(); 2821 QDate itemDate = mViewManager->currentSelectionDate();
2814 int km; 2822 int km;
2815 if (!itemDate.isValid()) { 2823 if (!itemDate.isValid()) {
2816 //kdDebug() << "Date Not Valid" << endl; 2824 //kdDebug() << "Date Not Valid" << endl;
2817 if (KOPrefs::instance()->mConfirm) { 2825 if (KOPrefs::instance()->mConfirm) {
2818 km = KMessageBox::warningContinueCancel(this,anEvent->summary() + 2826 km = KMessageBox::warningContinueCancel(this,anEvent->summary() +
2819 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 2827 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
2820 i18n("KO/Pi Confirmation"),i18n("Delete All")); 2828 i18n("KO/Pi Confirmation"),i18n("Delete All"));
2821 if ( km == KMessageBox::Continue ) 2829 if ( km == KMessageBox::Continue )
2822 km = KMessageBox::No; // No = all below 2830 km = KMessageBox::No; // No = all below
2823 } else 2831 } else
2824 km = KMessageBox::No; 2832 km = KMessageBox::No;
2825 } else { 2833 } else {
2826 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + 2834 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() +
2827 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 2835 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
2828 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 2836 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
2829 i18n("KO/Pi Confirmation"),i18n("Current"), 2837 i18n("KO/Pi Confirmation"),i18n("Current"),
2830 i18n("All")); 2838 i18n("All"));
2831 } 2839 }
2832 switch(km) { 2840 switch(km) {
2833 2841
2834 case KMessageBox::No: // Continue // all 2842 case KMessageBox::No: // Continue // all
2835 //qDebug("KMessageBox::No "); 2843 //qDebug("KMessageBox::No ");
2836 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2844 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2837 schedule(Scheduler::Cancel,anEvent); 2845 schedule(Scheduler::Cancel,anEvent);
2838 2846
2839 checkExternalId( anEvent); 2847 checkExternalId( anEvent);
2840 mCalendar->deleteEvent(anEvent); 2848 mCalendar->deleteEvent(anEvent);
2841 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 2849 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
2842 break; 2850 break;
2843 2851
2844 // Disabled because it does not work 2852 // Disabled because it does not work
2845 //#if 0 2853 //#if 0
2846 case KMessageBox::Yes: // just this one 2854 case KMessageBox::Yes: // just this one
2847 //QDate qd = mNavigator->selectedDates().first(); 2855 //QDate qd = mNavigator->selectedDates().first();
2848 //if (!qd.isValid()) { 2856 //if (!qd.isValid()) {
2849 // kdDebug() << "no date selected, or invalid date" << endl; 2857 // kdDebug() << "no date selected, or invalid date" << endl;
2850 // KNotifyClient::beep(); 2858 // KNotifyClient::beep();
2851 // return; 2859 // return;
2852 //} 2860 //}
2853 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 2861 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
2854 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 2862 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
2855 anEvent->addExDate(itemDate); 2863 anEvent->addExDate(itemDate);
2856 int duration = anEvent->recurrence()->duration(); 2864 int duration = anEvent->recurrence()->duration();
2857 if ( duration > 0 ) { 2865 if ( duration > 0 ) {
2858 anEvent->recurrence()->setDuration( duration - 1 ); 2866 anEvent->recurrence()->setDuration( duration - 1 );
2859 } 2867 }
2860 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 2868 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
2861 } 2869 }
2862 break; 2870 break;
2863 //#endif 2871 //#endif
2864 } // switch 2872 } // switch
2865 } else { 2873 } else {
2866 if (KOPrefs::instance()->mConfirm) { 2874 if (KOPrefs::instance()->mConfirm) {
2867 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + 2875 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() +
2868 i18n("\nAre you sure you want\nto delete this event?"), 2876 i18n("\nAre you sure you want\nto delete this event?"),
2869 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 2877 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
2870 case KMessageBox::Continue: // OK 2878 case KMessageBox::Continue: // OK
2871 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2879 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2872 schedule(Scheduler::Cancel,anEvent); 2880 schedule(Scheduler::Cancel,anEvent);
2873 checkExternalId( anEvent); 2881 checkExternalId( anEvent);
2874 mCalendar->deleteEvent(anEvent); 2882 mCalendar->deleteEvent(anEvent);
2875 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2883 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2876 break; 2884 break;
2877 } // switch 2885 } // switch
2878 } else { 2886 } else {
2879 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2887 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2880 schedule(Scheduler::Cancel,anEvent); 2888 schedule(Scheduler::Cancel,anEvent);
2881 checkExternalId( anEvent); 2889 checkExternalId( anEvent);
2882 mCalendar->deleteEvent(anEvent); 2890 mCalendar->deleteEvent(anEvent);
2883 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2891 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2884 } 2892 }
2885 } // if-else 2893 } // if-else
2886 emit updateSearchDialog(); 2894 emit updateSearchDialog();
2887} 2895}
2888 2896
2889bool CalendarView::deleteEvent(const QString &uid) 2897bool CalendarView::deleteEvent(const QString &uid)
2890{ 2898{
2891 Event *ev = mCalendar->event(uid); 2899 Event *ev = mCalendar->event(uid);
2892 if (ev) { 2900 if (ev) {
2893 deleteEvent(ev); 2901 deleteEvent(ev);
2894 return true; 2902 return true;
2895 } else { 2903 } else {
2896 return false; 2904 return false;
2897 } 2905 }
2898} 2906}
2899 2907
2900/*****************************************************************************/ 2908/*****************************************************************************/
2901 2909
2902void CalendarView::action_mail() 2910void CalendarView::action_mail()
2903{ 2911{
2904#ifndef KORG_NOMAIL 2912#ifndef KORG_NOMAIL
2905 KOMailClient mailClient; 2913 KOMailClient mailClient;
2906 2914
2907 Incidence *incidence = currentSelection(); 2915 Incidence *incidence = currentSelection();
2908 2916
2909 if (!incidence) { 2917 if (!incidence) {
2910 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2918 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2911 return; 2919 return;
2912 } 2920 }
2913 if(incidence->attendeeCount() == 0 ) { 2921 if(incidence->attendeeCount() == 0 ) {
2914 KMessageBox::sorry(this, 2922 KMessageBox::sorry(this,
2915 i18n("Can't generate mail:\nNo attendees defined.\n")); 2923 i18n("Can't generate mail:\nNo attendees defined.\n"));
2916 return; 2924 return;
2917 } 2925 }
2918 2926
2919 CalendarLocal cal_tmp; 2927 CalendarLocal cal_tmp;
2920 Event *event = 0; 2928 Event *event = 0;
2921 Event *ev = 0; 2929 Event *ev = 0;
2922 if ( incidence && incidence->type() == "Event" ) { 2930 if ( incidence && incidence->type() == "Event" ) {
2923 event = static_cast<Event *>(incidence); 2931 event = static_cast<Event *>(incidence);
2924 ev = new Event(*event); 2932 ev = new Event(*event);
2925 cal_tmp.addEvent(ev); 2933 cal_tmp.addEvent(ev);
2926 } 2934 }
2927 ICalFormat mForm(); 2935 ICalFormat mForm();
2928 QString attachment = mForm.toString( &cal_tmp ); 2936 QString attachment = mForm.toString( &cal_tmp );
2929 if (ev) delete(ev); 2937 if (ev) delete(ev);
2930 2938
2931 mailClient.mailAttendees(currentSelection(), attachment); 2939 mailClient.mailAttendees(currentSelection(), attachment);
2932 2940
2933#endif 2941#endif
2934 2942
2935#if 0 2943#if 0
2936 Event *anEvent = 0; 2944 Event *anEvent = 0;
2937 if (mViewManager->currentView()->isEventView()) { 2945 if (mViewManager->currentView()->isEventView()) {
2938 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 2946 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
2939 } 2947 }
2940 2948
2941 if (!anEvent) { 2949 if (!anEvent) {
2942 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2950 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2943 return; 2951 return;
2944 } 2952 }
2945 if(anEvent->attendeeCount() == 0 ) { 2953 if(anEvent->attendeeCount() == 0 ) {
2946 KMessageBox::sorry(this, 2954 KMessageBox::sorry(this,
2947 i18n("Can't generate mail:\nNo attendees defined.\n")); 2955 i18n("Can't generate mail:\nNo attendees defined.\n"));
2948 return; 2956 return;
2949 } 2957 }
2950 2958
2951 mailobject.emailEvent(anEvent); 2959 mailobject.emailEvent(anEvent);
2952#endif 2960#endif
2953} 2961}
2954 2962
2955 2963
2956void CalendarView::schedule_publish(Incidence *incidence) 2964void CalendarView::schedule_publish(Incidence *incidence)
2957{ 2965{
2958 Event *event = 0; 2966 Event *event = 0;
2959 Todo *todo = 0; 2967 Todo *todo = 0;
2960 2968
2961 if (incidence == 0) { 2969 if (incidence == 0) {
2962 incidence = mViewManager->currentView()->selectedIncidences().first(); 2970 incidence = mViewManager->currentView()->selectedIncidences().first();
2963 if (incidence == 0) { 2971 if (incidence == 0) {
2964 incidence = mTodoList->selectedIncidences().first(); 2972 incidence = mTodoList->selectedIncidences().first();
2965 } 2973 }
2966 } 2974 }
2967 if ( incidence && incidence->type() == "Event" ) { 2975 if ( incidence && incidence->type() == "Event" ) {
2968 event = static_cast<Event *>(incidence); 2976 event = static_cast<Event *>(incidence);
2969 } else { 2977 } else {
2970 if ( incidence && incidence->type() == "Todo" ) { 2978 if ( incidence && incidence->type() == "Todo" ) {
2971 todo = static_cast<Todo *>(incidence); 2979 todo = static_cast<Todo *>(incidence);
2972 } 2980 }
2973 } 2981 }
2974 2982
2975 if (!event && !todo) { 2983 if (!event && !todo) {
2976 KMessageBox::sorry(this,i18n("No event selected.")); 2984 KMessageBox::sorry(this,i18n("No event selected."));
2977 return; 2985 return;
2978 } 2986 }
2979 2987
2980 PublishDialog *publishdlg = new PublishDialog(); 2988 PublishDialog *publishdlg = new PublishDialog();
2981 if (incidence->attendeeCount()>0) { 2989 if (incidence->attendeeCount()>0) {
2982 QPtrList<Attendee> attendees = incidence->attendees(); 2990 QPtrList<Attendee> attendees = incidence->attendees();
2983 attendees.first(); 2991 attendees.first();
2984 while ( attendees.current()!=0 ) { 2992 while ( attendees.current()!=0 ) {
2985 publishdlg->addAttendee(attendees.current()); 2993 publishdlg->addAttendee(attendees.current());
2986 attendees.next(); 2994 attendees.next();
2987 } 2995 }
2988 } 2996 }
2989 bool send = true; 2997 bool send = true;
2990 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 2998 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
2991 if ( publishdlg->exec() != QDialog::Accepted ) 2999 if ( publishdlg->exec() != QDialog::Accepted )
2992 send = false; 3000 send = false;
2993 } 3001 }
2994 if ( send ) { 3002 if ( send ) {
2995 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3003 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2996 if ( event ) { 3004 if ( event ) {
2997 Event *ev = new Event(*event); 3005 Event *ev = new Event(*event);
2998 ev->registerObserver(0); 3006 ev->registerObserver(0);
2999 ev->clearAttendees(); 3007 ev->clearAttendees();
3000 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3008 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3001 delete(ev); 3009 delete(ev);
3002 } 3010 }
3003 } else { 3011 } else {
3004 if ( todo ) { 3012 if ( todo ) {
3005 Todo *ev = new Todo(*todo); 3013 Todo *ev = new Todo(*todo);
3006 ev->registerObserver(0); 3014 ev->registerObserver(0);
3007 ev->clearAttendees(); 3015 ev->clearAttendees();
3008 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3016 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3009 delete(ev); 3017 delete(ev);
3010 } 3018 }
3011 } 3019 }
3012 } 3020 }
3013 } 3021 }
3014 delete publishdlg; 3022 delete publishdlg;
3015} 3023}
3016 3024
3017void CalendarView::schedule_request(Incidence *incidence) 3025void CalendarView::schedule_request(Incidence *incidence)
3018{ 3026{
3019 schedule(Scheduler::Request,incidence); 3027 schedule(Scheduler::Request,incidence);
3020} 3028}
3021 3029
3022void CalendarView::schedule_refresh(Incidence *incidence) 3030void CalendarView::schedule_refresh(Incidence *incidence)
3023{ 3031{
3024 schedule(Scheduler::Refresh,incidence); 3032 schedule(Scheduler::Refresh,incidence);
3025} 3033}
3026 3034
3027void CalendarView::schedule_cancel(Incidence *incidence) 3035void CalendarView::schedule_cancel(Incidence *incidence)
3028{ 3036{
3029 schedule(Scheduler::Cancel,incidence); 3037 schedule(Scheduler::Cancel,incidence);
3030} 3038}
3031 3039
3032void CalendarView::schedule_add(Incidence *incidence) 3040void CalendarView::schedule_add(Incidence *incidence)
3033{ 3041{
3034 schedule(Scheduler::Add,incidence); 3042 schedule(Scheduler::Add,incidence);
3035} 3043}
3036 3044
3037void CalendarView::schedule_reply(Incidence *incidence) 3045void CalendarView::schedule_reply(Incidence *incidence)
3038{ 3046{
3039 schedule(Scheduler::Reply,incidence); 3047 schedule(Scheduler::Reply,incidence);
3040} 3048}
3041 3049
3042void CalendarView::schedule_counter(Incidence *incidence) 3050void CalendarView::schedule_counter(Incidence *incidence)
3043{ 3051{
3044 schedule(Scheduler::Counter,incidence); 3052 schedule(Scheduler::Counter,incidence);
3045} 3053}
3046 3054
3047void CalendarView::schedule_declinecounter(Incidence *incidence) 3055void CalendarView::schedule_declinecounter(Incidence *incidence)
3048{ 3056{
3049 schedule(Scheduler::Declinecounter,incidence); 3057 schedule(Scheduler::Declinecounter,incidence);
3050} 3058}
3051 3059
3052void CalendarView::schedule_publish_freebusy(int daysToPublish) 3060void CalendarView::schedule_publish_freebusy(int daysToPublish)
3053{ 3061{
3054 QDateTime start = QDateTime::currentDateTime(); 3062 QDateTime start = QDateTime::currentDateTime();
3055 QDateTime end = start.addDays(daysToPublish); 3063 QDateTime end = start.addDays(daysToPublish);
3056 3064
3057 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 3065 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
3058 freebusy->setOrganizer(KOPrefs::instance()->email()); 3066 freebusy->setOrganizer(KOPrefs::instance()->email());
3059 3067
3060 3068
3061 PublishDialog *publishdlg = new PublishDialog(); 3069 PublishDialog *publishdlg = new PublishDialog();
3062 if ( publishdlg->exec() == QDialog::Accepted ) { 3070 if ( publishdlg->exec() == QDialog::Accepted ) {
3063 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3071 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3064 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 3072 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
3065 delete(freebusy); 3073 delete(freebusy);
3066 } 3074 }
3067 } 3075 }
3068 delete publishdlg; 3076 delete publishdlg;
3069} 3077}
3070 3078
3071void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 3079void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
3072{ 3080{
3073 Event *event = 0; 3081 Event *event = 0;
3074 Todo *todo = 0; 3082 Todo *todo = 0;
3075 3083
3076 if (incidence == 0) { 3084 if (incidence == 0) {
3077 incidence = mViewManager->currentView()->selectedIncidences().first(); 3085 incidence = mViewManager->currentView()->selectedIncidences().first();
3078 if (incidence == 0) { 3086 if (incidence == 0) {
3079 incidence = mTodoList->selectedIncidences().first(); 3087 incidence = mTodoList->selectedIncidences().first();
3080 } 3088 }
3081 } 3089 }
3082 if ( incidence && incidence->type() == "Event" ) { 3090 if ( incidence && incidence->type() == "Event" ) {
3083 event = static_cast<Event *>(incidence); 3091 event = static_cast<Event *>(incidence);
3084 } 3092 }
3085 if ( incidence && incidence->type() == "Todo" ) { 3093 if ( incidence && incidence->type() == "Todo" ) {
3086 todo = static_cast<Todo *>(incidence); 3094 todo = static_cast<Todo *>(incidence);
3087 } 3095 }
3088 3096
3089 if (!event && !todo) { 3097 if (!event && !todo) {
3090 KMessageBox::sorry(this,i18n("No event selected.")); 3098 KMessageBox::sorry(this,i18n("No event selected."));
3091 return; 3099 return;
3092 } 3100 }
3093 3101
3094 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 3102 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
3095 KMessageBox::sorry(this,i18n("The event has no attendees.")); 3103 KMessageBox::sorry(this,i18n("The event has no attendees."));
3096 return; 3104 return;
3097 } 3105 }
3098 3106
3099 Event *ev = 0; 3107 Event *ev = 0;
3100 if (event) ev = new Event(*event); 3108 if (event) ev = new Event(*event);
3101 Todo *to = 0; 3109 Todo *to = 0;
3102 if (todo) to = new Todo(*todo); 3110 if (todo) to = new Todo(*todo);
3103 3111
3104 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 3112 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
3105 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 3113 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
3106 if (!me) { 3114 if (!me) {
3107 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 3115 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
3108 return; 3116 return;
3109 } 3117 }
3110 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 3118 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
3111 StatusDialog *statdlg = new StatusDialog(this); 3119 StatusDialog *statdlg = new StatusDialog(this);
3112 if (!statdlg->exec()==QDialog::Accepted) return; 3120 if (!statdlg->exec()==QDialog::Accepted) return;
3113 me->setStatus( statdlg->status() ); 3121 me->setStatus( statdlg->status() );
3114 delete(statdlg); 3122 delete(statdlg);
3115 } 3123 }
3116 Attendee *menew = new Attendee(*me); 3124 Attendee *menew = new Attendee(*me);
3117 if (ev) { 3125 if (ev) {
3118 ev->clearAttendees(); 3126 ev->clearAttendees();
3119 ev->addAttendee(menew,false); 3127 ev->addAttendee(menew,false);
3120 } else { 3128 } else {
3121 if (to) { 3129 if (to) {
3122 todo->clearAttendees(); 3130 todo->clearAttendees();
3123 todo->addAttendee(menew,false); 3131 todo->addAttendee(menew,false);
3124 } 3132 }
3125 } 3133 }
3126 } 3134 }
3127 3135
3128 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3136 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3129 if (ev) { 3137 if (ev) {
3130 if ( !dlg->addMessage(ev,method) ) delete(ev); 3138 if ( !dlg->addMessage(ev,method) ) delete(ev);
3131 } else { 3139 } else {
3132 if (to) { 3140 if (to) {
3133 if ( !dlg->addMessage(to,method) ) delete(to); 3141 if ( !dlg->addMessage(to,method) ) delete(to);
3134 } 3142 }
3135 } 3143 }
3136} 3144}
3137 3145
3138void CalendarView::openAddressbook() 3146void CalendarView::openAddressbook()
3139{ 3147{
3140 KRun::runCommand("kaddressbook"); 3148 KRun::runCommand("kaddressbook");
3141} 3149}
3142 3150
3143void CalendarView::setModified(bool modified) 3151void CalendarView::setModified(bool modified)
3144{ 3152{
3145 if ( modified ) 3153 if ( modified )
3146 emit signalmodified(); 3154 emit signalmodified();
3147 if (mModified != modified) { 3155 if (mModified != modified) {
3148 mModified = modified; 3156 mModified = modified;
3149 emit modifiedChanged(mModified); 3157 emit modifiedChanged(mModified);
3150 } 3158 }
3151} 3159}
3152 3160
3153bool CalendarView::isReadOnly() 3161bool CalendarView::isReadOnly()
3154{ 3162{
3155 return mReadOnly; 3163 return mReadOnly;
3156} 3164}
3157 3165
3158void CalendarView::setReadOnly(bool readOnly) 3166void CalendarView::setReadOnly(bool readOnly)
3159{ 3167{
3160 if (mReadOnly != readOnly) { 3168 if (mReadOnly != readOnly) {
3161 mReadOnly = readOnly; 3169 mReadOnly = readOnly;
3162 emit readOnlyChanged(mReadOnly); 3170 emit readOnlyChanged(mReadOnly);
3163 } 3171 }
3164} 3172}
3165 3173
3166bool CalendarView::isModified() 3174bool CalendarView::isModified()
3167{ 3175{
3168 return mModified; 3176 return mModified;
3169} 3177}
3170 3178
3171void CalendarView::printSetup() 3179void CalendarView::printSetup()
3172{ 3180{
3173#ifndef KORG_NOPRINTER 3181#ifndef KORG_NOPRINTER
3174 createPrinter(); 3182 createPrinter();
3175 3183
3176 mCalPrinter->setupPrinter(); 3184 mCalPrinter->setupPrinter();
3177#endif 3185#endif
3178} 3186}
3179 3187
3180void CalendarView::print() 3188void CalendarView::print()
3181{ 3189{
3182#ifndef KORG_NOPRINTER 3190#ifndef KORG_NOPRINTER
3183 createPrinter(); 3191 createPrinter();
3184 3192
3185 DateList tmpDateList = mNavigator->selectedDates(); 3193 DateList tmpDateList = mNavigator->selectedDates();
3186 mCalPrinter->print(CalPrinter::Month, 3194 mCalPrinter->print(CalPrinter::Month,
3187 tmpDateList.first(), tmpDateList.last()); 3195 tmpDateList.first(), tmpDateList.last());
3188#endif 3196#endif
3189} 3197}
3190 3198
3191void CalendarView::printPreview() 3199void CalendarView::printPreview()
3192{ 3200{
3193#ifndef KORG_NOPRINTER 3201#ifndef KORG_NOPRINTER
3194 kdDebug() << "CalendarView::printPreview()" << endl; 3202 kdDebug() << "CalendarView::printPreview()" << endl;
3195 3203
3196 createPrinter(); 3204 createPrinter();
3197 3205
3198 DateList tmpDateList = mNavigator->selectedDates(); 3206 DateList tmpDateList = mNavigator->selectedDates();
3199 3207
3200 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3208 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3201 tmpDateList.last()); 3209 tmpDateList.last());
3202#endif 3210#endif
3203} 3211}
3204 3212
3205void CalendarView::exportICalendar() 3213void CalendarView::exportICalendar()
3206{ 3214{
3207 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3215 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3208 3216
3209 // Force correct extension 3217 // Force correct extension
3210 if (filename.right(4) != ".ics") filename += ".ics"; 3218 if (filename.right(4) != ".ics") filename += ".ics";
3211 3219
3212 FileStorage storage( mCalendar, filename, new ICalFormat() ); 3220 FileStorage storage( mCalendar, filename, new ICalFormat() );
3213 storage.save(); 3221 storage.save();
3214} 3222}
3215 3223
3216bool CalendarView::exportVCalendar( QString filename ) 3224bool CalendarView::exportVCalendar( QString filename )
3217{ 3225{
3218 if (mCalendar->journals().count() > 0) { 3226 if (mCalendar->journals().count() > 0) {
3219 int result = KMessageBox::warningContinueCancel(this, 3227 int result = KMessageBox::warningContinueCancel(this,
3220 i18n("The journal entries can not be\nexported to a vCalendar file."), 3228 i18n("The journal entries can not be\nexported to a vCalendar file."),
3221 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3229 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3222 true); 3230 true);
3223 if (result != KMessageBox::Continue) return false; 3231 if (result != KMessageBox::Continue) return false;
3224 } 3232 }
3225 3233
3226 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3234 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3227 3235
3228 // Force correct extension 3236 // Force correct extension
3229 if (filename.right(4) != ".vcs") filename += ".vcs"; 3237 if (filename.right(4) != ".vcs") filename += ".vcs";
3230 3238
3231 FileStorage storage( mCalendar, filename, new VCalFormat ); 3239 FileStorage storage( mCalendar, filename, new VCalFormat );
3232 return storage.save(); 3240 return storage.save();
3233 3241
3234} 3242}
3235 3243
3236void CalendarView::eventUpdated(Incidence *) 3244void CalendarView::eventUpdated(Incidence *)
3237{ 3245{
3238 setModified(); 3246 setModified();
3239 // Don't call updateView here. The code, which has caused the update of the 3247 // Don't call updateView here. The code, which has caused the update of the
3240 // event is responsible for updating the view. 3248 // event is responsible for updating the view.
3241 // updateView(); 3249 // updateView();
3242} 3250}
3243 3251
3244void CalendarView::adaptNavigationUnits() 3252void CalendarView::adaptNavigationUnits()
3245{ 3253{
3246 if (mViewManager->currentView()->isEventView()) { 3254 if (mViewManager->currentView()->isEventView()) {
3247 int days = mViewManager->currentView()->currentDateCount(); 3255 int days = mViewManager->currentView()->currentDateCount();
3248 if (days == 1) { 3256 if (days == 1) {
3249 emit changeNavStringPrev(i18n("&Previous Day")); 3257 emit changeNavStringPrev(i18n("&Previous Day"));
3250 emit changeNavStringNext(i18n("&Next Day")); 3258 emit changeNavStringNext(i18n("&Next Day"));
3251 } else { 3259 } else {
3252 emit changeNavStringPrev(i18n("&Previous Week")); 3260 emit changeNavStringPrev(i18n("&Previous Week"));
3253 emit changeNavStringNext(i18n("&Next Week")); 3261 emit changeNavStringNext(i18n("&Next Week"));
3254 } 3262 }
3255 } 3263 }
3256} 3264}
3257 3265
3258void CalendarView::processMainViewSelection( Incidence *incidence ) 3266void CalendarView::processMainViewSelection( Incidence *incidence )
3259{ 3267{
3260 if ( incidence ) mTodoList->clearSelection(); 3268 if ( incidence ) mTodoList->clearSelection();
3261 processIncidenceSelection( incidence ); 3269 processIncidenceSelection( incidence );
3262} 3270}
3263 3271
3264void CalendarView::processTodoListSelection( Incidence *incidence ) 3272void CalendarView::processTodoListSelection( Incidence *incidence )
3265{ 3273{
3266 if ( incidence && mViewManager->currentView() ) { 3274 if ( incidence && mViewManager->currentView() ) {
3267 mViewManager->currentView()->clearSelection(); 3275 mViewManager->currentView()->clearSelection();
3268 } 3276 }
3269 processIncidenceSelection( incidence ); 3277 processIncidenceSelection( incidence );
3270} 3278}
3271 3279
3272void CalendarView::processIncidenceSelection( Incidence *incidence ) 3280void CalendarView::processIncidenceSelection( Incidence *incidence )
3273{ 3281{
3274 if ( incidence == mSelectedIncidence ) return; 3282 if ( incidence == mSelectedIncidence ) return;
3275 3283
3276 mSelectedIncidence = incidence; 3284 mSelectedIncidence = incidence;
3277 3285
3278 emit incidenceSelected( mSelectedIncidence ); 3286 emit incidenceSelected( mSelectedIncidence );
3279 3287
3280 if ( incidence && incidence->type() == "Event" ) { 3288 if ( incidence && incidence->type() == "Event" ) {
3281 Event *event = static_cast<Event *>( incidence ); 3289 Event *event = static_cast<Event *>( incidence );
3282 if ( event->organizer() == KOPrefs::instance()->email() ) { 3290 if ( event->organizer() == KOPrefs::instance()->email() ) {
3283 emit organizerEventsSelected( true ); 3291 emit organizerEventsSelected( true );
3284 } else { 3292 } else {
3285 emit organizerEventsSelected(false); 3293 emit organizerEventsSelected(false);
3286 } 3294 }
3287 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3295 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3288 KOPrefs::instance()->email() ) ) { 3296 KOPrefs::instance()->email() ) ) {
3289 emit groupEventsSelected( true ); 3297 emit groupEventsSelected( true );
3290 } else { 3298 } else {
3291 emit groupEventsSelected(false); 3299 emit groupEventsSelected(false);
3292 } 3300 }
3293 return; 3301 return;
3294 } else { 3302 } else {
3295 if ( incidence && incidence->type() == "Todo" ) { 3303 if ( incidence && incidence->type() == "Todo" ) {
3296 emit todoSelected( true ); 3304 emit todoSelected( true );
3297 Todo *event = static_cast<Todo *>( incidence ); 3305 Todo *event = static_cast<Todo *>( incidence );
3298 if ( event->organizer() == KOPrefs::instance()->email() ) { 3306 if ( event->organizer() == KOPrefs::instance()->email() ) {
3299 emit organizerEventsSelected( true ); 3307 emit organizerEventsSelected( true );
3300 } else { 3308 } else {
3301 emit organizerEventsSelected(false); 3309 emit organizerEventsSelected(false);
3302 } 3310 }
3303 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3311 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3304 KOPrefs::instance()->email() ) ) { 3312 KOPrefs::instance()->email() ) ) {
3305 emit groupEventsSelected( true ); 3313 emit groupEventsSelected( true );
3306 } else { 3314 } else {
3307 emit groupEventsSelected(false); 3315 emit groupEventsSelected(false);
3308 } 3316 }
3309 return; 3317 return;
3310 } else { 3318 } else {
3311 emit todoSelected( false ); 3319 emit todoSelected( false );
3312 emit organizerEventsSelected(false); 3320 emit organizerEventsSelected(false);
3313 emit groupEventsSelected(false); 3321 emit groupEventsSelected(false);
3314 } 3322 }
3315 return; 3323 return;
3316 } 3324 }
3317 3325
3318 /* if ( incidence && incidence->type() == "Todo" ) { 3326 /* if ( incidence && incidence->type() == "Todo" ) {
3319 emit todoSelected( true ); 3327 emit todoSelected( true );
3320 } else { 3328 } else {
3321 emit todoSelected( false ); 3329 emit todoSelected( false );
3322 }*/ 3330 }*/
3323} 3331}
3324 3332
3325 3333
3326void CalendarView::checkClipboard() 3334void CalendarView::checkClipboard()
3327{ 3335{
3328#ifndef KORG_NODND 3336#ifndef KORG_NODND
3329 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3337 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3330 emit pasteEnabled(true); 3338 emit pasteEnabled(true);
3331 } else { 3339 } else {
3332 emit pasteEnabled(false); 3340 emit pasteEnabled(false);
3333 } 3341 }
3334#endif 3342#endif
3335} 3343}
3336 3344
3337void CalendarView::showDates(const DateList &selectedDates) 3345void CalendarView::showDates(const DateList &selectedDates)
3338{ 3346{
3339 // kdDebug() << "CalendarView::selectDates()" << endl; 3347 // kdDebug() << "CalendarView::selectDates()" << endl;
3340 3348
3341 if ( mViewManager->currentView() ) { 3349 if ( mViewManager->currentView() ) {
3342 updateView( selectedDates.first(), selectedDates.last() ); 3350 updateView( selectedDates.first(), selectedDates.last() );
3343 } else { 3351 } else {
3344 mViewManager->showAgendaView(); 3352 mViewManager->showAgendaView();
3345 } 3353 }
3346 3354
3347 QString selDates; 3355 QString selDates;
3348 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); 3356 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true);
3349 if (selectedDates.first() < selectedDates.last() ) 3357 if (selectedDates.first() < selectedDates.last() )
3350 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3358 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3351 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3359 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3352 3360
3353} 3361}
3354 3362
3355QPtrList<CalFilter> CalendarView::filters() 3363QPtrList<CalFilter> CalendarView::filters()
3356{ 3364{
3357 return mFilters; 3365 return mFilters;
3358 3366
3359} 3367}
3360void CalendarView::editFilters() 3368void CalendarView::editFilters()
3361{ 3369{
3362 // kdDebug() << "CalendarView::editFilters()" << endl; 3370 // kdDebug() << "CalendarView::editFilters()" << endl;
3363 3371
3364 CalFilter *filter = mFilters.first(); 3372 CalFilter *filter = mFilters.first();
3365 while(filter) { 3373 while(filter) {
3366 kdDebug() << " Filter: " << filter->name() << endl; 3374 kdDebug() << " Filter: " << filter->name() << endl;
3367 filter = mFilters.next(); 3375 filter = mFilters.next();
3368 } 3376 }
3369 3377
3370 mDialogManager->showFilterEditDialog(&mFilters); 3378 mDialogManager->showFilterEditDialog(&mFilters);
3371} 3379}
3372void CalendarView::toggleFilter() 3380void CalendarView::toggleFilter()
3373{ 3381{
3374 showFilter(! mFilterView->isVisible()); 3382 showFilter(! mFilterView->isVisible());
3375} 3383}
3376 3384
3377KOFilterView *CalendarView::filterView() 3385KOFilterView *CalendarView::filterView()
3378{ 3386{
3379 return mFilterView; 3387 return mFilterView;
3380} 3388}
3381void CalendarView::selectFilter( int fil ) 3389void CalendarView::selectFilter( int fil )
3382{ 3390{
3383 mFilterView->setSelectedFilter( fil ); 3391 mFilterView->setSelectedFilter( fil );
3384} 3392}
3385void CalendarView::showFilter(bool visible) 3393void CalendarView::showFilter(bool visible)
3386{ 3394{
3387 if (visible) mFilterView->show(); 3395 if (visible) mFilterView->show();
3388 else mFilterView->hide(); 3396 else mFilterView->hide();
3389} 3397}
3390void CalendarView::toggleFilerEnabled( ) 3398void CalendarView::toggleFilerEnabled( )
3391{ 3399{
3392 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3400 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3393 if ( !mFilterView->filtersEnabled() ) 3401 if ( !mFilterView->filtersEnabled() )
3394 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3402 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3395 3403
3396} 3404}
3397void CalendarView::updateFilter() 3405void CalendarView::updateFilter()
3398{ 3406{
3399 CalFilter *filter = mFilterView->selectedFilter(); 3407 CalFilter *filter = mFilterView->selectedFilter();
3400 if (filter) { 3408 if (filter) {
3401 if (mFilterView->filtersEnabled()) { 3409 if (mFilterView->filtersEnabled()) {
3402 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); 3410 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() );
3403 filter->setEnabled(true); 3411 filter->setEnabled(true);
3404 } 3412 }
3405 else filter->setEnabled(false); 3413 else filter->setEnabled(false);
3406 mCalendar->setFilter(filter); 3414 mCalendar->setFilter(filter);
3407 updateView(); 3415 updateView();
3408 } 3416 }
3409} 3417}
3410 3418
3411void CalendarView::filterEdited() 3419void CalendarView::filterEdited()
3412{ 3420{
3413 mFilterView->updateFilters(); 3421 mFilterView->updateFilters();
3414 updateFilter(); 3422 updateFilter();
3415 writeSettings(); 3423 writeSettings();
3416} 3424}
3417 3425
3418 3426
3419void CalendarView::takeOverEvent() 3427void CalendarView::takeOverEvent()
3420{ 3428{
3421 Incidence *incidence = currentSelection(); 3429 Incidence *incidence = currentSelection();
3422 3430
3423 if (!incidence) return; 3431 if (!incidence) return;
3424 3432
3425 incidence->setOrganizer(KOPrefs::instance()->email()); 3433 incidence->setOrganizer(KOPrefs::instance()->email());
3426 incidence->recreate(); 3434 incidence->recreate();
3427 incidence->setReadOnly(false); 3435 incidence->setReadOnly(false);
3428 3436
3429 updateView(); 3437 updateView();
3430} 3438}
3431 3439
3432void CalendarView::takeOverCalendar() 3440void CalendarView::takeOverCalendar()
3433{ 3441{
3434 // TODO: Create Calendar::allIncidences() function and use it here 3442 // TODO: Create Calendar::allIncidences() function and use it here
3435 3443
3436 QPtrList<Event> events = mCalendar->events(); 3444 QPtrList<Event> events = mCalendar->events();
3437 for(uint i=0; i<events.count(); ++i) { 3445 for(uint i=0; i<events.count(); ++i) {
3438 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3446 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3439 events.at(i)->recreate(); 3447 events.at(i)->recreate();
3440 events.at(i)->setReadOnly(false); 3448 events.at(i)->setReadOnly(false);
3441 } 3449 }
3442 3450
3443 QPtrList<Todo> todos = mCalendar->todos(); 3451 QPtrList<Todo> todos = mCalendar->todos();
3444 for(uint i=0; i<todos.count(); ++i) { 3452 for(uint i=0; i<todos.count(); ++i) {
3445 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3453 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3446 todos.at(i)->recreate(); 3454 todos.at(i)->recreate();
3447 todos.at(i)->setReadOnly(false); 3455 todos.at(i)->setReadOnly(false);
3448 } 3456 }
3449 3457
3450 QPtrList<Journal> journals = mCalendar->journals(); 3458 QPtrList<Journal> journals = mCalendar->journals();
3451 for(uint i=0; i<journals.count(); ++i) { 3459 for(uint i=0; i<journals.count(); ++i) {
3452 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3460 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3453 journals.at(i)->recreate(); 3461 journals.at(i)->recreate();
3454 journals.at(i)->setReadOnly(false); 3462 journals.at(i)->setReadOnly(false);
3455 } 3463 }
3456 3464
3457 updateView(); 3465 updateView();
3458} 3466}
3459 3467
3460void CalendarView::showIntro() 3468void CalendarView::showIntro()
3461{ 3469{
3462 kdDebug() << "To be implemented." << endl; 3470 kdDebug() << "To be implemented." << endl;
3463} 3471}
3464 3472
3465QWidgetStack *CalendarView::viewStack() 3473QWidgetStack *CalendarView::viewStack()
3466{ 3474{
3467 return mRightFrame; 3475 return mRightFrame;
3468} 3476}
3469 3477
3470QWidget *CalendarView::leftFrame() 3478QWidget *CalendarView::leftFrame()
3471{ 3479{
3472 return mLeftFrame; 3480 return mLeftFrame;
3473} 3481}
3474 3482
3475DateNavigator *CalendarView::dateNavigator() 3483DateNavigator *CalendarView::dateNavigator()
3476{ 3484{
3477 return mNavigator; 3485 return mNavigator;
3478} 3486}
3479 3487
3480KDateNavigator* CalendarView::dateNavigatorWidget() 3488KDateNavigator* CalendarView::dateNavigatorWidget()
3481{ 3489{
3482 return mDateNavigator; 3490 return mDateNavigator;
3483} 3491}
3484void CalendarView::toggleDateNavigatorWidget() 3492void CalendarView::toggleDateNavigatorWidget()
3485{ 3493{
3486 if (mDateNavigator->isVisible()) 3494 if (mDateNavigator->isVisible())
3487 mDateNavigator->hide(); 3495 mDateNavigator->hide();
3488 else 3496 else
3489 mDateNavigator->show(); 3497 mDateNavigator->show();
3490} 3498}
3491void CalendarView::addView(KOrg::BaseView *view) 3499void CalendarView::addView(KOrg::BaseView *view)
3492{ 3500{
3493 mViewManager->addView(view); 3501 mViewManager->addView(view);
3494} 3502}
3495 3503
3496void CalendarView::showView(KOrg::BaseView *view) 3504void CalendarView::showView(KOrg::BaseView *view)
3497{ 3505{
3498 mViewManager->showView(view, mLeftFrame->isVisible()); 3506 mViewManager->showView(view, mLeftFrame->isVisible());
3499} 3507}
3500 3508
3501Incidence *CalendarView::currentSelection() 3509Incidence *CalendarView::currentSelection()
3502{ 3510{
3503 return mViewManager->currentSelection(); 3511 return mViewManager->currentSelection();
3504} 3512}
3505void CalendarView::toggleAllDaySize() 3513void CalendarView::toggleAllDaySize()
3506{ 3514{
3507 /* 3515 /*
3508 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3516 if ( KOPrefs::instance()->mAllDaySize > 47 )
3509 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3517 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3510 else 3518 else
3511 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3519 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3512 */ 3520 */
3513 viewManager()->agendaView()->toggleAllDay(); 3521 viewManager()->agendaView()->toggleAllDay();
3514} 3522}
3515void CalendarView::toggleExpand() 3523void CalendarView::toggleExpand()
3516{ 3524{
3517 // if ( mLeftFrame->isHidden() ) { 3525 // if ( mLeftFrame->isHidden() ) {
3518 // mLeftFrame->show(); 3526 // mLeftFrame->show();
3519 // emit calendarViewExpanded( false ); 3527 // emit calendarViewExpanded( false );
3520 // } else { 3528 // } else {
3521 // mLeftFrame->hide(); 3529 // mLeftFrame->hide();
3522 // emit calendarViewExpanded( true ); 3530 // emit calendarViewExpanded( true );
3523 // } 3531 // }
3524 3532
3525 globalFlagBlockAgenda = 1; 3533 globalFlagBlockAgenda = 1;
3526 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3534 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3527 globalFlagBlockAgenda = 5; 3535 globalFlagBlockAgenda = 5;
3528 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3536 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3529 //mViewManager->showView( 0, true ); 3537 //mViewManager->showView( 0, true );
3530} 3538}
3531 3539
3532void CalendarView::calendarModified( bool modified, Calendar * ) 3540void CalendarView::calendarModified( bool modified, Calendar * )
3533{ 3541{
3534 setModified( modified ); 3542 setModified( modified );
3535} 3543}
3536 3544
3537Todo *CalendarView::selectedTodo() 3545Todo *CalendarView::selectedTodo()
3538{ 3546{
3539 Incidence *incidence = currentSelection(); 3547 Incidence *incidence = currentSelection();
3540 if ( incidence && incidence->type() == "Todo" ) { 3548 if ( incidence && incidence->type() == "Todo" ) {
3541 return static_cast<Todo *>( incidence ); 3549 return static_cast<Todo *>( incidence );
3542 } 3550 }
3543 3551
3544 incidence = mTodoList->selectedIncidences().first(); 3552 incidence = mTodoList->selectedIncidences().first();
3545 if ( incidence && incidence->type() == "Todo" ) { 3553 if ( incidence && incidence->type() == "Todo" ) {
3546 return static_cast<Todo *>( incidence ); 3554 return static_cast<Todo *>( incidence );
3547 } 3555 }
3548 3556
3549 return 0; 3557 return 0;
3550} 3558}
3551 3559
3552void CalendarView::dialogClosing(Incidence *in) 3560void CalendarView::dialogClosing(Incidence *in)
3553{ 3561{
3554 // mDialogList.remove(in); 3562 // mDialogList.remove(in);
3555} 3563}
3556 3564
3557void CalendarView::showIncidence() 3565void CalendarView::showIncidence()
3558{ 3566{
3559 Incidence *incidence = currentSelection(); 3567 Incidence *incidence = currentSelection();
3560 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3568 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3561 if ( incidence ) { 3569 if ( incidence ) {
3562 ShowIncidenceVisitor v; 3570 ShowIncidenceVisitor v;
3563 v.act( incidence, this ); 3571 v.act( incidence, this );
3564 } 3572 }
3565} 3573}
3566void CalendarView::editIncidenceDescription() 3574void CalendarView::editIncidenceDescription()
3567{ 3575{
3568 mFlagEditDescription = true; 3576 mFlagEditDescription = true;
3569 editIncidence(); 3577 editIncidence();
3570 mFlagEditDescription = false; 3578 mFlagEditDescription = false;
3571} 3579}
3572void CalendarView::editIncidence() 3580void CalendarView::editIncidence()
3573{ 3581{
3574 // qDebug("editIncidence() "); 3582 // qDebug("editIncidence() ");
3575 Incidence *incidence = currentSelection(); 3583 Incidence *incidence = currentSelection();
3576 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3584 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3577 if ( incidence ) { 3585 if ( incidence ) {
3578 EditIncidenceVisitor v; 3586 EditIncidenceVisitor v;
3579 v.act( incidence, this ); 3587 v.act( incidence, this );
3580 } 3588 }
3581} 3589}
3582 3590
3583void CalendarView::deleteIncidence() 3591void CalendarView::deleteIncidence()
3584{ 3592{
3585 Incidence *incidence = currentSelection(); 3593 Incidence *incidence = currentSelection();
3586 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3594 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3587 if ( incidence ) { 3595 if ( incidence ) {
3588 deleteIncidence(incidence); 3596 deleteIncidence(incidence);
3589 } 3597 }
3590} 3598}
3591 3599
3592void CalendarView::showIncidence(Incidence *incidence) 3600void CalendarView::showIncidence(Incidence *incidence)
3593{ 3601{
3594 if ( incidence ) { 3602 if ( incidence ) {
3595 ShowIncidenceVisitor v; 3603 ShowIncidenceVisitor v;
3596 v.act( incidence, this ); 3604 v.act( incidence, this );
3597 } 3605 }
3598} 3606}
3599 3607
3600void CalendarView::editIncidence(Incidence *incidence) 3608void CalendarView::editIncidence(Incidence *incidence)
3601{ 3609{
3602 if ( incidence ) { 3610 if ( incidence ) {
3603 3611
3604 EditIncidenceVisitor v; 3612 EditIncidenceVisitor v;
3605 v.act( incidence, this ); 3613 v.act( incidence, this );
3606 3614
3607 } 3615 }
3608} 3616}
3609 3617
3610void CalendarView::deleteIncidence(Incidence *incidence) 3618void CalendarView::deleteIncidence(Incidence *incidence)
3611{ 3619{
3612 //qDebug(" CalendarView::deleteIncidence "); 3620 //qDebug(" CalendarView::deleteIncidence ");
3613 if ( incidence ) { 3621 if ( incidence ) {
3614 DeleteIncidenceVisitor v; 3622 DeleteIncidenceVisitor v;
3615 v.act( incidence, this ); 3623 v.act( incidence, this );
3616 } 3624 }
3617} 3625}
3618 3626
3619 3627
3620void CalendarView::lookForOutgoingMessages() 3628void CalendarView::lookForOutgoingMessages()
3621{ 3629{
3622 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3630 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3623 ogd->loadMessages(); 3631 ogd->loadMessages();
3624} 3632}
3625 3633
3626void CalendarView::lookForIncomingMessages() 3634void CalendarView::lookForIncomingMessages()
3627{ 3635{
3628 IncomingDialog *icd = mDialogManager->incomingDialog(); 3636 IncomingDialog *icd = mDialogManager->incomingDialog();
3629 icd->retrieve(); 3637 icd->retrieve();
3630} 3638}
3631 3639
3632bool CalendarView::removeCompletedSubTodos( Todo* t ) 3640bool CalendarView::removeCompletedSubTodos( Todo* t )
3633{ 3641{
3634 bool deleteTodo = true; 3642 bool deleteTodo = true;
3635 QPtrList<Incidence> subTodos; 3643 QPtrList<Incidence> subTodos;
3636 Incidence *aTodo; 3644 Incidence *aTodo;
3637 subTodos = t->relations(); 3645 subTodos = t->relations();
3638 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3646 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3639 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3647 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3640 deleteTodo = false; 3648 deleteTodo = false;
3641 } 3649 }
3642 if ( deleteTodo ) { 3650 if ( deleteTodo ) {
3643 if ( t->isCompleted() ) { 3651 if ( t->isCompleted() ) {
3644 checkExternalId( t ); 3652 checkExternalId( t );
3645 mCalendar->deleteTodo( t ); 3653 mCalendar->deleteTodo( t );
3646 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3654 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3647 } 3655 }
3648 else 3656 else
3649 deleteTodo = false; 3657 deleteTodo = false;
3650 } 3658 }
3651 return deleteTodo; 3659 return deleteTodo;
3652 3660
3653} 3661}
3654void CalendarView::purgeCompleted() 3662void CalendarView::purgeCompleted()
3655{ 3663{
3656 int result = KMessageBox::warningContinueCancel(this, 3664 int result = KMessageBox::warningContinueCancel(this,
3657 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3665 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3658 3666
3659 if (result == KMessageBox::Continue) { 3667 if (result == KMessageBox::Continue) {
3660 3668
3661 QPtrList<Todo> todoCal; 3669 QPtrList<Todo> todoCal;
3662 QPtrList<Todo> rootTodos; 3670 QPtrList<Todo> rootTodos;
3663 //QPtrList<Incidence> rel; 3671 //QPtrList<Incidence> rel;
3664 Todo *aTodo;//, *rTodo; 3672 Todo *aTodo;//, *rTodo;
3665 Incidence *rIncidence; 3673 Incidence *rIncidence;
3666 bool childDelete = false; 3674 bool childDelete = false;
3667 bool deletedOne = true; 3675 bool deletedOne = true;
3668 todoCal = calendar()->todos(); 3676 todoCal = calendar()->todos();
3669 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3677 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3670 if ( !aTodo->relatedTo() ) 3678 if ( !aTodo->relatedTo() )
3671 rootTodos.append( aTodo ); 3679 rootTodos.append( aTodo );
3672 } 3680 }
3673 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3681 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3674 removeCompletedSubTodos( aTodo ); 3682 removeCompletedSubTodos( aTodo );
3675 } 3683 }
3676 3684
3677 updateView(); 3685 updateView();
3678 } 3686 }
3679} 3687}
3680 3688
3681void CalendarView::slotCalendarChanged() 3689void CalendarView::slotCalendarChanged()
3682{ 3690{
3683 ; 3691 ;
3684} 3692}
3685 3693
3686NavigatorBar *CalendarView::navigatorBar() 3694NavigatorBar *CalendarView::navigatorBar()
3687{ 3695{
3688 return mNavigatorBar; 3696 return mNavigatorBar;
3689} 3697}
3690 3698
3691 3699
3692 3700
3693void CalendarView::keyPressEvent ( QKeyEvent *e) 3701void CalendarView::keyPressEvent ( QKeyEvent *e)
3694{ 3702{
3695 //qDebug(" alendarView::keyPressEvent "); 3703 //qDebug(" alendarView::keyPressEvent ");
3696 e->ignore(); 3704 e->ignore();
3697} 3705}
3698 3706
3699 3707
3700bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 3708bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
3701{ 3709{
3702 // mSyncManager = manager; 3710 // mSyncManager = manager;
3703 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3711 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3704 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3712 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3705 return syncCalendar( filename, mode ); 3713 return syncCalendar( filename, mode );
3706} 3714}
3707bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 3715bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
3708{ 3716{
3709 //mSyncManager = manager; 3717 //mSyncManager = manager;
3710 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3718 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3711 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3719 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3712 if ( resource == "sharp" ) 3720 if ( resource == "sharp" )
3713 syncExternal( 0 ); 3721 syncExternal( 0 );
3714 if ( resource == "phone" ) 3722 if ( resource == "phone" )
3715 syncExternal( 1 ); 3723 syncExternal( 1 );
3716 // pending setmodified 3724 // pending setmodified
3717 return true; 3725 return true;
3718} 3726}
3719void CalendarView::setSyncManager(KSyncManager* manager) 3727void CalendarView::setSyncManager(KSyncManager* manager)
3720{ 3728{
3721 mSyncManager = manager; 3729 mSyncManager = manager;
3722} 3730}
diff --git a/microkde/kapplication.cpp b/microkde/kapplication.cpp
index 98ef2f2..56c01af 100644
--- a/microkde/kapplication.cpp
+++ b/microkde/kapplication.cpp
@@ -1,84 +1,106 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include <stdio.h> 2#include <stdio.h>
3 3
4#include "kapplication.h" 4#include "kapplication.h"
5#include <qapplication.h> 5#include <qapplication.h>
6#include <qstring.h> 6#include <qstring.h>
7#include <qfile.h> 7#include <qfile.h>
8#include <qtextstream.h> 8#include <qtextstream.h>
9#include <qdialog.h> 9#include <qdialog.h>
10#include <qlayout.h> 10#include <qlayout.h>
11#include <qtextbrowser.h> 11#include <qtextbrowser.h>
12 12
13int KApplication::random() 13int KApplication::random()
14{ 14{
15 return rand(); 15 return rand();
16} 16}
17 17
18//US 18//US
19QString KApplication::randomString(int length) 19QString KApplication::randomString(int length)
20{ 20{
21 if (length <=0 ) return QString::null; 21 if (length <=0 ) return QString::null;
22 22
23 QString str; 23 QString str;
24 while (length--) 24 while (length--)
25 { 25 {
26 int r=random() % 62; 26 int r=random() % 62;
27 r+=48; 27 r+=48;
28 if (r>57) r+=7; 28 if (r>57) r+=7;
29 if (r>90) r+=6; 29 if (r>90) r+=6;
30 str += char(r); 30 str += char(r);
31 // so what if I work backwards? 31 // so what if I work backwards?
32 } 32 }
33 return str; 33 return str;
34} 34}
35int KApplication::execDialog( QDialog* d ) 35int KApplication::execDialog( QDialog* d )
36{ 36{
37 if (QApplication::desktop()->width() <= 640 ) 37 if (QApplication::desktop()->width() <= 640 )
38 d->showMaximized(); 38 d->showMaximized();
39 return d->exec(); 39 return d->exec();
40} 40}
41void KApplication::showLicence() 41void KApplication::showLicence()
42{ 42{
43 KApplication::showFile( "KDE-Pim/Pi licence", "kdepim/LICENCE.TXT" ); 43 KApplication::showFile( "KDE-Pim/Pi licence", "kdepim/LICENCE.TXT" );
44} 44}
45 45
46void KApplication::showFile(QString caption, QString fn) 46void KApplication::showFile(QString caption, QString fn)
47{ 47{
48 QString text; 48 QString text;
49 QString fileName; 49 QString fileName;
50#ifndef DESKTOP_VERSION 50#ifndef DESKTOP_VERSION
51 fileName = getenv("QPEDIR"); 51 fileName = getenv("QPEDIR");
52 fileName += "/pics/" + fn ; 52 fileName += "/pics/" + fn ;
53#else 53#else
54 fileName = qApp->applicationDirPath () + "/" + fn; 54 fileName = qApp->applicationDirPath () + "/" + fn;
55#endif 55#endif
56 QFile file( fileName ); 56 QFile file( fileName );
57 if (!file.open( IO_ReadOnly ) ) { 57 if (!file.open( IO_ReadOnly ) ) {
58 return ; 58 return ;
59 } 59 }
60 QTextStream ts( &file ); 60 QTextStream ts( &file );
61 text = ts.read(); 61 text = ts.read();
62 file.close(); 62 file.close();
63 KApplication::showText( caption, text ); 63 KApplication::showText( caption, text );
64 64
65} 65}
66 66
67bool KApplication::convert2latin1(QString fileName)
68{
69 QString text;
70 QFile file( fileName );
71 if (!file.open( IO_ReadOnly ) ) {
72 return false;
73
74 }
75 QTextStream ts( &file );
76 ts.setEncoding( QTextStream::UnicodeUTF8 );
77 text = ts.read();
78 file.close();
79 if (!file.open( IO_WriteOnly ) ) {
80 return false;
81 }
82 QTextStream tsIn( &file );
83 tsIn.setEncoding( QTextStream::Latin1 );
84 tsIn << text.latin1();
85 file.close();
86
87
88}
67void KApplication::showText(QString caption, QString text) 89void KApplication::showText(QString caption, QString text)
68{ 90{
69 QDialog dia( 0, "name", true ); ; 91 QDialog dia( 0, "name", true ); ;
70 dia.setCaption( caption ); 92 dia.setCaption( caption );
71 QVBoxLayout* lay = new QVBoxLayout( &dia ); 93 QVBoxLayout* lay = new QVBoxLayout( &dia );
72 lay->setSpacing( 3 ); 94 lay->setSpacing( 3 );
73 lay->setMargin( 3 ); 95 lay->setMargin( 3 );
74 QTextBrowser tb ( &dia ); 96 QTextBrowser tb ( &dia );
75 lay->addWidget( &tb ); 97 lay->addWidget( &tb );
76 tb.setText( text ); 98 tb.setText( text );
77#ifdef DESKTOP_VERSION 99#ifdef DESKTOP_VERSION
78 dia.resize( 640, 480); 100 dia.resize( 640, 480);
79#else 101#else
80 dia.showMaximized(); 102 dia.showMaximized();
81#endif 103#endif
82 dia.exec(); 104 dia.exec();
83 105
84} 106}
diff --git a/microkde/kapplication.h b/microkde/kapplication.h
index 79cdb33..41546a0 100644
--- a/microkde/kapplication.h
+++ b/microkde/kapplication.h
@@ -1,26 +1,27 @@
1#ifndef MINIKDE_KAPPLICATION_H 1#ifndef MINIKDE_KAPPLICATION_H
2#define MINIKDE_KAPPLICATION_H 2#define MINIKDE_KAPPLICATION_H
3 3
4#include "qstring.h" 4#include "qstring.h"
5#include <qdialog.h> 5#include <qdialog.h>
6 6
7class KApplication 7class KApplication
8{ 8{
9 public: 9 public:
10 static int random(); 10 static int random();
11 11
12//US 12//US
13 /** 13 /**
14 * Generates a random string. It operates in the range [A-Za-z0-9] 14 * Generates a random string. It operates in the range [A-Za-z0-9]
15 * @param length Generate a string of this length. 15 * @param length Generate a string of this length.
16 * @return the random string 16 * @return the random string
17 */ 17 */
18 static QString randomString(int length); 18 static QString randomString(int length);
19 static int execDialog( QDialog* ); 19 static int execDialog( QDialog* );
20 static void showLicence(); 20 static void showLicence();
21 static void showFile(QString caption, QString file); 21 static void showFile(QString caption, QString file);
22 static void showText(QString caption, QString text); 22 static void showText(QString caption, QString text);
23 static bool convert2latin1(QString file);
23}; 24};
24 25
25 26
26#endif 27#endif