author | zautrix <zautrix> | 2004-10-14 06:42:01 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-14 06:42:01 (UTC) |
commit | a6dff815a9c6d3a91094573d23c28a8553fc7cc2 (patch) (unidiff) | |
tree | a8830e9adcd72faa8178d4ee2517bfc31cda8653 | |
parent | 909d25797c50fc38c435834a68aaf60bf87e32f9 (diff) | |
download | kdepimpi-a6dff815a9c6d3a91094573d23c28a8553fc7cc2.zip kdepimpi-a6dff815a9c6d3a91094573d23c28a8553fc7cc2.tar.gz kdepimpi-a6dff815a9c6d3a91094573d23c28a8553fc7cc2.tar.bz2 |
fixes umlaute in beaming
-rw-r--r-- | gammu/emb/common/service/gsmcal.c | 15 | ||||
-rw-r--r-- | gammu/emb/common/service/gsmcal.h | 1 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 6 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 12 | ||||
-rw-r--r-- | microkde/kapplication.cpp | 22 | ||||
-rw-r--r-- | microkde/kapplication.h | 1 |
6 files changed, 50 insertions, 7 deletions
diff --git a/gammu/emb/common/service/gsmcal.c b/gammu/emb/common/service/gsmcal.c index 0ea8e06..0375fee 100644 --- a/gammu/emb/common/service/gsmcal.c +++ b/gammu/emb/common/service/gsmcal.c | |||
@@ -1,512 +1,521 @@ | |||
1 | /* (c) 2002-2003 by Marcin Wiacek */ | 1 | /* (c) 2002-2003 by Marcin Wiacek */ |
2 | 2 | ||
3 | #include <string.h> | 3 | #include <string.h> |
4 | 4 | ||
5 | #include "gsmcal.h" | 5 | #include "gsmcal.h" |
6 | #include "gsmmisc.h" | 6 | #include "gsmmisc.h" |
7 | #include "../misc/coding/coding.h" | 7 | #include "../misc/coding/coding.h" |
8 | 8 | ||
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; | ||
72 | break; | ||
73 | case CAL_DESCRIPTION: | ||
71 | if (*Text == -1) *Text = i; | 74 | if (*Text == -1) *Text = i; |
72 | break; | 75 | break; |
73 | case CAL_PHONE: | 76 | case CAL_PHONE: |
74 | if (*Phone == -1) *Phone = i; | 77 | if (*Phone == -1) *Phone = i; |
75 | break; | 78 | break; |
76 | case CAL_LOCATION: | 79 | case CAL_LOCATION: |
77 | if (*Location == -1) *Location = i; | 80 | if (*Location == -1) *Location = i; |
78 | break; | 81 | break; |
79 | default: | 82 | default: |
80 | break; | 83 | break; |
81 | } | 84 | } |
82 | } | 85 | } |
83 | } | 86 | } |
84 | 87 | ||
85 | 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) |
86 | { | 89 | { |
87 | int Text, Time, Alarm, Phone, Recurrance, EndTime, Location; | 90 | int Text, Time, Alarm, Phone, Recurrance, EndTime, Location; |
88 | char buffer[2000]; | 91 | char buffer[2000]; |
89 | 92 | ||
90 | GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(note, &Text, &Time, &Alarm, &Phone, &Recurrance, &EndTime, &Location); | 93 | GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(note, &Text, &Time, &Alarm, &Phone, &Recurrance, &EndTime, &Location); |
91 | 94 | ||
92 | if (header) { | 95 | if (header) { |
93 | *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10); | 96 | *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10); |
94 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10); | 97 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10); |
95 | } | 98 | } |
96 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VEVENT%c%c",13,10); | 99 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VEVENT%c%c",13,10); |
97 | 100 | ||
98 | if (Version == Nokia_VCalendar) { | 101 | if (Version == Nokia_VCalendar) { |
99 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); | 102 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); |
100 | switch (note->Type) { | 103 | switch (note->Type) { |
101 | case GSM_CAL_REMINDER: | 104 | case GSM_CAL_REMINDER: |
102 | *Length+=sprintf(Buffer+(*Length), "Reminder%c%c",13,10); | 105 | *Length+=sprintf(Buffer+(*Length), "Reminder%c%c",13,10); |
103 | break; | 106 | break; |
104 | case GSM_CAL_MEMO: | 107 | case GSM_CAL_MEMO: |
105 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); | 108 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); |
106 | break; | 109 | break; |
107 | case GSM_CAL_CALL: | 110 | case GSM_CAL_CALL: |
108 | *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10); | 111 | *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10); |
109 | break; | 112 | break; |
110 | case GSM_CAL_BIRTHDAY: | 113 | case GSM_CAL_BIRTHDAY: |
111 | *Length+=sprintf(Buffer+(*Length), "Special Occasion%c%c",13,10); | 114 | *Length+=sprintf(Buffer+(*Length), "Special Occasion%c%c",13,10); |
112 | break; | 115 | break; |
113 | case GSM_CAL_MEETING: | 116 | case GSM_CAL_MEETING: |
114 | default: | 117 | default: |
115 | *Length+=sprintf(Buffer+(*Length), "MeetingDEF%c%c",13,10); | 118 | *Length+=sprintf(Buffer+(*Length), "MeetingDEF%c%c",13,10); |
116 | break; | 119 | break; |
117 | } | 120 | } |
118 | if (note->Type == GSM_CAL_CALL) { | 121 | if (note->Type == GSM_CAL_CALL) { |
119 | buffer[0] = 0; | 122 | buffer[0] = 0; |
120 | buffer[1] = 0; | 123 | buffer[1] = 0; |
121 | if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text); | 124 | if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text); |
122 | if (Text != -1) { | 125 | if (Text != -1) { |
123 | if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1); | 126 | if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1); |
124 | CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text); | 127 | CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text); |
125 | } | 128 | } |
126 | SaveVCALText(Buffer, Length, buffer, "SUMMARY"); | 129 | SaveVCALText(Buffer, Length, buffer, "SUMMARY"); |
127 | } else { | 130 | } else { |
128 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); | 131 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); |
129 | } | 132 | } |
130 | if (note->Type == GSM_CAL_MEETING && Location != -1) { | 133 | if (note->Type == GSM_CAL_MEETING && Location != -1) { |
131 | SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION"); | 134 | SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION"); |
132 | } | 135 | } |
133 | 136 | ||
134 | if (Time == -1) return ERR_UNKNOWN; | 137 | if (Time == -1) return ERR_UNKNOWN; |
135 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); | 138 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); |
136 | 139 | ||
137 | if (EndTime != -1) { | 140 | if (EndTime != -1) { |
138 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DTEND"); | 141 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DTEND"); |
139 | } | 142 | } |
140 | 143 | ||
141 | if (Alarm != -1) { | 144 | if (Alarm != -1) { |
142 | if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) { | 145 | if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) { |
143 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); | 146 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); |
144 | } else { | 147 | } else { |
145 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); | 148 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); |
146 | } | 149 | } |
147 | } | 150 | } |
148 | 151 | ||
149 | /* Birthday is known to be recurranced */ | 152 | /* Birthday is known to be recurranced */ |
150 | if (Recurrance != -1 && note->Type != GSM_CAL_BIRTHDAY) { | 153 | if (Recurrance != -1 && note->Type != GSM_CAL_BIRTHDAY) { |
151 | switch(note->Entries[Recurrance].Number/24) { | 154 | switch(note->Entries[Recurrance].Number/24) { |
152 | case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1 #0%c%c",13,10); break; | 155 | case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1 #0%c%c",13,10); break; |
153 | case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:W1 #0%c%c",13,10); break; | 156 | case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:W1 #0%c%c",13,10); break; |
154 | case 14 : *Length+=sprintf(Buffer+(*Length), "RRULE:W2 #0%c%c",13,10); break; | 157 | case 14 : *Length+=sprintf(Buffer+(*Length), "RRULE:W2 #0%c%c",13,10); break; |
155 | case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1 #0%c%c",13,10); break; | 158 | case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1 #0%c%c",13,10); break; |
156 | } | 159 | } |
157 | } | 160 | } |
158 | } else if (Version == Siemens_VCalendar) { | 161 | } else if (Version == Siemens_VCalendar) { |
159 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); | 162 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); |
160 | switch (note->Type) { | 163 | switch (note->Type) { |
161 | case GSM_CAL_MEETING: | 164 | case GSM_CAL_MEETING: |
162 | *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10); | 165 | *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10); |
163 | break; | 166 | break; |
164 | case GSM_CAL_CALL: | 167 | case GSM_CAL_CALL: |
165 | *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10); | 168 | *Length+=sprintf(Buffer+(*Length), "Phone Call%c%c",13,10); |
166 | break; | 169 | break; |
167 | case GSM_CAL_BIRTHDAY: | 170 | case GSM_CAL_BIRTHDAY: |
168 | *Length+=sprintf(Buffer+(*Length), "Anniversary%c%c",13,10); | 171 | *Length+=sprintf(Buffer+(*Length), "Anniversary%c%c",13,10); |
169 | break; | 172 | break; |
170 | case GSM_CAL_MEMO: | 173 | case GSM_CAL_MEMO: |
171 | default: | 174 | default: |
172 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); | 175 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); |
173 | break; | 176 | break; |
174 | } | 177 | } |
175 | 178 | ||
176 | if (Time == -1) return ERR_UNKNOWN; | 179 | if (Time == -1) return ERR_UNKNOWN; |
177 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); | 180 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); |
178 | 181 | ||
179 | if (Alarm != -1) { | 182 | if (Alarm != -1) { |
180 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); | 183 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); |
181 | } | 184 | } |
182 | 185 | ||
183 | if (Recurrance != -1) { | 186 | if (Recurrance != -1) { |
184 | switch(note->Entries[Recurrance].Number/24) { | 187 | switch(note->Entries[Recurrance].Number/24) { |
185 | case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1%c%c",13,10);break; | 188 | case 1 : *Length+=sprintf(Buffer+(*Length), "RRULE:D1%c%c",13,10);break; |
186 | case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:D7%c%c",13,10);break; | 189 | case 7 : *Length+=sprintf(Buffer+(*Length), "RRULE:D7%c%c",13,10);break; |
187 | case 30 : *Length+=sprintf(Buffer+(*Length), "RRULE:MD1%c%c",13,10);break; | 190 | case 30 : *Length+=sprintf(Buffer+(*Length), "RRULE:MD1%c%c",13,10);break; |
188 | case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1%c%c",13,10);break; | 191 | case 365 : *Length+=sprintf(Buffer+(*Length), "RRULE:YD1%c%c",13,10);break; |
189 | } | 192 | } |
190 | } | 193 | } |
191 | 194 | ||
192 | if (note->Type == GSM_CAL_CALL) { | 195 | if (note->Type == GSM_CAL_CALL) { |
193 | buffer[0] = 0; | 196 | buffer[0] = 0; |
194 | buffer[1] = 0; | 197 | buffer[1] = 0; |
195 | if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text); | 198 | if (Phone != -1) CopyUnicodeString(buffer,note->Entries[Phone].Text); |
196 | if (Text != -1) { | 199 | if (Text != -1) { |
197 | if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1); | 200 | if (Phone != -1) EncodeUnicode(buffer+UnicodeLength(buffer)*2," ",1); |
198 | CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text); | 201 | CopyUnicodeString(buffer+UnicodeLength(buffer)*2,note->Entries[Text].Text); |
199 | } | 202 | } |
200 | SaveVCALText(Buffer, Length, buffer, "DESCRIPTION"); | 203 | SaveVCALText(Buffer, Length, buffer, "SUMMARY"); |
201 | } else { | 204 | } else { |
202 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "DESCRIPTION"); | 205 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); |
203 | } | 206 | } |
204 | } else if (Version == SonyEricsson_VCalendar) { | 207 | } else if (Version == SonyEricsson_VCalendar) { |
205 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); | 208 | *Length+=sprintf(Buffer+(*Length), "CATEGORIES:"); |
206 | switch (note->Type) { | 209 | switch (note->Type) { |
207 | case GSM_CAL_MEETING: | 210 | case GSM_CAL_MEETING: |
208 | *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10); | 211 | *Length+=sprintf(Buffer+(*Length), "Meeting%c%c",13,10); |
209 | break; | 212 | break; |
210 | case GSM_CAL_REMINDER: | 213 | case GSM_CAL_REMINDER: |
211 | *Length+=sprintf(Buffer+(*Length), "Date%c%c",13,10); | 214 | *Length+=sprintf(Buffer+(*Length), "Date%c%c",13,10); |
212 | break; | 215 | break; |
213 | case GSM_CAL_TRAVEL: | 216 | case GSM_CAL_TRAVEL: |
214 | *Length+=sprintf(Buffer+(*Length), "Travel%c%c",13,10); | 217 | *Length+=sprintf(Buffer+(*Length), "Travel%c%c",13,10); |
215 | break; | 218 | break; |
216 | case GSM_CAL_VACATION: | 219 | case GSM_CAL_VACATION: |
217 | *Length+=sprintf(Buffer+(*Length), "Vacation%c%c",13,10); | 220 | *Length+=sprintf(Buffer+(*Length), "Vacation%c%c",13,10); |
218 | break; | 221 | break; |
219 | case GSM_CAL_BIRTHDAY: | 222 | case GSM_CAL_BIRTHDAY: |
220 | *Length+=sprintf(Buffer+(*Length), "Anninversary%c%c",13,10); | 223 | *Length+=sprintf(Buffer+(*Length), "Anninversary%c%c",13,10); |
221 | break; | 224 | break; |
222 | case GSM_CAL_MEMO: | 225 | case GSM_CAL_MEMO: |
223 | default: | 226 | default: |
224 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); | 227 | *Length+=sprintf(Buffer+(*Length), "Miscellaneous%c%c",13,10); |
225 | break; | 228 | break; |
226 | } | 229 | } |
227 | 230 | ||
228 | if (Time == -1) return ERR_UNKNOWN; | 231 | if (Time == -1) return ERR_UNKNOWN; |
229 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); | 232 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Time].Date, "DTSTART"); |
230 | 233 | ||
231 | if (EndTime != -1) { | 234 | if (EndTime != -1) { |
232 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DTEND"); | 235 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DTEND"); |
233 | } | 236 | } |
234 | 237 | ||
235 | if (Alarm != -1) { | 238 | if (Alarm != -1) { |
236 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); | 239 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); |
237 | } | 240 | } |
238 | 241 | ||
239 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); | 242 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); |
240 | 243 | ||
241 | if (Location != -1) { | 244 | if (Location != -1) { |
242 | SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION"); | 245 | SaveVCALText(Buffer, Length, note->Entries[Location].Text, "LOCATION"); |
243 | } | 246 | } |
244 | } | 247 | } |
245 | 248 | ||
246 | *Length+=sprintf(Buffer+(*Length), "X-PILOTID:%d%c%c",note->Location,13,10); | 249 | *Length+=sprintf(Buffer+(*Length), "X-PILOTID:%d%c%c",note->Location,13,10); |
247 | *Length+=sprintf(Buffer+(*Length), "END:VEVENT%c%c",13,10); | 250 | *Length+=sprintf(Buffer+(*Length), "END:VEVENT%c%c",13,10); |
248 | if (header) *Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10); | 251 | if (header) *Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10); |
249 | 252 | ||
250 | return ERR_NONE; | 253 | return ERR_NONE; |
251 | } | 254 | } |
252 | 255 | ||
253 | 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) |
254 | { | 257 | { |
255 | int i; | 258 | int i; |
256 | 259 | ||
257 | *Text = -1; | 260 | *Text = -1; |
258 | *EndTime= -1; | 261 | *EndTime= -1; |
259 | *Alarm = -1; | 262 | *Alarm = -1; |
260 | *Completed= -1; | 263 | *Completed= -1; |
261 | *Phone = -1; | 264 | *Phone = -1; |
262 | for (i = 0; i < entry->EntriesNum; i++) { | 265 | for (i = 0; i < entry->EntriesNum; i++) { |
263 | switch (entry->Entries[i].EntryType) { | 266 | switch (entry->Entries[i].EntryType) { |
264 | case TODO_END_DATETIME : | 267 | case TODO_END_DATETIME : |
265 | if (*EndTime == -1) *EndTime = i; | 268 | if (*EndTime == -1) *EndTime = i; |
266 | break; | 269 | break; |
267 | case TODO_ALARM_DATETIME : | 270 | case TODO_ALARM_DATETIME : |
268 | case TODO_SILENT_ALARM_DATETIME: | 271 | case TODO_SILENT_ALARM_DATETIME: |
269 | if (*Alarm == -1) *Alarm = i; | 272 | if (*Alarm == -1) *Alarm = i; |
270 | break; | 273 | break; |
271 | case TODO_TEXT: | 274 | case TODO_TEXT: |
272 | if (*Text == -1) *Text = i; | 275 | if (*Text == -1) *Text = i; |
273 | break; | 276 | break; |
274 | case TODO_COMPLETED: | 277 | case TODO_COMPLETED: |
275 | if (*Completed == -1) *Completed = i; | 278 | if (*Completed == -1) *Completed = i; |
276 | break; | 279 | break; |
277 | case TODO_PHONE: | 280 | case TODO_PHONE: |
278 | if (*Phone == -1) *Phone = i; | 281 | if (*Phone == -1) *Phone = i; |
279 | break; | 282 | break; |
280 | default: | 283 | default: |
281 | break; | 284 | break; |
282 | } | 285 | } |
283 | } | 286 | } |
284 | } | 287 | } |
285 | 288 | ||
286 | 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) |
287 | { | 290 | { |
288 | int Text, Alarm, Completed, EndTime, Phone; | 291 | int Text, Alarm, Completed, EndTime, Phone; |
289 | 292 | ||
290 | GSM_ToDoFindDefaultTextTimeAlarmCompleted(note, &Text, &Alarm, &Completed, &EndTime, &Phone); | 293 | GSM_ToDoFindDefaultTextTimeAlarmCompleted(note, &Text, &Alarm, &Completed, &EndTime, &Phone); |
291 | 294 | ||
292 | if (header) { | 295 | if (header) { |
293 | *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10); | 296 | *Length+=sprintf(Buffer, "BEGIN:VCALENDAR%c%c",13,10); |
294 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10); | 297 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.0%c%c",13,10); |
295 | } | 298 | } |
296 | 299 | ||
297 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VTODO%c%c",13,10); | 300 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VTODO%c%c",13,10); |
298 | 301 | ||
299 | if (Version == Nokia_VToDo) { | 302 | if (Version == Nokia_VToDo) { |
300 | if (Text == -1) return ERR_UNKNOWN; | 303 | if (Text == -1) return ERR_UNKNOWN; |
301 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); | 304 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); |
302 | 305 | ||
303 | if (Completed == -1) { | 306 | if (Completed == -1) { |
304 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:0%c%c",13,10); | 307 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:0%c%c",13,10); |
305 | } else { | 308 | } else { |
306 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:100%c%c",13,10); | 309 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:100%c%c",13,10); |
307 | } | 310 | } |
308 | 311 | ||
309 | switch (note->Priority) { | 312 | switch (note->Priority) { |
310 | case GSM_Priority_Low: *Length+=sprintf(Buffer+(*Length), "PRIORITY:5%c%c",13,10); break; | 313 | case GSM_Priority_Low: *Length+=sprintf(Buffer+(*Length), "PRIORITY:5%c%c",13,10); break; |
311 | case GSM_Priority_Medium: *Length+=sprintf(Buffer+(*Length), "PRIORITY:3%c%c",13,10); break; | 314 | case GSM_Priority_Medium: *Length+=sprintf(Buffer+(*Length), "PRIORITY:3%c%c",13,10); break; |
312 | case GSM_Priority_High: *Length+=sprintf(Buffer+(*Length), "PRIORITY:1%c%c",13,10); break; | 315 | case GSM_Priority_High: *Length+=sprintf(Buffer+(*Length), "PRIORITY:1%c%c",13,10); break; |
313 | } | 316 | } |
314 | 317 | ||
315 | if (EndTime != -1) { | 318 | if (EndTime != -1) { |
316 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DUE"); | 319 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[EndTime].Date, "DUE"); |
317 | } | 320 | } |
318 | 321 | ||
319 | if (Alarm != -1) { | 322 | if (Alarm != -1) { |
320 | if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) { | 323 | if (note->Entries[Alarm].EntryType == CAL_SILENT_ALARM_DATETIME) { |
321 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); | 324 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "DALARM"); |
322 | } else { | 325 | } else { |
323 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); | 326 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); |
324 | } | 327 | } |
325 | } | 328 | } |
326 | } else if (Version == SonyEricsson_VToDo) { | 329 | } else if (Version == SonyEricsson_VToDo) { |
327 | if (Text == -1) return ERR_UNKNOWN; | 330 | if (Text == -1) return ERR_UNKNOWN; |
328 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); | 331 | SaveVCALText(Buffer, Length, note->Entries[Text].Text, "SUMMARY"); |
329 | 332 | ||
330 | if (Completed == -1) { | 333 | if (Completed == -1) { |
331 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:0%c%c",13,10); | 334 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:0%c%c",13,10); |
332 | } else { | 335 | } else { |
333 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:100%c%c",13,10); | 336 | *Length+=sprintf(Buffer+(*Length), "PERCENT-COMPLETE:100%c%c",13,10); |
334 | } | 337 | } |
335 | 338 | ||
336 | switch (note->Priority) { | 339 | switch (note->Priority) { |
337 | case GSM_Priority_Low: *Length+=sprintf(Buffer+(*Length), "PRIORITY:5%c%c",13,10); break; | 340 | case GSM_Priority_Low: *Length+=sprintf(Buffer+(*Length), "PRIORITY:5%c%c",13,10); break; |
338 | case GSM_Priority_Medium: *Length+=sprintf(Buffer+(*Length), "PRIORITY:3%c%c",13,10); break; | 341 | case GSM_Priority_Medium: *Length+=sprintf(Buffer+(*Length), "PRIORITY:3%c%c",13,10); break; |
339 | case GSM_Priority_High: *Length+=sprintf(Buffer+(*Length), "PRIORITY:1%c%c",13,10); break; | 342 | case GSM_Priority_High: *Length+=sprintf(Buffer+(*Length), "PRIORITY:1%c%c",13,10); break; |
340 | } | 343 | } |
341 | 344 | ||
342 | if (Alarm != -1) { | 345 | if (Alarm != -1) { |
343 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); | 346 | SaveVCALDateTime(Buffer, Length, ¬e->Entries[Alarm].Date, "AALARM"); |
344 | } | 347 | } |
345 | } | 348 | } |
346 | 349 | ||
347 | *Length+=sprintf(Buffer+(*Length), "X-PILOTID:%d%c%c",note->Location,13,10); | 350 | *Length+=sprintf(Buffer+(*Length), "X-PILOTID:%d%c%c",note->Location,13,10); |
348 | *Length+=sprintf(Buffer+(*Length), "END:VTODO%c%c",13,10); | 351 | *Length+=sprintf(Buffer+(*Length), "END:VTODO%c%c",13,10); |
349 | 352 | ||
350 | if (header) { | 353 | if (header) { |
351 | *Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10); | 354 | *Length+=sprintf(Buffer+(*Length), "END:VCALENDAR%c%c",13,10); |
352 | } | 355 | } |
353 | return ERR_NONE; | 356 | return ERR_NONE; |
354 | } | 357 | } |
355 | 358 | ||
356 | 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) |
357 | { | 360 | { |
358 | unsigned char Line[2000],Buff[2000]; | 361 | unsigned char Line[2000],Buff[2000]; |
359 | int Level = 0; | 362 | int Level = 0; |
360 | 363 | ||
361 | Calendar->EntriesNum = 0; | 364 | Calendar->EntriesNum = 0; |
362 | ToDo->EntriesNum = 0; | 365 | ToDo->EntriesNum = 0; |
363 | 366 | ||
364 | while (1) { | 367 | while (1) { |
365 | MyGetLine(Buffer, Pos, Line, strlen(Buffer)); | 368 | MyGetLine(Buffer, Pos, Line, strlen(Buffer)); |
366 | if (strlen(Line) == 0) break; | 369 | if (strlen(Line) == 0) break; |
367 | switch (Level) { | 370 | switch (Level) { |
368 | case 0: | 371 | case 0: |
369 | if (strstr(Line,"BEGIN:VEVENT")) { | 372 | if (strstr(Line,"BEGIN:VEVENT")) { |
370 | Calendar->Type = GSM_CAL_MEMO; | 373 | Calendar->Type = GSM_CAL_MEMO; |
371 | Level = 1; | 374 | Level = 1; |
372 | } | 375 | } |
373 | if (strstr(Line,"BEGIN:VTODO")) { | 376 | if (strstr(Line,"BEGIN:VTODO")) { |
374 | ToDo->Priority = GSM_Priority_Medium; | 377 | ToDo->Priority = GSM_Priority_Medium; |
375 | Level = 2; | 378 | Level = 2; |
376 | } | 379 | } |
377 | break; | 380 | break; |
378 | case 1: /* Calendar note */ | 381 | case 1: /* Calendar note */ |
379 | if (strstr(Line,"END:VEVENT")) { | 382 | if (strstr(Line,"END:VEVENT")) { |
380 | if (Calendar->EntriesNum == 0) return ERR_EMPTY; | 383 | if (Calendar->EntriesNum == 0) return ERR_EMPTY; |
381 | return ERR_NONE; | 384 | return ERR_NONE; |
382 | } | 385 | } |
383 | Calendar->Type = GSM_CAL_MEETING; | 386 | Calendar->Type = GSM_CAL_MEETING; |
384 | if (strstr(Line,"CATEGORIES:Reminder")) Calendar->Type = GSM_CAL_REMINDER; | 387 | if (strstr(Line,"CATEGORIES:Reminder")) Calendar->Type = GSM_CAL_REMINDER; |
385 | if (strstr(Line,"CATEGORIES:Date")) Calendar->Type = GSM_CAL_REMINDER;//SE | 388 | if (strstr(Line,"CATEGORIES:Date")) Calendar->Type = GSM_CAL_REMINDER;//SE |
386 | if (strstr(Line,"CATEGORIES:Travel")) Calendar->Type = GSM_CAL_TRAVEL; //SE | 389 | if (strstr(Line,"CATEGORIES:Travel")) Calendar->Type = GSM_CAL_TRAVEL; //SE |
387 | if (strstr(Line,"CATEGORIES:Vacation")) Calendar->Type = GSM_CAL_VACATION;//SE | 390 | if (strstr(Line,"CATEGORIES:Vacation")) Calendar->Type = GSM_CAL_VACATION;//SE |
388 | if (strstr(Line,"CATEGORIES:Miscellaneous")) Calendar->Type = GSM_CAL_MEMO; | 391 | if (strstr(Line,"CATEGORIES:Miscellaneous")) Calendar->Type = GSM_CAL_MEMO; |
389 | if (strstr(Line,"CATEGORIES:Phone Call")) Calendar->Type = GSM_CAL_CALL; | 392 | if (strstr(Line,"CATEGORIES:Phone Call")) Calendar->Type = GSM_CAL_CALL; |
390 | if (strstr(Line,"CATEGORIES:Special Occasion")) Calendar->Type = GSM_CAL_BIRTHDAY; | 393 | if (strstr(Line,"CATEGORIES:Special Occasion")) Calendar->Type = GSM_CAL_BIRTHDAY; |
391 | if (strstr(Line,"CATEGORIES:Anniversary")) Calendar->Type = GSM_CAL_BIRTHDAY; | 394 | if (strstr(Line,"CATEGORIES:Anniversary")) Calendar->Type = GSM_CAL_BIRTHDAY; |
392 | if (strstr(Line,"CATEGORIES:Meeting")) Calendar->Type = GSM_CAL_MEETING; | 395 | if (strstr(Line,"CATEGORIES:Meeting")) Calendar->Type = GSM_CAL_MEETING; |
393 | if (strstr(Line,"CATEGORIES:Appointment")) Calendar->Type = GSM_CAL_MEETING; | 396 | if (strstr(Line,"CATEGORIES:Appointment")) Calendar->Type = GSM_CAL_MEETING; |
394 | if (strstr(Line,"RRULE:D1")) { | 397 | if (strstr(Line,"RRULE:D1")) { |
395 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; | 398 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; |
396 | Calendar->Entries[Calendar->EntriesNum].Number = 1*24; | 399 | Calendar->Entries[Calendar->EntriesNum].Number = 1*24; |
397 | Calendar->EntriesNum++; | 400 | Calendar->EntriesNum++; |
398 | } | 401 | } |
399 | if ((strstr(Line,"RRULE:W1")) || (strstr(Line,"RRULE:D7"))) { | 402 | if ((strstr(Line,"RRULE:W1")) || (strstr(Line,"RRULE:D7"))) { |
400 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; | 403 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; |
401 | Calendar->Entries[Calendar->EntriesNum].Number = 7*24; | 404 | Calendar->Entries[Calendar->EntriesNum].Number = 7*24; |
402 | Calendar->EntriesNum++; | 405 | Calendar->EntriesNum++; |
403 | } | 406 | } |
404 | if (strstr(Line,"RRULE:W2")) { | 407 | if (strstr(Line,"RRULE:W2")) { |
405 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; | 408 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; |
406 | Calendar->Entries[Calendar->EntriesNum].Number = 14*24; | 409 | Calendar->Entries[Calendar->EntriesNum].Number = 14*24; |
407 | Calendar->EntriesNum++; | 410 | Calendar->EntriesNum++; |
408 | } | 411 | } |
409 | if (strstr(Line,"RRULE:MD1")) { | 412 | if (strstr(Line,"RRULE:MD1")) { |
410 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; | 413 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; |
411 | Calendar->Entries[Calendar->EntriesNum].Number = 30*24; | 414 | Calendar->Entries[Calendar->EntriesNum].Number = 30*24; |
412 | Calendar->EntriesNum++; | 415 | Calendar->EntriesNum++; |
413 | } | 416 | } |
414 | if (strstr(Line,"RRULE:YD1")) { | 417 | if (strstr(Line,"RRULE:YD1")) { |
415 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; | 418 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_RECURRANCE; |
416 | Calendar->Entries[Calendar->EntriesNum].Number = 365*24; | 419 | Calendar->Entries[Calendar->EntriesNum].Number = 365*24; |
417 | Calendar->EntriesNum++; | 420 | Calendar->EntriesNum++; |
418 | } | 421 | } |
419 | if ((ReadVCALText(Line, "SUMMARY", Buff)) || (ReadVCALText(Line, "DESCRIPTION", Buff))) { | 422 | // LR |
423 | if ((ReadVCALText(Line, "SUMMARY", Buff)) ) { | ||
420 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_TEXT; | 424 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_TEXT; |
421 | CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); | 425 | CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); |
422 | Calendar->EntriesNum++; | 426 | Calendar->EntriesNum++; |
423 | } | 427 | } |
428 | if (ReadVCALText(Line, "DESCRIPTION", Buff)) { | ||
429 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_DESCRIPTION; | ||
430 | CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); | ||
431 | Calendar->EntriesNum++; | ||
432 | } | ||
424 | if (ReadVCALText(Line, "LOCATION", Buff)) { | 433 | if (ReadVCALText(Line, "LOCATION", Buff)) { |
425 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_LOCATION; | 434 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_LOCATION; |
426 | CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); | 435 | CopyUnicodeString(Calendar->Entries[Calendar->EntriesNum].Text,Buff); |
427 | Calendar->EntriesNum++; | 436 | Calendar->EntriesNum++; |
428 | } | 437 | } |
429 | if (ReadVCALText(Line, "DTSTART", Buff)) { | 438 | if (ReadVCALText(Line, "DTSTART", Buff)) { |
430 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_START_DATETIME; | 439 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_START_DATETIME; |
431 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); | 440 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); |
432 | Calendar->EntriesNum++; | 441 | Calendar->EntriesNum++; |
433 | } | 442 | } |
434 | if (ReadVCALText(Line, "DTEND", Buff)) { | 443 | if (ReadVCALText(Line, "DTEND", Buff)) { |
435 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_END_DATETIME; | 444 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_END_DATETIME; |
436 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); | 445 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); |
437 | Calendar->EntriesNum++; | 446 | Calendar->EntriesNum++; |
438 | } | 447 | } |
439 | if (ReadVCALText(Line, "DALARM", Buff)) { | 448 | if (ReadVCALText(Line, "DALARM", Buff)) { |
440 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_SILENT_ALARM_DATETIME; | 449 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_SILENT_ALARM_DATETIME; |
441 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); | 450 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); |
442 | Calendar->EntriesNum++; | 451 | Calendar->EntriesNum++; |
443 | } | 452 | } |
444 | if (ReadVCALText(Line, "AALARM", Buff)) { | 453 | if (ReadVCALText(Line, "AALARM", Buff)) { |
445 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_ALARM_DATETIME; | 454 | Calendar->Entries[Calendar->EntriesNum].EntryType = CAL_ALARM_DATETIME; |
446 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); | 455 | ReadVCALDateTime(DecodeUnicodeString(Buff), &Calendar->Entries[Calendar->EntriesNum].Date); |
447 | Calendar->EntriesNum++; | 456 | Calendar->EntriesNum++; |
448 | } | 457 | } |
449 | break; | 458 | break; |
450 | case 2: /* ToDo note */ | 459 | case 2: /* ToDo note */ |
451 | if (strstr(Line,"END:VTODO")) { | 460 | if (strstr(Line,"END:VTODO")) { |
452 | if (ToDo->EntriesNum == 0) return ERR_EMPTY; | 461 | if (ToDo->EntriesNum == 0) return ERR_EMPTY; |
453 | return ERR_NONE; | 462 | return ERR_NONE; |
454 | } | 463 | } |
455 | if (ReadVCALText(Line, "DUE", Buff)) { | 464 | if (ReadVCALText(Line, "DUE", Buff)) { |
456 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_END_DATETIME; | 465 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_END_DATETIME; |
457 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); | 466 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); |
458 | ToDo->EntriesNum++; | 467 | ToDo->EntriesNum++; |
459 | } | 468 | } |
460 | if (ReadVCALText(Line, "DALARM", Buff)) { | 469 | if (ReadVCALText(Line, "DALARM", Buff)) { |
461 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_SILENT_ALARM_DATETIME; | 470 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_SILENT_ALARM_DATETIME; |
462 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); | 471 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); |
463 | ToDo->EntriesNum++; | 472 | ToDo->EntriesNum++; |
464 | } | 473 | } |
465 | if (ReadVCALText(Line, "AALARM", Buff)) { | 474 | if (ReadVCALText(Line, "AALARM", Buff)) { |
466 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_ALARM_DATETIME; | 475 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_ALARM_DATETIME; |
467 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); | 476 | ReadVCALDateTime(DecodeUnicodeString(Buff), &ToDo->Entries[ToDo->EntriesNum].Date); |
468 | ToDo->EntriesNum++; | 477 | ToDo->EntriesNum++; |
469 | } | 478 | } |
470 | if (ReadVCALText(Line, "SUMMARY", Buff)) { | 479 | if (ReadVCALText(Line, "SUMMARY", Buff)) { |
471 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_TEXT; | 480 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_TEXT; |
472 | CopyUnicodeString(ToDo->Entries[ToDo->EntriesNum].Text,Buff); | 481 | CopyUnicodeString(ToDo->Entries[ToDo->EntriesNum].Text,Buff); |
473 | ToDo->EntriesNum++; | 482 | ToDo->EntriesNum++; |
474 | } | 483 | } |
475 | if (ReadVCALText(Line, "PRIORITY", Buff)) { | 484 | if (ReadVCALText(Line, "PRIORITY", Buff)) { |
476 | if (ToDoVer == SonyEricsson_VToDo) { | 485 | if (ToDoVer == SonyEricsson_VToDo) { |
477 | ToDo->Priority = GSM_Priority_Medium; | 486 | ToDo->Priority = GSM_Priority_Medium; |
478 | if (atoi(DecodeUnicodeString(Buff))>3) ToDo->Priority = GSM_Priority_Low; | 487 | if (atoi(DecodeUnicodeString(Buff))>3) ToDo->Priority = GSM_Priority_Low; |
479 | if (atoi(DecodeUnicodeString(Buff))<3) ToDo->Priority = GSM_Priority_High; | 488 | if (atoi(DecodeUnicodeString(Buff))<3) ToDo->Priority = GSM_Priority_High; |
480 | dbgprintf("atoi is %i %s\n",atoi(DecodeUnicodeString(Buff)),DecodeUnicodeString(Buff)); | 489 | dbgprintf("atoi is %i %s\n",atoi(DecodeUnicodeString(Buff)),DecodeUnicodeString(Buff)); |
481 | } else if (ToDoVer == Nokia_VToDo) { | 490 | } else if (ToDoVer == Nokia_VToDo) { |
482 | ToDo->Priority = GSM_Priority_Medium; | 491 | ToDo->Priority = GSM_Priority_Medium; |
483 | if (atoi(DecodeUnicodeString(Buff))>3) ToDo->Priority = GSM_Priority_Low; | 492 | if (atoi(DecodeUnicodeString(Buff))>3) ToDo->Priority = GSM_Priority_Low; |
484 | if (atoi(DecodeUnicodeString(Buff))<3) ToDo->Priority = GSM_Priority_High; | 493 | if (atoi(DecodeUnicodeString(Buff))<3) ToDo->Priority = GSM_Priority_High; |
485 | } | 494 | } |
486 | } | 495 | } |
487 | if (strstr(Line,"PERCENT-COMPLETE:100")) { | 496 | if (strstr(Line,"PERCENT-COMPLETE:100")) { |
488 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_COMPLETED; | 497 | ToDo->Entries[ToDo->EntriesNum].EntryType = TODO_COMPLETED; |
489 | ToDo->Entries[ToDo->EntriesNum].Number = 1; | 498 | ToDo->Entries[ToDo->EntriesNum].Number = 1; |
490 | ToDo->EntriesNum++; | 499 | ToDo->EntriesNum++; |
491 | } | 500 | } |
492 | break; | 501 | break; |
493 | } | 502 | } |
494 | } | 503 | } |
495 | 504 | ||
496 | if (Calendar->EntriesNum == 0 && ToDo->EntriesNum == 0) return ERR_EMPTY; | 505 | if (Calendar->EntriesNum == 0 && ToDo->EntriesNum == 0) return ERR_EMPTY; |
497 | return ERR_NONE; | 506 | return ERR_NONE; |
498 | } | 507 | } |
499 | 508 | ||
500 | GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note) | 509 | GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note) |
501 | { | 510 | { |
502 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VNOTE%c%c",13,10); | 511 | *Length+=sprintf(Buffer+(*Length), "BEGIN:VNOTE%c%c",13,10); |
503 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.1%c%c",13,10); | 512 | *Length+=sprintf(Buffer+(*Length), "VERSION:1.1%c%c",13,10); |
504 | SaveVCALText(Buffer, Length, Note->Text, "BODY"); | 513 | SaveVCALText(Buffer, Length, Note->Text, "BODY"); |
505 | *Length+=sprintf(Buffer+(*Length), "END:VNOTE%c%c",13,10); | 514 | *Length+=sprintf(Buffer+(*Length), "END:VNOTE%c%c",13,10); |
506 | 515 | ||
507 | return ERR_NONE; | 516 | return ERR_NONE; |
508 | } | 517 | } |
509 | 518 | ||
510 | /* How should editor hadle tabs in this file? Add editor commands here. | 519 | /* How should editor hadle tabs in this file? Add editor commands here. |
511 | * vim: noexpandtab sw=8 ts=8 sts=8: | 520 | * vim: noexpandtab sw=8 ts=8 sts=8: |
512 | */ | 521 | */ |
diff --git a/gammu/emb/common/service/gsmcal.h b/gammu/emb/common/service/gsmcal.h index 0a41b7b..c69fdbe 100644 --- a/gammu/emb/common/service/gsmcal.h +++ b/gammu/emb/common/service/gsmcal.h | |||
@@ -1,445 +1,446 @@ | |||
1 | /* (c) 2002-2004 by Marcin Wiacek */ | 1 | /* (c) 2002-2004 by Marcin Wiacek */ |
2 | /* 5210 calendar IDs by Frederick Ros */ | 2 | /* 5210 calendar IDs by Frederick Ros */ |
3 | 3 | ||
4 | #ifndef __gsm_cal_h | 4 | #ifndef __gsm_cal_h |
5 | #define __gsm_cal_h | 5 | #define __gsm_cal_h |
6 | 6 | ||
7 | #include "../gsmcomon.h" | 7 | #include "../gsmcomon.h" |
8 | 8 | ||
9 | /* ---------------------------- calendar ----------------------------------- */ | 9 | /* ---------------------------- calendar ----------------------------------- */ |
10 | 10 | ||
11 | #define GSM_CALENDAR_ENTRIES 16 | 11 | #define GSM_CALENDAR_ENTRIES 16 |
12 | #define MAX_CALENDAR_TEXT_LENGTH256 /* In 6310 max. 256 chars */ | 12 | #define MAX_CALENDAR_TEXT_LENGTH256 /* In 6310 max. 256 chars */ |
13 | 13 | ||
14 | /** | 14 | /** |
15 | * Enum defines types of calendar notes | 15 | * Enum defines types of calendar notes |
16 | */ | 16 | */ |
17 | typedef enum { | 17 | typedef enum { |
18 | /** | 18 | /** |
19 | * Reminder or Date | 19 | * Reminder or Date |
20 | */ | 20 | */ |
21 | GSM_CAL_REMINDER=1, | 21 | GSM_CAL_REMINDER=1, |
22 | /** | 22 | /** |
23 | * Call | 23 | * Call |
24 | */ | 24 | */ |
25 | GSM_CAL_CALL, | 25 | GSM_CAL_CALL, |
26 | /** | 26 | /** |
27 | * Meeting | 27 | * Meeting |
28 | */ | 28 | */ |
29 | GSM_CAL_MEETING, | 29 | GSM_CAL_MEETING, |
30 | /** | 30 | /** |
31 | * Birthday or Anniversary or Special Occasion | 31 | * Birthday or Anniversary or Special Occasion |
32 | */ | 32 | */ |
33 | GSM_CAL_BIRTHDAY, | 33 | GSM_CAL_BIRTHDAY, |
34 | /** | 34 | /** |
35 | * Memo or Miscellaneous | 35 | * Memo or Miscellaneous |
36 | */ | 36 | */ |
37 | GSM_CAL_MEMO, | 37 | GSM_CAL_MEMO, |
38 | /** | 38 | /** |
39 | * Travel | 39 | * Travel |
40 | */ | 40 | */ |
41 | GSM_CAL_TRAVEL, | 41 | GSM_CAL_TRAVEL, |
42 | /** | 42 | /** |
43 | * Vacation | 43 | * Vacation |
44 | */ | 44 | */ |
45 | GSM_CAL_VACATION, | 45 | GSM_CAL_VACATION, |
46 | /** | 46 | /** |
47 | * Training - Athletism | 47 | * Training - Athletism |
48 | */ | 48 | */ |
49 | GSM_CAL_T_ATHL, | 49 | GSM_CAL_T_ATHL, |
50 | /** | 50 | /** |
51 | * Training - Ball Games | 51 | * Training - Ball Games |
52 | */ | 52 | */ |
53 | GSM_CAL_T_BALL, | 53 | GSM_CAL_T_BALL, |
54 | /** | 54 | /** |
55 | * Training - Cycling | 55 | * Training - Cycling |
56 | */ | 56 | */ |
57 | GSM_CAL_T_CYCL, | 57 | GSM_CAL_T_CYCL, |
58 | /** | 58 | /** |
59 | * Training - Budo | 59 | * Training - Budo |
60 | */ | 60 | */ |
61 | GSM_CAL_T_BUDO, | 61 | GSM_CAL_T_BUDO, |
62 | /** | 62 | /** |
63 | * Training - Dance | 63 | * Training - Dance |
64 | */ | 64 | */ |
65 | GSM_CAL_T_DANC, | 65 | GSM_CAL_T_DANC, |
66 | /** | 66 | /** |
67 | * Training - Extreme Sports | 67 | * Training - Extreme Sports |
68 | */ | 68 | */ |
69 | GSM_CAL_T_EXTR, | 69 | GSM_CAL_T_EXTR, |
70 | /** | 70 | /** |
71 | * Training - Football | 71 | * Training - Football |
72 | */ | 72 | */ |
73 | GSM_CAL_T_FOOT, | 73 | GSM_CAL_T_FOOT, |
74 | /** | 74 | /** |
75 | * Training - Golf | 75 | * Training - Golf |
76 | */ | 76 | */ |
77 | GSM_CAL_T_GOLF, | 77 | GSM_CAL_T_GOLF, |
78 | /** | 78 | /** |
79 | * Training - Gym | 79 | * Training - Gym |
80 | */ | 80 | */ |
81 | GSM_CAL_T_GYM, | 81 | GSM_CAL_T_GYM, |
82 | /** | 82 | /** |
83 | * Training - Horse Race | 83 | * Training - Horse Race |
84 | */ | 84 | */ |
85 | GSM_CAL_T_HORS, | 85 | GSM_CAL_T_HORS, |
86 | /** | 86 | /** |
87 | * Training - Hockey | 87 | * Training - Hockey |
88 | */ | 88 | */ |
89 | GSM_CAL_T_HOCK, | 89 | GSM_CAL_T_HOCK, |
90 | /** | 90 | /** |
91 | * Training - Races | 91 | * Training - Races |
92 | */ | 92 | */ |
93 | GSM_CAL_T_RACE, | 93 | GSM_CAL_T_RACE, |
94 | /** | 94 | /** |
95 | * Training - Rugby | 95 | * Training - Rugby |
96 | */ | 96 | */ |
97 | GSM_CAL_T_RUGB, | 97 | GSM_CAL_T_RUGB, |
98 | /** | 98 | /** |
99 | * Training - Sailing | 99 | * Training - Sailing |
100 | */ | 100 | */ |
101 | GSM_CAL_T_SAIL, | 101 | GSM_CAL_T_SAIL, |
102 | /** | 102 | /** |
103 | * Training - Street Games | 103 | * Training - Street Games |
104 | */ | 104 | */ |
105 | GSM_CAL_T_STRE, | 105 | GSM_CAL_T_STRE, |
106 | /** | 106 | /** |
107 | * Training - Swimming | 107 | * Training - Swimming |
108 | */ | 108 | */ |
109 | GSM_CAL_T_SWIM, | 109 | GSM_CAL_T_SWIM, |
110 | /** | 110 | /** |
111 | * Training - Tennis | 111 | * Training - Tennis |
112 | */ | 112 | */ |
113 | GSM_CAL_T_TENN, | 113 | GSM_CAL_T_TENN, |
114 | /** | 114 | /** |
115 | * Training - Travels | 115 | * Training - Travels |
116 | */ | 116 | */ |
117 | GSM_CAL_T_TRAV, | 117 | GSM_CAL_T_TRAV, |
118 | /** | 118 | /** |
119 | * Training - Winter Games | 119 | * Training - Winter Games |
120 | */ | 120 | */ |
121 | GSM_CAL_T_WINT, | 121 | GSM_CAL_T_WINT, |
122 | /** | 122 | /** |
123 | * Alarm | 123 | * Alarm |
124 | */ | 124 | */ |
125 | GSM_CAL_ALARM, | 125 | GSM_CAL_ALARM, |
126 | /** | 126 | /** |
127 | * Alarm repeating each day. | 127 | * Alarm repeating each day. |
128 | */ | 128 | */ |
129 | GSM_CAL_DAILY_ALARM | 129 | GSM_CAL_DAILY_ALARM |
130 | } GSM_CalendarNoteType; | 130 | } GSM_CalendarNoteType; |
131 | 131 | ||
132 | /** | 132 | /** |
133 | * One value of calendar event. | 133 | * One value of calendar event. |
134 | */ | 134 | */ |
135 | typedef enum { | 135 | typedef enum { |
136 | /** | 136 | /** |
137 | * Date and time of event start. | 137 | * Date and time of event start. |
138 | */ | 138 | */ |
139 | CAL_START_DATETIME = 1, | 139 | CAL_START_DATETIME = 1, |
140 | /** | 140 | /** |
141 | * Date and time of event end. | 141 | * Date and time of event end. |
142 | */ | 142 | */ |
143 | CAL_END_DATETIME, | 143 | CAL_END_DATETIME, |
144 | /** | 144 | /** |
145 | * Alarm date and time. | 145 | * Alarm date and time. |
146 | */ | 146 | */ |
147 | CAL_ALARM_DATETIME, | 147 | CAL_ALARM_DATETIME, |
148 | /** | 148 | /** |
149 | * Date and time of silent alarm. | 149 | * Date and time of silent alarm. |
150 | */ | 150 | */ |
151 | CAL_SILENT_ALARM_DATETIME, | 151 | CAL_SILENT_ALARM_DATETIME, |
152 | /** | 152 | /** |
153 | * Recurrance. | 153 | * Recurrance. |
154 | */ | 154 | */ |
155 | CAL_RECURRANCE, | 155 | CAL_RECURRANCE, |
156 | /** | 156 | /** |
157 | * Text. | 157 | * Text. |
158 | */ | 158 | */ |
159 | CAL_TEXT, | 159 | CAL_TEXT, |
160 | CAL_DESCRIPTION, // LR added | ||
160 | /** | 161 | /** |
161 | * Location. | 162 | * Location. |
162 | */ | 163 | */ |
163 | CAL_LOCATION, | 164 | CAL_LOCATION, |
164 | /** | 165 | /** |
165 | * Phone number. | 166 | * Phone number. |
166 | */ | 167 | */ |
167 | CAL_PHONE, | 168 | CAL_PHONE, |
168 | /** | 169 | /** |
169 | * Whether this entry is private. | 170 | * Whether this entry is private. |
170 | */ | 171 | */ |
171 | CAL_PRIVATE, | 172 | CAL_PRIVATE, |
172 | /** | 173 | /** |
173 | * Related contact id. | 174 | * Related contact id. |
174 | */ | 175 | */ |
175 | CAL_CONTACTID, | 176 | CAL_CONTACTID, |
176 | /** | 177 | /** |
177 | * Repeat each x'th day of week. | 178 | * Repeat each x'th day of week. |
178 | */ | 179 | */ |
179 | CAL_REPEAT_DAYOFWEEK, | 180 | CAL_REPEAT_DAYOFWEEK, |
180 | /** | 181 | /** |
181 | * Repeat each x'th day of month. | 182 | * Repeat each x'th day of month. |
182 | */ | 183 | */ |
183 | CAL_REPEAT_DAY, | 184 | CAL_REPEAT_DAY, |
184 | /** | 185 | /** |
185 | * Repeat x'th week of month. | 186 | * Repeat x'th week of month. |
186 | */ | 187 | */ |
187 | CAL_REPEAT_WEEKOFMONTH, | 188 | CAL_REPEAT_WEEKOFMONTH, |
188 | /** | 189 | /** |
189 | * Repeat x'th month. | 190 | * Repeat x'th month. |
190 | */ | 191 | */ |
191 | CAL_REPEAT_MONTH, | 192 | CAL_REPEAT_MONTH, |
192 | /** | 193 | /** |
193 | * Repeating frequency. | 194 | * Repeating frequency. |
194 | */ | 195 | */ |
195 | CAL_REPEAT_FREQUENCY, | 196 | CAL_REPEAT_FREQUENCY, |
196 | /** | 197 | /** |
197 | * Repeating start. | 198 | * Repeating start. |
198 | */ | 199 | */ |
199 | CAL_REPEAT_STARTDATE, | 200 | CAL_REPEAT_STARTDATE, |
200 | /** | 201 | /** |
201 | * Repeating end. | 202 | * Repeating end. |
202 | */ | 203 | */ |
203 | CAL_REPEAT_STOPDATE | 204 | CAL_REPEAT_STOPDATE |
204 | } GSM_CalendarType; | 205 | } GSM_CalendarType; |
205 | 206 | ||
206 | /** | 207 | /** |
207 | * One value of calendar event. | 208 | * One value of calendar event. |
208 | */ | 209 | */ |
209 | typedef struct { | 210 | typedef struct { |
210 | /** | 211 | /** |
211 | * Type of value. | 212 | * Type of value. |
212 | */ | 213 | */ |
213 | GSM_CalendarTypeEntryType; | 214 | GSM_CalendarTypeEntryType; |
214 | /** | 215 | /** |
215 | * Text of value, if applicable. | 216 | * Text of value, if applicable. |
216 | */ | 217 | */ |
217 | unsigned char Text[(MAX_CALENDAR_TEXT_LENGTH + 1)*2]; | 218 | unsigned char Text[(MAX_CALENDAR_TEXT_LENGTH + 1)*2]; |
218 | /** | 219 | /** |
219 | * Date and time of value, if applicable. | 220 | * Date and time of value, if applicable. |
220 | */ | 221 | */ |
221 | GSM_DateTime Date; | 222 | GSM_DateTime Date; |
222 | /** | 223 | /** |
223 | * Number of value, if applicable. | 224 | * Number of value, if applicable. |
224 | */ | 225 | */ |
225 | unsigned int Number; | 226 | unsigned int Number; |
226 | } GSM_SubCalendarEntry; | 227 | } GSM_SubCalendarEntry; |
227 | 228 | ||
228 | /** | 229 | /** |
229 | * Calendar note values. | 230 | * Calendar note values. |
230 | */ | 231 | */ |
231 | typedef struct { | 232 | typedef struct { |
232 | /** | 233 | /** |
233 | * Type of calendar note. | 234 | * Type of calendar note. |
234 | */ | 235 | */ |
235 | GSM_CalendarNoteType Type; | 236 | GSM_CalendarNoteType Type; |
236 | /** | 237 | /** |
237 | * Location in memory. | 238 | * Location in memory. |
238 | */ | 239 | */ |
239 | int Location; | 240 | int Location; |
240 | /** | 241 | /** |
241 | * Number of entries. | 242 | * Number of entries. |
242 | */ | 243 | */ |
243 | int EntriesNum; | 244 | int EntriesNum; |
244 | /** | 245 | /** |
245 | * Values of entries. | 246 | * Values of entries. |
246 | */ | 247 | */ |
247 | GSM_SubCalendarEntry Entries[GSM_CALENDAR_ENTRIES]; | 248 | GSM_SubCalendarEntry Entries[GSM_CALENDAR_ENTRIES]; |
248 | } GSM_CalendarEntry; | 249 | } GSM_CalendarEntry; |
249 | 250 | ||
250 | void GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(GSM_CalendarEntry *entry, int *Text, int *Time, int *Alarm, int *Phone, int *Recurrance, int *EndTime, int *Location); | 251 | void GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(GSM_CalendarEntry *entry, int *Text, int *Time, int *Alarm, int *Phone, int *Recurrance, int *EndTime, int *Location); |
251 | 252 | ||
252 | typedef enum { | 253 | typedef enum { |
253 | Nokia_VCalendar = 1, | 254 | Nokia_VCalendar = 1, |
254 | Siemens_VCalendar, | 255 | Siemens_VCalendar, |
255 | SonyEricsson_VCalendar | 256 | SonyEricsson_VCalendar |
256 | } GSM_VCalendarVersion; | 257 | } GSM_VCalendarVersion; |
257 | 258 | ||
258 | GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note, bool header, GSM_VCalendarVersion Version); | 259 | GSM_Error GSM_EncodeVCALENDAR(char *Buffer, int *Length, GSM_CalendarEntry *note, bool header, GSM_VCalendarVersion Version); |
259 | 260 | ||
260 | bool IsCalendarNoteFromThePast(GSM_CalendarEntry *note); | 261 | bool IsCalendarNoteFromThePast(GSM_CalendarEntry *note); |
261 | 262 | ||
262 | typedef struct { | 263 | typedef struct { |
263 | /** | 264 | /** |
264 | * Monday = 1, Tuesday = 2,... | 265 | * Monday = 1, Tuesday = 2,... |
265 | */ | 266 | */ |
266 | int StartDay; | 267 | int StartDay; |
267 | /** | 268 | /** |
268 | * 0 = no delete, 1 = after day,... | 269 | * 0 = no delete, 1 = after day,... |
269 | */ | 270 | */ |
270 | int AutoDelete; | 271 | int AutoDelete; |
271 | } GSM_CalendarSettings; | 272 | } GSM_CalendarSettings; |
272 | 273 | ||
273 | /** | 274 | /** |
274 | * Structure used for returning calendar status. | 275 | * Structure used for returning calendar status. |
275 | */ | 276 | */ |
276 | typedef struct { | 277 | typedef struct { |
277 | /** | 278 | /** |
278 | * Number of used positions. | 279 | * Number of used positions. |
279 | */ | 280 | */ |
280 | int Used; | 281 | int Used; |
281 | } GSM_CalendarStatus; | 282 | } GSM_CalendarStatus; |
282 | 283 | ||
283 | 284 | ||
284 | /* ------------------------------ to-do ------------------------------------ */ | 285 | /* ------------------------------ to-do ------------------------------------ */ |
285 | 286 | ||
286 | #define GSM_TODO_ENTRIES 7 | 287 | #define GSM_TODO_ENTRIES 7 |
287 | #define MAX_TODO_TEXT_LENGTH 50 /* Alcatel BE5 50 chars */ | 288 | #define MAX_TODO_TEXT_LENGTH 50 /* Alcatel BE5 50 chars */ |
288 | 289 | ||
289 | /** | 290 | /** |
290 | * Types of to do values. In parenthesis is member of @ref GSM_SubToDoEntry, | 291 | * Types of to do values. In parenthesis is member of @ref GSM_SubToDoEntry, |
291 | * where value is stored. | 292 | * where value is stored. |
292 | */ | 293 | */ |
293 | typedef enum { | 294 | typedef enum { |
294 | /** | 295 | /** |
295 | * Due date. (Date) | 296 | * Due date. (Date) |
296 | */ | 297 | */ |
297 | TODO_END_DATETIME = 1, | 298 | TODO_END_DATETIME = 1, |
298 | /** | 299 | /** |
299 | * Whether is completed. (Number) | 300 | * Whether is completed. (Number) |
300 | */ | 301 | */ |
301 | TODO_COMPLETED, | 302 | TODO_COMPLETED, |
302 | /** | 303 | /** |
303 | * When should alarm be fired (Date). | 304 | * When should alarm be fired (Date). |
304 | */ | 305 | */ |
305 | TODO_ALARM_DATETIME, | 306 | TODO_ALARM_DATETIME, |
306 | /** | 307 | /** |
307 | * When should silent alarm be fired (Date). | 308 | * When should silent alarm be fired (Date). |
308 | */ | 309 | */ |
309 | TODO_SILENT_ALARM_DATETIME, | 310 | TODO_SILENT_ALARM_DATETIME, |
310 | /** | 311 | /** |
311 | * Text of to do (Text). | 312 | * Text of to do (Text). |
312 | */ | 313 | */ |
313 | TODO_TEXT, | 314 | TODO_TEXT, |
314 | /** | 315 | /** |
315 | * Whether entry is private (Number). | 316 | * Whether entry is private (Number). |
316 | */ | 317 | */ |
317 | TODO_PRIVATE, | 318 | TODO_PRIVATE, |
318 | /** | 319 | /** |
319 | * Category of entry (Number). | 320 | * Category of entry (Number). |
320 | */ | 321 | */ |
321 | TODO_CATEGORY, | 322 | TODO_CATEGORY, |
322 | /** | 323 | /** |
323 | * Related contact ID (Number). | 324 | * Related contact ID (Number). |
324 | */ | 325 | */ |
325 | TODO_CONTACTID, | 326 | TODO_CONTACTID, |
326 | /** | 327 | /** |
327 | * Number to call (Text). | 328 | * Number to call (Text). |
328 | */ | 329 | */ |
329 | TODO_PHONE | 330 | TODO_PHONE |
330 | } GSM_ToDoType; | 331 | } GSM_ToDoType; |
331 | 332 | ||
332 | /** | 333 | /** |
333 | * Priority of to do. | 334 | * Priority of to do. |
334 | */ | 335 | */ |
335 | typedef enum { | 336 | typedef enum { |
336 | GSM_Priority_High = 1, | 337 | GSM_Priority_High = 1, |
337 | GSM_Priority_Medium, | 338 | GSM_Priority_Medium, |
338 | GSM_Priority_Low | 339 | GSM_Priority_Low |
339 | } GSM_ToDo_Priority; | 340 | } GSM_ToDo_Priority; |
340 | 341 | ||
341 | /** | 342 | /** |
342 | * Value of to do entry. | 343 | * Value of to do entry. |
343 | */ | 344 | */ |
344 | typedef struct { | 345 | typedef struct { |
345 | /** | 346 | /** |
346 | * Type of entry. | 347 | * Type of entry. |
347 | */ | 348 | */ |
348 | GSM_ToDoType EntryType; | 349 | GSM_ToDoType EntryType; |
349 | /** | 350 | /** |
350 | * Text of value, if appropriate, see @ref GSM_ToDoType. | 351 | * Text of value, if appropriate, see @ref GSM_ToDoType. |
351 | */ | 352 | */ |
352 | unsigned char Text[(MAX_TODO_TEXT_LENGTH + 1)*2]; | 353 | unsigned char Text[(MAX_TODO_TEXT_LENGTH + 1)*2]; |
353 | /** | 354 | /** |
354 | * Date of value, if appropriate, see @ref GSM_ToDoType. | 355 | * Date of value, if appropriate, see @ref GSM_ToDoType. |
355 | */ | 356 | */ |
356 | GSM_DateTime Date; | 357 | GSM_DateTime Date; |
357 | /** | 358 | /** |
358 | * Number of value, if appropriate, see @ref GSM_ToDoType. | 359 | * Number of value, if appropriate, see @ref GSM_ToDoType. |
359 | */ | 360 | */ |
360 | unsigned int Number; | 361 | unsigned int Number; |
361 | } GSM_SubToDoEntry; | 362 | } GSM_SubToDoEntry; |
362 | 363 | ||
363 | /** | 364 | /** |
364 | * To do entry. | 365 | * To do entry. |
365 | */ | 366 | */ |
366 | typedef struct { | 367 | typedef struct { |
367 | /** | 368 | /** |
368 | * Priority of entry. | 369 | * Priority of entry. |
369 | */ | 370 | */ |
370 | GSM_ToDo_Priority Priority; | 371 | GSM_ToDo_Priority Priority; |
371 | /** | 372 | /** |
372 | * Location in memory. | 373 | * Location in memory. |
373 | */ | 374 | */ |
374 | int Location; | 375 | int Location; |
375 | /** | 376 | /** |
376 | * Number of entries. | 377 | * Number of entries. |
377 | */ | 378 | */ |
378 | int EntriesNum; | 379 | int EntriesNum; |
379 | /** | 380 | /** |
380 | * Values of current entry. | 381 | * Values of current entry. |
381 | */ | 382 | */ |
382 | GSM_SubToDoEntryEntries[GSM_TODO_ENTRIES]; | 383 | GSM_SubToDoEntryEntries[GSM_TODO_ENTRIES]; |
383 | } GSM_ToDoEntry; | 384 | } GSM_ToDoEntry; |
384 | 385 | ||
385 | void GSM_ToDoFindDefaultTextTimeAlarmCompleted(GSM_ToDoEntry *entry, int *Text, int *Alarm, int *Completed, int *EndTime, int *Phone); | 386 | void GSM_ToDoFindDefaultTextTimeAlarmCompleted(GSM_ToDoEntry *entry, int *Text, int *Alarm, int *Completed, int *EndTime, int *Phone); |
386 | 387 | ||
387 | typedef enum { | 388 | typedef enum { |
388 | Nokia_VToDo = 1, | 389 | Nokia_VToDo = 1, |
389 | SonyEricsson_VToDo | 390 | SonyEricsson_VToDo |
390 | } GSM_VToDoVersion; | 391 | } GSM_VToDoVersion; |
391 | 392 | ||
392 | GSM_Error GSM_EncodeVTODO(char *Buffer, int *Length, GSM_ToDoEntry *note, bool header, GSM_VToDoVersion Version); | 393 | GSM_Error GSM_EncodeVTODO(char *Buffer, int *Length, GSM_ToDoEntry *note, bool header, GSM_VToDoVersion Version); |
393 | 394 | ||
394 | /** | 395 | /** |
395 | * Status of to do entries. | 396 | * Status of to do entries. |
396 | */ | 397 | */ |
397 | typedef struct { | 398 | typedef struct { |
398 | /** | 399 | /** |
399 | * Number of used positions. | 400 | * Number of used positions. |
400 | */ | 401 | */ |
401 | int Used; | 402 | int Used; |
402 | } GSM_ToDoStatus; | 403 | } GSM_ToDoStatus; |
403 | 404 | ||
404 | /* --------------------------- note ---------------------------------------- */ | 405 | /* --------------------------- note ---------------------------------------- */ |
405 | 406 | ||
406 | typedef struct { | 407 | typedef struct { |
407 | int Location; | 408 | int Location; |
408 | char Text[3000*2]; | 409 | char Text[3000*2]; |
409 | } GSM_NoteEntry; | 410 | } GSM_NoteEntry; |
410 | 411 | ||
411 | GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note); | 412 | GSM_Error GSM_EncodeVNTFile(unsigned char *Buffer, int *Length, GSM_NoteEntry *Note); |
412 | 413 | ||
413 | /* --------------------------- alarm --------------------------------------- */ | 414 | /* --------------------------- alarm --------------------------------------- */ |
414 | 415 | ||
415 | /** | 416 | /** |
416 | * Alarm values. | 417 | * Alarm values. |
417 | */ | 418 | */ |
418 | typedef struct { | 419 | typedef struct { |
419 | /** | 420 | /** |
420 | * Location where it is stored. | 421 | * Location where it is stored. |
421 | */ | 422 | */ |
422 | int Location; | 423 | int Location; |
423 | /** | 424 | /** |
424 | * Date and time of alarm. | 425 | * Date and time of alarm. |
425 | */ | 426 | */ |
426 | GSM_DateTime DateTime; | 427 | GSM_DateTime DateTime; |
427 | /** | 428 | /** |
428 | * Whether it repeats each day. | 429 | * Whether it repeats each day. |
429 | */ | 430 | */ |
430 | bool Repeating; | 431 | bool Repeating; |
431 | /** | 432 | /** |
432 | * Text that is shown on display. | 433 | * Text that is shown on display. |
433 | */ | 434 | */ |
434 | char Text[(MAX_CALENDAR_TEXT_LENGTH + 1) * 2]; | 435 | char Text[(MAX_CALENDAR_TEXT_LENGTH + 1) * 2]; |
435 | } GSM_Alarm; | 436 | } GSM_Alarm; |
436 | 437 | ||
437 | /* --------------------------- calendar & todo ----------------------------- */ | 438 | /* --------------------------- calendar & todo ----------------------------- */ |
438 | 439 | ||
439 | GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_CalendarEntry *Calendar, GSM_ToDoEntry *ToDo, GSM_VCalendarVersion CalVer, GSM_VToDoVersion ToDoVer); | 440 | GSM_Error GSM_DecodeVCALENDAR_VTODO(unsigned char *Buffer, int *Pos, GSM_CalendarEntry *Calendar, GSM_ToDoEntry *ToDo, GSM_VCalendarVersion CalVer, GSM_VToDoVersion ToDoVer); |
440 | 441 | ||
441 | #endif | 442 | #endif |
442 | 443 | ||
443 | /* How should editor hadle tabs in this file? Add editor commands here. | 444 | /* How should editor hadle tabs in this file? Add editor commands here. |
444 | * vim: noexpandtab sw=8 ts=8 sts=8: | 445 | * vim: noexpandtab sw=8 ts=8 sts=8: |
445 | */ | 446 | */ |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 47ed858..dae9cd2 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -304,1043 +304,1045 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const | |||
304 | SLOT( browse( const QString& ) ) ); | 304 | SLOT( browse( const QString& ) ) ); |
305 | 305 | ||
306 | 306 | ||
307 | mAddressBookService = new KAddressBookService( this ); | 307 | mAddressBookService = new KAddressBookService( this ); |
308 | 308 | ||
309 | #endif //KAB_EMBEDDED | 309 | #endif //KAB_EMBEDDED |
310 | mEditorDialog = 0; | 310 | mEditorDialog = 0; |
311 | createAddresseeEditorDialog( this ); | 311 | createAddresseeEditorDialog( this ); |
312 | setModified( false ); | 312 | setModified( false ); |
313 | } | 313 | } |
314 | 314 | ||
315 | KABCore::~KABCore() | 315 | KABCore::~KABCore() |
316 | { | 316 | { |
317 | // save(); | 317 | // save(); |
318 | //saveSettings(); | 318 | //saveSettings(); |
319 | //KABPrefs::instance()->writeConfig(); | 319 | //KABPrefs::instance()->writeConfig(); |
320 | delete AddresseeConfig::instance(); | 320 | delete AddresseeConfig::instance(); |
321 | mAddressBook = 0; | 321 | mAddressBook = 0; |
322 | KABC::StdAddressBook::close(); | 322 | KABC::StdAddressBook::close(); |
323 | 323 | ||
324 | delete syncManager; | 324 | delete syncManager; |
325 | 325 | ||
326 | } | 326 | } |
327 | 327 | ||
328 | void KABCore::recieve( QString fn ) | 328 | void KABCore::recieve( QString fn ) |
329 | { | 329 | { |
330 | //qDebug("KABCore::recieve "); | 330 | //qDebug("KABCore::recieve "); |
331 | mAddressBook->importFromFile( fn, true ); | 331 | mAddressBook->importFromFile( fn, true ); |
332 | mViewManager->refreshView(); | 332 | mViewManager->refreshView(); |
333 | topLevelWidget()->raise(); | 333 | topLevelWidget()->raise(); |
334 | } | 334 | } |
335 | void KABCore::restoreSettings() | 335 | void KABCore::restoreSettings() |
336 | { | 336 | { |
337 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 337 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
338 | 338 | ||
339 | bool state; | 339 | bool state; |
340 | 340 | ||
341 | if (mMultipleViewsAtOnce) | 341 | if (mMultipleViewsAtOnce) |
342 | state = KABPrefs::instance()->mDetailsPageVisible; | 342 | state = KABPrefs::instance()->mDetailsPageVisible; |
343 | else | 343 | else |
344 | state = false; | 344 | state = false; |
345 | 345 | ||
346 | mActionDetails->setChecked( state ); | 346 | mActionDetails->setChecked( state ); |
347 | setDetailsVisible( state ); | 347 | setDetailsVisible( state ); |
348 | 348 | ||
349 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 349 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
350 | 350 | ||
351 | mActionJumpBar->setChecked( state ); | 351 | mActionJumpBar->setChecked( state ); |
352 | setJumpButtonBarVisible( state ); | 352 | setJumpButtonBarVisible( state ); |
353 | /*US | 353 | /*US |
354 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 354 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
355 | if ( splitterSize.count() == 0 ) { | 355 | if ( splitterSize.count() == 0 ) { |
356 | splitterSize.append( width() / 2 ); | 356 | splitterSize.append( width() / 2 ); |
357 | splitterSize.append( width() / 2 ); | 357 | splitterSize.append( width() / 2 ); |
358 | } | 358 | } |
359 | mMiniSplitter->setSizes( splitterSize ); | 359 | mMiniSplitter->setSizes( splitterSize ); |
360 | if ( mExtensionBarSplitter ) { | 360 | if ( mExtensionBarSplitter ) { |
361 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 361 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
362 | if ( splitterSize.count() == 0 ) { | 362 | if ( splitterSize.count() == 0 ) { |
363 | splitterSize.append( width() / 2 ); | 363 | splitterSize.append( width() / 2 ); |
364 | splitterSize.append( width() / 2 ); | 364 | splitterSize.append( width() / 2 ); |
365 | } | 365 | } |
366 | mExtensionBarSplitter->setSizes( splitterSize ); | 366 | mExtensionBarSplitter->setSizes( splitterSize ); |
367 | 367 | ||
368 | } | 368 | } |
369 | */ | 369 | */ |
370 | mViewManager->restoreSettings(); | 370 | mViewManager->restoreSettings(); |
371 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 371 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
372 | mExtensionManager->restoreSettings(); | 372 | mExtensionManager->restoreSettings(); |
373 | #ifdef DESKTOP_VERSION | 373 | #ifdef DESKTOP_VERSION |
374 | int wid = width(); | 374 | int wid = width(); |
375 | if ( wid < 10 ) | 375 | if ( wid < 10 ) |
376 | wid = 400; | 376 | wid = 400; |
377 | #else | 377 | #else |
378 | int wid = QApplication::desktop()->width(); | 378 | int wid = QApplication::desktop()->width(); |
379 | if ( wid < 640 ) | 379 | if ( wid < 640 ) |
380 | wid = QApplication::desktop()->height(); | 380 | wid = QApplication::desktop()->height(); |
381 | #endif | 381 | #endif |
382 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; | 382 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; |
383 | if ( true /*splitterSize.count() == 0*/ ) { | 383 | if ( true /*splitterSize.count() == 0*/ ) { |
384 | splitterSize.append( wid / 2 ); | 384 | splitterSize.append( wid / 2 ); |
385 | splitterSize.append( wid / 2 ); | 385 | splitterSize.append( wid / 2 ); |
386 | } | 386 | } |
387 | mMiniSplitter->setSizes( splitterSize ); | 387 | mMiniSplitter->setSizes( splitterSize ); |
388 | if ( mExtensionBarSplitter ) { | 388 | if ( mExtensionBarSplitter ) { |
389 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 389 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
390 | if ( true /*splitterSize.count() == 0*/ ) { | 390 | if ( true /*splitterSize.count() == 0*/ ) { |
391 | splitterSize.append( wid / 2 ); | 391 | splitterSize.append( wid / 2 ); |
392 | splitterSize.append( wid / 2 ); | 392 | splitterSize.append( wid / 2 ); |
393 | } | 393 | } |
394 | mExtensionBarSplitter->setSizes( splitterSize ); | 394 | mExtensionBarSplitter->setSizes( splitterSize ); |
395 | 395 | ||
396 | } | 396 | } |
397 | 397 | ||
398 | 398 | ||
399 | } | 399 | } |
400 | 400 | ||
401 | void KABCore::saveSettings() | 401 | void KABCore::saveSettings() |
402 | { | 402 | { |
403 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 403 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
404 | if ( mExtensionBarSplitter ) | 404 | if ( mExtensionBarSplitter ) |
405 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 405 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
406 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 406 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
407 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 407 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
408 | #ifndef KAB_EMBEDDED | 408 | #ifndef KAB_EMBEDDED |
409 | 409 | ||
410 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 410 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
411 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 411 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
412 | #endif //KAB_EMBEDDED | 412 | #endif //KAB_EMBEDDED |
413 | mExtensionManager->saveSettings(); | 413 | mExtensionManager->saveSettings(); |
414 | mViewManager->saveSettings(); | 414 | mViewManager->saveSettings(); |
415 | 415 | ||
416 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 416 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
417 | } | 417 | } |
418 | 418 | ||
419 | KABC::AddressBook *KABCore::addressBook() const | 419 | KABC::AddressBook *KABCore::addressBook() const |
420 | { | 420 | { |
421 | return mAddressBook; | 421 | return mAddressBook; |
422 | } | 422 | } |
423 | 423 | ||
424 | KConfig *KABCore::config() | 424 | KConfig *KABCore::config() |
425 | { | 425 | { |
426 | #ifndef KAB_EMBEDDED | 426 | #ifndef KAB_EMBEDDED |
427 | return KABPrefs::instance()->config(); | 427 | return KABPrefs::instance()->config(); |
428 | #else //KAB_EMBEDDED | 428 | #else //KAB_EMBEDDED |
429 | return KABPrefs::instance()->getConfig(); | 429 | return KABPrefs::instance()->getConfig(); |
430 | #endif //KAB_EMBEDDED | 430 | #endif //KAB_EMBEDDED |
431 | } | 431 | } |
432 | 432 | ||
433 | KActionCollection *KABCore::actionCollection() const | 433 | KActionCollection *KABCore::actionCollection() const |
434 | { | 434 | { |
435 | return mGUIClient->actionCollection(); | 435 | return mGUIClient->actionCollection(); |
436 | } | 436 | } |
437 | 437 | ||
438 | KABC::Field *KABCore::currentSearchField() const | 438 | KABC::Field *KABCore::currentSearchField() const |
439 | { | 439 | { |
440 | if (mIncSearchWidget) | 440 | if (mIncSearchWidget) |
441 | return mIncSearchWidget->currentField(); | 441 | return mIncSearchWidget->currentField(); |
442 | else | 442 | else |
443 | return 0; | 443 | return 0; |
444 | } | 444 | } |
445 | 445 | ||
446 | QStringList KABCore::selectedUIDs() const | 446 | QStringList KABCore::selectedUIDs() const |
447 | { | 447 | { |
448 | return mViewManager->selectedUids(); | 448 | return mViewManager->selectedUids(); |
449 | } | 449 | } |
450 | 450 | ||
451 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 451 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
452 | { | 452 | { |
453 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 453 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
454 | 454 | ||
455 | QPtrList<KRES::Resource> kresResources; | 455 | QPtrList<KRES::Resource> kresResources; |
456 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 456 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
457 | KABC::Resource *resource; | 457 | KABC::Resource *resource; |
458 | while ( ( resource = resIt.current() ) != 0 ) { | 458 | while ( ( resource = resIt.current() ) != 0 ) { |
459 | ++resIt; | 459 | ++resIt; |
460 | if ( !resource->readOnly() ) { | 460 | if ( !resource->readOnly() ) { |
461 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 461 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
462 | if ( res ) | 462 | if ( res ) |
463 | kresResources.append( res ); | 463 | kresResources.append( res ); |
464 | } | 464 | } |
465 | } | 465 | } |
466 | 466 | ||
467 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 467 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
468 | return static_cast<KABC::Resource*>( res ); | 468 | return static_cast<KABC::Resource*>( res ); |
469 | } | 469 | } |
470 | 470 | ||
471 | #ifndef KAB_EMBEDDED | 471 | #ifndef KAB_EMBEDDED |
472 | KAboutData *KABCore::createAboutData() | 472 | KAboutData *KABCore::createAboutData() |
473 | #else //KAB_EMBEDDED | 473 | #else //KAB_EMBEDDED |
474 | void KABCore::createAboutData() | 474 | void KABCore::createAboutData() |
475 | #endif //KAB_EMBEDDED | 475 | #endif //KAB_EMBEDDED |
476 | { | 476 | { |
477 | #ifndef KAB_EMBEDDED | 477 | #ifndef KAB_EMBEDDED |
478 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 478 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
479 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 479 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
480 | KAboutData::License_GPL_V2, | 480 | KAboutData::License_GPL_V2, |
481 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 481 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
482 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 482 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
483 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 483 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
484 | about->addAuthor( "Cornelius Schumacher", | 484 | about->addAuthor( "Cornelius Schumacher", |
485 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 485 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
486 | "schumacher@kde.org" ); | 486 | "schumacher@kde.org" ); |
487 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 487 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
488 | "mpilone@slac.com" ); | 488 | "mpilone@slac.com" ); |
489 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 489 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
490 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 490 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
491 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 491 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
492 | "michel@klaralvdalens-datakonsult.se" ); | 492 | "michel@klaralvdalens-datakonsult.se" ); |
493 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 493 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
494 | "hansen@kde.org" ); | 494 | "hansen@kde.org" ); |
495 | 495 | ||
496 | return about; | 496 | return about; |
497 | #endif //KAB_EMBEDDED | 497 | #endif //KAB_EMBEDDED |
498 | 498 | ||
499 | QString version; | 499 | QString version; |
500 | #include <../version> | 500 | #include <../version> |
501 | QMessageBox::about( this, "About KAddressbook/Pi", | 501 | QMessageBox::about( this, "About KAddressbook/Pi", |
502 | "KAddressbook/Platform-independent\n" | 502 | "KAddressbook/Platform-independent\n" |
503 | "(KA/Pi) " +version + " - " + | 503 | "(KA/Pi) " +version + " - " + |
504 | #ifdef DESKTOP_VERSION | 504 | #ifdef DESKTOP_VERSION |
505 | "Desktop Edition\n" | 505 | "Desktop Edition\n" |
506 | #else | 506 | #else |
507 | "PDA-Edition\n" | 507 | "PDA-Edition\n" |
508 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 508 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
509 | #endif | 509 | #endif |
510 | 510 | ||
511 | "(c) 2004 Ulf Schenk\n" | 511 | "(c) 2004 Ulf Schenk\n" |
512 | "(c) 2004 Lutz Rogowski\n" | 512 | "(c) 2004 Lutz Rogowski\n" |
513 | "(c) 1997-2003, The KDE PIM Team\n" | 513 | "(c) 1997-2003, The KDE PIM Team\n" |
514 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" | 514 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" |
515 | "Don Sanders Original author\n" | 515 | "Don Sanders Original author\n" |
516 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" | 516 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" |
517 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" | 517 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" |
518 | "Greg Stern DCOP interface\n" | 518 | "Greg Stern DCOP interface\n" |
519 | "Mark Westcot Contact pinning\n" | 519 | "Mark Westcot Contact pinning\n" |
520 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 520 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
521 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" | 521 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" |
522 | #ifdef _WIN32_ | 522 | #ifdef _WIN32_ |
523 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 523 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
524 | #endif | 524 | #endif |
525 | ); | 525 | ); |
526 | } | 526 | } |
527 | 527 | ||
528 | void KABCore::setContactSelected( const QString &uid ) | 528 | void KABCore::setContactSelected( const QString &uid ) |
529 | { | 529 | { |
530 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 530 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
531 | if ( !mDetails->isHidden() ) | 531 | if ( !mDetails->isHidden() ) |
532 | mDetails->setAddressee( addr ); | 532 | mDetails->setAddressee( addr ); |
533 | 533 | ||
534 | if ( !addr.isEmpty() ) { | 534 | if ( !addr.isEmpty() ) { |
535 | emit contactSelected( addr.formattedName() ); | 535 | emit contactSelected( addr.formattedName() ); |
536 | KABC::Picture pic = addr.photo(); | 536 | KABC::Picture pic = addr.photo(); |
537 | if ( pic.isIntern() ) { | 537 | if ( pic.isIntern() ) { |
538 | //US emit contactSelected( pic.data() ); | 538 | //US emit contactSelected( pic.data() ); |
539 | //US instead use: | 539 | //US instead use: |
540 | QPixmap px; | 540 | QPixmap px; |
541 | if (pic.data().isNull() != true) | 541 | if (pic.data().isNull() != true) |
542 | { | 542 | { |
543 | px.convertFromImage(pic.data()); | 543 | px.convertFromImage(pic.data()); |
544 | } | 544 | } |
545 | 545 | ||
546 | emit contactSelected( px ); | 546 | emit contactSelected( px ); |
547 | } | 547 | } |
548 | } | 548 | } |
549 | 549 | ||
550 | 550 | ||
551 | mExtensionManager->setSelectionChanged(); | 551 | mExtensionManager->setSelectionChanged(); |
552 | 552 | ||
553 | // update the actions | 553 | // update the actions |
554 | bool selected = !uid.isEmpty(); | 554 | bool selected = !uid.isEmpty(); |
555 | 555 | ||
556 | if ( mReadWrite ) { | 556 | if ( mReadWrite ) { |
557 | mActionCut->setEnabled( selected ); | 557 | mActionCut->setEnabled( selected ); |
558 | mActionPaste->setEnabled( selected ); | 558 | mActionPaste->setEnabled( selected ); |
559 | } | 559 | } |
560 | 560 | ||
561 | mActionCopy->setEnabled( selected ); | 561 | mActionCopy->setEnabled( selected ); |
562 | mActionDelete->setEnabled( selected ); | 562 | mActionDelete->setEnabled( selected ); |
563 | mActionEditAddressee->setEnabled( selected ); | 563 | mActionEditAddressee->setEnabled( selected ); |
564 | mActionMail->setEnabled( selected ); | 564 | mActionMail->setEnabled( selected ); |
565 | mActionMailVCard->setEnabled( selected ); | 565 | mActionMailVCard->setEnabled( selected ); |
566 | //if (mActionBeam) | 566 | //if (mActionBeam) |
567 | //mActionBeam->setEnabled( selected ); | 567 | //mActionBeam->setEnabled( selected ); |
568 | 568 | ||
569 | if (mActionBeamVCard) | 569 | if (mActionBeamVCard) |
570 | mActionBeamVCard->setEnabled( selected ); | 570 | mActionBeamVCard->setEnabled( selected ); |
571 | 571 | ||
572 | mActionExport2phone->setEnabled( selected ); | 572 | mActionExport2phone->setEnabled( selected ); |
573 | mActionWhoAmI->setEnabled( selected ); | 573 | mActionWhoAmI->setEnabled( selected ); |
574 | mActionCategories->setEnabled( selected ); | 574 | mActionCategories->setEnabled( selected ); |
575 | } | 575 | } |
576 | 576 | ||
577 | void KABCore::sendMail() | 577 | void KABCore::sendMail() |
578 | { | 578 | { |
579 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 579 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
580 | } | 580 | } |
581 | 581 | ||
582 | void KABCore::sendMail( const QString& emaillist ) | 582 | void KABCore::sendMail( const QString& emaillist ) |
583 | { | 583 | { |
584 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 584 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
585 | if (emaillist.contains(",") > 0) | 585 | if (emaillist.contains(",") > 0) |
586 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 586 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
587 | else | 587 | else |
588 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 588 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
589 | } | 589 | } |
590 | 590 | ||
591 | 591 | ||
592 | 592 | ||
593 | void KABCore::mailVCard() | 593 | void KABCore::mailVCard() |
594 | { | 594 | { |
595 | QStringList uids = mViewManager->selectedUids(); | 595 | QStringList uids = mViewManager->selectedUids(); |
596 | if ( !uids.isEmpty() ) | 596 | if ( !uids.isEmpty() ) |
597 | mailVCard( uids ); | 597 | mailVCard( uids ); |
598 | } | 598 | } |
599 | 599 | ||
600 | void KABCore::mailVCard( const QStringList& uids ) | 600 | void KABCore::mailVCard( const QStringList& uids ) |
601 | { | 601 | { |
602 | QStringList urls; | 602 | QStringList urls; |
603 | 603 | ||
604 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 604 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
605 | 605 | ||
606 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 606 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
607 | 607 | ||
608 | 608 | ||
609 | 609 | ||
610 | QDir().mkdir( dirName, true ); | 610 | QDir().mkdir( dirName, true ); |
611 | 611 | ||
612 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 612 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
613 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 613 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
614 | 614 | ||
615 | if ( a.isEmpty() ) | 615 | if ( a.isEmpty() ) |
616 | continue; | 616 | continue; |
617 | 617 | ||
618 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 618 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
619 | 619 | ||
620 | QString fileName = dirName + "/" + name; | 620 | QString fileName = dirName + "/" + name; |
621 | 621 | ||
622 | QFile outFile(fileName); | 622 | QFile outFile(fileName); |
623 | 623 | ||
624 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 624 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
625 | KABC::VCardConverter converter; | 625 | KABC::VCardConverter converter; |
626 | QString vcard; | 626 | QString vcard; |
627 | 627 | ||
628 | converter.addresseeToVCard( a, vcard ); | 628 | converter.addresseeToVCard( a, vcard ); |
629 | 629 | ||
630 | QTextStream t( &outFile ); // use a text stream | 630 | QTextStream t( &outFile ); // use a text stream |
631 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 631 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
632 | t << vcard; | 632 | t << vcard; |
633 | 633 | ||
634 | outFile.close(); | 634 | outFile.close(); |
635 | 635 | ||
636 | urls.append( fileName ); | 636 | urls.append( fileName ); |
637 | } | 637 | } |
638 | } | 638 | } |
639 | 639 | ||
640 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 640 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
641 | 641 | ||
642 | 642 | ||
643 | /*US | 643 | /*US |
644 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 644 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
645 | QString::null, // subject | 645 | QString::null, // subject |
646 | QString::null, // body | 646 | QString::null, // body |
647 | QString::null, | 647 | QString::null, |
648 | urls ); // attachments | 648 | urls ); // attachments |
649 | */ | 649 | */ |
650 | 650 | ||
651 | } | 651 | } |
652 | 652 | ||
653 | /** | 653 | /** |
654 | Beams the "WhoAmI contact. | 654 | Beams the "WhoAmI contact. |
655 | */ | 655 | */ |
656 | void KABCore::beamMySelf() | 656 | void KABCore::beamMySelf() |
657 | { | 657 | { |
658 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 658 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
659 | if (!a.isEmpty()) | 659 | if (!a.isEmpty()) |
660 | { | 660 | { |
661 | QStringList uids; | 661 | QStringList uids; |
662 | uids << a.uid(); | 662 | uids << a.uid(); |
663 | 663 | ||
664 | beamVCard(uids); | 664 | beamVCard(uids); |
665 | } else { | 665 | } else { |
666 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 666 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
667 | 667 | ||
668 | 668 | ||
669 | } | 669 | } |
670 | } | 670 | } |
671 | 671 | ||
672 | void KABCore::export2phone() | 672 | void KABCore::export2phone() |
673 | { | 673 | { |
674 | 674 | ||
675 | KAex2phonePrefs ex2phone; | 675 | KAex2phonePrefs ex2phone; |
676 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 676 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
677 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 677 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
678 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 678 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
679 | 679 | ||
680 | if ( !ex2phone.exec() ) { | 680 | if ( !ex2phone.exec() ) { |
681 | return; | 681 | return; |
682 | } | 682 | } |
683 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 683 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
684 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 684 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
685 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 685 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
686 | 686 | ||
687 | 687 | ||
688 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 688 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
689 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 689 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
690 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 690 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
691 | 691 | ||
692 | QStringList uids = mViewManager->selectedUids(); | 692 | QStringList uids = mViewManager->selectedUids(); |
693 | if ( uids.isEmpty() ) | 693 | if ( uids.isEmpty() ) |
694 | return; | 694 | return; |
695 | 695 | ||
696 | #ifdef _WIN32_ | 696 | #ifdef _WIN32_ |
697 | QString fileName = locateLocal("tmp", "phonefile.vcf"); | 697 | QString fileName = locateLocal("tmp", "phonefile.vcf"); |
698 | #else | 698 | #else |
699 | QString fileName = "/tmp/phonefile.vcf"; | 699 | QString fileName = "/tmp/phonefile.vcf"; |
700 | #endif | 700 | #endif |
701 | 701 | ||
702 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) | 702 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) |
703 | return; | 703 | return; |
704 | 704 | ||
705 | if ( PhoneAccess::writeToPhone( fileName ) ) | 705 | if ( PhoneAccess::writeToPhone( fileName ) ) |
706 | qDebug("Export okay "); | 706 | qDebug("Export okay "); |
707 | else | 707 | else |
708 | qDebug("Error export contacts "); | 708 | qDebug("Error export contacts "); |
709 | 709 | ||
710 | 710 | ||
711 | #if 0 | 711 | #if 0 |
712 | 712 | ||
713 | setCaption( i18n("Writing to phone...")); | 713 | setCaption( i18n("Writing to phone...")); |
714 | if ( PhoneFormat::writeToPhone( cal ) ) | 714 | if ( PhoneFormat::writeToPhone( cal ) ) |
715 | setCaption( i18n("Export to phone successful!")); | 715 | setCaption( i18n("Export to phone successful!")); |
716 | else | 716 | else |
717 | setCaption( i18n("Error exporting to phone!")); | 717 | setCaption( i18n("Error exporting to phone!")); |
718 | #endif | 718 | #endif |
719 | 719 | ||
720 | 720 | ||
721 | } | 721 | } |
722 | void KABCore::beamVCard() | 722 | void KABCore::beamVCard() |
723 | { | 723 | { |
724 | QStringList uids = mViewManager->selectedUids(); | 724 | QStringList uids = mViewManager->selectedUids(); |
725 | if ( !uids.isEmpty() ) | 725 | if ( !uids.isEmpty() ) |
726 | beamVCard( uids ); | 726 | beamVCard( uids ); |
727 | } | 727 | } |
728 | 728 | ||
729 | 729 | ||
730 | void KABCore::beamVCard(const QStringList& uids) | 730 | void KABCore::beamVCard(const QStringList& uids) |
731 | { | 731 | { |
732 | /*US | 732 | /*US |
733 | QString beamFilename; | 733 | QString beamFilename; |
734 | Opie::OPimContact c; | 734 | Opie::OPimContact c; |
735 | if ( actionPersonal->isOn() ) { | 735 | if ( actionPersonal->isOn() ) { |
736 | beamFilename = addressbookPersonalVCardName(); | 736 | beamFilename = addressbookPersonalVCardName(); |
737 | if ( !QFile::exists( beamFilename ) ) | 737 | if ( !QFile::exists( beamFilename ) ) |
738 | return; // can't beam a non-existent file | 738 | return; // can't beam a non-existent file |
739 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 739 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
740 | beamFilename ); | 740 | beamFilename ); |
741 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 741 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
742 | Opie::OPimContactAccess::List allList = access->allRecords(); | 742 | Opie::OPimContactAccess::List allList = access->allRecords(); |
743 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first | 743 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first |
744 | c = *it; | 744 | c = *it; |
745 | 745 | ||
746 | delete access; | 746 | delete access; |
747 | } else { | 747 | } else { |
748 | unlink( beamfile ); // delete if exists | 748 | unlink( beamfile ); // delete if exists |
749 | mkdir("/tmp/obex/", 0755); | 749 | mkdir("/tmp/obex/", 0755); |
750 | c = m_abView -> currentEntry(); | 750 | c = m_abView -> currentEntry(); |
751 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 751 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
752 | beamfile ); | 752 | beamfile ); |
753 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 753 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
754 | access->add( c ); | 754 | access->add( c ); |
755 | access->save(); | 755 | access->save(); |
756 | delete access; | 756 | delete access; |
757 | 757 | ||
758 | beamFilename = beamfile; | 758 | beamFilename = beamfile; |
759 | } | 759 | } |
760 | 760 | ||
761 | owarn << "Beaming: " << beamFilename << oendl; | 761 | owarn << "Beaming: " << beamFilename << oendl; |
762 | */ | 762 | */ |
763 | 763 | ||
764 | #if 0 | 764 | #if 0 |
765 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 765 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
766 | 766 | ||
767 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); | 767 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); |
768 | 768 | ||
769 | QString name = "contact.vcf"; | 769 | QString name = "contact.vcf"; |
770 | 770 | ||
771 | QString fileName = dirName + "/" + name; | 771 | QString fileName = dirName + "/" + name; |
772 | #endif | 772 | #endif |
773 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory | 773 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory |
774 | // | 774 | // |
775 | QString fileName = "/tmp/kapibeamfile.vcf"; | 775 | QString fileName = "/tmp/kapibeamfile.vcf"; |
776 | 776 | ||
777 | 777 | ||
778 | //QDir().mkdir( dirName, true ); | 778 | //QDir().mkdir( dirName, true ); |
779 | 779 | ||
780 | 780 | ||
781 | KABC::VCardConverter converter; | 781 | KABC::VCardConverter converter; |
782 | QString description; | 782 | QString description; |
783 | QString datastream; | 783 | QString datastream; |
784 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 784 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
785 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 785 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
786 | 786 | ||
787 | if ( a.isEmpty() ) | 787 | if ( a.isEmpty() ) |
788 | continue; | 788 | continue; |
789 | 789 | ||
790 | if (description.isEmpty()) | 790 | if (description.isEmpty()) |
791 | description = a.formattedName(); | 791 | description = a.formattedName(); |
792 | 792 | ||
793 | QString vcard; | 793 | QString vcard; |
794 | converter.addresseeToVCard( a, vcard ); | 794 | converter.addresseeToVCard( a, vcard ); |
795 | int start = 0; | 795 | int start = 0; |
796 | int next; | 796 | int next; |
797 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 797 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
798 | int semi = vcard.find(";", next); | 798 | int semi = vcard.find(";", next); |
799 | int dopp = vcard.find(":", next); | 799 | int dopp = vcard.find(":", next); |
800 | int sep; | 800 | int sep; |
801 | if ( semi < dopp && semi >= 0 ) | 801 | if ( semi < dopp && semi >= 0 ) |
802 | sep = semi ; | 802 | sep = semi ; |
803 | else | 803 | else |
804 | sep = dopp; | 804 | sep = dopp; |
805 | datastream +=vcard.mid( start, next - start); | 805 | datastream +=vcard.mid( start, next - start); |
806 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 806 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
807 | start = sep; | 807 | start = sep; |
808 | } | 808 | } |
809 | datastream += vcard.mid( start,vcard.length() ); | 809 | datastream += vcard.mid( start,vcard.length() ); |
810 | } | 810 | } |
811 | #ifndef DESKTOP_VERSION | 811 | #ifndef DESKTOP_VERSION |
812 | QFile outFile(fileName); | 812 | QFile outFile(fileName); |
813 | if ( outFile.open(IO_WriteOnly) ) { | 813 | if ( outFile.open(IO_WriteOnly) ) { |
814 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 814 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
815 | QTextStream t( &outFile ); // use a text stream | 815 | QTextStream t( &outFile ); // use a text stream |
816 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 816 | //t.setEncoding( QTextStream::UnicodeUTF8 ); |
817 | t <<datastream; | 817 | t.setEncoding( QTextStream::Latin1 ); |
818 | t <<datastream.latin1(); | ||
818 | outFile.close(); | 819 | outFile.close(); |
819 | Ir *ir = new Ir( this ); | 820 | Ir *ir = new Ir( this ); |
820 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 821 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
821 | ir->send( fileName, description, "text/x-vCard" ); | 822 | ir->send( fileName, description, "text/x-vCard" ); |
822 | } else { | 823 | } else { |
823 | qDebug("Error open temp beam file "); | 824 | qDebug("Error open temp beam file "); |
824 | return; | 825 | return; |
825 | } | 826 | } |
826 | #endif | 827 | #endif |
827 | 828 | ||
828 | } | 829 | } |
829 | 830 | ||
830 | void KABCore::beamDone( Ir *ir ) | 831 | void KABCore::beamDone( Ir *ir ) |
831 | { | 832 | { |
832 | #ifndef DESKTOP_VERSION | 833 | #ifndef DESKTOP_VERSION |
833 | delete ir; | 834 | delete ir; |
834 | #endif | 835 | #endif |
836 | topLevelWidget()->raise(); | ||
835 | } | 837 | } |
836 | 838 | ||
837 | 839 | ||
838 | void KABCore::browse( const QString& url ) | 840 | void KABCore::browse( const QString& url ) |
839 | { | 841 | { |
840 | #ifndef KAB_EMBEDDED | 842 | #ifndef KAB_EMBEDDED |
841 | kapp->invokeBrowser( url ); | 843 | kapp->invokeBrowser( url ); |
842 | #else //KAB_EMBEDDED | 844 | #else //KAB_EMBEDDED |
843 | qDebug("KABCore::browse must be fixed"); | 845 | qDebug("KABCore::browse must be fixed"); |
844 | #endif //KAB_EMBEDDED | 846 | #endif //KAB_EMBEDDED |
845 | } | 847 | } |
846 | 848 | ||
847 | void KABCore::selectAllContacts() | 849 | void KABCore::selectAllContacts() |
848 | { | 850 | { |
849 | mViewManager->setSelected( QString::null, true ); | 851 | mViewManager->setSelected( QString::null, true ); |
850 | } | 852 | } |
851 | 853 | ||
852 | void KABCore::deleteContacts() | 854 | void KABCore::deleteContacts() |
853 | { | 855 | { |
854 | QStringList uidList = mViewManager->selectedUids(); | 856 | QStringList uidList = mViewManager->selectedUids(); |
855 | deleteContacts( uidList ); | 857 | deleteContacts( uidList ); |
856 | } | 858 | } |
857 | 859 | ||
858 | void KABCore::deleteContacts( const QStringList &uids ) | 860 | void KABCore::deleteContacts( const QStringList &uids ) |
859 | { | 861 | { |
860 | if ( uids.count() > 0 ) { | 862 | if ( uids.count() > 0 ) { |
861 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 863 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
862 | UndoStack::instance()->push( command ); | 864 | UndoStack::instance()->push( command ); |
863 | RedoStack::instance()->clear(); | 865 | RedoStack::instance()->clear(); |
864 | 866 | ||
865 | // now if we deleted anything, refresh | 867 | // now if we deleted anything, refresh |
866 | setContactSelected( QString::null ); | 868 | setContactSelected( QString::null ); |
867 | setModified( true ); | 869 | setModified( true ); |
868 | } | 870 | } |
869 | } | 871 | } |
870 | 872 | ||
871 | void KABCore::copyContacts() | 873 | void KABCore::copyContacts() |
872 | { | 874 | { |
873 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 875 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
874 | 876 | ||
875 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 877 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
876 | 878 | ||
877 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 879 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
878 | 880 | ||
879 | QClipboard *cb = QApplication::clipboard(); | 881 | QClipboard *cb = QApplication::clipboard(); |
880 | cb->setText( clipText ); | 882 | cb->setText( clipText ); |
881 | } | 883 | } |
882 | 884 | ||
883 | void KABCore::cutContacts() | 885 | void KABCore::cutContacts() |
884 | { | 886 | { |
885 | QStringList uidList = mViewManager->selectedUids(); | 887 | QStringList uidList = mViewManager->selectedUids(); |
886 | 888 | ||
887 | //US if ( uidList.size() > 0 ) { | 889 | //US if ( uidList.size() > 0 ) { |
888 | if ( uidList.count() > 0 ) { | 890 | if ( uidList.count() > 0 ) { |
889 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 891 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
890 | UndoStack::instance()->push( command ); | 892 | UndoStack::instance()->push( command ); |
891 | RedoStack::instance()->clear(); | 893 | RedoStack::instance()->clear(); |
892 | 894 | ||
893 | setModified( true ); | 895 | setModified( true ); |
894 | } | 896 | } |
895 | } | 897 | } |
896 | 898 | ||
897 | void KABCore::pasteContacts() | 899 | void KABCore::pasteContacts() |
898 | { | 900 | { |
899 | QClipboard *cb = QApplication::clipboard(); | 901 | QClipboard *cb = QApplication::clipboard(); |
900 | 902 | ||
901 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 903 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
902 | 904 | ||
903 | pasteContacts( list ); | 905 | pasteContacts( list ); |
904 | } | 906 | } |
905 | 907 | ||
906 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 908 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
907 | { | 909 | { |
908 | KABC::Resource *resource = requestResource( this ); | 910 | KABC::Resource *resource = requestResource( this ); |
909 | KABC::Addressee::List::Iterator it; | 911 | KABC::Addressee::List::Iterator it; |
910 | for ( it = list.begin(); it != list.end(); ++it ) | 912 | for ( it = list.begin(); it != list.end(); ++it ) |
911 | (*it).setResource( resource ); | 913 | (*it).setResource( resource ); |
912 | 914 | ||
913 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 915 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
914 | UndoStack::instance()->push( command ); | 916 | UndoStack::instance()->push( command ); |
915 | RedoStack::instance()->clear(); | 917 | RedoStack::instance()->clear(); |
916 | 918 | ||
917 | setModified( true ); | 919 | setModified( true ); |
918 | } | 920 | } |
919 | 921 | ||
920 | void KABCore::setWhoAmI() | 922 | void KABCore::setWhoAmI() |
921 | { | 923 | { |
922 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 924 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
923 | 925 | ||
924 | if ( addrList.count() > 1 ) { | 926 | if ( addrList.count() > 1 ) { |
925 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 927 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
926 | return; | 928 | return; |
927 | } | 929 | } |
928 | 930 | ||
929 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 931 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
930 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 932 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
931 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 933 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
932 | } | 934 | } |
933 | 935 | ||
934 | void KABCore::setCategories() | 936 | void KABCore::setCategories() |
935 | { | 937 | { |
936 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 938 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
937 | if ( !dlg.exec() ) | 939 | if ( !dlg.exec() ) |
938 | return; | 940 | return; |
939 | 941 | ||
940 | bool merge = false; | 942 | bool merge = false; |
941 | QString msg = i18n( "Merge with existing categories?" ); | 943 | QString msg = i18n( "Merge with existing categories?" ); |
942 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 944 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
943 | merge = true; | 945 | merge = true; |
944 | 946 | ||
945 | QStringList categories = dlg.selectedCategories(); | 947 | QStringList categories = dlg.selectedCategories(); |
946 | 948 | ||
947 | QStringList uids = mViewManager->selectedUids(); | 949 | QStringList uids = mViewManager->selectedUids(); |
948 | QStringList::Iterator it; | 950 | QStringList::Iterator it; |
949 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 951 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
950 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 952 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
951 | if ( !addr.isEmpty() ) { | 953 | if ( !addr.isEmpty() ) { |
952 | if ( !merge ) | 954 | if ( !merge ) |
953 | addr.setCategories( categories ); | 955 | addr.setCategories( categories ); |
954 | else { | 956 | else { |
955 | QStringList addrCategories = addr.categories(); | 957 | QStringList addrCategories = addr.categories(); |
956 | QStringList::Iterator catIt; | 958 | QStringList::Iterator catIt; |
957 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 959 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
958 | if ( !addrCategories.contains( *catIt ) ) | 960 | if ( !addrCategories.contains( *catIt ) ) |
959 | addrCategories.append( *catIt ); | 961 | addrCategories.append( *catIt ); |
960 | } | 962 | } |
961 | addr.setCategories( addrCategories ); | 963 | addr.setCategories( addrCategories ); |
962 | } | 964 | } |
963 | 965 | ||
964 | mAddressBook->insertAddressee( addr ); | 966 | mAddressBook->insertAddressee( addr ); |
965 | } | 967 | } |
966 | } | 968 | } |
967 | 969 | ||
968 | if ( uids.count() > 0 ) | 970 | if ( uids.count() > 0 ) |
969 | setModified( true ); | 971 | setModified( true ); |
970 | } | 972 | } |
971 | 973 | ||
972 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 974 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
973 | { | 975 | { |
974 | mIncSearchWidget->setFields( fields ); | 976 | mIncSearchWidget->setFields( fields ); |
975 | } | 977 | } |
976 | 978 | ||
977 | void KABCore::incrementalSearch( const QString& text ) | 979 | void KABCore::incrementalSearch( const QString& text ) |
978 | { | 980 | { |
979 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); | 981 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); |
980 | } | 982 | } |
981 | 983 | ||
982 | void KABCore::setModified() | 984 | void KABCore::setModified() |
983 | { | 985 | { |
984 | setModified( true ); | 986 | setModified( true ); |
985 | } | 987 | } |
986 | 988 | ||
987 | void KABCore::setModifiedWOrefresh() | 989 | void KABCore::setModifiedWOrefresh() |
988 | { | 990 | { |
989 | // qDebug("KABCore::setModifiedWOrefresh() "); | 991 | // qDebug("KABCore::setModifiedWOrefresh() "); |
990 | mModified = true; | 992 | mModified = true; |
991 | mActionSave->setEnabled( mModified ); | 993 | mActionSave->setEnabled( mModified ); |
992 | #ifdef DESKTOP_VERSION | 994 | #ifdef DESKTOP_VERSION |
993 | mDetails->refreshView(); | 995 | mDetails->refreshView(); |
994 | #endif | 996 | #endif |
995 | 997 | ||
996 | } | 998 | } |
997 | void KABCore::setModified( bool modified ) | 999 | void KABCore::setModified( bool modified ) |
998 | { | 1000 | { |
999 | mModified = modified; | 1001 | mModified = modified; |
1000 | mActionSave->setEnabled( mModified ); | 1002 | mActionSave->setEnabled( mModified ); |
1001 | 1003 | ||
1002 | if ( modified ) | 1004 | if ( modified ) |
1003 | mJumpButtonBar->recreateButtons(); | 1005 | mJumpButtonBar->recreateButtons(); |
1004 | 1006 | ||
1005 | mViewManager->refreshView(); | 1007 | mViewManager->refreshView(); |
1006 | mDetails->refreshView(); | 1008 | mDetails->refreshView(); |
1007 | 1009 | ||
1008 | } | 1010 | } |
1009 | 1011 | ||
1010 | bool KABCore::modified() const | 1012 | bool KABCore::modified() const |
1011 | { | 1013 | { |
1012 | return mModified; | 1014 | return mModified; |
1013 | } | 1015 | } |
1014 | 1016 | ||
1015 | void KABCore::contactModified( const KABC::Addressee &addr ) | 1017 | void KABCore::contactModified( const KABC::Addressee &addr ) |
1016 | { | 1018 | { |
1017 | 1019 | ||
1018 | Command *command = 0; | 1020 | Command *command = 0; |
1019 | QString uid; | 1021 | QString uid; |
1020 | 1022 | ||
1021 | // check if it exists already | 1023 | // check if it exists already |
1022 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 1024 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
1023 | if ( origAddr.isEmpty() ) | 1025 | if ( origAddr.isEmpty() ) |
1024 | command = new PwNewCommand( mAddressBook, addr ); | 1026 | command = new PwNewCommand( mAddressBook, addr ); |
1025 | else { | 1027 | else { |
1026 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 1028 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
1027 | uid = addr.uid(); | 1029 | uid = addr.uid(); |
1028 | } | 1030 | } |
1029 | 1031 | ||
1030 | UndoStack::instance()->push( command ); | 1032 | UndoStack::instance()->push( command ); |
1031 | RedoStack::instance()->clear(); | 1033 | RedoStack::instance()->clear(); |
1032 | 1034 | ||
1033 | setModified( true ); | 1035 | setModified( true ); |
1034 | } | 1036 | } |
1035 | 1037 | ||
1036 | void KABCore::newContact() | 1038 | void KABCore::newContact() |
1037 | { | 1039 | { |
1038 | 1040 | ||
1039 | 1041 | ||
1040 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 1042 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
1041 | 1043 | ||
1042 | QPtrList<KRES::Resource> kresResources; | 1044 | QPtrList<KRES::Resource> kresResources; |
1043 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 1045 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
1044 | KABC::Resource *resource; | 1046 | KABC::Resource *resource; |
1045 | while ( ( resource = it.current() ) != 0 ) { | 1047 | while ( ( resource = it.current() ) != 0 ) { |
1046 | ++it; | 1048 | ++it; |
1047 | if ( !resource->readOnly() ) { | 1049 | if ( !resource->readOnly() ) { |
1048 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 1050 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
1049 | if ( res ) | 1051 | if ( res ) |
1050 | kresResources.append( res ); | 1052 | kresResources.append( res ); |
1051 | } | 1053 | } |
1052 | } | 1054 | } |
1053 | 1055 | ||
1054 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 1056 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
1055 | resource = static_cast<KABC::Resource*>( res ); | 1057 | resource = static_cast<KABC::Resource*>( res ); |
1056 | 1058 | ||
1057 | if ( resource ) { | 1059 | if ( resource ) { |
1058 | KABC::Addressee addr; | 1060 | KABC::Addressee addr; |
1059 | addr.setResource( resource ); | 1061 | addr.setResource( resource ); |
1060 | mEditorDialog->setAddressee( addr ); | 1062 | mEditorDialog->setAddressee( addr ); |
1061 | KApplication::execDialog ( mEditorDialog ); | 1063 | KApplication::execDialog ( mEditorDialog ); |
1062 | 1064 | ||
1063 | } else | 1065 | } else |
1064 | return; | 1066 | return; |
1065 | 1067 | ||
1066 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 1068 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
1067 | 1069 | ||
1068 | 1070 | ||
1069 | } | 1071 | } |
1070 | 1072 | ||
1071 | void KABCore::addEmail( QString aStr ) | 1073 | void KABCore::addEmail( QString aStr ) |
1072 | { | 1074 | { |
1073 | #ifndef KAB_EMBEDDED | 1075 | #ifndef KAB_EMBEDDED |
1074 | QString fullName, email; | 1076 | QString fullName, email; |
1075 | 1077 | ||
1076 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 1078 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
1077 | 1079 | ||
1078 | // Try to lookup the addressee matching the email address | 1080 | // Try to lookup the addressee matching the email address |
1079 | bool found = false; | 1081 | bool found = false; |
1080 | QStringList emailList; | 1082 | QStringList emailList; |
1081 | KABC::AddressBook::Iterator it; | 1083 | KABC::AddressBook::Iterator it; |
1082 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 1084 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
1083 | emailList = (*it).emails(); | 1085 | emailList = (*it).emails(); |
1084 | if ( emailList.contains( email ) > 0 ) { | 1086 | if ( emailList.contains( email ) > 0 ) { |
1085 | found = true; | 1087 | found = true; |
1086 | (*it).setNameFromString( fullName ); | 1088 | (*it).setNameFromString( fullName ); |
1087 | editContact( (*it).uid() ); | 1089 | editContact( (*it).uid() ); |
1088 | } | 1090 | } |
1089 | } | 1091 | } |
1090 | 1092 | ||
1091 | if ( !found ) { | 1093 | if ( !found ) { |
1092 | KABC::Addressee addr; | 1094 | KABC::Addressee addr; |
1093 | addr.setNameFromString( fullName ); | 1095 | addr.setNameFromString( fullName ); |
1094 | addr.insertEmail( email, true ); | 1096 | addr.insertEmail( email, true ); |
1095 | 1097 | ||
1096 | mAddressBook->insertAddressee( addr ); | 1098 | mAddressBook->insertAddressee( addr ); |
1097 | mViewManager->refreshView( addr.uid() ); | 1099 | mViewManager->refreshView( addr.uid() ); |
1098 | editContact( addr.uid() ); | 1100 | editContact( addr.uid() ); |
1099 | } | 1101 | } |
1100 | #else //KAB_EMBEDDED | 1102 | #else //KAB_EMBEDDED |
1101 | qDebug("KABCore::addEmail finsih method"); | 1103 | qDebug("KABCore::addEmail finsih method"); |
1102 | #endif //KAB_EMBEDDED | 1104 | #endif //KAB_EMBEDDED |
1103 | } | 1105 | } |
1104 | 1106 | ||
1105 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 1107 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
1106 | { | 1108 | { |
1107 | mXXPortManager->importVCard( url, showPreview ); | 1109 | mXXPortManager->importVCard( url, showPreview ); |
1108 | } | 1110 | } |
1109 | void KABCore::importFromOL() | 1111 | void KABCore::importFromOL() |
1110 | { | 1112 | { |
1111 | #ifdef _WIN32_ | 1113 | #ifdef _WIN32_ |
1112 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 1114 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
1113 | idgl->exec(); | 1115 | idgl->exec(); |
1114 | KABC::Addressee::List list = idgl->getAddressList(); | 1116 | KABC::Addressee::List list = idgl->getAddressList(); |
1115 | if ( list.count() > 0 ) { | 1117 | if ( list.count() > 0 ) { |
1116 | KABC::Addressee::List listNew; | 1118 | KABC::Addressee::List listNew; |
1117 | KABC::Addressee::List listExisting; | 1119 | KABC::Addressee::List listExisting; |
1118 | KABC::Addressee::List::Iterator it; | 1120 | KABC::Addressee::List::Iterator it; |
1119 | KABC::AddressBook::Iterator iter; | 1121 | KABC::AddressBook::Iterator iter; |
1120 | for ( it = list.begin(); it != list.end(); ++it ) { | 1122 | for ( it = list.begin(); it != list.end(); ++it ) { |
1121 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1123 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1122 | listNew.append( (*it) ); | 1124 | listNew.append( (*it) ); |
1123 | else | 1125 | else |
1124 | listExisting.append( (*it) ); | 1126 | listExisting.append( (*it) ); |
1125 | } | 1127 | } |
1126 | if ( listExisting.count() > 0 ) | 1128 | if ( listExisting.count() > 0 ) |
1127 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1129 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1128 | if ( listNew.count() > 0 ) { | 1130 | if ( listNew.count() > 0 ) { |
1129 | pasteWithNewUid = false; | 1131 | pasteWithNewUid = false; |
1130 | pasteContacts( listNew ); | 1132 | pasteContacts( listNew ); |
1131 | pasteWithNewUid = true; | 1133 | pasteWithNewUid = true; |
1132 | } | 1134 | } |
1133 | } | 1135 | } |
1134 | delete idgl; | 1136 | delete idgl; |
1135 | #endif | 1137 | #endif |
1136 | } | 1138 | } |
1137 | 1139 | ||
1138 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1140 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1139 | { | 1141 | { |
1140 | mXXPortManager->importVCard( vCard, showPreview ); | 1142 | mXXPortManager->importVCard( vCard, showPreview ); |
1141 | } | 1143 | } |
1142 | 1144 | ||
1143 | //US added a second method without defaultparameter | 1145 | //US added a second method without defaultparameter |
1144 | void KABCore::editContact2() { | 1146 | void KABCore::editContact2() { |
1145 | editContact( QString::null ); | 1147 | editContact( QString::null ); |
1146 | } | 1148 | } |
1147 | 1149 | ||
1148 | void KABCore::editContact( const QString &uid ) | 1150 | void KABCore::editContact( const QString &uid ) |
1149 | { | 1151 | { |
1150 | 1152 | ||
1151 | if ( mExtensionManager->isQuickEditVisible() ) | 1153 | if ( mExtensionManager->isQuickEditVisible() ) |
1152 | return; | 1154 | return; |
1153 | 1155 | ||
1154 | // First, locate the contact entry | 1156 | // First, locate the contact entry |
1155 | QString localUID = uid; | 1157 | QString localUID = uid; |
1156 | if ( localUID.isNull() ) { | 1158 | if ( localUID.isNull() ) { |
1157 | QStringList uidList = mViewManager->selectedUids(); | 1159 | QStringList uidList = mViewManager->selectedUids(); |
1158 | if ( uidList.count() > 0 ) | 1160 | if ( uidList.count() > 0 ) |
1159 | localUID = *( uidList.at( 0 ) ); | 1161 | localUID = *( uidList.at( 0 ) ); |
1160 | } | 1162 | } |
1161 | 1163 | ||
1162 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1164 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1163 | if ( !addr.isEmpty() ) { | 1165 | if ( !addr.isEmpty() ) { |
1164 | mEditorDialog->setAddressee( addr ); | 1166 | mEditorDialog->setAddressee( addr ); |
1165 | KApplication::execDialog ( mEditorDialog ); | 1167 | KApplication::execDialog ( mEditorDialog ); |
1166 | } | 1168 | } |
1167 | } | 1169 | } |
1168 | 1170 | ||
1169 | /** | 1171 | /** |
1170 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1172 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1171 | the method will try to find a selected addressee in the view. | 1173 | the method will try to find a selected addressee in the view. |
1172 | */ | 1174 | */ |
1173 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1175 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1174 | { | 1176 | { |
1175 | if ( mMultipleViewsAtOnce ) | 1177 | if ( mMultipleViewsAtOnce ) |
1176 | { | 1178 | { |
1177 | editContact( uid ); | 1179 | editContact( uid ); |
1178 | } | 1180 | } |
1179 | else | 1181 | else |
1180 | { | 1182 | { |
1181 | setDetailsVisible( true ); | 1183 | setDetailsVisible( true ); |
1182 | mActionDetails->setChecked(true); | 1184 | mActionDetails->setChecked(true); |
1183 | } | 1185 | } |
1184 | 1186 | ||
1185 | } | 1187 | } |
1186 | 1188 | ||
1187 | void KABCore::save() | 1189 | void KABCore::save() |
1188 | { | 1190 | { |
1189 | if (syncManager->blockSave()) | 1191 | if (syncManager->blockSave()) |
1190 | return; | 1192 | return; |
1191 | if ( !mModified ) | 1193 | if ( !mModified ) |
1192 | return; | 1194 | return; |
1193 | 1195 | ||
1194 | syncManager->setBlockSave(true); | 1196 | syncManager->setBlockSave(true); |
1195 | QString text = i18n( "There was an error while attempting to save\n the " | 1197 | QString text = i18n( "There was an error while attempting to save\n the " |
1196 | "address book. Please check that some \nother application is " | 1198 | "address book. Please check that some \nother application is " |
1197 | "not using it. " ); | 1199 | "not using it. " ); |
1198 | statusMessage(i18n("Saving addressbook ... ")); | 1200 | statusMessage(i18n("Saving addressbook ... ")); |
1199 | #ifndef KAB_EMBEDDED | 1201 | #ifndef KAB_EMBEDDED |
1200 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1202 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1201 | if ( !b || !b->save() ) { | 1203 | if ( !b || !b->save() ) { |
1202 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1204 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1203 | } | 1205 | } |
1204 | #else //KAB_EMBEDDED | 1206 | #else //KAB_EMBEDDED |
1205 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1207 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1206 | if ( !b || !b->save() ) { | 1208 | if ( !b || !b->save() ) { |
1207 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1209 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1208 | } | 1210 | } |
1209 | #endif //KAB_EMBEDDED | 1211 | #endif //KAB_EMBEDDED |
1210 | 1212 | ||
1211 | statusMessage(i18n("Addressbook saved!")); | 1213 | statusMessage(i18n("Addressbook saved!")); |
1212 | setModified( false ); | 1214 | setModified( false ); |
1213 | syncManager->setBlockSave(false); | 1215 | syncManager->setBlockSave(false); |
1214 | } | 1216 | } |
1215 | 1217 | ||
1216 | void KABCore::statusMessage(QString mess , int time ) | 1218 | void KABCore::statusMessage(QString mess , int time ) |
1217 | { | 1219 | { |
1218 | //topLevelWidget()->setCaption( mess ); | 1220 | //topLevelWidget()->setCaption( mess ); |
1219 | // pending setting timer to revome message | 1221 | // pending setting timer to revome message |
1220 | } | 1222 | } |
1221 | void KABCore::undo() | 1223 | void KABCore::undo() |
1222 | { | 1224 | { |
1223 | UndoStack::instance()->undo(); | 1225 | UndoStack::instance()->undo(); |
1224 | 1226 | ||
1225 | // Refresh the view | 1227 | // Refresh the view |
1226 | mViewManager->refreshView(); | 1228 | mViewManager->refreshView(); |
1227 | } | 1229 | } |
1228 | 1230 | ||
1229 | void KABCore::redo() | 1231 | void KABCore::redo() |
1230 | { | 1232 | { |
1231 | RedoStack::instance()->redo(); | 1233 | RedoStack::instance()->redo(); |
1232 | 1234 | ||
1233 | // Refresh the view | 1235 | // Refresh the view |
1234 | mViewManager->refreshView(); | 1236 | mViewManager->refreshView(); |
1235 | } | 1237 | } |
1236 | 1238 | ||
1237 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1239 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1238 | { | 1240 | { |
1239 | if (mMultipleViewsAtOnce) | 1241 | if (mMultipleViewsAtOnce) |
1240 | { | 1242 | { |
1241 | if ( visible ) | 1243 | if ( visible ) |
1242 | mJumpButtonBar->show(); | 1244 | mJumpButtonBar->show(); |
1243 | else | 1245 | else |
1244 | mJumpButtonBar->hide(); | 1246 | mJumpButtonBar->hide(); |
1245 | } | 1247 | } |
1246 | else | 1248 | else |
1247 | { | 1249 | { |
1248 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1250 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1249 | if (mViewManager->isVisible()) | 1251 | if (mViewManager->isVisible()) |
1250 | { | 1252 | { |
1251 | if ( visible ) | 1253 | if ( visible ) |
1252 | mJumpButtonBar->show(); | 1254 | mJumpButtonBar->show(); |
1253 | else | 1255 | else |
1254 | mJumpButtonBar->hide(); | 1256 | mJumpButtonBar->hide(); |
1255 | } | 1257 | } |
1256 | else | 1258 | else |
1257 | { | 1259 | { |
1258 | mJumpButtonBar->hide(); | 1260 | mJumpButtonBar->hide(); |
1259 | } | 1261 | } |
1260 | } | 1262 | } |
1261 | } | 1263 | } |
1262 | 1264 | ||
1263 | 1265 | ||
1264 | void KABCore::setDetailsToState() | 1266 | void KABCore::setDetailsToState() |
1265 | { | 1267 | { |
1266 | setDetailsVisible( mActionDetails->isChecked() ); | 1268 | setDetailsVisible( mActionDetails->isChecked() ); |
1267 | } | 1269 | } |
1268 | 1270 | ||
1269 | 1271 | ||
1270 | 1272 | ||
1271 | void KABCore::setDetailsVisible( bool visible ) | 1273 | void KABCore::setDetailsVisible( bool visible ) |
1272 | { | 1274 | { |
1273 | if (visible && mDetails->isHidden()) | 1275 | if (visible && mDetails->isHidden()) |
1274 | { | 1276 | { |
1275 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1277 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1276 | if ( addrList.count() > 0 ) | 1278 | if ( addrList.count() > 0 ) |
1277 | mDetails->setAddressee( addrList[ 0 ] ); | 1279 | mDetails->setAddressee( addrList[ 0 ] ); |
1278 | } | 1280 | } |
1279 | 1281 | ||
1280 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1282 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1281 | // the listview and the detailview. We do that by changing the splitbar size. | 1283 | // the listview and the detailview. We do that by changing the splitbar size. |
1282 | if (mMultipleViewsAtOnce) | 1284 | if (mMultipleViewsAtOnce) |
1283 | { | 1285 | { |
1284 | if ( visible ) | 1286 | if ( visible ) |
1285 | mDetails->show(); | 1287 | mDetails->show(); |
1286 | else | 1288 | else |
1287 | mDetails->hide(); | 1289 | mDetails->hide(); |
1288 | } | 1290 | } |
1289 | else | 1291 | else |
1290 | { | 1292 | { |
1291 | if ( visible ) { | 1293 | if ( visible ) { |
1292 | mViewManager->hide(); | 1294 | mViewManager->hide(); |
1293 | mDetails->show(); | 1295 | mDetails->show(); |
1294 | } | 1296 | } |
1295 | else { | 1297 | else { |
1296 | mViewManager->show(); | 1298 | mViewManager->show(); |
1297 | mDetails->hide(); | 1299 | mDetails->hide(); |
1298 | } | 1300 | } |
1299 | setJumpButtonBarVisible( !visible ); | 1301 | setJumpButtonBarVisible( !visible ); |
1300 | } | 1302 | } |
1301 | 1303 | ||
1302 | } | 1304 | } |
1303 | 1305 | ||
1304 | void KABCore::extensionChanged( int id ) | 1306 | void KABCore::extensionChanged( int id ) |
1305 | { | 1307 | { |
1306 | //change the details view only for non desktop systems | 1308 | //change the details view only for non desktop systems |
1307 | #ifndef DESKTOP_VERSION | 1309 | #ifndef DESKTOP_VERSION |
1308 | 1310 | ||
1309 | if (id == 0) | 1311 | if (id == 0) |
1310 | { | 1312 | { |
1311 | //the user disabled the extension. | 1313 | //the user disabled the extension. |
1312 | 1314 | ||
1313 | if (mMultipleViewsAtOnce) | 1315 | if (mMultipleViewsAtOnce) |
1314 | { // enable detailsview again | 1316 | { // enable detailsview again |
1315 | setDetailsVisible( true ); | 1317 | setDetailsVisible( true ); |
1316 | mActionDetails->setChecked( true ); | 1318 | mActionDetails->setChecked( true ); |
1317 | } | 1319 | } |
1318 | else | 1320 | else |
1319 | { //go back to the listview | 1321 | { //go back to the listview |
1320 | setDetailsVisible( false ); | 1322 | setDetailsVisible( false ); |
1321 | mActionDetails->setChecked( false ); | 1323 | mActionDetails->setChecked( false ); |
1322 | mActionDetails->setEnabled(true); | 1324 | mActionDetails->setEnabled(true); |
1323 | } | 1325 | } |
1324 | 1326 | ||
1325 | } | 1327 | } |
1326 | else | 1328 | else |
1327 | { | 1329 | { |
1328 | //the user enabled the extension. | 1330 | //the user enabled the extension. |
1329 | setDetailsVisible( false ); | 1331 | setDetailsVisible( false ); |
1330 | mActionDetails->setChecked( false ); | 1332 | mActionDetails->setChecked( false ); |
1331 | 1333 | ||
1332 | if (!mMultipleViewsAtOnce) | 1334 | if (!mMultipleViewsAtOnce) |
1333 | { | 1335 | { |
1334 | mActionDetails->setEnabled(false); | 1336 | mActionDetails->setEnabled(false); |
1335 | } | 1337 | } |
1336 | 1338 | ||
1337 | mExtensionManager->setSelectionChanged(); | 1339 | mExtensionManager->setSelectionChanged(); |
1338 | 1340 | ||
1339 | } | 1341 | } |
1340 | 1342 | ||
1341 | #endif// DESKTOP_VERSION | 1343 | #endif// DESKTOP_VERSION |
1342 | 1344 | ||
1343 | } | 1345 | } |
1344 | 1346 | ||
1345 | 1347 | ||
1346 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1348 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 1f2c6da..3e0a27d 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1814,1054 +1814,1062 @@ void CalendarView::writeSettings() | |||
1814 | config->writeEntry("Separator2",list); | 1814 | config->writeEntry("Separator2",list); |
1815 | #endif | 1815 | #endif |
1816 | 1816 | ||
1817 | mViewManager->writeSettings( config ); | 1817 | mViewManager->writeSettings( config ); |
1818 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1818 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1819 | mDialogManager->writeSettings( config ); | 1819 | mDialogManager->writeSettings( config ); |
1820 | //KOPrefs::instance()->usrWriteConfig(); | 1820 | //KOPrefs::instance()->usrWriteConfig(); |
1821 | KOPrefs::instance()->writeConfig(); | 1821 | KOPrefs::instance()->writeConfig(); |
1822 | 1822 | ||
1823 | writeFilterSettings(config); | 1823 | writeFilterSettings(config); |
1824 | 1824 | ||
1825 | config->setGroup( "Views" ); | 1825 | config->setGroup( "Views" ); |
1826 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1826 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1827 | 1827 | ||
1828 | #ifdef DESKTOP_VERSION | 1828 | #ifdef DESKTOP_VERSION |
1829 | config->setGroup("WidgetLayout"); | 1829 | config->setGroup("WidgetLayout"); |
1830 | QStringList list ;//= config->readListEntry("MainLayout"); | 1830 | QStringList list ;//= config->readListEntry("MainLayout"); |
1831 | int x,y,w,h; | 1831 | int x,y,w,h; |
1832 | QWidget* wid; | 1832 | QWidget* wid; |
1833 | wid = topLevelWidget(); | 1833 | wid = topLevelWidget(); |
1834 | x = wid->geometry().x(); | 1834 | x = wid->geometry().x(); |
1835 | y = wid->geometry().y(); | 1835 | y = wid->geometry().y(); |
1836 | w = wid->width(); | 1836 | w = wid->width(); |
1837 | h = wid->height(); | 1837 | h = wid->height(); |
1838 | list.clear(); | 1838 | list.clear(); |
1839 | list << QString::number( x ); | 1839 | list << QString::number( x ); |
1840 | list << QString::number( y ); | 1840 | list << QString::number( y ); |
1841 | list << QString::number( w ); | 1841 | list << QString::number( w ); |
1842 | list << QString::number( h ); | 1842 | list << QString::number( h ); |
1843 | config->writeEntry("MainLayout",list ); | 1843 | config->writeEntry("MainLayout",list ); |
1844 | 1844 | ||
1845 | wid = mEventEditor; | 1845 | wid = mEventEditor; |
1846 | x = wid->geometry().x(); | 1846 | x = wid->geometry().x(); |
1847 | y = wid->geometry().y(); | 1847 | y = wid->geometry().y(); |
1848 | w = wid->width(); | 1848 | w = wid->width(); |
1849 | h = wid->height(); | 1849 | h = wid->height(); |
1850 | list.clear(); | 1850 | list.clear(); |
1851 | list << QString::number( x ); | 1851 | list << QString::number( x ); |
1852 | list << QString::number( y ); | 1852 | list << QString::number( y ); |
1853 | list << QString::number( w ); | 1853 | list << QString::number( w ); |
1854 | list << QString::number( h ); | 1854 | list << QString::number( h ); |
1855 | config->writeEntry("EditEventLayout",list ); | 1855 | config->writeEntry("EditEventLayout",list ); |
1856 | 1856 | ||
1857 | wid = mTodoEditor; | 1857 | wid = mTodoEditor; |
1858 | x = wid->geometry().x(); | 1858 | x = wid->geometry().x(); |
1859 | y = wid->geometry().y(); | 1859 | y = wid->geometry().y(); |
1860 | w = wid->width(); | 1860 | w = wid->width(); |
1861 | h = wid->height(); | 1861 | h = wid->height(); |
1862 | list.clear(); | 1862 | list.clear(); |
1863 | list << QString::number( x ); | 1863 | list << QString::number( x ); |
1864 | list << QString::number( y ); | 1864 | list << QString::number( y ); |
1865 | list << QString::number( w ); | 1865 | list << QString::number( w ); |
1866 | list << QString::number( h ); | 1866 | list << QString::number( h ); |
1867 | config->writeEntry("EditTodoLayout",list ); | 1867 | config->writeEntry("EditTodoLayout",list ); |
1868 | wid = getEventViewerDialog(); | 1868 | wid = getEventViewerDialog(); |
1869 | x = wid->geometry().x(); | 1869 | x = wid->geometry().x(); |
1870 | y = wid->geometry().y(); | 1870 | y = wid->geometry().y(); |
1871 | w = wid->width(); | 1871 | w = wid->width(); |
1872 | h = wid->height(); | 1872 | h = wid->height(); |
1873 | list.clear(); | 1873 | list.clear(); |
1874 | list << QString::number( x ); | 1874 | list << QString::number( x ); |
1875 | list << QString::number( y ); | 1875 | list << QString::number( y ); |
1876 | list << QString::number( w ); | 1876 | list << QString::number( w ); |
1877 | list << QString::number( h ); | 1877 | list << QString::number( h ); |
1878 | config->writeEntry("ViewerLayout",list ); | 1878 | config->writeEntry("ViewerLayout",list ); |
1879 | wid = mDialogManager->getSearchDialog(); | 1879 | wid = mDialogManager->getSearchDialog(); |
1880 | if ( wid ) { | 1880 | if ( wid ) { |
1881 | x = wid->geometry().x(); | 1881 | x = wid->geometry().x(); |
1882 | y = wid->geometry().y(); | 1882 | y = wid->geometry().y(); |
1883 | w = wid->width(); | 1883 | w = wid->width(); |
1884 | h = wid->height(); | 1884 | h = wid->height(); |
1885 | list.clear(); | 1885 | list.clear(); |
1886 | list << QString::number( x ); | 1886 | list << QString::number( x ); |
1887 | list << QString::number( y ); | 1887 | list << QString::number( y ); |
1888 | list << QString::number( w ); | 1888 | list << QString::number( w ); |
1889 | list << QString::number( h ); | 1889 | list << QString::number( h ); |
1890 | config->writeEntry("SearchLayout",list ); | 1890 | config->writeEntry("SearchLayout",list ); |
1891 | } | 1891 | } |
1892 | #endif | 1892 | #endif |
1893 | 1893 | ||
1894 | 1894 | ||
1895 | config->sync(); | 1895 | config->sync(); |
1896 | } | 1896 | } |
1897 | 1897 | ||
1898 | void CalendarView::readFilterSettings(KConfig *config) | 1898 | void CalendarView::readFilterSettings(KConfig *config) |
1899 | { | 1899 | { |
1900 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1900 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1901 | 1901 | ||
1902 | mFilters.clear(); | 1902 | mFilters.clear(); |
1903 | 1903 | ||
1904 | config->setGroup("General"); | 1904 | config->setGroup("General"); |
1905 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1905 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1906 | 1906 | ||
1907 | QStringList::ConstIterator it = filterList.begin(); | 1907 | QStringList::ConstIterator it = filterList.begin(); |
1908 | QStringList::ConstIterator end = filterList.end(); | 1908 | QStringList::ConstIterator end = filterList.end(); |
1909 | while(it != end) { | 1909 | while(it != end) { |
1910 | // kdDebug() << " filter: " << (*it) << endl; | 1910 | // kdDebug() << " filter: " << (*it) << endl; |
1911 | 1911 | ||
1912 | CalFilter *filter; | 1912 | CalFilter *filter; |
1913 | filter = new CalFilter(*it); | 1913 | filter = new CalFilter(*it); |
1914 | config->setGroup("Filter_" + (*it)); | 1914 | config->setGroup("Filter_" + (*it)); |
1915 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1915 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1916 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1916 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1917 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1917 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1918 | mFilters.append(filter); | 1918 | mFilters.append(filter); |
1919 | 1919 | ||
1920 | ++it; | 1920 | ++it; |
1921 | } | 1921 | } |
1922 | 1922 | ||
1923 | if (mFilters.count() == 0) { | 1923 | if (mFilters.count() == 0) { |
1924 | CalFilter *filter = new CalFilter(i18n("Default")); | 1924 | CalFilter *filter = new CalFilter(i18n("Default")); |
1925 | mFilters.append(filter); | 1925 | mFilters.append(filter); |
1926 | } | 1926 | } |
1927 | mFilterView->updateFilters(); | 1927 | mFilterView->updateFilters(); |
1928 | config->setGroup("FilterView"); | 1928 | config->setGroup("FilterView"); |
1929 | 1929 | ||
1930 | mFilterView->blockSignals(true); | 1930 | mFilterView->blockSignals(true); |
1931 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 1931 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
1932 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 1932 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
1933 | mFilterView->blockSignals(false); | 1933 | mFilterView->blockSignals(false); |
1934 | // We do it manually to avoid it being done twice by the above calls | 1934 | // We do it manually to avoid it being done twice by the above calls |
1935 | updateFilter(); | 1935 | updateFilter(); |
1936 | } | 1936 | } |
1937 | 1937 | ||
1938 | void CalendarView::writeFilterSettings(KConfig *config) | 1938 | void CalendarView::writeFilterSettings(KConfig *config) |
1939 | { | 1939 | { |
1940 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 1940 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
1941 | 1941 | ||
1942 | QStringList filterList; | 1942 | QStringList filterList; |
1943 | 1943 | ||
1944 | CalFilter *filter = mFilters.first(); | 1944 | CalFilter *filter = mFilters.first(); |
1945 | while(filter) { | 1945 | while(filter) { |
1946 | // kdDebug() << " fn: " << filter->name() << endl; | 1946 | // kdDebug() << " fn: " << filter->name() << endl; |
1947 | filterList << filter->name(); | 1947 | filterList << filter->name(); |
1948 | config->setGroup("Filter_" + filter->name()); | 1948 | config->setGroup("Filter_" + filter->name()); |
1949 | config->writeEntry("Criteria",filter->criteria()); | 1949 | config->writeEntry("Criteria",filter->criteria()); |
1950 | config->writeEntry("CategoryList",filter->categoryList()); | 1950 | config->writeEntry("CategoryList",filter->categoryList()); |
1951 | filter = mFilters.next(); | 1951 | filter = mFilters.next(); |
1952 | } | 1952 | } |
1953 | config->setGroup("General"); | 1953 | config->setGroup("General"); |
1954 | config->writeEntry("CalendarFilters",filterList); | 1954 | config->writeEntry("CalendarFilters",filterList); |
1955 | 1955 | ||
1956 | config->setGroup("FilterView"); | 1956 | config->setGroup("FilterView"); |
1957 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 1957 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
1958 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 1958 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
1959 | } | 1959 | } |
1960 | 1960 | ||
1961 | 1961 | ||
1962 | void CalendarView::goToday() | 1962 | void CalendarView::goToday() |
1963 | { | 1963 | { |
1964 | mNavigator->selectToday(); | 1964 | mNavigator->selectToday(); |
1965 | } | 1965 | } |
1966 | 1966 | ||
1967 | void CalendarView::goNext() | 1967 | void CalendarView::goNext() |
1968 | { | 1968 | { |
1969 | mNavigator->selectNext(); | 1969 | mNavigator->selectNext(); |
1970 | } | 1970 | } |
1971 | 1971 | ||
1972 | void CalendarView::goPrevious() | 1972 | void CalendarView::goPrevious() |
1973 | { | 1973 | { |
1974 | mNavigator->selectPrevious(); | 1974 | mNavigator->selectPrevious(); |
1975 | } | 1975 | } |
1976 | void CalendarView::goNextMonth() | 1976 | void CalendarView::goNextMonth() |
1977 | { | 1977 | { |
1978 | mNavigator->selectNextMonth(); | 1978 | mNavigator->selectNextMonth(); |
1979 | } | 1979 | } |
1980 | 1980 | ||
1981 | void CalendarView::goPreviousMonth() | 1981 | void CalendarView::goPreviousMonth() |
1982 | { | 1982 | { |
1983 | mNavigator->selectPreviousMonth(); | 1983 | mNavigator->selectPreviousMonth(); |
1984 | } | 1984 | } |
1985 | void CalendarView::writeLocale() | 1985 | void CalendarView::writeLocale() |
1986 | { | 1986 | { |
1987 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 1987 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
1988 | #if 0 | 1988 | #if 0 |
1989 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 1989 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
1990 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 1990 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
1991 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 1991 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
1992 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 1992 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
1993 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 1993 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
1994 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 1994 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
1995 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 1995 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
1996 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 1996 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
1997 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 1997 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
1998 | KOPrefs::instance()->mDaylightsavingStart, | 1998 | KOPrefs::instance()->mDaylightsavingStart, |
1999 | KOPrefs::instance()->mDaylightsavingEnd ); | 1999 | KOPrefs::instance()->mDaylightsavingEnd ); |
2000 | KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); | 2000 | KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); |
2001 | #endif | 2001 | #endif |
2002 | } | 2002 | } |
2003 | void CalendarView::updateConfig() | 2003 | void CalendarView::updateConfig() |
2004 | { | 2004 | { |
2005 | writeLocale(); | 2005 | writeLocale(); |
2006 | if ( KOPrefs::instance()->mUseAppColors ) | 2006 | if ( KOPrefs::instance()->mUseAppColors ) |
2007 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2007 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2008 | emit configChanged(); | 2008 | emit configChanged(); |
2009 | mTodoList->updateConfig(); | 2009 | mTodoList->updateConfig(); |
2010 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2010 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2011 | mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 2011 | mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
2012 | // To make the "fill window" configurations work | 2012 | // To make the "fill window" configurations work |
2013 | //mViewManager->raiseCurrentView(); | 2013 | //mViewManager->raiseCurrentView(); |
2014 | } | 2014 | } |
2015 | 2015 | ||
2016 | 2016 | ||
2017 | void CalendarView::eventChanged(Event *event) | 2017 | void CalendarView::eventChanged(Event *event) |
2018 | { | 2018 | { |
2019 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2019 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2020 | //updateUnmanagedViews(); | 2020 | //updateUnmanagedViews(); |
2021 | } | 2021 | } |
2022 | 2022 | ||
2023 | void CalendarView::eventAdded(Event *event) | 2023 | void CalendarView::eventAdded(Event *event) |
2024 | { | 2024 | { |
2025 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2025 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2026 | } | 2026 | } |
2027 | 2027 | ||
2028 | void CalendarView::eventToBeDeleted(Event *) | 2028 | void CalendarView::eventToBeDeleted(Event *) |
2029 | { | 2029 | { |
2030 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2030 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2031 | } | 2031 | } |
2032 | 2032 | ||
2033 | void CalendarView::eventDeleted() | 2033 | void CalendarView::eventDeleted() |
2034 | { | 2034 | { |
2035 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2035 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2036 | } | 2036 | } |
2037 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2037 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2038 | { | 2038 | { |
2039 | changeIncidenceDisplay((Incidence *)which, action); | 2039 | changeIncidenceDisplay((Incidence *)which, action); |
2040 | mDateNavigator->updateView(); //LR | 2040 | mDateNavigator->updateView(); //LR |
2041 | //mDialogManager->updateSearchDialog(); | 2041 | //mDialogManager->updateSearchDialog(); |
2042 | 2042 | ||
2043 | if (which) { | 2043 | if (which) { |
2044 | mViewManager->updateWNview(); | 2044 | mViewManager->updateWNview(); |
2045 | //mTodoList->updateView(); | 2045 | //mTodoList->updateView(); |
2046 | } | 2046 | } |
2047 | 2047 | ||
2048 | } | 2048 | } |
2049 | 2049 | ||
2050 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2050 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2051 | { | 2051 | { |
2052 | updateUnmanagedViews(); | 2052 | updateUnmanagedViews(); |
2053 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2053 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2054 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2054 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2055 | mCalendar->checkAlarmForIncidence( 0, true ); | 2055 | mCalendar->checkAlarmForIncidence( 0, true ); |
2056 | if ( mEventViewerDialog ) | 2056 | if ( mEventViewerDialog ) |
2057 | mEventViewerDialog->hide(); | 2057 | mEventViewerDialog->hide(); |
2058 | } | 2058 | } |
2059 | else | 2059 | else |
2060 | mCalendar->checkAlarmForIncidence( which , false ); | 2060 | mCalendar->checkAlarmForIncidence( which , false ); |
2061 | } | 2061 | } |
2062 | 2062 | ||
2063 | // most of the changeEventDisplays() right now just call the view's | 2063 | // most of the changeEventDisplays() right now just call the view's |
2064 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2064 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2065 | void CalendarView::changeEventDisplay(Event *which, int action) | 2065 | void CalendarView::changeEventDisplay(Event *which, int action) |
2066 | { | 2066 | { |
2067 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2067 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2068 | changeIncidenceDisplay((Incidence *)which, action); | 2068 | changeIncidenceDisplay((Incidence *)which, action); |
2069 | mDateNavigator->updateView(); | 2069 | mDateNavigator->updateView(); |
2070 | //mDialogManager->updateSearchDialog(); | 2070 | //mDialogManager->updateSearchDialog(); |
2071 | 2071 | ||
2072 | if (which) { | 2072 | if (which) { |
2073 | // If there is an event view visible update the display | 2073 | // If there is an event view visible update the display |
2074 | mViewManager->currentView()->changeEventDisplay(which,action); | 2074 | mViewManager->currentView()->changeEventDisplay(which,action); |
2075 | // TODO: check, if update needed | 2075 | // TODO: check, if update needed |
2076 | // if (which->getTodoStatus()) { | 2076 | // if (which->getTodoStatus()) { |
2077 | mTodoList->updateView(); | 2077 | mTodoList->updateView(); |
2078 | // } | 2078 | // } |
2079 | } else { | 2079 | } else { |
2080 | mViewManager->currentView()->updateView(); | 2080 | mViewManager->currentView()->updateView(); |
2081 | } | 2081 | } |
2082 | } | 2082 | } |
2083 | 2083 | ||
2084 | 2084 | ||
2085 | void CalendarView::updateTodoViews() | 2085 | void CalendarView::updateTodoViews() |
2086 | { | 2086 | { |
2087 | 2087 | ||
2088 | mTodoList->updateView(); | 2088 | mTodoList->updateView(); |
2089 | mViewManager->currentView()->updateView(); | 2089 | mViewManager->currentView()->updateView(); |
2090 | 2090 | ||
2091 | } | 2091 | } |
2092 | 2092 | ||
2093 | 2093 | ||
2094 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2094 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2095 | { | 2095 | { |
2096 | mTodoList->updateView(); | 2096 | mTodoList->updateView(); |
2097 | mViewManager->updateView(start, end); | 2097 | mViewManager->updateView(start, end); |
2098 | //mDateNavigator->updateView(); | 2098 | //mDateNavigator->updateView(); |
2099 | } | 2099 | } |
2100 | 2100 | ||
2101 | void CalendarView::updateView() | 2101 | void CalendarView::updateView() |
2102 | { | 2102 | { |
2103 | DateList tmpList = mNavigator->selectedDates(); | 2103 | DateList tmpList = mNavigator->selectedDates(); |
2104 | 2104 | ||
2105 | // We assume that the navigator only selects consecutive days. | 2105 | // We assume that the navigator only selects consecutive days. |
2106 | updateView( tmpList.first(), tmpList.last() ); | 2106 | updateView( tmpList.first(), tmpList.last() ); |
2107 | } | 2107 | } |
2108 | 2108 | ||
2109 | void CalendarView::updateUnmanagedViews() | 2109 | void CalendarView::updateUnmanagedViews() |
2110 | { | 2110 | { |
2111 | mDateNavigator->updateDayMatrix(); | 2111 | mDateNavigator->updateDayMatrix(); |
2112 | } | 2112 | } |
2113 | 2113 | ||
2114 | int CalendarView::msgItemDelete() | 2114 | int CalendarView::msgItemDelete() |
2115 | { | 2115 | { |
2116 | return KMessageBox::warningContinueCancel(this, | 2116 | return KMessageBox::warningContinueCancel(this, |
2117 | i18n("This item will be\npermanently deleted."), | 2117 | i18n("This item will be\npermanently deleted."), |
2118 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2118 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2119 | } | 2119 | } |
2120 | 2120 | ||
2121 | 2121 | ||
2122 | void CalendarView::edit_cut() | 2122 | void CalendarView::edit_cut() |
2123 | { | 2123 | { |
2124 | Event *anEvent=0; | 2124 | Event *anEvent=0; |
2125 | 2125 | ||
2126 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2126 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2127 | 2127 | ||
2128 | if (mViewManager->currentView()->isEventView()) { | 2128 | if (mViewManager->currentView()->isEventView()) { |
2129 | if ( incidence && incidence->type() == "Event" ) { | 2129 | if ( incidence && incidence->type() == "Event" ) { |
2130 | anEvent = static_cast<Event *>(incidence); | 2130 | anEvent = static_cast<Event *>(incidence); |
2131 | } | 2131 | } |
2132 | } | 2132 | } |
2133 | 2133 | ||
2134 | if (!anEvent) { | 2134 | if (!anEvent) { |
2135 | KNotifyClient::beep(); | 2135 | KNotifyClient::beep(); |
2136 | return; | 2136 | return; |
2137 | } | 2137 | } |
2138 | DndFactory factory( mCalendar ); | 2138 | DndFactory factory( mCalendar ); |
2139 | factory.cutEvent(anEvent); | 2139 | factory.cutEvent(anEvent); |
2140 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2140 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2141 | } | 2141 | } |
2142 | 2142 | ||
2143 | void CalendarView::edit_copy() | 2143 | void CalendarView::edit_copy() |
2144 | { | 2144 | { |
2145 | Event *anEvent=0; | 2145 | Event *anEvent=0; |
2146 | 2146 | ||
2147 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2147 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2148 | 2148 | ||
2149 | if (mViewManager->currentView()->isEventView()) { | 2149 | if (mViewManager->currentView()->isEventView()) { |
2150 | if ( incidence && incidence->type() == "Event" ) { | 2150 | if ( incidence && incidence->type() == "Event" ) { |
2151 | anEvent = static_cast<Event *>(incidence); | 2151 | anEvent = static_cast<Event *>(incidence); |
2152 | } | 2152 | } |
2153 | } | 2153 | } |
2154 | 2154 | ||
2155 | if (!anEvent) { | 2155 | if (!anEvent) { |
2156 | KNotifyClient::beep(); | 2156 | KNotifyClient::beep(); |
2157 | return; | 2157 | return; |
2158 | } | 2158 | } |
2159 | DndFactory factory( mCalendar ); | 2159 | DndFactory factory( mCalendar ); |
2160 | factory.copyEvent(anEvent); | 2160 | factory.copyEvent(anEvent); |
2161 | } | 2161 | } |
2162 | 2162 | ||
2163 | void CalendarView::edit_paste() | 2163 | void CalendarView::edit_paste() |
2164 | { | 2164 | { |
2165 | QDate date = mNavigator->selectedDates().first(); | 2165 | QDate date = mNavigator->selectedDates().first(); |
2166 | 2166 | ||
2167 | DndFactory factory( mCalendar ); | 2167 | DndFactory factory( mCalendar ); |
2168 | Event *pastedEvent = factory.pasteEvent( date ); | 2168 | Event *pastedEvent = factory.pasteEvent( date ); |
2169 | 2169 | ||
2170 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2170 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2171 | } | 2171 | } |
2172 | 2172 | ||
2173 | void CalendarView::edit_options() | 2173 | void CalendarView::edit_options() |
2174 | { | 2174 | { |
2175 | mDialogManager->showOptionsDialog(); | 2175 | mDialogManager->showOptionsDialog(); |
2176 | //writeSettings(); | 2176 | //writeSettings(); |
2177 | } | 2177 | } |
2178 | 2178 | ||
2179 | void CalendarView::slotSelectPickerDate( QDate d) | 2179 | void CalendarView::slotSelectPickerDate( QDate d) |
2180 | { | 2180 | { |
2181 | mDateFrame->hide(); | 2181 | mDateFrame->hide(); |
2182 | if ( mDatePickerMode == 1 ) { | 2182 | if ( mDatePickerMode == 1 ) { |
2183 | mNavigator->slotDaySelect( d ); | 2183 | mNavigator->slotDaySelect( d ); |
2184 | } else if ( mDatePickerMode == 2 ) { | 2184 | } else if ( mDatePickerMode == 2 ) { |
2185 | if ( mMoveIncidence->type() == "Todo" ) { | 2185 | if ( mMoveIncidence->type() == "Todo" ) { |
2186 | Todo * to = (Todo *) mMoveIncidence; | 2186 | Todo * to = (Todo *) mMoveIncidence; |
2187 | QTime tim; | 2187 | QTime tim; |
2188 | if ( to->hasDueDate() ) | 2188 | if ( to->hasDueDate() ) |
2189 | tim = to->dtDue().time(); | 2189 | tim = to->dtDue().time(); |
2190 | else { | 2190 | else { |
2191 | tim = QTime ( 0,0,0 ); | 2191 | tim = QTime ( 0,0,0 ); |
2192 | to->setFloats( true ); | 2192 | to->setFloats( true ); |
2193 | to->setHasDueDate( true ); | 2193 | to->setHasDueDate( true ); |
2194 | } | 2194 | } |
2195 | QDateTime dt ( d,tim ); | 2195 | QDateTime dt ( d,tim ); |
2196 | to->setDtDue( dt ); | 2196 | to->setDtDue( dt ); |
2197 | todoChanged( to ); | 2197 | todoChanged( to ); |
2198 | } else { | 2198 | } else { |
2199 | QTime tim = mMoveIncidence->dtStart().time(); | 2199 | QTime tim = mMoveIncidence->dtStart().time(); |
2200 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2200 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2201 | QDateTime dt ( d,tim ); | 2201 | QDateTime dt ( d,tim ); |
2202 | mMoveIncidence->setDtStart( dt ); | 2202 | mMoveIncidence->setDtStart( dt ); |
2203 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2203 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2204 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2204 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2205 | } | 2205 | } |
2206 | 2206 | ||
2207 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2207 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2208 | } | 2208 | } |
2209 | } | 2209 | } |
2210 | 2210 | ||
2211 | void CalendarView::removeCategories() | 2211 | void CalendarView::removeCategories() |
2212 | { | 2212 | { |
2213 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2213 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2214 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2214 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2215 | QStringList catIncList; | 2215 | QStringList catIncList; |
2216 | QStringList newCatList; | 2216 | QStringList newCatList; |
2217 | Incidence* inc = incList.first(); | 2217 | Incidence* inc = incList.first(); |
2218 | int i; | 2218 | int i; |
2219 | int count = 0; | 2219 | int count = 0; |
2220 | while ( inc ) { | 2220 | while ( inc ) { |
2221 | newCatList.clear(); | 2221 | newCatList.clear(); |
2222 | catIncList = inc->categories() ; | 2222 | catIncList = inc->categories() ; |
2223 | for( i = 0; i< catIncList.count(); ++i ) { | 2223 | for( i = 0; i< catIncList.count(); ++i ) { |
2224 | if ( catList.contains (catIncList[i])) | 2224 | if ( catList.contains (catIncList[i])) |
2225 | newCatList.append( catIncList[i] ); | 2225 | newCatList.append( catIncList[i] ); |
2226 | } | 2226 | } |
2227 | newCatList.sort(); | 2227 | newCatList.sort(); |
2228 | inc->setCategories( newCatList.join(",") ); | 2228 | inc->setCategories( newCatList.join(",") ); |
2229 | inc = incList.next(); | 2229 | inc = incList.next(); |
2230 | } | 2230 | } |
2231 | } | 2231 | } |
2232 | 2232 | ||
2233 | int CalendarView::addCategories() | 2233 | int CalendarView::addCategories() |
2234 | { | 2234 | { |
2235 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2235 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2236 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2236 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2237 | QStringList catIncList; | 2237 | QStringList catIncList; |
2238 | Incidence* inc = incList.first(); | 2238 | Incidence* inc = incList.first(); |
2239 | int i; | 2239 | int i; |
2240 | int count = 0; | 2240 | int count = 0; |
2241 | while ( inc ) { | 2241 | while ( inc ) { |
2242 | catIncList = inc->categories() ; | 2242 | catIncList = inc->categories() ; |
2243 | for( i = 0; i< catIncList.count(); ++i ) { | 2243 | for( i = 0; i< catIncList.count(); ++i ) { |
2244 | if ( !catList.contains (catIncList[i])) { | 2244 | if ( !catList.contains (catIncList[i])) { |
2245 | catList.append( catIncList[i] ); | 2245 | catList.append( catIncList[i] ); |
2246 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2246 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2247 | ++count; | 2247 | ++count; |
2248 | } | 2248 | } |
2249 | } | 2249 | } |
2250 | inc = incList.next(); | 2250 | inc = incList.next(); |
2251 | } | 2251 | } |
2252 | catList.sort(); | 2252 | catList.sort(); |
2253 | KOPrefs::instance()->mCustomCategories = catList; | 2253 | KOPrefs::instance()->mCustomCategories = catList; |
2254 | return count; | 2254 | return count; |
2255 | } | 2255 | } |
2256 | 2256 | ||
2257 | void CalendarView::manageCategories() | 2257 | void CalendarView::manageCategories() |
2258 | { | 2258 | { |
2259 | KOCatPrefs* cp = new KOCatPrefs(); | 2259 | KOCatPrefs* cp = new KOCatPrefs(); |
2260 | cp->show(); | 2260 | cp->show(); |
2261 | int w =cp->sizeHint().width() ; | 2261 | int w =cp->sizeHint().width() ; |
2262 | int h = cp->sizeHint().height() ; | 2262 | int h = cp->sizeHint().height() ; |
2263 | int dw = QApplication::desktop()->width(); | 2263 | int dw = QApplication::desktop()->width(); |
2264 | int dh = QApplication::desktop()->height(); | 2264 | int dh = QApplication::desktop()->height(); |
2265 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2265 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2266 | if ( !cp->exec() ) { | 2266 | if ( !cp->exec() ) { |
2267 | delete cp; | 2267 | delete cp; |
2268 | return; | 2268 | return; |
2269 | } | 2269 | } |
2270 | int count = 0; | 2270 | int count = 0; |
2271 | if ( cp->addCat() ) { | 2271 | if ( cp->addCat() ) { |
2272 | count = addCategories(); | 2272 | count = addCategories(); |
2273 | if ( count ) { | 2273 | if ( count ) { |
2274 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2274 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2275 | writeSettings(); | 2275 | writeSettings(); |
2276 | } | 2276 | } |
2277 | } else { | 2277 | } else { |
2278 | removeCategories(); | 2278 | removeCategories(); |
2279 | updateView(); | 2279 | updateView(); |
2280 | } | 2280 | } |
2281 | delete cp; | 2281 | delete cp; |
2282 | } | 2282 | } |
2283 | 2283 | ||
2284 | void CalendarView::beamIncidence(Incidence * Inc) | 2284 | void CalendarView::beamIncidence(Incidence * Inc) |
2285 | { | 2285 | { |
2286 | QPtrList<Incidence> delSel ; | 2286 | QPtrList<Incidence> delSel ; |
2287 | delSel.append(Inc); | 2287 | delSel.append(Inc); |
2288 | beamIncidenceList( delSel ); | 2288 | beamIncidenceList( delSel ); |
2289 | } | 2289 | } |
2290 | void CalendarView::beamCalendar() | 2290 | void CalendarView::beamCalendar() |
2291 | { | 2291 | { |
2292 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2292 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2293 | //qDebug("beamCalendar() "); | 2293 | //qDebug("beamCalendar() "); |
2294 | beamIncidenceList( delSel ); | 2294 | beamIncidenceList( delSel ); |
2295 | } | 2295 | } |
2296 | void CalendarView::beamFilteredCalendar() | 2296 | void CalendarView::beamFilteredCalendar() |
2297 | { | 2297 | { |
2298 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2298 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2299 | //qDebug("beamFilteredCalendar() "); | 2299 | //qDebug("beamFilteredCalendar() "); |
2300 | beamIncidenceList( delSel ); | 2300 | beamIncidenceList( delSel ); |
2301 | } | 2301 | } |
2302 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2302 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2303 | { | 2303 | { |
2304 | if ( beamDialog->exec () == QDialog::Rejected ) | 2304 | if ( beamDialog->exec () == QDialog::Rejected ) |
2305 | return; | 2305 | return; |
2306 | 2306 | ||
2307 | QString fn = "/tmp/kopibeamfile"; | 2307 | QString fn = "/tmp/kopibeamfile"; |
2308 | QString mes; | 2308 | QString mes; |
2309 | bool createbup = true; | 2309 | bool createbup = true; |
2310 | if ( createbup ) { | 2310 | if ( createbup ) { |
2311 | QString description = "\n"; | 2311 | QString description = "\n"; |
2312 | CalendarLocal* cal = new CalendarLocal(); | 2312 | CalendarLocal* cal = new CalendarLocal(); |
2313 | if ( beamDialog->beamLocal() ) | 2313 | if ( beamDialog->beamLocal() ) |
2314 | cal->setLocalTime(); | 2314 | cal->setLocalTime(); |
2315 | else | 2315 | else |
2316 | cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 2316 | cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
2317 | Incidence *incidence = delSel.first(); | 2317 | Incidence *incidence = delSel.first(); |
2318 | bool addText = false; | 2318 | bool addText = false; |
2319 | if ( delSel.count() < 10 ) | 2319 | if ( delSel.count() < 10 ) |
2320 | addText = true; | 2320 | addText = true; |
2321 | else { | 2321 | else { |
2322 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2322 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2323 | } | 2323 | } |
2324 | while ( incidence ) { | 2324 | while ( incidence ) { |
2325 | Incidence *in = incidence->clone(); | 2325 | Incidence *in = incidence->clone(); |
2326 | if ( ! in->summary().isEmpty() ) { | ||
2327 | in->setDescription(""); | ||
2328 | } else { | ||
2329 | in->setSummary( in->description().left(20)); | ||
2330 | in->setDescription(""); | ||
2331 | } | ||
2326 | if ( addText ) | 2332 | if ( addText ) |
2327 | description += in->summary() + "\n"; | 2333 | description += in->summary() + "\n"; |
2328 | cal->addIncidence( in ); | 2334 | cal->addIncidence( in ); |
2329 | incidence = delSel.next(); | 2335 | incidence = delSel.next(); |
2330 | } | 2336 | } |
2331 | if ( beamDialog->beamVcal() ) { | 2337 | if ( beamDialog->beamVcal() ) { |
2332 | fn += ".vcs"; | 2338 | fn += ".vcs"; |
2333 | FileStorage storage( cal, fn, new VCalFormat ); | 2339 | FileStorage storage( cal, fn, new VCalFormat ); |
2334 | storage.save(); | 2340 | storage.save(); |
2335 | } else { | 2341 | } else { |
2336 | fn += ".ics"; | 2342 | fn += ".ics"; |
2337 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2343 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2338 | storage.save(); | 2344 | storage.save(); |
2339 | } | 2345 | } |
2340 | delete cal; | 2346 | delete cal; |
2341 | mes = i18n("KO/Pi: Ready for beaming"); | 2347 | mes = i18n("KO/Pi: Ready for beaming"); |
2342 | setCaption(mes); | 2348 | topLevelWidget()->setCaption(mes); |
2343 | 2349 | KApplication::convert2latin1( fn ); | |
2344 | #ifndef DESKTOP_VERSION | 2350 | #ifndef DESKTOP_VERSION |
2345 | Ir *ir = new Ir( this ); | 2351 | Ir *ir = new Ir( this ); |
2346 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2352 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2347 | ir->send( fn, description, "text/x-vCalendar" ); | 2353 | ir->send( fn, description, "text/x-vCalendar" ); |
2348 | #endif | 2354 | #endif |
2349 | } | 2355 | } |
2350 | } | 2356 | } |
2351 | void CalendarView::beamDone( Ir *ir ) | 2357 | void CalendarView::beamDone( Ir *ir ) |
2352 | { | 2358 | { |
2353 | #ifndef DESKTOP_VERSION | 2359 | #ifndef DESKTOP_VERSION |
2354 | delete ir; | 2360 | delete ir; |
2355 | #endif | 2361 | #endif |
2362 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | ||
2363 | topLevelWidget()->raise(); | ||
2356 | } | 2364 | } |
2357 | 2365 | ||
2358 | void CalendarView::moveIncidence(Incidence * inc ) | 2366 | void CalendarView::moveIncidence(Incidence * inc ) |
2359 | { | 2367 | { |
2360 | if ( !inc ) return; | 2368 | if ( !inc ) return; |
2361 | // qDebug("showDatePickerForIncidence( ) "); | 2369 | // qDebug("showDatePickerForIncidence( ) "); |
2362 | if ( mDateFrame->isVisible() ) | 2370 | if ( mDateFrame->isVisible() ) |
2363 | mDateFrame->hide(); | 2371 | mDateFrame->hide(); |
2364 | else { | 2372 | else { |
2365 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2373 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2366 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2374 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2367 | int dw = QApplication::desktop()->width(); | 2375 | int dw = QApplication::desktop()->width(); |
2368 | int dh = QApplication::desktop()->height(); | 2376 | int dh = QApplication::desktop()->height(); |
2369 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2377 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2370 | mDateFrame->show(); | 2378 | mDateFrame->show(); |
2371 | } | 2379 | } |
2372 | mDatePickerMode = 2; | 2380 | mDatePickerMode = 2; |
2373 | mMoveIncidence = inc ; | 2381 | mMoveIncidence = inc ; |
2374 | QDate da; | 2382 | QDate da; |
2375 | if ( mMoveIncidence->type() == "Todo" ) { | 2383 | if ( mMoveIncidence->type() == "Todo" ) { |
2376 | Todo * to = (Todo *) mMoveIncidence; | 2384 | Todo * to = (Todo *) mMoveIncidence; |
2377 | if ( to->hasDueDate() ) | 2385 | if ( to->hasDueDate() ) |
2378 | da = to->dtDue().date(); | 2386 | da = to->dtDue().date(); |
2379 | else | 2387 | else |
2380 | da = QDate::currentDate(); | 2388 | da = QDate::currentDate(); |
2381 | } else { | 2389 | } else { |
2382 | da = mMoveIncidence->dtStart().date(); | 2390 | da = mMoveIncidence->dtStart().date(); |
2383 | } | 2391 | } |
2384 | mDatePicker->setDate( da ); | 2392 | mDatePicker->setDate( da ); |
2385 | } | 2393 | } |
2386 | void CalendarView::showDatePicker( ) | 2394 | void CalendarView::showDatePicker( ) |
2387 | { | 2395 | { |
2388 | //qDebug("CalendarView::showDatePicker( ) "); | 2396 | //qDebug("CalendarView::showDatePicker( ) "); |
2389 | if ( mDateFrame->isVisible() ) | 2397 | if ( mDateFrame->isVisible() ) |
2390 | mDateFrame->hide(); | 2398 | mDateFrame->hide(); |
2391 | else { | 2399 | else { |
2392 | int w =mDatePicker->sizeHint().width() ; | 2400 | int w =mDatePicker->sizeHint().width() ; |
2393 | int h = mDatePicker->sizeHint().height() ; | 2401 | int h = mDatePicker->sizeHint().height() ; |
2394 | int dw = QApplication::desktop()->width(); | 2402 | int dw = QApplication::desktop()->width(); |
2395 | int dh = QApplication::desktop()->height(); | 2403 | int dh = QApplication::desktop()->height(); |
2396 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2404 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2397 | mDateFrame->show(); | 2405 | mDateFrame->show(); |
2398 | } | 2406 | } |
2399 | mDatePickerMode = 1; | 2407 | mDatePickerMode = 1; |
2400 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2408 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2401 | } | 2409 | } |
2402 | 2410 | ||
2403 | void CalendarView::showEventEditor() | 2411 | void CalendarView::showEventEditor() |
2404 | { | 2412 | { |
2405 | #ifdef DESKTOP_VERSION | 2413 | #ifdef DESKTOP_VERSION |
2406 | mEventEditor->show(); | 2414 | mEventEditor->show(); |
2407 | #else | 2415 | #else |
2408 | mEventEditor->showMaximized(); | 2416 | mEventEditor->showMaximized(); |
2409 | #endif | 2417 | #endif |
2410 | } | 2418 | } |
2411 | void CalendarView::showTodoEditor() | 2419 | void CalendarView::showTodoEditor() |
2412 | { | 2420 | { |
2413 | #ifdef DESKTOP_VERSION | 2421 | #ifdef DESKTOP_VERSION |
2414 | mTodoEditor->show(); | 2422 | mTodoEditor->show(); |
2415 | #else | 2423 | #else |
2416 | mTodoEditor->showMaximized(); | 2424 | mTodoEditor->showMaximized(); |
2417 | #endif | 2425 | #endif |
2418 | } | 2426 | } |
2419 | 2427 | ||
2420 | void CalendarView::cloneIncidence() | 2428 | void CalendarView::cloneIncidence() |
2421 | { | 2429 | { |
2422 | Incidence *incidence = currentSelection(); | 2430 | Incidence *incidence = currentSelection(); |
2423 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2431 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2424 | if ( incidence ) { | 2432 | if ( incidence ) { |
2425 | cloneIncidence(incidence); | 2433 | cloneIncidence(incidence); |
2426 | } | 2434 | } |
2427 | } | 2435 | } |
2428 | void CalendarView::moveIncidence() | 2436 | void CalendarView::moveIncidence() |
2429 | { | 2437 | { |
2430 | Incidence *incidence = currentSelection(); | 2438 | Incidence *incidence = currentSelection(); |
2431 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2439 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2432 | if ( incidence ) { | 2440 | if ( incidence ) { |
2433 | moveIncidence(incidence); | 2441 | moveIncidence(incidence); |
2434 | } | 2442 | } |
2435 | } | 2443 | } |
2436 | void CalendarView::beamIncidence() | 2444 | void CalendarView::beamIncidence() |
2437 | { | 2445 | { |
2438 | Incidence *incidence = currentSelection(); | 2446 | Incidence *incidence = currentSelection(); |
2439 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2447 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2440 | if ( incidence ) { | 2448 | if ( incidence ) { |
2441 | beamIncidence(incidence); | 2449 | beamIncidence(incidence); |
2442 | } | 2450 | } |
2443 | } | 2451 | } |
2444 | void CalendarView::toggleCancelIncidence() | 2452 | void CalendarView::toggleCancelIncidence() |
2445 | { | 2453 | { |
2446 | Incidence *incidence = currentSelection(); | 2454 | Incidence *incidence = currentSelection(); |
2447 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2455 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2448 | if ( incidence ) { | 2456 | if ( incidence ) { |
2449 | cancelIncidence(incidence); | 2457 | cancelIncidence(incidence); |
2450 | } | 2458 | } |
2451 | } | 2459 | } |
2452 | 2460 | ||
2453 | 2461 | ||
2454 | void CalendarView::cancelIncidence(Incidence * inc ) | 2462 | void CalendarView::cancelIncidence(Incidence * inc ) |
2455 | { | 2463 | { |
2456 | inc->setCancelled( ! inc->cancelled() ); | 2464 | inc->setCancelled( ! inc->cancelled() ); |
2457 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2465 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2458 | updateView(); | 2466 | updateView(); |
2459 | } | 2467 | } |
2460 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2468 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2461 | { | 2469 | { |
2462 | Incidence * newInc = orgInc->clone(); | 2470 | Incidence * newInc = orgInc->clone(); |
2463 | newInc->recreate(); | 2471 | newInc->recreate(); |
2464 | 2472 | ||
2465 | if ( newInc->type() == "Todo" ) { | 2473 | if ( newInc->type() == "Todo" ) { |
2466 | Todo* t = (Todo*) newInc; | 2474 | Todo* t = (Todo*) newInc; |
2467 | mTodoEditor->editTodo( t ); | 2475 | mTodoEditor->editTodo( t ); |
2468 | showTodoEditor(); | 2476 | showTodoEditor(); |
2469 | if ( mTodoEditor->exec() ) { | 2477 | if ( mTodoEditor->exec() ) { |
2470 | mCalendar->addTodo( t ); | 2478 | mCalendar->addTodo( t ); |
2471 | updateView(); | 2479 | updateView(); |
2472 | } else { | 2480 | } else { |
2473 | delete t; | 2481 | delete t; |
2474 | } | 2482 | } |
2475 | } | 2483 | } |
2476 | else { | 2484 | else { |
2477 | Event* e = (Event*) newInc; | 2485 | Event* e = (Event*) newInc; |
2478 | mEventEditor->editEvent( e ); | 2486 | mEventEditor->editEvent( e ); |
2479 | showEventEditor(); | 2487 | showEventEditor(); |
2480 | if ( mEventEditor->exec() ) { | 2488 | if ( mEventEditor->exec() ) { |
2481 | mCalendar->addEvent( e ); | 2489 | mCalendar->addEvent( e ); |
2482 | updateView(); | 2490 | updateView(); |
2483 | } else { | 2491 | } else { |
2484 | delete e; | 2492 | delete e; |
2485 | } | 2493 | } |
2486 | } | 2494 | } |
2487 | } | 2495 | } |
2488 | 2496 | ||
2489 | void CalendarView::newEvent() | 2497 | void CalendarView::newEvent() |
2490 | { | 2498 | { |
2491 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2499 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2492 | KOAgendaView *aView = mViewManager->agendaView(); | 2500 | KOAgendaView *aView = mViewManager->agendaView(); |
2493 | if (aView) { | 2501 | if (aView) { |
2494 | if (aView->selectionStart().isValid()) { | 2502 | if (aView->selectionStart().isValid()) { |
2495 | if (aView->selectedIsAllDay()) { | 2503 | if (aView->selectedIsAllDay()) { |
2496 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2504 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2497 | } else { | 2505 | } else { |
2498 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2506 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2499 | } | 2507 | } |
2500 | return; | 2508 | return; |
2501 | } | 2509 | } |
2502 | } | 2510 | } |
2503 | 2511 | ||
2504 | QDate date = mNavigator->selectedDates().first(); | 2512 | QDate date = mNavigator->selectedDates().first(); |
2505 | QDateTime current = QDateTime::currentDateTime(); | 2513 | QDateTime current = QDateTime::currentDateTime(); |
2506 | if ( date <= current.date() ) { | 2514 | if ( date <= current.date() ) { |
2507 | int hour = current.time().hour() +1; | 2515 | int hour = current.time().hour() +1; |
2508 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2516 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2509 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2517 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2510 | } else | 2518 | } else |
2511 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2519 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2512 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2520 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2513 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2521 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2514 | } | 2522 | } |
2515 | 2523 | ||
2516 | void CalendarView::newEvent(QDateTime fh) | 2524 | void CalendarView::newEvent(QDateTime fh) |
2517 | { | 2525 | { |
2518 | newEvent(fh, | 2526 | newEvent(fh, |
2519 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2527 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2520 | } | 2528 | } |
2521 | 2529 | ||
2522 | void CalendarView::newEvent(QDate dt) | 2530 | void CalendarView::newEvent(QDate dt) |
2523 | { | 2531 | { |
2524 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2532 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2525 | QDateTime(dt, QTime(0,0,0)), true); | 2533 | QDateTime(dt, QTime(0,0,0)), true); |
2526 | } | 2534 | } |
2527 | 2535 | ||
2528 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2536 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2529 | { | 2537 | { |
2530 | 2538 | ||
2531 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2539 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2532 | if ( mFilterView->filtersEnabled() ) { | 2540 | if ( mFilterView->filtersEnabled() ) { |
2533 | CalFilter *filter = mFilterView->selectedFilter(); | 2541 | CalFilter *filter = mFilterView->selectedFilter(); |
2534 | if (filter && filter->showCategories()) { | 2542 | if (filter && filter->showCategories()) { |
2535 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2543 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2536 | } | 2544 | } |
2537 | if ( filter ) | 2545 | if ( filter ) |
2538 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2546 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2539 | } | 2547 | } |
2540 | showEventEditor(); | 2548 | showEventEditor(); |
2541 | } | 2549 | } |
2542 | void CalendarView::todoAdded(Todo * t) | 2550 | void CalendarView::todoAdded(Todo * t) |
2543 | { | 2551 | { |
2544 | 2552 | ||
2545 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2553 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2546 | updateTodoViews(); | 2554 | updateTodoViews(); |
2547 | } | 2555 | } |
2548 | void CalendarView::todoChanged(Todo * t) | 2556 | void CalendarView::todoChanged(Todo * t) |
2549 | { | 2557 | { |
2550 | emit todoModified( t, 4 ); | 2558 | emit todoModified( t, 4 ); |
2551 | // updateTodoViews(); | 2559 | // updateTodoViews(); |
2552 | } | 2560 | } |
2553 | void CalendarView::todoToBeDeleted(Todo *) | 2561 | void CalendarView::todoToBeDeleted(Todo *) |
2554 | { | 2562 | { |
2555 | //qDebug("todoToBeDeleted(Todo *) "); | 2563 | //qDebug("todoToBeDeleted(Todo *) "); |
2556 | updateTodoViews(); | 2564 | updateTodoViews(); |
2557 | } | 2565 | } |
2558 | void CalendarView::todoDeleted() | 2566 | void CalendarView::todoDeleted() |
2559 | { | 2567 | { |
2560 | //qDebug(" todoDeleted()"); | 2568 | //qDebug(" todoDeleted()"); |
2561 | updateTodoViews(); | 2569 | updateTodoViews(); |
2562 | } | 2570 | } |
2563 | 2571 | ||
2564 | 2572 | ||
2565 | 2573 | ||
2566 | void CalendarView::newTodo() | 2574 | void CalendarView::newTodo() |
2567 | { | 2575 | { |
2568 | 2576 | ||
2569 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); | 2577 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); |
2570 | if ( mFilterView->filtersEnabled() ) { | 2578 | if ( mFilterView->filtersEnabled() ) { |
2571 | CalFilter *filter = mFilterView->selectedFilter(); | 2579 | CalFilter *filter = mFilterView->selectedFilter(); |
2572 | if (filter && filter->showCategories()) { | 2580 | if (filter && filter->showCategories()) { |
2573 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2581 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2574 | } | 2582 | } |
2575 | if ( filter ) | 2583 | if ( filter ) |
2576 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2584 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2577 | } | 2585 | } |
2578 | showTodoEditor(); | 2586 | showTodoEditor(); |
2579 | } | 2587 | } |
2580 | 2588 | ||
2581 | void CalendarView::newSubTodo() | 2589 | void CalendarView::newSubTodo() |
2582 | { | 2590 | { |
2583 | Todo *todo = selectedTodo(); | 2591 | Todo *todo = selectedTodo(); |
2584 | if ( todo ) newSubTodo( todo ); | 2592 | if ( todo ) newSubTodo( todo ); |
2585 | } | 2593 | } |
2586 | 2594 | ||
2587 | void CalendarView::newSubTodo(Todo *parentEvent) | 2595 | void CalendarView::newSubTodo(Todo *parentEvent) |
2588 | { | 2596 | { |
2589 | 2597 | ||
2590 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); | 2598 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); |
2591 | showTodoEditor(); | 2599 | showTodoEditor(); |
2592 | } | 2600 | } |
2593 | 2601 | ||
2594 | void CalendarView::newFloatingEvent() | 2602 | void CalendarView::newFloatingEvent() |
2595 | { | 2603 | { |
2596 | DateList tmpList = mNavigator->selectedDates(); | 2604 | DateList tmpList = mNavigator->selectedDates(); |
2597 | QDate date = tmpList.first(); | 2605 | QDate date = tmpList.first(); |
2598 | 2606 | ||
2599 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2607 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2600 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2608 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2601 | } | 2609 | } |
2602 | 2610 | ||
2603 | 2611 | ||
2604 | void CalendarView::editEvent( Event *event ) | 2612 | void CalendarView::editEvent( Event *event ) |
2605 | { | 2613 | { |
2606 | 2614 | ||
2607 | if ( !event ) return; | 2615 | if ( !event ) return; |
2608 | if ( event->isReadOnly() ) { | 2616 | if ( event->isReadOnly() ) { |
2609 | showEvent( event ); | 2617 | showEvent( event ); |
2610 | return; | 2618 | return; |
2611 | } | 2619 | } |
2612 | mEventEditor->editEvent( event , mFlagEditDescription); | 2620 | mEventEditor->editEvent( event , mFlagEditDescription); |
2613 | showEventEditor(); | 2621 | showEventEditor(); |
2614 | } | 2622 | } |
2615 | void CalendarView::editJournal( Journal *jour ) | 2623 | void CalendarView::editJournal( Journal *jour ) |
2616 | { | 2624 | { |
2617 | if ( !jour ) return; | 2625 | if ( !jour ) return; |
2618 | mDialogManager->hideSearchDialog(); | 2626 | mDialogManager->hideSearchDialog(); |
2619 | mViewManager->showJournalView(); | 2627 | mViewManager->showJournalView(); |
2620 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2628 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2621 | } | 2629 | } |
2622 | void CalendarView::editTodo( Todo *todo ) | 2630 | void CalendarView::editTodo( Todo *todo ) |
2623 | { | 2631 | { |
2624 | if ( !todo ) return; | 2632 | if ( !todo ) return; |
2625 | 2633 | ||
2626 | if ( todo->isReadOnly() ) { | 2634 | if ( todo->isReadOnly() ) { |
2627 | showTodo( todo ); | 2635 | showTodo( todo ); |
2628 | return; | 2636 | return; |
2629 | } | 2637 | } |
2630 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 2638 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
2631 | showTodoEditor(); | 2639 | showTodoEditor(); |
2632 | 2640 | ||
2633 | } | 2641 | } |
2634 | 2642 | ||
2635 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2643 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2636 | { | 2644 | { |
2637 | if ( !mEventViewerDialog ) { | 2645 | if ( !mEventViewerDialog ) { |
2638 | mEventViewerDialog = new KOEventViewerDialog(this); | 2646 | mEventViewerDialog = new KOEventViewerDialog(this); |
2639 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2647 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2640 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2648 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2641 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2649 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2642 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2650 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2643 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2651 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2644 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2652 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2645 | mEventViewerDialog->resize( 640, 480 ); | 2653 | mEventViewerDialog->resize( 640, 480 ); |
2646 | 2654 | ||
2647 | } | 2655 | } |
2648 | return mEventViewerDialog; | 2656 | return mEventViewerDialog; |
2649 | } | 2657 | } |
2650 | void CalendarView::showEvent(Event *event) | 2658 | void CalendarView::showEvent(Event *event) |
2651 | { | 2659 | { |
2652 | getEventViewerDialog()->setEvent(event); | 2660 | getEventViewerDialog()->setEvent(event); |
2653 | getEventViewerDialog()->showMe(); | 2661 | getEventViewerDialog()->showMe(); |
2654 | } | 2662 | } |
2655 | 2663 | ||
2656 | void CalendarView::showTodo(Todo *event) | 2664 | void CalendarView::showTodo(Todo *event) |
2657 | { | 2665 | { |
2658 | getEventViewerDialog()->setTodo(event); | 2666 | getEventViewerDialog()->setTodo(event); |
2659 | getEventViewerDialog()->showMe(); | 2667 | getEventViewerDialog()->showMe(); |
2660 | } | 2668 | } |
2661 | void CalendarView::showJournal( Journal *jour ) | 2669 | void CalendarView::showJournal( Journal *jour ) |
2662 | { | 2670 | { |
2663 | getEventViewerDialog()->setJournal(jour); | 2671 | getEventViewerDialog()->setJournal(jour); |
2664 | getEventViewerDialog()->showMe(); | 2672 | getEventViewerDialog()->showMe(); |
2665 | 2673 | ||
2666 | } | 2674 | } |
2667 | // void CalendarView::todoModified (Todo *event, int changed) | 2675 | // void CalendarView::todoModified (Todo *event, int changed) |
2668 | // { | 2676 | // { |
2669 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 2677 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
2670 | // // kdDebug() << "Todo modified and open" << endl; | 2678 | // // kdDebug() << "Todo modified and open" << endl; |
2671 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 2679 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
2672 | // // temp->modified (changed); | 2680 | // // temp->modified (changed); |
2673 | 2681 | ||
2674 | // // } | 2682 | // // } |
2675 | 2683 | ||
2676 | // mViewManager->updateView(); | 2684 | // mViewManager->updateView(); |
2677 | // } | 2685 | // } |
2678 | 2686 | ||
2679 | void CalendarView::appointment_show() | 2687 | void CalendarView::appointment_show() |
2680 | { | 2688 | { |
2681 | Event *anEvent = 0; | 2689 | Event *anEvent = 0; |
2682 | 2690 | ||
2683 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2691 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2684 | 2692 | ||
2685 | if (mViewManager->currentView()->isEventView()) { | 2693 | if (mViewManager->currentView()->isEventView()) { |
2686 | if ( incidence && incidence->type() == "Event" ) { | 2694 | if ( incidence && incidence->type() == "Event" ) { |
2687 | anEvent = static_cast<Event *>(incidence); | 2695 | anEvent = static_cast<Event *>(incidence); |
2688 | } | 2696 | } |
2689 | } | 2697 | } |
2690 | 2698 | ||
2691 | if (!anEvent) { | 2699 | if (!anEvent) { |
2692 | KNotifyClient::beep(); | 2700 | KNotifyClient::beep(); |
2693 | return; | 2701 | return; |
2694 | } | 2702 | } |
2695 | 2703 | ||
2696 | showEvent(anEvent); | 2704 | showEvent(anEvent); |
2697 | } | 2705 | } |
2698 | 2706 | ||
2699 | void CalendarView::appointment_edit() | 2707 | void CalendarView::appointment_edit() |
2700 | { | 2708 | { |
2701 | Event *anEvent = 0; | 2709 | Event *anEvent = 0; |
2702 | 2710 | ||
2703 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2711 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2704 | 2712 | ||
2705 | if (mViewManager->currentView()->isEventView()) { | 2713 | if (mViewManager->currentView()->isEventView()) { |
2706 | if ( incidence && incidence->type() == "Event" ) { | 2714 | if ( incidence && incidence->type() == "Event" ) { |
2707 | anEvent = static_cast<Event *>(incidence); | 2715 | anEvent = static_cast<Event *>(incidence); |
2708 | } | 2716 | } |
2709 | } | 2717 | } |
2710 | 2718 | ||
2711 | if (!anEvent) { | 2719 | if (!anEvent) { |
2712 | KNotifyClient::beep(); | 2720 | KNotifyClient::beep(); |
2713 | return; | 2721 | return; |
2714 | } | 2722 | } |
2715 | 2723 | ||
2716 | editEvent(anEvent); | 2724 | editEvent(anEvent); |
2717 | } | 2725 | } |
2718 | 2726 | ||
2719 | void CalendarView::appointment_delete() | 2727 | void CalendarView::appointment_delete() |
2720 | { | 2728 | { |
2721 | Event *anEvent = 0; | 2729 | Event *anEvent = 0; |
2722 | 2730 | ||
2723 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2731 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2724 | 2732 | ||
2725 | if (mViewManager->currentView()->isEventView()) { | 2733 | if (mViewManager->currentView()->isEventView()) { |
2726 | if ( incidence && incidence->type() == "Event" ) { | 2734 | if ( incidence && incidence->type() == "Event" ) { |
2727 | anEvent = static_cast<Event *>(incidence); | 2735 | anEvent = static_cast<Event *>(incidence); |
2728 | } | 2736 | } |
2729 | } | 2737 | } |
2730 | 2738 | ||
2731 | if (!anEvent) { | 2739 | if (!anEvent) { |
2732 | KNotifyClient::beep(); | 2740 | KNotifyClient::beep(); |
2733 | return; | 2741 | return; |
2734 | } | 2742 | } |
2735 | 2743 | ||
2736 | deleteEvent(anEvent); | 2744 | deleteEvent(anEvent); |
2737 | } | 2745 | } |
2738 | 2746 | ||
2739 | void CalendarView::todo_unsub(Todo *anTodo ) | 2747 | void CalendarView::todo_unsub(Todo *anTodo ) |
2740 | { | 2748 | { |
2741 | // Todo *anTodo = selectedTodo(); | 2749 | // Todo *anTodo = selectedTodo(); |
2742 | if (!anTodo) return; | 2750 | if (!anTodo) return; |
2743 | if (!anTodo->relatedTo()) return; | 2751 | if (!anTodo->relatedTo()) return; |
2744 | anTodo->relatedTo()->removeRelation(anTodo); | 2752 | anTodo->relatedTo()->removeRelation(anTodo); |
2745 | anTodo->setRelatedTo(0); | 2753 | anTodo->setRelatedTo(0); |
2746 | anTodo->updated(); | 2754 | anTodo->updated(); |
2747 | anTodo->setRelatedToUid(""); | 2755 | anTodo->setRelatedToUid(""); |
2748 | setModified(true); | 2756 | setModified(true); |
2749 | updateView(); | 2757 | updateView(); |
2750 | } | 2758 | } |
2751 | 2759 | ||
2752 | void CalendarView::deleteTodo(Todo *todo) | 2760 | void CalendarView::deleteTodo(Todo *todo) |
2753 | { | 2761 | { |
2754 | if (!todo) { | 2762 | if (!todo) { |
2755 | KNotifyClient::beep(); | 2763 | KNotifyClient::beep(); |
2756 | return; | 2764 | return; |
2757 | } | 2765 | } |
2758 | if (KOPrefs::instance()->mConfirm) { | 2766 | if (KOPrefs::instance()->mConfirm) { |
2759 | switch (msgItemDelete()) { | 2767 | switch (msgItemDelete()) { |
2760 | case KMessageBox::Continue: // OK | 2768 | case KMessageBox::Continue: // OK |
2761 | if (!todo->relations().isEmpty()) { | 2769 | if (!todo->relations().isEmpty()) { |
2762 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2770 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2763 | i18n("Delete To-Do")); | 2771 | i18n("Delete To-Do")); |
2764 | } else { | 2772 | } else { |
2765 | checkExternalId( todo ); | 2773 | checkExternalId( todo ); |
2766 | calendar()->deleteTodo(todo); | 2774 | calendar()->deleteTodo(todo); |
2767 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2775 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2768 | updateView(); | 2776 | updateView(); |
2769 | } | 2777 | } |
2770 | break; | 2778 | break; |
2771 | } // switch | 2779 | } // switch |
2772 | } else { | 2780 | } else { |
2773 | if (!todo->relations().isEmpty()) { | 2781 | if (!todo->relations().isEmpty()) { |
2774 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2782 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2775 | i18n("Delete To-Do")); | 2783 | i18n("Delete To-Do")); |
2776 | } else { | 2784 | } else { |
2777 | checkExternalId( todo ); | 2785 | checkExternalId( todo ); |
2778 | mCalendar->deleteTodo(todo); | 2786 | mCalendar->deleteTodo(todo); |
2779 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2787 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2780 | updateView(); | 2788 | updateView(); |
2781 | } | 2789 | } |
2782 | } | 2790 | } |
2783 | emit updateSearchDialog(); | 2791 | emit updateSearchDialog(); |
2784 | } | 2792 | } |
2785 | void CalendarView::deleteJournal(Journal *jour) | 2793 | void CalendarView::deleteJournal(Journal *jour) |
2786 | { | 2794 | { |
2787 | if (!jour) { | 2795 | if (!jour) { |
2788 | KNotifyClient::beep(); | 2796 | KNotifyClient::beep(); |
2789 | return; | 2797 | return; |
2790 | } | 2798 | } |
2791 | if (KOPrefs::instance()->mConfirm) { | 2799 | if (KOPrefs::instance()->mConfirm) { |
2792 | switch (msgItemDelete()) { | 2800 | switch (msgItemDelete()) { |
2793 | case KMessageBox::Continue: // OK | 2801 | case KMessageBox::Continue: // OK |
2794 | calendar()->deleteJournal(jour); | 2802 | calendar()->deleteJournal(jour); |
2795 | updateView(); | 2803 | updateView(); |
2796 | break; | 2804 | break; |
2797 | } // switch | 2805 | } // switch |
2798 | } else { | 2806 | } else { |
2799 | calendar()->deleteJournal(jour);; | 2807 | calendar()->deleteJournal(jour);; |
2800 | updateView(); | 2808 | updateView(); |
2801 | } | 2809 | } |
2802 | emit updateSearchDialog(); | 2810 | emit updateSearchDialog(); |
2803 | } | 2811 | } |
2804 | 2812 | ||
2805 | void CalendarView::deleteEvent(Event *anEvent) | 2813 | void CalendarView::deleteEvent(Event *anEvent) |
2806 | { | 2814 | { |
2807 | if (!anEvent) { | 2815 | if (!anEvent) { |
2808 | KNotifyClient::beep(); | 2816 | KNotifyClient::beep(); |
2809 | return; | 2817 | return; |
2810 | } | 2818 | } |
2811 | 2819 | ||
2812 | if (anEvent->recurrence()->doesRecur()) { | 2820 | if (anEvent->recurrence()->doesRecur()) { |
2813 | QDate itemDate = mViewManager->currentSelectionDate(); | 2821 | QDate itemDate = mViewManager->currentSelectionDate(); |
2814 | int km; | 2822 | int km; |
2815 | if (!itemDate.isValid()) { | 2823 | if (!itemDate.isValid()) { |
2816 | //kdDebug() << "Date Not Valid" << endl; | 2824 | //kdDebug() << "Date Not Valid" << endl; |
2817 | if (KOPrefs::instance()->mConfirm) { | 2825 | if (KOPrefs::instance()->mConfirm) { |
2818 | km = KMessageBox::warningContinueCancel(this,anEvent->summary() + | 2826 | km = KMessageBox::warningContinueCancel(this,anEvent->summary() + |
2819 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 2827 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
2820 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 2828 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
2821 | if ( km == KMessageBox::Continue ) | 2829 | if ( km == KMessageBox::Continue ) |
2822 | km = KMessageBox::No; // No = all below | 2830 | km = KMessageBox::No; // No = all below |
2823 | } else | 2831 | } else |
2824 | km = KMessageBox::No; | 2832 | km = KMessageBox::No; |
2825 | } else { | 2833 | } else { |
2826 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + | 2834 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + |
2827 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 2835 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
2828 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 2836 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
2829 | i18n("KO/Pi Confirmation"),i18n("Current"), | 2837 | i18n("KO/Pi Confirmation"),i18n("Current"), |
2830 | i18n("All")); | 2838 | i18n("All")); |
2831 | } | 2839 | } |
2832 | switch(km) { | 2840 | switch(km) { |
2833 | 2841 | ||
2834 | case KMessageBox::No: // Continue // all | 2842 | case KMessageBox::No: // Continue // all |
2835 | //qDebug("KMessageBox::No "); | 2843 | //qDebug("KMessageBox::No "); |
2836 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2844 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2837 | schedule(Scheduler::Cancel,anEvent); | 2845 | schedule(Scheduler::Cancel,anEvent); |
2838 | 2846 | ||
2839 | checkExternalId( anEvent); | 2847 | checkExternalId( anEvent); |
2840 | mCalendar->deleteEvent(anEvent); | 2848 | mCalendar->deleteEvent(anEvent); |
2841 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 2849 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
2842 | break; | 2850 | break; |
2843 | 2851 | ||
2844 | // Disabled because it does not work | 2852 | // Disabled because it does not work |
2845 | //#if 0 | 2853 | //#if 0 |
2846 | case KMessageBox::Yes: // just this one | 2854 | case KMessageBox::Yes: // just this one |
2847 | //QDate qd = mNavigator->selectedDates().first(); | 2855 | //QDate qd = mNavigator->selectedDates().first(); |
2848 | //if (!qd.isValid()) { | 2856 | //if (!qd.isValid()) { |
2849 | // kdDebug() << "no date selected, or invalid date" << endl; | 2857 | // kdDebug() << "no date selected, or invalid date" << endl; |
2850 | // KNotifyClient::beep(); | 2858 | // KNotifyClient::beep(); |
2851 | // return; | 2859 | // return; |
2852 | //} | 2860 | //} |
2853 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 2861 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
2854 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 2862 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
2855 | anEvent->addExDate(itemDate); | 2863 | anEvent->addExDate(itemDate); |
2856 | int duration = anEvent->recurrence()->duration(); | 2864 | int duration = anEvent->recurrence()->duration(); |
2857 | if ( duration > 0 ) { | 2865 | if ( duration > 0 ) { |
2858 | anEvent->recurrence()->setDuration( duration - 1 ); | 2866 | anEvent->recurrence()->setDuration( duration - 1 ); |
2859 | } | 2867 | } |
2860 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 2868 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
2861 | } | 2869 | } |
2862 | break; | 2870 | break; |
2863 | //#endif | 2871 | //#endif |
2864 | } // switch | 2872 | } // switch |
2865 | } else { | 2873 | } else { |
2866 | if (KOPrefs::instance()->mConfirm) { | 2874 | if (KOPrefs::instance()->mConfirm) { |
2867 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + | 2875 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + |
diff --git a/microkde/kapplication.cpp b/microkde/kapplication.cpp index 98ef2f2..56c01af 100644 --- a/microkde/kapplication.cpp +++ b/microkde/kapplication.cpp | |||
@@ -1,84 +1,106 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <stdio.h> | 2 | #include <stdio.h> |
3 | 3 | ||
4 | #include "kapplication.h" | 4 | #include "kapplication.h" |
5 | #include <qapplication.h> | 5 | #include <qapplication.h> |
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | #include <qfile.h> | 7 | #include <qfile.h> |
8 | #include <qtextstream.h> | 8 | #include <qtextstream.h> |
9 | #include <qdialog.h> | 9 | #include <qdialog.h> |
10 | #include <qlayout.h> | 10 | #include <qlayout.h> |
11 | #include <qtextbrowser.h> | 11 | #include <qtextbrowser.h> |
12 | 12 | ||
13 | int KApplication::random() | 13 | int KApplication::random() |
14 | { | 14 | { |
15 | return rand(); | 15 | return rand(); |
16 | } | 16 | } |
17 | 17 | ||
18 | //US | 18 | //US |
19 | QString KApplication::randomString(int length) | 19 | QString KApplication::randomString(int length) |
20 | { | 20 | { |
21 | if (length <=0 ) return QString::null; | 21 | if (length <=0 ) return QString::null; |
22 | 22 | ||
23 | QString str; | 23 | QString str; |
24 | while (length--) | 24 | while (length--) |
25 | { | 25 | { |
26 | int r=random() % 62; | 26 | int r=random() % 62; |
27 | r+=48; | 27 | r+=48; |
28 | if (r>57) r+=7; | 28 | if (r>57) r+=7; |
29 | if (r>90) r+=6; | 29 | if (r>90) r+=6; |
30 | str += char(r); | 30 | str += char(r); |
31 | // so what if I work backwards? | 31 | // so what if I work backwards? |
32 | } | 32 | } |
33 | return str; | 33 | return str; |
34 | } | 34 | } |
35 | int KApplication::execDialog( QDialog* d ) | 35 | int KApplication::execDialog( QDialog* d ) |
36 | { | 36 | { |
37 | if (QApplication::desktop()->width() <= 640 ) | 37 | if (QApplication::desktop()->width() <= 640 ) |
38 | d->showMaximized(); | 38 | d->showMaximized(); |
39 | return d->exec(); | 39 | return d->exec(); |
40 | } | 40 | } |
41 | void KApplication::showLicence() | 41 | void KApplication::showLicence() |
42 | { | 42 | { |
43 | KApplication::showFile( "KDE-Pim/Pi licence", "kdepim/LICENCE.TXT" ); | 43 | KApplication::showFile( "KDE-Pim/Pi licence", "kdepim/LICENCE.TXT" ); |
44 | } | 44 | } |
45 | 45 | ||
46 | void KApplication::showFile(QString caption, QString fn) | 46 | void KApplication::showFile(QString caption, QString fn) |
47 | { | 47 | { |
48 | QString text; | 48 | QString text; |
49 | QString fileName; | 49 | QString fileName; |
50 | #ifndef DESKTOP_VERSION | 50 | #ifndef DESKTOP_VERSION |
51 | fileName = getenv("QPEDIR"); | 51 | fileName = getenv("QPEDIR"); |
52 | fileName += "/pics/" + fn ; | 52 | fileName += "/pics/" + fn ; |
53 | #else | 53 | #else |
54 | fileName = qApp->applicationDirPath () + "/" + fn; | 54 | fileName = qApp->applicationDirPath () + "/" + fn; |
55 | #endif | 55 | #endif |
56 | QFile file( fileName ); | 56 | QFile file( fileName ); |
57 | if (!file.open( IO_ReadOnly ) ) { | 57 | if (!file.open( IO_ReadOnly ) ) { |
58 | return ; | 58 | return ; |
59 | } | 59 | } |
60 | QTextStream ts( &file ); | 60 | QTextStream ts( &file ); |
61 | text = ts.read(); | 61 | text = ts.read(); |
62 | file.close(); | 62 | file.close(); |
63 | KApplication::showText( caption, text ); | 63 | KApplication::showText( caption, text ); |
64 | 64 | ||
65 | } | 65 | } |
66 | 66 | ||
67 | bool KApplication::convert2latin1(QString fileName) | ||
68 | { | ||
69 | QString text; | ||
70 | QFile file( fileName ); | ||
71 | if (!file.open( IO_ReadOnly ) ) { | ||
72 | return false; | ||
73 | |||
74 | } | ||
75 | QTextStream ts( &file ); | ||
76 | ts.setEncoding( QTextStream::UnicodeUTF8 ); | ||
77 | text = ts.read(); | ||
78 | file.close(); | ||
79 | if (!file.open( IO_WriteOnly ) ) { | ||
80 | return false; | ||
81 | } | ||
82 | QTextStream tsIn( &file ); | ||
83 | tsIn.setEncoding( QTextStream::Latin1 ); | ||
84 | tsIn << text.latin1(); | ||
85 | file.close(); | ||
86 | |||
87 | |||
88 | } | ||
67 | void KApplication::showText(QString caption, QString text) | 89 | void KApplication::showText(QString caption, QString text) |
68 | { | 90 | { |
69 | QDialog dia( 0, "name", true ); ; | 91 | QDialog dia( 0, "name", true ); ; |
70 | dia.setCaption( caption ); | 92 | dia.setCaption( caption ); |
71 | QVBoxLayout* lay = new QVBoxLayout( &dia ); | 93 | QVBoxLayout* lay = new QVBoxLayout( &dia ); |
72 | lay->setSpacing( 3 ); | 94 | lay->setSpacing( 3 ); |
73 | lay->setMargin( 3 ); | 95 | lay->setMargin( 3 ); |
74 | QTextBrowser tb ( &dia ); | 96 | QTextBrowser tb ( &dia ); |
75 | lay->addWidget( &tb ); | 97 | lay->addWidget( &tb ); |
76 | tb.setText( text ); | 98 | tb.setText( text ); |
77 | #ifdef DESKTOP_VERSION | 99 | #ifdef DESKTOP_VERSION |
78 | dia.resize( 640, 480); | 100 | dia.resize( 640, 480); |
79 | #else | 101 | #else |
80 | dia.showMaximized(); | 102 | dia.showMaximized(); |
81 | #endif | 103 | #endif |
82 | dia.exec(); | 104 | dia.exec(); |
83 | 105 | ||
84 | } | 106 | } |
diff --git a/microkde/kapplication.h b/microkde/kapplication.h index 79cdb33..41546a0 100644 --- a/microkde/kapplication.h +++ b/microkde/kapplication.h | |||
@@ -1,26 +1,27 @@ | |||
1 | #ifndef MINIKDE_KAPPLICATION_H | 1 | #ifndef MINIKDE_KAPPLICATION_H |
2 | #define MINIKDE_KAPPLICATION_H | 2 | #define MINIKDE_KAPPLICATION_H |
3 | 3 | ||
4 | #include "qstring.h" | 4 | #include "qstring.h" |
5 | #include <qdialog.h> | 5 | #include <qdialog.h> |
6 | 6 | ||
7 | class KApplication | 7 | class KApplication |
8 | { | 8 | { |
9 | public: | 9 | public: |
10 | static int random(); | 10 | static int random(); |
11 | 11 | ||
12 | //US | 12 | //US |
13 | /** | 13 | /** |
14 | * Generates a random string. It operates in the range [A-Za-z0-9] | 14 | * Generates a random string. It operates in the range [A-Za-z0-9] |
15 | * @param length Generate a string of this length. | 15 | * @param length Generate a string of this length. |
16 | * @return the random string | 16 | * @return the random string |
17 | */ | 17 | */ |
18 | static QString randomString(int length); | 18 | static QString randomString(int length); |
19 | static int execDialog( QDialog* ); | 19 | static int execDialog( QDialog* ); |
20 | static void showLicence(); | 20 | static void showLicence(); |
21 | static void showFile(QString caption, QString file); | 21 | static void showFile(QString caption, QString file); |
22 | static void showText(QString caption, QString text); | 22 | static void showText(QString caption, QString text); |
23 | static bool convert2latin1(QString file); | ||
23 | }; | 24 | }; |
24 | 25 | ||
25 | 26 | ||
26 | #endif | 27 | #endif |