author | zautrix <zautrix> | 2004-10-15 14:26:07 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-15 14:26:07 (UTC) |
commit | 4f276d80bd977401d656851515474cc00c661e5b (patch) (unidiff) | |
tree | 0d3a747bef0431ef791b69876f5bda554f9ca83f | |
parent | c2fb960297c4b08980921c818a4d347057732390 (diff) | |
download | kdepimpi-4f276d80bd977401d656851515474cc00c661e5b.zip kdepimpi-4f276d80bd977401d656851515474cc00c661e5b.tar.gz kdepimpi-4f276d80bd977401d656851515474cc00c661e5b.tar.bz2 |
many phone and sync fixes
-rw-r--r-- | gammu/emb/common/service/gsmcal.c | 20 | ||||
-rw-r--r-- | kabc/addressee.cpp | 1 | ||||
-rw-r--r-- | kabc/kabc.pro | 2 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 4 | ||||
-rw-r--r-- | libkcal/event.cpp | 46 | ||||
-rw-r--r-- | libkcal/event.h | 2 | ||||
-rw-r--r-- | libkcal/phoneformat.cpp | 104 | ||||
-rw-r--r-- | libkcal/phoneformat.h | 2 | ||||
-rw-r--r-- | libkcal/todo.cpp | 58 | ||||
-rw-r--r-- | libkcal/todo.h | 1 | ||||
-rw-r--r-- | libkcal/vcalformat.cpp | 141 | ||||
-rw-r--r-- | libkdepim/phoneaccess.cpp | 69 | ||||
-rw-r--r-- | microkde/microkde.pro | 2 | ||||
-rw-r--r-- | microkde/ofileselector_p.cpp | 7 |
14 files changed, 305 insertions, 154 deletions
diff --git a/gammu/emb/common/service/gsmcal.c b/gammu/emb/common/service/gsmcal.c index 0375fee..7310755 100644 --- a/gammu/emb/common/service/gsmcal.c +++ b/gammu/emb/common/service/gsmcal.c | |||
@@ -1,521 +1,527 @@ | |||
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 | ||
9 | bool IsCalendarNoteFromThePast(GSM_CalendarEntry *note) | 9 | bool 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 | ||
44 | void GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(GSM_CalendarEntry *entry, int *Text, int *Time, int *Alarm, int *Phone, int *Recurrance, int *EndTime, int *Location) | 44 | void 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; | 71 | *Text = i; |
72 | break; | 72 | break; |
73 | case CAL_DESCRIPTION: | 73 | case CAL_DESCRIPTION: |
74 | if (*Text == -1) *Text = i; | 74 | if (*Text == -1) *Text = i; |
75 | break; | 75 | break; |
76 | case CAL_PHONE: | 76 | case CAL_PHONE: |
77 | if (*Phone == -1) *Phone = i; | 77 | if (*Phone == -1) *Phone = i; |
78 | break; | 78 | break; |
79 | case CAL_LOCATION: | 79 | case CAL_LOCATION: |
80 | if (*Location == -1) *Location = i; | 80 | if (*Location == -1) *Location = i; |
81 | break; | 81 | break; |
82 | default: | 82 | default: |
83 | break; | 83 | break; |
84 | } | 84 | } |
85 | } | 85 | } |
86 | } | 86 | } |
87 | 87 | ||
88 | GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note, bool header, GSM_VCalendarVersion Version) | 88 | GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note, bool header, GSM_VCalendarVersion Version) |
89 | { | 89 | { |
90 | int Text, Time, Alarm, Phone, Recurrance, EndTime, Location; | 90 | int Text, Time, Alarm, Phone, Recurrance, EndTime, Location; |
91 | char buffer[2000]; | 91 | char buffer[2000]; |
92 | 92 | ||
93 | GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(note, &Text, &Time, &Alarm, &Phone, &Recurrance, &EndTime, &Location); | 93 | GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(note, &Text, &Time, &Alarm, &Phone, &Recurrance, &EndTime, &Location); |
94 | 94 | ||
95 | if (header) { | 95 | if (header) { |
96 | *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10); | 96 | *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10); |
97 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10); | 97 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10); |
98 | } | 98 | } |
99 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VEVENT%c%c",13,10); | 99 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VEVENT%c%c",13,10); |
100 | 100 | ||
101 | if (Version == Nokia_VCalendar) { | 101 | if (Version == Nokia_VCalendar) { |
102 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); | 102 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); |
103 | switch (note->Type) { | 103 | switch (note->Type) { |
104 | case GSM_CAL_REMINDER: | 104 | case GSM_CAL_REMINDER: |
105 | *Length+=sprintf(Buffer+(*Length), "Reminder%c%c",13,10); | 105 | *Length+=sprintf(Buffer+(*Length), "Reminder%c%c",13,10); |
106 | break; | 106 | break; |
107 | case GSM_CAL_MEMO: | 107 | case GSM_CAL_MEMO: |
108 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); | 108 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); |
109 | break; | 109 | break; |
110 | case GSM_CAL_CALL: | 110 | case GSM_CAL_CALL: |
111 | *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10); | 111 | *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10); |
112 | break; | 112 | break; |
113 | case GSM_CAL_BIRTHDAY: | 113 | case GSM_CAL_BIRTHDAY: |
114 | *Length+=sprintf(Buffer+(*Length), "Special Occasion%c%c",13,10); | 114 | *Length+=sprintf(Buffer+(*Length), "Birthday%c%c",13,10); |
115 | break; | 115 | break; |
116 | case GSM_CAL_MEETING: | 116 | case GSM_CAL_MEETING: |
117 | default: | 117 | default: |
118 | *Length+=sprintf(Buffer+(*Length), "MeetingDEF%c%c",13,10); | 118 | *Length+=sprintf(Buffer+(*Length), "MeetingDEF%c%c",13,10); |
119 | break; | 119 | break; |
120 | } | 120 | } |
121 | if (note->Type == GSM_CAL_CALL) { | 121 | if (note->Type == GSM_CAL_CALL) { |
122 | buffer[0] = 0; | 122 | buffer[0] = 0; |
123 | buffer[1] = 0; | 123 | buffer[1] = 0; |
124 | if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text); | 124 | if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text); |
125 | if (Text != -1) { | 125 | if (Text != -1) { |
126 | if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1); | 126 | if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1); |
127 | CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text); | 127 | CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text); |
128 | } | 128 | } |
129 | SaveVCALText(Buffer, Length, buffer, "SUMMARY"); | 129 | SaveVCALText(Buffer, Length, buffer, "SUMMARY"); |
130 | } else { | 130 | } else { |
131 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); | 131 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); |
132 | } | 132 | } |
133 | if (note->Type == GSM_CAL_MEETING && Location != -1) { | 133 | if (note->Type == GSM_CAL_MEETING && Location != -1) { |
134 | SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION"); | 134 | SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION"); |
135 | } | 135 | } |
136 | 136 | ||
137 | if (Time == -1) return ERR_UNKNOWN; | 137 | if (Time == -1) return ERR_UNKNOWN; |
138 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); | 138 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); |
139 | 139 | ||
140 | if (EndTime != -1) { | 140 | if (EndTime != -1) { |
141 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DTEND"); | 141 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DTEND"); |
142 | } | 142 | } |
143 | 143 | ||
144 | if (Alarm != -1) { | 144 | if (Alarm != -1) { |
145 | if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) { | 145 | if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) { |
146 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); | 146 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); |
147 | } else { | 147 | } else { |
148 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); | 148 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); |
149 | } | 149 | } |
150 | } | 150 | } |
151 | 151 | ||
152 | /* Birthday is known to be recurranced */ | 152 | /* Birthday is known to be recurranced */ |
153 | if (Recurrance != -1 && note->Type != GSM_CAL_BIRTHDAY) { | 153 | if (Recurrance != -1 ) { |
154 | switch(note->Entries[Recurrance].Number/24) { | 154 | switch(note->Entries[Recurrance].Number/24) { |
155 | 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; |
156 | 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; |
157 | 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; |
158 | case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1 #0%c%c",13,10); break; | 158 | case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YM1 #0%c%c",13,10); break; |
159 | } | 159 | } |
160 | } | 160 | } |
161 | } else if (Version == Siemens_VCalendar) { | 161 | } else if (Version == Siemens_VCalendar) { |
162 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); | 162 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); |
163 | switch (note->Type) { | 163 | switch (note->Type) { |
164 | case GSM_CAL_MEETING: | 164 | case GSM_CAL_MEETING: |
165 | *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10); | 165 | *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10); |
166 | break; | 166 | break; |
167 | case GSM_CAL_CALL: | 167 | case GSM_CAL_CALL: |
168 | *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10); | 168 | *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10); |
169 | break; | 169 | break; |
170 | case GSM_CAL_BIRTHDAY: | 170 | case GSM_CAL_BIRTHDAY: |
171 | *Length+=sprintf(Buffer+(*Length), "Anniversary%c%c",13,10); | 171 | *Length+=sprintf(Buffer+(*Length), "Birthday%c%c",13,10); |
172 | break; | 172 | break; |
173 | case GSM_CAL_MEMO: | 173 | case GSM_CAL_MEMO: |
174 | default: | 174 | default: |
175 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); | 175 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); |
176 | break; | 176 | break; |
177 | } | 177 | } |
178 | 178 | ||
179 | if (Time == -1) return ERR_UNKNOWN; | 179 | if (Time == -1) return ERR_UNKNOWN; |
180 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); | 180 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); |
181 | 181 | ||
182 | if (Alarm != -1) { | 182 | if (Alarm != -1) { |
183 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); | 183 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); |
184 | } | 184 | } |
185 | 185 | ||
186 | if (Recurrance != -1) { | 186 | if (Recurrance != -1) { |
187 | switch(note->Entries[Recurrance].Number/24) { | 187 | switch(note->Entries[Recurrance].Number/24) { |
188 | 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; |
189 | 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; |
190 | 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; |
191 | case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1%c%c",13,10);break; | 191 | case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YM1%c%c",13,10);break; |
192 | } | 192 | } |
193 | } | 193 | } |
194 | 194 | ||
195 | if (note->Type == GSM_CAL_CALL) { | 195 | if (note->Type == GSM_CAL_CALL) { |
196 | buffer[0] = 0; | 196 | buffer[0] = 0; |
197 | buffer[1] = 0; | 197 | buffer[1] = 0; |
198 | if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text); | 198 | if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text); |
199 | if (Text != -1) { | 199 | if (Text != -1) { |
200 | if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1); | 200 | if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1); |
201 | CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text); | 201 | CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text); |
202 | } | 202 | } |
203 | SaveVCALText(Buffer, Length, buffer, "SUMMARY"); | 203 | SaveVCALText(Buffer, Length, buffer, "SUMMARY"); |
204 | } else { | 204 | } else { |
205 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); | 205 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); |
206 | } | 206 | } |
207 | } else if (Version == SonyEricsson_VCalendar) { | 207 | } else if (Version == SonyEricsson_VCalendar) { |
208 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); | 208 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); |
209 | switch (note->Type) { | 209 | switch (note->Type) { |
210 | case GSM_CAL_MEETING: | 210 | case GSM_CAL_MEETING: |
211 | *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10); | 211 | *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10); |
212 | break; | 212 | break; |
213 | case GSM_CAL_REMINDER: | 213 | case GSM_CAL_REMINDER: |
214 | *Length+=sprintf(Buffer+(*Length), "Date%c%c",13,10); | 214 | *Length+=sprintf(Buffer+(*Length), "Date%c%c",13,10); |
215 | break; | 215 | break; |
216 | case GSM_CAL_TRAVEL: | 216 | case GSM_CAL_TRAVEL: |
217 | *Length+=sprintf(Buffer+(*Length), "Travel%c%c",13,10); | 217 | *Length+=sprintf(Buffer+(*Length), "Travel%c%c",13,10); |
218 | break; | 218 | break; |
219 | case GSM_CAL_VACATION: | 219 | case GSM_CAL_VACATION: |
220 | *Length+=sprintf(Buffer+(*Length), "Vacation%c%c",13,10); | 220 | *Length+=sprintf(Buffer+(*Length), "Vacation%c%c",13,10); |
221 | break; | 221 | break; |
222 | case GSM_CAL_BIRTHDAY: | 222 | case GSM_CAL_BIRTHDAY: |
223 | *Length+=sprintf(Buffer+(*Length), "Anninversary%c%c",13,10); | 223 | *Length+=sprintf(Buffer+(*Length), "Birthday%c%c",13,10); |
224 | break; | 224 | break; |
225 | case GSM_CAL_MEMO: | 225 | case GSM_CAL_MEMO: |
226 | default: | 226 | default: |
227 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); | 227 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); |
228 | break; | 228 | break; |
229 | } | 229 | } |
230 | 230 | ||
231 | if (Time == -1) return ERR_UNKNOWN; | 231 | if (Time == -1) return ERR_UNKNOWN; |
232 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); | 232 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); |
233 | 233 | ||
234 | if (EndTime != -1) { | 234 | if (EndTime != -1) { |
235 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DTEND"); | 235 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DTEND"); |
236 | } | 236 | } |
237 | 237 | ||
238 | if (Alarm != -1) { | 238 | if (Alarm != -1) { |
239 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); | 239 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); |
240 | } | 240 | } |
241 | 241 | ||
242 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); | 242 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); |
243 | 243 | ||
244 | if (Location != -1) { | 244 | if (Location != -1) { |
245 | SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION"); | 245 | SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION"); |
246 | } | 246 | } |
247 | } | 247 | } |
248 | 248 | ||
249 | *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); |
250 | *Length+=sprintf(Buffer+(*Length), "END:VEVENT%c%c",13,10); | 250 | *Length+=sprintf(Buffer+(*Length), "END:VEVENT%c%c",13,10); |
251 | 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); |
252 | 252 | ||
253 | return ERR_NONE; | 253 | return ERR_NONE; |
254 | } | 254 | } |
255 | 255 | ||
256 | void GSM_ToDoFindDefaultTextTimeAlarmCompleted(GSM_ToDoEntry *entry, int *Text, int *Alarm, int *Completed, int *EndTime, int *Phone) | 256 | void GSM_ToDoFindDefaultTextTimeAlarmCompleted(GSM_ToDoEntry *entry, int *Text, int *Alarm, int *Completed, int *EndTime, int *Phone) |
257 | { | 257 | { |
258 | int i; | 258 | int i; |
259 | 259 | ||
260 | *Text = -1; | 260 | *Text = -1; |
261 | *EndTime= -1; | 261 | *EndTime= -1; |
262 | *Alarm = -1; | 262 | *Alarm = -1; |
263 | *Completed= -1; | 263 | *Completed= -1; |
264 | *Phone = -1; | 264 | *Phone = -1; |
265 | for (i = 0; i < entry->EntriesNum; i++) { | 265 | for (i = 0; i < entry->EntriesNum; i++) { |
266 | switch (entry->Entries[i].EntryType) { | 266 | switch (entry->Entries[i].EntryType) { |
267 | case TODO_END_DATETIME : | 267 | case TODO_END_DATETIME : |
268 | if (*EndTime == -1) *EndTime = i; | 268 | if (*EndTime == -1) *EndTime = i; |
269 | break; | 269 | break; |
270 | case TODO_ALARM_DATETIME : | 270 | case TODO_ALARM_DATETIME : |
271 | case TODO_SILENT_ALARM_DATETIME: | 271 | case TODO_SILENT_ALARM_DATETIME: |
272 | if (*Alarm == -1) *Alarm = i; | 272 | if (*Alarm == -1) *Alarm = i; |
273 | break; | 273 | break; |
274 | case TODO_TEXT: | 274 | case TODO_TEXT: |
275 | if (*Text == -1) *Text = i; | 275 | if (*Text == -1) *Text = i; |
276 | break; | 276 | break; |
277 | case TODO_COMPLETED: | 277 | case TODO_COMPLETED: |
278 | if (*Completed == -1) *Completed = i; | 278 | if (*Completed == -1) *Completed = i; |
279 | break; | 279 | break; |
280 | case TODO_PHONE: | 280 | case TODO_PHONE: |
281 | if (*Phone == -1) *Phone = i; | 281 | if (*Phone == -1) *Phone = i; |
282 | break; | 282 | break; |
283 | default: | 283 | default: |
284 | break; | 284 | break; |
285 | } | 285 | } |
286 | } | 286 | } |
287 | } | 287 | } |
288 | 288 | ||
289 | GSM_Error GSM_EncodeVTODO(char *Buffer, int *Length, GSM_ToDoEntry *note, bool header, GSM_VToDoVersion Version) | 289 | GSM_Error GSM_EncodeVTODO(char *Buffer, int *Length, GSM_ToDoEntry *note, bool header, GSM_VToDoVersion Version) |
290 | { | 290 | { |
291 | int Text, Alarm, Completed, EndTime, Phone; | 291 | int Text, Alarm, Completed, EndTime, Phone; |
292 | 292 | ||
293 | GSM_ToDoFindDefaultTextTimeAlarmCompleted(note, &Text, &Alarm, &Completed, &EndTime, &Phone); | 293 | GSM_ToDoFindDefaultTextTimeAlarmCompleted(note, &Text, &Alarm, &Completed, &EndTime, &Phone); |
294 | 294 | ||
295 | if (header) { | 295 | if (header) { |
296 | *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10); | 296 | *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10); |
297 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10); | 297 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10); |
298 | } | 298 | } |
299 | 299 | ||
300 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VTODO%c%c",13,10); | 300 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VTODO%c%c",13,10); |
301 | 301 | ||
302 | if (Version == Nokia_VToDo) { | 302 | if (Version == Nokia_VToDo) { |
303 | if (Text == -1) return ERR_UNKNOWN; | 303 | if (Text == -1) return ERR_UNKNOWN; |
304 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); | 304 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); |
305 | 305 | ||
306 | if (Completed == -1) { | 306 | if (Completed == -1) { |
307 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:0%c%c",13,10); | 307 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:0%c%c",13,10); |
308 | } else { | 308 | } else { |
309 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:100%c%c",13,10); | 309 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:100%c%c",13,10); |
310 | } | 310 | } |
311 | 311 | ||
312 | switch (note->Priority) { | 312 | switch (note->Priority) { |
313 | 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; |
314 | 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; |
315 | 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; |
316 | } | 316 | } |
317 | 317 | ||
318 | if (EndTime != -1) { | 318 | if (EndTime != -1) { |
319 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DUE"); | 319 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DUE"); |
320 | } | 320 | } |
321 | 321 | ||
322 | if (Alarm != -1) { | 322 | if (Alarm != -1) { |
323 | if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) { | 323 | if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) { |
324 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); | 324 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); |
325 | } else { | 325 | } else { |
326 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); | 326 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); |
327 | } | 327 | } |
328 | } | 328 | } |
329 | } else if (Version == SonyEricsson_VToDo) { | 329 | } else if (Version == SonyEricsson_VToDo) { |
330 | if (Text == -1) return ERR_UNKNOWN; | 330 | if (Text == -1) return ERR_UNKNOWN; |
331 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); | 331 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); |
332 | 332 | ||
333 | if (Completed == -1) { | 333 | if (Completed == -1) { |
334 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:0%c%c",13,10); | 334 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:0%c%c",13,10); |
335 | } else { | 335 | } else { |
336 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:100%c%c",13,10); | 336 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:100%c%c",13,10); |
337 | } | 337 | } |
338 | 338 | ||
339 | switch (note->Priority) { | 339 | switch (note->Priority) { |
340 | 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; |
341 | 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; |
342 | 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; |
343 | } | 343 | } |
344 | 344 | ||
345 | if (Alarm != -1) { | 345 | if (Alarm != -1) { |
346 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); | 346 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); |
347 | } | 347 | } |
348 | } | 348 | } |
349 | 349 | ||
350 | *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); |
351 | *Length+=sprintf(Buffer+(*Length), "END:VTODO%c%c",13,10); | 351 | *Length+=sprintf(Buffer+(*Length), "END:VTODO%c%c",13,10); |
352 | 352 | ||
353 | if (header) { | 353 | if (header) { |
354 | *Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10); | 354 | *Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10); |
355 | } | 355 | } |
356 | return ERR_NONE; | 356 | return ERR_NONE; |
357 | } | 357 | } |
358 | 358 | ||
359 | GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_CalendarEntry *Calendar, GSM_ToDoEntry *ToDo, GSM_VCalendarVersion CalVer, GSM_VToDoVersion ToDoVer) | 359 | GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_CalendarEntry *Calendar, GSM_ToDoEntry *ToDo, GSM_VCalendarVersion CalVer, GSM_VToDoVersion ToDoVer) |
360 | { | 360 | { |
361 | unsigned char Line[2000],Buff[2000]; | 361 | unsigned char Line[2000],Buff[2000]; |
362 | int Level = 0; | 362 | int Level = 0; |
363 | 363 | ||
364 | Calendar->EntriesNum = 0; | 364 | Calendar->EntriesNum = 0; |
365 | ToDo->EntriesNum = 0; | 365 | ToDo->EntriesNum = 0; |
366 | 366 | ||
367 | while (1) { | 367 | while (1) { |
368 | MyGetLine(Buffer, Pos, Line, strlen(Buffer)); | 368 | MyGetLine(Buffer, Pos, Line, strlen(Buffer)); |
369 | if (strlen(Line) == 0) break; | 369 | if (strlen(Line) == 0) break; |
370 | switch (Level) { | 370 | switch (Level) { |
371 | case 0: | 371 | case 0: |
372 | if (strstr(Line,"BEGIN:VEVENT")) { | 372 | if (strstr(Line,"BEGIN:VEVENT")) { |
373 | Calendar->Type = GSM_CAL_MEMO; | 373 | Calendar->Type = GSM_CAL_MEMO; |
374 | Level = 1; | 374 | Level = 1; |
375 | } | 375 | } |
376 | if (strstr(Line,"BEGIN:VTODO")) { | 376 | if (strstr(Line,"BEGIN:VTODO")) { |
377 | ToDo->Priority = GSM_Priority_Medium; | 377 | ToDo->Priority = GSM_Priority_Medium; |
378 | Level = 2; | 378 | Level = 2; |
379 | } | 379 | } |
380 | break; | 380 | break; |
381 | case 1: /* Calendar note */ | 381 | case 1: /* Calendar note */ |
382 | if (strstr(Line,"END:VEVENT")) { | 382 | if (strstr(Line,"END:VEVENT")) { |
383 | if (Calendar->EntriesNum == 0) return ERR_EMPTY; | 383 | if (Calendar->EntriesNum == 0) return ERR_EMPTY; |
384 | return ERR_NONE; | 384 | return ERR_NONE; |
385 | } | 385 | } |
386 | Calendar->Type = GSM_CAL_MEETING; | 386 | Calendar->Type = GSM_CAL_MEETING; |
387 | if (strstr(Line,"CATEGORIES:Reminder")) Calendar->Type = GSM_CAL_REMINDER; | 387 | if (strstr(Line,"CATEGORIES:Reminder")) Calendar->Type = GSM_CAL_REMINDER; |
388 | if (strstr(Line,"CATEGORIES:Date")) Calendar->Type = GSM_CAL_REMINDER;//SE | 388 | if (strstr(Line,"CATEGORIES:Date")) Calendar->Type = GSM_CAL_REMINDER;//SE |
389 | if (strstr(Line,"CATEGORIES:Travel")) Calendar->Type = GSM_CAL_TRAVEL; //SE | 389 | if (strstr(Line,"CATEGORIES:Travel")) Calendar->Type = GSM_CAL_TRAVEL; //SE |
390 | if (strstr(Line,"CATEGORIES:Vacation")) Calendar->Type = GSM_CAL_VACATION;//SE | 390 | if (strstr(Line,"CATEGORIES:Vacation")) Calendar->Type = GSM_CAL_VACATION;//SE |
391 | if (strstr(Line,"CATEGORIES:Miscellaneous")) Calendar->Type = GSM_CAL_MEMO; | 391 | if (strstr(Line,"CATEGORIES:Miscellaneous")) Calendar->Type = GSM_CAL_MEMO; |
392 | if (strstr(Line,"CATEGORIES:Phone Call")) Calendar->Type = GSM_CAL_CALL; | 392 | if (strstr(Line,"CATEGORIES:Phone Call")) Calendar->Type = GSM_CAL_CALL; |
393 | if (strstr(Line,"CATEGORIES:Special Occasion")) Calendar->Type = GSM_CAL_BIRTHDAY; | ||
394 | if (strstr(Line,"CATEGORIES:Anniversary")) Calendar->Type = GSM_CAL_BIRTHDAY; | 393 | if (strstr(Line,"CATEGORIES:Anniversary")) Calendar->Type = GSM_CAL_BIRTHDAY; |
394 | if (strstr(Line,"CATEGORIES:Birthday")) Calendar->Type = GSM_CAL_BIRTHDAY; | ||
395 | if (strstr(Line,"CATEGORIES:Meeting")) Calendar->Type = GSM_CAL_MEETING; | 395 | if (strstr(Line,"CATEGORIES:Meeting")) Calendar->Type = GSM_CAL_MEETING; |
396 | if (strstr(Line,"CATEGORIES:Appointment")) Calendar->Type = GSM_CAL_MEETING; | 396 | if (strstr(Line,"CATEGORIES:Appointment")) Calendar->Type = GSM_CAL_MEETING; |
397 | if (strstr(Line,"RRULE:D1")) { | 397 | if (strstr(Line,"RRULE:D1")) { |
398 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; | 398 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; |
399 | Calendar->Entries[Calendar->EntriesNum].Number = 1*24; | 399 | Calendar->Entries[Calendar->EntriesNum].Number = 1*24; |
400 | Calendar->EntriesNum++; | 400 | Calendar->EntriesNum++; |
401 | } | 401 | } |
402 | if ((strstr(Line,"RRULE:W1")) || (strstr(Line,"RRULE:D7"))) { | 402 | if ((strstr(Line,"RRULE:W1")) || (strstr(Line,"RRULE:D7"))) { |
403 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; | 403 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; |
404 | Calendar->Entries[Calendar->EntriesNum].Number = 7*24; | 404 | Calendar->Entries[Calendar->EntriesNum].Number = 7*24; |
405 | Calendar->EntriesNum++; | 405 | Calendar->EntriesNum++; |
406 | } | 406 | } |
407 | if (strstr(Line,"RRULE:W2")) { | 407 | if (strstr(Line,"RRULE:W2")) { |
408 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; | 408 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; |
409 | Calendar->Entries[Calendar->EntriesNum].Number = 14*24; | 409 | Calendar->Entries[Calendar->EntriesNum].Number = 14*24; |
410 | Calendar->EntriesNum++; | 410 | Calendar->EntriesNum++; |
411 | } | 411 | } |
412 | if (strstr(Line,"RRULE:MD1")) { | 412 | if (strstr(Line,"RRULE:MD1")) { |
413 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; | 413 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; |
414 | Calendar->Entries[Calendar->EntriesNum].Number = 30*24; | 414 | Calendar->Entries[Calendar->EntriesNum].Number = 30*24; |
415 | Calendar->EntriesNum++; | 415 | Calendar->EntriesNum++; |
416 | } | 416 | } |
417 | if (strstr(Line,"RRULE:YD1")) { | 417 | if (strstr(Line,"RRULE:YD1")) { |
418 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; | 418 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; |
419 | Calendar->Entries[Calendar->EntriesNum].Number = 365*24; | 419 | Calendar->Entries[Calendar->EntriesNum].Number = 365*24; |
420 | Calendar->EntriesNum++; | 420 | Calendar->EntriesNum++; |
421 | } | 421 | } |
422 | // LR | 422 | // LR |
423 | if (strstr(Line,"RRULE:YM1")) { | ||
424 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; | ||
425 | Calendar->Entries[Calendar->EntriesNum].Number = 365*24; | ||
426 | Calendar->EntriesNum++; | ||
427 | } | ||
428 | // LR | ||
423 | if ((ReadVCALText(Line, "SUMMARY", Buff)) ) { | 429 | if ((ReadVCALText(Line, "SUMMARY", Buff)) ) { |
424 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_TEXT; | 430 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_TEXT; |
425 | CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); | 431 | CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); |
426 | Calendar->EntriesNum++; | 432 | Calendar->EntriesNum++; |
427 | } | 433 | } |
428 | if (ReadVCALText(Line, "DESCRIPTION", Buff)) { | 434 | if (ReadVCALText(Line, "DESCRIPTION", Buff)) { |
429 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_DESCRIPTION; | 435 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_DESCRIPTION; |
430 | CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); | 436 | CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); |
431 | Calendar->EntriesNum++; | 437 | Calendar->EntriesNum++; |
432 | } | 438 | } |
433 | if (ReadVCALText(Line, "LOCATION", Buff)) { | 439 | if (ReadVCALText(Line, "LOCATION", Buff)) { |
434 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_LOCATION; | 440 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_LOCATION; |
435 | CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); | 441 | CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); |
436 | Calendar->EntriesNum++; | 442 | Calendar->EntriesNum++; |
437 | } | 443 | } |
438 | if (ReadVCALText(Line, "DTSTART", Buff)) { | 444 | if (ReadVCALText(Line, "DTSTART", Buff)) { |
439 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_START_DATETIME; | 445 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_START_DATETIME; |
440 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); | 446 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); |
441 | Calendar->EntriesNum++; | 447 | Calendar->EntriesNum++; |
442 | } | 448 | } |
443 | if (ReadVCALText(Line, "DTEND", Buff)) { | 449 | if (ReadVCALText(Line, "DTEND", Buff)) { |
444 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_END_DATETIME; | 450 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_END_DATETIME; |
445 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); | 451 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); |
446 | Calendar->EntriesNum++; | 452 | Calendar->EntriesNum++; |
447 | } | 453 | } |
448 | if (ReadVCALText(Line, "DALARM", Buff)) { | 454 | if (ReadVCALText(Line, "DALARM", Buff)) { |
449 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_SILENT_ALARM_DATETIME; | 455 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_SILENT_ALARM_DATETIME; |
450 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); | 456 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); |
451 | Calendar->EntriesNum++; | 457 | Calendar->EntriesNum++; |
452 | } | 458 | } |
453 | if (ReadVCALText(Line, "AALARM", Buff)) { | 459 | if (ReadVCALText(Line, "AALARM", Buff)) { |
454 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_ALARM_DATETIME; | 460 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_ALARM_DATETIME; |
455 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); | 461 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); |
456 | Calendar->EntriesNum++; | 462 | Calendar->EntriesNum++; |
457 | } | 463 | } |
458 | break; | 464 | break; |
459 | case 2: /* ToDo note */ | 465 | case 2: /* ToDo note */ |
460 | if (strstr(Line,"END:VTODO")) { | 466 | if (strstr(Line,"END:VTODO")) { |
461 | if (ToDo->EntriesNum == 0) return ERR_EMPTY; | 467 | if (ToDo->EntriesNum == 0) return ERR_EMPTY; |
462 | return ERR_NONE; | 468 | return ERR_NONE; |
463 | } | 469 | } |
464 | if (ReadVCALText(Line, "DUE", Buff)) { | 470 | if (ReadVCALText(Line, "DUE", Buff)) { |
465 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_END_DATETIME; | 471 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_END_DATETIME; |
466 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); | 472 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); |
467 | ToDo->EntriesNum++; | 473 | ToDo->EntriesNum++; |
468 | } | 474 | } |
469 | if (ReadVCALText(Line, "DALARM", Buff)) { | 475 | if (ReadVCALText(Line, "DALARM", Buff)) { |
470 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_SILENT_ALARM_DATETIME; | 476 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_SILENT_ALARM_DATETIME; |
471 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); | 477 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); |
472 | ToDo->EntriesNum++; | 478 | ToDo->EntriesNum++; |
473 | } | 479 | } |
474 | if (ReadVCALText(Line, "AALARM", Buff)) { | 480 | if (ReadVCALText(Line, "AALARM", Buff)) { |
475 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_ALARM_DATETIME; | 481 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_ALARM_DATETIME; |
476 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); | 482 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); |
477 | ToDo->EntriesNum++; | 483 | ToDo->EntriesNum++; |
478 | } | 484 | } |
479 | if (ReadVCALText(Line, "SUMMARY", Buff)) { | 485 | if (ReadVCALText(Line, "SUMMARY", Buff)) { |
480 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_TEXT; | 486 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_TEXT; |
481 | CopyUnicodeString(ToDo->Entries[ToDo->EntriesNum].Text,Buff); | 487 | CopyUnicodeString(ToDo->Entries[ToDo->EntriesNum].Text,Buff); |
482 | ToDo->EntriesNum++; | 488 | ToDo->EntriesNum++; |
483 | } | 489 | } |
484 | if (ReadVCALText(Line, "PRIORITY", Buff)) { | 490 | if (ReadVCALText(Line, "PRIORITY", Buff)) { |
485 | if (ToDoVer == SonyEricsson_VToDo) { | 491 | if (ToDoVer == SonyEricsson_VToDo) { |
486 | ToDo->Priority = GSM_Priority_Medium; | 492 | ToDo->Priority = GSM_Priority_Medium; |
487 | if (atoi(DecodeUnicodeString(Buff))>3) ToDo->Priority = GSM_Priority_Low; | 493 | if (atoi(DecodeUnicodeString(Buff))>3) ToDo->Priority = GSM_Priority_Low; |
488 | if (atoi(DecodeUnicodeString(Buff))<3) ToDo->Priority = GSM_Priority_High; | 494 | if (atoi(DecodeUnicodeString(Buff))<3) ToDo->Priority = GSM_Priority_High; |
489 | dbgprintf("atoi is %i %s\n",atoi(DecodeUnicodeString(Buff)),DecodeUnicodeString(Buff)); | 495 | dbgprintf("atoi is %i %s\n",atoi(DecodeUnicodeString(Buff)),DecodeUnicodeString(Buff)); |
490 | } else if (ToDoVer == Nokia_VToDo) { | 496 | } else if (ToDoVer == Nokia_VToDo) { |
491 | ToDo->Priority = GSM_Priority_Medium; | 497 | ToDo->Priority = GSM_Priority_Medium; |
492 | if (atoi(DecodeUnicodeString(Buff))>3) ToDo->Priority = GSM_Priority_Low; | 498 | if (atoi(DecodeUnicodeString(Buff))>3) ToDo->Priority = GSM_Priority_Low; |
493 | if (atoi(DecodeUnicodeString(Buff))<3) ToDo->Priority = GSM_Priority_High; | 499 | if (atoi(DecodeUnicodeString(Buff))<3) ToDo->Priority = GSM_Priority_High; |
494 | } | 500 | } |
495 | } | 501 | } |
496 | if (strstr(Line,"PERCENT-COMPLETE:100")) { | 502 | if (strstr(Line,"PERCENT-COMPLETE:100")) { |
497 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_COMPLETED; | 503 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_COMPLETED; |
498 | ToDo->Entries[ToDo->EntriesNum].Number = 1; | 504 | ToDo->Entries[ToDo->EntriesNum].Number = 1; |
499 | ToDo->EntriesNum++; | 505 | ToDo->EntriesNum++; |
500 | } | 506 | } |
501 | break; | 507 | break; |
502 | } | 508 | } |
503 | } | 509 | } |
504 | 510 | ||
505 | if (Calendar->EntriesNum == 0 && ToDo->EntriesNum == 0) return ERR_EMPTY; | 511 | if (Calendar->EntriesNum == 0 && ToDo->EntriesNum == 0) return ERR_EMPTY; |
506 | return ERR_NONE; | 512 | return ERR_NONE; |
507 | } | 513 | } |
508 | 514 | ||
509 | GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note) | 515 | GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note) |
510 | { | 516 | { |
511 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VNOTE%c%c",13,10); | 517 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VNOTE%c%c",13,10); |
512 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.1%c%c",13,10); | 518 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.1%c%c",13,10); |
513 | SaveVCALText(Buffer, Length, Note->Text, "BODY"); | 519 | SaveVCALText(Buffer, Length, Note->Text, "BODY"); |
514 | *Length+=sprintf(Buffer+(*Length), "END:VNOTE%c%c",13,10); | 520 | *Length+=sprintf(Buffer+(*Length), "END:VNOTE%c%c",13,10); |
515 | 521 | ||
516 | return ERR_NONE; | 522 | return ERR_NONE; |
517 | } | 523 | } |
518 | 524 | ||
519 | /* How should editor hadle tabs in this file? Add editor commands here. | 525 | /* How should editor hadle tabs in this file? Add editor commands here. |
520 | * vim: noexpandtab sw=8 ts=8 sts=8: | 526 | * vim: noexpandtab sw=8 ts=8 sts=8: |
521 | */ | 527 | */ |
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 2564894..40877ef 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1,1848 +1,1849 @@ | |||
1 | /*** Warning! This file has been generated by the script makeaddressee ***/ | 1 | /*** Warning! This file has been generated by the script makeaddressee ***/ |
2 | /* | 2 | /* |
3 | This file is part of libkabc. | 3 | This file is part of libkabc. |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <kconfig.h> | 29 | #include <kconfig.h> |
30 | 30 | ||
31 | #include <ksharedptr.h> | 31 | #include <ksharedptr.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <kapplication.h> | 33 | #include <kapplication.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kidmanager.h> | 35 | #include <kidmanager.h> |
36 | //US | 36 | //US |
37 | #include <kstandarddirs.h> | 37 | #include <kstandarddirs.h> |
38 | #include <libkcal/syncdefines.h> | 38 | #include <libkcal/syncdefines.h> |
39 | 39 | ||
40 | //US #include "resource.h" | 40 | //US #include "resource.h" |
41 | #include "addressee.h" | 41 | #include "addressee.h" |
42 | 42 | ||
43 | using namespace KABC; | 43 | using namespace KABC; |
44 | 44 | ||
45 | static bool matchBinaryPattern( int value, int pattern ); | 45 | static bool matchBinaryPattern( int value, int pattern ); |
46 | static bool matchBinaryPatternA( int value, int pattern ); | 46 | static bool matchBinaryPatternA( int value, int pattern ); |
47 | static bool matchBinaryPatternP( int value, int pattern ); | 47 | static bool matchBinaryPatternP( int value, int pattern ); |
48 | 48 | ||
49 | struct Addressee::AddresseeData : public KShared | 49 | struct Addressee::AddresseeData : public KShared |
50 | { | 50 | { |
51 | QString uid; | 51 | QString uid; |
52 | QString name; | 52 | QString name; |
53 | QString formattedName; | 53 | QString formattedName; |
54 | QString familyName; | 54 | QString familyName; |
55 | QString givenName; | 55 | QString givenName; |
56 | QString additionalName; | 56 | QString additionalName; |
57 | QString prefix; | 57 | QString prefix; |
58 | QString suffix; | 58 | QString suffix; |
59 | QString nickName; | 59 | QString nickName; |
60 | QDateTime birthday; | 60 | QDateTime birthday; |
61 | QString mailer; | 61 | QString mailer; |
62 | TimeZone timeZone; | 62 | TimeZone timeZone; |
63 | Geo geo; | 63 | Geo geo; |
64 | QString title; | 64 | QString title; |
65 | QString role; | 65 | QString role; |
66 | QString organization; | 66 | QString organization; |
67 | QString note; | 67 | QString note; |
68 | QString productId; | 68 | QString productId; |
69 | QDateTime revision; | 69 | QDateTime revision; |
70 | QString sortString; | 70 | QString sortString; |
71 | QString externalUID; | 71 | QString externalUID; |
72 | QString originalExternalUID; | 72 | QString originalExternalUID; |
73 | KURL url; | 73 | KURL url; |
74 | Secrecy secrecy; | 74 | Secrecy secrecy; |
75 | Picture logo; | 75 | Picture logo; |
76 | Picture photo; | 76 | Picture photo; |
77 | Sound sound; | 77 | Sound sound; |
78 | Agent agent; | 78 | Agent agent; |
79 | QString mExternalId; | 79 | QString mExternalId; |
80 | PhoneNumber::List phoneNumbers; | 80 | PhoneNumber::List phoneNumbers; |
81 | Address::List addresses; | 81 | Address::List addresses; |
82 | Key::List keys; | 82 | Key::List keys; |
83 | QStringList emails; | 83 | QStringList emails; |
84 | QStringList categories; | 84 | QStringList categories; |
85 | QStringList custom; | 85 | QStringList custom; |
86 | int mTempSyncStat; | 86 | int mTempSyncStat; |
87 | Resource *resource; | 87 | Resource *resource; |
88 | 88 | ||
89 | bool empty :1; | 89 | bool empty :1; |
90 | bool changed :1; | 90 | bool changed :1; |
91 | bool tagged :1; | 91 | bool tagged :1; |
92 | }; | 92 | }; |
93 | 93 | ||
94 | Addressee::Addressee() | 94 | Addressee::Addressee() |
95 | { | 95 | { |
96 | mData = new AddresseeData; | 96 | mData = new AddresseeData; |
97 | mData->empty = true; | 97 | mData->empty = true; |
98 | mData->changed = false; | 98 | mData->changed = false; |
99 | mData->resource = 0; | 99 | mData->resource = 0; |
100 | mData->mExternalId = ":"; | 100 | mData->mExternalId = ":"; |
101 | mData->revision = QDateTime ( QDate( 2003,1,1)); | 101 | mData->revision = QDateTime ( QDate( 2003,1,1)); |
102 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | 102 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
103 | } | 103 | } |
104 | 104 | ||
105 | Addressee::~Addressee() | 105 | Addressee::~Addressee() |
106 | { | 106 | { |
107 | } | 107 | } |
108 | 108 | ||
109 | Addressee::Addressee( const Addressee &a ) | 109 | Addressee::Addressee( const Addressee &a ) |
110 | { | 110 | { |
111 | mData = a.mData; | 111 | mData = a.mData; |
112 | } | 112 | } |
113 | 113 | ||
114 | Addressee &Addressee::operator=( const Addressee &a ) | 114 | Addressee &Addressee::operator=( const Addressee &a ) |
115 | { | 115 | { |
116 | mData = a.mData; | 116 | mData = a.mData; |
117 | return (*this); | 117 | return (*this); |
118 | } | 118 | } |
119 | 119 | ||
120 | Addressee Addressee::copy() | 120 | Addressee Addressee::copy() |
121 | { | 121 | { |
122 | Addressee a; | 122 | Addressee a; |
123 | *(a.mData) = *mData; | 123 | *(a.mData) = *mData; |
124 | return a; | 124 | return a; |
125 | } | 125 | } |
126 | 126 | ||
127 | void Addressee::detach() | 127 | void Addressee::detach() |
128 | { | 128 | { |
129 | if ( mData.count() == 1 ) return; | 129 | if ( mData.count() == 1 ) return; |
130 | *this = copy(); | 130 | *this = copy(); |
131 | } | 131 | } |
132 | 132 | ||
133 | bool Addressee::operator==( const Addressee &a ) const | 133 | bool Addressee::operator==( const Addressee &a ) const |
134 | { | 134 | { |
135 | if ( uid() != a.uid() ) return false; | 135 | if ( uid() != a.uid() ) return false; |
136 | if ( mData->name != a.mData->name ) return false; | 136 | if ( mData->name != a.mData->name ) return false; |
137 | if ( mData->formattedName != a.mData->formattedName ) return false; | 137 | if ( mData->formattedName != a.mData->formattedName ) return false; |
138 | if ( mData->familyName != a.mData->familyName ) return false; | 138 | if ( mData->familyName != a.mData->familyName ) return false; |
139 | if ( mData->givenName != a.mData->givenName ) return false; | 139 | if ( mData->givenName != a.mData->givenName ) return false; |
140 | if ( mData->additionalName != a.mData->additionalName ) return false; | 140 | if ( mData->additionalName != a.mData->additionalName ) return false; |
141 | if ( mData->prefix != a.mData->prefix ) return false; | 141 | if ( mData->prefix != a.mData->prefix ) return false; |
142 | if ( mData->suffix != a.mData->suffix ) return false; | 142 | if ( mData->suffix != a.mData->suffix ) return false; |
143 | if ( mData->nickName != a.mData->nickName ) return false; | 143 | if ( mData->nickName != a.mData->nickName ) return false; |
144 | if ( mData->birthday != a.mData->birthday ) return false; | 144 | if ( mData->birthday != a.mData->birthday ) return false; |
145 | if ( mData->mailer != a.mData->mailer ) return false; | 145 | if ( mData->mailer != a.mData->mailer ) return false; |
146 | if ( mData->timeZone != a.mData->timeZone ) return false; | 146 | if ( mData->timeZone != a.mData->timeZone ) return false; |
147 | if ( mData->geo != a.mData->geo ) return false; | 147 | if ( mData->geo != a.mData->geo ) return false; |
148 | if ( mData->title != a.mData->title ) return false; | 148 | if ( mData->title != a.mData->title ) return false; |
149 | if ( mData->role != a.mData->role ) return false; | 149 | if ( mData->role != a.mData->role ) return false; |
150 | if ( mData->organization != a.mData->organization ) return false; | 150 | if ( mData->organization != a.mData->organization ) return false; |
151 | if ( mData->note != a.mData->note ) return false; | 151 | if ( mData->note != a.mData->note ) return false; |
152 | if ( mData->productId != a.mData->productId ) return false; | 152 | if ( mData->productId != a.mData->productId ) return false; |
153 | //if ( mData->revision != a.mData->revision ) return false; | 153 | //if ( mData->revision != a.mData->revision ) return false; |
154 | if ( mData->sortString != a.mData->sortString ) return false; | 154 | if ( mData->sortString != a.mData->sortString ) return false; |
155 | if ( mData->secrecy != a.mData->secrecy ) return false; | 155 | if ( mData->secrecy != a.mData->secrecy ) return false; |
156 | if ( mData->logo != a.mData->logo ) return false; | 156 | if ( mData->logo != a.mData->logo ) return false; |
157 | if ( mData->photo != a.mData->photo ) return false; | 157 | if ( mData->photo != a.mData->photo ) return false; |
158 | if ( mData->sound != a.mData->sound ) return false; | 158 | if ( mData->sound != a.mData->sound ) return false; |
159 | if ( mData->agent != a.mData->agent ) return false; | 159 | if ( mData->agent != a.mData->agent ) return false; |
160 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && | 160 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && |
161 | ( mData->url != a.mData->url ) ) return false; | 161 | ( mData->url != a.mData->url ) ) return false; |
162 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; | 162 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; |
163 | if ( mData->addresses != a.mData->addresses ) return false; | 163 | if ( mData->addresses != a.mData->addresses ) return false; |
164 | if ( mData->keys != a.mData->keys ) return false; | 164 | if ( mData->keys != a.mData->keys ) return false; |
165 | if ( mData->emails != a.mData->emails ) return false; | 165 | if ( mData->emails != a.mData->emails ) return false; |
166 | if ( mData->categories != a.mData->categories ) return false; | 166 | if ( mData->categories != a.mData->categories ) return false; |
167 | if ( mData->custom != a.mData->custom ) return false; | 167 | if ( mData->custom != a.mData->custom ) return false; |
168 | 168 | ||
169 | return true; | 169 | return true; |
170 | } | 170 | } |
171 | 171 | ||
172 | bool Addressee::operator!=( const Addressee &a ) const | 172 | bool Addressee::operator!=( const Addressee &a ) const |
173 | { | 173 | { |
174 | return !( a == *this ); | 174 | return !( a == *this ); |
175 | } | 175 | } |
176 | 176 | ||
177 | bool Addressee::isEmpty() const | 177 | bool Addressee::isEmpty() const |
178 | { | 178 | { |
179 | return mData->empty; | 179 | return mData->empty; |
180 | } | 180 | } |
181 | ulong Addressee::getCsum4List( const QStringList & attList) | 181 | ulong Addressee::getCsum4List( const QStringList & attList) |
182 | { | 182 | { |
183 | int max = attList.count(); | 183 | int max = attList.count(); |
184 | ulong cSum = 0; | 184 | ulong cSum = 0; |
185 | int j,k,i; | 185 | int j,k,i; |
186 | int add; | 186 | int add; |
187 | for ( i = 0; i < max ; ++i ) { | 187 | for ( i = 0; i < max ; ++i ) { |
188 | QString s = attList[i]; | 188 | QString s = attList[i]; |
189 | if ( ! s.isEmpty() ){ | 189 | if ( ! s.isEmpty() ){ |
190 | j = s.length(); | 190 | j = s.length(); |
191 | for ( k = 0; k < j; ++k ) { | 191 | for ( k = 0; k < j; ++k ) { |
192 | int mul = k +1; | 192 | int mul = k +1; |
193 | add = s[k].unicode (); | 193 | add = s[k].unicode (); |
194 | if ( k < 16 ) | 194 | if ( k < 16 ) |
195 | mul = mul * mul; | 195 | mul = mul * mul; |
196 | int ii = i+1; | 196 | int ii = i+1; |
197 | add = add * mul *ii*ii*ii; | 197 | add = add * mul *ii*ii*ii; |
198 | cSum += add; | 198 | cSum += add; |
199 | } | 199 | } |
200 | } | 200 | } |
201 | 201 | ||
202 | } | 202 | } |
203 | //QString dump = attList.join(","); | 203 | //QString dump = attList.join(","); |
204 | //qDebug("csum: %d %s", cSum,dump.latin1()); | 204 | //qDebug("csum: %d %s", cSum,dump.latin1()); |
205 | 205 | ||
206 | return cSum; | 206 | return cSum; |
207 | 207 | ||
208 | } | 208 | } |
209 | void Addressee::computeCsum(const QString &dev) | 209 | void Addressee::computeCsum(const QString &dev) |
210 | { | 210 | { |
211 | QStringList l; | 211 | QStringList l; |
212 | if ( !mData->name.isEmpty() ) l.append(mData->name); | 212 | if ( !mData->name.isEmpty() ) l.append(mData->name); |
213 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); | 213 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); |
214 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); | 214 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); |
215 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); | 215 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); |
216 | if ( !mData->additionalName ) l.append( mData->additionalName ); | 216 | if ( !mData->additionalName ) l.append( mData->additionalName ); |
217 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); | 217 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); |
218 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); | 218 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); |
219 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); | 219 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); |
220 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); | 220 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); |
221 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); | 221 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); |
222 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); | 222 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); |
223 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | 223 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); |
224 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | 224 | if ( !mData->title .isEmpty() ) l.append( mData->title ); |
225 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | 225 | if ( !mData->role.isEmpty() ) l.append( mData->role ); |
226 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | 226 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); |
227 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | 227 | if ( !mData->note.isEmpty() ) l.append( mData->note ); |
228 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | 228 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); |
229 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | 229 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); |
230 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | 230 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); |
231 | // if ( !mData->logo.isEmpty() ) l.append( ); | 231 | // if ( !mData->logo.isEmpty() ) l.append( ); |
232 | //if ( !mData->photo.isEmpty() ) l.append( ); | 232 | //if ( !mData->photo.isEmpty() ) l.append( ); |
233 | //if ( !mData->sound.isEmpty() ) l.append( ); | 233 | //if ( !mData->sound.isEmpty() ) l.append( ); |
234 | //if ( !mData->agent.isEmpty() ) l.append( ); | 234 | //if ( !mData->agent.isEmpty() ) l.append( ); |
235 | if ( mData->url.isValid() ) | 235 | if ( mData->url.isValid() ) |
236 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); | 236 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); |
237 | KABC::PhoneNumber::List phoneNumbers; | 237 | KABC::PhoneNumber::List phoneNumbers; |
238 | KABC::PhoneNumber::List::Iterator phoneIter; | 238 | KABC::PhoneNumber::List::Iterator phoneIter; |
239 | 239 | ||
240 | QStringList t; | 240 | QStringList t; |
241 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 241 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
242 | ++phoneIter ) | 242 | ++phoneIter ) |
243 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 243 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); |
244 | t.sort(); | 244 | t.sort(); |
245 | uint iii; | 245 | uint iii; |
246 | for ( iii = 0; iii < t.count(); ++iii) | 246 | for ( iii = 0; iii < t.count(); ++iii) |
247 | l.append( t[iii] ); | 247 | l.append( t[iii] ); |
248 | t = mData->emails; | 248 | t = mData->emails; |
249 | t.sort(); | 249 | t.sort(); |
250 | for ( iii = 0; iii < t.count(); ++iii) | 250 | for ( iii = 0; iii < t.count(); ++iii) |
251 | l.append( t[iii] ); | 251 | l.append( t[iii] ); |
252 | t = mData->categories; | 252 | t = mData->categories; |
253 | t.sort(); | 253 | t.sort(); |
254 | for ( iii = 0; iii < t.count(); ++iii) | 254 | for ( iii = 0; iii < t.count(); ++iii) |
255 | l.append( t[iii] ); | 255 | l.append( t[iii] ); |
256 | t = mData->custom; | 256 | t = mData->custom; |
257 | t.sort(); | 257 | t.sort(); |
258 | for ( iii = 0; iii < t.count(); ++iii) | 258 | for ( iii = 0; iii < t.count(); ++iii) |
259 | l.append( t[iii] ); | 259 | l.append( t[iii] ); |
260 | KABC::Address::List::Iterator addressIter; | 260 | KABC::Address::List::Iterator addressIter; |
261 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 261 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
262 | ++addressIter ) { | 262 | ++addressIter ) { |
263 | t = (*addressIter).asList(); | 263 | t = (*addressIter).asList(); |
264 | t.sort(); | 264 | t.sort(); |
265 | for ( iii = 0; iii < t.count(); ++iii) | 265 | for ( iii = 0; iii < t.count(); ++iii) |
266 | l.append( t[iii] ); | 266 | l.append( t[iii] ); |
267 | } | 267 | } |
268 | uint cs = getCsum4List(l); | 268 | uint cs = getCsum4List(l); |
269 | // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 269 | // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); |
270 | setCsum( dev, QString::number (cs )); | 270 | setCsum( dev, QString::number (cs )); |
271 | } | 271 | } |
272 | 272 | ||
273 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | 273 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) |
274 | { | 274 | { |
275 | 275 | ||
276 | detach(); | 276 | detach(); |
277 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; | 277 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; |
278 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | 278 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; |
279 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; | 279 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; |
280 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; | 280 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; |
281 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; | 281 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; |
282 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; | 282 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; |
283 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; | 283 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; |
284 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; | 284 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; |
285 | if ( !mData->birthday.isValid() ) | 285 | if ( !mData->birthday.isValid() ) |
286 | if ( ad.mData->birthday.isValid()) | 286 | if ( ad.mData->birthday.isValid()) |
287 | mData->birthday = ad.mData->birthday; | 287 | mData->birthday = ad.mData->birthday; |
288 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; | 288 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; |
289 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; | 289 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; |
290 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; | 290 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; |
291 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; | 291 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; |
292 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; | 292 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; |
293 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; | 293 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; |
294 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; | 294 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; |
295 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; | 295 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; |
296 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; | 296 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; |
297 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; | 297 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; |
298 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; | 298 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; |
299 | QStringList t; | 299 | QStringList t; |
300 | QStringList tAD; | 300 | QStringList tAD; |
301 | uint iii; | 301 | uint iii; |
302 | 302 | ||
303 | // ********** phone numbers | 303 | // ********** phone numbers |
304 | PhoneNumber::List phoneAD = ad.phoneNumbers(); | 304 | PhoneNumber::List phoneAD = ad.phoneNumbers(); |
305 | PhoneNumber::List::Iterator phoneItAD; | 305 | PhoneNumber::List::Iterator phoneItAD; |
306 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { | 306 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { |
307 | bool found = false; | 307 | bool found = false; |
308 | PhoneNumber::List::Iterator it; | 308 | PhoneNumber::List::Iterator it; |
309 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 309 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
310 | if ( ( *phoneItAD ).contains( (*it) ) ) { | 310 | if ( ( *phoneItAD ).contains( (*it) ) ) { |
311 | found = true; | 311 | found = true; |
312 | (*it).setType( ( *phoneItAD ).type() ); | 312 | (*it).setType( ( *phoneItAD ).type() ); |
313 | (*it).setNumber( ( *phoneItAD ).number() ); | ||
313 | break; | 314 | break; |
314 | } | 315 | } |
315 | } | 316 | } |
316 | if ( isSubSet && ! found ) | 317 | if ( isSubSet && ! found ) |
317 | mData->phoneNumbers.append( *phoneItAD ); | 318 | mData->phoneNumbers.append( *phoneItAD ); |
318 | } | 319 | } |
319 | if ( isSubSet ) { | 320 | if ( isSubSet ) { |
320 | // ************* emails; | 321 | // ************* emails; |
321 | t = mData->emails; | 322 | t = mData->emails; |
322 | tAD = ad.mData->emails; | 323 | tAD = ad.mData->emails; |
323 | for ( iii = 0; iii < tAD.count(); ++iii) | 324 | for ( iii = 0; iii < tAD.count(); ++iii) |
324 | if ( !t.contains(tAD[iii] ) ) | 325 | if ( !t.contains(tAD[iii] ) ) |
325 | mData->emails.append( tAD[iii] ); | 326 | mData->emails.append( tAD[iii] ); |
326 | } | 327 | } |
327 | 328 | ||
328 | // ************* categories; | 329 | // ************* categories; |
329 | t = mData->categories; | 330 | t = mData->categories; |
330 | tAD = ad.mData->categories; | 331 | tAD = ad.mData->categories; |
331 | for ( iii = 0; iii < tAD.count(); ++iii) | 332 | for ( iii = 0; iii < tAD.count(); ++iii) |
332 | if ( !t.contains(tAD[iii] ) ) | 333 | if ( !t.contains(tAD[iii] ) ) |
333 | mData->categories.append( tAD[iii] ); | 334 | mData->categories.append( tAD[iii] ); |
334 | QStringList::ConstIterator it; | 335 | QStringList::ConstIterator it; |
335 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { | 336 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { |
336 | QString qualifiedName = (*it).left( (*it).find( ":" )); | 337 | QString qualifiedName = (*it).left( (*it).find( ":" )); |
337 | bool found = false; | 338 | bool found = false; |
338 | QStringList::ConstIterator itL; | 339 | QStringList::ConstIterator itL; |
339 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { | 340 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { |
340 | if ( (*itL).startsWith( qualifiedName ) ) { | 341 | if ( (*itL).startsWith( qualifiedName ) ) { |
341 | found = true; | 342 | found = true; |
342 | break; | 343 | break; |
343 | } | 344 | } |
344 | } | 345 | } |
345 | if ( ! found ) { | 346 | if ( ! found ) { |
346 | mData->custom.append( *it ); | 347 | mData->custom.append( *it ); |
347 | } | 348 | } |
348 | } | 349 | } |
349 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; | 350 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; |
350 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; | 351 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; |
351 | if ( !mData->sound.isIntern() ) { | 352 | if ( !mData->sound.isIntern() ) { |
352 | if ( mData->sound.url().isEmpty() ) { | 353 | if ( mData->sound.url().isEmpty() ) { |
353 | mData->sound = ad.mData->sound; | 354 | mData->sound = ad.mData->sound; |
354 | } | 355 | } |
355 | } | 356 | } |
356 | if ( !mData->agent.isIntern() ) { | 357 | if ( !mData->agent.isIntern() ) { |
357 | if ( mData->agent.url().isEmpty() ) { | 358 | if ( mData->agent.url().isEmpty() ) { |
358 | mData->agent = ad.mData->agent; | 359 | mData->agent = ad.mData->agent; |
359 | } | 360 | } |
360 | } | 361 | } |
361 | { | 362 | { |
362 | Key::List::Iterator itA; | 363 | Key::List::Iterator itA; |
363 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { | 364 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { |
364 | bool found = false; | 365 | bool found = false; |
365 | Key::List::Iterator it; | 366 | Key::List::Iterator it; |
366 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 367 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
367 | if ( (*it) == (*itA)) { | 368 | if ( (*it) == (*itA)) { |
368 | found = true; | 369 | found = true; |
369 | break; | 370 | break; |
370 | 371 | ||
371 | } | 372 | } |
372 | } | 373 | } |
373 | if ( ! found ) { | 374 | if ( ! found ) { |
374 | mData->keys.append( *itA ); | 375 | mData->keys.append( *itA ); |
375 | } | 376 | } |
376 | } | 377 | } |
377 | } | 378 | } |
378 | KABC::Address::List::Iterator addressIterA; | 379 | KABC::Address::List::Iterator addressIterA; |
379 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { | 380 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { |
380 | bool found = false; | 381 | bool found = false; |
381 | KABC::Address::List::Iterator addressIter; | 382 | KABC::Address::List::Iterator addressIter; |
382 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 383 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
383 | ++addressIter ) { | 384 | ++addressIter ) { |
384 | if ( (*addressIter) == (*addressIterA)) { | 385 | if ( (*addressIter) == (*addressIterA)) { |
385 | found = true; | 386 | found = true; |
386 | (*addressIter).setType( (*addressIterA).type() ); | 387 | (*addressIter).setType( (*addressIterA).type() ); |
387 | break; | 388 | break; |
388 | } | 389 | } |
389 | 390 | ||
390 | } | 391 | } |
391 | if ( isSubSet && ! found ) { | 392 | if ( isSubSet && ! found ) { |
392 | mData->addresses.append( *addressIterA ); | 393 | mData->addresses.append( *addressIterA ); |
393 | } | 394 | } |
394 | } | 395 | } |
395 | //qDebug("merge contact %s ", ad.uid().latin1()); | 396 | //qDebug("merge contact %s ", ad.uid().latin1()); |
396 | setUid( ad.uid() ); | 397 | setUid( ad.uid() ); |
397 | setRevision( ad.revision() ); | 398 | setRevision( ad.revision() ); |
398 | } | 399 | } |
399 | 400 | ||
400 | bool Addressee::removeVoice() | 401 | bool Addressee::removeVoice() |
401 | { | 402 | { |
402 | PhoneNumber::List phoneN = phoneNumbers(); | 403 | PhoneNumber::List phoneN = phoneNumbers(); |
403 | PhoneNumber::List::Iterator phoneIt; | 404 | PhoneNumber::List::Iterator phoneIt; |
404 | bool found = false; | 405 | bool found = false; |
405 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | 406 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { |
406 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 407 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
407 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 408 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
408 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 409 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
409 | insertPhoneNumber( (*phoneIt) ); | 410 | insertPhoneNumber( (*phoneIt) ); |
410 | found = true; | 411 | found = true; |
411 | } | 412 | } |
412 | } | 413 | } |
413 | 414 | ||
414 | } | 415 | } |
415 | return found; | 416 | return found; |
416 | } | 417 | } |
417 | 418 | ||
418 | bool Addressee::containsAdr(const Addressee& ad ) | 419 | bool Addressee::containsAdr(const Addressee& ad ) |
419 | { | 420 | { |
420 | if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; | 421 | if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; |
421 | if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; | 422 | if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; |
422 | if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; | 423 | if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; |
423 | if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; | 424 | if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; |
424 | if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; | 425 | if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; |
425 | if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; | 426 | if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; |
426 | if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; | 427 | if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; |
427 | 428 | ||
428 | // compare phone numbers | 429 | // compare phone numbers |
429 | PhoneNumber::List phoneN = ad.phoneNumbers(); | 430 | PhoneNumber::List phoneN = ad.phoneNumbers(); |
430 | PhoneNumber::List::Iterator phoneIt; | 431 | PhoneNumber::List::Iterator phoneIt; |
431 | bool found = false; | 432 | bool found = false; |
432 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | 433 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { |
433 | bool found = false; | 434 | bool found = false; |
434 | PhoneNumber::List phoneL = ad.phoneNumbers(); | 435 | PhoneNumber::List phoneL = ad.phoneNumbers(); |
435 | PhoneNumber::List::Iterator phoneItL; | 436 | PhoneNumber::List::Iterator phoneItL; |
436 | for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { | 437 | for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { |
437 | if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { | 438 | if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { |
438 | found = true; | 439 | found = true; |
439 | break; | 440 | break; |
440 | } | 441 | } |
441 | } | 442 | } |
442 | if ( ! found ) | 443 | if ( ! found ) |
443 | return false; | 444 | return false; |
444 | } | 445 | } |
445 | return true; | 446 | return true; |
446 | 447 | ||
447 | } | 448 | } |
448 | void Addressee::simplifyAddresses() | 449 | void Addressee::simplifyAddresses() |
449 | { | 450 | { |
450 | 451 | ||
451 | 452 | ||
452 | Address::List list; | 453 | Address::List list; |
453 | Address::List::Iterator it; | 454 | Address::List::Iterator it; |
454 | Address::List::Iterator it2; | 455 | Address::List::Iterator it2; |
455 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 456 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
456 | it2 = it; | 457 | it2 = it; |
457 | ++it2; | 458 | ++it2; |
458 | for( ; it2 != mData->addresses.end(); ++it2 ) { | 459 | for( ; it2 != mData->addresses.end(); ++it2 ) { |
459 | if ( (*it) == (*it2) ) { | 460 | if ( (*it) == (*it2) ) { |
460 | list.append( *it ); | 461 | list.append( *it ); |
461 | break; | 462 | break; |
462 | } | 463 | } |
463 | } | 464 | } |
464 | } | 465 | } |
465 | for( it = list.begin(); it != list.end(); ++it ) { | 466 | for( it = list.begin(); it != list.end(); ++it ) { |
466 | removeAddress( (*it) ); | 467 | removeAddress( (*it) ); |
467 | } | 468 | } |
468 | 469 | ||
469 | list.clear(); | 470 | list.clear(); |
470 | int max = 2; | 471 | int max = 2; |
471 | if ( mData->url.isValid() ) | 472 | if ( mData->url.isValid() ) |
472 | max = 1; | 473 | max = 1; |
473 | if ( mData->addresses.count() <= max ) return ; | 474 | if ( mData->addresses.count() <= max ) return ; |
474 | int count = 0; | 475 | int count = 0; |
475 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 476 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
476 | if ( count >= max ) | 477 | if ( count >= max ) |
477 | list.append( *it ); | 478 | list.append( *it ); |
478 | ++count; | 479 | ++count; |
479 | } | 480 | } |
480 | for( it = list.begin(); it != list.end(); ++it ) { | 481 | for( it = list.begin(); it != list.end(); ++it ) { |
481 | removeAddress( (*it) ); | 482 | removeAddress( (*it) ); |
482 | } | 483 | } |
483 | } | 484 | } |
484 | 485 | ||
485 | // removes all emails but the first | 486 | // removes all emails but the first |
486 | // needed by phone sync | 487 | // needed by phone sync |
487 | void Addressee::simplifyEmails() | 488 | void Addressee::simplifyEmails() |
488 | { | 489 | { |
489 | if ( mData->emails.count() == 0 ) return ; | 490 | if ( mData->emails.count() == 0 ) return ; |
490 | QString email = mData->emails.first(); | 491 | QString email = mData->emails.first(); |
491 | detach(); | 492 | detach(); |
492 | mData->emails.clear(); | 493 | mData->emails.clear(); |
493 | mData->emails.append( email ); | 494 | mData->emails.append( email ); |
494 | } | 495 | } |
495 | 496 | ||
496 | void Addressee::simplifyPhoneNumbers() | 497 | void Addressee::simplifyPhoneNumbers() |
497 | { | 498 | { |
498 | int max = 4; | 499 | int max = 4; |
499 | int inList = mData->phoneNumbers.count(); | 500 | int inList = mData->phoneNumbers.count(); |
500 | KABC::PhoneNumber::List removeNumbers; | 501 | KABC::PhoneNumber::List removeNumbers; |
501 | KABC::PhoneNumber::List::Iterator phoneIter; | 502 | KABC::PhoneNumber::List::Iterator phoneIter; |
502 | if ( inList > max ) { | 503 | if ( inList > max ) { |
503 | // delete non-preferred numbers | 504 | // delete non-preferred numbers |
504 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 505 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
505 | ++phoneIter ) { | 506 | ++phoneIter ) { |
506 | if ( inList > max ) { | 507 | if ( inList > max ) { |
507 | if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { | 508 | if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { |
508 | removeNumbers.append( ( *phoneIter ) ); | 509 | removeNumbers.append( ( *phoneIter ) ); |
509 | --inList; | 510 | --inList; |
510 | } | 511 | } |
511 | } else | 512 | } else |
512 | break; | 513 | break; |
513 | } | 514 | } |
514 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 515 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
515 | ++phoneIter ) { | 516 | ++phoneIter ) { |
516 | removePhoneNumber(( *phoneIter )); | 517 | removePhoneNumber(( *phoneIter )); |
517 | } | 518 | } |
518 | // delete preferred numbers | 519 | // delete preferred numbers |
519 | if ( inList > max ) { | 520 | if ( inList > max ) { |
520 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 521 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
521 | ++phoneIter ) { | 522 | ++phoneIter ) { |
522 | if ( inList > max ) { | 523 | if ( inList > max ) { |
523 | removeNumbers.append( ( *phoneIter ) ); | 524 | removeNumbers.append( ( *phoneIter ) ); |
524 | --inList; | 525 | --inList; |
525 | } else | 526 | } else |
526 | break; | 527 | break; |
527 | } | 528 | } |
528 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 529 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
529 | ++phoneIter ) { | 530 | ++phoneIter ) { |
530 | removePhoneNumber(( *phoneIter )); | 531 | removePhoneNumber(( *phoneIter )); |
531 | } | 532 | } |
532 | } | 533 | } |
533 | } | 534 | } |
534 | // remove non-numeric characters | 535 | // remove non-numeric characters |
535 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 536 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
536 | ++phoneIter ) { | 537 | ++phoneIter ) { |
537 | if ( ! ( *phoneIter ).simplifyNumber() ) | 538 | if ( ! ( *phoneIter ).simplifyNumber() ) |
538 | removeNumbers.append( ( *phoneIter ) ); | 539 | removeNumbers.append( ( *phoneIter ) ); |
539 | } | 540 | } |
540 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 541 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
541 | ++phoneIter ) { | 542 | ++phoneIter ) { |
542 | removePhoneNumber(( *phoneIter )); | 543 | removePhoneNumber(( *phoneIter )); |
543 | } | 544 | } |
544 | } | 545 | } |
545 | void Addressee::simplifyPhoneNumberTypes() | 546 | void Addressee::simplifyPhoneNumberTypes() |
546 | { | 547 | { |
547 | KABC::PhoneNumber::List::Iterator phoneIter; | 548 | KABC::PhoneNumber::List::Iterator phoneIter; |
548 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 549 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
549 | ++phoneIter ) | 550 | ++phoneIter ) |
550 | ( *phoneIter ).simplifyType(); | 551 | ( *phoneIter ).simplifyType(); |
551 | } | 552 | } |
552 | void Addressee::removeID(const QString &prof) | 553 | void Addressee::removeID(const QString &prof) |
553 | { | 554 | { |
554 | detach(); | 555 | detach(); |
555 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | 556 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); |
556 | 557 | ||
557 | } | 558 | } |
558 | void Addressee::setID( const QString & prof , const QString & id ) | 559 | void Addressee::setID( const QString & prof , const QString & id ) |
559 | { | 560 | { |
560 | detach(); | 561 | detach(); |
561 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | 562 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); |
562 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 563 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
563 | } | 564 | } |
564 | void Addressee::setTempSyncStat( int id ) | 565 | void Addressee::setTempSyncStat( int id ) |
565 | { | 566 | { |
566 | if ( mData->mTempSyncStat == id ) return; | 567 | if ( mData->mTempSyncStat == id ) return; |
567 | detach(); | 568 | detach(); |
568 | mData->mTempSyncStat = id; | 569 | mData->mTempSyncStat = id; |
569 | } | 570 | } |
570 | int Addressee::tempSyncStat() const | 571 | int Addressee::tempSyncStat() const |
571 | { | 572 | { |
572 | return mData->mTempSyncStat; | 573 | return mData->mTempSyncStat; |
573 | } | 574 | } |
574 | 575 | ||
575 | QString Addressee::getID( const QString & prof) | 576 | QString Addressee::getID( const QString & prof) |
576 | { | 577 | { |
577 | return KIdManager::getId ( mData->mExternalId, prof ); | 578 | return KIdManager::getId ( mData->mExternalId, prof ); |
578 | } | 579 | } |
579 | 580 | ||
580 | void Addressee::setCsum( const QString & prof , const QString & id ) | 581 | void Addressee::setCsum( const QString & prof , const QString & id ) |
581 | { | 582 | { |
582 | detach(); | 583 | detach(); |
583 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 584 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
584 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | 585 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); |
585 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); | 586 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); |
586 | } | 587 | } |
587 | 588 | ||
588 | QString Addressee::getCsum( const QString & prof) | 589 | QString Addressee::getCsum( const QString & prof) |
589 | { | 590 | { |
590 | return KIdManager::getCsum ( mData->mExternalId, prof ); | 591 | return KIdManager::getCsum ( mData->mExternalId, prof ); |
591 | } | 592 | } |
592 | 593 | ||
593 | void Addressee::setIDStr( const QString & s ) | 594 | void Addressee::setIDStr( const QString & s ) |
594 | { | 595 | { |
595 | detach(); | 596 | detach(); |
596 | mData->mExternalId = s; | 597 | mData->mExternalId = s; |
597 | } | 598 | } |
598 | 599 | ||
599 | QString Addressee::IDStr() const | 600 | QString Addressee::IDStr() const |
600 | { | 601 | { |
601 | return mData->mExternalId; | 602 | return mData->mExternalId; |
602 | } | 603 | } |
603 | 604 | ||
604 | void Addressee::setExternalUID( const QString &id ) | 605 | void Addressee::setExternalUID( const QString &id ) |
605 | { | 606 | { |
606 | if ( id == mData->externalUID ) return; | 607 | if ( id == mData->externalUID ) return; |
607 | detach(); | 608 | detach(); |
608 | mData->empty = false; | 609 | mData->empty = false; |
609 | mData->externalUID = id; | 610 | mData->externalUID = id; |
610 | } | 611 | } |
611 | 612 | ||
612 | QString Addressee::externalUID() const | 613 | QString Addressee::externalUID() const |
613 | { | 614 | { |
614 | return mData->externalUID; | 615 | return mData->externalUID; |
615 | } | 616 | } |
616 | void Addressee::setOriginalExternalUID( const QString &id ) | 617 | void Addressee::setOriginalExternalUID( const QString &id ) |
617 | { | 618 | { |
618 | if ( id == mData->originalExternalUID ) return; | 619 | if ( id == mData->originalExternalUID ) return; |
619 | detach(); | 620 | detach(); |
620 | mData->empty = false; | 621 | mData->empty = false; |
621 | //qDebug("*******Set orig uid %s ", id.latin1()); | 622 | //qDebug("*******Set orig uid %s ", id.latin1()); |
622 | mData->originalExternalUID = id; | 623 | mData->originalExternalUID = id; |
623 | } | 624 | } |
624 | 625 | ||
625 | QString Addressee::originalExternalUID() const | 626 | QString Addressee::originalExternalUID() const |
626 | { | 627 | { |
627 | return mData->originalExternalUID; | 628 | return mData->originalExternalUID; |
628 | } | 629 | } |
629 | 630 | ||
630 | void Addressee::setUid( const QString &id ) | 631 | void Addressee::setUid( const QString &id ) |
631 | { | 632 | { |
632 | if ( id == mData->uid ) return; | 633 | if ( id == mData->uid ) return; |
633 | detach(); | 634 | detach(); |
634 | //qDebug("****setuid %s ", id.latin1()); | 635 | //qDebug("****setuid %s ", id.latin1()); |
635 | mData->empty = false; | 636 | mData->empty = false; |
636 | mData->uid = id; | 637 | mData->uid = id; |
637 | } | 638 | } |
638 | 639 | ||
639 | QString Addressee::uid() const | 640 | QString Addressee::uid() const |
640 | { | 641 | { |
641 | if ( mData->uid.isEmpty() ) | 642 | if ( mData->uid.isEmpty() ) |
642 | mData->uid = KApplication::randomString( 10 ); | 643 | mData->uid = KApplication::randomString( 10 ); |
643 | 644 | ||
644 | return mData->uid; | 645 | return mData->uid; |
645 | } | 646 | } |
646 | 647 | ||
647 | QString Addressee::uidLabel() | 648 | QString Addressee::uidLabel() |
648 | { | 649 | { |
649 | return i18n("Unique Identifier"); | 650 | return i18n("Unique Identifier"); |
650 | } | 651 | } |
651 | 652 | ||
652 | void Addressee::setName( const QString &name ) | 653 | void Addressee::setName( const QString &name ) |
653 | { | 654 | { |
654 | if ( name == mData->name ) return; | 655 | if ( name == mData->name ) return; |
655 | detach(); | 656 | detach(); |
656 | mData->empty = false; | 657 | mData->empty = false; |
657 | mData->name = name; | 658 | mData->name = name; |
658 | } | 659 | } |
659 | 660 | ||
660 | QString Addressee::name() const | 661 | QString Addressee::name() const |
661 | { | 662 | { |
662 | return mData->name; | 663 | return mData->name; |
663 | } | 664 | } |
664 | 665 | ||
665 | QString Addressee::nameLabel() | 666 | QString Addressee::nameLabel() |
666 | { | 667 | { |
667 | return i18n("Name"); | 668 | return i18n("Name"); |
668 | } | 669 | } |
669 | 670 | ||
670 | 671 | ||
671 | void Addressee::setFormattedName( const QString &formattedName ) | 672 | void Addressee::setFormattedName( const QString &formattedName ) |
672 | { | 673 | { |
673 | if ( formattedName == mData->formattedName ) return; | 674 | if ( formattedName == mData->formattedName ) return; |
674 | detach(); | 675 | detach(); |
675 | mData->empty = false; | 676 | mData->empty = false; |
676 | mData->formattedName = formattedName; | 677 | mData->formattedName = formattedName; |
677 | } | 678 | } |
678 | 679 | ||
679 | QString Addressee::formattedName() const | 680 | QString Addressee::formattedName() const |
680 | { | 681 | { |
681 | return mData->formattedName; | 682 | return mData->formattedName; |
682 | } | 683 | } |
683 | 684 | ||
684 | QString Addressee::formattedNameLabel() | 685 | QString Addressee::formattedNameLabel() |
685 | { | 686 | { |
686 | return i18n("Formatted Name"); | 687 | return i18n("Formatted Name"); |
687 | } | 688 | } |
688 | 689 | ||
689 | 690 | ||
690 | void Addressee::setFamilyName( const QString &familyName ) | 691 | void Addressee::setFamilyName( const QString &familyName ) |
691 | { | 692 | { |
692 | if ( familyName == mData->familyName ) return; | 693 | if ( familyName == mData->familyName ) return; |
693 | detach(); | 694 | detach(); |
694 | mData->empty = false; | 695 | mData->empty = false; |
695 | mData->familyName = familyName; | 696 | mData->familyName = familyName; |
696 | } | 697 | } |
697 | 698 | ||
698 | QString Addressee::familyName() const | 699 | QString Addressee::familyName() const |
699 | { | 700 | { |
700 | return mData->familyName; | 701 | return mData->familyName; |
701 | } | 702 | } |
702 | 703 | ||
703 | QString Addressee::familyNameLabel() | 704 | QString Addressee::familyNameLabel() |
704 | { | 705 | { |
705 | return i18n("Family Name"); | 706 | return i18n("Family Name"); |
706 | } | 707 | } |
707 | 708 | ||
708 | 709 | ||
709 | void Addressee::setGivenName( const QString &givenName ) | 710 | void Addressee::setGivenName( const QString &givenName ) |
710 | { | 711 | { |
711 | if ( givenName == mData->givenName ) return; | 712 | if ( givenName == mData->givenName ) return; |
712 | detach(); | 713 | detach(); |
713 | mData->empty = false; | 714 | mData->empty = false; |
714 | mData->givenName = givenName; | 715 | mData->givenName = givenName; |
715 | } | 716 | } |
716 | 717 | ||
717 | QString Addressee::givenName() const | 718 | QString Addressee::givenName() const |
718 | { | 719 | { |
719 | return mData->givenName; | 720 | return mData->givenName; |
720 | } | 721 | } |
721 | 722 | ||
722 | QString Addressee::givenNameLabel() | 723 | QString Addressee::givenNameLabel() |
723 | { | 724 | { |
724 | return i18n("Given Name"); | 725 | return i18n("Given Name"); |
725 | } | 726 | } |
726 | 727 | ||
727 | 728 | ||
728 | void Addressee::setAdditionalName( const QString &additionalName ) | 729 | void Addressee::setAdditionalName( const QString &additionalName ) |
729 | { | 730 | { |
730 | if ( additionalName == mData->additionalName ) return; | 731 | if ( additionalName == mData->additionalName ) return; |
731 | detach(); | 732 | detach(); |
732 | mData->empty = false; | 733 | mData->empty = false; |
733 | mData->additionalName = additionalName; | 734 | mData->additionalName = additionalName; |
734 | } | 735 | } |
735 | 736 | ||
736 | QString Addressee::additionalName() const | 737 | QString Addressee::additionalName() const |
737 | { | 738 | { |
738 | return mData->additionalName; | 739 | return mData->additionalName; |
739 | } | 740 | } |
740 | 741 | ||
741 | QString Addressee::additionalNameLabel() | 742 | QString Addressee::additionalNameLabel() |
742 | { | 743 | { |
743 | return i18n("Additional Names"); | 744 | return i18n("Additional Names"); |
744 | } | 745 | } |
745 | 746 | ||
746 | 747 | ||
747 | void Addressee::setPrefix( const QString &prefix ) | 748 | void Addressee::setPrefix( const QString &prefix ) |
748 | { | 749 | { |
749 | if ( prefix == mData->prefix ) return; | 750 | if ( prefix == mData->prefix ) return; |
750 | detach(); | 751 | detach(); |
751 | mData->empty = false; | 752 | mData->empty = false; |
752 | mData->prefix = prefix; | 753 | mData->prefix = prefix; |
753 | } | 754 | } |
754 | 755 | ||
755 | QString Addressee::prefix() const | 756 | QString Addressee::prefix() const |
756 | { | 757 | { |
757 | return mData->prefix; | 758 | return mData->prefix; |
758 | } | 759 | } |
759 | 760 | ||
760 | QString Addressee::prefixLabel() | 761 | QString Addressee::prefixLabel() |
761 | { | 762 | { |
762 | return i18n("Honorific Prefixes"); | 763 | return i18n("Honorific Prefixes"); |
763 | } | 764 | } |
764 | 765 | ||
765 | 766 | ||
766 | void Addressee::setSuffix( const QString &suffix ) | 767 | void Addressee::setSuffix( const QString &suffix ) |
767 | { | 768 | { |
768 | if ( suffix == mData->suffix ) return; | 769 | if ( suffix == mData->suffix ) return; |
769 | detach(); | 770 | detach(); |
770 | mData->empty = false; | 771 | mData->empty = false; |
771 | mData->suffix = suffix; | 772 | mData->suffix = suffix; |
772 | } | 773 | } |
773 | 774 | ||
774 | QString Addressee::suffix() const | 775 | QString Addressee::suffix() const |
775 | { | 776 | { |
776 | return mData->suffix; | 777 | return mData->suffix; |
777 | } | 778 | } |
778 | 779 | ||
779 | QString Addressee::suffixLabel() | 780 | QString Addressee::suffixLabel() |
780 | { | 781 | { |
781 | return i18n("Honorific Suffixes"); | 782 | return i18n("Honorific Suffixes"); |
782 | } | 783 | } |
783 | 784 | ||
784 | 785 | ||
785 | void Addressee::setNickName( const QString &nickName ) | 786 | void Addressee::setNickName( const QString &nickName ) |
786 | { | 787 | { |
787 | if ( nickName == mData->nickName ) return; | 788 | if ( nickName == mData->nickName ) return; |
788 | detach(); | 789 | detach(); |
789 | mData->empty = false; | 790 | mData->empty = false; |
790 | mData->nickName = nickName; | 791 | mData->nickName = nickName; |
791 | } | 792 | } |
792 | 793 | ||
793 | QString Addressee::nickName() const | 794 | QString Addressee::nickName() const |
794 | { | 795 | { |
795 | return mData->nickName; | 796 | return mData->nickName; |
796 | } | 797 | } |
797 | 798 | ||
798 | QString Addressee::nickNameLabel() | 799 | QString Addressee::nickNameLabel() |
799 | { | 800 | { |
800 | return i18n("Nick Name"); | 801 | return i18n("Nick Name"); |
801 | } | 802 | } |
802 | 803 | ||
803 | 804 | ||
804 | void Addressee::setBirthday( const QDateTime &birthday ) | 805 | void Addressee::setBirthday( const QDateTime &birthday ) |
805 | { | 806 | { |
806 | if ( birthday == mData->birthday ) return; | 807 | if ( birthday == mData->birthday ) return; |
807 | detach(); | 808 | detach(); |
808 | mData->empty = false; | 809 | mData->empty = false; |
809 | mData->birthday = birthday; | 810 | mData->birthday = birthday; |
810 | } | 811 | } |
811 | 812 | ||
812 | QDateTime Addressee::birthday() const | 813 | QDateTime Addressee::birthday() const |
813 | { | 814 | { |
814 | return mData->birthday; | 815 | return mData->birthday; |
815 | } | 816 | } |
816 | 817 | ||
817 | QString Addressee::birthdayLabel() | 818 | QString Addressee::birthdayLabel() |
818 | { | 819 | { |
819 | return i18n("Birthday"); | 820 | return i18n("Birthday"); |
820 | } | 821 | } |
821 | 822 | ||
822 | 823 | ||
823 | QString Addressee::homeAddressStreetLabel() | 824 | QString Addressee::homeAddressStreetLabel() |
824 | { | 825 | { |
825 | return i18n("Home Address Street"); | 826 | return i18n("Home Address Street"); |
826 | } | 827 | } |
827 | 828 | ||
828 | 829 | ||
829 | QString Addressee::homeAddressLocalityLabel() | 830 | QString Addressee::homeAddressLocalityLabel() |
830 | { | 831 | { |
831 | return i18n("Home Address Locality"); | 832 | return i18n("Home Address Locality"); |
832 | } | 833 | } |
833 | 834 | ||
834 | 835 | ||
835 | QString Addressee::homeAddressRegionLabel() | 836 | QString Addressee::homeAddressRegionLabel() |
836 | { | 837 | { |
837 | return i18n("Home Address Region"); | 838 | return i18n("Home Address Region"); |
838 | } | 839 | } |
839 | 840 | ||
840 | 841 | ||
841 | QString Addressee::homeAddressPostalCodeLabel() | 842 | QString Addressee::homeAddressPostalCodeLabel() |
842 | { | 843 | { |
843 | return i18n("Home Address Postal Code"); | 844 | return i18n("Home Address Postal Code"); |
844 | } | 845 | } |
845 | 846 | ||
846 | 847 | ||
847 | QString Addressee::homeAddressCountryLabel() | 848 | QString Addressee::homeAddressCountryLabel() |
848 | { | 849 | { |
849 | return i18n("Home Address Country"); | 850 | return i18n("Home Address Country"); |
850 | } | 851 | } |
851 | 852 | ||
852 | 853 | ||
853 | QString Addressee::homeAddressLabelLabel() | 854 | QString Addressee::homeAddressLabelLabel() |
854 | { | 855 | { |
855 | return i18n("Home Address Label"); | 856 | return i18n("Home Address Label"); |
856 | } | 857 | } |
857 | 858 | ||
858 | 859 | ||
859 | QString Addressee::businessAddressStreetLabel() | 860 | QString Addressee::businessAddressStreetLabel() |
860 | { | 861 | { |
861 | return i18n("Business Address Street"); | 862 | return i18n("Business Address Street"); |
862 | } | 863 | } |
863 | 864 | ||
864 | 865 | ||
865 | QString Addressee::businessAddressLocalityLabel() | 866 | QString Addressee::businessAddressLocalityLabel() |
866 | { | 867 | { |
867 | return i18n("Business Address Locality"); | 868 | return i18n("Business Address Locality"); |
868 | } | 869 | } |
869 | 870 | ||
870 | 871 | ||
871 | QString Addressee::businessAddressRegionLabel() | 872 | QString Addressee::businessAddressRegionLabel() |
872 | { | 873 | { |
873 | return i18n("Business Address Region"); | 874 | return i18n("Business Address Region"); |
874 | } | 875 | } |
875 | 876 | ||
876 | 877 | ||
877 | QString Addressee::businessAddressPostalCodeLabel() | 878 | QString Addressee::businessAddressPostalCodeLabel() |
878 | { | 879 | { |
879 | return i18n("Business Address Postal Code"); | 880 | return i18n("Business Address Postal Code"); |
880 | } | 881 | } |
881 | 882 | ||
882 | 883 | ||
883 | QString Addressee::businessAddressCountryLabel() | 884 | QString Addressee::businessAddressCountryLabel() |
884 | { | 885 | { |
885 | return i18n("Business Address Country"); | 886 | return i18n("Business Address Country"); |
886 | } | 887 | } |
887 | 888 | ||
888 | 889 | ||
889 | QString Addressee::businessAddressLabelLabel() | 890 | QString Addressee::businessAddressLabelLabel() |
890 | { | 891 | { |
891 | return i18n("Business Address Label"); | 892 | return i18n("Business Address Label"); |
892 | } | 893 | } |
893 | 894 | ||
894 | 895 | ||
895 | QString Addressee::homePhoneLabel() | 896 | QString Addressee::homePhoneLabel() |
896 | { | 897 | { |
897 | return i18n("Home Phone"); | 898 | return i18n("Home Phone"); |
898 | } | 899 | } |
899 | 900 | ||
900 | 901 | ||
901 | QString Addressee::businessPhoneLabel() | 902 | QString Addressee::businessPhoneLabel() |
902 | { | 903 | { |
903 | return i18n("Business Phone"); | 904 | return i18n("Business Phone"); |
904 | } | 905 | } |
905 | 906 | ||
906 | 907 | ||
907 | QString Addressee::mobilePhoneLabel() | 908 | QString Addressee::mobilePhoneLabel() |
908 | { | 909 | { |
909 | return i18n("Mobile Phone"); | 910 | return i18n("Mobile Phone"); |
910 | } | 911 | } |
911 | 912 | ||
912 | 913 | ||
913 | QString Addressee::homeFaxLabel() | 914 | QString Addressee::homeFaxLabel() |
914 | { | 915 | { |
915 | return i18n("Home Fax"); | 916 | return i18n("Home Fax"); |
916 | } | 917 | } |
917 | 918 | ||
918 | 919 | ||
919 | QString Addressee::businessFaxLabel() | 920 | QString Addressee::businessFaxLabel() |
920 | { | 921 | { |
921 | return i18n("Business Fax"); | 922 | return i18n("Business Fax"); |
922 | } | 923 | } |
923 | 924 | ||
924 | 925 | ||
925 | QString Addressee::carPhoneLabel() | 926 | QString Addressee::carPhoneLabel() |
926 | { | 927 | { |
927 | return i18n("Car Phone"); | 928 | return i18n("Car Phone"); |
928 | } | 929 | } |
929 | 930 | ||
930 | 931 | ||
931 | QString Addressee::isdnLabel() | 932 | QString Addressee::isdnLabel() |
932 | { | 933 | { |
933 | return i18n("ISDN"); | 934 | return i18n("ISDN"); |
934 | } | 935 | } |
935 | 936 | ||
936 | 937 | ||
937 | QString Addressee::pagerLabel() | 938 | QString Addressee::pagerLabel() |
938 | { | 939 | { |
939 | return i18n("Pager"); | 940 | return i18n("Pager"); |
940 | } | 941 | } |
941 | 942 | ||
942 | QString Addressee::sipLabel() | 943 | QString Addressee::sipLabel() |
943 | { | 944 | { |
944 | return i18n("SIP"); | 945 | return i18n("SIP"); |
945 | } | 946 | } |
946 | 947 | ||
947 | QString Addressee::emailLabel() | 948 | QString Addressee::emailLabel() |
948 | { | 949 | { |
949 | return i18n("Email Address"); | 950 | return i18n("Email Address"); |
950 | } | 951 | } |
951 | 952 | ||
952 | 953 | ||
953 | void Addressee::setMailer( const QString &mailer ) | 954 | void Addressee::setMailer( const QString &mailer ) |
954 | { | 955 | { |
955 | if ( mailer == mData->mailer ) return; | 956 | if ( mailer == mData->mailer ) return; |
956 | detach(); | 957 | detach(); |
957 | mData->empty = false; | 958 | mData->empty = false; |
958 | mData->mailer = mailer; | 959 | mData->mailer = mailer; |
959 | } | 960 | } |
960 | 961 | ||
961 | QString Addressee::mailer() const | 962 | QString Addressee::mailer() const |
962 | { | 963 | { |
963 | return mData->mailer; | 964 | return mData->mailer; |
964 | } | 965 | } |
965 | 966 | ||
966 | QString Addressee::mailerLabel() | 967 | QString Addressee::mailerLabel() |
967 | { | 968 | { |
968 | return i18n("Mail Client"); | 969 | return i18n("Mail Client"); |
969 | } | 970 | } |
970 | 971 | ||
971 | 972 | ||
972 | void Addressee::setTimeZone( const TimeZone &timeZone ) | 973 | void Addressee::setTimeZone( const TimeZone &timeZone ) |
973 | { | 974 | { |
974 | if ( timeZone == mData->timeZone ) return; | 975 | if ( timeZone == mData->timeZone ) return; |
975 | detach(); | 976 | detach(); |
976 | mData->empty = false; | 977 | mData->empty = false; |
977 | mData->timeZone = timeZone; | 978 | mData->timeZone = timeZone; |
978 | } | 979 | } |
979 | 980 | ||
980 | TimeZone Addressee::timeZone() const | 981 | TimeZone Addressee::timeZone() const |
981 | { | 982 | { |
982 | return mData->timeZone; | 983 | return mData->timeZone; |
983 | } | 984 | } |
984 | 985 | ||
985 | QString Addressee::timeZoneLabel() | 986 | QString Addressee::timeZoneLabel() |
986 | { | 987 | { |
987 | return i18n("Time Zone"); | 988 | return i18n("Time Zone"); |
988 | } | 989 | } |
989 | 990 | ||
990 | 991 | ||
991 | void Addressee::setGeo( const Geo &geo ) | 992 | void Addressee::setGeo( const Geo &geo ) |
992 | { | 993 | { |
993 | if ( geo == mData->geo ) return; | 994 | if ( geo == mData->geo ) return; |
994 | detach(); | 995 | detach(); |
995 | mData->empty = false; | 996 | mData->empty = false; |
996 | mData->geo = geo; | 997 | mData->geo = geo; |
997 | } | 998 | } |
998 | 999 | ||
999 | Geo Addressee::geo() const | 1000 | Geo Addressee::geo() const |
1000 | { | 1001 | { |
1001 | return mData->geo; | 1002 | return mData->geo; |
1002 | } | 1003 | } |
1003 | 1004 | ||
1004 | QString Addressee::geoLabel() | 1005 | QString Addressee::geoLabel() |
1005 | { | 1006 | { |
1006 | return i18n("Geographic Position"); | 1007 | return i18n("Geographic Position"); |
1007 | } | 1008 | } |
1008 | 1009 | ||
1009 | 1010 | ||
1010 | void Addressee::setTitle( const QString &title ) | 1011 | void Addressee::setTitle( const QString &title ) |
1011 | { | 1012 | { |
1012 | if ( title == mData->title ) return; | 1013 | if ( title == mData->title ) return; |
1013 | detach(); | 1014 | detach(); |
1014 | mData->empty = false; | 1015 | mData->empty = false; |
1015 | mData->title = title; | 1016 | mData->title = title; |
1016 | } | 1017 | } |
1017 | 1018 | ||
1018 | QString Addressee::title() const | 1019 | QString Addressee::title() const |
1019 | { | 1020 | { |
1020 | return mData->title; | 1021 | return mData->title; |
1021 | } | 1022 | } |
1022 | 1023 | ||
1023 | QString Addressee::titleLabel() | 1024 | QString Addressee::titleLabel() |
1024 | { | 1025 | { |
1025 | return i18n("Title"); | 1026 | return i18n("Title"); |
1026 | } | 1027 | } |
1027 | 1028 | ||
1028 | 1029 | ||
1029 | void Addressee::setRole( const QString &role ) | 1030 | void Addressee::setRole( const QString &role ) |
1030 | { | 1031 | { |
1031 | if ( role == mData->role ) return; | 1032 | if ( role == mData->role ) return; |
1032 | detach(); | 1033 | detach(); |
1033 | mData->empty = false; | 1034 | mData->empty = false; |
1034 | mData->role = role; | 1035 | mData->role = role; |
1035 | } | 1036 | } |
1036 | 1037 | ||
1037 | QString Addressee::role() const | 1038 | QString Addressee::role() const |
1038 | { | 1039 | { |
1039 | return mData->role; | 1040 | return mData->role; |
1040 | } | 1041 | } |
1041 | 1042 | ||
1042 | QString Addressee::roleLabel() | 1043 | QString Addressee::roleLabel() |
1043 | { | 1044 | { |
1044 | return i18n("Role"); | 1045 | return i18n("Role"); |
1045 | } | 1046 | } |
1046 | 1047 | ||
1047 | 1048 | ||
1048 | void Addressee::setOrganization( const QString &organization ) | 1049 | void Addressee::setOrganization( const QString &organization ) |
1049 | { | 1050 | { |
1050 | if ( organization == mData->organization ) return; | 1051 | if ( organization == mData->organization ) return; |
1051 | detach(); | 1052 | detach(); |
1052 | mData->empty = false; | 1053 | mData->empty = false; |
1053 | mData->organization = organization; | 1054 | mData->organization = organization; |
1054 | } | 1055 | } |
1055 | 1056 | ||
1056 | QString Addressee::organization() const | 1057 | QString Addressee::organization() const |
1057 | { | 1058 | { |
1058 | return mData->organization; | 1059 | return mData->organization; |
1059 | } | 1060 | } |
1060 | 1061 | ||
1061 | QString Addressee::organizationLabel() | 1062 | QString Addressee::organizationLabel() |
1062 | { | 1063 | { |
1063 | return i18n("Organization"); | 1064 | return i18n("Organization"); |
1064 | } | 1065 | } |
1065 | 1066 | ||
1066 | 1067 | ||
1067 | void Addressee::setNote( const QString ¬e ) | 1068 | void Addressee::setNote( const QString ¬e ) |
1068 | { | 1069 | { |
1069 | if ( note == mData->note ) return; | 1070 | if ( note == mData->note ) return; |
1070 | detach(); | 1071 | detach(); |
1071 | mData->empty = false; | 1072 | mData->empty = false; |
1072 | mData->note = note; | 1073 | mData->note = note; |
1073 | } | 1074 | } |
1074 | 1075 | ||
1075 | QString Addressee::note() const | 1076 | QString Addressee::note() const |
1076 | { | 1077 | { |
1077 | return mData->note; | 1078 | return mData->note; |
1078 | } | 1079 | } |
1079 | 1080 | ||
1080 | QString Addressee::noteLabel() | 1081 | QString Addressee::noteLabel() |
1081 | { | 1082 | { |
1082 | return i18n("Note"); | 1083 | return i18n("Note"); |
1083 | } | 1084 | } |
1084 | 1085 | ||
1085 | 1086 | ||
1086 | void Addressee::setProductId( const QString &productId ) | 1087 | void Addressee::setProductId( const QString &productId ) |
1087 | { | 1088 | { |
1088 | if ( productId == mData->productId ) return; | 1089 | if ( productId == mData->productId ) return; |
1089 | detach(); | 1090 | detach(); |
1090 | mData->empty = false; | 1091 | mData->empty = false; |
1091 | mData->productId = productId; | 1092 | mData->productId = productId; |
1092 | } | 1093 | } |
1093 | 1094 | ||
1094 | QString Addressee::productId() const | 1095 | QString Addressee::productId() const |
1095 | { | 1096 | { |
1096 | return mData->productId; | 1097 | return mData->productId; |
1097 | } | 1098 | } |
1098 | 1099 | ||
1099 | QString Addressee::productIdLabel() | 1100 | QString Addressee::productIdLabel() |
1100 | { | 1101 | { |
1101 | return i18n("Product Identifier"); | 1102 | return i18n("Product Identifier"); |
1102 | } | 1103 | } |
1103 | 1104 | ||
1104 | 1105 | ||
1105 | void Addressee::setRevision( const QDateTime &revision ) | 1106 | void Addressee::setRevision( const QDateTime &revision ) |
1106 | { | 1107 | { |
1107 | if ( revision == mData->revision ) return; | 1108 | if ( revision == mData->revision ) return; |
1108 | detach(); | 1109 | detach(); |
1109 | mData->empty = false; | 1110 | mData->empty = false; |
1110 | mData->revision = revision; | 1111 | mData->revision = revision; |
1111 | } | 1112 | } |
1112 | 1113 | ||
1113 | QDateTime Addressee::revision() const | 1114 | QDateTime Addressee::revision() const |
1114 | { | 1115 | { |
1115 | return mData->revision; | 1116 | return mData->revision; |
1116 | } | 1117 | } |
1117 | 1118 | ||
1118 | QString Addressee::revisionLabel() | 1119 | QString Addressee::revisionLabel() |
1119 | { | 1120 | { |
1120 | return i18n("Revision Date"); | 1121 | return i18n("Revision Date"); |
1121 | } | 1122 | } |
1122 | 1123 | ||
1123 | 1124 | ||
1124 | void Addressee::setSortString( const QString &sortString ) | 1125 | void Addressee::setSortString( const QString &sortString ) |
1125 | { | 1126 | { |
1126 | if ( sortString == mData->sortString ) return; | 1127 | if ( sortString == mData->sortString ) return; |
1127 | detach(); | 1128 | detach(); |
1128 | mData->empty = false; | 1129 | mData->empty = false; |
1129 | mData->sortString = sortString; | 1130 | mData->sortString = sortString; |
1130 | } | 1131 | } |
1131 | 1132 | ||
1132 | QString Addressee::sortString() const | 1133 | QString Addressee::sortString() const |
1133 | { | 1134 | { |
1134 | return mData->sortString; | 1135 | return mData->sortString; |
1135 | } | 1136 | } |
1136 | 1137 | ||
1137 | QString Addressee::sortStringLabel() | 1138 | QString Addressee::sortStringLabel() |
1138 | { | 1139 | { |
1139 | return i18n("Sort String"); | 1140 | return i18n("Sort String"); |
1140 | } | 1141 | } |
1141 | 1142 | ||
1142 | 1143 | ||
1143 | void Addressee::setUrl( const KURL &url ) | 1144 | void Addressee::setUrl( const KURL &url ) |
1144 | { | 1145 | { |
1145 | if ( url == mData->url ) return; | 1146 | if ( url == mData->url ) return; |
1146 | detach(); | 1147 | detach(); |
1147 | mData->empty = false; | 1148 | mData->empty = false; |
1148 | mData->url = url; | 1149 | mData->url = url; |
1149 | } | 1150 | } |
1150 | 1151 | ||
1151 | KURL Addressee::url() const | 1152 | KURL Addressee::url() const |
1152 | { | 1153 | { |
1153 | return mData->url; | 1154 | return mData->url; |
1154 | } | 1155 | } |
1155 | 1156 | ||
1156 | QString Addressee::urlLabel() | 1157 | QString Addressee::urlLabel() |
1157 | { | 1158 | { |
1158 | return i18n("URL"); | 1159 | return i18n("URL"); |
1159 | } | 1160 | } |
1160 | 1161 | ||
1161 | 1162 | ||
1162 | void Addressee::setSecrecy( const Secrecy &secrecy ) | 1163 | void Addressee::setSecrecy( const Secrecy &secrecy ) |
1163 | { | 1164 | { |
1164 | if ( secrecy == mData->secrecy ) return; | 1165 | if ( secrecy == mData->secrecy ) return; |
1165 | detach(); | 1166 | detach(); |
1166 | mData->empty = false; | 1167 | mData->empty = false; |
1167 | mData->secrecy = secrecy; | 1168 | mData->secrecy = secrecy; |
1168 | } | 1169 | } |
1169 | 1170 | ||
1170 | Secrecy Addressee::secrecy() const | 1171 | Secrecy Addressee::secrecy() const |
1171 | { | 1172 | { |
1172 | return mData->secrecy; | 1173 | return mData->secrecy; |
1173 | } | 1174 | } |
1174 | 1175 | ||
1175 | QString Addressee::secrecyLabel() | 1176 | QString Addressee::secrecyLabel() |
1176 | { | 1177 | { |
1177 | return i18n("Security Class"); | 1178 | return i18n("Security Class"); |
1178 | } | 1179 | } |
1179 | 1180 | ||
1180 | 1181 | ||
1181 | void Addressee::setLogo( const Picture &logo ) | 1182 | void Addressee::setLogo( const Picture &logo ) |
1182 | { | 1183 | { |
1183 | if ( logo == mData->logo ) return; | 1184 | if ( logo == mData->logo ) return; |
1184 | detach(); | 1185 | detach(); |
1185 | mData->empty = false; | 1186 | mData->empty = false; |
1186 | mData->logo = logo; | 1187 | mData->logo = logo; |
1187 | } | 1188 | } |
1188 | 1189 | ||
1189 | Picture Addressee::logo() const | 1190 | Picture Addressee::logo() const |
1190 | { | 1191 | { |
1191 | return mData->logo; | 1192 | return mData->logo; |
1192 | } | 1193 | } |
1193 | 1194 | ||
1194 | QString Addressee::logoLabel() | 1195 | QString Addressee::logoLabel() |
1195 | { | 1196 | { |
1196 | return i18n("Logo"); | 1197 | return i18n("Logo"); |
1197 | } | 1198 | } |
1198 | 1199 | ||
1199 | 1200 | ||
1200 | void Addressee::setPhoto( const Picture &photo ) | 1201 | void Addressee::setPhoto( const Picture &photo ) |
1201 | { | 1202 | { |
1202 | if ( photo == mData->photo ) return; | 1203 | if ( photo == mData->photo ) return; |
1203 | detach(); | 1204 | detach(); |
1204 | mData->empty = false; | 1205 | mData->empty = false; |
1205 | mData->photo = photo; | 1206 | mData->photo = photo; |
1206 | } | 1207 | } |
1207 | 1208 | ||
1208 | Picture Addressee::photo() const | 1209 | Picture Addressee::photo() const |
1209 | { | 1210 | { |
1210 | return mData->photo; | 1211 | return mData->photo; |
1211 | } | 1212 | } |
1212 | 1213 | ||
1213 | QString Addressee::photoLabel() | 1214 | QString Addressee::photoLabel() |
1214 | { | 1215 | { |
1215 | return i18n("Photo"); | 1216 | return i18n("Photo"); |
1216 | } | 1217 | } |
1217 | 1218 | ||
1218 | 1219 | ||
1219 | void Addressee::setSound( const Sound &sound ) | 1220 | void Addressee::setSound( const Sound &sound ) |
1220 | { | 1221 | { |
1221 | if ( sound == mData->sound ) return; | 1222 | if ( sound == mData->sound ) return; |
1222 | detach(); | 1223 | detach(); |
1223 | mData->empty = false; | 1224 | mData->empty = false; |
1224 | mData->sound = sound; | 1225 | mData->sound = sound; |
1225 | } | 1226 | } |
1226 | 1227 | ||
1227 | Sound Addressee::sound() const | 1228 | Sound Addressee::sound() const |
1228 | { | 1229 | { |
1229 | return mData->sound; | 1230 | return mData->sound; |
1230 | } | 1231 | } |
1231 | 1232 | ||
1232 | QString Addressee::soundLabel() | 1233 | QString Addressee::soundLabel() |
1233 | { | 1234 | { |
1234 | return i18n("Sound"); | 1235 | return i18n("Sound"); |
1235 | } | 1236 | } |
1236 | 1237 | ||
1237 | 1238 | ||
1238 | void Addressee::setAgent( const Agent &agent ) | 1239 | void Addressee::setAgent( const Agent &agent ) |
1239 | { | 1240 | { |
1240 | if ( agent == mData->agent ) return; | 1241 | if ( agent == mData->agent ) return; |
1241 | detach(); | 1242 | detach(); |
1242 | mData->empty = false; | 1243 | mData->empty = false; |
1243 | mData->agent = agent; | 1244 | mData->agent = agent; |
1244 | } | 1245 | } |
1245 | 1246 | ||
1246 | Agent Addressee::agent() const | 1247 | Agent Addressee::agent() const |
1247 | { | 1248 | { |
1248 | return mData->agent; | 1249 | return mData->agent; |
1249 | } | 1250 | } |
1250 | 1251 | ||
1251 | QString Addressee::agentLabel() | 1252 | QString Addressee::agentLabel() |
1252 | { | 1253 | { |
1253 | return i18n("Agent"); | 1254 | return i18n("Agent"); |
1254 | } | 1255 | } |
1255 | 1256 | ||
1256 | 1257 | ||
1257 | 1258 | ||
1258 | void Addressee::setNameFromString( const QString &str ) | 1259 | void Addressee::setNameFromString( const QString &str ) |
1259 | { | 1260 | { |
1260 | setFormattedName( str ); | 1261 | setFormattedName( str ); |
1261 | setName( str ); | 1262 | setName( str ); |
1262 | 1263 | ||
1263 | static bool first = true; | 1264 | static bool first = true; |
1264 | static QStringList titles; | 1265 | static QStringList titles; |
1265 | static QStringList suffixes; | 1266 | static QStringList suffixes; |
1266 | static QStringList prefixes; | 1267 | static QStringList prefixes; |
1267 | 1268 | ||
1268 | if ( first ) { | 1269 | if ( first ) { |
1269 | first = false; | 1270 | first = false; |
1270 | titles += i18n( "Dr." ); | 1271 | titles += i18n( "Dr." ); |
1271 | titles += i18n( "Miss" ); | 1272 | titles += i18n( "Miss" ); |
1272 | titles += i18n( "Mr." ); | 1273 | titles += i18n( "Mr." ); |
1273 | titles += i18n( "Mrs." ); | 1274 | titles += i18n( "Mrs." ); |
1274 | titles += i18n( "Ms." ); | 1275 | titles += i18n( "Ms." ); |
1275 | titles += i18n( "Prof." ); | 1276 | titles += i18n( "Prof." ); |
1276 | 1277 | ||
1277 | suffixes += i18n( "I" ); | 1278 | suffixes += i18n( "I" ); |
1278 | suffixes += i18n( "II" ); | 1279 | suffixes += i18n( "II" ); |
1279 | suffixes += i18n( "III" ); | 1280 | suffixes += i18n( "III" ); |
1280 | suffixes += i18n( "Jr." ); | 1281 | suffixes += i18n( "Jr." ); |
1281 | suffixes += i18n( "Sr." ); | 1282 | suffixes += i18n( "Sr." ); |
1282 | 1283 | ||
1283 | prefixes += "van"; | 1284 | prefixes += "van"; |
1284 | prefixes += "von"; | 1285 | prefixes += "von"; |
1285 | prefixes += "de"; | 1286 | prefixes += "de"; |
1286 | 1287 | ||
1287 | KConfig config( locateLocal( "config", "kabcrc") ); | 1288 | KConfig config( locateLocal( "config", "kabcrc") ); |
1288 | config.setGroup( "General" ); | 1289 | config.setGroup( "General" ); |
1289 | titles += config.readListEntry( "Prefixes" ); | 1290 | titles += config.readListEntry( "Prefixes" ); |
1290 | titles.remove( "" ); | 1291 | titles.remove( "" ); |
1291 | prefixes += config.readListEntry( "Inclusions" ); | 1292 | prefixes += config.readListEntry( "Inclusions" ); |
1292 | prefixes.remove( "" ); | 1293 | prefixes.remove( "" ); |
1293 | suffixes += config.readListEntry( "Suffixes" ); | 1294 | suffixes += config.readListEntry( "Suffixes" ); |
1294 | suffixes.remove( "" ); | 1295 | suffixes.remove( "" ); |
1295 | } | 1296 | } |
1296 | 1297 | ||
1297 | // clear all name parts | 1298 | // clear all name parts |
1298 | setPrefix( "" ); | 1299 | setPrefix( "" ); |
1299 | setGivenName( "" ); | 1300 | setGivenName( "" ); |
1300 | setAdditionalName( "" ); | 1301 | setAdditionalName( "" ); |
1301 | setFamilyName( "" ); | 1302 | setFamilyName( "" ); |
1302 | setSuffix( "" ); | 1303 | setSuffix( "" ); |
1303 | 1304 | ||
1304 | if ( str.isEmpty() ) | 1305 | if ( str.isEmpty() ) |
1305 | return; | 1306 | return; |
1306 | 1307 | ||
1307 | int i = str.find(','); | 1308 | int i = str.find(','); |
1308 | if( i < 0 ) { | 1309 | if( i < 0 ) { |
1309 | QStringList parts = QStringList::split( " ", str ); | 1310 | QStringList parts = QStringList::split( " ", str ); |
1310 | int leftOffset = 0; | 1311 | int leftOffset = 0; |
1311 | int rightOffset = parts.count() - 1; | 1312 | int rightOffset = parts.count() - 1; |
1312 | 1313 | ||
1313 | QString suffix; | 1314 | QString suffix; |
1314 | while ( rightOffset >= 0 ) { | 1315 | while ( rightOffset >= 0 ) { |
1315 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1316 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1316 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1317 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1317 | rightOffset--; | 1318 | rightOffset--; |
1318 | } else | 1319 | } else |
1319 | break; | 1320 | break; |
1320 | } | 1321 | } |
1321 | setSuffix( suffix ); | 1322 | setSuffix( suffix ); |
1322 | 1323 | ||
1323 | if ( rightOffset < 0 ) | 1324 | if ( rightOffset < 0 ) |
1324 | return; | 1325 | return; |
1325 | 1326 | ||
1326 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1327 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1327 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1328 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1328 | rightOffset--; | 1329 | rightOffset--; |
1329 | } else | 1330 | } else |
1330 | setFamilyName( parts[ rightOffset ] ); | 1331 | setFamilyName( parts[ rightOffset ] ); |
1331 | 1332 | ||
1332 | QString prefix; | 1333 | QString prefix; |
1333 | while ( leftOffset < rightOffset ) { | 1334 | while ( leftOffset < rightOffset ) { |
1334 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1335 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1335 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1336 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1336 | leftOffset++; | 1337 | leftOffset++; |
1337 | } else | 1338 | } else |
1338 | break; | 1339 | break; |
1339 | } | 1340 | } |
1340 | setPrefix( prefix ); | 1341 | setPrefix( prefix ); |
1341 | 1342 | ||
1342 | if ( leftOffset < rightOffset ) { | 1343 | if ( leftOffset < rightOffset ) { |
1343 | setGivenName( parts[ leftOffset ] ); | 1344 | setGivenName( parts[ leftOffset ] ); |
1344 | leftOffset++; | 1345 | leftOffset++; |
1345 | } | 1346 | } |
1346 | 1347 | ||
1347 | QString additionalName; | 1348 | QString additionalName; |
1348 | while ( leftOffset < rightOffset ) { | 1349 | while ( leftOffset < rightOffset ) { |
1349 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1350 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1350 | leftOffset++; | 1351 | leftOffset++; |
1351 | } | 1352 | } |
1352 | setAdditionalName( additionalName ); | 1353 | setAdditionalName( additionalName ); |
1353 | } else { | 1354 | } else { |
1354 | QString part1 = str.left( i ); | 1355 | QString part1 = str.left( i ); |
1355 | QString part2 = str.mid( i + 1 ); | 1356 | QString part2 = str.mid( i + 1 ); |
1356 | 1357 | ||
1357 | QStringList parts = QStringList::split( " ", part1 ); | 1358 | QStringList parts = QStringList::split( " ", part1 ); |
1358 | int leftOffset = 0; | 1359 | int leftOffset = 0; |
1359 | int rightOffset = parts.count() - 1; | 1360 | int rightOffset = parts.count() - 1; |
1360 | 1361 | ||
1361 | QString suffix; | 1362 | QString suffix; |
1362 | while ( rightOffset >= 0 ) { | 1363 | while ( rightOffset >= 0 ) { |
1363 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1364 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1364 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1365 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1365 | rightOffset--; | 1366 | rightOffset--; |
1366 | } else | 1367 | } else |
1367 | break; | 1368 | break; |
1368 | } | 1369 | } |
1369 | setSuffix( suffix ); | 1370 | setSuffix( suffix ); |
1370 | 1371 | ||
1371 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1372 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1372 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1373 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1373 | rightOffset--; | 1374 | rightOffset--; |
1374 | } else | 1375 | } else |
1375 | setFamilyName( parts[ rightOffset ] ); | 1376 | setFamilyName( parts[ rightOffset ] ); |
1376 | 1377 | ||
1377 | QString prefix; | 1378 | QString prefix; |
1378 | while ( leftOffset < rightOffset ) { | 1379 | while ( leftOffset < rightOffset ) { |
1379 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1380 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1380 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1381 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1381 | leftOffset++; | 1382 | leftOffset++; |
1382 | } else | 1383 | } else |
1383 | break; | 1384 | break; |
1384 | } | 1385 | } |
1385 | 1386 | ||
1386 | parts = QStringList::split( " ", part2 ); | 1387 | parts = QStringList::split( " ", part2 ); |
1387 | 1388 | ||
1388 | leftOffset = 0; | 1389 | leftOffset = 0; |
1389 | rightOffset = parts.count(); | 1390 | rightOffset = parts.count(); |
1390 | 1391 | ||
1391 | while ( leftOffset < rightOffset ) { | 1392 | while ( leftOffset < rightOffset ) { |
1392 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1393 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1393 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1394 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1394 | leftOffset++; | 1395 | leftOffset++; |
1395 | } else | 1396 | } else |
1396 | break; | 1397 | break; |
1397 | } | 1398 | } |
1398 | setPrefix( prefix ); | 1399 | setPrefix( prefix ); |
1399 | 1400 | ||
1400 | if ( leftOffset < rightOffset ) { | 1401 | if ( leftOffset < rightOffset ) { |
1401 | setGivenName( parts[ leftOffset ] ); | 1402 | setGivenName( parts[ leftOffset ] ); |
1402 | leftOffset++; | 1403 | leftOffset++; |
1403 | } | 1404 | } |
1404 | 1405 | ||
1405 | QString additionalName; | 1406 | QString additionalName; |
1406 | while ( leftOffset < rightOffset ) { | 1407 | while ( leftOffset < rightOffset ) { |
1407 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1408 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1408 | leftOffset++; | 1409 | leftOffset++; |
1409 | } | 1410 | } |
1410 | setAdditionalName( additionalName ); | 1411 | setAdditionalName( additionalName ); |
1411 | } | 1412 | } |
1412 | } | 1413 | } |
1413 | 1414 | ||
1414 | QString Addressee::realName() const | 1415 | QString Addressee::realName() const |
1415 | { | 1416 | { |
1416 | if ( !formattedName().isEmpty() ) | 1417 | if ( !formattedName().isEmpty() ) |
1417 | return formattedName(); | 1418 | return formattedName(); |
1418 | 1419 | ||
1419 | QString n = assembledName(); | 1420 | QString n = assembledName(); |
1420 | 1421 | ||
1421 | if ( n.isEmpty() ) | 1422 | if ( n.isEmpty() ) |
1422 | n = name(); | 1423 | n = name(); |
1423 | 1424 | ||
1424 | return n; | 1425 | return n; |
1425 | } | 1426 | } |
1426 | 1427 | ||
1427 | QString Addressee::assembledName() const | 1428 | QString Addressee::assembledName() const |
1428 | { | 1429 | { |
1429 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + | 1430 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + |
1430 | familyName() + " " + suffix(); | 1431 | familyName() + " " + suffix(); |
1431 | 1432 | ||
1432 | return name.simplifyWhiteSpace(); | 1433 | return name.simplifyWhiteSpace(); |
1433 | } | 1434 | } |
1434 | 1435 | ||
1435 | QString Addressee::fullEmail( const QString &email ) const | 1436 | QString Addressee::fullEmail( const QString &email ) const |
1436 | { | 1437 | { |
1437 | QString e; | 1438 | QString e; |
1438 | if ( email.isNull() ) { | 1439 | if ( email.isNull() ) { |
1439 | e = preferredEmail(); | 1440 | e = preferredEmail(); |
1440 | } else { | 1441 | } else { |
1441 | e = email; | 1442 | e = email; |
1442 | } | 1443 | } |
1443 | if ( e.isEmpty() ) return QString::null; | 1444 | if ( e.isEmpty() ) return QString::null; |
1444 | 1445 | ||
1445 | QString text; | 1446 | QString text; |
1446 | if ( realName().isEmpty() ) | 1447 | if ( realName().isEmpty() ) |
1447 | text = e; | 1448 | text = e; |
1448 | else | 1449 | else |
1449 | text = assembledName() + " <" + e + ">"; | 1450 | text = assembledName() + " <" + e + ">"; |
1450 | 1451 | ||
1451 | return text; | 1452 | return text; |
1452 | } | 1453 | } |
1453 | 1454 | ||
1454 | void Addressee::insertEmail( const QString &email, bool preferred ) | 1455 | void Addressee::insertEmail( const QString &email, bool preferred ) |
1455 | { | 1456 | { |
1456 | detach(); | 1457 | detach(); |
1457 | 1458 | ||
1458 | QStringList::Iterator it = mData->emails.find( email ); | 1459 | QStringList::Iterator it = mData->emails.find( email ); |
1459 | 1460 | ||
1460 | if ( it != mData->emails.end() ) { | 1461 | if ( it != mData->emails.end() ) { |
1461 | if ( !preferred || it == mData->emails.begin() ) return; | 1462 | if ( !preferred || it == mData->emails.begin() ) return; |
1462 | mData->emails.remove( it ); | 1463 | mData->emails.remove( it ); |
1463 | mData->emails.prepend( email ); | 1464 | mData->emails.prepend( email ); |
1464 | } else { | 1465 | } else { |
1465 | if ( preferred ) { | 1466 | if ( preferred ) { |
1466 | mData->emails.prepend( email ); | 1467 | mData->emails.prepend( email ); |
1467 | } else { | 1468 | } else { |
1468 | mData->emails.append( email ); | 1469 | mData->emails.append( email ); |
1469 | } | 1470 | } |
1470 | } | 1471 | } |
1471 | } | 1472 | } |
1472 | 1473 | ||
1473 | void Addressee::removeEmail( const QString &email ) | 1474 | void Addressee::removeEmail( const QString &email ) |
1474 | { | 1475 | { |
1475 | detach(); | 1476 | detach(); |
1476 | 1477 | ||
1477 | QStringList::Iterator it = mData->emails.find( email ); | 1478 | QStringList::Iterator it = mData->emails.find( email ); |
1478 | if ( it == mData->emails.end() ) return; | 1479 | if ( it == mData->emails.end() ) return; |
1479 | 1480 | ||
1480 | mData->emails.remove( it ); | 1481 | mData->emails.remove( it ); |
1481 | } | 1482 | } |
1482 | 1483 | ||
1483 | QString Addressee::preferredEmail() const | 1484 | QString Addressee::preferredEmail() const |
1484 | { | 1485 | { |
1485 | if ( mData->emails.count() == 0 ) return QString::null; | 1486 | if ( mData->emails.count() == 0 ) return QString::null; |
1486 | else return mData->emails.first(); | 1487 | else return mData->emails.first(); |
1487 | } | 1488 | } |
1488 | 1489 | ||
1489 | QStringList Addressee::emails() const | 1490 | QStringList Addressee::emails() const |
1490 | { | 1491 | { |
1491 | return mData->emails; | 1492 | return mData->emails; |
1492 | } | 1493 | } |
1493 | void Addressee::setEmails( const QStringList& emails ) { | 1494 | void Addressee::setEmails( const QStringList& emails ) { |
1494 | detach(); | 1495 | detach(); |
1495 | mData->emails = emails; | 1496 | mData->emails = emails; |
1496 | } | 1497 | } |
1497 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) | 1498 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) |
1498 | { | 1499 | { |
1499 | detach(); | 1500 | detach(); |
1500 | mData->empty = false; | 1501 | mData->empty = false; |
1501 | 1502 | ||
1502 | PhoneNumber::List::Iterator it; | 1503 | PhoneNumber::List::Iterator it; |
1503 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1504 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1504 | if ( (*it).id() == phoneNumber.id() ) { | 1505 | if ( (*it).id() == phoneNumber.id() ) { |
1505 | *it = phoneNumber; | 1506 | *it = phoneNumber; |
1506 | return; | 1507 | return; |
1507 | } | 1508 | } |
1508 | } | 1509 | } |
1509 | mData->phoneNumbers.append( phoneNumber ); | 1510 | mData->phoneNumbers.append( phoneNumber ); |
1510 | } | 1511 | } |
1511 | 1512 | ||
1512 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) | 1513 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) |
1513 | { | 1514 | { |
1514 | detach(); | 1515 | detach(); |
1515 | 1516 | ||
1516 | PhoneNumber::List::Iterator it; | 1517 | PhoneNumber::List::Iterator it; |
1517 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1518 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1518 | if ( (*it).id() == phoneNumber.id() ) { | 1519 | if ( (*it).id() == phoneNumber.id() ) { |
1519 | mData->phoneNumbers.remove( it ); | 1520 | mData->phoneNumbers.remove( it ); |
1520 | return; | 1521 | return; |
1521 | } | 1522 | } |
1522 | } | 1523 | } |
1523 | } | 1524 | } |
1524 | 1525 | ||
1525 | PhoneNumber Addressee::phoneNumber( int type ) const | 1526 | PhoneNumber Addressee::phoneNumber( int type ) const |
1526 | { | 1527 | { |
1527 | PhoneNumber phoneNumber( "", type ); | 1528 | PhoneNumber phoneNumber( "", type ); |
1528 | PhoneNumber::List::ConstIterator it; | 1529 | PhoneNumber::List::ConstIterator it; |
1529 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1530 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1530 | if ( matchBinaryPatternP( (*it).type(), type ) ) { | 1531 | if ( matchBinaryPatternP( (*it).type(), type ) ) { |
1531 | if ( (*it).type() & PhoneNumber::Pref ) | 1532 | if ( (*it).type() & PhoneNumber::Pref ) |
1532 | return (*it); | 1533 | return (*it); |
1533 | else if ( phoneNumber.number().isEmpty() ) | 1534 | else if ( phoneNumber.number().isEmpty() ) |
1534 | phoneNumber = (*it); | 1535 | phoneNumber = (*it); |
1535 | } | 1536 | } |
1536 | } | 1537 | } |
1537 | 1538 | ||
1538 | return phoneNumber; | 1539 | return phoneNumber; |
1539 | } | 1540 | } |
1540 | 1541 | ||
1541 | PhoneNumber::List Addressee::phoneNumbers() const | 1542 | PhoneNumber::List Addressee::phoneNumbers() const |
1542 | { | 1543 | { |
1543 | return mData->phoneNumbers; | 1544 | return mData->phoneNumbers; |
1544 | } | 1545 | } |
1545 | 1546 | ||
1546 | PhoneNumber::List Addressee::phoneNumbers( int type ) const | 1547 | PhoneNumber::List Addressee::phoneNumbers( int type ) const |
1547 | { | 1548 | { |
1548 | PhoneNumber::List list; | 1549 | PhoneNumber::List list; |
1549 | 1550 | ||
1550 | PhoneNumber::List::ConstIterator it; | 1551 | PhoneNumber::List::ConstIterator it; |
1551 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1552 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1552 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1553 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1553 | list.append( *it ); | 1554 | list.append( *it ); |
1554 | } | 1555 | } |
1555 | } | 1556 | } |
1556 | return list; | 1557 | return list; |
1557 | } | 1558 | } |
1558 | 1559 | ||
1559 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const | 1560 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const |
1560 | { | 1561 | { |
1561 | PhoneNumber::List::ConstIterator it; | 1562 | PhoneNumber::List::ConstIterator it; |
1562 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1563 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1563 | if ( (*it).id() == id ) { | 1564 | if ( (*it).id() == id ) { |
1564 | return *it; | 1565 | return *it; |
1565 | } | 1566 | } |
1566 | } | 1567 | } |
1567 | return PhoneNumber(); | 1568 | return PhoneNumber(); |
1568 | } | 1569 | } |
1569 | 1570 | ||
1570 | void Addressee::insertKey( const Key &key ) | 1571 | void Addressee::insertKey( const Key &key ) |
1571 | { | 1572 | { |
1572 | detach(); | 1573 | detach(); |
1573 | mData->empty = false; | 1574 | mData->empty = false; |
1574 | 1575 | ||
1575 | Key::List::Iterator it; | 1576 | Key::List::Iterator it; |
1576 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1577 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1577 | if ( (*it).id() == key.id() ) { | 1578 | if ( (*it).id() == key.id() ) { |
1578 | *it = key; | 1579 | *it = key; |
1579 | return; | 1580 | return; |
1580 | } | 1581 | } |
1581 | } | 1582 | } |
1582 | mData->keys.append( key ); | 1583 | mData->keys.append( key ); |
1583 | } | 1584 | } |
1584 | 1585 | ||
1585 | void Addressee::removeKey( const Key &key ) | 1586 | void Addressee::removeKey( const Key &key ) |
1586 | { | 1587 | { |
1587 | detach(); | 1588 | detach(); |
1588 | 1589 | ||
1589 | Key::List::Iterator it; | 1590 | Key::List::Iterator it; |
1590 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1591 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1591 | if ( (*it).id() == key.id() ) { | 1592 | if ( (*it).id() == key.id() ) { |
1592 | mData->keys.remove( key ); | 1593 | mData->keys.remove( key ); |
1593 | return; | 1594 | return; |
1594 | } | 1595 | } |
1595 | } | 1596 | } |
1596 | } | 1597 | } |
1597 | 1598 | ||
1598 | Key Addressee::key( int type, QString customTypeString ) const | 1599 | Key Addressee::key( int type, QString customTypeString ) const |
1599 | { | 1600 | { |
1600 | Key::List::ConstIterator it; | 1601 | Key::List::ConstIterator it; |
1601 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1602 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1602 | if ( (*it).type() == type ) { | 1603 | if ( (*it).type() == type ) { |
1603 | if ( type == Key::Custom ) { | 1604 | if ( type == Key::Custom ) { |
1604 | if ( customTypeString.isEmpty() ) { | 1605 | if ( customTypeString.isEmpty() ) { |
1605 | return *it; | 1606 | return *it; |
1606 | } else { | 1607 | } else { |
1607 | if ( (*it).customTypeString() == customTypeString ) | 1608 | if ( (*it).customTypeString() == customTypeString ) |
1608 | return (*it); | 1609 | return (*it); |
1609 | } | 1610 | } |
1610 | } else { | 1611 | } else { |
1611 | return *it; | 1612 | return *it; |
1612 | } | 1613 | } |
1613 | } | 1614 | } |
1614 | } | 1615 | } |
1615 | return Key( QString(), type ); | 1616 | return Key( QString(), type ); |
1616 | } | 1617 | } |
1617 | void Addressee::setKeys( const Key::List& list ) { | 1618 | void Addressee::setKeys( const Key::List& list ) { |
1618 | detach(); | 1619 | detach(); |
1619 | mData->keys = list; | 1620 | mData->keys = list; |
1620 | } | 1621 | } |
1621 | 1622 | ||
1622 | Key::List Addressee::keys() const | 1623 | Key::List Addressee::keys() const |
1623 | { | 1624 | { |
1624 | return mData->keys; | 1625 | return mData->keys; |
1625 | } | 1626 | } |
1626 | 1627 | ||
1627 | Key::List Addressee::keys( int type, QString customTypeString ) const | 1628 | Key::List Addressee::keys( int type, QString customTypeString ) const |
1628 | { | 1629 | { |
1629 | Key::List list; | 1630 | Key::List list; |
1630 | 1631 | ||
1631 | Key::List::ConstIterator it; | 1632 | Key::List::ConstIterator it; |
1632 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1633 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1633 | if ( (*it).type() == type ) { | 1634 | if ( (*it).type() == type ) { |
1634 | if ( type == Key::Custom ) { | 1635 | if ( type == Key::Custom ) { |
1635 | if ( customTypeString.isEmpty() ) { | 1636 | if ( customTypeString.isEmpty() ) { |
1636 | list.append(*it); | 1637 | list.append(*it); |
1637 | } else { | 1638 | } else { |
1638 | if ( (*it).customTypeString() == customTypeString ) | 1639 | if ( (*it).customTypeString() == customTypeString ) |
1639 | list.append(*it); | 1640 | list.append(*it); |
1640 | } | 1641 | } |
1641 | } else { | 1642 | } else { |
1642 | list.append(*it); | 1643 | list.append(*it); |
1643 | } | 1644 | } |
1644 | } | 1645 | } |
1645 | } | 1646 | } |
1646 | return list; | 1647 | return list; |
1647 | } | 1648 | } |
1648 | 1649 | ||
1649 | Key Addressee::findKey( const QString &id ) const | 1650 | Key Addressee::findKey( const QString &id ) const |
1650 | { | 1651 | { |
1651 | Key::List::ConstIterator it; | 1652 | Key::List::ConstIterator it; |
1652 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1653 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1653 | if ( (*it).id() == id ) { | 1654 | if ( (*it).id() == id ) { |
1654 | return *it; | 1655 | return *it; |
1655 | } | 1656 | } |
1656 | } | 1657 | } |
1657 | return Key(); | 1658 | return Key(); |
1658 | } | 1659 | } |
1659 | 1660 | ||
1660 | QString Addressee::asString() const | 1661 | QString Addressee::asString() const |
1661 | { | 1662 | { |
1662 | return "Smith, agent Smith..."; | 1663 | return "Smith, agent Smith..."; |
1663 | } | 1664 | } |
1664 | 1665 | ||
1665 | void Addressee::dump() const | 1666 | void Addressee::dump() const |
1666 | { | 1667 | { |
1667 | return; | 1668 | return; |
1668 | kdDebug(5700) << "Addressee {" << endl; | 1669 | kdDebug(5700) << "Addressee {" << endl; |
1669 | 1670 | ||
1670 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; | 1671 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; |
1671 | 1672 | ||
1672 | kdDebug(5700) << " Name: '" << name() << "'" << endl; | 1673 | kdDebug(5700) << " Name: '" << name() << "'" << endl; |
1673 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; | 1674 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; |
1674 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; | 1675 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; |
1675 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; | 1676 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; |
1676 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; | 1677 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; |
1677 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; | 1678 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; |
1678 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; | 1679 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; |
1679 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; | 1680 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; |
1680 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; | 1681 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; |
1681 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; | 1682 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; |
1682 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; | 1683 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; |
1683 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; | 1684 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; |
1684 | kdDebug(5700) << " Title: '" << title() << "'" << endl; | 1685 | kdDebug(5700) << " Title: '" << title() << "'" << endl; |
1685 | kdDebug(5700) << " Role: '" << role() << "'" << endl; | 1686 | kdDebug(5700) << " Role: '" << role() << "'" << endl; |
1686 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; | 1687 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; |
1687 | kdDebug(5700) << " Note: '" << note() << "'" << endl; | 1688 | kdDebug(5700) << " Note: '" << note() << "'" << endl; |
1688 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; | 1689 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; |
1689 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; | 1690 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; |
1690 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; | 1691 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; |
1691 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; | 1692 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; |
1692 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; | 1693 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; |
1693 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; | 1694 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; |
1694 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; | 1695 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; |
1695 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; | 1696 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; |
1696 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; | 1697 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; |
1697 | 1698 | ||
1698 | kdDebug(5700) << " Emails {" << endl; | 1699 | kdDebug(5700) << " Emails {" << endl; |
1699 | QStringList e = emails(); | 1700 | QStringList e = emails(); |
1700 | QStringList::ConstIterator it; | 1701 | QStringList::ConstIterator it; |
1701 | for( it = e.begin(); it != e.end(); ++it ) { | 1702 | for( it = e.begin(); it != e.end(); ++it ) { |
1702 | kdDebug(5700) << " " << (*it) << endl; | 1703 | kdDebug(5700) << " " << (*it) << endl; |
1703 | } | 1704 | } |
1704 | kdDebug(5700) << " }" << endl; | 1705 | kdDebug(5700) << " }" << endl; |
1705 | 1706 | ||
1706 | kdDebug(5700) << " PhoneNumbers {" << endl; | 1707 | kdDebug(5700) << " PhoneNumbers {" << endl; |
1707 | PhoneNumber::List p = phoneNumbers(); | 1708 | PhoneNumber::List p = phoneNumbers(); |
1708 | PhoneNumber::List::ConstIterator it2; | 1709 | PhoneNumber::List::ConstIterator it2; |
1709 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { | 1710 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { |
1710 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; | 1711 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; |
1711 | } | 1712 | } |
1712 | kdDebug(5700) << " }" << endl; | 1713 | kdDebug(5700) << " }" << endl; |
1713 | 1714 | ||
1714 | Address::List a = addresses(); | 1715 | Address::List a = addresses(); |
1715 | Address::List::ConstIterator it3; | 1716 | Address::List::ConstIterator it3; |
1716 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { | 1717 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { |
1717 | (*it3).dump(); | 1718 | (*it3).dump(); |
1718 | } | 1719 | } |
1719 | 1720 | ||
1720 | kdDebug(5700) << " Keys {" << endl; | 1721 | kdDebug(5700) << " Keys {" << endl; |
1721 | Key::List k = keys(); | 1722 | Key::List k = keys(); |
1722 | Key::List::ConstIterator it4; | 1723 | Key::List::ConstIterator it4; |
1723 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { | 1724 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { |
1724 | kdDebug(5700) << " Type: " << int((*it4).type()) << | 1725 | kdDebug(5700) << " Type: " << int((*it4).type()) << |
1725 | " Key: " << (*it4).textData() << | 1726 | " Key: " << (*it4).textData() << |
1726 | " CustomString: " << (*it4).customTypeString() << endl; | 1727 | " CustomString: " << (*it4).customTypeString() << endl; |
1727 | } | 1728 | } |
1728 | kdDebug(5700) << " }" << endl; | 1729 | kdDebug(5700) << " }" << endl; |
1729 | 1730 | ||
1730 | kdDebug(5700) << "}" << endl; | 1731 | kdDebug(5700) << "}" << endl; |
1731 | } | 1732 | } |
1732 | 1733 | ||
1733 | 1734 | ||
1734 | void Addressee::insertAddress( const Address &address ) | 1735 | void Addressee::insertAddress( const Address &address ) |
1735 | { | 1736 | { |
1736 | detach(); | 1737 | detach(); |
1737 | mData->empty = false; | 1738 | mData->empty = false; |
1738 | 1739 | ||
1739 | Address::List::Iterator it; | 1740 | Address::List::Iterator it; |
1740 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1741 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1741 | if ( (*it).id() == address.id() ) { | 1742 | if ( (*it).id() == address.id() ) { |
1742 | *it = address; | 1743 | *it = address; |
1743 | return; | 1744 | return; |
1744 | } | 1745 | } |
1745 | } | 1746 | } |
1746 | mData->addresses.append( address ); | 1747 | mData->addresses.append( address ); |
1747 | } | 1748 | } |
1748 | 1749 | ||
1749 | void Addressee::removeAddress( const Address &address ) | 1750 | void Addressee::removeAddress( const Address &address ) |
1750 | { | 1751 | { |
1751 | detach(); | 1752 | detach(); |
1752 | 1753 | ||
1753 | Address::List::Iterator it; | 1754 | Address::List::Iterator it; |
1754 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1755 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1755 | if ( (*it).id() == address.id() ) { | 1756 | if ( (*it).id() == address.id() ) { |
1756 | mData->addresses.remove( it ); | 1757 | mData->addresses.remove( it ); |
1757 | return; | 1758 | return; |
1758 | } | 1759 | } |
1759 | } | 1760 | } |
1760 | } | 1761 | } |
1761 | 1762 | ||
1762 | Address Addressee::address( int type ) const | 1763 | Address Addressee::address( int type ) const |
1763 | { | 1764 | { |
1764 | Address address( type ); | 1765 | Address address( type ); |
1765 | Address::List::ConstIterator it; | 1766 | Address::List::ConstIterator it; |
1766 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1767 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1767 | if ( matchBinaryPatternA( (*it).type(), type ) ) { | 1768 | if ( matchBinaryPatternA( (*it).type(), type ) ) { |
1768 | if ( (*it).type() & Address::Pref ) | 1769 | if ( (*it).type() & Address::Pref ) |
1769 | return (*it); | 1770 | return (*it); |
1770 | else if ( address.isEmpty() ) | 1771 | else if ( address.isEmpty() ) |
1771 | address = (*it); | 1772 | address = (*it); |
1772 | } | 1773 | } |
1773 | } | 1774 | } |
1774 | 1775 | ||
1775 | return address; | 1776 | return address; |
1776 | } | 1777 | } |
1777 | 1778 | ||
1778 | Address::List Addressee::addresses() const | 1779 | Address::List Addressee::addresses() const |
1779 | { | 1780 | { |
1780 | return mData->addresses; | 1781 | return mData->addresses; |
1781 | } | 1782 | } |
1782 | 1783 | ||
1783 | Address::List Addressee::addresses( int type ) const | 1784 | Address::List Addressee::addresses( int type ) const |
1784 | { | 1785 | { |
1785 | Address::List list; | 1786 | Address::List list; |
1786 | 1787 | ||
1787 | Address::List::ConstIterator it; | 1788 | Address::List::ConstIterator it; |
1788 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1789 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1789 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1790 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1790 | list.append( *it ); | 1791 | list.append( *it ); |
1791 | } | 1792 | } |
1792 | } | 1793 | } |
1793 | 1794 | ||
1794 | return list; | 1795 | return list; |
1795 | } | 1796 | } |
1796 | 1797 | ||
1797 | Address Addressee::findAddress( const QString &id ) const | 1798 | Address Addressee::findAddress( const QString &id ) const |
1798 | { | 1799 | { |
1799 | Address::List::ConstIterator it; | 1800 | Address::List::ConstIterator it; |
1800 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1801 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1801 | if ( (*it).id() == id ) { | 1802 | if ( (*it).id() == id ) { |
1802 | return *it; | 1803 | return *it; |
1803 | } | 1804 | } |
1804 | } | 1805 | } |
1805 | return Address(); | 1806 | return Address(); |
1806 | } | 1807 | } |
1807 | 1808 | ||
1808 | void Addressee::insertCategory( const QString &c ) | 1809 | void Addressee::insertCategory( const QString &c ) |
1809 | { | 1810 | { |
1810 | detach(); | 1811 | detach(); |
1811 | mData->empty = false; | 1812 | mData->empty = false; |
1812 | 1813 | ||
1813 | if ( mData->categories.contains( c ) ) return; | 1814 | if ( mData->categories.contains( c ) ) return; |
1814 | 1815 | ||
1815 | mData->categories.append( c ); | 1816 | mData->categories.append( c ); |
1816 | } | 1817 | } |
1817 | 1818 | ||
1818 | void Addressee::removeCategory( const QString &c ) | 1819 | void Addressee::removeCategory( const QString &c ) |
1819 | { | 1820 | { |
1820 | detach(); | 1821 | detach(); |
1821 | 1822 | ||
1822 | QStringList::Iterator it = mData->categories.find( c ); | 1823 | QStringList::Iterator it = mData->categories.find( c ); |
1823 | if ( it == mData->categories.end() ) return; | 1824 | if ( it == mData->categories.end() ) return; |
1824 | 1825 | ||
1825 | mData->categories.remove( it ); | 1826 | mData->categories.remove( it ); |
1826 | } | 1827 | } |
1827 | 1828 | ||
1828 | bool Addressee::hasCategory( const QString &c ) const | 1829 | bool Addressee::hasCategory( const QString &c ) const |
1829 | { | 1830 | { |
1830 | return ( mData->categories.contains( c ) ); | 1831 | return ( mData->categories.contains( c ) ); |
1831 | } | 1832 | } |
1832 | 1833 | ||
1833 | void Addressee::setCategories( const QStringList &c ) | 1834 | void Addressee::setCategories( const QStringList &c ) |
1834 | { | 1835 | { |
1835 | detach(); | 1836 | detach(); |
1836 | mData->empty = false; | 1837 | mData->empty = false; |
1837 | 1838 | ||
1838 | mData->categories = c; | 1839 | mData->categories = c; |
1839 | } | 1840 | } |
1840 | 1841 | ||
1841 | QStringList Addressee::categories() const | 1842 | QStringList Addressee::categories() const |
1842 | { | 1843 | { |
1843 | return mData->categories; | 1844 | return mData->categories; |
1844 | } | 1845 | } |
1845 | 1846 | ||
1846 | void Addressee::insertCustom( const QString &app, const QString &name, | 1847 | void Addressee::insertCustom( const QString &app, const QString &name, |
1847 | const QString &value ) | 1848 | const QString &value ) |
1848 | { | 1849 | { |
diff --git a/kabc/kabc.pro b/kabc/kabc.pro index d690acc..17ebff8 100644 --- a/kabc/kabc.pro +++ b/kabc/kabc.pro | |||
@@ -1,220 +1,218 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt warn_on | 2 | CONFIG += qt warn_on |
3 | #release debug | 3 | #release debug |
4 | DESTDIR=../bin | 4 | DESTDIR=../bin |
5 | 5 | ||
6 | TARGET = microkabc | 6 | TARGET = microkabc |
7 | 7 | ||
8 | include( ../variables.pri ) | 8 | include( ../variables.pri ) |
9 | 9 | ||
10 | INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim ../qtcompat ../microkde/kdeui .. | 10 | INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim ../qtcompat ../microkde/kdeui .. |
11 | 11 | ||
12 | #LIBS += -lmicrokde -lldap | 12 | #LIBS += -lmicrokde -lldap |
13 | LIBS += -L$(QPEDIR)/lib | 13 | LIBS += -L$(QPEDIR)/lib |
14 | DEFINES += KAB_EMBEDDED DESKTOP_VERSION | 14 | DEFINES += KAB_EMBEDDED DESKTOP_VERSION |
15 | unix : { | 15 | unix : { |
16 | 16 | ||
17 | OBJECTS_DIR = obj/unix | 17 | OBJECTS_DIR = obj/unix |
18 | MOC_DIR = moc/unix | 18 | MOC_DIR = moc/unix |
19 | } | 19 | } |
20 | win32: { | 20 | win32: { |
21 | DEFINES += _WIN32_ | 21 | DEFINES += _WIN32_ |
22 | OBJECTS_DIR = obj/win | 22 | OBJECTS_DIR = obj/win |
23 | MOC_DIR = moc/win | 23 | MOC_DIR = moc/win |
24 | } | 24 | } |
25 | INTERFACES = \ | 25 | INTERFACES = \ |
26 | 26 | ||
27 | 27 | ||
28 | HEADERS = \ | 28 | HEADERS = \ |
29 | resource.h \ | 29 | resource.h \ |
30 | stdaddressbook.h \ | 30 | stdaddressbook.h \ |
31 | agent.h \ | 31 | agent.h \ |
32 | geo.h \ | 32 | geo.h \ |
33 | key.h \ | 33 | key.h \ |
34 | field.h \ | 34 | field.h \ |
35 | plugin.h \ | 35 | plugin.h \ |
36 | address.h \ | 36 | address.h \ |
37 | addresseelist.h \ | 37 | addresseelist.h \ |
38 | addresseeview.h \ | 38 | addresseeview.h \ |
39 | formatfactory.h \ | 39 | formatfactory.h \ |
40 | formatplugin.h \ | 40 | formatplugin.h \ |
41 | phonenumber.h \ | 41 | phonenumber.h \ |
42 | distributionlist.h \ | 42 | distributionlist.h \ |
43 | distributionlistdialog.h \ | 43 | distributionlistdialog.h \ |
44 | distributionlisteditor.h \ | 44 | distributionlisteditor.h \ |
45 | vcardformatplugin.h \ | 45 | vcardformatplugin.h \ |
46 | formats/vcardformatplugin2.h \ | 46 | formats/vcardformatplugin2.h \ |
47 | picture.h \ | 47 | picture.h \ |
48 | secrecy.h \ | 48 | secrecy.h \ |
49 | sound.h \ | 49 | sound.h \ |
50 | addressbook.h \ | 50 | addressbook.h \ |
51 | syncprefwidget.h \ | ||
52 | timezone.h \ | 51 | timezone.h \ |
53 | tmpaddressbook.h \ | 52 | tmpaddressbook.h \ |
54 | addressee.h \ | 53 | addressee.h \ |
55 | addresseedialog.h \ | 54 | addresseedialog.h \ |
56 | vcardconverter.h \ | 55 | vcardconverter.h \ |
57 | vcard21parser.h \ | 56 | vcard21parser.h \ |
58 | vcardformatimpl.h \ | 57 | vcardformatimpl.h \ |
59 | plugins/file/resourcefile.h \ | 58 | plugins/file/resourcefile.h \ |
60 | plugins/file/resourcefileconfig.h \ | 59 | plugins/file/resourcefileconfig.h \ |
61 | plugins/dir/resourcedir.h \ | 60 | plugins/dir/resourcedir.h \ |
62 | plugins/dir/resourcedirconfig.h \ | 61 | plugins/dir/resourcedirconfig.h \ |
63 | vcardparser/vcardline.h \ | 62 | vcardparser/vcardline.h \ |
64 | vcardparser/vcard.h \ | 63 | vcardparser/vcard.h \ |
65 | vcardparser/vcardtool.h \ | 64 | vcardparser/vcardtool.h \ |
66 | vcardparser/vcardparser.h \ | 65 | vcardparser/vcardparser.h \ |
67 | vcard/include/VCardAdrParam.h \ | 66 | vcard/include/VCardAdrParam.h \ |
68 | vcard/include/VCardAdrValue.h \ | 67 | vcard/include/VCardAdrValue.h \ |
69 | vcard/include/VCardAgentParam.h \ | 68 | vcard/include/VCardAgentParam.h \ |
70 | vcard/include/VCardContentLine.h \ | 69 | vcard/include/VCardContentLine.h \ |
71 | vcard/include/VCardDateParam.h \ | 70 | vcard/include/VCardDateParam.h \ |
72 | vcard/include/VCardDateValue.h \ | 71 | vcard/include/VCardDateValue.h \ |
73 | vcard/include/VCardEmailParam.h \ | 72 | vcard/include/VCardEmailParam.h \ |
74 | vcard/include/VCardGeoValue.h \ | 73 | vcard/include/VCardGeoValue.h \ |
75 | vcard/include/VCardGroup.h \ | 74 | vcard/include/VCardGroup.h \ |
76 | vcard/include/VCardImageParam.h \ | 75 | vcard/include/VCardImageParam.h \ |
77 | vcard/include/VCardImageValue.h \ | 76 | vcard/include/VCardImageValue.h \ |
78 | vcard/include/VCardLangValue.h \ | 77 | vcard/include/VCardLangValue.h \ |
79 | vcard/include/VCardNValue.h \ | 78 | vcard/include/VCardNValue.h \ |
80 | vcard/include/VCardParam.h \ | 79 | vcard/include/VCardParam.h \ |
81 | vcard/include/VCardPhoneNumberValue.h \ | 80 | vcard/include/VCardPhoneNumberValue.h \ |
82 | vcard/include/VCardSourceParam.h \ | 81 | vcard/include/VCardSourceParam.h \ |
83 | vcard/include/VCardTelParam.h \ | 82 | vcard/include/VCardTelParam.h \ |
84 | vcard/include/VCardTextParam.h \ | 83 | vcard/include/VCardTextParam.h \ |
85 | vcard/include/VCardTextValue.h \ | 84 | vcard/include/VCardTextValue.h \ |
86 | vcard/include/VCardTextBinParam.h \ | 85 | vcard/include/VCardTextBinParam.h \ |
87 | vcard/include/VCardURIValue.h \ | 86 | vcard/include/VCardURIValue.h \ |
88 | vcard/include/VCardVCard.h \ | 87 | vcard/include/VCardVCard.h \ |
89 | vcard/include/VCardEntity.h \ | 88 | vcard/include/VCardEntity.h \ |
90 | vcard/include/VCardValue.h \ | 89 | vcard/include/VCardValue.h \ |
91 | vcard/include/VCardSoundValue.h \ | 90 | vcard/include/VCardSoundValue.h \ |
92 | vcard/include/VCardAgentValue.h \ | 91 | vcard/include/VCardAgentValue.h \ |
93 | vcard/include/VCardTelValue.h \ | 92 | vcard/include/VCardTelValue.h \ |
94 | vcard/include/VCardTextBinValue.h \ | 93 | vcard/include/VCardTextBinValue.h \ |
95 | vcard/include/VCardOrgValue.h \ | 94 | vcard/include/VCardOrgValue.h \ |
96 | vcard/include/VCardUTCValue.h \ | 95 | vcard/include/VCardUTCValue.h \ |
97 | vcard/include/VCardClassValue.h \ | 96 | vcard/include/VCardClassValue.h \ |
98 | vcard/include/VCardFloatValue.h \ | 97 | vcard/include/VCardFloatValue.h \ |
99 | vcard/include/VCardTextListValue.h \ | 98 | vcard/include/VCardTextListValue.h \ |
100 | vcard/include/generated/AdrParam-generated.h \ | 99 | vcard/include/generated/AdrParam-generated.h \ |
101 | vcard/include/generated/AdrValue-generated.h \ | 100 | vcard/include/generated/AdrValue-generated.h \ |
102 | vcard/include/generated/AgentParam-generated.h \ | 101 | vcard/include/generated/AgentParam-generated.h \ |
103 | vcard/include/generated/ContentLine-generated.h \ | 102 | vcard/include/generated/ContentLine-generated.h \ |
104 | vcard/include/generated/DateParam-generated.h \ | 103 | vcard/include/generated/DateParam-generated.h \ |
105 | vcard/include/generated/DateValue-generated.h \ | 104 | vcard/include/generated/DateValue-generated.h \ |
106 | vcard/include/generated/EmailParam-generated.h \ | 105 | vcard/include/generated/EmailParam-generated.h \ |
107 | vcard/include/generated/GeoValue-generated.h \ | 106 | vcard/include/generated/GeoValue-generated.h \ |
108 | vcard/include/generated/Group-generated.h \ | 107 | vcard/include/generated/Group-generated.h \ |
109 | vcard/include/generated/ImageParam-generated.h \ | 108 | vcard/include/generated/ImageParam-generated.h \ |
110 | vcard/include/generated/ImageValue-generated.h \ | 109 | vcard/include/generated/ImageValue-generated.h \ |
111 | vcard/include/generated/LangValue-generated.h \ | 110 | vcard/include/generated/LangValue-generated.h \ |
112 | vcard/include/generated/NValue-generated.h \ | 111 | vcard/include/generated/NValue-generated.h \ |
113 | vcard/include/generated/Param-generated.h \ | 112 | vcard/include/generated/Param-generated.h \ |
114 | vcard/include/generated/PhoneNumberValue-generated.h \ | 113 | vcard/include/generated/PhoneNumberValue-generated.h \ |
115 | vcard/include/generated/SourceParam-generated.h \ | 114 | vcard/include/generated/SourceParam-generated.h \ |
116 | vcard/include/generated/TelParam-generated.h \ | 115 | vcard/include/generated/TelParam-generated.h \ |
117 | vcard/include/generated/TextParam-generated.h \ | 116 | vcard/include/generated/TextParam-generated.h \ |
118 | vcard/include/generated/TextNSParam-generated.h \ | 117 | vcard/include/generated/TextNSParam-generated.h \ |
119 | vcard/include/generated/TextValue-generated.h \ | 118 | vcard/include/generated/TextValue-generated.h \ |
120 | vcard/include/generated/TextBinParam-generated.h \ | 119 | vcard/include/generated/TextBinParam-generated.h \ |
121 | vcard/include/generated/URIValue-generated.h \ | 120 | vcard/include/generated/URIValue-generated.h \ |
122 | vcard/include/generated/VCard-generated.h \ | 121 | vcard/include/generated/VCard-generated.h \ |
123 | vcard/include/generated/VCardEntity-generated.h \ | 122 | vcard/include/generated/VCardEntity-generated.h \ |
124 | vcard/include/generated/Value-generated.h \ | 123 | vcard/include/generated/Value-generated.h \ |
125 | vcard/include/generated/SoundValue-generated.h \ | 124 | vcard/include/generated/SoundValue-generated.h \ |
126 | vcard/include/generated/AgentValue-generated.h \ | 125 | vcard/include/generated/AgentValue-generated.h \ |
127 | vcard/include/generated/TelValue-generated.h \ | 126 | vcard/include/generated/TelValue-generated.h \ |
128 | vcard/include/generated/TextBinValue-generated.h \ | 127 | vcard/include/generated/TextBinValue-generated.h \ |
129 | vcard/include/generated/OrgValue-generated.h \ | 128 | vcard/include/generated/OrgValue-generated.h \ |
130 | vcard/include/generated/UTCValue-generated.h \ | 129 | vcard/include/generated/UTCValue-generated.h \ |
131 | vcard/include/generated/ClassValue-generated.h \ | 130 | vcard/include/generated/ClassValue-generated.h \ |
132 | vcard/include/generated/FloatValue-generated.h \ | 131 | vcard/include/generated/FloatValue-generated.h \ |
133 | vcard/include/generated/TextListValue-generated.h | 132 | vcard/include/generated/TextListValue-generated.h |
134 | 133 | ||
135 | 134 | ||
136 | # plugins/ldap/resourceldap.h \ | 135 | # plugins/ldap/resourceldap.h \ |
137 | # plugins/ldap/resourceldapconfig.h \ | 136 | # plugins/ldap/resourceldapconfig.h \ |
138 | #formats/binary/binaryformat.h \ | 137 | #formats/binary/binaryformat.h \ |
139 | 138 | ||
140 | #vcard/include/VCardTextNSParam.h \ | 139 | #vcard/include/VCardTextNSParam.h \ |
141 | 140 | ||
142 | SOURCES = \ | 141 | SOURCES = \ |
143 | distributionlist.cpp \ | 142 | distributionlist.cpp \ |
144 | distributionlistdialog.cpp \ | 143 | distributionlistdialog.cpp \ |
145 | distributionlisteditor.cpp \ | 144 | distributionlisteditor.cpp \ |
146 | vcardformatplugin.cpp \ | 145 | vcardformatplugin.cpp \ |
147 | formats/vcardformatplugin2.cpp \ | 146 | formats/vcardformatplugin2.cpp \ |
148 | formatfactory.cpp \ | 147 | formatfactory.cpp \ |
149 | resource.cpp \ | 148 | resource.cpp \ |
150 | stdaddressbook.cpp \ | 149 | stdaddressbook.cpp \ |
151 | plugin.cpp \ | 150 | plugin.cpp \ |
152 | agent.cpp \ | 151 | agent.cpp \ |
153 | geo.cpp \ | 152 | geo.cpp \ |
154 | key.cpp \ | 153 | key.cpp \ |
155 | field.cpp \ | 154 | field.cpp \ |
156 | addresseeview.cpp \ | 155 | addresseeview.cpp \ |
157 | address.cpp \ | 156 | address.cpp \ |
158 | phonenumber.cpp \ | 157 | phonenumber.cpp \ |
159 | picture.cpp \ | 158 | picture.cpp \ |
160 | secrecy.cpp \ | 159 | secrecy.cpp \ |
161 | sound.cpp \ | 160 | sound.cpp \ |
162 | addressbook.cpp \ | 161 | addressbook.cpp \ |
163 | syncprefwidget.cpp \ | ||
164 | timezone.cpp \ | 162 | timezone.cpp \ |
165 | tmpaddressbook.cpp \ | 163 | tmpaddressbook.cpp \ |
166 | addressee.cpp \ | 164 | addressee.cpp \ |
167 | addresseelist.cpp \ | 165 | addresseelist.cpp \ |
168 | addresseedialog.cpp \ | 166 | addresseedialog.cpp \ |
169 | vcardconverter.cpp \ | 167 | vcardconverter.cpp \ |
170 | vcard21parser.cpp \ | 168 | vcard21parser.cpp \ |
171 | vcardformatimpl.cpp \ | 169 | vcardformatimpl.cpp \ |
172 | plugins/file/resourcefile.cpp \ | 170 | plugins/file/resourcefile.cpp \ |
173 | plugins/file/resourcefileconfig.cpp \ | 171 | plugins/file/resourcefileconfig.cpp \ |
174 | plugins/dir/resourcedir.cpp \ | 172 | plugins/dir/resourcedir.cpp \ |
175 | plugins/dir/resourcedirconfig.cpp \ | 173 | plugins/dir/resourcedirconfig.cpp \ |
176 | vcardparser/vcardline.cpp \ | 174 | vcardparser/vcardline.cpp \ |
177 | vcardparser/vcard.cpp \ | 175 | vcardparser/vcard.cpp \ |
178 | vcardparser/vcardtool.cpp \ | 176 | vcardparser/vcardtool.cpp \ |
179 | vcardparser/vcardparser.cpp \ | 177 | vcardparser/vcardparser.cpp \ |
180 | vcard/AdrParam.cpp \ | 178 | vcard/AdrParam.cpp \ |
181 | vcard/AdrValue.cpp \ | 179 | vcard/AdrValue.cpp \ |
182 | vcard/AgentParam.cpp \ | 180 | vcard/AgentParam.cpp \ |
183 | vcard/ContentLine.cpp \ | 181 | vcard/ContentLine.cpp \ |
184 | vcard/DateParam.cpp \ | 182 | vcard/DateParam.cpp \ |
185 | vcard/DateValue.cpp \ | 183 | vcard/DateValue.cpp \ |
186 | vcard/EmailParam.cpp \ | 184 | vcard/EmailParam.cpp \ |
187 | vcard/Entity.cpp \ | 185 | vcard/Entity.cpp \ |
188 | vcard/Enum.cpp \ | 186 | vcard/Enum.cpp \ |
189 | vcard/GeoValue.cpp \ | 187 | vcard/GeoValue.cpp \ |
190 | vcard/ImageParam.cpp \ | 188 | vcard/ImageParam.cpp \ |
191 | vcard/ImageValue.cpp \ | 189 | vcard/ImageValue.cpp \ |
192 | vcard/LangValue.cpp \ | 190 | vcard/LangValue.cpp \ |
193 | vcard/NValue.cpp \ | 191 | vcard/NValue.cpp \ |
194 | vcard/Param.cpp \ | 192 | vcard/Param.cpp \ |
195 | vcard/PhoneNumberValue.cpp \ | 193 | vcard/PhoneNumberValue.cpp \ |
196 | vcard/RToken.cpp \ | 194 | vcard/RToken.cpp \ |
197 | vcard/SourceParam.cpp \ | 195 | vcard/SourceParam.cpp \ |
198 | vcard/TelParam.cpp \ | 196 | vcard/TelParam.cpp \ |
199 | vcard/TextParam.cpp \ | 197 | vcard/TextParam.cpp \ |
200 | vcard/TextValue.cpp \ | 198 | vcard/TextValue.cpp \ |
201 | vcard/TextBinParam.cpp \ | 199 | vcard/TextBinParam.cpp \ |
202 | vcard/URIValue.cpp \ | 200 | vcard/URIValue.cpp \ |
203 | vcard/VCardv.cpp \ | 201 | vcard/VCardv.cpp \ |
204 | vcard/VCardEntity.cpp \ | 202 | vcard/VCardEntity.cpp \ |
205 | vcard/Value.cpp \ | 203 | vcard/Value.cpp \ |
206 | vcard/SoundValue.cpp \ | 204 | vcard/SoundValue.cpp \ |
207 | vcard/AgentValue.cpp \ | 205 | vcard/AgentValue.cpp \ |
208 | vcard/TelValue.cpp \ | 206 | vcard/TelValue.cpp \ |
209 | vcard/TextBinValue.cpp \ | 207 | vcard/TextBinValue.cpp \ |
210 | vcard/OrgValue.cpp \ | 208 | vcard/OrgValue.cpp \ |
211 | vcard/UTCValue.cpp \ | 209 | vcard/UTCValue.cpp \ |
212 | vcard/ClassValue.cpp \ | 210 | vcard/ClassValue.cpp \ |
213 | vcard/FloatValue.cpp \ | 211 | vcard/FloatValue.cpp \ |
214 | vcard/TextListValue.cpp | 212 | vcard/TextListValue.cpp |
215 | 213 | ||
216 | 214 | ||
217 | # plugins/ldap/resourceldap.cpp \ | 215 | # plugins/ldap/resourceldap.cpp \ |
218 | # plugins/ldap/resourceldapconfig.cpp \ | 216 | # plugins/ldap/resourceldapconfig.cpp \ |
219 | 217 | ||
220 | #formats/binary/binaryformat.cpp \ | 218 | #formats/binary/binaryformat.cpp \ |
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 3e0a27d..e4a11f5 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,2714 +1,2716 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Requires the Qt and KDE widget libraries, available at no cost at | 4 | Requires the Qt and KDE widget libraries, available at no cost at |
5 | http://www.troll.no and http://www.kde.org respectively | 5 | http://www.troll.no and http://www.kde.org respectively |
6 | 6 | ||
7 | Copyright (c) 1997, 1998, 1999 | 7 | Copyright (c) 1997, 1998, 1999 |
8 | Preston Brown (preston.brown@yale.edu) | 8 | Preston Brown (preston.brown@yale.edu) |
9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) | 9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) |
10 | Ian Dawes (iadawes@globalserve.net) | 10 | Ian Dawes (iadawes@globalserve.net) |
11 | Laszlo Boloni (boloni@cs.purdue.edu) | 11 | Laszlo Boloni (boloni@cs.purdue.edu) |
12 | 12 | ||
13 | Copyright (c) 2000, 2001, 2002 | 13 | Copyright (c) 2000, 2001, 2002 |
14 | Cornelius Schumacher <schumacher@kde.org> | 14 | Cornelius Schumacher <schumacher@kde.org> |
15 | 15 | ||
16 | This program is free software; you can redistribute it and/or modify | 16 | This program is free software; you can redistribute it and/or modify |
17 | it under the terms of the GNU General Public License as published by | 17 | it under the terms of the GNU General Public License as published by |
18 | the Free Software Foundation; either version 2 of the License, or | 18 | the Free Software Foundation; either version 2 of the License, or |
19 | (at your option) any later version. | 19 | (at your option) any later version. |
20 | 20 | ||
21 | This program is distributed in the hope that it will be useful, | 21 | This program is distributed in the hope that it will be useful, |
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
24 | GNU General Public License for more details. | 24 | GNU General Public License for more details. |
25 | 25 | ||
26 | You should have received a copy of the GNU General Public License | 26 | You should have received a copy of the GNU General Public License |
27 | along with this program; if not, write to the Free Software | 27 | along with this program; if not, write to the Free Software |
28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qradiobutton.h> | 34 | #include <qradiobutton.h> |
35 | #include <qbuttongroup.h> | 35 | #include <qbuttongroup.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qclipboard.h> | 37 | #include <qclipboard.h> |
38 | #include <qcursor.h> | 38 | #include <qcursor.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qprogressbar.h> | 40 | #include <qprogressbar.h> |
41 | #include <qmultilineedit.h> | 41 | #include <qmultilineedit.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qwidgetstack.h> | 43 | #include <qwidgetstack.h> |
44 | #include <qptrlist.h> | 44 | #include <qptrlist.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qgroupbox.h> | 46 | #include <qgroupbox.h> |
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #ifndef KORG_NOSPLITTER | 49 | #ifndef KORG_NOSPLITTER |
50 | #include <qsplitter.h> | 50 | #include <qsplitter.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #include <kglobal.h> | 53 | #include <kglobal.h> |
54 | #include <kdebug.h> | 54 | #include <kdebug.h> |
55 | #include <kstandarddirs.h> | 55 | #include <kstandarddirs.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | #include <kmessagebox.h> | 57 | #include <kmessagebox.h> |
58 | #include <knotifyclient.h> | 58 | #include <knotifyclient.h> |
59 | #include <kconfig.h> | 59 | #include <kconfig.h> |
60 | 60 | ||
61 | #include <libkdepim/ksyncprefsdialog.h> | 61 | #include <libkdepim/ksyncprefsdialog.h> |
62 | #include <krun.h> | 62 | #include <krun.h> |
63 | #include <kdirwatch.h> | 63 | #include <kdirwatch.h> |
64 | #include <libkdepim/kdatepicker.h> | 64 | #include <libkdepim/kdatepicker.h> |
65 | #include <libkdepim/ksyncprofile.h> | 65 | #include <libkdepim/ksyncprofile.h> |
66 | #include <libkdepim/kpimglobalprefs.h> | 66 | #include <libkdepim/kpimglobalprefs.h> |
67 | 67 | ||
68 | #include <libkcal/vcaldrag.h> | 68 | #include <libkcal/vcaldrag.h> |
69 | #include <libkcal/icaldrag.h> | 69 | #include <libkcal/icaldrag.h> |
70 | #include <libkcal/icalformat.h> | 70 | #include <libkcal/icalformat.h> |
71 | #include <libkcal/vcalformat.h> | 71 | #include <libkcal/vcalformat.h> |
72 | #include <libkcal/scheduler.h> | 72 | #include <libkcal/scheduler.h> |
73 | #include <libkcal/calendarlocal.h> | 73 | #include <libkcal/calendarlocal.h> |
74 | #include <libkcal/journal.h> | 74 | #include <libkcal/journal.h> |
75 | #include <libkcal/calfilter.h> | 75 | #include <libkcal/calfilter.h> |
76 | #include <libkcal/attendee.h> | 76 | #include <libkcal/attendee.h> |
77 | #include <libkcal/dndfactory.h> | 77 | #include <libkcal/dndfactory.h> |
78 | #include <libkcal/freebusy.h> | 78 | #include <libkcal/freebusy.h> |
79 | #include <libkcal/filestorage.h> | 79 | #include <libkcal/filestorage.h> |
80 | #include <libkcal/calendarresources.h> | 80 | #include <libkcal/calendarresources.h> |
81 | #include <libkcal/qtopiaformat.h> | 81 | #include <libkcal/qtopiaformat.h> |
82 | #include "../kalarmd/alarmdialog.h" | 82 | #include "../kalarmd/alarmdialog.h" |
83 | 83 | ||
84 | #ifndef DESKTOP_VERSION | 84 | #ifndef DESKTOP_VERSION |
85 | #include <libkcal/sharpformat.h> | 85 | #include <libkcal/sharpformat.h> |
86 | #include <externalapphandler.h> | 86 | #include <externalapphandler.h> |
87 | #endif | 87 | #endif |
88 | #include <libkcal/phoneformat.h> | 88 | #include <libkcal/phoneformat.h> |
89 | #ifndef KORG_NOMAIL | 89 | #ifndef KORG_NOMAIL |
90 | #include "komailclient.h" | 90 | #include "komailclient.h" |
91 | #endif | 91 | #endif |
92 | #ifndef KORG_NOPRINTER | 92 | #ifndef KORG_NOPRINTER |
93 | #include "calprinter.h" | 93 | #include "calprinter.h" |
94 | #endif | 94 | #endif |
95 | #ifndef KORG_NOPLUGINS | 95 | #ifndef KORG_NOPLUGINS |
96 | #include "kocore.h" | 96 | #include "kocore.h" |
97 | #endif | 97 | #endif |
98 | #include "koeventeditor.h" | 98 | #include "koeventeditor.h" |
99 | #include "kotodoeditor.h" | 99 | #include "kotodoeditor.h" |
100 | #include "koprefs.h" | 100 | #include "koprefs.h" |
101 | #include "koeventviewerdialog.h" | 101 | #include "koeventviewerdialog.h" |
102 | #include "publishdialog.h" | 102 | #include "publishdialog.h" |
103 | #include "kofilterview.h" | 103 | #include "kofilterview.h" |
104 | #include "koglobals.h" | 104 | #include "koglobals.h" |
105 | #include "koviewmanager.h" | 105 | #include "koviewmanager.h" |
106 | #include "koagendaview.h" | 106 | #include "koagendaview.h" |
107 | #include "kodialogmanager.h" | 107 | #include "kodialogmanager.h" |
108 | #include "outgoingdialog.h" | 108 | #include "outgoingdialog.h" |
109 | #include "incomingdialog.h" | 109 | #include "incomingdialog.h" |
110 | #include "statusdialog.h" | 110 | #include "statusdialog.h" |
111 | #include "kdatenavigator.h" | 111 | #include "kdatenavigator.h" |
112 | #include "kotodoview.h" | 112 | #include "kotodoview.h" |
113 | #include "datenavigator.h" | 113 | #include "datenavigator.h" |
114 | #include "resourceview.h" | 114 | #include "resourceview.h" |
115 | #include "navigatorbar.h" | 115 | #include "navigatorbar.h" |
116 | #include "searchdialog.h" | 116 | #include "searchdialog.h" |
117 | #include "mainwindow.h" | 117 | #include "mainwindow.h" |
118 | 118 | ||
119 | #include "calendarview.h" | 119 | #include "calendarview.h" |
120 | #ifndef DESKTOP_VERSION | 120 | #ifndef DESKTOP_VERSION |
121 | #include <qtopia/alarmserver.h> | 121 | #include <qtopia/alarmserver.h> |
122 | #endif | 122 | #endif |
123 | #ifndef _WIN32_ | 123 | #ifndef _WIN32_ |
124 | #include <stdlib.h> | 124 | #include <stdlib.h> |
125 | #include <stdio.h> | 125 | #include <stdio.h> |
126 | #include <unistd.h> | 126 | #include <unistd.h> |
127 | #else | 127 | #else |
128 | #include <qprocess.h> | 128 | #include <qprocess.h> |
129 | #endif | 129 | #endif |
130 | 130 | ||
131 | #ifdef DESKTOP_VERSION | 131 | #ifdef DESKTOP_VERSION |
132 | #include <kabc/stdaddressbook.h> | 132 | #include <kabc/stdaddressbook.h> |
133 | #endif | 133 | #endif |
134 | using namespace KOrg; | 134 | using namespace KOrg; |
135 | using namespace KCal; | 135 | using namespace KCal; |
136 | extern int globalFlagBlockAgenda; | 136 | extern int globalFlagBlockAgenda; |
137 | extern int globalFlagBlockStartup; | 137 | extern int globalFlagBlockStartup; |
138 | 138 | ||
139 | 139 | ||
140 | 140 | ||
141 | class KOBeamPrefs : public QDialog | 141 | class KOBeamPrefs : public QDialog |
142 | { | 142 | { |
143 | public: | 143 | public: |
144 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 144 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
145 | QDialog( parent, name, true ) | 145 | QDialog( parent, name, true ) |
146 | { | 146 | { |
147 | setCaption( i18n("Beam Options") ); | 147 | setCaption( i18n("Beam Options") ); |
148 | QVBoxLayout* lay = new QVBoxLayout( this ); | 148 | QVBoxLayout* lay = new QVBoxLayout( this ); |
149 | lay->setSpacing( 3 ); | 149 | lay->setSpacing( 3 ); |
150 | lay->setMargin( 3 ); | 150 | lay->setMargin( 3 ); |
151 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 151 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
152 | lay->addWidget( format ); | 152 | lay->addWidget( format ); |
153 | format->setExclusive ( true ) ; | 153 | format->setExclusive ( true ) ; |
154 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 154 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
155 | lay->addWidget( time ); time->setExclusive ( true ) ; | 155 | lay->addWidget( time ); time->setExclusive ( true ) ; |
156 | vcal = new QRadioButton(" vCalendar ", format ); | 156 | vcal = new QRadioButton(" vCalendar ", format ); |
157 | ical = new QRadioButton(" iCalendar ", format ); | 157 | ical = new QRadioButton(" iCalendar ", format ); |
158 | vcal->setChecked( true ); | 158 | vcal->setChecked( true ); |
159 | tz = new QRadioButton(i18n(" With timezone "), time ); | 159 | tz = new QRadioButton(i18n(" With timezone "), time ); |
160 | local = new QRadioButton(i18n(" Local time "), time ); | 160 | local = new QRadioButton(i18n(" Local time "), time ); |
161 | tz->setChecked( true ); | 161 | tz->setChecked( true ); |
162 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 162 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
163 | lay->addWidget( ok ); | 163 | lay->addWidget( ok ); |
164 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 164 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
165 | lay->addWidget( cancel ); | 165 | lay->addWidget( cancel ); |
166 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 166 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
167 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 167 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
168 | resize( 200, 200 ); | 168 | resize( 200, 200 ); |
169 | } | 169 | } |
170 | 170 | ||
171 | bool beamVcal() { return vcal->isChecked(); } | 171 | bool beamVcal() { return vcal->isChecked(); } |
172 | bool beamLocal() { return local->isChecked(); } | 172 | bool beamLocal() { return local->isChecked(); } |
173 | private: | 173 | private: |
174 | QRadioButton* vcal, *ical, *local, *tz; | 174 | QRadioButton* vcal, *ical, *local, *tz; |
175 | }; | 175 | }; |
176 | class KOCatPrefs : public QDialog | 176 | class KOCatPrefs : public QDialog |
177 | { | 177 | { |
178 | public: | 178 | public: |
179 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 179 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
180 | QDialog( parent, name, true ) | 180 | QDialog( parent, name, true ) |
181 | { | 181 | { |
182 | setCaption( i18n("Manage new Categories") ); | 182 | setCaption( i18n("Manage new Categories") ); |
183 | QVBoxLayout* lay = new QVBoxLayout( this ); | 183 | QVBoxLayout* lay = new QVBoxLayout( this ); |
184 | lay->setSpacing( 3 ); | 184 | lay->setSpacing( 3 ); |
185 | lay->setMargin( 3 ); | 185 | lay->setMargin( 3 ); |
186 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 186 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
187 | lay->addWidget( lab ); | 187 | lay->addWidget( lab ); |
188 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 188 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
189 | lay->addWidget( format ); | 189 | lay->addWidget( format ); |
190 | format->setExclusive ( true ) ; | 190 | format->setExclusive ( true ) ; |
191 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 191 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
192 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 192 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
193 | addCatBut->setChecked( true ); | 193 | addCatBut->setChecked( true ); |
194 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 194 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
195 | lay->addWidget( ok ); | 195 | lay->addWidget( ok ); |
196 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 196 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
197 | lay->addWidget( cancel ); | 197 | lay->addWidget( cancel ); |
198 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 198 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
199 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 199 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
200 | resize( 200, 200 ); | 200 | resize( 200, 200 ); |
201 | } | 201 | } |
202 | 202 | ||
203 | bool addCat() { return addCatBut->isChecked(); } | 203 | bool addCat() { return addCatBut->isChecked(); } |
204 | private: | 204 | private: |
205 | QRadioButton* addCatBut; | 205 | QRadioButton* addCatBut; |
206 | }; | 206 | }; |
207 | 207 | ||
208 | 208 | ||
209 | 209 | ||
210 | CalendarView::CalendarView( CalendarResources *calendar, | 210 | CalendarView::CalendarView( CalendarResources *calendar, |
211 | QWidget *parent, const char *name ) | 211 | QWidget *parent, const char *name ) |
212 | : CalendarViewBase( parent, name ), | 212 | : CalendarViewBase( parent, name ), |
213 | mCalendar( calendar ), | 213 | mCalendar( calendar ), |
214 | mResourceManager( calendar->resourceManager() ) | 214 | mResourceManager( calendar->resourceManager() ) |
215 | { | 215 | { |
216 | 216 | ||
217 | mEventEditor = 0; | 217 | mEventEditor = 0; |
218 | mTodoEditor = 0; | 218 | mTodoEditor = 0; |
219 | 219 | ||
220 | init(); | 220 | init(); |
221 | } | 221 | } |
222 | 222 | ||
223 | CalendarView::CalendarView( Calendar *calendar, | 223 | CalendarView::CalendarView( Calendar *calendar, |
224 | QWidget *parent, const char *name ) | 224 | QWidget *parent, const char *name ) |
225 | : CalendarViewBase( parent, name ), | 225 | : CalendarViewBase( parent, name ), |
226 | mCalendar( calendar ), | 226 | mCalendar( calendar ), |
227 | mResourceManager( 0 ) | 227 | mResourceManager( 0 ) |
228 | { | 228 | { |
229 | 229 | ||
230 | mEventEditor = 0; | 230 | mEventEditor = 0; |
231 | mTodoEditor = 0; | 231 | mTodoEditor = 0; |
232 | init();} | 232 | init();} |
233 | 233 | ||
234 | void CalendarView::init() | 234 | void CalendarView::init() |
235 | { | 235 | { |
236 | beamDialog = new KOBeamPrefs(); | 236 | beamDialog = new KOBeamPrefs(); |
237 | mDatePickerMode = 0; | 237 | mDatePickerMode = 0; |
238 | mCurrentSyncDevice = ""; | 238 | mCurrentSyncDevice = ""; |
239 | writeLocale(); | 239 | writeLocale(); |
240 | mViewManager = new KOViewManager( this ); | 240 | mViewManager = new KOViewManager( this ); |
241 | mDialogManager = new KODialogManager( this ); | 241 | mDialogManager = new KODialogManager( this ); |
242 | mEventViewerDialog = 0; | 242 | mEventViewerDialog = 0; |
243 | mModified = false; | 243 | mModified = false; |
244 | mReadOnly = false; | 244 | mReadOnly = false; |
245 | mSelectedIncidence = 0; | 245 | mSelectedIncidence = 0; |
246 | mCalPrinter = 0; | 246 | mCalPrinter = 0; |
247 | mFilters.setAutoDelete(true); | 247 | mFilters.setAutoDelete(true); |
248 | 248 | ||
249 | mCalendar->registerObserver( this ); | 249 | mCalendar->registerObserver( this ); |
250 | // TODO: Make sure that view is updated, when calendar is changed. | 250 | // TODO: Make sure that view is updated, when calendar is changed. |
251 | 251 | ||
252 | mStorage = new FileStorage( mCalendar ); | 252 | mStorage = new FileStorage( mCalendar ); |
253 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 253 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
254 | 254 | ||
255 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 255 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
256 | #ifndef KORG_NOSPLITTER | 256 | #ifndef KORG_NOSPLITTER |
257 | // create the main layout frames. | 257 | // create the main layout frames. |
258 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 258 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
259 | topLayout->addWidget(mPanner); | 259 | topLayout->addWidget(mPanner); |
260 | 260 | ||
261 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 261 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
262 | "CalendarView::LeftFrame"); | 262 | "CalendarView::LeftFrame"); |
263 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 263 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
264 | 264 | ||
265 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, | 265 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, |
266 | "CalendarView::DateNavigator", QDate::currentDate() ); | 266 | "CalendarView::DateNavigator", QDate::currentDate() ); |
267 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 267 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
268 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 268 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
269 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 269 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
270 | 270 | ||
271 | #ifdef KORG_NORESOURCEVIEW | 271 | #ifdef KORG_NORESOURCEVIEW |
272 | mResourceView = 0; | 272 | mResourceView = 0; |
273 | #else | 273 | #else |
274 | if ( mResourceManager ) { | 274 | if ( mResourceManager ) { |
275 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 275 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
276 | mResourceView->updateView(); | 276 | mResourceView->updateView(); |
277 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 277 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
278 | SLOT( updateView() ) ); | 278 | SLOT( updateView() ) ); |
279 | } else { | 279 | } else { |
280 | mResourceView = 0; | 280 | mResourceView = 0; |
281 | } | 281 | } |
282 | #endif | 282 | #endif |
283 | QWidget *rightBox = new QWidget( mPanner ); | 283 | QWidget *rightBox = new QWidget( mPanner ); |
284 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 284 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
285 | 285 | ||
286 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 286 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
287 | rightLayout->addWidget( mNavigatorBar ); | 287 | rightLayout->addWidget( mNavigatorBar ); |
288 | 288 | ||
289 | mRightFrame = new QWidgetStack( rightBox ); | 289 | mRightFrame = new QWidgetStack( rightBox ); |
290 | rightLayout->addWidget( mRightFrame, 1 ); | 290 | rightLayout->addWidget( mRightFrame, 1 ); |
291 | 291 | ||
292 | mLeftFrame = mLeftSplitter; | 292 | mLeftFrame = mLeftSplitter; |
293 | #else | 293 | #else |
294 | QWidget *mainBox = new QWidget( this ); | 294 | QWidget *mainBox = new QWidget( this ); |
295 | QWidget *leftFrame = new QWidget( mainBox ); | 295 | QWidget *leftFrame = new QWidget( mainBox ); |
296 | 296 | ||
297 | QBoxLayout * mainBoxLayout; | 297 | QBoxLayout * mainBoxLayout; |
298 | QBoxLayout * leftFrameLayout; | 298 | QBoxLayout * leftFrameLayout; |
299 | if ( KOPrefs::instance()->mVerticalScreen ) { | 299 | if ( KOPrefs::instance()->mVerticalScreen ) { |
300 | mainBoxLayout = new QVBoxLayout(mainBox); | 300 | mainBoxLayout = new QVBoxLayout(mainBox); |
301 | leftFrameLayout = new QHBoxLayout(leftFrame ); | 301 | leftFrameLayout = new QHBoxLayout(leftFrame ); |
302 | } else { | 302 | } else { |
303 | mainBoxLayout = new QHBoxLayout(mainBox); | 303 | mainBoxLayout = new QHBoxLayout(mainBox); |
304 | leftFrameLayout = new QVBoxLayout(leftFrame ); | 304 | leftFrameLayout = new QVBoxLayout(leftFrame ); |
305 | } | 305 | } |
306 | topLayout->addWidget( mainBox ); | 306 | topLayout->addWidget( mainBox ); |
307 | mainBoxLayout->addWidget (leftFrame); | 307 | mainBoxLayout->addWidget (leftFrame); |
308 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, | 308 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, |
309 | "CalendarView::DateNavigator", QDate::currentDate()); | 309 | "CalendarView::DateNavigator", QDate::currentDate()); |
310 | // mDateNavigator->blockSignals( true ); | 310 | // mDateNavigator->blockSignals( true ); |
311 | leftFrameLayout->addWidget( mDateNavigator ); | 311 | leftFrameLayout->addWidget( mDateNavigator ); |
312 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); | 312 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); |
313 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); | 313 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); |
314 | 314 | ||
315 | if ( QApplication::desktop()->width() < 480 ) { | 315 | if ( QApplication::desktop()->width() < 480 ) { |
316 | leftFrameLayout->addWidget(mFilterView); | 316 | leftFrameLayout->addWidget(mFilterView); |
317 | leftFrameLayout->addWidget(mTodoList, 2 ); | 317 | leftFrameLayout->addWidget(mTodoList, 2 ); |
318 | 318 | ||
319 | } else { | 319 | } else { |
320 | leftFrameLayout->addWidget(mTodoList,2 ); | 320 | leftFrameLayout->addWidget(mTodoList,2 ); |
321 | leftFrameLayout->addWidget(mFilterView ); | 321 | leftFrameLayout->addWidget(mFilterView ); |
322 | } | 322 | } |
323 | mFilterView->hide(); | 323 | mFilterView->hide(); |
324 | QWidget *rightBox = new QWidget( mainBox ); | 324 | QWidget *rightBox = new QWidget( mainBox ); |
325 | mainBoxLayout->addWidget ( rightBox, 10 ); | 325 | mainBoxLayout->addWidget ( rightBox, 10 ); |
326 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 326 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
327 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 327 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
328 | mRightFrame = new QWidgetStack( rightBox ); | 328 | mRightFrame = new QWidgetStack( rightBox ); |
329 | rightLayout->addWidget( mNavigatorBar ); | 329 | rightLayout->addWidget( mNavigatorBar ); |
330 | rightLayout->addWidget( mRightFrame, 10 ); | 330 | rightLayout->addWidget( mRightFrame, 10 ); |
331 | 331 | ||
332 | mLeftFrame = leftFrame; | 332 | mLeftFrame = leftFrame; |
333 | if ( KOPrefs::instance()->mVerticalScreen ) { | 333 | if ( KOPrefs::instance()->mVerticalScreen ) { |
334 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 334 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
335 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 335 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
336 | } else { | 336 | } else { |
337 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 337 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
338 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 338 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
339 | } | 339 | } |
340 | 340 | ||
341 | //qDebug("Calendarview Size %d %d ", width(), height()); | 341 | //qDebug("Calendarview Size %d %d ", width(), height()); |
342 | #endif | 342 | #endif |
343 | 343 | ||
344 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 344 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
345 | SLOT( showDates( const KCal::DateList & ) ) ); | 345 | SLOT( showDates( const KCal::DateList & ) ) ); |
346 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 346 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
347 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 347 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
348 | 348 | ||
349 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), | 349 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), |
350 | mNavigator, SLOT( selectPreviousYear() ) ); | 350 | mNavigator, SLOT( selectPreviousYear() ) ); |
351 | connect( mNavigatorBar, SIGNAL( goNextYear() ), | 351 | connect( mNavigatorBar, SIGNAL( goNextYear() ), |
352 | mNavigator, SLOT( selectNextYear() ) ); | 352 | mNavigator, SLOT( selectNextYear() ) ); |
353 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), | 353 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), |
354 | mNavigator, SLOT( selectPreviousMonth() ) ); | 354 | mNavigator, SLOT( selectPreviousMonth() ) ); |
355 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), | 355 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), |
356 | mNavigator, SLOT( selectNextMonth() ) ); | 356 | mNavigator, SLOT( selectNextMonth() ) ); |
357 | 357 | ||
358 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 358 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
359 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); | 359 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); |
360 | 360 | ||
361 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 361 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
362 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 362 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
363 | 363 | ||
364 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 364 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
365 | mNavigator, SLOT( selectPreviousYear() ) ); | 365 | mNavigator, SLOT( selectPreviousYear() ) ); |
366 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 366 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
367 | mNavigator, SLOT( selectNextYear() ) ); | 367 | mNavigator, SLOT( selectNextYear() ) ); |
368 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 368 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
369 | mNavigator, SLOT( selectPreviousMonth() ) ); | 369 | mNavigator, SLOT( selectPreviousMonth() ) ); |
370 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 370 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
371 | mNavigator, SLOT( selectNextMonth() ) ); | 371 | mNavigator, SLOT( selectNextMonth() ) ); |
372 | 372 | ||
373 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 373 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
374 | mNavigator, SLOT( selectPrevious() ) ); | 374 | mNavigator, SLOT( selectPrevious() ) ); |
375 | connect( mDateNavigator, SIGNAL( goNext() ), | 375 | connect( mDateNavigator, SIGNAL( goNext() ), |
376 | mNavigator, SLOT( selectNext() ) ); | 376 | mNavigator, SLOT( selectNext() ) ); |
377 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 377 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
378 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 378 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
379 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), | 379 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), |
380 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 380 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
381 | 381 | ||
382 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 382 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
383 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 383 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
384 | 384 | ||
385 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), | 385 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), |
386 | SLOT( eventAdded( Event *) ) ); | 386 | SLOT( eventAdded( Event *) ) ); |
387 | 387 | ||
388 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 388 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
389 | 389 | ||
390 | connect( this, SIGNAL( configChanged() ), | 390 | connect( this, SIGNAL( configChanged() ), |
391 | mDateNavigator, SLOT( updateConfig() ) ); | 391 | mDateNavigator, SLOT( updateConfig() ) ); |
392 | 392 | ||
393 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 393 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
394 | SLOT( newTodo() ) ); | 394 | SLOT( newTodo() ) ); |
395 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 395 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
396 | SLOT( newSubTodo( Todo * ) ) ); | 396 | SLOT( newSubTodo( Todo * ) ) ); |
397 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 397 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
398 | SLOT( editTodo( Todo * ) ) ); | 398 | SLOT( editTodo( Todo * ) ) ); |
399 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 399 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
400 | SLOT( showTodo( Todo *) ) ); | 400 | SLOT( showTodo( Todo *) ) ); |
401 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 401 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
402 | SLOT( deleteTodo( Todo *) ) ); | 402 | SLOT( deleteTodo( Todo *) ) ); |
403 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 403 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
404 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 404 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
405 | SLOT( purgeCompleted() ) ); | 405 | SLOT( purgeCompleted() ) ); |
406 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 406 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
407 | SIGNAL( todoModified( Todo *, int ) ) ); | 407 | SIGNAL( todoModified( Todo *, int ) ) ); |
408 | 408 | ||
409 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 409 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
410 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 410 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
411 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 411 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
412 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 412 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
413 | 413 | ||
414 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 414 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
415 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 415 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
416 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 416 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
417 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 417 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
418 | 418 | ||
419 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 419 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
420 | this, SLOT ( todo_unsub( Todo * ) ) ); | 420 | this, SLOT ( todo_unsub( Todo * ) ) ); |
421 | 421 | ||
422 | connect( 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 | ||
481 | CalendarView::~CalendarView() | 481 | CalendarView::~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 | } |
492 | void CalendarView::timerAlarm() | 492 | void CalendarView::timerAlarm() |
493 | { | 493 | { |
494 | //qDebug("CalendarView::timerAlarm() "); | 494 | //qDebug("CalendarView::timerAlarm() "); |
495 | computeAlarm(mAlarmNotification ); | 495 | computeAlarm(mAlarmNotification ); |
496 | } | 496 | } |
497 | 497 | ||
498 | void CalendarView::suspendAlarm() | 498 | void CalendarView::suspendAlarm() |
499 | { | 499 | { |
500 | //qDebug(" CalendarView::suspendAlarm() "); | 500 | //qDebug(" CalendarView::suspendAlarm() "); |
501 | computeAlarm(mSuspendAlarmNotification ); | 501 | computeAlarm(mSuspendAlarmNotification ); |
502 | 502 | ||
503 | } | 503 | } |
504 | 504 | ||
505 | void CalendarView::startAlarm( QString mess , QString filename) | 505 | void 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 | ||
512 | void CalendarView::checkNextTimerAlarm() | 512 | void CalendarView::checkNextTimerAlarm() |
513 | { | 513 | { |
514 | mCalendar->checkAlarmForIncidence( 0, true ); | 514 | mCalendar->checkAlarmForIncidence( 0, true ); |
515 | } | 515 | } |
516 | 516 | ||
517 | void CalendarView::computeAlarm( QString msg ) | 517 | void 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 | ||
606 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 606 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
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 | ||
617 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 617 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
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 |
644 | void CalendarView::recheckTimerAlarm() | 644 | void 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 | } |
650 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 650 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
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 | } |
661 | void CalendarView::selectWeekNum ( int num ) | 661 | void CalendarView::selectWeekNum ( int num ) |
662 | { | 662 | { |
663 | dateNavigator()->selectWeek( num ); | 663 | dateNavigator()->selectWeek( num ); |
664 | mViewManager->showWeekView(); | 664 | mViewManager->showWeekView(); |
665 | } | 665 | } |
666 | KOViewManager *CalendarView::viewManager() | 666 | KOViewManager *CalendarView::viewManager() |
667 | { | 667 | { |
668 | return mViewManager; | 668 | return mViewManager; |
669 | } | 669 | } |
670 | 670 | ||
671 | KODialogManager *CalendarView::dialogManager() | 671 | KODialogManager *CalendarView::dialogManager() |
672 | { | 672 | { |
673 | return mDialogManager; | 673 | return mDialogManager; |
674 | } | 674 | } |
675 | 675 | ||
676 | QDate CalendarView::startDate() | 676 | QDate 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 | ||
683 | QDate CalendarView::endDate() | 683 | QDate 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 | ||
691 | void CalendarView::createPrinter() | 691 | void 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 | ||
712 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 712 | int 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 | } |
854 | Event* CalendarView::getLastSyncEvent() | 854 | Event* 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 |
879 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 879 | void 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 | } |
907 | void CalendarView::checkExternalId( Incidence * inc ) | 907 | void 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 | } |
913 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 913 | bool 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 | int remRem = 0; | ||
1133 | if ( mSyncManager->mWriteBackInFuture ) { | 1134 | if ( mSyncManager->mWriteBackInFuture ) { |
1134 | er = remote->rawIncidences(); | 1135 | er = remote->rawIncidences(); |
1136 | remRem = er.count(); | ||
1135 | inR = er.first(); | 1137 | inR = er.first(); |
1136 | QDateTime dt; | 1138 | QDateTime dt; |
1137 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1139 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1138 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); | 1140 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); |
1139 | while ( inR ) { | 1141 | while ( inR ) { |
1140 | if ( inR->type() == "Todo" ) { | 1142 | if ( inR->type() == "Todo" ) { |
1141 | Todo * t = (Todo*)inR; | 1143 | Todo * t = (Todo*)inR; |
1142 | if ( t->hasDueDate() ) | 1144 | if ( t->hasDueDate() ) |
1143 | dt = t->dtDue(); | 1145 | dt = t->dtDue(); |
1144 | else | 1146 | else |
1145 | dt = cur.addSecs( 62 ); | 1147 | dt = cur.addSecs( 62 ); |
1146 | } | 1148 | } |
1147 | else if (inR->type() == "Event" ) { | 1149 | else if (inR->type() == "Event" ) { |
1148 | bool ok; | 1150 | bool ok; |
1149 | dt = inR->getNextOccurence( cur, &ok ); | 1151 | dt = inR->getNextOccurence( cur, &ok ); |
1150 | if ( !ok ) | 1152 | if ( !ok ) |
1151 | dt = cur.addSecs( -62 ); | 1153 | dt = cur.addSecs( -62 ); |
1152 | } | 1154 | } |
1153 | else | 1155 | else |
1154 | dt = inR->dtStart(); | 1156 | dt = inR->dtStart(); |
1155 | if ( dt < cur || dt > end ) { | 1157 | if ( dt < cur || dt > end ) { |
1156 | remote->deleteIncidence( inR ); | 1158 | remote->deleteIncidence( inR ); |
1157 | ++delFut; | 1159 | ++delFut; |
1158 | } | 1160 | } |
1159 | inR = er.next(); | 1161 | inR = er.next(); |
1160 | } | 1162 | } |
1161 | } | 1163 | } |
1162 | bar.hide(); | 1164 | bar.hide(); |
1163 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1165 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1164 | eventLSync->setReadOnly( false ); | 1166 | eventLSync->setReadOnly( false ); |
1165 | eventLSync->setDtStart( mLastCalendarSync ); | 1167 | eventLSync->setDtStart( mLastCalendarSync ); |
1166 | eventRSync->setDtStart( mLastCalendarSync ); | 1168 | eventRSync->setDtStart( mLastCalendarSync ); |
1167 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1169 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1168 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1170 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1169 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1171 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1170 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1172 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1171 | eventLSync->setReadOnly( true ); | 1173 | eventLSync->setReadOnly( true ); |
1172 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 1174 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
1173 | remote->addEvent( eventRSync ); | 1175 | remote->addEvent( eventRSync ); |
1174 | QString mes; | 1176 | 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 ); | 1177 | 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; | 1178 | QString delmess; |
1177 | if ( delFut ) { | 1179 | 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 ); | 1180 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1179 | mes += delmess; | 1181 | mes += delmess; |
1180 | } | 1182 | } |
1181 | if ( mSyncManager->mShowSyncSummary ) { | 1183 | if ( mSyncManager->mShowSyncSummary ) { |
1182 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); | 1184 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); |
1183 | } | 1185 | } |
1184 | qDebug( mes ); | 1186 | qDebug( mes ); |
1185 | mCalendar->checkAlarmForIncidence( 0, true ); | 1187 | mCalendar->checkAlarmForIncidence( 0, true ); |
1186 | return syncOK; | 1188 | return syncOK; |
1187 | } | 1189 | } |
1188 | 1190 | ||
1189 | void CalendarView::setSyncDevice( QString s ) | 1191 | void CalendarView::setSyncDevice( QString s ) |
1190 | { | 1192 | { |
1191 | mCurrentSyncDevice= s; | 1193 | mCurrentSyncDevice= s; |
1192 | } | 1194 | } |
1193 | void CalendarView::setSyncName( QString s ) | 1195 | void CalendarView::setSyncName( QString s ) |
1194 | { | 1196 | { |
1195 | mCurrentSyncName= s; | 1197 | mCurrentSyncName= s; |
1196 | } | 1198 | } |
1197 | bool CalendarView::syncCalendar(QString filename, int mode) | 1199 | bool CalendarView::syncCalendar(QString filename, int mode) |
1198 | { | 1200 | { |
1199 | //qDebug("syncCalendar %s ", filename.latin1()); | 1201 | //qDebug("syncCalendar %s ", filename.latin1()); |
1200 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1202 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1201 | CalendarLocal* calendar = new CalendarLocal(); | 1203 | CalendarLocal* calendar = new CalendarLocal(); |
1202 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1204 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1203 | FileStorage* storage = new FileStorage( calendar ); | 1205 | FileStorage* storage = new FileStorage( calendar ); |
1204 | bool syncOK = false; | 1206 | bool syncOK = false; |
1205 | storage->setFileName( filename ); | 1207 | storage->setFileName( filename ); |
1206 | // qDebug("loading ... "); | 1208 | // qDebug("loading ... "); |
1207 | if ( storage->load() ) { | 1209 | if ( storage->load() ) { |
1208 | getEventViewerDialog()->setSyncMode( true ); | 1210 | getEventViewerDialog()->setSyncMode( true ); |
1209 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1211 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1210 | getEventViewerDialog()->setSyncMode( false ); | 1212 | getEventViewerDialog()->setSyncMode( false ); |
1211 | if ( syncOK ) { | 1213 | if ( syncOK ) { |
1212 | if ( mSyncManager->mWriteBackFile ) | 1214 | if ( mSyncManager->mWriteBackFile ) |
1213 | { | 1215 | { |
1214 | storage->setSaveFormat( new ICalFormat() ); | 1216 | storage->setSaveFormat( new ICalFormat() ); |
1215 | storage->save(); | 1217 | storage->save(); |
1216 | } | 1218 | } |
1217 | } | 1219 | } |
1218 | setModified( true ); | 1220 | setModified( true ); |
1219 | } | 1221 | } |
1220 | delete storage; | 1222 | delete storage; |
1221 | delete calendar; | 1223 | delete calendar; |
1222 | if ( syncOK ) | 1224 | if ( syncOK ) |
1223 | updateView(); | 1225 | updateView(); |
1224 | return syncOK; | 1226 | return syncOK; |
1225 | } | 1227 | } |
1226 | 1228 | ||
1227 | void CalendarView::syncExternal( int mode ) | 1229 | void CalendarView::syncExternal( int mode ) |
1228 | { | 1230 | { |
1229 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1231 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1230 | 1232 | ||
1231 | qApp->processEvents(); | 1233 | qApp->processEvents(); |
1232 | CalendarLocal* calendar = new CalendarLocal(); | 1234 | CalendarLocal* calendar = new CalendarLocal(); |
1233 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1235 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1234 | bool syncOK = false; | 1236 | bool syncOK = false; |
1235 | bool loadSuccess = false; | 1237 | bool loadSuccess = false; |
1236 | PhoneFormat* phoneFormat = 0; | 1238 | PhoneFormat* phoneFormat = 0; |
1237 | #ifndef DESKTOP_VERSION | 1239 | #ifndef DESKTOP_VERSION |
1238 | SharpFormat* sharpFormat = 0; | 1240 | SharpFormat* sharpFormat = 0; |
1239 | if ( mode == 0 ) { // sharp | 1241 | if ( mode == 0 ) { // sharp |
1240 | sharpFormat = new SharpFormat () ; | 1242 | sharpFormat = new SharpFormat () ; |
1241 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1243 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1242 | 1244 | ||
1243 | } else | 1245 | } else |
1244 | #endif | 1246 | #endif |
1245 | if ( mode == 1 ) { // phone | 1247 | if ( mode == 1 ) { // phone |
1246 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1248 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1247 | mSyncManager->mPhoneDevice, | 1249 | mSyncManager->mPhoneDevice, |
1248 | mSyncManager->mPhoneConnection, | 1250 | mSyncManager->mPhoneConnection, |
1249 | mSyncManager->mPhoneModel); | 1251 | mSyncManager->mPhoneModel); |
1250 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1252 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1251 | 1253 | ||
1252 | } else | 1254 | } else |
1253 | return; | 1255 | return; |
1254 | if ( loadSuccess ) { | 1256 | if ( loadSuccess ) { |
1255 | getEventViewerDialog()->setSyncMode( true ); | 1257 | getEventViewerDialog()->setSyncMode( true ); |
1256 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1258 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1257 | getEventViewerDialog()->setSyncMode( false ); | 1259 | getEventViewerDialog()->setSyncMode( false ); |
1258 | qApp->processEvents(); | 1260 | qApp->processEvents(); |
1259 | if ( syncOK ) { | 1261 | if ( syncOK ) { |
1260 | if ( mSyncManager->mWriteBackFile ) | 1262 | if ( mSyncManager->mWriteBackFile ) |
1261 | { | 1263 | { |
1262 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1264 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1263 | Incidence* inc = iL.first(); | 1265 | Incidence* inc = iL.first(); |
1264 | if ( phoneFormat ) { | 1266 | if ( phoneFormat ) { |
1265 | while ( inc ) { | 1267 | while ( inc ) { |
1266 | inc->removeID(mCurrentSyncDevice); | 1268 | inc->removeID(mCurrentSyncDevice); |
1267 | inc = iL.next(); | 1269 | inc = iL.next(); |
1268 | } | 1270 | } |
1269 | } | 1271 | } |
1270 | #ifndef DESKTOP_VERSION | 1272 | #ifndef DESKTOP_VERSION |
1271 | if ( sharpFormat ) | 1273 | if ( sharpFormat ) |
1272 | sharpFormat->save(calendar); | 1274 | sharpFormat->save(calendar); |
1273 | #endif | 1275 | #endif |
1274 | if ( phoneFormat ) | 1276 | if ( phoneFormat ) |
1275 | phoneFormat->save(calendar); | 1277 | phoneFormat->save(calendar); |
1276 | iL = calendar->rawIncidences(); | 1278 | iL = calendar->rawIncidences(); |
1277 | inc = iL.first(); | 1279 | inc = iL.first(); |
1278 | Incidence* loc; | 1280 | Incidence* loc; |
1279 | while ( inc ) { | 1281 | while ( inc ) { |
1280 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1282 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1281 | loc = mCalendar->incidence(inc->uid() ); | 1283 | loc = mCalendar->incidence(inc->uid() ); |
1282 | if ( loc ) { | 1284 | if ( loc ) { |
1283 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1285 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1284 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1286 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1285 | } | 1287 | } |
1286 | } | 1288 | } |
1287 | inc = iL.next(); | 1289 | inc = iL.next(); |
1288 | } | 1290 | } |
1289 | Incidence* lse = getLastSyncEvent(); | 1291 | Incidence* lse = getLastSyncEvent(); |
1290 | if ( lse ) { | 1292 | if ( lse ) { |
1291 | lse->setReadOnly( false ); | 1293 | lse->setReadOnly( false ); |
1292 | lse->setDescription( "" ); | 1294 | lse->setDescription( "" ); |
1293 | lse->setReadOnly( true ); | 1295 | lse->setReadOnly( true ); |
1294 | } | 1296 | } |
1295 | } | 1297 | } |
1296 | } | 1298 | } |
1297 | setModified( true ); | 1299 | setModified( true ); |
1298 | } else { | 1300 | } else { |
1299 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1301 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1300 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1302 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1301 | question, i18n("Ok")) ; | 1303 | question, i18n("Ok")) ; |
1302 | 1304 | ||
1303 | } | 1305 | } |
1304 | delete calendar; | 1306 | delete calendar; |
1305 | updateView(); | 1307 | updateView(); |
1306 | return ;//syncOK; | 1308 | return ;//syncOK; |
1307 | 1309 | ||
1308 | } | 1310 | } |
1309 | 1311 | ||
1310 | bool CalendarView::importBday() | 1312 | bool CalendarView::importBday() |
1311 | { | 1313 | { |
1312 | #ifndef KORG_NOKABC | 1314 | #ifndef KORG_NOKABC |
1313 | 1315 | ||
1314 | #ifdef DESKTOP_VERSION | 1316 | #ifdef DESKTOP_VERSION |
1315 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1317 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1316 | KABC::AddressBook::Iterator it; | 1318 | KABC::AddressBook::Iterator it; |
1317 | int count = 0; | 1319 | int count = 0; |
1318 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1320 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1319 | ++count; | 1321 | ++count; |
1320 | } | 1322 | } |
1321 | QProgressBar bar(count,0 ); | 1323 | QProgressBar bar(count,0 ); |
1322 | int w = 300; | 1324 | int w = 300; |
1323 | if ( QApplication::desktop()->width() < 320 ) | 1325 | if ( QApplication::desktop()->width() < 320 ) |
1324 | w = 220; | 1326 | w = 220; |
1325 | int h = bar.sizeHint().height() ; | 1327 | int h = bar.sizeHint().height() ; |
1326 | int dw = QApplication::desktop()->width(); | 1328 | int dw = QApplication::desktop()->width(); |
1327 | int dh = QApplication::desktop()->height(); | 1329 | int dh = QApplication::desktop()->height(); |
1328 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1330 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1329 | bar.show(); | 1331 | bar.show(); |
1330 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1332 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1331 | qApp->processEvents(); | 1333 | qApp->processEvents(); |
1332 | count = 0; | 1334 | count = 0; |
1333 | int addCount = 0; | 1335 | int addCount = 0; |
1334 | KCal::Attendee* a = 0; | 1336 | KCal::Attendee* a = 0; |
1335 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1337 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1336 | if ( ! bar.isVisible() ) | 1338 | if ( ! bar.isVisible() ) |
1337 | return false; | 1339 | return false; |
1338 | bar.setProgress( count++ ); | 1340 | bar.setProgress( count++ ); |
1339 | qApp->processEvents(); | 1341 | qApp->processEvents(); |
1340 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1342 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1341 | if ( (*it).birthday().date().isValid() ){ | 1343 | if ( (*it).birthday().date().isValid() ){ |
1342 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1344 | 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 ) ) | 1345 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1344 | ++addCount; | 1346 | ++addCount; |
1345 | } | 1347 | } |
1346 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1348 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1347 | if ( anni.isValid() ){ | 1349 | if ( anni.isValid() ){ |
1348 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1350 | 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 ) ) | 1351 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1350 | ++addCount; | 1352 | ++addCount; |
1351 | } | 1353 | } |
1352 | } | 1354 | } |
1353 | updateView(); | 1355 | updateView(); |
1354 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1356 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1355 | #else //DESKTOP_VERSION | 1357 | #else //DESKTOP_VERSION |
1356 | 1358 | ||
1357 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1359 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1358 | // the result should now arrive through method insertBirthdays | 1360 | // the result should now arrive through method insertBirthdays |
1359 | 1361 | ||
1360 | #endif //DESKTOP_VERSION | 1362 | #endif //DESKTOP_VERSION |
1361 | 1363 | ||
1362 | #endif //KORG_NOKABC | 1364 | #endif //KORG_NOKABC |
1363 | 1365 | ||
1364 | 1366 | ||
1365 | return true; | 1367 | return true; |
1366 | } | 1368 | } |
1367 | 1369 | ||
1368 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1370 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1369 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1371 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1370 | const QStringList& anniversaryList, const QStringList& realNameList, | 1372 | const QStringList& anniversaryList, const QStringList& realNameList, |
1371 | const QStringList& emailList, const QStringList& assembledNameList, | 1373 | const QStringList& emailList, const QStringList& assembledNameList, |
1372 | const QStringList& uidList) | 1374 | const QStringList& uidList) |
1373 | { | 1375 | { |
1374 | qDebug("CalendarView::insertBirthdays"); | 1376 | qDebug("CalendarView::insertBirthdays"); |
1375 | if (uid == this->name()) | 1377 | if (uid == this->name()) |
1376 | { | 1378 | { |
1377 | int count = birthdayList.count(); | 1379 | int count = birthdayList.count(); |
1378 | int addCount = 0; | 1380 | int addCount = 0; |
1379 | KCal::Attendee* a = 0; | 1381 | KCal::Attendee* a = 0; |
1380 | 1382 | ||
1381 | qDebug("CalView 1 %i", count); | 1383 | qDebug("CalView 1 %i", count); |
1382 | 1384 | ||
1383 | QProgressBar bar(count,0 ); | 1385 | QProgressBar bar(count,0 ); |
1384 | int w = 300; | 1386 | int w = 300; |
1385 | if ( QApplication::desktop()->width() < 320 ) | 1387 | if ( QApplication::desktop()->width() < 320 ) |
1386 | w = 220; | 1388 | w = 220; |
1387 | int h = bar.sizeHint().height() ; | 1389 | int h = bar.sizeHint().height() ; |
1388 | int dw = QApplication::desktop()->width(); | 1390 | int dw = QApplication::desktop()->width(); |
1389 | int dh = QApplication::desktop()->height(); | 1391 | int dh = QApplication::desktop()->height(); |
1390 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1392 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1391 | bar.show(); | 1393 | bar.show(); |
1392 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1394 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1393 | qApp->processEvents(); | 1395 | qApp->processEvents(); |
1394 | 1396 | ||
1395 | QDate birthday; | 1397 | QDate birthday; |
1396 | QDate anniversary; | 1398 | QDate anniversary; |
1397 | QString realName; | 1399 | QString realName; |
1398 | QString email; | 1400 | QString email; |
1399 | QString assembledName; | 1401 | QString assembledName; |
1400 | QString uid; | 1402 | QString uid; |
1401 | bool ok = true; | 1403 | bool ok = true; |
1402 | for ( int i = 0; i < count; i++) | 1404 | for ( int i = 0; i < count; i++) |
1403 | { | 1405 | { |
1404 | if ( ! bar.isVisible() ) | 1406 | if ( ! bar.isVisible() ) |
1405 | return; | 1407 | return; |
1406 | bar.setProgress( i ); | 1408 | bar.setProgress( i ); |
1407 | qApp->processEvents(); | 1409 | qApp->processEvents(); |
1408 | 1410 | ||
1409 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1411 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1410 | if (!ok) { | 1412 | if (!ok) { |
1411 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1413 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1412 | } | 1414 | } |
1413 | 1415 | ||
1414 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1416 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1415 | if (!ok) { | 1417 | if (!ok) { |
1416 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1418 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1417 | } | 1419 | } |
1418 | realName = realNameList[i]; | 1420 | realName = realNameList[i]; |
1419 | email = emailList[i]; | 1421 | email = emailList[i]; |
1420 | assembledName = assembledNameList[i]; | 1422 | assembledName = assembledNameList[i]; |
1421 | uid = uidList[i]; | 1423 | 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() ); | 1424 | //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 | 1425 | ||
1424 | if ( birthday.isValid() ){ | 1426 | if ( birthday.isValid() ){ |
1425 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1427 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1426 | KCal::Attendee::ReqParticipant,uid) ; | 1428 | KCal::Attendee::ReqParticipant,uid) ; |
1427 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1429 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1428 | ++addCount; | 1430 | ++addCount; |
1429 | } | 1431 | } |
1430 | 1432 | ||
1431 | if ( anniversary.isValid() ){ | 1433 | if ( anniversary.isValid() ){ |
1432 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1434 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1433 | KCal::Attendee::ReqParticipant,uid) ; | 1435 | KCal::Attendee::ReqParticipant,uid) ; |
1434 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1436 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1435 | ++addCount; | 1437 | ++addCount; |
1436 | } | 1438 | } |
1437 | } | 1439 | } |
1438 | 1440 | ||
1439 | updateView(); | 1441 | updateView(); |
1440 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1442 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1441 | 1443 | ||
1442 | } | 1444 | } |
1443 | 1445 | ||
1444 | } | 1446 | } |
1445 | 1447 | ||
1446 | 1448 | ||
1447 | 1449 | ||
1448 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1450 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1449 | { | 1451 | { |
1450 | //qDebug("addAnni "); | 1452 | //qDebug("addAnni "); |
1451 | Event * ev = new Event(); | 1453 | Event * ev = new Event(); |
1452 | if ( a ) { | 1454 | if ( a ) { |
1453 | ev->addAttendee( a ); | 1455 | ev->addAttendee( a ); |
1454 | } | 1456 | } |
1455 | QString kind; | 1457 | QString kind; |
1456 | if ( birthday ) | 1458 | if ( birthday ) |
1457 | kind = i18n( "Birthday" ); | 1459 | kind = i18n( "Birthday" ); |
1458 | else | 1460 | else |
1459 | kind = i18n( "Anniversary" ); | 1461 | kind = i18n( "Anniversary" ); |
1460 | ev->setSummary( name + " - " + kind ); | 1462 | ev->setSummary( name + " - " + kind ); |
1461 | ev->setOrganizer( "nobody@nowhere" ); | 1463 | ev->setOrganizer( "nobody@nowhere" ); |
1462 | ev->setCategories( kind ); | 1464 | ev->setCategories( kind ); |
1463 | ev->setDtStart( QDateTime(date) ); | 1465 | ev->setDtStart( QDateTime(date) ); |
1464 | ev->setDtEnd( QDateTime(date) ); | 1466 | ev->setDtEnd( QDateTime(date) ); |
1465 | ev->setFloats( true ); | 1467 | ev->setFloats( true ); |
1466 | Recurrence * rec = ev->recurrence(); | 1468 | Recurrence * rec = ev->recurrence(); |
1467 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1469 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1468 | rec->addYearlyNum( date.month() ); | 1470 | rec->addYearlyNum( date.month() ); |
1469 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1471 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1470 | delete ev; | 1472 | delete ev; |
1471 | return false; | 1473 | return false; |
1472 | } | 1474 | } |
1473 | return true; | 1475 | return true; |
1474 | 1476 | ||
1475 | } | 1477 | } |
1476 | bool CalendarView::importQtopia( const QString &categories, | 1478 | bool CalendarView::importQtopia( const QString &categories, |
1477 | const QString &datebook, | 1479 | const QString &datebook, |
1478 | const QString &todolist ) | 1480 | const QString &todolist ) |
1479 | { | 1481 | { |
1480 | 1482 | ||
1481 | QtopiaFormat qtopiaFormat; | 1483 | QtopiaFormat qtopiaFormat; |
1482 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1484 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1483 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1485 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1484 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1486 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1485 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1487 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1486 | 1488 | ||
1487 | updateView(); | 1489 | updateView(); |
1488 | return true; | 1490 | return true; |
1489 | 1491 | ||
1490 | #if 0 | 1492 | #if 0 |
1491 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1493 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1492 | mCurrentSyncDevice = "qtopia-XML"; | 1494 | mCurrentSyncDevice = "qtopia-XML"; |
1493 | if ( mSyncManager->mAskForPreferences ) | 1495 | if ( mSyncManager->mAskForPreferences ) |
1494 | edit_sync_options(); | 1496 | edit_sync_options(); |
1495 | qApp->processEvents(); | 1497 | qApp->processEvents(); |
1496 | CalendarLocal* calendar = new CalendarLocal(); | 1498 | CalendarLocal* calendar = new CalendarLocal(); |
1497 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1499 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1498 | bool syncOK = false; | 1500 | bool syncOK = false; |
1499 | QtopiaFormat qtopiaFormat; | 1501 | QtopiaFormat qtopiaFormat; |
1500 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1502 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1501 | bool loadOk = true; | 1503 | bool loadOk = true; |
1502 | if ( !categories.isEmpty() ) | 1504 | if ( !categories.isEmpty() ) |
1503 | loadOk = qtopiaFormat.load( calendar, categories ); | 1505 | loadOk = qtopiaFormat.load( calendar, categories ); |
1504 | if ( loadOk && !datebook.isEmpty() ) | 1506 | if ( loadOk && !datebook.isEmpty() ) |
1505 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1507 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1506 | if ( loadOk && !todolist.isEmpty() ) | 1508 | if ( loadOk && !todolist.isEmpty() ) |
1507 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1509 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1508 | 1510 | ||
1509 | if ( loadOk ) { | 1511 | if ( loadOk ) { |
1510 | getEventViewerDialog()->setSyncMode( true ); | 1512 | getEventViewerDialog()->setSyncMode( true ); |
1511 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1513 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1512 | getEventViewerDialog()->setSyncMode( false ); | 1514 | getEventViewerDialog()->setSyncMode( false ); |
1513 | qApp->processEvents(); | 1515 | qApp->processEvents(); |
1514 | if ( syncOK ) { | 1516 | if ( syncOK ) { |
1515 | if ( mSyncManager->mWriteBackFile ) | 1517 | if ( mSyncManager->mWriteBackFile ) |
1516 | { | 1518 | { |
1517 | // write back XML file | 1519 | // write back XML file |
1518 | 1520 | ||
1519 | } | 1521 | } |
1520 | setModified( true ); | 1522 | setModified( true ); |
1521 | } | 1523 | } |
1522 | } else { | 1524 | } else { |
1523 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1525 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1524 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1526 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1525 | question, i18n("Ok")) ; | 1527 | question, i18n("Ok")) ; |
1526 | } | 1528 | } |
1527 | delete calendar; | 1529 | delete calendar; |
1528 | updateView(); | 1530 | updateView(); |
1529 | return syncOK; | 1531 | return syncOK; |
1530 | 1532 | ||
1531 | 1533 | ||
1532 | #endif | 1534 | #endif |
1533 | 1535 | ||
1534 | } | 1536 | } |
1535 | 1537 | ||
1536 | void CalendarView::setSyncEventsReadOnly() | 1538 | void CalendarView::setSyncEventsReadOnly() |
1537 | { | 1539 | { |
1538 | Event * ev; | 1540 | Event * ev; |
1539 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1541 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1540 | ev = eL.first(); | 1542 | ev = eL.first(); |
1541 | while ( ev ) { | 1543 | while ( ev ) { |
1542 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1544 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1543 | ev->setReadOnly( true ); | 1545 | ev->setReadOnly( true ); |
1544 | ev = eL.next(); | 1546 | ev = eL.next(); |
1545 | } | 1547 | } |
1546 | } | 1548 | } |
1547 | bool CalendarView::openCalendar(QString filename, bool merge) | 1549 | bool CalendarView::openCalendar(QString filename, bool merge) |
1548 | { | 1550 | { |
1549 | 1551 | ||
1550 | if (filename.isEmpty()) { | 1552 | if (filename.isEmpty()) { |
1551 | return false; | 1553 | return false; |
1552 | } | 1554 | } |
1553 | 1555 | ||
1554 | if (!QFile::exists(filename)) { | 1556 | if (!QFile::exists(filename)) { |
1555 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1557 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1556 | return false; | 1558 | return false; |
1557 | } | 1559 | } |
1558 | 1560 | ||
1559 | globalFlagBlockAgenda = 1; | 1561 | globalFlagBlockAgenda = 1; |
1560 | if (!merge) mCalendar->close(); | 1562 | if (!merge) mCalendar->close(); |
1561 | 1563 | ||
1562 | mStorage->setFileName( filename ); | 1564 | mStorage->setFileName( filename ); |
1563 | 1565 | ||
1564 | if ( mStorage->load() ) { | 1566 | if ( mStorage->load() ) { |
1565 | if ( merge ) ;//setModified( true ); | 1567 | if ( merge ) ;//setModified( true ); |
1566 | else { | 1568 | else { |
1567 | //setModified( true ); | 1569 | //setModified( true ); |
1568 | mViewManager->setDocumentId( filename ); | 1570 | mViewManager->setDocumentId( filename ); |
1569 | mDialogManager->setDocumentId( filename ); | 1571 | mDialogManager->setDocumentId( filename ); |
1570 | mTodoList->setDocumentId( filename ); | 1572 | mTodoList->setDocumentId( filename ); |
1571 | } | 1573 | } |
1572 | globalFlagBlockAgenda = 2; | 1574 | globalFlagBlockAgenda = 2; |
1573 | // if ( getLastSyncEvent() ) | 1575 | // if ( getLastSyncEvent() ) |
1574 | // getLastSyncEvent()->setReadOnly( true ); | 1576 | // getLastSyncEvent()->setReadOnly( true ); |
1575 | mCalendar->reInitAlarmSettings(); | 1577 | mCalendar->reInitAlarmSettings(); |
1576 | setSyncEventsReadOnly(); | 1578 | setSyncEventsReadOnly(); |
1577 | updateUnmanagedViews(); | 1579 | updateUnmanagedViews(); |
1578 | updateView(); | 1580 | updateView(); |
1579 | if ( filename != MainWindow::defaultFileName() ) { | 1581 | if ( filename != MainWindow::defaultFileName() ) { |
1580 | saveCalendar( MainWindow::defaultFileName() ); | 1582 | saveCalendar( MainWindow::defaultFileName() ); |
1581 | } else { | 1583 | } else { |
1582 | QFileInfo finf ( MainWindow::defaultFileName()); | 1584 | QFileInfo finf ( MainWindow::defaultFileName()); |
1583 | if ( finf.exists() ) { | 1585 | if ( finf.exists() ) { |
1584 | setLoadedFileVersion( finf.lastModified () ); | 1586 | setLoadedFileVersion( finf.lastModified () ); |
1585 | } | 1587 | } |
1586 | } | 1588 | } |
1587 | return true; | 1589 | return true; |
1588 | } else { | 1590 | } else { |
1589 | // while failing to load, the calendar object could | 1591 | // while failing to load, the calendar object could |
1590 | // have become partially populated. Clear it out. | 1592 | // have become partially populated. Clear it out. |
1591 | if ( !merge ) { | 1593 | if ( !merge ) { |
1592 | mCalendar->close(); | 1594 | mCalendar->close(); |
1593 | mViewManager->setDocumentId( filename ); | 1595 | mViewManager->setDocumentId( filename ); |
1594 | mDialogManager->setDocumentId( filename ); | 1596 | mDialogManager->setDocumentId( filename ); |
1595 | mTodoList->setDocumentId( filename ); | 1597 | mTodoList->setDocumentId( filename ); |
1596 | } | 1598 | } |
1597 | 1599 | ||
1598 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1600 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1599 | 1601 | ||
1600 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1602 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1601 | globalFlagBlockAgenda = 2; | 1603 | globalFlagBlockAgenda = 2; |
1602 | mCalendar->reInitAlarmSettings(); | 1604 | mCalendar->reInitAlarmSettings(); |
1603 | setSyncEventsReadOnly(); | 1605 | setSyncEventsReadOnly(); |
1604 | updateUnmanagedViews(); | 1606 | updateUnmanagedViews(); |
1605 | updateView(); | 1607 | updateView(); |
1606 | } | 1608 | } |
1607 | return false; | 1609 | return false; |
1608 | } | 1610 | } |
1609 | void CalendarView::showOpenError() | 1611 | void CalendarView::showOpenError() |
1610 | { | 1612 | { |
1611 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1613 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1612 | } | 1614 | } |
1613 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1615 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1614 | { | 1616 | { |
1615 | loadedFileVersion = dt; | 1617 | loadedFileVersion = dt; |
1616 | } | 1618 | } |
1617 | bool CalendarView::checkFileChanged(QString fn) | 1619 | bool CalendarView::checkFileChanged(QString fn) |
1618 | { | 1620 | { |
1619 | QFileInfo finf ( fn ); | 1621 | QFileInfo finf ( fn ); |
1620 | if ( !finf.exists() ) | 1622 | if ( !finf.exists() ) |
1621 | return true; | 1623 | return true; |
1622 | QDateTime dt = finf.lastModified (); | 1624 | QDateTime dt = finf.lastModified (); |
1623 | if ( dt <= loadedFileVersion ) | 1625 | if ( dt <= loadedFileVersion ) |
1624 | return false; | 1626 | return false; |
1625 | return true; | 1627 | return true; |
1626 | 1628 | ||
1627 | } | 1629 | } |
1628 | void CalendarView::watchSavedFile() | 1630 | void CalendarView::watchSavedFile() |
1629 | { | 1631 | { |
1630 | QFileInfo finf ( MainWindow::defaultFileName()); | 1632 | QFileInfo finf ( MainWindow::defaultFileName()); |
1631 | if ( !finf.exists() ) | 1633 | if ( !finf.exists() ) |
1632 | return; | 1634 | return; |
1633 | QDateTime dt = finf.lastModified (); | 1635 | QDateTime dt = finf.lastModified (); |
1634 | if ( dt < loadedFileVersion ) { | 1636 | if ( dt < loadedFileVersion ) { |
1635 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1637 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1636 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1638 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1637 | return; | 1639 | return; |
1638 | } | 1640 | } |
1639 | loadedFileVersion = dt; | 1641 | loadedFileVersion = dt; |
1640 | } | 1642 | } |
1641 | 1643 | ||
1642 | bool CalendarView::checkFileVersion(QString fn) | 1644 | bool CalendarView::checkFileVersion(QString fn) |
1643 | { | 1645 | { |
1644 | QFileInfo finf ( fn ); | 1646 | QFileInfo finf ( fn ); |
1645 | if ( !finf.exists() ) | 1647 | if ( !finf.exists() ) |
1646 | return true; | 1648 | return true; |
1647 | QDateTime dt = finf.lastModified (); | 1649 | QDateTime dt = finf.lastModified (); |
1648 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1650 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1649 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1651 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1650 | if ( dt <= loadedFileVersion ) | 1652 | if ( dt <= loadedFileVersion ) |
1651 | return true; | 1653 | 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)) , | 1654 | 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"), | 1655 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1654 | i18n("Sync+save")); | 1656 | i18n("Sync+save")); |
1655 | 1657 | ||
1656 | if ( km == KMessageBox::Cancel ) | 1658 | if ( km == KMessageBox::Cancel ) |
1657 | return false; | 1659 | return false; |
1658 | if ( km == KMessageBox::Yes ) | 1660 | if ( km == KMessageBox::Yes ) |
1659 | return true; | 1661 | return true; |
1660 | 1662 | ||
1661 | setSyncDevice("deleteaftersync" ); | 1663 | setSyncDevice("deleteaftersync" ); |
1662 | mSyncManager->mAskForPreferences = true; | 1664 | mSyncManager->mAskForPreferences = true; |
1663 | mSyncManager->mSyncAlgoPrefs = 3; | 1665 | mSyncManager->mSyncAlgoPrefs = 3; |
1664 | mSyncManager->mWriteBackFile = false; | 1666 | mSyncManager->mWriteBackFile = false; |
1665 | mSyncManager->mWriteBackExistingOnly = false; | 1667 | mSyncManager->mWriteBackExistingOnly = false; |
1666 | mSyncManager->mShowSyncSummary = false; | 1668 | mSyncManager->mShowSyncSummary = false; |
1667 | syncCalendar( fn, 3 ); | 1669 | syncCalendar( fn, 3 ); |
1668 | Event * e = getLastSyncEvent(); | 1670 | Event * e = getLastSyncEvent(); |
1669 | mCalendar->deleteEvent ( e ); | 1671 | mCalendar->deleteEvent ( e ); |
1670 | updateView(); | 1672 | updateView(); |
1671 | return true; | 1673 | return true; |
1672 | } | 1674 | } |
1673 | 1675 | ||
1674 | bool CalendarView::saveCalendar( QString filename ) | 1676 | bool CalendarView::saveCalendar( QString filename ) |
1675 | { | 1677 | { |
1676 | 1678 | ||
1677 | // Store back all unsaved data into calendar object | 1679 | // Store back all unsaved data into calendar object |
1678 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1680 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1679 | if ( mViewManager->currentView() ) | 1681 | if ( mViewManager->currentView() ) |
1680 | mViewManager->currentView()->flushView(); | 1682 | mViewManager->currentView()->flushView(); |
1681 | 1683 | ||
1682 | 1684 | ||
1683 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1685 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1684 | mStorage->setSaveFormat( new ICalFormat() ); | 1686 | mStorage->setSaveFormat( new ICalFormat() ); |
1685 | mStorage->setFileName( filename ); | 1687 | mStorage->setFileName( filename ); |
1686 | bool success; | 1688 | bool success; |
1687 | success = mStorage->save(); | 1689 | success = mStorage->save(); |
1688 | if ( !success ) { | 1690 | if ( !success ) { |
1689 | return false; | 1691 | return false; |
1690 | } | 1692 | } |
1691 | if ( filename == MainWindow::defaultFileName() ) { | 1693 | if ( filename == MainWindow::defaultFileName() ) { |
1692 | setLoadedFileVersion( lfv ); | 1694 | setLoadedFileVersion( lfv ); |
1693 | watchSavedFile(); | 1695 | watchSavedFile(); |
1694 | } | 1696 | } |
1695 | return true; | 1697 | return true; |
1696 | } | 1698 | } |
1697 | 1699 | ||
1698 | void CalendarView::closeCalendar() | 1700 | void CalendarView::closeCalendar() |
1699 | { | 1701 | { |
1700 | 1702 | ||
1701 | // child windows no longer valid | 1703 | // child windows no longer valid |
1702 | emit closingDown(); | 1704 | emit closingDown(); |
1703 | 1705 | ||
1704 | mCalendar->close(); | 1706 | mCalendar->close(); |
1705 | setModified(false); | 1707 | setModified(false); |
1706 | updateView(); | 1708 | updateView(); |
1707 | } | 1709 | } |
1708 | 1710 | ||
1709 | void CalendarView::archiveCalendar() | 1711 | void CalendarView::archiveCalendar() |
1710 | { | 1712 | { |
1711 | mDialogManager->showArchiveDialog(); | 1713 | mDialogManager->showArchiveDialog(); |
1712 | } | 1714 | } |
1713 | 1715 | ||
1714 | 1716 | ||
1715 | void CalendarView::readSettings() | 1717 | void CalendarView::readSettings() |
1716 | { | 1718 | { |
1717 | 1719 | ||
1718 | 1720 | ||
1719 | // mViewManager->showAgendaView(); | 1721 | // mViewManager->showAgendaView(); |
1720 | QString str; | 1722 | QString str; |
1721 | //qDebug("CalendarView::readSettings() "); | 1723 | //qDebug("CalendarView::readSettings() "); |
1722 | // read settings from the KConfig, supplying reasonable | 1724 | // read settings from the KConfig, supplying reasonable |
1723 | // defaults where none are to be found | 1725 | // defaults where none are to be found |
1724 | KConfig *config = KOGlobals::config(); | 1726 | KConfig *config = KOGlobals::config(); |
1725 | #ifndef KORG_NOSPLITTER | 1727 | #ifndef KORG_NOSPLITTER |
1726 | config->setGroup("KOrganizer Geometry"); | 1728 | config->setGroup("KOrganizer Geometry"); |
1727 | 1729 | ||
1728 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1730 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1729 | if (sizes.count() != 2) { | 1731 | if (sizes.count() != 2) { |
1730 | sizes << mDateNavigator->minimumSizeHint().width(); | 1732 | sizes << mDateNavigator->minimumSizeHint().width(); |
1731 | sizes << 300; | 1733 | sizes << 300; |
1732 | } | 1734 | } |
1733 | mPanner->setSizes(sizes); | 1735 | mPanner->setSizes(sizes); |
1734 | 1736 | ||
1735 | sizes = config->readIntListEntry("Separator2"); | 1737 | sizes = config->readIntListEntry("Separator2"); |
1736 | if ( ( mResourceView && sizes.count() == 4 ) || | 1738 | if ( ( mResourceView && sizes.count() == 4 ) || |
1737 | ( !mResourceView && sizes.count() == 3 ) ) { | 1739 | ( !mResourceView && sizes.count() == 3 ) ) { |
1738 | mLeftSplitter->setSizes(sizes); | 1740 | mLeftSplitter->setSizes(sizes); |
1739 | } | 1741 | } |
1740 | #endif | 1742 | #endif |
1741 | globalFlagBlockAgenda = 1; | 1743 | globalFlagBlockAgenda = 1; |
1742 | mViewManager->showAgendaView(); | 1744 | mViewManager->showAgendaView(); |
1743 | //mViewManager->readSettings( config ); | 1745 | //mViewManager->readSettings( config ); |
1744 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1746 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1745 | readFilterSettings(config); | 1747 | readFilterSettings(config); |
1746 | config->setGroup( "Views" ); | 1748 | config->setGroup( "Views" ); |
1747 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1749 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1748 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1750 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1749 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1751 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1750 | else mNavigator->selectDates( dateCount ); | 1752 | else mNavigator->selectDates( dateCount ); |
1751 | // mViewManager->readSettings( config ); | 1753 | // mViewManager->readSettings( config ); |
1752 | updateConfig(); | 1754 | updateConfig(); |
1753 | globalFlagBlockAgenda = 2; | 1755 | globalFlagBlockAgenda = 2; |
1754 | mViewManager->readSettings( config ); | 1756 | mViewManager->readSettings( config ); |
1755 | #ifdef DESKTOP_VERSION | 1757 | #ifdef DESKTOP_VERSION |
1756 | config->setGroup("WidgetLayout"); | 1758 | config->setGroup("WidgetLayout"); |
1757 | QStringList list; | 1759 | QStringList list; |
1758 | list = config->readListEntry("MainLayout"); | 1760 | list = config->readListEntry("MainLayout"); |
1759 | int x,y,w,h; | 1761 | int x,y,w,h; |
1760 | if ( ! list.isEmpty() ) { | 1762 | if ( ! list.isEmpty() ) { |
1761 | x = list[0].toInt(); | 1763 | x = list[0].toInt(); |
1762 | y = list[1].toInt(); | 1764 | y = list[1].toInt(); |
1763 | w = list[2].toInt(); | 1765 | w = list[2].toInt(); |
1764 | h = list[3].toInt(); | 1766 | h = list[3].toInt(); |
1765 | topLevelWidget()->setGeometry(x,y,w,h); | 1767 | topLevelWidget()->setGeometry(x,y,w,h); |
1766 | 1768 | ||
1767 | } else { | 1769 | } else { |
1768 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1770 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1769 | } | 1771 | } |
1770 | list = config->readListEntry("EditEventLayout"); | 1772 | list = config->readListEntry("EditEventLayout"); |
1771 | if ( ! list.isEmpty() ) { | 1773 | if ( ! list.isEmpty() ) { |
1772 | x = list[0].toInt(); | 1774 | x = list[0].toInt(); |
1773 | y = list[1].toInt(); | 1775 | y = list[1].toInt(); |
1774 | w = list[2].toInt(); | 1776 | w = list[2].toInt(); |
1775 | h = list[3].toInt(); | 1777 | h = list[3].toInt(); |
1776 | mEventEditor->setGeometry(x,y,w,h); | 1778 | mEventEditor->setGeometry(x,y,w,h); |
1777 | 1779 | ||
1778 | } | 1780 | } |
1779 | list = config->readListEntry("EditTodoLayout"); | 1781 | list = config->readListEntry("EditTodoLayout"); |
1780 | if ( ! list.isEmpty() ) { | 1782 | if ( ! list.isEmpty() ) { |
1781 | x = list[0].toInt(); | 1783 | x = list[0].toInt(); |
1782 | y = list[1].toInt(); | 1784 | y = list[1].toInt(); |
1783 | w = list[2].toInt(); | 1785 | w = list[2].toInt(); |
1784 | h = list[3].toInt(); | 1786 | h = list[3].toInt(); |
1785 | mTodoEditor->setGeometry(x,y,w,h); | 1787 | mTodoEditor->setGeometry(x,y,w,h); |
1786 | 1788 | ||
1787 | } | 1789 | } |
1788 | list = config->readListEntry("ViewerLayout"); | 1790 | list = config->readListEntry("ViewerLayout"); |
1789 | if ( ! list.isEmpty() ) { | 1791 | if ( ! list.isEmpty() ) { |
1790 | x = list[0].toInt(); | 1792 | x = list[0].toInt(); |
1791 | y = list[1].toInt(); | 1793 | y = list[1].toInt(); |
1792 | w = list[2].toInt(); | 1794 | w = list[2].toInt(); |
1793 | h = list[3].toInt(); | 1795 | h = list[3].toInt(); |
1794 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1796 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1795 | } | 1797 | } |
1796 | #endif | 1798 | #endif |
1797 | 1799 | ||
1798 | } | 1800 | } |
1799 | 1801 | ||
1800 | 1802 | ||
1801 | void CalendarView::writeSettings() | 1803 | void CalendarView::writeSettings() |
1802 | { | 1804 | { |
1803 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1805 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1804 | 1806 | ||
1805 | KConfig *config = KOGlobals::config(); | 1807 | KConfig *config = KOGlobals::config(); |
1806 | 1808 | ||
1807 | #ifndef KORG_NOSPLITTER | 1809 | #ifndef KORG_NOSPLITTER |
1808 | config->setGroup("KOrganizer Geometry"); | 1810 | config->setGroup("KOrganizer Geometry"); |
1809 | 1811 | ||
1810 | QValueList<int> list = mPanner->sizes(); | 1812 | QValueList<int> list = mPanner->sizes(); |
1811 | config->writeEntry("Separator1",list); | 1813 | config->writeEntry("Separator1",list); |
1812 | 1814 | ||
1813 | list = mLeftSplitter->sizes(); | 1815 | list = mLeftSplitter->sizes(); |
1814 | config->writeEntry("Separator2",list); | 1816 | config->writeEntry("Separator2",list); |
1815 | #endif | 1817 | #endif |
1816 | 1818 | ||
1817 | mViewManager->writeSettings( config ); | 1819 | mViewManager->writeSettings( config ); |
1818 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1820 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1819 | mDialogManager->writeSettings( config ); | 1821 | mDialogManager->writeSettings( config ); |
1820 | //KOPrefs::instance()->usrWriteConfig(); | 1822 | //KOPrefs::instance()->usrWriteConfig(); |
1821 | KOPrefs::instance()->writeConfig(); | 1823 | KOPrefs::instance()->writeConfig(); |
1822 | 1824 | ||
1823 | writeFilterSettings(config); | 1825 | writeFilterSettings(config); |
1824 | 1826 | ||
1825 | config->setGroup( "Views" ); | 1827 | config->setGroup( "Views" ); |
1826 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1828 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1827 | 1829 | ||
1828 | #ifdef DESKTOP_VERSION | 1830 | #ifdef DESKTOP_VERSION |
1829 | config->setGroup("WidgetLayout"); | 1831 | config->setGroup("WidgetLayout"); |
1830 | QStringList list ;//= config->readListEntry("MainLayout"); | 1832 | QStringList list ;//= config->readListEntry("MainLayout"); |
1831 | int x,y,w,h; | 1833 | int x,y,w,h; |
1832 | QWidget* wid; | 1834 | QWidget* wid; |
1833 | wid = topLevelWidget(); | 1835 | wid = topLevelWidget(); |
1834 | x = wid->geometry().x(); | 1836 | x = wid->geometry().x(); |
1835 | y = wid->geometry().y(); | 1837 | y = wid->geometry().y(); |
1836 | w = wid->width(); | 1838 | w = wid->width(); |
1837 | h = wid->height(); | 1839 | h = wid->height(); |
1838 | list.clear(); | 1840 | list.clear(); |
1839 | list << QString::number( x ); | 1841 | list << QString::number( x ); |
1840 | list << QString::number( y ); | 1842 | list << QString::number( y ); |
1841 | list << QString::number( w ); | 1843 | list << QString::number( w ); |
1842 | list << QString::number( h ); | 1844 | list << QString::number( h ); |
1843 | config->writeEntry("MainLayout",list ); | 1845 | config->writeEntry("MainLayout",list ); |
1844 | 1846 | ||
1845 | wid = mEventEditor; | 1847 | wid = mEventEditor; |
1846 | x = wid->geometry().x(); | 1848 | x = wid->geometry().x(); |
1847 | y = wid->geometry().y(); | 1849 | y = wid->geometry().y(); |
1848 | w = wid->width(); | 1850 | w = wid->width(); |
1849 | h = wid->height(); | 1851 | h = wid->height(); |
1850 | list.clear(); | 1852 | list.clear(); |
1851 | list << QString::number( x ); | 1853 | list << QString::number( x ); |
1852 | list << QString::number( y ); | 1854 | list << QString::number( y ); |
1853 | list << QString::number( w ); | 1855 | list << QString::number( w ); |
1854 | list << QString::number( h ); | 1856 | list << QString::number( h ); |
1855 | config->writeEntry("EditEventLayout",list ); | 1857 | config->writeEntry("EditEventLayout",list ); |
1856 | 1858 | ||
1857 | wid = mTodoEditor; | 1859 | wid = mTodoEditor; |
1858 | x = wid->geometry().x(); | 1860 | x = wid->geometry().x(); |
1859 | y = wid->geometry().y(); | 1861 | y = wid->geometry().y(); |
1860 | w = wid->width(); | 1862 | w = wid->width(); |
1861 | h = wid->height(); | 1863 | h = wid->height(); |
1862 | list.clear(); | 1864 | list.clear(); |
1863 | list << QString::number( x ); | 1865 | list << QString::number( x ); |
1864 | list << QString::number( y ); | 1866 | list << QString::number( y ); |
1865 | list << QString::number( w ); | 1867 | list << QString::number( w ); |
1866 | list << QString::number( h ); | 1868 | list << QString::number( h ); |
1867 | config->writeEntry("EditTodoLayout",list ); | 1869 | config->writeEntry("EditTodoLayout",list ); |
1868 | wid = getEventViewerDialog(); | 1870 | wid = getEventViewerDialog(); |
1869 | x = wid->geometry().x(); | 1871 | x = wid->geometry().x(); |
1870 | y = wid->geometry().y(); | 1872 | y = wid->geometry().y(); |
1871 | w = wid->width(); | 1873 | w = wid->width(); |
1872 | h = wid->height(); | 1874 | h = wid->height(); |
1873 | list.clear(); | 1875 | list.clear(); |
1874 | list << QString::number( x ); | 1876 | list << QString::number( x ); |
1875 | list << QString::number( y ); | 1877 | list << QString::number( y ); |
1876 | list << QString::number( w ); | 1878 | list << QString::number( w ); |
1877 | list << QString::number( h ); | 1879 | list << QString::number( h ); |
1878 | config->writeEntry("ViewerLayout",list ); | 1880 | config->writeEntry("ViewerLayout",list ); |
1879 | wid = mDialogManager->getSearchDialog(); | 1881 | wid = mDialogManager->getSearchDialog(); |
1880 | if ( wid ) { | 1882 | if ( wid ) { |
1881 | x = wid->geometry().x(); | 1883 | x = wid->geometry().x(); |
1882 | y = wid->geometry().y(); | 1884 | y = wid->geometry().y(); |
1883 | w = wid->width(); | 1885 | w = wid->width(); |
1884 | h = wid->height(); | 1886 | h = wid->height(); |
1885 | list.clear(); | 1887 | list.clear(); |
1886 | list << QString::number( x ); | 1888 | list << QString::number( x ); |
1887 | list << QString::number( y ); | 1889 | list << QString::number( y ); |
1888 | list << QString::number( w ); | 1890 | list << QString::number( w ); |
1889 | list << QString::number( h ); | 1891 | list << QString::number( h ); |
1890 | config->writeEntry("SearchLayout",list ); | 1892 | config->writeEntry("SearchLayout",list ); |
1891 | } | 1893 | } |
1892 | #endif | 1894 | #endif |
1893 | 1895 | ||
1894 | 1896 | ||
1895 | config->sync(); | 1897 | config->sync(); |
1896 | } | 1898 | } |
1897 | 1899 | ||
1898 | void CalendarView::readFilterSettings(KConfig *config) | 1900 | void CalendarView::readFilterSettings(KConfig *config) |
1899 | { | 1901 | { |
1900 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1902 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1901 | 1903 | ||
1902 | mFilters.clear(); | 1904 | mFilters.clear(); |
1903 | 1905 | ||
1904 | config->setGroup("General"); | 1906 | config->setGroup("General"); |
1905 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1907 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1906 | 1908 | ||
1907 | QStringList::ConstIterator it = filterList.begin(); | 1909 | QStringList::ConstIterator it = filterList.begin(); |
1908 | QStringList::ConstIterator end = filterList.end(); | 1910 | QStringList::ConstIterator end = filterList.end(); |
1909 | while(it != end) { | 1911 | while(it != end) { |
1910 | // kdDebug() << " filter: " << (*it) << endl; | 1912 | // kdDebug() << " filter: " << (*it) << endl; |
1911 | 1913 | ||
1912 | CalFilter *filter; | 1914 | CalFilter *filter; |
1913 | filter = new CalFilter(*it); | 1915 | filter = new CalFilter(*it); |
1914 | config->setGroup("Filter_" + (*it)); | 1916 | config->setGroup("Filter_" + (*it)); |
1915 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1917 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1916 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1918 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1917 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1919 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1918 | mFilters.append(filter); | 1920 | mFilters.append(filter); |
1919 | 1921 | ||
1920 | ++it; | 1922 | ++it; |
1921 | } | 1923 | } |
1922 | 1924 | ||
1923 | if (mFilters.count() == 0) { | 1925 | if (mFilters.count() == 0) { |
1924 | CalFilter *filter = new CalFilter(i18n("Default")); | 1926 | CalFilter *filter = new CalFilter(i18n("Default")); |
1925 | mFilters.append(filter); | 1927 | mFilters.append(filter); |
1926 | } | 1928 | } |
1927 | mFilterView->updateFilters(); | 1929 | mFilterView->updateFilters(); |
1928 | config->setGroup("FilterView"); | 1930 | config->setGroup("FilterView"); |
1929 | 1931 | ||
1930 | mFilterView->blockSignals(true); | 1932 | mFilterView->blockSignals(true); |
1931 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 1933 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
1932 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 1934 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
1933 | mFilterView->blockSignals(false); | 1935 | mFilterView->blockSignals(false); |
1934 | // We do it manually to avoid it being done twice by the above calls | 1936 | // We do it manually to avoid it being done twice by the above calls |
1935 | updateFilter(); | 1937 | updateFilter(); |
1936 | } | 1938 | } |
1937 | 1939 | ||
1938 | void CalendarView::writeFilterSettings(KConfig *config) | 1940 | void CalendarView::writeFilterSettings(KConfig *config) |
1939 | { | 1941 | { |
1940 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 1942 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
1941 | 1943 | ||
1942 | QStringList filterList; | 1944 | QStringList filterList; |
1943 | 1945 | ||
1944 | CalFilter *filter = mFilters.first(); | 1946 | CalFilter *filter = mFilters.first(); |
1945 | while(filter) { | 1947 | while(filter) { |
1946 | // kdDebug() << " fn: " << filter->name() << endl; | 1948 | // kdDebug() << " fn: " << filter->name() << endl; |
1947 | filterList << filter->name(); | 1949 | filterList << filter->name(); |
1948 | config->setGroup("Filter_" + filter->name()); | 1950 | config->setGroup("Filter_" + filter->name()); |
1949 | config->writeEntry("Criteria",filter->criteria()); | 1951 | config->writeEntry("Criteria",filter->criteria()); |
1950 | config->writeEntry("CategoryList",filter->categoryList()); | 1952 | config->writeEntry("CategoryList",filter->categoryList()); |
1951 | filter = mFilters.next(); | 1953 | filter = mFilters.next(); |
1952 | } | 1954 | } |
1953 | config->setGroup("General"); | 1955 | config->setGroup("General"); |
1954 | config->writeEntry("CalendarFilters",filterList); | 1956 | config->writeEntry("CalendarFilters",filterList); |
1955 | 1957 | ||
1956 | config->setGroup("FilterView"); | 1958 | config->setGroup("FilterView"); |
1957 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 1959 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
1958 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 1960 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
1959 | } | 1961 | } |
1960 | 1962 | ||
1961 | 1963 | ||
1962 | void CalendarView::goToday() | 1964 | void CalendarView::goToday() |
1963 | { | 1965 | { |
1964 | mNavigator->selectToday(); | 1966 | mNavigator->selectToday(); |
1965 | } | 1967 | } |
1966 | 1968 | ||
1967 | void CalendarView::goNext() | 1969 | void CalendarView::goNext() |
1968 | { | 1970 | { |
1969 | mNavigator->selectNext(); | 1971 | mNavigator->selectNext(); |
1970 | } | 1972 | } |
1971 | 1973 | ||
1972 | void CalendarView::goPrevious() | 1974 | void CalendarView::goPrevious() |
1973 | { | 1975 | { |
1974 | mNavigator->selectPrevious(); | 1976 | mNavigator->selectPrevious(); |
1975 | } | 1977 | } |
1976 | void CalendarView::goNextMonth() | 1978 | void CalendarView::goNextMonth() |
1977 | { | 1979 | { |
1978 | mNavigator->selectNextMonth(); | 1980 | mNavigator->selectNextMonth(); |
1979 | } | 1981 | } |
1980 | 1982 | ||
1981 | void CalendarView::goPreviousMonth() | 1983 | void CalendarView::goPreviousMonth() |
1982 | { | 1984 | { |
1983 | mNavigator->selectPreviousMonth(); | 1985 | mNavigator->selectPreviousMonth(); |
1984 | } | 1986 | } |
1985 | void CalendarView::writeLocale() | 1987 | void CalendarView::writeLocale() |
1986 | { | 1988 | { |
1987 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 1989 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
1988 | #if 0 | 1990 | #if 0 |
1989 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 1991 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
1990 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 1992 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
1991 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 1993 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
1992 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 1994 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
1993 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 1995 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
1994 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 1996 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
1995 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 1997 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
1996 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 1998 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
1997 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 1999 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
1998 | KOPrefs::instance()->mDaylightsavingStart, | 2000 | KOPrefs::instance()->mDaylightsavingStart, |
1999 | KOPrefs::instance()->mDaylightsavingEnd ); | 2001 | KOPrefs::instance()->mDaylightsavingEnd ); |
2000 | KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); | 2002 | KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); |
2001 | #endif | 2003 | #endif |
2002 | } | 2004 | } |
2003 | void CalendarView::updateConfig() | 2005 | void CalendarView::updateConfig() |
2004 | { | 2006 | { |
2005 | writeLocale(); | 2007 | writeLocale(); |
2006 | if ( KOPrefs::instance()->mUseAppColors ) | 2008 | if ( KOPrefs::instance()->mUseAppColors ) |
2007 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2009 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2008 | emit configChanged(); | 2010 | emit configChanged(); |
2009 | mTodoList->updateConfig(); | 2011 | mTodoList->updateConfig(); |
2010 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2012 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2011 | mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 2013 | mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
2012 | // To make the "fill window" configurations work | 2014 | // To make the "fill window" configurations work |
2013 | //mViewManager->raiseCurrentView(); | 2015 | //mViewManager->raiseCurrentView(); |
2014 | } | 2016 | } |
2015 | 2017 | ||
2016 | 2018 | ||
2017 | void CalendarView::eventChanged(Event *event) | 2019 | void CalendarView::eventChanged(Event *event) |
2018 | { | 2020 | { |
2019 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2021 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2020 | //updateUnmanagedViews(); | 2022 | //updateUnmanagedViews(); |
2021 | } | 2023 | } |
2022 | 2024 | ||
2023 | void CalendarView::eventAdded(Event *event) | 2025 | void CalendarView::eventAdded(Event *event) |
2024 | { | 2026 | { |
2025 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2027 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2026 | } | 2028 | } |
2027 | 2029 | ||
2028 | void CalendarView::eventToBeDeleted(Event *) | 2030 | void CalendarView::eventToBeDeleted(Event *) |
2029 | { | 2031 | { |
2030 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2032 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2031 | } | 2033 | } |
2032 | 2034 | ||
2033 | void CalendarView::eventDeleted() | 2035 | void CalendarView::eventDeleted() |
2034 | { | 2036 | { |
2035 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2037 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2036 | } | 2038 | } |
2037 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2039 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2038 | { | 2040 | { |
2039 | changeIncidenceDisplay((Incidence *)which, action); | 2041 | changeIncidenceDisplay((Incidence *)which, action); |
2040 | mDateNavigator->updateView(); //LR | 2042 | mDateNavigator->updateView(); //LR |
2041 | //mDialogManager->updateSearchDialog(); | 2043 | //mDialogManager->updateSearchDialog(); |
2042 | 2044 | ||
2043 | if (which) { | 2045 | if (which) { |
2044 | mViewManager->updateWNview(); | 2046 | mViewManager->updateWNview(); |
2045 | //mTodoList->updateView(); | 2047 | //mTodoList->updateView(); |
2046 | } | 2048 | } |
2047 | 2049 | ||
2048 | } | 2050 | } |
2049 | 2051 | ||
2050 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2052 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2051 | { | 2053 | { |
2052 | updateUnmanagedViews(); | 2054 | updateUnmanagedViews(); |
2053 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2055 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2054 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2056 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2055 | mCalendar->checkAlarmForIncidence( 0, true ); | 2057 | mCalendar->checkAlarmForIncidence( 0, true ); |
2056 | if ( mEventViewerDialog ) | 2058 | if ( mEventViewerDialog ) |
2057 | mEventViewerDialog->hide(); | 2059 | mEventViewerDialog->hide(); |
2058 | } | 2060 | } |
2059 | else | 2061 | else |
2060 | mCalendar->checkAlarmForIncidence( which , false ); | 2062 | mCalendar->checkAlarmForIncidence( which , false ); |
2061 | } | 2063 | } |
2062 | 2064 | ||
2063 | // most of the changeEventDisplays() right now just call the view's | 2065 | // 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. | 2066 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2065 | void CalendarView::changeEventDisplay(Event *which, int action) | 2067 | void CalendarView::changeEventDisplay(Event *which, int action) |
2066 | { | 2068 | { |
2067 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2069 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2068 | changeIncidenceDisplay((Incidence *)which, action); | 2070 | changeIncidenceDisplay((Incidence *)which, action); |
2069 | mDateNavigator->updateView(); | 2071 | mDateNavigator->updateView(); |
2070 | //mDialogManager->updateSearchDialog(); | 2072 | //mDialogManager->updateSearchDialog(); |
2071 | 2073 | ||
2072 | if (which) { | 2074 | if (which) { |
2073 | // If there is an event view visible update the display | 2075 | // If there is an event view visible update the display |
2074 | mViewManager->currentView()->changeEventDisplay(which,action); | 2076 | mViewManager->currentView()->changeEventDisplay(which,action); |
2075 | // TODO: check, if update needed | 2077 | // TODO: check, if update needed |
2076 | // if (which->getTodoStatus()) { | 2078 | // if (which->getTodoStatus()) { |
2077 | mTodoList->updateView(); | 2079 | mTodoList->updateView(); |
2078 | // } | 2080 | // } |
2079 | } else { | 2081 | } else { |
2080 | mViewManager->currentView()->updateView(); | 2082 | mViewManager->currentView()->updateView(); |
2081 | } | 2083 | } |
2082 | } | 2084 | } |
2083 | 2085 | ||
2084 | 2086 | ||
2085 | void CalendarView::updateTodoViews() | 2087 | void CalendarView::updateTodoViews() |
2086 | { | 2088 | { |
2087 | 2089 | ||
2088 | mTodoList->updateView(); | 2090 | mTodoList->updateView(); |
2089 | mViewManager->currentView()->updateView(); | 2091 | mViewManager->currentView()->updateView(); |
2090 | 2092 | ||
2091 | } | 2093 | } |
2092 | 2094 | ||
2093 | 2095 | ||
2094 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2096 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2095 | { | 2097 | { |
2096 | mTodoList->updateView(); | 2098 | mTodoList->updateView(); |
2097 | mViewManager->updateView(start, end); | 2099 | mViewManager->updateView(start, end); |
2098 | //mDateNavigator->updateView(); | 2100 | //mDateNavigator->updateView(); |
2099 | } | 2101 | } |
2100 | 2102 | ||
2101 | void CalendarView::updateView() | 2103 | void CalendarView::updateView() |
2102 | { | 2104 | { |
2103 | DateList tmpList = mNavigator->selectedDates(); | 2105 | DateList tmpList = mNavigator->selectedDates(); |
2104 | 2106 | ||
2105 | // We assume that the navigator only selects consecutive days. | 2107 | // We assume that the navigator only selects consecutive days. |
2106 | updateView( tmpList.first(), tmpList.last() ); | 2108 | updateView( tmpList.first(), tmpList.last() ); |
2107 | } | 2109 | } |
2108 | 2110 | ||
2109 | void CalendarView::updateUnmanagedViews() | 2111 | void CalendarView::updateUnmanagedViews() |
2110 | { | 2112 | { |
2111 | mDateNavigator->updateDayMatrix(); | 2113 | mDateNavigator->updateDayMatrix(); |
2112 | } | 2114 | } |
2113 | 2115 | ||
2114 | int CalendarView::msgItemDelete() | 2116 | int CalendarView::msgItemDelete() |
2115 | { | 2117 | { |
2116 | return KMessageBox::warningContinueCancel(this, | 2118 | return KMessageBox::warningContinueCancel(this, |
2117 | i18n("This item will be\npermanently deleted."), | 2119 | i18n("This item will be\npermanently deleted."), |
2118 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2120 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2119 | } | 2121 | } |
2120 | 2122 | ||
2121 | 2123 | ||
2122 | void CalendarView::edit_cut() | 2124 | void CalendarView::edit_cut() |
2123 | { | 2125 | { |
2124 | Event *anEvent=0; | 2126 | Event *anEvent=0; |
2125 | 2127 | ||
2126 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2128 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2127 | 2129 | ||
2128 | if (mViewManager->currentView()->isEventView()) { | 2130 | if (mViewManager->currentView()->isEventView()) { |
2129 | if ( incidence && incidence->type() == "Event" ) { | 2131 | if ( incidence && incidence->type() == "Event" ) { |
2130 | anEvent = static_cast<Event *>(incidence); | 2132 | anEvent = static_cast<Event *>(incidence); |
2131 | } | 2133 | } |
2132 | } | 2134 | } |
2133 | 2135 | ||
2134 | if (!anEvent) { | 2136 | if (!anEvent) { |
2135 | KNotifyClient::beep(); | 2137 | KNotifyClient::beep(); |
2136 | return; | 2138 | return; |
2137 | } | 2139 | } |
2138 | DndFactory factory( mCalendar ); | 2140 | DndFactory factory( mCalendar ); |
2139 | factory.cutEvent(anEvent); | 2141 | factory.cutEvent(anEvent); |
2140 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2142 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2141 | } | 2143 | } |
2142 | 2144 | ||
2143 | void CalendarView::edit_copy() | 2145 | void CalendarView::edit_copy() |
2144 | { | 2146 | { |
2145 | Event *anEvent=0; | 2147 | Event *anEvent=0; |
2146 | 2148 | ||
2147 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2149 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2148 | 2150 | ||
2149 | if (mViewManager->currentView()->isEventView()) { | 2151 | if (mViewManager->currentView()->isEventView()) { |
2150 | if ( incidence && incidence->type() == "Event" ) { | 2152 | if ( incidence && incidence->type() == "Event" ) { |
2151 | anEvent = static_cast<Event *>(incidence); | 2153 | anEvent = static_cast<Event *>(incidence); |
2152 | } | 2154 | } |
2153 | } | 2155 | } |
2154 | 2156 | ||
2155 | if (!anEvent) { | 2157 | if (!anEvent) { |
2156 | KNotifyClient::beep(); | 2158 | KNotifyClient::beep(); |
2157 | return; | 2159 | return; |
2158 | } | 2160 | } |
2159 | DndFactory factory( mCalendar ); | 2161 | DndFactory factory( mCalendar ); |
2160 | factory.copyEvent(anEvent); | 2162 | factory.copyEvent(anEvent); |
2161 | } | 2163 | } |
2162 | 2164 | ||
2163 | void CalendarView::edit_paste() | 2165 | void CalendarView::edit_paste() |
2164 | { | 2166 | { |
2165 | QDate date = mNavigator->selectedDates().first(); | 2167 | QDate date = mNavigator->selectedDates().first(); |
2166 | 2168 | ||
2167 | DndFactory factory( mCalendar ); | 2169 | DndFactory factory( mCalendar ); |
2168 | Event *pastedEvent = factory.pasteEvent( date ); | 2170 | Event *pastedEvent = factory.pasteEvent( date ); |
2169 | 2171 | ||
2170 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2172 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2171 | } | 2173 | } |
2172 | 2174 | ||
2173 | void CalendarView::edit_options() | 2175 | void CalendarView::edit_options() |
2174 | { | 2176 | { |
2175 | mDialogManager->showOptionsDialog(); | 2177 | mDialogManager->showOptionsDialog(); |
2176 | //writeSettings(); | 2178 | //writeSettings(); |
2177 | } | 2179 | } |
2178 | 2180 | ||
2179 | void CalendarView::slotSelectPickerDate( QDate d) | 2181 | void CalendarView::slotSelectPickerDate( QDate d) |
2180 | { | 2182 | { |
2181 | mDateFrame->hide(); | 2183 | mDateFrame->hide(); |
2182 | if ( mDatePickerMode == 1 ) { | 2184 | if ( mDatePickerMode == 1 ) { |
2183 | mNavigator->slotDaySelect( d ); | 2185 | mNavigator->slotDaySelect( d ); |
2184 | } else if ( mDatePickerMode == 2 ) { | 2186 | } else if ( mDatePickerMode == 2 ) { |
2185 | if ( mMoveIncidence->type() == "Todo" ) { | 2187 | if ( mMoveIncidence->type() == "Todo" ) { |
2186 | Todo * to = (Todo *) mMoveIncidence; | 2188 | Todo * to = (Todo *) mMoveIncidence; |
2187 | QTime tim; | 2189 | QTime tim; |
2188 | if ( to->hasDueDate() ) | 2190 | if ( to->hasDueDate() ) |
2189 | tim = to->dtDue().time(); | 2191 | tim = to->dtDue().time(); |
2190 | else { | 2192 | else { |
2191 | tim = QTime ( 0,0,0 ); | 2193 | tim = QTime ( 0,0,0 ); |
2192 | to->setFloats( true ); | 2194 | to->setFloats( true ); |
2193 | to->setHasDueDate( true ); | 2195 | to->setHasDueDate( true ); |
2194 | } | 2196 | } |
2195 | QDateTime dt ( d,tim ); | 2197 | QDateTime dt ( d,tim ); |
2196 | to->setDtDue( dt ); | 2198 | to->setDtDue( dt ); |
2197 | todoChanged( to ); | 2199 | todoChanged( to ); |
2198 | } else { | 2200 | } else { |
2199 | QTime tim = mMoveIncidence->dtStart().time(); | 2201 | QTime tim = mMoveIncidence->dtStart().time(); |
2200 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2202 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2201 | QDateTime dt ( d,tim ); | 2203 | QDateTime dt ( d,tim ); |
2202 | mMoveIncidence->setDtStart( dt ); | 2204 | mMoveIncidence->setDtStart( dt ); |
2203 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2205 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2204 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2206 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2205 | } | 2207 | } |
2206 | 2208 | ||
2207 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2209 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2208 | } | 2210 | } |
2209 | } | 2211 | } |
2210 | 2212 | ||
2211 | void CalendarView::removeCategories() | 2213 | void CalendarView::removeCategories() |
2212 | { | 2214 | { |
2213 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2215 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2214 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2216 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2215 | QStringList catIncList; | 2217 | QStringList catIncList; |
2216 | QStringList newCatList; | 2218 | QStringList newCatList; |
2217 | Incidence* inc = incList.first(); | 2219 | Incidence* inc = incList.first(); |
2218 | int i; | 2220 | int i; |
2219 | int count = 0; | 2221 | int count = 0; |
2220 | while ( inc ) { | 2222 | while ( inc ) { |
2221 | newCatList.clear(); | 2223 | newCatList.clear(); |
2222 | catIncList = inc->categories() ; | 2224 | catIncList = inc->categories() ; |
2223 | for( i = 0; i< catIncList.count(); ++i ) { | 2225 | for( i = 0; i< catIncList.count(); ++i ) { |
2224 | if ( catList.contains (catIncList[i])) | 2226 | if ( catList.contains (catIncList[i])) |
2225 | newCatList.append( catIncList[i] ); | 2227 | newCatList.append( catIncList[i] ); |
2226 | } | 2228 | } |
2227 | newCatList.sort(); | 2229 | newCatList.sort(); |
2228 | inc->setCategories( newCatList.join(",") ); | 2230 | inc->setCategories( newCatList.join(",") ); |
2229 | inc = incList.next(); | 2231 | inc = incList.next(); |
2230 | } | 2232 | } |
2231 | } | 2233 | } |
2232 | 2234 | ||
2233 | int CalendarView::addCategories() | 2235 | int CalendarView::addCategories() |
2234 | { | 2236 | { |
2235 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2237 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2236 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2238 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2237 | QStringList catIncList; | 2239 | QStringList catIncList; |
2238 | Incidence* inc = incList.first(); | 2240 | Incidence* inc = incList.first(); |
2239 | int i; | 2241 | int i; |
2240 | int count = 0; | 2242 | int count = 0; |
2241 | while ( inc ) { | 2243 | while ( inc ) { |
2242 | catIncList = inc->categories() ; | 2244 | catIncList = inc->categories() ; |
2243 | for( i = 0; i< catIncList.count(); ++i ) { | 2245 | for( i = 0; i< catIncList.count(); ++i ) { |
2244 | if ( !catList.contains (catIncList[i])) { | 2246 | if ( !catList.contains (catIncList[i])) { |
2245 | catList.append( catIncList[i] ); | 2247 | catList.append( catIncList[i] ); |
2246 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2248 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2247 | ++count; | 2249 | ++count; |
2248 | } | 2250 | } |
2249 | } | 2251 | } |
2250 | inc = incList.next(); | 2252 | inc = incList.next(); |
2251 | } | 2253 | } |
2252 | catList.sort(); | 2254 | catList.sort(); |
2253 | KOPrefs::instance()->mCustomCategories = catList; | 2255 | KOPrefs::instance()->mCustomCategories = catList; |
2254 | return count; | 2256 | return count; |
2255 | } | 2257 | } |
2256 | 2258 | ||
2257 | void CalendarView::manageCategories() | 2259 | void CalendarView::manageCategories() |
2258 | { | 2260 | { |
2259 | KOCatPrefs* cp = new KOCatPrefs(); | 2261 | KOCatPrefs* cp = new KOCatPrefs(); |
2260 | cp->show(); | 2262 | cp->show(); |
2261 | int w =cp->sizeHint().width() ; | 2263 | int w =cp->sizeHint().width() ; |
2262 | int h = cp->sizeHint().height() ; | 2264 | int h = cp->sizeHint().height() ; |
2263 | int dw = QApplication::desktop()->width(); | 2265 | int dw = QApplication::desktop()->width(); |
2264 | int dh = QApplication::desktop()->height(); | 2266 | int dh = QApplication::desktop()->height(); |
2265 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2267 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2266 | if ( !cp->exec() ) { | 2268 | if ( !cp->exec() ) { |
2267 | delete cp; | 2269 | delete cp; |
2268 | return; | 2270 | return; |
2269 | } | 2271 | } |
2270 | int count = 0; | 2272 | int count = 0; |
2271 | if ( cp->addCat() ) { | 2273 | if ( cp->addCat() ) { |
2272 | count = addCategories(); | 2274 | count = addCategories(); |
2273 | if ( count ) { | 2275 | if ( count ) { |
2274 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2276 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2275 | writeSettings(); | 2277 | writeSettings(); |
2276 | } | 2278 | } |
2277 | } else { | 2279 | } else { |
2278 | removeCategories(); | 2280 | removeCategories(); |
2279 | updateView(); | 2281 | updateView(); |
2280 | } | 2282 | } |
2281 | delete cp; | 2283 | delete cp; |
2282 | } | 2284 | } |
2283 | 2285 | ||
2284 | void CalendarView::beamIncidence(Incidence * Inc) | 2286 | void CalendarView::beamIncidence(Incidence * Inc) |
2285 | { | 2287 | { |
2286 | QPtrList<Incidence> delSel ; | 2288 | QPtrList<Incidence> delSel ; |
2287 | delSel.append(Inc); | 2289 | delSel.append(Inc); |
2288 | beamIncidenceList( delSel ); | 2290 | beamIncidenceList( delSel ); |
2289 | } | 2291 | } |
2290 | void CalendarView::beamCalendar() | 2292 | void CalendarView::beamCalendar() |
2291 | { | 2293 | { |
2292 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2294 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2293 | //qDebug("beamCalendar() "); | 2295 | //qDebug("beamCalendar() "); |
2294 | beamIncidenceList( delSel ); | 2296 | beamIncidenceList( delSel ); |
2295 | } | 2297 | } |
2296 | void CalendarView::beamFilteredCalendar() | 2298 | void CalendarView::beamFilteredCalendar() |
2297 | { | 2299 | { |
2298 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2300 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2299 | //qDebug("beamFilteredCalendar() "); | 2301 | //qDebug("beamFilteredCalendar() "); |
2300 | beamIncidenceList( delSel ); | 2302 | beamIncidenceList( delSel ); |
2301 | } | 2303 | } |
2302 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2304 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2303 | { | 2305 | { |
2304 | if ( beamDialog->exec () == QDialog::Rejected ) | 2306 | if ( beamDialog->exec () == QDialog::Rejected ) |
2305 | return; | 2307 | return; |
2306 | 2308 | ||
2307 | QString fn = "/tmp/kopibeamfile"; | 2309 | QString fn = "/tmp/kopibeamfile"; |
2308 | QString mes; | 2310 | QString mes; |
2309 | bool createbup = true; | 2311 | bool createbup = true; |
2310 | if ( createbup ) { | 2312 | if ( createbup ) { |
2311 | QString description = "\n"; | 2313 | QString description = "\n"; |
2312 | CalendarLocal* cal = new CalendarLocal(); | 2314 | CalendarLocal* cal = new CalendarLocal(); |
2313 | if ( beamDialog->beamLocal() ) | 2315 | if ( beamDialog->beamLocal() ) |
2314 | cal->setLocalTime(); | 2316 | cal->setLocalTime(); |
2315 | else | 2317 | else |
2316 | cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 2318 | cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
2317 | Incidence *incidence = delSel.first(); | 2319 | Incidence *incidence = delSel.first(); |
2318 | bool addText = false; | 2320 | bool addText = false; |
2319 | if ( delSel.count() < 10 ) | 2321 | if ( delSel.count() < 10 ) |
2320 | addText = true; | 2322 | addText = true; |
2321 | else { | 2323 | else { |
2322 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2324 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2323 | } | 2325 | } |
2324 | while ( incidence ) { | 2326 | while ( incidence ) { |
2325 | Incidence *in = incidence->clone(); | 2327 | Incidence *in = incidence->clone(); |
2326 | if ( ! in->summary().isEmpty() ) { | 2328 | if ( ! in->summary().isEmpty() ) { |
2327 | in->setDescription(""); | 2329 | in->setDescription(""); |
2328 | } else { | 2330 | } else { |
2329 | in->setSummary( in->description().left(20)); | 2331 | in->setSummary( in->description().left(20)); |
2330 | in->setDescription(""); | 2332 | in->setDescription(""); |
2331 | } | 2333 | } |
2332 | if ( addText ) | 2334 | if ( addText ) |
2333 | description += in->summary() + "\n"; | 2335 | description += in->summary() + "\n"; |
2334 | cal->addIncidence( in ); | 2336 | cal->addIncidence( in ); |
2335 | incidence = delSel.next(); | 2337 | incidence = delSel.next(); |
2336 | } | 2338 | } |
2337 | if ( beamDialog->beamVcal() ) { | 2339 | if ( beamDialog->beamVcal() ) { |
2338 | fn += ".vcs"; | 2340 | fn += ".vcs"; |
2339 | FileStorage storage( cal, fn, new VCalFormat ); | 2341 | FileStorage storage( cal, fn, new VCalFormat ); |
2340 | storage.save(); | 2342 | storage.save(); |
2341 | } else { | 2343 | } else { |
2342 | fn += ".ics"; | 2344 | fn += ".ics"; |
2343 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2345 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2344 | storage.save(); | 2346 | storage.save(); |
2345 | } | 2347 | } |
2346 | delete cal; | 2348 | delete cal; |
2347 | mes = i18n("KO/Pi: Ready for beaming"); | 2349 | mes = i18n("KO/Pi: Ready for beaming"); |
2348 | topLevelWidget()->setCaption(mes); | 2350 | topLevelWidget()->setCaption(mes); |
2349 | KApplication::convert2latin1( fn ); | 2351 | KApplication::convert2latin1( fn ); |
2350 | #ifndef DESKTOP_VERSION | 2352 | #ifndef DESKTOP_VERSION |
2351 | Ir *ir = new Ir( this ); | 2353 | Ir *ir = new Ir( this ); |
2352 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2354 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2353 | ir->send( fn, description, "text/x-vCalendar" ); | 2355 | ir->send( fn, description, "text/x-vCalendar" ); |
2354 | #endif | 2356 | #endif |
2355 | } | 2357 | } |
2356 | } | 2358 | } |
2357 | void CalendarView::beamDone( Ir *ir ) | 2359 | void CalendarView::beamDone( Ir *ir ) |
2358 | { | 2360 | { |
2359 | #ifndef DESKTOP_VERSION | 2361 | #ifndef DESKTOP_VERSION |
2360 | delete ir; | 2362 | delete ir; |
2361 | #endif | 2363 | #endif |
2362 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2364 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2363 | topLevelWidget()->raise(); | 2365 | topLevelWidget()->raise(); |
2364 | } | 2366 | } |
2365 | 2367 | ||
2366 | void CalendarView::moveIncidence(Incidence * inc ) | 2368 | void CalendarView::moveIncidence(Incidence * inc ) |
2367 | { | 2369 | { |
2368 | if ( !inc ) return; | 2370 | if ( !inc ) return; |
2369 | // qDebug("showDatePickerForIncidence( ) "); | 2371 | // qDebug("showDatePickerForIncidence( ) "); |
2370 | if ( mDateFrame->isVisible() ) | 2372 | if ( mDateFrame->isVisible() ) |
2371 | mDateFrame->hide(); | 2373 | mDateFrame->hide(); |
2372 | else { | 2374 | else { |
2373 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2375 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2374 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2376 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2375 | int dw = QApplication::desktop()->width(); | 2377 | int dw = QApplication::desktop()->width(); |
2376 | int dh = QApplication::desktop()->height(); | 2378 | int dh = QApplication::desktop()->height(); |
2377 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2379 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2378 | mDateFrame->show(); | 2380 | mDateFrame->show(); |
2379 | } | 2381 | } |
2380 | mDatePickerMode = 2; | 2382 | mDatePickerMode = 2; |
2381 | mMoveIncidence = inc ; | 2383 | mMoveIncidence = inc ; |
2382 | QDate da; | 2384 | QDate da; |
2383 | if ( mMoveIncidence->type() == "Todo" ) { | 2385 | if ( mMoveIncidence->type() == "Todo" ) { |
2384 | Todo * to = (Todo *) mMoveIncidence; | 2386 | Todo * to = (Todo *) mMoveIncidence; |
2385 | if ( to->hasDueDate() ) | 2387 | if ( to->hasDueDate() ) |
2386 | da = to->dtDue().date(); | 2388 | da = to->dtDue().date(); |
2387 | else | 2389 | else |
2388 | da = QDate::currentDate(); | 2390 | da = QDate::currentDate(); |
2389 | } else { | 2391 | } else { |
2390 | da = mMoveIncidence->dtStart().date(); | 2392 | da = mMoveIncidence->dtStart().date(); |
2391 | } | 2393 | } |
2392 | mDatePicker->setDate( da ); | 2394 | mDatePicker->setDate( da ); |
2393 | } | 2395 | } |
2394 | void CalendarView::showDatePicker( ) | 2396 | void CalendarView::showDatePicker( ) |
2395 | { | 2397 | { |
2396 | //qDebug("CalendarView::showDatePicker( ) "); | 2398 | //qDebug("CalendarView::showDatePicker( ) "); |
2397 | if ( mDateFrame->isVisible() ) | 2399 | if ( mDateFrame->isVisible() ) |
2398 | mDateFrame->hide(); | 2400 | mDateFrame->hide(); |
2399 | else { | 2401 | else { |
2400 | int w =mDatePicker->sizeHint().width() ; | 2402 | int w =mDatePicker->sizeHint().width() ; |
2401 | int h = mDatePicker->sizeHint().height() ; | 2403 | int h = mDatePicker->sizeHint().height() ; |
2402 | int dw = QApplication::desktop()->width(); | 2404 | int dw = QApplication::desktop()->width(); |
2403 | int dh = QApplication::desktop()->height(); | 2405 | int dh = QApplication::desktop()->height(); |
2404 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2406 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2405 | mDateFrame->show(); | 2407 | mDateFrame->show(); |
2406 | } | 2408 | } |
2407 | mDatePickerMode = 1; | 2409 | mDatePickerMode = 1; |
2408 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2410 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2409 | } | 2411 | } |
2410 | 2412 | ||
2411 | void CalendarView::showEventEditor() | 2413 | void CalendarView::showEventEditor() |
2412 | { | 2414 | { |
2413 | #ifdef DESKTOP_VERSION | 2415 | #ifdef DESKTOP_VERSION |
2414 | mEventEditor->show(); | 2416 | mEventEditor->show(); |
2415 | #else | 2417 | #else |
2416 | mEventEditor->showMaximized(); | 2418 | mEventEditor->showMaximized(); |
2417 | #endif | 2419 | #endif |
2418 | } | 2420 | } |
2419 | void CalendarView::showTodoEditor() | 2421 | void CalendarView::showTodoEditor() |
2420 | { | 2422 | { |
2421 | #ifdef DESKTOP_VERSION | 2423 | #ifdef DESKTOP_VERSION |
2422 | mTodoEditor->show(); | 2424 | mTodoEditor->show(); |
2423 | #else | 2425 | #else |
2424 | mTodoEditor->showMaximized(); | 2426 | mTodoEditor->showMaximized(); |
2425 | #endif | 2427 | #endif |
2426 | } | 2428 | } |
2427 | 2429 | ||
2428 | void CalendarView::cloneIncidence() | 2430 | void CalendarView::cloneIncidence() |
2429 | { | 2431 | { |
2430 | Incidence *incidence = currentSelection(); | 2432 | Incidence *incidence = currentSelection(); |
2431 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2433 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2432 | if ( incidence ) { | 2434 | if ( incidence ) { |
2433 | cloneIncidence(incidence); | 2435 | cloneIncidence(incidence); |
2434 | } | 2436 | } |
2435 | } | 2437 | } |
2436 | void CalendarView::moveIncidence() | 2438 | void CalendarView::moveIncidence() |
2437 | { | 2439 | { |
2438 | Incidence *incidence = currentSelection(); | 2440 | Incidence *incidence = currentSelection(); |
2439 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2441 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2440 | if ( incidence ) { | 2442 | if ( incidence ) { |
2441 | moveIncidence(incidence); | 2443 | moveIncidence(incidence); |
2442 | } | 2444 | } |
2443 | } | 2445 | } |
2444 | void CalendarView::beamIncidence() | 2446 | void CalendarView::beamIncidence() |
2445 | { | 2447 | { |
2446 | Incidence *incidence = currentSelection(); | 2448 | Incidence *incidence = currentSelection(); |
2447 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2449 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2448 | if ( incidence ) { | 2450 | if ( incidence ) { |
2449 | beamIncidence(incidence); | 2451 | beamIncidence(incidence); |
2450 | } | 2452 | } |
2451 | } | 2453 | } |
2452 | void CalendarView::toggleCancelIncidence() | 2454 | void CalendarView::toggleCancelIncidence() |
2453 | { | 2455 | { |
2454 | Incidence *incidence = currentSelection(); | 2456 | Incidence *incidence = currentSelection(); |
2455 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2457 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2456 | if ( incidence ) { | 2458 | if ( incidence ) { |
2457 | cancelIncidence(incidence); | 2459 | cancelIncidence(incidence); |
2458 | } | 2460 | } |
2459 | } | 2461 | } |
2460 | 2462 | ||
2461 | 2463 | ||
2462 | void CalendarView::cancelIncidence(Incidence * inc ) | 2464 | void CalendarView::cancelIncidence(Incidence * inc ) |
2463 | { | 2465 | { |
2464 | inc->setCancelled( ! inc->cancelled() ); | 2466 | inc->setCancelled( ! inc->cancelled() ); |
2465 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2467 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2466 | updateView(); | 2468 | updateView(); |
2467 | } | 2469 | } |
2468 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2470 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2469 | { | 2471 | { |
2470 | Incidence * newInc = orgInc->clone(); | 2472 | Incidence * newInc = orgInc->clone(); |
2471 | newInc->recreate(); | 2473 | newInc->recreate(); |
2472 | 2474 | ||
2473 | if ( newInc->type() == "Todo" ) { | 2475 | if ( newInc->type() == "Todo" ) { |
2474 | Todo* t = (Todo*) newInc; | 2476 | Todo* t = (Todo*) newInc; |
2475 | mTodoEditor->editTodo( t ); | 2477 | mTodoEditor->editTodo( t ); |
2476 | showTodoEditor(); | 2478 | showTodoEditor(); |
2477 | if ( mTodoEditor->exec() ) { | 2479 | if ( mTodoEditor->exec() ) { |
2478 | mCalendar->addTodo( t ); | 2480 | mCalendar->addTodo( t ); |
2479 | updateView(); | 2481 | updateView(); |
2480 | } else { | 2482 | } else { |
2481 | delete t; | 2483 | delete t; |
2482 | } | 2484 | } |
2483 | } | 2485 | } |
2484 | else { | 2486 | else { |
2485 | Event* e = (Event*) newInc; | 2487 | Event* e = (Event*) newInc; |
2486 | mEventEditor->editEvent( e ); | 2488 | mEventEditor->editEvent( e ); |
2487 | showEventEditor(); | 2489 | showEventEditor(); |
2488 | if ( mEventEditor->exec() ) { | 2490 | if ( mEventEditor->exec() ) { |
2489 | mCalendar->addEvent( e ); | 2491 | mCalendar->addEvent( e ); |
2490 | updateView(); | 2492 | updateView(); |
2491 | } else { | 2493 | } else { |
2492 | delete e; | 2494 | delete e; |
2493 | } | 2495 | } |
2494 | } | 2496 | } |
2495 | } | 2497 | } |
2496 | 2498 | ||
2497 | void CalendarView::newEvent() | 2499 | void CalendarView::newEvent() |
2498 | { | 2500 | { |
2499 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2501 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2500 | KOAgendaView *aView = mViewManager->agendaView(); | 2502 | KOAgendaView *aView = mViewManager->agendaView(); |
2501 | if (aView) { | 2503 | if (aView) { |
2502 | if (aView->selectionStart().isValid()) { | 2504 | if (aView->selectionStart().isValid()) { |
2503 | if (aView->selectedIsAllDay()) { | 2505 | if (aView->selectedIsAllDay()) { |
2504 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2506 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2505 | } else { | 2507 | } else { |
2506 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2508 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2507 | } | 2509 | } |
2508 | return; | 2510 | return; |
2509 | } | 2511 | } |
2510 | } | 2512 | } |
2511 | 2513 | ||
2512 | QDate date = mNavigator->selectedDates().first(); | 2514 | QDate date = mNavigator->selectedDates().first(); |
2513 | QDateTime current = QDateTime::currentDateTime(); | 2515 | QDateTime current = QDateTime::currentDateTime(); |
2514 | if ( date <= current.date() ) { | 2516 | if ( date <= current.date() ) { |
2515 | int hour = current.time().hour() +1; | 2517 | int hour = current.time().hour() +1; |
2516 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2518 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2517 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2519 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2518 | } else | 2520 | } else |
2519 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2521 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2520 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2522 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2521 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2523 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2522 | } | 2524 | } |
2523 | 2525 | ||
2524 | void CalendarView::newEvent(QDateTime fh) | 2526 | void CalendarView::newEvent(QDateTime fh) |
2525 | { | 2527 | { |
2526 | newEvent(fh, | 2528 | newEvent(fh, |
2527 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2529 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2528 | } | 2530 | } |
2529 | 2531 | ||
2530 | void CalendarView::newEvent(QDate dt) | 2532 | void CalendarView::newEvent(QDate dt) |
2531 | { | 2533 | { |
2532 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2534 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2533 | QDateTime(dt, QTime(0,0,0)), true); | 2535 | QDateTime(dt, QTime(0,0,0)), true); |
2534 | } | 2536 | } |
2535 | 2537 | ||
2536 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2538 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2537 | { | 2539 | { |
2538 | 2540 | ||
2539 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2541 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2540 | if ( mFilterView->filtersEnabled() ) { | 2542 | if ( mFilterView->filtersEnabled() ) { |
2541 | CalFilter *filter = mFilterView->selectedFilter(); | 2543 | CalFilter *filter = mFilterView->selectedFilter(); |
2542 | if (filter && filter->showCategories()) { | 2544 | if (filter && filter->showCategories()) { |
2543 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2545 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2544 | } | 2546 | } |
2545 | if ( filter ) | 2547 | if ( filter ) |
2546 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2548 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2547 | } | 2549 | } |
2548 | showEventEditor(); | 2550 | showEventEditor(); |
2549 | } | 2551 | } |
2550 | void CalendarView::todoAdded(Todo * t) | 2552 | void CalendarView::todoAdded(Todo * t) |
2551 | { | 2553 | { |
2552 | 2554 | ||
2553 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2555 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2554 | updateTodoViews(); | 2556 | updateTodoViews(); |
2555 | } | 2557 | } |
2556 | void CalendarView::todoChanged(Todo * t) | 2558 | void CalendarView::todoChanged(Todo * t) |
2557 | { | 2559 | { |
2558 | emit todoModified( t, 4 ); | 2560 | emit todoModified( t, 4 ); |
2559 | // updateTodoViews(); | 2561 | // updateTodoViews(); |
2560 | } | 2562 | } |
2561 | void CalendarView::todoToBeDeleted(Todo *) | 2563 | void CalendarView::todoToBeDeleted(Todo *) |
2562 | { | 2564 | { |
2563 | //qDebug("todoToBeDeleted(Todo *) "); | 2565 | //qDebug("todoToBeDeleted(Todo *) "); |
2564 | updateTodoViews(); | 2566 | updateTodoViews(); |
2565 | } | 2567 | } |
2566 | void CalendarView::todoDeleted() | 2568 | void CalendarView::todoDeleted() |
2567 | { | 2569 | { |
2568 | //qDebug(" todoDeleted()"); | 2570 | //qDebug(" todoDeleted()"); |
2569 | updateTodoViews(); | 2571 | updateTodoViews(); |
2570 | } | 2572 | } |
2571 | 2573 | ||
2572 | 2574 | ||
2573 | 2575 | ||
2574 | void CalendarView::newTodo() | 2576 | void CalendarView::newTodo() |
2575 | { | 2577 | { |
2576 | 2578 | ||
2577 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); | 2579 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); |
2578 | if ( mFilterView->filtersEnabled() ) { | 2580 | if ( mFilterView->filtersEnabled() ) { |
2579 | CalFilter *filter = mFilterView->selectedFilter(); | 2581 | CalFilter *filter = mFilterView->selectedFilter(); |
2580 | if (filter && filter->showCategories()) { | 2582 | if (filter && filter->showCategories()) { |
2581 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2583 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2582 | } | 2584 | } |
2583 | if ( filter ) | 2585 | if ( filter ) |
2584 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2586 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2585 | } | 2587 | } |
2586 | showTodoEditor(); | 2588 | showTodoEditor(); |
2587 | } | 2589 | } |
2588 | 2590 | ||
2589 | void CalendarView::newSubTodo() | 2591 | void CalendarView::newSubTodo() |
2590 | { | 2592 | { |
2591 | Todo *todo = selectedTodo(); | 2593 | Todo *todo = selectedTodo(); |
2592 | if ( todo ) newSubTodo( todo ); | 2594 | if ( todo ) newSubTodo( todo ); |
2593 | } | 2595 | } |
2594 | 2596 | ||
2595 | void CalendarView::newSubTodo(Todo *parentEvent) | 2597 | void CalendarView::newSubTodo(Todo *parentEvent) |
2596 | { | 2598 | { |
2597 | 2599 | ||
2598 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); | 2600 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); |
2599 | showTodoEditor(); | 2601 | showTodoEditor(); |
2600 | } | 2602 | } |
2601 | 2603 | ||
2602 | void CalendarView::newFloatingEvent() | 2604 | void CalendarView::newFloatingEvent() |
2603 | { | 2605 | { |
2604 | DateList tmpList = mNavigator->selectedDates(); | 2606 | DateList tmpList = mNavigator->selectedDates(); |
2605 | QDate date = tmpList.first(); | 2607 | QDate date = tmpList.first(); |
2606 | 2608 | ||
2607 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2609 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2608 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2610 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2609 | } | 2611 | } |
2610 | 2612 | ||
2611 | 2613 | ||
2612 | void CalendarView::editEvent( Event *event ) | 2614 | void CalendarView::editEvent( Event *event ) |
2613 | { | 2615 | { |
2614 | 2616 | ||
2615 | if ( !event ) return; | 2617 | if ( !event ) return; |
2616 | if ( event->isReadOnly() ) { | 2618 | if ( event->isReadOnly() ) { |
2617 | showEvent( event ); | 2619 | showEvent( event ); |
2618 | return; | 2620 | return; |
2619 | } | 2621 | } |
2620 | mEventEditor->editEvent( event , mFlagEditDescription); | 2622 | mEventEditor->editEvent( event , mFlagEditDescription); |
2621 | showEventEditor(); | 2623 | showEventEditor(); |
2622 | } | 2624 | } |
2623 | void CalendarView::editJournal( Journal *jour ) | 2625 | void CalendarView::editJournal( Journal *jour ) |
2624 | { | 2626 | { |
2625 | if ( !jour ) return; | 2627 | if ( !jour ) return; |
2626 | mDialogManager->hideSearchDialog(); | 2628 | mDialogManager->hideSearchDialog(); |
2627 | mViewManager->showJournalView(); | 2629 | mViewManager->showJournalView(); |
2628 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2630 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2629 | } | 2631 | } |
2630 | void CalendarView::editTodo( Todo *todo ) | 2632 | void CalendarView::editTodo( Todo *todo ) |
2631 | { | 2633 | { |
2632 | if ( !todo ) return; | 2634 | if ( !todo ) return; |
2633 | 2635 | ||
2634 | if ( todo->isReadOnly() ) { | 2636 | if ( todo->isReadOnly() ) { |
2635 | showTodo( todo ); | 2637 | showTodo( todo ); |
2636 | return; | 2638 | return; |
2637 | } | 2639 | } |
2638 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 2640 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
2639 | showTodoEditor(); | 2641 | showTodoEditor(); |
2640 | 2642 | ||
2641 | } | 2643 | } |
2642 | 2644 | ||
2643 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2645 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2644 | { | 2646 | { |
2645 | if ( !mEventViewerDialog ) { | 2647 | if ( !mEventViewerDialog ) { |
2646 | mEventViewerDialog = new KOEventViewerDialog(this); | 2648 | mEventViewerDialog = new KOEventViewerDialog(this); |
2647 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2649 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2648 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2650 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2649 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2651 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2650 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2652 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2651 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2653 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2652 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2654 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2653 | mEventViewerDialog->resize( 640, 480 ); | 2655 | mEventViewerDialog->resize( 640, 480 ); |
2654 | 2656 | ||
2655 | } | 2657 | } |
2656 | return mEventViewerDialog; | 2658 | return mEventViewerDialog; |
2657 | } | 2659 | } |
2658 | void CalendarView::showEvent(Event *event) | 2660 | void CalendarView::showEvent(Event *event) |
2659 | { | 2661 | { |
2660 | getEventViewerDialog()->setEvent(event); | 2662 | getEventViewerDialog()->setEvent(event); |
2661 | getEventViewerDialog()->showMe(); | 2663 | getEventViewerDialog()->showMe(); |
2662 | } | 2664 | } |
2663 | 2665 | ||
2664 | void CalendarView::showTodo(Todo *event) | 2666 | void CalendarView::showTodo(Todo *event) |
2665 | { | 2667 | { |
2666 | getEventViewerDialog()->setTodo(event); | 2668 | getEventViewerDialog()->setTodo(event); |
2667 | getEventViewerDialog()->showMe(); | 2669 | getEventViewerDialog()->showMe(); |
2668 | } | 2670 | } |
2669 | void CalendarView::showJournal( Journal *jour ) | 2671 | void CalendarView::showJournal( Journal *jour ) |
2670 | { | 2672 | { |
2671 | getEventViewerDialog()->setJournal(jour); | 2673 | getEventViewerDialog()->setJournal(jour); |
2672 | getEventViewerDialog()->showMe(); | 2674 | getEventViewerDialog()->showMe(); |
2673 | 2675 | ||
2674 | } | 2676 | } |
2675 | // void CalendarView::todoModified (Todo *event, int changed) | 2677 | // void CalendarView::todoModified (Todo *event, int changed) |
2676 | // { | 2678 | // { |
2677 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 2679 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
2678 | // // kdDebug() << "Todo modified and open" << endl; | 2680 | // // kdDebug() << "Todo modified and open" << endl; |
2679 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 2681 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
2680 | // // temp->modified (changed); | 2682 | // // temp->modified (changed); |
2681 | 2683 | ||
2682 | // // } | 2684 | // // } |
2683 | 2685 | ||
2684 | // mViewManager->updateView(); | 2686 | // mViewManager->updateView(); |
2685 | // } | 2687 | // } |
2686 | 2688 | ||
2687 | void CalendarView::appointment_show() | 2689 | void CalendarView::appointment_show() |
2688 | { | 2690 | { |
2689 | Event *anEvent = 0; | 2691 | Event *anEvent = 0; |
2690 | 2692 | ||
2691 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2693 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2692 | 2694 | ||
2693 | if (mViewManager->currentView()->isEventView()) { | 2695 | if (mViewManager->currentView()->isEventView()) { |
2694 | if ( incidence && incidence->type() == "Event" ) { | 2696 | if ( incidence && incidence->type() == "Event" ) { |
2695 | anEvent = static_cast<Event *>(incidence); | 2697 | anEvent = static_cast<Event *>(incidence); |
2696 | } | 2698 | } |
2697 | } | 2699 | } |
2698 | 2700 | ||
2699 | if (!anEvent) { | 2701 | if (!anEvent) { |
2700 | KNotifyClient::beep(); | 2702 | KNotifyClient::beep(); |
2701 | return; | 2703 | return; |
2702 | } | 2704 | } |
2703 | 2705 | ||
2704 | showEvent(anEvent); | 2706 | showEvent(anEvent); |
2705 | } | 2707 | } |
2706 | 2708 | ||
2707 | void CalendarView::appointment_edit() | 2709 | void CalendarView::appointment_edit() |
2708 | { | 2710 | { |
2709 | Event *anEvent = 0; | 2711 | Event *anEvent = 0; |
2710 | 2712 | ||
2711 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2713 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2712 | 2714 | ||
2713 | if (mViewManager->currentView()->isEventView()) { | 2715 | if (mViewManager->currentView()->isEventView()) { |
2714 | if ( incidence && incidence->type() == "Event" ) { | 2716 | if ( incidence && incidence->type() == "Event" ) { |
diff --git a/libkcal/event.cpp b/libkcal/event.cpp index dfa265b..7256f05 100644 --- a/libkcal/event.cpp +++ b/libkcal/event.cpp | |||
@@ -1,177 +1,223 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <kglobal.h> | 21 | #include <kglobal.h> |
22 | #include <klocale.h> | 22 | #include <klocale.h> |
23 | #include <kdebug.h> | 23 | #include <kdebug.h> |
24 | 24 | ||
25 | #include "event.h" | 25 | #include "event.h" |
26 | 26 | ||
27 | using namespace KCal; | 27 | using namespace KCal; |
28 | 28 | ||
29 | Event::Event() : | 29 | Event::Event() : |
30 | mHasEndDate( false ), mTransparency( Opaque ) | 30 | mHasEndDate( false ), mTransparency( Opaque ) |
31 | { | 31 | { |
32 | } | 32 | } |
33 | 33 | ||
34 | Event::Event(const Event &e) : Incidence(e) | 34 | Event::Event(const Event &e) : Incidence(e) |
35 | { | 35 | { |
36 | mDtEnd = e.mDtEnd; | 36 | mDtEnd = e.mDtEnd; |
37 | mHasEndDate = e.mHasEndDate; | 37 | mHasEndDate = e.mHasEndDate; |
38 | mTransparency = e.mTransparency; | 38 | mTransparency = e.mTransparency; |
39 | } | 39 | } |
40 | 40 | ||
41 | Event::~Event() | 41 | Event::~Event() |
42 | { | 42 | { |
43 | } | 43 | } |
44 | 44 | ||
45 | Incidence *Event::clone() | 45 | Incidence *Event::clone() |
46 | { | 46 | { |
47 | return new Event(*this); | 47 | return new Event(*this); |
48 | } | 48 | } |
49 | 49 | ||
50 | bool KCal::operator==( const Event& e1, const Event& e2 ) | 50 | bool KCal::operator==( const Event& e1, const Event& e2 ) |
51 | { | 51 | { |
52 | return operator==( (const Incidence&)e1, (const Incidence&)e2 ) && | 52 | return operator==( (const Incidence&)e1, (const Incidence&)e2 ) && |
53 | e1.dtEnd() == e2.dtEnd() && | 53 | e1.dtEnd() == e2.dtEnd() && |
54 | e1.hasEndDate() == e2.hasEndDate() && | 54 | e1.hasEndDate() == e2.hasEndDate() && |
55 | e1.transparency() == e2.transparency(); | 55 | e1.transparency() == e2.transparency(); |
56 | } | 56 | } |
57 | 57 | ||
58 | 58 | ||
59 | bool Event::contains ( Event* from ) | ||
60 | { | ||
61 | |||
62 | if ( !from->summary().isEmpty() ) | ||
63 | if ( !summary().startsWith( from->summary() )) | ||
64 | return false; | ||
65 | if ( from->dtStart().isValid() ) | ||
66 | if (dtStart() != from->dtStart() ) | ||
67 | return false; | ||
68 | if ( from->dtEnd().isValid() ) | ||
69 | if ( dtEnd() != from->dtEnd() ) | ||
70 | return false; | ||
71 | if ( !from->location().isEmpty() ) | ||
72 | if ( !location().startsWith( from->location() ) ) | ||
73 | return false; | ||
74 | if ( !from->description().isEmpty() ) | ||
75 | if ( !description().startsWith( from->description() )) | ||
76 | return false; | ||
77 | if ( from->alarms().count() ) { | ||
78 | Alarm *a = from->alarms().first(); | ||
79 | if ( a->enabled() ){ | ||
80 | if ( !alarms().count() ) | ||
81 | return false; | ||
82 | Alarm *b = alarms().first(); | ||
83 | if( ! b->enabled() ) | ||
84 | return false; | ||
85 | if ( ! (a->offset() == b->offset() )) | ||
86 | return false; | ||
87 | } | ||
88 | } | ||
89 | QStringList cat = categories(); | ||
90 | QStringList catFrom = from->categories(); | ||
91 | QString nCat; | ||
92 | int iii; | ||
93 | for ( iii = 0; iii < catFrom.count();++iii ) { | ||
94 | nCat = catFrom[iii]; | ||
95 | if ( !nCat.isEmpty() ) | ||
96 | if ( !cat.contains( nCat )) { | ||
97 | return false; | ||
98 | } | ||
99 | } | ||
100 | if ( from->doesRecur() ) | ||
101 | if ( from->doesRecur() != doesRecur() && ! (from->doesRecur()== Recurrence::rYearlyMonth && doesRecur()== Recurrence::rYearlyDay) ) | ||
102 | return false; | ||
103 | return true; | ||
104 | } | ||
59 | 105 | ||
60 | void Event::setDtEnd(const QDateTime &dtEnd) | 106 | void Event::setDtEnd(const QDateTime &dtEnd) |
61 | { | 107 | { |
62 | if (mReadOnly) return; | 108 | if (mReadOnly) return; |
63 | 109 | ||
64 | mDtEnd = getEvenTime( dtEnd ); | 110 | mDtEnd = getEvenTime( dtEnd ); |
65 | 111 | ||
66 | setHasEndDate(true); | 112 | setHasEndDate(true); |
67 | setHasDuration(false); | 113 | setHasDuration(false); |
68 | 114 | ||
69 | updated(); | 115 | updated(); |
70 | } | 116 | } |
71 | 117 | ||
72 | QDateTime Event::dtEnd() const | 118 | QDateTime Event::dtEnd() const |
73 | { | 119 | { |
74 | if (hasEndDate()) return mDtEnd; | 120 | if (hasEndDate()) return mDtEnd; |
75 | if (hasDuration()) return dtStart().addSecs(duration()); | 121 | if (hasDuration()) return dtStart().addSecs(duration()); |
76 | 122 | ||
77 | kdDebug(5800) << "Warning! Event '" << summary() | 123 | kdDebug(5800) << "Warning! Event '" << summary() |
78 | << "' does have neither end date nor duration." << endl; | 124 | << "' does have neither end date nor duration." << endl; |
79 | return dtStart(); | 125 | return dtStart(); |
80 | } | 126 | } |
81 | 127 | ||
82 | QString Event::dtEndTimeStr() const | 128 | QString Event::dtEndTimeStr() const |
83 | { | 129 | { |
84 | return KGlobal::locale()->formatTime(mDtEnd.time()); | 130 | return KGlobal::locale()->formatTime(mDtEnd.time()); |
85 | } | 131 | } |
86 | 132 | ||
87 | QString Event::dtEndDateStr(bool shortfmt) const | 133 | QString Event::dtEndDateStr(bool shortfmt) const |
88 | { | 134 | { |
89 | return KGlobal::locale()->formatDate(mDtEnd.date(),shortfmt); | 135 | return KGlobal::locale()->formatDate(mDtEnd.date(),shortfmt); |
90 | } | 136 | } |
91 | 137 | ||
92 | QString Event::dtEndStr(bool shortfmt) const | 138 | QString Event::dtEndStr(bool shortfmt) const |
93 | { | 139 | { |
94 | return KGlobal::locale()->formatDateTime(mDtEnd, shortfmt); | 140 | return KGlobal::locale()->formatDateTime(mDtEnd, shortfmt); |
95 | } | 141 | } |
96 | 142 | ||
97 | void Event::setHasEndDate(bool b) | 143 | void Event::setHasEndDate(bool b) |
98 | { | 144 | { |
99 | mHasEndDate = b; | 145 | mHasEndDate = b; |
100 | } | 146 | } |
101 | 147 | ||
102 | bool Event::hasEndDate() const | 148 | bool Event::hasEndDate() const |
103 | { | 149 | { |
104 | return mHasEndDate; | 150 | return mHasEndDate; |
105 | } | 151 | } |
106 | 152 | ||
107 | bool Event::isMultiDay() const | 153 | bool Event::isMultiDay() const |
108 | { | 154 | { |
109 | bool multi = !(dtStart().date() == dtEnd().date()); | 155 | bool multi = !(dtStart().date() == dtEnd().date()); |
110 | return multi; | 156 | return multi; |
111 | } | 157 | } |
112 | 158 | ||
113 | void Event::setTransparency(Event::Transparency transparency) | 159 | void Event::setTransparency(Event::Transparency transparency) |
114 | { | 160 | { |
115 | if (mReadOnly) return; | 161 | if (mReadOnly) return; |
116 | mTransparency = transparency; | 162 | mTransparency = transparency; |
117 | updated(); | 163 | updated(); |
118 | } | 164 | } |
119 | 165 | ||
120 | Event::Transparency Event::transparency() const | 166 | Event::Transparency Event::transparency() const |
121 | { | 167 | { |
122 | return mTransparency; | 168 | return mTransparency; |
123 | } | 169 | } |
124 | 170 | ||
125 | void Event::setDuration(int seconds) | 171 | void Event::setDuration(int seconds) |
126 | { | 172 | { |
127 | setHasEndDate(false); | 173 | setHasEndDate(false); |
128 | Incidence::setDuration(seconds); | 174 | Incidence::setDuration(seconds); |
129 | } | 175 | } |
130 | QDateTime Event::getNextAlarmDateTime( bool * ok, int * offset ) const | 176 | QDateTime Event::getNextAlarmDateTime( bool * ok, int * offset ) const |
131 | { | 177 | { |
132 | 178 | ||
133 | bool yes; | 179 | bool yes; |
134 | QDateTime incidenceStart = getNextOccurence( QDateTime::currentDateTime(), &yes ); | 180 | QDateTime incidenceStart = getNextOccurence( QDateTime::currentDateTime(), &yes ); |
135 | if ( ! yes || cancelled() ) { | 181 | if ( ! yes || cancelled() ) { |
136 | *ok = false; | 182 | *ok = false; |
137 | return QDateTime (); | 183 | return QDateTime (); |
138 | } | 184 | } |
139 | 185 | ||
140 | bool enabled = false; | 186 | bool enabled = false; |
141 | Alarm* alarm; | 187 | Alarm* alarm; |
142 | int off; | 188 | int off; |
143 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; | 189 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; |
144 | // if ( QDateTime::currentDateTime() > incidenceStart ){ | 190 | // if ( QDateTime::currentDateTime() > incidenceStart ){ |
145 | // *ok = false; | 191 | // *ok = false; |
146 | // return incidenceStart; | 192 | // return incidenceStart; |
147 | // } | 193 | // } |
148 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 194 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
149 | if (alarm->enabled()) { | 195 | if (alarm->enabled()) { |
150 | if ( alarm->hasTime () ) { | 196 | if ( alarm->hasTime () ) { |
151 | if ( alarm->time() < alarmStart ) { | 197 | if ( alarm->time() < alarmStart ) { |
152 | alarmStart = alarm->time(); | 198 | alarmStart = alarm->time(); |
153 | enabled = true; | 199 | enabled = true; |
154 | off = alarmStart.secsTo( incidenceStart ); | 200 | off = alarmStart.secsTo( incidenceStart ); |
155 | } | 201 | } |
156 | 202 | ||
157 | } else { | 203 | } else { |
158 | int secs = alarm->startOffset().asSeconds(); | 204 | int secs = alarm->startOffset().asSeconds(); |
159 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { | 205 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { |
160 | alarmStart = incidenceStart.addSecs( secs ); | 206 | alarmStart = incidenceStart.addSecs( secs ); |
161 | enabled = true; | 207 | enabled = true; |
162 | off = -secs; | 208 | off = -secs; |
163 | } | 209 | } |
164 | } | 210 | } |
165 | } | 211 | } |
166 | } | 212 | } |
167 | if ( enabled ) { | 213 | if ( enabled ) { |
168 | if ( alarmStart > QDateTime::currentDateTime() ) { | 214 | if ( alarmStart > QDateTime::currentDateTime() ) { |
169 | *ok = true; | 215 | *ok = true; |
170 | * offset = off; | 216 | * offset = off; |
171 | return alarmStart; | 217 | return alarmStart; |
172 | } | 218 | } |
173 | } | 219 | } |
174 | *ok = false; | 220 | *ok = false; |
175 | return QDateTime (); | 221 | return QDateTime (); |
176 | 222 | ||
177 | } | 223 | } |
diff --git a/libkcal/event.h b/libkcal/event.h index 2a8bd95..3bc8adc 100644 --- a/libkcal/event.h +++ b/libkcal/event.h | |||
@@ -1,88 +1,90 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #ifndef EVENT_H | 21 | #ifndef EVENT_H |
22 | #define EVENT_H | 22 | #define EVENT_H |
23 | // | 23 | // |
24 | // Event component, representing a VEVENT object | 24 | // Event component, representing a VEVENT object |
25 | // | 25 | // |
26 | 26 | ||
27 | #include "incidence.h" | 27 | #include "incidence.h" |
28 | namespace KCal { | 28 | namespace KCal { |
29 | 29 | ||
30 | /** | 30 | /** |
31 | This class provides an Event in the sense of RFC2445. | 31 | This class provides an Event in the sense of RFC2445. |
32 | */ | 32 | */ |
33 | class Event : public Incidence | 33 | class Event : public Incidence |
34 | { | 34 | { |
35 | public: | 35 | public: |
36 | enum Transparency { Opaque, Transparent }; | 36 | enum Transparency { Opaque, Transparent }; |
37 | typedef ListBase<Event> List; | 37 | typedef ListBase<Event> List; |
38 | Event(); | 38 | Event(); |
39 | Event(const Event &); | 39 | Event(const Event &); |
40 | ~Event(); | 40 | ~Event(); |
41 | 41 | ||
42 | QCString type() const { return "Event"; } | 42 | QCString type() const { return "Event"; } |
43 | 43 | ||
44 | Incidence *clone(); | 44 | Incidence *clone(); |
45 | QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const; | 45 | QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const; |
46 | 46 | ||
47 | /** for setting an event's ending date/time with a QDateTime. */ | 47 | /** for setting an event's ending date/time with a QDateTime. */ |
48 | void setDtEnd(const QDateTime &dtEnd); | 48 | void setDtEnd(const QDateTime &dtEnd); |
49 | /** Return the event's ending date/time as a QDateTime. */ | 49 | /** Return the event's ending date/time as a QDateTime. */ |
50 | virtual QDateTime dtEnd() const; | 50 | virtual QDateTime dtEnd() const; |
51 | /** returns an event's end time as a string formatted according to the | 51 | /** returns an event's end time as a string formatted according to the |
52 | users locale settings */ | 52 | users locale settings */ |
53 | QString dtEndTimeStr() const; | 53 | QString dtEndTimeStr() const; |
54 | /** returns an event's end date as a string formatted according to the | 54 | /** returns an event's end date as a string formatted according to the |
55 | users locale settings */ | 55 | users locale settings */ |
56 | QString dtEndDateStr(bool shortfmt=true) const; | 56 | QString dtEndDateStr(bool shortfmt=true) const; |
57 | /** returns an event's end date and time as a string formatted according | 57 | /** returns an event's end date and time as a string formatted according |
58 | to the users locale settings */ | 58 | to the users locale settings */ |
59 | QString dtEndStr(bool shortfmt=true) const; | 59 | QString dtEndStr(bool shortfmt=true) const; |
60 | void setHasEndDate(bool); | 60 | void setHasEndDate(bool); |
61 | /** Return whether the event has an end date/time. */ | 61 | /** Return whether the event has an end date/time. */ |
62 | bool hasEndDate() const; | 62 | bool hasEndDate() const; |
63 | 63 | ||
64 | /** Return true if the event spans multiple days, otherwise return false. */ | 64 | /** Return true if the event spans multiple days, otherwise return false. */ |
65 | bool isMultiDay() const; | 65 | bool isMultiDay() const; |
66 | 66 | ||
67 | /** set the event's time transparency level. */ | 67 | /** set the event's time transparency level. */ |
68 | void setTransparency(Transparency transparency); | 68 | void setTransparency(Transparency transparency); |
69 | /** get the event's time transparency level. */ | 69 | /** get the event's time transparency level. */ |
70 | Transparency transparency() const; | 70 | Transparency transparency() const; |
71 | 71 | ||
72 | void setDuration(int seconds); | 72 | void setDuration(int seconds); |
73 | 73 | ||
74 | bool contains ( Event*); | ||
75 | |||
74 | private: | 76 | private: |
75 | bool accept(Visitor &v) { return v.visit(this); } | 77 | bool accept(Visitor &v) { return v.visit(this); } |
76 | 78 | ||
77 | QDateTime mDtEnd; | 79 | QDateTime mDtEnd; |
78 | bool mHasEndDate; | 80 | bool mHasEndDate; |
79 | Transparency mTransparency; | 81 | Transparency mTransparency; |
80 | }; | 82 | }; |
81 | 83 | ||
82 | bool operator==( const Event&, const Event& ); | 84 | bool operator==( const Event&, const Event& ); |
83 | 85 | ||
84 | 86 | ||
85 | } | 87 | } |
86 | 88 | ||
87 | 89 | ||
88 | #endif | 90 | #endif |
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index 281434e..101db57 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp | |||
@@ -1,634 +1,620 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | 3 | ||
4 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> | 4 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <qdatetime.h> | 22 | #include <qdatetime.h> |
23 | #include <qstring.h> | 23 | #include <qstring.h> |
24 | #include <qapplication.h> | 24 | #include <qapplication.h> |
25 | #include <qptrlist.h> | 25 | #include <qptrlist.h> |
26 | #include <qregexp.h> | 26 | #include <qregexp.h> |
27 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
28 | #include <qclipboard.h> | 28 | #include <qclipboard.h> |
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | #include <qtextstream.h> | 30 | #include <qtextstream.h> |
31 | #include <qtextcodec.h> | 31 | #include <qtextcodec.h> |
32 | #include <qdir.h> | 32 | #include <qdir.h> |
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | 34 | ||
35 | #include <kdebug.h> | 35 | #include <kdebug.h> |
36 | #include <klocale.h> | 36 | #include <klocale.h> |
37 | #include <kglobal.h> | 37 | #include <kglobal.h> |
38 | #include <kmessagebox.h> | 38 | #include <kmessagebox.h> |
39 | #include <phoneaccess.h> | 39 | #include <phoneaccess.h> |
40 | 40 | ||
41 | #include "calendar.h" | 41 | #include "calendar.h" |
42 | #include "alarm.h" | 42 | #include "alarm.h" |
43 | #include "recurrence.h" | 43 | #include "recurrence.h" |
44 | #include "calendarlocal.h" | 44 | #include "calendarlocal.h" |
45 | 45 | ||
46 | #include "phoneformat.h" | 46 | #include "phoneformat.h" |
47 | #include "syncdefines.h" | 47 | #include "syncdefines.h" |
48 | 48 | ||
49 | using namespace KCal; | 49 | using namespace KCal; |
50 | class PhoneParser : public QObject | 50 | class PhoneParser : public QObject |
51 | { | 51 | { |
52 | public: | 52 | public: |
53 | PhoneParser( ) { | 53 | PhoneParser( ) { |
54 | ; | 54 | ; |
55 | } | 55 | } |
56 | 56 | ||
57 | static QString dtToString( const QDateTime& dti, bool useTZ = false ) | 57 | static QString dtToString( const QDateTime& dti, bool useTZ = false ) |
58 | { | 58 | { |
59 | QString datestr; | 59 | QString datestr; |
60 | QString timestr; | 60 | QString timestr; |
61 | int offset = KGlobal::locale()->localTimeOffset( dti ); | 61 | int offset = KGlobal::locale()->localTimeOffset( dti ); |
62 | QDateTime dt; | 62 | QDateTime dt; |
63 | if (useTZ) | 63 | if (useTZ) |
64 | dt = dti.addSecs ( -(offset*60)); | 64 | dt = dti.addSecs ( -(offset*60)); |
65 | else | 65 | else |
66 | dt = dti; | 66 | dt = dti; |
67 | if(dt.date().isValid()){ | 67 | if(dt.date().isValid()){ |
68 | const QDate& date = dt.date(); | 68 | const QDate& date = dt.date(); |
69 | datestr.sprintf("%04d%02d%02d", | 69 | datestr.sprintf("%04d%02d%02d", |
70 | date.year(), date.month(), date.day()); | 70 | date.year(), date.month(), date.day()); |
71 | } | 71 | } |
72 | if(dt.time().isValid()){ | 72 | if(dt.time().isValid()){ |
73 | const QTime& time = dt.time(); | 73 | const QTime& time = dt.time(); |
74 | timestr.sprintf("T%02d%02d%02d", | 74 | timestr.sprintf("T%02d%02d%02d", |
75 | time.hour(), time.minute(), time.second()); | 75 | time.hour(), time.minute(), time.second()); |
76 | } | 76 | } |
77 | return datestr + timestr; | 77 | return datestr + timestr; |
78 | } | 78 | } |
79 | 79 | ||
80 | 80 | ||
81 | }; | 81 | }; |
82 | 82 | ||
83 | 83 | ||
84 | 84 | ||
85 | PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model ) | 85 | PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model ) |
86 | { | 86 | { |
87 | mProfileName = profileName; | 87 | mProfileName = profileName; |
88 | PhoneAccess::writeConfig( device, connection, model ); | 88 | PhoneAccess::writeConfig( device, connection, model ); |
89 | } | 89 | } |
90 | 90 | ||
91 | PhoneFormat::~PhoneFormat() | 91 | PhoneFormat::~PhoneFormat() |
92 | { | 92 | { |
93 | } | 93 | } |
94 | 94 | ||
95 | #if 0 | 95 | #if 0 |
96 | int PhoneFormat::initDevice(GSM_StateMachine *s) | 96 | int PhoneFormat::initDevice(GSM_StateMachine *s) |
97 | { | 97 | { |
98 | GSM_ReadConfig(NULL, &s->Config[0], 0); | 98 | GSM_ReadConfig(NULL, &s->Config[0], 0); |
99 | s->ConfigNum = 1; | 99 | s->ConfigNum = 1; |
100 | GSM_Config *cfg = &s->Config[0]; | 100 | GSM_Config *cfg = &s->Config[0]; |
101 | if ( ! mConnection.isEmpty() ) { | 101 | if ( ! mConnection.isEmpty() ) { |
102 | cfg->Connection = strdup(mConnection.latin1()); | 102 | cfg->Connection = strdup(mConnection.latin1()); |
103 | cfg->DefaultConnection = false; | 103 | cfg->DefaultConnection = false; |
104 | qDebug("Connection set %s ", cfg->Connection ); | 104 | qDebug("Connection set %s ", cfg->Connection ); |
105 | 105 | ||
106 | } | 106 | } |
107 | if ( ! mDevice.isEmpty() ) { | 107 | if ( ! mDevice.isEmpty() ) { |
108 | cfg->Device = strdup(mDevice.latin1()); | 108 | cfg->Device = strdup(mDevice.latin1()); |
109 | cfg->DefaultDevice = false; | 109 | cfg->DefaultDevice = false; |
110 | qDebug("Device set %s ", cfg->Device); | 110 | qDebug("Device set %s ", cfg->Device); |
111 | 111 | ||
112 | } | 112 | } |
113 | if ( ! mModel.isEmpty() ) { | 113 | if ( ! mModel.isEmpty() ) { |
114 | strcpy(cfg->Model,mModel.latin1() ); | 114 | strcpy(cfg->Model,mModel.latin1() ); |
115 | cfg->DefaultModel = false; | 115 | cfg->DefaultModel = false; |
116 | qDebug("Model set %s ",cfg->Model ); | 116 | qDebug("Model set %s ",cfg->Model ); |
117 | } | 117 | } |
118 | int error=GSM_InitConnection(s,3); | 118 | int error=GSM_InitConnection(s,3); |
119 | return error; | 119 | return error; |
120 | } | 120 | } |
121 | #endif | 121 | #endif |
122 | ulong PhoneFormat::getCsumTodo( Todo* todo ) | 122 | ulong PhoneFormat::getCsumTodo( Todo* todo ) |
123 | { | 123 | { |
124 | QStringList attList; | 124 | QStringList attList; |
125 | if ( todo->hasDueDate() ) | 125 | if ( todo->hasDueDate() ) |
126 | attList << PhoneParser::dtToString ( todo->dtDue() ); | 126 | attList << PhoneParser::dtToString ( todo->dtDue() ); |
127 | attList << todo->summary(); | 127 | attList << todo->summary(); |
128 | QString completedString = "no"; | 128 | QString completedString = "no"; |
129 | if ( todo->isCompleted() ) | 129 | if ( todo->isCompleted() ) |
130 | completedString = "yes"; | 130 | completedString = "yes"; |
131 | attList << completedString; | 131 | attList << completedString; |
132 | int prio = todo->priority(); | 132 | int prio = todo->priority(); |
133 | if( prio == 2 ) prio = 1; | 133 | if( prio == 2 ) prio = 1; |
134 | if (prio == 4 ) prio = 5 ; | 134 | if (prio == 4 ) prio = 5 ; |
135 | attList << QString::number( prio ); | 135 | attList << QString::number( prio ); |
136 | QString alarmString = "na"; | 136 | QString alarmString = "na"; |
137 | Alarm *alarm; | 137 | Alarm *alarm; |
138 | if ( todo->alarms().count() > 0 ) { | 138 | if ( todo->alarms().count() > 0 ) { |
139 | alarm = todo->alarms().first(); | 139 | alarm = todo->alarms().first(); |
140 | if ( alarm->enabled() ) { | 140 | if ( alarm->enabled() ) { |
141 | alarmString = QString::number(alarm->offset() ); | 141 | alarmString = QString::number(alarm->offset() ); |
142 | } | 142 | } |
143 | } | 143 | } |
144 | attList << alarmString; | 144 | attList << alarmString; |
145 | attList << todo->categoriesStr(); | 145 | attList << todo->categoriesStr(); |
146 | attList << todo->secrecyStr(); | 146 | attList << todo->secrecyStr(); |
147 | return PhoneFormat::getCsum(attList ); | 147 | return PhoneFormat::getCsum(attList ); |
148 | 148 | ||
149 | } | 149 | } |
150 | ulong PhoneFormat::getCsumEvent( Event* event ) | 150 | ulong PhoneFormat::getCsumEvent( Event* event ) |
151 | { | 151 | { |
152 | QStringList attList; | 152 | QStringList attList; |
153 | attList << PhoneParser::dtToString ( event->dtStart() ); | 153 | attList << PhoneParser::dtToString ( event->dtStart() ); |
154 | attList << PhoneParser::dtToString ( event->dtEnd() ); | 154 | attList << PhoneParser::dtToString ( event->dtEnd() ); |
155 | attList << event->summary(); | 155 | attList << event->summary(); |
156 | attList << event->location(); | 156 | attList << event->location(); |
157 | QString alarmString = "na"; | 157 | QString alarmString = "na"; |
158 | Alarm *alarm; | 158 | Alarm *alarm; |
159 | if ( event->alarms().count() > 0 ) { | 159 | if ( event->alarms().count() > 0 ) { |
160 | alarm = event->alarms().first(); | 160 | alarm = event->alarms().first(); |
161 | if ( alarm->enabled() ) { | 161 | if ( alarm->enabled() ) { |
162 | alarmString = QString::number( alarm->offset() ); | 162 | alarmString = QString::number( alarm->offset() ); |
163 | } | 163 | } |
164 | } | 164 | } |
165 | attList << alarmString; | 165 | attList << alarmString; |
166 | Recurrence* rec = event->recurrence(); | 166 | Recurrence* rec = event->recurrence(); |
167 | QStringList list; | 167 | QStringList list; |
168 | bool writeEndDate = false; | 168 | bool writeEndDate = false; |
169 | switch ( rec->doesRecur() ) | 169 | switch ( rec->doesRecur() ) |
170 | { | 170 | { |
171 | case Recurrence::rDaily: // 0 | 171 | case Recurrence::rDaily: // 0 |
172 | list.append( "0" ); | 172 | list.append( "0" ); |
173 | list.append( QString::number( rec->frequency() ));//12 | 173 | list.append( QString::number( rec->frequency() ));//12 |
174 | list.append( "0" ); | 174 | list.append( "0" ); |
175 | list.append( "0" ); | 175 | list.append( "0" ); |
176 | writeEndDate = true; | 176 | writeEndDate = true; |
177 | break; | 177 | break; |
178 | case Recurrence::rWeekly:// 1 | 178 | case Recurrence::rWeekly:// 1 |
179 | list.append( "1" ); | 179 | list.append( "1" ); |
180 | list.append( QString::number( rec->frequency()) );//12 | 180 | list.append( QString::number( rec->frequency()) );//12 |
181 | list.append( "0" ); | 181 | list.append( "0" ); |
182 | { | 182 | { |
183 | int days = 0; | 183 | int days = 0; |
184 | QBitArray weekDays = rec->days(); | 184 | QBitArray weekDays = rec->days(); |
185 | int i; | 185 | int i; |
186 | for( i = 1; i <= 7; ++i ) { | 186 | for( i = 1; i <= 7; ++i ) { |
187 | if ( weekDays[i-1] ) { | 187 | if ( weekDays[i-1] ) { |
188 | days += 1 << (i-1); | 188 | days += 1 << (i-1); |
189 | } | 189 | } |
190 | } | 190 | } |
191 | list.append( QString::number( days ) ); | 191 | list.append( QString::number( days ) ); |
192 | } | 192 | } |
193 | //pending weekdays | 193 | //pending weekdays |
194 | writeEndDate = true; | 194 | writeEndDate = true; |
195 | 195 | ||
196 | break; | 196 | break; |
197 | case Recurrence::rMonthlyPos:// 2 | 197 | case Recurrence::rMonthlyPos:// 2 |
198 | list.append( "2" ); | 198 | list.append( "2" ); |
199 | list.append( QString::number( rec->frequency()) );//12 | 199 | list.append( QString::number( rec->frequency()) );//12 |
200 | 200 | ||
201 | writeEndDate = true; | 201 | writeEndDate = true; |
202 | { | 202 | { |
203 | int count = 1; | 203 | int count = 1; |
204 | QPtrList<Recurrence::rMonthPos> rmp; | 204 | QPtrList<Recurrence::rMonthPos> rmp; |
205 | rmp = rec->monthPositions(); | 205 | rmp = rec->monthPositions(); |
206 | if ( rmp.first()->negative ) | 206 | if ( rmp.first()->negative ) |
207 | count = 5 - rmp.first()->rPos - 1; | 207 | count = 5 - rmp.first()->rPos - 1; |
208 | else | 208 | else |
209 | count = rmp.first()->rPos - 1; | 209 | count = rmp.first()->rPos - 1; |
210 | list.append( QString::number( count ) ); | 210 | list.append( QString::number( count ) ); |
211 | 211 | ||
212 | } | 212 | } |
213 | 213 | ||
214 | list.append( "0" ); | 214 | list.append( "0" ); |
215 | break; | 215 | break; |
216 | case Recurrence::rMonthlyDay:// 3 | 216 | case Recurrence::rMonthlyDay:// 3 |
217 | list.append( "3" ); | 217 | list.append( "3" ); |
218 | list.append( QString::number( rec->frequency()) );//12 | 218 | list.append( QString::number( rec->frequency()) );//12 |
219 | list.append( "0" ); | 219 | list.append( "0" ); |
220 | list.append( "0" ); | 220 | list.append( "0" ); |
221 | writeEndDate = true; | 221 | writeEndDate = true; |
222 | break; | 222 | break; |
223 | case Recurrence::rYearlyMonth://4 | 223 | case Recurrence::rYearlyMonth://4 |
224 | list.append( "4" ); | 224 | list.append( "4" ); |
225 | list.append( QString::number( rec->frequency()) );//12 | 225 | list.append( QString::number( rec->frequency()) );//12 |
226 | list.append( "0" ); | 226 | list.append( "0" ); |
227 | list.append( "0" ); | 227 | list.append( "0" ); |
228 | writeEndDate = true; | 228 | writeEndDate = true; |
229 | break; | 229 | break; |
230 | 230 | ||
231 | default: | 231 | default: |
232 | list.append( "255" ); | 232 | list.append( "255" ); |
233 | list.append( QString() ); | 233 | list.append( QString() ); |
234 | list.append( "0" ); | 234 | list.append( "0" ); |
235 | list.append( QString() ); | 235 | list.append( QString() ); |
236 | list.append( "0" ); | 236 | list.append( "0" ); |
237 | list.append( "20991231T000000" ); | 237 | list.append( "20991231T000000" ); |
238 | break; | 238 | break; |
239 | } | 239 | } |
240 | if ( writeEndDate ) { | 240 | if ( writeEndDate ) { |
241 | 241 | ||
242 | if ( rec->endDate().isValid() ) { // 15 + 16 | 242 | if ( rec->endDate().isValid() ) { // 15 + 16 |
243 | list.append( "1" ); | 243 | list.append( "1" ); |
244 | list.append( PhoneParser::dtToString( rec->endDate()) ); | 244 | list.append( PhoneParser::dtToString( rec->endDate()) ); |
245 | } else { | 245 | } else { |
246 | list.append( "0" ); | 246 | list.append( "0" ); |
247 | list.append( "20991231T000000" ); | 247 | list.append( "20991231T000000" ); |
248 | } | 248 | } |
249 | 249 | ||
250 | } | 250 | } |
251 | attList << list.join(""); | 251 | attList << list.join(""); |
252 | attList << event->categoriesStr(); | 252 | attList << event->categoriesStr(); |
253 | //qDebug("csum cat %s", event->categoriesStr().latin1()); | 253 | //qDebug("csum cat %s", event->categoriesStr().latin1()); |
254 | 254 | ||
255 | attList << event->secrecyStr(); | 255 | attList << event->secrecyStr(); |
256 | return PhoneFormat::getCsum(attList ); | 256 | return PhoneFormat::getCsum(attList ); |
257 | } | 257 | } |
258 | ulong PhoneFormat::getCsum( const QStringList & attList) | 258 | ulong PhoneFormat::getCsum( const QStringList & attList) |
259 | { | 259 | { |
260 | int max = attList.count(); | 260 | int max = attList.count(); |
261 | ulong cSum = 0; | 261 | ulong cSum = 0; |
262 | int j,k,i; | 262 | int j,k,i; |
263 | int add; | 263 | int add; |
264 | for ( i = 0; i < max ; ++i ) { | 264 | for ( i = 0; i < max ; ++i ) { |
265 | QString s = attList[i]; | 265 | QString s = attList[i]; |
266 | if ( ! s.isEmpty() ){ | 266 | if ( ! s.isEmpty() ){ |
267 | j = s.length(); | 267 | j = s.length(); |
268 | for ( k = 0; k < j; ++k ) { | 268 | for ( k = 0; k < j; ++k ) { |
269 | int mul = k +1; | 269 | int mul = k +1; |
270 | add = s[k].unicode (); | 270 | add = s[k].unicode (); |
271 | if ( k < 16 ) | 271 | if ( k < 16 ) |
272 | mul = mul * mul; | 272 | mul = mul * mul; |
273 | int ii = i+1; | 273 | int ii = i+1; |
274 | add = add * mul *ii*ii*ii; | 274 | add = add * mul *ii*ii*ii; |
275 | cSum += add; | 275 | cSum += add; |
276 | } | 276 | } |
277 | } | 277 | } |
278 | 278 | ||
279 | } | 279 | } |
280 | //QString dump = attList.join(","); | 280 | //QString dump = attList.join(","); |
281 | //qDebug("csum: %d %s", cSum,dump.latin1()); | 281 | //qDebug("csum: %d %s", cSum,dump.latin1()); |
282 | 282 | ||
283 | return cSum; | 283 | return cSum; |
284 | 284 | ||
285 | } | 285 | } |
286 | //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); | 286 | //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); |
287 | #include <stdlib.h> | 287 | #include <stdlib.h> |
288 | #define DEBUGMODE false | 288 | #define DEBUGMODE false |
289 | bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) | 289 | bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) |
290 | { | 290 | { |
291 | 291 | ||
292 | QString fileName; | 292 | QString fileName; |
293 | #ifdef _WIN32_ | 293 | #ifdef _WIN32_ |
294 | fileName = locateLocal("tmp", "phonefile.vcs"); | 294 | fileName = locateLocal("tmp", "phonefile.vcs"); |
295 | #else | 295 | #else |
296 | fileName = "/tmp/phonefile.vcs"; | 296 | fileName = "/tmp/phonefile.vcs"; |
297 | #endif | 297 | #endif |
298 | QString command; | 298 | QString command; |
299 | if ( ! PhoneAccess::readFromPhone( fileName )) { | 299 | if ( ! PhoneAccess::readFromPhone( fileName )) { |
300 | return false; | 300 | return false; |
301 | } | 301 | } |
302 | VCalFormat vfload; | 302 | VCalFormat vfload; |
303 | vfload.setLocalTime ( true ); | 303 | vfload.setLocalTime ( true ); |
304 | qDebug("loading file ..."); | 304 | qDebug("loading file ..."); |
305 | 305 | ||
306 | if ( ! vfload.load( calendar, fileName ) ) | 306 | if ( ! vfload.load( calendar, fileName ) ) |
307 | return false; | 307 | return false; |
308 | QPtrList<Event> er = calendar->rawEvents(); | 308 | QPtrList<Event> er = calendar->rawEvents(); |
309 | Event* ev = er.first(); | 309 | Event* ev = er.first(); |
310 | qDebug("reading events... "); | 310 | qDebug("reading events... "); |
311 | while ( ev ) { | 311 | while ( ev ) { |
312 | QStringList cat = ev->categories(); | 312 | QStringList cat = ev->categories(); |
313 | if ( cat.contains( "MeetingDEF" )) { | 313 | if ( cat.contains( "MeetingDEF" )) { |
314 | ev->setCategories( QStringList() ); | 314 | ev->setCategories( QStringList() ); |
315 | } else | ||
316 | if ( cat.contains( "Birthday" )) { | ||
317 | ev->setFloats( true ); | ||
318 | QDate da = ev->dtStart().date(); | ||
319 | ev->setDtStart( QDateTime( da) ); | ||
320 | ev->setDtEnd( QDateTime( da.addDays(1)) ); | ||
321 | |||
315 | } | 322 | } |
323 | uint cSum; | ||
324 | cSum = PhoneFormat::getCsumEvent( ev ); | ||
316 | int id = ev->pilotId(); | 325 | int id = ev->pilotId(); |
317 | Event *event; | 326 | Event *event; |
318 | event = existingCal->event( mProfileName ,QString::number( id ) ); | 327 | event = existingCal->event( mProfileName ,QString::number( id ) ); |
319 | if ( event ) { | 328 | if ( event ) { |
320 | event = (Event*)event->clone(); | 329 | event = (Event*)event->clone(); |
321 | copyEvent( event, ev ); | 330 | copyEvent( event, ev ); |
322 | calendar->deleteEvent( ev ); | 331 | calendar->deleteEvent( ev ); |
323 | calendar->addEvent( event); | 332 | calendar->addEvent( event); |
324 | } | 333 | } |
325 | else | 334 | else |
326 | event = ev; | 335 | event = ev; |
327 | uint cSum; | ||
328 | cSum = PhoneFormat::getCsumEvent( event ); | ||
329 | event->setCsum( mProfileName, QString::number( cSum )); | 336 | event->setCsum( mProfileName, QString::number( cSum )); |
330 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 337 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
331 | event->setID( mProfileName,QString::number( id ) ); | 338 | event->setID( mProfileName,QString::number( id ) ); |
332 | ev = er.next(); | 339 | ev = er.next(); |
333 | } | 340 | } |
334 | { | 341 | { |
335 | qDebug("reading todos... "); | 342 | qDebug("reading todos... "); |
336 | QPtrList<Todo> tr = calendar->rawTodos(); | 343 | QPtrList<Todo> tr = calendar->rawTodos(); |
337 | Todo* ev = tr.first(); | 344 | Todo* ev = tr.first(); |
338 | while ( ev ) { | 345 | while ( ev ) { |
339 | 346 | ||
340 | QStringList cat = ev->categories(); | 347 | QStringList cat = ev->categories(); |
341 | if ( cat.contains( "MeetingDEF" )) { | 348 | if ( cat.contains( "MeetingDEF" )) { |
342 | ev->setCategories( QStringList() ); | 349 | ev->setCategories( QStringList() ); |
343 | } | 350 | } |
344 | int id = ev->pilotId(); | 351 | int id = ev->pilotId(); |
352 | uint cSum; | ||
353 | cSum = PhoneFormat::getCsumTodo( ev ); | ||
345 | Todo *event; | 354 | Todo *event; |
346 | event = existingCal->todo( mProfileName ,QString::number( id ) ); | 355 | event = existingCal->todo( mProfileName ,QString::number( id ) ); |
347 | if ( event ) { | 356 | if ( event ) { |
348 | //qDebug("copy todo %s ", event->summary().latin1()); | 357 | //qDebug("copy todo %s ", event->summary().latin1()); |
349 | 358 | ||
350 | event = (Todo*)event->clone(); | 359 | event = (Todo*)event->clone(); |
351 | copyTodo( event, ev ); | 360 | copyTodo( event, ev ); |
352 | calendar->deleteTodo( ev ); | 361 | calendar->deleteTodo( ev ); |
353 | calendar->addTodo( event); | 362 | calendar->addTodo( event); |
354 | } | 363 | } |
355 | else | 364 | else |
356 | event = ev; | 365 | event = ev; |
357 | uint cSum; | ||
358 | cSum = PhoneFormat::getCsumTodo( event ); | ||
359 | event->setCsum( mProfileName, QString::number( cSum )); | 366 | event->setCsum( mProfileName, QString::number( cSum )); |
360 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 367 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
361 | event->setID( mProfileName,QString::number( id ) ); | 368 | event->setID( mProfileName,QString::number( id ) ); |
362 | ev = tr.next(); | 369 | ev = tr.next(); |
363 | } | 370 | } |
364 | } | 371 | } |
365 | return true; | 372 | return true; |
366 | } | 373 | } |
367 | void PhoneFormat::copyEvent( Event* to, Event* from ) | 374 | void PhoneFormat::copyEvent( Event* to, Event* from ) |
368 | { | 375 | { |
369 | if ( from->dtStart().isValid() ) | 376 | if ( from->dtStart().isValid() ) |
370 | to->setDtStart( from->dtStart() ); | 377 | to->setDtStart( from->dtStart() ); |
371 | if ( from->dtEnd().isValid() ) | 378 | if ( from->dtEnd().isValid() ) |
372 | to->setDtEnd( from->dtEnd() ); | 379 | to->setDtEnd( from->dtEnd() ); |
373 | if ( !from->location().isEmpty() ) | 380 | if ( !from->location().isEmpty() ) |
374 | to->setLocation( from->location() ); | 381 | to->setLocation( from->location() ); |
375 | if ( !from->description().isEmpty() ) | 382 | if ( !from->description().isEmpty() ) |
376 | to->setDescription( from->description() ); | 383 | to->setDescription( from->description() ); |
377 | if ( !from->summary().isEmpty() ) | 384 | if ( !from->summary().isEmpty() ) |
378 | to->setSummary( from->summary() ); | 385 | to->setSummary( from->summary() ); |
379 | 386 | ||
380 | if ( from->alarms().count() ) { | 387 | if ( from->alarms().count() ) { |
381 | to->clearAlarms(); | 388 | to->clearAlarms(); |
382 | Alarm *a = from->alarms().first(); | 389 | Alarm *a = from->alarms().first(); |
383 | Alarm *b = to->newAlarm( ); | 390 | Alarm *b = to->newAlarm( ); |
384 | b->setEnabled( a->enabled() ); | 391 | b->setEnabled( a->enabled() ); |
385 | if ( a->hasStartOffset() ) { | 392 | b->setStartOffset(Duration( a->offset() ) ); |
386 | b->setStartOffset( a->startOffset() ); | ||
387 | } | ||
388 | if ( a->hasTime() ) | ||
389 | b->setTime( a->time() ); | ||
390 | 393 | ||
391 | } | 394 | } |
392 | QStringList cat = to->categories(); | 395 | QStringList cat = to->categories(); |
393 | QStringList catFrom = from->categories(); | 396 | QStringList catFrom = from->categories(); |
394 | QString nCat; | 397 | QString nCat; |
395 | int iii; | 398 | int iii; |
396 | for ( iii = 0; iii < catFrom.count();++iii ) { | 399 | for ( iii = 0; iii < catFrom.count();++iii ) { |
397 | nCat = catFrom[iii]; | 400 | nCat = catFrom[iii]; |
398 | if ( !nCat.isEmpty() ) | 401 | if ( !nCat.isEmpty() ) |
399 | if ( !cat.contains( nCat )) { | 402 | if ( !cat.contains( nCat )) { |
400 | cat << nCat; | 403 | cat << nCat; |
401 | } | 404 | } |
402 | } | 405 | } |
403 | to->setCategories( cat ); | 406 | to->setCategories( cat ); |
404 | Recurrence * r = new Recurrence( *from->recurrence(),to); | 407 | if ( from->doesRecur() ) { |
405 | to->setRecurrence( r ) ; | 408 | Recurrence * r = new Recurrence( *from->recurrence(),to); |
409 | to->setRecurrence( r ) ; | ||
410 | } | ||
406 | 411 | ||
407 | 412 | ||
408 | } | 413 | } |
409 | void PhoneFormat::copyTodo( Todo* to, Todo* from ) | 414 | void PhoneFormat::copyTodo( Todo* to, Todo* from ) |
410 | { | 415 | { |
411 | if ( from->dtStart().isValid() ) | 416 | if ( from->hasStartDate() ) { |
417 | to->setHasStartDate( true ); | ||
412 | to->setDtStart( from->dtStart() ); | 418 | to->setDtStart( from->dtStart() ); |
413 | if ( from->dtDue().isValid() ) | 419 | } |
420 | if ( from->hasDueDate() ){ | ||
421 | to->setHasDueDate( true ); | ||
414 | to->setDtDue( from->dtDue() ); | 422 | to->setDtDue( from->dtDue() ); |
423 | } | ||
415 | if ( !from->location().isEmpty() ) | 424 | if ( !from->location().isEmpty() ) |
416 | to->setLocation( from->location() ); | 425 | to->setLocation( from->location() ); |
417 | if ( !from->description().isEmpty() ) | 426 | if ( !from->description().isEmpty() ) |
418 | to->setDescription( from->description() ); | 427 | to->setDescription( from->description() ); |
419 | if ( !from->summary().isEmpty() ) | 428 | if ( !from->summary().isEmpty() ) |
420 | to->setSummary( from->summary() ); | 429 | to->setSummary( from->summary() ); |
421 | 430 | ||
422 | if ( from->alarms().count() ) { | 431 | if ( from->alarms().count() ) { |
423 | to->clearAlarms(); | 432 | to->clearAlarms(); |
424 | Alarm *a = from->alarms().first(); | 433 | Alarm *a = from->alarms().first(); |
425 | Alarm *b = to->newAlarm( ); | 434 | Alarm *b = to->newAlarm( ); |
426 | b->setEnabled( a->enabled() ); | 435 | b->setEnabled( a->enabled() ); |
427 | if ( a->hasStartOffset() ) | 436 | b->setStartOffset(Duration( a->offset() ) ); |
428 | b->setStartOffset( a->startOffset() ); | ||
429 | if ( a->hasTime() ) | ||
430 | b->setTime( a->time() ); | ||
431 | } | 437 | } |
432 | 438 | ||
433 | QStringList cat = to->categories(); | 439 | QStringList cat = to->categories(); |
434 | QStringList catFrom = from->categories(); | 440 | QStringList catFrom = from->categories(); |
435 | QString nCat; | 441 | QString nCat; |
436 | int iii; | 442 | int iii; |
437 | for ( iii = 0; iii < catFrom.count();++iii ) { | 443 | for ( iii = 0; iii < catFrom.count();++iii ) { |
438 | nCat = catFrom[iii]; | 444 | nCat = catFrom[iii]; |
439 | if ( !nCat.isEmpty() ) | 445 | if ( !nCat.isEmpty() ) |
440 | if ( !cat.contains( nCat )) { | 446 | if ( !cat.contains( nCat )) { |
441 | cat << nCat; | 447 | cat << nCat; |
442 | } | 448 | } |
443 | } | 449 | } |
444 | to->setCategories( cat ); | 450 | to->setCategories( cat ); |
445 | if ( from->isCompleted() ) { | 451 | if ( from->isCompleted() ) { |
446 | to->setCompleted( true ); | 452 | to->setCompleted( true ); |
447 | if( from->completed().isValid() ) | 453 | if( from->completed().isValid() ) |
448 | to->setCompleted( from->completed() ); | 454 | to->setCompleted( from->completed() ); |
449 | } else { | 455 | } else { |
450 | // set percentcomplete only, if to->isCompleted() | 456 | // set percentcomplete only, if to->isCompleted() |
451 | if ( to->isCompleted() ) | 457 | if ( to->isCompleted() ) |
452 | to->setPercentComplete(from->percentComplete()); | 458 | to->setPercentComplete(from->percentComplete()); |
453 | } | 459 | } |
454 | if( to->priority() == 2 && from->priority() == 1 ) | 460 | if( to->priority() == 2 && from->priority() == 1 ) |
455 | ; //skip | 461 | ; //skip |
456 | else if (to->priority() == 4 && from->priority() == 5 ) | 462 | else if (to->priority() == 4 && from->priority() == 5 ) |
457 | ; | 463 | ; |
458 | else | 464 | else |
459 | to->setPriority(from->priority()); | 465 | to->setPriority(from->priority()); |
460 | 466 | ||
461 | } | 467 | } |
462 | #include <qcstring.h> | 468 | #include <qcstring.h> |
463 | 469 | ||
464 | void PhoneFormat::afterSave( Incidence* inc) | 470 | void PhoneFormat::afterSave( Incidence* inc,const QString& id ,const QString& csum) |
465 | { | 471 | { |
466 | uint csum; | 472 | inc->setID( mProfileName, id ); |
467 | inc->removeID( mProfileName ); | 473 | inc->setCsum( mProfileName, csum); |
468 | if ( inc->type() == "Event") | ||
469 | csum = PhoneFormat::getCsumEvent( (Event*) inc ); | ||
470 | else | ||
471 | csum = PhoneFormat::getCsumTodo( (Todo*) inc ); | ||
472 | inc->setCsum( mProfileName, QString::number( csum )); | ||
473 | |||
474 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 474 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
475 | 475 | ||
476 | } | 476 | } |
477 | 477 | ||
478 | bool PhoneFormat::writeToPhone( Calendar * calendar) | 478 | bool PhoneFormat::writeToPhone( Calendar * calendar) |
479 | { | 479 | { |
480 | #ifdef _WIN32_ | 480 | #ifdef _WIN32_ |
481 | QString fileName = locateLocal("tmp", "tempfile.vcs"); | 481 | QString fileName = locateLocal("tmp", "phonefile.vcs"); |
482 | #else | 482 | #else |
483 | QString fileName = "/tmp/kdepimtemp.vcs"; | 483 | QString fileName = "/tmp/phonefile.vcs"; |
484 | #endif | 484 | #endif |
485 | 485 | ||
486 | VCalFormat vfsave; | 486 | VCalFormat vfsave; |
487 | vfsave.setLocalTime ( true ); | 487 | vfsave.setLocalTime ( true ); |
488 | QString id = calendar->timeZoneId(); | 488 | QString id = calendar->timeZoneId(); |
489 | calendar->setLocalTime(); | 489 | calendar->setLocalTime(); |
490 | if ( ! vfsave.save( calendar, fileName ) ) | 490 | if ( ! vfsave.save( calendar, fileName ) ) |
491 | return false; | 491 | return false; |
492 | calendar->setTimeZoneId( id ); | 492 | calendar->setTimeZoneId( id ); |
493 | return PhoneAccess::writeToPhone( fileName ); | 493 | return PhoneAccess::writeToPhone( fileName ); |
494 | } | 494 | } |
495 | bool PhoneFormat::save( Calendar *calendar) | 495 | bool PhoneFormat::save( Calendar *calendar) |
496 | { | 496 | { |
497 | QLabel status ( i18n(" Opening device ..."), 0 ); | 497 | |
498 | int w = status.sizeHint().width()+20 ; | ||
499 | if ( w < 200 ) w = 230; | ||
500 | int h = status.sizeHint().height()+20 ; | ||
501 | int dw = QApplication::desktop()->width(); | ||
502 | int dh = QApplication::desktop()->height(); | ||
503 | status.setCaption(i18n("Writing to phone...") ); | ||
504 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | ||
505 | status.show(); | ||
506 | status.raise(); | ||
507 | qApp->processEvents(); | ||
508 | QString message; | ||
509 | 498 | ||
510 | // 1 remove events which should be deleted | 499 | // 1 remove events which should be deleted |
511 | QPtrList<Event> er = calendar->rawEvents(); | 500 | QPtrList<Event> er = calendar->rawEvents(); |
512 | Event* ev = er.first(); | 501 | Event* ev = er.first(); |
513 | while ( ev ) { | 502 | while ( ev ) { |
514 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | 503 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { |
515 | calendar->deleteEvent( ev ); | 504 | calendar->deleteEvent( ev ); |
516 | } else { | 505 | } else { |
517 | 506 | ||
518 | } | 507 | } |
519 | ev = er.next(); | 508 | ev = er.next(); |
520 | } | 509 | } |
521 | // 2 remove todos which should be deleted | 510 | // 2 remove todos which should be deleted |
522 | QPtrList<Todo> tl = calendar->rawTodos(); | 511 | QPtrList<Todo> tl = calendar->rawTodos(); |
523 | Todo* to = tl.first(); | 512 | Todo* to = tl.first(); |
524 | while ( to ) { | 513 | while ( to ) { |
525 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | 514 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { |
526 | calendar->deleteTodo( to ); | 515 | calendar->deleteTodo( to ); |
527 | } else { | 516 | } else { |
528 | if ( to->isCompleted()) { | 517 | if ( to->isCompleted()) { |
529 | calendar->deleteTodo( to ); | 518 | calendar->deleteTodo( to ); |
530 | } | 519 | } |
531 | } | 520 | } |
532 | to = tl.next(); | 521 | to = tl.next(); |
533 | } | 522 | } |
534 | // 3 save file | 523 | // 3 save file |
535 | if ( !writeToPhone( calendar ) ) | 524 | if ( !writeToPhone( calendar ) ) |
536 | return false; | 525 | return false; |
537 | 526 | QLabel status ( i18n(" Opening device ..."), 0 ); | |
527 | int w = status.sizeHint().width()+20 ; | ||
528 | if ( w < 200 ) w = 230; | ||
529 | int h = status.sizeHint().height()+20 ; | ||
530 | int dw = QApplication::desktop()->width(); | ||
531 | int dh = QApplication::desktop()->height(); | ||
532 | status.setCaption(i18n("Writing to phone...") ); | ||
533 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | ||
534 | QString message; | ||
535 | status.show(); | ||
536 | status.raise(); | ||
537 | qApp->processEvents(); | ||
538 | // 5 reread data | 538 | // 5 reread data |
539 | message = i18n(" Rereading all data ... "); | 539 | message = i18n(" Rereading all data ... "); |
540 | status.setText ( message ); | 540 | status.setText ( message ); |
541 | qApp->processEvents(); | 541 | qApp->processEvents(); |
542 | CalendarLocal* calendarTemp = new CalendarLocal(); | 542 | CalendarLocal* calendarTemp = new CalendarLocal(); |
543 | calendarTemp->setTimeZoneId( calendar->timeZoneId()); | 543 | calendarTemp->setTimeZoneId( calendar->timeZoneId()); |
544 | if ( ! load( calendarTemp,calendar) ){ | 544 | if ( ! load( calendarTemp,calendar) ){ |
545 | qDebug("error reloading calendar "); | 545 | qDebug("error reloading calendar "); |
546 | delete calendarTemp; | 546 | delete calendarTemp; |
547 | return false; | 547 | return false; |
548 | } | 548 | } |
549 | // 6 compare data | 549 | // 6 compare data |
550 | 550 | ||
551 | //algo 6 compare event | 551 | //algo 6 compare event |
552 | er = calendar->rawEvents(); | 552 | er = calendar->rawEvents(); |
553 | ev = er.first(); | 553 | ev = er.first(); |
554 | message = i18n(" Comparing event # "); | 554 | message = i18n(" Comparing event # "); |
555 | QPtrList<Event> er1 = calendarTemp->rawEvents(); | 555 | QPtrList<Event> er1 = calendarTemp->rawEvents(); |
556 | Event* ev1; | 556 | Event* ev1; |
557 | int procCount = 0; | 557 | int procCount = 0; |
558 | while ( ev ) { | 558 | while ( ev ) { |
559 | //qDebug("event new ID %s",ev->summary().latin1()); | 559 | //qDebug("event new ID %s",ev->summary().latin1()); |
560 | status.setText ( message + QString::number ( ++procCount ) ); | 560 | status.setText ( message + QString::number ( ++procCount ) ); |
561 | qApp->processEvents(); | 561 | qApp->processEvents(); |
562 | uint csum; | ||
563 | csum = PhoneFormat::getCsumEvent( ev ); | ||
564 | QString cSum = QString::number( csum ); | ||
565 | //ev->setCsum( mProfileName, cSum ); | ||
566 | //qDebug("Event cSum %s ", cSum.latin1()); | ||
567 | ev1 = er1.first(); | 562 | ev1 = er1.first(); |
568 | while ( ev1 ) { | 563 | while ( ev1 ) { |
569 | if ( ev1->getCsum( mProfileName ) == cSum ) { | 564 | if ( ev->contains( ev1 ) ) { |
565 | afterSave( ev ,ev1->getID(mProfileName),ev1->getCsum(mProfileName)); | ||
570 | er1.remove( ev1 ); | 566 | er1.remove( ev1 ); |
571 | afterSave( ev ); | ||
572 | ev->setID(mProfileName, ev1->getID(mProfileName) ); | ||
573 | //qDebug("Event found on phone for %s ", ev->summary().latin1()); | ||
574 | |||
575 | break; | 567 | break; |
576 | } | 568 | } |
577 | ev1 = er1.next(); | 569 | ev1 = er1.next(); |
578 | } | 570 | } |
579 | if ( ! ev1 ) { | 571 | if ( ! ev1 ) { |
580 | // ev->removeID(mProfileName); | 572 | // ev->removeID(mProfileName); |
581 | qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1()); | 573 | qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1()); |
582 | } | 574 | } |
583 | 575 | ||
584 | 576 | ||
585 | ev = er.next(); | 577 | ev = er.next(); |
586 | } | 578 | } |
587 | //algo 6 compare todo | 579 | //algo 6 compare todo |
588 | tl = calendar->rawTodos(); | 580 | tl = calendar->rawTodos(); |
589 | to = tl.first(); | 581 | to = tl.first(); |
590 | procCount = 0; | 582 | procCount = 0; |
591 | QPtrList<Todo> tl1 = calendarTemp->rawTodos(); | 583 | QPtrList<Todo> tl1 = calendarTemp->rawTodos(); |
592 | Todo* to1 ; | 584 | Todo* to1 ; |
593 | message = i18n(" Comparing todo # "); | 585 | message = i18n(" Comparing todo # "); |
594 | while ( to ) { | 586 | while ( to ) { |
595 | status.setText ( message + QString::number ( ++procCount ) ); | 587 | status.setText ( message + QString::number ( ++procCount ) ); |
596 | qApp->processEvents(); | 588 | qApp->processEvents(); |
597 | uint csum; | ||
598 | csum = PhoneFormat::getCsumTodo( to ); | ||
599 | QString cSum = QString::number( csum ); | ||
600 | //to->setCsum( mProfileName, cSum ); | ||
601 | //qDebug("Todo cSum %s ", cSum.latin1()); | ||
602 | Todo* to1 = tl1.first(); | 589 | Todo* to1 = tl1.first(); |
603 | while ( to1 ) { | 590 | while ( to1 ) { |
604 | if ( to1->getCsum( mProfileName ) == cSum ) { | 591 | if ( to->contains( to1 ) ) { |
592 | afterSave( to ,to1->getID(mProfileName),to1->getCsum(mProfileName)); | ||
605 | tl1.remove( to1 ); | 593 | tl1.remove( to1 ); |
606 | afterSave( to ); | ||
607 | to->setID(mProfileName, to1->getID(mProfileName) ); | ||
608 | break; | 594 | break; |
609 | } | 595 | } |
610 | to1 = tl1.next(); | 596 | to1 = tl1.next(); |
611 | } | 597 | } |
612 | if ( ! to1 ) { | 598 | if ( ! to1 ) { |
613 | //to->removeID(mProfileName); | 599 | //to->removeID(mProfileName); |
614 | qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1()); | 600 | qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1()); |
615 | } | 601 | } |
616 | 602 | ||
617 | to = tl.next(); | 603 | to = tl.next(); |
618 | } | 604 | } |
619 | delete calendarTemp; | 605 | delete calendarTemp; |
620 | return true; | 606 | return true; |
621 | 607 | ||
622 | 608 | ||
623 | 609 | ||
624 | } | 610 | } |
625 | 611 | ||
626 | 612 | ||
627 | QString PhoneFormat::toString( Calendar * ) | 613 | QString PhoneFormat::toString( Calendar * ) |
628 | { | 614 | { |
629 | return QString::null; | 615 | return QString::null; |
630 | } | 616 | } |
631 | bool PhoneFormat::fromString( Calendar *calendar, const QString & text) | 617 | bool PhoneFormat::fromString( Calendar *calendar, const QString & text) |
632 | { | 618 | { |
633 | return false; | 619 | return false; |
634 | } | 620 | } |
diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h index 001fd81..d11f68b 100644 --- a/libkcal/phoneformat.h +++ b/libkcal/phoneformat.h | |||
@@ -1,62 +1,62 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | 3 | ||
4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | #ifndef PHONEFORMAT_H | 21 | #ifndef PHONEFORMAT_H |
22 | #define PHONEFORMAT_H | 22 | #define PHONEFORMAT_H |
23 | 23 | ||
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | 25 | ||
26 | #include "scheduler.h" | 26 | #include "scheduler.h" |
27 | 27 | ||
28 | #include "vcalformat.h" | 28 | #include "vcalformat.h" |
29 | #include "calformat.h" | 29 | #include "calformat.h" |
30 | 30 | ||
31 | namespace KCal { | 31 | namespace KCal { |
32 | 32 | ||
33 | /** | 33 | /** |
34 | This class implements the calendar format used by Phone. | 34 | This class implements the calendar format used by Phone. |
35 | */ | 35 | */ |
36 | class Event; | 36 | class Event; |
37 | class Todo; | 37 | class Todo; |
38 | class PhoneFormat : public QObject { | 38 | class PhoneFormat : public QObject { |
39 | public: | 39 | public: |
40 | /** Create new iCalendar format. */ | 40 | /** Create new iCalendar format. */ |
41 | PhoneFormat(QString profileName, QString device,QString connection, QString model); | 41 | PhoneFormat(QString profileName, QString device,QString connection, QString model); |
42 | virtual ~PhoneFormat(); | 42 | virtual ~PhoneFormat(); |
43 | 43 | ||
44 | bool load( Calendar * ,Calendar * ); | 44 | bool load( Calendar * ,Calendar * ); |
45 | bool save( Calendar * ); | 45 | bool save( Calendar * ); |
46 | bool fromString( Calendar *, const QString & ); | 46 | bool fromString( Calendar *, const QString & ); |
47 | QString toString( Calendar * ); | 47 | QString toString( Calendar * ); |
48 | static ulong getCsum( const QStringList & ); | 48 | static ulong getCsum( const QStringList & ); |
49 | static ulong getCsumTodo( Todo* to ); | 49 | static ulong getCsumTodo( Todo* to ); |
50 | static ulong getCsumEvent( Event* ev ); | 50 | static ulong getCsumEvent( Event* ev ); |
51 | static bool writeToPhone( Calendar * ); | 51 | static bool writeToPhone( Calendar * ); |
52 | private: | 52 | private: |
53 | void copyEvent( Event* to, Event* from ); | 53 | void copyEvent( Event* to, Event* from ); |
54 | void copyTodo( Todo* to, Todo* from ); | 54 | void copyTodo( Todo* to, Todo* from ); |
55 | //int initDevice(GSM_StateMachine *s); | 55 | //int initDevice(GSM_StateMachine *s); |
56 | QString mProfileName; | 56 | QString mProfileName; |
57 | void afterSave( Incidence* ); | 57 | void afterSave( Incidence* ,const QString&,const QString&); |
58 | }; | 58 | }; |
59 | 59 | ||
60 | } | 60 | } |
61 | 61 | ||
62 | #endif | 62 | #endif |
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 0c1e3e4..3d2de61 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp | |||
@@ -1,316 +1,374 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <kglobal.h> | 21 | #include <kglobal.h> |
22 | #include <klocale.h> | 22 | #include <klocale.h> |
23 | #include <kdebug.h> | 23 | #include <kdebug.h> |
24 | 24 | ||
25 | #include "todo.h" | 25 | #include "todo.h" |
26 | 26 | ||
27 | using namespace KCal; | 27 | using namespace KCal; |
28 | 28 | ||
29 | Todo::Todo(): Incidence() | 29 | Todo::Todo(): Incidence() |
30 | { | 30 | { |
31 | // mStatus = TENTATIVE; | 31 | // mStatus = TENTATIVE; |
32 | 32 | ||
33 | mHasDueDate = false; | 33 | mHasDueDate = false; |
34 | setHasStartDate( false ); | 34 | setHasStartDate( false ); |
35 | mCompleted = getEvenTime(QDateTime::currentDateTime()); | 35 | mCompleted = getEvenTime(QDateTime::currentDateTime()); |
36 | mHasCompletedDate = false; | 36 | mHasCompletedDate = false; |
37 | mPercentComplete = 0; | 37 | mPercentComplete = 0; |
38 | } | 38 | } |
39 | 39 | ||
40 | Todo::Todo(const Todo &t) : Incidence(t) | 40 | Todo::Todo(const Todo &t) : Incidence(t) |
41 | { | 41 | { |
42 | mDtDue = t.mDtDue; | 42 | mDtDue = t.mDtDue; |
43 | mHasDueDate = t.mHasDueDate; | 43 | mHasDueDate = t.mHasDueDate; |
44 | mCompleted = t.mCompleted; | 44 | mCompleted = t.mCompleted; |
45 | mHasCompletedDate = t.mHasCompletedDate; | 45 | mHasCompletedDate = t.mHasCompletedDate; |
46 | mPercentComplete = t.mPercentComplete; | 46 | mPercentComplete = t.mPercentComplete; |
47 | } | 47 | } |
48 | 48 | ||
49 | Todo::~Todo() | 49 | Todo::~Todo() |
50 | { | 50 | { |
51 | 51 | ||
52 | } | 52 | } |
53 | 53 | ||
54 | Incidence *Todo::clone() | 54 | Incidence *Todo::clone() |
55 | { | 55 | { |
56 | return new Todo(*this); | 56 | return new Todo(*this); |
57 | } | 57 | } |
58 | 58 | ||
59 | bool Todo::contains ( Todo* from ) | ||
60 | { | ||
59 | 61 | ||
62 | if ( !from->summary().isEmpty() ) | ||
63 | if ( !summary().startsWith( from->summary() )) | ||
64 | return false; | ||
65 | if ( from->hasStartDate() ) { | ||
66 | if ( !hasStartDate() ) | ||
67 | return false; | ||
68 | if ( from->dtStart() != dtStart()) | ||
69 | return false; | ||
70 | } | ||
71 | if ( from->hasDueDate() ){ | ||
72 | if ( !hasDueDate() ) | ||
73 | return false; | ||
74 | if ( from->dtDue() != dtDue()) | ||
75 | return false; | ||
76 | } | ||
77 | if ( !from->location().isEmpty() ) | ||
78 | if ( !location().startsWith( from->location() ) ) | ||
79 | return false; | ||
80 | if ( !from->description().isEmpty() ) | ||
81 | if ( !description().startsWith( from->description() )) | ||
82 | return false; | ||
83 | if ( from->alarms().count() ) { | ||
84 | Alarm *a = from->alarms().first(); | ||
85 | if ( a->enabled() ){ | ||
86 | if ( !alarms().count() ) | ||
87 | return false; | ||
88 | Alarm *b = alarms().first(); | ||
89 | if( ! b->enabled() ) | ||
90 | return false; | ||
91 | if ( ! (a->offset() == b->offset() )) | ||
92 | return false; | ||
93 | } | ||
94 | } | ||
95 | |||
96 | QStringList cat = categories(); | ||
97 | QStringList catFrom = from->categories(); | ||
98 | QString nCat; | ||
99 | int iii; | ||
100 | for ( iii = 0; iii < catFrom.count();++iii ) { | ||
101 | nCat = catFrom[iii]; | ||
102 | if ( !nCat.isEmpty() ) | ||
103 | if ( !cat.contains( nCat )) { | ||
104 | return false; | ||
105 | } | ||
106 | } | ||
107 | if ( from->isCompleted() ) { | ||
108 | if ( !isCompleted() ) | ||
109 | return false; | ||
110 | } | ||
111 | if( priority() != from->priority() ) | ||
112 | return false; | ||
113 | |||
114 | |||
115 | return true; | ||
116 | |||
117 | } | ||
60 | bool KCal::operator==( const Todo& t1, const Todo& t2 ) | 118 | bool KCal::operator==( const Todo& t1, const Todo& t2 ) |
61 | { | 119 | { |
62 | 120 | ||
63 | bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 ); | 121 | bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 ); |
64 | if ( ! ret ) | 122 | if ( ! ret ) |
65 | return false; | 123 | return false; |
66 | if ( t1.hasDueDate() == t2.hasDueDate() ) { | 124 | if ( t1.hasDueDate() == t2.hasDueDate() ) { |
67 | if ( t1.hasDueDate() ) { | 125 | if ( t1.hasDueDate() ) { |
68 | if ( t1.doesFloat() == t2.doesFloat() ) { | 126 | if ( t1.doesFloat() == t2.doesFloat() ) { |
69 | if ( t1.doesFloat() ) { | 127 | if ( t1.doesFloat() ) { |
70 | if ( t1.dtDue().date() != t2.dtDue().date() ) | 128 | if ( t1.dtDue().date() != t2.dtDue().date() ) |
71 | return false; | 129 | return false; |
72 | } else | 130 | } else |
73 | if ( t1.dtDue() != t2.dtDue() ) | 131 | if ( t1.dtDue() != t2.dtDue() ) |
74 | return false; | 132 | return false; |
75 | } else | 133 | } else |
76 | return false;// float != | 134 | return false;// float != |
77 | } | 135 | } |
78 | 136 | ||
79 | } else | 137 | } else |
80 | return false; | 138 | return false; |
81 | if ( t1.percentComplete() != t2.percentComplete() ) | 139 | if ( t1.percentComplete() != t2.percentComplete() ) |
82 | return false; | 140 | return false; |
83 | if ( t1.isCompleted() ) { | 141 | if ( t1.isCompleted() ) { |
84 | if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { | 142 | if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { |
85 | if ( t1.hasCompletedDate() ) { | 143 | if ( t1.hasCompletedDate() ) { |
86 | if ( t1.completed() != t2.completed() ) | 144 | if ( t1.completed() != t2.completed() ) |
87 | return false; | 145 | return false; |
88 | } | 146 | } |
89 | 147 | ||
90 | } else | 148 | } else |
91 | return false; | 149 | return false; |
92 | } | 150 | } |
93 | return true; | 151 | return true; |
94 | 152 | ||
95 | } | 153 | } |
96 | 154 | ||
97 | void Todo::setDtDue(const QDateTime &dtDue) | 155 | void Todo::setDtDue(const QDateTime &dtDue) |
98 | { | 156 | { |
99 | //int diffsecs = mDtDue.secsTo(dtDue); | 157 | //int diffsecs = mDtDue.secsTo(dtDue); |
100 | 158 | ||
101 | /*if (mReadOnly) return; | 159 | /*if (mReadOnly) return; |
102 | const QPtrList<Alarm>& alarms = alarms(); | 160 | const QPtrList<Alarm>& alarms = alarms(); |
103 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) { | 161 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) { |
104 | if (alarm->enabled()) { | 162 | if (alarm->enabled()) { |
105 | alarm->setTime(alarm->time().addSecs(diffsecs)); | 163 | alarm->setTime(alarm->time().addSecs(diffsecs)); |
106 | } | 164 | } |
107 | }*/ | 165 | }*/ |
108 | mDtDue = getEvenTime(dtDue); | 166 | mDtDue = getEvenTime(dtDue); |
109 | 167 | ||
110 | //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl; | 168 | //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl; |
111 | 169 | ||
112 | /*const QPtrList<Alarm>& alarms = alarms(); | 170 | /*const QPtrList<Alarm>& alarms = alarms(); |
113 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) | 171 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) |
114 | alarm->setAlarmStart(mDtDue);*/ | 172 | alarm->setAlarmStart(mDtDue);*/ |
115 | 173 | ||
116 | updated(); | 174 | updated(); |
117 | } | 175 | } |
118 | 176 | ||
119 | QDateTime Todo::dtDue() const | 177 | QDateTime Todo::dtDue() const |
120 | { | 178 | { |
121 | return mDtDue; | 179 | return mDtDue; |
122 | } | 180 | } |
123 | 181 | ||
124 | QString Todo::dtDueTimeStr() const | 182 | QString Todo::dtDueTimeStr() const |
125 | { | 183 | { |
126 | return KGlobal::locale()->formatTime(mDtDue.time()); | 184 | return KGlobal::locale()->formatTime(mDtDue.time()); |
127 | } | 185 | } |
128 | 186 | ||
129 | QString Todo::dtDueDateStr(bool shortfmt) const | 187 | QString Todo::dtDueDateStr(bool shortfmt) const |
130 | { | 188 | { |
131 | return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); | 189 | return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); |
132 | } | 190 | } |
133 | 191 | ||
134 | QString Todo::dtDueStr(bool shortfmt) const | 192 | QString Todo::dtDueStr(bool shortfmt) const |
135 | { | 193 | { |
136 | return KGlobal::locale()->formatDateTime(mDtDue, shortfmt); | 194 | return KGlobal::locale()->formatDateTime(mDtDue, shortfmt); |
137 | } | 195 | } |
138 | 196 | ||
139 | bool Todo::hasDueDate() const | 197 | bool Todo::hasDueDate() const |
140 | { | 198 | { |
141 | return mHasDueDate; | 199 | return mHasDueDate; |
142 | } | 200 | } |
143 | 201 | ||
144 | void Todo::setHasDueDate(bool f) | 202 | void Todo::setHasDueDate(bool f) |
145 | { | 203 | { |
146 | if (mReadOnly) return; | 204 | if (mReadOnly) return; |
147 | mHasDueDate = f; | 205 | mHasDueDate = f; |
148 | updated(); | 206 | updated(); |
149 | } | 207 | } |
150 | 208 | ||
151 | 209 | ||
152 | #if 0 | 210 | #if 0 |
153 | void Todo::setStatus(const QString &statStr) | 211 | void Todo::setStatus(const QString &statStr) |
154 | { | 212 | { |
155 | if (mReadOnly) return; | 213 | if (mReadOnly) return; |
156 | QString ss(statStr.upper()); | 214 | QString ss(statStr.upper()); |
157 | 215 | ||
158 | if (ss == "X-ACTION") | 216 | if (ss == "X-ACTION") |
159 | mStatus = NEEDS_ACTION; | 217 | mStatus = NEEDS_ACTION; |
160 | else if (ss == "NEEDS ACTION") | 218 | else if (ss == "NEEDS ACTION") |
161 | mStatus = NEEDS_ACTION; | 219 | mStatus = NEEDS_ACTION; |
162 | else if (ss == "ACCEPTED") | 220 | else if (ss == "ACCEPTED") |
163 | mStatus = ACCEPTED; | 221 | mStatus = ACCEPTED; |
164 | else if (ss == "SENT") | 222 | else if (ss == "SENT") |
165 | mStatus = SENT; | 223 | mStatus = SENT; |
166 | else if (ss == "TENTATIVE") | 224 | else if (ss == "TENTATIVE") |
167 | mStatus = TENTATIVE; | 225 | mStatus = TENTATIVE; |
168 | else if (ss == "CONFIRMED") | 226 | else if (ss == "CONFIRMED") |
169 | mStatus = CONFIRMED; | 227 | mStatus = CONFIRMED; |
170 | else if (ss == "DECLINED") | 228 | else if (ss == "DECLINED") |
171 | mStatus = DECLINED; | 229 | mStatus = DECLINED; |
172 | else if (ss == "COMPLETED") | 230 | else if (ss == "COMPLETED") |
173 | mStatus = COMPLETED; | 231 | mStatus = COMPLETED; |
174 | else if (ss == "DELEGATED") | 232 | else if (ss == "DELEGATED") |
175 | mStatus = DELEGATED; | 233 | mStatus = DELEGATED; |
176 | 234 | ||
177 | updated(); | 235 | updated(); |
178 | } | 236 | } |
179 | 237 | ||
180 | void Todo::setStatus(int status) | 238 | void Todo::setStatus(int status) |
181 | { | 239 | { |
182 | if (mReadOnly) return; | 240 | if (mReadOnly) return; |
183 | mStatus = status; | 241 | mStatus = status; |
184 | updated(); | 242 | updated(); |
185 | } | 243 | } |
186 | 244 | ||
187 | int Todo::status() const | 245 | int Todo::status() const |
188 | { | 246 | { |
189 | return mStatus; | 247 | return mStatus; |
190 | } | 248 | } |
191 | 249 | ||
192 | QString Todo::statusStr() const | 250 | QString Todo::statusStr() const |
193 | { | 251 | { |
194 | switch(mStatus) { | 252 | switch(mStatus) { |
195 | case NEEDS_ACTION: | 253 | case NEEDS_ACTION: |
196 | return QString("NEEDS ACTION"); | 254 | return QString("NEEDS ACTION"); |
197 | break; | 255 | break; |
198 | case ACCEPTED: | 256 | case ACCEPTED: |
199 | return QString("ACCEPTED"); | 257 | return QString("ACCEPTED"); |
200 | break; | 258 | break; |
201 | case SENT: | 259 | case SENT: |
202 | return QString("SENT"); | 260 | return QString("SENT"); |
203 | break; | 261 | break; |
204 | case TENTATIVE: | 262 | case TENTATIVE: |
205 | return QString("TENTATIVE"); | 263 | return QString("TENTATIVE"); |
206 | break; | 264 | break; |
207 | case CONFIRMED: | 265 | case CONFIRMED: |
208 | return QString("CONFIRMED"); | 266 | return QString("CONFIRMED"); |
209 | break; | 267 | break; |
210 | case DECLINED: | 268 | case DECLINED: |
211 | return QString("DECLINED"); | 269 | return QString("DECLINED"); |
212 | break; | 270 | break; |
213 | case COMPLETED: | 271 | case COMPLETED: |
214 | return QString("COMPLETED"); | 272 | return QString("COMPLETED"); |
215 | break; | 273 | break; |
216 | case DELEGATED: | 274 | case DELEGATED: |
217 | return QString("DELEGATED"); | 275 | return QString("DELEGATED"); |
218 | break; | 276 | break; |
219 | } | 277 | } |
220 | return QString(""); | 278 | return QString(""); |
221 | } | 279 | } |
222 | #endif | 280 | #endif |
223 | 281 | ||
224 | bool Todo::isCompleted() const | 282 | bool Todo::isCompleted() const |
225 | { | 283 | { |
226 | if (mPercentComplete == 100) return true; | 284 | if (mPercentComplete == 100) return true; |
227 | else return false; | 285 | else return false; |
228 | } | 286 | } |
229 | 287 | ||
230 | void Todo::setCompleted(bool completed) | 288 | void Todo::setCompleted(bool completed) |
231 | { | 289 | { |
232 | if (completed) mPercentComplete = 100; | 290 | if (completed) mPercentComplete = 100; |
233 | else mPercentComplete = 0; | 291 | else mPercentComplete = 0; |
234 | updated(); | 292 | updated(); |
235 | } | 293 | } |
236 | 294 | ||
237 | QDateTime Todo::completed() const | 295 | QDateTime Todo::completed() const |
238 | { | 296 | { |
239 | return mCompleted; | 297 | return mCompleted; |
240 | } | 298 | } |
241 | 299 | ||
242 | QString Todo::completedStr() const | 300 | QString Todo::completedStr() const |
243 | { | 301 | { |
244 | return KGlobal::locale()->formatDateTime(mCompleted); | 302 | return KGlobal::locale()->formatDateTime(mCompleted); |
245 | } | 303 | } |
246 | 304 | ||
247 | void Todo::setCompleted(const QDateTime &completed) | 305 | void Todo::setCompleted(const QDateTime &completed) |
248 | { | 306 | { |
249 | mHasCompletedDate = true; | 307 | mHasCompletedDate = true; |
250 | mPercentComplete = 100; | 308 | mPercentComplete = 100; |
251 | mCompleted = getEvenTime(completed); | 309 | mCompleted = getEvenTime(completed); |
252 | updated(); | 310 | updated(); |
253 | } | 311 | } |
254 | 312 | ||
255 | bool Todo::hasCompletedDate() const | 313 | bool Todo::hasCompletedDate() const |
256 | { | 314 | { |
257 | return mHasCompletedDate; | 315 | return mHasCompletedDate; |
258 | } | 316 | } |
259 | 317 | ||
260 | int Todo::percentComplete() const | 318 | int Todo::percentComplete() const |
261 | { | 319 | { |
262 | return mPercentComplete; | 320 | return mPercentComplete; |
263 | } | 321 | } |
264 | 322 | ||
265 | void Todo::setPercentComplete(int v) | 323 | void Todo::setPercentComplete(int v) |
266 | { | 324 | { |
267 | mPercentComplete = v; | 325 | mPercentComplete = v; |
268 | updated(); | 326 | updated(); |
269 | } | 327 | } |
270 | QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const | 328 | QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const |
271 | { | 329 | { |
272 | if ( isCompleted() || ! hasDueDate() || cancelled() ) { | 330 | if ( isCompleted() || ! hasDueDate() || cancelled() ) { |
273 | *ok = false; | 331 | *ok = false; |
274 | return QDateTime (); | 332 | return QDateTime (); |
275 | } | 333 | } |
276 | QDateTime incidenceStart; | 334 | QDateTime incidenceStart; |
277 | incidenceStart = dtDue(); | 335 | incidenceStart = dtDue(); |
278 | bool enabled = false; | 336 | bool enabled = false; |
279 | Alarm* alarm; | 337 | Alarm* alarm; |
280 | int off; | 338 | int off; |
281 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; | 339 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; |
282 | // if ( QDateTime::currentDateTime() > incidenceStart ){ | 340 | // if ( QDateTime::currentDateTime() > incidenceStart ){ |
283 | // *ok = false; | 341 | // *ok = false; |
284 | // return incidenceStart; | 342 | // return incidenceStart; |
285 | // } | 343 | // } |
286 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 344 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
287 | if (alarm->enabled()) { | 345 | if (alarm->enabled()) { |
288 | if ( alarm->hasTime () ) { | 346 | if ( alarm->hasTime () ) { |
289 | if ( alarm->time() < alarmStart ) { | 347 | if ( alarm->time() < alarmStart ) { |
290 | alarmStart = alarm->time(); | 348 | alarmStart = alarm->time(); |
291 | enabled = true; | 349 | enabled = true; |
292 | off = alarmStart.secsTo( incidenceStart ); | 350 | off = alarmStart.secsTo( incidenceStart ); |
293 | } | 351 | } |
294 | 352 | ||
295 | } else { | 353 | } else { |
296 | int secs = alarm->startOffset().asSeconds(); | 354 | int secs = alarm->startOffset().asSeconds(); |
297 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { | 355 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { |
298 | alarmStart = incidenceStart.addSecs( secs ); | 356 | alarmStart = incidenceStart.addSecs( secs ); |
299 | enabled = true; | 357 | enabled = true; |
300 | off = -secs; | 358 | off = -secs; |
301 | } | 359 | } |
302 | } | 360 | } |
303 | } | 361 | } |
304 | } | 362 | } |
305 | if ( enabled ) { | 363 | if ( enabled ) { |
306 | if ( alarmStart > QDateTime::currentDateTime() ) { | 364 | if ( alarmStart > QDateTime::currentDateTime() ) { |
307 | *ok = true; | 365 | *ok = true; |
308 | * offset = off; | 366 | * offset = off; |
309 | return alarmStart; | 367 | return alarmStart; |
310 | } | 368 | } |
311 | } | 369 | } |
312 | *ok = false; | 370 | *ok = false; |
313 | return QDateTime (); | 371 | return QDateTime (); |
314 | 372 | ||
315 | } | 373 | } |
316 | 374 | ||
diff --git a/libkcal/todo.h b/libkcal/todo.h index 9aa92f8..0f22c59 100644 --- a/libkcal/todo.h +++ b/libkcal/todo.h | |||
@@ -1,121 +1,122 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | #ifndef TODO_H | 20 | #ifndef TODO_H |
21 | #define TODO_H | 21 | #define TODO_H |
22 | // | 22 | // |
23 | // Todo component, representing a VTODO object | 23 | // Todo component, representing a VTODO object |
24 | // | 24 | // |
25 | 25 | ||
26 | #include "incidence.h" | 26 | #include "incidence.h" |
27 | 27 | ||
28 | namespace KCal { | 28 | namespace KCal { |
29 | 29 | ||
30 | /** | 30 | /** |
31 | This class provides a Todo in the sense of RFC2445. | 31 | This class provides a Todo in the sense of RFC2445. |
32 | */ | 32 | */ |
33 | class Todo : public Incidence | 33 | class Todo : public Incidence |
34 | { | 34 | { |
35 | public: | 35 | public: |
36 | Todo(); | 36 | Todo(); |
37 | Todo(const Todo &); | 37 | Todo(const Todo &); |
38 | ~Todo(); | 38 | ~Todo(); |
39 | typedef ListBase<Todo> List; | 39 | typedef ListBase<Todo> List; |
40 | QCString type() const { return "Todo"; } | 40 | QCString type() const { return "Todo"; } |
41 | 41 | ||
42 | /** Return an exact copy of this todo. */ | 42 | /** Return an exact copy of this todo. */ |
43 | Incidence *clone(); | 43 | Incidence *clone(); |
44 | QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const; | 44 | QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const; |
45 | 45 | ||
46 | /** for setting the todo's due date/time with a QDateTime. */ | 46 | /** for setting the todo's due date/time with a QDateTime. */ |
47 | void setDtDue(const QDateTime &dtDue); | 47 | void setDtDue(const QDateTime &dtDue); |
48 | /** returns an event's Due date/time as a QDateTime. */ | 48 | /** returns an event's Due date/time as a QDateTime. */ |
49 | QDateTime dtDue() const; | 49 | QDateTime dtDue() const; |
50 | /** returns an event's due time as a string formatted according to the | 50 | /** returns an event's due time as a string formatted according to the |
51 | users locale settings */ | 51 | users locale settings */ |
52 | QString dtDueTimeStr() const; | 52 | QString dtDueTimeStr() const; |
53 | /** returns an event's due date as a string formatted according to the | 53 | /** returns an event's due date as a string formatted according to the |
54 | users locale settings */ | 54 | users locale settings */ |
55 | QString dtDueDateStr(bool shortfmt=true) const; | 55 | QString dtDueDateStr(bool shortfmt=true) const; |
56 | /** returns an event's due date and time as a string formatted according | 56 | /** returns an event's due date and time as a string formatted according |
57 | to the users locale settings */ | 57 | to the users locale settings */ |
58 | QString dtDueStr(bool shortfmt=true) const; | 58 | QString dtDueStr(bool shortfmt=true) const; |
59 | 59 | ||
60 | /** returns TRUE or FALSE depending on whether the todo has a due date */ | 60 | /** returns TRUE or FALSE depending on whether the todo has a due date */ |
61 | bool hasDueDate() const; | 61 | bool hasDueDate() const; |
62 | /** sets the event's hasDueDate value. */ | 62 | /** sets the event's hasDueDate value. */ |
63 | void setHasDueDate(bool f); | 63 | void setHasDueDate(bool f); |
64 | 64 | ||
65 | 65 | ||
66 | /** sets the event's status to the string specified. The string | 66 | /** sets the event's status to the string specified. The string |
67 | * must be a recognized value for the status field, i.e. a string | 67 | * must be a recognized value for the status field, i.e. a string |
68 | * equivalent of the possible status enumerations previously described. */ | 68 | * equivalent of the possible status enumerations previously described. */ |
69 | // void setStatus(const QString &statStr); | 69 | // void setStatus(const QString &statStr); |
70 | /** sets the event's status to the value specified. See the enumeration | 70 | /** sets the event's status to the value specified. See the enumeration |
71 | * above for possible values. */ | 71 | * above for possible values. */ |
72 | // void setStatus(int); | 72 | // void setStatus(int); |
73 | /** return the event's status. */ | 73 | /** return the event's status. */ |
74 | // int status() const; | 74 | // int status() const; |
75 | /** return the event's status in string format. */ | 75 | /** return the event's status in string format. */ |
76 | // QString statusStr() const; | 76 | // QString statusStr() const; |
77 | 77 | ||
78 | /** return, if this todo is completed */ | 78 | /** return, if this todo is completed */ |
79 | bool isCompleted() const; | 79 | bool isCompleted() const; |
80 | /** set completed state of this todo */ | 80 | /** set completed state of this todo */ |
81 | void setCompleted(bool); | 81 | void setCompleted(bool); |
82 | 82 | ||
83 | /** | 83 | /** |
84 | Return how many percent of the task are completed. Returns a value | 84 | Return how many percent of the task are completed. Returns a value |
85 | between 0 and 100. | 85 | between 0 and 100. |
86 | */ | 86 | */ |
87 | int percentComplete() const; | 87 | int percentComplete() const; |
88 | /** | 88 | /** |
89 | Set how many percent of the task are completed. Valid values are in the | 89 | Set how many percent of the task are completed. Valid values are in the |
90 | range from 0 to 100. | 90 | range from 0 to 100. |
91 | */ | 91 | */ |
92 | void setPercentComplete(int); | 92 | void setPercentComplete(int); |
93 | 93 | ||
94 | /** return date and time when todo was completed */ | 94 | /** return date and time when todo was completed */ |
95 | QDateTime completed() const; | 95 | QDateTime completed() const; |
96 | QString completedStr() const; | 96 | QString completedStr() const; |
97 | /** set date and time of completion */ | 97 | /** set date and time of completion */ |
98 | void setCompleted(const QDateTime &completed); | 98 | void setCompleted(const QDateTime &completed); |
99 | 99 | ||
100 | /** Return true, if todo has a date associated with completion */ | 100 | /** Return true, if todo has a date associated with completion */ |
101 | bool hasCompletedDate() const; | 101 | bool hasCompletedDate() const; |
102 | bool contains ( Todo*); | ||
102 | 103 | ||
103 | private: | 104 | private: |
104 | bool accept(Visitor &v) { return v.visit(this); } | 105 | bool accept(Visitor &v) { return v.visit(this); } |
105 | 106 | ||
106 | QDateTime mDtDue; // due date of todo | 107 | QDateTime mDtDue; // due date of todo |
107 | 108 | ||
108 | bool mHasDueDate; // if todo has associated due date | 109 | bool mHasDueDate; // if todo has associated due date |
109 | 110 | ||
110 | // int mStatus; // confirmed/delegated/tentative/etc | 111 | // int mStatus; // confirmed/delegated/tentative/etc |
111 | 112 | ||
112 | QDateTime mCompleted; | 113 | QDateTime mCompleted; |
113 | bool mHasCompletedDate; | 114 | bool mHasCompletedDate; |
114 | 115 | ||
115 | int mPercentComplete; | 116 | int mPercentComplete; |
116 | }; | 117 | }; |
117 | 118 | ||
118 | bool operator==( const Todo&, const Todo& ); | 119 | bool operator==( const Todo&, const Todo& ); |
119 | } | 120 | } |
120 | 121 | ||
121 | #endif | 122 | #endif |
diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp index a6ae1bc..df93209 100644 --- a/libkcal/vcalformat.cpp +++ b/libkcal/vcalformat.cpp | |||
@@ -1,1713 +1,1720 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 1998 Preston Brwon | 3 | Copyright (c) 1998 Preston Brwon |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <qapplication.h> | 22 | #include <qapplication.h> |
23 | #include <qdatetime.h> | 23 | #include <qdatetime.h> |
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qptrlist.h> | 25 | #include <qptrlist.h> |
26 | #include <qregexp.h> | 26 | #include <qregexp.h> |
27 | #include <qclipboard.h> | 27 | #include <qclipboard.h> |
28 | #include <qdialog.h> | 28 | #include <qdialog.h> |
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | 30 | ||
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <kglobal.h> | 32 | #include <kglobal.h> |
33 | #include <kmessagebox.h> | 33 | #include <kmessagebox.h> |
34 | #include <kiconloader.h> | 34 | #include <kiconloader.h> |
35 | #include <klocale.h> | 35 | #include <klocale.h> |
36 | 36 | ||
37 | #include "vcc.h" | 37 | #include "vcc.h" |
38 | #include "vobject.h" | 38 | #include "vobject.h" |
39 | 39 | ||
40 | #include "vcaldrag.h" | 40 | #include "vcaldrag.h" |
41 | #include "calendar.h" | 41 | #include "calendar.h" |
42 | 42 | ||
43 | #include "vcalformat.h" | 43 | #include "vcalformat.h" |
44 | 44 | ||
45 | using namespace KCal; | 45 | using namespace KCal; |
46 | 46 | ||
47 | VCalFormat::VCalFormat() | 47 | VCalFormat::VCalFormat() |
48 | { | 48 | { |
49 | mCalendar = 0; | 49 | mCalendar = 0; |
50 | useLocalTime = false; | 50 | useLocalTime = false; |
51 | } | 51 | } |
52 | 52 | ||
53 | VCalFormat::~VCalFormat() | 53 | VCalFormat::~VCalFormat() |
54 | { | 54 | { |
55 | } | 55 | } |
56 | 56 | ||
57 | void VCalFormat::setLocalTime ( bool b ) | 57 | void VCalFormat::setLocalTime ( bool b ) |
58 | { | 58 | { |
59 | useLocalTime = b; | 59 | useLocalTime = b; |
60 | } | 60 | } |
61 | bool VCalFormat::load(Calendar *calendar, const QString &fileName) | 61 | bool VCalFormat::load(Calendar *calendar, const QString &fileName) |
62 | { | 62 | { |
63 | mCalendar = calendar; | 63 | mCalendar = calendar; |
64 | clearException(); | 64 | clearException(); |
65 | useLocalTime = mCalendar->isLocalTime(); | 65 | if ( ! useLocalTime ) |
66 | useLocalTime = mCalendar->isLocalTime(); | ||
66 | VObject *vcal = 0; | 67 | VObject *vcal = 0; |
67 | 68 | ||
68 | // this is not necessarily only 1 vcal. Could be many vcals, or include | 69 | // this is not necessarily only 1 vcal. Could be many vcals, or include |
69 | // a vcard... | 70 | // a vcard... |
70 | vcal = Parse_MIME_FromFileName(const_cast<char *>(QFile::encodeName(fileName).data())); | 71 | vcal = Parse_MIME_FromFileName(const_cast<char *>(QFile::encodeName(fileName).data())); |
71 | 72 | ||
72 | if (!vcal) { | 73 | if (!vcal) { |
73 | setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); | 74 | setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); |
74 | return FALSE; | 75 | return FALSE; |
75 | } | 76 | } |
76 | 77 | ||
77 | // any other top-level calendar stuff should be added/initialized here | 78 | // any other top-level calendar stuff should be added/initialized here |
78 | 79 | ||
79 | // put all vobjects into their proper places | 80 | // put all vobjects into their proper places |
80 | populate(vcal); | 81 | populate(vcal); |
81 | 82 | ||
82 | // clean up from vcal API stuff | 83 | // clean up from vcal API stuff |
83 | cleanVObjects(vcal); | 84 | cleanVObjects(vcal); |
84 | cleanStrTbl(); | 85 | cleanStrTbl(); |
85 | 86 | ||
86 | return true; | 87 | return true; |
87 | } | 88 | } |
88 | 89 | ||
89 | 90 | ||
90 | bool VCalFormat::save(Calendar *calendar, const QString &fileName) | 91 | bool VCalFormat::save(Calendar *calendar, const QString &fileName) |
91 | { | 92 | { |
92 | mCalendar = calendar; | 93 | mCalendar = calendar; |
93 | useLocalTime = mCalendar->isLocalTime(); | 94 | if ( ! useLocalTime ) |
95 | useLocalTime = mCalendar->isLocalTime(); | ||
94 | 96 | ||
95 | QString tmpStr; | 97 | QString tmpStr; |
96 | VObject *vcal, *vo; | 98 | VObject *vcal, *vo; |
97 | 99 | ||
98 | 100 | ||
99 | vcal = newVObject(VCCalProp); | 101 | vcal = newVObject(VCCalProp); |
100 | 102 | ||
101 | // addPropValue(vcal,VCLocationProp, "0.0"); | 103 | // addPropValue(vcal,VCLocationProp, "0.0"); |
102 | addPropValue(vcal,VCProdIdProp, productId()); | 104 | addPropValue(vcal,VCProdIdProp, productId()); |
103 | tmpStr = mCalendar->getTimeZoneStr(); | 105 | tmpStr = mCalendar->getTimeZoneStr(); |
104 | //qDebug("mCalendar->getTimeZoneStr() %s",tmpStr.latin1() ); | 106 | //qDebug("mCalendar->getTimeZoneStr() %s",tmpStr.latin1() ); |
105 | addPropValue(vcal,VCTimeZoneProp, tmpStr.local8Bit()); | 107 | addPropValue(vcal,VCTimeZoneProp, tmpStr.local8Bit()); |
106 | addPropValue(vcal,VCVersionProp, _VCAL_VERSION); | 108 | addPropValue(vcal,VCVersionProp, _VCAL_VERSION); |
107 | 109 | ||
108 | // TODO STUFF | 110 | // TODO STUFF |
109 | QPtrList<Todo> todoList = mCalendar->rawTodos(); | 111 | QPtrList<Todo> todoList = mCalendar->rawTodos(); |
110 | QPtrListIterator<Todo> qlt(todoList); | 112 | QPtrListIterator<Todo> qlt(todoList); |
111 | for (; qlt.current(); ++qlt) { | 113 | for (; qlt.current(); ++qlt) { |
112 | vo = eventToVTodo(qlt.current()); | 114 | vo = eventToVTodo(qlt.current()); |
113 | addVObjectProp(vcal, vo); | 115 | addVObjectProp(vcal, vo); |
114 | } | 116 | } |
115 | 117 | ||
116 | // EVENT STUFF | 118 | // EVENT STUFF |
117 | QPtrList<Event> events = mCalendar->rawEvents(); | 119 | QPtrList<Event> events = mCalendar->rawEvents(); |
118 | Event *ev; | 120 | Event *ev; |
119 | for(ev=events.first();ev;ev=events.next()) { | 121 | for(ev=events.first();ev;ev=events.next()) { |
120 | vo = eventToVEvent(ev); | 122 | vo = eventToVEvent(ev); |
121 | addVObjectProp(vcal, vo); | 123 | addVObjectProp(vcal, vo); |
122 | } | 124 | } |
123 | 125 | ||
124 | writeVObjectToFile(QFile::encodeName(fileName).data() ,vcal); | 126 | writeVObjectToFile(QFile::encodeName(fileName).data() ,vcal); |
125 | cleanVObjects(vcal); | 127 | cleanVObjects(vcal); |
126 | cleanStrTbl(); | 128 | cleanStrTbl(); |
127 | 129 | ||
128 | if (QFile::exists(fileName)) { | 130 | if (QFile::exists(fileName)) { |
129 | return true; | 131 | return true; |
130 | } else { | 132 | } else { |
131 | return false; // error | 133 | return false; // error |
132 | } | 134 | } |
133 | } | 135 | } |
134 | 136 | ||
135 | bool VCalFormat::fromString( Calendar *calendar, const QString &text ) | 137 | bool VCalFormat::fromString( Calendar *calendar, const QString &text ) |
136 | { | 138 | { |
137 | // TODO: Factor out VCalFormat::fromString() | 139 | // TODO: Factor out VCalFormat::fromString() |
138 | 140 | ||
139 | QCString data = text.utf8(); | 141 | QCString data = text.utf8(); |
140 | 142 | ||
141 | if ( !data.size() ) return false; | 143 | if ( !data.size() ) return false; |
142 | 144 | ||
143 | VObject *vcal = Parse_MIME( data.data(), data.size()); | 145 | VObject *vcal = Parse_MIME( data.data(), data.size()); |
144 | if ( !vcal ) return false; | 146 | if ( !vcal ) return false; |
145 | 147 | ||
146 | VObjectIterator i; | 148 | VObjectIterator i; |
147 | VObject *curvo; | 149 | VObject *curvo; |
148 | initPropIterator( &i, vcal ); | 150 | initPropIterator( &i, vcal ); |
149 | 151 | ||
150 | // we only take the first object. TODO: parse all incidences. | 152 | // we only take the first object. TODO: parse all incidences. |
151 | do { | 153 | do { |
152 | curvo = nextVObject( &i ); | 154 | curvo = nextVObject( &i ); |
153 | } while ( strcmp( vObjectName( curvo ), VCEventProp ) && | 155 | } while ( strcmp( vObjectName( curvo ), VCEventProp ) && |
154 | strcmp( vObjectName( curvo ), VCTodoProp ) ); | 156 | strcmp( vObjectName( curvo ), VCTodoProp ) ); |
155 | 157 | ||
156 | if ( strcmp( vObjectName( curvo ), VCEventProp ) == 0 ) { | 158 | if ( strcmp( vObjectName( curvo ), VCEventProp ) == 0 ) { |
157 | Event *event = VEventToEvent( curvo ); | 159 | Event *event = VEventToEvent( curvo ); |
158 | calendar->addEvent( event ); | 160 | calendar->addEvent( event ); |
159 | } else { | 161 | } else { |
160 | qDebug("VCalFormat::fromString(): Unknown object type. "); | 162 | qDebug("VCalFormat::fromString(): Unknown object type. "); |
161 | deleteVObject( vcal ); | 163 | deleteVObject( vcal ); |
162 | return false; | 164 | return false; |
163 | } | 165 | } |
164 | 166 | ||
165 | deleteVObject( vcal ); | 167 | deleteVObject( vcal ); |
166 | 168 | ||
167 | return true; | 169 | return true; |
168 | } | 170 | } |
169 | 171 | ||
170 | QString VCalFormat::eventToString( Event * event, Calendar *calendar, bool useLocal) | 172 | QString VCalFormat::eventToString( Event * event, Calendar *calendar, bool useLocal) |
171 | { | 173 | { |
172 | 174 | ||
173 | if ( !event ) return QString::null; | 175 | if ( !event ) return QString::null; |
174 | bool useL = useLocalTime; | 176 | bool useL = useLocalTime; |
175 | useLocalTime = useLocal; | 177 | useLocalTime = useLocal; |
176 | mCalendar = calendar; | 178 | mCalendar = calendar; |
177 | VObject *vevent = eventToVEvent( event ); | 179 | VObject *vevent = eventToVEvent( event ); |
178 | char *buf = writeMemVObject( 0, 0, vevent ); | 180 | char *buf = writeMemVObject( 0, 0, vevent ); |
179 | QString result( buf ); | 181 | QString result( buf ); |
180 | cleanVObject( vevent ); | 182 | cleanVObject( vevent ); |
181 | useLocalTime = useL; | 183 | useLocalTime = useL; |
182 | return result; | 184 | return result; |
183 | } | 185 | } |
184 | QString VCalFormat::todoToString( Todo * todo, Calendar *calendar, bool useLocal ) | 186 | QString VCalFormat::todoToString( Todo * todo, Calendar *calendar, bool useLocal ) |
185 | { | 187 | { |
186 | 188 | ||
187 | if ( !todo ) return QString::null; | 189 | if ( !todo ) return QString::null; |
188 | bool useL = useLocalTime; | 190 | bool useL = useLocalTime; |
189 | useLocalTime = useLocal; | 191 | useLocalTime = useLocal; |
190 | mCalendar = calendar; | 192 | mCalendar = calendar; |
191 | VObject *vevent = eventToVTodo( todo ); | 193 | VObject *vevent = eventToVTodo( todo ); |
192 | char *buf = writeMemVObject( 0, 0, vevent ); | 194 | char *buf = writeMemVObject( 0, 0, vevent ); |
193 | QString result( buf ); | 195 | QString result( buf ); |
194 | cleanVObject( vevent ); | 196 | cleanVObject( vevent ); |
195 | useLocalTime = useL; | 197 | useLocalTime = useL; |
196 | return result; | 198 | return result; |
197 | } | 199 | } |
198 | 200 | ||
199 | QString VCalFormat::toString( Calendar *calendar ) | 201 | QString VCalFormat::toString( Calendar *calendar ) |
200 | { | 202 | { |
201 | // TODO: Factor out VCalFormat::asString() | 203 | // TODO: Factor out VCalFormat::asString() |
202 | 204 | ||
203 | VObject *vcal = newVObject(VCCalProp); | 205 | VObject *vcal = newVObject(VCCalProp); |
204 | 206 | ||
205 | addPropValue( vcal, VCProdIdProp, CalFormat::productId() ); | 207 | addPropValue( vcal, VCProdIdProp, CalFormat::productId() ); |
206 | QString tmpStr = mCalendar->getTimeZoneStr(); | 208 | QString tmpStr = mCalendar->getTimeZoneStr(); |
207 | addPropValue( vcal, VCTimeZoneProp, tmpStr.local8Bit() ); | 209 | addPropValue( vcal, VCTimeZoneProp, tmpStr.local8Bit() ); |
208 | addPropValue( vcal, VCVersionProp, _VCAL_VERSION ); | 210 | addPropValue( vcal, VCVersionProp, _VCAL_VERSION ); |
209 | 211 | ||
210 | // TODO: Use all data. | 212 | // TODO: Use all data. |
211 | QPtrList<Event> events = calendar->events(); | 213 | QPtrList<Event> events = calendar->events(); |
212 | Event *event = events.first(); | 214 | Event *event = events.first(); |
213 | if ( !event ) return QString::null; | 215 | if ( !event ) return QString::null; |
214 | 216 | ||
215 | VObject *vevent = eventToVEvent( event ); | 217 | VObject *vevent = eventToVEvent( event ); |
216 | 218 | ||
217 | addVObjectProp( vcal, vevent ); | 219 | addVObjectProp( vcal, vevent ); |
218 | 220 | ||
219 | char *buf = writeMemVObject( 0, 0, vcal ); | 221 | char *buf = writeMemVObject( 0, 0, vcal ); |
220 | 222 | ||
221 | QString result( buf ); | 223 | QString result( buf ); |
222 | 224 | ||
223 | cleanVObject( vcal ); | 225 | cleanVObject( vcal ); |
224 | 226 | ||
225 | return result; | 227 | return result; |
226 | } | 228 | } |
227 | 229 | ||
228 | VObject *VCalFormat::eventToVTodo(const Todo *anEvent) | 230 | VObject *VCalFormat::eventToVTodo(const Todo *anEvent) |
229 | { | 231 | { |
230 | VObject *vtodo; | 232 | VObject *vtodo; |
231 | QString tmpStr; | 233 | QString tmpStr; |
232 | QStringList tmpStrList; | 234 | QStringList tmpStrList; |
233 | 235 | ||
234 | vtodo = newVObject(VCTodoProp); | 236 | vtodo = newVObject(VCTodoProp); |
235 | 237 | ||
236 | // due date | 238 | // due date |
237 | if (anEvent->hasDueDate()) { | 239 | if (anEvent->hasDueDate()) { |
238 | tmpStr = qDateTimeToISO(anEvent->dtDue(), | 240 | tmpStr = qDateTimeToISO(anEvent->dtDue(), |
239 | !anEvent->doesFloat()); | 241 | !anEvent->doesFloat()); |
240 | addPropValue(vtodo, VCDueProp, tmpStr.local8Bit()); | 242 | addPropValue(vtodo, VCDueProp, tmpStr.local8Bit()); |
241 | } | 243 | } |
242 | 244 | ||
243 | // start date | 245 | // start date |
244 | if (anEvent->hasStartDate()) { | 246 | if (anEvent->hasStartDate()) { |
245 | tmpStr = qDateTimeToISO(anEvent->dtStart(), | 247 | tmpStr = qDateTimeToISO(anEvent->dtStart(), |
246 | !anEvent->doesFloat()); | 248 | !anEvent->doesFloat()); |
247 | addPropValue(vtodo, VCDTstartProp, tmpStr.local8Bit()); | 249 | addPropValue(vtodo, VCDTstartProp, tmpStr.local8Bit()); |
248 | } | 250 | } |
249 | 251 | ||
250 | // creation date | 252 | // creation date |
251 | tmpStr = qDateTimeToISO(anEvent->created()); | 253 | tmpStr = qDateTimeToISO(anEvent->created()); |
252 | addPropValue(vtodo, VCDCreatedProp, tmpStr.local8Bit()); | 254 | addPropValue(vtodo, VCDCreatedProp, tmpStr.local8Bit()); |
253 | 255 | ||
254 | // unique id | 256 | // unique id |
255 | addPropValue(vtodo, VCUniqueStringProp, | 257 | addPropValue(vtodo, VCUniqueStringProp, |
256 | anEvent->uid().local8Bit()); | 258 | anEvent->uid().local8Bit()); |
257 | 259 | ||
258 | // revision | 260 | // revision |
259 | tmpStr.sprintf("%i", anEvent->revision()); | 261 | tmpStr.sprintf("%i", anEvent->revision()); |
260 | addPropValue(vtodo, VCSequenceProp, tmpStr.local8Bit()); | 262 | addPropValue(vtodo, VCSequenceProp, tmpStr.local8Bit()); |
261 | 263 | ||
262 | // last modification date | 264 | // last modification date |
263 | tmpStr = qDateTimeToISO(anEvent->lastModified()); | 265 | tmpStr = qDateTimeToISO(anEvent->lastModified()); |
264 | addPropValue(vtodo, VCLastModifiedProp, tmpStr.local8Bit()); | 266 | addPropValue(vtodo, VCLastModifiedProp, tmpStr.local8Bit()); |
265 | 267 | ||
266 | // organizer stuff | 268 | // organizer stuff |
267 | tmpStr = "MAILTO:" + anEvent->organizer(); | 269 | tmpStr = "MAILTO:" + anEvent->organizer(); |
268 | addPropValue(vtodo, ICOrganizerProp, tmpStr.local8Bit()); | 270 | addPropValue(vtodo, ICOrganizerProp, tmpStr.local8Bit()); |
269 | 271 | ||
270 | // attendees | 272 | // attendees |
271 | if (anEvent->attendeeCount() != 0) { | 273 | if (anEvent->attendeeCount() != 0) { |
272 | QPtrList<Attendee> al = anEvent->attendees(); | 274 | QPtrList<Attendee> al = anEvent->attendees(); |
273 | QPtrListIterator<Attendee> ai(al); | 275 | QPtrListIterator<Attendee> ai(al); |
274 | Attendee *curAttendee; | 276 | Attendee *curAttendee; |
275 | 277 | ||
276 | for (; ai.current(); ++ai) { | 278 | for (; ai.current(); ++ai) { |
277 | curAttendee = ai.current(); | 279 | curAttendee = ai.current(); |
278 | if (!curAttendee->email().isEmpty() && | 280 | if (!curAttendee->email().isEmpty() && |
279 | !curAttendee->name().isEmpty()) | 281 | !curAttendee->name().isEmpty()) |
280 | tmpStr = "MAILTO:" + curAttendee->name() + " <" + | 282 | tmpStr = "MAILTO:" + curAttendee->name() + " <" + |
281 | curAttendee->email() + ">"; | 283 | curAttendee->email() + ">"; |
282 | else if (curAttendee->name().isEmpty()) | 284 | else if (curAttendee->name().isEmpty()) |
283 | tmpStr = "MAILTO: " + curAttendee->email(); | 285 | tmpStr = "MAILTO: " + curAttendee->email(); |
284 | else if (curAttendee->email().isEmpty()) | 286 | else if (curAttendee->email().isEmpty()) |
285 | tmpStr = "MAILTO: " + curAttendee->name(); | 287 | tmpStr = "MAILTO: " + curAttendee->name(); |
286 | else if (curAttendee->name().isEmpty() && | 288 | else if (curAttendee->name().isEmpty() && |
287 | curAttendee->email().isEmpty()) | 289 | curAttendee->email().isEmpty()) |
288 | kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; | 290 | kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; |
289 | VObject *aProp = addPropValue(vtodo, VCAttendeeProp, tmpStr.local8Bit()); | 291 | VObject *aProp = addPropValue(vtodo, VCAttendeeProp, tmpStr.local8Bit()); |
290 | addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE"); | 292 | addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE"); |
291 | addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); | 293 | addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); |
292 | } | 294 | } |
293 | } | 295 | } |
294 | 296 | ||
295 | // description BL: | 297 | // description BL: |
296 | if (!anEvent->description().isEmpty()) { | 298 | if (!anEvent->description().isEmpty()) { |
297 | VObject *d = addPropValue(vtodo, VCDescriptionProp, | 299 | VObject *d = addPropValue(vtodo, VCDescriptionProp, |
298 | anEvent->description().local8Bit()); | 300 | anEvent->description().local8Bit()); |
299 | if (anEvent->description().find('\n') != -1) | 301 | if (anEvent->description().find('\n') != -1) |
300 | addProp(d, VCQuotedPrintableProp); | 302 | addProp(d, VCQuotedPrintableProp); |
301 | } | 303 | } |
302 | 304 | ||
303 | // summary | 305 | // summary |
304 | if (!anEvent->summary().isEmpty()) | 306 | if (!anEvent->summary().isEmpty()) |
305 | addPropValue(vtodo, VCSummaryProp, anEvent->summary().local8Bit()); | 307 | addPropValue(vtodo, VCSummaryProp, anEvent->summary().local8Bit()); |
306 | 308 | ||
307 | if (!anEvent->location().isEmpty()) | 309 | if (!anEvent->location().isEmpty()) |
308 | addPropValue(vtodo, VCLocationProp, anEvent->location().local8Bit()); | 310 | addPropValue(vtodo, VCLocationProp, anEvent->location().local8Bit()); |
309 | 311 | ||
310 | // completed | 312 | // completed |
311 | // status | 313 | // status |
312 | // backward compatibility, KOrganizer used to interpret only these two values | 314 | // backward compatibility, KOrganizer used to interpret only these two values |
313 | addPropValue(vtodo, VCStatusProp, anEvent->isCompleted() ? "COMPLETED" : | 315 | addPropValue(vtodo, VCStatusProp, anEvent->isCompleted() ? "COMPLETED" : |
314 | "NEEDS_ACTION"); | 316 | "NEEDS_ACTION"); |
315 | // completion date | 317 | // completion date |
316 | if (anEvent->hasCompletedDate()) { | 318 | if (anEvent->hasCompletedDate()) { |
317 | tmpStr = qDateTimeToISO(anEvent->completed()); | 319 | tmpStr = qDateTimeToISO(anEvent->completed()); |
318 | addPropValue(vtodo, VCCompletedProp, tmpStr.local8Bit()); | 320 | addPropValue(vtodo, VCCompletedProp, tmpStr.local8Bit()); |
319 | } | 321 | } |
320 | 322 | ||
321 | // priority | 323 | // priority |
322 | tmpStr.sprintf("%i",anEvent->priority()); | 324 | tmpStr.sprintf("%i",anEvent->priority()); |
323 | addPropValue(vtodo, VCPriorityProp, tmpStr.local8Bit()); | 325 | addPropValue(vtodo, VCPriorityProp, tmpStr.local8Bit()); |
324 | 326 | ||
325 | // related event | 327 | // related event |
326 | if (anEvent->relatedTo()) { | 328 | if (anEvent->relatedTo()) { |
327 | addPropValue(vtodo, VCRelatedToProp, | 329 | addPropValue(vtodo, VCRelatedToProp, |
328 | anEvent->relatedTo()->uid().local8Bit()); | 330 | anEvent->relatedTo()->uid().local8Bit()); |
329 | } | 331 | } |
330 | 332 | ||
331 | // categories | 333 | // categories |
332 | tmpStrList = anEvent->categories(); | 334 | tmpStrList = anEvent->categories(); |
333 | tmpStr = ""; | 335 | tmpStr = ""; |
334 | QString catStr; | 336 | QString catStr; |
335 | for ( QStringList::Iterator it = tmpStrList.begin(); | 337 | for ( QStringList::Iterator it = tmpStrList.begin(); |
336 | it != tmpStrList.end(); | 338 | it != tmpStrList.end(); |
337 | ++it ) { | 339 | ++it ) { |
338 | catStr = *it; | 340 | catStr = *it; |
339 | if (catStr[0] == ' ') | 341 | if (catStr[0] == ' ') |
340 | tmpStr += catStr.mid(1); | 342 | tmpStr += catStr.mid(1); |
341 | else | 343 | else |
342 | tmpStr += catStr; | 344 | tmpStr += catStr; |
343 | // this must be a ';' character as the vCalendar specification requires! | 345 | // this must be a ';' character as the vCalendar specification requires! |
344 | // vcc.y has been hacked to translate the ';' to a ',' when the vcal is | 346 | // vcc.y has been hacked to translate the ';' to a ',' when the vcal is |
345 | // read in. | 347 | // read in. |
346 | tmpStr += ";"; | 348 | tmpStr += ";"; |
347 | } | 349 | } |
348 | if (!tmpStr.isEmpty()) { | 350 | if (!tmpStr.isEmpty()) { |
349 | tmpStr.truncate(tmpStr.length()-1); | 351 | tmpStr.truncate(tmpStr.length()-1); |
350 | addPropValue(vtodo, VCCategoriesProp, tmpStr.local8Bit()); | 352 | addPropValue(vtodo, VCCategoriesProp, tmpStr.local8Bit()); |
351 | } | 353 | } |
352 | 354 | ||
353 | // alarm stuff | 355 | // alarm stuff |
354 | kdDebug(5800) << "vcalformat::eventToVTodo was called" << endl; | 356 | kdDebug(5800) << "vcalformat::eventToVTodo was called" << endl; |
355 | QPtrList<Alarm> alarms = anEvent->alarms(); | 357 | QPtrList<Alarm> alarms = anEvent->alarms(); |
356 | Alarm* alarm; | 358 | Alarm* alarm; |
357 | for (alarm = alarms.first(); alarm; alarm = alarms.next()) { | 359 | for (alarm = alarms.first(); alarm; alarm = alarms.next()) { |
358 | if (alarm->enabled()) { | 360 | if (alarm->enabled()) { |
359 | VObject *a; | 361 | VObject *a; |
360 | tmpStr = qDateTimeToISO(alarm->time()); | 362 | tmpStr = qDateTimeToISO(alarm->time()); |
361 | if (alarm->type() == Alarm::Audio) { | 363 | if (alarm->type() == Alarm::Audio) { |
362 | a = addProp(vtodo, VCAAlarmProp); | 364 | a = addProp(vtodo, VCAAlarmProp); |
363 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 365 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
364 | addPropValue(a, VCRepeatCountProp, "1"); | 366 | addPropValue(a, VCRepeatCountProp, "1"); |
365 | addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); | 367 | addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); |
366 | } | 368 | } |
367 | else if (alarm->type() == Alarm::Procedure) { | 369 | else if (alarm->type() == Alarm::Procedure) { |
368 | a = addProp(vtodo, VCPAlarmProp); | 370 | a = addProp(vtodo, VCPAlarmProp); |
369 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 371 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
370 | addPropValue(a, VCRepeatCountProp, "1"); | 372 | addPropValue(a, VCRepeatCountProp, "1"); |
371 | addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); | 373 | addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); |
372 | } else { | 374 | } else { |
373 | a = addProp(vtodo, VCDAlarmProp); | 375 | a = addProp(vtodo, VCDAlarmProp); |
374 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 376 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
375 | addPropValue(a, VCRepeatCountProp, "1"); | 377 | addPropValue(a, VCRepeatCountProp, "1"); |
376 | addPropValue(a, VCDisplayStringProp, "beep!"); | 378 | addPropValue(a, VCDisplayStringProp, "beep!"); |
377 | } | 379 | } |
378 | } | 380 | } |
379 | } | 381 | } |
380 | 382 | ||
381 | if (anEvent->pilotId()) { | 383 | if (anEvent->pilotId()) { |
382 | // pilot sync stuff | 384 | // pilot sync stuff |
383 | tmpStr.sprintf("%i",anEvent->pilotId()); | 385 | tmpStr.sprintf("%i",anEvent->pilotId()); |
384 | addPropValue(vtodo, XPilotIdProp, tmpStr.local8Bit()); | 386 | addPropValue(vtodo, XPilotIdProp, tmpStr.local8Bit()); |
385 | tmpStr.sprintf("%i",anEvent->syncStatus()); | 387 | tmpStr.sprintf("%i",anEvent->syncStatus()); |
386 | addPropValue(vtodo, XPilotStatusProp, tmpStr.local8Bit()); | 388 | addPropValue(vtodo, XPilotStatusProp, tmpStr.local8Bit()); |
387 | } | 389 | } |
388 | 390 | ||
389 | return vtodo; | 391 | return vtodo; |
390 | } | 392 | } |
391 | 393 | ||
392 | VObject* VCalFormat::eventToVEvent(const Event *anEvent) | 394 | VObject* VCalFormat::eventToVEvent(const Event *anEvent) |
393 | { | 395 | { |
394 | VObject *vevent; | 396 | VObject *vevent; |
395 | QString tmpStr; | 397 | QString tmpStr; |
396 | QStringList tmpStrList; | 398 | QStringList tmpStrList; |
397 | 399 | ||
398 | vevent = newVObject(VCEventProp); | 400 | vevent = newVObject(VCEventProp); |
399 | 401 | ||
400 | // start and end time | 402 | // start and end time |
401 | tmpStr = qDateTimeToISO(anEvent->dtStart(), | 403 | tmpStr = qDateTimeToISO(anEvent->dtStart(), |
402 | !anEvent->doesFloat()); | 404 | !anEvent->doesFloat()); |
403 | addPropValue(vevent, VCDTstartProp, tmpStr.local8Bit()); | 405 | addPropValue(vevent, VCDTstartProp, tmpStr.local8Bit()); |
404 | 406 | ||
405 | // events that have time associated but take up no time should | 407 | // events that have time associated but take up no time should |
406 | // not have both DTSTART and DTEND. | 408 | // not have both DTSTART and DTEND. |
407 | if (anEvent->dtStart() != anEvent->dtEnd()) { | 409 | if (anEvent->dtStart() != anEvent->dtEnd()) { |
408 | tmpStr = qDateTimeToISO(anEvent->dtEnd(), | 410 | tmpStr = qDateTimeToISO(anEvent->dtEnd(), |
409 | !anEvent->doesFloat()); | 411 | !anEvent->doesFloat()); |
410 | addPropValue(vevent, VCDTendProp, tmpStr.local8Bit()); | 412 | addPropValue(vevent, VCDTendProp, tmpStr.local8Bit()); |
411 | } | 413 | } |
412 | 414 | ||
413 | // creation date | 415 | // creation date |
414 | tmpStr = qDateTimeToISO(anEvent->created()); | 416 | tmpStr = qDateTimeToISO(anEvent->created()); |
415 | addPropValue(vevent, VCDCreatedProp, tmpStr.local8Bit()); | 417 | addPropValue(vevent, VCDCreatedProp, tmpStr.local8Bit()); |
416 | 418 | ||
417 | // unique id | 419 | // unique id |
418 | addPropValue(vevent, VCUniqueStringProp, | 420 | addPropValue(vevent, VCUniqueStringProp, |
419 | anEvent->uid().local8Bit()); | 421 | anEvent->uid().local8Bit()); |
420 | 422 | ||
421 | // revision | 423 | // revision |
422 | tmpStr.sprintf("%i", anEvent->revision()); | 424 | tmpStr.sprintf("%i", anEvent->revision()); |
423 | addPropValue(vevent, VCSequenceProp, tmpStr.local8Bit()); | 425 | addPropValue(vevent, VCSequenceProp, tmpStr.local8Bit()); |
424 | 426 | ||
425 | // last modification date | 427 | // last modification date |
426 | tmpStr = qDateTimeToISO(anEvent->lastModified()); | 428 | tmpStr = qDateTimeToISO(anEvent->lastModified()); |
427 | addPropValue(vevent, VCLastModifiedProp, tmpStr.local8Bit()); | 429 | addPropValue(vevent, VCLastModifiedProp, tmpStr.local8Bit()); |
428 | 430 | ||
429 | // attendee and organizer stuff | 431 | // attendee and organizer stuff |
430 | tmpStr = "MAILTO:" + anEvent->organizer(); | 432 | tmpStr = "MAILTO:" + anEvent->organizer(); |
431 | addPropValue(vevent, ICOrganizerProp, tmpStr.local8Bit()); | 433 | addPropValue(vevent, ICOrganizerProp, tmpStr.local8Bit()); |
432 | 434 | ||
433 | if (anEvent->attendeeCount() != 0) { | 435 | if (anEvent->attendeeCount() != 0) { |
434 | QPtrList<Attendee> al = anEvent->attendees(); | 436 | QPtrList<Attendee> al = anEvent->attendees(); |
435 | QPtrListIterator<Attendee> ai(al); | 437 | QPtrListIterator<Attendee> ai(al); |
436 | Attendee *curAttendee; | 438 | Attendee *curAttendee; |
437 | 439 | ||
438 | // TODO: Put this functionality into Attendee class | 440 | // TODO: Put this functionality into Attendee class |
439 | for (; ai.current(); ++ai) { | 441 | for (; ai.current(); ++ai) { |
440 | curAttendee = ai.current(); | 442 | curAttendee = ai.current(); |
441 | if (!curAttendee->email().isEmpty() && | 443 | if (!curAttendee->email().isEmpty() && |
442 | !curAttendee->name().isEmpty()) | 444 | !curAttendee->name().isEmpty()) |
443 | tmpStr = "MAILTO:" + curAttendee->name() + " <" + | 445 | tmpStr = "MAILTO:" + curAttendee->name() + " <" + |
444 | curAttendee->email() + ">"; | 446 | curAttendee->email() + ">"; |
445 | else if (curAttendee->name().isEmpty()) | 447 | else if (curAttendee->name().isEmpty()) |
446 | tmpStr = "MAILTO: " + curAttendee->email(); | 448 | tmpStr = "MAILTO: " + curAttendee->email(); |
447 | else if (curAttendee->email().isEmpty()) | 449 | else if (curAttendee->email().isEmpty()) |
448 | tmpStr = "MAILTO: " + curAttendee->name(); | 450 | tmpStr = "MAILTO: " + curAttendee->name(); |
449 | else if (curAttendee->name().isEmpty() && | 451 | else if (curAttendee->name().isEmpty() && |
450 | curAttendee->email().isEmpty()) | 452 | curAttendee->email().isEmpty()) |
451 | kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; | 453 | kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; |
452 | VObject *aProp = addPropValue(vevent, VCAttendeeProp, tmpStr.local8Bit()); | 454 | VObject *aProp = addPropValue(vevent, VCAttendeeProp, tmpStr.local8Bit()); |
453 | addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE");; | 455 | addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE");; |
454 | addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); | 456 | addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); |
455 | } | 457 | } |
456 | } | 458 | } |
457 | 459 | ||
458 | // recurrence rule stuff | 460 | // recurrence rule stuff |
459 | if (anEvent->recurrence()->doesRecur()) { | 461 | if (anEvent->recurrence()->doesRecur()) { |
460 | // some more variables | 462 | // some more variables |
461 | QPtrList<Recurrence::rMonthPos> tmpPositions; | 463 | QPtrList<Recurrence::rMonthPos> tmpPositions; |
462 | QPtrList<int> tmpDays; | 464 | QPtrList<int> tmpDays; |
463 | int *tmpDay; | 465 | int *tmpDay; |
464 | Recurrence::rMonthPos *tmpPos; | 466 | Recurrence::rMonthPos *tmpPos; |
465 | QString tmpStr2; | 467 | QString tmpStr2; |
466 | int i; | 468 | int i; |
467 | 469 | ||
468 | switch(anEvent->recurrence()->doesRecur()) { | 470 | switch(anEvent->recurrence()->doesRecur()) { |
469 | case Recurrence::rDaily: | 471 | case Recurrence::rDaily: |
470 | tmpStr.sprintf("D%i ",anEvent->recurrence()->frequency()); | 472 | tmpStr.sprintf("D%i ",anEvent->recurrence()->frequency()); |
471 | // if (anEvent->rDuration > 0) | 473 | // if (anEvent->rDuration > 0) |
472 | //tmpStr += "#"; | 474 | //tmpStr += "#"; |
473 | break; | 475 | break; |
474 | case Recurrence::rWeekly: | 476 | case Recurrence::rWeekly: |
475 | tmpStr.sprintf("W%i ",anEvent->recurrence()->frequency()); | 477 | tmpStr.sprintf("W%i ",anEvent->recurrence()->frequency()); |
476 | for (i = 0; i < 7; i++) { | 478 | for (i = 0; i < 7; i++) { |
477 | if (anEvent->recurrence()->days().testBit(i)) | 479 | if (anEvent->recurrence()->days().testBit(i)) |
478 | tmpStr += dayFromNum(i); | 480 | tmpStr += dayFromNum(i); |
479 | } | 481 | } |
480 | break; | 482 | break; |
481 | case Recurrence::rMonthlyPos: | 483 | case Recurrence::rMonthlyPos: |
482 | tmpStr.sprintf("MP%i ", anEvent->recurrence()->frequency()); | 484 | tmpStr.sprintf("MP%i ", anEvent->recurrence()->frequency()); |
483 | // write out all rMonthPos's | 485 | // write out all rMonthPos's |
484 | tmpPositions = anEvent->recurrence()->monthPositions(); | 486 | tmpPositions = anEvent->recurrence()->monthPositions(); |
485 | for (tmpPos = tmpPositions.first(); | 487 | for (tmpPos = tmpPositions.first(); |
486 | tmpPos; | 488 | tmpPos; |
487 | tmpPos = tmpPositions.next()) { | 489 | tmpPos = tmpPositions.next()) { |
488 | 490 | ||
489 | tmpStr2.sprintf("%i", tmpPos->rPos); | 491 | tmpStr2.sprintf("%i", tmpPos->rPos); |
490 | if (tmpPos->negative) | 492 | if (tmpPos->negative) |
491 | tmpStr2 += "- "; | 493 | tmpStr2 += "- "; |
492 | else | 494 | else |
493 | tmpStr2 += "+ "; | 495 | tmpStr2 += "+ "; |
494 | tmpStr += tmpStr2; | 496 | tmpStr += tmpStr2; |
495 | for (i = 0; i < 7; i++) { | 497 | for (i = 0; i < 7; i++) { |
496 | if (tmpPos->rDays.testBit(i)) | 498 | if (tmpPos->rDays.testBit(i)) |
497 | tmpStr += dayFromNum(i); | 499 | tmpStr += dayFromNum(i); |
498 | } | 500 | } |
499 | } // loop for all rMonthPos's | 501 | } // loop for all rMonthPos's |
500 | break; | 502 | break; |
501 | case Recurrence::rMonthlyDay: | 503 | case Recurrence::rMonthlyDay: |
502 | tmpStr.sprintf("MD%i ", anEvent->recurrence()->frequency()); | 504 | tmpStr.sprintf("MD%i ", anEvent->recurrence()->frequency()); |
503 | // write out all rMonthDays; | 505 | // write out all rMonthDays; |
504 | tmpDays = anEvent->recurrence()->monthDays(); | 506 | tmpDays = anEvent->recurrence()->monthDays(); |
505 | for (tmpDay = tmpDays.first(); | 507 | for (tmpDay = tmpDays.first(); |
506 | tmpDay; | 508 | tmpDay; |
507 | tmpDay = tmpDays.next()) { | 509 | tmpDay = tmpDays.next()) { |
508 | tmpStr2.sprintf("%i ", *tmpDay); | 510 | tmpStr2.sprintf("%i ", *tmpDay); |
509 | tmpStr += tmpStr2; | 511 | tmpStr += tmpStr2; |
510 | } | 512 | } |
511 | break; | 513 | break; |
512 | case Recurrence::rYearlyMonth: | 514 | case Recurrence::rYearlyMonth: |
513 | tmpStr.sprintf("YM%i ", anEvent->recurrence()->frequency()); | 515 | tmpStr.sprintf("YM%i ", anEvent->recurrence()->frequency()); |
514 | // write out all the rYearNums; | 516 | // write out all the rYearNums; |
515 | tmpDays = anEvent->recurrence()->yearNums(); | 517 | tmpDays = anEvent->recurrence()->yearNums(); |
516 | for (tmpDay = tmpDays.first(); | 518 | for (tmpDay = tmpDays.first(); |
517 | tmpDay; | 519 | tmpDay; |
518 | tmpDay = tmpDays.next()) { | 520 | tmpDay = tmpDays.next()) { |
519 | tmpStr2.sprintf("%i ", *tmpDay); | 521 | tmpStr2.sprintf("%i ", *tmpDay); |
520 | tmpStr += tmpStr2; | 522 | tmpStr += tmpStr2; |
521 | } | 523 | } |
522 | break; | 524 | break; |
523 | case Recurrence::rYearlyDay: | 525 | case Recurrence::rYearlyDay: |
524 | tmpStr.sprintf("YD%i ", anEvent->recurrence()->frequency()); | 526 | tmpStr.sprintf("YD%i ", anEvent->recurrence()->frequency()); |
525 | // write out all the rYearNums; | 527 | // write out all the rYearNums; |
526 | tmpDays = anEvent->recurrence()->yearNums(); | 528 | tmpDays = anEvent->recurrence()->yearNums(); |
527 | for (tmpDay = tmpDays.first(); | 529 | for (tmpDay = tmpDays.first(); |
528 | tmpDay; | 530 | tmpDay; |
529 | tmpDay = tmpDays.next()) { | 531 | tmpDay = tmpDays.next()) { |
530 | tmpStr2.sprintf("%i ", *tmpDay); | 532 | tmpStr2.sprintf("%i ", *tmpDay); |
531 | tmpStr += tmpStr2; | 533 | tmpStr += tmpStr2; |
532 | } | 534 | } |
533 | break; | 535 | break; |
534 | default: | 536 | default: |
535 | kdDebug(5800) << "ERROR, it should never get here in eventToVEvent!" << endl; | 537 | kdDebug(5800) << "ERROR, it should never get here in eventToVEvent!" << endl; |
536 | break; | 538 | break; |
537 | } // switch | 539 | } // switch |
538 | 540 | ||
539 | if (anEvent->recurrence()->duration() > 0) { | 541 | if (anEvent->recurrence()->duration() > 0) { |
540 | tmpStr2.sprintf("#%i",anEvent->recurrence()->duration()); | 542 | tmpStr2.sprintf("#%i",anEvent->recurrence()->duration()); |
541 | tmpStr += tmpStr2; | 543 | tmpStr += tmpStr2; |
542 | } else if (anEvent->recurrence()->duration() == -1) { | 544 | } else if (anEvent->recurrence()->duration() == -1) { |
543 | tmpStr += "#0"; // defined as repeat forever | 545 | tmpStr += "#0"; // defined as repeat forever |
544 | } else { | 546 | } else { |
545 | tmpStr += qDateTimeToISO(anEvent->recurrence()->endDate(), FALSE); | 547 | tmpStr += qDateTimeToISO(anEvent->recurrence()->endDate(), FALSE); |
546 | } | 548 | } |
547 | addPropValue(vevent,VCRRuleProp, tmpStr.local8Bit()); | 549 | addPropValue(vevent,VCRRuleProp, tmpStr.local8Bit()); |
548 | 550 | ||
549 | } // event repeats | 551 | } // event repeats |
550 | 552 | ||
551 | // exceptions to recurrence | 553 | // exceptions to recurrence |
552 | DateList dateList = anEvent->exDates(); | 554 | DateList dateList = anEvent->exDates(); |
553 | DateList::ConstIterator it; | 555 | DateList::ConstIterator it; |
554 | QString tmpStr2; | 556 | QString tmpStr2; |
555 | 557 | ||
556 | for (it = dateList.begin(); it != dateList.end(); ++it) { | 558 | for (it = dateList.begin(); it != dateList.end(); ++it) { |
557 | tmpStr = qDateToISO(*it) + ";"; | 559 | tmpStr = qDateToISO(*it) + ";"; |
558 | tmpStr2 += tmpStr; | 560 | tmpStr2 += tmpStr; |
559 | } | 561 | } |
560 | if (!tmpStr2.isEmpty()) { | 562 | if (!tmpStr2.isEmpty()) { |
561 | tmpStr2.truncate(tmpStr2.length()-1); | 563 | tmpStr2.truncate(tmpStr2.length()-1); |
562 | addPropValue(vevent, VCExpDateProp, tmpStr2.local8Bit()); | 564 | addPropValue(vevent, VCExpDateProp, tmpStr2.local8Bit()); |
563 | } | 565 | } |
564 | 566 | ||
565 | // description | 567 | // description |
566 | if (!anEvent->description().isEmpty()) { | 568 | if (!anEvent->description().isEmpty()) { |
567 | VObject *d = addPropValue(vevent, VCDescriptionProp, | 569 | VObject *d = addPropValue(vevent, VCDescriptionProp, |
568 | anEvent->description().local8Bit()); | 570 | anEvent->description().local8Bit()); |
569 | if (anEvent->description().find('\n') != -1) | 571 | if (anEvent->description().find('\n') != -1) |
570 | addProp(d, VCQuotedPrintableProp); | 572 | addProp(d, VCQuotedPrintableProp); |
571 | } | 573 | } |
572 | 574 | ||
573 | // summary | 575 | // summary |
574 | if (!anEvent->summary().isEmpty()) | 576 | if (!anEvent->summary().isEmpty()) |
575 | addPropValue(vevent, VCSummaryProp, anEvent->summary().local8Bit()); | 577 | addPropValue(vevent, VCSummaryProp, anEvent->summary().local8Bit()); |
576 | 578 | ||
577 | if (!anEvent->location().isEmpty()) | 579 | if (!anEvent->location().isEmpty()) |
578 | addPropValue(vevent, VCLocationProp, anEvent->location().local8Bit()); | 580 | addPropValue(vevent, VCLocationProp, anEvent->location().local8Bit()); |
579 | 581 | ||
580 | // status | 582 | // status |
581 | // TODO: define Event status | 583 | // TODO: define Event status |
582 | // addPropValue(vevent, VCStatusProp, anEvent->statusStr().local8Bit()); | 584 | // addPropValue(vevent, VCStatusProp, anEvent->statusStr().local8Bit()); |
583 | 585 | ||
584 | // secrecy | 586 | // secrecy |
585 | const char *text = 0; | 587 | const char *text = 0; |
586 | switch (anEvent->secrecy()) { | 588 | switch (anEvent->secrecy()) { |
587 | case Incidence::SecrecyPublic: | 589 | case Incidence::SecrecyPublic: |
588 | text = "PUBLIC"; | 590 | text = "PUBLIC"; |
589 | break; | 591 | break; |
590 | case Incidence::SecrecyPrivate: | 592 | case Incidence::SecrecyPrivate: |
591 | text = "PRIVATE"; | 593 | text = "PRIVATE"; |
592 | break; | 594 | break; |
593 | case Incidence::SecrecyConfidential: | 595 | case Incidence::SecrecyConfidential: |
594 | text = "CONFIDENTIAL"; | 596 | text = "CONFIDENTIAL"; |
595 | break; | 597 | break; |
596 | } | 598 | } |
597 | if (text) { | 599 | if (text) { |
598 | addPropValue(vevent, VCClassProp, text); | 600 | addPropValue(vevent, VCClassProp, text); |
599 | } | 601 | } |
600 | 602 | ||
601 | // categories | 603 | // categories |
602 | tmpStrList = anEvent->categories(); | 604 | tmpStrList = anEvent->categories(); |
603 | tmpStr = ""; | 605 | tmpStr = ""; |
604 | QString catStr; | 606 | QString catStr; |
605 | for ( QStringList::Iterator it = tmpStrList.begin(); | 607 | for ( QStringList::Iterator it = tmpStrList.begin(); |
606 | it != tmpStrList.end(); | 608 | it != tmpStrList.end(); |
607 | ++it ) { | 609 | ++it ) { |
608 | catStr = *it; | 610 | catStr = *it; |
609 | if (catStr[0] == ' ') | 611 | if (catStr[0] == ' ') |
610 | tmpStr += catStr.mid(1); | 612 | tmpStr += catStr.mid(1); |
611 | else | 613 | else |
612 | tmpStr += catStr; | 614 | tmpStr += catStr; |
613 | // this must be a ';' character as the vCalendar specification requires! | 615 | // this must be a ';' character as the vCalendar specification requires! |
614 | // vcc.y has been hacked to translate the ';' to a ',' when the vcal is | 616 | // vcc.y has been hacked to translate the ';' to a ',' when the vcal is |
615 | // read in. | 617 | // read in. |
616 | tmpStr += ";"; | 618 | tmpStr += ";"; |
617 | } | 619 | } |
618 | if (!tmpStr.isEmpty()) { | 620 | if (!tmpStr.isEmpty()) { |
619 | tmpStr.truncate(tmpStr.length()-1); | 621 | tmpStr.truncate(tmpStr.length()-1); |
620 | addPropValue(vevent, VCCategoriesProp, tmpStr.local8Bit()); | 622 | addPropValue(vevent, VCCategoriesProp, tmpStr.local8Bit()); |
621 | } | 623 | } |
622 | 624 | ||
623 | // attachments | 625 | // attachments |
624 | // TODO: handle binary attachments! | 626 | // TODO: handle binary attachments! |
625 | QPtrList<Attachment> attachments = anEvent->attachments(); | 627 | QPtrList<Attachment> attachments = anEvent->attachments(); |
626 | for ( Attachment *at = attachments.first(); at; at = attachments.next() ) | 628 | for ( Attachment *at = attachments.first(); at; at = attachments.next() ) |
627 | addPropValue(vevent, VCAttachProp, at->uri().local8Bit()); | 629 | addPropValue(vevent, VCAttachProp, at->uri().local8Bit()); |
628 | 630 | ||
629 | // resources | 631 | // resources |
630 | tmpStrList = anEvent->resources(); | 632 | tmpStrList = anEvent->resources(); |
631 | tmpStr = tmpStrList.join(";"); | 633 | tmpStr = tmpStrList.join(";"); |
632 | if (!tmpStr.isEmpty()) | 634 | if (!tmpStr.isEmpty()) |
633 | addPropValue(vevent, VCResourcesProp, tmpStr.local8Bit()); | 635 | addPropValue(vevent, VCResourcesProp, tmpStr.local8Bit()); |
634 | 636 | ||
635 | // alarm stuff | 637 | // alarm stuff |
636 | QPtrList<Alarm> alarms = anEvent->alarms(); | 638 | QPtrList<Alarm> alarms = anEvent->alarms(); |
637 | Alarm* alarm; | 639 | Alarm* alarm; |
638 | for (alarm = alarms.first(); alarm; alarm = alarms.next()) { | 640 | for (alarm = alarms.first(); alarm; alarm = alarms.next()) { |
639 | if (alarm->enabled()) { | 641 | if (alarm->enabled()) { |
640 | VObject *a ; | 642 | VObject *a ; |
641 | tmpStr = qDateTimeToISO(alarm->time()); | 643 | tmpStr = qDateTimeToISO(alarm->time()); |
642 | if (alarm->type() == Alarm::Audio) { | 644 | if (alarm->type() == Alarm::Audio) { |
643 | a = addProp(vevent, VCAAlarmProp); | 645 | a = addProp(vevent, VCAAlarmProp); |
644 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 646 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
645 | addPropValue(a, VCRepeatCountProp, "1"); | 647 | addPropValue(a, VCRepeatCountProp, "1"); |
646 | addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); | 648 | addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); |
647 | } | 649 | } |
648 | if (alarm->type() == Alarm::Procedure) { | 650 | if (alarm->type() == Alarm::Procedure) { |
649 | a = addProp(vevent, VCPAlarmProp); | 651 | a = addProp(vevent, VCPAlarmProp); |
650 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 652 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
651 | addPropValue(a, VCRepeatCountProp, "1"); | 653 | addPropValue(a, VCRepeatCountProp, "1"); |
652 | addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); | 654 | addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); |
653 | } else { | 655 | } else { |
654 | a = addProp(vevent, VCDAlarmProp); | 656 | a = addProp(vevent, VCDAlarmProp); |
655 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 657 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
656 | addPropValue(a, VCRepeatCountProp, "1"); | 658 | addPropValue(a, VCRepeatCountProp, "1"); |
657 | addPropValue(a, VCDisplayStringProp, "beep!"); | 659 | addPropValue(a, VCDisplayStringProp, "beep!"); |
658 | 660 | ||
659 | } | 661 | } |
660 | } | 662 | } |
661 | } | 663 | } |
662 | 664 | ||
663 | // priority | 665 | // priority |
664 | tmpStr.sprintf("%i",anEvent->priority()); | 666 | tmpStr.sprintf("%i",anEvent->priority()); |
665 | addPropValue(vevent, VCPriorityProp, tmpStr.local8Bit()); | 667 | addPropValue(vevent, VCPriorityProp, tmpStr.local8Bit()); |
666 | 668 | ||
667 | // transparency | 669 | // transparency |
668 | tmpStr.sprintf("%i",anEvent->transparency()); | 670 | tmpStr.sprintf("%i",anEvent->transparency()); |
669 | addPropValue(vevent, VCTranspProp, tmpStr.local8Bit()); | 671 | addPropValue(vevent, VCTranspProp, tmpStr.local8Bit()); |
670 | 672 | ||
671 | // related event | 673 | // related event |
672 | if (anEvent->relatedTo()) { | 674 | if (anEvent->relatedTo()) { |
673 | addPropValue(vevent, VCRelatedToProp, | 675 | addPropValue(vevent, VCRelatedToProp, |
674 | anEvent->relatedTo()->uid().local8Bit()); | 676 | anEvent->relatedTo()->uid().local8Bit()); |
675 | } | 677 | } |
676 | 678 | ||
677 | if (anEvent->pilotId()) { | 679 | if (anEvent->pilotId()) { |
678 | // pilot sync stuff | 680 | // pilot sync stuff |
679 | tmpStr.sprintf("%i",anEvent->pilotId()); | 681 | tmpStr.sprintf("%i",anEvent->pilotId()); |
680 | addPropValue(vevent, XPilotIdProp, tmpStr.local8Bit()); | 682 | addPropValue(vevent, XPilotIdProp, tmpStr.local8Bit()); |
681 | tmpStr.sprintf("%i",anEvent->syncStatus()); | 683 | tmpStr.sprintf("%i",anEvent->syncStatus()); |
682 | addPropValue(vevent, XPilotStatusProp, tmpStr.local8Bit()); | 684 | addPropValue(vevent, XPilotStatusProp, tmpStr.local8Bit()); |
683 | } | 685 | } |
684 | 686 | ||
685 | return vevent; | 687 | return vevent; |
686 | } | 688 | } |
687 | 689 | ||
688 | Todo *VCalFormat::VTodoToEvent(VObject *vtodo) | 690 | Todo *VCalFormat::VTodoToEvent(VObject *vtodo) |
689 | { | 691 | { |
690 | VObject *vo; | 692 | VObject *vo; |
691 | VObjectIterator voi; | 693 | VObjectIterator voi; |
692 | char *s; | 694 | char *s; |
693 | 695 | ||
694 | Todo *anEvent = new Todo; | 696 | Todo *anEvent = new Todo; |
695 | 697 | ||
696 | // creation date | 698 | // creation date |
697 | if ((vo = isAPropertyOf(vtodo, VCDCreatedProp)) != 0) { | 699 | if ((vo = isAPropertyOf(vtodo, VCDCreatedProp)) != 0) { |
698 | anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 700 | anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
699 | deleteStr(s); | 701 | deleteStr(s); |
700 | } | 702 | } |
701 | 703 | ||
702 | // unique id | 704 | // unique id |
703 | vo = isAPropertyOf(vtodo, VCUniqueStringProp); | 705 | vo = isAPropertyOf(vtodo, VCUniqueStringProp); |
704 | // while the UID property is preferred, it is not required. We'll use the | 706 | // while the UID property is preferred, it is not required. We'll use the |
705 | // default Event UID if none is given. | 707 | // default Event UID if none is given. |
706 | if (vo) { | 708 | if (vo) { |
707 | anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); | 709 | anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); |
708 | deleteStr(s); | 710 | deleteStr(s); |
709 | } | 711 | } |
710 | 712 | ||
711 | // last modification date | 713 | // last modification date |
712 | if ((vo = isAPropertyOf(vtodo, VCLastModifiedProp)) != 0) { | 714 | if ((vo = isAPropertyOf(vtodo, VCLastModifiedProp)) != 0) { |
713 | anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 715 | anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
714 | deleteStr(s); | 716 | deleteStr(s); |
715 | } | 717 | } |
716 | else | 718 | else |
717 | anEvent->setLastModified(QDateTime(QDate::currentDate(), | 719 | anEvent->setLastModified(QDateTime(QDate::currentDate(), |
718 | QTime::currentTime())); | 720 | QTime::currentTime())); |
719 | 721 | ||
720 | // organizer | 722 | // organizer |
721 | // if our extension property for the event's ORGANIZER exists, add it. | 723 | // if our extension property for the event's ORGANIZER exists, add it. |
722 | if ((vo = isAPropertyOf(vtodo, ICOrganizerProp)) != 0) { | 724 | if ((vo = isAPropertyOf(vtodo, ICOrganizerProp)) != 0) { |
723 | anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo))); | 725 | anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo))); |
724 | deleteStr(s); | 726 | deleteStr(s); |
725 | } else { | 727 | } else { |
726 | anEvent->setOrganizer(mCalendar->getEmail()); | 728 | anEvent->setOrganizer(mCalendar->getEmail()); |
727 | } | 729 | } |
728 | 730 | ||
729 | // attendees. | 731 | // attendees. |
730 | initPropIterator(&voi, vtodo); | 732 | initPropIterator(&voi, vtodo); |
731 | while (moreIteration(&voi)) { | 733 | while (moreIteration(&voi)) { |
732 | vo = nextVObject(&voi); | 734 | vo = nextVObject(&voi); |
733 | if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) { | 735 | if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) { |
734 | Attendee *a; | 736 | Attendee *a; |
735 | VObject *vp; | 737 | VObject *vp; |
736 | s = fakeCString(vObjectUStringZValue(vo)); | 738 | s = fakeCString(vObjectUStringZValue(vo)); |
737 | QString tmpStr = QString::fromLocal8Bit(s); | 739 | QString tmpStr = QString::fromLocal8Bit(s); |
738 | deleteStr(s); | 740 | deleteStr(s); |
739 | tmpStr = tmpStr.simplifyWhiteSpace(); | 741 | tmpStr = tmpStr.simplifyWhiteSpace(); |
740 | int emailPos1, emailPos2; | 742 | int emailPos1, emailPos2; |
741 | if ((emailPos1 = tmpStr.find('<')) > 0) { | 743 | if ((emailPos1 = tmpStr.find('<')) > 0) { |
742 | // both email address and name | 744 | // both email address and name |
743 | emailPos2 = tmpStr.findRev('>'); | 745 | emailPos2 = tmpStr.findRev('>'); |
744 | a = new Attendee(tmpStr.left(emailPos1 - 1), | 746 | a = new Attendee(tmpStr.left(emailPos1 - 1), |
745 | tmpStr.mid(emailPos1 + 1, | 747 | tmpStr.mid(emailPos1 + 1, |
746 | emailPos2 - (emailPos1 + 1))); | 748 | emailPos2 - (emailPos1 + 1))); |
747 | } else if (tmpStr.find('@') > 0) { | 749 | } else if (tmpStr.find('@') > 0) { |
748 | // just an email address | 750 | // just an email address |
749 | a = new Attendee(0, tmpStr); | 751 | a = new Attendee(0, tmpStr); |
750 | } else { | 752 | } else { |
751 | // just a name | 753 | // just a name |
752 | QString email = tmpStr.replace( QRegExp(" "), "." ); | 754 | QString email = tmpStr.replace( QRegExp(" "), "." ); |
753 | a = new Attendee(tmpStr,email); | 755 | a = new Attendee(tmpStr,email); |
754 | } | 756 | } |
755 | 757 | ||
756 | // is there an RSVP property? | 758 | // is there an RSVP property? |
757 | if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0) | 759 | if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0) |
758 | a->setRSVP(vObjectStringZValue(vp)); | 760 | a->setRSVP(vObjectStringZValue(vp)); |
759 | // is there a status property? | 761 | // is there a status property? |
760 | if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0) | 762 | if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0) |
761 | a->setStatus(readStatus(vObjectStringZValue(vp))); | 763 | a->setStatus(readStatus(vObjectStringZValue(vp))); |
762 | // add the attendee | 764 | // add the attendee |
763 | anEvent->addAttendee(a); | 765 | anEvent->addAttendee(a); |
764 | } | 766 | } |
765 | } | 767 | } |
766 | 768 | ||
767 | // description for todo | 769 | // description for todo |
768 | if ((vo = isAPropertyOf(vtodo, VCDescriptionProp)) != 0) { | 770 | if ((vo = isAPropertyOf(vtodo, VCDescriptionProp)) != 0) { |
769 | s = fakeCString(vObjectUStringZValue(vo)); | 771 | s = fakeCString(vObjectUStringZValue(vo)); |
770 | anEvent->setDescription(QString::fromLocal8Bit(s)); | 772 | anEvent->setDescription(QString::fromLocal8Bit(s)); |
771 | deleteStr(s); | 773 | deleteStr(s); |
772 | } | 774 | } |
773 | 775 | ||
774 | // summary | 776 | // summary |
775 | if ((vo = isAPropertyOf(vtodo, VCSummaryProp))) { | 777 | if ((vo = isAPropertyOf(vtodo, VCSummaryProp))) { |
776 | s = fakeCString(vObjectUStringZValue(vo)); | 778 | s = fakeCString(vObjectUStringZValue(vo)); |
777 | anEvent->setSummary(QString::fromLocal8Bit(s)); | 779 | anEvent->setSummary(QString::fromLocal8Bit(s)); |
778 | deleteStr(s); | 780 | deleteStr(s); |
779 | } | 781 | } |
780 | if ((vo = isAPropertyOf(vtodo, VCLocationProp))) { | 782 | if ((vo = isAPropertyOf(vtodo, VCLocationProp))) { |
781 | s = fakeCString(vObjectUStringZValue(vo)); | 783 | s = fakeCString(vObjectUStringZValue(vo)); |
782 | anEvent->setLocation(QString::fromLocal8Bit(s)); | 784 | anEvent->setLocation(QString::fromLocal8Bit(s)); |
783 | deleteStr(s); | 785 | deleteStr(s); |
784 | } | 786 | } |
785 | 787 | ||
786 | 788 | ||
787 | // completed | 789 | // completed |
788 | // was: status | 790 | // was: status |
789 | if ((vo = isAPropertyOf(vtodo, VCStatusProp)) != 0) { | 791 | if ((vo = isAPropertyOf(vtodo, VCStatusProp)) != 0) { |
790 | s = fakeCString(vObjectUStringZValue(vo)); | 792 | s = fakeCString(vObjectUStringZValue(vo)); |
791 | if (strcmp(s,"COMPLETED") == 0) { | 793 | if (strcmp(s,"COMPLETED") == 0) { |
792 | anEvent->setCompleted(true); | 794 | anEvent->setCompleted(true); |
793 | } else { | 795 | } else { |
794 | anEvent->setCompleted(false); | 796 | anEvent->setCompleted(false); |
795 | } | 797 | } |
796 | deleteStr(s); | 798 | deleteStr(s); |
797 | } | 799 | } |
798 | else | 800 | else |
799 | anEvent->setCompleted(false); | 801 | anEvent->setCompleted(false); |
800 | 802 | ||
801 | // completion date | 803 | // completion date |
802 | if ((vo = isAPropertyOf(vtodo, VCCompletedProp)) != 0) { | 804 | if ((vo = isAPropertyOf(vtodo, VCCompletedProp)) != 0) { |
803 | anEvent->setCompleted(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 805 | anEvent->setCompleted(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
804 | deleteStr(s); | 806 | deleteStr(s); |
805 | } | 807 | } |
806 | 808 | ||
807 | // priority | 809 | // priority |
808 | if ((vo = isAPropertyOf(vtodo, VCPriorityProp))) { | 810 | if ((vo = isAPropertyOf(vtodo, VCPriorityProp))) { |
809 | anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 811 | anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
810 | deleteStr(s); | 812 | deleteStr(s); |
811 | } | 813 | } |
812 | 814 | ||
813 | // due date | 815 | // due date |
814 | if ((vo = isAPropertyOf(vtodo, VCDueProp)) != 0) { | 816 | if ((vo = isAPropertyOf(vtodo, VCDueProp)) != 0) { |
815 | anEvent->setDtDue(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 817 | anEvent->setDtDue(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
816 | deleteStr(s); | 818 | deleteStr(s); |
817 | anEvent->setHasDueDate(true); | 819 | anEvent->setHasDueDate(true); |
818 | } else { | 820 | } else { |
819 | anEvent->setHasDueDate(false); | 821 | anEvent->setHasDueDate(false); |
820 | } | 822 | } |
821 | 823 | ||
822 | // start time | 824 | // start time |
823 | if ((vo = isAPropertyOf(vtodo, VCDTstartProp)) != 0) { | 825 | if ((vo = isAPropertyOf(vtodo, VCDTstartProp)) != 0) { |
824 | anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 826 | anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
825 | // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl; | 827 | // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl; |
826 | deleteStr(s); | 828 | deleteStr(s); |
827 | anEvent->setHasStartDate(true); | 829 | anEvent->setHasStartDate(true); |
828 | } else { | 830 | } else { |
829 | anEvent->setHasStartDate(false); | 831 | anEvent->setHasStartDate(false); |
830 | } | 832 | } |
831 | 833 | ||
832 | /* alarm stuff */ | 834 | /* alarm stuff */ |
833 | //kdDebug(5800) << "vcalformat::VTodoToEvent called" << endl; | 835 | //kdDebug(5800) << "vcalformat::VTodoToEvent called" << endl; |
834 | if ((vo = isAPropertyOf(vtodo, VCDAlarmProp))) { | 836 | if ((vo = isAPropertyOf(vtodo, VCDAlarmProp))) { |
835 | Alarm* alarm = anEvent->newAlarm(); | 837 | Alarm* alarm = anEvent->newAlarm(); |
836 | VObject *a; | 838 | VObject *a; |
837 | if ((a = isAPropertyOf(vo, VCRunTimeProp))) { | 839 | if ((a = isAPropertyOf(vo, VCRunTimeProp))) { |
838 | alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a)))); | 840 | alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a)))); |
839 | deleteStr(s); | 841 | deleteStr(s); |
840 | } | 842 | } |
841 | alarm->setEnabled(true); | 843 | alarm->setEnabled(true); |
842 | if ((vo = isAPropertyOf(vtodo, VCPAlarmProp))) { | 844 | if ((vo = isAPropertyOf(vtodo, VCPAlarmProp))) { |
843 | if ((a = isAPropertyOf(vo, VCProcedureNameProp))) { | 845 | if ((a = isAPropertyOf(vo, VCProcedureNameProp))) { |
844 | s = fakeCString(vObjectUStringZValue(a)); | 846 | s = fakeCString(vObjectUStringZValue(a)); |
845 | alarm->setProcedureAlarm(QFile::decodeName(s)); | 847 | alarm->setProcedureAlarm(QFile::decodeName(s)); |
846 | deleteStr(s); | 848 | deleteStr(s); |
847 | } | 849 | } |
848 | } | 850 | } |
849 | if ((vo = isAPropertyOf(vtodo, VCAAlarmProp))) { | 851 | if ((vo = isAPropertyOf(vtodo, VCAAlarmProp))) { |
850 | if ((a = isAPropertyOf(vo, VCAudioContentProp))) { | 852 | if ((a = isAPropertyOf(vo, VCAudioContentProp))) { |
851 | s = fakeCString(vObjectUStringZValue(a)); | 853 | s = fakeCString(vObjectUStringZValue(a)); |
852 | alarm->setAudioAlarm(QFile::decodeName(s)); | 854 | alarm->setAudioAlarm(QFile::decodeName(s)); |
853 | deleteStr(s); | 855 | deleteStr(s); |
854 | } | 856 | } |
855 | } | 857 | } |
856 | } | 858 | } |
857 | 859 | ||
858 | // related todo | 860 | // related todo |
859 | if ((vo = isAPropertyOf(vtodo, VCRelatedToProp)) != 0) { | 861 | if ((vo = isAPropertyOf(vtodo, VCRelatedToProp)) != 0) { |
860 | anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); | 862 | anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); |
861 | deleteStr(s); | 863 | deleteStr(s); |
862 | mTodosRelate.append(anEvent); | 864 | mTodosRelate.append(anEvent); |
863 | } | 865 | } |
864 | 866 | ||
865 | // categories | 867 | // categories |
866 | QStringList tmpStrList; | 868 | QStringList tmpStrList; |
867 | int index1 = 0; | 869 | int index1 = 0; |
868 | int index2 = 0; | 870 | int index2 = 0; |
869 | if ((vo = isAPropertyOf(vtodo, VCCategoriesProp)) != 0) { | 871 | if ((vo = isAPropertyOf(vtodo, VCCategoriesProp)) != 0) { |
870 | s = fakeCString(vObjectUStringZValue(vo)); | 872 | s = fakeCString(vObjectUStringZValue(vo)); |
871 | QString categories = QString::fromLocal8Bit(s); | 873 | QString categories = QString::fromLocal8Bit(s); |
872 | deleteStr(s); | 874 | deleteStr(s); |
873 | //const char* category; | 875 | //const char* category; |
874 | QString category; | 876 | QString category; |
875 | while ((index2 = categories.find(',', index1)) != -1) { | 877 | while ((index2 = categories.find(',', index1)) != -1) { |
876 | //category = (const char *) categories.mid(index1, (index2 - index1)); | 878 | //category = (const char *) categories.mid(index1, (index2 - index1)); |
877 | category = categories.mid(index1, (index2 - index1)); | 879 | category = categories.mid(index1, (index2 - index1)); |
878 | tmpStrList.append(category); | 880 | tmpStrList.append(category); |
879 | index1 = index2+1; | 881 | index1 = index2+1; |
880 | } | 882 | } |
881 | // get last category | 883 | // get last category |
882 | category = categories.mid(index1, (categories.length()-index1)); | 884 | category = categories.mid(index1, (categories.length()-index1)); |
883 | tmpStrList.append(category); | 885 | tmpStrList.append(category); |
884 | anEvent->setCategories(tmpStrList); | 886 | anEvent->setCategories(tmpStrList); |
885 | } | 887 | } |
886 | 888 | ||
887 | /* PILOT SYNC STUFF */ | 889 | /* PILOT SYNC STUFF */ |
888 | if ((vo = isAPropertyOf(vtodo, XPilotIdProp))) { | 890 | if ((vo = isAPropertyOf(vtodo, XPilotIdProp))) { |
889 | anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 891 | anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
890 | deleteStr(s); | 892 | deleteStr(s); |
891 | } | 893 | } |
892 | else | 894 | else |
893 | anEvent->setPilotId(0); | 895 | anEvent->setPilotId(0); |
894 | 896 | ||
895 | if ((vo = isAPropertyOf(vtodo, XPilotStatusProp))) { | 897 | if ((vo = isAPropertyOf(vtodo, XPilotStatusProp))) { |
896 | anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 898 | anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
897 | deleteStr(s); | 899 | deleteStr(s); |
898 | } | 900 | } |
899 | else | 901 | else |
900 | anEvent->setSyncStatus(Event::SYNCMOD); | 902 | anEvent->setSyncStatus(Event::SYNCMOD); |
901 | 903 | ||
902 | return anEvent; | 904 | return anEvent; |
903 | } | 905 | } |
904 | 906 | ||
905 | Event* VCalFormat::VEventToEvent(VObject *vevent) | 907 | Event* VCalFormat::VEventToEvent(VObject *vevent) |
906 | { | 908 | { |
907 | VObject *vo; | 909 | VObject *vo; |
908 | VObjectIterator voi; | 910 | VObjectIterator voi; |
909 | char *s; | 911 | char *s; |
910 | 912 | ||
911 | Event *anEvent = new Event; | 913 | Event *anEvent = new Event; |
912 | 914 | ||
913 | // creation date | 915 | // creation date |
914 | if ((vo = isAPropertyOf(vevent, VCDCreatedProp)) != 0) { | 916 | if ((vo = isAPropertyOf(vevent, VCDCreatedProp)) != 0) { |
915 | anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 917 | anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
916 | deleteStr(s); | 918 | deleteStr(s); |
917 | } | 919 | } |
918 | 920 | ||
919 | // unique id | 921 | // unique id |
920 | vo = isAPropertyOf(vevent, VCUniqueStringProp); | 922 | vo = isAPropertyOf(vevent, VCUniqueStringProp); |
921 | // while the UID property is preferred, it is not required. We'll use the | 923 | // while the UID property is preferred, it is not required. We'll use the |
922 | // default Event UID if none is given. | 924 | // default Event UID if none is given. |
923 | if (vo) { | 925 | if (vo) { |
924 | anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); | 926 | anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); |
925 | deleteStr(s); | 927 | deleteStr(s); |
926 | } | 928 | } |
927 | 929 | ||
928 | // revision | 930 | // revision |
929 | // again NSCAL doesn't give us much to work with, so we improvise... | 931 | // again NSCAL doesn't give us much to work with, so we improvise... |
930 | if ((vo = isAPropertyOf(vevent, VCSequenceProp)) != 0) { | 932 | if ((vo = isAPropertyOf(vevent, VCSequenceProp)) != 0) { |
931 | anEvent->setRevision(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 933 | anEvent->setRevision(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
932 | deleteStr(s); | 934 | deleteStr(s); |
933 | } | 935 | } |
934 | else | 936 | else |
935 | anEvent->setRevision(0); | 937 | anEvent->setRevision(0); |
936 | 938 | ||
937 | // last modification date | 939 | // last modification date |
938 | if ((vo = isAPropertyOf(vevent, VCLastModifiedProp)) != 0) { | 940 | if ((vo = isAPropertyOf(vevent, VCLastModifiedProp)) != 0) { |
939 | anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 941 | anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
940 | deleteStr(s); | 942 | deleteStr(s); |
941 | } | 943 | } |
942 | else | 944 | else |
943 | anEvent->setLastModified(QDateTime(QDate::currentDate(), | 945 | anEvent->setLastModified(QDateTime(QDate::currentDate(), |
944 | QTime::currentTime())); | 946 | QTime::currentTime())); |
945 | 947 | ||
946 | // organizer | 948 | // organizer |
947 | // if our extension property for the event's ORGANIZER exists, add it. | 949 | // if our extension property for the event's ORGANIZER exists, add it. |
948 | if ((vo = isAPropertyOf(vevent, ICOrganizerProp)) != 0) { | 950 | if ((vo = isAPropertyOf(vevent, ICOrganizerProp)) != 0) { |
949 | anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo))); | 951 | anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo))); |
950 | deleteStr(s); | 952 | deleteStr(s); |
951 | } else { | 953 | } else { |
952 | anEvent->setOrganizer(mCalendar->getEmail()); | 954 | anEvent->setOrganizer(mCalendar->getEmail()); |
953 | } | 955 | } |
954 | 956 | ||
955 | // deal with attendees. | 957 | // deal with attendees. |
956 | initPropIterator(&voi, vevent); | 958 | initPropIterator(&voi, vevent); |
957 | while (moreIteration(&voi)) { | 959 | while (moreIteration(&voi)) { |
958 | vo = nextVObject(&voi); | 960 | vo = nextVObject(&voi); |
959 | if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) { | 961 | if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) { |
960 | Attendee *a; | 962 | Attendee *a; |
961 | VObject *vp; | 963 | VObject *vp; |
962 | s = fakeCString(vObjectUStringZValue(vo)); | 964 | s = fakeCString(vObjectUStringZValue(vo)); |
963 | QString tmpStr = QString::fromLocal8Bit(s); | 965 | QString tmpStr = QString::fromLocal8Bit(s); |
964 | deleteStr(s); | 966 | deleteStr(s); |
965 | tmpStr = tmpStr.simplifyWhiteSpace(); | 967 | tmpStr = tmpStr.simplifyWhiteSpace(); |
966 | int emailPos1, emailPos2; | 968 | int emailPos1, emailPos2; |
967 | if ((emailPos1 = tmpStr.find('<')) > 0) { | 969 | if ((emailPos1 = tmpStr.find('<')) > 0) { |
968 | // both email address and name | 970 | // both email address and name |
969 | emailPos2 = tmpStr.findRev('>'); | 971 | emailPos2 = tmpStr.findRev('>'); |
970 | a = new Attendee(tmpStr.left(emailPos1 - 1), | 972 | a = new Attendee(tmpStr.left(emailPos1 - 1), |
971 | tmpStr.mid(emailPos1 + 1, | 973 | tmpStr.mid(emailPos1 + 1, |
972 | emailPos2 - (emailPos1 + 1))); | 974 | emailPos2 - (emailPos1 + 1))); |
973 | } else if (tmpStr.find('@') > 0) { | 975 | } else if (tmpStr.find('@') > 0) { |
974 | // just an email address | 976 | // just an email address |
975 | a = new Attendee(0, tmpStr); | 977 | a = new Attendee(0, tmpStr); |
976 | } else { | 978 | } else { |
977 | // just a name | 979 | // just a name |
978 | QString email = tmpStr.replace( QRegExp(" "), "." ); | 980 | QString email = tmpStr.replace( QRegExp(" "), "." ); |
979 | a = new Attendee(tmpStr,email); | 981 | a = new Attendee(tmpStr,email); |
980 | } | 982 | } |
981 | 983 | ||
982 | // is there an RSVP property? | 984 | // is there an RSVP property? |
983 | if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0) | 985 | if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0) |
984 | a->setRSVP(vObjectStringZValue(vp)); | 986 | a->setRSVP(vObjectStringZValue(vp)); |
985 | // is there a status property? | 987 | // is there a status property? |
986 | if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0) | 988 | if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0) |
987 | a->setStatus(readStatus(vObjectStringZValue(vp))); | 989 | a->setStatus(readStatus(vObjectStringZValue(vp))); |
988 | // add the attendee | 990 | // add the attendee |
989 | anEvent->addAttendee(a); | 991 | anEvent->addAttendee(a); |
990 | } | 992 | } |
991 | } | 993 | } |
992 | 994 | ||
993 | // This isn't strictly true. An event that doesn't have a start time | 995 | // This isn't strictly true. An event that doesn't have a start time |
994 | // or an end time doesn't "float", it has an anchor in time but it doesn't | 996 | // or an end time doesn't "float", it has an anchor in time but it doesn't |
995 | // "take up" any time. | 997 | // "take up" any time. |
996 | /*if ((isAPropertyOf(vevent, VCDTstartProp) == 0) || | 998 | /*if ((isAPropertyOf(vevent, VCDTstartProp) == 0) || |
997 | (isAPropertyOf(vevent, VCDTendProp) == 0)) { | 999 | (isAPropertyOf(vevent, VCDTendProp) == 0)) { |
998 | anEvent->setFloats(TRUE); | 1000 | anEvent->setFloats(TRUE); |
999 | } else { | 1001 | } else { |
1000 | }*/ | 1002 | }*/ |
1001 | 1003 | ||
1002 | anEvent->setFloats(FALSE); | 1004 | anEvent->setFloats(FALSE); |
1003 | 1005 | ||
1004 | // start time | 1006 | // start time |
1005 | if ((vo = isAPropertyOf(vevent, VCDTstartProp)) != 0) { | 1007 | if ((vo = isAPropertyOf(vevent, VCDTstartProp)) != 0) { |
1006 | anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 1008 | anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
1007 | // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl; | 1009 | // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl; |
1008 | deleteStr(s); | 1010 | deleteStr(s); |
1009 | if (anEvent->dtStart().time().isNull()) | 1011 | if (anEvent->dtStart().time().isNull()) |
1010 | anEvent->setFloats(TRUE); | 1012 | anEvent->setFloats(TRUE); |
1011 | } | 1013 | } |
1012 | 1014 | ||
1013 | // stop time | 1015 | // stop time |
1014 | if ((vo = isAPropertyOf(vevent, VCDTendProp)) != 0) { | 1016 | if ((vo = isAPropertyOf(vevent, VCDTendProp)) != 0) { |
1015 | anEvent->setDtEnd(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 1017 | anEvent->setDtEnd(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
1016 | deleteStr(s); | 1018 | deleteStr(s); |
1017 | if (anEvent->dtEnd().time().isNull()) | 1019 | if (anEvent->dtEnd().time().isNull()) |
1018 | anEvent->setFloats(TRUE); | 1020 | anEvent->setFloats(TRUE); |
1019 | } | 1021 | } |
1020 | 1022 | ||
1021 | // at this point, there should be at least a start or end time. | 1023 | // at this point, there should be at least a start or end time. |
1022 | // fix up for events that take up no time but have a time associated | 1024 | // fix up for events that take up no time but have a time associated |
1023 | if (!(vo = isAPropertyOf(vevent, VCDTstartProp))) | 1025 | if (!(vo = isAPropertyOf(vevent, VCDTstartProp))) |
1024 | anEvent->setDtStart(anEvent->dtEnd()); | 1026 | anEvent->setDtStart(anEvent->dtEnd()); |
1025 | if (!(vo = isAPropertyOf(vevent, VCDTendProp))) | 1027 | if (!(vo = isAPropertyOf(vevent, VCDTendProp))) |
1026 | anEvent->setDtEnd(anEvent->dtStart()); | 1028 | anEvent->setDtEnd(anEvent->dtStart()); |
1027 | 1029 | ||
1028 | /////////////////////////////////////////////////////////////////////////// | 1030 | /////////////////////////////////////////////////////////////////////////// |
1029 | 1031 | ||
1030 | // repeat stuff | 1032 | // repeat stuff |
1031 | if ((vo = isAPropertyOf(vevent, VCRRuleProp)) != 0) { | 1033 | if ((vo = isAPropertyOf(vevent, VCRRuleProp)) != 0) { |
1032 | QString tmpStr = (s = fakeCString(vObjectUStringZValue(vo))); | 1034 | QString tmpStr = (s = fakeCString(vObjectUStringZValue(vo))); |
1033 | deleteStr(s); | 1035 | deleteStr(s); |
1034 | tmpStr.simplifyWhiteSpace(); | 1036 | tmpStr.simplifyWhiteSpace(); |
1035 | tmpStr = tmpStr.upper(); | 1037 | tmpStr = tmpStr.upper(); |
1036 | 1038 | ||
1037 | /********************************* DAILY ******************************/ | 1039 | /********************************* DAILY ******************************/ |
1038 | if (tmpStr.left(1) == "D") { | 1040 | if (tmpStr.left(1) == "D") { |
1039 | int index = tmpStr.find(' '); | 1041 | int index = tmpStr.find(' '); |
1040 | int rFreq = tmpStr.mid(1, (index-1)).toInt(); | 1042 | int rFreq = tmpStr.mid(1, (index-1)).toInt(); |
1041 | index = tmpStr.findRev(' ') + 1; // advance to last field | 1043 | index = tmpStr.findRev(' ') + 1; // advance to last field |
1042 | if (tmpStr.mid(index,1) == "#") index++; | 1044 | if (tmpStr.mid(index,1) == "#") index++; |
1043 | if (tmpStr.find('T', index) != -1) { | 1045 | if (tmpStr.find('T', index) != -1) { |
1044 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); | 1046 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); |
1045 | anEvent->recurrence()->setDaily(rFreq, rEndDate); | 1047 | anEvent->recurrence()->setDaily(rFreq, rEndDate); |
1046 | } else { | 1048 | } else { |
1047 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); | 1049 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); |
1048 | if (rDuration == 0) // VEvents set this to 0 forever, we use -1 | 1050 | if (rDuration == 0) // VEvents set this to 0 forever, we use -1 |
1049 | anEvent->recurrence()->setDaily(rFreq, -1); | 1051 | anEvent->recurrence()->setDaily(rFreq, -1); |
1050 | else | 1052 | else |
1051 | anEvent->recurrence()->setDaily(rFreq, rDuration); | 1053 | anEvent->recurrence()->setDaily(rFreq, rDuration); |
1052 | } | 1054 | } |
1053 | } | 1055 | } |
1054 | /********************************* WEEKLY ******************************/ | 1056 | /********************************* WEEKLY ******************************/ |
1055 | else if (tmpStr.left(1) == "W") { | 1057 | else if (tmpStr.left(1) == "W") { |
1056 | int index = tmpStr.find(' '); | 1058 | int index = tmpStr.find(' '); |
1057 | int last = tmpStr.findRev(' ') + 1; | 1059 | int last = tmpStr.findRev(' ') + 1; |
1058 | int rFreq = tmpStr.mid(1, (index-1)).toInt(); | 1060 | int rFreq = tmpStr.mid(1, (index-1)).toInt(); |
1059 | index += 1; // advance to beginning of stuff after freq | 1061 | index += 1; // advance to beginning of stuff after freq |
1060 | QBitArray qba(7); | 1062 | QBitArray qba(7); |
1061 | QString dayStr; | 1063 | QString dayStr; |
1062 | if( index == last ) { | 1064 | if( index == last ) { |
1063 | // e.g. W1 #0 | 1065 | // e.g. W1 #0 |
1064 | qba.setBit(anEvent->dtStart().date().dayOfWeek() - 1); | 1066 | qba.setBit(anEvent->dtStart().date().dayOfWeek() - 1); |
1065 | } | 1067 | } |
1066 | else { | 1068 | else { |
1067 | // e.g. W1 SU #0 | 1069 | // e.g. W1 SU #0 |
1068 | while (index < last) { | 1070 | while (index < last) { |
1069 | dayStr = tmpStr.mid(index, 3); | 1071 | dayStr = tmpStr.mid(index, 3); |
1070 | int dayNum = numFromDay(dayStr); | 1072 | int dayNum = numFromDay(dayStr); |
1071 | qba.setBit(dayNum); | 1073 | qba.setBit(dayNum); |
1072 | index += 3; // advance to next day, or possibly "#" | 1074 | index += 3; // advance to next day, or possibly "#" |
1073 | } | 1075 | } |
1074 | } | 1076 | } |
1075 | index = last; if (tmpStr.mid(index,1) == "#") index++; | 1077 | index = last; if (tmpStr.mid(index,1) == "#") index++; |
1076 | if (tmpStr.find('T', index) != -1) { | 1078 | if (tmpStr.find('T', index) != -1) { |
1077 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); | 1079 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); |
1078 | anEvent->recurrence()->setWeekly(rFreq, qba, rEndDate); | 1080 | anEvent->recurrence()->setWeekly(rFreq, qba, rEndDate); |
1079 | } else { | 1081 | } else { |
1080 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); | 1082 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); |
1081 | if (rDuration == 0) | 1083 | if (rDuration == 0) |
1082 | anEvent->recurrence()->setWeekly(rFreq, qba, -1); | 1084 | anEvent->recurrence()->setWeekly(rFreq, qba, -1); |
1083 | else | 1085 | else |
1084 | anEvent->recurrence()->setWeekly(rFreq, qba, rDuration); | 1086 | anEvent->recurrence()->setWeekly(rFreq, qba, rDuration); |
1085 | } | 1087 | } |
1086 | } | 1088 | } |
1087 | /**************************** MONTHLY-BY-POS ***************************/ | 1089 | /**************************** MONTHLY-BY-POS ***************************/ |
1088 | else if (tmpStr.left(2) == "MP") { | 1090 | else if (tmpStr.left(2) == "MP") { |
1089 | int index = tmpStr.find(' '); | 1091 | int index = tmpStr.find(' '); |
1090 | int last = tmpStr.findRev(' ') + 1; | 1092 | int last = tmpStr.findRev(' ') + 1; |
1091 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); | 1093 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); |
1092 | index += 1; // advance to beginning of stuff after freq | 1094 | index += 1; // advance to beginning of stuff after freq |
1093 | QBitArray qba(7); | 1095 | QBitArray qba(7); |
1094 | short tmpPos; | 1096 | short tmpPos; |
1095 | if( index == last ) { | 1097 | if( index == last ) { |
1096 | // e.g. MP1 #0 | 1098 | // e.g. MP1 #0 |
1097 | tmpPos = anEvent->dtStart().date().day()/7 + 1; | 1099 | tmpPos = anEvent->dtStart().date().day()/7 + 1; |
1098 | if( tmpPos == 5 ) | 1100 | if( tmpPos == 5 ) |
1099 | tmpPos = -1; | 1101 | tmpPos = -1; |
1100 | qba.setBit(anEvent->dtStart().date().dayOfWeek() - 1); | 1102 | qba.setBit(anEvent->dtStart().date().dayOfWeek() - 1); |
1101 | anEvent->recurrence()->addMonthlyPos(tmpPos, qba); | 1103 | anEvent->recurrence()->addMonthlyPos(tmpPos, qba); |
1102 | } | 1104 | } |
1103 | else { | 1105 | else { |
1104 | // e.g. MP1 1+ SU #0 | 1106 | // e.g. MP1 1+ SU #0 |
1105 | while (index < last) { | 1107 | while (index < last) { |
1106 | tmpPos = tmpStr.mid(index,1).toShort(); | 1108 | tmpPos = tmpStr.mid(index,1).toShort(); |
1107 | index += 1; | 1109 | index += 1; |
1108 | if (tmpStr.mid(index,1) == "-") | 1110 | if (tmpStr.mid(index,1) == "-") |
1109 | // convert tmpPos to negative | 1111 | // convert tmpPos to negative |
1110 | tmpPos = 0 - tmpPos; | 1112 | tmpPos = 0 - tmpPos; |
1111 | index += 2; // advance to day(s) | 1113 | index += 2; // advance to day(s) |
1112 | while (numFromDay(tmpStr.mid(index,3)) >= 0) { | 1114 | while (numFromDay(tmpStr.mid(index,3)) >= 0) { |
1113 | int dayNum = numFromDay(tmpStr.mid(index,3)); | 1115 | int dayNum = numFromDay(tmpStr.mid(index,3)); |
1114 | qba.setBit(dayNum); | 1116 | qba.setBit(dayNum); |
1115 | index += 3; // advance to next day, or possibly pos or "#" | 1117 | index += 3; // advance to next day, or possibly pos or "#" |
1116 | } | 1118 | } |
1117 | anEvent->recurrence()->addMonthlyPos(tmpPos, qba); | 1119 | anEvent->recurrence()->addMonthlyPos(tmpPos, qba); |
1118 | qba.detach(); | 1120 | qba.detach(); |
1119 | qba.fill(FALSE); // clear out | 1121 | qba.fill(FALSE); // clear out |
1120 | } // while != "#" | 1122 | } // while != "#" |
1121 | } | 1123 | } |
1122 | index = last; if (tmpStr.mid(index,1) == "#") index++; | 1124 | index = last; if (tmpStr.mid(index,1) == "#") index++; |
1123 | if (tmpStr.find('T', index) != -1) { | 1125 | if (tmpStr.find('T', index) != -1) { |
1124 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length() - | 1126 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length() - |
1125 | index))).date(); | 1127 | index))).date(); |
1126 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, rEndDate); | 1128 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, rEndDate); |
1127 | } else { | 1129 | } else { |
1128 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); | 1130 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); |
1129 | if (rDuration == 0) | 1131 | if (rDuration == 0) |
1130 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, -1); | 1132 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, -1); |
1131 | else | 1133 | else |
1132 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, rDuration); | 1134 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, rDuration); |
1133 | } | 1135 | } |
1134 | } | 1136 | } |
1135 | 1137 | ||
1136 | /**************************** MONTHLY-BY-DAY ***************************/ | 1138 | /**************************** MONTHLY-BY-DAY ***************************/ |
1137 | else if (tmpStr.left(2) == "MD") { | 1139 | else if (tmpStr.left(2) == "MD") { |
1138 | int index = tmpStr.find(' '); | 1140 | int index = tmpStr.find(' '); |
1139 | int last = tmpStr.findRev(' ') + 1; | 1141 | int last = tmpStr.findRev(' ') + 1; |
1140 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); | 1142 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); |
1141 | index += 1; | 1143 | index += 1; |
1142 | short tmpDay; | 1144 | short tmpDay; |
1143 | if( index == last ) { | 1145 | if( index == last ) { |
1144 | // e.g. MD1 #0 | 1146 | // e.g. MD1 #0 |
1145 | tmpDay = anEvent->dtStart().date().day(); | 1147 | tmpDay = anEvent->dtStart().date().day(); |
1146 | anEvent->recurrence()->addMonthlyDay(tmpDay); | 1148 | anEvent->recurrence()->addMonthlyDay(tmpDay); |
1147 | } | 1149 | } |
1148 | else { | 1150 | else { |
1149 | // e.g. MD1 3 #0 | 1151 | // e.g. MD1 3 #0 |
1150 | while (index < last) { | 1152 | while (index < last) { |
1151 | int index2 = tmpStr.find(' ', index); | 1153 | int index2 = tmpStr.find(' ', index); |
1152 | tmpDay = tmpStr.mid(index, (index2-index)).toShort(); | 1154 | tmpDay = tmpStr.mid(index, (index2-index)).toShort(); |
1153 | index = index2-1; | 1155 | index = index2-1; |
1154 | if (tmpStr.mid(index, 1) == "-") | 1156 | if (tmpStr.mid(index, 1) == "-") |
1155 | tmpDay = 0 - tmpDay; | 1157 | tmpDay = 0 - tmpDay; |
1156 | index += 2; // advance the index; | 1158 | index += 2; // advance the index; |
1157 | anEvent->recurrence()->addMonthlyDay(tmpDay); | 1159 | anEvent->recurrence()->addMonthlyDay(tmpDay); |
1158 | } // while != # | 1160 | } // while != # |
1159 | } | 1161 | } |
1160 | index = last; if (tmpStr.mid(index,1) == "#") index++; | 1162 | index = last; if (tmpStr.mid(index,1) == "#") index++; |
1161 | if (tmpStr.find('T', index) != -1) { | 1163 | if (tmpStr.find('T', index) != -1) { |
1162 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); | 1164 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); |
1163 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, rEndDate); | 1165 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, rEndDate); |
1164 | } else { | 1166 | } else { |
1165 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); | 1167 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); |
1166 | if (rDuration == 0) | 1168 | if (rDuration == 0) |
1167 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, -1); | 1169 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, -1); |
1168 | else | 1170 | else |
1169 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, rDuration); | 1171 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, rDuration); |
1170 | } | 1172 | } |
1171 | } | 1173 | } |
1172 | 1174 | ||
1173 | /*********************** YEARLY-BY-MONTH *******************************/ | 1175 | /*********************** YEARLY-BY-MONTH *******************************/ |
1174 | else if (tmpStr.left(2) == "YM") { | 1176 | else if (tmpStr.left(2) == "YM") { |
1175 | int index = tmpStr.find(' '); | 1177 | // we have to set this such that recurrence accepts addYearlyNum(tmpDay); |
1176 | int last = tmpStr.findRev(' ') + 1; | 1178 | anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, 1, -1); |
1177 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); | 1179 | int index = tmpStr.find(' '); |
1178 | index += 1; | 1180 | int last = tmpStr.findRev(' ') + 1; |
1179 | short tmpMonth; | 1181 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); |
1180 | if( index == last ) { | 1182 | index += 1; |
1181 | // e.g. YM1 #0 | 1183 | short tmpMonth; |
1182 | tmpMonth = anEvent->dtStart().date().month(); | 1184 | if( index == last ) { |
1183 | anEvent->recurrence()->addYearlyNum(tmpMonth); | 1185 | // e.g. YM1 #0 |
1184 | } | 1186 | tmpMonth = anEvent->dtStart().date().month(); |
1185 | else { | 1187 | anEvent->recurrence()->addYearlyNum(tmpMonth); |
1186 | // e.g. YM1 3 #0 | 1188 | } |
1187 | while (index < last) { | 1189 | else { |
1188 | int index2 = tmpStr.find(' ', index); | 1190 | // e.g. YM1 3 #0 |
1189 | tmpMonth = tmpStr.mid(index, (index2-index)).toShort(); | 1191 | while (index < last) { |
1190 | index = index2+1; | 1192 | int index2 = tmpStr.find(' ', index); |
1191 | anEvent->recurrence()->addYearlyNum(tmpMonth); | 1193 | tmpMonth = tmpStr.mid(index, (index2-index)).toShort(); |
1192 | } // while != # | 1194 | index = index2+1; |
1193 | } | 1195 | anEvent->recurrence()->addYearlyNum(tmpMonth); |
1194 | index = last; if (tmpStr.mid(index,1) == "#") index++; | 1196 | } // while != # |
1195 | if (tmpStr.find('T', index) != -1) { | 1197 | } |
1196 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); | 1198 | index = last; if (tmpStr.mid(index,1) == "#") index++; |
1197 | anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rEndDate); | 1199 | if (tmpStr.find('T', index) != -1) { |
1198 | } else { | 1200 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); |
1199 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); | 1201 | anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rEndDate); |
1200 | if (rDuration == 0) | 1202 | } else { |
1201 | anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, -1); | 1203 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); |
1202 | else | 1204 | if (rDuration == 0) |
1203 | anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rDuration); | 1205 | anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, -1); |
1204 | } | 1206 | else |
1207 | anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rDuration); | ||
1208 | } | ||
1205 | } | 1209 | } |
1206 | 1210 | ||
1207 | /*********************** YEARLY-BY-DAY *********************************/ | 1211 | /*********************** YEARLY-BY-DAY *********************************/ |
1208 | else if (tmpStr.left(2) == "YD") { | 1212 | else if (tmpStr.left(2) == "YD") { |
1209 | int index = tmpStr.find(' '); | 1213 | // we have to set this such that recurrence accepts addYearlyNum(tmpDay); |
1210 | int last = tmpStr.findRev(' ') + 1; | 1214 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, 1, -1); |
1211 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); | 1215 | int index = tmpStr.find(' '); |
1212 | index += 1; | 1216 | int last = tmpStr.findRev(' ') + 1; |
1213 | short tmpDay; | 1217 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); |
1214 | if( index == last ) { | 1218 | index += 1; |
1215 | // e.g. YD1 #0 | 1219 | short tmpDay; |
1216 | tmpDay = anEvent->dtStart().date().dayOfYear(); | 1220 | if( index == last ) { |
1217 | anEvent->recurrence()->addYearlyNum(tmpDay); | 1221 | // e.g. YD1 #0 |
1218 | } | 1222 | tmpDay = anEvent->dtStart().date().dayOfYear(); |
1219 | else { | 1223 | anEvent->recurrence()->addYearlyNum(tmpDay); |
1220 | // e.g. YD1 123 #0 | 1224 | } |
1221 | while (index < last) { | 1225 | else { |
1222 | int index2 = tmpStr.find(' ', index); | 1226 | // e.g. YD1 123 #0 |
1223 | tmpDay = tmpStr.mid(index, (index2-index)).toShort(); | 1227 | while (index < last) { |
1224 | index = index2+1; | 1228 | int index2 = tmpStr.find(' ', index); |
1225 | anEvent->recurrence()->addYearlyNum(tmpDay); | 1229 | tmpDay = tmpStr.mid(index, (index2-index)).toShort(); |
1226 | } // while != # | 1230 | index = index2+1; |
1227 | } | 1231 | anEvent->recurrence()->addYearlyNum(tmpDay); |
1228 | index = last; if (tmpStr.mid(index,1) == "#") index++; | 1232 | } // while != # |
1229 | if (tmpStr.find('T', index) != -1) { | 1233 | } |
1230 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); | 1234 | index = last; if (tmpStr.mid(index,1) == "#") index++; |
1231 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rEndDate); | 1235 | if (tmpStr.find('T', index) != -1) { |
1232 | } else { | 1236 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); |
1233 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); | 1237 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rEndDate); |
1234 | if (rDuration == 0) | 1238 | } else { |
1235 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, -1); | 1239 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); |
1236 | else | 1240 | if (rDuration == 0) |
1237 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rDuration); | 1241 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, -1); |
1238 | } | 1242 | else |
1243 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rDuration); | ||
1244 | } | ||
1239 | } else { | 1245 | } else { |
1240 | kdDebug(5800) << "we don't understand this type of recurrence!" << endl; | 1246 | kdDebug(5800) << "we don't understand this type of recurrence!" << endl; |
1241 | } // if | 1247 | } // if |
1242 | } // repeats | 1248 | } // repeats |
1243 | 1249 | ||
1244 | 1250 | ||
1245 | // recurrence exceptions | 1251 | // recurrence exceptions |
1246 | if ((vo = isAPropertyOf(vevent, VCExpDateProp)) != 0) { | 1252 | if ((vo = isAPropertyOf(vevent, VCExpDateProp)) != 0) { |
1247 | s = fakeCString(vObjectUStringZValue(vo)); | 1253 | s = fakeCString(vObjectUStringZValue(vo)); |
1248 | QStringList exDates = QStringList::split(",",s); | 1254 | QStringList exDates = QStringList::split(",",s); |
1249 | QStringList::ConstIterator it; | 1255 | QStringList::ConstIterator it; |
1250 | for(it = exDates.begin(); it != exDates.end(); ++it ) { | 1256 | for(it = exDates.begin(); it != exDates.end(); ++it ) { |
1251 | anEvent->addExDate(ISOToQDate(*it)); | 1257 | anEvent->addExDate(ISOToQDate(*it)); |
1252 | } | 1258 | } |
1253 | deleteStr(s); | 1259 | deleteStr(s); |
1254 | } | 1260 | } |
1255 | 1261 | ||
1256 | // summary | 1262 | // summary |
1257 | if ((vo = isAPropertyOf(vevent, VCSummaryProp))) { | 1263 | if ((vo = isAPropertyOf(vevent, VCSummaryProp))) { |
1258 | s = fakeCString(vObjectUStringZValue(vo)); | 1264 | s = fakeCString(vObjectUStringZValue(vo)); |
1259 | anEvent->setSummary(QString::fromLocal8Bit(s)); | 1265 | anEvent->setSummary(QString::fromLocal8Bit(s)); |
1260 | deleteStr(s); | 1266 | deleteStr(s); |
1261 | } | 1267 | } |
1262 | if ((vo = isAPropertyOf(vevent, VCLocationProp))) { | 1268 | if ((vo = isAPropertyOf(vevent, VCLocationProp))) { |
1263 | s = fakeCString(vObjectUStringZValue(vo)); | 1269 | s = fakeCString(vObjectUStringZValue(vo)); |
1264 | anEvent->setLocation(QString::fromLocal8Bit(s)); | 1270 | anEvent->setLocation(QString::fromLocal8Bit(s)); |
1265 | deleteStr(s); | 1271 | deleteStr(s); |
1266 | } | 1272 | } |
1267 | 1273 | ||
1268 | // description | 1274 | // description |
1269 | if ((vo = isAPropertyOf(vevent, VCDescriptionProp)) != 0) { | 1275 | if ((vo = isAPropertyOf(vevent, VCDescriptionProp)) != 0) { |
1270 | s = fakeCString(vObjectUStringZValue(vo)); | 1276 | s = fakeCString(vObjectUStringZValue(vo)); |
1271 | if (!anEvent->description().isEmpty()) { | 1277 | if (!anEvent->description().isEmpty()) { |
1272 | anEvent->setDescription(anEvent->description() + "\n" + | 1278 | anEvent->setDescription(anEvent->description() + "\n" + |
1273 | QString::fromLocal8Bit(s)); | 1279 | QString::fromLocal8Bit(s)); |
1274 | } else { | 1280 | } else { |
1275 | anEvent->setDescription(QString::fromLocal8Bit(s)); | 1281 | anEvent->setDescription(QString::fromLocal8Bit(s)); |
1276 | } | 1282 | } |
1277 | deleteStr(s); | 1283 | deleteStr(s); |
1278 | } | 1284 | } |
1279 | 1285 | ||
1280 | // some stupid vCal exporters ignore the standard and use Description | 1286 | // some stupid vCal exporters ignore the standard and use Description |
1281 | // instead of Summary for the default field. Correct for this. | 1287 | // instead of Summary for the default field. Correct for this. |
1282 | if (anEvent->summary().isEmpty() && | 1288 | if (anEvent->summary().isEmpty() && |
1283 | !(anEvent->description().isEmpty())) { | 1289 | !(anEvent->description().isEmpty())) { |
1284 | QString tmpStr = anEvent->description().simplifyWhiteSpace(); | 1290 | QString tmpStr = anEvent->description().simplifyWhiteSpace(); |
1285 | anEvent->setDescription(""); | 1291 | anEvent->setDescription(""); |
1286 | anEvent->setSummary(tmpStr); | 1292 | anEvent->setSummary(tmpStr); |
1287 | } | 1293 | } |
1288 | 1294 | ||
1289 | #if 0 | 1295 | #if 0 |
1290 | // status | 1296 | // status |
1291 | if ((vo = isAPropertyOf(vevent, VCStatusProp)) != 0) { | 1297 | if ((vo = isAPropertyOf(vevent, VCStatusProp)) != 0) { |
1292 | QString tmpStr(s = fakeCString(vObjectUStringZValue(vo))); | 1298 | QString tmpStr(s = fakeCString(vObjectUStringZValue(vo))); |
1293 | deleteStr(s); | 1299 | deleteStr(s); |
1294 | // TODO: Define Event status | 1300 | // TODO: Define Event status |
1295 | // anEvent->setStatus(tmpStr); | 1301 | // anEvent->setStatus(tmpStr); |
1296 | } | 1302 | } |
1297 | else | 1303 | else |
1298 | // anEvent->setStatus("NEEDS ACTION"); | 1304 | // anEvent->setStatus("NEEDS ACTION"); |
1299 | #endif | 1305 | #endif |
1300 | 1306 | ||
1301 | // secrecy | 1307 | // secrecy |
1302 | int secrecy = Incidence::SecrecyPublic; | 1308 | int secrecy = Incidence::SecrecyPublic; |
1303 | if ((vo = isAPropertyOf(vevent, VCClassProp)) != 0) { | 1309 | if ((vo = isAPropertyOf(vevent, VCClassProp)) != 0) { |
1304 | s = fakeCString(vObjectUStringZValue(vo)); | 1310 | s = fakeCString(vObjectUStringZValue(vo)); |
1305 | if (strcmp(s,"PRIVATE") == 0) { | 1311 | if (strcmp(s,"PRIVATE") == 0) { |
1306 | secrecy = Incidence::SecrecyPrivate; | 1312 | secrecy = Incidence::SecrecyPrivate; |
1307 | } else if (strcmp(s,"CONFIDENTIAL") == 0) { | 1313 | } else if (strcmp(s,"CONFIDENTIAL") == 0) { |
1308 | secrecy = Incidence::SecrecyConfidential; | 1314 | secrecy = Incidence::SecrecyConfidential; |
1309 | } | 1315 | } |
1310 | deleteStr(s); | 1316 | deleteStr(s); |
1311 | } | 1317 | } |
1312 | anEvent->setSecrecy(secrecy); | 1318 | anEvent->setSecrecy(secrecy); |
1313 | 1319 | ||
1314 | // categories | 1320 | // categories |
1315 | QStringList tmpStrList; | 1321 | QStringList tmpStrList; |
1316 | int index1 = 0; | 1322 | int index1 = 0; |
1317 | int index2 = 0; | 1323 | int index2 = 0; |
1318 | if ((vo = isAPropertyOf(vevent, VCCategoriesProp)) != 0) { | 1324 | if ((vo = isAPropertyOf(vevent, VCCategoriesProp)) != 0) { |
1319 | s = fakeCString(vObjectUStringZValue(vo)); | 1325 | s = fakeCString(vObjectUStringZValue(vo)); |
1320 | QString categories = QString::fromLocal8Bit(s); | 1326 | QString categories = QString::fromLocal8Bit(s); |
1321 | deleteStr(s); | 1327 | deleteStr(s); |
1322 | //const char* category; | 1328 | //const char* category; |
1323 | QString category; | 1329 | QString category; |
1324 | while ((index2 = categories.find(',', index1)) != -1) { | 1330 | while ((index2 = categories.find(',', index1)) != -1) { |
1325 | //category = (const char *) categories.mid(index1, (index2 - index1)); | 1331 | //category = (const char *) categories.mid(index1, (index2 - index1)); |
1326 | category = categories.mid(index1, (index2 - index1)); | 1332 | category = categories.mid(index1, (index2 - index1)); |
1327 | tmpStrList.append(category); | 1333 | tmpStrList.append(category); |
1328 | index1 = index2+1; | 1334 | index1 = index2+1; |
1329 | } | 1335 | } |
1330 | // get last category | 1336 | // get last category |
1331 | category = categories.mid(index1, (categories.length()-index1)); | 1337 | category = categories.mid(index1, (categories.length()-index1)); |
1332 | tmpStrList.append(category); | 1338 | tmpStrList.append(category); |
1333 | anEvent->setCategories(tmpStrList); | 1339 | anEvent->setCategories(tmpStrList); |
1334 | } | 1340 | } |
1335 | 1341 | ||
1336 | // attachments | 1342 | // attachments |
1337 | tmpStrList.clear(); | 1343 | tmpStrList.clear(); |
1338 | initPropIterator(&voi, vevent); | 1344 | initPropIterator(&voi, vevent); |
1339 | while (moreIteration(&voi)) { | 1345 | while (moreIteration(&voi)) { |
1340 | vo = nextVObject(&voi); | 1346 | vo = nextVObject(&voi); |
1341 | if (strcmp(vObjectName(vo), VCAttachProp) == 0) { | 1347 | if (strcmp(vObjectName(vo), VCAttachProp) == 0) { |
1342 | s = fakeCString(vObjectUStringZValue(vo)); | 1348 | s = fakeCString(vObjectUStringZValue(vo)); |
1343 | anEvent->addAttachment(new Attachment(QString(s))); | 1349 | anEvent->addAttachment(new Attachment(QString(s))); |
1344 | deleteStr(s); | 1350 | deleteStr(s); |
1345 | } | 1351 | } |
1346 | } | 1352 | } |
1347 | 1353 | ||
1348 | // resources | 1354 | // resources |
1349 | if ((vo = isAPropertyOf(vevent, VCResourcesProp)) != 0) { | 1355 | if ((vo = isAPropertyOf(vevent, VCResourcesProp)) != 0) { |
1350 | QString resources = (s = fakeCString(vObjectUStringZValue(vo))); | 1356 | QString resources = (s = fakeCString(vObjectUStringZValue(vo))); |
1351 | deleteStr(s); | 1357 | deleteStr(s); |
1352 | tmpStrList.clear(); | 1358 | tmpStrList.clear(); |
1353 | index1 = 0; | 1359 | index1 = 0; |
1354 | index2 = 0; | 1360 | index2 = 0; |
1355 | QString resource; | 1361 | QString resource; |
1356 | while ((index2 = resources.find(';', index1)) != -1) { | 1362 | while ((index2 = resources.find(';', index1)) != -1) { |
1357 | resource = resources.mid(index1, (index2 - index1)); | 1363 | resource = resources.mid(index1, (index2 - index1)); |
1358 | tmpStrList.append(resource); | 1364 | tmpStrList.append(resource); |
1359 | index1 = index2; | 1365 | index1 = index2; |
1360 | } | 1366 | } |
1361 | anEvent->setResources(tmpStrList); | 1367 | anEvent->setResources(tmpStrList); |
1362 | } | 1368 | } |
1363 | 1369 | ||
1364 | /* alarm stuff */ | 1370 | /* alarm stuff */ |
1365 | if ((vo = isAPropertyOf(vevent, VCDAlarmProp))) { | 1371 | if ((vo = isAPropertyOf(vevent, VCDAlarmProp))) { |
1366 | Alarm* alarm = anEvent->newAlarm(); | 1372 | Alarm* alarm = anEvent->newAlarm(); |
1367 | VObject *a; | 1373 | VObject *a; |
1368 | if ((a = isAPropertyOf(vo, VCRunTimeProp))) { | 1374 | if ((a = isAPropertyOf(vo, VCRunTimeProp))) { |
1369 | alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a)))); | 1375 | alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a)))); |
1370 | deleteStr(s); | 1376 | deleteStr(s); |
1371 | } | 1377 | } |
1372 | alarm->setEnabled(true); | 1378 | alarm->setEnabled(true); |
1373 | if ((vo = isAPropertyOf(vevent, VCPAlarmProp))) { | 1379 | if ((vo = isAPropertyOf(vevent, VCPAlarmProp))) { |
1374 | if ((a = isAPropertyOf(vo, VCProcedureNameProp))) { | 1380 | if ((a = isAPropertyOf(vo, VCProcedureNameProp))) { |
1375 | s = fakeCString(vObjectUStringZValue(a)); | 1381 | s = fakeCString(vObjectUStringZValue(a)); |
1376 | alarm->setProcedureAlarm(QFile::decodeName(s)); | 1382 | alarm->setProcedureAlarm(QFile::decodeName(s)); |
1377 | deleteStr(s); | 1383 | deleteStr(s); |
1378 | } | 1384 | } |
1379 | } | 1385 | } |
1380 | if ((vo = isAPropertyOf(vevent, VCAAlarmProp))) { | 1386 | if ((vo = isAPropertyOf(vevent, VCAAlarmProp))) { |
1381 | if ((a = isAPropertyOf(vo, VCAudioContentProp))) { | 1387 | if ((a = isAPropertyOf(vo, VCAudioContentProp))) { |
1382 | s = fakeCString(vObjectUStringZValue(a)); | 1388 | s = fakeCString(vObjectUStringZValue(a)); |
1383 | alarm->setAudioAlarm(QFile::decodeName(s)); | 1389 | alarm->setAudioAlarm(QFile::decodeName(s)); |
1384 | deleteStr(s); | 1390 | deleteStr(s); |
1385 | } | 1391 | } |
1386 | } | 1392 | } |
1387 | } | 1393 | } |
1388 | 1394 | ||
1389 | // priority | 1395 | // priority |
1390 | if ((vo = isAPropertyOf(vevent, VCPriorityProp))) { | 1396 | if ((vo = isAPropertyOf(vevent, VCPriorityProp))) { |
1391 | anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 1397 | anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
1392 | deleteStr(s); | 1398 | deleteStr(s); |
1393 | } | 1399 | } |
1394 | 1400 | ||
1395 | // transparency | 1401 | // transparency |
1396 | if ((vo = isAPropertyOf(vevent, VCTranspProp)) != 0) { | 1402 | if ((vo = isAPropertyOf(vevent, VCTranspProp)) != 0) { |
1397 | int i = atoi(s = fakeCString(vObjectUStringZValue(vo))); | 1403 | int i = atoi(s = fakeCString(vObjectUStringZValue(vo))); |
1398 | anEvent->setTransparency( i == 1 ? Event::Transparent : Event::Opaque ); | 1404 | anEvent->setTransparency( i == 1 ? Event::Transparent : Event::Opaque ); |
1399 | deleteStr(s); | 1405 | deleteStr(s); |
1400 | } | 1406 | } |
1401 | 1407 | ||
1402 | // related event | 1408 | // related event |
1403 | if ((vo = isAPropertyOf(vevent, VCRelatedToProp)) != 0) { | 1409 | if ((vo = isAPropertyOf(vevent, VCRelatedToProp)) != 0) { |
1404 | anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); | 1410 | anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); |
1405 | deleteStr(s); | 1411 | deleteStr(s); |
1406 | mEventsRelate.append(anEvent); | 1412 | mEventsRelate.append(anEvent); |
1407 | } | 1413 | } |
1408 | 1414 | ||
1409 | /* PILOT SYNC STUFF */ | 1415 | /* PILOT SYNC STUFF */ |
1410 | if ((vo = isAPropertyOf(vevent, XPilotIdProp))) { | 1416 | if ((vo = isAPropertyOf(vevent, XPilotIdProp))) { |
1411 | anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 1417 | anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
1412 | deleteStr(s); | 1418 | deleteStr(s); |
1413 | } | 1419 | } |
1414 | else | 1420 | else |
1415 | anEvent->setPilotId(0); | 1421 | anEvent->setPilotId(0); |
1416 | 1422 | ||
1417 | if ((vo = isAPropertyOf(vevent, XPilotStatusProp))) { | 1423 | if ((vo = isAPropertyOf(vevent, XPilotStatusProp))) { |
1418 | anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 1424 | anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
1419 | deleteStr(s); | 1425 | deleteStr(s); |
1420 | } | 1426 | } |
1421 | else | 1427 | else |
1422 | anEvent->setSyncStatus(Event::SYNCMOD); | 1428 | anEvent->setSyncStatus(Event::SYNCMOD); |
1423 | 1429 | ||
1424 | return anEvent; | 1430 | return anEvent; |
1425 | } | 1431 | } |
1426 | 1432 | ||
1427 | 1433 | ||
1428 | QString VCalFormat::qDateToISO(const QDate &qd) | 1434 | QString VCalFormat::qDateToISO(const QDate &qd) |
1429 | { | 1435 | { |
1430 | QString tmpStr; | 1436 | QString tmpStr; |
1431 | 1437 | ||
1432 | ASSERT(qd.isValid()); | 1438 | ASSERT(qd.isValid()); |
1433 | 1439 | ||
1434 | tmpStr.sprintf("%.2d%.2d%.2d", | 1440 | tmpStr.sprintf("%.2d%.2d%.2d", |
1435 | qd.year(), qd.month(), qd.day()); | 1441 | qd.year(), qd.month(), qd.day()); |
1436 | return tmpStr; | 1442 | return tmpStr; |
1437 | 1443 | ||
1438 | } | 1444 | } |
1439 | 1445 | ||
1440 | QString VCalFormat::qDateTimeToISO(const QDateTime &qdt, bool zulu) | 1446 | QString VCalFormat::qDateTimeToISO(const QDateTime &qdt, bool zulu) |
1441 | { | 1447 | { |
1442 | QString tmpStr; | 1448 | QString tmpStr; |
1443 | 1449 | ||
1444 | ASSERT(qdt.date().isValid()); | 1450 | ASSERT(qdt.date().isValid()); |
1445 | ASSERT(qdt.time().isValid()); | 1451 | ASSERT(qdt.time().isValid()); |
1446 | if (zulu && !useLocalTime ) { | 1452 | if (zulu && !useLocalTime ) { |
1447 | QDateTime tmpDT = qdt.addSecs ( -KGlobal::locale()->localTimeOffset( qdt )*60); | 1453 | QDateTime tmpDT = qdt.addSecs ( -KGlobal::locale()->localTimeOffset( qdt )*60); |
1448 | tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2dZ", | 1454 | tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2dZ", |
1449 | tmpDT.date().year(), tmpDT.date().month(), | 1455 | tmpDT.date().year(), tmpDT.date().month(), |
1450 | tmpDT.date().day(), tmpDT.time().hour(), | 1456 | tmpDT.date().day(), tmpDT.time().hour(), |
1451 | tmpDT.time().minute(), tmpDT.time().second()); | 1457 | tmpDT.time().minute(), tmpDT.time().second()); |
1452 | } else { | 1458 | } else { |
1453 | tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2d", | 1459 | tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2d", |
1454 | qdt.date().year(), qdt.date().month(), | 1460 | qdt.date().year(), qdt.date().month(), |
1455 | qdt.date().day(), qdt.time().hour(), | 1461 | qdt.date().day(), qdt.time().hour(), |
1456 | qdt.time().minute(), qdt.time().second()); | 1462 | qdt.time().minute(), qdt.time().second()); |
1457 | } | 1463 | } |
1458 | return tmpStr; | 1464 | return tmpStr; |
1459 | } | 1465 | } |
1460 | 1466 | ||
1461 | QDateTime VCalFormat::ISOToQDateTime(const QString & dtStr) | 1467 | QDateTime VCalFormat::ISOToQDateTime(const QString & dtStr) |
1462 | { | 1468 | { |
1463 | QDate tmpDate; | 1469 | QDate tmpDate; |
1464 | QTime tmpTime; | 1470 | QTime tmpTime; |
1465 | QString tmpStr; | 1471 | QString tmpStr; |
1466 | int year, month, day, hour, minute, second; | 1472 | int year, month, day, hour, minute, second; |
1467 | 1473 | ||
1468 | tmpStr = dtStr; | 1474 | tmpStr = dtStr; |
1469 | year = tmpStr.left(4).toInt(); | 1475 | year = tmpStr.left(4).toInt(); |
1470 | month = tmpStr.mid(4,2).toInt(); | 1476 | month = tmpStr.mid(4,2).toInt(); |
1471 | day = tmpStr.mid(6,2).toInt(); | 1477 | day = tmpStr.mid(6,2).toInt(); |
1472 | hour = tmpStr.mid(9,2).toInt(); | 1478 | hour = tmpStr.mid(9,2).toInt(); |
1473 | minute = tmpStr.mid(11,2).toInt(); | 1479 | minute = tmpStr.mid(11,2).toInt(); |
1474 | second = tmpStr.mid(13,2).toInt(); | 1480 | second = tmpStr.mid(13,2).toInt(); |
1475 | tmpDate.setYMD(year, month, day); | 1481 | tmpDate.setYMD(year, month, day); |
1476 | tmpTime.setHMS(hour, minute, second); | 1482 | tmpTime.setHMS(hour, minute, second); |
1477 | 1483 | ||
1478 | ASSERT(tmpDate.isValid()); | 1484 | ASSERT(tmpDate.isValid()); |
1479 | ASSERT(tmpTime.isValid()); | 1485 | ASSERT(tmpTime.isValid()); |
1480 | QDateTime tmpDT(tmpDate, tmpTime); | 1486 | QDateTime tmpDT(tmpDate, tmpTime); |
1481 | // correct for GMT if string is in Zulu format | 1487 | // correct for GMT if string is in Zulu format |
1482 | if (dtStr.at(dtStr.length()-1) == 'Z') | 1488 | if (dtStr.at(dtStr.length()-1) == 'Z') |
1483 | tmpDT = tmpDT.addSecs (KGlobal::locale()->localTimeOffset( tmpDT )*60); | 1489 | tmpDT = tmpDT.addSecs (KGlobal::locale()->localTimeOffset( tmpDT )*60); |
1484 | return tmpDT; | 1490 | return tmpDT; |
1485 | } | 1491 | } |
1486 | 1492 | ||
1487 | QDate VCalFormat::ISOToQDate(const QString &dateStr) | 1493 | QDate VCalFormat::ISOToQDate(const QString &dateStr) |
1488 | { | 1494 | { |
1489 | int year, month, day; | 1495 | int year, month, day; |
1490 | 1496 | ||
1491 | year = dateStr.left(4).toInt(); | 1497 | year = dateStr.left(4).toInt(); |
1492 | month = dateStr.mid(4,2).toInt(); | 1498 | month = dateStr.mid(4,2).toInt(); |
1493 | day = dateStr.mid(6,2).toInt(); | 1499 | day = dateStr.mid(6,2).toInt(); |
1494 | 1500 | ||
1495 | return(QDate(year, month, day)); | 1501 | return(QDate(year, month, day)); |
1496 | } | 1502 | } |
1497 | 1503 | ||
1498 | // take a raw vcalendar (i.e. from a file on disk, clipboard, etc. etc. | 1504 | // take a raw vcalendar (i.e. from a file on disk, clipboard, etc. etc. |
1499 | // and break it down from it's tree-like format into the dictionary format | 1505 | // and break it down from it's tree-like format into the dictionary format |
1500 | // that is used internally in the VCalFormat. | 1506 | // that is used internally in the VCalFormat. |
1501 | void VCalFormat::populate(VObject *vcal) | 1507 | void VCalFormat::populate(VObject *vcal) |
1502 | { | 1508 | { |
1503 | // this function will populate the caldict dictionary and other event | 1509 | // this function will populate the caldict dictionary and other event |
1504 | // lists. It turns vevents into Events and then inserts them. | 1510 | // lists. It turns vevents into Events and then inserts them. |
1505 | 1511 | ||
1506 | VObjectIterator i; | 1512 | VObjectIterator i; |
1507 | VObject *curVO, *curVOProp; | 1513 | VObject *curVO, *curVOProp; |
1508 | Event *anEvent; | 1514 | Event *anEvent; |
1509 | 1515 | ||
1510 | if ((curVO = isAPropertyOf(vcal, ICMethodProp)) != 0) { | 1516 | if ((curVO = isAPropertyOf(vcal, ICMethodProp)) != 0) { |
1511 | char *methodType = 0; | 1517 | char *methodType = 0; |
1512 | methodType = fakeCString(vObjectUStringZValue(curVO)); | 1518 | methodType = fakeCString(vObjectUStringZValue(curVO)); |
1513 | kdDebug() << "This calendar is an iTIP transaction of type '" | 1519 | kdDebug() << "This calendar is an iTIP transaction of type '" |
1514 | << methodType << "'" << endl; | 1520 | << methodType << "'" << endl; |
1515 | delete methodType; | 1521 | delete methodType; |
1516 | } | 1522 | } |
1517 | 1523 | ||
1518 | // warn the user that we might have trouble reading non-known calendar. | 1524 | // warn the user that we might have trouble reading non-known calendar. |
1519 | if ((curVO = isAPropertyOf(vcal, VCProdIdProp)) != 0) { | 1525 | if ((curVO = isAPropertyOf(vcal, VCProdIdProp)) != 0) { |
1520 | char *s = fakeCString(vObjectUStringZValue(curVO)); | 1526 | char *s = fakeCString(vObjectUStringZValue(curVO)); |
1521 | if (strcmp(productId().local8Bit(), s) != 0) | 1527 | if (strcmp(productId().local8Bit(), s) != 0) |
1522 | kdDebug() << "This vCalendar file was not created by KOrganizer " | 1528 | kdDebug() << "This vCalendar file was not created by KOrganizer " |
1523 | "or any other product we support. Loading anyway..." << endl; | 1529 | "or any other product we support. Loading anyway..." << endl; |
1524 | mLoadedProductId = s; | 1530 | mLoadedProductId = s; |
1525 | deleteStr(s); | 1531 | deleteStr(s); |
1526 | } | 1532 | } |
1527 | 1533 | ||
1528 | // warn the user we might have trouble reading this unknown version. | 1534 | // warn the user we might have trouble reading this unknown version. |
1529 | if ((curVO = isAPropertyOf(vcal, VCVersionProp)) != 0) { | 1535 | if ((curVO = isAPropertyOf(vcal, VCVersionProp)) != 0) { |
1530 | char *s = fakeCString(vObjectUStringZValue(curVO)); | 1536 | char *s = fakeCString(vObjectUStringZValue(curVO)); |
1531 | if (strcmp(_VCAL_VERSION, s) != 0) | 1537 | if (strcmp(_VCAL_VERSION, s) != 0) |
1532 | kdDebug() << "This vCalendar file has version " << s | 1538 | kdDebug() << "This vCalendar file has version " << s |
1533 | << "We only support " << _VCAL_VERSION << endl; | 1539 | << "We only support " << _VCAL_VERSION << endl; |
1534 | deleteStr(s); | 1540 | deleteStr(s); |
1535 | } | 1541 | } |
1536 | 1542 | ||
1537 | // set the time zone | 1543 | // set the time zone |
1538 | if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) { | 1544 | if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) { |
1539 | char *s = fakeCString(vObjectUStringZValue(curVO)); | 1545 | if ( vObjectUStringZValue(curVO) != 0 ) { |
1540 | mCalendar->setTimeZone(s); | 1546 | char *s = fakeCString(vObjectUStringZValue(curVO)); |
1541 | deleteStr(s); | 1547 | mCalendar->setTimeZone(s); |
1548 | deleteStr(s); | ||
1549 | } | ||
1542 | } | 1550 | } |
1543 | 1551 | ||
1544 | |||
1545 | // Store all events with a relatedTo property in a list for post-processing | 1552 | // Store all events with a relatedTo property in a list for post-processing |
1546 | mEventsRelate.clear(); | 1553 | mEventsRelate.clear(); |
1547 | mTodosRelate.clear(); | 1554 | mTodosRelate.clear(); |
1548 | 1555 | ||
1549 | initPropIterator(&i, vcal); | 1556 | initPropIterator(&i, vcal); |
1550 | 1557 | ||
1551 | // go through all the vobjects in the vcal | 1558 | // go through all the vobjects in the vcal |
1552 | while (moreIteration(&i)) { | 1559 | while (moreIteration(&i)) { |
1553 | curVO = nextVObject(&i); | 1560 | curVO = nextVObject(&i); |
1554 | 1561 | ||
1555 | /************************************************************************/ | 1562 | /************************************************************************/ |
1556 | 1563 | ||
1557 | // now, check to see that the object is an event or todo. | 1564 | // now, check to see that the object is an event or todo. |
1558 | if (strcmp(vObjectName(curVO), VCEventProp) == 0) { | 1565 | if (strcmp(vObjectName(curVO), VCEventProp) == 0) { |
1559 | 1566 | ||
1560 | if ((curVOProp = isAPropertyOf(curVO, XPilotStatusProp)) != 0) { | 1567 | if ((curVOProp = isAPropertyOf(curVO, XPilotStatusProp)) != 0) { |
1561 | char *s; | 1568 | char *s; |
1562 | s = fakeCString(vObjectUStringZValue(curVOProp)); | 1569 | s = fakeCString(vObjectUStringZValue(curVOProp)); |
1563 | // check to see if event was deleted by the kpilot conduit | 1570 | // check to see if event was deleted by the kpilot conduit |
1564 | if (atoi(s) == Event::SYNCDEL) { | 1571 | if (atoi(s) == Event::SYNCDEL) { |
1565 | deleteStr(s); | 1572 | deleteStr(s); |
1566 | kdDebug(5800) << "skipping pilot-deleted event" << endl; | 1573 | kdDebug(5800) << "skipping pilot-deleted event" << endl; |
1567 | goto SKIP; | 1574 | goto SKIP; |
1568 | } | 1575 | } |
1569 | deleteStr(s); | 1576 | deleteStr(s); |
1570 | } | 1577 | } |
1571 | 1578 | ||
1572 | // this code checks to see if we are trying to read in an event | 1579 | // this code checks to see if we are trying to read in an event |
1573 | // that we already find to be in the calendar. If we find this | 1580 | // that we already find to be in the calendar. If we find this |
1574 | // to be the case, we skip the event. | 1581 | // to be the case, we skip the event. |
1575 | if ((curVOProp = isAPropertyOf(curVO, VCUniqueStringProp)) != 0) { | 1582 | if ((curVOProp = isAPropertyOf(curVO, VCUniqueStringProp)) != 0) { |
1576 | char *s = fakeCString(vObjectUStringZValue(curVOProp)); | 1583 | char *s = fakeCString(vObjectUStringZValue(curVOProp)); |
1577 | QString tmpStr(s); | 1584 | QString tmpStr(s); |
1578 | deleteStr(s); | 1585 | deleteStr(s); |
1579 | 1586 | ||
1580 | if (mCalendar->event(tmpStr)) { | 1587 | if (mCalendar->event(tmpStr)) { |
1581 | goto SKIP; | 1588 | goto SKIP; |
1582 | } | 1589 | } |
1583 | if (mCalendar->todo(tmpStr)) { | 1590 | if (mCalendar->todo(tmpStr)) { |
1584 | goto SKIP; | 1591 | goto SKIP; |
1585 | } | 1592 | } |
1586 | } | 1593 | } |
1587 | 1594 | ||
1588 | if ((!(curVOProp = isAPropertyOf(curVO, VCDTstartProp))) && | 1595 | if ((!(curVOProp = isAPropertyOf(curVO, VCDTstartProp))) && |
1589 | (!(curVOProp = isAPropertyOf(curVO, VCDTendProp)))) { | 1596 | (!(curVOProp = isAPropertyOf(curVO, VCDTendProp)))) { |
1590 | kdDebug(5800) << "found a VEvent with no DTSTART and no DTEND! Skipping..." << endl; | 1597 | kdDebug(5800) << "found a VEvent with no DTSTART and no DTEND! Skipping..." << endl; |
1591 | goto SKIP; | 1598 | goto SKIP; |
1592 | } | 1599 | } |
1593 | 1600 | ||
1594 | anEvent = VEventToEvent(curVO); | 1601 | anEvent = VEventToEvent(curVO); |
1595 | // we now use addEvent instead of insertEvent so that the | 1602 | // we now use addEvent instead of insertEvent so that the |
1596 | // signal/slot get connected. | 1603 | // signal/slot get connected. |
1597 | if (anEvent) { | 1604 | if (anEvent) { |
1598 | if ( !anEvent->dtStart().isValid() || !anEvent->dtEnd().isValid() ) { | 1605 | if ( !anEvent->dtStart().isValid() || !anEvent->dtEnd().isValid() ) { |
1599 | kdDebug() << "VCalFormat::populate(): Event has invalid dates." | 1606 | kdDebug() << "VCalFormat::populate(): Event has invalid dates." |
1600 | << endl; | 1607 | << endl; |
1601 | } else { | 1608 | } else { |
1602 | mCalendar->addEvent(anEvent); | 1609 | mCalendar->addEvent(anEvent); |
1603 | } | 1610 | } |
1604 | } else { | 1611 | } else { |
1605 | // some sort of error must have occurred while in translation. | 1612 | // some sort of error must have occurred while in translation. |
1606 | goto SKIP; | 1613 | goto SKIP; |
1607 | } | 1614 | } |
1608 | } else if (strcmp(vObjectName(curVO), VCTodoProp) == 0) { | 1615 | } else if (strcmp(vObjectName(curVO), VCTodoProp) == 0) { |
1609 | Todo *aTodo = VTodoToEvent(curVO); | 1616 | Todo *aTodo = VTodoToEvent(curVO); |
1610 | mCalendar->addTodo(aTodo); | 1617 | mCalendar->addTodo(aTodo); |
1611 | } else if ((strcmp(vObjectName(curVO), VCVersionProp) == 0) || | 1618 | } else if ((strcmp(vObjectName(curVO), VCVersionProp) == 0) || |
1612 | (strcmp(vObjectName(curVO), VCProdIdProp) == 0) || | 1619 | (strcmp(vObjectName(curVO), VCProdIdProp) == 0) || |
1613 | (strcmp(vObjectName(curVO), VCTimeZoneProp) == 0)) { | 1620 | (strcmp(vObjectName(curVO), VCTimeZoneProp) == 0)) { |
1614 | // do nothing, we know these properties and we want to skip them. | 1621 | // do nothing, we know these properties and we want to skip them. |
1615 | // we have either already processed them or are ignoring them. | 1622 | // we have either already processed them or are ignoring them. |
1616 | ; | 1623 | ; |
1617 | } else { | 1624 | } else { |
1618 | kdDebug(5800) << "Ignoring unknown vObject \"" << vObjectName(curVO) << "\"" << endl; | 1625 | kdDebug(5800) << "Ignoring unknown vObject \"" << vObjectName(curVO) << "\"" << endl; |
1619 | } | 1626 | } |
1620 | SKIP: | 1627 | SKIP: |
1621 | ; | 1628 | ; |
1622 | } // while | 1629 | } // while |
1623 | 1630 | ||
1624 | // Post-Process list of events with relations, put Event objects in relation | 1631 | // Post-Process list of events with relations, put Event objects in relation |
1625 | Event *ev; | 1632 | Event *ev; |
1626 | for ( ev=mEventsRelate.first(); ev != 0; ev=mEventsRelate.next() ) { | 1633 | for ( ev=mEventsRelate.first(); ev != 0; ev=mEventsRelate.next() ) { |
1627 | ev->setRelatedTo(mCalendar->event(ev->relatedToUid())); | 1634 | ev->setRelatedTo(mCalendar->event(ev->relatedToUid())); |
1628 | } | 1635 | } |
1629 | Todo *todo; | 1636 | Todo *todo; |
1630 | for ( todo=mTodosRelate.first(); todo != 0; todo=mTodosRelate.next() ) { | 1637 | for ( todo=mTodosRelate.first(); todo != 0; todo=mTodosRelate.next() ) { |
1631 | todo->setRelatedTo(mCalendar->todo(todo->relatedToUid())); | 1638 | todo->setRelatedTo(mCalendar->todo(todo->relatedToUid())); |
1632 | } | 1639 | } |
1633 | } | 1640 | } |
1634 | 1641 | ||
1635 | const char *VCalFormat::dayFromNum(int day) | 1642 | const char *VCalFormat::dayFromNum(int day) |
1636 | { | 1643 | { |
1637 | const char *days[7] = { "MO ", "TU ", "WE ", "TH ", "FR ", "SA ", "SU " }; | 1644 | const char *days[7] = { "MO ", "TU ", "WE ", "TH ", "FR ", "SA ", "SU " }; |
1638 | 1645 | ||
1639 | return days[day]; | 1646 | return days[day]; |
1640 | } | 1647 | } |
1641 | 1648 | ||
1642 | int VCalFormat::numFromDay(const QString &day) | 1649 | int VCalFormat::numFromDay(const QString &day) |
1643 | { | 1650 | { |
1644 | if (day == "MO ") return 0; | 1651 | if (day == "MO ") return 0; |
1645 | if (day == "TU ") return 1; | 1652 | if (day == "TU ") return 1; |
1646 | if (day == "WE ") return 2; | 1653 | if (day == "WE ") return 2; |
1647 | if (day == "TH ") return 3; | 1654 | if (day == "TH ") return 3; |
1648 | if (day == "FR ") return 4; | 1655 | if (day == "FR ") return 4; |
1649 | if (day == "SA ") return 5; | 1656 | if (day == "SA ") return 5; |
1650 | if (day == "SU ") return 6; | 1657 | if (day == "SU ") return 6; |
1651 | 1658 | ||
1652 | return -1; // something bad happened. :) | 1659 | return -1; // something bad happened. :) |
1653 | } | 1660 | } |
1654 | 1661 | ||
1655 | Attendee::PartStat VCalFormat::readStatus(const char *s) const | 1662 | Attendee::PartStat VCalFormat::readStatus(const char *s) const |
1656 | { | 1663 | { |
1657 | QString statStr = s; | 1664 | QString statStr = s; |
1658 | statStr = statStr.upper(); | 1665 | statStr = statStr.upper(); |
1659 | Attendee::PartStat status; | 1666 | Attendee::PartStat status; |
1660 | 1667 | ||
1661 | if (statStr == "X-ACTION") | 1668 | if (statStr == "X-ACTION") |
1662 | status = Attendee::NeedsAction; | 1669 | status = Attendee::NeedsAction; |
1663 | else if (statStr == "NEEDS ACTION") | 1670 | else if (statStr == "NEEDS ACTION") |
1664 | status = Attendee::NeedsAction; | 1671 | status = Attendee::NeedsAction; |
1665 | else if (statStr== "ACCEPTED") | 1672 | else if (statStr== "ACCEPTED") |
1666 | status = Attendee::Accepted; | 1673 | status = Attendee::Accepted; |
1667 | else if (statStr== "SENT") | 1674 | else if (statStr== "SENT") |
1668 | status = Attendee::NeedsAction; | 1675 | status = Attendee::NeedsAction; |
1669 | else if (statStr== "TENTATIVE") | 1676 | else if (statStr== "TENTATIVE") |
1670 | status = Attendee::Tentative; | 1677 | status = Attendee::Tentative; |
1671 | else if (statStr== "CONFIRMED") | 1678 | else if (statStr== "CONFIRMED") |
1672 | status = Attendee::Accepted; | 1679 | status = Attendee::Accepted; |
1673 | else if (statStr== "DECLINED") | 1680 | else if (statStr== "DECLINED") |
1674 | status = Attendee::Declined; | 1681 | status = Attendee::Declined; |
1675 | else if (statStr== "COMPLETED") | 1682 | else if (statStr== "COMPLETED") |
1676 | status = Attendee::Completed; | 1683 | status = Attendee::Completed; |
1677 | else if (statStr== "DELEGATED") | 1684 | else if (statStr== "DELEGATED") |
1678 | status = Attendee::Delegated; | 1685 | status = Attendee::Delegated; |
1679 | else { | 1686 | else { |
1680 | kdDebug(5800) << "error setting attendee mStatus, unknown mStatus!" << endl; | 1687 | kdDebug(5800) << "error setting attendee mStatus, unknown mStatus!" << endl; |
1681 | status = Attendee::NeedsAction; | 1688 | status = Attendee::NeedsAction; |
1682 | } | 1689 | } |
1683 | 1690 | ||
1684 | return status; | 1691 | return status; |
1685 | } | 1692 | } |
1686 | 1693 | ||
1687 | QCString VCalFormat::writeStatus(Attendee::PartStat status) const | 1694 | QCString VCalFormat::writeStatus(Attendee::PartStat status) const |
1688 | { | 1695 | { |
1689 | switch(status) { | 1696 | switch(status) { |
1690 | default: | 1697 | default: |
1691 | case Attendee::NeedsAction: | 1698 | case Attendee::NeedsAction: |
1692 | return "NEEDS ACTION"; | 1699 | return "NEEDS ACTION"; |
1693 | break; | 1700 | break; |
1694 | case Attendee::Accepted: | 1701 | case Attendee::Accepted: |
1695 | return "ACCEPTED"; | 1702 | return "ACCEPTED"; |
1696 | break; | 1703 | break; |
1697 | case Attendee::Declined: | 1704 | case Attendee::Declined: |
1698 | return "DECLINED"; | 1705 | return "DECLINED"; |
1699 | break; | 1706 | break; |
1700 | case Attendee::Tentative: | 1707 | case Attendee::Tentative: |
1701 | return "TENTATIVE"; | 1708 | return "TENTATIVE"; |
1702 | break; | 1709 | break; |
1703 | case Attendee::Delegated: | 1710 | case Attendee::Delegated: |
1704 | return "DELEGATED"; | 1711 | return "DELEGATED"; |
1705 | break; | 1712 | break; |
1706 | case Attendee::Completed: | 1713 | case Attendee::Completed: |
1707 | return "COMPLETED"; | 1714 | return "COMPLETED"; |
1708 | break; | 1715 | break; |
1709 | case Attendee::InProcess: | 1716 | case Attendee::InProcess: |
1710 | return "NEEDS ACTION"; | 1717 | return "NEEDS ACTION"; |
1711 | break; | 1718 | break; |
1712 | } | 1719 | } |
1713 | } | 1720 | } |
diff --git a/libkdepim/phoneaccess.cpp b/libkdepim/phoneaccess.cpp index 8298aa6..e24ad9e 100644 --- a/libkdepim/phoneaccess.cpp +++ b/libkdepim/phoneaccess.cpp | |||
@@ -1,173 +1,216 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkdepim. | 2 | This file is part of libkdepim. |
3 | 3 | ||
4 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> | 4 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | 22 | ||
23 | #include <qstring.h> | 23 | #include <qstring.h> |
24 | #include <qapplication.h> | 24 | #include <qapplication.h> |
25 | #include <qptrlist.h> | 25 | #include <qptrlist.h> |
26 | #include <qregexp.h> | 26 | #include <qregexp.h> |
27 | #include <qfile.h> | 27 | #include <qfile.h> |
28 | #include <qlabel.h> | ||
28 | #include <qtextstream.h> | 29 | #include <qtextstream.h> |
29 | #include <qtextcodec.h> | 30 | #include <qtextcodec.h> |
30 | #include <qdir.h> | 31 | #include <qdir.h> |
31 | #include <kmessagebox.h> | 32 | #include <kmessagebox.h> |
32 | #include <stdlib.h> | 33 | #include <stdlib.h> |
33 | #include "phoneaccess.h" | 34 | #include "phoneaccess.h" |
34 | 35 | ||
35 | void PhoneAccess::writeConfig( QString device, QString connection, QString model ) | 36 | void PhoneAccess::writeConfig( QString device, QString connection, QString model ) |
36 | { | 37 | { |
37 | #ifdef _WIN32_ | 38 | #ifdef _WIN32_ |
38 | QString fileName = qApp->applicationDirPath () +"\\gammurc"; | 39 | QString fileName = qApp->applicationDirPath () +"\\gammurc"; |
39 | #else | 40 | #else |
40 | QString fileName = QDir::homeDirPath() +"/.gammurc"; | 41 | QString fileName = QDir::homeDirPath() +"/.gammurc"; |
41 | #endif | 42 | #endif |
42 | //qDebug("save %d ", load ); | 43 | //qDebug("save %d ", load ); |
43 | QString content = "[gammu]\n";; | 44 | QString content = "[gammu]\n";; |
44 | bool write = false; | 45 | bool write = false; |
45 | bool addPort = true, addConnection = true, addModel = true; | 46 | bool addPort = true, addConnection = true, addModel = true; |
46 | QFile file( fileName ); | 47 | QFile file( fileName ); |
47 | if ( QFile::exists( fileName) ) { | 48 | if ( QFile::exists( fileName) ) { |
48 | if (!file.open( IO_ReadOnly ) ) { | 49 | if (!file.open( IO_ReadOnly ) ) { |
49 | qDebug("Error: cannot open %s ", fileName.latin1() ); | 50 | qDebug("Error: cannot open %s ", fileName.latin1() ); |
50 | return; | 51 | return; |
51 | } | 52 | } |
52 | QString line; | 53 | QString line; |
53 | while ( file.readLine( line, 1024 ) > 0 ) { | 54 | while ( file.readLine( line, 1024 ) > 0 ) { |
54 | //qDebug("*%s* ", line.latin1() ); | 55 | //qDebug("*%s* ", line.latin1() ); |
55 | if ( line.left(7 ) == "[gammu]" ) { | 56 | if ( line.left(7 ) == "[gammu]" ) { |
56 | ; | 57 | ; |
57 | } else | 58 | } else |
58 | if ( line.left(4 ) == "port" ) { | 59 | if ( line.left(4 ) == "port" ) { |
59 | if ( line == "port = " + device+"\n" ) { | 60 | if ( line == "port = " + device+"\n" ) { |
60 | content += line ; | 61 | content += line ; |
61 | addPort = false; | 62 | addPort = false; |
62 | //qDebug("port found" ); | 63 | //qDebug("port found" ); |
63 | } | 64 | } |
64 | 65 | ||
65 | } else if ( line.left(5 ) == "model" ) { | 66 | } else if ( line.left(5 ) == "model" ) { |
66 | if ( line == "model = " + model +"\n") { | 67 | if ( line == "model = " + model +"\n") { |
67 | content += line ; | 68 | content += line ; |
68 | addModel = false; | 69 | addModel = false; |
69 | //qDebug("model found" ); | 70 | //qDebug("model found" ); |
70 | } | 71 | } |
71 | 72 | ||
72 | } else if ( line.left( 10 ) == "connection" ) { | 73 | } else if ( line.left( 10 ) == "connection" ) { |
73 | if ( line == "connection = " + connection +"\n") { | 74 | if ( line == "connection = " + connection +"\n") { |
74 | addConnection = false; | 75 | addConnection = false; |
75 | content += line ; | 76 | content += line ; |
76 | //qDebug("con found" ); | 77 | //qDebug("con found" ); |
77 | } | 78 | } |
78 | 79 | ||
79 | } else { | 80 | } else { |
80 | content += line ; | 81 | content += line ; |
81 | } | 82 | } |
82 | } | 83 | } |
83 | file.close(); | 84 | file.close(); |
84 | } else { | 85 | } else { |
85 | if ( ! connection.isEmpty() ) { | 86 | if ( ! connection.isEmpty() ) { |
86 | addConnection = true; | 87 | addConnection = true; |
87 | } | 88 | } |
88 | if ( ! device.isEmpty() ) { | 89 | if ( ! device.isEmpty() ) { |
89 | addPort = true; | 90 | addPort = true; |
90 | 91 | ||
91 | } | 92 | } |
92 | if ( ! model.isEmpty() ) { | 93 | if ( ! model.isEmpty() ) { |
93 | addModel = true; | 94 | addModel = true; |
94 | } | 95 | } |
95 | } | 96 | } |
96 | 97 | ||
97 | if ( addConnection ) { | 98 | if ( addConnection ) { |
98 | write = true; | 99 | write = true; |
99 | content += "connection = "; | 100 | content += "connection = "; |
100 | content += connection; | 101 | content += connection; |
101 | content += "\n"; | 102 | content += "\n"; |
102 | } | 103 | } |
103 | if ( addPort ) { | 104 | if ( addPort ) { |
104 | write = true; | 105 | write = true; |
105 | content += "port = "; | 106 | content += "port = "; |
106 | content += device; | 107 | content += device; |
107 | content += "\n"; | 108 | content += "\n"; |
108 | 109 | ||
109 | } | 110 | } |
110 | if ( addModel ) { | 111 | if ( addModel ) { |
111 | write = true; | 112 | write = true; |
112 | content += "model = "; | 113 | content += "model = "; |
113 | content += model; | 114 | content += model; |
114 | content += "\n"; | 115 | content += "\n"; |
115 | } | 116 | } |
116 | if ( write ) { | 117 | if ( write ) { |
117 | if (!file.open( IO_WriteOnly ) ) { | 118 | if (!file.open( IO_WriteOnly ) ) { |
118 | qDebug("Error: cannot write file %s ", fileName.latin1() ); | 119 | qDebug("Error: cannot write file %s ", fileName.latin1() ); |
119 | return; | 120 | return; |
120 | } | 121 | } |
121 | qDebug("Writing file %s ", fileName.latin1() ); | 122 | qDebug("Writing file %s ", fileName.latin1() ); |
122 | QTextStream ts( &file ); | 123 | QTextStream ts( &file ); |
123 | ts << content ; | 124 | ts << content ; |
124 | file.close(); | 125 | file.close(); |
125 | } | 126 | } |
126 | 127 | ||
127 | } | 128 | } |
128 | 129 | ||
129 | 130 | ||
130 | bool PhoneAccess::writeToPhone( QString fileName) | 131 | bool PhoneAccess::writeToPhone( QString fileName) |
131 | { | 132 | { |
132 | 133 | ||
133 | #ifdef DESKTOP_VERSION | 134 | #ifdef DESKTOP_VERSION |
134 | #ifdef _WIN32_ | 135 | #ifdef _WIN32_ |
135 | QString command ="kammu --restore " + fileName ; | 136 | QString command ="kammu --restore " + fileName ; |
136 | #else | 137 | #else |
137 | QString command ="./kammu --restore " + fileName ; | 138 | QString command ="./kammu --restore " + fileName ; |
138 | #endif | 139 | #endif |
139 | #else | 140 | #else |
140 | QString command ="kammu --restore " + fileName ; | 141 | QString command ="kammu --restore " + fileName ; |
141 | #endif | 142 | #endif |
142 | int ret; | 143 | int ret = 1; |
143 | while ( (ret = system ( command.latin1())) != 0 ) { | 144 | while ( ret != 0 ) { |
144 | qDebug("Error S::command returned %d.", ret); | 145 | QLabel* status = new QLabel( i18n(" This may take 1-3 minutes!"), 0 ); |
145 | int retval = KMessageBox::warningContinueCancel(0, | 146 | int w = 235; |
146 | i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel")); | 147 | int h = status->sizeHint().height()+20 ; |
147 | if ( retval != KMessageBox::Continue ) | 148 | int dw = QApplication::desktop()->width(); |
148 | return false; | 149 | int dh = QApplication::desktop()->height(); |
150 | if ( dw > 310 ) | ||
151 | w = 310; | ||
152 | status->setCaption(i18n("Writing to phone...") ); | ||
153 | status->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | ||
154 | status->show(); | ||
155 | status->raise(); | ||
156 | status->update(); | ||
157 | qApp->processEvents(); | ||
158 | status->update(); | ||
159 | qApp->processEvents(); | ||
160 | ret = system ( command.latin1()); | ||
161 | delete status; | ||
162 | qApp->processEvents(); | ||
163 | if ( ret ) { | ||
164 | qDebug("Error S::command returned %d.", ret); | ||
165 | int retval = KMessageBox::warningContinueCancel(0, | ||
166 | i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel")); | ||
167 | if ( retval != KMessageBox::Continue ) | ||
168 | return false; | ||
169 | } | ||
149 | } | 170 | } |
150 | return true; | 171 | return true; |
151 | } | 172 | } |
152 | bool PhoneAccess::readFromPhone( QString fileName) | 173 | bool PhoneAccess::readFromPhone( QString fileName) |
153 | { | 174 | { |
154 | 175 | ||
155 | #ifdef DESKTOP_VERSION | 176 | #ifdef DESKTOP_VERSION |
156 | #ifdef _WIN32_ | 177 | #ifdef _WIN32_ |
157 | QString command ="kammu --backup " + fileName + " -yes" ; | 178 | QString command ="kammu --backup " + fileName + " -yes" ; |
158 | #else | 179 | #else |
159 | QString command ="./kammu --backup " + fileName + " -yes" ; | 180 | QString command ="./kammu --backup " + fileName + " -yes" ; |
160 | #endif | 181 | #endif |
161 | #else | 182 | #else |
162 | QString command ="kammu --backup " + fileName + " -yes" ; | 183 | QString command ="kammu --backup " + fileName + " -yes" ; |
163 | #endif | 184 | #endif |
164 | int ret; | 185 | int ret; |
165 | while ( (ret = system ( command.latin1())) != 0 ) { | 186 | while ( ret != 0 ) { |
166 | qDebug("Error reading from phone:Command returned %d", ret); | 187 | QLabel* status = new QLabel( i18n(" This may take 1-3 minutes!"), 0 ); |
167 | int retval = KMessageBox::warningContinueCancel(0, | 188 | int w = 235; |
168 | i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel")); | 189 | int h = status->sizeHint().height()+20 ; |
169 | if ( retval != KMessageBox::Continue ) | 190 | int dw = QApplication::desktop()->width(); |
170 | return false; | 191 | int dh = QApplication::desktop()->height(); |
192 | if ( dw > 310 ) | ||
193 | w = 310; | ||
194 | status->setCaption(i18n("Reading from phone...") ); | ||
195 | status->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | ||
196 | status->show(); | ||
197 | status->raise(); | ||
198 | status->update(); | ||
199 | qApp->processEvents(); | ||
200 | status->update(); | ||
201 | qApp->processEvents(); | ||
202 | ret = system ( command.latin1() ); | ||
203 | delete status; | ||
204 | qApp->processEvents(); | ||
205 | if ( ret ) { | ||
206 | qDebug("Error reading from phone:Command returned %d", ret); | ||
207 | int retval = KMessageBox::warningContinueCancel(0, | ||
208 | i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel")); | ||
209 | if ( retval != KMessageBox::Continue ) | ||
210 | return false; | ||
211 | |||
212 | } | ||
171 | } | 213 | } |
214 | qApp->processEvents(); | ||
172 | return true; | 215 | return true; |
173 | } | 216 | } |
diff --git a/microkde/microkde.pro b/microkde/microkde.pro index 71d662b..21da158 100644 --- a/microkde/microkde.pro +++ b/microkde/microkde.pro | |||
@@ -1,176 +1,174 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt warn_on | 2 | CONFIG += qt warn_on |
3 | #INCLUDEPATH += $(QTDIR)/include . | 3 | #INCLUDEPATH += $(QTDIR)/include . |
4 | #DEPENDPATH += $(QTDIR)/include | 4 | #DEPENDPATH += $(QTDIR)/include |
5 | INCLUDEPATH += . ../ ../kabc ./kdecore ./kdeui ./kio/kfile ./kio/kio | 5 | INCLUDEPATH += . ../ ../kabc ./kdecore ./kdeui ./kio/kfile ./kio/kio |
6 | #LIBS += -lqtcompat | 6 | #LIBS += -lqtcompat |
7 | 7 | ||
8 | TARGET = microkde | 8 | TARGET = microkde |
9 | DESTDIR= ../bin | 9 | DESTDIR= ../bin |
10 | DEFINES += DESKTOP_VERSION KDE_QT_ONLY | 10 | DEFINES += DESKTOP_VERSION KDE_QT_ONLY |
11 | unix : { | 11 | unix : { |
12 | OBJECTS_DIR = obj/unix | 12 | OBJECTS_DIR = obj/unix |
13 | MOC_DIR = moc/unix | 13 | MOC_DIR = moc/unix |
14 | } | 14 | } |
15 | win32: { | 15 | win32: { |
16 | DEFINES += _WIN32_ | 16 | DEFINES += _WIN32_ |
17 | OBJECTS_DIR = obj/win | 17 | OBJECTS_DIR = obj/win |
18 | MOC_DIR = moc/win | 18 | MOC_DIR = moc/win |
19 | } | 19 | } |
20 | include( ../variables.pri ) | 20 | include( ../variables.pri ) |
21 | 21 | ||
22 | 22 | ||
23 | 23 | ||
24 | HEADERS = \ | 24 | HEADERS = \ |
25 | qlayoutengine_p.h \ | 25 | qlayoutengine_p.h \ |
26 | KDGanttMinimizeSplitter.h \ | 26 | KDGanttMinimizeSplitter.h \ |
27 | kapplication.h \ | 27 | kapplication.h \ |
28 | kaudioplayer.h \ | 28 | kaudioplayer.h \ |
29 | kcalendarsystem.h \ | 29 | kcalendarsystem.h \ |
30 | kcalendarsystemgregorian.h \ | 30 | kcalendarsystemgregorian.h \ |
31 | kcolorbutton.h \ | 31 | kcolorbutton.h \ |
32 | kcolordialog.h \ | 32 | kcolordialog.h \ |
33 | kcombobox.h \ | 33 | kcombobox.h \ |
34 | kconfig.h \ | 34 | kconfig.h \ |
35 | kdatetbl.h \ | 35 | kdatetbl.h \ |
36 | kdebug.h \ | 36 | kdebug.h \ |
37 | kdialog.h \ | 37 | kdialog.h \ |
38 | kdialogbase.h \ | 38 | kdialogbase.h \ |
39 | keditlistbox.h \ | 39 | keditlistbox.h \ |
40 | kemailsettings.h \ | 40 | kemailsettings.h \ |
41 | kfiledialog.h \ | 41 | kfiledialog.h \ |
42 | kfontdialog.h \ | 42 | kfontdialog.h \ |
43 | kglobal.h \ | 43 | kglobal.h \ |
44 | kglobalsettings.h \ | 44 | kglobalsettings.h \ |
45 | kiconloader.h \ | 45 | kiconloader.h \ |
46 | klineedit.h \ | 46 | klineedit.h \ |
47 | klineeditdlg.h \ | 47 | klineeditdlg.h \ |
48 | kmessagebox.h \ | 48 | kmessagebox.h \ |
49 | knotifyclient.h \ | 49 | knotifyclient.h \ |
50 | kprinter.h \ | 50 | kprinter.h \ |
51 | kprocess.h \ | 51 | kprocess.h \ |
52 | krestrictedline.h \ | 52 | krestrictedline.h \ |
53 | krun.h \ | 53 | krun.h \ |
54 | ksimpleconfig.h \ | 54 | ksimpleconfig.h \ |
55 | kstaticdeleter.h \ | 55 | kstaticdeleter.h \ |
56 | ksystemtray.h \ | 56 | ksystemtray.h \ |
57 | ktempfile.h \ | 57 | ktempfile.h \ |
58 | ktextedit.h \ | 58 | ktextedit.h \ |
59 | kunload.h \ | 59 | kunload.h \ |
60 | kurl.h \ | 60 | kurl.h \ |
61 | kdeui/kguiitem.h \ | 61 | kdeui/kguiitem.h \ |
62 | kdeui/kcmodule.h \ | 62 | kdeui/kcmodule.h \ |
63 | kdeui/kbuttonbox.h \ | 63 | kdeui/kbuttonbox.h \ |
64 | kdeui/klistbox.h \ | 64 | kdeui/klistbox.h \ |
65 | kdeui/klistview.h \ | 65 | kdeui/klistview.h \ |
66 | kdeui/kjanuswidget.h \ | 66 | kdeui/kjanuswidget.h \ |
67 | kdeui/kseparator.h \ | 67 | kdeui/kseparator.h \ |
68 | kdeui/knuminput.h \ | 68 | kdeui/knuminput.h \ |
69 | kdeui/knumvalidator.h \ | 69 | kdeui/knumvalidator.h \ |
70 | kdeui/ksqueezedtextlabel.h \ | 70 | kdeui/ksqueezedtextlabel.h \ |
71 | kio/job.h \ | 71 | kio/job.h \ |
72 | kio/kio/kdirwatch.h \ | 72 | kio/kio/kdirwatch.h \ |
73 | kio/kio/kdirwatch_p.h \ | 73 | kio/kio/kdirwatch_p.h \ |
74 | kio/kfile/kurlrequester.h \ | 74 | kio/kfile/kurlrequester.h \ |
75 | kresources/resource.h \ | 75 | kresources/resource.h \ |
76 | kresources/factory.h \ | 76 | kresources/factory.h \ |
77 | kresources/managerimpl.h \ | 77 | kresources/managerimpl.h \ |
78 | kresources/manager.h \ | 78 | kresources/manager.h \ |
79 | kresources/selectdialog.h \ | 79 | kresources/selectdialog.h \ |
80 | kresources/configpage.h \ | 80 | kresources/configpage.h \ |
81 | kresources/configwidget.h \ | 81 | kresources/configwidget.h \ |
82 | kresources/configdialog.h \ | 82 | kresources/configdialog.h \ |
83 | kresources/kcmkresources.h \ | 83 | kresources/kcmkresources.h \ |
84 | kresources/syncwidget.h \ | ||
85 | kdecore/kmdcodec.h \ | 84 | kdecore/kmdcodec.h \ |
86 | kdecore/kconfigbase.h \ | 85 | kdecore/kconfigbase.h \ |
87 | kdecore/klocale.h \ | 86 | kdecore/klocale.h \ |
88 | kdecore/kcatalogue.h \ | 87 | kdecore/kcatalogue.h \ |
89 | kdecore/ksharedptr.h \ | 88 | kdecore/ksharedptr.h \ |
90 | kdecore/kshell.h \ | 89 | kdecore/kshell.h \ |
91 | kdecore/kstandarddirs.h \ | 90 | kdecore/kstandarddirs.h \ |
92 | kdecore/kstringhandler.h \ | 91 | kdecore/kstringhandler.h \ |
93 | kdecore/kshortcut.h \ | 92 | kdecore/kshortcut.h \ |
94 | kutils/kcmultidialog.h \ | 93 | kutils/kcmultidialog.h \ |
95 | kdeui/kxmlguiclient.h \ | 94 | kdeui/kxmlguiclient.h \ |
96 | kdeui/kstdaction.h \ | 95 | kdeui/kstdaction.h \ |
97 | kdeui/kmainwindow.h \ | 96 | kdeui/kmainwindow.h \ |
98 | kdeui/ktoolbar.h \ | 97 | kdeui/ktoolbar.h \ |
99 | kdeui/ktoolbarbutton.h \ | 98 | kdeui/ktoolbarbutton.h \ |
100 | kdeui/ktoolbarhandler.h \ | 99 | kdeui/ktoolbarhandler.h \ |
101 | kdeui/kaction.h \ | 100 | kdeui/kaction.h \ |
102 | kdeui/kactionclasses.h \ | 101 | kdeui/kactionclasses.h \ |
103 | kdeui/kactioncollection.h \ | 102 | kdeui/kactioncollection.h \ |
104 | kdecore/kprefs.h \ | 103 | kdecore/kprefs.h \ |
105 | kdecore/klibloader.h \ | 104 | kdecore/klibloader.h \ |
106 | kidmanager.h | 105 | kidmanager.h |
107 | 106 | ||
108 | 107 | ||
109 | # kdecore/klibloader.h \ | 108 | # kdecore/klibloader.h \ |
110 | 109 | ||
111 | 110 | ||
112 | SOURCES = \ | 111 | SOURCES = \ |
113 | KDGanttMinimizeSplitter.cpp \ | 112 | KDGanttMinimizeSplitter.cpp \ |
114 | kapplication.cpp \ | 113 | kapplication.cpp \ |
115 | kcalendarsystem.cpp \ | 114 | kcalendarsystem.cpp \ |
116 | kcalendarsystemgregorian.cpp \ | 115 | kcalendarsystemgregorian.cpp \ |
117 | kcolorbutton.cpp \ | 116 | kcolorbutton.cpp \ |
118 | kcolordialog.cpp \ | 117 | kcolordialog.cpp \ |
119 | kconfig.cpp \ | 118 | kconfig.cpp \ |
120 | kdatetbl.cpp \ | 119 | kdatetbl.cpp \ |
121 | kdialog.cpp \ | 120 | kdialog.cpp \ |
122 | kdialogbase.cpp \ | 121 | kdialogbase.cpp \ |
123 | keditlistbox.cpp \ | 122 | keditlistbox.cpp \ |
124 | kemailsettings.cpp \ | 123 | kemailsettings.cpp \ |
125 | kfontdialog.cpp \ | 124 | kfontdialog.cpp \ |
126 | kfiledialog.cpp \ | 125 | kfiledialog.cpp \ |
127 | kglobal.cpp \ | 126 | kglobal.cpp \ |
128 | kglobalsettings.cpp \ | 127 | kglobalsettings.cpp \ |
129 | kiconloader.cpp \ | 128 | kiconloader.cpp \ |
130 | kmessagebox.cpp \ | 129 | kmessagebox.cpp \ |
131 | ktextedit.cpp \ | 130 | ktextedit.cpp \ |
132 | kprocess.cpp \ | 131 | kprocess.cpp \ |
133 | krun.cpp \ | 132 | krun.cpp \ |
134 | ksystemtray.cpp \ | 133 | ksystemtray.cpp \ |
135 | ktempfile.cpp \ | 134 | ktempfile.cpp \ |
136 | kurl.cpp \ | 135 | kurl.cpp \ |
137 | kdecore/kcatalogue.cpp \ | 136 | kdecore/kcatalogue.cpp \ |
138 | kdecore/klocale.cpp \ | 137 | kdecore/klocale.cpp \ |
139 | kdecore/kmdcodec.cpp \ | 138 | kdecore/kmdcodec.cpp \ |
140 | kdecore/kshell.cpp \ | 139 | kdecore/kshell.cpp \ |
141 | kdecore/kstandarddirs.cpp \ | 140 | kdecore/kstandarddirs.cpp \ |
142 | kdecore/kstringhandler.cpp \ | 141 | kdecore/kstringhandler.cpp \ |
143 | kdeui/kbuttonbox.cpp \ | 142 | kdeui/kbuttonbox.cpp \ |
144 | kdeui/kcmodule.cpp \ | 143 | kdeui/kcmodule.cpp \ |
145 | kdeui/kguiitem.cpp \ | 144 | kdeui/kguiitem.cpp \ |
146 | kdeui/kjanuswidget.cpp \ | 145 | kdeui/kjanuswidget.cpp \ |
147 | kdeui/klistbox.cpp \ | 146 | kdeui/klistbox.cpp \ |
148 | kdeui/klistview.cpp \ | 147 | kdeui/klistview.cpp \ |
149 | kdeui/knuminput.cpp \ | 148 | kdeui/knuminput.cpp \ |
150 | kdeui/knumvalidator.cpp \ | 149 | kdeui/knumvalidator.cpp \ |
151 | kdeui/kseparator.cpp \ | 150 | kdeui/kseparator.cpp \ |
152 | kdeui/ksqueezedtextlabel.cpp \ | 151 | kdeui/ksqueezedtextlabel.cpp \ |
153 | kio/kio/kdirwatch.cpp \ | 152 | kio/kio/kdirwatch.cpp \ |
154 | kio/kfile/kurlrequester.cpp \ | 153 | kio/kfile/kurlrequester.cpp \ |
155 | kresources/configpage.cpp \ | 154 | kresources/configpage.cpp \ |
156 | kresources/configdialog.cpp \ | 155 | kresources/configdialog.cpp \ |
157 | kresources/configwidget.cpp \ | 156 | kresources/configwidget.cpp \ |
158 | kresources/factory.cpp \ | 157 | kresources/factory.cpp \ |
159 | kresources/kcmkresources.cpp \ | 158 | kresources/kcmkresources.cpp \ |
160 | kresources/managerimpl.cpp \ | 159 | kresources/managerimpl.cpp \ |
161 | kresources/resource.cpp \ | 160 | kresources/resource.cpp \ |
162 | kresources/selectdialog.cpp \ | 161 | kresources/selectdialog.cpp \ |
163 | kresources/syncwidget.cpp \ | ||
164 | kutils/kcmultidialog.cpp \ | 162 | kutils/kcmultidialog.cpp \ |
165 | kdeui/kaction.cpp \ | 163 | kdeui/kaction.cpp \ |
166 | kdeui/kactionclasses.cpp \ | 164 | kdeui/kactionclasses.cpp \ |
167 | kdeui/kactioncollection.cpp \ | 165 | kdeui/kactioncollection.cpp \ |
168 | kdeui/kmainwindow.cpp \ | 166 | kdeui/kmainwindow.cpp \ |
169 | kdeui/ktoolbar.cpp \ | 167 | kdeui/ktoolbar.cpp \ |
170 | kdeui/ktoolbarbutton.cpp \ | 168 | kdeui/ktoolbarbutton.cpp \ |
171 | kdeui/ktoolbarhandler.cpp \ | 169 | kdeui/ktoolbarhandler.cpp \ |
172 | kdeui/kstdaction.cpp \ | 170 | kdeui/kstdaction.cpp \ |
173 | kdeui/kxmlguiclient.cpp \ | 171 | kdeui/kxmlguiclient.cpp \ |
174 | kdecore/kprefs.cpp \ | 172 | kdecore/kprefs.cpp \ |
175 | kdecore/klibloader.cpp \ | 173 | kdecore/klibloader.cpp \ |
176 | kidmanager.cpp | 174 | kidmanager.cpp |
diff --git a/microkde/ofileselector_p.cpp b/microkde/ofileselector_p.cpp index cf6074d..fd5f965 100644 --- a/microkde/ofileselector_p.cpp +++ b/microkde/ofileselector_p.cpp | |||
@@ -1,863 +1,866 @@ | |||
1 | #include <qcombobox.h> | 1 | #include <qcombobox.h> |
2 | #include <qdir.h> | 2 | #include <qdir.h> |
3 | #include <qhbox.h> | 3 | #include <qhbox.h> |
4 | #include <qheader.h> | 4 | #include <qheader.h> |
5 | #include <qlabel.h> | 5 | #include <qlabel.h> |
6 | #include <qlayout.h> | 6 | #include <qlayout.h> |
7 | #include <qlineedit.h> | 7 | #include <qlineedit.h> |
8 | #include <qlistview.h> | 8 | #include <qlistview.h> |
9 | #include <qpopupmenu.h> | 9 | #include <qpopupmenu.h> |
10 | #include <qwidgetstack.h> | 10 | #include <qwidgetstack.h> |
11 | #include <qregexp.h> | 11 | #include <qregexp.h> |
12 | #include <qobjectlist.h> | 12 | #include <qobjectlist.h> |
13 | 13 | ||
14 | /* hacky but we need to get FileSelector::filter */ | 14 | /* hacky but we need to get FileSelector::filter */ |
15 | #define private public | 15 | #define private public |
16 | #include <qpe/fileselector.h> | 16 | #include <qpe/fileselector.h> |
17 | #undef private | 17 | #undef private |
18 | 18 | ||
19 | #include <qpe/qpeapplication.h> | 19 | #include <qpe/qpeapplication.h> |
20 | #include <qpe/mimetype.h> | 20 | #include <qpe/mimetype.h> |
21 | #include <qpe/resource.h> | 21 | #include <qpe/resource.h> |
22 | #include <qpe/storage.h> | 22 | #include <qpe/storage.h> |
23 | #include <kglobal.h> | ||
24 | #include <klocale.h> | ||
23 | 25 | ||
24 | #include "ofileselector_p.h" | 26 | #include "ofileselector_p.h" |
25 | //US#include "ofileselector.h" | 27 | //US#include "ofileselector.h" |
26 | 28 | ||
27 | #include "klocale.h" | 29 | #include "klocale.h" |
28 | 30 | ||
29 | OFileViewInterface::OFileViewInterface( OFileSelector* selector ) | 31 | OFileViewInterface::OFileViewInterface( OFileSelector* selector ) |
30 | : m_selector( selector ) { | 32 | : m_selector( selector ) { |
31 | } | 33 | } |
32 | OFileViewInterface::~OFileViewInterface() { | 34 | OFileViewInterface::~OFileViewInterface() { |
33 | } | 35 | } |
34 | QString OFileViewInterface::name()const{ | 36 | QString OFileViewInterface::name()const{ |
35 | return m_name; | 37 | return m_name; |
36 | } | 38 | } |
37 | void OFileViewInterface::setName( const QString& name ) { | 39 | void OFileViewInterface::setName( const QString& name ) { |
38 | m_name = name; | 40 | m_name = name; |
39 | } | 41 | } |
40 | OFileSelector* OFileViewInterface::selector()const { | 42 | OFileSelector* OFileViewInterface::selector()const { |
41 | return m_selector; | 43 | return m_selector; |
42 | } | 44 | } |
43 | 45 | ||
44 | DocLnk OFileViewInterface::selectedDocument()const { | 46 | DocLnk OFileViewInterface::selectedDocument()const { |
45 | return DocLnk( selectedName() ); | 47 | return DocLnk( selectedName() ); |
46 | } | 48 | } |
47 | 49 | ||
48 | bool OFileViewInterface::showNew()const { | 50 | bool OFileViewInterface::showNew()const { |
49 | return selector()->showNew(); | 51 | return selector()->showNew(); |
50 | } | 52 | } |
51 | bool OFileViewInterface::showClose()const { | 53 | bool OFileViewInterface::showClose()const { |
52 | return selector()->showClose(); | 54 | return selector()->showClose(); |
53 | } | 55 | } |
54 | MimeTypes OFileViewInterface::mimeTypes()const { | 56 | MimeTypes OFileViewInterface::mimeTypes()const { |
55 | return selector()->mimeTypes(); | 57 | return selector()->mimeTypes(); |
56 | } | 58 | } |
57 | QStringList OFileViewInterface::currentMimeType()const { | 59 | QStringList OFileViewInterface::currentMimeType()const { |
58 | return selector()->currentMimeType(); | 60 | return selector()->currentMimeType(); |
59 | } | 61 | } |
60 | void OFileViewInterface::activate( const QString& ) { | 62 | void OFileViewInterface::activate( const QString& ) { |
61 | // not implemented here | 63 | // not implemented here |
62 | } | 64 | } |
63 | void OFileViewInterface::ok() { | 65 | void OFileViewInterface::ok() { |
64 | emit selector()->ok(); | 66 | emit selector()->ok(); |
65 | } | 67 | } |
66 | void OFileViewInterface::cancel() { | 68 | void OFileViewInterface::cancel() { |
67 | emit selector()->cancel(); | 69 | emit selector()->cancel(); |
68 | } | 70 | } |
69 | void OFileViewInterface::closeMe() { | 71 | void OFileViewInterface::closeMe() { |
70 | emit selector()->closeMe(); | 72 | emit selector()->closeMe(); |
71 | } | 73 | } |
72 | void OFileViewInterface::fileSelected( const QString& str) { | 74 | void OFileViewInterface::fileSelected( const QString& str) { |
73 | emit selector()->fileSelected( str); | 75 | emit selector()->fileSelected( str); |
74 | } | 76 | } |
75 | void OFileViewInterface::fileSelected( const DocLnk& lnk) { | 77 | void OFileViewInterface::fileSelected( const DocLnk& lnk) { |
76 | emit selector()->fileSelected( lnk ); | 78 | emit selector()->fileSelected( lnk ); |
77 | } | 79 | } |
78 | void OFileViewInterface::setCurrentFileName( const QString& str ) { | 80 | void OFileViewInterface::setCurrentFileName( const QString& str ) { |
79 | selector()->m_lneEdit->setText( str ); | 81 | selector()->m_lneEdit->setText( str ); |
80 | } | 82 | } |
81 | QString OFileViewInterface::currentFileName()const{ | 83 | QString OFileViewInterface::currentFileName()const{ |
82 | return selector()->m_lneEdit->text(); | 84 | return selector()->m_lneEdit->text(); |
83 | } | 85 | } |
84 | QString OFileViewInterface::startDirectory()const{ | 86 | QString OFileViewInterface::startDirectory()const{ |
85 | return selector()->m_startDir; | 87 | return selector()->m_startDir; |
86 | } | 88 | } |
87 | 89 | ||
88 | 90 | ||
89 | ODocumentFileView::ODocumentFileView( OFileSelector* selector ) | 91 | ODocumentFileView::ODocumentFileView( OFileSelector* selector ) |
90 | : OFileViewInterface( selector ) { | 92 | : OFileViewInterface( selector ) { |
91 | m_selector = 0; | 93 | m_selector = 0; |
92 | setName( i18n("Documents") ); | 94 | setName( i18n("Documents") ); |
93 | } | 95 | } |
94 | ODocumentFileView::~ODocumentFileView() { | 96 | ODocumentFileView::~ODocumentFileView() { |
95 | 97 | ||
96 | } | 98 | } |
97 | QString ODocumentFileView::selectedName()const { | 99 | QString ODocumentFileView::selectedName()const { |
98 | if (!m_selector) | 100 | if (!m_selector) |
99 | return QString::null; | 101 | return QString::null; |
100 | 102 | ||
101 | return m_selector->selected()->file(); | 103 | return m_selector->selected()->file(); |
102 | } | 104 | } |
103 | QString ODocumentFileView::selectedPath()const { | 105 | QString ODocumentFileView::selectedPath()const { |
104 | return QPEApplication::documentDir(); | 106 | return QPEApplication::documentDir(); |
105 | } | 107 | } |
106 | QString ODocumentFileView::directory()const { | 108 | QString ODocumentFileView::directory()const { |
107 | return selectedPath(); | 109 | return selectedPath(); |
108 | } | 110 | } |
109 | void ODocumentFileView::reread() { | 111 | void ODocumentFileView::reread() { |
110 | if (!m_selector) | 112 | if (!m_selector) |
111 | return; | 113 | return; |
112 | 114 | ||
113 | m_selector->setNewVisible( showNew() ); | 115 | m_selector->setNewVisible( showNew() ); |
114 | m_selector->setCloseVisible( showClose() ); | 116 | m_selector->setCloseVisible( showClose() ); |
115 | m_selector->filter = currentMimeType().join(";"); | 117 | m_selector->filter = currentMimeType().join(";"); |
116 | m_selector->reread(); | 118 | m_selector->reread(); |
117 | } | 119 | } |
118 | int ODocumentFileView::fileCount()const { | 120 | int ODocumentFileView::fileCount()const { |
119 | if (!m_selector) | 121 | if (!m_selector) |
120 | return -1; | 122 | return -1; |
121 | 123 | ||
122 | return m_selector->fileCount(); | 124 | return m_selector->fileCount(); |
123 | } | 125 | } |
124 | 126 | ||
125 | DocLnk ODocumentFileView::selectedDocument()const { | 127 | DocLnk ODocumentFileView::selectedDocument()const { |
126 | if (!m_selector) | 128 | if (!m_selector) |
127 | return DocLnk(); | 129 | return DocLnk(); |
128 | DocLnk lnk = *m_selector->selected(); | 130 | DocLnk lnk = *m_selector->selected(); |
129 | return lnk; | 131 | return lnk; |
130 | } | 132 | } |
131 | 133 | ||
132 | QWidget* ODocumentFileView::widget( QWidget* parent ) { | 134 | QWidget* ODocumentFileView::widget( QWidget* parent ) { |
133 | if (!m_selector ) { | 135 | if (!m_selector ) { |
134 | m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() ); | 136 | m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() ); |
135 | QObject::connect(m_selector, SIGNAL(fileSelected( const DocLnk& ) ), | 137 | QObject::connect(m_selector, SIGNAL(fileSelected( const DocLnk& ) ), |
136 | selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) ); | 138 | selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) ); |
137 | QObject::connect(m_selector, SIGNAL(closeMe() ), | 139 | QObject::connect(m_selector, SIGNAL(closeMe() ), |
138 | selector(), SIGNAL(closeMe() ) ); | 140 | selector(), SIGNAL(closeMe() ) ); |
139 | QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk& ) ), | 141 | QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk& ) ), |
140 | selector(), SIGNAL(newSelected(const DocLnk& ) ) ); | 142 | selector(), SIGNAL(newSelected(const DocLnk& ) ) ); |
141 | } | 143 | } |
142 | 144 | ||
143 | return m_selector; | 145 | return m_selector; |
144 | } | 146 | } |
145 | 147 | ||
146 | /* | 148 | /* |
147 | * This is the file system view used | 149 | * This is the file system view used |
148 | * we use a QListView + QListViewItems for it | 150 | * we use a QListView + QListViewItems for it |
149 | */ | 151 | */ |
150 | 152 | ||
151 | OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap, | 153 | OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap, |
152 | const QString& path, const QString& date, | 154 | const QString& path, const QString& date, |
153 | const QString& size, const QString& dir, | 155 | const QString& size, const QString& dir, |
154 | bool isLocked, bool isDir ) | 156 | bool isLocked, bool isDir ) |
155 | : QListViewItem( view ) | 157 | : QListViewItem( view ) |
156 | { | 158 | { |
157 | setPixmap(0, pixmap ); | 159 | setPixmap(0, pixmap ); |
158 | setText(1, path ); | 160 | setText(1, path ); |
159 | setText(2, size ); | 161 | setText(2, size ); |
160 | setText(3, date ); | 162 | setText(3, date ); |
161 | m_isDir = isDir; | 163 | m_isDir = isDir; |
162 | m_dir = dir; | 164 | m_dir = dir; |
163 | m_locked = isLocked; | 165 | m_locked = isLocked; |
164 | } | 166 | } |
165 | OFileSelectorItem::~OFileSelectorItem() { | 167 | OFileSelectorItem::~OFileSelectorItem() { |
166 | 168 | ||
167 | } | 169 | } |
168 | bool OFileSelectorItem::isLocked()const { | 170 | bool OFileSelectorItem::isLocked()const { |
169 | return m_locked; | 171 | return m_locked; |
170 | } | 172 | } |
171 | QString OFileSelectorItem::directory()const { | 173 | QString OFileSelectorItem::directory()const { |
172 | return m_dir; | 174 | return m_dir; |
173 | } | 175 | } |
174 | bool OFileSelectorItem::isDir()const { | 176 | bool OFileSelectorItem::isDir()const { |
175 | return m_isDir; | 177 | return m_isDir; |
176 | } | 178 | } |
177 | QString OFileSelectorItem::path()const { | 179 | QString OFileSelectorItem::path()const { |
178 | return text( 1 ); | 180 | return text( 1 ); |
179 | } | 181 | } |
180 | QString OFileSelectorItem::key( int id, bool )const { | 182 | QString OFileSelectorItem::key( int id, bool )const { |
181 | QString ke; | 183 | QString ke; |
182 | if( id == 0 || id == 1 ){ // name | 184 | if( id == 0 || id == 1 ){ // name |
183 | if( m_isDir ){ | 185 | if( m_isDir ){ |
184 | ke.append("0" ); | 186 | ke.append("0" ); |
185 | ke.append( text(1) ); | 187 | ke.append( text(1) ); |
186 | }else{ | 188 | }else{ |
187 | ke.append("1" ); | 189 | ke.append("1" ); |
188 | ke.append( text(1) ); | 190 | ke.append( text(1) ); |
189 | } | 191 | } |
190 | return ke; | 192 | return ke; |
191 | }else | 193 | }else |
192 | return text( id ); | 194 | return text( id ); |
193 | 195 | ||
194 | } | 196 | } |
195 | 197 | ||
196 | OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, | 198 | OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, |
197 | OFileSelector* sel) | 199 | OFileSelector* sel) |
198 | : QWidget( parent ), m_sel( sel ) { | 200 | : QWidget( parent ), m_sel( sel ) { |
199 | m_all = false; | 201 | m_all = false; |
200 | QVBoxLayout* lay = new QVBoxLayout( this ); | 202 | QVBoxLayout* lay = new QVBoxLayout( this ); |
201 | m_currentDir = startDir; | 203 | m_currentDir = startDir; |
202 | 204 | ||
203 | /* | 205 | /* |
204 | * now we add a special bar | 206 | * now we add a special bar |
205 | * One Button For Up | 207 | * One Button For Up |
206 | * Home | 208 | * Home |
207 | * Doc | 209 | * Doc |
208 | * And a dropdown menu with FileSystems | 210 | * And a dropdown menu with FileSystems |
209 | * FUTURE: one to change dir with lineedit | 211 | * FUTURE: one to change dir with lineedit |
210 | * Bookmarks | 212 | * Bookmarks |
211 | * Create Dir | 213 | * Create Dir |
212 | */ | 214 | */ |
213 | QHBox* box = new QHBox(this ); | 215 | QHBox* box = new QHBox(this ); |
214 | box->setBackgroundMode( PaletteButton ); | 216 | box->setBackgroundMode( PaletteButton ); |
215 | box->setSpacing( 0 ); | 217 | box->setSpacing( 0 ); |
216 | 218 | ||
217 | QToolButton *btn = new QToolButton( box ); | 219 | QToolButton *btn = new QToolButton( box ); |
218 | btn->setIconSet( Resource::loadPixmap("up") ); | 220 | btn->setIconSet( Resource::loadPixmap("up") ); |
219 | connect(btn, SIGNAL(clicked() ), | 221 | connect(btn, SIGNAL(clicked() ), |
220 | this, SLOT( cdUP() ) ); | 222 | this, SLOT( cdUP() ) ); |
221 | 223 | ||
222 | btn = new QToolButton( box ); | 224 | btn = new QToolButton( box ); |
223 | btn->setIconSet( Resource::loadPixmap("home") ); | 225 | btn->setIconSet( Resource::loadPixmap("home") ); |
224 | connect(btn, SIGNAL(clicked() ), | 226 | connect(btn, SIGNAL(clicked() ), |
225 | this, SLOT( cdHome() ) ); | 227 | this, SLOT( cdHome() ) ); |
226 | 228 | ||
227 | btn = new QToolButton( box ); | 229 | btn = new QToolButton( box ); |
228 | btn->setIconSet( Resource::loadPixmap("DocsIcon") ); | 230 | btn->setIconSet( Resource::loadPixmap("DocsIcon") ); |
229 | connect(btn, SIGNAL(clicked() ), | 231 | connect(btn, SIGNAL(clicked() ), |
230 | this, SLOT(cdDoc() ) ); | 232 | this, SLOT(cdDoc() ) ); |
231 | 233 | ||
232 | m_btnNew = new QToolButton( box ); | 234 | m_btnNew = new QToolButton( box ); |
233 | m_btnNew->setIconSet( Resource::loadPixmap("new") ); | 235 | m_btnNew->setIconSet( Resource::loadPixmap("new") ); |
234 | connect(m_btnNew, SIGNAL(clicked() ), | 236 | connect(m_btnNew, SIGNAL(clicked() ), |
235 | this, SLOT(slotNew() ) ); | 237 | this, SLOT(slotNew() ) ); |
236 | 238 | ||
237 | 239 | ||
238 | m_btnClose = new QToolButton( box ); | 240 | m_btnClose = new QToolButton( box ); |
239 | m_btnClose->setIconSet( Resource::loadPixmap("close") ); | 241 | m_btnClose->setIconSet( Resource::loadPixmap("close") ); |
240 | connect(m_btnClose, SIGNAL(clicked() ), | 242 | connect(m_btnClose, SIGNAL(clicked() ), |
241 | selector(), SIGNAL(closeMe() ) ); | 243 | selector(), SIGNAL(closeMe() ) ); |
242 | 244 | ||
243 | btn = new QToolButton( box ); | 245 | btn = new QToolButton( box ); |
244 | btn->setIconSet( Resource::loadPixmap("cardmon/pcmcia") ); | 246 | btn->setIconSet( Resource::loadPixmap("cardmon/pcmcia") ); |
245 | 247 | ||
246 | /* let's fill device parts */ | 248 | /* let's fill device parts */ |
247 | QPopupMenu* pop = new QPopupMenu(this); | 249 | QPopupMenu* pop = new QPopupMenu(this); |
248 | connect(pop, SIGNAL( activated(int) ), | 250 | connect(pop, SIGNAL( activated(int) ), |
249 | this, SLOT(slotFSActivated(int) ) ); | 251 | this, SLOT(slotFSActivated(int) ) ); |
250 | 252 | ||
251 | StorageInfo storage; | 253 | StorageInfo storage; |
252 | const QList<FileSystem> &fs = storage.fileSystems(); | 254 | const QList<FileSystem> &fs = storage.fileSystems(); |
253 | QListIterator<FileSystem> it(fs); | 255 | QListIterator<FileSystem> it(fs); |
254 | for ( ; it.current(); ++it ) { | 256 | for ( ; it.current(); ++it ) { |
255 | const QString disk = (*it)->name(); | 257 | const QString disk = (*it)->name(); |
256 | const QString path = (*it)->path(); | 258 | const QString path = (*it)->path(); |
257 | m_dev.insert( disk, path ); | 259 | m_dev.insert( disk, path ); |
258 | pop->insertItem( disk ); | 260 | pop->insertItem( disk ); |
259 | } | 261 | } |
260 | m_fsPop = pop; | 262 | m_fsPop = pop; |
261 | 263 | ||
262 | 264 | ||
263 | btn->setPopup( pop ); | 265 | btn->setPopup( pop ); |
264 | btn->setPopupDelay ( 0 ); | 266 | btn->setPopupDelay ( 0 ); |
265 | lay->addWidget( box ); | 267 | lay->addWidget( box ); |
266 | 268 | ||
267 | m_view = new QListView( this ); | 269 | m_view = new QListView( this ); |
268 | 270 | ||
269 | m_view->installEventFilter(this); | 271 | m_view->installEventFilter(this); |
270 | 272 | ||
271 | QPEApplication::setStylusOperation( m_view->viewport(), | 273 | QPEApplication::setStylusOperation( m_view->viewport(), |
272 | QPEApplication::RightOnHold); | 274 | QPEApplication::RightOnHold); |
273 | m_view->addColumn(" " ); | 275 | m_view->addColumn(" " ); |
274 | m_view->addColumn(i18n("Name"), 135 ); | 276 | m_view->addColumn(i18n("Name"), 135 ); |
275 | m_view->addColumn(i18n("Size"), -1 ); | 277 | m_view->addColumn(i18n("Size"), -1 ); |
276 | m_view->addColumn(i18n("Date"), 60 ); | 278 | m_view->addColumn(i18n("Date"), 60 ); |
277 | m_view->addColumn(i18n("Mime Type"), -1 ); | 279 | m_view->addColumn(i18n("Mime Type"), -1 ); |
278 | 280 | ||
279 | 281 | ||
280 | m_view->setSorting( 1 ); | 282 | m_view->setSorting( 1 ); |
281 | m_view->setAllColumnsShowFocus( TRUE ); | 283 | m_view->setAllColumnsShowFocus( TRUE ); |
282 | 284 | ||
283 | lay->addWidget( m_view, 1000 ); | 285 | lay->addWidget( m_view, 1000 ); |
284 | connectSlots(); | 286 | connectSlots(); |
285 | } | 287 | } |
286 | OFileViewFileListView::~OFileViewFileListView() { | 288 | OFileViewFileListView::~OFileViewFileListView() { |
287 | } | 289 | } |
288 | void OFileViewFileListView::slotNew() { | 290 | void OFileViewFileListView::slotNew() { |
289 | DocLnk lnk; | 291 | DocLnk lnk; |
290 | emit selector()->newSelected( lnk ); | 292 | emit selector()->newSelected( lnk ); |
291 | } | 293 | } |
292 | OFileSelectorItem* OFileViewFileListView::currentItem()const{ | 294 | OFileSelectorItem* OFileViewFileListView::currentItem()const{ |
293 | QListViewItem* item = m_view->currentItem(); | 295 | QListViewItem* item = m_view->currentItem(); |
294 | if (!item ) | 296 | if (!item ) |
295 | return 0l; | 297 | return 0l; |
296 | 298 | ||
297 | return static_cast<OFileSelectorItem*>(item); | 299 | return static_cast<OFileSelectorItem*>(item); |
298 | } | 300 | } |
299 | void OFileViewFileListView::reread( bool all ) { | 301 | void OFileViewFileListView::reread( bool all ) { |
300 | m_view->clear(); | 302 | m_view->clear(); |
301 | 303 | ||
302 | if (selector()->showClose() ) | 304 | if (selector()->showClose() ) |
303 | m_btnClose->show(); | 305 | m_btnClose->show(); |
304 | else | 306 | else |
305 | m_btnClose->hide(); | 307 | m_btnClose->hide(); |
306 | 308 | ||
307 | if (selector()->showNew() ) | 309 | if (selector()->showNew() ) |
308 | m_btnNew->show(); | 310 | m_btnNew->show(); |
309 | else | 311 | else |
310 | m_btnNew->hide(); | 312 | m_btnNew->hide(); |
311 | 313 | ||
312 | m_mimes = selector()->currentMimeType(); | 314 | m_mimes = selector()->currentMimeType(); |
313 | m_all = all; | 315 | m_all = all; |
314 | 316 | ||
315 | QDir dir( m_currentDir ); | 317 | QDir dir( m_currentDir ); |
316 | if (!dir.exists() ) | 318 | if (!dir.exists() ) |
317 | return; | 319 | return; |
318 | topLevelWidget()->setCaption( dir.path() ); | 320 | topLevelWidget()->setCaption( dir.path() ); |
319 | dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); | 321 | dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); |
320 | int filter; | 322 | int filter; |
321 | if (m_all ) | 323 | if (m_all ) |
322 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; | 324 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; |
323 | else | 325 | else |
324 | filter = QDir::Files | QDir::Dirs | QDir::All; | 326 | filter = QDir::Files | QDir::Dirs | QDir::All; |
325 | dir.setFilter( filter ); | 327 | dir.setFilter( filter ); |
326 | 328 | ||
327 | // now go through all files | 329 | // now go through all files |
328 | const QFileInfoList *list = dir.entryInfoList(); | 330 | const QFileInfoList *list = dir.entryInfoList(); |
329 | if (!list) { | 331 | if (!list) { |
330 | cdUP(); | 332 | cdUP(); |
331 | return; | 333 | return; |
332 | } | 334 | } |
333 | QFileInfoListIterator it( *list ); | 335 | QFileInfoListIterator it( *list ); |
334 | QFileInfo *fi; | 336 | QFileInfo *fi; |
335 | while( (fi=it.current() ) ){ | 337 | while( (fi=it.current() ) ){ |
336 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){ | 338 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){ |
337 | ++it; | 339 | ++it; |
338 | continue; | 340 | continue; |
339 | } | 341 | } |
340 | 342 | ||
341 | /* | 343 | /* |
342 | * It is a symlink we try to resolve it now but don't let us attack by DOS | 344 | * It is a symlink we try to resolve it now but don't let us attack by DOS |
343 | * | 345 | * |
344 | */ | 346 | */ |
345 | if( fi->isSymLink() ){ | 347 | if( fi->isSymLink() ){ |
346 | QString file = fi->dirPath( true ) + "/" + fi->readLink(); | 348 | QString file = fi->dirPath( true ) + "/" + fi->readLink(); |
347 | for( int i = 0; i<=4; i++) { // 5 tries to prevent dos | 349 | for( int i = 0; i<=4; i++) { // 5 tries to prevent dos |
348 | QFileInfo info( file ); | 350 | QFileInfo info( file ); |
349 | if( !info.exists() ){ | 351 | if( !info.exists() ){ |
350 | addSymlink( fi, TRUE ); | 352 | addSymlink( fi, TRUE ); |
351 | break; | 353 | break; |
352 | }else if( info.isDir() ){ | 354 | }else if( info.isDir() ){ |
353 | addDir( fi, TRUE ); | 355 | addDir( fi, TRUE ); |
354 | break; | 356 | break; |
355 | }else if( info.isFile() ){ | 357 | }else if( info.isFile() ){ |
356 | addFile( fi, TRUE ); | 358 | addFile( fi, TRUE ); |
357 | break; | 359 | break; |
358 | }else if( info.isSymLink() ){ | 360 | }else if( info.isSymLink() ){ |
359 | file = info.dirPath(true ) + "/" + info.readLink() ; | 361 | file = info.dirPath(true ) + "/" + info.readLink() ; |
360 | break; | 362 | break; |
361 | }else if( i == 4){ // couldn't resolve symlink add it as symlink | 363 | }else if( i == 4){ // couldn't resolve symlink add it as symlink |
362 | addSymlink( fi ); | 364 | addSymlink( fi ); |
363 | } | 365 | } |
364 | } // off for loop for symlink resolving | 366 | } // off for loop for symlink resolving |
365 | }else if( fi->isDir() ) | 367 | }else if( fi->isDir() ) |
366 | addDir( fi ); | 368 | addDir( fi ); |
367 | else if( fi->isFile() ) | 369 | else if( fi->isFile() ) |
368 | addFile( fi ); | 370 | addFile( fi ); |
369 | 371 | ||
370 | ++it; | 372 | ++it; |
371 | } // of while loop | 373 | } // of while loop |
372 | m_view->sort(); | 374 | m_view->sort(); |
373 | 375 | ||
374 | } | 376 | } |
375 | int OFileViewFileListView::fileCount()const{ | 377 | int OFileViewFileListView::fileCount()const{ |
376 | return m_view->childCount(); | 378 | return m_view->childCount(); |
377 | } | 379 | } |
378 | QString OFileViewFileListView::currentDir()const{ | 380 | QString OFileViewFileListView::currentDir()const{ |
379 | return m_currentDir; | 381 | return m_currentDir; |
380 | } | 382 | } |
381 | OFileSelector* OFileViewFileListView::selector() { | 383 | OFileSelector* OFileViewFileListView::selector() { |
382 | return m_sel; | 384 | return m_sel; |
383 | } | 385 | } |
384 | 386 | ||
385 | bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e) { | 387 | bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e) { |
386 | if ( e->type() == QEvent::KeyPress ) { | 388 | if ( e->type() == QEvent::KeyPress ) { |
387 | QKeyEvent *k = (QKeyEvent *)e; | 389 | QKeyEvent *k = (QKeyEvent *)e; |
388 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) { | 390 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) { |
389 | slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); | 391 | slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); |
390 | return true; | 392 | return true; |
391 | } | 393 | } |
392 | } | 394 | } |
393 | return false; | 395 | return false; |
394 | } | 396 | } |
395 | 397 | ||
396 | 398 | ||
397 | void OFileViewFileListView::connectSlots() { | 399 | void OFileViewFileListView::connectSlots() { |
398 | connect(m_view, SIGNAL(clicked(QListViewItem*) ), | 400 | connect(m_view, SIGNAL(clicked(QListViewItem*) ), |
399 | this, SLOT(slotCurrentChanged(QListViewItem*) ) ); | 401 | this, SLOT(slotCurrentChanged(QListViewItem*) ) ); |
400 | connect(m_view, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint&, int ) ), | 402 | connect(m_view, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint&, int ) ), |
401 | this, SLOT(slotClicked(int, QListViewItem*, const QPoint&, int ) ) ); | 403 | this, SLOT(slotClicked(int, QListViewItem*, const QPoint&, int ) ) ); |
402 | } | 404 | } |
403 | void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) { | 405 | void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) { |
404 | if (!item) | 406 | if (!item) |
405 | return; | 407 | return; |
406 | #if 0 | 408 | #if 0 |
407 | 409 | ||
408 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); | 410 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); |
409 | 411 | ||
410 | if (!sel->isDir() ) { | 412 | if (!sel->isDir() ) { |
411 | selector()->m_lneEdit->setText( sel->text(1) ); | 413 | selector()->m_lneEdit->setText( sel->text(1) ); |
412 | // if in fileselector mode we will emit selected | 414 | // if in fileselector mode we will emit selected |
413 | if ( selector()->mode() == OFileSelector::FileSelector ) { | 415 | if ( selector()->mode() == OFileSelector::FileSelector ) { |
414 | qWarning("slot Current Changed"); | 416 | qWarning("slot Current Changed"); |
415 | QStringList str = QStringList::split("->", sel->text(1) ); | 417 | QStringList str = QStringList::split("->", sel->text(1) ); |
416 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); | 418 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); |
417 | emit selector()->fileSelected( path ); | 419 | emit selector()->fileSelected( path ); |
418 | DocLnk lnk( path ); | 420 | DocLnk lnk( path ); |
419 | emit selector()->fileSelected( lnk ); | 421 | emit selector()->fileSelected( lnk ); |
420 | } | 422 | } |
421 | } | 423 | } |
422 | #endif | 424 | #endif |
423 | } | 425 | } |
424 | void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) { | 426 | void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) { |
425 | if (!item || ( button != Qt::LeftButton) ) | 427 | if (!item || ( button != Qt::LeftButton) ) |
426 | return; | 428 | return; |
427 | 429 | ||
428 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); | 430 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); |
429 | if (!sel->isLocked() ) { | 431 | if (!sel->isLocked() ) { |
430 | QStringList str = QStringList::split("->", sel->text(1) ); | 432 | QStringList str = QStringList::split("->", sel->text(1) ); |
431 | if (sel->isDir() ) { | 433 | if (sel->isDir() ) { |
432 | m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace(); | 434 | m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace(); |
433 | emit selector()->dirSelected( m_currentDir ); | 435 | emit selector()->dirSelected( m_currentDir ); |
434 | reread( m_all ); | 436 | reread( m_all ); |
435 | }else { // file | 437 | }else { // file |
436 | qWarning("slot Clicked"); | 438 | qWarning("slot Clicked"); |
437 | selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); | 439 | selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); |
438 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); | 440 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); |
439 | emit selector()->fileSelected( path ); | 441 | emit selector()->fileSelected( path ); |
440 | DocLnk lnk( path ); | 442 | DocLnk lnk( path ); |
441 | emit selector()->fileSelected( lnk ); | 443 | emit selector()->fileSelected( lnk ); |
442 | } | 444 | } |
443 | } // not locked | 445 | } // not locked |
444 | } | 446 | } |
445 | void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) { | 447 | void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) { |
446 | MimeType type( info->absFilePath() ); | 448 | MimeType type( info->absFilePath() ); |
447 | if (!compliesMime( type.id() ) ) | 449 | if (!compliesMime( type.id() ) ) |
448 | return; | 450 | return; |
449 | 451 | ||
450 | QPixmap pix = type.pixmap(); | 452 | QPixmap pix = type.pixmap(); |
451 | QString dir, name; bool locked; | 453 | QString dir, name; bool locked; |
452 | if ( pix.isNull() ) { | 454 | if ( pix.isNull() ) { |
453 | QWMatrix matrix; | 455 | QWMatrix matrix; |
454 | QPixmap pixer(Resource::loadPixmap("UnknownDocument") ); | 456 | QPixmap pixer(Resource::loadPixmap("UnknownDocument") ); |
455 | matrix.scale( .4, .4 ); | 457 | matrix.scale( .4, .4 ); |
456 | pix = pixer.xForm( matrix ); | 458 | pix = pixer.xForm( matrix ); |
457 | } | 459 | } |
458 | dir = info->dirPath( true ); | 460 | dir = info->dirPath( true ); |
459 | locked = false; | 461 | locked = false; |
460 | if ( symlink ) | 462 | if ( symlink ) |
461 | name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink(); | 463 | name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink(); |
462 | else{ | 464 | else{ |
463 | name = info->fileName(); | 465 | name = info->fileName(); |
464 | if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) || | 466 | if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) || |
465 | ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) { | 467 | ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) { |
466 | locked = true; pix = Resource::loadPixmap("locked"); | 468 | locked = true; pix = Resource::loadPixmap("locked"); |
467 | } | 469 | } |
468 | } | 470 | } |
469 | (void)new OFileSelectorItem( m_view, pix, name, | 471 | (void)new OFileSelectorItem( m_view, pix, name, |
470 | info->lastModified().toString(), QString::number( info->size() ), | 472 | KGlobal::locale()->formatDateTime(info->lastModified(),true, true, KLocale::ISODate), |
473 | QString::number( info->size() ), | ||
471 | dir, locked ); | 474 | dir, locked ); |
472 | } | 475 | } |
473 | void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) { | 476 | void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) { |
474 | bool locked = false; QString name; QPixmap pix; | 477 | bool locked = false; QString name; QPixmap pix; |
475 | 478 | ||
476 | if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) || | 479 | if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) || |
477 | ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) { | 480 | ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) { |
478 | locked = true; | 481 | locked = true; |
479 | if ( symlink ) | 482 | if ( symlink ) |
480 | pix = Resource::loadPixmap( "symlink" ); | 483 | pix = Resource::loadPixmap( "symlink" ); |
481 | else | 484 | else |
482 | pix = Resource::loadPixmap( "lockedfolder" ); | 485 | pix = Resource::loadPixmap( "lockedfolder" ); |
483 | }else | 486 | }else |
484 | pix = symlink ? Resource::loadPixmap( "symlink") : Resource::loadPixmap("folder"); | 487 | pix = symlink ? Resource::loadPixmap( "symlink") : Resource::loadPixmap("folder"); |
485 | 488 | ||
486 | name = symlink ? info->fileName() + " -> " + info->dirPath(true) + "/" + info->readLink() : | 489 | name = symlink ? info->fileName() + " -> " + info->dirPath(true) + "/" + info->readLink() : |
487 | info->fileName(); | 490 | info->fileName(); |
488 | 491 | ||
489 | (void)new OFileSelectorItem( m_view, pix, name, | 492 | (void)new OFileSelectorItem( m_view, pix, name, |
490 | info->lastModified().toString(), | 493 | KGlobal::locale()->formatDateTime(info->lastModified(),true, true, KLocale::ISODate), |
491 | QString::number( info->size() ), | 494 | QString::number( info->size() ), |
492 | info->dirPath( true ), locked, true ); | 495 | info->dirPath( true ), locked, true ); |
493 | 496 | ||
494 | 497 | ||
495 | } | 498 | } |
496 | void OFileViewFileListView::addSymlink( QFileInfo* , bool ) { | 499 | void OFileViewFileListView::addSymlink( QFileInfo* , bool ) { |
497 | 500 | ||
498 | } | 501 | } |
499 | void OFileViewFileListView::cdUP() { | 502 | void OFileViewFileListView::cdUP() { |
500 | QDir dir( m_currentDir ); | 503 | QDir dir( m_currentDir ); |
501 | dir.cdUp(); | 504 | dir.cdUp(); |
502 | 505 | ||
503 | if (!dir.exists() ) | 506 | if (!dir.exists() ) |
504 | m_currentDir = "/"; | 507 | m_currentDir = "/"; |
505 | else | 508 | else |
506 | m_currentDir = dir.absPath(); | 509 | m_currentDir = dir.absPath(); |
507 | 510 | ||
508 | emit selector()->dirSelected( m_currentDir ); | 511 | emit selector()->dirSelected( m_currentDir ); |
509 | reread( m_all ); | 512 | reread( m_all ); |
510 | } | 513 | } |
511 | void OFileViewFileListView::cdHome() { | 514 | void OFileViewFileListView::cdHome() { |
512 | m_currentDir = QDir::homeDirPath(); | 515 | m_currentDir = QDir::homeDirPath(); |
513 | emit selector()->dirSelected( m_currentDir ); | 516 | emit selector()->dirSelected( m_currentDir ); |
514 | reread( m_all ); | 517 | reread( m_all ); |
515 | } | 518 | } |
516 | void OFileViewFileListView::cdDoc() { | 519 | void OFileViewFileListView::cdDoc() { |
517 | m_currentDir = QPEApplication::documentDir(); | 520 | m_currentDir = QPEApplication::documentDir(); |
518 | emit selector()->dirSelected( m_currentDir ); | 521 | emit selector()->dirSelected( m_currentDir ); |
519 | reread( m_all ); | 522 | reread( m_all ); |
520 | } | 523 | } |
521 | void OFileViewFileListView::changeDir( const QString& dir ) { | 524 | void OFileViewFileListView::changeDir( const QString& dir ) { |
522 | m_currentDir = dir; | 525 | m_currentDir = dir; |
523 | emit selector()->dirSelected( m_currentDir ); | 526 | emit selector()->dirSelected( m_currentDir ); |
524 | reread( m_all ); | 527 | reread( m_all ); |
525 | } | 528 | } |
526 | void OFileViewFileListView::slotFSActivated( int id ) { | 529 | void OFileViewFileListView::slotFSActivated( int id ) { |
527 | changeDir ( m_dev[m_fsPop->text(id)] ); | 530 | changeDir ( m_dev[m_fsPop->text(id)] ); |
528 | } | 531 | } |
529 | 532 | ||
530 | /* check if the mimetype in mime | 533 | /* check if the mimetype in mime |
531 | * complies with the one which is current | 534 | * complies with the one which is current |
532 | */ | 535 | */ |
533 | /* | 536 | /* |
534 | * We've the mimetype of the file | 537 | * We've the mimetype of the file |
535 | * We need to get the stringlist of the current mimetype | 538 | * We need to get the stringlist of the current mimetype |
536 | * | 539 | * |
537 | * mime = image@slashjpeg | 540 | * mime = image@slashjpeg |
538 | * QStringList = 'image@slash*' | 541 | * QStringList = 'image@slash*' |
539 | * or QStringList = image/jpeg;image/png;application/x-ogg | 542 | * or QStringList = image/jpeg;image/png;application/x-ogg |
540 | * or QStringList = application/x-ogg;image@slash*; | 543 | * or QStringList = application/x-ogg;image@slash*; |
541 | * with all these mime filters it should get acceptes | 544 | * with all these mime filters it should get acceptes |
542 | * to do so we need to look if mime is contained inside | 545 | * to do so we need to look if mime is contained inside |
543 | * the stringlist | 546 | * the stringlist |
544 | * if it's contained return true | 547 | * if it's contained return true |
545 | * if not ( I'm no RegExp expert at all ) we'll look if a '@slash*' | 548 | * if not ( I'm no RegExp expert at all ) we'll look if a '@slash*' |
546 | * is contained in the mimefilter and then we will | 549 | * is contained in the mimefilter and then we will |
547 | * look if both are equal until the '/' | 550 | * look if both are equal until the '/' |
548 | */ | 551 | */ |
549 | bool OFileViewFileListView::compliesMime( const QString& str) { | 552 | bool OFileViewFileListView::compliesMime( const QString& str) { |
550 | if (str.isEmpty() || m_mimes.isEmpty() || str.stripWhiteSpace().isEmpty() ) | 553 | if (str.isEmpty() || m_mimes.isEmpty() || str.stripWhiteSpace().isEmpty() ) |
551 | return true; | 554 | return true; |
552 | 555 | ||
553 | for (QStringList::Iterator it = m_mimes.begin(); it != m_mimes.end(); ++it ) { | 556 | for (QStringList::Iterator it = m_mimes.begin(); it != m_mimes.end(); ++it ) { |
554 | QRegExp reg( (*it) ); | 557 | QRegExp reg( (*it) ); |
555 | reg.setWildcard( true ); | 558 | reg.setWildcard( true ); |
556 | if ( str.find( reg ) != -1 ) | 559 | if ( str.find( reg ) != -1 ) |
557 | return true; | 560 | return true; |
558 | 561 | ||
559 | } | 562 | } |
560 | return false; | 563 | return false; |
561 | } | 564 | } |
562 | /* | 565 | /* |
563 | * The listView giving access to the file system! | 566 | * The listView giving access to the file system! |
564 | */ | 567 | */ |
565 | class OFileViewFileSystem : public OFileViewInterface { | 568 | class OFileViewFileSystem : public OFileViewInterface { |
566 | public: | 569 | public: |
567 | OFileViewFileSystem( OFileSelector* ); | 570 | OFileViewFileSystem( OFileSelector* ); |
568 | ~OFileViewFileSystem(); | 571 | ~OFileViewFileSystem(); |
569 | 572 | ||
570 | QString selectedName() const; | 573 | QString selectedName() const; |
571 | QString selectedPath() const; | 574 | QString selectedPath() const; |
572 | 575 | ||
573 | QString directory()const; | 576 | QString directory()const; |
574 | void reread(); | 577 | void reread(); |
575 | int fileCount()const; | 578 | int fileCount()const; |
576 | 579 | ||
577 | QWidget* widget( QWidget* parent ); | 580 | QWidget* widget( QWidget* parent ); |
578 | void activate( const QString& ); | 581 | void activate( const QString& ); |
579 | private: | 582 | private: |
580 | OFileViewFileListView* m_view; | 583 | OFileViewFileListView* m_view; |
581 | bool m_all : 1; | 584 | bool m_all : 1; |
582 | }; | 585 | }; |
583 | OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel) | 586 | OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel) |
584 | : OFileViewInterface( sel ) { | 587 | : OFileViewInterface( sel ) { |
585 | m_view = 0; | 588 | m_view = 0; |
586 | m_all = false; | 589 | m_all = false; |
587 | } | 590 | } |
588 | OFileViewFileSystem::~OFileViewFileSystem() { | 591 | OFileViewFileSystem::~OFileViewFileSystem() { |
589 | } | 592 | } |
590 | QString OFileViewFileSystem::selectedName()const{ | 593 | QString OFileViewFileSystem::selectedName()const{ |
591 | if (!m_view ) | 594 | if (!m_view ) |
592 | return QString::null; | 595 | return QString::null; |
593 | 596 | ||
594 | QString cFN=currentFileName(); | 597 | QString cFN=currentFileName(); |
595 | if (cFN.startsWith("/")) return cFN; | 598 | if (cFN.startsWith("/")) return cFN; |
596 | return m_view->currentDir() + "/" + cFN; | 599 | return m_view->currentDir() + "/" + cFN; |
597 | } | 600 | } |
598 | QString OFileViewFileSystem::selectedPath()const{ | 601 | QString OFileViewFileSystem::selectedPath()const{ |
599 | return QString::null; | 602 | return QString::null; |
600 | } | 603 | } |
601 | QString OFileViewFileSystem::directory()const{ | 604 | QString OFileViewFileSystem::directory()const{ |
602 | if (!m_view) | 605 | if (!m_view) |
603 | return QString::null; | 606 | return QString::null; |
604 | 607 | ||
605 | OFileSelectorItem* item = m_view->currentItem(); | 608 | OFileSelectorItem* item = m_view->currentItem(); |
606 | if (!item ) | 609 | if (!item ) |
607 | return QString::null; | 610 | return QString::null; |
608 | 611 | ||
609 | return QDir(item->directory() ).absPath(); | 612 | return QDir(item->directory() ).absPath(); |
610 | } | 613 | } |
611 | void OFileViewFileSystem::reread() { | 614 | void OFileViewFileSystem::reread() { |
612 | if (!m_view) | 615 | if (!m_view) |
613 | return; | 616 | return; |
614 | 617 | ||
615 | m_view->reread( m_all ); | 618 | m_view->reread( m_all ); |
616 | } | 619 | } |
617 | int OFileViewFileSystem::fileCount()const{ | 620 | int OFileViewFileSystem::fileCount()const{ |
618 | if (!m_view ) | 621 | if (!m_view ) |
619 | return -1; | 622 | return -1; |
620 | return m_view->fileCount(); | 623 | return m_view->fileCount(); |
621 | } | 624 | } |
622 | QWidget* OFileViewFileSystem::widget( QWidget* parent ) { | 625 | QWidget* OFileViewFileSystem::widget( QWidget* parent ) { |
623 | if (!m_view ) { | 626 | if (!m_view ) { |
624 | m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); | 627 | m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); |
625 | } | 628 | } |
626 | return m_view; | 629 | return m_view; |
627 | } | 630 | } |
628 | void OFileViewFileSystem::activate( const QString& str) { | 631 | void OFileViewFileSystem::activate( const QString& str) { |
629 | m_all = (str !=i18n("Files") ); | 632 | m_all = (str !=i18n("Files") ); |
630 | 633 | ||
631 | 634 | ||
632 | } | 635 | } |
633 | 636 | ||
634 | /* Selector */ | 637 | /* Selector */ |
635 | OFileSelector::OFileSelector( QWidget* parent, int mode, int sel, | 638 | OFileSelector::OFileSelector( QWidget* parent, int mode, int sel, |
636 | const QString& dirName, const QString& fileName, | 639 | const QString& dirName, const QString& fileName, |
637 | const MimeTypes& mimetypes, | 640 | const MimeTypes& mimetypes, |
638 | bool showNew, bool showClose) | 641 | bool showNew, bool showClose) |
639 | : QWidget( parent, "OFileSelector" ) | 642 | : QWidget( parent, "OFileSelector" ) |
640 | { | 643 | { |
641 | m_current = 0; | 644 | m_current = 0; |
642 | m_shNew = showNew; | 645 | m_shNew = showNew; |
643 | m_shClose = showClose; | 646 | m_shClose = showClose; |
644 | m_mimeType = mimetypes; | 647 | m_mimeType = mimetypes; |
645 | m_startDir = dirName; | 648 | m_startDir = dirName; |
646 | m_mode = mode; | 649 | m_mode = mode; |
647 | m_selector = sel; | 650 | m_selector = sel; |
648 | 651 | ||
649 | initUI(); | 652 | initUI(); |
650 | m_lneEdit->setText( fileName ); | 653 | m_lneEdit->setText( fileName ); |
651 | initMime(); | 654 | initMime(); |
652 | initViews(); | 655 | initViews(); |
653 | 656 | ||
654 | QString str; | 657 | QString str; |
655 | switch ( m_selector ) { | 658 | switch ( m_selector ) { |
656 | default: | 659 | default: |
657 | case Normal: | 660 | case Normal: |
658 | str = i18n("Documents"); | 661 | str = i18n("Documents"); |
659 | m_cmbView->setCurrentItem( 0 ); | 662 | m_cmbView->setCurrentItem( 0 ); |
660 | break; | 663 | break; |
661 | case Extended: | 664 | case Extended: |
662 | str = i18n("Files"); | 665 | str = i18n("Files"); |
663 | m_cmbView->setCurrentItem( 1 ); | 666 | m_cmbView->setCurrentItem( 1 ); |
664 | break; | 667 | break; |
665 | case ExtendedAll: | 668 | case ExtendedAll: |
666 | str = i18n("All Files"); | 669 | str = i18n("All Files"); |
667 | m_cmbView->setCurrentItem( 2 ); | 670 | m_cmbView->setCurrentItem( 2 ); |
668 | break; | 671 | break; |
669 | } | 672 | } |
670 | slotViewChange( str ); | 673 | slotViewChange( str ); |
671 | 674 | ||
672 | } | 675 | } |
673 | OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name, | 676 | OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name, |
674 | bool showNew, bool showClose ) | 677 | bool showNew, bool showClose ) |
675 | : QWidget( parent, name ) | 678 | : QWidget( parent, name ) |
676 | { | 679 | { |
677 | m_current = 0; | 680 | m_current = 0; |
678 | m_shNew = showNew; | 681 | m_shNew = showNew; |
679 | m_shClose = showClose; | 682 | m_shClose = showClose; |
680 | m_startDir = QPEApplication::documentDir(); | 683 | m_startDir = QPEApplication::documentDir(); |
681 | 684 | ||
682 | if (!mimeFilter.isEmpty() ) | 685 | if (!mimeFilter.isEmpty() ) |
683 | m_mimeType.insert(mimeFilter, QStringList::split(";", mimeFilter ) ); | 686 | m_mimeType.insert(mimeFilter, QStringList::split(";", mimeFilter ) ); |
684 | 687 | ||
685 | m_mode = OFileSelector::FileSelector; | 688 | m_mode = OFileSelector::FileSelector; |
686 | m_selector = OFileSelector::Normal; | 689 | m_selector = OFileSelector::Normal; |
687 | 690 | ||
688 | initUI(); | 691 | initUI(); |
689 | initMime(); | 692 | initMime(); |
690 | initViews(); | 693 | initViews(); |
691 | m_cmbView->setCurrentItem( 0 ); | 694 | m_cmbView->setCurrentItem( 0 ); |
692 | slotViewChange( i18n("Documents") ); | 695 | slotViewChange( i18n("Documents") ); |
693 | } | 696 | } |
694 | /* | 697 | /* |
695 | * INIT UI will set up the basic GUI | 698 | * INIT UI will set up the basic GUI |
696 | * Layout: Simple VBoxLayout | 699 | * Layout: Simple VBoxLayout |
697 | * On top a WidgetStack containing the Views... | 700 | * On top a WidgetStack containing the Views... |
698 | * - List View | 701 | * - List View |
699 | * - Document View | 702 | * - Document View |
700 | * Below we will have a Label + LineEdit | 703 | * Below we will have a Label + LineEdit |
701 | * Below we will have two ComoBoxes one for choosing the view one for | 704 | * Below we will have two ComoBoxes one for choosing the view one for |
702 | * choosing the mimetype | 705 | * choosing the mimetype |
703 | */ | 706 | */ |
704 | void OFileSelector::initUI() { | 707 | void OFileSelector::initUI() { |
705 | QVBoxLayout* lay = new QVBoxLayout( this ); | 708 | QVBoxLayout* lay = new QVBoxLayout( this ); |
706 | 709 | ||
707 | m_stack = new QWidgetStack( this ); | 710 | m_stack = new QWidgetStack( this ); |
708 | lay->addWidget( m_stack, 1000 ); | 711 | lay->addWidget( m_stack, 1000 ); |
709 | 712 | ||
710 | m_nameBox = new QHBox( this ); | 713 | m_nameBox = new QHBox( this ); |
711 | (void)new QLabel( i18n("Name:"), m_nameBox ); | 714 | (void)new QLabel( i18n("Name:"), m_nameBox ); |
712 | m_lneEdit = new QLineEdit( m_nameBox ); | 715 | m_lneEdit = new QLineEdit( m_nameBox ); |
713 | m_lneEdit ->installEventFilter(this); | 716 | m_lneEdit ->installEventFilter(this); |
714 | lay->addWidget( m_nameBox ); | 717 | lay->addWidget( m_nameBox ); |
715 | 718 | ||
716 | m_cmbBox = new QHBox( this ); | 719 | m_cmbBox = new QHBox( this ); |
717 | m_cmbView = new QComboBox( m_cmbBox ); | 720 | m_cmbView = new QComboBox( m_cmbBox ); |
718 | m_cmbMime = new QComboBox( m_cmbBox ); | 721 | m_cmbMime = new QComboBox( m_cmbBox ); |
719 | lay->addWidget( m_cmbBox ); | 722 | lay->addWidget( m_cmbBox ); |
720 | } | 723 | } |
721 | 724 | ||
722 | /* | 725 | /* |
723 | * This will make sure that the return key in the name edit causes dialogs to close | 726 | * This will make sure that the return key in the name edit causes dialogs to close |
724 | */ | 727 | */ |
725 | 728 | ||
726 | bool OFileSelector::eventFilter (QObject *o, QEvent *e) { | 729 | bool OFileSelector::eventFilter (QObject *o, QEvent *e) { |
727 | if ( e->type() == QEvent::KeyPress ) { | 730 | if ( e->type() == QEvent::KeyPress ) { |
728 | QKeyEvent *k = (QKeyEvent *)e; | 731 | QKeyEvent *k = (QKeyEvent *)e; |
729 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) { | 732 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) { |
730 | emit ok(); | 733 | emit ok(); |
731 | return true; | 734 | return true; |
732 | } | 735 | } |
733 | } | 736 | } |
734 | return false; | 737 | return false; |
735 | } | 738 | } |
736 | 739 | ||
737 | /* | 740 | /* |
738 | * This will insert the MimeTypes into the Combo Box | 741 | * This will insert the MimeTypes into the Combo Box |
739 | * And also connect the changed signal | 742 | * And also connect the changed signal |
740 | * | 743 | * |
741 | * AutoMimeTyping is disabled for now. It used to reparse a dir and then set available mimetypes | 744 | * AutoMimeTyping is disabled for now. It used to reparse a dir and then set available mimetypes |
742 | */ | 745 | */ |
743 | void OFileSelector::initMime() { | 746 | void OFileSelector::initMime() { |
744 | MimeTypes::Iterator it; | 747 | MimeTypes::Iterator it; |
745 | for ( it = m_mimeType.begin(); it != m_mimeType.end(); ++it ) { | 748 | for ( it = m_mimeType.begin(); it != m_mimeType.end(); ++it ) { |
746 | m_cmbMime->insertItem( it.key() ); | 749 | m_cmbMime->insertItem( it.key() ); |
747 | } | 750 | } |
748 | m_cmbMime->setCurrentItem( 0 ); | 751 | m_cmbMime->setCurrentItem( 0 ); |
749 | 752 | ||
750 | connect( m_cmbMime, SIGNAL(activated(int) ), | 753 | connect( m_cmbMime, SIGNAL(activated(int) ), |
751 | this, SLOT(slotMimeTypeChanged() ) ); | 754 | this, SLOT(slotMimeTypeChanged() ) ); |
752 | 755 | ||
753 | } | 756 | } |
754 | void OFileSelector::initViews() { | 757 | void OFileSelector::initViews() { |
755 | m_cmbView->insertItem( i18n("Documents") ); | 758 | m_cmbView->insertItem( i18n("Documents") ); |
756 | m_cmbView->insertItem( i18n("Files") ); | 759 | m_cmbView->insertItem( i18n("Files") ); |
757 | m_cmbView->insertItem( i18n("All Files") ); | 760 | m_cmbView->insertItem( i18n("All Files") ); |
758 | connect(m_cmbView, SIGNAL(activated( const QString& ) ), | 761 | connect(m_cmbView, SIGNAL(activated( const QString& ) ), |
759 | this, SLOT(slotViewChange( const QString& ) ) ); | 762 | this, SLOT(slotViewChange( const QString& ) ) ); |
760 | 763 | ||
761 | 764 | ||
762 | m_views.insert( i18n("Documents"), new ODocumentFileView(this) ); | 765 | m_views.insert( i18n("Documents"), new ODocumentFileView(this) ); |
763 | 766 | ||
764 | /* see above why add both */ | 767 | /* see above why add both */ |
765 | OFileViewInterface* in = new OFileViewFileSystem( this ); | 768 | OFileViewInterface* in = new OFileViewFileSystem( this ); |
766 | m_views.insert( i18n("Files"), in ); | 769 | m_views.insert( i18n("Files"), in ); |
767 | m_views.insert( i18n("All Files"), in ); | 770 | m_views.insert( i18n("All Files"), in ); |
768 | } | 771 | } |
769 | OFileSelector::~OFileSelector() { | 772 | OFileSelector::~OFileSelector() { |
770 | 773 | ||
771 | } | 774 | } |
772 | 775 | ||
773 | const DocLnk* OFileSelector::selected() { | 776 | const DocLnk* OFileSelector::selected() { |
774 | DocLnk* lnk = ¤tView()->selectedDocument() ; | 777 | DocLnk* lnk = ¤tView()->selectedDocument() ; |
775 | return lnk; | 778 | return lnk; |
776 | } | 779 | } |
777 | 780 | ||
778 | QString OFileSelector::selectedName()const{ | 781 | QString OFileSelector::selectedName()const{ |
779 | return currentView()->selectedName(); | 782 | return currentView()->selectedName(); |
780 | } | 783 | } |
781 | QString OFileSelector::selectedPath()const { | 784 | QString OFileSelector::selectedPath()const { |
782 | return currentView()->selectedPath(); | 785 | return currentView()->selectedPath(); |
783 | } | 786 | } |
784 | QString OFileSelector::directory()const { | 787 | QString OFileSelector::directory()const { |
785 | return currentView()->directory(); | 788 | return currentView()->directory(); |
786 | } | 789 | } |
787 | 790 | ||
788 | DocLnk OFileSelector::selectedDocument()const { | 791 | DocLnk OFileSelector::selectedDocument()const { |
789 | return currentView()->selectedDocument(); | 792 | return currentView()->selectedDocument(); |
790 | } | 793 | } |
791 | 794 | ||
792 | int OFileSelector::fileCount()const { | 795 | int OFileSelector::fileCount()const { |
793 | return currentView()->fileCount(); | 796 | return currentView()->fileCount(); |
794 | } | 797 | } |
795 | void OFileSelector::reread() { | 798 | void OFileSelector::reread() { |
796 | return currentView()->reread(); | 799 | return currentView()->reread(); |
797 | } | 800 | } |
798 | OFileViewInterface* OFileSelector::currentView()const{ | 801 | OFileViewInterface* OFileSelector::currentView()const{ |
799 | return m_current; | 802 | return m_current; |
800 | } | 803 | } |
801 | bool OFileSelector::showNew()const { | 804 | bool OFileSelector::showNew()const { |
802 | return m_shNew; | 805 | return m_shNew; |
803 | } | 806 | } |
804 | bool OFileSelector::showClose()const { | 807 | bool OFileSelector::showClose()const { |
805 | return m_shClose; | 808 | return m_shClose; |
806 | } | 809 | } |
807 | MimeTypes OFileSelector::mimeTypes()const { | 810 | MimeTypes OFileSelector::mimeTypes()const { |
808 | return m_mimeType; | 811 | return m_mimeType; |
809 | } | 812 | } |
810 | int OFileSelector::mode()const{ | 813 | int OFileSelector::mode()const{ |
811 | return m_mode; | 814 | return m_mode; |
812 | } | 815 | } |
813 | int OFileSelector::selector()const{ | 816 | int OFileSelector::selector()const{ |
814 | return m_selector; | 817 | return m_selector; |
815 | } | 818 | } |
816 | QStringList OFileSelector::currentMimeType()const { | 819 | QStringList OFileSelector::currentMimeType()const { |
817 | return m_mimeType[m_cmbMime->currentText()]; | 820 | return m_mimeType[m_cmbMime->currentText()]; |
818 | } | 821 | } |
819 | void OFileSelector::slotMimeTypeChanged() { | 822 | void OFileSelector::slotMimeTypeChanged() { |
820 | reread(); | 823 | reread(); |
821 | } | 824 | } |
822 | void OFileSelector::slotDocLnkBridge( const DocLnk& lnk) { | 825 | void OFileSelector::slotDocLnkBridge( const DocLnk& lnk) { |
823 | m_lneEdit->setText( lnk.name() ); | 826 | m_lneEdit->setText( lnk.name() ); |
824 | emit fileSelected( lnk ); | 827 | emit fileSelected( lnk ); |
825 | emit fileSelected( lnk.name() ); | 828 | emit fileSelected( lnk.name() ); |
826 | } | 829 | } |
827 | void OFileSelector::slotFileBridge( const QString& str) { | 830 | void OFileSelector::slotFileBridge( const QString& str) { |
828 | DocLnk lnk( str ); | 831 | DocLnk lnk( str ); |
829 | emit fileSelected( lnk ); | 832 | emit fileSelected( lnk ); |
830 | } | 833 | } |
831 | void OFileSelector::slotViewChange( const QString& view ) { | 834 | void OFileSelector::slotViewChange( const QString& view ) { |
832 | OFileViewInterface* interface = m_views[view]; | 835 | OFileViewInterface* interface = m_views[view]; |
833 | if (!interface) | 836 | if (!interface) |
834 | return; | 837 | return; |
835 | 838 | ||
836 | interface->activate( view ); | 839 | interface->activate( view ); |
837 | if (m_current) | 840 | if (m_current) |
838 | m_stack->removeWidget( m_current->widget( m_stack ) ); | 841 | m_stack->removeWidget( m_current->widget( m_stack ) ); |
839 | 842 | ||
840 | static int id = 1; | 843 | static int id = 1; |
841 | 844 | ||
842 | m_stack->addWidget( interface->widget(m_stack), id ); | 845 | m_stack->addWidget( interface->widget(m_stack), id ); |
843 | m_stack->raiseWidget( id ); | 846 | m_stack->raiseWidget( id ); |
844 | 847 | ||
845 | interface->reread(); | 848 | interface->reread(); |
846 | m_current = interface; | 849 | m_current = interface; |
847 | 850 | ||
848 | id++; | 851 | id++; |
849 | } | 852 | } |
850 | void OFileSelector::setNewVisible( bool b ) { | 853 | void OFileSelector::setNewVisible( bool b ) { |
851 | m_shNew = b; | 854 | m_shNew = b; |
852 | currentView()->reread(); | 855 | currentView()->reread(); |
853 | } | 856 | } |
854 | void OFileSelector::setCloseVisible( bool b ) { | 857 | void OFileSelector::setCloseVisible( bool b ) { |
855 | m_shClose = b; | 858 | m_shClose = b; |
856 | currentView()->reread(); | 859 | currentView()->reread(); |
857 | } | 860 | } |
858 | void OFileSelector::setNameVisible( bool b ) { | 861 | void OFileSelector::setNameVisible( bool b ) { |
859 | if ( b ) | 862 | if ( b ) |
860 | m_nameBox->show(); | 863 | m_nameBox->show(); |
861 | else | 864 | else |
862 | m_nameBox->hide(); | 865 | m_nameBox->hide(); |
863 | } | 866 | } |