author | zautrix <zautrix> | 2004-09-13 21:35:12 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-13 21:35:12 (UTC) |
commit | bd6b4acb39498ffea3beea7d9b5f7620b60c14db (patch) (unidiff) | |
tree | e2d7425b7bb49fbcb7acb5ced497ac1fed06dfaf | |
parent | 06eabf6e82c0390699d11fd12580d91261829431 (diff) | |
download | kdepimpi-bd6b4acb39498ffea3beea7d9b5f7620b60c14db.zip kdepimpi-bd6b4acb39498ffea3beea7d9b5f7620b60c14db.tar.gz kdepimpi-bd6b4acb39498ffea3beea7d9b5f7620b60c14db.tar.bz2 |
Many bugfixes
-rw-r--r-- | kabc/addressee.cpp | 62 | ||||
-rw-r--r-- | kaddressbook/addresseeeditorwidget.cpp | 56 | ||||
-rw-r--r-- | kaddressbook/mainembedded.cpp | 15 | ||||
-rw-r--r-- | kaddressbook/nameeditdialog.cpp | 7 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/genericwrapper.cpp | 2 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 8 | ||||
-rw-r--r-- | libkdepim/addresseeview.cpp | 10 | ||||
-rw-r--r-- | libkdepim/kdateedit.cpp | 17 | ||||
-rw-r--r-- | libkdepim/kdateedit.h | 3 | ||||
-rw-r--r-- | microkde/kdeui/kaction.cpp | 44 |
10 files changed, 144 insertions, 80 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 6b282e2..4cdd5e5 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1,1626 +1,1630 @@ | |||
1 | /*** Warning! This file has been generated by the script makeaddressee ***/ | 1 | /*** Warning! This file has been generated by the script makeaddressee ***/ |
2 | /* | 2 | /* |
3 | This file is part of libkabc. | 3 | This file is part of libkabc. |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <kconfig.h> | 29 | #include <kconfig.h> |
30 | 30 | ||
31 | #include <ksharedptr.h> | 31 | #include <ksharedptr.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <kapplication.h> | 33 | #include <kapplication.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | //US | 35 | //US |
36 | #include <kstandarddirs.h> | 36 | #include <kstandarddirs.h> |
37 | 37 | ||
38 | //US #include "resource.h" | 38 | //US #include "resource.h" |
39 | #include "addressee.h" | 39 | #include "addressee.h" |
40 | 40 | ||
41 | using namespace KABC; | 41 | using namespace KABC; |
42 | 42 | ||
43 | static bool matchBinaryPattern( int value, int pattern ); | 43 | static bool matchBinaryPattern( int value, int pattern ); |
44 | 44 | ||
45 | struct Addressee::AddresseeData : public KShared | 45 | struct Addressee::AddresseeData : public KShared |
46 | { | 46 | { |
47 | QString uid; | 47 | QString uid; |
48 | QString name; | 48 | QString name; |
49 | QString formattedName; | 49 | QString formattedName; |
50 | QString familyName; | 50 | QString familyName; |
51 | QString givenName; | 51 | QString givenName; |
52 | QString additionalName; | 52 | QString additionalName; |
53 | QString prefix; | 53 | QString prefix; |
54 | QString suffix; | 54 | QString suffix; |
55 | QString nickName; | 55 | QString nickName; |
56 | QDateTime birthday; | 56 | QDateTime birthday; |
57 | QString mailer; | 57 | QString mailer; |
58 | TimeZone timeZone; | 58 | TimeZone timeZone; |
59 | Geo geo; | 59 | Geo geo; |
60 | QString title; | 60 | QString title; |
61 | QString role; | 61 | QString role; |
62 | QString organization; | 62 | QString organization; |
63 | QString note; | 63 | QString note; |
64 | QString productId; | 64 | QString productId; |
65 | QDateTime revision; | 65 | QDateTime revision; |
66 | QString sortString; | 66 | QString sortString; |
67 | KURL url; | 67 | KURL url; |
68 | Secrecy secrecy; | 68 | Secrecy secrecy; |
69 | Picture logo; | 69 | Picture logo; |
70 | Picture photo; | 70 | Picture photo; |
71 | Sound sound; | 71 | Sound sound; |
72 | Agent agent; | 72 | Agent agent; |
73 | 73 | ||
74 | PhoneNumber::List phoneNumbers; | 74 | PhoneNumber::List phoneNumbers; |
75 | Address::List addresses; | 75 | Address::List addresses; |
76 | Key::List keys; | 76 | Key::List keys; |
77 | QStringList emails; | 77 | QStringList emails; |
78 | QStringList categories; | 78 | QStringList categories; |
79 | QStringList custom; | 79 | QStringList custom; |
80 | 80 | ||
81 | Resource *resource; | 81 | Resource *resource; |
82 | 82 | ||
83 | bool empty :1; | 83 | bool empty :1; |
84 | bool changed :1; | 84 | bool changed :1; |
85 | }; | 85 | }; |
86 | 86 | ||
87 | Addressee::Addressee() | 87 | Addressee::Addressee() |
88 | { | 88 | { |
89 | mData = new AddresseeData; | 89 | mData = new AddresseeData; |
90 | mData->empty = true; | 90 | mData->empty = true; |
91 | mData->changed = false; | 91 | mData->changed = false; |
92 | mData->resource = 0; | 92 | mData->resource = 0; |
93 | } | 93 | } |
94 | 94 | ||
95 | Addressee::~Addressee() | 95 | Addressee::~Addressee() |
96 | { | 96 | { |
97 | } | 97 | } |
98 | 98 | ||
99 | Addressee::Addressee( const Addressee &a ) | 99 | Addressee::Addressee( const Addressee &a ) |
100 | { | 100 | { |
101 | mData = a.mData; | 101 | mData = a.mData; |
102 | } | 102 | } |
103 | 103 | ||
104 | Addressee &Addressee::operator=( const Addressee &a ) | 104 | Addressee &Addressee::operator=( const Addressee &a ) |
105 | { | 105 | { |
106 | mData = a.mData; | 106 | mData = a.mData; |
107 | return (*this); | 107 | return (*this); |
108 | } | 108 | } |
109 | 109 | ||
110 | Addressee Addressee::copy() | 110 | Addressee Addressee::copy() |
111 | { | 111 | { |
112 | Addressee a; | 112 | Addressee a; |
113 | *(a.mData) = *mData; | 113 | *(a.mData) = *mData; |
114 | return a; | 114 | return a; |
115 | } | 115 | } |
116 | 116 | ||
117 | void Addressee::detach() | 117 | void Addressee::detach() |
118 | { | 118 | { |
119 | if ( mData.count() == 1 ) return; | 119 | if ( mData.count() == 1 ) return; |
120 | *this = copy(); | 120 | *this = copy(); |
121 | } | 121 | } |
122 | 122 | ||
123 | bool Addressee::operator==( const Addressee &a ) const | 123 | bool Addressee::operator==( const Addressee &a ) const |
124 | { | 124 | { |
125 | if ( uid() != a.uid() ) return false; | 125 | if ( uid() != a.uid() ) return false; |
126 | if ( mData->name != a.mData->name ) return false; | 126 | if ( mData->name != a.mData->name ) return false; |
127 | if ( mData->formattedName != a.mData->formattedName ) return false; | 127 | if ( mData->formattedName != a.mData->formattedName ) return false; |
128 | if ( mData->familyName != a.mData->familyName ) return false; | 128 | if ( mData->familyName != a.mData->familyName ) return false; |
129 | if ( mData->givenName != a.mData->givenName ) return false; | 129 | if ( mData->givenName != a.mData->givenName ) return false; |
130 | if ( mData->additionalName != a.mData->additionalName ) return false; | 130 | if ( mData->additionalName != a.mData->additionalName ) return false; |
131 | if ( mData->prefix != a.mData->prefix ) return false; | 131 | if ( mData->prefix != a.mData->prefix ) return false; |
132 | if ( mData->suffix != a.mData->suffix ) return false; | 132 | if ( mData->suffix != a.mData->suffix ) return false; |
133 | if ( mData->nickName != a.mData->nickName ) return false; | 133 | if ( mData->nickName != a.mData->nickName ) return false; |
134 | if ( mData->birthday != a.mData->birthday ) return false; | 134 | if ( mData->birthday != a.mData->birthday ) return false; |
135 | if ( mData->mailer != a.mData->mailer ) return false; | 135 | if ( mData->mailer != a.mData->mailer ) return false; |
136 | if ( mData->timeZone != a.mData->timeZone ) return false; | 136 | if ( mData->timeZone != a.mData->timeZone ) return false; |
137 | if ( mData->geo != a.mData->geo ) return false; | 137 | if ( mData->geo != a.mData->geo ) return false; |
138 | if ( mData->title != a.mData->title ) return false; | 138 | if ( mData->title != a.mData->title ) return false; |
139 | if ( mData->role != a.mData->role ) return false; | 139 | if ( mData->role != a.mData->role ) return false; |
140 | if ( mData->organization != a.mData->organization ) return false; | 140 | if ( mData->organization != a.mData->organization ) return false; |
141 | if ( mData->note != a.mData->note ) return false; | 141 | if ( mData->note != a.mData->note ) return false; |
142 | if ( mData->productId != a.mData->productId ) return false; | 142 | if ( mData->productId != a.mData->productId ) return false; |
143 | if ( mData->revision != a.mData->revision ) return false; | 143 | if ( mData->revision != a.mData->revision ) return false; |
144 | if ( mData->sortString != a.mData->sortString ) return false; | 144 | if ( mData->sortString != a.mData->sortString ) return false; |
145 | if ( mData->secrecy != a.mData->secrecy ) return false; | 145 | if ( mData->secrecy != a.mData->secrecy ) return false; |
146 | if ( mData->logo != a.mData->logo ) return false; | 146 | if ( mData->logo != a.mData->logo ) return false; |
147 | if ( mData->photo != a.mData->photo ) return false; | 147 | if ( mData->photo != a.mData->photo ) return false; |
148 | if ( mData->sound != a.mData->sound ) return false; | 148 | if ( mData->sound != a.mData->sound ) return false; |
149 | if ( mData->agent != a.mData->agent ) return false; | 149 | if ( mData->agent != a.mData->agent ) return false; |
150 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && | 150 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && |
151 | ( mData->url != a.mData->url ) ) return false; | 151 | ( mData->url != a.mData->url ) ) return false; |
152 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; | 152 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; |
153 | if ( mData->addresses != a.mData->addresses ) return false; | 153 | if ( mData->addresses != a.mData->addresses ) return false; |
154 | if ( mData->keys != a.mData->keys ) return false; | 154 | if ( mData->keys != a.mData->keys ) return false; |
155 | if ( mData->emails != a.mData->emails ) return false; | 155 | if ( mData->emails != a.mData->emails ) return false; |
156 | if ( mData->categories != a.mData->categories ) return false; | 156 | if ( mData->categories != a.mData->categories ) return false; |
157 | if ( mData->custom != a.mData->custom ) return false; | 157 | if ( mData->custom != a.mData->custom ) return false; |
158 | 158 | ||
159 | return true; | 159 | return true; |
160 | } | 160 | } |
161 | 161 | ||
162 | bool Addressee::operator!=( const Addressee &a ) const | 162 | bool Addressee::operator!=( const Addressee &a ) const |
163 | { | 163 | { |
164 | return !( a == *this ); | 164 | return !( a == *this ); |
165 | } | 165 | } |
166 | 166 | ||
167 | bool Addressee::isEmpty() const | 167 | bool Addressee::isEmpty() const |
168 | { | 168 | { |
169 | return mData->empty; | 169 | return mData->empty; |
170 | } | 170 | } |
171 | 171 | ||
172 | void Addressee::setUid( const QString &id ) | 172 | void Addressee::setUid( const QString &id ) |
173 | { | 173 | { |
174 | if ( id == mData->uid ) return; | 174 | if ( id == mData->uid ) return; |
175 | detach(); | 175 | detach(); |
176 | mData->empty = false; | 176 | mData->empty = false; |
177 | mData->uid = id; | 177 | mData->uid = id; |
178 | } | 178 | } |
179 | 179 | ||
180 | QString Addressee::uid() const | 180 | QString Addressee::uid() const |
181 | { | 181 | { |
182 | if ( mData->uid.isEmpty() ) | 182 | if ( mData->uid.isEmpty() ) |
183 | mData->uid = KApplication::randomString( 10 ); | 183 | mData->uid = KApplication::randomString( 10 ); |
184 | 184 | ||
185 | return mData->uid; | 185 | return mData->uid; |
186 | } | 186 | } |
187 | 187 | ||
188 | QString Addressee::uidLabel() | 188 | QString Addressee::uidLabel() |
189 | { | 189 | { |
190 | return i18n("Unique Identifier"); | 190 | return i18n("Unique Identifier"); |
191 | } | 191 | } |
192 | 192 | ||
193 | void Addressee::setName( const QString &name ) | 193 | void Addressee::setName( const QString &name ) |
194 | { | 194 | { |
195 | if ( name == mData->name ) return; | 195 | if ( name == mData->name ) return; |
196 | detach(); | 196 | detach(); |
197 | mData->empty = false; | 197 | mData->empty = false; |
198 | mData->name = name; | 198 | mData->name = name; |
199 | } | 199 | } |
200 | 200 | ||
201 | QString Addressee::name() const | 201 | QString Addressee::name() const |
202 | { | 202 | { |
203 | return mData->name; | 203 | return mData->name; |
204 | } | 204 | } |
205 | 205 | ||
206 | QString Addressee::nameLabel() | 206 | QString Addressee::nameLabel() |
207 | { | 207 | { |
208 | return i18n("Name"); | 208 | return i18n("Name"); |
209 | } | 209 | } |
210 | 210 | ||
211 | 211 | ||
212 | void Addressee::setFormattedName( const QString &formattedName ) | 212 | void Addressee::setFormattedName( const QString &formattedName ) |
213 | { | 213 | { |
214 | if ( formattedName == mData->formattedName ) return; | 214 | if ( formattedName == mData->formattedName ) return; |
215 | detach(); | 215 | detach(); |
216 | mData->empty = false; | 216 | mData->empty = false; |
217 | mData->formattedName = formattedName; | 217 | mData->formattedName = formattedName; |
218 | } | 218 | } |
219 | 219 | ||
220 | QString Addressee::formattedName() const | 220 | QString Addressee::formattedName() const |
221 | { | 221 | { |
222 | return mData->formattedName; | 222 | return mData->formattedName; |
223 | } | 223 | } |
224 | 224 | ||
225 | QString Addressee::formattedNameLabel() | 225 | QString Addressee::formattedNameLabel() |
226 | { | 226 | { |
227 | return i18n("Formatted Name"); | 227 | return i18n("Formatted Name"); |
228 | } | 228 | } |
229 | 229 | ||
230 | 230 | ||
231 | void Addressee::setFamilyName( const QString &familyName ) | 231 | void Addressee::setFamilyName( const QString &familyName ) |
232 | { | 232 | { |
233 | if ( familyName == mData->familyName ) return; | 233 | if ( familyName == mData->familyName ) return; |
234 | detach(); | 234 | detach(); |
235 | mData->empty = false; | 235 | mData->empty = false; |
236 | mData->familyName = familyName; | 236 | mData->familyName = familyName; |
237 | } | 237 | } |
238 | 238 | ||
239 | QString Addressee::familyName() const | 239 | QString Addressee::familyName() const |
240 | { | 240 | { |
241 | return mData->familyName; | 241 | return mData->familyName; |
242 | } | 242 | } |
243 | 243 | ||
244 | QString Addressee::familyNameLabel() | 244 | QString Addressee::familyNameLabel() |
245 | { | 245 | { |
246 | return i18n("Family Name"); | 246 | return i18n("Family Name"); |
247 | } | 247 | } |
248 | 248 | ||
249 | 249 | ||
250 | void Addressee::setGivenName( const QString &givenName ) | 250 | void Addressee::setGivenName( const QString &givenName ) |
251 | { | 251 | { |
252 | if ( givenName == mData->givenName ) return; | 252 | if ( givenName == mData->givenName ) return; |
253 | detach(); | 253 | detach(); |
254 | mData->empty = false; | 254 | mData->empty = false; |
255 | mData->givenName = givenName; | 255 | mData->givenName = givenName; |
256 | } | 256 | } |
257 | 257 | ||
258 | QString Addressee::givenName() const | 258 | QString Addressee::givenName() const |
259 | { | 259 | { |
260 | return mData->givenName; | 260 | return mData->givenName; |
261 | } | 261 | } |
262 | 262 | ||
263 | QString Addressee::givenNameLabel() | 263 | QString Addressee::givenNameLabel() |
264 | { | 264 | { |
265 | return i18n("Given Name"); | 265 | return i18n("Given Name"); |
266 | } | 266 | } |
267 | 267 | ||
268 | 268 | ||
269 | void Addressee::setAdditionalName( const QString &additionalName ) | 269 | void Addressee::setAdditionalName( const QString &additionalName ) |
270 | { | 270 | { |
271 | if ( additionalName == mData->additionalName ) return; | 271 | if ( additionalName == mData->additionalName ) return; |
272 | detach(); | 272 | detach(); |
273 | mData->empty = false; | 273 | mData->empty = false; |
274 | mData->additionalName = additionalName; | 274 | mData->additionalName = additionalName; |
275 | } | 275 | } |
276 | 276 | ||
277 | QString Addressee::additionalName() const | 277 | QString Addressee::additionalName() const |
278 | { | 278 | { |
279 | return mData->additionalName; | 279 | return mData->additionalName; |
280 | } | 280 | } |
281 | 281 | ||
282 | QString Addressee::additionalNameLabel() | 282 | QString Addressee::additionalNameLabel() |
283 | { | 283 | { |
284 | return i18n("Additional Names"); | 284 | return i18n("Additional Names"); |
285 | } | 285 | } |
286 | 286 | ||
287 | 287 | ||
288 | void Addressee::setPrefix( const QString &prefix ) | 288 | void Addressee::setPrefix( const QString &prefix ) |
289 | { | 289 | { |
290 | if ( prefix == mData->prefix ) return; | 290 | if ( prefix == mData->prefix ) return; |
291 | detach(); | 291 | detach(); |
292 | mData->empty = false; | 292 | mData->empty = false; |
293 | mData->prefix = prefix; | 293 | mData->prefix = prefix; |
294 | } | 294 | } |
295 | 295 | ||
296 | QString Addressee::prefix() const | 296 | QString Addressee::prefix() const |
297 | { | 297 | { |
298 | return mData->prefix; | 298 | return mData->prefix; |
299 | } | 299 | } |
300 | 300 | ||
301 | QString Addressee::prefixLabel() | 301 | QString Addressee::prefixLabel() |
302 | { | 302 | { |
303 | return i18n("Honorific Prefixes"); | 303 | return i18n("Honorific Prefixes"); |
304 | } | 304 | } |
305 | 305 | ||
306 | 306 | ||
307 | void Addressee::setSuffix( const QString &suffix ) | 307 | void Addressee::setSuffix( const QString &suffix ) |
308 | { | 308 | { |
309 | if ( suffix == mData->suffix ) return; | 309 | if ( suffix == mData->suffix ) return; |
310 | detach(); | 310 | detach(); |
311 | mData->empty = false; | 311 | mData->empty = false; |
312 | mData->suffix = suffix; | 312 | mData->suffix = suffix; |
313 | } | 313 | } |
314 | 314 | ||
315 | QString Addressee::suffix() const | 315 | QString Addressee::suffix() const |
316 | { | 316 | { |
317 | return mData->suffix; | 317 | return mData->suffix; |
318 | } | 318 | } |
319 | 319 | ||
320 | QString Addressee::suffixLabel() | 320 | QString Addressee::suffixLabel() |
321 | { | 321 | { |
322 | return i18n("Honorific Suffixes"); | 322 | return i18n("Honorific Suffixes"); |
323 | } | 323 | } |
324 | 324 | ||
325 | 325 | ||
326 | void Addressee::setNickName( const QString &nickName ) | 326 | void Addressee::setNickName( const QString &nickName ) |
327 | { | 327 | { |
328 | if ( nickName == mData->nickName ) return; | 328 | if ( nickName == mData->nickName ) return; |
329 | detach(); | 329 | detach(); |
330 | mData->empty = false; | 330 | mData->empty = false; |
331 | mData->nickName = nickName; | 331 | mData->nickName = nickName; |
332 | } | 332 | } |
333 | 333 | ||
334 | QString Addressee::nickName() const | 334 | QString Addressee::nickName() const |
335 | { | 335 | { |
336 | return mData->nickName; | 336 | return mData->nickName; |
337 | } | 337 | } |
338 | 338 | ||
339 | QString Addressee::nickNameLabel() | 339 | QString Addressee::nickNameLabel() |
340 | { | 340 | { |
341 | return i18n("Nick Name"); | 341 | return i18n("Nick Name"); |
342 | } | 342 | } |
343 | 343 | ||
344 | 344 | ||
345 | void Addressee::setBirthday( const QDateTime &birthday ) | 345 | void Addressee::setBirthday( const QDateTime &birthday ) |
346 | { | 346 | { |
347 | if ( birthday == mData->birthday ) return; | 347 | if ( birthday == mData->birthday ) return; |
348 | detach(); | 348 | detach(); |
349 | mData->empty = false; | 349 | mData->empty = false; |
350 | mData->birthday = birthday; | 350 | mData->birthday = birthday; |
351 | } | 351 | } |
352 | 352 | ||
353 | QDateTime Addressee::birthday() const | 353 | QDateTime Addressee::birthday() const |
354 | { | 354 | { |
355 | return mData->birthday; | 355 | return mData->birthday; |
356 | } | 356 | } |
357 | 357 | ||
358 | QString Addressee::birthdayLabel() | 358 | QString Addressee::birthdayLabel() |
359 | { | 359 | { |
360 | return i18n("Birthday"); | 360 | return i18n("Birthday"); |
361 | } | 361 | } |
362 | 362 | ||
363 | 363 | ||
364 | QString Addressee::homeAddressStreetLabel() | 364 | QString Addressee::homeAddressStreetLabel() |
365 | { | 365 | { |
366 | return i18n("Home Address Street"); | 366 | return i18n("Home Address Street"); |
367 | } | 367 | } |
368 | 368 | ||
369 | 369 | ||
370 | QString Addressee::homeAddressLocalityLabel() | 370 | QString Addressee::homeAddressLocalityLabel() |
371 | { | 371 | { |
372 | return i18n("Home Address Locality"); | 372 | return i18n("Home Address Locality"); |
373 | } | 373 | } |
374 | 374 | ||
375 | 375 | ||
376 | QString Addressee::homeAddressRegionLabel() | 376 | QString Addressee::homeAddressRegionLabel() |
377 | { | 377 | { |
378 | return i18n("Home Address Region"); | 378 | return i18n("Home Address Region"); |
379 | } | 379 | } |
380 | 380 | ||
381 | 381 | ||
382 | QString Addressee::homeAddressPostalCodeLabel() | 382 | QString Addressee::homeAddressPostalCodeLabel() |
383 | { | 383 | { |
384 | return i18n("Home Address Postal Code"); | 384 | return i18n("Home Address Postal Code"); |
385 | } | 385 | } |
386 | 386 | ||
387 | 387 | ||
388 | QString Addressee::homeAddressCountryLabel() | 388 | QString Addressee::homeAddressCountryLabel() |
389 | { | 389 | { |
390 | return i18n("Home Address Country"); | 390 | return i18n("Home Address Country"); |
391 | } | 391 | } |
392 | 392 | ||
393 | 393 | ||
394 | QString Addressee::homeAddressLabelLabel() | 394 | QString Addressee::homeAddressLabelLabel() |
395 | { | 395 | { |
396 | return i18n("Home Address Label"); | 396 | return i18n("Home Address Label"); |
397 | } | 397 | } |
398 | 398 | ||
399 | 399 | ||
400 | QString Addressee::businessAddressStreetLabel() | 400 | QString Addressee::businessAddressStreetLabel() |
401 | { | 401 | { |
402 | return i18n("Business Address Street"); | 402 | return i18n("Business Address Street"); |
403 | } | 403 | } |
404 | 404 | ||
405 | 405 | ||
406 | QString Addressee::businessAddressLocalityLabel() | 406 | QString Addressee::businessAddressLocalityLabel() |
407 | { | 407 | { |
408 | return i18n("Business Address Locality"); | 408 | return i18n("Business Address Locality"); |
409 | } | 409 | } |
410 | 410 | ||
411 | 411 | ||
412 | QString Addressee::businessAddressRegionLabel() | 412 | QString Addressee::businessAddressRegionLabel() |
413 | { | 413 | { |
414 | return i18n("Business Address Region"); | 414 | return i18n("Business Address Region"); |
415 | } | 415 | } |
416 | 416 | ||
417 | 417 | ||
418 | QString Addressee::businessAddressPostalCodeLabel() | 418 | QString Addressee::businessAddressPostalCodeLabel() |
419 | { | 419 | { |
420 | return i18n("Business Address Postal Code"); | 420 | return i18n("Business Address Postal Code"); |
421 | } | 421 | } |
422 | 422 | ||
423 | 423 | ||
424 | QString Addressee::businessAddressCountryLabel() | 424 | QString Addressee::businessAddressCountryLabel() |
425 | { | 425 | { |
426 | return i18n("Business Address Country"); | 426 | return i18n("Business Address Country"); |
427 | } | 427 | } |
428 | 428 | ||
429 | 429 | ||
430 | QString Addressee::businessAddressLabelLabel() | 430 | QString Addressee::businessAddressLabelLabel() |
431 | { | 431 | { |
432 | return i18n("Business Address Label"); | 432 | return i18n("Business Address Label"); |
433 | } | 433 | } |
434 | 434 | ||
435 | 435 | ||
436 | QString Addressee::homePhoneLabel() | 436 | QString Addressee::homePhoneLabel() |
437 | { | 437 | { |
438 | return i18n("Home Phone"); | 438 | return i18n("Home Phone"); |
439 | } | 439 | } |
440 | 440 | ||
441 | 441 | ||
442 | QString Addressee::businessPhoneLabel() | 442 | QString Addressee::businessPhoneLabel() |
443 | { | 443 | { |
444 | return i18n("Business Phone"); | 444 | return i18n("Business Phone"); |
445 | } | 445 | } |
446 | 446 | ||
447 | 447 | ||
448 | QString Addressee::mobilePhoneLabel() | 448 | QString Addressee::mobilePhoneLabel() |
449 | { | 449 | { |
450 | return i18n("Mobile Phone"); | 450 | return i18n("Mobile Phone"); |
451 | } | 451 | } |
452 | 452 | ||
453 | 453 | ||
454 | QString Addressee::homeFaxLabel() | 454 | QString Addressee::homeFaxLabel() |
455 | { | 455 | { |
456 | return i18n("Home Fax"); | 456 | return i18n("Home Fax"); |
457 | } | 457 | } |
458 | 458 | ||
459 | 459 | ||
460 | QString Addressee::businessFaxLabel() | 460 | QString Addressee::businessFaxLabel() |
461 | { | 461 | { |
462 | return i18n("Business Fax"); | 462 | return i18n("Business Fax"); |
463 | } | 463 | } |
464 | 464 | ||
465 | 465 | ||
466 | QString Addressee::carPhoneLabel() | 466 | QString Addressee::carPhoneLabel() |
467 | { | 467 | { |
468 | return i18n("Car Phone"); | 468 | return i18n("Car Phone"); |
469 | } | 469 | } |
470 | 470 | ||
471 | 471 | ||
472 | QString Addressee::isdnLabel() | 472 | QString Addressee::isdnLabel() |
473 | { | 473 | { |
474 | return i18n("ISDN"); | 474 | return i18n("ISDN"); |
475 | } | 475 | } |
476 | 476 | ||
477 | 477 | ||
478 | QString Addressee::pagerLabel() | 478 | QString Addressee::pagerLabel() |
479 | { | 479 | { |
480 | return i18n("Pager"); | 480 | return i18n("Pager"); |
481 | } | 481 | } |
482 | 482 | ||
483 | QString Addressee::sipLabel() | 483 | QString Addressee::sipLabel() |
484 | { | 484 | { |
485 | return i18n("SIP"); | 485 | return i18n("SIP"); |
486 | } | 486 | } |
487 | 487 | ||
488 | QString Addressee::emailLabel() | 488 | QString Addressee::emailLabel() |
489 | { | 489 | { |
490 | return i18n("Email Address"); | 490 | return i18n("Email Address"); |
491 | } | 491 | } |
492 | 492 | ||
493 | 493 | ||
494 | void Addressee::setMailer( const QString &mailer ) | 494 | void Addressee::setMailer( const QString &mailer ) |
495 | { | 495 | { |
496 | if ( mailer == mData->mailer ) return; | 496 | if ( mailer == mData->mailer ) return; |
497 | detach(); | 497 | detach(); |
498 | mData->empty = false; | 498 | mData->empty = false; |
499 | mData->mailer = mailer; | 499 | mData->mailer = mailer; |
500 | } | 500 | } |
501 | 501 | ||
502 | QString Addressee::mailer() const | 502 | QString Addressee::mailer() const |
503 | { | 503 | { |
504 | return mData->mailer; | 504 | return mData->mailer; |
505 | } | 505 | } |
506 | 506 | ||
507 | QString Addressee::mailerLabel() | 507 | QString Addressee::mailerLabel() |
508 | { | 508 | { |
509 | return i18n("Mail Client"); | 509 | return i18n("Mail Client"); |
510 | } | 510 | } |
511 | 511 | ||
512 | 512 | ||
513 | void Addressee::setTimeZone( const TimeZone &timeZone ) | 513 | void Addressee::setTimeZone( const TimeZone &timeZone ) |
514 | { | 514 | { |
515 | if ( timeZone == mData->timeZone ) return; | 515 | if ( timeZone == mData->timeZone ) return; |
516 | detach(); | 516 | detach(); |
517 | mData->empty = false; | 517 | mData->empty = false; |
518 | mData->timeZone = timeZone; | 518 | mData->timeZone = timeZone; |
519 | } | 519 | } |
520 | 520 | ||
521 | TimeZone Addressee::timeZone() const | 521 | TimeZone Addressee::timeZone() const |
522 | { | 522 | { |
523 | return mData->timeZone; | 523 | return mData->timeZone; |
524 | } | 524 | } |
525 | 525 | ||
526 | QString Addressee::timeZoneLabel() | 526 | QString Addressee::timeZoneLabel() |
527 | { | 527 | { |
528 | return i18n("Time Zone"); | 528 | return i18n("Time Zone"); |
529 | } | 529 | } |
530 | 530 | ||
531 | 531 | ||
532 | void Addressee::setGeo( const Geo &geo ) | 532 | void Addressee::setGeo( const Geo &geo ) |
533 | { | 533 | { |
534 | if ( geo == mData->geo ) return; | 534 | if ( geo == mData->geo ) return; |
535 | detach(); | 535 | detach(); |
536 | mData->empty = false; | 536 | mData->empty = false; |
537 | mData->geo = geo; | 537 | mData->geo = geo; |
538 | } | 538 | } |
539 | 539 | ||
540 | Geo Addressee::geo() const | 540 | Geo Addressee::geo() const |
541 | { | 541 | { |
542 | return mData->geo; | 542 | return mData->geo; |
543 | } | 543 | } |
544 | 544 | ||
545 | QString Addressee::geoLabel() | 545 | QString Addressee::geoLabel() |
546 | { | 546 | { |
547 | return i18n("Geographic Position"); | 547 | return i18n("Geographic Position"); |
548 | } | 548 | } |
549 | 549 | ||
550 | 550 | ||
551 | void Addressee::setTitle( const QString &title ) | 551 | void Addressee::setTitle( const QString &title ) |
552 | { | 552 | { |
553 | if ( title == mData->title ) return; | 553 | if ( title == mData->title ) return; |
554 | detach(); | 554 | detach(); |
555 | mData->empty = false; | 555 | mData->empty = false; |
556 | mData->title = title; | 556 | mData->title = title; |
557 | } | 557 | } |
558 | 558 | ||
559 | QString Addressee::title() const | 559 | QString Addressee::title() const |
560 | { | 560 | { |
561 | return mData->title; | 561 | return mData->title; |
562 | } | 562 | } |
563 | 563 | ||
564 | QString Addressee::titleLabel() | 564 | QString Addressee::titleLabel() |
565 | { | 565 | { |
566 | return i18n("Title"); | 566 | return i18n("Title"); |
567 | } | 567 | } |
568 | 568 | ||
569 | 569 | ||
570 | void Addressee::setRole( const QString &role ) | 570 | void Addressee::setRole( const QString &role ) |
571 | { | 571 | { |
572 | if ( role == mData->role ) return; | 572 | if ( role == mData->role ) return; |
573 | detach(); | 573 | detach(); |
574 | mData->empty = false; | 574 | mData->empty = false; |
575 | mData->role = role; | 575 | mData->role = role; |
576 | } | 576 | } |
577 | 577 | ||
578 | QString Addressee::role() const | 578 | QString Addressee::role() const |
579 | { | 579 | { |
580 | return mData->role; | 580 | return mData->role; |
581 | } | 581 | } |
582 | 582 | ||
583 | QString Addressee::roleLabel() | 583 | QString Addressee::roleLabel() |
584 | { | 584 | { |
585 | return i18n("Role"); | 585 | return i18n("Role"); |
586 | } | 586 | } |
587 | 587 | ||
588 | 588 | ||
589 | void Addressee::setOrganization( const QString &organization ) | 589 | void Addressee::setOrganization( const QString &organization ) |
590 | { | 590 | { |
591 | if ( organization == mData->organization ) return; | 591 | if ( organization == mData->organization ) return; |
592 | detach(); | 592 | detach(); |
593 | mData->empty = false; | 593 | mData->empty = false; |
594 | mData->organization = organization; | 594 | mData->organization = organization; |
595 | } | 595 | } |
596 | 596 | ||
597 | QString Addressee::organization() const | 597 | QString Addressee::organization() const |
598 | { | 598 | { |
599 | return mData->organization; | 599 | return mData->organization; |
600 | } | 600 | } |
601 | 601 | ||
602 | QString Addressee::organizationLabel() | 602 | QString Addressee::organizationLabel() |
603 | { | 603 | { |
604 | return i18n("Organization"); | 604 | return i18n("Organization"); |
605 | } | 605 | } |
606 | 606 | ||
607 | 607 | ||
608 | void Addressee::setNote( const QString ¬e ) | 608 | void Addressee::setNote( const QString ¬e ) |
609 | { | 609 | { |
610 | if ( note == mData->note ) return; | 610 | if ( note == mData->note ) return; |
611 | detach(); | 611 | detach(); |
612 | mData->empty = false; | 612 | mData->empty = false; |
613 | mData->note = note; | 613 | mData->note = note; |
614 | } | 614 | } |
615 | 615 | ||
616 | QString Addressee::note() const | 616 | QString Addressee::note() const |
617 | { | 617 | { |
618 | return mData->note; | 618 | return mData->note; |
619 | } | 619 | } |
620 | 620 | ||
621 | QString Addressee::noteLabel() | 621 | QString Addressee::noteLabel() |
622 | { | 622 | { |
623 | return i18n("Note"); | 623 | return i18n("Note"); |
624 | } | 624 | } |
625 | 625 | ||
626 | 626 | ||
627 | void Addressee::setProductId( const QString &productId ) | 627 | void Addressee::setProductId( const QString &productId ) |
628 | { | 628 | { |
629 | if ( productId == mData->productId ) return; | 629 | if ( productId == mData->productId ) return; |
630 | detach(); | 630 | detach(); |
631 | mData->empty = false; | 631 | mData->empty = false; |
632 | mData->productId = productId; | 632 | mData->productId = productId; |
633 | } | 633 | } |
634 | 634 | ||
635 | QString Addressee::productId() const | 635 | QString Addressee::productId() const |
636 | { | 636 | { |
637 | return mData->productId; | 637 | return mData->productId; |
638 | } | 638 | } |
639 | 639 | ||
640 | QString Addressee::productIdLabel() | 640 | QString Addressee::productIdLabel() |
641 | { | 641 | { |
642 | return i18n("Product Identifier"); | 642 | return i18n("Product Identifier"); |
643 | } | 643 | } |
644 | 644 | ||
645 | 645 | ||
646 | void Addressee::setRevision( const QDateTime &revision ) | 646 | void Addressee::setRevision( const QDateTime &revision ) |
647 | { | 647 | { |
648 | if ( revision == mData->revision ) return; | 648 | if ( revision == mData->revision ) return; |
649 | detach(); | 649 | detach(); |
650 | mData->empty = false; | 650 | mData->empty = false; |
651 | mData->revision = revision; | 651 | mData->revision = revision; |
652 | } | 652 | } |
653 | 653 | ||
654 | QDateTime Addressee::revision() const | 654 | QDateTime Addressee::revision() const |
655 | { | 655 | { |
656 | return mData->revision; | 656 | return mData->revision; |
657 | } | 657 | } |
658 | 658 | ||
659 | QString Addressee::revisionLabel() | 659 | QString Addressee::revisionLabel() |
660 | { | 660 | { |
661 | return i18n("Revision Date"); | 661 | return i18n("Revision Date"); |
662 | } | 662 | } |
663 | 663 | ||
664 | 664 | ||
665 | void Addressee::setSortString( const QString &sortString ) | 665 | void Addressee::setSortString( const QString &sortString ) |
666 | { | 666 | { |
667 | if ( sortString == mData->sortString ) return; | 667 | if ( sortString == mData->sortString ) return; |
668 | detach(); | 668 | detach(); |
669 | mData->empty = false; | 669 | mData->empty = false; |
670 | mData->sortString = sortString; | 670 | mData->sortString = sortString; |
671 | } | 671 | } |
672 | 672 | ||
673 | QString Addressee::sortString() const | 673 | QString Addressee::sortString() const |
674 | { | 674 | { |
675 | return mData->sortString; | 675 | return mData->sortString; |
676 | } | 676 | } |
677 | 677 | ||
678 | QString Addressee::sortStringLabel() | 678 | QString Addressee::sortStringLabel() |
679 | { | 679 | { |
680 | return i18n("Sort String"); | 680 | return i18n("Sort String"); |
681 | } | 681 | } |
682 | 682 | ||
683 | 683 | ||
684 | void Addressee::setUrl( const KURL &url ) | 684 | void Addressee::setUrl( const KURL &url ) |
685 | { | 685 | { |
686 | if ( url == mData->url ) return; | 686 | if ( url == mData->url ) return; |
687 | detach(); | 687 | detach(); |
688 | mData->empty = false; | 688 | mData->empty = false; |
689 | mData->url = url; | 689 | mData->url = url; |
690 | } | 690 | } |
691 | 691 | ||
692 | KURL Addressee::url() const | 692 | KURL Addressee::url() const |
693 | { | 693 | { |
694 | return mData->url; | 694 | return mData->url; |
695 | } | 695 | } |
696 | 696 | ||
697 | QString Addressee::urlLabel() | 697 | QString Addressee::urlLabel() |
698 | { | 698 | { |
699 | return i18n("URL"); | 699 | return i18n("URL"); |
700 | } | 700 | } |
701 | 701 | ||
702 | 702 | ||
703 | void Addressee::setSecrecy( const Secrecy &secrecy ) | 703 | void Addressee::setSecrecy( const Secrecy &secrecy ) |
704 | { | 704 | { |
705 | if ( secrecy == mData->secrecy ) return; | 705 | if ( secrecy == mData->secrecy ) return; |
706 | detach(); | 706 | detach(); |
707 | mData->empty = false; | 707 | mData->empty = false; |
708 | mData->secrecy = secrecy; | 708 | mData->secrecy = secrecy; |
709 | } | 709 | } |
710 | 710 | ||
711 | Secrecy Addressee::secrecy() const | 711 | Secrecy Addressee::secrecy() const |
712 | { | 712 | { |
713 | return mData->secrecy; | 713 | return mData->secrecy; |
714 | } | 714 | } |
715 | 715 | ||
716 | QString Addressee::secrecyLabel() | 716 | QString Addressee::secrecyLabel() |
717 | { | 717 | { |
718 | return i18n("Security Class"); | 718 | return i18n("Security Class"); |
719 | } | 719 | } |
720 | 720 | ||
721 | 721 | ||
722 | void Addressee::setLogo( const Picture &logo ) | 722 | void Addressee::setLogo( const Picture &logo ) |
723 | { | 723 | { |
724 | if ( logo == mData->logo ) return; | 724 | if ( logo == mData->logo ) return; |
725 | detach(); | 725 | detach(); |
726 | mData->empty = false; | 726 | mData->empty = false; |
727 | mData->logo = logo; | 727 | mData->logo = logo; |
728 | } | 728 | } |
729 | 729 | ||
730 | Picture Addressee::logo() const | 730 | Picture Addressee::logo() const |
731 | { | 731 | { |
732 | return mData->logo; | 732 | return mData->logo; |
733 | } | 733 | } |
734 | 734 | ||
735 | QString Addressee::logoLabel() | 735 | QString Addressee::logoLabel() |
736 | { | 736 | { |
737 | return i18n("Logo"); | 737 | return i18n("Logo"); |
738 | } | 738 | } |
739 | 739 | ||
740 | 740 | ||
741 | void Addressee::setPhoto( const Picture &photo ) | 741 | void Addressee::setPhoto( const Picture &photo ) |
742 | { | 742 | { |
743 | if ( photo == mData->photo ) return; | 743 | if ( photo == mData->photo ) return; |
744 | detach(); | 744 | detach(); |
745 | mData->empty = false; | 745 | mData->empty = false; |
746 | mData->photo = photo; | 746 | mData->photo = photo; |
747 | } | 747 | } |
748 | 748 | ||
749 | Picture Addressee::photo() const | 749 | Picture Addressee::photo() const |
750 | { | 750 | { |
751 | return mData->photo; | 751 | return mData->photo; |
752 | } | 752 | } |
753 | 753 | ||
754 | QString Addressee::photoLabel() | 754 | QString Addressee::photoLabel() |
755 | { | 755 | { |
756 | return i18n("Photo"); | 756 | return i18n("Photo"); |
757 | } | 757 | } |
758 | 758 | ||
759 | 759 | ||
760 | void Addressee::setSound( const Sound &sound ) | 760 | void Addressee::setSound( const Sound &sound ) |
761 | { | 761 | { |
762 | if ( sound == mData->sound ) return; | 762 | if ( sound == mData->sound ) return; |
763 | detach(); | 763 | detach(); |
764 | mData->empty = false; | 764 | mData->empty = false; |
765 | mData->sound = sound; | 765 | mData->sound = sound; |
766 | } | 766 | } |
767 | 767 | ||
768 | Sound Addressee::sound() const | 768 | Sound Addressee::sound() const |
769 | { | 769 | { |
770 | return mData->sound; | 770 | return mData->sound; |
771 | } | 771 | } |
772 | 772 | ||
773 | QString Addressee::soundLabel() | 773 | QString Addressee::soundLabel() |
774 | { | 774 | { |
775 | return i18n("Sound"); | 775 | return i18n("Sound"); |
776 | } | 776 | } |
777 | 777 | ||
778 | 778 | ||
779 | void Addressee::setAgent( const Agent &agent ) | 779 | void Addressee::setAgent( const Agent &agent ) |
780 | { | 780 | { |
781 | if ( agent == mData->agent ) return; | 781 | if ( agent == mData->agent ) return; |
782 | detach(); | 782 | detach(); |
783 | mData->empty = false; | 783 | mData->empty = false; |
784 | mData->agent = agent; | 784 | mData->agent = agent; |
785 | } | 785 | } |
786 | 786 | ||
787 | Agent Addressee::agent() const | 787 | Agent Addressee::agent() const |
788 | { | 788 | { |
789 | return mData->agent; | 789 | return mData->agent; |
790 | } | 790 | } |
791 | 791 | ||
792 | QString Addressee::agentLabel() | 792 | QString Addressee::agentLabel() |
793 | { | 793 | { |
794 | return i18n("Agent"); | 794 | return i18n("Agent"); |
795 | } | 795 | } |
796 | 796 | ||
797 | 797 | ||
798 | 798 | ||
799 | void Addressee::setNameFromString( const QString &str ) | 799 | void Addressee::setNameFromString( const QString &str ) |
800 | { | 800 | { |
801 | setFormattedName( str ); | 801 | setFormattedName( str ); |
802 | setName( str ); | 802 | setName( str ); |
803 | 803 | ||
804 | QStringList titles; | 804 | static bool first = true; |
805 | titles += i18n( "Dr." ); | 805 | static QStringList titles; |
806 | titles += i18n( "Miss" ); | 806 | static QStringList suffixes; |
807 | titles += i18n( "Mr." ); | 807 | static QStringList prefixes; |
808 | titles += i18n( "Mrs." ); | 808 | |
809 | titles += i18n( "Ms." ); | 809 | if ( first ) { |
810 | titles += i18n( "Prof." ); | 810 | first = false; |
811 | 811 | titles += i18n( "Dr." ); | |
812 | QStringList suffixes; | 812 | titles += i18n( "Miss" ); |
813 | suffixes += i18n( "I" ); | 813 | titles += i18n( "Mr." ); |
814 | suffixes += i18n( "II" ); | 814 | titles += i18n( "Mrs." ); |
815 | suffixes += i18n( "III" ); | 815 | titles += i18n( "Ms." ); |
816 | suffixes += i18n( "Jr." ); | 816 | titles += i18n( "Prof." ); |
817 | suffixes += i18n( "Sr." ); | 817 | |
818 | 818 | suffixes += i18n( "I" ); | |
819 | QStringList prefixes; | 819 | suffixes += i18n( "II" ); |
820 | prefixes += "van"; | 820 | suffixes += i18n( "III" ); |
821 | prefixes += "von"; | 821 | suffixes += i18n( "Jr." ); |
822 | prefixes += "de"; | 822 | suffixes += i18n( "Sr." ); |
823 | 823 | ||
824 | //US KConfig config( "kabcrc" ); | 824 | prefixes += "van"; |
825 | KConfig config( locateLocal( "config", "kabcrc") ); | 825 | prefixes += "von"; |
826 | config.setGroup( "General" ); | 826 | prefixes += "de"; |
827 | titles += config.readListEntry( "Prefixes" ); | 827 | |
828 | titles.remove( "" ); | 828 | KConfig config( locateLocal( "config", "kabcrc") ); |
829 | prefixes += config.readListEntry( "Inclusions" ); | 829 | config.setGroup( "General" ); |
830 | prefixes.remove( "" ); | 830 | titles += config.readListEntry( "Prefixes" ); |
831 | suffixes += config.readListEntry( "Suffixes" ); | 831 | titles.remove( "" ); |
832 | suffixes.remove( "" ); | 832 | prefixes += config.readListEntry( "Inclusions" ); |
833 | prefixes.remove( "" ); | ||
834 | suffixes += config.readListEntry( "Suffixes" ); | ||
835 | suffixes.remove( "" ); | ||
836 | } | ||
833 | 837 | ||
834 | // clear all name parts | 838 | // clear all name parts |
835 | setPrefix( "" ); | 839 | setPrefix( "" ); |
836 | setGivenName( "" ); | 840 | setGivenName( "" ); |
837 | setAdditionalName( "" ); | 841 | setAdditionalName( "" ); |
838 | setFamilyName( "" ); | 842 | setFamilyName( "" ); |
839 | setSuffix( "" ); | 843 | setSuffix( "" ); |
840 | 844 | ||
841 | if ( str.isEmpty() ) | 845 | if ( str.isEmpty() ) |
842 | return; | 846 | return; |
843 | 847 | ||
844 | int i = str.find(','); | 848 | int i = str.find(','); |
845 | if( i < 0 ) { | 849 | if( i < 0 ) { |
846 | QStringList parts = QStringList::split( " ", str ); | 850 | QStringList parts = QStringList::split( " ", str ); |
847 | int leftOffset = 0; | 851 | int leftOffset = 0; |
848 | int rightOffset = parts.count() - 1; | 852 | int rightOffset = parts.count() - 1; |
849 | 853 | ||
850 | QString suffix; | 854 | QString suffix; |
851 | while ( rightOffset >= 0 ) { | 855 | while ( rightOffset >= 0 ) { |
852 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 856 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
853 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 857 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
854 | rightOffset--; | 858 | rightOffset--; |
855 | } else | 859 | } else |
856 | break; | 860 | break; |
857 | } | 861 | } |
858 | setSuffix( suffix ); | 862 | setSuffix( suffix ); |
859 | 863 | ||
860 | if ( rightOffset < 0 ) | 864 | if ( rightOffset < 0 ) |
861 | return; | 865 | return; |
862 | 866 | ||
863 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 867 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
864 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 868 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
865 | rightOffset--; | 869 | rightOffset--; |
866 | } else | 870 | } else |
867 | setFamilyName( parts[ rightOffset ] ); | 871 | setFamilyName( parts[ rightOffset ] ); |
868 | 872 | ||
869 | QString prefix; | 873 | QString prefix; |
870 | while ( leftOffset < rightOffset ) { | 874 | while ( leftOffset < rightOffset ) { |
871 | if ( titles.contains( parts[ leftOffset ] ) ) { | 875 | if ( titles.contains( parts[ leftOffset ] ) ) { |
872 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 876 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
873 | leftOffset++; | 877 | leftOffset++; |
874 | } else | 878 | } else |
875 | break; | 879 | break; |
876 | } | 880 | } |
877 | setPrefix( prefix ); | 881 | setPrefix( prefix ); |
878 | 882 | ||
879 | if ( leftOffset < rightOffset ) { | 883 | if ( leftOffset < rightOffset ) { |
880 | setGivenName( parts[ leftOffset ] ); | 884 | setGivenName( parts[ leftOffset ] ); |
881 | leftOffset++; | 885 | leftOffset++; |
882 | } | 886 | } |
883 | 887 | ||
884 | QString additionalName; | 888 | QString additionalName; |
885 | while ( leftOffset < rightOffset ) { | 889 | while ( leftOffset < rightOffset ) { |
886 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 890 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
887 | leftOffset++; | 891 | leftOffset++; |
888 | } | 892 | } |
889 | setAdditionalName( additionalName ); | 893 | setAdditionalName( additionalName ); |
890 | } else { | 894 | } else { |
891 | QString part1 = str.left( i ); | 895 | QString part1 = str.left( i ); |
892 | QString part2 = str.mid( i + 1 ); | 896 | QString part2 = str.mid( i + 1 ); |
893 | 897 | ||
894 | QStringList parts = QStringList::split( " ", part1 ); | 898 | QStringList parts = QStringList::split( " ", part1 ); |
895 | int leftOffset = 0; | 899 | int leftOffset = 0; |
896 | int rightOffset = parts.count() - 1; | 900 | int rightOffset = parts.count() - 1; |
897 | 901 | ||
898 | QString suffix; | 902 | QString suffix; |
899 | while ( rightOffset >= 0 ) { | 903 | while ( rightOffset >= 0 ) { |
900 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 904 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
901 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 905 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
902 | rightOffset--; | 906 | rightOffset--; |
903 | } else | 907 | } else |
904 | break; | 908 | break; |
905 | } | 909 | } |
906 | setSuffix( suffix ); | 910 | setSuffix( suffix ); |
907 | 911 | ||
908 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 912 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
909 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 913 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
910 | rightOffset--; | 914 | rightOffset--; |
911 | } else | 915 | } else |
912 | setFamilyName( parts[ rightOffset ] ); | 916 | setFamilyName( parts[ rightOffset ] ); |
913 | 917 | ||
914 | QString prefix; | 918 | QString prefix; |
915 | while ( leftOffset < rightOffset ) { | 919 | while ( leftOffset < rightOffset ) { |
916 | if ( titles.contains( parts[ leftOffset ] ) ) { | 920 | if ( titles.contains( parts[ leftOffset ] ) ) { |
917 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 921 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
918 | leftOffset++; | 922 | leftOffset++; |
919 | } else | 923 | } else |
920 | break; | 924 | break; |
921 | } | 925 | } |
922 | 926 | ||
923 | parts = QStringList::split( " ", part2 ); | 927 | parts = QStringList::split( " ", part2 ); |
924 | 928 | ||
925 | leftOffset = 0; | 929 | leftOffset = 0; |
926 | rightOffset = parts.count(); | 930 | rightOffset = parts.count(); |
927 | 931 | ||
928 | while ( leftOffset < rightOffset ) { | 932 | while ( leftOffset < rightOffset ) { |
929 | if ( titles.contains( parts[ leftOffset ] ) ) { | 933 | if ( titles.contains( parts[ leftOffset ] ) ) { |
930 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 934 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
931 | leftOffset++; | 935 | leftOffset++; |
932 | } else | 936 | } else |
933 | break; | 937 | break; |
934 | } | 938 | } |
935 | setPrefix( prefix ); | 939 | setPrefix( prefix ); |
936 | 940 | ||
937 | if ( leftOffset < rightOffset ) { | 941 | if ( leftOffset < rightOffset ) { |
938 | setGivenName( parts[ leftOffset ] ); | 942 | setGivenName( parts[ leftOffset ] ); |
939 | leftOffset++; | 943 | leftOffset++; |
940 | } | 944 | } |
941 | 945 | ||
942 | QString additionalName; | 946 | QString additionalName; |
943 | while ( leftOffset < rightOffset ) { | 947 | while ( leftOffset < rightOffset ) { |
944 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 948 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
945 | leftOffset++; | 949 | leftOffset++; |
946 | } | 950 | } |
947 | setAdditionalName( additionalName ); | 951 | setAdditionalName( additionalName ); |
948 | } | 952 | } |
949 | } | 953 | } |
950 | 954 | ||
951 | QString Addressee::realName() const | 955 | QString Addressee::realName() const |
952 | { | 956 | { |
953 | if ( !formattedName().isEmpty() ) | 957 | if ( !formattedName().isEmpty() ) |
954 | return formattedName(); | 958 | return formattedName(); |
955 | 959 | ||
956 | QString n = assembledName(); | 960 | QString n = assembledName(); |
957 | 961 | ||
958 | if ( n.isEmpty() ) | 962 | if ( n.isEmpty() ) |
959 | n = name(); | 963 | n = name(); |
960 | 964 | ||
961 | return n; | 965 | return n; |
962 | } | 966 | } |
963 | 967 | ||
964 | QString Addressee::assembledName() const | 968 | QString Addressee::assembledName() const |
965 | { | 969 | { |
966 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + | 970 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + |
967 | familyName() + " " + suffix(); | 971 | familyName() + " " + suffix(); |
968 | 972 | ||
969 | return name.simplifyWhiteSpace(); | 973 | return name.simplifyWhiteSpace(); |
970 | } | 974 | } |
971 | 975 | ||
972 | QString Addressee::fullEmail( const QString &email ) const | 976 | QString Addressee::fullEmail( const QString &email ) const |
973 | { | 977 | { |
974 | QString e; | 978 | QString e; |
975 | if ( email.isNull() ) { | 979 | if ( email.isNull() ) { |
976 | e = preferredEmail(); | 980 | e = preferredEmail(); |
977 | } else { | 981 | } else { |
978 | e = email; | 982 | e = email; |
979 | } | 983 | } |
980 | if ( e.isEmpty() ) return QString::null; | 984 | if ( e.isEmpty() ) return QString::null; |
981 | 985 | ||
982 | QString text; | 986 | QString text; |
983 | if ( realName().isEmpty() ) | 987 | if ( realName().isEmpty() ) |
984 | text = e; | 988 | text = e; |
985 | else | 989 | else |
986 | text = assembledName() + " <" + e + ">"; | 990 | text = assembledName() + " <" + e + ">"; |
987 | 991 | ||
988 | return text; | 992 | return text; |
989 | } | 993 | } |
990 | 994 | ||
991 | void Addressee::insertEmail( const QString &email, bool preferred ) | 995 | void Addressee::insertEmail( const QString &email, bool preferred ) |
992 | { | 996 | { |
993 | detach(); | 997 | detach(); |
994 | 998 | ||
995 | QStringList::Iterator it = mData->emails.find( email ); | 999 | QStringList::Iterator it = mData->emails.find( email ); |
996 | 1000 | ||
997 | if ( it != mData->emails.end() ) { | 1001 | if ( it != mData->emails.end() ) { |
998 | if ( !preferred || it == mData->emails.begin() ) return; | 1002 | if ( !preferred || it == mData->emails.begin() ) return; |
999 | mData->emails.remove( it ); | 1003 | mData->emails.remove( it ); |
1000 | mData->emails.prepend( email ); | 1004 | mData->emails.prepend( email ); |
1001 | } else { | 1005 | } else { |
1002 | if ( preferred ) { | 1006 | if ( preferred ) { |
1003 | mData->emails.prepend( email ); | 1007 | mData->emails.prepend( email ); |
1004 | } else { | 1008 | } else { |
1005 | mData->emails.append( email ); | 1009 | mData->emails.append( email ); |
1006 | } | 1010 | } |
1007 | } | 1011 | } |
1008 | } | 1012 | } |
1009 | 1013 | ||
1010 | void Addressee::removeEmail( const QString &email ) | 1014 | void Addressee::removeEmail( const QString &email ) |
1011 | { | 1015 | { |
1012 | detach(); | 1016 | detach(); |
1013 | 1017 | ||
1014 | QStringList::Iterator it = mData->emails.find( email ); | 1018 | QStringList::Iterator it = mData->emails.find( email ); |
1015 | if ( it == mData->emails.end() ) return; | 1019 | if ( it == mData->emails.end() ) return; |
1016 | 1020 | ||
1017 | mData->emails.remove( it ); | 1021 | mData->emails.remove( it ); |
1018 | } | 1022 | } |
1019 | 1023 | ||
1020 | QString Addressee::preferredEmail() const | 1024 | QString Addressee::preferredEmail() const |
1021 | { | 1025 | { |
1022 | if ( mData->emails.count() == 0 ) return QString::null; | 1026 | if ( mData->emails.count() == 0 ) return QString::null; |
1023 | else return mData->emails.first(); | 1027 | else return mData->emails.first(); |
1024 | } | 1028 | } |
1025 | 1029 | ||
1026 | QStringList Addressee::emails() const | 1030 | QStringList Addressee::emails() const |
1027 | { | 1031 | { |
1028 | return mData->emails; | 1032 | return mData->emails; |
1029 | } | 1033 | } |
1030 | void Addressee::setEmails( const QStringList& emails ) { | 1034 | void Addressee::setEmails( const QStringList& emails ) { |
1031 | detach(); | 1035 | detach(); |
1032 | mData->emails = emails; | 1036 | mData->emails = emails; |
1033 | } | 1037 | } |
1034 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) | 1038 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) |
1035 | { | 1039 | { |
1036 | detach(); | 1040 | detach(); |
1037 | mData->empty = false; | 1041 | mData->empty = false; |
1038 | 1042 | ||
1039 | PhoneNumber::List::Iterator it; | 1043 | PhoneNumber::List::Iterator it; |
1040 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1044 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1041 | if ( (*it).id() == phoneNumber.id() ) { | 1045 | if ( (*it).id() == phoneNumber.id() ) { |
1042 | *it = phoneNumber; | 1046 | *it = phoneNumber; |
1043 | return; | 1047 | return; |
1044 | } | 1048 | } |
1045 | } | 1049 | } |
1046 | mData->phoneNumbers.append( phoneNumber ); | 1050 | mData->phoneNumbers.append( phoneNumber ); |
1047 | } | 1051 | } |
1048 | 1052 | ||
1049 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) | 1053 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) |
1050 | { | 1054 | { |
1051 | detach(); | 1055 | detach(); |
1052 | 1056 | ||
1053 | PhoneNumber::List::Iterator it; | 1057 | PhoneNumber::List::Iterator it; |
1054 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1058 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1055 | if ( (*it).id() == phoneNumber.id() ) { | 1059 | if ( (*it).id() == phoneNumber.id() ) { |
1056 | mData->phoneNumbers.remove( it ); | 1060 | mData->phoneNumbers.remove( it ); |
1057 | return; | 1061 | return; |
1058 | } | 1062 | } |
1059 | } | 1063 | } |
1060 | } | 1064 | } |
1061 | 1065 | ||
1062 | PhoneNumber Addressee::phoneNumber( int type ) const | 1066 | PhoneNumber Addressee::phoneNumber( int type ) const |
1063 | { | 1067 | { |
1064 | PhoneNumber phoneNumber( "", type ); | 1068 | PhoneNumber phoneNumber( "", type ); |
1065 | PhoneNumber::List::ConstIterator it; | 1069 | PhoneNumber::List::ConstIterator it; |
1066 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1070 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1067 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1071 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1068 | if ( (*it).type() & PhoneNumber::Pref ) | 1072 | if ( (*it).type() & PhoneNumber::Pref ) |
1069 | return (*it); | 1073 | return (*it); |
1070 | else if ( phoneNumber.number().isEmpty() ) | 1074 | else if ( phoneNumber.number().isEmpty() ) |
1071 | phoneNumber = (*it); | 1075 | phoneNumber = (*it); |
1072 | } | 1076 | } |
1073 | } | 1077 | } |
1074 | 1078 | ||
1075 | return phoneNumber; | 1079 | return phoneNumber; |
1076 | } | 1080 | } |
1077 | 1081 | ||
1078 | PhoneNumber::List Addressee::phoneNumbers() const | 1082 | PhoneNumber::List Addressee::phoneNumbers() const |
1079 | { | 1083 | { |
1080 | return mData->phoneNumbers; | 1084 | return mData->phoneNumbers; |
1081 | } | 1085 | } |
1082 | 1086 | ||
1083 | PhoneNumber::List Addressee::phoneNumbers( int type ) const | 1087 | PhoneNumber::List Addressee::phoneNumbers( int type ) const |
1084 | { | 1088 | { |
1085 | PhoneNumber::List list; | 1089 | PhoneNumber::List list; |
1086 | 1090 | ||
1087 | PhoneNumber::List::ConstIterator it; | 1091 | PhoneNumber::List::ConstIterator it; |
1088 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1092 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1089 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1093 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1090 | list.append( *it ); | 1094 | list.append( *it ); |
1091 | } | 1095 | } |
1092 | } | 1096 | } |
1093 | return list; | 1097 | return list; |
1094 | } | 1098 | } |
1095 | 1099 | ||
1096 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const | 1100 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const |
1097 | { | 1101 | { |
1098 | PhoneNumber::List::ConstIterator it; | 1102 | PhoneNumber::List::ConstIterator it; |
1099 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1103 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1100 | if ( (*it).id() == id ) { | 1104 | if ( (*it).id() == id ) { |
1101 | return *it; | 1105 | return *it; |
1102 | } | 1106 | } |
1103 | } | 1107 | } |
1104 | return PhoneNumber(); | 1108 | return PhoneNumber(); |
1105 | } | 1109 | } |
1106 | 1110 | ||
1107 | void Addressee::insertKey( const Key &key ) | 1111 | void Addressee::insertKey( const Key &key ) |
1108 | { | 1112 | { |
1109 | detach(); | 1113 | detach(); |
1110 | mData->empty = false; | 1114 | mData->empty = false; |
1111 | 1115 | ||
1112 | Key::List::Iterator it; | 1116 | Key::List::Iterator it; |
1113 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1117 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1114 | if ( (*it).id() == key.id() ) { | 1118 | if ( (*it).id() == key.id() ) { |
1115 | *it = key; | 1119 | *it = key; |
1116 | return; | 1120 | return; |
1117 | } | 1121 | } |
1118 | } | 1122 | } |
1119 | mData->keys.append( key ); | 1123 | mData->keys.append( key ); |
1120 | } | 1124 | } |
1121 | 1125 | ||
1122 | void Addressee::removeKey( const Key &key ) | 1126 | void Addressee::removeKey( const Key &key ) |
1123 | { | 1127 | { |
1124 | detach(); | 1128 | detach(); |
1125 | 1129 | ||
1126 | Key::List::Iterator it; | 1130 | Key::List::Iterator it; |
1127 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1131 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1128 | if ( (*it).id() == key.id() ) { | 1132 | if ( (*it).id() == key.id() ) { |
1129 | mData->keys.remove( key ); | 1133 | mData->keys.remove( key ); |
1130 | return; | 1134 | return; |
1131 | } | 1135 | } |
1132 | } | 1136 | } |
1133 | } | 1137 | } |
1134 | 1138 | ||
1135 | Key Addressee::key( int type, QString customTypeString ) const | 1139 | Key Addressee::key( int type, QString customTypeString ) const |
1136 | { | 1140 | { |
1137 | Key::List::ConstIterator it; | 1141 | Key::List::ConstIterator it; |
1138 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1142 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1139 | if ( (*it).type() == type ) { | 1143 | if ( (*it).type() == type ) { |
1140 | if ( type == Key::Custom ) { | 1144 | if ( type == Key::Custom ) { |
1141 | if ( customTypeString.isEmpty() ) { | 1145 | if ( customTypeString.isEmpty() ) { |
1142 | return *it; | 1146 | return *it; |
1143 | } else { | 1147 | } else { |
1144 | if ( (*it).customTypeString() == customTypeString ) | 1148 | if ( (*it).customTypeString() == customTypeString ) |
1145 | return (*it); | 1149 | return (*it); |
1146 | } | 1150 | } |
1147 | } else { | 1151 | } else { |
1148 | return *it; | 1152 | return *it; |
1149 | } | 1153 | } |
1150 | } | 1154 | } |
1151 | } | 1155 | } |
1152 | return Key( QString(), type ); | 1156 | return Key( QString(), type ); |
1153 | } | 1157 | } |
1154 | void Addressee::setKeys( const Key::List& list ) { | 1158 | void Addressee::setKeys( const Key::List& list ) { |
1155 | detach(); | 1159 | detach(); |
1156 | mData->keys = list; | 1160 | mData->keys = list; |
1157 | } | 1161 | } |
1158 | 1162 | ||
1159 | Key::List Addressee::keys() const | 1163 | Key::List Addressee::keys() const |
1160 | { | 1164 | { |
1161 | return mData->keys; | 1165 | return mData->keys; |
1162 | } | 1166 | } |
1163 | 1167 | ||
1164 | Key::List Addressee::keys( int type, QString customTypeString ) const | 1168 | Key::List Addressee::keys( int type, QString customTypeString ) const |
1165 | { | 1169 | { |
1166 | Key::List list; | 1170 | Key::List list; |
1167 | 1171 | ||
1168 | Key::List::ConstIterator it; | 1172 | Key::List::ConstIterator it; |
1169 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1173 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1170 | if ( (*it).type() == type ) { | 1174 | if ( (*it).type() == type ) { |
1171 | if ( type == Key::Custom ) { | 1175 | if ( type == Key::Custom ) { |
1172 | if ( customTypeString.isEmpty() ) { | 1176 | if ( customTypeString.isEmpty() ) { |
1173 | list.append(*it); | 1177 | list.append(*it); |
1174 | } else { | 1178 | } else { |
1175 | if ( (*it).customTypeString() == customTypeString ) | 1179 | if ( (*it).customTypeString() == customTypeString ) |
1176 | list.append(*it); | 1180 | list.append(*it); |
1177 | } | 1181 | } |
1178 | } else { | 1182 | } else { |
1179 | list.append(*it); | 1183 | list.append(*it); |
1180 | } | 1184 | } |
1181 | } | 1185 | } |
1182 | } | 1186 | } |
1183 | return list; | 1187 | return list; |
1184 | } | 1188 | } |
1185 | 1189 | ||
1186 | Key Addressee::findKey( const QString &id ) const | 1190 | Key Addressee::findKey( const QString &id ) const |
1187 | { | 1191 | { |
1188 | Key::List::ConstIterator it; | 1192 | Key::List::ConstIterator it; |
1189 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1193 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1190 | if ( (*it).id() == id ) { | 1194 | if ( (*it).id() == id ) { |
1191 | return *it; | 1195 | return *it; |
1192 | } | 1196 | } |
1193 | } | 1197 | } |
1194 | return Key(); | 1198 | return Key(); |
1195 | } | 1199 | } |
1196 | 1200 | ||
1197 | QString Addressee::asString() const | 1201 | QString Addressee::asString() const |
1198 | { | 1202 | { |
1199 | return "Smith, agent Smith..."; | 1203 | return "Smith, agent Smith..."; |
1200 | } | 1204 | } |
1201 | 1205 | ||
1202 | void Addressee::dump() const | 1206 | void Addressee::dump() const |
1203 | { | 1207 | { |
1204 | return; | 1208 | return; |
1205 | kdDebug(5700) << "Addressee {" << endl; | 1209 | kdDebug(5700) << "Addressee {" << endl; |
1206 | 1210 | ||
1207 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; | 1211 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; |
1208 | 1212 | ||
1209 | kdDebug(5700) << " Name: '" << name() << "'" << endl; | 1213 | kdDebug(5700) << " Name: '" << name() << "'" << endl; |
1210 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; | 1214 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; |
1211 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; | 1215 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; |
1212 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; | 1216 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; |
1213 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; | 1217 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; |
1214 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; | 1218 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; |
1215 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; | 1219 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; |
1216 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; | 1220 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; |
1217 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; | 1221 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; |
1218 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; | 1222 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; |
1219 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; | 1223 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; |
1220 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; | 1224 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; |
1221 | kdDebug(5700) << " Title: '" << title() << "'" << endl; | 1225 | kdDebug(5700) << " Title: '" << title() << "'" << endl; |
1222 | kdDebug(5700) << " Role: '" << role() << "'" << endl; | 1226 | kdDebug(5700) << " Role: '" << role() << "'" << endl; |
1223 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; | 1227 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; |
1224 | kdDebug(5700) << " Note: '" << note() << "'" << endl; | 1228 | kdDebug(5700) << " Note: '" << note() << "'" << endl; |
1225 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; | 1229 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; |
1226 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; | 1230 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; |
1227 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; | 1231 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; |
1228 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; | 1232 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; |
1229 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; | 1233 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; |
1230 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; | 1234 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; |
1231 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; | 1235 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; |
1232 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; | 1236 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; |
1233 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; | 1237 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; |
1234 | 1238 | ||
1235 | kdDebug(5700) << " Emails {" << endl; | 1239 | kdDebug(5700) << " Emails {" << endl; |
1236 | QStringList e = emails(); | 1240 | QStringList e = emails(); |
1237 | QStringList::ConstIterator it; | 1241 | QStringList::ConstIterator it; |
1238 | for( it = e.begin(); it != e.end(); ++it ) { | 1242 | for( it = e.begin(); it != e.end(); ++it ) { |
1239 | kdDebug(5700) << " " << (*it) << endl; | 1243 | kdDebug(5700) << " " << (*it) << endl; |
1240 | } | 1244 | } |
1241 | kdDebug(5700) << " }" << endl; | 1245 | kdDebug(5700) << " }" << endl; |
1242 | 1246 | ||
1243 | kdDebug(5700) << " PhoneNumbers {" << endl; | 1247 | kdDebug(5700) << " PhoneNumbers {" << endl; |
1244 | PhoneNumber::List p = phoneNumbers(); | 1248 | PhoneNumber::List p = phoneNumbers(); |
1245 | PhoneNumber::List::ConstIterator it2; | 1249 | PhoneNumber::List::ConstIterator it2; |
1246 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { | 1250 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { |
1247 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; | 1251 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; |
1248 | } | 1252 | } |
1249 | kdDebug(5700) << " }" << endl; | 1253 | kdDebug(5700) << " }" << endl; |
1250 | 1254 | ||
1251 | Address::List a = addresses(); | 1255 | Address::List a = addresses(); |
1252 | Address::List::ConstIterator it3; | 1256 | Address::List::ConstIterator it3; |
1253 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { | 1257 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { |
1254 | (*it3).dump(); | 1258 | (*it3).dump(); |
1255 | } | 1259 | } |
1256 | 1260 | ||
1257 | kdDebug(5700) << " Keys {" << endl; | 1261 | kdDebug(5700) << " Keys {" << endl; |
1258 | Key::List k = keys(); | 1262 | Key::List k = keys(); |
1259 | Key::List::ConstIterator it4; | 1263 | Key::List::ConstIterator it4; |
1260 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { | 1264 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { |
1261 | kdDebug(5700) << " Type: " << int((*it4).type()) << | 1265 | kdDebug(5700) << " Type: " << int((*it4).type()) << |
1262 | " Key: " << (*it4).textData() << | 1266 | " Key: " << (*it4).textData() << |
1263 | " CustomString: " << (*it4).customTypeString() << endl; | 1267 | " CustomString: " << (*it4).customTypeString() << endl; |
1264 | } | 1268 | } |
1265 | kdDebug(5700) << " }" << endl; | 1269 | kdDebug(5700) << " }" << endl; |
1266 | 1270 | ||
1267 | kdDebug(5700) << "}" << endl; | 1271 | kdDebug(5700) << "}" << endl; |
1268 | } | 1272 | } |
1269 | 1273 | ||
1270 | 1274 | ||
1271 | void Addressee::insertAddress( const Address &address ) | 1275 | void Addressee::insertAddress( const Address &address ) |
1272 | { | 1276 | { |
1273 | detach(); | 1277 | detach(); |
1274 | mData->empty = false; | 1278 | mData->empty = false; |
1275 | 1279 | ||
1276 | Address::List::Iterator it; | 1280 | Address::List::Iterator it; |
1277 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1281 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1278 | if ( (*it).id() == address.id() ) { | 1282 | if ( (*it).id() == address.id() ) { |
1279 | *it = address; | 1283 | *it = address; |
1280 | return; | 1284 | return; |
1281 | } | 1285 | } |
1282 | } | 1286 | } |
1283 | mData->addresses.append( address ); | 1287 | mData->addresses.append( address ); |
1284 | } | 1288 | } |
1285 | 1289 | ||
1286 | void Addressee::removeAddress( const Address &address ) | 1290 | void Addressee::removeAddress( const Address &address ) |
1287 | { | 1291 | { |
1288 | detach(); | 1292 | detach(); |
1289 | 1293 | ||
1290 | Address::List::Iterator it; | 1294 | Address::List::Iterator it; |
1291 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1295 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1292 | if ( (*it).id() == address.id() ) { | 1296 | if ( (*it).id() == address.id() ) { |
1293 | mData->addresses.remove( it ); | 1297 | mData->addresses.remove( it ); |
1294 | return; | 1298 | return; |
1295 | } | 1299 | } |
1296 | } | 1300 | } |
1297 | } | 1301 | } |
1298 | 1302 | ||
1299 | Address Addressee::address( int type ) const | 1303 | Address Addressee::address( int type ) const |
1300 | { | 1304 | { |
1301 | Address address( type ); | 1305 | Address address( type ); |
1302 | Address::List::ConstIterator it; | 1306 | Address::List::ConstIterator it; |
1303 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1307 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1304 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1308 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1305 | if ( (*it).type() & Address::Pref ) | 1309 | if ( (*it).type() & Address::Pref ) |
1306 | return (*it); | 1310 | return (*it); |
1307 | else if ( address.isEmpty() ) | 1311 | else if ( address.isEmpty() ) |
1308 | address = (*it); | 1312 | address = (*it); |
1309 | } | 1313 | } |
1310 | } | 1314 | } |
1311 | 1315 | ||
1312 | return address; | 1316 | return address; |
1313 | } | 1317 | } |
1314 | 1318 | ||
1315 | Address::List Addressee::addresses() const | 1319 | Address::List Addressee::addresses() const |
1316 | { | 1320 | { |
1317 | return mData->addresses; | 1321 | return mData->addresses; |
1318 | } | 1322 | } |
1319 | 1323 | ||
1320 | Address::List Addressee::addresses( int type ) const | 1324 | Address::List Addressee::addresses( int type ) const |
1321 | { | 1325 | { |
1322 | Address::List list; | 1326 | Address::List list; |
1323 | 1327 | ||
1324 | Address::List::ConstIterator it; | 1328 | Address::List::ConstIterator it; |
1325 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1329 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1326 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1330 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1327 | list.append( *it ); | 1331 | list.append( *it ); |
1328 | } | 1332 | } |
1329 | } | 1333 | } |
1330 | 1334 | ||
1331 | return list; | 1335 | return list; |
1332 | } | 1336 | } |
1333 | 1337 | ||
1334 | Address Addressee::findAddress( const QString &id ) const | 1338 | Address Addressee::findAddress( const QString &id ) const |
1335 | { | 1339 | { |
1336 | Address::List::ConstIterator it; | 1340 | Address::List::ConstIterator it; |
1337 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1341 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1338 | if ( (*it).id() == id ) { | 1342 | if ( (*it).id() == id ) { |
1339 | return *it; | 1343 | return *it; |
1340 | } | 1344 | } |
1341 | } | 1345 | } |
1342 | return Address(); | 1346 | return Address(); |
1343 | } | 1347 | } |
1344 | 1348 | ||
1345 | void Addressee::insertCategory( const QString &c ) | 1349 | void Addressee::insertCategory( const QString &c ) |
1346 | { | 1350 | { |
1347 | detach(); | 1351 | detach(); |
1348 | mData->empty = false; | 1352 | mData->empty = false; |
1349 | 1353 | ||
1350 | if ( mData->categories.contains( c ) ) return; | 1354 | if ( mData->categories.contains( c ) ) return; |
1351 | 1355 | ||
1352 | mData->categories.append( c ); | 1356 | mData->categories.append( c ); |
1353 | } | 1357 | } |
1354 | 1358 | ||
1355 | void Addressee::removeCategory( const QString &c ) | 1359 | void Addressee::removeCategory( const QString &c ) |
1356 | { | 1360 | { |
1357 | detach(); | 1361 | detach(); |
1358 | 1362 | ||
1359 | QStringList::Iterator it = mData->categories.find( c ); | 1363 | QStringList::Iterator it = mData->categories.find( c ); |
1360 | if ( it == mData->categories.end() ) return; | 1364 | if ( it == mData->categories.end() ) return; |
1361 | 1365 | ||
1362 | mData->categories.remove( it ); | 1366 | mData->categories.remove( it ); |
1363 | } | 1367 | } |
1364 | 1368 | ||
1365 | bool Addressee::hasCategory( const QString &c ) const | 1369 | bool Addressee::hasCategory( const QString &c ) const |
1366 | { | 1370 | { |
1367 | return ( mData->categories.contains( c ) ); | 1371 | return ( mData->categories.contains( c ) ); |
1368 | } | 1372 | } |
1369 | 1373 | ||
1370 | void Addressee::setCategories( const QStringList &c ) | 1374 | void Addressee::setCategories( const QStringList &c ) |
1371 | { | 1375 | { |
1372 | detach(); | 1376 | detach(); |
1373 | mData->empty = false; | 1377 | mData->empty = false; |
1374 | 1378 | ||
1375 | mData->categories = c; | 1379 | mData->categories = c; |
1376 | } | 1380 | } |
1377 | 1381 | ||
1378 | QStringList Addressee::categories() const | 1382 | QStringList Addressee::categories() const |
1379 | { | 1383 | { |
1380 | return mData->categories; | 1384 | return mData->categories; |
1381 | } | 1385 | } |
1382 | 1386 | ||
1383 | void Addressee::insertCustom( const QString &app, const QString &name, | 1387 | void Addressee::insertCustom( const QString &app, const QString &name, |
1384 | const QString &value ) | 1388 | const QString &value ) |
1385 | { | 1389 | { |
1386 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; | 1390 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; |
1387 | 1391 | ||
1388 | detach(); | 1392 | detach(); |
1389 | mData->empty = false; | 1393 | mData->empty = false; |
1390 | 1394 | ||
1391 | QString qualifiedName = app + "-" + name + ":"; | 1395 | QString qualifiedName = app + "-" + name + ":"; |
1392 | 1396 | ||
1393 | QStringList::Iterator it; | 1397 | QStringList::Iterator it; |
1394 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1398 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1395 | if ( (*it).startsWith( qualifiedName ) ) { | 1399 | if ( (*it).startsWith( qualifiedName ) ) { |
1396 | (*it) = qualifiedName + value; | 1400 | (*it) = qualifiedName + value; |
1397 | return; | 1401 | return; |
1398 | } | 1402 | } |
1399 | } | 1403 | } |
1400 | 1404 | ||
1401 | mData->custom.append( qualifiedName + value ); | 1405 | mData->custom.append( qualifiedName + value ); |
1402 | } | 1406 | } |
1403 | 1407 | ||
1404 | void Addressee::removeCustom( const QString &app, const QString &name) | 1408 | void Addressee::removeCustom( const QString &app, const QString &name) |
1405 | { | 1409 | { |
1406 | detach(); | 1410 | detach(); |
1407 | 1411 | ||
1408 | QString qualifiedName = app + "-" + name + ":"; | 1412 | QString qualifiedName = app + "-" + name + ":"; |
1409 | 1413 | ||
1410 | QStringList::Iterator it; | 1414 | QStringList::Iterator it; |
1411 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1415 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1412 | if ( (*it).startsWith( qualifiedName ) ) { | 1416 | if ( (*it).startsWith( qualifiedName ) ) { |
1413 | mData->custom.remove( it ); | 1417 | mData->custom.remove( it ); |
1414 | return; | 1418 | return; |
1415 | } | 1419 | } |
1416 | } | 1420 | } |
1417 | } | 1421 | } |
1418 | 1422 | ||
1419 | QString Addressee::custom( const QString &app, const QString &name ) const | 1423 | QString Addressee::custom( const QString &app, const QString &name ) const |
1420 | { | 1424 | { |
1421 | QString qualifiedName = app + "-" + name + ":"; | 1425 | QString qualifiedName = app + "-" + name + ":"; |
1422 | QString value; | 1426 | QString value; |
1423 | 1427 | ||
1424 | QStringList::ConstIterator it; | 1428 | QStringList::ConstIterator it; |
1425 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1429 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1426 | if ( (*it).startsWith( qualifiedName ) ) { | 1430 | if ( (*it).startsWith( qualifiedName ) ) { |
1427 | value = (*it).mid( (*it).find( ":" ) + 1 ); | 1431 | value = (*it).mid( (*it).find( ":" ) + 1 ); |
1428 | break; | 1432 | break; |
1429 | } | 1433 | } |
1430 | } | 1434 | } |
1431 | 1435 | ||
1432 | return value; | 1436 | return value; |
1433 | } | 1437 | } |
1434 | 1438 | ||
1435 | void Addressee::setCustoms( const QStringList &l ) | 1439 | void Addressee::setCustoms( const QStringList &l ) |
1436 | { | 1440 | { |
1437 | detach(); | 1441 | detach(); |
1438 | mData->empty = false; | 1442 | mData->empty = false; |
1439 | 1443 | ||
1440 | mData->custom = l; | 1444 | mData->custom = l; |
1441 | } | 1445 | } |
1442 | 1446 | ||
1443 | QStringList Addressee::customs() const | 1447 | QStringList Addressee::customs() const |
1444 | { | 1448 | { |
1445 | return mData->custom; | 1449 | return mData->custom; |
1446 | } | 1450 | } |
1447 | 1451 | ||
1448 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, | 1452 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, |
1449 | QString &email) | 1453 | QString &email) |
1450 | { | 1454 | { |
1451 | int startPos, endPos, len; | 1455 | int startPos, endPos, len; |
1452 | QString partA, partB, result; | 1456 | QString partA, partB, result; |
1453 | char endCh = '>'; | 1457 | char endCh = '>'; |
1454 | 1458 | ||
1455 | startPos = rawEmail.find('<'); | 1459 | startPos = rawEmail.find('<'); |
1456 | if (startPos < 0) | 1460 | if (startPos < 0) |
1457 | { | 1461 | { |
1458 | startPos = rawEmail.find('('); | 1462 | startPos = rawEmail.find('('); |
1459 | endCh = ')'; | 1463 | endCh = ')'; |
1460 | } | 1464 | } |
1461 | if (startPos < 0) | 1465 | if (startPos < 0) |
1462 | { | 1466 | { |
1463 | // We couldn't find any separators, so we assume the whole string | 1467 | // We couldn't find any separators, so we assume the whole string |
1464 | // is the email address | 1468 | // is the email address |
1465 | email = rawEmail; | 1469 | email = rawEmail; |
1466 | fullName = ""; | 1470 | fullName = ""; |
1467 | } | 1471 | } |
1468 | else | 1472 | else |
1469 | { | 1473 | { |
1470 | // We have a start position, try to find an end | 1474 | // We have a start position, try to find an end |
1471 | endPos = rawEmail.find(endCh, startPos+1); | 1475 | endPos = rawEmail.find(endCh, startPos+1); |
1472 | 1476 | ||
1473 | if (endPos < 0) | 1477 | if (endPos < 0) |
1474 | { | 1478 | { |
1475 | // We couldn't find the end of the email address. We can only | 1479 | // We couldn't find the end of the email address. We can only |
1476 | // assume the entire string is the email address. | 1480 | // assume the entire string is the email address. |
1477 | email = rawEmail; | 1481 | email = rawEmail; |
1478 | fullName = ""; | 1482 | fullName = ""; |
1479 | } | 1483 | } |
1480 | else | 1484 | else |
1481 | { | 1485 | { |
1482 | // We have a start and end to the email address | 1486 | // We have a start and end to the email address |
1483 | 1487 | ||
1484 | // Grab the name part | 1488 | // Grab the name part |
1485 | fullName = rawEmail.left(startPos).stripWhiteSpace(); | 1489 | fullName = rawEmail.left(startPos).stripWhiteSpace(); |
1486 | 1490 | ||
1487 | // grab the email part | 1491 | // grab the email part |
1488 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); | 1492 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); |
1489 | 1493 | ||
1490 | // Check that we do not have any extra characters on the end of the | 1494 | // Check that we do not have any extra characters on the end of the |
1491 | // strings | 1495 | // strings |
1492 | len = fullName.length(); | 1496 | len = fullName.length(); |
1493 | if (fullName[0]=='"' && fullName[len-1]=='"') | 1497 | if (fullName[0]=='"' && fullName[len-1]=='"') |
1494 | fullName = fullName.mid(1, len-2); | 1498 | fullName = fullName.mid(1, len-2); |
1495 | else if (fullName[0]=='<' && fullName[len-1]=='>') | 1499 | else if (fullName[0]=='<' && fullName[len-1]=='>') |
1496 | fullName = fullName.mid(1, len-2); | 1500 | fullName = fullName.mid(1, len-2); |
1497 | else if (fullName[0]=='(' && fullName[len-1]==')') | 1501 | else if (fullName[0]=='(' && fullName[len-1]==')') |
1498 | fullName = fullName.mid(1, len-2); | 1502 | fullName = fullName.mid(1, len-2); |
1499 | } | 1503 | } |
1500 | } | 1504 | } |
1501 | } | 1505 | } |
1502 | 1506 | ||
1503 | void Addressee::setResource( Resource *resource ) | 1507 | void Addressee::setResource( Resource *resource ) |
1504 | { | 1508 | { |
1505 | detach(); | 1509 | detach(); |
1506 | mData->resource = resource; | 1510 | mData->resource = resource; |
1507 | } | 1511 | } |
1508 | 1512 | ||
1509 | Resource *Addressee::resource() const | 1513 | Resource *Addressee::resource() const |
1510 | { | 1514 | { |
1511 | return mData->resource; | 1515 | return mData->resource; |
1512 | } | 1516 | } |
1513 | 1517 | ||
1514 | //US | 1518 | //US |
1515 | QString Addressee::resourceLabel() | 1519 | QString Addressee::resourceLabel() |
1516 | { | 1520 | { |
1517 | return i18n("Resource"); | 1521 | return i18n("Resource"); |
1518 | } | 1522 | } |
1519 | 1523 | ||
1520 | void Addressee::setChanged( bool value ) | 1524 | void Addressee::setChanged( bool value ) |
1521 | { | 1525 | { |
1522 | detach(); | 1526 | detach(); |
1523 | mData->changed = value; | 1527 | mData->changed = value; |
1524 | } | 1528 | } |
1525 | 1529 | ||
1526 | bool Addressee::changed() const | 1530 | bool Addressee::changed() const |
1527 | { | 1531 | { |
1528 | return mData->changed; | 1532 | return mData->changed; |
1529 | } | 1533 | } |
1530 | 1534 | ||
1531 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) | 1535 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) |
1532 | { | 1536 | { |
1533 | if (!a.mData) return s; | 1537 | if (!a.mData) return s; |
1534 | 1538 | ||
1535 | s << a.uid(); | 1539 | s << a.uid(); |
1536 | 1540 | ||
1537 | s << a.mData->name; | 1541 | s << a.mData->name; |
1538 | s << a.mData->formattedName; | 1542 | s << a.mData->formattedName; |
1539 | s << a.mData->familyName; | 1543 | s << a.mData->familyName; |
1540 | s << a.mData->givenName; | 1544 | s << a.mData->givenName; |
1541 | s << a.mData->additionalName; | 1545 | s << a.mData->additionalName; |
1542 | s << a.mData->prefix; | 1546 | s << a.mData->prefix; |
1543 | s << a.mData->suffix; | 1547 | s << a.mData->suffix; |
1544 | s << a.mData->nickName; | 1548 | s << a.mData->nickName; |
1545 | s << a.mData->birthday; | 1549 | s << a.mData->birthday; |
1546 | s << a.mData->mailer; | 1550 | s << a.mData->mailer; |
1547 | s << a.mData->timeZone; | 1551 | s << a.mData->timeZone; |
1548 | s << a.mData->geo; | 1552 | s << a.mData->geo; |
1549 | s << a.mData->title; | 1553 | s << a.mData->title; |
1550 | s << a.mData->role; | 1554 | s << a.mData->role; |
1551 | s << a.mData->organization; | 1555 | s << a.mData->organization; |
1552 | s << a.mData->note; | 1556 | s << a.mData->note; |
1553 | s << a.mData->productId; | 1557 | s << a.mData->productId; |
1554 | s << a.mData->revision; | 1558 | s << a.mData->revision; |
1555 | s << a.mData->sortString; | 1559 | s << a.mData->sortString; |
1556 | s << a.mData->url; | 1560 | s << a.mData->url; |
1557 | s << a.mData->secrecy; | 1561 | s << a.mData->secrecy; |
1558 | s << a.mData->logo; | 1562 | s << a.mData->logo; |
1559 | s << a.mData->photo; | 1563 | s << a.mData->photo; |
1560 | s << a.mData->sound; | 1564 | s << a.mData->sound; |
1561 | s << a.mData->agent; | 1565 | s << a.mData->agent; |
1562 | s << a.mData->phoneNumbers; | 1566 | s << a.mData->phoneNumbers; |
1563 | s << a.mData->addresses; | 1567 | s << a.mData->addresses; |
1564 | s << a.mData->emails; | 1568 | s << a.mData->emails; |
1565 | s << a.mData->categories; | 1569 | s << a.mData->categories; |
1566 | s << a.mData->custom; | 1570 | s << a.mData->custom; |
1567 | s << a.mData->keys; | 1571 | s << a.mData->keys; |
1568 | return s; | 1572 | return s; |
1569 | } | 1573 | } |
1570 | 1574 | ||
1571 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) | 1575 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) |
1572 | { | 1576 | { |
1573 | if (!a.mData) return s; | 1577 | if (!a.mData) return s; |
1574 | 1578 | ||
1575 | s >> a.mData->uid; | 1579 | s >> a.mData->uid; |
1576 | 1580 | ||
1577 | s >> a.mData->name; | 1581 | s >> a.mData->name; |
1578 | s >> a.mData->formattedName; | 1582 | s >> a.mData->formattedName; |
1579 | s >> a.mData->familyName; | 1583 | s >> a.mData->familyName; |
1580 | s >> a.mData->givenName; | 1584 | s >> a.mData->givenName; |
1581 | s >> a.mData->additionalName; | 1585 | s >> a.mData->additionalName; |
1582 | s >> a.mData->prefix; | 1586 | s >> a.mData->prefix; |
1583 | s >> a.mData->suffix; | 1587 | s >> a.mData->suffix; |
1584 | s >> a.mData->nickName; | 1588 | s >> a.mData->nickName; |
1585 | s >> a.mData->birthday; | 1589 | s >> a.mData->birthday; |
1586 | s >> a.mData->mailer; | 1590 | s >> a.mData->mailer; |
1587 | s >> a.mData->timeZone; | 1591 | s >> a.mData->timeZone; |
1588 | s >> a.mData->geo; | 1592 | s >> a.mData->geo; |
1589 | s >> a.mData->title; | 1593 | s >> a.mData->title; |
1590 | s >> a.mData->role; | 1594 | s >> a.mData->role; |
1591 | s >> a.mData->organization; | 1595 | s >> a.mData->organization; |
1592 | s >> a.mData->note; | 1596 | s >> a.mData->note; |
1593 | s >> a.mData->productId; | 1597 | s >> a.mData->productId; |
1594 | s >> a.mData->revision; | 1598 | s >> a.mData->revision; |
1595 | s >> a.mData->sortString; | 1599 | s >> a.mData->sortString; |
1596 | s >> a.mData->url; | 1600 | s >> a.mData->url; |
1597 | s >> a.mData->secrecy; | 1601 | s >> a.mData->secrecy; |
1598 | s >> a.mData->logo; | 1602 | s >> a.mData->logo; |
1599 | s >> a.mData->photo; | 1603 | s >> a.mData->photo; |
1600 | s >> a.mData->sound; | 1604 | s >> a.mData->sound; |
1601 | s >> a.mData->agent; | 1605 | s >> a.mData->agent; |
1602 | s >> a.mData->phoneNumbers; | 1606 | s >> a.mData->phoneNumbers; |
1603 | s >> a.mData->addresses; | 1607 | s >> a.mData->addresses; |
1604 | s >> a.mData->emails; | 1608 | s >> a.mData->emails; |
1605 | s >> a.mData->categories; | 1609 | s >> a.mData->categories; |
1606 | s >> a.mData->custom; | 1610 | s >> a.mData->custom; |
1607 | s >> a.mData->keys; | 1611 | s >> a.mData->keys; |
1608 | 1612 | ||
1609 | a.mData->empty = false; | 1613 | a.mData->empty = false; |
1610 | 1614 | ||
1611 | return s; | 1615 | return s; |
1612 | } | 1616 | } |
1613 | 1617 | ||
1614 | bool matchBinaryPattern( int value, int pattern ) | 1618 | bool matchBinaryPattern( int value, int pattern ) |
1615 | { | 1619 | { |
1616 | /** | 1620 | /** |
1617 | We want to match all telephonnumbers/addresses which have the bits in the | 1621 | We want to match all telephonnumbers/addresses which have the bits in the |
1618 | pattern set. More are allowed. | 1622 | pattern set. More are allowed. |
1619 | if pattern == 0 we have a special handling, then we want only those with | 1623 | if pattern == 0 we have a special handling, then we want only those with |
1620 | exactly no bit set. | 1624 | exactly no bit set. |
1621 | */ | 1625 | */ |
1622 | if ( pattern == 0 ) | 1626 | if ( pattern == 0 ) |
1623 | return ( value == 0 ); | 1627 | return ( value == 0 ); |
1624 | else | 1628 | else |
1625 | return ( pattern == ( pattern & value ) ); | 1629 | return ( pattern == ( pattern & value ) ); |
1626 | } | 1630 | } |
diff --git a/kaddressbook/addresseeeditorwidget.cpp b/kaddressbook/addresseeeditorwidget.cpp index 3cfc1f2..826c69b 100644 --- a/kaddressbook/addresseeeditorwidget.cpp +++ b/kaddressbook/addresseeeditorwidget.cpp | |||
@@ -1,1280 +1,1306 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qcheckbox.h> | 24 | #include <qcheckbox.h> |
25 | #include <qhbox.h> | 25 | #include <qhbox.h> |
26 | #include <qlabel.h> | 26 | #include <qlabel.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qlistbox.h> | 28 | #include <qlistbox.h> |
29 | #include <qpushbutton.h> | 29 | #include <qpushbutton.h> |
30 | #include <qtabwidget.h> | 30 | #include <qtabwidget.h> |
31 | 31 | ||
32 | #ifndef KAB_EMBEDDED | 32 | #ifndef KAB_EMBEDDED |
33 | #include <qtextedit.h> | 33 | #include <qtextedit.h> |
34 | 34 | ||
35 | #include <kaccelmanager.h> | 35 | #include <kaccelmanager.h> |
36 | #include "keywidget.h" | 36 | #include "keywidget.h" |
37 | #include "soundwidget.h" | 37 | #include "soundwidget.h" |
38 | 38 | ||
39 | #else //KAB_EMBEDDED | 39 | #else //KAB_EMBEDDED |
40 | #include <qmultilineedit.h> | 40 | #include <qmultilineedit.h> |
41 | #endif //KAB_EMBEDDED | 41 | #endif //KAB_EMBEDDED |
42 | 42 | ||
43 | 43 | ||
44 | #include "keywidget.h" | 44 | #include "keywidget.h" |
45 | #include "geowidget.h" | 45 | #include "geowidget.h" |
46 | #include "imagewidget.h" | 46 | #include "imagewidget.h" |
47 | #include "nameeditdialog.h" | 47 | #include "nameeditdialog.h" |
48 | #include "phoneeditwidget.h" | 48 | #include "phoneeditwidget.h" |
49 | #include "secrecywidget.h" | 49 | #include "secrecywidget.h" |
50 | 50 | ||
51 | 51 | ||
52 | #include <qtoolbutton.h> | 52 | #include <qtoolbutton.h> |
53 | #include <qtooltip.h> | 53 | #include <qtooltip.h> |
54 | 54 | ||
55 | #include <kapplication.h> | 55 | #include <kapplication.h> |
56 | #include <kconfig.h> | 56 | #include <kconfig.h> |
57 | #include <kcombobox.h> | 57 | #include <kcombobox.h> |
58 | #include <kdebug.h> | 58 | #include <kdebug.h> |
59 | #include <kdialogbase.h> | 59 | #include <kdialogbase.h> |
60 | #include <kglobal.h> | 60 | #include <kglobal.h> |
61 | #include <kiconloader.h> | 61 | #include <kiconloader.h> |
62 | #include <klineedit.h> | 62 | #include <klineedit.h> |
63 | #include <klocale.h> | 63 | #include <klocale.h> |
64 | #include <kmessagebox.h> | 64 | #include <kmessagebox.h> |
65 | #include <kseparator.h> | 65 | #include <kseparator.h> |
66 | #include <ksqueezedtextlabel.h> | 66 | #include <ksqueezedtextlabel.h> |
67 | 67 | ||
68 | #include <libkdepim/categoryeditdialog.h> | 68 | #include <libkdepim/categoryeditdialog.h> |
69 | #include <libkdepim/categoryselectdialog.h> | 69 | #include <libkdepim/categoryselectdialog.h> |
70 | 70 | ||
71 | #include <libkdepim/kdateedit.h> | 71 | #include <libkdepim/kdateedit.h> |
72 | 72 | ||
73 | #include "addresseditwidget.h" | 73 | #include "addresseditwidget.h" |
74 | #include "emaileditwidget.h" | 74 | #include "emaileditwidget.h" |
75 | #include "kabcore.h" | 75 | #include "kabcore.h" |
76 | #include "kabprefs.h" | 76 | #include "kabprefs.h" |
77 | 77 | ||
78 | #include "addresseeeditorwidget.h" | 78 | #include "addresseeeditorwidget.h" |
79 | 79 | ||
80 | 80 | ||
81 | 81 | ||
82 | AddresseeEditorWidget::AddresseeEditorWidget( KABCore *core, bool isExtension, | 82 | AddresseeEditorWidget::AddresseeEditorWidget( KABCore *core, bool isExtension, |
83 | QWidget *parent, const char *name ) | 83 | QWidget *parent, const char *name ) |
84 | : ExtensionWidget( core, parent, name ), mIsExtension( isExtension ), | 84 | : ExtensionWidget( core, parent, name ), mIsExtension( isExtension ), |
85 | mBlockSignals( false ) | 85 | mBlockSignals( false ) |
86 | { | 86 | { |
87 | 87 | ||
88 | mAConfig = AddresseeConfig::instance(); | 88 | mAConfig = AddresseeConfig::instance(); |
89 | 89 | ||
90 | kdDebug(5720) << "AddresseeEditorWidget()" << endl; | ||
91 | mFormattedNameType = NameEditDialog::CustomName; | 90 | mFormattedNameType = NameEditDialog::CustomName; |
92 | initGUI(); | 91 | initGUI(); |
93 | mCategoryDialog = 0; | 92 | mCategoryDialog = 0; |
94 | mCategoryEditDialog = 0; | 93 | mCategoryEditDialog = 0; |
95 | 94 | ||
96 | // Load the empty addressee as defaults | 95 | // Load the empty addressee as defaults |
97 | load(); | 96 | load(); |
98 | 97 | ||
99 | mDirty = false; | 98 | mDirty = false; |
100 | } | 99 | } |
101 | 100 | ||
102 | AddresseeEditorWidget::~AddresseeEditorWidget() | 101 | AddresseeEditorWidget::~AddresseeEditorWidget() |
103 | { | 102 | { |
104 | kdDebug(5720) << "~AddresseeEditorWidget()" << endl; | 103 | kdDebug(5720) << "~AddresseeEditorWidget()" << endl; |
105 | } | 104 | } |
106 | 105 | ||
107 | void AddresseeEditorWidget::contactsSelectionChanged() | 106 | void AddresseeEditorWidget::contactsSelectionChanged() |
108 | { | 107 | { |
109 | KABC::Addressee::List list = selectedContacts(); | 108 | KABC::Addressee::List list = selectedContacts(); |
110 | 109 | ||
111 | mAddressee = list[ 0 ]; | 110 | mAddressee = list[ 0 ]; |
112 | load(); | 111 | load(); |
113 | } | 112 | } |
114 | 113 | ||
115 | void AddresseeEditorWidget::setAddressee( const KABC::Addressee &addr ) | 114 | void AddresseeEditorWidget::setAddressee( const KABC::Addressee &addr ) |
116 | { | 115 | { |
117 | mAddressee = addr; | 116 | mAddressee = addr; |
118 | load(); | 117 | load(); |
119 | } | 118 | } |
120 | 119 | ||
121 | const KABC::Addressee &AddresseeEditorWidget::addressee() | 120 | const KABC::Addressee &AddresseeEditorWidget::addressee() |
122 | { | 121 | { |
123 | return mAddressee; | 122 | return mAddressee; |
124 | } | 123 | } |
125 | 124 | ||
126 | void AddresseeEditorWidget::textChanged( const QString& ) | 125 | void AddresseeEditorWidget::textChanged( const QString& ) |
127 | { | 126 | { |
128 | emitModified(); | 127 | emitModified(); |
129 | } | 128 | } |
130 | 129 | ||
131 | void AddresseeEditorWidget::initGUI() | 130 | void AddresseeEditorWidget::initGUI() |
132 | { | 131 | { |
133 | QVBoxLayout *layout = new QVBoxLayout( this ); | 132 | QVBoxLayout *layout = new QVBoxLayout( this ); |
134 | 133 | ||
135 | mTabWidget = new QTabWidget( this ); | 134 | mTabWidget = new QTabWidget( this ); |
136 | layout->addWidget( mTabWidget ); | 135 | layout->addWidget( mTabWidget ); |
137 | 136 | ||
138 | setupTab1(); | 137 | setupTab1(); |
139 | setupTab1_1(); | 138 | setupTab1_1(); |
140 | setupTab2(); | 139 | setupTab2(); |
141 | setupTab2_1(); | 140 | setupTab2_1(); |
142 | setupTab3(); | 141 | setupTab3(); |
143 | setupTab3_1(); | 142 | setupTab3_1(); |
144 | 143 | ||
145 | mNameEdit->setFocus(); | 144 | mNameEdit->setFocus(); |
146 | 145 | ||
147 | connect( mTabWidget, SIGNAL( currentChanged(QWidget*) ), | 146 | connect( mTabWidget, SIGNAL( currentChanged(QWidget*) ), |
148 | SLOT( pageChanged(QWidget*) ) ); | 147 | SLOT( pageChanged(QWidget*) ) ); |
149 | } | 148 | } |
150 | 149 | ||
151 | void AddresseeEditorWidget::setupTab1() | 150 | void AddresseeEditorWidget::setupTab1() |
152 | { | 151 | { |
153 | // This is the General tab | 152 | // This is the General tab |
154 | QWidget *tab1 = new QWidget( mTabWidget ); | 153 | QWidget *tab1 = new QWidget( mTabWidget ); |
155 | 154 | ||
156 | //US QGridLayout *layout = new QGridLayout( tab1, 11, 7 ); | 155 | //US QGridLayout *layout = new QGridLayout( tab1, 11, 7 ); |
157 | QGridLayout *layout = new QGridLayout( tab1, 7, 1 ); | 156 | QGridLayout *layout = new QGridLayout( tab1, 7, 1 ); |
158 | layout->setMargin( KDialogBase::marginHintSmall() ); | 157 | layout->setMargin( KDialogBase::marginHintSmall() ); |
159 | layout->setSpacing( KDialogBase::spacingHintSmall() ); | 158 | layout->setSpacing( KDialogBase::spacingHintSmall() ); |
160 | 159 | ||
161 | QLabel *label; | 160 | QLabel *label; |
162 | KSeparator* bar; | 161 | KSeparator* bar; |
163 | QPushButton *button; | 162 | QPushButton *button; |
164 | 163 | ||
165 | ////////////////////////////////// | 164 | ////////////////////////////////// |
166 | // Upper left group (person info) | 165 | // Upper left group (person info) |
167 | 166 | ||
168 | // Person icon | 167 | // Person icon |
169 | /* LR | 168 | /* LR |
170 | label = new QLabel( tab1 ); | 169 | label = new QLabel( tab1 ); |
171 | //US ambiguous call. Add one more parameter | 170 | //US ambiguous call. Add one more parameter |
172 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) ); | 171 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) ); |
173 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) ); | 172 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) ); |
174 | layout->addMultiCellWidget( label, 0, 1, 0, 0 ); | 173 | layout->addMultiCellWidget( label, 0, 1, 0, 0 ); |
175 | */ | 174 | */ |
176 | // First name | 175 | // First name |
177 | button = new QPushButton( i18n( "Name..." ), tab1 ); | 176 | button = new QPushButton( i18n( "Name..." ), tab1 ); |
178 | //US QToolTip::add( button, i18n( "Edit the contact's name" ) ); | 177 | //US QToolTip::add( button, i18n( "Edit the contact's name" ) ); |
179 | mNameEdit = new KLineEdit( tab1, "mNameEdit" ); | 178 | mNameEdit = new KLineEdit( tab1, "mNameEdit" ); |
180 | connect( mNameEdit, SIGNAL( textChanged( const QString& ) ), | 179 | connect( mNameEdit, SIGNAL( textChanged( const QString& ) ), |
181 | SLOT( nameTextChanged( const QString& ) ) ); | 180 | SLOT( nameTextChanged( const QString& ) ) ); |
182 | connect( button, SIGNAL( clicked() ), SLOT( nameButtonClicked() ) ); | 181 | connect( button, SIGNAL( clicked() ), SLOT( nameButtonClicked() ) ); |
183 | 182 | ||
184 | mNameLabel = new KSqueezedTextLabel( tab1 ); | 183 | mNameLabel = new KSqueezedTextLabel( tab1 ); |
185 | mNameLabel->hide(); | 184 | mNameLabel->hide(); |
186 | 185 | ||
187 | layout->addWidget( button, 0, 0 ); | 186 | layout->addWidget( button, 0, 0 ); |
188 | layout->addWidget( mNameEdit, 0, 1 ); | 187 | layout->addWidget( mNameEdit, 0, 1 ); |
189 | layout->addWidget( mNameLabel, 0, 1 ); | 188 | layout->addWidget( mNameLabel, 0, 1 ); |
190 | 189 | ||
191 | label = new QLabel( i18n( "Role:" ), tab1 ); | 190 | label = new QLabel( i18n( "Role:" ), tab1 ); |
192 | mRoleEdit = new KLineEdit( tab1 ); | 191 | mRoleEdit = new KLineEdit( tab1 ); |
193 | connect( mRoleEdit, SIGNAL( textChanged( const QString& ) ), | 192 | connect( mRoleEdit, SIGNAL( textChanged( const QString& ) ), |
194 | SLOT( textChanged( const QString& ) ) ); | 193 | SLOT( textChanged( const QString& ) ) ); |
195 | label->setBuddy( mRoleEdit ); | 194 | label->setBuddy( mRoleEdit ); |
196 | layout->addWidget( label, 1, 0 ); | 195 | layout->addWidget( label, 1, 0 ); |
197 | layout->addWidget( mRoleEdit, 1, 1 ); | 196 | layout->addWidget( mRoleEdit, 1, 1 ); |
198 | 197 | ||
199 | // Organization | 198 | // Organization |
200 | label = new QLabel( i18n( "Organization:" ), tab1 ); | 199 | label = new QLabel( i18n( "Organization:" ), tab1 ); |
201 | mOrgEdit = new KLineEdit( tab1 ); | 200 | mOrgEdit = new KLineEdit( tab1 ); |
202 | label->setBuddy( mOrgEdit ); | 201 | label->setBuddy( mOrgEdit ); |
203 | connect( mOrgEdit, SIGNAL( textChanged( const QString& ) ), | 202 | connect( mOrgEdit, SIGNAL( textChanged( const QString& ) ), |
204 | SLOT( textChanged( const QString& ) ) ); | 203 | SLOT( textChanged( const QString& ) ) ); |
205 | layout->addWidget( label, 2, 0 ); | 204 | layout->addWidget( label, 2, 0 ); |
206 | layout->addWidget( mOrgEdit, 2, 1 ); | 205 | layout->addWidget( mOrgEdit, 2, 1 ); |
207 | 206 | ||
208 | // File as (formatted name) | 207 | // File as (formatted name) |
209 | label = new QLabel( i18n( "Formatted name:" ), tab1 ); | 208 | label = new QLabel( i18n( "Formatted name:" ), tab1 ); |
210 | mFormattedNameLabel = new KSqueezedTextLabel( tab1 ); | 209 | mFormattedNameLabel = new KSqueezedTextLabel( tab1 ); |
211 | layout->addWidget( label, 3, 0 ); | 210 | layout->addWidget( label, 3, 0 ); |
212 | layout->addWidget( mFormattedNameLabel, 3, 1 ); | 211 | layout->addWidget( mFormattedNameLabel, 3, 1 ); |
213 | /* LR | 212 | /* LR |
214 | // Left hand separator. This separator doesn't go all the way | 213 | // Left hand separator. This separator doesn't go all the way |
215 | // across so the dialog still flows from top to bottom | 214 | // across so the dialog still flows from top to bottom |
216 | bar = new KSeparator( KSeparator::HLine, tab1 ); | 215 | bar = new KSeparator( KSeparator::HLine, tab1 ); |
217 | layout->addMultiCellWidget( bar, 4, 4, 0, 2 ); | 216 | layout->addMultiCellWidget( bar, 4, 4, 0, 2 ); |
218 | */ | 217 | */ |
219 | ////////////////////////////////////// | 218 | ////////////////////////////////////// |
220 | 219 | ||
221 | /* LR | 220 | /* LR |
222 | // Phone numbers (upper right) | 221 | // Phone numbers (upper right) |
223 | label = new QLabel( tab1 ); | 222 | label = new QLabel( tab1 ); |
224 | //US loadIcon call is ambiguous. Add one more parameter | 223 | //US loadIcon call is ambiguous. Add one more parameter |
225 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop ) ); | 224 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop ) ); |
226 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) ); | 225 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) ); |
227 | //US layout->addMultiCellWidget( label, 0, 1, 3, 3 ); | 226 | //US layout->addMultiCellWidget( label, 0, 1, 3, 3 ); |
228 | layout->addMultiCellWidget( label, 5, 6, 0, 0 ); | 227 | layout->addMultiCellWidget( label, 5, 6, 0, 0 ); |
229 | */ | 228 | */ |
230 | mPhoneEditWidget = new PhoneEditWidget( tab1 ); | 229 | mPhoneEditWidget = new PhoneEditWidget( tab1 ); |
231 | connect( mPhoneEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); | 230 | connect( mPhoneEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); |
232 | //US layout->addMultiCellWidget( mPhoneEditWidget, 0, 3, 4, 6 ); | 231 | //US layout->addMultiCellWidget( mPhoneEditWidget, 0, 3, 4, 6 ); |
233 | int iii; | 232 | int iii; |
234 | #ifndef DESKTOP_VERSION | 233 | #ifndef DESKTOP_VERSION |
235 | iii = 7; | 234 | iii = 7; |
236 | #else | 235 | #else |
237 | iii = 8; | 236 | iii = 8; |
238 | #endif | 237 | #endif |
239 | layout->addMultiCellWidget( mPhoneEditWidget, 4, iii, 0, 1 ); | 238 | layout->addMultiCellWidget( mPhoneEditWidget, 4, iii, 0, 1 ); |
240 | ++iii; | 239 | ++iii; |
241 | /* LR | 240 | /* LR |
242 | bar = new KSeparator( KSeparator::HLine, tab1 ); | 241 | bar = new KSeparator( KSeparator::HLine, tab1 ); |
243 | //US layout->addMultiCellWidget( bar, 4, 4, 3, 6 ); | 242 | //US layout->addMultiCellWidget( bar, 4, 4, 3, 6 ); |
244 | layout->addMultiCellWidget( bar, 9, 9, 0, 2 ); | 243 | layout->addMultiCellWidget( bar, 9, 9, 0, 2 ); |
245 | */ | 244 | */ |
246 | /*US | 245 | /*US |
247 | ////////////////////////////////////// | 246 | ////////////////////////////////////// |
248 | // Addresses (lower left) | 247 | // Addresses (lower left) |
249 | label = new QLabel( tab1 ); | 248 | label = new QLabel( tab1 ); |
250 | //US loadIcon call is ambiguous. Add one more parameter | 249 | //US loadIcon call is ambiguous. Add one more parameter |
251 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop ) ); | 250 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop ) ); |
252 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop, 0 ) ); | 251 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop, 0 ) ); |
253 | layout->addMultiCellWidget( label, 5, 6, 0, 0 ); | 252 | layout->addMultiCellWidget( label, 5, 6, 0, 0 ); |
254 | 253 | ||
255 | mAddressEditWidget = new AddressEditWidget( tab1 ); | 254 | mAddressEditWidget = new AddressEditWidget( tab1 ); |
256 | connect( mAddressEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); | 255 | connect( mAddressEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); |
257 | layout->addMultiCellWidget( mAddressEditWidget, 5, 9, 1, 2 ); | 256 | layout->addMultiCellWidget( mAddressEditWidget, 5, 9, 1, 2 ); |
258 | 257 | ||
259 | ////////////////////////////////////// | 258 | ////////////////////////////////////// |
260 | // Email / Web (lower right) | 259 | // Email / Web (lower right) |
261 | label = new QLabel( tab1 ); | 260 | label = new QLabel( tab1 ); |
262 | //US loadIcon call is ambiguous. Add one more parameter | 261 | //US loadIcon call is ambiguous. Add one more parameter |
263 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop) ); | 262 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop) ); |
264 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop, 0) ); | 263 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop, 0) ); |
265 | layout->addMultiCellWidget( label, 5, 6, 3, 3 ); | 264 | layout->addMultiCellWidget( label, 5, 6, 3, 3 ); |
266 | 265 | ||
267 | mEmailWidget = new EmailEditWidget( tab1 ); | 266 | mEmailWidget = new EmailEditWidget( tab1 ); |
268 | connect( mEmailWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); | 267 | connect( mEmailWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); |
269 | layout->addMultiCellWidget( mEmailWidget, 5, 6, 4, 6 ); | 268 | layout->addMultiCellWidget( mEmailWidget, 5, 6, 4, 6 ); |
270 | 269 | ||
271 | // add the separator | 270 | // add the separator |
272 | bar = new KSeparator( KSeparator::HLine, tab1 ); | 271 | bar = new KSeparator( KSeparator::HLine, tab1 ); |
273 | layout->addMultiCellWidget( bar, 7, 7, 3, 6 ); | 272 | layout->addMultiCellWidget( bar, 7, 7, 3, 6 ); |
274 | 273 | ||
275 | label = new QLabel( tab1 ); | 274 | label = new QLabel( tab1 ); |
276 | //US loadIcon call is ambiguous. Add one more parameter | 275 | //US loadIcon call is ambiguous. Add one more parameter |
277 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop) ); | 276 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop) ); |
278 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop, 0) ); | 277 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop, 0) ); |
279 | layout->addMultiCellWidget( label, 8, 9, 3, 3 ); | 278 | layout->addMultiCellWidget( label, 8, 9, 3, 3 ); |
280 | 279 | ||
281 | label = new QLabel( i18n( "URL:" ), tab1 ); | 280 | label = new QLabel( i18n( "URL:" ), tab1 ); |
282 | mURLEdit = new KLineEdit( tab1 ); | 281 | mURLEdit = new KLineEdit( tab1 ); |
283 | connect( mURLEdit, SIGNAL( textChanged( const QString& ) ), | 282 | connect( mURLEdit, SIGNAL( textChanged( const QString& ) ), |
284 | SLOT( textChanged( const QString& ) ) ); | 283 | SLOT( textChanged( const QString& ) ) ); |
285 | label->setBuddy( mURLEdit ); | 284 | label->setBuddy( mURLEdit ); |
286 | layout->addWidget( label, 8, 4 ); | 285 | layout->addWidget( label, 8, 4 ); |
287 | layout->addMultiCellWidget( mURLEdit, 8, 8, 5, 6 ); | 286 | layout->addMultiCellWidget( mURLEdit, 8, 8, 5, 6 ); |
288 | 287 | ||
289 | label = new QLabel( i18n( "&IM address:" ), tab1 ); | 288 | label = new QLabel( i18n( "&IM address:" ), tab1 ); |
290 | mIMAddressEdit = new KLineEdit( tab1 ); | 289 | mIMAddressEdit = new KLineEdit( tab1 ); |
291 | connect( mIMAddressEdit, SIGNAL( textChanged( const QString& ) ), | 290 | connect( mIMAddressEdit, SIGNAL( textChanged( const QString& ) ), |
292 | SLOT( textChanged( const QString& ) ) ); | 291 | SLOT( textChanged( const QString& ) ) ); |
293 | label->setBuddy( mIMAddressEdit ); | 292 | label->setBuddy( mIMAddressEdit ); |
294 | layout->addWidget( label, 9, 4 ); | 293 | layout->addWidget( label, 9, 4 ); |
295 | layout->addMultiCellWidget( mIMAddressEdit, 9, 9, 5, 6 ); | 294 | layout->addMultiCellWidget( mIMAddressEdit, 9, 9, 5, 6 ); |
296 | 295 | ||
297 | layout->addColSpacing( 6, 50 ); | 296 | layout->addColSpacing( 6, 50 ); |
298 | 297 | ||
299 | bar = new KSeparator( KSeparator::HLine, tab1 ); | 298 | bar = new KSeparator( KSeparator::HLine, tab1 ); |
300 | layout->addMultiCellWidget( bar, 10, 10, 0, 6 ); | 299 | layout->addMultiCellWidget( bar, 10, 10, 0, 6 ); |
301 | */ | 300 | */ |
302 | /////////////////////////////////////// | 301 | /////////////////////////////////////// |
303 | QHBox *categoryBox = new QHBox( tab1 ); | 302 | QHBox *categoryBox = new QHBox( tab1 ); |
304 | categoryBox->setSpacing( KDialogBase::spacingHint() ); | 303 | categoryBox->setSpacing( KDialogBase::spacingHint() ); |
305 | categoryBox->setMargin( KDialogBase::marginHintSmall() ); | 304 | categoryBox->setMargin( KDialogBase::marginHintSmall() ); |
306 | 305 | ||
307 | // Categories | 306 | // Categories |
308 | button = new QPushButton( i18n( "Categories" ), categoryBox ); | 307 | button = new QPushButton( i18n( "Categories" ), categoryBox ); |
309 | connect( button, SIGNAL( clicked() ), SLOT( categoryButtonClicked() ) ); | 308 | connect( button, SIGNAL( clicked() ), SLOT( categoryButtonClicked() ) ); |
310 | 309 | ||
311 | mCategoryEdit = new KLineEdit( categoryBox ); | 310 | mCategoryEdit = new KLineEdit( categoryBox ); |
312 | mCategoryEdit->setReadOnly( true ); | 311 | mCategoryEdit->setReadOnly( true ); |
313 | connect( mCategoryEdit, SIGNAL( textChanged( const QString& ) ), | 312 | connect( mCategoryEdit, SIGNAL( textChanged( const QString& ) ), |
314 | SLOT( textChanged( const QString& ) ) ); | 313 | SLOT( textChanged( const QString& ) ) ); |
315 | 314 | ||
316 | mSecrecyWidget = new SecrecyWidget( categoryBox ); | 315 | mSecrecyWidget = new SecrecyWidget( categoryBox ); |
317 | connect( mSecrecyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); | 316 | connect( mSecrecyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); |
318 | 317 | ||
319 | //US layout->addMultiCellWidget( categoryBox, 11, 11, 0, 6 ); | 318 | //US layout->addMultiCellWidget( categoryBox, 11, 11, 0, 6 ); |
320 | layout->addMultiCellWidget( categoryBox, iii, iii, 0, 1 ); | 319 | layout->addMultiCellWidget( categoryBox, iii, iii, 0, 1 ); |
321 | 320 | ||
322 | // Build the layout and add to the tab widget | 321 | // Build the layout and add to the tab widget |
323 | layout->activate(); // required | 322 | layout->activate(); // required |
324 | 323 | ||
325 | mTabWidget->addTab( tab1, i18n( "&General" ) ); | 324 | mTabWidget->addTab( tab1, i18n( "&General" ) ); |
326 | } | 325 | } |
327 | 326 | ||
328 | 327 | ||
329 | void AddresseeEditorWidget::setupTab1_1() | 328 | void AddresseeEditorWidget::setupTab1_1() |
330 | { | 329 | { |
331 | // This is the Address tab | 330 | // This is the Address tab |
332 | QWidget *tab1_1 = new QWidget( mTabWidget ); | 331 | QWidget *tab1_1 = new QWidget( mTabWidget ); |
333 | 332 | ||
334 | //US QGridLayout *layout = new QGridLayout( tab1_1, 11, 7 ); | 333 | //US QGridLayout *layout = new QGridLayout( tab1_1, 11, 7 ); |
335 | QGridLayout *layout = new QGridLayout( tab1_1, 7, 2 ); | 334 | QGridLayout *layout = new QGridLayout( tab1_1, 7, 2 ); |
336 | layout->setMargin( KDialogBase::marginHintSmall() ); | 335 | layout->setMargin( KDialogBase::marginHintSmall() ); |
337 | layout->setSpacing( KDialogBase::spacingHintSmall() ); | 336 | layout->setSpacing( KDialogBase::spacingHintSmall() ); |
338 | 337 | ||
339 | QLabel *label; | 338 | QLabel *label; |
340 | KSeparator* bar; | 339 | KSeparator* bar; |
341 | QPushButton *button; | 340 | QPushButton *button; |
342 | 341 | ||
343 | /*US | 342 | /*US |
344 | ////////////////////////////////// | 343 | ////////////////////////////////// |
345 | // Upper left group (person info) | 344 | // Upper left group (person info) |
346 | 345 | ||
347 | // Person icon | 346 | // Person icon |
348 | label = new QLabel( tab1 ); | 347 | label = new QLabel( tab1 ); |
349 | //US ambiguous call. Add one more parameter | 348 | //US ambiguous call. Add one more parameter |
350 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) ); | 349 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) ); |
351 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) ); | 350 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) ); |
352 | layout->addMultiCellWidget( label, 0, 1, 0, 0 ); | 351 | layout->addMultiCellWidget( label, 0, 1, 0, 0 ); |
353 | 352 | ||
354 | // First name | 353 | // First name |
355 | button = new QPushButton( i18n( "Name..." ), tab1 ); | 354 | button = new QPushButton( i18n( "Name..." ), tab1 ); |
356 | QToolTip::add( button, i18n( "Edit the contact's name" ) ); | 355 | QToolTip::add( button, i18n( "Edit the contact's name" ) ); |
357 | mNameEdit = new KLineEdit( tab1, "mNameEdit" ); | 356 | mNameEdit = new KLineEdit( tab1, "mNameEdit" ); |
358 | connect( mNameEdit, SIGNAL( textChanged( const QString& ) ), | 357 | connect( mNameEdit, SIGNAL( textChanged( const QString& ) ), |
359 | SLOT( nameTextChanged( const QString& ) ) ); | 358 | SLOT( nameTextChanged( const QString& ) ) ); |
360 | connect( button, SIGNAL( clicked() ), SLOT( nameButtonClicked() ) ); | 359 | connect( button, SIGNAL( clicked() ), SLOT( nameButtonClicked() ) ); |
361 | 360 | ||
362 | #ifndef KAB_EMBEDDED | 361 | #ifndef KAB_EMBEDDED |
363 | mNameLabel = new KSqueezedTextLabel( tab1 ); | 362 | mNameLabel = new KSqueezedTextLabel( tab1 ); |
364 | mNameLabel->hide(); | 363 | mNameLabel->hide(); |
365 | #else //KAB_EMBEDDED | 364 | #else //KAB_EMBEDDED |
366 | qDebug("AddresseeEditorWidget::setupTab1 has to be changed"); | 365 | qDebug("AddresseeEditorWidget::setupTab1 has to be changed"); |
367 | #endif //KAB_EMBEDDED | 366 | #endif //KAB_EMBEDDED |
368 | 367 | ||
369 | layout->addWidget( button, 0, 1 ); | 368 | layout->addWidget( button, 0, 1 ); |
370 | layout->addWidget( mNameEdit, 0, 2 ); | 369 | layout->addWidget( mNameEdit, 0, 2 ); |
371 | 370 | ||
372 | #ifndef KAB_EMBEDDED | 371 | #ifndef KAB_EMBEDDED |
373 | layout->addWidget( mNameLabel, 0, 2 ); | 372 | layout->addWidget( mNameLabel, 0, 2 ); |
374 | #else //KAB_EMBEDDED | 373 | #else //KAB_EMBEDDED |
375 | qDebug("AddresseeEditorWidget::setupTab1 has to be changed"); | 374 | qDebug("AddresseeEditorWidget::setupTab1 has to be changed"); |
376 | #endif //KAB_EMBEDDED | 375 | #endif //KAB_EMBEDDED |
377 | 376 | ||
378 | label = new QLabel( i18n( "Role:" ), tab1 ); | 377 | label = new QLabel( i18n( "Role:" ), tab1 ); |
379 | mRoleEdit = new KLineEdit( tab1 ); | 378 | mRoleEdit = new KLineEdit( tab1 ); |
380 | connect( mRoleEdit, SIGNAL( textChanged( const QString& ) ), | 379 | connect( mRoleEdit, SIGNAL( textChanged( const QString& ) ), |
381 | SLOT( textChanged( const QString& ) ) ); | 380 | SLOT( textChanged( const QString& ) ) ); |
382 | label->setBuddy( mRoleEdit ); | 381 | label->setBuddy( mRoleEdit ); |
383 | layout->addWidget( label, 1, 1 ); | 382 | layout->addWidget( label, 1, 1 ); |
384 | layout->addWidget( mRoleEdit, 1, 2 ); | 383 | layout->addWidget( mRoleEdit, 1, 2 ); |
385 | 384 | ||
386 | // Organization | 385 | // Organization |
387 | label = new QLabel( i18n( "Organization:" ), tab1 ); | 386 | label = new QLabel( i18n( "Organization:" ), tab1 ); |
388 | mOrgEdit = new KLineEdit( tab1 ); | 387 | mOrgEdit = new KLineEdit( tab1 ); |
389 | label->setBuddy( mOrgEdit ); | 388 | label->setBuddy( mOrgEdit ); |
390 | connect( mOrgEdit, SIGNAL( textChanged( const QString& ) ), | 389 | connect( mOrgEdit, SIGNAL( textChanged( const QString& ) ), |
391 | SLOT( textChanged( const QString& ) ) ); | 390 | SLOT( textChanged( const QString& ) ) ); |
392 | layout->addWidget( label, 2, 1 ); | 391 | layout->addWidget( label, 2, 1 ); |
393 | layout->addWidget( mOrgEdit, 2, 2 ); | 392 | layout->addWidget( mOrgEdit, 2, 2 ); |
394 | 393 | ||
395 | // File as (formatted name) | 394 | // File as (formatted name) |
396 | label = new QLabel( i18n( "Formatted name:" ), tab1 ); | 395 | label = new QLabel( i18n( "Formatted name:" ), tab1 ); |
397 | #ifndef KAB_EMBEDDED | 396 | #ifndef KAB_EMBEDDED |
398 | mFormattedNameLabel = new KSqueezedTextLabel( tab1 ); | 397 | mFormattedNameLabel = new KSqueezedTextLabel( tab1 ); |
399 | #else //KAB_EMBEDDED | 398 | #else //KAB_EMBEDDED |
400 | qDebug("AddresseeEditorWidget::setupTab1 has to be changed"); | 399 | qDebug("AddresseeEditorWidget::setupTab1 has to be changed"); |
401 | #endif //KAB_EMBEDDED | 400 | #endif //KAB_EMBEDDED |
402 | layout->addWidget( label, 3, 1 ); | 401 | layout->addWidget( label, 3, 1 ); |
403 | #ifndef KAB_EMBEDDED | 402 | #ifndef KAB_EMBEDDED |
404 | layout->addWidget( mFormattedNameLabel, 3, 2 ); | 403 | layout->addWidget( mFormattedNameLabel, 3, 2 ); |
405 | #else //KAB_EMBEDDED | 404 | #else //KAB_EMBEDDED |
406 | qDebug("AddresseeEditorWidget::setupTab1 has to be changed"); | 405 | qDebug("AddresseeEditorWidget::setupTab1 has to be changed"); |
407 | #endif //KAB_EMBEDDED | 406 | #endif //KAB_EMBEDDED |
408 | 407 | ||
409 | // Left hand separator. This separator doesn't go all the way | 408 | // Left hand separator. This separator doesn't go all the way |
410 | // across so the dialog still flows from top to bottom | 409 | // across so the dialog still flows from top to bottom |
411 | bar = new KSeparator( KSeparator::HLine, tab1 ); | 410 | bar = new KSeparator( KSeparator::HLine, tab1 ); |
412 | layout->addMultiCellWidget( bar, 4, 4, 0, 2 ); | 411 | layout->addMultiCellWidget( bar, 4, 4, 0, 2 ); |
413 | 412 | ||
414 | ////////////////////////////////////// | 413 | ////////////////////////////////////// |
415 | // Phone numbers (upper right) | 414 | // Phone numbers (upper right) |
416 | label = new QLabel( tab1 ); | 415 | label = new QLabel( tab1 ); |
417 | //US loadIcon call is ambiguous. Add one more parameter | 416 | //US loadIcon call is ambiguous. Add one more parameter |
418 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop ) ); | 417 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop ) ); |
419 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) ); | 418 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) ); |
420 | layout->addMultiCellWidget( label, 0, 1, 3, 3 ); | 419 | layout->addMultiCellWidget( label, 0, 1, 3, 3 ); |
421 | 420 | ||
422 | mPhoneEditWidget = new PhoneEditWidget( tab1 ); | 421 | mPhoneEditWidget = new PhoneEditWidget( tab1 ); |
423 | connect( mPhoneEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); | 422 | connect( mPhoneEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); |
424 | layout->addMultiCellWidget( mPhoneEditWidget, 0, 3, 4, 6 ); | 423 | layout->addMultiCellWidget( mPhoneEditWidget, 0, 3, 4, 6 ); |
425 | 424 | ||
426 | bar = new KSeparator( KSeparator::HLine, tab1 ); | 425 | bar = new KSeparator( KSeparator::HLine, tab1 ); |
427 | layout->addMultiCellWidget( bar, 4, 4, 3, 6 ); | 426 | layout->addMultiCellWidget( bar, 4, 4, 3, 6 ); |
428 | */ | 427 | */ |
429 | ////////////////////////////////////// | 428 | ////////////////////////////////////// |
430 | // Addresses (lower left) | 429 | // Addresses (lower left) |
431 | /* LR | 430 | /* LR |
432 | label = new QLabel( tab1_1 ); | 431 | label = new QLabel( tab1_1 ); |
433 | //US loadIcon call is ambiguous. Add one more parameter | 432 | //US loadIcon call is ambiguous. Add one more parameter |
434 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop ) ); | 433 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop ) ); |
435 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop, 0 ) ); | 434 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop, 0 ) ); |
436 | //US layout->addMultiCellWidget( label, 5, 6, 0, 0 ); | 435 | //US layout->addMultiCellWidget( label, 5, 6, 0, 0 ); |
437 | layout->addMultiCellWidget( label, 0, 1, 0, 0 ); | 436 | layout->addMultiCellWidget( label, 0, 1, 0, 0 ); |
438 | */ | 437 | */ |
439 | 438 | ||
440 | mAddressEditWidget = new AddressEditWidget( tab1_1 ); | 439 | mAddressEditWidget = new AddressEditWidget( tab1_1 ); |
441 | connect( mAddressEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); | 440 | connect( mAddressEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); |
442 | //US layout->addMultiCellWidget( mAddressEditWidget, 5, 9, 1, 2 ); | 441 | //US layout->addMultiCellWidget( mAddressEditWidget, 5, 9, 1, 2 ); |
443 | layout->addMultiCellWidget( mAddressEditWidget, 0, 4, 0, 1 ); | 442 | layout->addMultiCellWidget( mAddressEditWidget, 0, 4, 0, 1 ); |
444 | 443 | ||
445 | //US | 444 | //US |
446 | /* LR | 445 | /* LR |
447 | bar = new KSeparator( KSeparator::HLine, tab1_1 ); | 446 | bar = new KSeparator( KSeparator::HLine, tab1_1 ); |
448 | layout->addMultiCellWidget( bar, 5, 5, 0, 3 ); | 447 | layout->addMultiCellWidget( bar, 5, 5, 0, 3 ); |
449 | */ | 448 | */ |
450 | 449 | ||
451 | ////////////////////////////////////// | 450 | ////////////////////////////////////// |
452 | // Email / Web (lower right) | 451 | // Email / Web (lower right) |
453 | /* LR | 452 | /* LR |
454 | label = new QLabel( tab1_1 ); | 453 | label = new QLabel( tab1_1 ); |
455 | //US loadIcon call is ambiguous. Add one more parameter | 454 | //US loadIcon call is ambiguous. Add one more parameter |
456 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop) ); | 455 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop) ); |
457 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop, 0) ); | 456 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop, 0) ); |
458 | //US layout->addMultiCellWidget( label, 5, 6, 3, 3 ); | 457 | //US layout->addMultiCellWidget( label, 5, 6, 3, 3 ); |
459 | layout->addMultiCellWidget( label, 6, 7, 0, 0 ); | 458 | layout->addMultiCellWidget( label, 6, 7, 0, 0 ); |
460 | */ | 459 | */ |
461 | mEmailWidget = new EmailEditWidget( tab1_1 ); | 460 | mEmailWidget = new EmailEditWidget( tab1_1 ); |
462 | connect( mEmailWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); | 461 | connect( mEmailWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); |
463 | //US layout->addMultiCellWidget( mEmailWidget, 5, 6, 4, 6 ); | 462 | //US layout->addMultiCellWidget( mEmailWidget, 5, 6, 4, 6 ); |
464 | layout->addMultiCellWidget( mEmailWidget, 5, 6, 0, 1 ); | 463 | layout->addMultiCellWidget( mEmailWidget, 5, 6, 0, 1 ); |
465 | 464 | ||
466 | /* LR | 465 | /* LR |
467 | // add the separator | 466 | // add the separator |
468 | bar = new KSeparator( KSeparator::HLine, tab1_1 ); | 467 | bar = new KSeparator( KSeparator::HLine, tab1_1 ); |
469 | //US layout->addMultiCellWidget( bar, 7, 7, 3, 6 ); | 468 | //US layout->addMultiCellWidget( bar, 7, 7, 3, 6 ); |
470 | layout->addMultiCellWidget( bar, 8, 8, 0, 3 ); | 469 | layout->addMultiCellWidget( bar, 8, 8, 0, 3 ); |
471 | 470 | ||
472 | label = new QLabel( tab1_1 ); | 471 | label = new QLabel( tab1_1 ); |
473 | //US loadIcon call is ambiguous. Add one more parameter | 472 | //US loadIcon call is ambiguous. Add one more parameter |
474 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop) ); | 473 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop) ); |
475 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop, 0) ); | 474 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop, 0) ); |
476 | //US layout->addMultiCellWidget( label, 8, 9, 3, 3 ); | 475 | //US layout->addMultiCellWidget( label, 8, 9, 3, 3 ); |
477 | layout->addMultiCellWidget( label, 9, 10, 0, 0 ); | 476 | layout->addMultiCellWidget( label, 9, 10, 0, 0 ); |
478 | */ | 477 | */ |
479 | label = new QLabel( i18n( "URL:" ), tab1_1 ); | 478 | label = new QLabel( i18n( "URL:" ), tab1_1 ); |
480 | mURLEdit = new KLineEdit( tab1_1 ); | 479 | mURLEdit = new KLineEdit( tab1_1 ); |
481 | connect( mURLEdit, SIGNAL( textChanged( const QString& ) ), | 480 | connect( mURLEdit, SIGNAL( textChanged( const QString& ) ), |
482 | SLOT( textChanged( const QString& ) ) ); | 481 | SLOT( textChanged( const QString& ) ) ); |
483 | label->setBuddy( mURLEdit ); | 482 | label->setBuddy( mURLEdit ); |
484 | //US layout->addWidget( label, 8, 4 ); | 483 | //US layout->addWidget( label, 8, 4 ); |
485 | layout->addWidget( label, 7,0 ); | 484 | layout->addWidget( label, 7,0 ); |
486 | //US layout->addMultiCellWidget( mURLEdit, 8, 8, 5, 6 ); | 485 | //US layout->addMultiCellWidget( mURLEdit, 8, 8, 5, 6 ); |
487 | layout->addWidget( mURLEdit, 7, 1); | 486 | layout->addWidget( mURLEdit, 7, 1); |
488 | 487 | ||
489 | label = new QLabel( i18n( "&IM address:" ), tab1_1 ); | 488 | label = new QLabel( i18n( "&IM address:" ), tab1_1 ); |
490 | mIMAddressEdit = new KLineEdit( tab1_1 ); | 489 | mIMAddressEdit = new KLineEdit( tab1_1 ); |
491 | connect( mIMAddressEdit, SIGNAL( textChanged( const QString& ) ), | 490 | connect( mIMAddressEdit, SIGNAL( textChanged( const QString& ) ), |
492 | SLOT( textChanged( const QString& ) ) ); | 491 | SLOT( textChanged( const QString& ) ) ); |
493 | label->setBuddy( mIMAddressEdit ); | 492 | label->setBuddy( mIMAddressEdit ); |
494 | //US layout->addWidget( label, 9, 4 ); | 493 | //US layout->addWidget( label, 9, 4 ); |
495 | layout->addWidget( label, 8, 0 ); | 494 | layout->addWidget( label, 8, 0 ); |
496 | //US layout->addMultiCellWidget( mIMAddressEdit, 9, 9, 5, 6 ); | 495 | //US layout->addMultiCellWidget( mIMAddressEdit, 9, 9, 5, 6 ); |
497 | layout->addWidget( mIMAddressEdit, 8,1 ); | 496 | layout->addWidget( mIMAddressEdit, 8,1 ); |
498 | 497 | ||
499 | //US layout->addColSpacing( 6, 50 ); | 498 | //US layout->addColSpacing( 6, 50 ); |
500 | 499 | ||
501 | //US bar = new KSeparator( KSeparator::HLine, tab1_1 ); | 500 | //US bar = new KSeparator( KSeparator::HLine, tab1_1 ); |
502 | //US layout->addMultiCellWidget( bar, 10, 10, 0, 6 ); | 501 | //US layout->addMultiCellWidget( bar, 10, 10, 0, 6 ); |
503 | 502 | ||
504 | /*US | 503 | /*US |
505 | /////////////////////////////////////// | 504 | /////////////////////////////////////// |
506 | QHBox *categoryBox = new QHBox( tab1 ); | 505 | QHBox *categoryBox = new QHBox( tab1 ); |
507 | categoryBox->setSpacing( KDialogBase::spacingHintSmall() ); | 506 | categoryBox->setSpacing( KDialogBase::spacingHintSmall() ); |
508 | 507 | ||
509 | // Categories | 508 | // Categories |
510 | button = new QPushButton( i18n( "Categories" ), categoryBox ); | 509 | button = new QPushButton( i18n( "Categories" ), categoryBox ); |
511 | connect( button, SIGNAL( clicked() ), SLOT( categoryButtonClicked() ) ); | 510 | connect( button, SIGNAL( clicked() ), SLOT( categoryButtonClicked() ) ); |
512 | 511 | ||
513 | mCategoryEdit = new KLineEdit( categoryBox ); | 512 | mCategoryEdit = new KLineEdit( categoryBox ); |
514 | mCategoryEdit->setReadOnly( true ); | 513 | mCategoryEdit->setReadOnly( true ); |
515 | connect( mCategoryEdit, SIGNAL( textChanged( const QString& ) ), | 514 | connect( mCategoryEdit, SIGNAL( textChanged( const QString& ) ), |
516 | SLOT( textChanged( const QString& ) ) ); | 515 | SLOT( textChanged( const QString& ) ) ); |
517 | 516 | ||
518 | mSecrecyWidget = new SecrecyWidget( categoryBox ); | 517 | mSecrecyWidget = new SecrecyWidget( categoryBox ); |
519 | connect( mSecrecyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); | 518 | connect( mSecrecyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); |
520 | 519 | ||
521 | layout->addMultiCellWidget( categoryBox, 11, 11, 0, 6 ); | 520 | layout->addMultiCellWidget( categoryBox, 11, 11, 0, 6 ); |
522 | */ | 521 | */ |
523 | // Build the layout and add to the tab widget | 522 | // Build the layout and add to the tab widget |
524 | layout->activate(); // required | 523 | layout->activate(); // required |
525 | 524 | ||
526 | mTabWidget->addTab( tab1_1, i18n( "&Address" ) ); | 525 | mTabWidget->addTab( tab1_1, i18n( "&Address" ) ); |
527 | } | 526 | } |
528 | 527 | ||
529 | 528 | ||
530 | 529 | ||
531 | void AddresseeEditorWidget::setupTab2() | 530 | void AddresseeEditorWidget::setupTab2() |
532 | { | 531 | { |
533 | // This is the Details tab | 532 | // This is the Details tab |
534 | QWidget *tab2 = new QWidget( mTabWidget ); | 533 | QWidget *tab2 = new QWidget( mTabWidget ); |
535 | 534 | ||
536 | QGridLayout *layout = new QGridLayout( tab2, 8, 3 ); | 535 | QGridLayout *layout = new QGridLayout( tab2, 8, 3 ); |
537 | layout->setMargin( KDialogBase::marginHintSmall() ); | 536 | layout->setMargin( KDialogBase::marginHintSmall() ); |
538 | layout->setSpacing( KDialogBase::spacingHintSmall() ); | 537 | layout->setSpacing( KDialogBase::spacingHintSmall() ); |
539 | 538 | ||
540 | QLabel *label; | 539 | QLabel *label; |
541 | KSeparator* bar; | 540 | KSeparator* bar; |
542 | 541 | ||
543 | /////////////////////// | 542 | /////////////////////// |
544 | // Office info | 543 | // Office info |
545 | 544 | ||
546 | // Department | 545 | // Department |
547 | label = new QLabel( tab2 ); | 546 | label = new QLabel( tab2 ); |
548 | //US loadIcon call is ambiguous. Add one more parameter | 547 | //US loadIcon call is ambiguous. Add one more parameter |
549 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop ) ); | 548 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop ) ); |
550 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop, 0 ) ); | 549 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop, 0 ) ); |
551 | layout->addMultiCellWidget( label, 0, 1, 0, 0 ); | 550 | layout->addMultiCellWidget( label, 0, 1, 0, 0 ); |
552 | 551 | ||
553 | label = new QLabel( i18n( "Department:" ), tab2 ); | 552 | label = new QLabel( i18n( "Department:" ), tab2 ); |
554 | layout->addWidget( label, 0, 1 ); | 553 | layout->addWidget( label, 0, 1 ); |
555 | mDepartmentEdit = new KLineEdit( tab2 ); | 554 | mDepartmentEdit = new KLineEdit( tab2 ); |
556 | connect( mDepartmentEdit, SIGNAL( textChanged( const QString& ) ), | 555 | connect( mDepartmentEdit, SIGNAL( textChanged( const QString& ) ), |
557 | SLOT( textChanged( const QString& ) ) ); | 556 | SLOT( textChanged( const QString& ) ) ); |
558 | label->setBuddy( mDepartmentEdit ); | 557 | label->setBuddy( mDepartmentEdit ); |
559 | layout->addWidget( mDepartmentEdit, 0, 2 ); | 558 | layout->addWidget( mDepartmentEdit, 0, 2 ); |
560 | 559 | ||
561 | label = new QLabel( i18n( "Office:" ), tab2 ); | 560 | label = new QLabel( i18n( "Office:" ), tab2 ); |
562 | layout->addWidget( label, 1, 1 ); | 561 | layout->addWidget( label, 1, 1 ); |
563 | mOfficeEdit = new KLineEdit( tab2 ); | 562 | mOfficeEdit = new KLineEdit( tab2 ); |
564 | connect( mOfficeEdit, SIGNAL( textChanged( const QString& ) ), | 563 | connect( mOfficeEdit, SIGNAL( textChanged( const QString& ) ), |
565 | SLOT( textChanged( const QString& ) ) ); | 564 | SLOT( textChanged( const QString& ) ) ); |
566 | label->setBuddy( mOfficeEdit ); | 565 | label->setBuddy( mOfficeEdit ); |
567 | layout->addWidget( mOfficeEdit, 1, 2 ); | 566 | layout->addWidget( mOfficeEdit, 1, 2 ); |
568 | 567 | ||
569 | label = new QLabel( i18n( "Profession:" ), tab2 ); | 568 | label = new QLabel( i18n( "Profession:" ), tab2 ); |
570 | layout->addWidget( label, 2, 1 ); | 569 | layout->addWidget( label, 2, 1 ); |
571 | mProfessionEdit = new KLineEdit( tab2 ); | 570 | mProfessionEdit = new KLineEdit( tab2 ); |
572 | connect( mProfessionEdit, SIGNAL( textChanged( const QString& ) ), | 571 | connect( mProfessionEdit, SIGNAL( textChanged( const QString& ) ), |
573 | SLOT( textChanged( const QString& ) ) ); | 572 | SLOT( textChanged( const QString& ) ) ); |
574 | label->setBuddy( mProfessionEdit ); | 573 | label->setBuddy( mProfessionEdit ); |
575 | layout->addWidget( mProfessionEdit, 2, 2 ); | 574 | layout->addWidget( mProfessionEdit, 2, 2 ); |
576 | 575 | ||
577 | label = new QLabel( i18n( "Manager\'s name:" ), tab2 ); | 576 | label = new QLabel( i18n( "Manager\'s name:" ), tab2 ); |
578 | //US layout->addWidget( label, 0, 3 ); | 577 | //US layout->addWidget( label, 0, 3 ); |
579 | layout->addWidget( label, 3, 1 ); | 578 | layout->addWidget( label, 3, 1 ); |
580 | mManagerEdit = new KLineEdit( tab2 ); | 579 | mManagerEdit = new KLineEdit( tab2 ); |
581 | connect( mManagerEdit, SIGNAL( textChanged( const QString& ) ), | 580 | connect( mManagerEdit, SIGNAL( textChanged( const QString& ) ), |
582 | SLOT( textChanged( const QString& ) ) ); | 581 | SLOT( textChanged( const QString& ) ) ); |
583 | label->setBuddy( mManagerEdit ); | 582 | label->setBuddy( mManagerEdit ); |
584 | //US layout->addMultiCellWidget( mManagerEdit, 0, 0, 4, 5 ); | 583 | //US layout->addMultiCellWidget( mManagerEdit, 0, 0, 4, 5 ); |
585 | layout->addWidget( mManagerEdit, 3, 2 ); | 584 | layout->addWidget( mManagerEdit, 3, 2 ); |
586 | 585 | ||
587 | label = new QLabel( i18n( "Assistant's name:" ), tab2 ); | 586 | label = new QLabel( i18n( "Assistant's name:" ), tab2 ); |
588 | //US layout->addWidget( label, 1, 3 ); | 587 | //US layout->addWidget( label, 1, 3 ); |
589 | layout->addWidget( label, 4, 1 ); | 588 | layout->addWidget( label, 4, 1 ); |
590 | mAssistantEdit = new KLineEdit( tab2 ); | 589 | mAssistantEdit = new KLineEdit( tab2 ); |
591 | connect( mAssistantEdit, SIGNAL( textChanged( const QString& ) ), | 590 | connect( mAssistantEdit, SIGNAL( textChanged( const QString& ) ), |
592 | SLOT( textChanged( const QString& ) ) ); | 591 | SLOT( textChanged( const QString& ) ) ); |
593 | label->setBuddy( mAssistantEdit ); | 592 | label->setBuddy( mAssistantEdit ); |
594 | //US layout->addMultiCellWidget( mAssistantEdit, 1, 1, 4, 5 ); | 593 | //US layout->addMultiCellWidget( mAssistantEdit, 1, 1, 4, 5 ); |
595 | layout->addWidget( mAssistantEdit, 4, 2 ); | 594 | layout->addWidget( mAssistantEdit, 4, 2 ); |
596 | 595 | ||
597 | bar = new KSeparator( KSeparator::HLine, tab2 ); | 596 | bar = new KSeparator( KSeparator::HLine, tab2 ); |
598 | //US layout->addMultiCellWidget( bar, 3, 3, 0, 5 ); | 597 | //US layout->addMultiCellWidget( bar, 3, 3, 0, 5 ); |
599 | layout->addMultiCellWidget( bar, 5, 5, 0, 2 ); | 598 | layout->addMultiCellWidget( bar, 5, 5, 0, 2 ); |
600 | 599 | ||
601 | ///////////////////////////////////////////////// | 600 | ///////////////////////////////////////////////// |
602 | // Personal info | 601 | // Personal info |
603 | 602 | ||
604 | label = new QLabel( tab2 ); | 603 | label = new QLabel( tab2 ); |
605 | //US loadIcon call is ambiguous. Add one more parameter | 604 | //US loadIcon call is ambiguous. Add one more parameter |
606 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) ); | 605 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) ); |
607 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) ); | 606 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) ); |
608 | //US layout->addMultiCellWidget( label, 4, 5, 0, 0 ); | 607 | //US layout->addMultiCellWidget( label, 4, 5, 0, 0 ); |
609 | layout->addMultiCellWidget( label, 6, 7, 0, 0 ); | 608 | layout->addMultiCellWidget( label, 6, 7, 0, 0 ); |
610 | 609 | ||
611 | label = new QLabel( i18n( "Nick name:" ), tab2 ); | 610 | label = new QLabel( i18n( "Nick name:" ), tab2 ); |
612 | //US layout->addWidget( label, 4, 1 ); | 611 | //US layout->addWidget( label, 4, 1 ); |
613 | layout->addWidget( label, 6, 1 ); | 612 | layout->addWidget( label, 6, 1 ); |
614 | mNicknameEdit = new KLineEdit( tab2 ); | 613 | mNicknameEdit = new KLineEdit( tab2 ); |
615 | connect( mNicknameEdit, SIGNAL( textChanged( const QString& ) ), | 614 | connect( mNicknameEdit, SIGNAL( textChanged( const QString& ) ), |
616 | SLOT( textChanged( const QString& ) ) ); | 615 | SLOT( textChanged( const QString& ) ) ); |
617 | label->setBuddy( mNicknameEdit ); | 616 | label->setBuddy( mNicknameEdit ); |
618 | //US layout->addWidget( mNicknameEdit, 4, 2 ); | 617 | //US layout->addWidget( mNicknameEdit, 4, 2 ); |
619 | layout->addWidget( mNicknameEdit, 6, 2 ); | 618 | layout->addWidget( mNicknameEdit, 6, 2 ); |
620 | 619 | ||
621 | label = new QLabel( i18n( "Spouse's name:" ), tab2 ); | 620 | label = new QLabel( i18n( "Spouse's name:" ), tab2 ); |
622 | //US layout->addWidget( label, 5, 1 ); | 621 | //US layout->addWidget( label, 5, 1 ); |
623 | layout->addWidget( label, 7, 1 ); | 622 | layout->addWidget( label, 7, 1 ); |
624 | mSpouseEdit = new KLineEdit( tab2 ); | 623 | mSpouseEdit = new KLineEdit( tab2 ); |
625 | connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ), | 624 | connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ), |
626 | SLOT( textChanged( const QString& ) ) ); | 625 | SLOT( textChanged( const QString& ) ) ); |
627 | label->setBuddy( mSpouseEdit ); | 626 | label->setBuddy( mSpouseEdit ); |
628 | //US layout->addWidget( mSpouseEdit, 5, 2 ); | 627 | //US layout->addWidget( mSpouseEdit, 5, 2 ); |
629 | layout->addWidget( mSpouseEdit, 7, 2 ); | 628 | layout->addWidget( mSpouseEdit, 7, 2 ); |
630 | 629 | ||
631 | label = new QLabel( i18n( "Birthday:" ), tab2 ); | 630 | label = new QLabel( i18n( "Birthday:" ), tab2 ); |
632 | //US layout->addWidget( label, 4, 3 ); | 631 | //US layout->addWidget( label, 4, 3 ); |
633 | layout->addWidget( label, 8, 1 ); | 632 | layout->addWidget( label, 8, 1 ); |
634 | mBirthdayPicker = new KDateEdit( tab2 ); | 633 | mBirthdayPicker = new KDateEdit( tab2 ); |
634 | mBirthdayPicker->toggleDateFormat(); | ||
635 | mBirthdayPicker->setHandleInvalid( true ); | 635 | mBirthdayPicker->setHandleInvalid( true ); |
636 | connect( mBirthdayPicker, SIGNAL( dateChanged( QDate ) ), | 636 | connect( mBirthdayPicker, SIGNAL( dateChanged( QDate ) ), |
637 | SLOT( dateChanged( QDate ) ) ); | 637 | SLOT( dateChanged( QDate ) ) ); |
638 | 638 | ||
639 | 639 | ||
640 | #ifndef KAB_EMBEDDED | 640 | #ifndef KAB_EMBEDDED |
641 | //US invalid dates are handdled by the KDateEdit widget itself | 641 | //US invalid dates are handdled by the KDateEdit widget itself |
642 | connect( mBirthdayPicker, SIGNAL( invalidDateEntered() ), | 642 | connect( mBirthdayPicker, SIGNAL( invalidDateEntered() ), |
643 | SLOT( invalidDate() ) ); | 643 | SLOT( invalidDate() ) ); |
644 | connect( mBirthdayPicker, SIGNAL( textChanged( const QString& ) ), | 644 | connect( mBirthdayPicker, SIGNAL( textChanged( const QString& ) ), |
645 | SLOT( emitModified() ) ); | 645 | SLOT( emitModified() ) ); |
646 | #endif //KAB_EMBEDDED | 646 | #endif //KAB_EMBEDDED |
647 | 647 | ||
648 | label->setBuddy( mBirthdayPicker ); | 648 | label->setBuddy( mBirthdayPicker ); |
649 | //US layout->addWidget( mBirthdayPicker, 4, 4 ); | 649 | //US layout->addWidget( mBirthdayPicker, 4, 4 ); |
650 | layout->addWidget( mBirthdayPicker, 8, 2 ); | 650 | layout->addWidget( mBirthdayPicker, 8, 2 ); |
651 | 651 | ||
652 | label = new QLabel( i18n( "Anniversary:" ), tab2 ); | 652 | label = new QLabel( i18n( "Anniversary:" ), tab2 ); |
653 | //US layout->addWidget( label, 5, 3 ); | 653 | //US layout->addWidget( label, 5, 3 ); |
654 | layout->addWidget( label, 9, 1 ); | 654 | layout->addWidget( label, 9, 1 ); |
655 | mAnniversaryPicker = new KDateEdit( tab2 ); | 655 | mAnniversaryPicker = new KDateEdit( tab2 ); |
656 | mAnniversaryPicker->setHandleInvalid( true ); | 656 | mAnniversaryPicker->setHandleInvalid( true ); |
657 | connect( mAnniversaryPicker, SIGNAL( dateChanged( QDate ) ), | 657 | connect( mAnniversaryPicker, SIGNAL( dateChanged( QDate ) ), |
658 | SLOT( dateChanged( QDate ) ) ); | 658 | SLOT( dateChanged( QDate ) ) ); |
659 | #ifndef KAB_EMBEDDED | 659 | #ifndef KAB_EMBEDDED |
660 | //US invalid dates are handled by the KDateEdit widget itself | 660 | //US invalid dates are handled by the KDateEdit widget itself |
661 | connect( mAnniversaryPicker, SIGNAL( invalidDateEntered() ), | 661 | connect( mAnniversaryPicker, SIGNAL( invalidDateEntered() ), |
662 | SLOT( invalidDate() ) ); | 662 | SLOT( invalidDate() ) ); |
663 | connect( mAnniversaryPicker, SIGNAL( textChanged( const QString& ) ), | 663 | connect( mAnniversaryPicker, SIGNAL( textChanged( const QString& ) ), |
664 | SLOT( emitModified() ) ); | 664 | SLOT( emitModified() ) ); |
665 | #endif //KAB_EMBEDDED | 665 | #endif //KAB_EMBEDDED |
666 | 666 | ||
667 | label->setBuddy( mAnniversaryPicker ); | 667 | label->setBuddy( mAnniversaryPicker ); |
668 | //US layout->addWidget( mAnniversaryPicker, 5, 4 ); | 668 | //US layout->addWidget( mAnniversaryPicker, 5, 4 ); |
669 | layout->addWidget( mAnniversaryPicker, 9, 2 ); | 669 | layout->addWidget( mAnniversaryPicker, 9, 2 ); |
670 | 670 | ||
671 | /*US | 671 | /*US |
672 | bar = new KSeparator( KSeparator::HLine, tab2 ); | 672 | bar = new KSeparator( KSeparator::HLine, tab2 ); |
673 | layout->addMultiCellWidget( bar, 6, 6, 0, 5 ); | 673 | layout->addMultiCellWidget( bar, 6, 6, 0, 5 ); |
674 | 674 | ||
675 | ////////////////////////////////////// | 675 | ////////////////////////////////////// |
676 | // Notes | 676 | // Notes |
677 | label = new QLabel( i18n( "Note:" ), tab2 ); | 677 | label = new QLabel( i18n( "Note:" ), tab2 ); |
678 | label->setAlignment( Qt::AlignTop | Qt::AlignLeft ); | 678 | label->setAlignment( Qt::AlignTop | Qt::AlignLeft ); |
679 | layout->addWidget( label, 7, 0 ); | 679 | layout->addWidget( label, 7, 0 ); |
680 | #ifndef KAB_EMBEDDED | 680 | #ifndef KAB_EMBEDDED |
681 | mNoteEdit = new QTextEdit( tab2 ); | 681 | mNoteEdit = new QTextEdit( tab2 ); |
682 | mNoteEdit->setWordWrap( QTextEdit::WidgetWidth ); | 682 | mNoteEdit->setWordWrap( QTextEdit::WidgetWidth ); |
683 | mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() ); | 683 | mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() ); |
684 | #else //KAB_EMBEDDED | 684 | #else //KAB_EMBEDDED |
685 | mNoteEdit = new QMultiLineEdit( tab2 ); | 685 | mNoteEdit = new QMultiLineEdit( tab2 ); |
686 | //US mNoteEdit->setWordWrap( QTextEdit::WidgetWidth ); | 686 | //US mNoteEdit->setWordWrap( QTextEdit::WidgetWidth ); |
687 | //US mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() ); | 687 | //US mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() ); |
688 | qDebug("AddresseeEditorWidget::setupTab2 has to be changed"); | 688 | qDebug("AddresseeEditorWidget::setupTab2 has to be changed"); |
689 | #endif //KAB_EMBEDDED | 689 | #endif //KAB_EMBEDDED |
690 | connect( mNoteEdit, SIGNAL( textChanged() ), SLOT( emitModified() ) ); | 690 | connect( mNoteEdit, SIGNAL( textChanged() ), SLOT( emitModified() ) ); |
691 | label->setBuddy( mNoteEdit ); | 691 | label->setBuddy( mNoteEdit ); |
692 | layout->addMultiCellWidget( mNoteEdit, 7, 7, 1, 5 ); | 692 | layout->addMultiCellWidget( mNoteEdit, 7, 7, 1, 5 ); |
693 | */ | 693 | */ |
694 | // Build the layout and add to the tab widget | 694 | // Build the layout and add to the tab widget |
695 | layout->activate(); // required | 695 | layout->activate(); // required |
696 | 696 | ||
697 | mTabWidget->addTab( tab2, i18n( "&Details" ) ); | 697 | mTabWidget->addTab( tab2, i18n( "&Details" ) ); |
698 | } | 698 | } |
699 | 699 | ||
700 | void AddresseeEditorWidget::setupTab2_1() | 700 | void AddresseeEditorWidget::setupTab2_1() |
701 | { | 701 | { |
702 | // This is the Details tab | 702 | // This is the Details tab |
703 | QWidget *tab2_2 = new QWidget( mTabWidget ); | 703 | QWidget *tab2_2 = new QWidget( mTabWidget ); |
704 | 704 | ||
705 | QGridLayout *layout = new QGridLayout( tab2_2, 1, 2 ); | 705 | QGridLayout *layout = new QGridLayout( tab2_2, 1, 2 ); |
706 | layout->setMargin( KDialogBase::marginHintSmall() ); | 706 | layout->setMargin( KDialogBase::marginHintSmall() ); |
707 | layout->setSpacing( KDialogBase::spacingHintSmall() ); | 707 | layout->setSpacing( KDialogBase::spacingHintSmall() ); |
708 | 708 | ||
709 | QLabel *label; | 709 | QLabel *label; |
710 | KSeparator* bar; | 710 | KSeparator* bar; |
711 | 711 | ||
712 | /*US | 712 | /*US |
713 | /////////////////////// | 713 | /////////////////////// |
714 | // Office info | 714 | // Office info |
715 | 715 | ||
716 | // Department | 716 | // Department |
717 | label = new QLabel( tab2 ); | 717 | label = new QLabel( tab2 ); |
718 | //US loadIcon call is ambiguous. Add one more parameter | 718 | //US loadIcon call is ambiguous. Add one more parameter |
719 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop ) ); | 719 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop ) ); |
720 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop, 0 ) ); | 720 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop, 0 ) ); |
721 | layout->addMultiCellWidget( label, 0, 1, 0, 0 ); | 721 | layout->addMultiCellWidget( label, 0, 1, 0, 0 ); |
722 | 722 | ||
723 | label = new QLabel( i18n( "Department:" ), tab2 ); | 723 | label = new QLabel( i18n( "Department:" ), tab2 ); |
724 | layout->addWidget( label, 0, 1 ); | 724 | layout->addWidget( label, 0, 1 ); |
725 | mDepartmentEdit = new KLineEdit( tab2 ); | 725 | mDepartmentEdit = new KLineEdit( tab2 ); |
726 | connect( mDepartmentEdit, SIGNAL( textChanged( const QString& ) ), | 726 | connect( mDepartmentEdit, SIGNAL( textChanged( const QString& ) ), |
727 | SLOT( textChanged( const QString& ) ) ); | 727 | SLOT( textChanged( const QString& ) ) ); |
728 | label->setBuddy( mDepartmentEdit ); | 728 | label->setBuddy( mDepartmentEdit ); |
729 | layout->addWidget( mDepartmentEdit, 0, 2 ); | 729 | layout->addWidget( mDepartmentEdit, 0, 2 ); |
730 | 730 | ||
731 | label = new QLabel( i18n( "Office:" ), tab2 ); | 731 | label = new QLabel( i18n( "Office:" ), tab2 ); |
732 | layout->addWidget( label, 1, 1 ); | 732 | layout->addWidget( label, 1, 1 ); |
733 | mOfficeEdit = new KLineEdit( tab2 ); | 733 | mOfficeEdit = new KLineEdit( tab2 ); |
734 | connect( mOfficeEdit, SIGNAL( textChanged( const QString& ) ), | 734 | connect( mOfficeEdit, SIGNAL( textChanged( const QString& ) ), |
735 | SLOT( textChanged( const QString& ) ) ); | 735 | SLOT( textChanged( const QString& ) ) ); |
736 | label->setBuddy( mOfficeEdit ); | 736 | label->setBuddy( mOfficeEdit ); |
737 | layout->addWidget( mOfficeEdit, 1, 2 ); | 737 | layout->addWidget( mOfficeEdit, 1, 2 ); |
738 | 738 | ||
739 | label = new QLabel( i18n( "Profession:" ), tab2 ); | 739 | label = new QLabel( i18n( "Profession:" ), tab2 ); |
740 | layout->addWidget( label, 2, 1 ); | 740 | layout->addWidget( label, 2, 1 ); |
741 | mProfessionEdit = new KLineEdit( tab2 ); | 741 | mProfessionEdit = new KLineEdit( tab2 ); |
742 | connect( mProfessionEdit, SIGNAL( textChanged( const QString& ) ), | 742 | connect( mProfessionEdit, SIGNAL( textChanged( const QString& ) ), |
743 | SLOT( textChanged( const QString& ) ) ); | 743 | SLOT( textChanged( const QString& ) ) ); |
744 | label->setBuddy( mProfessionEdit ); | 744 | label->setBuddy( mProfessionEdit ); |
745 | layout->addWidget( mProfessionEdit, 2, 2 ); | 745 | layout->addWidget( mProfessionEdit, 2, 2 ); |
746 | 746 | ||
747 | label = new QLabel( i18n( "Manager\'s name:" ), tab2 ); | 747 | label = new QLabel( i18n( "Manager\'s name:" ), tab2 ); |
748 | layout->addWidget( label, 0, 3 ); | 748 | layout->addWidget( label, 0, 3 ); |
749 | mManagerEdit = new KLineEdit( tab2 ); | 749 | mManagerEdit = new KLineEdit( tab2 ); |
750 | connect( mManagerEdit, SIGNAL( textChanged( const QString& ) ), | 750 | connect( mManagerEdit, SIGNAL( textChanged( const QString& ) ), |
751 | SLOT( textChanged( const QString& ) ) ); | 751 | SLOT( textChanged( const QString& ) ) ); |
752 | label->setBuddy( mManagerEdit ); | 752 | label->setBuddy( mManagerEdit ); |
753 | layout->addMultiCellWidget( mManagerEdit, 0, 0, 4, 5 ); | 753 | layout->addMultiCellWidget( mManagerEdit, 0, 0, 4, 5 ); |
754 | 754 | ||
755 | label = new QLabel( i18n( "Assistant's name:" ), tab2 ); | 755 | label = new QLabel( i18n( "Assistant's name:" ), tab2 ); |
756 | layout->addWidget( label, 1, 3 ); | 756 | layout->addWidget( label, 1, 3 ); |
757 | mAssistantEdit = new KLineEdit( tab2 ); | 757 | mAssistantEdit = new KLineEdit( tab2 ); |
758 | connect( mAssistantEdit, SIGNAL( textChanged( const QString& ) ), | 758 | connect( mAssistantEdit, SIGNAL( textChanged( const QString& ) ), |
759 | SLOT( textChanged( const QString& ) ) ); | 759 | SLOT( textChanged( const QString& ) ) ); |
760 | label->setBuddy( mAssistantEdit ); | 760 | label->setBuddy( mAssistantEdit ); |
761 | layout->addMultiCellWidget( mAssistantEdit, 1, 1, 4, 5 ); | 761 | layout->addMultiCellWidget( mAssistantEdit, 1, 1, 4, 5 ); |
762 | 762 | ||
763 | bar = new KSeparator( KSeparator::HLine, tab2 ); | 763 | bar = new KSeparator( KSeparator::HLine, tab2 ); |
764 | layout->addMultiCellWidget( bar, 3, 3, 0, 5 ); | 764 | layout->addMultiCellWidget( bar, 3, 3, 0, 5 ); |
765 | 765 | ||
766 | ///////////////////////////////////////////////// | 766 | ///////////////////////////////////////////////// |
767 | // Personal info | 767 | // Personal info |
768 | 768 | ||
769 | label = new QLabel( tab2 ); | 769 | label = new QLabel( tab2 ); |
770 | //US loadIcon call is ambiguous. Add one more parameter | 770 | //US loadIcon call is ambiguous. Add one more parameter |
771 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) ); | 771 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) ); |
772 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) ); | 772 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) ); |
773 | layout->addMultiCellWidget( label, 4, 5, 0, 0 ); | 773 | layout->addMultiCellWidget( label, 4, 5, 0, 0 ); |
774 | 774 | ||
775 | label = new QLabel( i18n( "Nick name:" ), tab2 ); | 775 | label = new QLabel( i18n( "Nick name:" ), tab2 ); |
776 | layout->addWidget( label, 4, 1 ); | 776 | layout->addWidget( label, 4, 1 ); |
777 | mNicknameEdit = new KLineEdit( tab2 ); | 777 | mNicknameEdit = new KLineEdit( tab2 ); |
778 | connect( mNicknameEdit, SIGNAL( textChanged( const QString& ) ), | 778 | connect( mNicknameEdit, SIGNAL( textChanged( const QString& ) ), |
779 | SLOT( textChanged( const QString& ) ) ); | 779 | SLOT( textChanged( const QString& ) ) ); |
780 | label->setBuddy( mNicknameEdit ); | 780 | label->setBuddy( mNicknameEdit ); |
781 | layout->addWidget( mNicknameEdit, 4, 2 ); | 781 | layout->addWidget( mNicknameEdit, 4, 2 ); |
782 | 782 | ||
783 | label = new QLabel( i18n( "Spouse's name:" ), tab2 ); | 783 | label = new QLabel( i18n( "Spouse's name:" ), tab2 ); |
784 | layout->addWidget( label, 5, 1 ); | 784 | layout->addWidget( label, 5, 1 ); |
785 | mSpouseEdit = new KLineEdit( tab2 ); | 785 | mSpouseEdit = new KLineEdit( tab2 ); |
786 | connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ), | 786 | connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ), |
787 | SLOT( textChanged( const QString& ) ) ); | 787 | SLOT( textChanged( const QString& ) ) ); |
788 | label->setBuddy( mSpouseEdit ); | 788 | label->setBuddy( mSpouseEdit ); |
789 | layout->addWidget( mSpouseEdit, 5, 2 ); | 789 | layout->addWidget( mSpouseEdit, 5, 2 ); |
790 | 790 | ||
791 | label = new QLabel( i18n( "Birthday:" ), tab2 ); | 791 | label = new QLabel( i18n( "Birthday:" ), tab2 ); |
792 | layout->addWidget( label, 4, 3 ); | 792 | layout->addWidget( label, 4, 3 ); |
793 | mBirthdayPicker = new KDateEdit( tab2 ); | 793 | mBirthdayPicker = new KDateEdit( tab2 ); |
794 | mBirthdayPicker->setHandleInvalid( true ); | 794 | mBirthdayPicker->setHandleInvalid( true ); |
795 | connect( mBirthdayPicker, SIGNAL( dateChanged( QDate ) ), | 795 | connect( mBirthdayPicker, SIGNAL( dateChanged( QDate ) ), |
796 | SLOT( dateChanged( QDate ) ) ); | 796 | SLOT( dateChanged( QDate ) ) ); |
797 | connect( mBirthdayPicker, SIGNAL( invalidDateEntered() ), | 797 | connect( mBirthdayPicker, SIGNAL( invalidDateEntered() ), |
798 | SLOT( invalidDate() ) ); | 798 | SLOT( invalidDate() ) ); |
799 | connect( mBirthdayPicker, SIGNAL( textChanged( const QString& ) ), | 799 | connect( mBirthdayPicker, SIGNAL( textChanged( const QString& ) ), |
800 | SLOT( emitModified() ) ); | 800 | SLOT( emitModified() ) ); |
801 | label->setBuddy( mBirthdayPicker ); | 801 | label->setBuddy( mBirthdayPicker ); |
802 | layout->addWidget( mBirthdayPicker, 4, 4 ); | 802 | layout->addWidget( mBirthdayPicker, 4, 4 ); |
803 | 803 | ||
804 | label = new QLabel( i18n( "Anniversary:" ), tab2 ); | 804 | label = new QLabel( i18n( "Anniversary:" ), tab2 ); |
805 | layout->addWidget( label, 5, 3 ); | 805 | layout->addWidget( label, 5, 3 ); |
806 | mAnniversaryPicker = new KDateEdit( tab2 ); | 806 | mAnniversaryPicker = new KDateEdit( tab2 ); |
807 | mAnniversaryPicker->setHandleInvalid( true ); | 807 | mAnniversaryPicker->setHandleInvalid( true ); |
808 | connect( mAnniversaryPicker, SIGNAL( dateChanged( QDate ) ), | 808 | connect( mAnniversaryPicker, SIGNAL( dateChanged( QDate ) ), |
809 | SLOT( dateChanged( QDate ) ) ); | 809 | SLOT( dateChanged( QDate ) ) ); |
810 | connect( mAnniversaryPicker, SIGNAL( invalidDateEntered() ), | 810 | connect( mAnniversaryPicker, SIGNAL( invalidDateEntered() ), |
811 | SLOT( invalidDate() ) ); | 811 | SLOT( invalidDate() ) ); |
812 | connect( mAnniversaryPicker, SIGNAL( textChanged( const QString& ) ), | 812 | connect( mAnniversaryPicker, SIGNAL( textChanged( const QString& ) ), |
813 | SLOT( emitModified() ) ); | 813 | SLOT( emitModified() ) ); |
814 | label->setBuddy( mAnniversaryPicker ); | 814 | label->setBuddy( mAnniversaryPicker ); |
815 | layout->addWidget( mAnniversaryPicker, 5, 4 ); | 815 | layout->addWidget( mAnniversaryPicker, 5, 4 ); |
816 | 816 | ||
817 | bar = new KSeparator( KSeparator::HLine, tab2 ); | 817 | bar = new KSeparator( KSeparator::HLine, tab2 ); |
818 | layout->addMultiCellWidget( bar, 6, 6, 0, 5 ); | 818 | layout->addMultiCellWidget( bar, 6, 6, 0, 5 ); |
819 | */ | 819 | */ |
820 | ////////////////////////////////////// | 820 | ////////////////////////////////////// |
821 | // Notes | 821 | // Notes |
822 | label = new QLabel( i18n( "Note:" ), tab2_2 ); | 822 | label = new QLabel( i18n( "Note:" ), tab2_2 ); |
823 | label->setAlignment( Qt::AlignTop | Qt::AlignLeft ); | 823 | label->setAlignment( Qt::AlignTop | Qt::AlignLeft ); |
824 | //US layout->addWidget( label, 7, 0 ); | 824 | //US layout->addWidget( label, 7, 0 ); |
825 | layout->addWidget( label, 0, 0 ); | 825 | layout->addWidget( label, 0, 0 ); |
826 | #ifndef KAB_EMBEDDED | 826 | #ifndef KAB_EMBEDDED |
827 | mNoteEdit = new QTextEdit( tab2_2 ); | 827 | mNoteEdit = new QTextEdit( tab2_2 ); |
828 | mNoteEdit->setWordWrap( QTextEdit::WidgetWidth ); | 828 | mNoteEdit->setWordWrap( QTextEdit::WidgetWidth ); |
829 | mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() ); | 829 | mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() ); |
830 | #else //KAB_EMBEDDED | 830 | #else //KAB_EMBEDDED |
831 | mNoteEdit = new QMultiLineEdit( tab2_2 ); | 831 | mNoteEdit = new QMultiLineEdit( tab2_2 ); |
832 | mNoteEdit->setWordWrap( QMultiLineEdit::WidgetWidth ); | 832 | mNoteEdit->setWordWrap( QMultiLineEdit::WidgetWidth ); |
833 | mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() ); | 833 | mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() ); |
834 | #endif //KAB_EMBEDDED | 834 | #endif //KAB_EMBEDDED |
835 | 835 | ||
836 | connect( mNoteEdit, SIGNAL( textChanged() ), SLOT( emitModified() ) ); | 836 | connect( mNoteEdit, SIGNAL( textChanged() ), SLOT( emitModified() ) ); |
837 | label->setBuddy( mNoteEdit ); | 837 | label->setBuddy( mNoteEdit ); |
838 | //US layout->addMultiCellWidget( mNoteEdit, 7, 7, 1, 5 ); | 838 | //US layout->addMultiCellWidget( mNoteEdit, 7, 7, 1, 5 ); |
839 | layout->addWidget( mNoteEdit, 1, 0); | 839 | layout->addWidget( mNoteEdit, 1, 0); |
840 | 840 | ||
841 | // Build the layout and add to the tab widget | 841 | // Build the layout and add to the tab widget |
842 | layout->activate(); // required | 842 | layout->activate(); // required |
843 | 843 | ||
844 | mTabWidget->addTab( tab2_2, i18n( "&Notes" ) ); | 844 | mTabWidget->addTab( tab2_2, i18n( "&Notes" ) ); |
845 | } | 845 | } |
846 | 846 | ||
847 | 847 | ||
848 | 848 | ||
849 | void AddresseeEditorWidget::setupTab3() | 849 | void AddresseeEditorWidget::setupTab3() |
850 | { | 850 | { |
851 | // This is the Misc tab | 851 | // This is the Misc tab |
852 | QWidget *tab3 = new QWidget( mTabWidget ); | 852 | QWidget *tab3 = new QWidget( mTabWidget ); |
853 | 853 | ||
854 | QGridLayout *layout = new QGridLayout( tab3, 1, 1 ); | 854 | QGridLayout *layout = new QGridLayout( tab3, 1, 1 ); |
855 | layout->setMargin( KDialogBase::marginHintSmall() ); | 855 | layout->setMargin( KDialogBase::marginHintSmall() ); |
856 | layout->setSpacing( KDialogBase::spacingHintSmall() ); | 856 | layout->setSpacing( KDialogBase::spacingHintSmall() ); |
857 | //US layout->setColStretch( 2, 1 ); | 857 | //US layout->setColStretch( 2, 1 ); |
858 | 858 | ||
859 | ////////////////////////////////////// | 859 | ////////////////////////////////////// |
860 | // Geo | 860 | // Geo |
861 | mGeoWidget = new GeoWidget( tab3 ); | 861 | mGeoWidget = new GeoWidget( tab3 ); |
862 | // mGeoWidget->setMinimumSize( mGeoWidget->sizeHint() ); | 862 | // mGeoWidget->setMinimumSize( mGeoWidget->sizeHint() ); |
863 | connect( mGeoWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); | 863 | connect( mGeoWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); |
864 | layout->addWidget( mGeoWidget, 0, 0 ); | 864 | layout->addWidget( mGeoWidget, 0, 0 ); |
865 | /*US | 865 | /*US |
866 | ////////////////////////////////////// | 866 | ////////////////////////////////////// |
867 | // Sound | 867 | // Sound |
868 | #ifndef KAB_EMBEDDED | 868 | #ifndef KAB_EMBEDDED |
869 | mSoundWidget = new SoundWidget( tab3 ); | 869 | mSoundWidget = new SoundWidget( tab3 ); |
870 | mSoundWidget->setMinimumSize( mSoundWidget->sizeHint() ); | 870 | mSoundWidget->setMinimumSize( mSoundWidget->sizeHint() ); |
871 | connect( mSoundWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); | 871 | connect( mSoundWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); |
872 | layout->addWidget( mSoundWidget, 0, 1, Qt::AlignTop ); | 872 | layout->addWidget( mSoundWidget, 0, 1, Qt::AlignTop ); |
873 | #else //KAB_EMBEDDED | 873 | #else //KAB_EMBEDDED |
874 | qDebug("AddresseeEditorWidget::setupTab2 sound part is not supported = has to be changed"); | 874 | qDebug("AddresseeEditorWidget::setupTab2 sound part is not supported = has to be changed"); |
875 | #endif //KAB_EMBEDDED | 875 | #endif //KAB_EMBEDDED |
876 | 876 | ||
877 | ////////////////////////////////////// | 877 | ////////////////////////////////////// |
878 | // Images | 878 | // Images |
879 | mImageWidget = new ImageWidget( tab3 ); | 879 | mImageWidget = new ImageWidget( tab3 ); |
880 | mImageWidget->setMinimumSize( mImageWidget->sizeHint() ); | 880 | mImageWidget->setMinimumSize( mImageWidget->sizeHint() ); |
881 | connect( mImageWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); | 881 | connect( mImageWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); |
882 | layout->addWidget( mImageWidget, 1, 0, Qt::AlignTop ); | 882 | layout->addWidget( mImageWidget, 1, 0, Qt::AlignTop ); |
883 | */ | 883 | */ |
884 | //US | 884 | //US |
885 | /* | 885 | /* |
886 | KSeparator* bar = new KSeparator( KSeparator::HLine, tab3 ); | 886 | KSeparator* bar = new KSeparator( KSeparator::HLine, tab3 ); |
887 | layout->addMultiCellWidget( bar, 1, 1, 0, 0 ); | 887 | layout->addMultiCellWidget( bar, 1, 1, 0, 0 ); |
888 | */ | 888 | */ |
889 | ////////////////////////////////////// | 889 | ////////////////////////////////////// |
890 | // Keys | 890 | // Keys |
891 | mKeyWidget = new KeyWidget( tab3 ); | 891 | mKeyWidget = new KeyWidget( tab3 ); |
892 | //mKeyWidget->setMinimumSize( mKeyWidget->sizeHint() ); | 892 | //mKeyWidget->setMinimumSize( mKeyWidget->sizeHint() ); |
893 | connect( mKeyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); | 893 | connect( mKeyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); |
894 | //US layout->addWidget( mKeyWidget, 1, 1, Qt::AlignTop ); | 894 | //US layout->addWidget( mKeyWidget, 1, 1, Qt::AlignTop ); |
895 | layout->addWidget( mKeyWidget, 1, 0 ); | 895 | layout->addWidget( mKeyWidget, 1, 0 ); |
896 | 896 | ||
897 | mTabWidget->addTab( tab3, i18n( "&Misc" ) ); | 897 | mTabWidget->addTab( tab3, i18n( "&Misc" ) ); |
898 | } | 898 | } |
899 | 899 | ||
900 | void AddresseeEditorWidget::setupTab3_1() | 900 | void AddresseeEditorWidget::setupTab3_1() |
901 | { | 901 | { |
902 | // This is the Misc tab | 902 | // This is the Misc tab |
903 | QWidget *tab3 = new QWidget( mTabWidget ); | 903 | QWidget *tab3 = new QWidget( mTabWidget ); |
904 | 904 | ||
905 | //US QGridLayout *layout = new QGridLayout( tab3, 2, 3 ); | 905 | //US QGridLayout *layout = new QGridLayout( tab3, 2, 3 ); |
906 | QGridLayout *layout = new QGridLayout( tab3, 1, 1 ); | 906 | QGridLayout *layout = new QGridLayout( tab3, 1, 1 ); |
907 | layout->setMargin( KDialogBase::marginHint() ); | 907 | layout->setMargin( KDialogBase::marginHint() ); |
908 | layout->setSpacing( KDialogBase::spacingHint() ); | 908 | layout->setSpacing( KDialogBase::spacingHint() ); |
909 | //US layout->setColStretch( 2, 1 ); | 909 | //US layout->setColStretch( 2, 1 ); |
910 | 910 | ||
911 | /*US | 911 | /*US |
912 | ////////////////////////////////////// | 912 | ////////////////////////////////////// |
913 | // Geo | 913 | // Geo |
914 | mGeoWidget = new GeoWidget( tab3 ); | 914 | mGeoWidget = new GeoWidget( tab3 ); |
915 | mGeoWidget->setMinimumSize( mGeoWidget->sizeHint() ); | 915 | mGeoWidget->setMinimumSize( mGeoWidget->sizeHint() ); |
916 | connect( mGeoWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); | 916 | connect( mGeoWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); |
917 | layout->addWidget( mGeoWidget, 0, 0, Qt::AlignTop ); | 917 | layout->addWidget( mGeoWidget, 0, 0, Qt::AlignTop ); |
918 | */ | 918 | */ |
919 | ////////////////////////////////////// | 919 | ////////////////////////////////////// |
920 | // Sound | 920 | // Sound |
921 | #ifndef KAB_EMBEDDED | 921 | #ifndef KAB_EMBEDDED |
922 | mSoundWidget = new SoundWidget( tab3 ); | 922 | mSoundWidget = new SoundWidget( tab3 ); |
923 | mSoundWidget->setMinimumSize( mSoundWidget->sizeHint() ); | 923 | mSoundWidget->setMinimumSize( mSoundWidget->sizeHint() ); |
924 | connect( mSoundWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); | 924 | connect( mSoundWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); |
925 | layout->addWidget( mSoundWidget, 0, 1, Qt::AlignTop ); | 925 | layout->addWidget( mSoundWidget, 0, 1, Qt::AlignTop ); |
926 | #else //KAB_EMBEDDED | 926 | #else //KAB_EMBEDDED |
927 | //US qDebug("AddresseeEditorWidget::setupTab2 sound part is not supported = has to be changed"); | 927 | //US qDebug("AddresseeEditorWidget::setupTab2 sound part is not supported = has to be changed"); |
928 | #endif //KAB_EMBEDDED | 928 | #endif //KAB_EMBEDDED |
929 | 929 | ||
930 | ////////////////////////////////////// | 930 | ////////////////////////////////////// |
931 | // Images | 931 | // Images |
932 | mImageWidget = new ImageWidget( tab3 ); | 932 | mImageWidget = new ImageWidget( tab3 ); |
933 | mImageWidget->setMinimumSize( mImageWidget->sizeHint() ); | 933 | mImageWidget->setMinimumSize( mImageWidget->sizeHint() ); |
934 | connect( mImageWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); | 934 | connect( mImageWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); |
935 | layout->addWidget( mImageWidget, 0, 0, Qt::AlignTop ); | 935 | layout->addWidget( mImageWidget, 0, 0, Qt::AlignTop ); |
936 | /*US | 936 | /*US |
937 | ////////////////////////////////////// | 937 | ////////////////////////////////////// |
938 | // Keys | 938 | // Keys |
939 | mKeyWidget = new KeyWidget( tab3 ); | 939 | mKeyWidget = new KeyWidget( tab3 ); |
940 | mKeyWidget->setMinimumSize( mKeyWidget->sizeHint() ); | 940 | mKeyWidget->setMinimumSize( mKeyWidget->sizeHint() ); |
941 | connect( mKeyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); | 941 | connect( mKeyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); |
942 | layout->addWidget( mKeyWidget, 1, 1, Qt::AlignTop ); | 942 | layout->addWidget( mKeyWidget, 1, 1, Qt::AlignTop ); |
943 | */ | 943 | */ |
944 | mTabWidget->addTab( tab3, i18n( "&Images" ) ); | 944 | mTabWidget->addTab( tab3, i18n( "&Images" ) ); |
945 | } | 945 | } |
946 | 946 | ||
947 | 947 | ||
948 | void AddresseeEditorWidget::load() | 948 | void AddresseeEditorWidget::load() |
949 | { | 949 | { |
950 | kdDebug(5720) << "AddresseeEditorWidget::load()" << endl; | ||
951 | 950 | ||
952 | // Block signals in case anything tries to emit modified | 951 | // Block signals in case anything tries to emit modified |
953 | // CS: This doesn't seem to work. | 952 | // CS: This doesn't seem to work. |
954 | bool block = signalsBlocked(); | 953 | bool block = signalsBlocked(); |
955 | blockSignals( true ); | 954 | blockSignals( true ); |
956 | mBlockSignals = true; // used for internal signal blocking | 955 | mBlockSignals = true; // used for internal signal blocking |
957 | 956 | ||
958 | mNameEdit->setText( mAddressee.assembledName() ); | 957 | mNameEdit->setText( mAddressee.assembledName() ); |
959 | 958 | ||
960 | if ( mAddressee.formattedName().isEmpty() ) { | 959 | if ( mAddressee.formattedName().isEmpty() ) { |
961 | //US KConfig config( "kaddressbookrc" ); | 960 | //US KConfig config( "kaddressbookrc" ); |
962 | KConfig config( locateLocal("config", "kaddressbookrc") ); | 961 | KConfig config( locateLocal("config", "kaddressbookrc") ); |
963 | config.setGroup( "General" ); | 962 | config.setGroup( "General" ); |
964 | mFormattedNameType = config.readNumEntry( "FormattedNameType", 1 ); | 963 | mFormattedNameType = config.readNumEntry( "FormattedNameType", 1 ); |
965 | mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); | 964 | mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); |
966 | } else { | 965 | } else { |
967 | if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::SimpleName ) ) | 966 | if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::SimpleName ) ) |
968 | mFormattedNameType = NameEditDialog::SimpleName; | 967 | mFormattedNameType = NameEditDialog::SimpleName; |
969 | else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::FullName ) ) | 968 | else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::FullName ) ) |
970 | mFormattedNameType = NameEditDialog::FullName; | 969 | mFormattedNameType = NameEditDialog::FullName; |
971 | else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::ReverseName ) ) | 970 | else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::ReverseName ) ) |
972 | mFormattedNameType = NameEditDialog::ReverseName; | 971 | mFormattedNameType = NameEditDialog::ReverseName; |
973 | else | 972 | else |
974 | mFormattedNameType = NameEditDialog::CustomName; | 973 | mFormattedNameType = NameEditDialog::CustomName; |
975 | } | 974 | } |
976 | 975 | ||
977 | mFormattedNameLabel->setText( mAddressee.formattedName() ); | 976 | mFormattedNameLabel->setText( mAddressee.formattedName() ); |
978 | 977 | ||
979 | mRoleEdit->setText( mAddressee.role() ); | 978 | mRoleEdit->setText( mAddressee.role() ); |
980 | mOrgEdit->setText( mAddressee.organization() ); | 979 | mOrgEdit->setText( mAddressee.organization() ); |
981 | 980 | ||
982 | //US mURLEdit->setURL( mAddressee.url().url() ); | 981 | //US mURLEdit->setURL( mAddressee.url().url() ); |
983 | mURLEdit->setText( mAddressee.url().prettyURL() ); | 982 | mURLEdit->setText( mAddressee.url().prettyURL() ); |
984 | //US?? mURLEdit->home( false ); | 983 | //US?? mURLEdit->home( false ); |
985 | 984 | ||
986 | // mNoteEdit->setText( mAddressee.note() ); | 985 | // mNoteEdit->setText( mAddressee.note() ); |
987 | mNoteEdit->setText( mAddressee.note() ); | 986 | mNoteEdit->setText( mAddressee.note() ); |
988 | mEmailWidget->setEmails( mAddressee.emails() ); | 987 | mEmailWidget->setEmails( mAddressee.emails() ); |
989 | mPhoneEditWidget->setPhoneNumbers( mAddressee.phoneNumbers() ); | 988 | mPhoneEditWidget->setPhoneNumbers( mAddressee.phoneNumbers() ); |
990 | mAddressEditWidget->setAddresses( mAddressee, mAddressee.addresses() ); | 989 | mAddressEditWidget->setAddresses( mAddressee, mAddressee.addresses() ); |
991 | mBirthdayPicker->setDate( mAddressee.birthday().date() ); | 990 | mBirthdayPicker->setDate( mAddressee.birthday().date() ); |
992 | 991 | ||
993 | //US mAnniversaryPicker->setDate( QDate::fromString( mAddressee.custom( | 992 | //US mAnniversaryPicker->setDate( QDate::fromString( mAddressee.custom( |
994 | //US "KADDRESSBOOK", "X-Anniversary" ), Qt::ISODate) ); | 993 | //US "KADDRESSBOOK", "X-Anniversary" ), Qt::ISODate) ); |
995 | QDate dt = KGlobal::locale()->readDate( mAddressee.custom("KADDRESSBOOK", "X-Anniversary" ), | 994 | QDate dt = KGlobal::locale()->readDate( mAddressee.custom("KADDRESSBOOK", "X-Anniversary" ), |
996 | "%Y-%m-%d"); // = Qt::ISODate | 995 | "%Y-%m-%d"); // = Qt::ISODate |
997 | mAnniversaryPicker->setDate( dt ); | 996 | mAnniversaryPicker->setDate( dt ); |
998 | 997 | ||
999 | 998 | ||
1000 | mNicknameEdit->setText( mAddressee.nickName() ); | 999 | mNicknameEdit->setText( mAddressee.nickName() ); |
1001 | mCategoryEdit->setText( mAddressee.categories().join( "," ) ); | 1000 | mCategoryEdit->setText( mAddressee.categories().join( "," ) ); |
1002 | 1001 | ||
1003 | mGeoWidget->setGeo( mAddressee.geo() ); | 1002 | mGeoWidget->setGeo( mAddressee.geo() ); |
1004 | mImageWidget->setPhoto( mAddressee.photo() ); | 1003 | mImageWidget->setPhoto( mAddressee.photo() ); |
1005 | mImageWidget->setLogo( mAddressee.logo() ); | 1004 | mImageWidget->setLogo( mAddressee.logo() ); |
1006 | mKeyWidget->setKeys( mAddressee.keys() ); | 1005 | mKeyWidget->setKeys( mAddressee.keys() ); |
1007 | mSecrecyWidget->setSecrecy( mAddressee.secrecy() ); | 1006 | mSecrecyWidget->setSecrecy( mAddressee.secrecy() ); |
1008 | #ifndef KAB_EMBEDDED | 1007 | #ifndef KAB_EMBEDDED |
1009 | mSoundWidget->setSound( mAddressee.sound() ); | 1008 | mSoundWidget->setSound( mAddressee.sound() ); |
1010 | #else //KAB_EMBEDDED | 1009 | #else //KAB_EMBEDDED |
1011 | //US qDebug("AddresseeEditorWidget::load has to be changed 2"); | 1010 | //US qDebug("AddresseeEditorWidget::load has to be changed 2"); |
1012 | #endif //KAB_EMBEDDED | 1011 | #endif //KAB_EMBEDDED |
1013 | 1012 | ||
1014 | // Load customs | 1013 | // Load customs |
1015 | mIMAddressEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-IMAddress" ) ); | 1014 | mIMAddressEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-IMAddress" ) ); |
1016 | mSpouseEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ) ); | 1015 | mSpouseEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ) ); |
1017 | mManagerEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-ManagersName" ) ); | 1016 | mManagerEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-ManagersName" ) ); |
1018 | mAssistantEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-AssistantsName" ) ); | 1017 | mAssistantEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-AssistantsName" ) ); |
1019 | mDepartmentEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Department" ) ); | 1018 | mDepartmentEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Department" ) ); |
1020 | mOfficeEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Office" ) ); | 1019 | mOfficeEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Office" ) ); |
1021 | mProfessionEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Profession" ) ); | 1020 | mProfessionEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Profession" ) ); |
1022 | 1021 | ||
1023 | blockSignals( block ); | 1022 | blockSignals( block ); |
1024 | mBlockSignals = false; | 1023 | mBlockSignals = false; |
1025 | 1024 | ||
1026 | mDirty = false; | 1025 | mDirty = false; |
1027 | } | 1026 | } |
1028 | 1027 | ||
1029 | void AddresseeEditorWidget::save() | 1028 | void AddresseeEditorWidget::save() |
1030 | { | 1029 | { |
1031 | if ( !mDirty ) return; | 1030 | if ( !dirty() ) { |
1031 | return; | ||
1032 | } | ||
1032 | 1033 | ||
1033 | mAddressee.setRole( mRoleEdit->text() ); | 1034 | mAddressee.setRole( mRoleEdit->text() ); |
1034 | mAddressee.setOrganization( mOrgEdit->text() ); | 1035 | mAddressee.setOrganization( mOrgEdit->text() ); |
1035 | mAddressee.setUrl( KURL( mURLEdit->text() ) ); | 1036 | mAddressee.setUrl( KURL( mURLEdit->text() ) ); |
1036 | mAddressee.setNote( mNoteEdit->text() ); | 1037 | mAddressee.setNote( mNoteEdit->text() ); |
1037 | if ( mBirthdayPicker->inputIsValid() ) | 1038 | if ( mBirthdayPicker->inputIsValid() ) { |
1038 | mAddressee.setBirthday( QDateTime( mBirthdayPicker->date() ) ); | 1039 | QDate da = mBirthdayPicker->date(); |
1039 | else | 1040 | if ( da > QDate::currentDate() ) |
1041 | da.setYMD(da.year()-100, da.month(), da.day() ); | ||
1042 | mAddressee.setBirthday( QDateTime( da ) ); | ||
1043 | qDebug("bday %s ",da.toString().latin1()); | ||
1044 | } | ||
1045 | else { | ||
1040 | mAddressee.setBirthday( QDateTime() ); | 1046 | mAddressee.setBirthday( QDateTime() ); |
1041 | 1047 | mBirthdayPicker->clear(); | |
1048 | } | ||
1042 | mAddressee.setNickName( mNicknameEdit->text() ); | 1049 | mAddressee.setNickName( mNicknameEdit->text() ); |
1043 | mAddressee.setCategories( QStringList::split( ",", mCategoryEdit->text() ) ); | 1050 | mAddressee.setCategories( QStringList::split( ",", mCategoryEdit->text() ) ); |
1044 | 1051 | ||
1045 | mAddressee.setGeo( mGeoWidget->geo() ); | 1052 | mAddressee.setGeo( mGeoWidget->geo() ); |
1046 | mAddressee.setPhoto( mImageWidget->photo() ); | 1053 | mAddressee.setPhoto( mImageWidget->photo() ); |
1047 | mAddressee.setLogo( mImageWidget->logo() ); | 1054 | mAddressee.setLogo( mImageWidget->logo() ); |
1048 | mAddressee.setKeys( mKeyWidget->keys() ); | 1055 | mAddressee.setKeys( mKeyWidget->keys() ); |
1049 | #ifndef KAB_EMBEDDED | 1056 | #ifndef KAB_EMBEDDED |
1050 | mAddressee.setSound( mSoundWidget->sound() ); | 1057 | mAddressee.setSound( mSoundWidget->sound() ); |
1051 | #else //KAB_EMBEDDED | 1058 | #else //KAB_EMBEDDED |
1052 | //US qDebug("AddresseeEditorWidget::save sound not supported"); | 1059 | //US qDebug("AddresseeEditorWidget::save sound not supported"); |
1053 | #endif //KAB_EMBEDDED | 1060 | #endif //KAB_EMBEDDED |
1054 | mAddressee.setSecrecy( mSecrecyWidget->secrecy() ); | 1061 | mAddressee.setSecrecy( mSecrecyWidget->secrecy() ); |
1055 | 1062 | ||
1056 | // save custom fields | 1063 | // save custom fields |
1057 | mAddressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", mIMAddressEdit->text() ); | 1064 | mAddressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", mIMAddressEdit->text() ); |
1058 | mAddressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", mSpouseEdit->text() ); | 1065 | mAddressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", mSpouseEdit->text() ); |
1059 | mAddressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", mManagerEdit->text() ); | 1066 | mAddressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", mManagerEdit->text() ); |
1060 | mAddressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", mAssistantEdit->text() ); | 1067 | mAddressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", mAssistantEdit->text() ); |
1061 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Department", mDepartmentEdit->text() ); | 1068 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Department", mDepartmentEdit->text() ); |
1062 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Office", mOfficeEdit->text() ); | 1069 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Office", mOfficeEdit->text() ); |
1063 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Profession", mProfessionEdit->text() ); | 1070 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Profession", mProfessionEdit->text() ); |
1064 | if ( mAnniversaryPicker->inputIsValid() ) { | 1071 | if ( mAnniversaryPicker->inputIsValid() ) { |
1065 | |||
1066 | //US mAddressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", | ||
1067 | //US mAnniversaryPicker->date().toString( Qt::ISODate ) ); | ||
1068 | QString dt = KGlobal::locale()->formatDate(mAnniversaryPicker->date(), true, KLocale::ISODate); | 1072 | QString dt = KGlobal::locale()->formatDate(mAnniversaryPicker->date(), true, KLocale::ISODate); |
1069 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); | 1073 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); |
1070 | } | 1074 | } |
1071 | else | 1075 | else { |
1072 | mAddressee.removeCustom( "KADDRESSBOOK", "X-Anniversary" ); | 1076 | mAddressee.removeCustom( "KADDRESSBOOK", "X-Anniversary" ); |
1077 | mAnniversaryPicker->clear(); | ||
1078 | } | ||
1073 | 1079 | ||
1074 | // Save the email addresses | 1080 | // Save the email addresses |
1075 | QStringList emails = mAddressee.emails(); | 1081 | QStringList emails = mAddressee.emails(); |
1076 | QStringList::Iterator iter; | 1082 | QStringList::Iterator iter; |
1077 | for ( iter = emails.begin(); iter != emails.end(); ++iter ) | 1083 | for ( iter = emails.begin(); iter != emails.end(); ++iter ) |
1078 | mAddressee.removeEmail( *iter ); | 1084 | mAddressee.removeEmail( *iter ); |
1079 | 1085 | ||
1080 | emails = mEmailWidget->emails(); | 1086 | emails = mEmailWidget->emails(); |
1081 | bool first = true; | 1087 | bool first = true; |
1082 | for ( iter = emails.begin(); iter != emails.end(); ++iter ) { | 1088 | for ( iter = emails.begin(); iter != emails.end(); ++iter ) { |
1083 | mAddressee.insertEmail( *iter, first ); | 1089 | mAddressee.insertEmail( *iter, first ); |
1084 | first = false; | 1090 | first = false; |
1085 | } | 1091 | } |
1086 | 1092 | ||
1087 | // Save the phone numbers | 1093 | // Save the phone numbers |
1088 | KABC::PhoneNumber::List phoneNumbers; | 1094 | KABC::PhoneNumber::List phoneNumbers; |
1089 | KABC::PhoneNumber::List::Iterator phoneIter; | 1095 | KABC::PhoneNumber::List::Iterator phoneIter; |
1090 | phoneNumbers = mAddressee.phoneNumbers(); | 1096 | phoneNumbers = mAddressee.phoneNumbers(); |
1091 | for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end(); | 1097 | for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end(); |
1092 | ++phoneIter ) | 1098 | ++phoneIter ) |
1093 | mAddressee.removePhoneNumber( *phoneIter ); | 1099 | mAddressee.removePhoneNumber( *phoneIter ); |
1094 | 1100 | ||
1095 | phoneNumbers = mPhoneEditWidget->phoneNumbers(); | 1101 | phoneNumbers = mPhoneEditWidget->phoneNumbers(); |
1096 | for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end(); | 1102 | for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end(); |
1097 | ++phoneIter ) | 1103 | ++phoneIter ) |
1098 | mAddressee.insertPhoneNumber( *phoneIter ); | 1104 | mAddressee.insertPhoneNumber( *phoneIter ); |
1099 | 1105 | ||
1100 | // Save the addresses | 1106 | // Save the addresses |
1101 | KABC::Address::List addresses; | 1107 | KABC::Address::List addresses; |
1102 | KABC::Address::List::Iterator addressIter; | 1108 | KABC::Address::List::Iterator addressIter; |
1103 | addresses = mAddressee.addresses(); | 1109 | addresses = mAddressee.addresses(); |
1104 | for ( addressIter = addresses.begin(); addressIter != addresses.end(); | 1110 | for ( addressIter = addresses.begin(); addressIter != addresses.end(); |
1105 | ++addressIter ) | 1111 | ++addressIter ) |
1106 | mAddressee.removeAddress( *addressIter ); | 1112 | mAddressee.removeAddress( *addressIter ); |
1107 | 1113 | ||
1108 | addresses = mAddressEditWidget->addresses(); | 1114 | addresses = mAddressEditWidget->addresses(); |
1109 | for ( addressIter = addresses.begin(); addressIter != addresses.end(); | 1115 | for ( addressIter = addresses.begin(); addressIter != addresses.end(); |
1110 | ++addressIter ) | 1116 | ++addressIter ) |
1111 | mAddressee.insertAddress( *addressIter ); | 1117 | mAddressee.insertAddress( *addressIter ); |
1112 | mDirty = false; | 1118 | mDirty = false; |
1113 | } | 1119 | } |
1114 | 1120 | ||
1115 | bool AddresseeEditorWidget::dirty() | 1121 | bool AddresseeEditorWidget::dirty() |
1116 | { | 1122 | { |
1123 | |||
1124 | if ( ! mDirty ) { | ||
1125 | if ( mBirthdayPicker->inputIsValid() ) { | ||
1126 | QDate da = mBirthdayPicker->date(); | ||
1127 | if ( !(da == mAddressee.birthday().date())) | ||
1128 | mDirty = true; | ||
1129 | } | ||
1130 | else { | ||
1131 | mBirthdayPicker->clear(); | ||
1132 | } | ||
1133 | if ( mAnniversaryPicker->inputIsValid() ) { | ||
1134 | QDate da = mAnniversaryPicker->date(); | ||
1135 | if ( da != KGlobal::locale()->readDate( mAddressee.custom("KADDRESSBOOK", "X-Anniversary" ), | ||
1136 | "%Y-%m-%d")) | ||
1137 | mDirty = true; | ||
1138 | } | ||
1139 | else { | ||
1140 | mAnniversaryPicker->clear(); | ||
1141 | } | ||
1142 | } | ||
1117 | return mDirty; | 1143 | return mDirty; |
1118 | } | 1144 | } |
1119 | 1145 | ||
1120 | void AddresseeEditorWidget::nameTextChanged( const QString &text ) | 1146 | void AddresseeEditorWidget::nameTextChanged( const QString &text ) |
1121 | { | 1147 | { |
1122 | // use the addressee class to parse the name for us | 1148 | // use the addressee class to parse the name for us |
1123 | mAConfig->setUid( mAddressee.uid() ); | 1149 | mAConfig->setUid( mAddressee.uid() ); |
1124 | if ( mAConfig->automaticNameParsing() ) { | 1150 | if ( mAConfig->automaticNameParsing() ) { |
1125 | if ( !mAddressee.formattedName().isEmpty() ) { | 1151 | if ( !mAddressee.formattedName().isEmpty() ) { |
1126 | QString fn = mAddressee.formattedName(); | 1152 | QString fn = mAddressee.formattedName(); |
1127 | mAddressee.setNameFromString( text ); | 1153 | mAddressee.setNameFromString( text ); |
1128 | mAddressee.setFormattedName( fn ); | 1154 | mAddressee.setFormattedName( fn ); |
1129 | } else { | 1155 | } else { |
1130 | // use extra addressee to avoid a formatted name assignment | 1156 | // use extra addressee to avoid a formatted name assignment |
1131 | Addressee addr; | 1157 | Addressee addr; |
1132 | addr.setNameFromString( text ); | 1158 | addr.setNameFromString( text ); |
1133 | mAddressee.setPrefix( addr.prefix() ); | 1159 | mAddressee.setPrefix( addr.prefix() ); |
1134 | mAddressee.setGivenName( addr.givenName() ); | 1160 | mAddressee.setGivenName( addr.givenName() ); |
1135 | mAddressee.setAdditionalName( addr.additionalName() ); | 1161 | mAddressee.setAdditionalName( addr.additionalName() ); |
1136 | mAddressee.setFamilyName( addr.familyName() ); | 1162 | mAddressee.setFamilyName( addr.familyName() ); |
1137 | mAddressee.setSuffix( addr.suffix() ); | 1163 | mAddressee.setSuffix( addr.suffix() ); |
1138 | } | 1164 | } |
1139 | } | 1165 | } |
1140 | 1166 | ||
1141 | nameBoxChanged(); | 1167 | nameBoxChanged(); |
1142 | 1168 | ||
1143 | emitModified(); | 1169 | emitModified(); |
1144 | } | 1170 | } |
1145 | 1171 | ||
1146 | void AddresseeEditorWidget::nameBoxChanged() | 1172 | void AddresseeEditorWidget::nameBoxChanged() |
1147 | { | 1173 | { |
1148 | KABC::Addressee addr; | 1174 | KABC::Addressee addr; |
1149 | mAConfig->setUid( mAddressee.uid() ); | 1175 | mAConfig->setUid( mAddressee.uid() ); |
1150 | if ( mAConfig->automaticNameParsing() ) { | 1176 | if ( mAConfig->automaticNameParsing() ) { |
1151 | addr.setNameFromString( mNameEdit->text() ); | 1177 | addr.setNameFromString( mNameEdit->text() ); |
1152 | mNameLabel->hide(); | 1178 | mNameLabel->hide(); |
1153 | mNameEdit->show(); | 1179 | mNameEdit->show(); |
1154 | } else { | 1180 | } else { |
1155 | addr = mAddressee; | 1181 | addr = mAddressee; |
1156 | mNameEdit->hide(); | 1182 | mNameEdit->hide(); |
1157 | mNameLabel->setText( mNameEdit->text() ); | 1183 | mNameLabel->setText( mNameEdit->text() ); |
1158 | mNameLabel->show(); | 1184 | mNameLabel->show(); |
1159 | } | 1185 | } |
1160 | 1186 | ||
1161 | if ( mFormattedNameType != NameEditDialog::CustomName ) { | 1187 | if ( mFormattedNameType != NameEditDialog::CustomName ) { |
1162 | mFormattedNameLabel->setText( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); | 1188 | mFormattedNameLabel->setText( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); |
1163 | mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); | 1189 | mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); |
1164 | } | 1190 | } |
1165 | } | 1191 | } |
1166 | 1192 | ||
1167 | void AddresseeEditorWidget::nameButtonClicked() | 1193 | void AddresseeEditorWidget::nameButtonClicked() |
1168 | { | 1194 | { |
1169 | // show the name dialog. | 1195 | // show the name dialog. |
1170 | NameEditDialog dialog( mAddressee, mFormattedNameType, this ); | 1196 | NameEditDialog dialog( mAddressee, mFormattedNameType, this ); |
1171 | 1197 | ||
1172 | if ( dialog.exec() ) { | 1198 | if ( KApplication::execDialog( &dialog) ) { |
1173 | if ( dialog.changed() ) { | 1199 | if ( dialog.changed() ) { |
1174 | mAddressee.setFamilyName( dialog.familyName() ); | 1200 | mAddressee.setFamilyName( dialog.familyName() ); |
1175 | mAddressee.setGivenName( dialog.givenName() ); | 1201 | mAddressee.setGivenName( dialog.givenName() ); |
1176 | mAddressee.setPrefix( dialog.prefix() ); | 1202 | mAddressee.setPrefix( dialog.prefix() ); |
1177 | mAddressee.setSuffix( dialog.suffix() ); | 1203 | mAddressee.setSuffix( dialog.suffix() ); |
1178 | mAddressee.setAdditionalName( dialog.additionalName() ); | 1204 | mAddressee.setAdditionalName( dialog.additionalName() ); |
1179 | mFormattedNameType = dialog.formattedNameType(); | 1205 | mFormattedNameType = dialog.formattedNameType(); |
1180 | if ( mFormattedNameType == NameEditDialog::CustomName ) { | 1206 | if ( mFormattedNameType == NameEditDialog::CustomName ) { |
1181 | mFormattedNameLabel->setText( dialog.customFormattedName() ); | 1207 | mFormattedNameLabel->setText( dialog.customFormattedName() ); |
1182 | mAddressee.setFormattedName( dialog.customFormattedName() ); | 1208 | mAddressee.setFormattedName( dialog.customFormattedName() ); |
1183 | } | 1209 | } |
1184 | // Update the name edit. | 1210 | // Update the name edit. |
1185 | bool block = mNameEdit->signalsBlocked(); | 1211 | bool block = mNameEdit->signalsBlocked(); |
1186 | mNameEdit->blockSignals( true ); | 1212 | mNameEdit->blockSignals( true ); |
1187 | mNameEdit->setText( mAddressee.assembledName() ); | 1213 | mNameEdit->setText( mAddressee.assembledName() ); |
1188 | mNameEdit->blockSignals( block ); | 1214 | mNameEdit->blockSignals( block ); |
1189 | 1215 | ||
1190 | // Update the combo box. | 1216 | // Update the combo box. |
1191 | nameBoxChanged(); | 1217 | nameBoxChanged(); |
1192 | 1218 | ||
1193 | emitModified(); | 1219 | emitModified(); |
1194 | } | 1220 | } |
1195 | } | 1221 | } |
1196 | } | 1222 | } |
1197 | 1223 | ||
1198 | void AddresseeEditorWidget::categoryButtonClicked() | 1224 | void AddresseeEditorWidget::categoryButtonClicked() |
1199 | { | 1225 | { |
1200 | // Show the category dialog | 1226 | // Show the category dialog |
1201 | if ( mCategoryDialog == 0 ) { | 1227 | if ( mCategoryDialog == 0 ) { |
1202 | mCategoryDialog = new KPIM::CategorySelectDialog( KABPrefs::instance(), this ); | 1228 | mCategoryDialog = new KPIM::CategorySelectDialog( KABPrefs::instance(), this ); |
1203 | connect( mCategoryDialog, SIGNAL( categoriesSelected( const QStringList& ) ), | 1229 | connect( mCategoryDialog, SIGNAL( categoriesSelected( const QStringList& ) ), |
1204 | SLOT(categoriesSelected( const QStringList& ) ) ); | 1230 | SLOT(categoriesSelected( const QStringList& ) ) ); |
1205 | connect( mCategoryDialog, SIGNAL( editCategories() ), SLOT( editCategories() ) ); | 1231 | connect( mCategoryDialog, SIGNAL( editCategories() ), SLOT( editCategories() ) ); |
1206 | } | 1232 | } |
1207 | 1233 | ||
1208 | mCategoryDialog->setCategories(); | 1234 | mCategoryDialog->setCategories(); |
1209 | mCategoryDialog->setSelected( QStringList::split( ",", mCategoryEdit->text() ) ); | 1235 | mCategoryDialog->setSelected( QStringList::split( ",", mCategoryEdit->text() ) ); |
1210 | mCategoryDialog->show(); | 1236 | mCategoryDialog->show(); |
1211 | mCategoryDialog->raise(); | 1237 | mCategoryDialog->raise(); |
1212 | } | 1238 | } |
1213 | 1239 | ||
1214 | void AddresseeEditorWidget::categoriesSelected( const QStringList &list ) | 1240 | void AddresseeEditorWidget::categoriesSelected( const QStringList &list ) |
1215 | { | 1241 | { |
1216 | mCategoryEdit->setText( list.join( "," ) ); | 1242 | mCategoryEdit->setText( list.join( "," ) ); |
1217 | } | 1243 | } |
1218 | 1244 | ||
1219 | void AddresseeEditorWidget::editCategories() | 1245 | void AddresseeEditorWidget::editCategories() |
1220 | { | 1246 | { |
1221 | if ( mCategoryEditDialog == 0 ) { | 1247 | if ( mCategoryEditDialog == 0 ) { |
1222 | mCategoryEditDialog = new KPIM::CategoryEditDialog( KABPrefs::instance(), this ); | 1248 | mCategoryEditDialog = new KPIM::CategoryEditDialog( KABPrefs::instance(), this ); |
1223 | connect( mCategoryEditDialog, SIGNAL( categoryConfigChanged() ), | 1249 | connect( mCategoryEditDialog, SIGNAL( categoryConfigChanged() ), |
1224 | SLOT( categoryButtonClicked() ) ); | 1250 | SLOT( categoryButtonClicked() ) ); |
1225 | } | 1251 | } |
1226 | 1252 | ||
1227 | mCategoryEditDialog->show(); | 1253 | mCategoryEditDialog->show(); |
1228 | mCategoryEditDialog->raise(); | 1254 | mCategoryEditDialog->raise(); |
1229 | } | 1255 | } |
1230 | 1256 | ||
1231 | void AddresseeEditorWidget::emitModified() | 1257 | void AddresseeEditorWidget::emitModified() |
1232 | { | 1258 | { |
1233 | mDirty = true; | 1259 | mDirty = true; |
1234 | 1260 | ||
1235 | KABC::Addressee::List list; | 1261 | KABC::Addressee::List list; |
1236 | 1262 | ||
1237 | if ( mIsExtension && !mBlockSignals ) { | 1263 | if ( mIsExtension && !mBlockSignals ) { |
1238 | save(); | 1264 | save(); |
1239 | list.append( mAddressee ); | 1265 | list.append( mAddressee ); |
1240 | } | 1266 | } |
1241 | 1267 | ||
1242 | emit modified( list ); | 1268 | emit modified( list ); |
1243 | } | 1269 | } |
1244 | 1270 | ||
1245 | void AddresseeEditorWidget::dateChanged( QDate ) | 1271 | void AddresseeEditorWidget::dateChanged( QDate ) |
1246 | { | 1272 | { |
1247 | emitModified(); | 1273 | emitModified(); |
1248 | } | 1274 | } |
1249 | 1275 | ||
1250 | //US invalid dates are handdled by the KDateEdit widget itself | 1276 | //US invalid dates are handdled by the KDateEdit widget itself |
1251 | void AddresseeEditorWidget::invalidDate() | 1277 | void AddresseeEditorWidget::invalidDate() |
1252 | { | 1278 | { |
1253 | KMessageBox::sorry( this, i18n( "You must specify a valid date" ) ); | 1279 | KMessageBox::sorry( this, i18n( "You must specify a valid date" ) ); |
1254 | } | 1280 | } |
1255 | 1281 | ||
1256 | 1282 | ||
1257 | void AddresseeEditorWidget::pageChanged( QWidget *wdg ) | 1283 | void AddresseeEditorWidget::pageChanged( QWidget *wdg ) |
1258 | { | 1284 | { |
1259 | #ifndef KAB_EMBEDDED | 1285 | #ifndef KAB_EMBEDDED |
1260 | if ( wdg ) | 1286 | if ( wdg ) |
1261 | KAcceleratorManager::manage( wdg ); | 1287 | KAcceleratorManager::manage( wdg ); |
1262 | #else //KAB_EMBEDDED | 1288 | #else //KAB_EMBEDDED |
1263 | //US | 1289 | //US |
1264 | #endif //KAB_EMBEDDED | 1290 | #endif //KAB_EMBEDDED |
1265 | 1291 | ||
1266 | } | 1292 | } |
1267 | 1293 | ||
1268 | QString AddresseeEditorWidget::title() const | 1294 | QString AddresseeEditorWidget::title() const |
1269 | { | 1295 | { |
1270 | return i18n( "Contact Editor" ); | 1296 | return i18n( "Contact Editor" ); |
1271 | } | 1297 | } |
1272 | 1298 | ||
1273 | QString AddresseeEditorWidget::identifier() const | 1299 | QString AddresseeEditorWidget::identifier() const |
1274 | { | 1300 | { |
1275 | return i18n( "contact_editor" ); | 1301 | return i18n( "contact_editor" ); |
1276 | } | 1302 | } |
1277 | 1303 | ||
1278 | #ifndef KAB_EMBEDDED | 1304 | #ifndef KAB_EMBEDDED |
1279 | #include "addresseeeditorwidget.moc" | 1305 | #include "addresseeeditorwidget.moc" |
1280 | #endif //KAB_EMBEDDED | 1306 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp index d781f67..4230c07 100644 --- a/kaddressbook/mainembedded.cpp +++ b/kaddressbook/mainembedded.cpp | |||
@@ -1,207 +1,222 @@ | |||
1 | #ifndef DESKTOP_VERSION | 1 | #ifndef DESKTOP_VERSION |
2 | #include <qpe/qpeapplication.h> | 2 | #include <qpe/qpeapplication.h> |
3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
4 | #else | 4 | #else |
5 | #include <qapplication.h> | 5 | #include <qapplication.h> |
6 | #include <qwindowsstyle.h> | 6 | #include <qwindowsstyle.h> |
7 | #include <qplatinumstyle.h> | 7 | #include <qplatinumstyle.h> |
8 | #include <qmainwindow.h> | 8 | #include <qmainwindow.h> |
9 | #endif | 9 | #endif |
10 | 10 | ||
11 | #include <kstandarddirs.h> | 11 | #include <kstandarddirs.h> |
12 | #include <kglobal.h> | 12 | #include <kglobal.h> |
13 | #include <stdio.h> | 13 | #include <stdio.h> |
14 | #include <qdir.h> | 14 | #include <qdir.h> |
15 | #include "kaddressbookmain.h" | 15 | #include "kaddressbookmain.h" |
16 | #include "externalapphandler.h" | 16 | #include "externalapphandler.h" |
17 | 17 | ||
18 | int main( int argc, char **argv ) | 18 | int main( int argc, char **argv ) |
19 | { | 19 | { |
20 | #ifndef DESKTOP_VERSION | 20 | #ifndef DESKTOP_VERSION |
21 | QPEApplication a( argc, argv ); | 21 | QPEApplication a( argc, argv ); |
22 | a.setKeepRunning (); | 22 | a.setKeepRunning (); |
23 | #else | 23 | #else |
24 | QApplication a( argc, argv ); | 24 | QApplication a( argc, argv ); |
25 | QApplication::setStyle( new QPlatinumStyle ()); | 25 | QApplication::setStyle( new QPlatinumStyle ()); |
26 | QString hdir = QDir::homeDirPath(); | 26 | QString hdir = QDir::homeDirPath(); |
27 | // there is a bug when creating dirs for WIN 98 | 27 | // there is a bug when creating dirs for WIN 98 |
28 | // it is difficult to fix, because we have no WIN 98 runnung | 28 | // it is difficult to fix, because we have no WIN 98 runnung |
29 | // such that we try it to create the dirs at startup here | 29 | // such that we try it to create the dirs at startup here |
30 | if ( hdir == "C:\\" ) { // win 98 or ME | 30 | if ( hdir == "C:\\" ) { // win 98 or ME |
31 | QDir app_dir; | 31 | QDir app_dir; |
32 | if ( !app_dir.exists("C:\\kdepim") ) | 32 | if ( !app_dir.exists("C:\\kdepim") ) |
33 | app_dir.mkdir ("C:\\kdepim"); | 33 | app_dir.mkdir ("C:\\kdepim"); |
34 | if ( !app_dir.exists("C:\\kdepim\\apps") ) | 34 | if ( !app_dir.exists("C:\\kdepim\\apps") ) |
35 | app_dir.mkdir ("C:\\kdepim\\apps"); | 35 | app_dir.mkdir ("C:\\kdepim\\apps"); |
36 | if ( !app_dir.exists("C:\\kdepim\\config") ) | 36 | if ( !app_dir.exists("C:\\kdepim\\config") ) |
37 | app_dir.mkdir ("C:\\kdepim\\config"); | 37 | app_dir.mkdir ("C:\\kdepim\\config"); |
38 | if ( !app_dir.exists("C:\\kdepim\\apps\\kaddressbook") ) | 38 | if ( !app_dir.exists("C:\\kdepim\\apps\\kaddressbook") ) |
39 | app_dir.mkdir ("C:\\kdepim\\apps\\kaddressbook"); | 39 | app_dir.mkdir ("C:\\kdepim\\apps\\kaddressbook"); |
40 | } | 40 | } |
41 | #endif | 41 | #endif |
42 | 42 | ||
43 | bool exitHelp = false; | 43 | bool exitHelp = false; |
44 | if ( argc > 1 ) { | 44 | if ( argc > 1 ) { |
45 | QString command = argv[1]; | 45 | QString command = argv[1]; |
46 | if ( command == "-help" ){ | 46 | if ( command == "-help" ){ |
47 | printf("KA/E command line commands:\n"); | 47 | printf("KA/E command line commands:\n"); |
48 | printf(" no command: Start KA/E in usual way\n"); | 48 | printf(" no command: Start KA/E in usual way\n"); |
49 | printf(" -help: This output\n"); | 49 | printf(" -help: This output\n"); |
50 | printf(" KA/E is exiting now. Bye!\n"); | 50 | printf(" KA/E is exiting now. Bye!\n"); |
51 | exitHelp = true; | 51 | exitHelp = true; |
52 | } | 52 | } |
53 | } | 53 | } |
54 | if ( ! exitHelp ) { | 54 | if ( ! exitHelp ) { |
55 | 55 | ||
56 | KGlobal::setAppName( "kaddressbook" ); | 56 | KGlobal::setAppName( "kaddressbook" ); |
57 | #ifndef DESKTOP_VERSION | 57 | #ifndef DESKTOP_VERSION |
58 | if ( QApplication::desktop()->width() > 320 ) | 58 | if ( QApplication::desktop()->width() > 320 ) |
59 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/"); | 59 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/"); |
60 | else | 60 | else |
61 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/"); | 61 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/"); |
62 | #else | 62 | #else |
63 | QString fileName ; | 63 | QString fileName ; |
64 | fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/"; | 64 | fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/"; |
65 | KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); | 65 | KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); |
66 | QApplication::addLibraryPath ( qApp->applicationDirPath () ); | 66 | QApplication::addLibraryPath ( qApp->applicationDirPath () ); |
67 | 67 | ||
68 | #endif | 68 | #endif |
69 | KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); | 69 | KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); |
70 | KAddressBookMain m ; | 70 | KAddressBookMain m ; |
71 | //US MainWindow m; | 71 | //US MainWindow m; |
72 | QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | 72 | QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); |
73 | 73 | ||
74 | { | ||
75 | KConfig kon ( locateLocal( "config", "korganizerrc" ) ); | ||
76 | kon.setGroup("Locale"); | ||
77 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)kon.readNumEntry( "PreferredDate",0) ); | ||
78 | QString dummy = kon.readEntry( "UserDateFormatShort","%aK %d.%m.%y" );// kon.readEntry( ""); | ||
79 | KGlobal::locale()->setHore24Format( !kon.readBoolEntry( "PreferredTime",0 ) ); | ||
80 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | ||
81 | dummy = kon.readEntry( "UserDateFormatLong","%A %d %b %y" ); | ||
82 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | ||
83 | kon.setGroup("Time & Date"); | ||
84 | KGlobal::locale()->setDaylightSaving( kon.readBoolEntry( "UseDaylightsaving", true ), | ||
85 | kon.readNumEntry( "DaylightsavingStart", 90), | ||
86 | kon.readNumEntry( "DaylightsavingEnd",304) ); | ||
87 | KGlobal::locale()->setTimezone( kon.readEntry( "TimeZoneName" ," 00:00 Europe/London(UTC)") ); | ||
88 | } | ||
74 | #ifndef DESKTOP_VERSION | 89 | #ifndef DESKTOP_VERSION |
75 | a.showMainWidget( &m ); | 90 | a.showMainWidget( &m ); |
76 | #else | 91 | #else |
77 | a.setMainWidget( &m ); | 92 | a.setMainWidget( &m ); |
78 | m.resize (640, 480 ); | 93 | m.resize (640, 480 ); |
79 | m.show(); | 94 | m.show(); |
80 | #endif | 95 | #endif |
81 | a.exec(); | 96 | a.exec(); |
82 | 97 | ||
83 | } | 98 | } |
84 | qDebug("KA: Bye! "); | 99 | qDebug("KA: Bye! "); |
85 | } | 100 | } |
86 | 101 | ||
87 | /* | 102 | /* |
88 | #include <stdlib.h> | 103 | #include <stdlib.h> |
89 | 104 | ||
90 | #include <qstring.h> | 105 | #include <qstring.h> |
91 | 106 | ||
92 | #include <kabc/stdaddressbook.h> | 107 | #include <kabc/stdaddressbook.h> |
93 | #include <kaboutdata.h> | 108 | #include <kaboutdata.h> |
94 | #include <kcmdlineargs.h> | 109 | #include <kcmdlineargs.h> |
95 | #include <kcrash.h> | 110 | #include <kcrash.h> |
96 | #include <kdebug.h> | 111 | #include <kdebug.h> |
97 | #include <klocale.h> | 112 | #include <klocale.h> |
98 | #include <kstartupinfo.h> | 113 | #include <kstartupinfo.h> |
99 | #include <kuniqueapplication.h> | 114 | #include <kuniqueapplication.h> |
100 | #include <kwin.h> | 115 | #include <kwin.h> |
101 | 116 | ||
102 | #include "kaddressbookmain.h" | 117 | #include "kaddressbookmain.h" |
103 | #include "kabcore.h" | 118 | #include "kabcore.h" |
104 | 119 | ||
105 | extern "C" { | 120 | extern "C" { |
106 | 121 | ||
107 | void crashHandler( int ) | 122 | void crashHandler( int ) |
108 | { | 123 | { |
109 | KABC::StdAddressBook::handleCrash(); | 124 | KABC::StdAddressBook::handleCrash(); |
110 | ::exit( 0 ); | 125 | ::exit( 0 ); |
111 | } | 126 | } |
112 | 127 | ||
113 | } | 128 | } |
114 | 129 | ||
115 | class KAddressBookApp : public KUniqueApplication { | 130 | class KAddressBookApp : public KUniqueApplication { |
116 | public: | 131 | public: |
117 | KAddressBookApp() : mMainWin( 0 ) {} | 132 | KAddressBookApp() : mMainWin( 0 ) {} |
118 | ~KAddressBookApp() {} | 133 | ~KAddressBookApp() {} |
119 | 134 | ||
120 | int newInstance(); | 135 | int newInstance(); |
121 | 136 | ||
122 | private: | 137 | private: |
123 | KAddressBookMain *mMainWin; | 138 | KAddressBookMain *mMainWin; |
124 | }; | 139 | }; |
125 | 140 | ||
126 | int KAddressBookApp::newInstance() | 141 | int KAddressBookApp::newInstance() |
127 | { | 142 | { |
128 | if ( isRestored() ) { | 143 | if ( isRestored() ) { |
129 | // There can only be one main window | 144 | // There can only be one main window |
130 | if ( KMainWindow::canBeRestored( 1 ) ) { | 145 | if ( KMainWindow::canBeRestored( 1 ) ) { |
131 | mMainWin = new KAddressBookMain; | 146 | mMainWin = new KAddressBookMain; |
132 | mMainWin->show(); | 147 | mMainWin->show(); |
133 | mMainWin->restore( 1 ); | 148 | mMainWin->restore( 1 ); |
134 | } | 149 | } |
135 | } else { | 150 | } else { |
136 | KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); | 151 | KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); |
137 | 152 | ||
138 | QCString addrStr = args->getOption( "addr" ); | 153 | QCString addrStr = args->getOption( "addr" ); |
139 | QCString uidStr = args->getOption( "uid" ); | 154 | QCString uidStr = args->getOption( "uid" ); |
140 | QString addr; | 155 | QString addr; |
141 | QString uid; | 156 | QString uid; |
142 | if ( !addrStr.isEmpty() ) | 157 | if ( !addrStr.isEmpty() ) |
143 | addr = QString::fromLocal8Bit( addrStr ); | 158 | addr = QString::fromLocal8Bit( addrStr ); |
144 | if ( !uidStr.isEmpty() ) | 159 | if ( !uidStr.isEmpty() ) |
145 | uid = QString::fromLocal8Bit( uidStr ); | 160 | uid = QString::fromLocal8Bit( uidStr ); |
146 | 161 | ||
147 | 162 | ||
148 | if ( args->isSet( "editor-only" ) ) { | 163 | if ( args->isSet( "editor-only" ) ) { |
149 | if ( !mMainWin ) | 164 | if ( !mMainWin ) |
150 | mMainWin = new KAddressBookMain; | 165 | mMainWin = new KAddressBookMain; |
151 | KStartupInfo::appStarted(); | 166 | KStartupInfo::appStarted(); |
152 | mMainWin->hide(); | 167 | mMainWin->hide(); |
153 | } else { | 168 | } else { |
154 | if ( mMainWin ) { | 169 | if ( mMainWin ) { |
155 | mMainWin->show(); | 170 | mMainWin->show(); |
156 | KWin::setActiveWindow( mMainWin->winId() ); | 171 | KWin::setActiveWindow( mMainWin->winId() ); |
157 | } else { | 172 | } else { |
158 | mMainWin = new KAddressBookMain; | 173 | mMainWin = new KAddressBookMain; |
159 | mMainWin->show(); | 174 | mMainWin->show(); |
160 | } | 175 | } |
161 | } | 176 | } |
162 | // Can not see why anyone would pass both a uid and an email address, so I'll leave it that two contact editors will show if they do | 177 | // Can not see why anyone would pass both a uid and an email address, so I'll leave it that two contact editors will show if they do |
163 | if ( !addr.isEmpty() ) | 178 | if ( !addr.isEmpty() ) |
164 | mMainWin->addEmail( addr ); | 179 | mMainWin->addEmail( addr ); |
165 | 180 | ||
166 | if ( !uid.isEmpty() ) | 181 | if ( !uid.isEmpty() ) |
167 | mMainWin->showContactEditor( uid ); | 182 | mMainWin->showContactEditor( uid ); |
168 | if ( args->isSet( "new-contact" ) ) { | 183 | if ( args->isSet( "new-contact" ) ) { |
169 | mMainWin->newContact(); | 184 | mMainWin->newContact(); |
170 | } | 185 | } |
171 | } | 186 | } |
172 | 187 | ||
173 | KCrash::setEmergencySaveFunction( crashHandler ); | 188 | KCrash::setEmergencySaveFunction( crashHandler ); |
174 | 189 | ||
175 | return 0; | 190 | return 0; |
176 | } | 191 | } |
177 | 192 | ||
178 | // the dummy argument is required, because KMail apparently sends an empty | 193 | // the dummy argument is required, because KMail apparently sends an empty |
179 | // argument. | 194 | // argument. |
180 | static KCmdLineOptions kmoptions[] = | 195 | static KCmdLineOptions kmoptions[] = |
181 | { | 196 | { |
182 | { "a", 0 , 0 }, | 197 | { "a", 0 , 0 }, |
183 | { "addr <email>", I18N_NOOP( "Shows contact editor with given email address" ), 0 }, | 198 | { "addr <email>", I18N_NOOP( "Shows contact editor with given email address" ), 0 }, |
184 | { "uid <uid>", I18N_NOOP( "Shows contact editor with given uid" ), 0 }, | 199 | { "uid <uid>", I18N_NOOP( "Shows contact editor with given uid" ), 0 }, |
185 | { "editor-only", I18N_NOOP( "Launches in editor only mode" ), 0 }, | 200 | { "editor-only", I18N_NOOP( "Launches in editor only mode" ), 0 }, |
186 | { "new-contact", I18N_NOOP( "Launches editor for the new contact" ), 0 }, | 201 | { "new-contact", I18N_NOOP( "Launches editor for the new contact" ), 0 }, |
187 | { "+[argument]", I18N_NOOP( "dummy argument" ), 0}, | 202 | { "+[argument]", I18N_NOOP( "dummy argument" ), 0}, |
188 | { 0, 0, 0} | 203 | { 0, 0, 0} |
189 | }; | 204 | }; |
190 | 205 | ||
191 | int main( int argc, char *argv[] ) | 206 | int main( int argc, char *argv[] ) |
192 | { | 207 | { |
193 | KLocale::setMainCatalogue( "kaddressbook" ); | 208 | KLocale::setMainCatalogue( "kaddressbook" ); |
194 | 209 | ||
195 | KCmdLineArgs::init( argc, argv, KABCore::createAboutData() ); | 210 | KCmdLineArgs::init( argc, argv, KABCore::createAboutData() ); |
196 | KCmdLineArgs::addCmdLineOptions( kmoptions ); | 211 | KCmdLineArgs::addCmdLineOptions( kmoptions ); |
197 | KUniqueApplication::addCmdLineOptions(); | 212 | KUniqueApplication::addCmdLineOptions(); |
198 | 213 | ||
199 | if ( !KAddressBookApp::start() ) | 214 | if ( !KAddressBookApp::start() ) |
200 | exit( 0 ); | 215 | exit( 0 ); |
201 | 216 | ||
202 | KAddressBookApp app; | 217 | KAddressBookApp app; |
203 | KGlobal::locale()->insertCatalogue( "libkdepim" ); | 218 | KGlobal::locale()->insertCatalogue( "libkdepim" ); |
204 | 219 | ||
205 | return app.exec(); | 220 | return app.exec(); |
206 | } | 221 | } |
207 | */ | 222 | */ |
diff --git a/kaddressbook/nameeditdialog.cpp b/kaddressbook/nameeditdialog.cpp index fb7eb22..8213c2b 100644 --- a/kaddressbook/nameeditdialog.cpp +++ b/kaddressbook/nameeditdialog.cpp | |||
@@ -1,296 +1,293 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qlayout.h> | 24 | #include <qlayout.h> |
25 | #include <qlabel.h> | 25 | #include <qlabel.h> |
26 | #include <qlistbox.h> | 26 | #include <qlistbox.h> |
27 | #include <qlistview.h> | 27 | #include <qlistview.h> |
28 | #include <qtooltip.h> | 28 | #include <qtooltip.h> |
29 | #include <qpushbutton.h> | 29 | #include <qpushbutton.h> |
30 | #include <qcheckbox.h> | 30 | #include <qcheckbox.h> |
31 | #include <qstring.h> | 31 | #include <qstring.h> |
32 | 32 | ||
33 | #ifndef KAB_EMBEDDED | 33 | #ifndef KAB_EMBEDDED |
34 | #include <kaccelmanager.h> | 34 | #include <kaccelmanager.h> |
35 | #else //KAB_EMBEDDED | 35 | #else //KAB_EMBEDDED |
36 | #include <kstandarddirs.h> | 36 | #include <kstandarddirs.h> |
37 | #endif //KAB_EMBEDDED | 37 | #endif //KAB_EMBEDDED |
38 | 38 | ||
39 | #include <kapplication.h> | 39 | #include <kapplication.h> |
40 | #include <kbuttonbox.h> | 40 | #include <kbuttonbox.h> |
41 | #include <kconfig.h> | 41 | #include <kconfig.h> |
42 | #include <klineedit.h> | 42 | #include <klineedit.h> |
43 | #include <klistview.h> | 43 | #include <klistview.h> |
44 | #include <kcombobox.h> | 44 | #include <kcombobox.h> |
45 | #include <klocale.h> | 45 | #include <klocale.h> |
46 | #include <kglobal.h> | 46 | #include <kglobal.h> |
47 | #include <kdebug.h> | 47 | #include <kdebug.h> |
48 | #include <kiconloader.h> | 48 | #include <kiconloader.h> |
49 | #include <kmessagebox.h> | 49 | #include <kmessagebox.h> |
50 | 50 | ||
51 | #include "nameeditdialog.h" | 51 | #include "nameeditdialog.h" |
52 | 52 | ||
53 | NameEditDialog::NameEditDialog( const KABC::Addressee &addr, int type, | 53 | NameEditDialog::NameEditDialog( const KABC::Addressee &addr, int type, |
54 | QWidget *parent, const char *name ) | 54 | QWidget *parent, const char *name ) |
55 | : KDialogBase( Plain, i18n( "Edit Contact Name" ), Help | Ok | Cancel, | 55 | : KDialogBase( Plain, i18n( "Edit Contact Name" ), Help | Ok | Cancel, |
56 | Ok, parent, name, true ) | 56 | Ok, parent, name, true ) |
57 | { | 57 | { |
58 | 58 | ||
59 | QWidget *page = plainPage(); | 59 | QWidget *page = plainPage(); |
60 | QGridLayout *layout = new QGridLayout( page, 5, 3 ); | 60 | QGridLayout *layout = new QGridLayout( page, 5, 3 ); |
61 | layout->setSpacing( spacingHint() ); | 61 | layout->setSpacing( spacingHint() ); |
62 | layout->addColSpacing( 2, 100 ); | 62 | layout->addColSpacing( 2, 100 ); |
63 | QLabel *label; | 63 | QLabel *label; |
64 | 64 | ||
65 | label = new QLabel( i18n( "Honorific prefixes:" ), page ); | 65 | label = new QLabel( i18n( "Honorific prefixes:" ), page ); |
66 | layout->addWidget( label, 0, 0 ); | 66 | layout->addWidget( label, 0, 0 ); |
67 | mPrefixCombo = new KComboBox( page ); | 67 | mPrefixCombo = new KComboBox( page ); |
68 | mPrefixCombo->setDuplicatesEnabled( false ); | 68 | mPrefixCombo->setDuplicatesEnabled( false ); |
69 | mPrefixCombo->setEditable( true ); | 69 | mPrefixCombo->setEditable( true ); |
70 | label->setBuddy( mPrefixCombo ); | 70 | label->setBuddy( mPrefixCombo ); |
71 | layout->addMultiCellWidget( mPrefixCombo, 0, 0, 1, 2 ); | 71 | layout->addMultiCellWidget( mPrefixCombo, 0, 0, 1, 2 ); |
72 | 72 | ||
73 | label = new QLabel( i18n( "Given name:" ), page ); | 73 | label = new QLabel( i18n( "Given name:" ), page ); |
74 | layout->addWidget( label, 1, 0 ); | 74 | layout->addWidget( label, 1, 0 ); |
75 | mGivenNameEdit = new KLineEdit( page ); | 75 | mGivenNameEdit = new KLineEdit( page ); |
76 | label->setBuddy( mGivenNameEdit ); | 76 | label->setBuddy( mGivenNameEdit ); |
77 | layout->addMultiCellWidget( mGivenNameEdit, 1, 1, 1, 2 ); | 77 | layout->addMultiCellWidget( mGivenNameEdit, 1, 1, 1, 2 ); |
78 | 78 | ||
79 | label = new QLabel( i18n( "Additional names:" ), page ); | 79 | label = new QLabel( i18n( "Additional names:" ), page ); |
80 | layout->addWidget( label, 2, 0 ); | 80 | layout->addWidget( label, 2, 0 ); |
81 | mAdditionalNameEdit = new KLineEdit( page ); | 81 | mAdditionalNameEdit = new KLineEdit( page ); |
82 | label->setBuddy( mAdditionalNameEdit ); | 82 | label->setBuddy( mAdditionalNameEdit ); |
83 | layout->addMultiCellWidget( mAdditionalNameEdit, 2, 2, 1, 2 ); | 83 | layout->addMultiCellWidget( mAdditionalNameEdit, 2, 2, 1, 2 ); |
84 | 84 | ||
85 | label = new QLabel( i18n( "Family names:" ), page ); | 85 | label = new QLabel( i18n( "Family names:" ), page ); |
86 | layout->addWidget( label, 3, 0 ); | 86 | layout->addWidget( label, 3, 0 ); |
87 | mFamilyNameEdit = new KLineEdit( page ); | 87 | mFamilyNameEdit = new KLineEdit( page ); |
88 | label->setBuddy( mFamilyNameEdit ); | 88 | label->setBuddy( mFamilyNameEdit ); |
89 | layout->addMultiCellWidget( mFamilyNameEdit, 3, 3, 1, 2 ); | 89 | layout->addMultiCellWidget( mFamilyNameEdit, 3, 3, 1, 2 ); |
90 | 90 | ||
91 | label = new QLabel( i18n( "Honorific suffixes:" ), page ); | 91 | label = new QLabel( i18n( "Honorific suffixes:" ), page ); |
92 | layout->addWidget( label, 4, 0 ); | 92 | layout->addWidget( label, 4, 0 ); |
93 | mSuffixCombo = new KComboBox( page ); | 93 | mSuffixCombo = new KComboBox( page ); |
94 | mSuffixCombo->setDuplicatesEnabled( false ); | 94 | mSuffixCombo->setDuplicatesEnabled( false ); |
95 | mSuffixCombo->setEditable( true ); | 95 | mSuffixCombo->setEditable( true ); |
96 | label->setBuddy( mSuffixCombo ); | 96 | label->setBuddy( mSuffixCombo ); |
97 | layout->addMultiCellWidget( mSuffixCombo, 4, 4, 1, 2 ); | 97 | layout->addMultiCellWidget( mSuffixCombo, 4, 4, 1, 2 ); |
98 | 98 | ||
99 | mFormattedNameCombo = new KComboBox( page ); | 99 | mFormattedNameCombo = new KComboBox( page ); |
100 | mFormattedNameCombo->setMaximumWidth(100); | 100 | mFormattedNameCombo->setMaximumWidth(100); |
101 | 101 | ||
102 | layout->addMultiCellWidget( mFormattedNameCombo, 5, 5, 0, 0 ); | 102 | layout->addMultiCellWidget( mFormattedNameCombo, 5, 5, 0, 0 ); |
103 | connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SLOT( typeChanged( int ) ) ); | 103 | connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SLOT( typeChanged( int ) ) ); |
104 | 104 | ||
105 | mFormattedNameEdit = new KLineEdit( page ); | 105 | mFormattedNameEdit = new KLineEdit( page ); |
106 | mFormattedNameEdit->setEnabled( type == CustomName ); | 106 | mFormattedNameEdit->setEnabled( type == CustomName ); |
107 | layout->addMultiCellWidget( mFormattedNameEdit, 5, 5, 1, 2 ); | 107 | layout->addMultiCellWidget( mFormattedNameEdit, 5, 5, 1, 2 ); |
108 | 108 | ||
109 | mParseBox = new QCheckBox( i18n( "Parse name automatically" ), page ); | 109 | mParseBox = new QCheckBox( i18n( "Parse name automatically" ), page ); |
110 | connect( mParseBox, SIGNAL( toggled(bool) ), SLOT( parseBoxChanged(bool) ) ); | 110 | connect( mParseBox, SIGNAL( toggled(bool) ), SLOT( parseBoxChanged(bool) ) ); |
111 | connect( mParseBox, SIGNAL( toggled(bool) ), SLOT( modified() ) ); | 111 | connect( mParseBox, SIGNAL( toggled(bool) ), SLOT( modified() ) ); |
112 | layout->addMultiCellWidget( mParseBox, 6, 6, 0, 1 ); | 112 | layout->addMultiCellWidget( mParseBox, 6, 6, 0, 2 ); |
113 | 113 | ||
114 | // Fill in the values | 114 | // Fill in the values |
115 | mFamilyNameEdit->setText( addr.familyName() ); | 115 | mFamilyNameEdit->setText( addr.familyName() ); |
116 | mGivenNameEdit->setText( addr.givenName() ); | 116 | mGivenNameEdit->setText( addr.givenName() ); |
117 | mAdditionalNameEdit->setText( addr.additionalName() ); | 117 | mAdditionalNameEdit->setText( addr.additionalName() ); |
118 | mFormattedNameEdit->setText( addr.formattedName() ); | 118 | mFormattedNameEdit->setText( addr.formattedName() ); |
119 | 119 | ||
120 | // Prefix and suffix combos | 120 | // Prefix and suffix combos |
121 | //US KConfig config( "kabcrc" ); | 121 | //US KConfig config( "kabcrc" ); |
122 | KConfig config( locateLocal("config", "kabcrc") ); | 122 | KConfig config( locateLocal("config", "kabcrc") ); |
123 | config.setGroup( "General" ); | 123 | config.setGroup( "General" ); |
124 | 124 | ||
125 | QStringList sTitle; | 125 | QStringList sTitle; |
126 | sTitle += i18n( "Dr." ); | 126 | sTitle += i18n( "Dr." ); |
127 | sTitle += i18n( "Miss" ); | 127 | sTitle += i18n( "Miss" ); |
128 | sTitle += i18n( "Mr." ); | 128 | sTitle += i18n( "Mr." ); |
129 | sTitle += i18n( "Mrs." ); | 129 | sTitle += i18n( "Mrs." ); |
130 | sTitle += i18n( "Ms." ); | 130 | sTitle += i18n( "Ms." ); |
131 | sTitle += i18n( "Prof." ); | 131 | sTitle += i18n( "Prof." ); |
132 | sTitle += config.readListEntry( "Prefixes" ); | 132 | sTitle += config.readListEntry( "Prefixes" ); |
133 | sTitle.sort(); | 133 | sTitle.sort(); |
134 | 134 | ||
135 | QStringList sSuffix; | 135 | QStringList sSuffix; |
136 | sSuffix += i18n( "I" ); | 136 | sSuffix += i18n( "I" ); |
137 | sSuffix += i18n( "II" ); | 137 | sSuffix += i18n( "II" ); |
138 | sSuffix += i18n( "III" ); | 138 | sSuffix += i18n( "III" ); |
139 | sSuffix += i18n( "Jr." ); | 139 | sSuffix += i18n( "Jr." ); |
140 | sSuffix += i18n( "Sr." ); | 140 | sSuffix += i18n( "Sr." ); |
141 | sSuffix += config.readListEntry( "Suffixes" ); | 141 | sSuffix += config.readListEntry( "Suffixes" ); |
142 | sSuffix.sort(); | 142 | sSuffix.sort(); |
143 | 143 | ||
144 | mPrefixCombo->insertStringList( sTitle ); | 144 | mPrefixCombo->insertStringList( sTitle ); |
145 | mSuffixCombo->insertStringList( sSuffix ); | 145 | mSuffixCombo->insertStringList( sSuffix ); |
146 | 146 | ||
147 | #ifndef KAB_EMBEDDED | 147 | #ifndef KAB_EMBEDDED |
148 | mPrefixCombo->setCurrentText( addr.prefix() ); | 148 | mPrefixCombo->setCurrentText( addr.prefix() ); |
149 | mSuffixCombo->setCurrentText( addr.suffix() ); | 149 | mSuffixCombo->setCurrentText( addr.suffix() ); |
150 | #else //KAB_EMBEDDED | 150 | #else //KAB_EMBEDDED |
151 | mPrefixCombo->setEditText( addr.prefix() ); | 151 | mPrefixCombo->setEditText( addr.prefix() ); |
152 | mSuffixCombo->setEditText( addr.suffix() ); | 152 | mSuffixCombo->setEditText( addr.suffix() ); |
153 | #endif //KAB_EMBEDDED | 153 | #endif //KAB_EMBEDDED |
154 | 154 | ||
155 | AddresseeConfig::instance()->setUid( addr.uid() ); | 155 | AddresseeConfig::instance()->setUid( addr.uid() ); |
156 | mParseBox->setChecked( AddresseeConfig::instance()->automaticNameParsing() ); | 156 | mParseBox->setChecked( AddresseeConfig::instance()->automaticNameParsing() ); |
157 | 157 | ||
158 | #ifndef KAB_EMBEDDED | 158 | #ifndef KAB_EMBEDDED |
159 | KAcceleratorManager::manage( this ); | 159 | KAcceleratorManager::manage( this ); |
160 | #endif //KAB_EMBEDDED | 160 | #endif //KAB_EMBEDDED |
161 | 161 | ||
162 | connect( mPrefixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); | 162 | connect( mPrefixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); |
163 | connect( mPrefixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); | 163 | connect( mPrefixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); |
164 | connect( mGivenNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); | 164 | connect( mGivenNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); |
165 | connect( mGivenNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); | 165 | connect( mGivenNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); |
166 | connect( mAdditionalNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); | 166 | connect( mAdditionalNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); |
167 | connect( mAdditionalNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); | 167 | connect( mAdditionalNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); |
168 | connect( mFamilyNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); | 168 | connect( mFamilyNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); |
169 | connect( mFamilyNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); | 169 | connect( mFamilyNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); |
170 | connect( mSuffixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); | 170 | connect( mSuffixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); |
171 | connect( mSuffixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); | 171 | connect( mSuffixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); |
172 | connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SLOT( modified() ) ); | 172 | connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SLOT( modified() ) ); |
173 | connect( mFormattedNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); | 173 | connect( mFormattedNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); |
174 | 174 | ||
175 | updateTypeCombo(); | 175 | updateTypeCombo(); |
176 | mFormattedNameCombo->setCurrentItem( type ); | 176 | mFormattedNameCombo->setCurrentItem( type ); |
177 | 177 | ||
178 | #ifdef KAB_EMBEDDED | 178 | |
179 | resize( KMIN(KGlobal::getDesktopWidth()-10, 490), KMIN(KGlobal::getDesktopHeight()-50, 300)); | ||
180 | #endif //KAB_EMBEDDED | ||
181 | |||
182 | mChanged = false; | 179 | mChanged = false; |
183 | } | 180 | } |
184 | 181 | ||
185 | NameEditDialog::~NameEditDialog() | 182 | NameEditDialog::~NameEditDialog() |
186 | { | 183 | { |
187 | } | 184 | } |
188 | 185 | ||
189 | QString NameEditDialog::familyName() const | 186 | QString NameEditDialog::familyName() const |
190 | { | 187 | { |
191 | return mFamilyNameEdit->text(); | 188 | return mFamilyNameEdit->text(); |
192 | } | 189 | } |
193 | 190 | ||
194 | QString NameEditDialog::givenName() const | 191 | QString NameEditDialog::givenName() const |
195 | { | 192 | { |
196 | return mGivenNameEdit->text(); | 193 | return mGivenNameEdit->text(); |
197 | } | 194 | } |
198 | 195 | ||
199 | QString NameEditDialog::prefix() const | 196 | QString NameEditDialog::prefix() const |
200 | { | 197 | { |
201 | return mPrefixCombo->currentText(); | 198 | return mPrefixCombo->currentText(); |
202 | } | 199 | } |
203 | 200 | ||
204 | QString NameEditDialog::suffix() const | 201 | QString NameEditDialog::suffix() const |
205 | { | 202 | { |
206 | return mSuffixCombo->currentText(); | 203 | return mSuffixCombo->currentText(); |
207 | } | 204 | } |
208 | 205 | ||
209 | QString NameEditDialog::additionalName() const | 206 | QString NameEditDialog::additionalName() const |
210 | { | 207 | { |
211 | return mAdditionalNameEdit->text(); | 208 | return mAdditionalNameEdit->text(); |
212 | } | 209 | } |
213 | 210 | ||
214 | QString NameEditDialog::customFormattedName() const | 211 | QString NameEditDialog::customFormattedName() const |
215 | { | 212 | { |
216 | return mFormattedNameEdit->text(); | 213 | return mFormattedNameEdit->text(); |
217 | } | 214 | } |
218 | 215 | ||
219 | int NameEditDialog::formattedNameType() const | 216 | int NameEditDialog::formattedNameType() const |
220 | { | 217 | { |
221 | return mFormattedNameCombo->currentItem(); | 218 | return mFormattedNameCombo->currentItem(); |
222 | } | 219 | } |
223 | 220 | ||
224 | bool NameEditDialog::changed() const | 221 | bool NameEditDialog::changed() const |
225 | { | 222 | { |
226 | return mChanged; | 223 | return mChanged; |
227 | } | 224 | } |
228 | 225 | ||
229 | QString NameEditDialog::formattedName( const KABC::Addressee &addr, int type ) | 226 | QString NameEditDialog::formattedName( const KABC::Addressee &addr, int type ) |
230 | { | 227 | { |
231 | switch ( type ) { | 228 | switch ( type ) { |
232 | case SimpleName: | 229 | case SimpleName: |
233 | return addr.givenName() + " " + addr.familyName(); | 230 | return addr.givenName() + " " + addr.familyName(); |
234 | break; | 231 | break; |
235 | case FullName: | 232 | case FullName: |
236 | return addr.prefix() + " " + addr.givenName() + " " + | 233 | return addr.prefix() + " " + addr.givenName() + " " + |
237 | addr.additionalName() + " " + addr.familyName() + " " + | 234 | addr.additionalName() + " " + addr.familyName() + " " + |
238 | addr.suffix(); | 235 | addr.suffix(); |
239 | break; | 236 | break; |
240 | case ReverseName: | 237 | case ReverseName: |
241 | return addr.familyName() + ", " + addr.givenName(); | 238 | return addr.familyName() + ", " + addr.givenName(); |
242 | break; | 239 | break; |
243 | default: | 240 | default: |
244 | return ""; | 241 | return ""; |
245 | break; | 242 | break; |
246 | } | 243 | } |
247 | } | 244 | } |
248 | 245 | ||
249 | void NameEditDialog::parseBoxChanged( bool value ) | 246 | void NameEditDialog::parseBoxChanged( bool value ) |
250 | { | 247 | { |
251 | //AddresseeConfig::instance()->setUid( addr.uid() ); | 248 | //AddresseeConfig::instance()->setUid( addr.uid() ); |
252 | AddresseeConfig::instance()->setAutomaticNameParsing( value ); | 249 | AddresseeConfig::instance()->setAutomaticNameParsing( value ); |
253 | } | 250 | } |
254 | 251 | ||
255 | void NameEditDialog::typeChanged( int pos ) | 252 | void NameEditDialog::typeChanged( int pos ) |
256 | { | 253 | { |
257 | mFormattedNameEdit->setEnabled( pos == 0 ); | 254 | mFormattedNameEdit->setEnabled( pos == 0 ); |
258 | } | 255 | } |
259 | 256 | ||
260 | void NameEditDialog::modified() | 257 | void NameEditDialog::modified() |
261 | { | 258 | { |
262 | mChanged = true; | 259 | mChanged = true; |
263 | } | 260 | } |
264 | 261 | ||
265 | void NameEditDialog::updateTypeCombo() | 262 | void NameEditDialog::updateTypeCombo() |
266 | { | 263 | { |
267 | KABC::Addressee addr; | 264 | KABC::Addressee addr; |
268 | addr.setPrefix( mPrefixCombo->currentText() ); | 265 | addr.setPrefix( mPrefixCombo->currentText() ); |
269 | addr.setGivenName( mGivenNameEdit->text() ); | 266 | addr.setGivenName( mGivenNameEdit->text() ); |
270 | addr.setAdditionalName( mAdditionalNameEdit->text() ); | 267 | addr.setAdditionalName( mAdditionalNameEdit->text() ); |
271 | addr.setFamilyName( mFamilyNameEdit->text() ); | 268 | addr.setFamilyName( mFamilyNameEdit->text() ); |
272 | addr.setSuffix( mSuffixCombo->currentText() ); | 269 | addr.setSuffix( mSuffixCombo->currentText() ); |
273 | 270 | ||
274 | int pos = mFormattedNameCombo->currentItem(); | 271 | int pos = mFormattedNameCombo->currentItem(); |
275 | 272 | ||
276 | mFormattedNameCombo->clear(); | 273 | mFormattedNameCombo->clear(); |
277 | mFormattedNameCombo->insertItem( i18n( "Custom" ) ); | 274 | mFormattedNameCombo->insertItem( i18n( "Custom" ) ); |
278 | mFormattedNameCombo->insertItem( formattedName( addr, SimpleName ) ); | 275 | mFormattedNameCombo->insertItem( formattedName( addr, SimpleName ) ); |
279 | mFormattedNameCombo->insertItem( formattedName( addr, FullName ) ); | 276 | mFormattedNameCombo->insertItem( formattedName( addr, FullName ) ); |
280 | mFormattedNameCombo->insertItem( formattedName( addr, ReverseName ) ); | 277 | mFormattedNameCombo->insertItem( formattedName( addr, ReverseName ) ); |
281 | 278 | ||
282 | mFormattedNameCombo->setCurrentItem( pos ); | 279 | mFormattedNameCombo->setCurrentItem( pos ); |
283 | } | 280 | } |
284 | 281 | ||
285 | void NameEditDialog::slotHelp() | 282 | void NameEditDialog::slotHelp() |
286 | { | 283 | { |
287 | #ifndef KAB_EMBEDDED | 284 | #ifndef KAB_EMBEDDED |
288 | kapp->invokeHelp( "managing-contacts-automatic-nameparsing" ); | 285 | kapp->invokeHelp( "managing-contacts-automatic-nameparsing" ); |
289 | #else //KAB_EMBEDDED | 286 | #else //KAB_EMBEDDED |
290 | qDebug("NameEditDialog::slotHelp Help is not supported yet"); | 287 | qDebug("NameEditDialog::slotHelp Help is not supported yet"); |
291 | #endif //KAB_EMBEDDED | 288 | #endif //KAB_EMBEDDED |
292 | } | 289 | } |
293 | 290 | ||
294 | #ifndef KAB_EMBEDDED | 291 | #ifndef KAB_EMBEDDED |
295 | #include "nameeditdialog.moc" | 292 | #include "nameeditdialog.moc" |
296 | #endif //KAB_EMBEDDED | 293 | #endif //KAB_EMBEDDED |
diff --git a/kmicromail/libmailwrapper/genericwrapper.cpp b/kmicromail/libmailwrapper/genericwrapper.cpp index ed591fc..c3a1627 100644 --- a/kmicromail/libmailwrapper/genericwrapper.cpp +++ b/kmicromail/libmailwrapper/genericwrapper.cpp | |||
@@ -1,531 +1,533 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include "genericwrapper.h" | 2 | #include "genericwrapper.h" |
3 | #include <libetpan/libetpan.h> | 3 | #include <libetpan/libetpan.h> |
4 | #include "mailtypes.h" | 4 | #include "mailtypes.h" |
5 | 5 | ||
6 | #include <kconfig.h> | 6 | #include <kconfig.h> |
7 | #include <kglobal.h> | 7 | #include <kglobal.h> |
8 | #include <kstandarddirs.h> | 8 | #include <kstandarddirs.h> |
9 | 9 | ||
10 | 10 | ||
11 | using namespace Opie::Core; | 11 | using namespace Opie::Core; |
12 | Genericwrapper::Genericwrapper() | 12 | Genericwrapper::Genericwrapper() |
13 | : AbstractMail() | 13 | : AbstractMail() |
14 | { | 14 | { |
15 | bodyCache.clear(); | 15 | bodyCache.clear(); |
16 | m_storage = 0; | 16 | m_storage = 0; |
17 | m_folder = 0; | 17 | m_folder = 0; |
18 | } | 18 | } |
19 | 19 | ||
20 | Genericwrapper::~Genericwrapper() | 20 | Genericwrapper::~Genericwrapper() |
21 | { | 21 | { |
22 | if (m_folder) { | 22 | if (m_folder) { |
23 | mailfolder_free(m_folder); | 23 | mailfolder_free(m_folder); |
24 | } | 24 | } |
25 | if (m_storage) { | 25 | if (m_storage) { |
26 | mailstorage_free(m_storage); | 26 | mailstorage_free(m_storage); |
27 | } | 27 | } |
28 | cleanMimeCache(); | 28 | cleanMimeCache(); |
29 | } | 29 | } |
30 | QString Genericwrapper::parseDateTime( mailimf_date_time *date ) | 30 | QString Genericwrapper::parseDateTime( mailimf_date_time *date ) |
31 | { | 31 | { |
32 | static bool init = false ; | 32 | static bool init = false ; |
33 | if ( ! init ) { | 33 | if ( ! init ) { |
34 | KConfig kon ( locateLocal( "config", "korganizerrc" ) ); | 34 | KConfig kon ( locateLocal( "config", "korganizerrc" ) ); |
35 | kon.setGroup("Locale"); | 35 | kon.setGroup("Locale"); |
36 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)kon.readNumEntry( "PreferredDate",0) ); | 36 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)kon.readNumEntry( "PreferredDate",0) ); |
37 | QString dummy = kon.readEntry( "UserDateFormatShort","%aK %d.%m.%y" );// kon.readEntry( ""); | 37 | QString dummy = kon.readEntry( "UserDateFormatShort","%aK %d.%m.%y" );// kon.readEntry( ""); |
38 | KGlobal::locale()->setHore24Format( !kon.readBoolEntry( "PreferredTime",0 ) ); | 38 | KGlobal::locale()->setHore24Format( !kon.readBoolEntry( "PreferredTime",0 ) ); |
39 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 39 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
40 | dummy = kon.readEntry( "UserDateFormatLong","%A %d %b %y" ); | ||
41 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | ||
40 | kon.setGroup("Time & Date"); | 42 | kon.setGroup("Time & Date"); |
41 | KGlobal::locale()->setDaylightSaving( kon.readBoolEntry( "UseDaylightsaving", true ), | 43 | KGlobal::locale()->setDaylightSaving( kon.readBoolEntry( "UseDaylightsaving", true ), |
42 | kon.readNumEntry( "DaylightsavingStart", 90), | 44 | kon.readNumEntry( "DaylightsavingStart", 90), |
43 | kon.readNumEntry( "DaylightsavingEnd",304) ); | 45 | kon.readNumEntry( "DaylightsavingEnd",304) ); |
44 | KGlobal::locale()->setTimezone( kon.readEntry( "TimeZoneName" ," 00:00 Europe/London(UTC)") ); | 46 | KGlobal::locale()->setTimezone( kon.readEntry( "TimeZoneName" ," 00:00 Europe/London(UTC)") ); |
45 | 47 | ||
46 | init = true; | 48 | init = true; |
47 | 49 | ||
48 | } | 50 | } |
49 | QDate da (date->dt_year,date->dt_month, date->dt_day ); | 51 | QDate da (date->dt_year,date->dt_month, date->dt_day ); |
50 | QTime ti ( date->dt_hour, date->dt_min, date->dt_sec ); | 52 | QTime ti ( date->dt_hour, date->dt_min, date->dt_sec ); |
51 | QDateTime dt ( da ,ti ); | 53 | QDateTime dt ( da ,ti ); |
52 | int off = KGlobal::locale()->localTimeOffset( dt ); | 54 | int off = KGlobal::locale()->localTimeOffset( dt ); |
53 | //dt = dt.addSecs( off*60 ); | 55 | //dt = dt.addSecs( off*60 ); |
54 | QString ret; | 56 | QString ret; |
55 | if ( da == QDate::currentDate () ) | 57 | if ( da == QDate::currentDate () ) |
56 | ret = KGlobal::locale()->formatTime( ti,true); | 58 | ret = KGlobal::locale()->formatTime( ti,true); |
57 | 59 | ||
58 | else { | 60 | else { |
59 | ret = KGlobal::locale()->formatDateTime( dt,true,true); | 61 | ret = KGlobal::locale()->formatDateTime( dt,true,true); |
60 | } | 62 | } |
61 | #if 0 | 63 | #if 0 |
62 | if ( off < 0 ) | 64 | if ( off < 0 ) |
63 | ret += " -"; | 65 | ret += " -"; |
64 | else | 66 | else |
65 | ret += " +"; | 67 | ret += " +"; |
66 | ret += QString::number( off / 60 ); | 68 | ret += QString::number( off / 60 ); |
67 | ret += "h"; | 69 | ret += "h"; |
68 | #endif | 70 | #endif |
69 | #if 0 | 71 | #if 0 |
70 | char tmp[23]; | 72 | char tmp[23]; |
71 | 73 | ||
72 | // snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", | 74 | // snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", |
73 | // date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | 75 | // date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); |
74 | snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %+05i", | 76 | snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %+05i", |
75 | date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | 77 | date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); |
76 | 78 | ||
77 | 79 | ||
78 | return QString( tmp ); | 80 | return QString( tmp ); |
79 | #endif | 81 | #endif |
80 | return ret; | 82 | return ret; |
81 | } | 83 | } |
82 | 84 | ||
83 | void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime) | 85 | void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime) |
84 | { | 86 | { |
85 | if (!mime) { | 87 | if (!mime) { |
86 | return; | 88 | return; |
87 | } | 89 | } |
88 | mailmime_field*field = 0; | 90 | mailmime_field*field = 0; |
89 | mailmime_single_fields fields; | 91 | mailmime_single_fields fields; |
90 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); | 92 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); |
91 | if (mime->mm_mime_fields != NULL) { | 93 | if (mime->mm_mime_fields != NULL) { |
92 | mailmime_single_fields_init(&fields, mime->mm_mime_fields, | 94 | mailmime_single_fields_init(&fields, mime->mm_mime_fields, |
93 | mime->mm_content_type); | 95 | mime->mm_content_type); |
94 | } | 96 | } |
95 | 97 | ||
96 | mailmime_content*type = fields.fld_content; | 98 | mailmime_content*type = fields.fld_content; |
97 | clistcell*current; | 99 | clistcell*current; |
98 | if (!type) { | 100 | if (!type) { |
99 | target->setType("text"); | 101 | target->setType("text"); |
100 | target->setSubtype("plain"); | 102 | target->setSubtype("plain"); |
101 | } else { | 103 | } else { |
102 | target->setSubtype(type->ct_subtype); | 104 | target->setSubtype(type->ct_subtype); |
103 | switch(type->ct_type->tp_data.tp_discrete_type->dt_type) { | 105 | switch(type->ct_type->tp_data.tp_discrete_type->dt_type) { |
104 | case MAILMIME_DISCRETE_TYPE_TEXT: | 106 | case MAILMIME_DISCRETE_TYPE_TEXT: |
105 | target->setType("text"); | 107 | target->setType("text"); |
106 | break; | 108 | break; |
107 | case MAILMIME_DISCRETE_TYPE_IMAGE: | 109 | case MAILMIME_DISCRETE_TYPE_IMAGE: |
108 | target->setType("image"); | 110 | target->setType("image"); |
109 | break; | 111 | break; |
110 | case MAILMIME_DISCRETE_TYPE_AUDIO: | 112 | case MAILMIME_DISCRETE_TYPE_AUDIO: |
111 | target->setType("audio"); | 113 | target->setType("audio"); |
112 | break; | 114 | break; |
113 | case MAILMIME_DISCRETE_TYPE_VIDEO: | 115 | case MAILMIME_DISCRETE_TYPE_VIDEO: |
114 | target->setType("video"); | 116 | target->setType("video"); |
115 | break; | 117 | break; |
116 | case MAILMIME_DISCRETE_TYPE_APPLICATION: | 118 | case MAILMIME_DISCRETE_TYPE_APPLICATION: |
117 | target->setType("application"); | 119 | target->setType("application"); |
118 | break; | 120 | break; |
119 | case MAILMIME_DISCRETE_TYPE_EXTENSION: | 121 | case MAILMIME_DISCRETE_TYPE_EXTENSION: |
120 | default: | 122 | default: |
121 | if (type->ct_type->tp_data.tp_discrete_type->dt_extension) { | 123 | if (type->ct_type->tp_data.tp_discrete_type->dt_extension) { |
122 | target->setType(type->ct_type->tp_data.tp_discrete_type->dt_extension); | 124 | target->setType(type->ct_type->tp_data.tp_discrete_type->dt_extension); |
123 | } | 125 | } |
124 | break; | 126 | break; |
125 | } | 127 | } |
126 | if (type->ct_parameters) { | 128 | if (type->ct_parameters) { |
127 | fillParameters(target,type->ct_parameters); | 129 | fillParameters(target,type->ct_parameters); |
128 | } | 130 | } |
129 | } | 131 | } |
130 | if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) { | 132 | if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) { |
131 | for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) { | 133 | for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) { |
132 | field = (mailmime_field*)current->data; | 134 | field = (mailmime_field*)current->data; |
133 | switch(field->fld_type) { | 135 | switch(field->fld_type) { |
134 | case MAILMIME_FIELD_TRANSFER_ENCODING: | 136 | case MAILMIME_FIELD_TRANSFER_ENCODING: |
135 | target->setEncoding(getencoding(field->fld_data.fld_encoding)); | 137 | target->setEncoding(getencoding(field->fld_data.fld_encoding)); |
136 | break; | 138 | break; |
137 | case MAILMIME_FIELD_ID: | 139 | case MAILMIME_FIELD_ID: |
138 | target->setIdentifier(field->fld_data.fld_id); | 140 | target->setIdentifier(field->fld_data.fld_id); |
139 | break; | 141 | break; |
140 | case MAILMIME_FIELD_DESCRIPTION: | 142 | case MAILMIME_FIELD_DESCRIPTION: |
141 | target->setDescription(field->fld_data.fld_description); | 143 | target->setDescription(field->fld_data.fld_description); |
142 | break; | 144 | break; |
143 | default: | 145 | default: |
144 | break; | 146 | break; |
145 | } | 147 | } |
146 | } | 148 | } |
147 | } | 149 | } |
148 | } | 150 | } |
149 | 151 | ||
150 | void Genericwrapper::fillParameters(RecPartP&target,clist*parameters) | 152 | void Genericwrapper::fillParameters(RecPartP&target,clist*parameters) |
151 | { | 153 | { |
152 | if (!parameters) {return;} | 154 | if (!parameters) {return;} |
153 | clistcell*current=0; | 155 | clistcell*current=0; |
154 | mailmime_parameter*param; | 156 | mailmime_parameter*param; |
155 | for (current=clist_begin(parameters);current!=0;current=clist_next(current)) { | 157 | for (current=clist_begin(parameters);current!=0;current=clist_next(current)) { |
156 | param = (mailmime_parameter*)current->data; | 158 | param = (mailmime_parameter*)current->data; |
157 | if (param) { | 159 | if (param) { |
158 | target->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | 160 | target->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); |
159 | } | 161 | } |
160 | } | 162 | } |
161 | } | 163 | } |
162 | 164 | ||
163 | QString Genericwrapper::getencoding(mailmime_mechanism*aEnc) | 165 | QString Genericwrapper::getencoding(mailmime_mechanism*aEnc) |
164 | { | 166 | { |
165 | QString enc="7bit"; | 167 | QString enc="7bit"; |
166 | if (!aEnc) return enc; | 168 | if (!aEnc) return enc; |
167 | switch(aEnc->enc_type) { | 169 | switch(aEnc->enc_type) { |
168 | case MAILMIME_MECHANISM_7BIT: | 170 | case MAILMIME_MECHANISM_7BIT: |
169 | enc = "7bit"; | 171 | enc = "7bit"; |
170 | break; | 172 | break; |
171 | case MAILMIME_MECHANISM_8BIT: | 173 | case MAILMIME_MECHANISM_8BIT: |
172 | enc = "8bit"; | 174 | enc = "8bit"; |
173 | break; | 175 | break; |
174 | case MAILMIME_MECHANISM_BINARY: | 176 | case MAILMIME_MECHANISM_BINARY: |
175 | enc = "binary"; | 177 | enc = "binary"; |
176 | break; | 178 | break; |
177 | case MAILMIME_MECHANISM_QUOTED_PRINTABLE: | 179 | case MAILMIME_MECHANISM_QUOTED_PRINTABLE: |
178 | enc = "quoted-printable"; | 180 | enc = "quoted-printable"; |
179 | break; | 181 | break; |
180 | case MAILMIME_MECHANISM_BASE64: | 182 | case MAILMIME_MECHANISM_BASE64: |
181 | enc = "base64"; | 183 | enc = "base64"; |
182 | break; | 184 | break; |
183 | case MAILMIME_MECHANISM_TOKEN: | 185 | case MAILMIME_MECHANISM_TOKEN: |
184 | default: | 186 | default: |
185 | if (aEnc->enc_token) { | 187 | if (aEnc->enc_token) { |
186 | enc = QString(aEnc->enc_token); | 188 | enc = QString(aEnc->enc_token); |
187 | } | 189 | } |
188 | break; | 190 | break; |
189 | } | 191 | } |
190 | return enc; | 192 | return enc; |
191 | } | 193 | } |
192 | 194 | ||
193 | void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count) | 195 | void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count) |
194 | { | 196 | { |
195 | if (current_rec >= 10) { | 197 | if (current_rec >= 10) { |
196 | ; // odebug << "too deep recursion!" << oendl; | 198 | ; // odebug << "too deep recursion!" << oendl; |
197 | } | 199 | } |
198 | if (!message || !mime) { | 200 | if (!message || !mime) { |
199 | return; | 201 | return; |
200 | } | 202 | } |
201 | int r; | 203 | int r; |
202 | char*data = 0; | 204 | char*data = 0; |
203 | size_t len; | 205 | size_t len; |
204 | clistiter * cur = 0; | 206 | clistiter * cur = 0; |
205 | QString b; | 207 | QString b; |
206 | RecPartP part = new RecPart(); | 208 | RecPartP part = new RecPart(); |
207 | 209 | ||
208 | switch (mime->mm_type) { | 210 | switch (mime->mm_type) { |
209 | case MAILMIME_SINGLE: | 211 | case MAILMIME_SINGLE: |
210 | { | 212 | { |
211 | QValueList<int>countlist = recList; | 213 | QValueList<int>countlist = recList; |
212 | countlist.append(current_count); | 214 | countlist.append(current_count); |
213 | r = mailmessage_fetch_section(message,mime,&data,&len); | 215 | r = mailmessage_fetch_section(message,mime,&data,&len); |
214 | part->setSize(len); | 216 | part->setSize(len); |
215 | part->setPositionlist(countlist); | 217 | part->setPositionlist(countlist); |
216 | b = gen_attachment_id(); | 218 | b = gen_attachment_id(); |
217 | part->setIdentifier(b); | 219 | part->setIdentifier(b); |
218 | fillSingleBody(part,message,mime); | 220 | fillSingleBody(part,message,mime); |
219 | if (part->Type()=="text" && target->Bodytext().isNull()) { | 221 | if (part->Type()=="text" && target->Bodytext().isNull()) { |
220 | encodedString*rs = new encodedString(); | 222 | encodedString*rs = new encodedString(); |
221 | rs->setContent(data,len); | 223 | rs->setContent(data,len); |
222 | encodedString*res = decode_String(rs,part->Encoding()); | 224 | encodedString*res = decode_String(rs,part->Encoding()); |
223 | if (countlist.count()>2) { | 225 | if (countlist.count()>2) { |
224 | bodyCache[b]=rs; | 226 | bodyCache[b]=rs; |
225 | target->addPart(part); | 227 | target->addPart(part); |
226 | } else { | 228 | } else { |
227 | delete rs; | 229 | delete rs; |
228 | } | 230 | } |
229 | b = QString(res->Content()); | 231 | b = QString(res->Content()); |
230 | delete res; | 232 | delete res; |
231 | target->setBodytext(b); | 233 | target->setBodytext(b); |
232 | target->setDescription(part); | 234 | target->setDescription(part); |
233 | } else { | 235 | } else { |
234 | bodyCache[b]=new encodedString(data,len); | 236 | bodyCache[b]=new encodedString(data,len); |
235 | target->addPart(part); | 237 | target->addPart(part); |
236 | } | 238 | } |
237 | } | 239 | } |
238 | break; | 240 | break; |
239 | case MAILMIME_MULTIPLE: | 241 | case MAILMIME_MULTIPLE: |
240 | { | 242 | { |
241 | unsigned int ccount = 1; | 243 | unsigned int ccount = 1; |
242 | mailmime*cbody=0; | 244 | mailmime*cbody=0; |
243 | QValueList<int>countlist = recList; | 245 | QValueList<int>countlist = recList; |
244 | for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { | 246 | for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { |
245 | cbody = (mailmime*)clist_content(cur); | 247 | cbody = (mailmime*)clist_content(cur); |
246 | if (cbody->mm_type==MAILMIME_MULTIPLE) { | 248 | if (cbody->mm_type==MAILMIME_MULTIPLE) { |
247 | RecPartP targetPart = new RecPart(); | 249 | RecPartP targetPart = new RecPart(); |
248 | targetPart->setType("multipart"); | 250 | targetPart->setType("multipart"); |
249 | countlist.append(current_count); | 251 | countlist.append(current_count); |
250 | targetPart->setPositionlist(countlist); | 252 | targetPart->setPositionlist(countlist); |
251 | target->addPart(targetPart); | 253 | target->addPart(targetPart); |
252 | } | 254 | } |
253 | traverseBody(target,message, cbody,countlist,current_rec+1,ccount); | 255 | traverseBody(target,message, cbody,countlist,current_rec+1,ccount); |
254 | if (cbody->mm_type==MAILMIME_MULTIPLE) { | 256 | if (cbody->mm_type==MAILMIME_MULTIPLE) { |
255 | countlist = recList; | 257 | countlist = recList; |
256 | } | 258 | } |
257 | ++ccount; | 259 | ++ccount; |
258 | } | 260 | } |
259 | } | 261 | } |
260 | break; | 262 | break; |
261 | case MAILMIME_MESSAGE: | 263 | case MAILMIME_MESSAGE: |
262 | { | 264 | { |
263 | QValueList<int>countlist = recList; | 265 | QValueList<int>countlist = recList; |
264 | countlist.append(current_count); | 266 | countlist.append(current_count); |
265 | /* the own header is always at recursion 0 - we don't need that */ | 267 | /* the own header is always at recursion 0 - we don't need that */ |
266 | if (current_rec > 0) { | 268 | if (current_rec > 0) { |
267 | part->setPositionlist(countlist); | 269 | part->setPositionlist(countlist); |
268 | r = mailmessage_fetch_section(message,mime,&data,&len); | 270 | r = mailmessage_fetch_section(message,mime,&data,&len); |
269 | part->setSize(len); | 271 | part->setSize(len); |
270 | part->setPositionlist(countlist); | 272 | part->setPositionlist(countlist); |
271 | b = gen_attachment_id(); | 273 | b = gen_attachment_id(); |
272 | part->setIdentifier(b); | 274 | part->setIdentifier(b); |
273 | part->setType("message"); | 275 | part->setType("message"); |
274 | part->setSubtype("rfc822"); | 276 | part->setSubtype("rfc822"); |
275 | bodyCache[b]=new encodedString(data,len); | 277 | bodyCache[b]=new encodedString(data,len); |
276 | target->addPart(part); | 278 | target->addPart(part); |
277 | } | 279 | } |
278 | if (mime->mm_data.mm_message.mm_msg_mime != NULL) { | 280 | if (mime->mm_data.mm_message.mm_msg_mime != NULL) { |
279 | traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1); | 281 | traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1); |
280 | } | 282 | } |
281 | } | 283 | } |
282 | break; | 284 | break; |
283 | } | 285 | } |
284 | } | 286 | } |
285 | 287 | ||
286 | RecBodyP Genericwrapper::parseMail( mailmessage * msg ) | 288 | RecBodyP Genericwrapper::parseMail( mailmessage * msg ) |
287 | { | 289 | { |
288 | int err = MAILIMF_NO_ERROR; | 290 | int err = MAILIMF_NO_ERROR; |
289 | mailmime_single_fields fields; | 291 | mailmime_single_fields fields; |
290 | /* is bound to msg and will be freed there */ | 292 | /* is bound to msg and will be freed there */ |
291 | mailmime * mime=0; | 293 | mailmime * mime=0; |
292 | RecBodyP body = new RecBody(); | 294 | RecBodyP body = new RecBody(); |
293 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); | 295 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); |
294 | err = mailmessage_get_bodystructure(msg,&mime); | 296 | err = mailmessage_get_bodystructure(msg,&mime); |
295 | QValueList<int>recList; | 297 | QValueList<int>recList; |
296 | traverseBody(body,msg,mime,recList); | 298 | traverseBody(body,msg,mime,recList); |
297 | return body; | 299 | return body; |
298 | } | 300 | } |
299 | 301 | ||
300 | 302 | ||
301 | QString Genericwrapper::parseAddressList( mailimf_address_list *list ) | 303 | QString Genericwrapper::parseAddressList( mailimf_address_list *list ) |
302 | { | 304 | { |
303 | QString result( "" ); | 305 | QString result( "" ); |
304 | 306 | ||
305 | bool first = true; | 307 | bool first = true; |
306 | if (list == 0) return result; | 308 | if (list == 0) return result; |
307 | for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { | 309 | for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { |
308 | mailimf_address *addr = (mailimf_address *) current->data; | 310 | mailimf_address *addr = (mailimf_address *) current->data; |
309 | 311 | ||
310 | if ( !first ) { | 312 | if ( !first ) { |
311 | result.append( "," ); | 313 | result.append( "," ); |
312 | } else { | 314 | } else { |
313 | first = false; | 315 | first = false; |
314 | } | 316 | } |
315 | 317 | ||
316 | switch ( addr->ad_type ) { | 318 | switch ( addr->ad_type ) { |
317 | case MAILIMF_ADDRESS_MAILBOX: | 319 | case MAILIMF_ADDRESS_MAILBOX: |
318 | result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); | 320 | result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); |
319 | break; | 321 | break; |
320 | case MAILIMF_ADDRESS_GROUP: | 322 | case MAILIMF_ADDRESS_GROUP: |
321 | result.append( parseGroup( addr->ad_data.ad_group ) ); | 323 | result.append( parseGroup( addr->ad_data.ad_group ) ); |
322 | break; | 324 | break; |
323 | default: | 325 | default: |
324 | ; // odebug << "Generic: unkown mailimf address type" << oendl; | 326 | ; // odebug << "Generic: unkown mailimf address type" << oendl; |
325 | break; | 327 | break; |
326 | } | 328 | } |
327 | } | 329 | } |
328 | 330 | ||
329 | return result; | 331 | return result; |
330 | } | 332 | } |
331 | 333 | ||
332 | QString Genericwrapper::parseGroup( mailimf_group *group ) | 334 | QString Genericwrapper::parseGroup( mailimf_group *group ) |
333 | { | 335 | { |
334 | QString result( "" ); | 336 | QString result( "" ); |
335 | 337 | ||
336 | result.append( group->grp_display_name ); | 338 | result.append( group->grp_display_name ); |
337 | result.append( ": " ); | 339 | result.append( ": " ); |
338 | 340 | ||
339 | if ( group->grp_mb_list != NULL ) { | 341 | if ( group->grp_mb_list != NULL ) { |
340 | result.append( parseMailboxList( group->grp_mb_list ) ); | 342 | result.append( parseMailboxList( group->grp_mb_list ) ); |
341 | } | 343 | } |
342 | 344 | ||
343 | result.append( ";" ); | 345 | result.append( ";" ); |
344 | 346 | ||
345 | return result; | 347 | return result; |
346 | } | 348 | } |
347 | 349 | ||
348 | QString Genericwrapper::parseMailbox( mailimf_mailbox *box ) | 350 | QString Genericwrapper::parseMailbox( mailimf_mailbox *box ) |
349 | { | 351 | { |
350 | QString result( "" ); | 352 | QString result( "" ); |
351 | 353 | ||
352 | if ( box->mb_display_name == NULL ) { | 354 | if ( box->mb_display_name == NULL ) { |
353 | result.append( box->mb_addr_spec ); | 355 | result.append( box->mb_addr_spec ); |
354 | } else { | 356 | } else { |
355 | result.append( convert_String(box->mb_display_name).latin1() ); | 357 | result.append( convert_String(box->mb_display_name).latin1() ); |
356 | result.append( " <" ); | 358 | result.append( " <" ); |
357 | result.append( box->mb_addr_spec ); | 359 | result.append( box->mb_addr_spec ); |
358 | result.append( ">" ); | 360 | result.append( ">" ); |
359 | } | 361 | } |
360 | 362 | ||
361 | return result; | 363 | return result; |
362 | } | 364 | } |
363 | 365 | ||
364 | QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list ) | 366 | QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list ) |
365 | { | 367 | { |
366 | QString result( "" ); | 368 | QString result( "" ); |
367 | 369 | ||
368 | bool first = true; | 370 | bool first = true; |
369 | for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) { | 371 | for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) { |
370 | mailimf_mailbox *box = (mailimf_mailbox *) current->data; | 372 | mailimf_mailbox *box = (mailimf_mailbox *) current->data; |
371 | 373 | ||
372 | if ( !first ) { | 374 | if ( !first ) { |
373 | result.append( "," ); | 375 | result.append( "," ); |
374 | } else { | 376 | } else { |
375 | first = false; | 377 | first = false; |
376 | } | 378 | } |
377 | 379 | ||
378 | result.append( parseMailbox( box ) ); | 380 | result.append( parseMailbox( box ) ); |
379 | } | 381 | } |
380 | 382 | ||
381 | return result; | 383 | return result; |
382 | } | 384 | } |
383 | 385 | ||
384 | encodedString* Genericwrapper::fetchDecodedPart(const RecMailP&,const RecPartP&part) | 386 | encodedString* Genericwrapper::fetchDecodedPart(const RecMailP&,const RecPartP&part) |
385 | { | 387 | { |
386 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier()); | 388 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier()); |
387 | if (it==bodyCache.end()) return new encodedString(); | 389 | if (it==bodyCache.end()) return new encodedString(); |
388 | encodedString*t = decode_String(it.data(),part->Encoding()); | 390 | encodedString*t = decode_String(it.data(),part->Encoding()); |
389 | return t; | 391 | return t; |
390 | } | 392 | } |
391 | 393 | ||
392 | encodedString* Genericwrapper::fetchRawPart(const RecMailP&,const RecPartP&part) | 394 | encodedString* Genericwrapper::fetchRawPart(const RecMailP&,const RecPartP&part) |
393 | { | 395 | { |
394 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier()); | 396 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier()); |
395 | if (it==bodyCache.end()) return new encodedString(); | 397 | if (it==bodyCache.end()) return new encodedString(); |
396 | encodedString*t = it.data(); | 398 | encodedString*t = it.data(); |
397 | return t; | 399 | return t; |
398 | } | 400 | } |
399 | 401 | ||
400 | QString Genericwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) | 402 | QString Genericwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) |
401 | { | 403 | { |
402 | encodedString*t = fetchDecodedPart(mail,part); | 404 | encodedString*t = fetchDecodedPart(mail,part); |
403 | QString text=t->Content(); | 405 | QString text=t->Content(); |
404 | delete t; | 406 | delete t; |
405 | return text; | 407 | return text; |
406 | } | 408 | } |
407 | 409 | ||
408 | void Genericwrapper::cleanMimeCache() | 410 | void Genericwrapper::cleanMimeCache() |
409 | { | 411 | { |
410 | QMap<QString,encodedString*>::Iterator it = bodyCache.begin(); | 412 | QMap<QString,encodedString*>::Iterator it = bodyCache.begin(); |
411 | for (;it!=bodyCache.end();++it) { | 413 | for (;it!=bodyCache.end();++it) { |
412 | encodedString*t = it.data(); | 414 | encodedString*t = it.data(); |
413 | //it.setValue(0); | 415 | //it.setValue(0); |
414 | if (t) delete t; | 416 | if (t) delete t; |
415 | } | 417 | } |
416 | bodyCache.clear(); | 418 | bodyCache.clear(); |
417 | ; // odebug << "Genericwrapper: cache cleaned" << oendl; | 419 | ; // odebug << "Genericwrapper: cache cleaned" << oendl; |
418 | } | 420 | } |
419 | 421 | ||
420 | QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies) | 422 | QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies) |
421 | { | 423 | { |
422 | QStringList res; | 424 | QStringList res; |
423 | if (!in_replies || !in_replies->mid_list) return res; | 425 | if (!in_replies || !in_replies->mid_list) return res; |
424 | clistiter * current = 0; | 426 | clistiter * current = 0; |
425 | for ( current = clist_begin( in_replies->mid_list ); current != NULL; current = current->next ) { | 427 | for ( current = clist_begin( in_replies->mid_list ); current != NULL; current = current->next ) { |
426 | QString h((char*)current->data); | 428 | QString h((char*)current->data); |
427 | while (h.length()>0 && h[0]=='<') { | 429 | while (h.length()>0 && h[0]=='<') { |
428 | h.remove(0,1); | 430 | h.remove(0,1); |
429 | } | 431 | } |
430 | while (h.length()>0 && h[h.length()-1]=='>') { | 432 | while (h.length()>0 && h[h.length()-1]=='>') { |
431 | h.remove(h.length()-1,1); | 433 | h.remove(h.length()-1,1); |
432 | } | 434 | } |
433 | if (h.length()>0) { | 435 | if (h.length()>0) { |
434 | res.append(h); | 436 | res.append(h); |
435 | } | 437 | } |
436 | } | 438 | } |
437 | return res; | 439 | return res; |
438 | } | 440 | } |
439 | 441 | ||
440 | void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to, int maxSizeInKb) | 442 | void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to, int maxSizeInKb) |
441 | { | 443 | { |
442 | int r; | 444 | int r; |
443 | mailmessage_list * env_list = 0; | 445 | mailmessage_list * env_list = 0; |
444 | r = mailsession_get_messages_list(session,&env_list); | 446 | r = mailsession_get_messages_list(session,&env_list); |
445 | if (r != MAIL_NO_ERROR) { | 447 | if (r != MAIL_NO_ERROR) { |
446 | ; // odebug << "Error message list" << oendl; | 448 | ; // odebug << "Error message list" << oendl; |
447 | return; | 449 | return; |
448 | } | 450 | } |
449 | r = mailsession_get_envelopes_list(session, env_list); | 451 | r = mailsession_get_envelopes_list(session, env_list); |
450 | if (r != MAIL_NO_ERROR) { | 452 | if (r != MAIL_NO_ERROR) { |
451 | ; // odebug << "Error filling message list" << oendl; | 453 | ; // odebug << "Error filling message list" << oendl; |
452 | if (env_list) { | 454 | if (env_list) { |
453 | mailmessage_list_free(env_list); | 455 | mailmessage_list_free(env_list); |
454 | } | 456 | } |
455 | return; | 457 | return; |
456 | } | 458 | } |
457 | mailimf_references * refs = 0; | 459 | mailimf_references * refs = 0; |
458 | mailimf_in_reply_to * in_replies = 0; | 460 | mailimf_in_reply_to * in_replies = 0; |
459 | uint32_t i = 0; | 461 | uint32_t i = 0; |
460 | for(; i < carray_count(env_list->msg_tab) ; ++i) { | 462 | for(; i < carray_count(env_list->msg_tab) ; ++i) { |
461 | mailmessage * msg; | 463 | mailmessage * msg; |
462 | QBitArray mFlags(7); | 464 | QBitArray mFlags(7); |
463 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); | 465 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); |
464 | if (msg->msg_fields == NULL) { | 466 | if (msg->msg_fields == NULL) { |
465 | //; // odebug << "could not fetch envelope of message " << i << "" << oendl; | 467 | //; // odebug << "could not fetch envelope of message " << i << "" << oendl; |
466 | continue; | 468 | continue; |
467 | } | 469 | } |
468 | RecMailP mail = new RecMail(); | 470 | RecMailP mail = new RecMail(); |
469 | mail->setWrapper(this); | 471 | mail->setWrapper(this); |
470 | mail_flags * flag_result = 0; | 472 | mail_flags * flag_result = 0; |
471 | r = mailmessage_get_flags(msg,&flag_result); | 473 | r = mailmessage_get_flags(msg,&flag_result); |
472 | if (r == MAIL_ERROR_NOT_IMPLEMENTED) { | 474 | if (r == MAIL_ERROR_NOT_IMPLEMENTED) { |
473 | mFlags.setBit(FLAG_SEEN); | 475 | mFlags.setBit(FLAG_SEEN); |
474 | } | 476 | } |
475 | mailimf_single_fields single_fields; | 477 | mailimf_single_fields single_fields; |
476 | mailimf_single_fields_init(&single_fields, msg->msg_fields); | 478 | mailimf_single_fields_init(&single_fields, msg->msg_fields); |
477 | mail->setMsgsize(msg->msg_size); | 479 | mail->setMsgsize(msg->msg_size); |
478 | mail->setFlags(mFlags); | 480 | mail->setFlags(mFlags); |
479 | mail->setMbox(mailbox); | 481 | mail->setMbox(mailbox); |
480 | mail->setNumber(msg->msg_index); | 482 | mail->setNumber(msg->msg_index); |
481 | if (single_fields.fld_subject) | 483 | if (single_fields.fld_subject) |
482 | mail->setSubject( convert_String(single_fields.fld_subject->sbj_value)); | 484 | mail->setSubject( convert_String(single_fields.fld_subject->sbj_value)); |
483 | if (single_fields.fld_from) | 485 | if (single_fields.fld_from) |
484 | mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list)); | 486 | mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list)); |
485 | if (!mbox_as_to) { | 487 | if (!mbox_as_to) { |
486 | if (single_fields.fld_to) | 488 | if (single_fields.fld_to) |
487 | mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); | 489 | mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); |
488 | } else { | 490 | } else { |
489 | mail->setTo(mailbox); | 491 | mail->setTo(mailbox); |
490 | } | 492 | } |
491 | if (single_fields.fld_cc) | 493 | if (single_fields.fld_cc) |
492 | mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); | 494 | mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); |
493 | if (single_fields.fld_bcc) | 495 | if (single_fields.fld_bcc) |
494 | mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); | 496 | mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); |
495 | if (single_fields.fld_orig_date) { | 497 | if (single_fields.fld_orig_date) { |
496 | mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); | 498 | mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); |
497 | char tmp[23]; | 499 | char tmp[23]; |
498 | struct mailimf_date_time* date = single_fields.fld_orig_date->dt_date_time; | 500 | struct mailimf_date_time* date = single_fields.fld_orig_date->dt_date_time; |
499 | snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %05i", | 501 | snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %05i", |
500 | date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | 502 | date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); |
501 | mail->setIsoDate( QString( tmp ) ); | 503 | mail->setIsoDate( QString( tmp ) ); |
502 | } | 504 | } |
503 | // crashes when accessing pop3 account? | 505 | // crashes when accessing pop3 account? |
504 | if (single_fields.fld_message_id) { | 506 | if (single_fields.fld_message_id) { |
505 | mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); | 507 | mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); |
506 | ; // odebug << "Msgid == " << mail->Msgid().latin1() << "" << oendl; | 508 | ; // odebug << "Msgid == " << mail->Msgid().latin1() << "" << oendl; |
507 | } | 509 | } |
508 | if (single_fields.fld_reply_to) { | 510 | if (single_fields.fld_reply_to) { |
509 | QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list); | 511 | QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list); |
510 | if (t.count()>0) { | 512 | if (t.count()>0) { |
511 | mail->setReplyto(t[0]); | 513 | mail->setReplyto(t[0]); |
512 | } | 514 | } |
513 | } | 515 | } |
514 | #if 0 | 516 | #if 0 |
515 | refs = single_fields.fld_references; | 517 | refs = single_fields.fld_references; |
516 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { | 518 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { |
517 | char * text = (char*)refs->mid_list->first->data; | 519 | char * text = (char*)refs->mid_list->first->data; |
518 | mail->setReplyto(QString(text)); | 520 | mail->setReplyto(QString(text)); |
519 | } | 521 | } |
520 | #endif | 522 | #endif |
521 | if (single_fields.fld_in_reply_to && single_fields.fld_in_reply_to->mid_list && | 523 | if (single_fields.fld_in_reply_to && single_fields.fld_in_reply_to->mid_list && |
522 | clist_count(single_fields.fld_in_reply_to->mid_list)) { | 524 | clist_count(single_fields.fld_in_reply_to->mid_list)) { |
523 | mail->setInreply(parseInreplies(single_fields.fld_in_reply_to)); | 525 | mail->setInreply(parseInreplies(single_fields.fld_in_reply_to)); |
524 | } | 526 | } |
525 | if ( maxSizeInKb == 0 || mail->Msgsize()<=maxSizeInKb*1024 ) | 527 | if ( maxSizeInKb == 0 || mail->Msgsize()<=maxSizeInKb*1024 ) |
526 | target.append(mail); | 528 | target.append(mail); |
527 | } | 529 | } |
528 | if (env_list) { | 530 | if (env_list) { |
529 | mailmessage_list_free(env_list); | 531 | mailmessage_list_free(env_list); |
530 | } | 532 | } |
531 | } | 533 | } |
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index d5d31e2..258bd43 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,3590 +1,3592 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Requires the Qt and KDE widget libraries, available at no cost at | 4 | Requires the Qt and KDE widget libraries, available at no cost at |
5 | http://www.troll.no and http://www.kde.org respectively | 5 | http://www.troll.no and http://www.kde.org respectively |
6 | 6 | ||
7 | Copyright (c) 1997, 1998, 1999 | 7 | Copyright (c) 1997, 1998, 1999 |
8 | Preston Brown (preston.brown@yale.edu) | 8 | Preston Brown (preston.brown@yale.edu) |
9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) | 9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) |
10 | Ian Dawes (iadawes@globalserve.net) | 10 | Ian Dawes (iadawes@globalserve.net) |
11 | Laszlo Boloni (boloni@cs.purdue.edu) | 11 | Laszlo Boloni (boloni@cs.purdue.edu) |
12 | 12 | ||
13 | Copyright (c) 2000, 2001, 2002 | 13 | Copyright (c) 2000, 2001, 2002 |
14 | Cornelius Schumacher <schumacher@kde.org> | 14 | Cornelius Schumacher <schumacher@kde.org> |
15 | 15 | ||
16 | This program is free software; you can redistribute it and/or modify | 16 | This program is free software; you can redistribute it and/or modify |
17 | it under the terms of the GNU General Public License as published by | 17 | it under the terms of the GNU General Public License as published by |
18 | the Free Software Foundation; either version 2 of the License, or | 18 | the Free Software Foundation; either version 2 of the License, or |
19 | (at your option) any later version. | 19 | (at your option) any later version. |
20 | 20 | ||
21 | This program is distributed in the hope that it will be useful, | 21 | This program is distributed in the hope that it will be useful, |
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
24 | GNU General Public License for more details. | 24 | GNU General Public License for more details. |
25 | 25 | ||
26 | You should have received a copy of the GNU General Public License | 26 | You should have received a copy of the GNU General Public License |
27 | along with this program; if not, write to the Free Software | 27 | along with this program; if not, write to the Free Software |
28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qradiobutton.h> | 34 | #include <qradiobutton.h> |
35 | #include <qbuttongroup.h> | 35 | #include <qbuttongroup.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qclipboard.h> | 37 | #include <qclipboard.h> |
38 | #include <qcursor.h> | 38 | #include <qcursor.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qprogressbar.h> | 40 | #include <qprogressbar.h> |
41 | #include <qmultilineedit.h> | 41 | #include <qmultilineedit.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qwidgetstack.h> | 43 | #include <qwidgetstack.h> |
44 | #include <qptrlist.h> | 44 | #include <qptrlist.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qgroupbox.h> | 46 | #include <qgroupbox.h> |
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #ifndef KORG_NOSPLITTER | 49 | #ifndef KORG_NOSPLITTER |
50 | #include <qsplitter.h> | 50 | #include <qsplitter.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #include <kglobal.h> | 53 | #include <kglobal.h> |
54 | #include <kdebug.h> | 54 | #include <kdebug.h> |
55 | #include <kstandarddirs.h> | 55 | #include <kstandarddirs.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | #include <kmessagebox.h> | 57 | #include <kmessagebox.h> |
58 | #include <knotifyclient.h> | 58 | #include <knotifyclient.h> |
59 | #include <kconfig.h> | 59 | #include <kconfig.h> |
60 | 60 | ||
61 | #include <libkdepim/ksyncprefsdialog.h> | 61 | #include <libkdepim/ksyncprefsdialog.h> |
62 | #include <krun.h> | 62 | #include <krun.h> |
63 | #include <kdirwatch.h> | 63 | #include <kdirwatch.h> |
64 | #include <libkdepim/kdatepicker.h> | 64 | #include <libkdepim/kdatepicker.h> |
65 | #include <libkdepim/ksyncprofile.h> | 65 | #include <libkdepim/ksyncprofile.h> |
66 | 66 | ||
67 | #include <libkcal/vcaldrag.h> | 67 | #include <libkcal/vcaldrag.h> |
68 | #include <libkcal/icaldrag.h> | 68 | #include <libkcal/icaldrag.h> |
69 | #include <libkcal/icalformat.h> | 69 | #include <libkcal/icalformat.h> |
70 | #include <libkcal/vcalformat.h> | 70 | #include <libkcal/vcalformat.h> |
71 | #include <libkcal/scheduler.h> | 71 | #include <libkcal/scheduler.h> |
72 | #include <libkcal/calendarlocal.h> | 72 | #include <libkcal/calendarlocal.h> |
73 | #include <libkcal/journal.h> | 73 | #include <libkcal/journal.h> |
74 | #include <libkcal/calfilter.h> | 74 | #include <libkcal/calfilter.h> |
75 | #include <libkcal/attendee.h> | 75 | #include <libkcal/attendee.h> |
76 | #include <libkcal/dndfactory.h> | 76 | #include <libkcal/dndfactory.h> |
77 | #include <libkcal/freebusy.h> | 77 | #include <libkcal/freebusy.h> |
78 | #include <libkcal/filestorage.h> | 78 | #include <libkcal/filestorage.h> |
79 | #include <libkcal/calendarresources.h> | 79 | #include <libkcal/calendarresources.h> |
80 | #include <libkcal/qtopiaformat.h> | 80 | #include <libkcal/qtopiaformat.h> |
81 | #include "../kalarmd/alarmdialog.h" | 81 | #include "../kalarmd/alarmdialog.h" |
82 | 82 | ||
83 | #ifndef DESKTOP_VERSION | 83 | #ifndef DESKTOP_VERSION |
84 | #include <libkcal/sharpformat.h> | 84 | #include <libkcal/sharpformat.h> |
85 | #endif | 85 | #endif |
86 | #include <libkcal/phoneformat.h> | 86 | #include <libkcal/phoneformat.h> |
87 | #ifndef KORG_NOMAIL | 87 | #ifndef KORG_NOMAIL |
88 | #include "komailclient.h" | 88 | #include "komailclient.h" |
89 | #endif | 89 | #endif |
90 | #ifndef KORG_NOPRINTER | 90 | #ifndef KORG_NOPRINTER |
91 | #include "calprinter.h" | 91 | #include "calprinter.h" |
92 | #endif | 92 | #endif |
93 | #ifndef KORG_NOPLUGINS | 93 | #ifndef KORG_NOPLUGINS |
94 | #include "kocore.h" | 94 | #include "kocore.h" |
95 | #endif | 95 | #endif |
96 | #include "koeventeditor.h" | 96 | #include "koeventeditor.h" |
97 | #include "kotodoeditor.h" | 97 | #include "kotodoeditor.h" |
98 | #include "koprefs.h" | 98 | #include "koprefs.h" |
99 | #include "koeventviewerdialog.h" | 99 | #include "koeventviewerdialog.h" |
100 | #include "publishdialog.h" | 100 | #include "publishdialog.h" |
101 | #include "kofilterview.h" | 101 | #include "kofilterview.h" |
102 | #include "koglobals.h" | 102 | #include "koglobals.h" |
103 | #include "koviewmanager.h" | 103 | #include "koviewmanager.h" |
104 | #include "koagendaview.h" | 104 | #include "koagendaview.h" |
105 | #include "kodialogmanager.h" | 105 | #include "kodialogmanager.h" |
106 | #include "outgoingdialog.h" | 106 | #include "outgoingdialog.h" |
107 | #include "incomingdialog.h" | 107 | #include "incomingdialog.h" |
108 | #include "statusdialog.h" | 108 | #include "statusdialog.h" |
109 | #include "kdatenavigator.h" | 109 | #include "kdatenavigator.h" |
110 | #include "kotodoview.h" | 110 | #include "kotodoview.h" |
111 | #include "datenavigator.h" | 111 | #include "datenavigator.h" |
112 | #include "resourceview.h" | 112 | #include "resourceview.h" |
113 | #include "navigatorbar.h" | 113 | #include "navigatorbar.h" |
114 | #include "searchdialog.h" | 114 | #include "searchdialog.h" |
115 | #include "mainwindow.h" | 115 | #include "mainwindow.h" |
116 | 116 | ||
117 | #include "calendarview.h" | 117 | #include "calendarview.h" |
118 | #ifndef DESKTOP_VERSION | 118 | #ifndef DESKTOP_VERSION |
119 | #include <qtopia/alarmserver.h> | 119 | #include <qtopia/alarmserver.h> |
120 | #endif | 120 | #endif |
121 | #ifndef _WIN32_ | 121 | #ifndef _WIN32_ |
122 | #include <stdlib.h> | 122 | #include <stdlib.h> |
123 | #include <stdio.h> | 123 | #include <stdio.h> |
124 | #include <unistd.h> | 124 | #include <unistd.h> |
125 | #else | 125 | #else |
126 | #include <qprocess.h> | 126 | #include <qprocess.h> |
127 | #endif | 127 | #endif |
128 | using namespace KOrg; | 128 | using namespace KOrg; |
129 | using namespace KCal; | 129 | using namespace KCal; |
130 | extern int globalFlagBlockAgenda; | 130 | extern int globalFlagBlockAgenda; |
131 | extern int globalFlagBlockStartup; | 131 | extern int globalFlagBlockStartup; |
132 | 132 | ||
133 | 133 | ||
134 | 134 | ||
135 | class KOBeamPrefs : public QDialog | 135 | class KOBeamPrefs : public QDialog |
136 | { | 136 | { |
137 | public: | 137 | public: |
138 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 138 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
139 | QDialog( parent, name, true ) | 139 | QDialog( parent, name, true ) |
140 | { | 140 | { |
141 | setCaption( i18n("Beam Options") ); | 141 | setCaption( i18n("Beam Options") ); |
142 | QVBoxLayout* lay = new QVBoxLayout( this ); | 142 | QVBoxLayout* lay = new QVBoxLayout( this ); |
143 | lay->setSpacing( 3 ); | 143 | lay->setSpacing( 3 ); |
144 | lay->setMargin( 3 ); | 144 | lay->setMargin( 3 ); |
145 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 145 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
146 | lay->addWidget( format ); | 146 | lay->addWidget( format ); |
147 | format->setExclusive ( true ) ; | 147 | format->setExclusive ( true ) ; |
148 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 148 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
149 | lay->addWidget( time ); time->setExclusive ( true ) ; | 149 | lay->addWidget( time ); time->setExclusive ( true ) ; |
150 | vcal = new QRadioButton(" vCalendar ", format ); | 150 | vcal = new QRadioButton(" vCalendar ", format ); |
151 | ical = new QRadioButton(" iCalendar ", format ); | 151 | ical = new QRadioButton(" iCalendar ", format ); |
152 | vcal->setChecked( true ); | 152 | vcal->setChecked( true ); |
153 | tz = new QRadioButton(i18n(" With timezone "), time ); | 153 | tz = new QRadioButton(i18n(" With timezone "), time ); |
154 | local = new QRadioButton(i18n(" Local time "), time ); | 154 | local = new QRadioButton(i18n(" Local time "), time ); |
155 | tz->setChecked( true ); | 155 | tz->setChecked( true ); |
156 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 156 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
157 | lay->addWidget( ok ); | 157 | lay->addWidget( ok ); |
158 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 158 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
159 | lay->addWidget( cancel ); | 159 | lay->addWidget( cancel ); |
160 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 160 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
161 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 161 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
162 | resize( 200, 200 ); | 162 | resize( 200, 200 ); |
163 | } | 163 | } |
164 | 164 | ||
165 | bool beamVcal() { return vcal->isChecked(); } | 165 | bool beamVcal() { return vcal->isChecked(); } |
166 | bool beamLocal() { return local->isChecked(); } | 166 | bool beamLocal() { return local->isChecked(); } |
167 | private: | 167 | private: |
168 | QRadioButton* vcal, *ical, *local, *tz; | 168 | QRadioButton* vcal, *ical, *local, *tz; |
169 | }; | 169 | }; |
170 | class KOCatPrefs : public QDialog | 170 | class KOCatPrefs : public QDialog |
171 | { | 171 | { |
172 | public: | 172 | public: |
173 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 173 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
174 | QDialog( parent, name, true ) | 174 | QDialog( parent, name, true ) |
175 | { | 175 | { |
176 | setCaption( i18n("Manage new Categories") ); | 176 | setCaption( i18n("Manage new Categories") ); |
177 | QVBoxLayout* lay = new QVBoxLayout( this ); | 177 | QVBoxLayout* lay = new QVBoxLayout( this ); |
178 | lay->setSpacing( 3 ); | 178 | lay->setSpacing( 3 ); |
179 | lay->setMargin( 3 ); | 179 | lay->setMargin( 3 ); |
180 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 180 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
181 | lay->addWidget( lab ); | 181 | lay->addWidget( lab ); |
182 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 182 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
183 | lay->addWidget( format ); | 183 | lay->addWidget( format ); |
184 | format->setExclusive ( true ) ; | 184 | format->setExclusive ( true ) ; |
185 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 185 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
186 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 186 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
187 | addCatBut->setChecked( true ); | 187 | addCatBut->setChecked( true ); |
188 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 188 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
189 | lay->addWidget( ok ); | 189 | lay->addWidget( ok ); |
190 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 190 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
191 | lay->addWidget( cancel ); | 191 | lay->addWidget( cancel ); |
192 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 192 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
193 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 193 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
194 | resize( 200, 200 ); | 194 | resize( 200, 200 ); |
195 | } | 195 | } |
196 | 196 | ||
197 | bool addCat() { return addCatBut->isChecked(); } | 197 | bool addCat() { return addCatBut->isChecked(); } |
198 | private: | 198 | private: |
199 | QRadioButton* addCatBut; | 199 | QRadioButton* addCatBut; |
200 | }; | 200 | }; |
201 | 201 | ||
202 | 202 | ||
203 | 203 | ||
204 | CalendarView::CalendarView( CalendarResources *calendar, | 204 | CalendarView::CalendarView( CalendarResources *calendar, |
205 | QWidget *parent, const char *name ) | 205 | QWidget *parent, const char *name ) |
206 | : CalendarViewBase( parent, name ), | 206 | : CalendarViewBase( parent, name ), |
207 | mCalendar( calendar ), | 207 | mCalendar( calendar ), |
208 | mResourceManager( calendar->resourceManager() ) | 208 | mResourceManager( calendar->resourceManager() ) |
209 | { | 209 | { |
210 | 210 | ||
211 | mEventEditor = 0; | 211 | mEventEditor = 0; |
212 | mTodoEditor = 0; | 212 | mTodoEditor = 0; |
213 | 213 | ||
214 | init(); | 214 | init(); |
215 | } | 215 | } |
216 | 216 | ||
217 | CalendarView::CalendarView( Calendar *calendar, | 217 | CalendarView::CalendarView( Calendar *calendar, |
218 | QWidget *parent, const char *name ) | 218 | QWidget *parent, const char *name ) |
219 | : CalendarViewBase( parent, name ), | 219 | : CalendarViewBase( parent, name ), |
220 | mCalendar( calendar ), | 220 | mCalendar( calendar ), |
221 | mResourceManager( 0 ) | 221 | mResourceManager( 0 ) |
222 | { | 222 | { |
223 | 223 | ||
224 | mEventEditor = 0; | 224 | mEventEditor = 0; |
225 | mTodoEditor = 0; | 225 | mTodoEditor = 0; |
226 | init();} | 226 | init();} |
227 | 227 | ||
228 | void CalendarView::init() | 228 | void CalendarView::init() |
229 | { | 229 | { |
230 | beamDialog = new KOBeamPrefs(); | 230 | beamDialog = new KOBeamPrefs(); |
231 | mDatePickerMode = 0; | 231 | mDatePickerMode = 0; |
232 | mCurrentSyncDevice = ""; | 232 | mCurrentSyncDevice = ""; |
233 | writeLocale(); | 233 | writeLocale(); |
234 | mViewManager = new KOViewManager( this ); | 234 | mViewManager = new KOViewManager( this ); |
235 | mDialogManager = new KODialogManager( this ); | 235 | mDialogManager = new KODialogManager( this ); |
236 | mEventViewerDialog = 0; | 236 | mEventViewerDialog = 0; |
237 | mModified = false; | 237 | mModified = false; |
238 | mReadOnly = false; | 238 | mReadOnly = false; |
239 | mSelectedIncidence = 0; | 239 | mSelectedIncidence = 0; |
240 | mCalPrinter = 0; | 240 | mCalPrinter = 0; |
241 | mFilters.setAutoDelete(true); | 241 | mFilters.setAutoDelete(true); |
242 | 242 | ||
243 | mCalendar->registerObserver( this ); | 243 | mCalendar->registerObserver( this ); |
244 | // TODO: Make sure that view is updated, when calendar is changed. | 244 | // TODO: Make sure that view is updated, when calendar is changed. |
245 | 245 | ||
246 | mStorage = new FileStorage( mCalendar ); | 246 | mStorage = new FileStorage( mCalendar ); |
247 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 247 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
248 | 248 | ||
249 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 249 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
250 | #ifndef KORG_NOSPLITTER | 250 | #ifndef KORG_NOSPLITTER |
251 | // create the main layout frames. | 251 | // create the main layout frames. |
252 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 252 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
253 | topLayout->addWidget(mPanner); | 253 | topLayout->addWidget(mPanner); |
254 | 254 | ||
255 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 255 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
256 | "CalendarView::LeftFrame"); | 256 | "CalendarView::LeftFrame"); |
257 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 257 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
258 | 258 | ||
259 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, | 259 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, |
260 | "CalendarView::DateNavigator", QDate::currentDate() ); | 260 | "CalendarView::DateNavigator", QDate::currentDate() ); |
261 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 261 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
262 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 262 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
263 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 263 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
264 | 264 | ||
265 | #ifdef KORG_NORESOURCEVIEW | 265 | #ifdef KORG_NORESOURCEVIEW |
266 | mResourceView = 0; | 266 | mResourceView = 0; |
267 | #else | 267 | #else |
268 | if ( mResourceManager ) { | 268 | if ( mResourceManager ) { |
269 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 269 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
270 | mResourceView->updateView(); | 270 | mResourceView->updateView(); |
271 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 271 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
272 | SLOT( updateView() ) ); | 272 | SLOT( updateView() ) ); |
273 | } else { | 273 | } else { |
274 | mResourceView = 0; | 274 | mResourceView = 0; |
275 | } | 275 | } |
276 | #endif | 276 | #endif |
277 | QWidget *rightBox = new QWidget( mPanner ); | 277 | QWidget *rightBox = new QWidget( mPanner ); |
278 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 278 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
279 | 279 | ||
280 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 280 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
281 | rightLayout->addWidget( mNavigatorBar ); | 281 | rightLayout->addWidget( mNavigatorBar ); |
282 | 282 | ||
283 | mRightFrame = new QWidgetStack( rightBox ); | 283 | mRightFrame = new QWidgetStack( rightBox ); |
284 | rightLayout->addWidget( mRightFrame, 1 ); | 284 | rightLayout->addWidget( mRightFrame, 1 ); |
285 | 285 | ||
286 | mLeftFrame = mLeftSplitter; | 286 | mLeftFrame = mLeftSplitter; |
287 | #else | 287 | #else |
288 | QWidget *mainBox = new QWidget( this ); | 288 | QWidget *mainBox = new QWidget( this ); |
289 | QWidget *leftFrame = new QWidget( mainBox ); | 289 | QWidget *leftFrame = new QWidget( mainBox ); |
290 | 290 | ||
291 | QBoxLayout * mainBoxLayout; | 291 | QBoxLayout * mainBoxLayout; |
292 | QBoxLayout * leftFrameLayout; | 292 | QBoxLayout * leftFrameLayout; |
293 | if ( KOPrefs::instance()->mVerticalScreen ) { | 293 | if ( KOPrefs::instance()->mVerticalScreen ) { |
294 | mainBoxLayout = new QVBoxLayout(mainBox); | 294 | mainBoxLayout = new QVBoxLayout(mainBox); |
295 | leftFrameLayout = new QHBoxLayout(leftFrame ); | 295 | leftFrameLayout = new QHBoxLayout(leftFrame ); |
296 | } else { | 296 | } else { |
297 | mainBoxLayout = new QHBoxLayout(mainBox); | 297 | mainBoxLayout = new QHBoxLayout(mainBox); |
298 | leftFrameLayout = new QVBoxLayout(leftFrame ); | 298 | leftFrameLayout = new QVBoxLayout(leftFrame ); |
299 | } | 299 | } |
300 | topLayout->addWidget( mainBox ); | 300 | topLayout->addWidget( mainBox ); |
301 | mainBoxLayout->addWidget (leftFrame); | 301 | mainBoxLayout->addWidget (leftFrame); |
302 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, | 302 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, |
303 | "CalendarView::DateNavigator", QDate::currentDate()); | 303 | "CalendarView::DateNavigator", QDate::currentDate()); |
304 | // mDateNavigator->blockSignals( true ); | 304 | // mDateNavigator->blockSignals( true ); |
305 | leftFrameLayout->addWidget( mDateNavigator ); | 305 | leftFrameLayout->addWidget( mDateNavigator ); |
306 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); | 306 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); |
307 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist"); | 307 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist"); |
308 | 308 | ||
309 | if ( QApplication::desktop()->width() < 480 ) { | 309 | if ( QApplication::desktop()->width() < 480 ) { |
310 | leftFrameLayout->addWidget(mFilterView); | 310 | leftFrameLayout->addWidget(mFilterView); |
311 | leftFrameLayout->addWidget(mTodoList, 2 ); | 311 | leftFrameLayout->addWidget(mTodoList, 2 ); |
312 | 312 | ||
313 | } else { | 313 | } else { |
314 | leftFrameLayout->addWidget(mTodoList,2 ); | 314 | leftFrameLayout->addWidget(mTodoList,2 ); |
315 | leftFrameLayout->addWidget(mFilterView ); | 315 | leftFrameLayout->addWidget(mFilterView ); |
316 | } | 316 | } |
317 | mFilterView->hide(); | 317 | mFilterView->hide(); |
318 | QWidget *rightBox = new QWidget( mainBox ); | 318 | QWidget *rightBox = new QWidget( mainBox ); |
319 | mainBoxLayout->addWidget ( rightBox, 10 ); | 319 | mainBoxLayout->addWidget ( rightBox, 10 ); |
320 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 320 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
321 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 321 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
322 | mRightFrame = new QWidgetStack( rightBox ); | 322 | mRightFrame = new QWidgetStack( rightBox ); |
323 | rightLayout->addWidget( mNavigatorBar ); | 323 | rightLayout->addWidget( mNavigatorBar ); |
324 | rightLayout->addWidget( mRightFrame, 10 ); | 324 | rightLayout->addWidget( mRightFrame, 10 ); |
325 | 325 | ||
326 | mLeftFrame = leftFrame; | 326 | mLeftFrame = leftFrame; |
327 | if ( KOPrefs::instance()->mVerticalScreen ) { | 327 | if ( KOPrefs::instance()->mVerticalScreen ) { |
328 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 328 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
329 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 329 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
330 | } else { | 330 | } else { |
331 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 331 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
332 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 332 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
333 | } | 333 | } |
334 | 334 | ||
335 | //qDebug("Calendarview Size %d %d ", width(), height()); | 335 | //qDebug("Calendarview Size %d %d ", width(), height()); |
336 | #endif | 336 | #endif |
337 | 337 | ||
338 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 338 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
339 | SLOT( showDates( const KCal::DateList & ) ) ); | 339 | SLOT( showDates( const KCal::DateList & ) ) ); |
340 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 340 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
341 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 341 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
342 | 342 | ||
343 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), | 343 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), |
344 | mNavigator, SLOT( selectPreviousYear() ) ); | 344 | mNavigator, SLOT( selectPreviousYear() ) ); |
345 | connect( mNavigatorBar, SIGNAL( goNextYear() ), | 345 | connect( mNavigatorBar, SIGNAL( goNextYear() ), |
346 | mNavigator, SLOT( selectNextYear() ) ); | 346 | mNavigator, SLOT( selectNextYear() ) ); |
347 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), | 347 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), |
348 | mNavigator, SLOT( selectPreviousMonth() ) ); | 348 | mNavigator, SLOT( selectPreviousMonth() ) ); |
349 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), | 349 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), |
350 | mNavigator, SLOT( selectNextMonth() ) ); | 350 | mNavigator, SLOT( selectNextMonth() ) ); |
351 | 351 | ||
352 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 352 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
353 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); | 353 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); |
354 | 354 | ||
355 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 355 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
356 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 356 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
357 | 357 | ||
358 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 358 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
359 | mNavigator, SLOT( selectPreviousYear() ) ); | 359 | mNavigator, SLOT( selectPreviousYear() ) ); |
360 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 360 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
361 | mNavigator, SLOT( selectNextYear() ) ); | 361 | mNavigator, SLOT( selectNextYear() ) ); |
362 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 362 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
363 | mNavigator, SLOT( selectPreviousMonth() ) ); | 363 | mNavigator, SLOT( selectPreviousMonth() ) ); |
364 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 364 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
365 | mNavigator, SLOT( selectNextMonth() ) ); | 365 | mNavigator, SLOT( selectNextMonth() ) ); |
366 | 366 | ||
367 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 367 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
368 | mNavigator, SLOT( selectPrevious() ) ); | 368 | mNavigator, SLOT( selectPrevious() ) ); |
369 | connect( mDateNavigator, SIGNAL( goNext() ), | 369 | connect( mDateNavigator, SIGNAL( goNext() ), |
370 | mNavigator, SLOT( selectNext() ) ); | 370 | mNavigator, SLOT( selectNext() ) ); |
371 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 371 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
372 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 372 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
373 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), | 373 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), |
374 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 374 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
375 | 375 | ||
376 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 376 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
377 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 377 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
378 | 378 | ||
379 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), | 379 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), |
380 | SLOT( eventAdded( Event *) ) ); | 380 | SLOT( eventAdded( Event *) ) ); |
381 | 381 | ||
382 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 382 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
383 | 383 | ||
384 | connect( this, SIGNAL( configChanged() ), | 384 | connect( this, SIGNAL( configChanged() ), |
385 | mDateNavigator, SLOT( updateConfig() ) ); | 385 | mDateNavigator, SLOT( updateConfig() ) ); |
386 | 386 | ||
387 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 387 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
388 | SLOT( newTodo() ) ); | 388 | SLOT( newTodo() ) ); |
389 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 389 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
390 | SLOT( newSubTodo( Todo * ) ) ); | 390 | SLOT( newSubTodo( Todo * ) ) ); |
391 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 391 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
392 | SLOT( editTodo( Todo * ) ) ); | 392 | SLOT( editTodo( Todo * ) ) ); |
393 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 393 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
394 | SLOT( showTodo( Todo *) ) ); | 394 | SLOT( showTodo( Todo *) ) ); |
395 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 395 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
396 | SLOT( deleteTodo( Todo *) ) ); | 396 | SLOT( deleteTodo( Todo *) ) ); |
397 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 397 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
398 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 398 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
399 | SLOT( purgeCompleted() ) ); | 399 | SLOT( purgeCompleted() ) ); |
400 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 400 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
401 | SIGNAL( todoModified( Todo *, int ) ) ); | 401 | SIGNAL( todoModified( Todo *, int ) ) ); |
402 | 402 | ||
403 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 403 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
404 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 404 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
405 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 405 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
406 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 406 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
407 | 407 | ||
408 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 408 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
409 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 409 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
410 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 410 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
411 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 411 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
412 | 412 | ||
413 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 413 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
414 | this, SLOT ( todo_unsub( Todo * ) ) ); | 414 | this, SLOT ( todo_unsub( Todo * ) ) ); |
415 | 415 | ||
416 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 416 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
417 | SLOT( updateTodo( Todo *, int ) ) ); | 417 | SLOT( updateTodo( Todo *, int ) ) ); |
418 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 418 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
419 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 419 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
420 | 420 | ||
421 | 421 | ||
422 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 422 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
423 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 423 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
424 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 424 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
425 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 425 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
426 | 426 | ||
427 | 427 | ||
428 | 428 | ||
429 | 429 | ||
430 | 430 | ||
431 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 431 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
432 | SLOT(checkClipboard())); | 432 | SLOT(checkClipboard())); |
433 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 433 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
434 | SLOT( processTodoListSelection( Incidence * ) ) ); | 434 | SLOT( processTodoListSelection( Incidence * ) ) ); |
435 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 435 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
436 | 436 | ||
437 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 437 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
438 | 438 | ||
439 | mDateFrame = new QVBox(0,0,WType_Popup); | 439 | mDateFrame = new QVBox(0,0,WType_Popup); |
440 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 440 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
441 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 441 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
442 | mDateFrame->setLineWidth(3); | 442 | mDateFrame->setLineWidth(3); |
443 | mDateFrame->hide(); | 443 | mDateFrame->hide(); |
444 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 444 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
445 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 445 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
446 | 446 | ||
447 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 447 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
448 | 448 | ||
449 | mEventEditor = mDialogManager->getEventEditor(); | 449 | mEventEditor = mDialogManager->getEventEditor(); |
450 | mTodoEditor = mDialogManager->getTodoEditor(); | 450 | mTodoEditor = mDialogManager->getTodoEditor(); |
451 | 451 | ||
452 | mFlagEditDescription = false; | 452 | mFlagEditDescription = false; |
453 | 453 | ||
454 | mSuspendTimer = new QTimer( this ); | 454 | mSuspendTimer = new QTimer( this ); |
455 | mAlarmTimer = new QTimer( this ); | 455 | mAlarmTimer = new QTimer( this ); |
456 | mRecheckAlarmTimer = new QTimer( this ); | 456 | mRecheckAlarmTimer = new QTimer( this ); |
457 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 457 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
458 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 458 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
459 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 459 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
460 | mAlarmDialog = new AlarmDialog( this ); | 460 | mAlarmDialog = new AlarmDialog( this ); |
461 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 461 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
462 | mAlarmDialog->setServerNotification( false ); | 462 | mAlarmDialog->setServerNotification( false ); |
463 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 463 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
464 | } | 464 | } |
465 | 465 | ||
466 | 466 | ||
467 | CalendarView::~CalendarView() | 467 | CalendarView::~CalendarView() |
468 | { | 468 | { |
469 | // kdDebug() << "~CalendarView()" << endl; | 469 | // kdDebug() << "~CalendarView()" << endl; |
470 | //qDebug("CalendarView::~CalendarView() "); | 470 | //qDebug("CalendarView::~CalendarView() "); |
471 | delete mDialogManager; | 471 | delete mDialogManager; |
472 | delete mViewManager; | 472 | delete mViewManager; |
473 | delete mStorage; | 473 | delete mStorage; |
474 | delete mDateFrame ; | 474 | delete mDateFrame ; |
475 | delete beamDialog; | 475 | delete beamDialog; |
476 | //kdDebug() << "~CalendarView() done" << endl; | 476 | //kdDebug() << "~CalendarView() done" << endl; |
477 | } | 477 | } |
478 | void CalendarView::timerAlarm() | 478 | void CalendarView::timerAlarm() |
479 | { | 479 | { |
480 | //qDebug("CalendarView::timerAlarm() "); | 480 | //qDebug("CalendarView::timerAlarm() "); |
481 | computeAlarm(mAlarmNotification ); | 481 | computeAlarm(mAlarmNotification ); |
482 | } | 482 | } |
483 | 483 | ||
484 | void CalendarView::suspendAlarm() | 484 | void CalendarView::suspendAlarm() |
485 | { | 485 | { |
486 | //qDebug(" CalendarView::suspendAlarm() "); | 486 | //qDebug(" CalendarView::suspendAlarm() "); |
487 | computeAlarm(mSuspendAlarmNotification ); | 487 | computeAlarm(mSuspendAlarmNotification ); |
488 | 488 | ||
489 | } | 489 | } |
490 | 490 | ||
491 | void CalendarView::startAlarm( QString mess , QString filename) | 491 | void CalendarView::startAlarm( QString mess , QString filename) |
492 | { | 492 | { |
493 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 493 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
494 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 494 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
495 | 495 | ||
496 | } | 496 | } |
497 | 497 | ||
498 | void CalendarView::checkNextTimerAlarm() | 498 | void CalendarView::checkNextTimerAlarm() |
499 | { | 499 | { |
500 | mCalendar->checkAlarmForIncidence( 0, true ); | 500 | mCalendar->checkAlarmForIncidence( 0, true ); |
501 | } | 501 | } |
502 | 502 | ||
503 | void CalendarView::computeAlarm( QString msg ) | 503 | void CalendarView::computeAlarm( QString msg ) |
504 | { | 504 | { |
505 | 505 | ||
506 | QString mess = msg; | 506 | QString mess = msg; |
507 | QString mAlarmMessage = mess.mid( 9 ); | 507 | QString mAlarmMessage = mess.mid( 9 ); |
508 | QString filename = MainWindow::resourcePath(); | 508 | QString filename = MainWindow::resourcePath(); |
509 | filename += "koalarm.wav"; | 509 | filename += "koalarm.wav"; |
510 | QString tempfilename; | 510 | QString tempfilename; |
511 | if ( mess.left( 13 ) == "suspend_alarm") { | 511 | if ( mess.left( 13 ) == "suspend_alarm") { |
512 | bool error = false; | 512 | bool error = false; |
513 | int len = mess.mid( 13 ).find("+++"); | 513 | int len = mess.mid( 13 ).find("+++"); |
514 | if ( len < 2 ) | 514 | if ( len < 2 ) |
515 | error = true; | 515 | error = true; |
516 | else { | 516 | else { |
517 | tempfilename = mess.mid( 13, len ); | 517 | tempfilename = mess.mid( 13, len ); |
518 | if ( !QFile::exists( tempfilename ) ) | 518 | if ( !QFile::exists( tempfilename ) ) |
519 | error = true; | 519 | error = true; |
520 | } | 520 | } |
521 | if ( ! error ) { | 521 | if ( ! error ) { |
522 | filename = tempfilename; | 522 | filename = tempfilename; |
523 | } | 523 | } |
524 | mAlarmMessage = mess.mid( 13+len+3 ); | 524 | mAlarmMessage = mess.mid( 13+len+3 ); |
525 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 525 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
526 | startAlarm( mAlarmMessage, filename); | 526 | startAlarm( mAlarmMessage, filename); |
527 | return; | 527 | return; |
528 | } | 528 | } |
529 | if ( mess.left( 11 ) == "timer_alarm") { | 529 | if ( mess.left( 11 ) == "timer_alarm") { |
530 | //mTimerTime = 0; | 530 | //mTimerTime = 0; |
531 | startAlarm( mess.mid( 11 ), filename ); | 531 | startAlarm( mess.mid( 11 ), filename ); |
532 | return; | 532 | return; |
533 | } | 533 | } |
534 | if ( mess.left( 10 ) == "proc_alarm") { | 534 | if ( mess.left( 10 ) == "proc_alarm") { |
535 | bool error = false; | 535 | bool error = false; |
536 | int len = mess.mid( 10 ).find("+++"); | 536 | int len = mess.mid( 10 ).find("+++"); |
537 | if ( len < 2 ) | 537 | if ( len < 2 ) |
538 | error = true; | 538 | error = true; |
539 | else { | 539 | else { |
540 | tempfilename = mess.mid( 10, len ); | 540 | tempfilename = mess.mid( 10, len ); |
541 | if ( !QFile::exists( tempfilename ) ) | 541 | if ( !QFile::exists( tempfilename ) ) |
542 | error = true; | 542 | error = true; |
543 | } | 543 | } |
544 | if ( error ) { | 544 | if ( error ) { |
545 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 545 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
546 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 546 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
547 | } else { | 547 | } else { |
548 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 548 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
549 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 549 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
550 | #ifndef _WIN32_ | 550 | #ifndef _WIN32_ |
551 | if ( vfork () == 0 ) { | 551 | if ( vfork () == 0 ) { |
552 | execl ( tempfilename.latin1(), 0 ); | 552 | execl ( tempfilename.latin1(), 0 ); |
553 | return; | 553 | return; |
554 | } | 554 | } |
555 | #else | 555 | #else |
556 | QProcess* p = new QProcess(); | 556 | QProcess* p = new QProcess(); |
557 | p->addArgument( tempfilename.latin1() ); | 557 | p->addArgument( tempfilename.latin1() ); |
558 | p->start(); | 558 | p->start(); |
559 | return; | 559 | return; |
560 | #endif | 560 | #endif |
561 | 561 | ||
562 | return; | 562 | return; |
563 | } | 563 | } |
564 | 564 | ||
565 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 565 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
566 | } | 566 | } |
567 | if ( mess.left( 11 ) == "audio_alarm") { | 567 | if ( mess.left( 11 ) == "audio_alarm") { |
568 | bool error = false; | 568 | bool error = false; |
569 | int len = mess.mid( 11 ).find("+++"); | 569 | int len = mess.mid( 11 ).find("+++"); |
570 | if ( len < 2 ) | 570 | if ( len < 2 ) |
571 | error = true; | 571 | error = true; |
572 | else { | 572 | else { |
573 | tempfilename = mess.mid( 11, len ); | 573 | tempfilename = mess.mid( 11, len ); |
574 | if ( !QFile::exists( tempfilename ) ) | 574 | if ( !QFile::exists( tempfilename ) ) |
575 | error = true; | 575 | error = true; |
576 | } | 576 | } |
577 | if ( ! error ) { | 577 | if ( ! error ) { |
578 | filename = tempfilename; | 578 | filename = tempfilename; |
579 | } | 579 | } |
580 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 580 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
581 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 581 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
582 | } | 582 | } |
583 | if ( mess.left( 9 ) == "cal_alarm") { | 583 | if ( mess.left( 9 ) == "cal_alarm") { |
584 | mAlarmMessage = mess.mid( 9 ) ; | 584 | mAlarmMessage = mess.mid( 9 ) ; |
585 | } | 585 | } |
586 | 586 | ||
587 | startAlarm( mAlarmMessage, filename ); | 587 | startAlarm( mAlarmMessage, filename ); |
588 | 588 | ||
589 | 589 | ||
590 | } | 590 | } |
591 | 591 | ||
592 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 592 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
593 | { | 593 | { |
594 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 594 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
595 | 595 | ||
596 | mSuspendAlarmNotification = noti; | 596 | mSuspendAlarmNotification = noti; |
597 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 597 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
598 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 598 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
599 | mSuspendTimer->start( ms , true ); | 599 | mSuspendTimer->start( ms , true ); |
600 | 600 | ||
601 | } | 601 | } |
602 | 602 | ||
603 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 603 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
604 | { | 604 | { |
605 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 605 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
606 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 606 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
607 | #ifndef DESKTOP_VERSION | 607 | #ifndef DESKTOP_VERSION |
608 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 608 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
609 | #endif | 609 | #endif |
610 | return; | 610 | return; |
611 | } | 611 | } |
612 | int maxSec; | 612 | int maxSec; |
613 | //maxSec = 5; //testing only | 613 | //maxSec = 5; //testing only |
614 | maxSec = 86400+3600; // one day+1hour | 614 | maxSec = 86400+3600; // one day+1hour |
615 | mAlarmNotification = noti; | 615 | mAlarmNotification = noti; |
616 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 616 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
617 | if ( sec > maxSec ) { | 617 | if ( sec > maxSec ) { |
618 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 618 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
619 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 619 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
620 | return; | 620 | return; |
621 | } else { | 621 | } else { |
622 | mRecheckAlarmTimer->stop(); | 622 | mRecheckAlarmTimer->stop(); |
623 | } | 623 | } |
624 | //qDebug("Alarm timer started with secs: %d ", sec); | 624 | //qDebug("Alarm timer started with secs: %d ", sec); |
625 | mAlarmTimer->start( sec *1000 , true ); | 625 | mAlarmTimer->start( sec *1000 , true ); |
626 | 626 | ||
627 | } | 627 | } |
628 | // called by mRecheckAlarmTimer to get next alarm | 628 | // called by mRecheckAlarmTimer to get next alarm |
629 | // we need this, because a QTimer has only a max range of 25 days | 629 | // we need this, because a QTimer has only a max range of 25 days |
630 | void CalendarView::recheckTimerAlarm() | 630 | void CalendarView::recheckTimerAlarm() |
631 | { | 631 | { |
632 | mAlarmTimer->stop(); | 632 | mAlarmTimer->stop(); |
633 | mRecheckAlarmTimer->stop(); | 633 | mRecheckAlarmTimer->stop(); |
634 | mCalendar->checkAlarmForIncidence( 0, true ); | 634 | mCalendar->checkAlarmForIncidence( 0, true ); |
635 | } | 635 | } |
636 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 636 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
637 | { | 637 | { |
638 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 638 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
639 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 639 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
640 | #ifndef DESKTOP_VERSION | 640 | #ifndef DESKTOP_VERSION |
641 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 641 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
642 | #endif | 642 | #endif |
643 | return; | 643 | return; |
644 | } | 644 | } |
645 | mAlarmTimer->stop(); | 645 | mAlarmTimer->stop(); |
646 | } | 646 | } |
647 | void CalendarView::selectWeekNum ( int num ) | 647 | void CalendarView::selectWeekNum ( int num ) |
648 | { | 648 | { |
649 | dateNavigator()->selectWeek( num ); | 649 | dateNavigator()->selectWeek( num ); |
650 | mViewManager->showWeekView(); | 650 | mViewManager->showWeekView(); |
651 | } | 651 | } |
652 | KOViewManager *CalendarView::viewManager() | 652 | KOViewManager *CalendarView::viewManager() |
653 | { | 653 | { |
654 | return mViewManager; | 654 | return mViewManager; |
655 | } | 655 | } |
656 | 656 | ||
657 | KODialogManager *CalendarView::dialogManager() | 657 | KODialogManager *CalendarView::dialogManager() |
658 | { | 658 | { |
659 | return mDialogManager; | 659 | return mDialogManager; |
660 | } | 660 | } |
661 | 661 | ||
662 | QDate CalendarView::startDate() | 662 | QDate CalendarView::startDate() |
663 | { | 663 | { |
664 | DateList dates = mNavigator->selectedDates(); | 664 | DateList dates = mNavigator->selectedDates(); |
665 | 665 | ||
666 | return dates.first(); | 666 | return dates.first(); |
667 | } | 667 | } |
668 | 668 | ||
669 | QDate CalendarView::endDate() | 669 | QDate CalendarView::endDate() |
670 | { | 670 | { |
671 | DateList dates = mNavigator->selectedDates(); | 671 | DateList dates = mNavigator->selectedDates(); |
672 | 672 | ||
673 | return dates.last(); | 673 | return dates.last(); |
674 | } | 674 | } |
675 | 675 | ||
676 | 676 | ||
677 | void CalendarView::createPrinter() | 677 | void CalendarView::createPrinter() |
678 | { | 678 | { |
679 | #ifndef KORG_NOPRINTER | 679 | #ifndef KORG_NOPRINTER |
680 | if (!mCalPrinter) { | 680 | if (!mCalPrinter) { |
681 | mCalPrinter = new CalPrinter(this, mCalendar); | 681 | mCalPrinter = new CalPrinter(this, mCalendar); |
682 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 682 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
683 | } | 683 | } |
684 | #endif | 684 | #endif |
685 | } | 685 | } |
686 | 686 | ||
687 | void CalendarView::confSync() | 687 | void CalendarView::confSync() |
688 | { | 688 | { |
689 | static KSyncPrefsDialog* sp = 0; | 689 | static KSyncPrefsDialog* sp = 0; |
690 | if ( ! sp ) { | 690 | if ( ! sp ) { |
691 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); | 691 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); |
692 | } | 692 | } |
693 | sp->usrReadConfig(); | 693 | sp->usrReadConfig(); |
694 | #ifndef DESKTOP_VERSION | 694 | #ifndef DESKTOP_VERSION |
695 | sp->showMaximized(); | 695 | sp->showMaximized(); |
696 | #else | 696 | #else |
697 | sp->show(); | 697 | sp->show(); |
698 | #endif | 698 | #endif |
699 | sp->exec(); | 699 | sp->exec(); |
700 | KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); | 700 | KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); |
701 | KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); | 701 | KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); |
702 | } | 702 | } |
703 | 703 | ||
704 | 704 | ||
705 | //KOPrefs::instance()->mWriteBackFile | 705 | //KOPrefs::instance()->mWriteBackFile |
706 | //KOPrefs::instance()->mWriteBackExistingOnly | 706 | //KOPrefs::instance()->mWriteBackExistingOnly |
707 | 707 | ||
708 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 708 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
709 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 709 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
710 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 710 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
711 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 711 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
712 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 712 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
713 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 713 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
714 | 714 | ||
715 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 715 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
716 | { | 716 | { |
717 | 717 | ||
718 | //void setZaurusId(int id); | 718 | //void setZaurusId(int id); |
719 | // int zaurusId() const; | 719 | // int zaurusId() const; |
720 | // void setZaurusUid(int id); | 720 | // void setZaurusUid(int id); |
721 | // int zaurusUid() const; | 721 | // int zaurusUid() const; |
722 | // void setZaurusStat(int id); | 722 | // void setZaurusStat(int id); |
723 | // int zaurusStat() const; | 723 | // int zaurusStat() const; |
724 | // 0 equal | 724 | // 0 equal |
725 | // 1 take local | 725 | // 1 take local |
726 | // 2 take remote | 726 | // 2 take remote |
727 | // 3 cancel | 727 | // 3 cancel |
728 | QDateTime lastSync = mLastCalendarSync; | 728 | QDateTime lastSync = mLastCalendarSync; |
729 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 729 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
730 | bool remCh, locCh; | 730 | bool remCh, locCh; |
731 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 731 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
732 | if ( remCh ) | 732 | if ( remCh ) |
733 | qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 733 | qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
734 | locCh = ( local->lastModified() > mLastCalendarSync ); | 734 | locCh = ( local->lastModified() > mLastCalendarSync ); |
735 | //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); | 735 | //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); |
736 | if ( !remCh && ! locCh ) { | 736 | if ( !remCh && ! locCh ) { |
737 | qDebug("both not changed "); | 737 | qDebug("both not changed "); |
738 | lastSync = local->lastModified().addDays(1); | 738 | lastSync = local->lastModified().addDays(1); |
739 | } else { | 739 | } else { |
740 | if ( locCh ) { | 740 | if ( locCh ) { |
741 | qDebug("loc changed %d", local->revision() ); | 741 | qDebug("loc changed %d", local->revision() ); |
742 | lastSync = local->lastModified().addDays( -1 ); | 742 | lastSync = local->lastModified().addDays( -1 ); |
743 | if ( !remCh ) | 743 | if ( !remCh ) |
744 | remote->setLastModified( lastSync.addDays( -1 ) ); | 744 | remote->setLastModified( lastSync.addDays( -1 ) ); |
745 | } else { | 745 | } else { |
746 | qDebug(" not loc changed "); | 746 | qDebug(" not loc changed "); |
747 | lastSync = local->lastModified().addDays( 1 ); | 747 | lastSync = local->lastModified().addDays( 1 ); |
748 | if ( remCh ) | 748 | if ( remCh ) |
749 | remote->setLastModified( lastSync.addDays( 1 ) ); | 749 | remote->setLastModified( lastSync.addDays( 1 ) ); |
750 | 750 | ||
751 | } | 751 | } |
752 | } | 752 | } |
753 | full = true; | 753 | full = true; |
754 | if ( mode < SYNC_PREF_ASK ) | 754 | if ( mode < SYNC_PREF_ASK ) |
755 | mode = SYNC_PREF_ASK; | 755 | mode = SYNC_PREF_ASK; |
756 | } else { | 756 | } else { |
757 | if ( local->lastModified() == remote->lastModified() ) | 757 | if ( local->lastModified() == remote->lastModified() ) |
758 | if ( local->revision() == remote->revision() ) | 758 | if ( local->revision() == remote->revision() ) |
759 | return 0; | 759 | return 0; |
760 | 760 | ||
761 | } | 761 | } |
762 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 762 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
763 | 763 | ||
764 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); | 764 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); |
765 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 765 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
766 | //full = true; //debug only | 766 | //full = true; //debug only |
767 | if ( full ) { | 767 | if ( full ) { |
768 | bool equ = false; | 768 | bool equ = false; |
769 | if ( local->type() == "Event" ) { | 769 | if ( local->type() == "Event" ) { |
770 | equ = (*((Event*) local) == *((Event*) remote)); | 770 | equ = (*((Event*) local) == *((Event*) remote)); |
771 | } | 771 | } |
772 | else if ( local->type() =="Todo" ) | 772 | else if ( local->type() =="Todo" ) |
773 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 773 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
774 | else if ( local->type() =="Journal" ) | 774 | else if ( local->type() =="Journal" ) |
775 | equ = (*((Journal*) local) == *((Journal*) remote)); | 775 | equ = (*((Journal*) local) == *((Journal*) remote)); |
776 | if ( equ ) { | 776 | if ( equ ) { |
777 | //qDebug("equal "); | 777 | //qDebug("equal "); |
778 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 778 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
779 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 779 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
780 | } | 780 | } |
781 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 781 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
782 | return 0; | 782 | return 0; |
783 | 783 | ||
784 | }//else //debug only | 784 | }//else //debug only |
785 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 785 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
786 | } | 786 | } |
787 | int result; | 787 | int result; |
788 | bool localIsNew; | 788 | bool localIsNew; |
789 | qDebug("mLastCalendarSync %s lastsync %s --- local %s remote %s ",mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); | 789 | qDebug("mLastCalendarSync %s lastsync %s --- local %s remote %s ",mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); |
790 | 790 | ||
791 | if ( full && mode < SYNC_PREF_NEWEST ) | 791 | if ( full && mode < SYNC_PREF_NEWEST ) |
792 | mode = SYNC_PREF_ASK; | 792 | mode = SYNC_PREF_ASK; |
793 | 793 | ||
794 | switch( mode ) { | 794 | switch( mode ) { |
795 | case SYNC_PREF_LOCAL: | 795 | case SYNC_PREF_LOCAL: |
796 | if ( lastSync > remote->lastModified() ) | 796 | if ( lastSync > remote->lastModified() ) |
797 | return 1; | 797 | return 1; |
798 | if ( lastSync > local->lastModified() ) | 798 | if ( lastSync > local->lastModified() ) |
799 | return 2; | 799 | return 2; |
800 | return 1; | 800 | return 1; |
801 | break; | 801 | break; |
802 | case SYNC_PREF_REMOTE: | 802 | case SYNC_PREF_REMOTE: |
803 | if ( lastSync > remote->lastModified() ) | 803 | if ( lastSync > remote->lastModified() ) |
804 | return 1; | 804 | return 1; |
805 | if ( lastSync > local->lastModified() ) | 805 | if ( lastSync > local->lastModified() ) |
806 | return 2; | 806 | return 2; |
807 | return 2; | 807 | return 2; |
808 | break; | 808 | break; |
809 | case SYNC_PREF_NEWEST: | 809 | case SYNC_PREF_NEWEST: |
810 | if ( local->lastModified() > remote->lastModified() ) | 810 | if ( local->lastModified() > remote->lastModified() ) |
811 | return 1; | 811 | return 1; |
812 | else | 812 | else |
813 | return 2; | 813 | return 2; |
814 | break; | 814 | break; |
815 | case SYNC_PREF_ASK: | 815 | case SYNC_PREF_ASK: |
816 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); | 816 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); |
817 | if ( lastSync > remote->lastModified() ) | 817 | if ( lastSync > remote->lastModified() ) |
818 | return 1; | 818 | return 1; |
819 | if ( lastSync > local->lastModified() ) | 819 | if ( lastSync > local->lastModified() ) |
820 | return 2; | 820 | return 2; |
821 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); | 821 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); |
822 | localIsNew = local->lastModified() >= remote->lastModified(); | 822 | localIsNew = local->lastModified() >= remote->lastModified(); |
823 | if ( localIsNew ) | 823 | if ( localIsNew ) |
824 | getEventViewerDialog()->setColorMode( 1 ); | 824 | getEventViewerDialog()->setColorMode( 1 ); |
825 | else | 825 | else |
826 | getEventViewerDialog()->setColorMode( 2 ); | 826 | getEventViewerDialog()->setColorMode( 2 ); |
827 | getEventViewerDialog()->setIncidence(local); | 827 | getEventViewerDialog()->setIncidence(local); |
828 | if ( localIsNew ) | 828 | if ( localIsNew ) |
829 | getEventViewerDialog()->setColorMode( 2 ); | 829 | getEventViewerDialog()->setColorMode( 2 ); |
830 | else | 830 | else |
831 | getEventViewerDialog()->setColorMode( 1 ); | 831 | getEventViewerDialog()->setColorMode( 1 ); |
832 | getEventViewerDialog()->addIncidence(remote); | 832 | getEventViewerDialog()->addIncidence(remote); |
833 | getEventViewerDialog()->setColorMode( 0 ); | 833 | getEventViewerDialog()->setColorMode( 0 ); |
834 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 834 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
835 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 835 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
836 | getEventViewerDialog()->showMe(); | 836 | getEventViewerDialog()->showMe(); |
837 | result = getEventViewerDialog()->executeS( localIsNew ); | 837 | result = getEventViewerDialog()->executeS( localIsNew ); |
838 | return result; | 838 | return result; |
839 | 839 | ||
840 | break; | 840 | break; |
841 | case SYNC_PREF_FORCE_LOCAL: | 841 | case SYNC_PREF_FORCE_LOCAL: |
842 | return 1; | 842 | return 1; |
843 | break; | 843 | break; |
844 | case SYNC_PREF_FORCE_REMOTE: | 844 | case SYNC_PREF_FORCE_REMOTE: |
845 | return 2; | 845 | return 2; |
846 | break; | 846 | break; |
847 | 847 | ||
848 | default: | 848 | default: |
849 | // SYNC_PREF_TAKE_BOTH not implemented | 849 | // SYNC_PREF_TAKE_BOTH not implemented |
850 | break; | 850 | break; |
851 | } | 851 | } |
852 | return 0; | 852 | return 0; |
853 | } | 853 | } |
854 | Event* CalendarView::getLastSyncEvent() | 854 | Event* CalendarView::getLastSyncEvent() |
855 | { | 855 | { |
856 | Event* lse; | 856 | Event* lse; |
857 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 857 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
858 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 858 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
859 | if (!lse) { | 859 | if (!lse) { |
860 | lse = new Event(); | 860 | lse = new Event(); |
861 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 861 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
862 | QString sum = ""; | 862 | QString sum = ""; |
863 | if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 863 | if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
864 | sum = "E: "; | 864 | sum = "E: "; |
865 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 865 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
866 | lse->setDtStart( mLastCalendarSync ); | 866 | lse->setDtStart( mLastCalendarSync ); |
867 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 867 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
868 | lse->setCategories( i18n("SyncEvent") ); | 868 | lse->setCategories( i18n("SyncEvent") ); |
869 | lse->setReadOnly( true ); | 869 | lse->setReadOnly( true ); |
870 | mCalendar->addEvent( lse ); | 870 | mCalendar->addEvent( lse ); |
871 | } | 871 | } |
872 | 872 | ||
873 | return lse; | 873 | return lse; |
874 | 874 | ||
875 | } | 875 | } |
876 | // probaly useless | 876 | // probaly useless |
877 | void CalendarView::setupExternSyncProfiles() | 877 | void CalendarView::setupExternSyncProfiles() |
878 | { | 878 | { |
879 | Event* lse; | 879 | Event* lse; |
880 | mExternLastSyncEvent.clear(); | 880 | mExternLastSyncEvent.clear(); |
881 | int i; | 881 | int i; |
882 | for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) { | 882 | for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) { |
883 | lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] ); | 883 | lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] ); |
884 | if ( lse ) | 884 | if ( lse ) |
885 | mExternLastSyncEvent.append( lse ); | 885 | mExternLastSyncEvent.append( lse ); |
886 | else | 886 | else |
887 | qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1()); | 887 | qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1()); |
888 | } | 888 | } |
889 | 889 | ||
890 | } | 890 | } |
891 | // we check, if the to delete event has a id for a profile | 891 | // we check, if the to delete event has a id for a profile |
892 | // if yes, we set this id in the profile to delete | 892 | // if yes, we set this id in the profile to delete |
893 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 893 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
894 | { | 894 | { |
895 | if ( lastSync.count() == 0 ) { | 895 | if ( lastSync.count() == 0 ) { |
896 | //qDebug(" lastSync.count() == 0"); | 896 | //qDebug(" lastSync.count() == 0"); |
897 | return; | 897 | return; |
898 | } | 898 | } |
899 | if ( toDelete->type() == "Journal" ) | 899 | if ( toDelete->type() == "Journal" ) |
900 | return; | 900 | return; |
901 | 901 | ||
902 | Event* eve = lastSync.first(); | 902 | Event* eve = lastSync.first(); |
903 | 903 | ||
904 | while ( eve ) { | 904 | while ( eve ) { |
905 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 905 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
906 | if ( !id.isEmpty() ) { | 906 | if ( !id.isEmpty() ) { |
907 | QString des = eve->description(); | 907 | QString des = eve->description(); |
908 | QString pref = "e"; | 908 | QString pref = "e"; |
909 | if ( toDelete->type() == "Todo" ) | 909 | if ( toDelete->type() == "Todo" ) |
910 | pref = "t"; | 910 | pref = "t"; |
911 | des += pref+ id + ","; | 911 | des += pref+ id + ","; |
912 | eve->setReadOnly( false ); | 912 | eve->setReadOnly( false ); |
913 | eve->setDescription( des ); | 913 | eve->setDescription( des ); |
914 | //qDebug("setdes %s ", des.latin1()); | 914 | //qDebug("setdes %s ", des.latin1()); |
915 | eve->setReadOnly( true ); | 915 | eve->setReadOnly( true ); |
916 | } | 916 | } |
917 | eve = lastSync.next(); | 917 | eve = lastSync.next(); |
918 | } | 918 | } |
919 | 919 | ||
920 | } | 920 | } |
921 | void CalendarView::checkExternalId( Incidence * inc ) | 921 | void CalendarView::checkExternalId( Incidence * inc ) |
922 | { | 922 | { |
923 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 923 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
924 | checkExternSyncEvent( lastSync, inc ); | 924 | checkExternSyncEvent( lastSync, inc ); |
925 | 925 | ||
926 | } | 926 | } |
927 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 927 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
928 | { | 928 | { |
929 | bool syncOK = true; | 929 | bool syncOK = true; |
930 | int addedEvent = 0; | 930 | int addedEvent = 0; |
931 | int addedEventR = 0; | 931 | int addedEventR = 0; |
932 | int deletedEventR = 0; | 932 | int deletedEventR = 0; |
933 | int deletedEventL = 0; | 933 | int deletedEventL = 0; |
934 | int changedLocal = 0; | 934 | int changedLocal = 0; |
935 | int changedRemote = 0; | 935 | int changedRemote = 0; |
936 | //QPtrList<Event> el = local->rawEvents(); | 936 | //QPtrList<Event> el = local->rawEvents(); |
937 | Event* eventR; | 937 | Event* eventR; |
938 | QString uid; | 938 | QString uid; |
939 | int take; | 939 | int take; |
940 | Event* eventL; | 940 | Event* eventL; |
941 | Event* eventRSync; | 941 | Event* eventRSync; |
942 | Event* eventLSync; | 942 | Event* eventLSync; |
943 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 943 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
944 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 944 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
945 | bool fullDateRange = false; | 945 | bool fullDateRange = false; |
946 | local->resetTempSyncStat(); | 946 | local->resetTempSyncStat(); |
947 | mLastCalendarSync = QDateTime::currentDateTime(); | 947 | mLastCalendarSync = QDateTime::currentDateTime(); |
948 | QDateTime modifiedCalendar = mLastCalendarSync;; | 948 | QDateTime modifiedCalendar = mLastCalendarSync;; |
949 | eventLSync = getLastSyncEvent(); | 949 | eventLSync = getLastSyncEvent(); |
950 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 950 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
951 | if ( eventR ) { | 951 | if ( eventR ) { |
952 | eventRSync = (Event*) eventR->clone(); | 952 | eventRSync = (Event*) eventR->clone(); |
953 | remote->deleteEvent(eventR ); | 953 | remote->deleteEvent(eventR ); |
954 | 954 | ||
955 | } else { | 955 | } else { |
956 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 956 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
957 | eventRSync = (Event*)eventLSync->clone(); | 957 | eventRSync = (Event*)eventLSync->clone(); |
958 | } else { | 958 | } else { |
959 | fullDateRange = true; | 959 | fullDateRange = true; |
960 | eventRSync = new Event(); | 960 | eventRSync = new Event(); |
961 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 961 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
962 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 962 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
963 | eventRSync->setDtStart( mLastCalendarSync ); | 963 | eventRSync->setDtStart( mLastCalendarSync ); |
964 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 964 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
965 | eventRSync->setCategories( i18n("SyncEvent") ); | 965 | eventRSync->setCategories( i18n("SyncEvent") ); |
966 | } | 966 | } |
967 | } | 967 | } |
968 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 968 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
969 | fullDateRange = true; | 969 | fullDateRange = true; |
970 | 970 | ||
971 | if ( ! fullDateRange ) { | 971 | if ( ! fullDateRange ) { |
972 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 972 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
973 | 973 | ||
974 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 974 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
975 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 975 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
976 | fullDateRange = true; | 976 | fullDateRange = true; |
977 | } | 977 | } |
978 | } | 978 | } |
979 | if ( fullDateRange ) | 979 | if ( fullDateRange ) |
980 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 980 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
981 | else | 981 | else |
982 | mLastCalendarSync = eventLSync->dtStart(); | 982 | mLastCalendarSync = eventLSync->dtStart(); |
983 | // for resyncing if own file has changed | 983 | // for resyncing if own file has changed |
984 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 984 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
985 | mLastCalendarSync = loadedFileVersion; | 985 | mLastCalendarSync = loadedFileVersion; |
986 | qDebug("setting mLastCalendarSync "); | 986 | qDebug("setting mLastCalendarSync "); |
987 | } | 987 | } |
988 | //qDebug("*************************** "); | 988 | //qDebug("*************************** "); |
989 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); | 989 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); |
990 | QPtrList<Incidence> er = remote->rawIncidences(); | 990 | QPtrList<Incidence> er = remote->rawIncidences(); |
991 | Incidence* inR = er.first(); | 991 | Incidence* inR = er.first(); |
992 | Incidence* inL; | 992 | Incidence* inL; |
993 | QProgressBar bar( er.count(),0 ); | 993 | QProgressBar bar( er.count(),0 ); |
994 | bar.setCaption (i18n("Syncing - close to abort!") ); | 994 | bar.setCaption (i18n("Syncing - close to abort!") ); |
995 | 995 | ||
996 | int w = 300; | 996 | int w = 300; |
997 | if ( QApplication::desktop()->width() < 320 ) | 997 | if ( QApplication::desktop()->width() < 320 ) |
998 | w = 220; | 998 | w = 220; |
999 | int h = bar.sizeHint().height() ; | 999 | int h = bar.sizeHint().height() ; |
1000 | int dw = QApplication::desktop()->width(); | 1000 | int dw = QApplication::desktop()->width(); |
1001 | int dh = QApplication::desktop()->height(); | 1001 | int dh = QApplication::desktop()->height(); |
1002 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1002 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1003 | bar.show(); | 1003 | bar.show(); |
1004 | int modulo = (er.count()/10)+1; | 1004 | int modulo = (er.count()/10)+1; |
1005 | int incCounter = 0; | 1005 | int incCounter = 0; |
1006 | while ( inR ) { | 1006 | while ( inR ) { |
1007 | if ( ! bar.isVisible() ) | 1007 | if ( ! bar.isVisible() ) |
1008 | return false; | 1008 | return false; |
1009 | if ( incCounter % modulo == 0 ) | 1009 | if ( incCounter % modulo == 0 ) |
1010 | bar.setProgress( incCounter ); | 1010 | bar.setProgress( incCounter ); |
1011 | ++incCounter; | 1011 | ++incCounter; |
1012 | uid = inR->uid(); | 1012 | uid = inR->uid(); |
1013 | bool skipIncidence = false; | 1013 | bool skipIncidence = false; |
1014 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1014 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1015 | skipIncidence = true; | 1015 | skipIncidence = true; |
1016 | 1016 | ||
1017 | qApp->processEvents(); | 1017 | qApp->processEvents(); |
1018 | if ( !skipIncidence ) { | 1018 | if ( !skipIncidence ) { |
1019 | inL = local->incidence( uid ); | 1019 | inL = local->incidence( uid ); |
1020 | if ( inL ) { // maybe conflict - same uid in both calendars | 1020 | if ( inL ) { // maybe conflict - same uid in both calendars |
1021 | int maxrev = inL->revision(); | 1021 | int maxrev = inL->revision(); |
1022 | if ( maxrev < inR->revision() ) | 1022 | if ( maxrev < inR->revision() ) |
1023 | maxrev = inR->revision(); | 1023 | maxrev = inR->revision(); |
1024 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1024 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1025 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1025 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1026 | if ( take == 3 ) | 1026 | if ( take == 3 ) |
1027 | return false; | 1027 | return false; |
1028 | if ( take == 1 ) {// take local | 1028 | if ( take == 1 ) {// take local |
1029 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1029 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1030 | remote->deleteIncidence( inR ); | 1030 | remote->deleteIncidence( inR ); |
1031 | if ( inL->revision() < maxrev ) | 1031 | if ( inL->revision() < maxrev ) |
1032 | inL->setRevision( maxrev ); | 1032 | inL->setRevision( maxrev ); |
1033 | remote->addIncidence( inL->clone() ); | 1033 | remote->addIncidence( inL->clone() ); |
1034 | ++changedRemote; | 1034 | ++changedRemote; |
1035 | } else { | 1035 | } else { |
1036 | if ( inR->revision() < maxrev ) | 1036 | if ( inR->revision() < maxrev ) |
1037 | inR->setRevision( maxrev ); | 1037 | inR->setRevision( maxrev ); |
1038 | local->deleteIncidence( inL ); | 1038 | local->deleteIncidence( inL ); |
1039 | local->addIncidence( inR->clone() ); | 1039 | local->addIncidence( inR->clone() ); |
1040 | ++changedLocal; | 1040 | ++changedLocal; |
1041 | } | 1041 | } |
1042 | } | 1042 | } |
1043 | } else { // no conflict | 1043 | } else { // no conflict |
1044 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1044 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1045 | QString des = eventLSync->description(); | 1045 | QString des = eventLSync->description(); |
1046 | QString pref = "e"; | 1046 | QString pref = "e"; |
1047 | if ( inR->type() == "Todo" ) | 1047 | if ( inR->type() == "Todo" ) |
1048 | pref = "t"; | 1048 | pref = "t"; |
1049 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1049 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1050 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1050 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1051 | //remote->deleteIncidence( inR ); | 1051 | //remote->deleteIncidence( inR ); |
1052 | ++deletedEventR; | 1052 | ++deletedEventR; |
1053 | } else { | 1053 | } else { |
1054 | inR->setLastModified( modifiedCalendar ); | 1054 | inR->setLastModified( modifiedCalendar ); |
1055 | local->addIncidence( inR->clone() ); | 1055 | local->addIncidence( inR->clone() ); |
1056 | ++addedEvent; | 1056 | ++addedEvent; |
1057 | } | 1057 | } |
1058 | } else { | 1058 | } else { |
1059 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1059 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1060 | inR->setLastModified( modifiedCalendar ); | 1060 | inR->setLastModified( modifiedCalendar ); |
1061 | local->addIncidence( inR->clone() ); | 1061 | local->addIncidence( inR->clone() ); |
1062 | ++addedEvent; | 1062 | ++addedEvent; |
1063 | } else { | 1063 | } else { |
1064 | checkExternSyncEvent(eventRSyncSharp, inR); | 1064 | checkExternSyncEvent(eventRSyncSharp, inR); |
1065 | remote->deleteIncidence( inR ); | 1065 | remote->deleteIncidence( inR ); |
1066 | ++deletedEventR; | 1066 | ++deletedEventR; |
1067 | } | 1067 | } |
1068 | } | 1068 | } |
1069 | } | 1069 | } |
1070 | } | 1070 | } |
1071 | inR = er.next(); | 1071 | inR = er.next(); |
1072 | } | 1072 | } |
1073 | QPtrList<Incidence> el = local->rawIncidences(); | 1073 | QPtrList<Incidence> el = local->rawIncidences(); |
1074 | inL = el.first(); | 1074 | inL = el.first(); |
1075 | modulo = (el.count()/10)+1; | 1075 | modulo = (el.count()/10)+1; |
1076 | bar.setCaption (i18n("Add / remove events") ); | 1076 | bar.setCaption (i18n("Add / remove events") ); |
1077 | bar.setTotalSteps ( el.count() ) ; | 1077 | bar.setTotalSteps ( el.count() ) ; |
1078 | bar.show(); | 1078 | bar.show(); |
1079 | incCounter = 0; | 1079 | incCounter = 0; |
1080 | 1080 | ||
1081 | while ( inL ) { | 1081 | while ( inL ) { |
1082 | 1082 | ||
1083 | qApp->processEvents(); | 1083 | qApp->processEvents(); |
1084 | if ( ! bar.isVisible() ) | 1084 | if ( ! bar.isVisible() ) |
1085 | return false; | 1085 | return false; |
1086 | if ( incCounter % modulo == 0 ) | 1086 | if ( incCounter % modulo == 0 ) |
1087 | bar.setProgress( incCounter ); | 1087 | bar.setProgress( incCounter ); |
1088 | ++incCounter; | 1088 | ++incCounter; |
1089 | uid = inL->uid(); | 1089 | uid = inL->uid(); |
1090 | bool skipIncidence = false; | 1090 | bool skipIncidence = false; |
1091 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1091 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1092 | skipIncidence = true; | 1092 | skipIncidence = true; |
1093 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1093 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1094 | skipIncidence = true; | 1094 | skipIncidence = true; |
1095 | if ( !skipIncidence ) { | 1095 | if ( !skipIncidence ) { |
1096 | inR = remote->incidence( uid ); | 1096 | inR = remote->incidence( uid ); |
1097 | if ( ! inR ) { | 1097 | if ( ! inR ) { |
1098 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1098 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1099 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1099 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1100 | local->deleteIncidence( inL ); | 1100 | local->deleteIncidence( inL ); |
1101 | ++deletedEventL; | 1101 | ++deletedEventL; |
1102 | } else { | 1102 | } else { |
1103 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1103 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
1104 | inL->removeID(mCurrentSyncDevice ); | 1104 | inL->removeID(mCurrentSyncDevice ); |
1105 | ++addedEventR; | 1105 | ++addedEventR; |
1106 | inL->setLastModified( modifiedCalendar ); | 1106 | inL->setLastModified( modifiedCalendar ); |
1107 | remote->addIncidence( inL->clone() ); | 1107 | remote->addIncidence( inL->clone() ); |
1108 | } | 1108 | } |
1109 | } | 1109 | } |
1110 | } else { | 1110 | } else { |
1111 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1111 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1112 | checkExternSyncEvent(eventLSyncSharp, inL); | 1112 | checkExternSyncEvent(eventLSyncSharp, inL); |
1113 | local->deleteIncidence( inL ); | 1113 | local->deleteIncidence( inL ); |
1114 | ++deletedEventL; | 1114 | ++deletedEventL; |
1115 | } else { | 1115 | } else { |
1116 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1116 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
1117 | ++addedEventR; | 1117 | ++addedEventR; |
1118 | inL->setLastModified( modifiedCalendar ); | 1118 | inL->setLastModified( modifiedCalendar ); |
1119 | remote->addIncidence( inL->clone() ); | 1119 | remote->addIncidence( inL->clone() ); |
1120 | } | 1120 | } |
1121 | } | 1121 | } |
1122 | } | 1122 | } |
1123 | } | 1123 | } |
1124 | } | 1124 | } |
1125 | inL = el.next(); | 1125 | inL = el.next(); |
1126 | } | 1126 | } |
1127 | int delFut = 0; | 1127 | int delFut = 0; |
1128 | if ( KOPrefs::instance()->mWriteBackInFuture ) { | 1128 | if ( KOPrefs::instance()->mWriteBackInFuture ) { |
1129 | er = remote->rawIncidences(); | 1129 | er = remote->rawIncidences(); |
1130 | inR = er.first(); | 1130 | inR = er.first(); |
1131 | QDateTime dt; | 1131 | QDateTime dt; |
1132 | QDateTime cur = QDateTime::currentDateTime(); | 1132 | QDateTime cur = QDateTime::currentDateTime(); |
1133 | QDateTime end = cur.addSecs( KOPrefs::instance()->mWriteBackInFuture * 3600 *24 *7 ); | 1133 | QDateTime end = cur.addSecs( KOPrefs::instance()->mWriteBackInFuture * 3600 *24 *7 ); |
1134 | while ( inR ) { | 1134 | while ( inR ) { |
1135 | if ( inR->type() == "Todo" ) { | 1135 | if ( inR->type() == "Todo" ) { |
1136 | Todo * t = (Todo*)inR; | 1136 | Todo * t = (Todo*)inR; |
1137 | if ( t->hasDueDate() ) | 1137 | if ( t->hasDueDate() ) |
1138 | dt = t->dtDue(); | 1138 | dt = t->dtDue(); |
1139 | else | 1139 | else |
1140 | dt = cur.addSecs( 62 ); | 1140 | dt = cur.addSecs( 62 ); |
1141 | } | 1141 | } |
1142 | else if (inR->type() == "Event" ) { | 1142 | else if (inR->type() == "Event" ) { |
1143 | bool ok; | 1143 | bool ok; |
1144 | dt = inR->getNextOccurence( cur, &ok ); | 1144 | dt = inR->getNextOccurence( cur, &ok ); |
1145 | if ( !ok ) | 1145 | if ( !ok ) |
1146 | dt = cur.addSecs( -62 ); | 1146 | dt = cur.addSecs( -62 ); |
1147 | } | 1147 | } |
1148 | else | 1148 | else |
1149 | dt = inR->dtStart(); | 1149 | dt = inR->dtStart(); |
1150 | if ( dt < cur || dt > end ) { | 1150 | if ( dt < cur || dt > end ) { |
1151 | remote->deleteIncidence( inR ); | 1151 | remote->deleteIncidence( inR ); |
1152 | ++delFut; | 1152 | ++delFut; |
1153 | } | 1153 | } |
1154 | inR = er.next(); | 1154 | inR = er.next(); |
1155 | } | 1155 | } |
1156 | } | 1156 | } |
1157 | bar.hide(); | 1157 | bar.hide(); |
1158 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1158 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1159 | eventLSync->setReadOnly( false ); | 1159 | eventLSync->setReadOnly( false ); |
1160 | eventLSync->setDtStart( mLastCalendarSync ); | 1160 | eventLSync->setDtStart( mLastCalendarSync ); |
1161 | eventRSync->setDtStart( mLastCalendarSync ); | 1161 | eventRSync->setDtStart( mLastCalendarSync ); |
1162 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1162 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1163 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1163 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1164 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1164 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1165 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1165 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1166 | eventLSync->setReadOnly( true ); | 1166 | eventLSync->setReadOnly( true ); |
1167 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 1167 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
1168 | remote->addEvent( eventRSync ); | 1168 | remote->addEvent( eventRSync ); |
1169 | QString mes; | 1169 | QString mes; |
1170 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); | 1170 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); |
1171 | QString delmess; | 1171 | QString delmess; |
1172 | if ( delFut ) { | 1172 | if ( delFut ) { |
1173 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture ); | 1173 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture ); |
1174 | mes += delmess; | 1174 | mes += delmess; |
1175 | } | 1175 | } |
1176 | if ( KOPrefs::instance()->mShowSyncSummary ) { | 1176 | if ( KOPrefs::instance()->mShowSyncSummary ) { |
1177 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); | 1177 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); |
1178 | } | 1178 | } |
1179 | qDebug( mes ); | 1179 | qDebug( mes ); |
1180 | mCalendar->checkAlarmForIncidence( 0, true ); | 1180 | mCalendar->checkAlarmForIncidence( 0, true ); |
1181 | return syncOK; | 1181 | return syncOK; |
1182 | } | 1182 | } |
1183 | 1183 | ||
1184 | void CalendarView::setSyncDevice( QString s ) | 1184 | void CalendarView::setSyncDevice( QString s ) |
1185 | { | 1185 | { |
1186 | mCurrentSyncDevice= s; | 1186 | mCurrentSyncDevice= s; |
1187 | } | 1187 | } |
1188 | void CalendarView::setSyncName( QString s ) | 1188 | void CalendarView::setSyncName( QString s ) |
1189 | { | 1189 | { |
1190 | mCurrentSyncName= s; | 1190 | mCurrentSyncName= s; |
1191 | } | 1191 | } |
1192 | bool CalendarView::syncCalendar(QString filename, int mode) | 1192 | bool CalendarView::syncCalendar(QString filename, int mode) |
1193 | { | 1193 | { |
1194 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1194 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1195 | CalendarLocal* calendar = new CalendarLocal(); | 1195 | CalendarLocal* calendar = new CalendarLocal(); |
1196 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1196 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1197 | FileStorage* storage = new FileStorage( calendar ); | 1197 | FileStorage* storage = new FileStorage( calendar ); |
1198 | bool syncOK = false; | 1198 | bool syncOK = false; |
1199 | storage->setFileName( filename ); | 1199 | storage->setFileName( filename ); |
1200 | // qDebug("loading ... "); | 1200 | // qDebug("loading ... "); |
1201 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | 1201 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { |
1202 | getEventViewerDialog()->setSyncMode( true ); | 1202 | getEventViewerDialog()->setSyncMode( true ); |
1203 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1203 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1204 | getEventViewerDialog()->setSyncMode( false ); | 1204 | getEventViewerDialog()->setSyncMode( false ); |
1205 | if ( syncOK ) { | 1205 | if ( syncOK ) { |
1206 | if ( KOPrefs::instance()->mWriteBackFile ) | 1206 | if ( KOPrefs::instance()->mWriteBackFile ) |
1207 | { | 1207 | { |
1208 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 1208 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
1209 | storage->save(); | 1209 | storage->save(); |
1210 | } | 1210 | } |
1211 | } | 1211 | } |
1212 | setModified( true ); | 1212 | setModified( true ); |
1213 | } | 1213 | } |
1214 | delete storage; | 1214 | delete storage; |
1215 | delete calendar; | 1215 | delete calendar; |
1216 | if ( syncOK ) | 1216 | if ( syncOK ) |
1217 | updateView(); | 1217 | updateView(); |
1218 | return syncOK; | 1218 | return syncOK; |
1219 | } | 1219 | } |
1220 | void CalendarView::syncPhone() | 1220 | void CalendarView::syncPhone() |
1221 | { | 1221 | { |
1222 | syncExternal( 1 ); | 1222 | syncExternal( 1 ); |
1223 | } | 1223 | } |
1224 | void CalendarView::syncExternal( int mode ) | 1224 | void CalendarView::syncExternal( int mode ) |
1225 | { | 1225 | { |
1226 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1226 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1227 | //mCurrentSyncDevice = "sharp-DTM"; | 1227 | //mCurrentSyncDevice = "sharp-DTM"; |
1228 | if ( KOPrefs::instance()->mAskForPreferences ) | 1228 | if ( KOPrefs::instance()->mAskForPreferences ) |
1229 | edit_sync_options(); | 1229 | edit_sync_options(); |
1230 | qApp->processEvents(); | 1230 | qApp->processEvents(); |
1231 | CalendarLocal* calendar = new CalendarLocal(); | 1231 | CalendarLocal* calendar = new CalendarLocal(); |
1232 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1232 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1233 | bool syncOK = false; | 1233 | bool syncOK = false; |
1234 | bool loadSuccess = false; | 1234 | bool loadSuccess = false; |
1235 | PhoneFormat* phoneFormat = 0; | 1235 | PhoneFormat* phoneFormat = 0; |
1236 | #ifndef DESKTOP_VERSION | 1236 | #ifndef DESKTOP_VERSION |
1237 | SharpFormat* sharpFormat = 0; | 1237 | SharpFormat* sharpFormat = 0; |
1238 | if ( mode == 0 ) { // sharp | 1238 | if ( mode == 0 ) { // sharp |
1239 | sharpFormat = new SharpFormat () ; | 1239 | sharpFormat = new SharpFormat () ; |
1240 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1240 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1241 | 1241 | ||
1242 | } else | 1242 | } else |
1243 | #endif | 1243 | #endif |
1244 | if ( mode == 1 ) { // phone | 1244 | if ( mode == 1 ) { // phone |
1245 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1245 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1246 | KOPrefs::instance()->mPhoneDevice, | 1246 | KOPrefs::instance()->mPhoneDevice, |
1247 | KOPrefs::instance()->mPhoneConnection, | 1247 | KOPrefs::instance()->mPhoneConnection, |
1248 | KOPrefs::instance()->mPhoneModel); | 1248 | KOPrefs::instance()->mPhoneModel); |
1249 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1249 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1250 | 1250 | ||
1251 | } else | 1251 | } else |
1252 | return; | 1252 | return; |
1253 | if ( loadSuccess ) { | 1253 | if ( loadSuccess ) { |
1254 | getEventViewerDialog()->setSyncMode( true ); | 1254 | getEventViewerDialog()->setSyncMode( true ); |
1255 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); | 1255 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); |
1256 | getEventViewerDialog()->setSyncMode( false ); | 1256 | getEventViewerDialog()->setSyncMode( false ); |
1257 | qApp->processEvents(); | 1257 | qApp->processEvents(); |
1258 | if ( syncOK ) { | 1258 | if ( syncOK ) { |
1259 | if ( KOPrefs::instance()->mWriteBackFile ) | 1259 | if ( KOPrefs::instance()->mWriteBackFile ) |
1260 | { | 1260 | { |
1261 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1261 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1262 | Incidence* inc = iL.first(); | 1262 | Incidence* inc = iL.first(); |
1263 | while ( inc ) { | 1263 | if ( phoneFormat ) { |
1264 | inc->removeID(mCurrentSyncDevice); | 1264 | while ( inc ) { |
1265 | inc = iL.next(); | 1265 | inc->removeID(mCurrentSyncDevice); |
1266 | inc = iL.next(); | ||
1267 | } | ||
1266 | } | 1268 | } |
1267 | #ifndef DESKTOP_VERSION | 1269 | #ifndef DESKTOP_VERSION |
1268 | if ( sharpFormat ) | 1270 | if ( sharpFormat ) |
1269 | sharpFormat->save(calendar); | 1271 | sharpFormat->save(calendar); |
1270 | #endif | 1272 | #endif |
1271 | if ( phoneFormat ) | 1273 | if ( phoneFormat ) |
1272 | phoneFormat->save(calendar); | 1274 | phoneFormat->save(calendar); |
1273 | iL = calendar->rawIncidences(); | 1275 | iL = calendar->rawIncidences(); |
1274 | inc = iL.first(); | 1276 | inc = iL.first(); |
1275 | Incidence* loc; | 1277 | Incidence* loc; |
1276 | while ( inc ) { | 1278 | while ( inc ) { |
1277 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1279 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1278 | loc = mCalendar->incidence(inc->uid() ); | 1280 | loc = mCalendar->incidence(inc->uid() ); |
1279 | if ( loc ) { | 1281 | if ( loc ) { |
1280 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1282 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1281 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1283 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1282 | } | 1284 | } |
1283 | } | 1285 | } |
1284 | inc = iL.next(); | 1286 | inc = iL.next(); |
1285 | } | 1287 | } |
1286 | Incidence* lse = getLastSyncEvent(); | 1288 | Incidence* lse = getLastSyncEvent(); |
1287 | if ( lse ) { | 1289 | if ( lse ) { |
1288 | lse->setReadOnly( false ); | 1290 | lse->setReadOnly( false ); |
1289 | lse->setDescription( "" ); | 1291 | lse->setDescription( "" ); |
1290 | lse->setReadOnly( true ); | 1292 | lse->setReadOnly( true ); |
1291 | } | 1293 | } |
1292 | } | 1294 | } |
1293 | } | 1295 | } |
1294 | setModified( true ); | 1296 | setModified( true ); |
1295 | } else { | 1297 | } else { |
1296 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1298 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1297 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1299 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1298 | question, i18n("Ok")) ; | 1300 | question, i18n("Ok")) ; |
1299 | 1301 | ||
1300 | } | 1302 | } |
1301 | delete calendar; | 1303 | delete calendar; |
1302 | updateView(); | 1304 | updateView(); |
1303 | return ;//syncOK; | 1305 | return ;//syncOK; |
1304 | 1306 | ||
1305 | } | 1307 | } |
1306 | void CalendarView::syncSharp() | 1308 | void CalendarView::syncSharp() |
1307 | { | 1309 | { |
1308 | syncExternal( 0 ); | 1310 | syncExternal( 0 ); |
1309 | 1311 | ||
1310 | } | 1312 | } |
1311 | 1313 | ||
1312 | 1314 | ||
1313 | #include <kabc/stdaddressbook.h> | 1315 | #include <kabc/stdaddressbook.h> |
1314 | bool CalendarView::importBday() | 1316 | bool CalendarView::importBday() |
1315 | { | 1317 | { |
1316 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1318 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1317 | KABC::AddressBook::Iterator it; | 1319 | KABC::AddressBook::Iterator it; |
1318 | int count = 0; | 1320 | int count = 0; |
1319 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1321 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1320 | ++count; | 1322 | ++count; |
1321 | } | 1323 | } |
1322 | QProgressBar bar(count,0 ); | 1324 | QProgressBar bar(count,0 ); |
1323 | int w = 300; | 1325 | int w = 300; |
1324 | if ( QApplication::desktop()->width() < 320 ) | 1326 | if ( QApplication::desktop()->width() < 320 ) |
1325 | w = 220; | 1327 | w = 220; |
1326 | int h = bar.sizeHint().height() ; | 1328 | int h = bar.sizeHint().height() ; |
1327 | int dw = QApplication::desktop()->width(); | 1329 | int dw = QApplication::desktop()->width(); |
1328 | int dh = QApplication::desktop()->height(); | 1330 | int dh = QApplication::desktop()->height(); |
1329 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1331 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1330 | bar.show(); | 1332 | bar.show(); |
1331 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1333 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1332 | qApp->processEvents(); | 1334 | qApp->processEvents(); |
1333 | count = 0; | 1335 | count = 0; |
1334 | int addCount = 0; | 1336 | int addCount = 0; |
1335 | KCal::Attendee* a = 0; | 1337 | KCal::Attendee* a = 0; |
1336 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1338 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1337 | if ( ! bar.isVisible() ) | 1339 | if ( ! bar.isVisible() ) |
1338 | return false; | 1340 | return false; |
1339 | bar.setProgress( count++ ); | 1341 | bar.setProgress( count++ ); |
1340 | qApp->processEvents(); | 1342 | qApp->processEvents(); |
1341 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1343 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1342 | if ( (*it).birthday().date().isValid() ){ | 1344 | if ( (*it).birthday().date().isValid() ){ |
1343 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1345 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1344 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1346 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1345 | ++addCount; | 1347 | ++addCount; |
1346 | } | 1348 | } |
1347 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1349 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1348 | if ( anni.isValid() ){ | 1350 | if ( anni.isValid() ){ |
1349 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1351 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1350 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1352 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1351 | ++addCount; | 1353 | ++addCount; |
1352 | } | 1354 | } |
1353 | } | 1355 | } |
1354 | updateView(); | 1356 | updateView(); |
1355 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1357 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1356 | return true; | 1358 | return true; |
1357 | } | 1359 | } |
1358 | 1360 | ||
1359 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1361 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1360 | { | 1362 | { |
1361 | //qDebug("addAnni "); | 1363 | //qDebug("addAnni "); |
1362 | Event * ev = new Event(); | 1364 | Event * ev = new Event(); |
1363 | if ( a ) { | 1365 | if ( a ) { |
1364 | ev->addAttendee( a ); | 1366 | ev->addAttendee( a ); |
1365 | } | 1367 | } |
1366 | QString kind; | 1368 | QString kind; |
1367 | if ( birthday ) | 1369 | if ( birthday ) |
1368 | kind = i18n( "Birthday" ); | 1370 | kind = i18n( "Birthday" ); |
1369 | else | 1371 | else |
1370 | kind = i18n( "Anniversary" ); | 1372 | kind = i18n( "Anniversary" ); |
1371 | ev->setSummary( name + " - " + kind ); | 1373 | ev->setSummary( name + " - " + kind ); |
1372 | ev->setOrganizer( "nobody@nowhere" ); | 1374 | ev->setOrganizer( "nobody@nowhere" ); |
1373 | ev->setCategories( kind ); | 1375 | ev->setCategories( kind ); |
1374 | ev->setDtStart( QDateTime(date) ); | 1376 | ev->setDtStart( QDateTime(date) ); |
1375 | ev->setDtEnd( QDateTime(date) ); | 1377 | ev->setDtEnd( QDateTime(date) ); |
1376 | ev->setFloats( true ); | 1378 | ev->setFloats( true ); |
1377 | Recurrence * rec = ev->recurrence(); | 1379 | Recurrence * rec = ev->recurrence(); |
1378 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1380 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1379 | rec->addYearlyNum( date.month() ); | 1381 | rec->addYearlyNum( date.month() ); |
1380 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1382 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1381 | delete ev; | 1383 | delete ev; |
1382 | return false; | 1384 | return false; |
1383 | } | 1385 | } |
1384 | return true; | 1386 | return true; |
1385 | 1387 | ||
1386 | } | 1388 | } |
1387 | bool CalendarView::importQtopia( const QString &categories, | 1389 | bool CalendarView::importQtopia( const QString &categories, |
1388 | const QString &datebook, | 1390 | const QString &datebook, |
1389 | const QString &todolist ) | 1391 | const QString &todolist ) |
1390 | { | 1392 | { |
1391 | 1393 | ||
1392 | QtopiaFormat qtopiaFormat; | 1394 | QtopiaFormat qtopiaFormat; |
1393 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1395 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1394 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1396 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1395 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1397 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1396 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1398 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1397 | 1399 | ||
1398 | updateView(); | 1400 | updateView(); |
1399 | return true; | 1401 | return true; |
1400 | 1402 | ||
1401 | #if 0 | 1403 | #if 0 |
1402 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1404 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1403 | mCurrentSyncDevice = "qtopia-XML"; | 1405 | mCurrentSyncDevice = "qtopia-XML"; |
1404 | if ( KOPrefs::instance()->mAskForPreferences ) | 1406 | if ( KOPrefs::instance()->mAskForPreferences ) |
1405 | edit_sync_options(); | 1407 | edit_sync_options(); |
1406 | qApp->processEvents(); | 1408 | qApp->processEvents(); |
1407 | CalendarLocal* calendar = new CalendarLocal(); | 1409 | CalendarLocal* calendar = new CalendarLocal(); |
1408 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1410 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1409 | bool syncOK = false; | 1411 | bool syncOK = false; |
1410 | QtopiaFormat qtopiaFormat; | 1412 | QtopiaFormat qtopiaFormat; |
1411 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1413 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1412 | bool loadOk = true; | 1414 | bool loadOk = true; |
1413 | if ( !categories.isEmpty() ) | 1415 | if ( !categories.isEmpty() ) |
1414 | loadOk = qtopiaFormat.load( calendar, categories ); | 1416 | loadOk = qtopiaFormat.load( calendar, categories ); |
1415 | if ( loadOk && !datebook.isEmpty() ) | 1417 | if ( loadOk && !datebook.isEmpty() ) |
1416 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1418 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1417 | if ( loadOk && !todolist.isEmpty() ) | 1419 | if ( loadOk && !todolist.isEmpty() ) |
1418 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1420 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1419 | 1421 | ||
1420 | if ( loadOk ) { | 1422 | if ( loadOk ) { |
1421 | getEventViewerDialog()->setSyncMode( true ); | 1423 | getEventViewerDialog()->setSyncMode( true ); |
1422 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); | 1424 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); |
1423 | getEventViewerDialog()->setSyncMode( false ); | 1425 | getEventViewerDialog()->setSyncMode( false ); |
1424 | qApp->processEvents(); | 1426 | qApp->processEvents(); |
1425 | if ( syncOK ) { | 1427 | if ( syncOK ) { |
1426 | if ( KOPrefs::instance()->mWriteBackFile ) | 1428 | if ( KOPrefs::instance()->mWriteBackFile ) |
1427 | { | 1429 | { |
1428 | // write back XML file | 1430 | // write back XML file |
1429 | 1431 | ||
1430 | } | 1432 | } |
1431 | setModified( true ); | 1433 | setModified( true ); |
1432 | } | 1434 | } |
1433 | } else { | 1435 | } else { |
1434 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1436 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1435 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1437 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1436 | question, i18n("Ok")) ; | 1438 | question, i18n("Ok")) ; |
1437 | } | 1439 | } |
1438 | delete calendar; | 1440 | delete calendar; |
1439 | updateView(); | 1441 | updateView(); |
1440 | return syncOK; | 1442 | return syncOK; |
1441 | 1443 | ||
1442 | 1444 | ||
1443 | #endif | 1445 | #endif |
1444 | 1446 | ||
1445 | } | 1447 | } |
1446 | 1448 | ||
1447 | void CalendarView::setSyncEventsReadOnly() | 1449 | void CalendarView::setSyncEventsReadOnly() |
1448 | { | 1450 | { |
1449 | Event * ev; | 1451 | Event * ev; |
1450 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1452 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1451 | ev = eL.first(); | 1453 | ev = eL.first(); |
1452 | while ( ev ) { | 1454 | while ( ev ) { |
1453 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1455 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1454 | ev->setReadOnly( true ); | 1456 | ev->setReadOnly( true ); |
1455 | ev = eL.next(); | 1457 | ev = eL.next(); |
1456 | } | 1458 | } |
1457 | } | 1459 | } |
1458 | bool CalendarView::openCalendar(QString filename, bool merge) | 1460 | bool CalendarView::openCalendar(QString filename, bool merge) |
1459 | { | 1461 | { |
1460 | 1462 | ||
1461 | if (filename.isEmpty()) { | 1463 | if (filename.isEmpty()) { |
1462 | return false; | 1464 | return false; |
1463 | } | 1465 | } |
1464 | 1466 | ||
1465 | if (!QFile::exists(filename)) { | 1467 | if (!QFile::exists(filename)) { |
1466 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1468 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1467 | return false; | 1469 | return false; |
1468 | } | 1470 | } |
1469 | 1471 | ||
1470 | globalFlagBlockAgenda = 1; | 1472 | globalFlagBlockAgenda = 1; |
1471 | if (!merge) mCalendar->close(); | 1473 | if (!merge) mCalendar->close(); |
1472 | 1474 | ||
1473 | mStorage->setFileName( filename ); | 1475 | mStorage->setFileName( filename ); |
1474 | 1476 | ||
1475 | if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) { | 1477 | if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) { |
1476 | if ( merge ) ;//setModified( true ); | 1478 | if ( merge ) ;//setModified( true ); |
1477 | else { | 1479 | else { |
1478 | //setModified( true ); | 1480 | //setModified( true ); |
1479 | mViewManager->setDocumentId( filename ); | 1481 | mViewManager->setDocumentId( filename ); |
1480 | mDialogManager->setDocumentId( filename ); | 1482 | mDialogManager->setDocumentId( filename ); |
1481 | mTodoList->setDocumentId( filename ); | 1483 | mTodoList->setDocumentId( filename ); |
1482 | } | 1484 | } |
1483 | globalFlagBlockAgenda = 2; | 1485 | globalFlagBlockAgenda = 2; |
1484 | // if ( getLastSyncEvent() ) | 1486 | // if ( getLastSyncEvent() ) |
1485 | // getLastSyncEvent()->setReadOnly( true ); | 1487 | // getLastSyncEvent()->setReadOnly( true ); |
1486 | mCalendar->reInitAlarmSettings(); | 1488 | mCalendar->reInitAlarmSettings(); |
1487 | setSyncEventsReadOnly(); | 1489 | setSyncEventsReadOnly(); |
1488 | updateUnmanagedViews(); | 1490 | updateUnmanagedViews(); |
1489 | updateView(); | 1491 | updateView(); |
1490 | if ( filename != MainWindow::defaultFileName() ) | 1492 | if ( filename != MainWindow::defaultFileName() ) |
1491 | saveCalendar( MainWindow::defaultFileName() ); | 1493 | saveCalendar( MainWindow::defaultFileName() ); |
1492 | loadedFileVersion = QDateTime::currentDateTime(); | 1494 | loadedFileVersion = QDateTime::currentDateTime(); |
1493 | return true; | 1495 | return true; |
1494 | } else { | 1496 | } else { |
1495 | // while failing to load, the calendar object could | 1497 | // while failing to load, the calendar object could |
1496 | // have become partially populated. Clear it out. | 1498 | // have become partially populated. Clear it out. |
1497 | if ( !merge ) mCalendar->close(); | 1499 | if ( !merge ) mCalendar->close(); |
1498 | 1500 | ||
1499 | KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1501 | KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1500 | 1502 | ||
1501 | globalFlagBlockAgenda = 2; | 1503 | globalFlagBlockAgenda = 2; |
1502 | updateView(); | 1504 | updateView(); |
1503 | } | 1505 | } |
1504 | return false; | 1506 | return false; |
1505 | } | 1507 | } |
1506 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1508 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1507 | { | 1509 | { |
1508 | loadedFileVersion = dt; | 1510 | loadedFileVersion = dt; |
1509 | } | 1511 | } |
1510 | bool CalendarView::checkFileChanged(QString fn) | 1512 | bool CalendarView::checkFileChanged(QString fn) |
1511 | { | 1513 | { |
1512 | QFileInfo finf ( fn ); | 1514 | QFileInfo finf ( fn ); |
1513 | if ( !finf.exists() ) | 1515 | if ( !finf.exists() ) |
1514 | return true; | 1516 | return true; |
1515 | QDateTime dt = finf.lastModified (); | 1517 | QDateTime dt = finf.lastModified (); |
1516 | if ( dt <= loadedFileVersion ) | 1518 | if ( dt <= loadedFileVersion ) |
1517 | return false; | 1519 | return false; |
1518 | return true; | 1520 | return true; |
1519 | 1521 | ||
1520 | } | 1522 | } |
1521 | bool CalendarView::checkFileVersion(QString fn) | 1523 | bool CalendarView::checkFileVersion(QString fn) |
1522 | { | 1524 | { |
1523 | QFileInfo finf ( fn ); | 1525 | QFileInfo finf ( fn ); |
1524 | if ( !finf.exists() ) | 1526 | if ( !finf.exists() ) |
1525 | return true; | 1527 | return true; |
1526 | QDateTime dt = finf.lastModified (); | 1528 | QDateTime dt = finf.lastModified (); |
1527 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1529 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1528 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1530 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1529 | if ( dt <= loadedFileVersion ) | 1531 | if ( dt <= loadedFileVersion ) |
1530 | return true; | 1532 | return true; |
1531 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, false)) , | 1533 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, false)) , |
1532 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1534 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1533 | i18n("Sync+save")); | 1535 | i18n("Sync+save")); |
1534 | 1536 | ||
1535 | if ( km == KMessageBox::Cancel ) | 1537 | if ( km == KMessageBox::Cancel ) |
1536 | return false; | 1538 | return false; |
1537 | if ( km == KMessageBox::Yes ) | 1539 | if ( km == KMessageBox::Yes ) |
1538 | return true; | 1540 | return true; |
1539 | 1541 | ||
1540 | setSyncDevice("deleteaftersync" ); | 1542 | setSyncDevice("deleteaftersync" ); |
1541 | KOPrefs::instance()->mAskForPreferences = true; | 1543 | KOPrefs::instance()->mAskForPreferences = true; |
1542 | KOPrefs::instance()->mSyncAlgoPrefs = 3; | 1544 | KOPrefs::instance()->mSyncAlgoPrefs = 3; |
1543 | KOPrefs::instance()->mWriteBackFile = false; | 1545 | KOPrefs::instance()->mWriteBackFile = false; |
1544 | KOPrefs::instance()->mWriteBackExistingOnly = false; | 1546 | KOPrefs::instance()->mWriteBackExistingOnly = false; |
1545 | KOPrefs::instance()->mShowSyncSummary = false; | 1547 | KOPrefs::instance()->mShowSyncSummary = false; |
1546 | syncCalendar( fn, 3 ); | 1548 | syncCalendar( fn, 3 ); |
1547 | Event * e = getLastSyncEvent(); | 1549 | Event * e = getLastSyncEvent(); |
1548 | mCalendar->deleteEvent ( e ); | 1550 | mCalendar->deleteEvent ( e ); |
1549 | updateView(); | 1551 | updateView(); |
1550 | return true; | 1552 | return true; |
1551 | } | 1553 | } |
1552 | 1554 | ||
1553 | bool CalendarView::saveCalendar( QString filename ) | 1555 | bool CalendarView::saveCalendar( QString filename ) |
1554 | { | 1556 | { |
1555 | 1557 | ||
1556 | // Store back all unsaved data into calendar object | 1558 | // Store back all unsaved data into calendar object |
1557 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1559 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1558 | if ( mViewManager->currentView() ) | 1560 | if ( mViewManager->currentView() ) |
1559 | mViewManager->currentView()->flushView(); | 1561 | mViewManager->currentView()->flushView(); |
1560 | 1562 | ||
1561 | //mStorage->setFileName( filename ); | 1563 | //mStorage->setFileName( filename ); |
1562 | 1564 | ||
1563 | mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 1565 | mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
1564 | mStorage->setFileName( filename ); | 1566 | mStorage->setFileName( filename ); |
1565 | bool success; | 1567 | bool success; |
1566 | success = mStorage->save(); | 1568 | success = mStorage->save(); |
1567 | if ( !success ) { | 1569 | if ( !success ) { |
1568 | return false; | 1570 | return false; |
1569 | } | 1571 | } |
1570 | 1572 | ||
1571 | return true; | 1573 | return true; |
1572 | } | 1574 | } |
1573 | 1575 | ||
1574 | void CalendarView::closeCalendar() | 1576 | void CalendarView::closeCalendar() |
1575 | { | 1577 | { |
1576 | 1578 | ||
1577 | // child windows no longer valid | 1579 | // child windows no longer valid |
1578 | emit closingDown(); | 1580 | emit closingDown(); |
1579 | 1581 | ||
1580 | mCalendar->close(); | 1582 | mCalendar->close(); |
1581 | setModified(false); | 1583 | setModified(false); |
1582 | updateView(); | 1584 | updateView(); |
1583 | } | 1585 | } |
1584 | 1586 | ||
1585 | void CalendarView::archiveCalendar() | 1587 | void CalendarView::archiveCalendar() |
1586 | { | 1588 | { |
1587 | mDialogManager->showArchiveDialog(); | 1589 | mDialogManager->showArchiveDialog(); |
1588 | } | 1590 | } |
1589 | 1591 | ||
1590 | 1592 | ||
1591 | void CalendarView::readSettings() | 1593 | void CalendarView::readSettings() |
1592 | { | 1594 | { |
1593 | 1595 | ||
1594 | 1596 | ||
1595 | // mViewManager->showAgendaView(); | 1597 | // mViewManager->showAgendaView(); |
1596 | QString str; | 1598 | QString str; |
1597 | //qDebug("CalendarView::readSettings() "); | 1599 | //qDebug("CalendarView::readSettings() "); |
1598 | // read settings from the KConfig, supplying reasonable | 1600 | // read settings from the KConfig, supplying reasonable |
1599 | // defaults where none are to be found | 1601 | // defaults where none are to be found |
1600 | KConfig *config = KOGlobals::config(); | 1602 | KConfig *config = KOGlobals::config(); |
1601 | #ifndef KORG_NOSPLITTER | 1603 | #ifndef KORG_NOSPLITTER |
1602 | config->setGroup("KOrganizer Geometry"); | 1604 | config->setGroup("KOrganizer Geometry"); |
1603 | 1605 | ||
1604 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1606 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1605 | if (sizes.count() != 2) { | 1607 | if (sizes.count() != 2) { |
1606 | sizes << mDateNavigator->minimumSizeHint().width(); | 1608 | sizes << mDateNavigator->minimumSizeHint().width(); |
1607 | sizes << 300; | 1609 | sizes << 300; |
1608 | } | 1610 | } |
1609 | mPanner->setSizes(sizes); | 1611 | mPanner->setSizes(sizes); |
1610 | 1612 | ||
1611 | sizes = config->readIntListEntry("Separator2"); | 1613 | sizes = config->readIntListEntry("Separator2"); |
1612 | if ( ( mResourceView && sizes.count() == 4 ) || | 1614 | if ( ( mResourceView && sizes.count() == 4 ) || |
1613 | ( !mResourceView && sizes.count() == 3 ) ) { | 1615 | ( !mResourceView && sizes.count() == 3 ) ) { |
1614 | mLeftSplitter->setSizes(sizes); | 1616 | mLeftSplitter->setSizes(sizes); |
1615 | } | 1617 | } |
1616 | #endif | 1618 | #endif |
1617 | globalFlagBlockAgenda = 1; | 1619 | globalFlagBlockAgenda = 1; |
1618 | mViewManager->showAgendaView(); | 1620 | mViewManager->showAgendaView(); |
1619 | //mViewManager->readSettings( config ); | 1621 | //mViewManager->readSettings( config ); |
1620 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1622 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1621 | readFilterSettings(config); | 1623 | readFilterSettings(config); |
1622 | config->setGroup( "Views" ); | 1624 | config->setGroup( "Views" ); |
1623 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1625 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1624 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1626 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1625 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1627 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1626 | else mNavigator->selectDates( dateCount ); | 1628 | else mNavigator->selectDates( dateCount ); |
1627 | // mViewManager->readSettings( config ); | 1629 | // mViewManager->readSettings( config ); |
1628 | updateConfig(); | 1630 | updateConfig(); |
1629 | globalFlagBlockAgenda = 2; | 1631 | globalFlagBlockAgenda = 2; |
1630 | mViewManager->readSettings( config ); | 1632 | mViewManager->readSettings( config ); |
1631 | #ifdef DESKTOP_VERSION | 1633 | #ifdef DESKTOP_VERSION |
1632 | config->setGroup("WidgetLayout"); | 1634 | config->setGroup("WidgetLayout"); |
1633 | QStringList list; | 1635 | QStringList list; |
1634 | list = config->readListEntry("MainLayout"); | 1636 | list = config->readListEntry("MainLayout"); |
1635 | int x,y,w,h; | 1637 | int x,y,w,h; |
1636 | if ( ! list.isEmpty() ) { | 1638 | if ( ! list.isEmpty() ) { |
1637 | x = list[0].toInt(); | 1639 | x = list[0].toInt(); |
1638 | y = list[1].toInt(); | 1640 | y = list[1].toInt(); |
1639 | w = list[2].toInt(); | 1641 | w = list[2].toInt(); |
1640 | h = list[3].toInt(); | 1642 | h = list[3].toInt(); |
1641 | topLevelWidget()->setGeometry(x,y,w,h); | 1643 | topLevelWidget()->setGeometry(x,y,w,h); |
1642 | 1644 | ||
1643 | } else { | 1645 | } else { |
1644 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1646 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1645 | } | 1647 | } |
1646 | list = config->readListEntry("EditEventLayout"); | 1648 | list = config->readListEntry("EditEventLayout"); |
1647 | if ( ! list.isEmpty() ) { | 1649 | if ( ! list.isEmpty() ) { |
1648 | x = list[0].toInt(); | 1650 | x = list[0].toInt(); |
1649 | y = list[1].toInt(); | 1651 | y = list[1].toInt(); |
1650 | w = list[2].toInt(); | 1652 | w = list[2].toInt(); |
1651 | h = list[3].toInt(); | 1653 | h = list[3].toInt(); |
1652 | mEventEditor->setGeometry(x,y,w,h); | 1654 | mEventEditor->setGeometry(x,y,w,h); |
1653 | 1655 | ||
1654 | } | 1656 | } |
1655 | list = config->readListEntry("EditTodoLayout"); | 1657 | list = config->readListEntry("EditTodoLayout"); |
1656 | if ( ! list.isEmpty() ) { | 1658 | if ( ! list.isEmpty() ) { |
1657 | x = list[0].toInt(); | 1659 | x = list[0].toInt(); |
1658 | y = list[1].toInt(); | 1660 | y = list[1].toInt(); |
1659 | w = list[2].toInt(); | 1661 | w = list[2].toInt(); |
1660 | h = list[3].toInt(); | 1662 | h = list[3].toInt(); |
1661 | mTodoEditor->setGeometry(x,y,w,h); | 1663 | mTodoEditor->setGeometry(x,y,w,h); |
1662 | 1664 | ||
1663 | } | 1665 | } |
1664 | list = config->readListEntry("ViewerLayout"); | 1666 | list = config->readListEntry("ViewerLayout"); |
1665 | if ( ! list.isEmpty() ) { | 1667 | if ( ! list.isEmpty() ) { |
1666 | x = list[0].toInt(); | 1668 | x = list[0].toInt(); |
1667 | y = list[1].toInt(); | 1669 | y = list[1].toInt(); |
1668 | w = list[2].toInt(); | 1670 | w = list[2].toInt(); |
1669 | h = list[3].toInt(); | 1671 | h = list[3].toInt(); |
1670 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1672 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1671 | } | 1673 | } |
1672 | #endif | 1674 | #endif |
1673 | 1675 | ||
1674 | } | 1676 | } |
1675 | 1677 | ||
1676 | 1678 | ||
1677 | void CalendarView::writeSettings() | 1679 | void CalendarView::writeSettings() |
1678 | { | 1680 | { |
1679 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1681 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1680 | 1682 | ||
1681 | KConfig *config = KOGlobals::config(); | 1683 | KConfig *config = KOGlobals::config(); |
1682 | 1684 | ||
1683 | #ifndef KORG_NOSPLITTER | 1685 | #ifndef KORG_NOSPLITTER |
1684 | config->setGroup("KOrganizer Geometry"); | 1686 | config->setGroup("KOrganizer Geometry"); |
1685 | 1687 | ||
1686 | QValueList<int> list = mPanner->sizes(); | 1688 | QValueList<int> list = mPanner->sizes(); |
1687 | config->writeEntry("Separator1",list); | 1689 | config->writeEntry("Separator1",list); |
1688 | 1690 | ||
1689 | list = mLeftSplitter->sizes(); | 1691 | list = mLeftSplitter->sizes(); |
1690 | config->writeEntry("Separator2",list); | 1692 | config->writeEntry("Separator2",list); |
1691 | #endif | 1693 | #endif |
1692 | 1694 | ||
1693 | mViewManager->writeSettings( config ); | 1695 | mViewManager->writeSettings( config ); |
1694 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1696 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1695 | mDialogManager->writeSettings( config ); | 1697 | mDialogManager->writeSettings( config ); |
1696 | //KOPrefs::instance()->usrWriteConfig(); | 1698 | //KOPrefs::instance()->usrWriteConfig(); |
1697 | KOPrefs::instance()->writeConfig(); | 1699 | KOPrefs::instance()->writeConfig(); |
1698 | 1700 | ||
1699 | writeFilterSettings(config); | 1701 | writeFilterSettings(config); |
1700 | 1702 | ||
1701 | config->setGroup( "Views" ); | 1703 | config->setGroup( "Views" ); |
1702 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1704 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1703 | 1705 | ||
1704 | #ifdef DESKTOP_VERSION | 1706 | #ifdef DESKTOP_VERSION |
1705 | config->setGroup("WidgetLayout"); | 1707 | config->setGroup("WidgetLayout"); |
1706 | QStringList list ;//= config->readListEntry("MainLayout"); | 1708 | QStringList list ;//= config->readListEntry("MainLayout"); |
1707 | int x,y,w,h; | 1709 | int x,y,w,h; |
1708 | QWidget* wid; | 1710 | QWidget* wid; |
1709 | wid = topLevelWidget(); | 1711 | wid = topLevelWidget(); |
1710 | x = wid->geometry().x(); | 1712 | x = wid->geometry().x(); |
1711 | y = wid->geometry().y(); | 1713 | y = wid->geometry().y(); |
1712 | w = wid->width(); | 1714 | w = wid->width(); |
1713 | h = wid->height(); | 1715 | h = wid->height(); |
1714 | list.clear(); | 1716 | list.clear(); |
1715 | list << QString::number( x ); | 1717 | list << QString::number( x ); |
1716 | list << QString::number( y ); | 1718 | list << QString::number( y ); |
1717 | list << QString::number( w ); | 1719 | list << QString::number( w ); |
1718 | list << QString::number( h ); | 1720 | list << QString::number( h ); |
1719 | config->writeEntry("MainLayout",list ); | 1721 | config->writeEntry("MainLayout",list ); |
1720 | 1722 | ||
1721 | wid = mEventEditor; | 1723 | wid = mEventEditor; |
1722 | x = wid->geometry().x(); | 1724 | x = wid->geometry().x(); |
1723 | y = wid->geometry().y(); | 1725 | y = wid->geometry().y(); |
1724 | w = wid->width(); | 1726 | w = wid->width(); |
1725 | h = wid->height(); | 1727 | h = wid->height(); |
1726 | list.clear(); | 1728 | list.clear(); |
1727 | list << QString::number( x ); | 1729 | list << QString::number( x ); |
1728 | list << QString::number( y ); | 1730 | list << QString::number( y ); |
1729 | list << QString::number( w ); | 1731 | list << QString::number( w ); |
1730 | list << QString::number( h ); | 1732 | list << QString::number( h ); |
1731 | config->writeEntry("EditEventLayout",list ); | 1733 | config->writeEntry("EditEventLayout",list ); |
1732 | 1734 | ||
1733 | wid = mTodoEditor; | 1735 | wid = mTodoEditor; |
1734 | x = wid->geometry().x(); | 1736 | x = wid->geometry().x(); |
1735 | y = wid->geometry().y(); | 1737 | y = wid->geometry().y(); |
1736 | w = wid->width(); | 1738 | w = wid->width(); |
1737 | h = wid->height(); | 1739 | h = wid->height(); |
1738 | list.clear(); | 1740 | list.clear(); |
1739 | list << QString::number( x ); | 1741 | list << QString::number( x ); |
1740 | list << QString::number( y ); | 1742 | list << QString::number( y ); |
1741 | list << QString::number( w ); | 1743 | list << QString::number( w ); |
1742 | list << QString::number( h ); | 1744 | list << QString::number( h ); |
1743 | config->writeEntry("EditTodoLayout",list ); | 1745 | config->writeEntry("EditTodoLayout",list ); |
1744 | wid = getEventViewerDialog(); | 1746 | wid = getEventViewerDialog(); |
1745 | x = wid->geometry().x(); | 1747 | x = wid->geometry().x(); |
1746 | y = wid->geometry().y(); | 1748 | y = wid->geometry().y(); |
1747 | w = wid->width(); | 1749 | w = wid->width(); |
1748 | h = wid->height(); | 1750 | h = wid->height(); |
1749 | list.clear(); | 1751 | list.clear(); |
1750 | list << QString::number( x ); | 1752 | list << QString::number( x ); |
1751 | list << QString::number( y ); | 1753 | list << QString::number( y ); |
1752 | list << QString::number( w ); | 1754 | list << QString::number( w ); |
1753 | list << QString::number( h ); | 1755 | list << QString::number( h ); |
1754 | config->writeEntry("ViewerLayout",list ); | 1756 | config->writeEntry("ViewerLayout",list ); |
1755 | wid = mDialogManager->getSearchDialog(); | 1757 | wid = mDialogManager->getSearchDialog(); |
1756 | if ( wid ) { | 1758 | if ( wid ) { |
1757 | x = wid->geometry().x(); | 1759 | x = wid->geometry().x(); |
1758 | y = wid->geometry().y(); | 1760 | y = wid->geometry().y(); |
1759 | w = wid->width(); | 1761 | w = wid->width(); |
1760 | h = wid->height(); | 1762 | h = wid->height(); |
1761 | list.clear(); | 1763 | list.clear(); |
1762 | list << QString::number( x ); | 1764 | list << QString::number( x ); |
1763 | list << QString::number( y ); | 1765 | list << QString::number( y ); |
1764 | list << QString::number( w ); | 1766 | list << QString::number( w ); |
1765 | list << QString::number( h ); | 1767 | list << QString::number( h ); |
1766 | config->writeEntry("SearchLayout",list ); | 1768 | config->writeEntry("SearchLayout",list ); |
1767 | } | 1769 | } |
1768 | #endif | 1770 | #endif |
1769 | 1771 | ||
1770 | 1772 | ||
1771 | config->sync(); | 1773 | config->sync(); |
1772 | } | 1774 | } |
1773 | 1775 | ||
1774 | void CalendarView::readFilterSettings(KConfig *config) | 1776 | void CalendarView::readFilterSettings(KConfig *config) |
1775 | { | 1777 | { |
1776 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1778 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1777 | 1779 | ||
1778 | mFilters.clear(); | 1780 | mFilters.clear(); |
1779 | 1781 | ||
1780 | config->setGroup("General"); | 1782 | config->setGroup("General"); |
1781 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1783 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1782 | 1784 | ||
1783 | QStringList::ConstIterator it = filterList.begin(); | 1785 | QStringList::ConstIterator it = filterList.begin(); |
1784 | QStringList::ConstIterator end = filterList.end(); | 1786 | QStringList::ConstIterator end = filterList.end(); |
1785 | while(it != end) { | 1787 | while(it != end) { |
1786 | // kdDebug() << " filter: " << (*it) << endl; | 1788 | // kdDebug() << " filter: " << (*it) << endl; |
1787 | 1789 | ||
1788 | CalFilter *filter; | 1790 | CalFilter *filter; |
1789 | filter = new CalFilter(*it); | 1791 | filter = new CalFilter(*it); |
1790 | config->setGroup("Filter_" + (*it)); | 1792 | config->setGroup("Filter_" + (*it)); |
1791 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1793 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1792 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1794 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1793 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1795 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1794 | mFilters.append(filter); | 1796 | mFilters.append(filter); |
1795 | 1797 | ||
1796 | ++it; | 1798 | ++it; |
1797 | } | 1799 | } |
1798 | 1800 | ||
1799 | if (mFilters.count() == 0) { | 1801 | if (mFilters.count() == 0) { |
1800 | CalFilter *filter = new CalFilter(i18n("Default")); | 1802 | CalFilter *filter = new CalFilter(i18n("Default")); |
1801 | mFilters.append(filter); | 1803 | mFilters.append(filter); |
1802 | } | 1804 | } |
1803 | mFilterView->updateFilters(); | 1805 | mFilterView->updateFilters(); |
1804 | config->setGroup("FilterView"); | 1806 | config->setGroup("FilterView"); |
1805 | 1807 | ||
1806 | mFilterView->blockSignals(true); | 1808 | mFilterView->blockSignals(true); |
1807 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 1809 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
1808 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 1810 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
1809 | mFilterView->blockSignals(false); | 1811 | mFilterView->blockSignals(false); |
1810 | // We do it manually to avoid it being done twice by the above calls | 1812 | // We do it manually to avoid it being done twice by the above calls |
1811 | updateFilter(); | 1813 | updateFilter(); |
1812 | } | 1814 | } |
1813 | 1815 | ||
1814 | void CalendarView::writeFilterSettings(KConfig *config) | 1816 | void CalendarView::writeFilterSettings(KConfig *config) |
1815 | { | 1817 | { |
1816 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 1818 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
1817 | 1819 | ||
1818 | QStringList filterList; | 1820 | QStringList filterList; |
1819 | 1821 | ||
1820 | CalFilter *filter = mFilters.first(); | 1822 | CalFilter *filter = mFilters.first(); |
1821 | while(filter) { | 1823 | while(filter) { |
1822 | // kdDebug() << " fn: " << filter->name() << endl; | 1824 | // kdDebug() << " fn: " << filter->name() << endl; |
1823 | filterList << filter->name(); | 1825 | filterList << filter->name(); |
1824 | config->setGroup("Filter_" + filter->name()); | 1826 | config->setGroup("Filter_" + filter->name()); |
1825 | config->writeEntry("Criteria",filter->criteria()); | 1827 | config->writeEntry("Criteria",filter->criteria()); |
1826 | config->writeEntry("CategoryList",filter->categoryList()); | 1828 | config->writeEntry("CategoryList",filter->categoryList()); |
1827 | filter = mFilters.next(); | 1829 | filter = mFilters.next(); |
1828 | } | 1830 | } |
1829 | config->setGroup("General"); | 1831 | config->setGroup("General"); |
1830 | config->writeEntry("CalendarFilters",filterList); | 1832 | config->writeEntry("CalendarFilters",filterList); |
1831 | 1833 | ||
1832 | config->setGroup("FilterView"); | 1834 | config->setGroup("FilterView"); |
1833 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 1835 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
1834 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 1836 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
1835 | } | 1837 | } |
1836 | 1838 | ||
1837 | 1839 | ||
1838 | void CalendarView::goToday() | 1840 | void CalendarView::goToday() |
1839 | { | 1841 | { |
1840 | mNavigator->selectToday(); | 1842 | mNavigator->selectToday(); |
1841 | } | 1843 | } |
1842 | 1844 | ||
1843 | void CalendarView::goNext() | 1845 | void CalendarView::goNext() |
1844 | { | 1846 | { |
1845 | mNavigator->selectNext(); | 1847 | mNavigator->selectNext(); |
1846 | } | 1848 | } |
1847 | 1849 | ||
1848 | void CalendarView::goPrevious() | 1850 | void CalendarView::goPrevious() |
1849 | { | 1851 | { |
1850 | mNavigator->selectPrevious(); | 1852 | mNavigator->selectPrevious(); |
1851 | } | 1853 | } |
1852 | void CalendarView::goNextMonth() | 1854 | void CalendarView::goNextMonth() |
1853 | { | 1855 | { |
1854 | mNavigator->selectNextMonth(); | 1856 | mNavigator->selectNextMonth(); |
1855 | } | 1857 | } |
1856 | 1858 | ||
1857 | void CalendarView::goPreviousMonth() | 1859 | void CalendarView::goPreviousMonth() |
1858 | { | 1860 | { |
1859 | mNavigator->selectPreviousMonth(); | 1861 | mNavigator->selectPreviousMonth(); |
1860 | } | 1862 | } |
1861 | void CalendarView::writeLocale() | 1863 | void CalendarView::writeLocale() |
1862 | { | 1864 | { |
1863 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 1865 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
1864 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 1866 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
1865 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 1867 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
1866 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 1868 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
1867 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 1869 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
1868 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 1870 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
1869 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 1871 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
1870 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 1872 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
1871 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 1873 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
1872 | KOPrefs::instance()->mDaylightsavingStart, | 1874 | KOPrefs::instance()->mDaylightsavingStart, |
1873 | KOPrefs::instance()->mDaylightsavingEnd ); | 1875 | KOPrefs::instance()->mDaylightsavingEnd ); |
1874 | KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); | 1876 | KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); |
1875 | } | 1877 | } |
1876 | void CalendarView::updateConfig() | 1878 | void CalendarView::updateConfig() |
1877 | { | 1879 | { |
1878 | writeLocale(); | 1880 | writeLocale(); |
1879 | if ( KOPrefs::instance()->mUseAppColors ) | 1881 | if ( KOPrefs::instance()->mUseAppColors ) |
1880 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 1882 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
1881 | emit configChanged(); | 1883 | emit configChanged(); |
1882 | mTodoList->updateConfig(); | 1884 | mTodoList->updateConfig(); |
1883 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 1885 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
1884 | mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1886 | mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1885 | // To make the "fill window" configurations work | 1887 | // To make the "fill window" configurations work |
1886 | //mViewManager->raiseCurrentView(); | 1888 | //mViewManager->raiseCurrentView(); |
1887 | } | 1889 | } |
1888 | 1890 | ||
1889 | 1891 | ||
1890 | void CalendarView::eventChanged(Event *event) | 1892 | void CalendarView::eventChanged(Event *event) |
1891 | { | 1893 | { |
1892 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 1894 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
1893 | //updateUnmanagedViews(); | 1895 | //updateUnmanagedViews(); |
1894 | } | 1896 | } |
1895 | 1897 | ||
1896 | void CalendarView::eventAdded(Event *event) | 1898 | void CalendarView::eventAdded(Event *event) |
1897 | { | 1899 | { |
1898 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 1900 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
1899 | } | 1901 | } |
1900 | 1902 | ||
1901 | void CalendarView::eventToBeDeleted(Event *) | 1903 | void CalendarView::eventToBeDeleted(Event *) |
1902 | { | 1904 | { |
1903 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 1905 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
1904 | } | 1906 | } |
1905 | 1907 | ||
1906 | void CalendarView::eventDeleted() | 1908 | void CalendarView::eventDeleted() |
1907 | { | 1909 | { |
1908 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 1910 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
1909 | } | 1911 | } |
1910 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 1912 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
1911 | { | 1913 | { |
1912 | changeIncidenceDisplay((Incidence *)which, action); | 1914 | changeIncidenceDisplay((Incidence *)which, action); |
1913 | mDateNavigator->updateView(); | 1915 | mDateNavigator->updateView(); |
1914 | //mDialogManager->updateSearchDialog(); | 1916 | //mDialogManager->updateSearchDialog(); |
1915 | 1917 | ||
1916 | if (which) { | 1918 | if (which) { |
1917 | mViewManager->currentView()->updateView(); | 1919 | mViewManager->currentView()->updateView(); |
1918 | //mTodoList->updateView(); | 1920 | //mTodoList->updateView(); |
1919 | } | 1921 | } |
1920 | 1922 | ||
1921 | } | 1923 | } |
1922 | 1924 | ||
1923 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 1925 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
1924 | { | 1926 | { |
1925 | updateUnmanagedViews(); | 1927 | updateUnmanagedViews(); |
1926 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 1928 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
1927 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 1929 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
1928 | mCalendar->checkAlarmForIncidence( 0, true ); | 1930 | mCalendar->checkAlarmForIncidence( 0, true ); |
1929 | if ( mEventViewerDialog ) | 1931 | if ( mEventViewerDialog ) |
1930 | mEventViewerDialog->hide(); | 1932 | mEventViewerDialog->hide(); |
1931 | } | 1933 | } |
1932 | else | 1934 | else |
1933 | mCalendar->checkAlarmForIncidence( which , false ); | 1935 | mCalendar->checkAlarmForIncidence( which , false ); |
1934 | } | 1936 | } |
1935 | 1937 | ||
1936 | // most of the changeEventDisplays() right now just call the view's | 1938 | // most of the changeEventDisplays() right now just call the view's |
1937 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 1939 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
1938 | void CalendarView::changeEventDisplay(Event *which, int action) | 1940 | void CalendarView::changeEventDisplay(Event *which, int action) |
1939 | { | 1941 | { |
1940 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 1942 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
1941 | changeIncidenceDisplay((Incidence *)which, action); | 1943 | changeIncidenceDisplay((Incidence *)which, action); |
1942 | mDateNavigator->updateView(); | 1944 | mDateNavigator->updateView(); |
1943 | //mDialogManager->updateSearchDialog(); | 1945 | //mDialogManager->updateSearchDialog(); |
1944 | 1946 | ||
1945 | if (which) { | 1947 | if (which) { |
1946 | // If there is an event view visible update the display | 1948 | // If there is an event view visible update the display |
1947 | mViewManager->currentView()->changeEventDisplay(which,action); | 1949 | mViewManager->currentView()->changeEventDisplay(which,action); |
1948 | // TODO: check, if update needed | 1950 | // TODO: check, if update needed |
1949 | // if (which->getTodoStatus()) { | 1951 | // if (which->getTodoStatus()) { |
1950 | mTodoList->updateView(); | 1952 | mTodoList->updateView(); |
1951 | // } | 1953 | // } |
1952 | } else { | 1954 | } else { |
1953 | mViewManager->currentView()->updateView(); | 1955 | mViewManager->currentView()->updateView(); |
1954 | } | 1956 | } |
1955 | } | 1957 | } |
1956 | 1958 | ||
1957 | 1959 | ||
1958 | void CalendarView::updateTodoViews() | 1960 | void CalendarView::updateTodoViews() |
1959 | { | 1961 | { |
1960 | 1962 | ||
1961 | mTodoList->updateView(); | 1963 | mTodoList->updateView(); |
1962 | mViewManager->currentView()->updateView(); | 1964 | mViewManager->currentView()->updateView(); |
1963 | 1965 | ||
1964 | } | 1966 | } |
1965 | 1967 | ||
1966 | 1968 | ||
1967 | void CalendarView::updateView(const QDate &start, const QDate &end) | 1969 | void CalendarView::updateView(const QDate &start, const QDate &end) |
1968 | { | 1970 | { |
1969 | mTodoList->updateView(); | 1971 | mTodoList->updateView(); |
1970 | mViewManager->updateView(start, end); | 1972 | mViewManager->updateView(start, end); |
1971 | //mDateNavigator->updateView(); | 1973 | //mDateNavigator->updateView(); |
1972 | } | 1974 | } |
1973 | 1975 | ||
1974 | void CalendarView::updateView() | 1976 | void CalendarView::updateView() |
1975 | { | 1977 | { |
1976 | DateList tmpList = mNavigator->selectedDates(); | 1978 | DateList tmpList = mNavigator->selectedDates(); |
1977 | 1979 | ||
1978 | // We assume that the navigator only selects consecutive days. | 1980 | // We assume that the navigator only selects consecutive days. |
1979 | updateView( tmpList.first(), tmpList.last() ); | 1981 | updateView( tmpList.first(), tmpList.last() ); |
1980 | } | 1982 | } |
1981 | 1983 | ||
1982 | void CalendarView::updateUnmanagedViews() | 1984 | void CalendarView::updateUnmanagedViews() |
1983 | { | 1985 | { |
1984 | mDateNavigator->updateDayMatrix(); | 1986 | mDateNavigator->updateDayMatrix(); |
1985 | } | 1987 | } |
1986 | 1988 | ||
1987 | int CalendarView::msgItemDelete() | 1989 | int CalendarView::msgItemDelete() |
1988 | { | 1990 | { |
1989 | return KMessageBox::warningContinueCancel(this, | 1991 | return KMessageBox::warningContinueCancel(this, |
1990 | i18n("This item will be\npermanently deleted."), | 1992 | i18n("This item will be\npermanently deleted."), |
1991 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 1993 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
1992 | } | 1994 | } |
1993 | 1995 | ||
1994 | 1996 | ||
1995 | void CalendarView::edit_cut() | 1997 | void CalendarView::edit_cut() |
1996 | { | 1998 | { |
1997 | Event *anEvent=0; | 1999 | Event *anEvent=0; |
1998 | 2000 | ||
1999 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2001 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2000 | 2002 | ||
2001 | if (mViewManager->currentView()->isEventView()) { | 2003 | if (mViewManager->currentView()->isEventView()) { |
2002 | if ( incidence && incidence->type() == "Event" ) { | 2004 | if ( incidence && incidence->type() == "Event" ) { |
2003 | anEvent = static_cast<Event *>(incidence); | 2005 | anEvent = static_cast<Event *>(incidence); |
2004 | } | 2006 | } |
2005 | } | 2007 | } |
2006 | 2008 | ||
2007 | if (!anEvent) { | 2009 | if (!anEvent) { |
2008 | KNotifyClient::beep(); | 2010 | KNotifyClient::beep(); |
2009 | return; | 2011 | return; |
2010 | } | 2012 | } |
2011 | DndFactory factory( mCalendar ); | 2013 | DndFactory factory( mCalendar ); |
2012 | factory.cutEvent(anEvent); | 2014 | factory.cutEvent(anEvent); |
2013 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2015 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2014 | } | 2016 | } |
2015 | 2017 | ||
2016 | void CalendarView::edit_copy() | 2018 | void CalendarView::edit_copy() |
2017 | { | 2019 | { |
2018 | Event *anEvent=0; | 2020 | Event *anEvent=0; |
2019 | 2021 | ||
2020 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2022 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2021 | 2023 | ||
2022 | if (mViewManager->currentView()->isEventView()) { | 2024 | if (mViewManager->currentView()->isEventView()) { |
2023 | if ( incidence && incidence->type() == "Event" ) { | 2025 | if ( incidence && incidence->type() == "Event" ) { |
2024 | anEvent = static_cast<Event *>(incidence); | 2026 | anEvent = static_cast<Event *>(incidence); |
2025 | } | 2027 | } |
2026 | } | 2028 | } |
2027 | 2029 | ||
2028 | if (!anEvent) { | 2030 | if (!anEvent) { |
2029 | KNotifyClient::beep(); | 2031 | KNotifyClient::beep(); |
2030 | return; | 2032 | return; |
2031 | } | 2033 | } |
2032 | DndFactory factory( mCalendar ); | 2034 | DndFactory factory( mCalendar ); |
2033 | factory.copyEvent(anEvent); | 2035 | factory.copyEvent(anEvent); |
2034 | } | 2036 | } |
2035 | 2037 | ||
2036 | void CalendarView::edit_paste() | 2038 | void CalendarView::edit_paste() |
2037 | { | 2039 | { |
2038 | QDate date = mNavigator->selectedDates().first(); | 2040 | QDate date = mNavigator->selectedDates().first(); |
2039 | 2041 | ||
2040 | DndFactory factory( mCalendar ); | 2042 | DndFactory factory( mCalendar ); |
2041 | Event *pastedEvent = factory.pasteEvent( date ); | 2043 | Event *pastedEvent = factory.pasteEvent( date ); |
2042 | 2044 | ||
2043 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2045 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2044 | } | 2046 | } |
2045 | 2047 | ||
2046 | void CalendarView::edit_options() | 2048 | void CalendarView::edit_options() |
2047 | { | 2049 | { |
2048 | mDialogManager->showOptionsDialog(); | 2050 | mDialogManager->showOptionsDialog(); |
2049 | //writeSettings(); | 2051 | //writeSettings(); |
2050 | } | 2052 | } |
2051 | void CalendarView::edit_sync_options() | 2053 | void CalendarView::edit_sync_options() |
2052 | { | 2054 | { |
2053 | //mDialogManager->showSyncOptions(); | 2055 | //mDialogManager->showSyncOptions(); |
2054 | //KOPrefs::instance()->mSyncAlgoPrefs | 2056 | //KOPrefs::instance()->mSyncAlgoPrefs |
2055 | QDialog dia( this, "dia", true ); | 2057 | QDialog dia( this, "dia", true ); |
2056 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 2058 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
2057 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 2059 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
2058 | QVBoxLayout lay ( &dia ); | 2060 | QVBoxLayout lay ( &dia ); |
2059 | lay.setSpacing( 2 ); | 2061 | lay.setSpacing( 2 ); |
2060 | lay.setMargin( 3 ); | 2062 | lay.setMargin( 3 ); |
2061 | lay.addWidget(&gr); | 2063 | lay.addWidget(&gr); |
2062 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 2064 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
2063 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 2065 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
2064 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 2066 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
2065 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 2067 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
2066 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 2068 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
2067 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 2069 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
2068 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 2070 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
2069 | QPushButton pb ( "OK", &dia); | 2071 | QPushButton pb ( "OK", &dia); |
2070 | lay.addWidget( &pb ); | 2072 | lay.addWidget( &pb ); |
2071 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2073 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2072 | switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { | 2074 | switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { |
2073 | case 0: | 2075 | case 0: |
2074 | loc.setChecked( true); | 2076 | loc.setChecked( true); |
2075 | break; | 2077 | break; |
2076 | case 1: | 2078 | case 1: |
2077 | rem.setChecked( true ); | 2079 | rem.setChecked( true ); |
2078 | break; | 2080 | break; |
2079 | case 2: | 2081 | case 2: |
2080 | newest.setChecked( true); | 2082 | newest.setChecked( true); |
2081 | break; | 2083 | break; |
2082 | case 3: | 2084 | case 3: |
2083 | ask.setChecked( true); | 2085 | ask.setChecked( true); |
2084 | break; | 2086 | break; |
2085 | case 4: | 2087 | case 4: |
2086 | f_loc.setChecked( true); | 2088 | f_loc.setChecked( true); |
2087 | break; | 2089 | break; |
2088 | case 5: | 2090 | case 5: |
2089 | f_rem.setChecked( true); | 2091 | f_rem.setChecked( true); |
2090 | break; | 2092 | break; |
2091 | case 6: | 2093 | case 6: |
2092 | // both.setChecked( true); | 2094 | // both.setChecked( true); |
2093 | break; | 2095 | break; |
2094 | default: | 2096 | default: |
2095 | break; | 2097 | break; |
2096 | } | 2098 | } |
2097 | if ( dia.exec() ) { | 2099 | if ( dia.exec() ) { |
2098 | KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 2100 | KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
2099 | } | 2101 | } |
2100 | 2102 | ||
2101 | } | 2103 | } |
2102 | 2104 | ||
2103 | void CalendarView::slotSelectPickerDate( QDate d) | 2105 | void CalendarView::slotSelectPickerDate( QDate d) |
2104 | { | 2106 | { |
2105 | mDateFrame->hide(); | 2107 | mDateFrame->hide(); |
2106 | if ( mDatePickerMode == 1 ) { | 2108 | if ( mDatePickerMode == 1 ) { |
2107 | mNavigator->slotDaySelect( d ); | 2109 | mNavigator->slotDaySelect( d ); |
2108 | } else if ( mDatePickerMode == 2 ) { | 2110 | } else if ( mDatePickerMode == 2 ) { |
2109 | if ( mMoveIncidence->type() == "Todo" ) { | 2111 | if ( mMoveIncidence->type() == "Todo" ) { |
2110 | Todo * to = (Todo *) mMoveIncidence; | 2112 | Todo * to = (Todo *) mMoveIncidence; |
2111 | QTime tim; | 2113 | QTime tim; |
2112 | if ( to->hasDueDate() ) | 2114 | if ( to->hasDueDate() ) |
2113 | tim = to->dtDue().time(); | 2115 | tim = to->dtDue().time(); |
2114 | else { | 2116 | else { |
2115 | tim = QTime ( 0,0,0 ); | 2117 | tim = QTime ( 0,0,0 ); |
2116 | to->setFloats( true ); | 2118 | to->setFloats( true ); |
2117 | to->setHasDueDate( true ); | 2119 | to->setHasDueDate( true ); |
2118 | } | 2120 | } |
2119 | QDateTime dt ( d,tim ); | 2121 | QDateTime dt ( d,tim ); |
2120 | to->setDtDue( dt ); | 2122 | to->setDtDue( dt ); |
2121 | todoChanged( to ); | 2123 | todoChanged( to ); |
2122 | } else { | 2124 | } else { |
2123 | QTime tim = mMoveIncidence->dtStart().time(); | 2125 | QTime tim = mMoveIncidence->dtStart().time(); |
2124 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2126 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2125 | QDateTime dt ( d,tim ); | 2127 | QDateTime dt ( d,tim ); |
2126 | mMoveIncidence->setDtStart( dt ); | 2128 | mMoveIncidence->setDtStart( dt ); |
2127 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2129 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2128 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2130 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2129 | } | 2131 | } |
2130 | 2132 | ||
2131 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2133 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2132 | } | 2134 | } |
2133 | } | 2135 | } |
2134 | 2136 | ||
2135 | void CalendarView::removeCategories() | 2137 | void CalendarView::removeCategories() |
2136 | { | 2138 | { |
2137 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2139 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2138 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2140 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2139 | QStringList catIncList; | 2141 | QStringList catIncList; |
2140 | QStringList newCatList; | 2142 | QStringList newCatList; |
2141 | Incidence* inc = incList.first(); | 2143 | Incidence* inc = incList.first(); |
2142 | int i; | 2144 | int i; |
2143 | int count = 0; | 2145 | int count = 0; |
2144 | while ( inc ) { | 2146 | while ( inc ) { |
2145 | newCatList.clear(); | 2147 | newCatList.clear(); |
2146 | catIncList = inc->categories() ; | 2148 | catIncList = inc->categories() ; |
2147 | for( i = 0; i< catIncList.count(); ++i ) { | 2149 | for( i = 0; i< catIncList.count(); ++i ) { |
2148 | if ( catList.contains (catIncList[i])) | 2150 | if ( catList.contains (catIncList[i])) |
2149 | newCatList.append( catIncList[i] ); | 2151 | newCatList.append( catIncList[i] ); |
2150 | } | 2152 | } |
2151 | newCatList.sort(); | 2153 | newCatList.sort(); |
2152 | inc->setCategories( newCatList.join(",") ); | 2154 | inc->setCategories( newCatList.join(",") ); |
2153 | inc = incList.next(); | 2155 | inc = incList.next(); |
2154 | } | 2156 | } |
2155 | } | 2157 | } |
2156 | 2158 | ||
2157 | int CalendarView::addCategories() | 2159 | int CalendarView::addCategories() |
2158 | { | 2160 | { |
2159 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2161 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2160 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2162 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2161 | QStringList catIncList; | 2163 | QStringList catIncList; |
2162 | Incidence* inc = incList.first(); | 2164 | Incidence* inc = incList.first(); |
2163 | int i; | 2165 | int i; |
2164 | int count = 0; | 2166 | int count = 0; |
2165 | while ( inc ) { | 2167 | while ( inc ) { |
2166 | catIncList = inc->categories() ; | 2168 | catIncList = inc->categories() ; |
2167 | for( i = 0; i< catIncList.count(); ++i ) { | 2169 | for( i = 0; i< catIncList.count(); ++i ) { |
2168 | if ( !catList.contains (catIncList[i])) { | 2170 | if ( !catList.contains (catIncList[i])) { |
2169 | catList.append( catIncList[i] ); | 2171 | catList.append( catIncList[i] ); |
2170 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2172 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2171 | ++count; | 2173 | ++count; |
2172 | } | 2174 | } |
2173 | } | 2175 | } |
2174 | inc = incList.next(); | 2176 | inc = incList.next(); |
2175 | } | 2177 | } |
2176 | catList.sort(); | 2178 | catList.sort(); |
2177 | KOPrefs::instance()->mCustomCategories = catList; | 2179 | KOPrefs::instance()->mCustomCategories = catList; |
2178 | return count; | 2180 | return count; |
2179 | } | 2181 | } |
2180 | 2182 | ||
2181 | void CalendarView::manageCategories() | 2183 | void CalendarView::manageCategories() |
2182 | { | 2184 | { |
2183 | KOCatPrefs* cp = new KOCatPrefs(); | 2185 | KOCatPrefs* cp = new KOCatPrefs(); |
2184 | cp->show(); | 2186 | cp->show(); |
2185 | int w =cp->sizeHint().width() ; | 2187 | int w =cp->sizeHint().width() ; |
2186 | int h = cp->sizeHint().height() ; | 2188 | int h = cp->sizeHint().height() ; |
2187 | int dw = QApplication::desktop()->width(); | 2189 | int dw = QApplication::desktop()->width(); |
2188 | int dh = QApplication::desktop()->height(); | 2190 | int dh = QApplication::desktop()->height(); |
2189 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2191 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2190 | if ( !cp->exec() ) { | 2192 | if ( !cp->exec() ) { |
2191 | delete cp; | 2193 | delete cp; |
2192 | return; | 2194 | return; |
2193 | } | 2195 | } |
2194 | int count = 0; | 2196 | int count = 0; |
2195 | if ( cp->addCat() ) { | 2197 | if ( cp->addCat() ) { |
2196 | count = addCategories(); | 2198 | count = addCategories(); |
2197 | if ( count ) { | 2199 | if ( count ) { |
2198 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2200 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2199 | writeSettings(); | 2201 | writeSettings(); |
2200 | } | 2202 | } |
2201 | } else { | 2203 | } else { |
2202 | removeCategories(); | 2204 | removeCategories(); |
2203 | updateView(); | 2205 | updateView(); |
2204 | } | 2206 | } |
2205 | delete cp; | 2207 | delete cp; |
2206 | } | 2208 | } |
2207 | 2209 | ||
2208 | void CalendarView::beamIncidence(Incidence * Inc) | 2210 | void CalendarView::beamIncidence(Incidence * Inc) |
2209 | { | 2211 | { |
2210 | QPtrList<Incidence> delSel ; | 2212 | QPtrList<Incidence> delSel ; |
2211 | delSel.append(Inc); | 2213 | delSel.append(Inc); |
2212 | beamIncidenceList( delSel ); | 2214 | beamIncidenceList( delSel ); |
2213 | } | 2215 | } |
2214 | void CalendarView::beamCalendar() | 2216 | void CalendarView::beamCalendar() |
2215 | { | 2217 | { |
2216 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2218 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2217 | //qDebug("beamCalendar() "); | 2219 | //qDebug("beamCalendar() "); |
2218 | beamIncidenceList( delSel ); | 2220 | beamIncidenceList( delSel ); |
2219 | } | 2221 | } |
2220 | void CalendarView::beamFilteredCalendar() | 2222 | void CalendarView::beamFilteredCalendar() |
2221 | { | 2223 | { |
2222 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2224 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2223 | //qDebug("beamFilteredCalendar() "); | 2225 | //qDebug("beamFilteredCalendar() "); |
2224 | beamIncidenceList( delSel ); | 2226 | beamIncidenceList( delSel ); |
2225 | } | 2227 | } |
2226 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2228 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2227 | { | 2229 | { |
2228 | if ( beamDialog->exec () == QDialog::Rejected ) | 2230 | if ( beamDialog->exec () == QDialog::Rejected ) |
2229 | return; | 2231 | return; |
2230 | 2232 | ||
2231 | QString fn = "/tmp/kopibeamfile"; | 2233 | QString fn = "/tmp/kopibeamfile"; |
2232 | QString mes; | 2234 | QString mes; |
2233 | bool createbup = true; | 2235 | bool createbup = true; |
2234 | if ( createbup ) { | 2236 | if ( createbup ) { |
2235 | QString description = "\n"; | 2237 | QString description = "\n"; |
2236 | CalendarLocal* cal = new CalendarLocal(); | 2238 | CalendarLocal* cal = new CalendarLocal(); |
2237 | if ( beamDialog->beamLocal() ) | 2239 | if ( beamDialog->beamLocal() ) |
2238 | cal->setLocalTime(); | 2240 | cal->setLocalTime(); |
2239 | else | 2241 | else |
2240 | cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 2242 | cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
2241 | Incidence *incidence = delSel.first(); | 2243 | Incidence *incidence = delSel.first(); |
2242 | bool addText = false; | 2244 | bool addText = false; |
2243 | if ( delSel.count() < 10 ) | 2245 | if ( delSel.count() < 10 ) |
2244 | addText = true; | 2246 | addText = true; |
2245 | else { | 2247 | else { |
2246 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2248 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2247 | } | 2249 | } |
2248 | while ( incidence ) { | 2250 | while ( incidence ) { |
2249 | Incidence *in = incidence->clone(); | 2251 | Incidence *in = incidence->clone(); |
2250 | if ( addText ) | 2252 | if ( addText ) |
2251 | description += in->summary() + "\n"; | 2253 | description += in->summary() + "\n"; |
2252 | cal->addIncidence( in ); | 2254 | cal->addIncidence( in ); |
2253 | incidence = delSel.next(); | 2255 | incidence = delSel.next(); |
2254 | } | 2256 | } |
2255 | if ( beamDialog->beamVcal() ) { | 2257 | if ( beamDialog->beamVcal() ) { |
2256 | fn += ".vcs"; | 2258 | fn += ".vcs"; |
2257 | FileStorage storage( cal, fn, new VCalFormat ); | 2259 | FileStorage storage( cal, fn, new VCalFormat ); |
2258 | storage.save(); | 2260 | storage.save(); |
2259 | } else { | 2261 | } else { |
2260 | fn += ".ics"; | 2262 | fn += ".ics"; |
2261 | FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 2263 | FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
2262 | storage.save(); | 2264 | storage.save(); |
2263 | } | 2265 | } |
2264 | delete cal; | 2266 | delete cal; |
2265 | mes = i18n("KO/Pi: Ready for beaming"); | 2267 | mes = i18n("KO/Pi: Ready for beaming"); |
2266 | setCaption(mes); | 2268 | setCaption(mes); |
2267 | 2269 | ||
2268 | #ifndef DESKTOP_VERSION | 2270 | #ifndef DESKTOP_VERSION |
2269 | Ir *ir = new Ir( this ); | 2271 | Ir *ir = new Ir( this ); |
2270 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2272 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2271 | ir->send( fn, description, "text/x-vCalendar" ); | 2273 | ir->send( fn, description, "text/x-vCalendar" ); |
2272 | #endif | 2274 | #endif |
2273 | } | 2275 | } |
2274 | } | 2276 | } |
2275 | void CalendarView::beamDone( Ir *ir ) | 2277 | void CalendarView::beamDone( Ir *ir ) |
2276 | { | 2278 | { |
2277 | #ifndef DESKTOP_VERSION | 2279 | #ifndef DESKTOP_VERSION |
2278 | delete ir; | 2280 | delete ir; |
2279 | #endif | 2281 | #endif |
2280 | } | 2282 | } |
2281 | 2283 | ||
2282 | void CalendarView::moveIncidence(Incidence * inc ) | 2284 | void CalendarView::moveIncidence(Incidence * inc ) |
2283 | { | 2285 | { |
2284 | if ( !inc ) return; | 2286 | if ( !inc ) return; |
2285 | // qDebug("showDatePickerForIncidence( ) "); | 2287 | // qDebug("showDatePickerForIncidence( ) "); |
2286 | if ( mDateFrame->isVisible() ) | 2288 | if ( mDateFrame->isVisible() ) |
2287 | mDateFrame->hide(); | 2289 | mDateFrame->hide(); |
2288 | else { | 2290 | else { |
2289 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2291 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2290 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2292 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2291 | int dw = QApplication::desktop()->width(); | 2293 | int dw = QApplication::desktop()->width(); |
2292 | int dh = QApplication::desktop()->height(); | 2294 | int dh = QApplication::desktop()->height(); |
2293 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2295 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2294 | mDateFrame->show(); | 2296 | mDateFrame->show(); |
2295 | } | 2297 | } |
2296 | mDatePickerMode = 2; | 2298 | mDatePickerMode = 2; |
2297 | mMoveIncidence = inc ; | 2299 | mMoveIncidence = inc ; |
2298 | QDate da; | 2300 | QDate da; |
2299 | if ( mMoveIncidence->type() == "Todo" ) { | 2301 | if ( mMoveIncidence->type() == "Todo" ) { |
2300 | Todo * to = (Todo *) mMoveIncidence; | 2302 | Todo * to = (Todo *) mMoveIncidence; |
2301 | if ( to->hasDueDate() ) | 2303 | if ( to->hasDueDate() ) |
2302 | da = to->dtDue().date(); | 2304 | da = to->dtDue().date(); |
2303 | else | 2305 | else |
2304 | da = QDate::currentDate(); | 2306 | da = QDate::currentDate(); |
2305 | } else { | 2307 | } else { |
2306 | da = mMoveIncidence->dtStart().date(); | 2308 | da = mMoveIncidence->dtStart().date(); |
2307 | } | 2309 | } |
2308 | mDatePicker->setDate( da ); | 2310 | mDatePicker->setDate( da ); |
2309 | } | 2311 | } |
2310 | void CalendarView::showDatePicker( ) | 2312 | void CalendarView::showDatePicker( ) |
2311 | { | 2313 | { |
2312 | //qDebug("CalendarView::showDatePicker( ) "); | 2314 | //qDebug("CalendarView::showDatePicker( ) "); |
2313 | if ( mDateFrame->isVisible() ) | 2315 | if ( mDateFrame->isVisible() ) |
2314 | mDateFrame->hide(); | 2316 | mDateFrame->hide(); |
2315 | else { | 2317 | else { |
2316 | int w =mDatePicker->sizeHint().width() ; | 2318 | int w =mDatePicker->sizeHint().width() ; |
2317 | int h = mDatePicker->sizeHint().height() ; | 2319 | int h = mDatePicker->sizeHint().height() ; |
2318 | int dw = QApplication::desktop()->width(); | 2320 | int dw = QApplication::desktop()->width(); |
2319 | int dh = QApplication::desktop()->height(); | 2321 | int dh = QApplication::desktop()->height(); |
2320 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2322 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2321 | mDateFrame->show(); | 2323 | mDateFrame->show(); |
2322 | } | 2324 | } |
2323 | mDatePickerMode = 1; | 2325 | mDatePickerMode = 1; |
2324 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2326 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2325 | } | 2327 | } |
2326 | 2328 | ||
2327 | void CalendarView::showEventEditor() | 2329 | void CalendarView::showEventEditor() |
2328 | { | 2330 | { |
2329 | #ifdef DESKTOP_VERSION | 2331 | #ifdef DESKTOP_VERSION |
2330 | mEventEditor->show(); | 2332 | mEventEditor->show(); |
2331 | #else | 2333 | #else |
2332 | mEventEditor->showMaximized(); | 2334 | mEventEditor->showMaximized(); |
2333 | #endif | 2335 | #endif |
2334 | } | 2336 | } |
2335 | void CalendarView::showTodoEditor() | 2337 | void CalendarView::showTodoEditor() |
2336 | { | 2338 | { |
2337 | #ifdef DESKTOP_VERSION | 2339 | #ifdef DESKTOP_VERSION |
2338 | mTodoEditor->show(); | 2340 | mTodoEditor->show(); |
2339 | #else | 2341 | #else |
2340 | mTodoEditor->showMaximized(); | 2342 | mTodoEditor->showMaximized(); |
2341 | #endif | 2343 | #endif |
2342 | } | 2344 | } |
2343 | void CalendarView::cancelIncidence(Incidence * inc ) | 2345 | void CalendarView::cancelIncidence(Incidence * inc ) |
2344 | { | 2346 | { |
2345 | inc->setCancelled( ! inc->cancelled() ); | 2347 | inc->setCancelled( ! inc->cancelled() ); |
2346 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2348 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2347 | updateView(); | 2349 | updateView(); |
2348 | } | 2350 | } |
2349 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2351 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2350 | { | 2352 | { |
2351 | Incidence * newInc = orgInc->clone(); | 2353 | Incidence * newInc = orgInc->clone(); |
2352 | newInc->recreate(); | 2354 | newInc->recreate(); |
2353 | 2355 | ||
2354 | if ( newInc->type() == "Todo" ) { | 2356 | if ( newInc->type() == "Todo" ) { |
2355 | Todo* t = (Todo*) newInc; | 2357 | Todo* t = (Todo*) newInc; |
2356 | mTodoEditor->editTodo( t ); | 2358 | mTodoEditor->editTodo( t ); |
2357 | showTodoEditor(); | 2359 | showTodoEditor(); |
2358 | if ( mTodoEditor->exec() ) { | 2360 | if ( mTodoEditor->exec() ) { |
2359 | mCalendar->addTodo( t ); | 2361 | mCalendar->addTodo( t ); |
2360 | updateView(); | 2362 | updateView(); |
2361 | } else { | 2363 | } else { |
2362 | delete t; | 2364 | delete t; |
2363 | } | 2365 | } |
2364 | } | 2366 | } |
2365 | else { | 2367 | else { |
2366 | Event* e = (Event*) newInc; | 2368 | Event* e = (Event*) newInc; |
2367 | mEventEditor->editEvent( e ); | 2369 | mEventEditor->editEvent( e ); |
2368 | showEventEditor(); | 2370 | showEventEditor(); |
2369 | if ( mEventEditor->exec() ) { | 2371 | if ( mEventEditor->exec() ) { |
2370 | mCalendar->addEvent( e ); | 2372 | mCalendar->addEvent( e ); |
2371 | updateView(); | 2373 | updateView(); |
2372 | } else { | 2374 | } else { |
2373 | delete e; | 2375 | delete e; |
2374 | } | 2376 | } |
2375 | } | 2377 | } |
2376 | } | 2378 | } |
2377 | 2379 | ||
2378 | void CalendarView::newEvent() | 2380 | void CalendarView::newEvent() |
2379 | { | 2381 | { |
2380 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2382 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2381 | KOAgendaView *aView = mViewManager->agendaView(); | 2383 | KOAgendaView *aView = mViewManager->agendaView(); |
2382 | if (aView) { | 2384 | if (aView) { |
2383 | if (aView->selectionStart().isValid()) { | 2385 | if (aView->selectionStart().isValid()) { |
2384 | if (aView->selectedIsAllDay()) { | 2386 | if (aView->selectedIsAllDay()) { |
2385 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2387 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2386 | } else { | 2388 | } else { |
2387 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2389 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2388 | } | 2390 | } |
2389 | return; | 2391 | return; |
2390 | } | 2392 | } |
2391 | } | 2393 | } |
2392 | 2394 | ||
2393 | QDate date = mNavigator->selectedDates().first(); | 2395 | QDate date = mNavigator->selectedDates().first(); |
2394 | QDateTime current = QDateTime::currentDateTime(); | 2396 | QDateTime current = QDateTime::currentDateTime(); |
2395 | if ( date <= current.date() ) { | 2397 | if ( date <= current.date() ) { |
2396 | int hour = current.time().hour() +1; | 2398 | int hour = current.time().hour() +1; |
2397 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2399 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2398 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2400 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2399 | } else | 2401 | } else |
2400 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2402 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2401 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2403 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2402 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2404 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2403 | } | 2405 | } |
2404 | 2406 | ||
2405 | void CalendarView::newEvent(QDateTime fh) | 2407 | void CalendarView::newEvent(QDateTime fh) |
2406 | { | 2408 | { |
2407 | newEvent(fh, | 2409 | newEvent(fh, |
2408 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2410 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2409 | } | 2411 | } |
2410 | 2412 | ||
2411 | void CalendarView::newEvent(QDate dt) | 2413 | void CalendarView::newEvent(QDate dt) |
2412 | { | 2414 | { |
2413 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2415 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2414 | QDateTime(dt, QTime(0,0,0)), true); | 2416 | QDateTime(dt, QTime(0,0,0)), true); |
2415 | } | 2417 | } |
2416 | 2418 | ||
2417 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2419 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2418 | { | 2420 | { |
2419 | 2421 | ||
2420 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2422 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2421 | if ( mFilterView->filtersEnabled() ) { | 2423 | if ( mFilterView->filtersEnabled() ) { |
2422 | CalFilter *filter = mFilterView->selectedFilter(); | 2424 | CalFilter *filter = mFilterView->selectedFilter(); |
2423 | if (filter && filter->showCategories()) { | 2425 | if (filter && filter->showCategories()) { |
2424 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2426 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2425 | } | 2427 | } |
2426 | if ( filter ) | 2428 | if ( filter ) |
2427 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2429 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2428 | } | 2430 | } |
2429 | showEventEditor(); | 2431 | showEventEditor(); |
2430 | } | 2432 | } |
2431 | void CalendarView::todoAdded(Todo * t) | 2433 | void CalendarView::todoAdded(Todo * t) |
2432 | { | 2434 | { |
2433 | 2435 | ||
2434 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2436 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2435 | updateTodoViews(); | 2437 | updateTodoViews(); |
2436 | } | 2438 | } |
2437 | void CalendarView::todoChanged(Todo * t) | 2439 | void CalendarView::todoChanged(Todo * t) |
2438 | { | 2440 | { |
2439 | emit todoModified( t, 4 ); | 2441 | emit todoModified( t, 4 ); |
2440 | // updateTodoViews(); | 2442 | // updateTodoViews(); |
2441 | } | 2443 | } |
2442 | void CalendarView::todoToBeDeleted(Todo *) | 2444 | void CalendarView::todoToBeDeleted(Todo *) |
2443 | { | 2445 | { |
2444 | //qDebug("todoToBeDeleted(Todo *) "); | 2446 | //qDebug("todoToBeDeleted(Todo *) "); |
2445 | updateTodoViews(); | 2447 | updateTodoViews(); |
2446 | } | 2448 | } |
2447 | void CalendarView::todoDeleted() | 2449 | void CalendarView::todoDeleted() |
2448 | { | 2450 | { |
2449 | //qDebug(" todoDeleted()"); | 2451 | //qDebug(" todoDeleted()"); |
2450 | updateTodoViews(); | 2452 | updateTodoViews(); |
2451 | } | 2453 | } |
2452 | 2454 | ||
2453 | 2455 | ||
2454 | 2456 | ||
2455 | void CalendarView::newTodo() | 2457 | void CalendarView::newTodo() |
2456 | { | 2458 | { |
2457 | 2459 | ||
2458 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); | 2460 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); |
2459 | if ( mFilterView->filtersEnabled() ) { | 2461 | if ( mFilterView->filtersEnabled() ) { |
2460 | CalFilter *filter = mFilterView->selectedFilter(); | 2462 | CalFilter *filter = mFilterView->selectedFilter(); |
2461 | if (filter && filter->showCategories()) { | 2463 | if (filter && filter->showCategories()) { |
2462 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2464 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2463 | } | 2465 | } |
2464 | if ( filter ) | 2466 | if ( filter ) |
2465 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2467 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2466 | } | 2468 | } |
2467 | showTodoEditor(); | 2469 | showTodoEditor(); |
2468 | } | 2470 | } |
2469 | 2471 | ||
2470 | void CalendarView::newSubTodo() | 2472 | void CalendarView::newSubTodo() |
2471 | { | 2473 | { |
2472 | Todo *todo = selectedTodo(); | 2474 | Todo *todo = selectedTodo(); |
2473 | if ( todo ) newSubTodo( todo ); | 2475 | if ( todo ) newSubTodo( todo ); |
2474 | } | 2476 | } |
2475 | 2477 | ||
2476 | void CalendarView::newSubTodo(Todo *parentEvent) | 2478 | void CalendarView::newSubTodo(Todo *parentEvent) |
2477 | { | 2479 | { |
2478 | 2480 | ||
2479 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); | 2481 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); |
2480 | showTodoEditor(); | 2482 | showTodoEditor(); |
2481 | } | 2483 | } |
2482 | 2484 | ||
2483 | void CalendarView::newFloatingEvent() | 2485 | void CalendarView::newFloatingEvent() |
2484 | { | 2486 | { |
2485 | DateList tmpList = mNavigator->selectedDates(); | 2487 | DateList tmpList = mNavigator->selectedDates(); |
2486 | QDate date = tmpList.first(); | 2488 | QDate date = tmpList.first(); |
2487 | 2489 | ||
2488 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2490 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2489 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2491 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2490 | } | 2492 | } |
2491 | 2493 | ||
2492 | 2494 | ||
2493 | void CalendarView::editEvent( Event *event ) | 2495 | void CalendarView::editEvent( Event *event ) |
2494 | { | 2496 | { |
2495 | 2497 | ||
2496 | if ( !event ) return; | 2498 | if ( !event ) return; |
2497 | if ( event->isReadOnly() ) { | 2499 | if ( event->isReadOnly() ) { |
2498 | showEvent( event ); | 2500 | showEvent( event ); |
2499 | return; | 2501 | return; |
2500 | } | 2502 | } |
2501 | mEventEditor->editEvent( event , mFlagEditDescription); | 2503 | mEventEditor->editEvent( event , mFlagEditDescription); |
2502 | showEventEditor(); | 2504 | showEventEditor(); |
2503 | } | 2505 | } |
2504 | void CalendarView::editJournal( Journal *jour ) | 2506 | void CalendarView::editJournal( Journal *jour ) |
2505 | { | 2507 | { |
2506 | if ( !jour ) return; | 2508 | if ( !jour ) return; |
2507 | mDialogManager->hideSearchDialog(); | 2509 | mDialogManager->hideSearchDialog(); |
2508 | mViewManager->showJournalView(); | 2510 | mViewManager->showJournalView(); |
2509 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2511 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2510 | } | 2512 | } |
2511 | void CalendarView::editTodo( Todo *todo ) | 2513 | void CalendarView::editTodo( Todo *todo ) |
2512 | { | 2514 | { |
2513 | if ( !todo ) return; | 2515 | if ( !todo ) return; |
2514 | 2516 | ||
2515 | if ( todo->isReadOnly() ) { | 2517 | if ( todo->isReadOnly() ) { |
2516 | showTodo( todo ); | 2518 | showTodo( todo ); |
2517 | return; | 2519 | return; |
2518 | } | 2520 | } |
2519 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 2521 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
2520 | showTodoEditor(); | 2522 | showTodoEditor(); |
2521 | 2523 | ||
2522 | } | 2524 | } |
2523 | 2525 | ||
2524 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2526 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2525 | { | 2527 | { |
2526 | if ( !mEventViewerDialog ) { | 2528 | if ( !mEventViewerDialog ) { |
2527 | mEventViewerDialog = new KOEventViewerDialog(this); | 2529 | mEventViewerDialog = new KOEventViewerDialog(this); |
2528 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2530 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2529 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2531 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2530 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2532 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2531 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2533 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2532 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2534 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2533 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2535 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2534 | mEventViewerDialog->resize( 640, 480 ); | 2536 | mEventViewerDialog->resize( 640, 480 ); |
2535 | 2537 | ||
2536 | } | 2538 | } |
2537 | return mEventViewerDialog; | 2539 | return mEventViewerDialog; |
2538 | } | 2540 | } |
2539 | void CalendarView::showEvent(Event *event) | 2541 | void CalendarView::showEvent(Event *event) |
2540 | { | 2542 | { |
2541 | getEventViewerDialog()->setEvent(event); | 2543 | getEventViewerDialog()->setEvent(event); |
2542 | getEventViewerDialog()->showMe(); | 2544 | getEventViewerDialog()->showMe(); |
2543 | } | 2545 | } |
2544 | 2546 | ||
2545 | void CalendarView::showTodo(Todo *event) | 2547 | void CalendarView::showTodo(Todo *event) |
2546 | { | 2548 | { |
2547 | getEventViewerDialog()->setTodo(event); | 2549 | getEventViewerDialog()->setTodo(event); |
2548 | getEventViewerDialog()->showMe(); | 2550 | getEventViewerDialog()->showMe(); |
2549 | } | 2551 | } |
2550 | void CalendarView::showJournal( Journal *jour ) | 2552 | void CalendarView::showJournal( Journal *jour ) |
2551 | { | 2553 | { |
2552 | getEventViewerDialog()->setJournal(jour); | 2554 | getEventViewerDialog()->setJournal(jour); |
2553 | getEventViewerDialog()->showMe(); | 2555 | getEventViewerDialog()->showMe(); |
2554 | 2556 | ||
2555 | } | 2557 | } |
2556 | // void CalendarView::todoModified (Todo *event, int changed) | 2558 | // void CalendarView::todoModified (Todo *event, int changed) |
2557 | // { | 2559 | // { |
2558 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 2560 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
2559 | // // kdDebug() << "Todo modified and open" << endl; | 2561 | // // kdDebug() << "Todo modified and open" << endl; |
2560 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 2562 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
2561 | // // temp->modified (changed); | 2563 | // // temp->modified (changed); |
2562 | 2564 | ||
2563 | // // } | 2565 | // // } |
2564 | 2566 | ||
2565 | // mViewManager->updateView(); | 2567 | // mViewManager->updateView(); |
2566 | // } | 2568 | // } |
2567 | 2569 | ||
2568 | void CalendarView::appointment_show() | 2570 | void CalendarView::appointment_show() |
2569 | { | 2571 | { |
2570 | Event *anEvent = 0; | 2572 | Event *anEvent = 0; |
2571 | 2573 | ||
2572 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2574 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2573 | 2575 | ||
2574 | if (mViewManager->currentView()->isEventView()) { | 2576 | if (mViewManager->currentView()->isEventView()) { |
2575 | if ( incidence && incidence->type() == "Event" ) { | 2577 | if ( incidence && incidence->type() == "Event" ) { |
2576 | anEvent = static_cast<Event *>(incidence); | 2578 | anEvent = static_cast<Event *>(incidence); |
2577 | } | 2579 | } |
2578 | } | 2580 | } |
2579 | 2581 | ||
2580 | if (!anEvent) { | 2582 | if (!anEvent) { |
2581 | KNotifyClient::beep(); | 2583 | KNotifyClient::beep(); |
2582 | return; | 2584 | return; |
2583 | } | 2585 | } |
2584 | 2586 | ||
2585 | showEvent(anEvent); | 2587 | showEvent(anEvent); |
2586 | } | 2588 | } |
2587 | 2589 | ||
2588 | void CalendarView::appointment_edit() | 2590 | void CalendarView::appointment_edit() |
2589 | { | 2591 | { |
2590 | Event *anEvent = 0; | 2592 | Event *anEvent = 0; |
2591 | 2593 | ||
2592 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2594 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2593 | 2595 | ||
2594 | if (mViewManager->currentView()->isEventView()) { | 2596 | if (mViewManager->currentView()->isEventView()) { |
2595 | if ( incidence && incidence->type() == "Event" ) { | 2597 | if ( incidence && incidence->type() == "Event" ) { |
2596 | anEvent = static_cast<Event *>(incidence); | 2598 | anEvent = static_cast<Event *>(incidence); |
2597 | } | 2599 | } |
2598 | } | 2600 | } |
2599 | 2601 | ||
2600 | if (!anEvent) { | 2602 | if (!anEvent) { |
2601 | KNotifyClient::beep(); | 2603 | KNotifyClient::beep(); |
2602 | return; | 2604 | return; |
2603 | } | 2605 | } |
2604 | 2606 | ||
2605 | editEvent(anEvent); | 2607 | editEvent(anEvent); |
2606 | } | 2608 | } |
2607 | 2609 | ||
2608 | void CalendarView::appointment_delete() | 2610 | void CalendarView::appointment_delete() |
2609 | { | 2611 | { |
2610 | Event *anEvent = 0; | 2612 | Event *anEvent = 0; |
2611 | 2613 | ||
2612 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2614 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2613 | 2615 | ||
2614 | if (mViewManager->currentView()->isEventView()) { | 2616 | if (mViewManager->currentView()->isEventView()) { |
2615 | if ( incidence && incidence->type() == "Event" ) { | 2617 | if ( incidence && incidence->type() == "Event" ) { |
2616 | anEvent = static_cast<Event *>(incidence); | 2618 | anEvent = static_cast<Event *>(incidence); |
2617 | } | 2619 | } |
2618 | } | 2620 | } |
2619 | 2621 | ||
2620 | if (!anEvent) { | 2622 | if (!anEvent) { |
2621 | KNotifyClient::beep(); | 2623 | KNotifyClient::beep(); |
2622 | return; | 2624 | return; |
2623 | } | 2625 | } |
2624 | 2626 | ||
2625 | deleteEvent(anEvent); | 2627 | deleteEvent(anEvent); |
2626 | } | 2628 | } |
2627 | 2629 | ||
2628 | void CalendarView::todo_unsub(Todo *anTodo ) | 2630 | void CalendarView::todo_unsub(Todo *anTodo ) |
2629 | { | 2631 | { |
2630 | // Todo *anTodo = selectedTodo(); | 2632 | // Todo *anTodo = selectedTodo(); |
2631 | if (!anTodo) return; | 2633 | if (!anTodo) return; |
2632 | if (!anTodo->relatedTo()) return; | 2634 | if (!anTodo->relatedTo()) return; |
2633 | anTodo->relatedTo()->removeRelation(anTodo); | 2635 | anTodo->relatedTo()->removeRelation(anTodo); |
2634 | anTodo->setRelatedTo(0); | 2636 | anTodo->setRelatedTo(0); |
2635 | anTodo->updated(); | 2637 | anTodo->updated(); |
2636 | anTodo->setRelatedToUid(""); | 2638 | anTodo->setRelatedToUid(""); |
2637 | setModified(true); | 2639 | setModified(true); |
2638 | updateView(); | 2640 | updateView(); |
2639 | } | 2641 | } |
2640 | 2642 | ||
2641 | void CalendarView::deleteTodo(Todo *todo) | 2643 | void CalendarView::deleteTodo(Todo *todo) |
2642 | { | 2644 | { |
2643 | if (!todo) { | 2645 | if (!todo) { |
2644 | KNotifyClient::beep(); | 2646 | KNotifyClient::beep(); |
2645 | return; | 2647 | return; |
2646 | } | 2648 | } |
2647 | if (KOPrefs::instance()->mConfirm) { | 2649 | if (KOPrefs::instance()->mConfirm) { |
2648 | switch (msgItemDelete()) { | 2650 | switch (msgItemDelete()) { |
2649 | case KMessageBox::Continue: // OK | 2651 | case KMessageBox::Continue: // OK |
2650 | if (!todo->relations().isEmpty()) { | 2652 | if (!todo->relations().isEmpty()) { |
2651 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2653 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2652 | i18n("Delete To-Do")); | 2654 | i18n("Delete To-Do")); |
2653 | } else { | 2655 | } else { |
2654 | checkExternalId( todo ); | 2656 | checkExternalId( todo ); |
2655 | calendar()->deleteTodo(todo); | 2657 | calendar()->deleteTodo(todo); |
2656 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2658 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2657 | updateView(); | 2659 | updateView(); |
2658 | } | 2660 | } |
2659 | break; | 2661 | break; |
2660 | } // switch | 2662 | } // switch |
2661 | } else { | 2663 | } else { |
2662 | if (!todo->relations().isEmpty()) { | 2664 | if (!todo->relations().isEmpty()) { |
2663 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2665 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2664 | i18n("Delete To-Do")); | 2666 | i18n("Delete To-Do")); |
2665 | } else { | 2667 | } else { |
2666 | checkExternalId( todo ); | 2668 | checkExternalId( todo ); |
2667 | mCalendar->deleteTodo(todo); | 2669 | mCalendar->deleteTodo(todo); |
2668 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2670 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2669 | updateView(); | 2671 | updateView(); |
2670 | } | 2672 | } |
2671 | } | 2673 | } |
2672 | emit updateSearchDialog(); | 2674 | emit updateSearchDialog(); |
2673 | } | 2675 | } |
2674 | void CalendarView::deleteJournal(Journal *jour) | 2676 | void CalendarView::deleteJournal(Journal *jour) |
2675 | { | 2677 | { |
2676 | if (!jour) { | 2678 | if (!jour) { |
2677 | KNotifyClient::beep(); | 2679 | KNotifyClient::beep(); |
2678 | return; | 2680 | return; |
2679 | } | 2681 | } |
2680 | if (KOPrefs::instance()->mConfirm) { | 2682 | if (KOPrefs::instance()->mConfirm) { |
2681 | switch (msgItemDelete()) { | 2683 | switch (msgItemDelete()) { |
2682 | case KMessageBox::Continue: // OK | 2684 | case KMessageBox::Continue: // OK |
2683 | calendar()->deleteJournal(jour); | 2685 | calendar()->deleteJournal(jour); |
2684 | updateView(); | 2686 | updateView(); |
2685 | break; | 2687 | break; |
2686 | } // switch | 2688 | } // switch |
2687 | } else { | 2689 | } else { |
2688 | calendar()->deleteJournal(jour);; | 2690 | calendar()->deleteJournal(jour);; |
2689 | updateView(); | 2691 | updateView(); |
2690 | } | 2692 | } |
2691 | emit updateSearchDialog(); | 2693 | emit updateSearchDialog(); |
2692 | } | 2694 | } |
2693 | 2695 | ||
2694 | void CalendarView::deleteEvent(Event *anEvent) | 2696 | void CalendarView::deleteEvent(Event *anEvent) |
2695 | { | 2697 | { |
2696 | if (!anEvent) { | 2698 | if (!anEvent) { |
2697 | KNotifyClient::beep(); | 2699 | KNotifyClient::beep(); |
2698 | return; | 2700 | return; |
2699 | } | 2701 | } |
2700 | 2702 | ||
2701 | if (anEvent->recurrence()->doesRecur()) { | 2703 | if (anEvent->recurrence()->doesRecur()) { |
2702 | QDate itemDate = mViewManager->currentSelectionDate(); | 2704 | QDate itemDate = mViewManager->currentSelectionDate(); |
2703 | int km; | 2705 | int km; |
2704 | if (!itemDate.isValid()) { | 2706 | if (!itemDate.isValid()) { |
2705 | //kdDebug() << "Date Not Valid" << endl; | 2707 | //kdDebug() << "Date Not Valid" << endl; |
2706 | if (KOPrefs::instance()->mConfirm) { | 2708 | if (KOPrefs::instance()->mConfirm) { |
2707 | km = KMessageBox::warningContinueCancel(this,anEvent->summary() + | 2709 | km = KMessageBox::warningContinueCancel(this,anEvent->summary() + |
2708 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 2710 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
2709 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 2711 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
2710 | if ( km == KMessageBox::Continue ) | 2712 | if ( km == KMessageBox::Continue ) |
2711 | km = KMessageBox::No; // No = all below | 2713 | km = KMessageBox::No; // No = all below |
2712 | } else | 2714 | } else |
2713 | km = KMessageBox::No; | 2715 | km = KMessageBox::No; |
2714 | } else { | 2716 | } else { |
2715 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + | 2717 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + |
2716 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 2718 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
2717 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 2719 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
2718 | i18n("KO/Pi Confirmation"),i18n("Current"), | 2720 | i18n("KO/Pi Confirmation"),i18n("Current"), |
2719 | i18n("All")); | 2721 | i18n("All")); |
2720 | } | 2722 | } |
2721 | switch(km) { | 2723 | switch(km) { |
2722 | 2724 | ||
2723 | case KMessageBox::No: // Continue // all | 2725 | case KMessageBox::No: // Continue // all |
2724 | //qDebug("KMessageBox::No "); | 2726 | //qDebug("KMessageBox::No "); |
2725 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2727 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2726 | schedule(Scheduler::Cancel,anEvent); | 2728 | schedule(Scheduler::Cancel,anEvent); |
2727 | 2729 | ||
2728 | checkExternalId( anEvent); | 2730 | checkExternalId( anEvent); |
2729 | mCalendar->deleteEvent(anEvent); | 2731 | mCalendar->deleteEvent(anEvent); |
2730 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 2732 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
2731 | break; | 2733 | break; |
2732 | 2734 | ||
2733 | // Disabled because it does not work | 2735 | // Disabled because it does not work |
2734 | //#if 0 | 2736 | //#if 0 |
2735 | case KMessageBox::Yes: // just this one | 2737 | case KMessageBox::Yes: // just this one |
2736 | //QDate qd = mNavigator->selectedDates().first(); | 2738 | //QDate qd = mNavigator->selectedDates().first(); |
2737 | //if (!qd.isValid()) { | 2739 | //if (!qd.isValid()) { |
2738 | // kdDebug() << "no date selected, or invalid date" << endl; | 2740 | // kdDebug() << "no date selected, or invalid date" << endl; |
2739 | // KNotifyClient::beep(); | 2741 | // KNotifyClient::beep(); |
2740 | // return; | 2742 | // return; |
2741 | //} | 2743 | //} |
2742 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 2744 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
2743 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 2745 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
2744 | anEvent->addExDate(itemDate); | 2746 | anEvent->addExDate(itemDate); |
2745 | int duration = anEvent->recurrence()->duration(); | 2747 | int duration = anEvent->recurrence()->duration(); |
2746 | if ( duration > 0 ) { | 2748 | if ( duration > 0 ) { |
2747 | anEvent->recurrence()->setDuration( duration - 1 ); | 2749 | anEvent->recurrence()->setDuration( duration - 1 ); |
2748 | } | 2750 | } |
2749 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 2751 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
2750 | } | 2752 | } |
2751 | break; | 2753 | break; |
2752 | //#endif | 2754 | //#endif |
2753 | } // switch | 2755 | } // switch |
2754 | } else { | 2756 | } else { |
2755 | if (KOPrefs::instance()->mConfirm) { | 2757 | if (KOPrefs::instance()->mConfirm) { |
2756 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + | 2758 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + |
2757 | i18n("\nAre you sure you want\nto delete this event?"), | 2759 | i18n("\nAre you sure you want\nto delete this event?"), |
2758 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 2760 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
2759 | case KMessageBox::Continue: // OK | 2761 | case KMessageBox::Continue: // OK |
2760 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2762 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2761 | schedule(Scheduler::Cancel,anEvent); | 2763 | schedule(Scheduler::Cancel,anEvent); |
2762 | checkExternalId( anEvent); | 2764 | checkExternalId( anEvent); |
2763 | mCalendar->deleteEvent(anEvent); | 2765 | mCalendar->deleteEvent(anEvent); |
2764 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2766 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2765 | break; | 2767 | break; |
2766 | } // switch | 2768 | } // switch |
2767 | } else { | 2769 | } else { |
2768 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2770 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2769 | schedule(Scheduler::Cancel,anEvent); | 2771 | schedule(Scheduler::Cancel,anEvent); |
2770 | checkExternalId( anEvent); | 2772 | checkExternalId( anEvent); |
2771 | mCalendar->deleteEvent(anEvent); | 2773 | mCalendar->deleteEvent(anEvent); |
2772 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2774 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2773 | } | 2775 | } |
2774 | } // if-else | 2776 | } // if-else |
2775 | emit updateSearchDialog(); | 2777 | emit updateSearchDialog(); |
2776 | } | 2778 | } |
2777 | 2779 | ||
2778 | bool CalendarView::deleteEvent(const QString &uid) | 2780 | bool CalendarView::deleteEvent(const QString &uid) |
2779 | { | 2781 | { |
2780 | Event *ev = mCalendar->event(uid); | 2782 | Event *ev = mCalendar->event(uid); |
2781 | if (ev) { | 2783 | if (ev) { |
2782 | deleteEvent(ev); | 2784 | deleteEvent(ev); |
2783 | return true; | 2785 | return true; |
2784 | } else { | 2786 | } else { |
2785 | return false; | 2787 | return false; |
2786 | } | 2788 | } |
2787 | } | 2789 | } |
2788 | 2790 | ||
2789 | /*****************************************************************************/ | 2791 | /*****************************************************************************/ |
2790 | 2792 | ||
2791 | void CalendarView::action_mail() | 2793 | void CalendarView::action_mail() |
2792 | { | 2794 | { |
2793 | #ifndef KORG_NOMAIL | 2795 | #ifndef KORG_NOMAIL |
2794 | KOMailClient mailClient; | 2796 | KOMailClient mailClient; |
2795 | 2797 | ||
2796 | Incidence *incidence = currentSelection(); | 2798 | Incidence *incidence = currentSelection(); |
2797 | 2799 | ||
2798 | if (!incidence) { | 2800 | if (!incidence) { |
2799 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 2801 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
2800 | return; | 2802 | return; |
2801 | } | 2803 | } |
2802 | if(incidence->attendeeCount() == 0 ) { | 2804 | if(incidence->attendeeCount() == 0 ) { |
2803 | KMessageBox::sorry(this, | 2805 | KMessageBox::sorry(this, |
2804 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 2806 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
2805 | return; | 2807 | return; |
2806 | } | 2808 | } |
2807 | 2809 | ||
2808 | CalendarLocal cal_tmp; | 2810 | CalendarLocal cal_tmp; |
2809 | Event *event = 0; | 2811 | Event *event = 0; |
2810 | Event *ev = 0; | 2812 | Event *ev = 0; |
2811 | if ( incidence && incidence->type() == "Event" ) { | 2813 | if ( incidence && incidence->type() == "Event" ) { |
2812 | event = static_cast<Event *>(incidence); | 2814 | event = static_cast<Event *>(incidence); |
2813 | ev = new Event(*event); | 2815 | ev = new Event(*event); |
2814 | cal_tmp.addEvent(ev); | 2816 | cal_tmp.addEvent(ev); |
2815 | } | 2817 | } |
2816 | ICalFormat mForm( KOPrefs::instance()->mUseQuicksave); | 2818 | ICalFormat mForm( KOPrefs::instance()->mUseQuicksave); |
2817 | QString attachment = mForm.toString( &cal_tmp ); | 2819 | QString attachment = mForm.toString( &cal_tmp ); |
2818 | if (ev) delete(ev); | 2820 | if (ev) delete(ev); |
2819 | 2821 | ||
2820 | mailClient.mailAttendees(currentSelection(), attachment); | 2822 | mailClient.mailAttendees(currentSelection(), attachment); |
2821 | 2823 | ||
2822 | #endif | 2824 | #endif |
2823 | 2825 | ||
2824 | #if 0 | 2826 | #if 0 |
2825 | Event *anEvent = 0; | 2827 | Event *anEvent = 0; |
2826 | if (mViewManager->currentView()->isEventView()) { | 2828 | if (mViewManager->currentView()->isEventView()) { |
2827 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 2829 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
2828 | } | 2830 | } |
2829 | 2831 | ||
2830 | if (!anEvent) { | 2832 | if (!anEvent) { |
2831 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 2833 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
2832 | return; | 2834 | return; |
2833 | } | 2835 | } |
2834 | if(anEvent->attendeeCount() == 0 ) { | 2836 | if(anEvent->attendeeCount() == 0 ) { |
2835 | KMessageBox::sorry(this, | 2837 | KMessageBox::sorry(this, |
2836 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 2838 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
2837 | return; | 2839 | return; |
2838 | } | 2840 | } |
2839 | 2841 | ||
2840 | mailobject.emailEvent(anEvent); | 2842 | mailobject.emailEvent(anEvent); |
2841 | #endif | 2843 | #endif |
2842 | } | 2844 | } |
2843 | 2845 | ||
2844 | 2846 | ||
2845 | void CalendarView::schedule_publish(Incidence *incidence) | 2847 | void CalendarView::schedule_publish(Incidence *incidence) |
2846 | { | 2848 | { |
2847 | Event *event = 0; | 2849 | Event *event = 0; |
2848 | Todo *todo = 0; | 2850 | Todo *todo = 0; |
2849 | 2851 | ||
2850 | if (incidence == 0) { | 2852 | if (incidence == 0) { |
2851 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 2853 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
2852 | if (incidence == 0) { | 2854 | if (incidence == 0) { |
2853 | incidence = mTodoList->selectedIncidences().first(); | 2855 | incidence = mTodoList->selectedIncidences().first(); |
2854 | } | 2856 | } |
2855 | } | 2857 | } |
2856 | if ( incidence && incidence->type() == "Event" ) { | 2858 | if ( incidence && incidence->type() == "Event" ) { |
2857 | event = static_cast<Event *>(incidence); | 2859 | event = static_cast<Event *>(incidence); |
2858 | } else { | 2860 | } else { |
2859 | if ( incidence && incidence->type() == "Todo" ) { | 2861 | if ( incidence && incidence->type() == "Todo" ) { |
2860 | todo = static_cast<Todo *>(incidence); | 2862 | todo = static_cast<Todo *>(incidence); |
2861 | } | 2863 | } |
2862 | } | 2864 | } |
2863 | 2865 | ||
2864 | if (!event && !todo) { | 2866 | if (!event && !todo) { |
2865 | KMessageBox::sorry(this,i18n("No event selected.")); | 2867 | KMessageBox::sorry(this,i18n("No event selected.")); |
2866 | return; | 2868 | return; |
2867 | } | 2869 | } |
2868 | 2870 | ||
2869 | PublishDialog *publishdlg = new PublishDialog(); | 2871 | PublishDialog *publishdlg = new PublishDialog(); |
2870 | if (incidence->attendeeCount()>0) { | 2872 | if (incidence->attendeeCount()>0) { |
2871 | QPtrList<Attendee> attendees = incidence->attendees(); | 2873 | QPtrList<Attendee> attendees = incidence->attendees(); |
2872 | attendees.first(); | 2874 | attendees.first(); |
2873 | while ( attendees.current()!=0 ) { | 2875 | while ( attendees.current()!=0 ) { |
2874 | publishdlg->addAttendee(attendees.current()); | 2876 | publishdlg->addAttendee(attendees.current()); |
2875 | attendees.next(); | 2877 | attendees.next(); |
2876 | } | 2878 | } |
2877 | } | 2879 | } |
2878 | bool send = true; | 2880 | bool send = true; |
2879 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 2881 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
2880 | if ( publishdlg->exec() != QDialog::Accepted ) | 2882 | if ( publishdlg->exec() != QDialog::Accepted ) |
2881 | send = false; | 2883 | send = false; |
2882 | } | 2884 | } |
2883 | if ( send ) { | 2885 | if ( send ) { |
2884 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 2886 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
2885 | if ( event ) { | 2887 | if ( event ) { |
2886 | Event *ev = new Event(*event); | 2888 | Event *ev = new Event(*event); |
2887 | ev->registerObserver(0); | 2889 | ev->registerObserver(0); |
2888 | ev->clearAttendees(); | 2890 | ev->clearAttendees(); |
2889 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 2891 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
2890 | delete(ev); | 2892 | delete(ev); |
2891 | } | 2893 | } |
2892 | } else { | 2894 | } else { |
2893 | if ( todo ) { | 2895 | if ( todo ) { |
2894 | Todo *ev = new Todo(*todo); | 2896 | Todo *ev = new Todo(*todo); |
2895 | ev->registerObserver(0); | 2897 | ev->registerObserver(0); |
2896 | ev->clearAttendees(); | 2898 | ev->clearAttendees(); |
2897 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 2899 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
2898 | delete(ev); | 2900 | delete(ev); |
2899 | } | 2901 | } |
2900 | } | 2902 | } |
2901 | } | 2903 | } |
2902 | } | 2904 | } |
2903 | delete publishdlg; | 2905 | delete publishdlg; |
2904 | } | 2906 | } |
2905 | 2907 | ||
2906 | void CalendarView::schedule_request(Incidence *incidence) | 2908 | void CalendarView::schedule_request(Incidence *incidence) |
2907 | { | 2909 | { |
2908 | schedule(Scheduler::Request,incidence); | 2910 | schedule(Scheduler::Request,incidence); |
2909 | } | 2911 | } |
2910 | 2912 | ||
2911 | void CalendarView::schedule_refresh(Incidence *incidence) | 2913 | void CalendarView::schedule_refresh(Incidence *incidence) |
2912 | { | 2914 | { |
2913 | schedule(Scheduler::Refresh,incidence); | 2915 | schedule(Scheduler::Refresh,incidence); |
2914 | } | 2916 | } |
2915 | 2917 | ||
2916 | void CalendarView::schedule_cancel(Incidence *incidence) | 2918 | void CalendarView::schedule_cancel(Incidence *incidence) |
2917 | { | 2919 | { |
2918 | schedule(Scheduler::Cancel,incidence); | 2920 | schedule(Scheduler::Cancel,incidence); |
2919 | } | 2921 | } |
2920 | 2922 | ||
2921 | void CalendarView::schedule_add(Incidence *incidence) | 2923 | void CalendarView::schedule_add(Incidence *incidence) |
2922 | { | 2924 | { |
2923 | schedule(Scheduler::Add,incidence); | 2925 | schedule(Scheduler::Add,incidence); |
2924 | } | 2926 | } |
2925 | 2927 | ||
2926 | void CalendarView::schedule_reply(Incidence *incidence) | 2928 | void CalendarView::schedule_reply(Incidence *incidence) |
2927 | { | 2929 | { |
2928 | schedule(Scheduler::Reply,incidence); | 2930 | schedule(Scheduler::Reply,incidence); |
2929 | } | 2931 | } |
2930 | 2932 | ||
2931 | void CalendarView::schedule_counter(Incidence *incidence) | 2933 | void CalendarView::schedule_counter(Incidence *incidence) |
2932 | { | 2934 | { |
2933 | schedule(Scheduler::Counter,incidence); | 2935 | schedule(Scheduler::Counter,incidence); |
2934 | } | 2936 | } |
2935 | 2937 | ||
2936 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 2938 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
2937 | { | 2939 | { |
2938 | schedule(Scheduler::Declinecounter,incidence); | 2940 | schedule(Scheduler::Declinecounter,incidence); |
2939 | } | 2941 | } |
2940 | 2942 | ||
2941 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 2943 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
2942 | { | 2944 | { |
2943 | QDateTime start = QDateTime::currentDateTime(); | 2945 | QDateTime start = QDateTime::currentDateTime(); |
2944 | QDateTime end = start.addDays(daysToPublish); | 2946 | QDateTime end = start.addDays(daysToPublish); |
2945 | 2947 | ||
2946 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 2948 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
2947 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 2949 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
2948 | 2950 | ||
2949 | 2951 | ||
2950 | PublishDialog *publishdlg = new PublishDialog(); | 2952 | PublishDialog *publishdlg = new PublishDialog(); |
2951 | if ( publishdlg->exec() == QDialog::Accepted ) { | 2953 | if ( publishdlg->exec() == QDialog::Accepted ) { |
2952 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 2954 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
2953 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 2955 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
2954 | delete(freebusy); | 2956 | delete(freebusy); |
2955 | } | 2957 | } |
2956 | } | 2958 | } |
2957 | delete publishdlg; | 2959 | delete publishdlg; |
2958 | } | 2960 | } |
2959 | 2961 | ||
2960 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 2962 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
2961 | { | 2963 | { |
2962 | Event *event = 0; | 2964 | Event *event = 0; |
2963 | Todo *todo = 0; | 2965 | Todo *todo = 0; |
2964 | 2966 | ||
2965 | if (incidence == 0) { | 2967 | if (incidence == 0) { |
2966 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 2968 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
2967 | if (incidence == 0) { | 2969 | if (incidence == 0) { |
2968 | incidence = mTodoList->selectedIncidences().first(); | 2970 | incidence = mTodoList->selectedIncidences().first(); |
2969 | } | 2971 | } |
2970 | } | 2972 | } |
2971 | if ( incidence && incidence->type() == "Event" ) { | 2973 | if ( incidence && incidence->type() == "Event" ) { |
2972 | event = static_cast<Event *>(incidence); | 2974 | event = static_cast<Event *>(incidence); |
2973 | } | 2975 | } |
2974 | if ( incidence && incidence->type() == "Todo" ) { | 2976 | if ( incidence && incidence->type() == "Todo" ) { |
2975 | todo = static_cast<Todo *>(incidence); | 2977 | todo = static_cast<Todo *>(incidence); |
2976 | } | 2978 | } |
2977 | 2979 | ||
2978 | if (!event && !todo) { | 2980 | if (!event && !todo) { |
2979 | KMessageBox::sorry(this,i18n("No event selected.")); | 2981 | KMessageBox::sorry(this,i18n("No event selected.")); |
2980 | return; | 2982 | return; |
2981 | } | 2983 | } |
2982 | 2984 | ||
2983 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 2985 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
2984 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 2986 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
2985 | return; | 2987 | return; |
2986 | } | 2988 | } |
2987 | 2989 | ||
2988 | Event *ev = 0; | 2990 | Event *ev = 0; |
2989 | if (event) ev = new Event(*event); | 2991 | if (event) ev = new Event(*event); |
2990 | Todo *to = 0; | 2992 | Todo *to = 0; |
2991 | if (todo) to = new Todo(*todo); | 2993 | if (todo) to = new Todo(*todo); |
2992 | 2994 | ||
2993 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 2995 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
2994 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 2996 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
2995 | if (!me) { | 2997 | if (!me) { |
2996 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 2998 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
2997 | return; | 2999 | return; |
2998 | } | 3000 | } |
2999 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3001 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3000 | StatusDialog *statdlg = new StatusDialog(this); | 3002 | StatusDialog *statdlg = new StatusDialog(this); |
3001 | if (!statdlg->exec()==QDialog::Accepted) return; | 3003 | if (!statdlg->exec()==QDialog::Accepted) return; |
3002 | me->setStatus( statdlg->status() ); | 3004 | me->setStatus( statdlg->status() ); |
3003 | delete(statdlg); | 3005 | delete(statdlg); |
3004 | } | 3006 | } |
3005 | Attendee *menew = new Attendee(*me); | 3007 | Attendee *menew = new Attendee(*me); |
3006 | if (ev) { | 3008 | if (ev) { |
3007 | ev->clearAttendees(); | 3009 | ev->clearAttendees(); |
3008 | ev->addAttendee(menew,false); | 3010 | ev->addAttendee(menew,false); |
3009 | } else { | 3011 | } else { |
3010 | if (to) { | 3012 | if (to) { |
3011 | todo->clearAttendees(); | 3013 | todo->clearAttendees(); |
3012 | todo->addAttendee(menew,false); | 3014 | todo->addAttendee(menew,false); |
3013 | } | 3015 | } |
3014 | } | 3016 | } |
3015 | } | 3017 | } |
3016 | 3018 | ||
3017 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3019 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3018 | if (ev) { | 3020 | if (ev) { |
3019 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3021 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3020 | } else { | 3022 | } else { |
3021 | if (to) { | 3023 | if (to) { |
3022 | if ( !dlg->addMessage(to,method) ) delete(to); | 3024 | if ( !dlg->addMessage(to,method) ) delete(to); |
3023 | } | 3025 | } |
3024 | } | 3026 | } |
3025 | } | 3027 | } |
3026 | 3028 | ||
3027 | void CalendarView::openAddressbook() | 3029 | void CalendarView::openAddressbook() |
3028 | { | 3030 | { |
3029 | KRun::runCommand("kaddressbook"); | 3031 | KRun::runCommand("kaddressbook"); |
3030 | } | 3032 | } |
3031 | 3033 | ||
3032 | void CalendarView::setModified(bool modified) | 3034 | void CalendarView::setModified(bool modified) |
3033 | { | 3035 | { |
3034 | if ( modified ) | 3036 | if ( modified ) |
3035 | emit signalmodified(); | 3037 | emit signalmodified(); |
3036 | if (mModified != modified) { | 3038 | if (mModified != modified) { |
3037 | mModified = modified; | 3039 | mModified = modified; |
3038 | emit modifiedChanged(mModified); | 3040 | emit modifiedChanged(mModified); |
3039 | } | 3041 | } |
3040 | } | 3042 | } |
3041 | 3043 | ||
3042 | bool CalendarView::isReadOnly() | 3044 | bool CalendarView::isReadOnly() |
3043 | { | 3045 | { |
3044 | return mReadOnly; | 3046 | return mReadOnly; |
3045 | } | 3047 | } |
3046 | 3048 | ||
3047 | void CalendarView::setReadOnly(bool readOnly) | 3049 | void CalendarView::setReadOnly(bool readOnly) |
3048 | { | 3050 | { |
3049 | if (mReadOnly != readOnly) { | 3051 | if (mReadOnly != readOnly) { |
3050 | mReadOnly = readOnly; | 3052 | mReadOnly = readOnly; |
3051 | emit readOnlyChanged(mReadOnly); | 3053 | emit readOnlyChanged(mReadOnly); |
3052 | } | 3054 | } |
3053 | } | 3055 | } |
3054 | 3056 | ||
3055 | bool CalendarView::isModified() | 3057 | bool CalendarView::isModified() |
3056 | { | 3058 | { |
3057 | return mModified; | 3059 | return mModified; |
3058 | } | 3060 | } |
3059 | 3061 | ||
3060 | void CalendarView::printSetup() | 3062 | void CalendarView::printSetup() |
3061 | { | 3063 | { |
3062 | #ifndef KORG_NOPRINTER | 3064 | #ifndef KORG_NOPRINTER |
3063 | createPrinter(); | 3065 | createPrinter(); |
3064 | 3066 | ||
3065 | mCalPrinter->setupPrinter(); | 3067 | mCalPrinter->setupPrinter(); |
3066 | #endif | 3068 | #endif |
3067 | } | 3069 | } |
3068 | 3070 | ||
3069 | void CalendarView::print() | 3071 | void CalendarView::print() |
3070 | { | 3072 | { |
3071 | #ifndef KORG_NOPRINTER | 3073 | #ifndef KORG_NOPRINTER |
3072 | createPrinter(); | 3074 | createPrinter(); |
3073 | 3075 | ||
3074 | DateList tmpDateList = mNavigator->selectedDates(); | 3076 | DateList tmpDateList = mNavigator->selectedDates(); |
3075 | mCalPrinter->print(CalPrinter::Month, | 3077 | mCalPrinter->print(CalPrinter::Month, |
3076 | tmpDateList.first(), tmpDateList.last()); | 3078 | tmpDateList.first(), tmpDateList.last()); |
3077 | #endif | 3079 | #endif |
3078 | } | 3080 | } |
3079 | 3081 | ||
3080 | void CalendarView::printPreview() | 3082 | void CalendarView::printPreview() |
3081 | { | 3083 | { |
3082 | #ifndef KORG_NOPRINTER | 3084 | #ifndef KORG_NOPRINTER |
3083 | kdDebug() << "CalendarView::printPreview()" << endl; | 3085 | kdDebug() << "CalendarView::printPreview()" << endl; |
3084 | 3086 | ||
3085 | createPrinter(); | 3087 | createPrinter(); |
3086 | 3088 | ||
3087 | DateList tmpDateList = mNavigator->selectedDates(); | 3089 | DateList tmpDateList = mNavigator->selectedDates(); |
3088 | 3090 | ||
3089 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3091 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3090 | tmpDateList.last()); | 3092 | tmpDateList.last()); |
3091 | #endif | 3093 | #endif |
3092 | } | 3094 | } |
3093 | 3095 | ||
3094 | void CalendarView::exportICalendar() | 3096 | void CalendarView::exportICalendar() |
3095 | { | 3097 | { |
3096 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3098 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3097 | 3099 | ||
3098 | // Force correct extension | 3100 | // Force correct extension |
3099 | if (filename.right(4) != ".ics") filename += ".ics"; | 3101 | if (filename.right(4) != ".ics") filename += ".ics"; |
3100 | 3102 | ||
3101 | FileStorage storage( mCalendar, filename, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 3103 | FileStorage storage( mCalendar, filename, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
3102 | storage.save(); | 3104 | storage.save(); |
3103 | } | 3105 | } |
3104 | 3106 | ||
3105 | bool CalendarView::exportVCalendar( QString filename ) | 3107 | bool CalendarView::exportVCalendar( QString filename ) |
3106 | { | 3108 | { |
3107 | if (mCalendar->journals().count() > 0) { | 3109 | if (mCalendar->journals().count() > 0) { |
3108 | int result = KMessageBox::warningContinueCancel(this, | 3110 | int result = KMessageBox::warningContinueCancel(this, |
3109 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3111 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3110 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3112 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3111 | true); | 3113 | true); |
3112 | if (result != KMessageBox::Continue) return false; | 3114 | if (result != KMessageBox::Continue) return false; |
3113 | } | 3115 | } |
3114 | 3116 | ||
3115 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3117 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3116 | 3118 | ||
3117 | // Force correct extension | 3119 | // Force correct extension |
3118 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3120 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3119 | 3121 | ||
3120 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3122 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3121 | return storage.save(); | 3123 | return storage.save(); |
3122 | 3124 | ||
3123 | } | 3125 | } |
3124 | 3126 | ||
3125 | void CalendarView::eventUpdated(Incidence *) | 3127 | void CalendarView::eventUpdated(Incidence *) |
3126 | { | 3128 | { |
3127 | setModified(); | 3129 | setModified(); |
3128 | // Don't call updateView here. The code, which has caused the update of the | 3130 | // Don't call updateView here. The code, which has caused the update of the |
3129 | // event is responsible for updating the view. | 3131 | // event is responsible for updating the view. |
3130 | // updateView(); | 3132 | // updateView(); |
3131 | } | 3133 | } |
3132 | 3134 | ||
3133 | void CalendarView::adaptNavigationUnits() | 3135 | void CalendarView::adaptNavigationUnits() |
3134 | { | 3136 | { |
3135 | if (mViewManager->currentView()->isEventView()) { | 3137 | if (mViewManager->currentView()->isEventView()) { |
3136 | int days = mViewManager->currentView()->currentDateCount(); | 3138 | int days = mViewManager->currentView()->currentDateCount(); |
3137 | if (days == 1) { | 3139 | if (days == 1) { |
3138 | emit changeNavStringPrev(i18n("&Previous Day")); | 3140 | emit changeNavStringPrev(i18n("&Previous Day")); |
3139 | emit changeNavStringNext(i18n("&Next Day")); | 3141 | emit changeNavStringNext(i18n("&Next Day")); |
3140 | } else { | 3142 | } else { |
3141 | emit changeNavStringPrev(i18n("&Previous Week")); | 3143 | emit changeNavStringPrev(i18n("&Previous Week")); |
3142 | emit changeNavStringNext(i18n("&Next Week")); | 3144 | emit changeNavStringNext(i18n("&Next Week")); |
3143 | } | 3145 | } |
3144 | } | 3146 | } |
3145 | } | 3147 | } |
3146 | 3148 | ||
3147 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 3149 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
3148 | { | 3150 | { |
3149 | if ( incidence ) mTodoList->clearSelection(); | 3151 | if ( incidence ) mTodoList->clearSelection(); |
3150 | processIncidenceSelection( incidence ); | 3152 | processIncidenceSelection( incidence ); |
3151 | } | 3153 | } |
3152 | 3154 | ||
3153 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 3155 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
3154 | { | 3156 | { |
3155 | if ( incidence && mViewManager->currentView() ) { | 3157 | if ( incidence && mViewManager->currentView() ) { |
3156 | mViewManager->currentView()->clearSelection(); | 3158 | mViewManager->currentView()->clearSelection(); |
3157 | } | 3159 | } |
3158 | processIncidenceSelection( incidence ); | 3160 | processIncidenceSelection( incidence ); |
3159 | } | 3161 | } |
3160 | 3162 | ||
3161 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 3163 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
3162 | { | 3164 | { |
3163 | if ( incidence == mSelectedIncidence ) return; | 3165 | if ( incidence == mSelectedIncidence ) return; |
3164 | 3166 | ||
3165 | mSelectedIncidence = incidence; | 3167 | mSelectedIncidence = incidence; |
3166 | 3168 | ||
3167 | emit incidenceSelected( mSelectedIncidence ); | 3169 | emit incidenceSelected( mSelectedIncidence ); |
3168 | 3170 | ||
3169 | if ( incidence && incidence->type() == "Event" ) { | 3171 | if ( incidence && incidence->type() == "Event" ) { |
3170 | Event *event = static_cast<Event *>( incidence ); | 3172 | Event *event = static_cast<Event *>( incidence ); |
3171 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3173 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3172 | emit organizerEventsSelected( true ); | 3174 | emit organizerEventsSelected( true ); |
3173 | } else { | 3175 | } else { |
3174 | emit organizerEventsSelected(false); | 3176 | emit organizerEventsSelected(false); |
3175 | } | 3177 | } |
3176 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3178 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3177 | KOPrefs::instance()->email() ) ) { | 3179 | KOPrefs::instance()->email() ) ) { |
3178 | emit groupEventsSelected( true ); | 3180 | emit groupEventsSelected( true ); |
3179 | } else { | 3181 | } else { |
3180 | emit groupEventsSelected(false); | 3182 | emit groupEventsSelected(false); |
3181 | } | 3183 | } |
3182 | return; | 3184 | return; |
3183 | } else { | 3185 | } else { |
3184 | if ( incidence && incidence->type() == "Todo" ) { | 3186 | if ( incidence && incidence->type() == "Todo" ) { |
3185 | emit todoSelected( true ); | 3187 | emit todoSelected( true ); |
3186 | Todo *event = static_cast<Todo *>( incidence ); | 3188 | Todo *event = static_cast<Todo *>( incidence ); |
3187 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3189 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3188 | emit organizerEventsSelected( true ); | 3190 | emit organizerEventsSelected( true ); |
3189 | } else { | 3191 | } else { |
3190 | emit organizerEventsSelected(false); | 3192 | emit organizerEventsSelected(false); |
3191 | } | 3193 | } |
3192 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3194 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3193 | KOPrefs::instance()->email() ) ) { | 3195 | KOPrefs::instance()->email() ) ) { |
3194 | emit groupEventsSelected( true ); | 3196 | emit groupEventsSelected( true ); |
3195 | } else { | 3197 | } else { |
3196 | emit groupEventsSelected(false); | 3198 | emit groupEventsSelected(false); |
3197 | } | 3199 | } |
3198 | return; | 3200 | return; |
3199 | } else { | 3201 | } else { |
3200 | emit todoSelected( false ); | 3202 | emit todoSelected( false ); |
3201 | emit organizerEventsSelected(false); | 3203 | emit organizerEventsSelected(false); |
3202 | emit groupEventsSelected(false); | 3204 | emit groupEventsSelected(false); |
3203 | } | 3205 | } |
3204 | return; | 3206 | return; |
3205 | } | 3207 | } |
3206 | 3208 | ||
3207 | /* if ( incidence && incidence->type() == "Todo" ) { | 3209 | /* if ( incidence && incidence->type() == "Todo" ) { |
3208 | emit todoSelected( true ); | 3210 | emit todoSelected( true ); |
3209 | } else { | 3211 | } else { |
3210 | emit todoSelected( false ); | 3212 | emit todoSelected( false ); |
3211 | }*/ | 3213 | }*/ |
3212 | } | 3214 | } |
3213 | 3215 | ||
3214 | 3216 | ||
3215 | void CalendarView::checkClipboard() | 3217 | void CalendarView::checkClipboard() |
3216 | { | 3218 | { |
3217 | #ifndef KORG_NODND | 3219 | #ifndef KORG_NODND |
3218 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 3220 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
3219 | emit pasteEnabled(true); | 3221 | emit pasteEnabled(true); |
3220 | } else { | 3222 | } else { |
3221 | emit pasteEnabled(false); | 3223 | emit pasteEnabled(false); |
3222 | } | 3224 | } |
3223 | #endif | 3225 | #endif |
3224 | } | 3226 | } |
3225 | 3227 | ||
3226 | void CalendarView::showDates(const DateList &selectedDates) | 3228 | void CalendarView::showDates(const DateList &selectedDates) |
3227 | { | 3229 | { |
3228 | // kdDebug() << "CalendarView::selectDates()" << endl; | 3230 | // kdDebug() << "CalendarView::selectDates()" << endl; |
3229 | 3231 | ||
3230 | if ( mViewManager->currentView() ) { | 3232 | if ( mViewManager->currentView() ) { |
3231 | updateView( selectedDates.first(), selectedDates.last() ); | 3233 | updateView( selectedDates.first(), selectedDates.last() ); |
3232 | } else { | 3234 | } else { |
3233 | mViewManager->showAgendaView(); | 3235 | mViewManager->showAgendaView(); |
3234 | } | 3236 | } |
3235 | 3237 | ||
3236 | QString selDates; | 3238 | QString selDates; |
3237 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); | 3239 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); |
3238 | if (selectedDates.first() < selectedDates.last() ) | 3240 | if (selectedDates.first() < selectedDates.last() ) |
3239 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 3241 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
3240 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 3242 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
3241 | 3243 | ||
3242 | } | 3244 | } |
3243 | 3245 | ||
3244 | QPtrList<CalFilter> CalendarView::filters() | 3246 | QPtrList<CalFilter> CalendarView::filters() |
3245 | { | 3247 | { |
3246 | return mFilters; | 3248 | return mFilters; |
3247 | 3249 | ||
3248 | } | 3250 | } |
3249 | void CalendarView::editFilters() | 3251 | void CalendarView::editFilters() |
3250 | { | 3252 | { |
3251 | // kdDebug() << "CalendarView::editFilters()" << endl; | 3253 | // kdDebug() << "CalendarView::editFilters()" << endl; |
3252 | 3254 | ||
3253 | CalFilter *filter = mFilters.first(); | 3255 | CalFilter *filter = mFilters.first(); |
3254 | while(filter) { | 3256 | while(filter) { |
3255 | kdDebug() << " Filter: " << filter->name() << endl; | 3257 | kdDebug() << " Filter: " << filter->name() << endl; |
3256 | filter = mFilters.next(); | 3258 | filter = mFilters.next(); |
3257 | } | 3259 | } |
3258 | 3260 | ||
3259 | mDialogManager->showFilterEditDialog(&mFilters); | 3261 | mDialogManager->showFilterEditDialog(&mFilters); |
3260 | } | 3262 | } |
3261 | void CalendarView::toggleFilter() | 3263 | void CalendarView::toggleFilter() |
3262 | { | 3264 | { |
3263 | showFilter(! mFilterView->isVisible()); | 3265 | showFilter(! mFilterView->isVisible()); |
3264 | } | 3266 | } |
3265 | 3267 | ||
3266 | KOFilterView *CalendarView::filterView() | 3268 | KOFilterView *CalendarView::filterView() |
3267 | { | 3269 | { |
3268 | return mFilterView; | 3270 | return mFilterView; |
3269 | } | 3271 | } |
3270 | void CalendarView::selectFilter( int fil ) | 3272 | void CalendarView::selectFilter( int fil ) |
3271 | { | 3273 | { |
3272 | mFilterView->setSelectedFilter( fil ); | 3274 | mFilterView->setSelectedFilter( fil ); |
3273 | } | 3275 | } |
3274 | void CalendarView::showFilter(bool visible) | 3276 | void CalendarView::showFilter(bool visible) |
3275 | { | 3277 | { |
3276 | if (visible) mFilterView->show(); | 3278 | if (visible) mFilterView->show(); |
3277 | else mFilterView->hide(); | 3279 | else mFilterView->hide(); |
3278 | } | 3280 | } |
3279 | void CalendarView::toggleFilerEnabled( ) | 3281 | void CalendarView::toggleFilerEnabled( ) |
3280 | { | 3282 | { |
3281 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 3283 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
3282 | if ( !mFilterView->filtersEnabled() ) | 3284 | if ( !mFilterView->filtersEnabled() ) |
3283 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 3285 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
3284 | 3286 | ||
3285 | } | 3287 | } |
3286 | void CalendarView::updateFilter() | 3288 | void CalendarView::updateFilter() |
3287 | { | 3289 | { |
3288 | CalFilter *filter = mFilterView->selectedFilter(); | 3290 | CalFilter *filter = mFilterView->selectedFilter(); |
3289 | if (filter) { | 3291 | if (filter) { |
3290 | if (mFilterView->filtersEnabled()) { | 3292 | if (mFilterView->filtersEnabled()) { |
3291 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); | 3293 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); |
3292 | filter->setEnabled(true); | 3294 | filter->setEnabled(true); |
3293 | } | 3295 | } |
3294 | else filter->setEnabled(false); | 3296 | else filter->setEnabled(false); |
3295 | mCalendar->setFilter(filter); | 3297 | mCalendar->setFilter(filter); |
3296 | updateView(); | 3298 | updateView(); |
3297 | } | 3299 | } |
3298 | } | 3300 | } |
3299 | 3301 | ||
3300 | void CalendarView::filterEdited() | 3302 | void CalendarView::filterEdited() |
3301 | { | 3303 | { |
3302 | mFilterView->updateFilters(); | 3304 | mFilterView->updateFilters(); |
3303 | updateFilter(); | 3305 | updateFilter(); |
3304 | writeSettings(); | 3306 | writeSettings(); |
3305 | } | 3307 | } |
3306 | 3308 | ||
3307 | 3309 | ||
3308 | void CalendarView::takeOverEvent() | 3310 | void CalendarView::takeOverEvent() |
3309 | { | 3311 | { |
3310 | Incidence *incidence = currentSelection(); | 3312 | Incidence *incidence = currentSelection(); |
3311 | 3313 | ||
3312 | if (!incidence) return; | 3314 | if (!incidence) return; |
3313 | 3315 | ||
3314 | incidence->setOrganizer(KOPrefs::instance()->email()); | 3316 | incidence->setOrganizer(KOPrefs::instance()->email()); |
3315 | incidence->recreate(); | 3317 | incidence->recreate(); |
3316 | incidence->setReadOnly(false); | 3318 | incidence->setReadOnly(false); |
3317 | 3319 | ||
3318 | updateView(); | 3320 | updateView(); |
3319 | } | 3321 | } |
3320 | 3322 | ||
3321 | void CalendarView::takeOverCalendar() | 3323 | void CalendarView::takeOverCalendar() |
3322 | { | 3324 | { |
3323 | // TODO: Create Calendar::allIncidences() function and use it here | 3325 | // TODO: Create Calendar::allIncidences() function and use it here |
3324 | 3326 | ||
3325 | QPtrList<Event> events = mCalendar->events(); | 3327 | QPtrList<Event> events = mCalendar->events(); |
3326 | for(uint i=0; i<events.count(); ++i) { | 3328 | for(uint i=0; i<events.count(); ++i) { |
3327 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3329 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3328 | events.at(i)->recreate(); | 3330 | events.at(i)->recreate(); |
3329 | events.at(i)->setReadOnly(false); | 3331 | events.at(i)->setReadOnly(false); |
3330 | } | 3332 | } |
3331 | 3333 | ||
3332 | QPtrList<Todo> todos = mCalendar->todos(); | 3334 | QPtrList<Todo> todos = mCalendar->todos(); |
3333 | for(uint i=0; i<todos.count(); ++i) { | 3335 | for(uint i=0; i<todos.count(); ++i) { |
3334 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3336 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3335 | todos.at(i)->recreate(); | 3337 | todos.at(i)->recreate(); |
3336 | todos.at(i)->setReadOnly(false); | 3338 | todos.at(i)->setReadOnly(false); |
3337 | } | 3339 | } |
3338 | 3340 | ||
3339 | QPtrList<Journal> journals = mCalendar->journals(); | 3341 | QPtrList<Journal> journals = mCalendar->journals(); |
3340 | for(uint i=0; i<journals.count(); ++i) { | 3342 | for(uint i=0; i<journals.count(); ++i) { |
3341 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3343 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3342 | journals.at(i)->recreate(); | 3344 | journals.at(i)->recreate(); |
3343 | journals.at(i)->setReadOnly(false); | 3345 | journals.at(i)->setReadOnly(false); |
3344 | } | 3346 | } |
3345 | 3347 | ||
3346 | updateView(); | 3348 | updateView(); |
3347 | } | 3349 | } |
3348 | 3350 | ||
3349 | void CalendarView::showIntro() | 3351 | void CalendarView::showIntro() |
3350 | { | 3352 | { |
3351 | kdDebug() << "To be implemented." << endl; | 3353 | kdDebug() << "To be implemented." << endl; |
3352 | } | 3354 | } |
3353 | 3355 | ||
3354 | QWidgetStack *CalendarView::viewStack() | 3356 | QWidgetStack *CalendarView::viewStack() |
3355 | { | 3357 | { |
3356 | return mRightFrame; | 3358 | return mRightFrame; |
3357 | } | 3359 | } |
3358 | 3360 | ||
3359 | QWidget *CalendarView::leftFrame() | 3361 | QWidget *CalendarView::leftFrame() |
3360 | { | 3362 | { |
3361 | return mLeftFrame; | 3363 | return mLeftFrame; |
3362 | } | 3364 | } |
3363 | 3365 | ||
3364 | DateNavigator *CalendarView::dateNavigator() | 3366 | DateNavigator *CalendarView::dateNavigator() |
3365 | { | 3367 | { |
3366 | return mNavigator; | 3368 | return mNavigator; |
3367 | } | 3369 | } |
3368 | 3370 | ||
3369 | KDateNavigator* CalendarView::dateNavigatorWidget() | 3371 | KDateNavigator* CalendarView::dateNavigatorWidget() |
3370 | { | 3372 | { |
3371 | return mDateNavigator; | 3373 | return mDateNavigator; |
3372 | } | 3374 | } |
3373 | void CalendarView::toggleDateNavigatorWidget() | 3375 | void CalendarView::toggleDateNavigatorWidget() |
3374 | { | 3376 | { |
3375 | if (mDateNavigator->isVisible()) | 3377 | if (mDateNavigator->isVisible()) |
3376 | mDateNavigator->hide(); | 3378 | mDateNavigator->hide(); |
3377 | else | 3379 | else |
3378 | mDateNavigator->show(); | 3380 | mDateNavigator->show(); |
3379 | } | 3381 | } |
3380 | void CalendarView::addView(KOrg::BaseView *view) | 3382 | void CalendarView::addView(KOrg::BaseView *view) |
3381 | { | 3383 | { |
3382 | mViewManager->addView(view); | 3384 | mViewManager->addView(view); |
3383 | } | 3385 | } |
3384 | 3386 | ||
3385 | void CalendarView::showView(KOrg::BaseView *view) | 3387 | void CalendarView::showView(KOrg::BaseView *view) |
3386 | { | 3388 | { |
3387 | mViewManager->showView(view, mLeftFrame->isVisible()); | 3389 | mViewManager->showView(view, mLeftFrame->isVisible()); |
3388 | } | 3390 | } |
3389 | 3391 | ||
3390 | Incidence *CalendarView::currentSelection() | 3392 | Incidence *CalendarView::currentSelection() |
3391 | { | 3393 | { |
3392 | return mViewManager->currentSelection(); | 3394 | return mViewManager->currentSelection(); |
3393 | } | 3395 | } |
3394 | void CalendarView::toggleAllDaySize() | 3396 | void CalendarView::toggleAllDaySize() |
3395 | { | 3397 | { |
3396 | /* | 3398 | /* |
3397 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 3399 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
3398 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 3400 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
3399 | else | 3401 | else |
3400 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 3402 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
3401 | */ | 3403 | */ |
3402 | viewManager()->agendaView()->toggleAllDay(); | 3404 | viewManager()->agendaView()->toggleAllDay(); |
3403 | } | 3405 | } |
3404 | void CalendarView::toggleExpand() | 3406 | void CalendarView::toggleExpand() |
3405 | { | 3407 | { |
3406 | // if ( mLeftFrame->isHidden() ) { | 3408 | // if ( mLeftFrame->isHidden() ) { |
3407 | // mLeftFrame->show(); | 3409 | // mLeftFrame->show(); |
3408 | // emit calendarViewExpanded( false ); | 3410 | // emit calendarViewExpanded( false ); |
3409 | // } else { | 3411 | // } else { |
3410 | // mLeftFrame->hide(); | 3412 | // mLeftFrame->hide(); |
3411 | // emit calendarViewExpanded( true ); | 3413 | // emit calendarViewExpanded( true ); |
3412 | // } | 3414 | // } |
3413 | 3415 | ||
3414 | globalFlagBlockAgenda = 1; | 3416 | globalFlagBlockAgenda = 1; |
3415 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 3417 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
3416 | globalFlagBlockAgenda = 5; | 3418 | globalFlagBlockAgenda = 5; |
3417 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 3419 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
3418 | //mViewManager->showView( 0, true ); | 3420 | //mViewManager->showView( 0, true ); |
3419 | } | 3421 | } |
3420 | 3422 | ||
3421 | void CalendarView::calendarModified( bool modified, Calendar * ) | 3423 | void CalendarView::calendarModified( bool modified, Calendar * ) |
3422 | { | 3424 | { |
3423 | setModified( modified ); | 3425 | setModified( modified ); |
3424 | } | 3426 | } |
3425 | 3427 | ||
3426 | Todo *CalendarView::selectedTodo() | 3428 | Todo *CalendarView::selectedTodo() |
3427 | { | 3429 | { |
3428 | Incidence *incidence = currentSelection(); | 3430 | Incidence *incidence = currentSelection(); |
3429 | if ( incidence && incidence->type() == "Todo" ) { | 3431 | if ( incidence && incidence->type() == "Todo" ) { |
3430 | return static_cast<Todo *>( incidence ); | 3432 | return static_cast<Todo *>( incidence ); |
3431 | } | 3433 | } |
3432 | 3434 | ||
3433 | incidence = mTodoList->selectedIncidences().first(); | 3435 | incidence = mTodoList->selectedIncidences().first(); |
3434 | if ( incidence && incidence->type() == "Todo" ) { | 3436 | if ( incidence && incidence->type() == "Todo" ) { |
3435 | return static_cast<Todo *>( incidence ); | 3437 | return static_cast<Todo *>( incidence ); |
3436 | } | 3438 | } |
3437 | 3439 | ||
3438 | return 0; | 3440 | return 0; |
3439 | } | 3441 | } |
3440 | 3442 | ||
3441 | void CalendarView::dialogClosing(Incidence *in) | 3443 | void CalendarView::dialogClosing(Incidence *in) |
3442 | { | 3444 | { |
3443 | // mDialogList.remove(in); | 3445 | // mDialogList.remove(in); |
3444 | } | 3446 | } |
3445 | 3447 | ||
3446 | void CalendarView::showIncidence() | 3448 | void CalendarView::showIncidence() |
3447 | { | 3449 | { |
3448 | Incidence *incidence = currentSelection(); | 3450 | Incidence *incidence = currentSelection(); |
3449 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3451 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3450 | if ( incidence ) { | 3452 | if ( incidence ) { |
3451 | ShowIncidenceVisitor v; | 3453 | ShowIncidenceVisitor v; |
3452 | v.act( incidence, this ); | 3454 | v.act( incidence, this ); |
3453 | } | 3455 | } |
3454 | } | 3456 | } |
3455 | void CalendarView::editIncidenceDescription() | 3457 | void CalendarView::editIncidenceDescription() |
3456 | { | 3458 | { |
3457 | mFlagEditDescription = true; | 3459 | mFlagEditDescription = true; |
3458 | editIncidence(); | 3460 | editIncidence(); |
3459 | mFlagEditDescription = false; | 3461 | mFlagEditDescription = false; |
3460 | } | 3462 | } |
3461 | void CalendarView::editIncidence() | 3463 | void CalendarView::editIncidence() |
3462 | { | 3464 | { |
3463 | // qDebug("editIncidence() "); | 3465 | // qDebug("editIncidence() "); |
3464 | Incidence *incidence = currentSelection(); | 3466 | Incidence *incidence = currentSelection(); |
3465 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3467 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3466 | if ( incidence ) { | 3468 | if ( incidence ) { |
3467 | EditIncidenceVisitor v; | 3469 | EditIncidenceVisitor v; |
3468 | v.act( incidence, this ); | 3470 | v.act( incidence, this ); |
3469 | } | 3471 | } |
3470 | } | 3472 | } |
3471 | 3473 | ||
3472 | void CalendarView::deleteIncidence() | 3474 | void CalendarView::deleteIncidence() |
3473 | { | 3475 | { |
3474 | Incidence *incidence = currentSelection(); | 3476 | Incidence *incidence = currentSelection(); |
3475 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3477 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3476 | if ( incidence ) { | 3478 | if ( incidence ) { |
3477 | deleteIncidence(incidence); | 3479 | deleteIncidence(incidence); |
3478 | } | 3480 | } |
3479 | } | 3481 | } |
3480 | 3482 | ||
3481 | void CalendarView::showIncidence(Incidence *incidence) | 3483 | void CalendarView::showIncidence(Incidence *incidence) |
3482 | { | 3484 | { |
3483 | if ( incidence ) { | 3485 | if ( incidence ) { |
3484 | ShowIncidenceVisitor v; | 3486 | ShowIncidenceVisitor v; |
3485 | v.act( incidence, this ); | 3487 | v.act( incidence, this ); |
3486 | } | 3488 | } |
3487 | } | 3489 | } |
3488 | 3490 | ||
3489 | void CalendarView::editIncidence(Incidence *incidence) | 3491 | void CalendarView::editIncidence(Incidence *incidence) |
3490 | { | 3492 | { |
3491 | if ( incidence ) { | 3493 | if ( incidence ) { |
3492 | 3494 | ||
3493 | EditIncidenceVisitor v; | 3495 | EditIncidenceVisitor v; |
3494 | v.act( incidence, this ); | 3496 | v.act( incidence, this ); |
3495 | 3497 | ||
3496 | } | 3498 | } |
3497 | } | 3499 | } |
3498 | 3500 | ||
3499 | void CalendarView::deleteIncidence(Incidence *incidence) | 3501 | void CalendarView::deleteIncidence(Incidence *incidence) |
3500 | { | 3502 | { |
3501 | //qDebug(" CalendarView::deleteIncidence "); | 3503 | //qDebug(" CalendarView::deleteIncidence "); |
3502 | if ( incidence ) { | 3504 | if ( incidence ) { |
3503 | DeleteIncidenceVisitor v; | 3505 | DeleteIncidenceVisitor v; |
3504 | v.act( incidence, this ); | 3506 | v.act( incidence, this ); |
3505 | } | 3507 | } |
3506 | } | 3508 | } |
3507 | 3509 | ||
3508 | 3510 | ||
3509 | void CalendarView::lookForOutgoingMessages() | 3511 | void CalendarView::lookForOutgoingMessages() |
3510 | { | 3512 | { |
3511 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 3513 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
3512 | ogd->loadMessages(); | 3514 | ogd->loadMessages(); |
3513 | } | 3515 | } |
3514 | 3516 | ||
3515 | void CalendarView::lookForIncomingMessages() | 3517 | void CalendarView::lookForIncomingMessages() |
3516 | { | 3518 | { |
3517 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 3519 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
3518 | icd->retrieve(); | 3520 | icd->retrieve(); |
3519 | } | 3521 | } |
3520 | 3522 | ||
3521 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 3523 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
3522 | { | 3524 | { |
3523 | bool deleteTodo = true; | 3525 | bool deleteTodo = true; |
3524 | QPtrList<Incidence> subTodos; | 3526 | QPtrList<Incidence> subTodos; |
3525 | Incidence *aTodo; | 3527 | Incidence *aTodo; |
3526 | subTodos = t->relations(); | 3528 | subTodos = t->relations(); |
3527 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 3529 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
3528 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 3530 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
3529 | deleteTodo = false; | 3531 | deleteTodo = false; |
3530 | } | 3532 | } |
3531 | if ( deleteTodo ) { | 3533 | if ( deleteTodo ) { |
3532 | if ( t->isCompleted() ) { | 3534 | if ( t->isCompleted() ) { |
3533 | checkExternalId( t ); | 3535 | checkExternalId( t ); |
3534 | mCalendar->deleteTodo( t ); | 3536 | mCalendar->deleteTodo( t ); |
3535 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 3537 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
3536 | } | 3538 | } |
3537 | else | 3539 | else |
3538 | deleteTodo = false; | 3540 | deleteTodo = false; |
3539 | } | 3541 | } |
3540 | return deleteTodo; | 3542 | return deleteTodo; |
3541 | 3543 | ||
3542 | } | 3544 | } |
3543 | void CalendarView::purgeCompleted() | 3545 | void CalendarView::purgeCompleted() |
3544 | { | 3546 | { |
3545 | int result = KMessageBox::warningContinueCancel(this, | 3547 | int result = KMessageBox::warningContinueCancel(this, |
3546 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); | 3548 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); |
3547 | 3549 | ||
3548 | if (result == KMessageBox::Continue) { | 3550 | if (result == KMessageBox::Continue) { |
3549 | 3551 | ||
3550 | QPtrList<Todo> todoCal; | 3552 | QPtrList<Todo> todoCal; |
3551 | QPtrList<Todo> rootTodos; | 3553 | QPtrList<Todo> rootTodos; |
3552 | //QPtrList<Incidence> rel; | 3554 | //QPtrList<Incidence> rel; |
3553 | Todo *aTodo;//, *rTodo; | 3555 | Todo *aTodo;//, *rTodo; |
3554 | Incidence *rIncidence; | 3556 | Incidence *rIncidence; |
3555 | bool childDelete = false; | 3557 | bool childDelete = false; |
3556 | bool deletedOne = true; | 3558 | bool deletedOne = true; |
3557 | todoCal = calendar()->todos(); | 3559 | todoCal = calendar()->todos(); |
3558 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 3560 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
3559 | if ( !aTodo->relatedTo() ) | 3561 | if ( !aTodo->relatedTo() ) |
3560 | rootTodos.append( aTodo ); | 3562 | rootTodos.append( aTodo ); |
3561 | } | 3563 | } |
3562 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 3564 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
3563 | removeCompletedSubTodos( aTodo ); | 3565 | removeCompletedSubTodos( aTodo ); |
3564 | } | 3566 | } |
3565 | 3567 | ||
3566 | updateView(); | 3568 | updateView(); |
3567 | } | 3569 | } |
3568 | } | 3570 | } |
3569 | 3571 | ||
3570 | void CalendarView::slotCalendarChanged() | 3572 | void CalendarView::slotCalendarChanged() |
3571 | { | 3573 | { |
3572 | ; | 3574 | ; |
3573 | } | 3575 | } |
3574 | 3576 | ||
3575 | NavigatorBar *CalendarView::navigatorBar() | 3577 | NavigatorBar *CalendarView::navigatorBar() |
3576 | { | 3578 | { |
3577 | return mNavigatorBar; | 3579 | return mNavigatorBar; |
3578 | } | 3580 | } |
3579 | 3581 | ||
3580 | 3582 | ||
3581 | 3583 | ||
3582 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 3584 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
3583 | { | 3585 | { |
3584 | //qDebug(" alendarView::keyPressEvent "); | 3586 | //qDebug(" alendarView::keyPressEvent "); |
3585 | e->ignore(); | 3587 | e->ignore(); |
3586 | } | 3588 | } |
3587 | 3589 | ||
3588 | //#include "calendarview.moc" | 3590 | //#include "calendarview.moc" |
3589 | 3591 | ||
3590 | //#include "calendarviewbase.moc" | 3592 | //#include "calendarviewbase.moc" |
diff --git a/libkdepim/addresseeview.cpp b/libkdepim/addresseeview.cpp index d710541..5c69010 100644 --- a/libkdepim/addresseeview.cpp +++ b/libkdepim/addresseeview.cpp | |||
@@ -1,389 +1,395 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkdepim. | 2 | This file is part of libkdepim. |
3 | 3 | ||
4 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 4 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <kabc/address.h> | 22 | #include <kabc/address.h> |
23 | #include <kabc/addressee.h> | 23 | #include <kabc/addressee.h> |
24 | #include <kabc/phonenumber.h> | 24 | #include <kabc/phonenumber.h> |
25 | #include <kglobal.h> | 25 | #include <kglobal.h> |
26 | //US#include <kglobalsettings.h> | 26 | //US#include <kglobalsettings.h> |
27 | #include <kiconloader.h> | 27 | #include <kiconloader.h> |
28 | #include <klocale.h> | 28 | #include <klocale.h> |
29 | //US #include <kstringhandler.h> | 29 | //US #include <kstringhandler.h> |
30 | #include <qscrollview.h> | 30 | #include <qscrollview.h> |
31 | #include <qregexp.h> | 31 | #include <qregexp.h> |
32 | #include <qfile.h> | 32 | #include <qfile.h> |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | 34 | ||
35 | 35 | ||
36 | #include "externalapphandler.h" | 36 | #include "externalapphandler.h" |
37 | #include "addresseeview.h" | 37 | #include "addresseeview.h" |
38 | 38 | ||
39 | 39 | ||
40 | //US #ifndef DESKTOP_VERSION | 40 | //US #ifndef DESKTOP_VERSION |
41 | //US #include <qtopia/qcopenvelope_qws.h> | 41 | //US #include <qtopia/qcopenvelope_qws.h> |
42 | //US #include <qpe/qpeapplication.h> | 42 | //US #include <qpe/qpeapplication.h> |
43 | //US #endif | 43 | //US #endif |
44 | 44 | ||
45 | //US static int kphoneInstalled = 0; | 45 | //US static int kphoneInstalled = 0; |
46 | 46 | ||
47 | using namespace KPIM; | 47 | using namespace KPIM; |
48 | 48 | ||
49 | AddresseeView::AddresseeView( QWidget *parent, const char *name ) | 49 | AddresseeView::AddresseeView( QWidget *parent, const char *name ) |
50 | //US : KTextBrowser( parent, name ) | 50 | //US : KTextBrowser( parent, name ) |
51 | : QTextBrowser( parent, name ) | 51 | : QTextBrowser( parent, name ) |
52 | 52 | ||
53 | 53 | ||
54 | { | 54 | { |
55 | //US setWrapPolicy( QTextEdit::AtWordBoundary ); | 55 | //US setWrapPolicy( QTextEdit::AtWordBoundary ); |
56 | setLinkUnderline( false ); | 56 | setLinkUnderline( false ); |
57 | // setVScrollBarMode( QScrollView::AlwaysOff ); | 57 | // setVScrollBarMode( QScrollView::AlwaysOff ); |
58 | //setHScrollBarMode( QScrollView::AlwaysOff ); | 58 | //setHScrollBarMode( QScrollView::AlwaysOff ); |
59 | 59 | ||
60 | //US QStyleSheet *sheet = styleSheet(); | 60 | //US QStyleSheet *sheet = styleSheet(); |
61 | //US QStyleSheetItem *link = sheet->item( "a" ); | 61 | //US QStyleSheetItem *link = sheet->item( "a" ); |
62 | //US link->setColor( KGlobalSettings::linkColor() ); | 62 | //US link->setColor( KGlobalSettings::linkColor() ); |
63 | 63 | ||
64 | } | 64 | } |
65 | 65 | ||
66 | void AddresseeView::setSource(const QString& n) | 66 | void AddresseeView::setSource(const QString& n) |
67 | { | 67 | { |
68 | qDebug("********AddresseeView::setSource %s", n.latin1()); | 68 | //qDebug("********AddresseeView::setSource %s", n.latin1()); |
69 | 69 | ||
70 | if ( n.left( 6 ) == "mailto" ) | 70 | if ( n.left( 6 ) == "mailto" ) |
71 | ExternalAppHandler::instance()->mailToOneContact( n.mid(7) ); | 71 | ExternalAppHandler::instance()->mailToOneContact( n.mid(7) ); |
72 | else if ( n.left( 7 ) == "phoneto" ) | 72 | else if ( n.left( 7 ) == "phoneto" ) |
73 | ExternalAppHandler::instance()->callByPhone( n.mid(8) ); | 73 | ExternalAppHandler::instance()->callByPhone( n.mid(8) ); |
74 | else if ( n.left( 5 ) == "faxto" ) | 74 | else if ( n.left( 5 ) == "faxto" ) |
75 | ExternalAppHandler::instance()->callByFax( n.mid(6) ); | 75 | ExternalAppHandler::instance()->callByFax( n.mid(6) ); |
76 | else if ( n.left( 5 ) == "smsto" ) | 76 | else if ( n.left( 5 ) == "smsto" ) |
77 | ExternalAppHandler::instance()->callBySMS( n.mid(6) ); | 77 | ExternalAppHandler::instance()->callBySMS( n.mid(6) ); |
78 | else if ( n.left( 7 ) == "pagerto" ) | 78 | else if ( n.left( 7 ) == "pagerto" ) |
79 | ExternalAppHandler::instance()->callByPager( n.mid(8) ); | 79 | ExternalAppHandler::instance()->callByPager( n.mid(8) ); |
80 | 80 | ||
81 | } | 81 | } |
82 | void AddresseeView::setAddressee( const KABC::Addressee& addr ) | 82 | void AddresseeView::setAddressee( const KABC::Addressee& addr ) |
83 | { | 83 | { |
84 | ExternalAppHandler* eah = ExternalAppHandler::instance(); | 84 | ExternalAppHandler* eah = ExternalAppHandler::instance(); |
85 | bool kemailAvail = eah->isEmailAppAvailable(); | 85 | bool kemailAvail = eah->isEmailAppAvailable(); |
86 | bool kphoneAvail = eah->isPhoneAppAvailable(); | 86 | bool kphoneAvail = eah->isPhoneAppAvailable(); |
87 | bool kfaxAvail = eah->isFaxAppAvailable(); | 87 | bool kfaxAvail = eah->isFaxAppAvailable(); |
88 | bool ksmsAvail = eah->isSMSAppAvailable(); | 88 | bool ksmsAvail = eah->isSMSAppAvailable(); |
89 | bool kpagerAvail = eah->isPagerAppAvailable(); | 89 | bool kpagerAvail = eah->isPagerAppAvailable(); |
90 | 90 | ||
91 | 91 | ||
92 | mAddressee = addr; | 92 | mAddressee = addr; |
93 | // clear view | 93 | // clear view |
94 | setText( QString::null ); | 94 | setText( QString::null ); |
95 | 95 | ||
96 | if ( mAddressee.isEmpty() ) | 96 | if ( mAddressee.isEmpty() ) |
97 | return; | 97 | return; |
98 | 98 | ||
99 | QString name = ( mAddressee.assembledName().isEmpty() ? | 99 | QString name = ( mAddressee.assembledName().isEmpty() ? |
100 | mAddressee.formattedName() : mAddressee.assembledName() ); | 100 | mAddressee.formattedName() : mAddressee.assembledName() ); |
101 | 101 | ||
102 | QString dynamicPart; | 102 | QString dynamicPart; |
103 | 103 | ||
104 | QStringList emails = mAddressee.emails(); | 104 | QStringList emails = mAddressee.emails(); |
105 | QStringList::ConstIterator emailIt; | 105 | QStringList::ConstIterator emailIt; |
106 | QString type = i18n( "Email" ); | 106 | QString type = i18n( "Email" ); |
107 | emailIt = emails.begin(); | 107 | emailIt = emails.begin(); |
108 | if ( emailIt != emails.end() ) { | 108 | if ( emailIt != emails.end() ) { |
109 | if ( kemailAvail ) { | 109 | if ( kemailAvail ) { |
110 | dynamicPart += QString( | 110 | dynamicPart += QString( |
111 | "<tr><td align=\"right\"><b>%1</b></td>" | 111 | "<tr><td align=\"right\"><b>%1</b></td>" |
112 | "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) | 112 | "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) |
113 | .arg( type ) | 113 | .arg( type ) |
114 | .arg( name ) | 114 | .arg( name ) |
115 | .arg( *emailIt ) | 115 | .arg( *emailIt ) |
116 | .arg( *emailIt ); | 116 | .arg( *emailIt ); |
117 | ++emailIt; | 117 | ++emailIt; |
118 | } else { | 118 | } else { |
119 | dynamicPart += QString( | 119 | dynamicPart += QString( |
120 | "<tr><td align=\"right\"><b>%1</b></td>" | 120 | "<tr><td align=\"right\"><b>%1</b></td>" |
121 | "<td align=\"left\">%2</td></tr>" ) | 121 | "<td align=\"left\">%2</td></tr>" ) |
122 | .arg( type ) | 122 | .arg( type ) |
123 | .arg( *emailIt ); | 123 | .arg( *emailIt ); |
124 | ++emailIt; | 124 | ++emailIt; |
125 | } | 125 | } |
126 | } | 126 | } |
127 | 127 | if ( mAddressee.birthday().date().isValid() ) { | |
128 | dynamicPart += QString( | ||
129 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
130 | "<td align=\"left\">%2</td></tr>" ) | ||
131 | .arg( i18n ("Birthday") ) | ||
132 | .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) ); | ||
133 | } | ||
128 | KABC::PhoneNumber::List phones = mAddressee.phoneNumbers(); | 134 | KABC::PhoneNumber::List phones = mAddressee.phoneNumbers(); |
129 | KABC::PhoneNumber::List::ConstIterator phoneIt; | 135 | KABC::PhoneNumber::List::ConstIterator phoneIt; |
130 | QString extension; | 136 | QString extension; |
131 | int phonetype; | 137 | int phonetype; |
132 | QString sms; | 138 | QString sms; |
133 | for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) { | 139 | for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) { |
134 | phonetype = (*phoneIt).type(); | 140 | phonetype = (*phoneIt).type(); |
135 | if (ksmsAvail && | 141 | if (ksmsAvail && |
136 | ( | 142 | ( |
137 | ((phonetype & KABC::PhoneNumber::Car) == KABC::PhoneNumber::Car) || | 143 | ((phonetype & KABC::PhoneNumber::Car) == KABC::PhoneNumber::Car) || |
138 | ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell) | 144 | ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell) |
139 | ) | 145 | ) |
140 | ) | 146 | ) |
141 | { | 147 | { |
142 | sms = QString("<a href=\"smsto:%1 \">(sms)</a>" ) | 148 | sms = QString("<a href=\"smsto:%1 \">(sms)</a>" ) |
143 | .arg( (*phoneIt).number() ); | 149 | .arg( (*phoneIt).number() ); |
144 | 150 | ||
145 | } | 151 | } |
146 | else | 152 | else |
147 | sms = ""; | 153 | sms = ""; |
148 | 154 | ||
149 | extension = QString::null; | 155 | extension = QString::null; |
150 | if ((phonetype & KABC::PhoneNumber::Fax) == KABC::PhoneNumber::Fax) { | 156 | if ((phonetype & KABC::PhoneNumber::Fax) == KABC::PhoneNumber::Fax) { |
151 | if (kfaxAvail) extension = "faxto:"; | 157 | if (kfaxAvail) extension = "faxto:"; |
152 | } | 158 | } |
153 | else if ((phonetype & KABC::PhoneNumber::Pager) == KABC::PhoneNumber::Pager) { | 159 | else if ((phonetype & KABC::PhoneNumber::Pager) == KABC::PhoneNumber::Pager) { |
154 | if (kpagerAvail) extension = "pagerto:"; | 160 | if (kpagerAvail) extension = "pagerto:"; |
155 | } | 161 | } |
156 | else if (kphoneAvail) { | 162 | else if (kphoneAvail) { |
157 | extension = "phoneto:"; | 163 | extension = "phoneto:"; |
158 | } | 164 | } |
159 | else | 165 | else |
160 | extension = QString::null; | 166 | extension = QString::null; |
161 | 167 | ||
162 | if ( !extension.isEmpty() ) { | 168 | if ( !extension.isEmpty() ) { |
163 | dynamicPart += QString( | 169 | dynamicPart += QString( |
164 | "<tr><td align=\"right\"><b>%1</b></td>" | 170 | "<tr><td align=\"right\"><b>%1</b></td>" |
165 | "<td align=\"left\"><a href=\"%2%3 \">%4</a> %5</td></tr>" ) | 171 | "<td align=\"left\"><a href=\"%2%3 \">%4</a> %5</td></tr>" ) |
166 | .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) | 172 | .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) |
167 | .arg( extension ) | 173 | .arg( extension ) |
168 | .arg( (*phoneIt).number() ) | 174 | .arg( (*phoneIt).number() ) |
169 | .arg( (*phoneIt).number() ) | 175 | .arg( (*phoneIt).number() ) |
170 | .arg( sms ); | 176 | .arg( sms ); |
171 | 177 | ||
172 | } else { | 178 | } else { |
173 | dynamicPart += QString( | 179 | dynamicPart += QString( |
174 | "<tr><td align=\"right\"><b>%1</b></td>" | 180 | "<tr><td align=\"right\"><b>%1</b></td>" |
175 | "<td align=\"left\">%2 %3</td></tr>" ) | 181 | "<td align=\"left\">%2 %3</td></tr>" ) |
176 | .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) | 182 | .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) |
177 | .arg( (*phoneIt).number() ) | 183 | .arg( (*phoneIt).number() ) |
178 | .arg( sms ); | 184 | .arg( sms ); |
179 | } | 185 | } |
180 | } | 186 | } |
181 | 187 | ||
182 | 188 | ||
183 | for ( ; emailIt != emails.end(); ++emailIt ) { | 189 | for ( ; emailIt != emails.end(); ++emailIt ) { |
184 | if ( kemailAvail ) { | 190 | if ( kemailAvail ) { |
185 | dynamicPart += QString( | 191 | dynamicPart += QString( |
186 | "<tr><td align=\"right\"><b>%1</b></td>" | 192 | "<tr><td align=\"right\"><b>%1</b></td>" |
187 | "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) | 193 | "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) |
188 | .arg( type ) | 194 | .arg( type ) |
189 | .arg( name ) | 195 | .arg( name ) |
190 | .arg( *emailIt ) | 196 | .arg( *emailIt ) |
191 | .arg( *emailIt ); | 197 | .arg( *emailIt ); |
192 | } else { | 198 | } else { |
193 | dynamicPart += QString( | 199 | dynamicPart += QString( |
194 | "<tr><td align=\"right\"><b>%1</b></td>" | 200 | "<tr><td align=\"right\"><b>%1</b></td>" |
195 | "<td align=\"left\">%2</td></tr>" ) | 201 | "<td align=\"left\">%2</td></tr>" ) |
196 | .arg( type ) | 202 | .arg( type ) |
197 | .arg( *emailIt ); | 203 | .arg( *emailIt ); |
198 | } | 204 | } |
199 | } | 205 | } |
200 | 206 | ||
201 | if ( !mAddressee.url().url().isEmpty() ) { | 207 | if ( !mAddressee.url().url().isEmpty() ) { |
202 | dynamicPart += QString( | 208 | dynamicPart += QString( |
203 | "<tr><td align=\"right\"><b>%1</b></td>" | 209 | "<tr><td align=\"right\"><b>%1</b></td>" |
204 | "<td align=\"left\">%2</td></tr>" ) | 210 | "<td align=\"left\">%2</td></tr>" ) |
205 | .arg( i18n( "Homepage" ) ) | 211 | .arg( i18n( "Homepage" ) ) |
206 | //US .arg( KStringHandler::tagURLs( mAddressee.url().url() ) ); | 212 | //US .arg( KStringHandler::tagURLs( mAddressee.url().url() ) ); |
207 | .arg( mAddressee.url().url() ); | 213 | .arg( mAddressee.url().url() ); |
208 | //qDebug("AddresseeView::setAddressee has to be verified."); | 214 | //qDebug("AddresseeView::setAddressee has to be verified."); |
209 | } | 215 | } |
210 | 216 | ||
211 | KABC::Address::List addresses = mAddressee.addresses(); | 217 | KABC::Address::List addresses = mAddressee.addresses(); |
212 | KABC::Address::List::ConstIterator addrIt; | 218 | KABC::Address::List::ConstIterator addrIt; |
213 | for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) { | 219 | for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) { |
214 | if ( true /*(*addrIt).label().isEmpty()*/ ) { | 220 | if ( true /*(*addrIt).label().isEmpty()*/ ) { |
215 | QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace(); | 221 | QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace(); |
216 | //US formattedAddress = formattedAddress.replace( '\n', "<br>" ); | 222 | //US formattedAddress = formattedAddress.replace( '\n', "<br>" ); |
217 | //qDebug("adresss %s ",formattedAddress.latin1() ); | 223 | //qDebug("adresss %s ",formattedAddress.latin1() ); |
218 | formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" ); | 224 | formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" ); |
219 | //qDebug("AddresseeView::setAddressee has to be verified."); | 225 | //qDebug("AddresseeView::setAddressee has to be verified."); |
220 | 226 | ||
221 | dynamicPart += QString( | 227 | dynamicPart += QString( |
222 | "<tr><td align=\"right\"><b>%1</b></td>" | 228 | "<tr><td align=\"right\"><b>%1</b></td>" |
223 | "<td align=\"left\">%2</td></tr>" ) | 229 | "<td align=\"left\">%2</td></tr>" ) |
224 | .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) | 230 | .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) |
225 | .arg( formattedAddress ); | 231 | .arg( formattedAddress ); |
226 | } else { | 232 | } else { |
227 | 233 | ||
228 | dynamicPart += QString( | 234 | dynamicPart += QString( |
229 | "<tr><td align=\"right\"><b>%1</b></td>" | 235 | "<tr><td align=\"right\"><b>%1</b></td>" |
230 | "<td align=\"left\">%2</td></tr>" ) | 236 | "<td align=\"left\">%2</td></tr>" ) |
231 | .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) | 237 | .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) |
232 | //US .arg( (*addrIt).label().replace( '\n', "<br>" ) ); | 238 | //US .arg( (*addrIt).label().replace( '\n', "<br>" ) ); |
233 | .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ ); | 239 | .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ ); |
234 | 240 | ||
235 | } | 241 | } |
236 | } | 242 | } |
237 | 243 | ||
238 | QString notes; | 244 | QString notes; |
239 | if ( !mAddressee.note().isEmpty() ) { | 245 | if ( !mAddressee.note().isEmpty() ) { |
240 | notes = QString( | 246 | notes = QString( |
241 | "<tr>" | 247 | "<tr>" |
242 | "<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label | 248 | "<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label |
243 | "<td align=\"left\">%2</td>" // note | 249 | "<td align=\"left\">%2</td>" // note |
244 | "</tr>" ).arg( i18n( "Notes" ) ) | 250 | "</tr>" ).arg( i18n( "Notes" ) ) |
245 | //US .arg( mAddressee.note().replace( '\n', "<br>" ) ); | 251 | //US .arg( mAddressee.note().replace( '\n', "<br>" ) ); |
246 | .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) ); | 252 | .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) ); |
247 | //qDebug("AddresseeView::setAddressee has to be verified."); | 253 | //qDebug("AddresseeView::setAddressee has to be verified."); |
248 | } | 254 | } |
249 | 255 | ||
250 | QString aRole = ""; | 256 | QString aRole = ""; |
251 | QString aOrga = ""; | 257 | QString aOrga = ""; |
252 | if ( true /*!mAddressee.role().isEmpty()*/ ) { | 258 | if ( true /*!mAddressee.role().isEmpty()*/ ) { |
253 | aRole = "<tr>" | 259 | aRole = "<tr>" |
254 | "<td align=\"left\">" + mAddressee.role() + "</td>" | 260 | "<td align=\"left\">" + mAddressee.role() + "</td>" |
255 | "</tr>"; | 261 | "</tr>"; |
256 | } | 262 | } |
257 | if ( true /*!mAddressee.organization().isEmpty()*/ ) { | 263 | if ( true /*!mAddressee.organization().isEmpty()*/ ) { |
258 | aOrga = "<tr>" | 264 | aOrga = "<tr>" |
259 | "<td align=\"left\">" + mAddressee.organization() + "</td>" ; | 265 | "<td align=\"left\">" + mAddressee.organization() + "</td>" ; |
260 | "</tr>"; | 266 | "</tr>"; |
261 | } | 267 | } |
262 | mText = ""; | 268 | mText = ""; |
263 | QString picString = ""; | 269 | QString picString = ""; |
264 | KABC::Picture picture = mAddressee.photo(); | 270 | KABC::Picture picture = mAddressee.photo(); |
265 | bool picAvailintern = false; | 271 | bool picAvailintern = false; |
266 | bool picAvailUrl = false; | 272 | bool picAvailUrl = false; |
267 | if (! picture.undefined() ) { | 273 | if (! picture.undefined() ) { |
268 | picAvailintern = (picture.isIntern() && !picture.data().isNull()); | 274 | picAvailintern = (picture.isIntern() && !picture.data().isNull()); |
269 | picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() ); | 275 | picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() ); |
270 | } | 276 | } |
271 | if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) { | 277 | if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) { |
272 | if ( picAvailintern ) { | 278 | if ( picAvailintern ) { |
273 | QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() ); | 279 | QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() ); |
274 | } else { | 280 | } else { |
275 | if ( picAvailUrl ) { | 281 | if ( picAvailUrl ) { |
276 | QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", QPixmap( picture.url() )); | 282 | QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", QPixmap( picture.url() )); |
277 | } else { | 283 | } else { |
278 | QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", KGlobal::iconLoader()->loadIcon( "package_toys", KIcon::Desktop, 128 ) ); | 284 | QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", KGlobal::iconLoader()->loadIcon( "package_toys", KIcon::Desktop, 128 ) ); |
279 | } | 285 | } |
280 | } | 286 | } |
281 | picString = "<img src=\"myimage\" width=\"50\" height=\"70\">"; | 287 | picString = "<img src=\"myimage\" width=\"50\" height=\"70\">"; |
282 | mText = QString::fromLatin1( | 288 | mText = QString::fromLatin1( |
283 | "<html>" | 289 | "<html>" |
284 | "<body text=\"%1\" bgcolor=\"%2\">" // text and background color | 290 | "<body text=\"%1\" bgcolor=\"%2\">" // text and background color |
285 | "<table>" | 291 | "<table>" |
286 | "<tr>" | 292 | "<tr>" |
287 | "<td rowspan=\"3\" align=\"right\" valign=\"top\">" | 293 | "<td rowspan=\"3\" align=\"right\" valign=\"top\">" |
288 | "%3" | 294 | "%3" |
289 | "</td>" | 295 | "</td>" |
290 | "<td align=\"left\"><font size=\"+2\"><b>%4</b></font></td>" // name | 296 | "<td align=\"left\"><font size=\"+2\"><b>%4</b></font></td>" // name |
291 | "</tr>" | 297 | "</tr>" |
292 | "%5" // role | 298 | "%5" // role |
293 | "%6" // organization | 299 | "%6" // organization |
294 | "<td colspan=\"2\"> </td>" | 300 | "<td colspan=\"2\"> </td>" |
295 | "%7" // dynamic part | 301 | "%7" // dynamic part |
296 | "%8" // notes | 302 | "%8" // notes |
297 | "</table>" | 303 | "</table>" |
298 | "</body>" | 304 | "</body>" |
299 | "</html>") | 305 | "</html>") |
300 | //US | 306 | //US |
301 | .arg( /*KGlobalSettings::textColor().name()*/ "black" ) | 307 | .arg( /*KGlobalSettings::textColor().name()*/ "black" ) |
302 | //US | 308 | //US |
303 | .arg( /*KGlobalSettings::baseColor().name()*/ "white" ) | 309 | .arg( /*KGlobalSettings::baseColor().name()*/ "white" ) |
304 | .arg( picString ) | 310 | .arg( picString ) |
305 | .arg( name ) | 311 | .arg( name ) |
306 | .arg( aRole ) | 312 | .arg( aRole ) |
307 | .arg( aOrga ) | 313 | .arg( aOrga ) |
308 | .arg( dynamicPart ) | 314 | .arg( dynamicPart ) |
309 | .arg( notes ); | 315 | .arg( notes ); |
310 | 316 | ||
311 | } else { // no picture! | 317 | } else { // no picture! |
312 | 318 | ||
313 | mText = "<table width=\"100%\">\n"; | 319 | mText = "<table width=\"100%\">\n"; |
314 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 320 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
315 | #ifdef DESKTOP_VERSION | 321 | #ifdef DESKTOP_VERSION |
316 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h1>"; | 322 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h1>"; |
317 | #else | 323 | #else |
318 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h2>"; | 324 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h2>"; |
319 | #endif | 325 | #endif |
320 | 326 | ||
321 | #ifdef DESKTOP_VERSION | 327 | #ifdef DESKTOP_VERSION |
322 | mText += "<font color=\"#FFFFFF\"> <em>" + name+"</em></font></h1>"; | 328 | mText += "<font color=\"#FFFFFF\"> <em>" + name+"</em></font></h1>"; |
323 | #else | 329 | #else |
324 | mText += "<font color=\"#FFFFFF\"> <em>" + name +"</em></font></h2>"; | 330 | mText += "<font color=\"#FFFFFF\"> <em>" + name +"</em></font></h2>"; |
325 | #endif | 331 | #endif |
326 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; | 332 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; |
327 | 333 | ||
328 | mText += "<table><td colspan=\"2\"> </td>"; | 334 | mText += "<table><td colspan=\"2\"> </td>"; |
329 | /* | 335 | /* |
330 | mText += QString("<tr><td align=\"right\"><b2>%1</b2></td>" | 336 | mText += QString("<tr><td align=\"right\"><b2>%1</b2></td>" |
331 | "<td align=\"left\"><b>%2</b></td></tr>" ) | 337 | "<td align=\"left\"><b>%2</b></td></tr>" ) |
332 | .arg( i18n(" ") ) | 338 | .arg( i18n(" ") ) |
333 | .arg( name ); | 339 | .arg( name ); |
334 | */ | 340 | */ |
335 | if ( ! mAddressee.role().isEmpty() ) | 341 | if ( ! mAddressee.role().isEmpty() ) |
336 | mText += QString("<tr><td align=\"right\"><b>%1</b></td>" | 342 | mText += QString("<tr><td align=\"right\"><b>%1</b></td>" |
337 | "<td align=\"left\">%2</td></tr>" ) | 343 | "<td align=\"left\">%2</td></tr>" ) |
338 | .arg( i18n(" ") ) | 344 | .arg( i18n(" ") ) |
339 | .arg( mAddressee.role()); | 345 | .arg( mAddressee.role()); |
340 | if ( ! mAddressee.organization().isEmpty() ) | 346 | if ( ! mAddressee.organization().isEmpty() ) |
341 | mText += QString("<tr><td align=\"right\"><b>%1</b></td>" | 347 | mText += QString("<tr><td align=\"right\"><b>%1</b></td>" |
342 | "<td align=\"left\">%2</td></tr>" ) | 348 | "<td align=\"left\">%2</td></tr>" ) |
343 | .arg( i18n(" ") ) | 349 | .arg( i18n(" ") ) |
344 | .arg( mAddressee.organization()); | 350 | .arg( mAddressee.organization()); |
345 | mText += dynamicPart; | 351 | mText += dynamicPart; |
346 | mText += notes; | 352 | mText += notes; |
347 | mText += "</table>"; | 353 | mText += "</table>"; |
348 | 354 | ||
349 | } | 355 | } |
350 | 356 | ||
351 | // at last display it... | 357 | // at last display it... |
352 | setText( mText ); | 358 | setText( mText ); |
353 | 359 | ||
354 | } | 360 | } |
355 | 361 | ||
356 | KABC::Addressee AddresseeView::addressee() const | 362 | KABC::Addressee AddresseeView::addressee() const |
357 | { | 363 | { |
358 | return mAddressee; | 364 | return mAddressee; |
359 | } | 365 | } |
360 | void AddresseeView::addTag(const QString & tag,const QString & text) | 366 | void AddresseeView::addTag(const QString & tag,const QString & text) |
361 | { | 367 | { |
362 | if ( text.isEmpty() ) | 368 | if ( text.isEmpty() ) |
363 | return; | 369 | return; |
364 | int number=text.contains("\n"); | 370 | int number=text.contains("\n"); |
365 | QString str = "<" + tag + ">"; | 371 | QString str = "<" + tag + ">"; |
366 | QString tmpText=text; | 372 | QString tmpText=text; |
367 | QString tmpStr=str; | 373 | QString tmpStr=str; |
368 | if(number !=-1) | 374 | if(number !=-1) |
369 | { | 375 | { |
370 | if (number > 0) { | 376 | if (number > 0) { |
371 | int pos=0; | 377 | int pos=0; |
372 | QString tmp; | 378 | QString tmp; |
373 | for(int i=0;i<=number;i++) { | 379 | for(int i=0;i<=number;i++) { |
374 | pos=tmpText.find("\n"); | 380 | pos=tmpText.find("\n"); |
375 | tmp=tmpText.left(pos); | 381 | tmp=tmpText.left(pos); |
376 | tmpText=tmpText.right(tmpText.length()-pos-1); | 382 | tmpText=tmpText.right(tmpText.length()-pos-1); |
377 | tmpStr+=tmp+"<br>"; | 383 | tmpStr+=tmp+"<br>"; |
378 | } | 384 | } |
379 | } | 385 | } |
380 | else tmpStr += tmpText; | 386 | else tmpStr += tmpText; |
381 | tmpStr+="</" + tag + ">"; | 387 | tmpStr+="</" + tag + ">"; |
382 | mText.append(tmpStr); | 388 | mText.append(tmpStr); |
383 | } | 389 | } |
384 | else | 390 | else |
385 | { | 391 | { |
386 | str += text + "</" + tag + ">"; | 392 | str += text + "</" + tag + ">"; |
387 | mText.append(str); | 393 | mText.append(str); |
388 | } | 394 | } |
389 | } | 395 | } |
diff --git a/libkdepim/kdateedit.cpp b/libkdepim/kdateedit.cpp index 5fb948a..c4c0081 100644 --- a/libkdepim/kdateedit.cpp +++ b/libkdepim/kdateedit.cpp | |||
@@ -1,486 +1,497 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkdepim. | 2 | This file is part of libkdepim. |
3 | 3 | ||
4 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <qapplication.h> | 25 | #include <qapplication.h> |
26 | #include <qevent.h> | 26 | #include <qevent.h> |
27 | #include <qlineedit.h> | 27 | #include <qlineedit.h> |
28 | #include <qpixmap.h> | 28 | #include <qpixmap.h> |
29 | #include <qpushbutton.h> | 29 | #include <qpushbutton.h> |
30 | 30 | ||
31 | #include <kdatepicker.h> | 31 | #include <kdatepicker.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <kglobal.h> | 33 | #include <kglobal.h> |
34 | #include <kiconloader.h> | 34 | #include <kiconloader.h> |
35 | #include <klocale.h> | 35 | #include <klocale.h> |
36 | #include <kmessagebox.h> | 36 | #include <kmessagebox.h> |
37 | #include <knotifyclient.h> | 37 | #include <knotifyclient.h> |
38 | #include <qpalette.h> | 38 | #include <qpalette.h> |
39 | 39 | ||
40 | #include "kdateedit.h" | 40 | #include "kdateedit.h" |
41 | //#include "kdateedit.moc" | 41 | //#include "kdateedit.moc" |
42 | 42 | ||
43 | KDateEdit::KDateEdit(QWidget *parent, const char *name, bool withoutDP ) | 43 | KDateEdit::KDateEdit(QWidget *parent, const char *name, bool withoutDP ) |
44 | : QHBox(parent, name) | 44 | : QHBox(parent, name) |
45 | { | 45 | { |
46 | dateFormShort = true; | 46 | dateFormShort = true; |
47 | withoutDp = withoutDP; | 47 | withoutDp = withoutDP; |
48 | mDateEdit = new QLineEdit(this); | 48 | mDateEdit = new QLineEdit(this); |
49 | mDateEdit->setText(KGlobal::locale()->formatDate(QDate::currentDate(),dateFormShort)); | 49 | mDateEdit->setText(KGlobal::locale()->formatDate(QDate::currentDate(),dateFormShort)); |
50 | setFocusProxy(mDateEdit); | 50 | setFocusProxy(mDateEdit); |
51 | mDateEdit->installEventFilter(this); | 51 | mDateEdit->installEventFilter(this); |
52 | 52 | ||
53 | // Highlight Background and Textcolor | 53 | // Highlight Background and Textcolor |
54 | QPalette palette = QWidget::palette(); | 54 | QPalette palette = QWidget::palette(); |
55 | unsigned char red, green, blue; | 55 | unsigned char red, green, blue; |
56 | red = palette.color( QPalette::Normal , QColorGroup::Background ).red() - 10; | 56 | red = palette.color( QPalette::Normal , QColorGroup::Background ).red() - 10; |
57 | green = palette.color( QPalette::Normal , QColorGroup::Background ).green() - 10; | 57 | green = palette.color( QPalette::Normal , QColorGroup::Background ).green() - 10; |
58 | blue = palette.color( QPalette::Normal , QColorGroup::Background ).blue() - 10; | 58 | blue = palette.color( QPalette::Normal , QColorGroup::Background ).blue() - 10; |
59 | palette.setColor( QColorGroup::Highlight, QColor(red,green,blue) ); | 59 | palette.setColor( QColorGroup::Highlight, QColor(red,green,blue) ); |
60 | palette.setColor( QColorGroup::HighlightedText, palette.color( QPalette::Normal , QColorGroup::Foreground ) ); | 60 | palette.setColor( QColorGroup::HighlightedText, palette.color( QPalette::Normal , QColorGroup::Foreground ) ); |
61 | mDateEdit->setPalette( palette ); | 61 | mDateEdit->setPalette( palette ); |
62 | 62 | ||
63 | if ( withoutDP ) { | 63 | if ( withoutDP ) { |
64 | mDateFrame = 0; | 64 | mDateFrame = 0; |
65 | mDateButton = 0; | 65 | mDateButton = 0; |
66 | mDatePicker = 0; | 66 | mDatePicker = 0; |
67 | } else { | 67 | } else { |
68 | QPixmap pixmap = SmallIcon("smallcal"); | 68 | QPixmap pixmap = SmallIcon("smallcal"); |
69 | mDateButton = new QPushButton(this); | 69 | mDateButton = new QPushButton(this); |
70 | mDateButton->setPixmap(pixmap); | 70 | mDateButton->setPixmap(pixmap); |
71 | 71 | ||
72 | mDateFrame = new QVBox(0,0,WType_Popup); | 72 | mDateFrame = new QVBox(0,0,WType_Popup); |
73 | // mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 73 | // mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
74 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 74 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
75 | mDateFrame->setLineWidth(3); | 75 | mDateFrame->setLineWidth(3); |
76 | mDateFrame->hide(); | 76 | mDateFrame->hide(); |
77 | 77 | ||
78 | mDatePicker = new KDatePicker(mDateFrame,QDate::currentDate()); | 78 | mDatePicker = new KDatePicker(mDateFrame,QDate::currentDate()); |
79 | connect(mDatePicker,SIGNAL(dateEntered(QDate)),SLOT(setDate(QDate))); | 79 | connect(mDatePicker,SIGNAL(dateEntered(QDate)),SLOT(setDate(QDate))); |
80 | connect(mDatePicker,SIGNAL(dateEntered(QDate)),SIGNAL(dateChanged(QDate))); | 80 | connect(mDatePicker,SIGNAL(dateEntered(QDate)),SIGNAL(dateChanged(QDate))); |
81 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(setDate(QDate))); | 81 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(setDate(QDate))); |
82 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SIGNAL(dateChanged(QDate))); | 82 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SIGNAL(dateChanged(QDate))); |
83 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),mDateFrame,SLOT(hide())); | 83 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),mDateFrame,SLOT(hide())); |
84 | connect(mDateButton,SIGNAL(clicked()),SLOT(toggleDatePicker())); | 84 | connect(mDateButton,SIGNAL(clicked()),SLOT(toggleDatePicker())); |
85 | 85 | ||
86 | //mDateFrame->resize( 400, 300 ); | 86 | //mDateFrame->resize( 400, 300 ); |
87 | 87 | ||
88 | } | 88 | } |
89 | connect(mDateEdit,SIGNAL(returnPressed()),SLOT(lineEnterPressed())); | 89 | connect(mDateEdit,SIGNAL(returnPressed()),SLOT(lineEnterPressed())); |
90 | connect(mDateEdit,SIGNAL(textChanged(const QString &)), | 90 | connect(mDateEdit,SIGNAL(textChanged(const QString &)), |
91 | SLOT(textChanged(const QString &))); | 91 | SLOT(textChanged(const QString &))); |
92 | 92 | ||
93 | // Create the keyword list. This will be used to match against when the user | 93 | // Create the keyword list. This will be used to match against when the user |
94 | // enters information. | 94 | // enters information. |
95 | mKeywordMap[i18n("tomorrow")] = 1; | 95 | mKeywordMap[i18n("tomorrow")] = 1; |
96 | mKeywordMap[i18n("today")] = 0; | 96 | mKeywordMap[i18n("today")] = 0; |
97 | mKeywordMap[i18n("yesterday")] = -1; | 97 | mKeywordMap[i18n("yesterday")] = -1; |
98 | 98 | ||
99 | /* | 99 | /* |
100 | * This loop uses some math tricks to figure out the offset in days | 100 | * This loop uses some math tricks to figure out the offset in days |
101 | * to the next date the given day of the week occurs. There | 101 | * to the next date the given day of the week occurs. There |
102 | * are two cases, that the new day is >= the current day, which means | 102 | * are two cases, that the new day is >= the current day, which means |
103 | * the new day has not occured yet or that the new day < the current day, | 103 | * the new day has not occured yet or that the new day < the current day, |
104 | * which means the new day is already passed (so we need to find the | 104 | * which means the new day is already passed (so we need to find the |
105 | * day in the next week). | 105 | * day in the next week). |
106 | */ | 106 | */ |
107 | QString dayName; | 107 | QString dayName; |
108 | int currentDay = QDate::currentDate().dayOfWeek(); | 108 | int currentDay = QDate::currentDate().dayOfWeek(); |
109 | for (int i = 1; i <= 7; ++i) | 109 | for (int i = 1; i <= 7; ++i) |
110 | { | 110 | { |
111 | dayName = KGlobal::locale()->weekDayName(i).lower(); | 111 | dayName = KGlobal::locale()->weekDayName(i).lower(); |
112 | if (i >= currentDay) | 112 | if (i >= currentDay) |
113 | mKeywordMap[dayName] = i - currentDay; | 113 | mKeywordMap[dayName] = i - currentDay; |
114 | else | 114 | else |
115 | mKeywordMap[dayName] = 7 - currentDay + i; | 115 | mKeywordMap[dayName] = 7 - currentDay + i; |
116 | } | 116 | } |
117 | 117 | ||
118 | mTextChanged = false; | 118 | mTextChanged = false; |
119 | mHandleInvalid = false; | 119 | mHandleInvalid = false; |
120 | QWidget::setTabOrder( mDateEdit, mDateButton ); | 120 | QWidget::setTabOrder( mDateEdit, mDateButton ); |
121 | } | 121 | } |
122 | 122 | ||
123 | KDateEdit::~KDateEdit() | 123 | KDateEdit::~KDateEdit() |
124 | { | 124 | { |
125 | delete mDateFrame; | 125 | delete mDateFrame; |
126 | } | 126 | } |
127 | 127 | void KDateEdit::clear() | |
128 | { | ||
129 | bool b = mDateEdit->signalsBlocked(); | ||
130 | mDateEdit->blockSignals(true); | ||
131 | mDateEdit->setText(""); | ||
132 | mDateEdit->blockSignals(b); | ||
133 | } | ||
128 | void KDateEdit::setDate(QDate newDate) | 134 | void KDateEdit::setDate(QDate newDate) |
129 | { | 135 | { |
130 | if (!newDate.isValid() && !mHandleInvalid) | 136 | if (!newDate.isValid() && !mHandleInvalid) |
131 | return; | 137 | return; |
132 | if ( readDate() == newDate ) | 138 | if ( readDate() == newDate ) |
133 | return; | 139 | return; |
134 | QString dateString = ""; | 140 | QString dateString = ""; |
135 | if(newDate.isValid()) | 141 | if(newDate.isValid()) |
136 | dateString = KGlobal::locale()->formatDate( newDate, dateFormShort ); | 142 | dateString = KGlobal::locale()->formatDate( newDate, dateFormShort ); |
137 | 143 | ||
138 | mTextChanged = false; | 144 | mTextChanged = false; |
139 | 145 | ||
140 | // We do not want to generate a signal here, since we explicity setting | 146 | // We do not want to generate a signal here, since we explicity setting |
141 | // the date | 147 | // the date |
142 | bool b = mDateEdit->signalsBlocked(); | 148 | bool b = mDateEdit->signalsBlocked(); |
143 | mDateEdit->blockSignals(true); | 149 | mDateEdit->blockSignals(true); |
144 | mDateEdit->setText(dateString); | 150 | mDateEdit->setText(dateString); |
145 | mDateEdit->blockSignals(b); | 151 | mDateEdit->blockSignals(b); |
146 | } | 152 | } |
147 | 153 | ||
148 | void KDateEdit::setDate( QDate date,int *cpos,const int key ,const bool dateFormShort) | 154 | void KDateEdit::setDate( QDate date,int *cpos,const int key ,const bool dateFormShort) |
149 | { | 155 | { |
150 | QString dateForm = dateFormShort ? | 156 | QString dateForm = dateFormShort ? |
151 | KGlobal::locale()->dateFormatShort() : | 157 | KGlobal::locale()->dateFormatShort() : |
152 | KGlobal::locale()->dateFormat(); | 158 | KGlobal::locale()->dateFormat(); |
153 | 159 | ||
154 | int begin = dateForm.find("%"); | 160 | int begin = dateForm.find("%"); |
155 | int space = 0; | 161 | int space = 0; |
156 | int allStrLength = 0; | 162 | int allStrLength = 0; |
157 | int strLength = 0; | 163 | int strLength = 0; |
158 | int repeat = 0; | 164 | int repeat = 0; |
159 | 165 | ||
160 | // witch? Day, Month or Year switch? | 166 | // witch? Day, Month or Year switch? |
161 | while(1){ | 167 | while(1){ |
162 | switch ( dateForm.at(begin + 1).latin1() ) | 168 | switch ( dateForm.at(begin + 1).latin1() ) |
163 | { | 169 | { |
164 | case 'd':// 16 (month day) | 170 | case 'd':// 16 (month day) |
165 | strLength = 2; //Ok | 171 | strLength = 2; //Ok |
166 | break; | 172 | break; |
167 | case 'm':// 01 (month) | 173 | case 'm':// 01 (month) |
168 | strLength = 2; //Ok | 174 | strLength = 2; //Ok |
169 | break; | 175 | break; |
170 | case 'a':// Mon (Weekday) | 176 | case 'a':// Mon (Weekday) |
171 | strLength = KGlobal::locale()->weekDayName(date.dayOfWeek(), true).length(); | 177 | strLength = KGlobal::locale()->weekDayName(date.dayOfWeek(), true).length(); |
172 | break; | 178 | break; |
173 | case 'A':// Monday (Weekday) | 179 | case 'A':// Monday (Weekday) |
174 | strLength = KGlobal::locale()->weekDayName(date.dayOfWeek(), false).length(); | 180 | strLength = KGlobal::locale()->weekDayName(date.dayOfWeek(), false).length(); |
175 | break; | 181 | break; |
176 | case 'b':// Jan (monthName) | 182 | case 'b':// Jan (monthName) |
177 | strLength = KGlobal::locale()->monthName(date.month(), true).length(); | 183 | strLength = KGlobal::locale()->monthName(date.month(), true).length(); |
178 | break; | 184 | break; |
179 | case 'B':// January (monthName) | 185 | case 'B':// January (monthName) |
180 | strLength = KGlobal::locale()->monthName(date.month(), false).length(); | 186 | strLength = KGlobal::locale()->monthName(date.month(), false).length(); |
181 | break; | 187 | break; |
182 | case 'y':// 04 (year short) | 188 | case 'y':// 04 (year short) |
183 | strLength = 2; //Ok | 189 | strLength = 2; //Ok |
184 | break; | 190 | break; |
185 | case 'Y':// 2004 (year) | 191 | case 'Y':// 2004 (year) |
186 | strLength = 4; //Ok | 192 | strLength = 4; //Ok |
187 | break; | 193 | break; |
188 | default: | 194 | default: |
189 | break; | 195 | break; |
190 | } | 196 | } |
191 | space = begin - (repeat++ * 2); | 197 | space = begin - (repeat++ * 2); |
192 | // all select? then dayswitch | 198 | // all select? then dayswitch |
193 | if( (mDateEdit->text().length() == mDateEdit->markedText().length() ) && | 199 | if( (mDateEdit->text().length() == mDateEdit->markedText().length() ) && |
194 | ( (dateForm.at(begin + 1).latin1() == 'd') || | 200 | ( (dateForm.at(begin + 1).latin1() == 'd') || |
195 | (dateForm.at(begin + 1).latin1() == 'a') || | 201 | (dateForm.at(begin + 1).latin1() == 'a') || |
196 | (dateForm.at(begin + 1).latin1() == 'A') ) ) { | 202 | (dateForm.at(begin + 1).latin1() == 'A') ) ) { |
197 | break; | 203 | break; |
198 | } | 204 | } |
199 | // mDateEdit-StringPos == CursorPosition(cpos) then break and set date | 205 | // mDateEdit-StringPos == CursorPosition(cpos) then break and set date |
200 | if( ( (space + allStrLength) <= *cpos && *cpos <= (space + allStrLength + strLength) ) || *cpos < begin ) { | 206 | if( ( (space + allStrLength) <= *cpos && *cpos <= (space + allStrLength + strLength) ) || *cpos < begin ) { |
201 | break; | 207 | break; |
202 | } | 208 | } |
203 | allStrLength += strLength; | 209 | allStrLength += strLength; |
204 | begin = dateForm.find("%", begin +1); | 210 | begin = dateForm.find("%", begin +1); |
205 | } | 211 | } |
206 | 212 | ||
207 | // set date | 213 | // set date |
208 | switch ( dateForm.at(begin + 1).latin1() ) { | 214 | switch ( dateForm.at(begin + 1).latin1() ) { |
209 | case 'd': | 215 | case 'd': |
210 | case 'a': | 216 | case 'a': |
211 | case 'A': | 217 | case 'A': |
212 | if(key == Key_Up) { | 218 | if(key == Key_Up) { |
213 | setDate( date.addDays( 1 ) ); | 219 | setDate( date.addDays( 1 ) ); |
214 | } | 220 | } |
215 | else if(key == Key_Down) { | 221 | else if(key == Key_Down) { |
216 | setDate( date.addDays( -1 ) ); | 222 | setDate( date.addDays( -1 ) ); |
217 | } | 223 | } |
218 | maxDay = readDate().day(); | 224 | maxDay = readDate().day(); |
219 | break; | 225 | break; |
220 | case 'm': | 226 | case 'm': |
221 | case 'b': | 227 | case 'b': |
222 | case 'B': | 228 | case 'B': |
223 | if(key == Key_Up) { | 229 | if(key == Key_Up) { |
224 | int year = ((date.month()+1)>12)?date.year()+1:date.year(); | 230 | int year = ((date.month()+1)>12)?date.year()+1:date.year(); |
225 | int month = ((date.month()+1)>12)?1:date.month()+1; | 231 | int month = ((date.month()+1)>12)?1:date.month()+1; |
226 | int day = (QDate(year,month,1).daysInMonth()<maxDay)?QDate(year,month,1).daysInMonth():maxDay; | 232 | int day = (QDate(year,month,1).daysInMonth()<maxDay)?QDate(year,month,1).daysInMonth():maxDay; |
227 | setDate( QDate( year, month, day ) ); | 233 | setDate( QDate( year, month, day ) ); |
228 | } else if(key == Key_Down) { | 234 | } else if(key == Key_Down) { |
229 | int year = ((date.month()-1)<1)?date.year()-1:date.year(); | 235 | int year = ((date.month()-1)<1)?date.year()-1:date.year(); |
230 | int month = ((date.month()-1)<1)?12:date.month()-1; | 236 | int month = ((date.month()-1)<1)?12:date.month()-1; |
231 | int day = (QDate(year,month,1).daysInMonth()<maxDay)?QDate(year,month,1).daysInMonth():maxDay; | 237 | int day = (QDate(year,month,1).daysInMonth()<maxDay)?QDate(year,month,1).daysInMonth():maxDay; |
232 | setDate( QDate( year, month, day ) ); | 238 | setDate( QDate( year, month, day ) ); |
233 | } | 239 | } |
234 | break; | 240 | break; |
235 | case 'y': | 241 | case 'y': |
236 | case 'Y': | 242 | case 'Y': |
237 | if(key == Key_Up) { | 243 | if(key == Key_Up) { |
238 | setDate( QDate( date.year() + 1, date.month() , date.day()) ); | 244 | setDate( QDate( date.year() + 1, date.month() , date.day()) ); |
239 | } | 245 | } |
240 | else if(key == Key_Down) { | 246 | else if(key == Key_Down) { |
241 | setDate( QDate( date.year() - 1, date.month() , date.day()) ); | 247 | setDate( QDate( date.year() - 1, date.month() , date.day()) ); |
242 | } | 248 | } |
243 | break; | 249 | break; |
244 | /* default: | 250 | /* default: |
245 | if(key == Key_Up) { | 251 | if(key == Key_Up) { |
246 | setDate( date.addDays( 1 ) ); | 252 | setDate( date.addDays( 1 ) ); |
247 | } else if(key == Key_Down) { | 253 | } else if(key == Key_Down) { |
248 | setDate( date.addDays( -1 ) ); | 254 | setDate( date.addDays( -1 ) ); |
249 | } | 255 | } |
250 | break;*/ | 256 | break;*/ |
251 | } | 257 | } |
252 | 258 | ||
253 | date = readDate(); | 259 | date = readDate(); |
254 | begin = dateForm.find("%"); | 260 | begin = dateForm.find("%"); |
255 | int allSelectStrLength = 0; | 261 | int allSelectStrLength = 0; |
256 | int selectStrLength = 0; | 262 | int selectStrLength = 0; |
257 | 263 | ||
258 | // set selection do new date an set cursor at end of selection | 264 | // set selection do new date an set cursor at end of selection |
259 | for(int i = 0; i < repeat; i++){ | 265 | for(int i = 0; i < repeat; i++){ |
260 | switch ( dateForm.at(begin + 1).latin1() ) | 266 | switch ( dateForm.at(begin + 1).latin1() ) |
261 | { | 267 | { |
262 | case 'd':// 16 (month day) | 268 | case 'd':// 16 (month day) |
263 | selectStrLength = 2; //Ok | 269 | selectStrLength = 2; //Ok |
264 | break; | 270 | break; |
265 | case 'm':// 01 (month) | 271 | case 'm':// 01 (month) |
266 | selectStrLength = 2; //Ok | 272 | selectStrLength = 2; //Ok |
267 | break; | 273 | break; |
268 | case 'a':// Mon (Weekday short) | 274 | case 'a':// Mon (Weekday short) |
269 | selectStrLength = KGlobal::locale()->weekDayName(date.dayOfWeek(), true).length(); | 275 | selectStrLength = KGlobal::locale()->weekDayName(date.dayOfWeek(), true).length(); |
270 | break; | 276 | break; |
271 | case 'A':// Monday (Weekday) | 277 | case 'A':// Monday (Weekday) |
272 | selectStrLength = KGlobal::locale()->weekDayName(date.dayOfWeek(), false).length(); | 278 | selectStrLength = KGlobal::locale()->weekDayName(date.dayOfWeek(), false).length(); |
273 | break; | 279 | break; |
274 | case 'b':// Jan (monthName short) | 280 | case 'b':// Jan (monthName short) |
275 | selectStrLength = KGlobal::locale()->monthName(date.month(), true).length(); | 281 | selectStrLength = KGlobal::locale()->monthName(date.month(), true).length(); |
276 | break; | 282 | break; |
277 | case 'B':// January (monthName) | 283 | case 'B':// January (monthName) |
278 | selectStrLength = KGlobal::locale()->monthName(date.month(), false).length(); | 284 | selectStrLength = KGlobal::locale()->monthName(date.month(), false).length(); |
279 | break; | 285 | break; |
280 | case 'y':// 04 (year short) | 286 | case 'y':// 04 (year short) |
281 | selectStrLength = 2; //Ok | 287 | selectStrLength = 2; //Ok |
282 | break; | 288 | break; |
283 | case 'Y':// 2004 (year) | 289 | case 'Y':// 2004 (year) |
284 | selectStrLength = 4; //Ok | 290 | selectStrLength = 4; //Ok |
285 | break; | 291 | break; |
286 | default: | 292 | default: |
287 | break; | 293 | break; |
288 | } | 294 | } |
289 | space = begin - (i * 2); | 295 | space = begin - (i * 2); |
290 | allSelectStrLength += selectStrLength; | 296 | allSelectStrLength += selectStrLength; |
291 | begin = dateForm.find("%", begin +1); | 297 | begin = dateForm.find("%", begin +1); |
292 | } | 298 | } |
293 | // set selection from begin of date | 299 | // set selection from begin of date |
294 | setSelect( space + allSelectStrLength - selectStrLength , selectStrLength); | 300 | setSelect( space + allSelectStrLength - selectStrLength , selectStrLength); |
295 | *cpos = space + allSelectStrLength; | 301 | *cpos = space + allSelectStrLength; |
296 | emit(dateChanged(date)); | 302 | emit(dateChanged(date)); |
297 | 303 | ||
298 | return; | 304 | return; |
299 | } | 305 | } |
300 | 306 | ||
301 | void KDateEdit::setHandleInvalid(bool handleInvalid) | 307 | void KDateEdit::setHandleInvalid(bool handleInvalid) |
302 | { | 308 | { |
303 | mHandleInvalid = handleInvalid; | 309 | mHandleInvalid = handleInvalid; |
304 | } | 310 | } |
305 | 311 | ||
306 | void KDateEdit::setEnabled(bool on) | 312 | void KDateEdit::setEnabled(bool on) |
307 | { | 313 | { |
308 | mDateEdit->setEnabled(on); | 314 | mDateEdit->setEnabled(on); |
309 | mDateButton->setEnabled(on); | 315 | mDateButton->setEnabled(on); |
310 | } | 316 | } |
311 | 317 | ||
312 | QDate KDateEdit::date() const | 318 | QDate KDateEdit::date() const |
313 | { | 319 | { |
314 | QDate date = readDate(); | 320 | QDate date = readDate(); |
315 | 321 | ||
316 | if (date.isValid() || mHandleInvalid) { | 322 | if (date.isValid() || mHandleInvalid) { |
317 | return date; | 323 | return date; |
318 | } else { | 324 | } else { |
319 | KNotifyClient::beep(); | 325 | KNotifyClient::beep(); |
320 | return QDate::currentDate(); | 326 | return QDate::currentDate(); |
321 | } | 327 | } |
322 | } | 328 | } |
323 | 329 | ||
324 | void KDateEdit::keyPressEvent(QKeyEvent *e) | 330 | void KDateEdit::keyPressEvent(QKeyEvent *e) |
325 | { | 331 | { |
326 | QDate date = readDate(); | 332 | QDate date = readDate(); |
327 | int cpos = mDateEdit->cursorPosition(); | 333 | int cpos = mDateEdit->cursorPosition(); |
328 | 334 | ||
329 | switch(e->key()) | 335 | switch(e->key()) |
330 | { | 336 | { |
331 | case Key_Escape: | 337 | case Key_Escape: |
332 | mDateEdit->deselect(); | 338 | mDateEdit->deselect(); |
333 | case Key_Tab: | 339 | case Key_Tab: |
334 | QHBox::keyPressEvent(e); | 340 | QHBox::keyPressEvent(e); |
335 | break; | 341 | break; |
336 | case Key_Up: | 342 | case Key_Up: |
337 | // when date invalid then set to currend and return | 343 | // when date invalid then set to currend and return |
338 | if(!date.isValid()) { | 344 | if(!date.isValid()) { |
339 | date = QDate::currentDate(); | 345 | date = QDate::currentDate(); |
340 | setDate(date); | 346 | setDate(date); |
341 | mDateEdit->setCursorPosition(cpos); | 347 | mDateEdit->setCursorPosition(cpos); |
342 | emit(dateChanged(date)); | 348 | emit(dateChanged(date)); |
343 | QString text = i18n( "You entered an invalid date!\n Date changed to current date." ); | 349 | QString text = i18n( "You entered an invalid date!\n Date changed to current date." ); |
344 | KMessageBox::information( 0, text ); | 350 | KMessageBox::information( 0, text ); |
345 | return; | 351 | return; |
346 | } | 352 | } |
347 | setDate(date, &cpos, Key_Up, dateFormShort); | 353 | setDate(date, &cpos, Key_Up, dateFormShort); |
348 | break; | 354 | break; |
349 | case Key_Down: | 355 | case Key_Down: |
350 | // when date invalid then set to current and return | 356 | // when date invalid then set to current and return |
351 | if(!date.isValid()) { | 357 | if(!date.isValid()) { |
352 | date = QDate::currentDate(); | 358 | date = QDate::currentDate(); |
353 | setDate(date); | 359 | setDate(date); |
354 | mDateEdit->setCursorPosition(cpos); | 360 | mDateEdit->setCursorPosition(cpos); |
355 | emit(dateChanged(date)); | 361 | emit(dateChanged(date)); |
356 | QString text = i18n( "You entered an invalid date!\n Date changed to current date." ); | 362 | QString text = i18n( "You entered an invalid date!\n Date changed to current date." ); |
357 | KMessageBox::information( 0, text ); | 363 | KMessageBox::information( 0, text ); |
358 | return; | 364 | return; |
359 | } | 365 | } |
360 | setDate(date, &cpos, Key_Down, dateFormShort); | 366 | setDate(date, &cpos, Key_Down, dateFormShort); |
361 | break; | 367 | break; |
362 | default: | 368 | default: |
363 | QHBox::keyPressEvent(e); | 369 | QHBox::keyPressEvent(e); |
364 | break; | 370 | break; |
365 | } // switch | 371 | } // switch |
366 | mDateEdit->setCursorPosition(cpos); | 372 | mDateEdit->setCursorPosition(cpos); |
367 | } | 373 | } |
368 | 374 | ||
369 | void KDateEdit::setSelect( int from, int to ) | 375 | void KDateEdit::setSelect( int from, int to ) |
370 | { | 376 | { |
371 | // return; | 377 | // return; |
372 | mDateEdit->setSelection( from , to ); | 378 | mDateEdit->setSelection( from , to ); |
373 | } | 379 | } |
374 | 380 | ||
375 | void KDateEdit::toggleDatePicker() | 381 | void KDateEdit::toggleDatePicker() |
376 | { | 382 | { |
377 | if( mDateFrame->isVisible() ) { | 383 | if( mDateFrame->isVisible() ) { |
378 | mDateFrame->hide(); | 384 | mDateFrame->hide(); |
379 | } else { | 385 | } else { |
380 | QPoint tmpPoint = mapToGlobal(mDateButton->geometry().bottomRight()); | 386 | QPoint tmpPoint = mapToGlobal(mDateButton->geometry().bottomRight()); |
381 | QSize datepickersize = mDatePicker->sizeHint(); | 387 | QSize datepickersize = mDatePicker->sizeHint(); |
382 | 388 | ||
383 | if ( tmpPoint.x() < 7+datepickersize.width() ) tmpPoint.setX( 7+datepickersize.width() ); | 389 | if ( tmpPoint.x() < 7+datepickersize.width() ) tmpPoint.setX( 7+datepickersize.width() ); |
384 | 390 | ||
385 | int h = QApplication::desktop()->height(); | 391 | int h = QApplication::desktop()->height(); |
386 | 392 | ||
387 | if ( tmpPoint.y() + datepickersize.height() > h ) tmpPoint.setY( h - datepickersize.height() ); | 393 | if ( tmpPoint.y() + datepickersize.height() > h ) tmpPoint.setY( h - datepickersize.height() ); |
388 | 394 | ||
389 | mDateFrame->setGeometry(tmpPoint.x()-datepickersize.width()-7, tmpPoint.y(), | 395 | mDateFrame->setGeometry(tmpPoint.x()-datepickersize.width()-7, tmpPoint.y(), |
390 | datepickersize.width()+2*mDateFrame->lineWidth(), datepickersize.height()+2*mDateFrame->lineWidth()); | 396 | datepickersize.width()+2*mDateFrame->lineWidth(), datepickersize.height()+2*mDateFrame->lineWidth()); |
391 | 397 | ||
392 | QDate date = readDate(); | 398 | QDate date = readDate(); |
393 | if(date.isValid()) { | 399 | if(date.isValid()) { |
394 | mDatePicker->setDate(date); | 400 | mDatePicker->setDate(date); |
395 | } else { | 401 | } else { |
396 | mDatePicker->setDate(QDate::currentDate()); | 402 | mDatePicker->setDate(QDate::currentDate()); |
397 | } | 403 | } |
398 | mDateFrame->show(); | 404 | mDateFrame->show(); |
399 | } | 405 | } |
400 | } | 406 | } |
401 | 407 | ||
402 | 408 | ||
403 | void KDateEdit::lineEnterPressed() | 409 | void KDateEdit::lineEnterPressed() |
404 | { | 410 | { |
405 | QDate date = readDate(); | 411 | QDate date = readDate(); |
406 | 412 | ||
407 | if(date.isValid()) | 413 | if(date.isValid()) |
408 | { | 414 | { |
409 | // Update the edit. This is needed if the user has entered a | 415 | // Update the edit. This is needed if the user has entered a |
410 | // word rather than the actual date. | 416 | // word rather than the actual date. |
411 | setDate(date); | 417 | setDate(date); |
412 | emit(dateChanged(date)); | 418 | emit(dateChanged(date)); |
413 | emit returnPressed(); | 419 | emit returnPressed(); |
414 | } | 420 | } |
415 | else | 421 | else |
416 | { | 422 | { |
417 | if ( withoutDp ) { | 423 | if ( withoutDp ) { |
418 | KNotifyClient::beep(); | 424 | KNotifyClient::beep(); |
419 | } else { | 425 | } else { |
420 | if ( !mDateEdit->text().isEmpty() ) { | 426 | if ( !mDateEdit->text().isEmpty() ) { |
421 | mTextChanged = false; | 427 | mTextChanged = false; |
422 | QString text = i18n( "You entered an invalid date!\n Will use current date instead." ); | 428 | QString text = i18n( "You entered an invalid date!\n Will use current date instead." ); |
423 | if ( KMessageBox::warningContinueCancel( 0, text ) == KMessageBox::Continue ) { | 429 | if ( KMessageBox::warningContinueCancel( 0, text ) == KMessageBox::Continue ) { |
424 | setDate( QDate::currentDate() ); | 430 | setDate( QDate::currentDate() ); |
425 | emit dateChanged( QDate::currentDate() ); | 431 | emit dateChanged( QDate::currentDate() ); |
426 | } | 432 | } |
427 | } | 433 | } |
428 | } | 434 | } |
429 | } | 435 | } |
430 | } | 436 | } |
431 | 437 | ||
432 | bool KDateEdit::inputIsValid() | 438 | bool KDateEdit::inputIsValid() |
433 | { | 439 | { |
434 | return readDate().isValid(); | 440 | return readDate().isValid(); |
435 | } | 441 | } |
436 | 442 | ||
437 | QDate KDateEdit::readDate() const | 443 | QDate KDateEdit::readDate() const |
438 | { | 444 | { |
439 | QString text = mDateEdit->text(); | 445 | QString text = mDateEdit->text(); |
440 | QDate date; | 446 | QDate date; |
441 | 447 | ||
442 | if (mKeywordMap.contains(text.lower())) | 448 | if (mKeywordMap.contains(text.lower())) |
443 | { | 449 | { |
444 | date = QDate::currentDate().addDays(mKeywordMap[text.lower()]); | 450 | date = QDate::currentDate().addDays(mKeywordMap[text.lower()]); |
445 | } | 451 | } |
446 | else | 452 | else |
447 | { | 453 | { |
448 | date = KGlobal::locale()->readDate(text); | 454 | date = KGlobal::locale()->readDate(text); |
449 | } | 455 | } |
450 | 456 | ||
451 | return date; | 457 | return date; |
452 | } | 458 | } |
453 | 459 | ||
454 | bool KDateEdit::eventFilter(QObject *, QEvent *e) | 460 | bool KDateEdit::eventFilter(QObject *, QEvent *e) |
455 | { | 461 | { |
456 | // We only process the focus out event if the text has changed | 462 | // We only process the focus out event if the text has changed |
457 | // since we got focus | 463 | // since we got focus |
458 | if ((e->type() == QEvent::FocusOut) && mTextChanged) | 464 | if ((e->type() == QEvent::FocusOut) && mTextChanged) |
459 | { | 465 | { |
460 | lineEnterPressed(); | 466 | lineEnterPressed(); |
461 | mTextChanged = false; | 467 | mTextChanged = false; |
462 | } | 468 | } |
463 | // switch dateFormShort by double klick with mouse | 469 | // switch dateFormShort by double klick with mouse |
464 | else if (e->type() == QEvent::MouseButtonDblClick) | 470 | else if (e->type() == QEvent::MouseButtonDblClick) |
465 | { | 471 | { |
466 | dateFormShort = dateFormShort?false:true; | 472 | toggleDateFormat(); |
467 | mDateEdit->setText(KGlobal::locale()->formatDate(readDate(),dateFormShort)); | ||
468 | } | 473 | } |
469 | else if (e->type() == QEvent::FocusIn) | 474 | else if (e->type() == QEvent::FocusIn) |
470 | { | 475 | { |
471 | maxDay = readDate().day(); | 476 | maxDay = readDate().day(); |
472 | } | 477 | } |
473 | 478 | ||
474 | return false; | 479 | return false; |
475 | } | 480 | } |
481 | void KDateEdit::toggleDateFormat() | ||
482 | { | ||
483 | dateFormShort = ! dateFormShort; | ||
484 | mDateEdit->setText(KGlobal::locale()->formatDate(readDate(),dateFormShort)); | ||
485 | |||
486 | } | ||
476 | 487 | ||
477 | void KDateEdit::textChanged(const QString &) | 488 | void KDateEdit::textChanged(const QString &) |
478 | { | 489 | { |
479 | if(mHandleInvalid && mDateEdit->text().stripWhiteSpace().isEmpty()) { | 490 | if(mHandleInvalid && mDateEdit->text().stripWhiteSpace().isEmpty()) { |
480 | QDate date; //invalid date | 491 | QDate date; //invalid date |
481 | emit(dateChanged(date)); | 492 | emit(dateChanged(date)); |
482 | } else { | 493 | } else { |
483 | mTextChanged = true; | 494 | mTextChanged = true; |
484 | } | 495 | } |
485 | maxDay = readDate().day(); | 496 | maxDay = readDate().day(); |
486 | } | 497 | } |
diff --git a/libkdepim/kdateedit.h b/libkdepim/kdateedit.h index 742d843..cf3b90a 100644 --- a/libkdepim/kdateedit.h +++ b/libkdepim/kdateedit.h | |||
@@ -1,140 +1,141 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkdepim. | 2 | This file is part of libkdepim. |
3 | 3 | ||
4 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | #ifndef KDATEEDIT_H | 24 | #ifndef KDATEEDIT_H |
25 | #define KDATEEDIT_H | 25 | #define KDATEEDIT_H |
26 | 26 | ||
27 | #include <qhbox.h> | 27 | #include <qhbox.h> |
28 | #include <qvbox.h> | 28 | #include <qvbox.h> |
29 | #include <qdatetime.h> | 29 | #include <qdatetime.h> |
30 | #include <qmap.h> | 30 | #include <qmap.h> |
31 | 31 | ||
32 | class QLineEdit; | 32 | class QLineEdit; |
33 | class QPushButton; | 33 | class QPushButton; |
34 | class QObject; | 34 | class QObject; |
35 | class QEvent; | 35 | class QEvent; |
36 | class KDatePicker; | 36 | class KDatePicker; |
37 | class KDateValidator; | 37 | class KDateValidator; |
38 | 38 | ||
39 | /** | 39 | /** |
40 | * A date editing widget that consists of a line edit followed by | 40 | * A date editing widget that consists of a line edit followed by |
41 | * a small push button. The line edit contains the date in text form, | 41 | * a small push button. The line edit contains the date in text form, |
42 | * and the push button will display a 'popup' style date picker. | 42 | * and the push button will display a 'popup' style date picker. |
43 | * | 43 | * |
44 | * This widget also supports advanced features like allowing the user | 44 | * This widget also supports advanced features like allowing the user |
45 | * to type in the day name to get the date. The following keywords | 45 | * to type in the day name to get the date. The following keywords |
46 | * are supported (in the native language): tomorrow, yesturday, today, | 46 | * are supported (in the native language): tomorrow, yesturday, today, |
47 | * monday, tuesday, wednesday, thursday, friday, saturday, sunday. | 47 | * monday, tuesday, wednesday, thursday, friday, saturday, sunday. |
48 | * | 48 | * |
49 | * @author Cornelius Schumacher <schumacher@kde.org> | 49 | * @author Cornelius Schumacher <schumacher@kde.org> |
50 | * @author Mike Pilone <mpilone@slac.com> | 50 | * @author Mike Pilone <mpilone@slac.com> |
51 | */ | 51 | */ |
52 | class KDateEdit : public QHBox | 52 | class KDateEdit : public QHBox |
53 | { | 53 | { |
54 | Q_OBJECT | 54 | Q_OBJECT |
55 | public: | 55 | public: |
56 | KDateEdit(QWidget *parent=0, const char *name=0, bool withoutDP = false ); | 56 | KDateEdit(QWidget *parent=0, const char *name=0, bool withoutDP = false ); |
57 | virtual ~KDateEdit(); | 57 | virtual ~KDateEdit(); |
58 | 58 | ||
59 | /** @return True if the date in the text edit is valid, | 59 | /** @return True if the date in the text edit is valid, |
60 | * false otherwise. This will not modify the display of the date, | 60 | * false otherwise. This will not modify the display of the date, |
61 | * but only check for validity. | 61 | * but only check for validity. |
62 | */ | 62 | */ |
63 | bool inputIsValid(); | 63 | bool inputIsValid(); |
64 | 64 | ||
65 | /** @return The date entered. This will not | 65 | /** @return The date entered. This will not |
66 | * modify the display of the date, but only return it. | 66 | * modify the display of the date, but only return it. |
67 | */ | 67 | */ |
68 | QDate date() const; | 68 | QDate date() const; |
69 | 69 | ||
70 | /** @param handleInvalid If true the date edit accepts invalid dates | 70 | /** @param handleInvalid If true the date edit accepts invalid dates |
71 | * and displays them as the empty ("") string. It also returns an invalid date. | 71 | * and displays them as the empty ("") string. It also returns an invalid date. |
72 | * If false (default) invalid dates are not accepted and instead the date | 72 | * If false (default) invalid dates are not accepted and instead the date |
73 | * of today will be returned. | 73 | * of today will be returned. |
74 | */ | 74 | */ |
75 | void setHandleInvalid(bool handleInvalid); | 75 | void setHandleInvalid(bool handleInvalid); |
76 | 76 | ||
77 | /** Checks for a focus out event. The display of the date is updated | 77 | /** Checks for a focus out event. The display of the date is updated |
78 | * to display the proper date when the focus leaves. | 78 | * to display the proper date when the focus leaves. |
79 | */ | 79 | */ |
80 | virtual bool eventFilter(QObject *o, QEvent *e); | 80 | virtual bool eventFilter(QObject *o, QEvent *e); |
81 | 81 | void toggleDateFormat(); | |
82 | void clear(); | ||
82 | signals: | 83 | signals: |
83 | /** This signal is emitted whenever the user modifies the date. This | 84 | /** This signal is emitted whenever the user modifies the date. This |
84 | * may not get emitted until the user presses enter in the line edit or | 85 | * may not get emitted until the user presses enter in the line edit or |
85 | * focus leaves the widget (ie: the user confirms their selection). | 86 | * focus leaves the widget (ie: the user confirms their selection). |
86 | */ | 87 | */ |
87 | void dateChanged(QDate); | 88 | void dateChanged(QDate); |
88 | void returnPressed(); | 89 | void returnPressed(); |
89 | public slots: | 90 | public slots: |
90 | /** Sets the date. | 91 | /** Sets the date. |
91 | * | 92 | * |
92 | * @param date The new date to display. This date must be valid or | 93 | * @param date The new date to display. This date must be valid or |
93 | * it will not be displayed. | 94 | * it will not be displayed. |
94 | */ | 95 | */ |
95 | void setDate(QDate date); | 96 | void setDate(QDate date); |
96 | // set Date with key_up key_down to relation of cursor Position | 97 | // set Date with key_up key_down to relation of cursor Position |
97 | // and set selection from begin to end of single date | 98 | // and set selection from begin to end of single date |
98 | void setDate(QDate, int *cpos, const int, const bool); | 99 | void setDate(QDate, int *cpos, const int, const bool); |
99 | 100 | ||
100 | /** Sets the date edit to be enabled or disabled (grayed out) | 101 | /** Sets the date edit to be enabled or disabled (grayed out) |
101 | * | 102 | * |
102 | * @param on Enabled if true, disabled if false | 103 | * @param on Enabled if true, disabled if false |
103 | */ | 104 | */ |
104 | void setEnabled(bool on); | 105 | void setEnabled(bool on); |
105 | 106 | ||
106 | protected slots: | 107 | protected slots: |
107 | void toggleDatePicker(); | 108 | void toggleDatePicker(); |
108 | void lineEnterPressed(); | 109 | void lineEnterPressed(); |
109 | void textChanged(const QString &); | 110 | void textChanged(const QString &); |
110 | 111 | ||
111 | private: | 112 | private: |
112 | /** Reads the text from the line edit. If the text is a keyword, the | 113 | /** Reads the text from the line edit. If the text is a keyword, the |
113 | * word will be translated to a date. If the text is not a keyword, the | 114 | * word will be translated to a date. If the text is not a keyword, the |
114 | * text will be interpreted as a date. | 115 | * text will be interpreted as a date. |
115 | */ | 116 | */ |
116 | QDate readDate() const; | 117 | QDate readDate() const; |
117 | 118 | ||
118 | /** Maps the text that the user can enter to the offset in days from | 119 | /** Maps the text that the user can enter to the offset in days from |
119 | * today. For example, the text 'tomorrow' is mapped to +1. | 120 | * today. For example, the text 'tomorrow' is mapped to +1. |
120 | */ | 121 | */ |
121 | QMap<QString, int> mKeywordMap; | 122 | QMap<QString, int> mKeywordMap; |
122 | bool mTextChanged; | 123 | bool mTextChanged; |
123 | bool mHandleInvalid; | 124 | bool mHandleInvalid; |
124 | 125 | ||
125 | QPushButton *mDateButton; | 126 | QPushButton *mDateButton; |
126 | QLineEdit *mDateEdit; | 127 | QLineEdit *mDateEdit; |
127 | KDatePicker *mDatePicker; | 128 | KDatePicker *mDatePicker; |
128 | QVBox *mDateFrame; | 129 | QVBox *mDateFrame; |
129 | int maxDay; | 130 | int maxDay; |
130 | bool withoutDp; | 131 | bool withoutDp; |
131 | 132 | ||
132 | protected: | 133 | protected: |
133 | virtual void keyPressEvent(QKeyEvent *qke); | 134 | virtual void keyPressEvent(QKeyEvent *qke); |
134 | void setSelect ( int, int ); | 135 | void setSelect ( int, int ); |
135 | bool dateFormShort; | 136 | bool dateFormShort; |
136 | char lengthMonthName; | 137 | char lengthMonthName; |
137 | 138 | ||
138 | }; | 139 | }; |
139 | 140 | ||
140 | #endif | 141 | #endif |
diff --git a/microkde/kdeui/kaction.cpp b/microkde/kdeui/kaction.cpp index 77d36a5..d38a6d5 100644 --- a/microkde/kdeui/kaction.cpp +++ b/microkde/kdeui/kaction.cpp | |||
@@ -1,1215 +1,1215 @@ | |||
1 | /* This file is part of the KDE libraries | 1 | /* This file is part of the KDE libraries |
2 | Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org> | 2 | Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org> |
3 | (C) 1999 Simon Hausmann <hausmann@kde.org> | 3 | (C) 1999 Simon Hausmann <hausmann@kde.org> |
4 | (C) 2000 Nicolas Hadacek <haadcek@kde.org> | 4 | (C) 2000 Nicolas Hadacek <haadcek@kde.org> |
5 | (C) 2000 Kurt Granroth <granroth@kde.org> | 5 | (C) 2000 Kurt Granroth <granroth@kde.org> |
6 | (C) 2000 Michael Koch <koch@kde.org> | 6 | (C) 2000 Michael Koch <koch@kde.org> |
7 | (C) 2001 Holger Freyther <freyther@kde.org> | 7 | (C) 2001 Holger Freyther <freyther@kde.org> |
8 | (C) 2002 Ellis Whitehead <ellis@kde.org> | 8 | (C) 2002 Ellis Whitehead <ellis@kde.org> |
9 | (C) 2002 Joseph Wenninger <jowenn@kde.org> | 9 | (C) 2002 Joseph Wenninger <jowenn@kde.org> |
10 | 10 | ||
11 | This library is free software; you can redistribute it and/or | 11 | This library is free software; you can redistribute it and/or |
12 | modify it under the terms of the GNU Library General Public | 12 | modify it under the terms of the GNU Library General Public |
13 | License version 2 as published by the Free Software Foundation. | 13 | License version 2 as published by the Free Software Foundation. |
14 | 14 | ||
15 | This library is distributed in the hope that it will be useful, | 15 | This library is distributed in the hope that it will be useful, |
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
18 | Library General Public License for more details. | 18 | Library General Public License for more details. |
19 | 19 | ||
20 | You should have received a copy of the GNU Library General Public License | 20 | You should have received a copy of the GNU Library General Public License |
21 | along with this library; see the file COPYING.LIB. If not, write to | 21 | along with this library; see the file COPYING.LIB. If not, write to |
22 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 22 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
23 | Boston, MA 02111-1307, USA. | 23 | Boston, MA 02111-1307, USA. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include "kaction.h" | 26 | #include "kaction.h" |
27 | 27 | ||
28 | #include <assert.h> | 28 | #include <assert.h> |
29 | 29 | ||
30 | #include <qtooltip.h> | 30 | #include <qtooltip.h> |
31 | //US#include <qwhatsthis.h> | 31 | //US#include <qwhatsthis.h> |
32 | //US#include <kaccel.h> | 32 | //US#include <kaccel.h> |
33 | //US#include <kaccelbase.h> | 33 | //US#include <kaccelbase.h> |
34 | #include <kapplication.h> | 34 | #include <kapplication.h> |
35 | #include <kdebug.h> | 35 | #include <kdebug.h> |
36 | #include <kguiitem.h> | 36 | #include <kguiitem.h> |
37 | //US#include <kmainwindow.h> | 37 | //US#include <kmainwindow.h> |
38 | //US#include <kmenubar.h> | 38 | //US#include <kmenubar.h> |
39 | //US#include <kpopupmenu.h> | 39 | //US#include <kpopupmenu.h> |
40 | #include <ktoolbar.h> | 40 | #include <ktoolbar.h> |
41 | #include <ktoolbarbutton.h> | 41 | #include <ktoolbarbutton.h> |
42 | 42 | ||
43 | //US added this includefiles | 43 | //US added this includefiles |
44 | #include <qmenubar.h> | 44 | #include <qmenubar.h> |
45 | #include <qtoolbar.h> | 45 | #include <qtoolbar.h> |
46 | #include <qpopupmenu.h> | 46 | #include <qpopupmenu.h> |
47 | #include <qiconset.h> | 47 | #include <qiconset.h> |
48 | 48 | ||
49 | /** | 49 | /** |
50 | * How it works. | 50 | * How it works. |
51 | * KActionCollection is an organizing container for KActions. | 51 | * KActionCollection is an organizing container for KActions. |
52 | * KActionCollection keeps track of the information necessary to handle | 52 | * KActionCollection keeps track of the information necessary to handle |
53 | * configuration and shortcuts. | 53 | * configuration and shortcuts. |
54 | * | 54 | * |
55 | * Focus Widget pointer: | 55 | * Focus Widget pointer: |
56 | * This is the widget which is the focus for action shortcuts. | 56 | * This is the widget which is the focus for action shortcuts. |
57 | * It is set either by passing a QWidget* to the KActionCollection constructor | 57 | * It is set either by passing a QWidget* to the KActionCollection constructor |
58 | * or by calling setWidget() if the widget wasn't known when the object was | 58 | * or by calling setWidget() if the widget wasn't known when the object was |
59 | * initially constructed (as in KXMLGUIClient and KParts::PartBase) | 59 | * initially constructed (as in KXMLGUIClient and KParts::PartBase) |
60 | * | 60 | * |
61 | * Shortcuts: | 61 | * Shortcuts: |
62 | * An action's shortcut will not not be connected unless a focus widget has | 62 | * An action's shortcut will not not be connected unless a focus widget has |
63 | * been specified in KActionCollection. | 63 | * been specified in KActionCollection. |
64 | * | 64 | * |
65 | * XML Filename: | 65 | * XML Filename: |
66 | * This is used to save user-modified settings back to the *ui.rc file. | 66 | * This is used to save user-modified settings back to the *ui.rc file. |
67 | * It is set by KXMLGUIFactory. | 67 | * It is set by KXMLGUIFactory. |
68 | */ | 68 | */ |
69 | 69 | ||
70 | int KAction::getToolButtonID() | 70 | int KAction::getToolButtonID() |
71 | { | 71 | { |
72 | static int toolbutton_no = -2; | 72 | static int toolbutton_no = -2; |
73 | return toolbutton_no--; | 73 | return toolbutton_no--; |
74 | } | 74 | } |
75 | 75 | ||
76 | //--------------------------------------------------------------------- | 76 | //--------------------------------------------------------------------- |
77 | // KAction::KActionPrivate | 77 | // KAction::KActionPrivate |
78 | //--------------------------------------------------------------------- | 78 | //--------------------------------------------------------------------- |
79 | 79 | ||
80 | class KAction::KActionPrivate : public KGuiItem | 80 | class KAction::KActionPrivate : public KGuiItem |
81 | { | 81 | { |
82 | public: | 82 | public: |
83 | KActionPrivate() : KGuiItem() | 83 | KActionPrivate() : KGuiItem() |
84 | { | 84 | { |
85 | m_kaccel = 0; | 85 | m_kaccel = 0; |
86 | m_configurable = true; | 86 | m_configurable = true; |
87 | } | 87 | } |
88 | 88 | ||
89 | KAccel *m_kaccel; | 89 | KAccel *m_kaccel; |
90 | QValueList<KAccel*> m_kaccelList; | 90 | QValueList<KAccel*> m_kaccelList; |
91 | 91 | ||
92 | QString m_groupText; | 92 | QString m_groupText; |
93 | QString m_group; | 93 | QString m_group; |
94 | 94 | ||
95 | KShortcut m_cut; | 95 | KShortcut m_cut; |
96 | KShortcut m_cutDefault; | 96 | KShortcut m_cutDefault; |
97 | 97 | ||
98 | bool m_configurable; | 98 | bool m_configurable; |
99 | 99 | ||
100 | struct Container | 100 | struct Container |
101 | { | 101 | { |
102 | Container() { m_container = 0; m_representative = 0; m_id = 0; } | 102 | Container() { m_container = 0; m_representative = 0; m_id = 0; } |
103 | Container( const Container& s ) { m_container = s.m_container; | 103 | Container( const Container& s ) { m_container = s.m_container; |
104 | m_id = s.m_id; m_representative = s.m_representative; } | 104 | m_id = s.m_id; m_representative = s.m_representative; } |
105 | QWidget* m_container; | 105 | QWidget* m_container; |
106 | int m_id; | 106 | int m_id; |
107 | QWidget* m_representative; | 107 | QWidget* m_representative; |
108 | }; | 108 | }; |
109 | 109 | ||
110 | QValueList<Container> m_containers; | 110 | QValueList<Container> m_containers; |
111 | }; | 111 | }; |
112 | 112 | ||
113 | //--------------------------------------------------------------------- | 113 | //--------------------------------------------------------------------- |
114 | // KAction | 114 | // KAction |
115 | //--------------------------------------------------------------------- | 115 | //--------------------------------------------------------------------- |
116 | KAction::KAction( const QString& text, const KShortcut& cut, | 116 | KAction::KAction( const QString& text, const KShortcut& cut, |
117 | const QObject* receiver, const char* slot, | 117 | const QObject* receiver, const char* slot, |
118 | KActionCollection* parent, const char* name ) | 118 | KActionCollection* parent, const char* name ) |
119 | : QObject( parent, name ) | 119 | : QObject( parent, name ) |
120 | { | 120 | { |
121 | initPrivate( text, cut, receiver, slot ); | 121 | initPrivate( text, cut, receiver, slot ); |
122 | } | 122 | } |
123 | 123 | ||
124 | KAction::KAction( const QString& text, const QString& sIconName, const KShortcut& cut, | 124 | KAction::KAction( const QString& text, const QString& sIconName, const KShortcut& cut, |
125 | const QObject* receiver, const char* slot, | 125 | const QObject* receiver, const char* slot, |
126 | KActionCollection* parent, const char* name ) | 126 | KActionCollection* parent, const char* name ) |
127 | : QObject( parent, name ) | 127 | : QObject( parent, name ) |
128 | { | 128 | { |
129 | initPrivate( text, cut, receiver, slot ); | 129 | initPrivate( text, cut, receiver, slot ); |
130 | d->setIconName( sIconName ); | 130 | d->setIconName( sIconName ); |
131 | } | 131 | } |
132 | 132 | ||
133 | KAction::KAction( const QString& text, const QIconSet& pix, const KShortcut& cut, | 133 | KAction::KAction( const QString& text, const QIconSet& pix, const KShortcut& cut, |
134 | const QObject* receiver, const char* slot, | 134 | const QObject* receiver, const char* slot, |
135 | KActionCollection* parent, const char* name ) | 135 | KActionCollection* parent, const char* name ) |
136 | : QObject( parent, name ) | 136 | : QObject( parent, name ) |
137 | { | 137 | { |
138 | initPrivate( text, cut, receiver, slot ); | 138 | initPrivate( text, cut, receiver, slot ); |
139 | d->setIconSet( pix ); | 139 | d->setIconSet( pix ); |
140 | } | 140 | } |
141 | KAction::KAction( const KGuiItem& item, const KShortcut& cut, | 141 | KAction::KAction( const KGuiItem& item, const KShortcut& cut, |
142 | const QObject* receiver, const char* slot, | 142 | const QObject* receiver, const char* slot, |
143 | KActionCollection* parent, const char* name ) | 143 | KActionCollection* parent, const char* name ) |
144 | : QObject( parent, name ) | 144 | : QObject( parent, name ) |
145 | { | 145 | { |
146 | initPrivate( item.text(), cut, receiver, slot ); | 146 | initPrivate( item.text(), cut, receiver, slot ); |
147 | if( item.hasIconSet() ) | 147 | if( item.hasIconSet() ) |
148 | setIcon( item.iconName() ); | 148 | setIcon( item.iconName() ); |
149 | setToolTip( item.toolTip() ); | 149 | setToolTip( item.toolTip() ); |
150 | setWhatsThis( item.whatsThis() ); | 150 | setWhatsThis( item.whatsThis() ); |
151 | } | 151 | } |
152 | 152 | ||
153 | // KDE 4: remove | 153 | // KDE 4: remove |
154 | KAction::KAction( const QString& text, const KShortcut& cut, | 154 | KAction::KAction( const QString& text, const KShortcut& cut, |
155 | QObject* parent, const char* name ) | 155 | QObject* parent, const char* name ) |
156 | : QObject( parent, name ) | 156 | : QObject( parent, name ) |
157 | { | 157 | { |
158 | initPrivate( text, cut, 0, 0 ); | 158 | initPrivate( text, cut, 0, 0 ); |
159 | } | 159 | } |
160 | KAction::KAction( const QString& text, const KShortcut& cut, | 160 | KAction::KAction( const QString& text, const KShortcut& cut, |
161 | const QObject* receiver, | 161 | const QObject* receiver, |
162 | const char* slot, QObject* parent, const char* name ) | 162 | const char* slot, QObject* parent, const char* name ) |
163 | : QObject( parent, name ) | 163 | : QObject( parent, name ) |
164 | { | 164 | { |
165 | initPrivate( text, cut, receiver, slot ); | 165 | initPrivate( text, cut, receiver, slot ); |
166 | } | 166 | } |
167 | KAction::KAction( const QString& text, const QIconSet& pix, | 167 | KAction::KAction( const QString& text, const QIconSet& pix, |
168 | const KShortcut& cut, | 168 | const KShortcut& cut, |
169 | QObject* parent, const char* name ) | 169 | QObject* parent, const char* name ) |
170 | : QObject( parent, name ) | 170 | : QObject( parent, name ) |
171 | { | 171 | { |
172 | initPrivate( text, cut, 0, 0 ); | 172 | initPrivate( text, cut, 0, 0 ); |
173 | setIconSet( pix ); | 173 | setIconSet( pix ); |
174 | } | 174 | } |
175 | 175 | ||
176 | KAction::KAction( const QString& text, const QString& pix, | 176 | KAction::KAction( const QString& text, const QString& pix, |
177 | const KShortcut& cut, | 177 | const KShortcut& cut, |
178 | QObject* parent, const char* name ) | 178 | QObject* parent, const char* name ) |
179 | : QObject( parent, name ) | 179 | : QObject( parent, name ) |
180 | { | 180 | { |
181 | initPrivate( text, cut, 0, 0 ); | 181 | initPrivate( text, cut, 0, 0 ); |
182 | d->setIconName( pix ); | 182 | d->setIconName( pix ); |
183 | } | 183 | } |
184 | 184 | ||
185 | KAction::KAction( const QString& text, const QIconSet& pix, | 185 | KAction::KAction( const QString& text, const QIconSet& pix, |
186 | const KShortcut& cut, | 186 | const KShortcut& cut, |
187 | const QObject* receiver, const char* slot, QObject* parent, | 187 | const QObject* receiver, const char* slot, QObject* parent, |
188 | const char* name ) | 188 | const char* name ) |
189 | : QObject( parent, name ) | 189 | : QObject( parent, name ) |
190 | { | 190 | { |
191 | initPrivate( text, cut, receiver, slot ); | 191 | initPrivate( text, cut, receiver, slot ); |
192 | setIconSet( pix ); | 192 | setIconSet( pix ); |
193 | } | 193 | } |
194 | 194 | ||
195 | KAction::KAction( const QString& text, const QString& pix, | 195 | KAction::KAction( const QString& text, const QString& pix, |
196 | const KShortcut& cut, | 196 | const KShortcut& cut, |
197 | const QObject* receiver, const char* slot, QObject* parent, | 197 | const QObject* receiver, const char* slot, QObject* parent, |
198 | const char* name ) | 198 | const char* name ) |
199 | : QObject( parent, name ) | 199 | : QObject( parent, name ) |
200 | { | 200 | { |
201 | initPrivate( text, cut, receiver, slot ); | 201 | initPrivate( text, cut, receiver, slot ); |
202 | d->setIconName(pix); | 202 | d->setIconName(pix); |
203 | } | 203 | } |
204 | 204 | ||
205 | KAction::KAction( QObject* parent, const char* name ) | 205 | KAction::KAction( QObject* parent, const char* name ) |
206 | : QObject( parent, name ) | 206 | : QObject( parent, name ) |
207 | { | 207 | { |
208 | 208 | ||
209 | initPrivate( QString::null, KShortcut(), 0, 0 ); | 209 | initPrivate( QString::null, KShortcut(), 0, 0 ); |
210 | } | 210 | } |
211 | // KDE 4: remove end | 211 | // KDE 4: remove end |
212 | 212 | ||
213 | KAction::~KAction() | 213 | KAction::~KAction() |
214 | { | 214 | { |
215 | kdDebug(129) << "KAction::~KAction( this = \"" << name() << "\" )" << endl; // -- ellis | ||
216 | #ifndef KDE_NO_COMPAT | 215 | #ifndef KDE_NO_COMPAT |
217 | if (d->m_kaccel) | 216 | if (d->m_kaccel) |
218 | unplugAccel(); | 217 | unplugAccel(); |
219 | #endif | 218 | #endif |
220 | 219 | ||
221 | // If actionCollection hasn't already been destructed, | 220 | // If actionCollection hasn't already been destructed, |
222 | if ( m_parentCollection ) { | 221 | if ( m_parentCollection ) { |
223 | m_parentCollection->take( this ); | 222 | m_parentCollection->take( this ); |
224 | for( uint i = 0; i < d->m_kaccelList.count(); i++ ) | 223 | for( uint i = 0; i < d->m_kaccelList.count(); i++ ) |
225 | //US d->m_kaccelList[i]->remove( name() ); | 224 | //US d->m_kaccelList[i]->remove( name() ); |
226 | qDebug("KAction::KAction~ ...1 has top be fixed"); | 225 | qDebug("KAction::KAction~ ...1 has top be fixed"); |
227 | } | 226 | } |
228 | 227 | ||
229 | // Do not call unplugAll from here, as tempting as it sounds. | 228 | // Do not call unplugAll from here, as tempting as it sounds. |
230 | // KAction is designed around the idea that you need to plug | 229 | // KAction is designed around the idea that you need to plug |
231 | // _and_ to unplug it "manually". Unplugging leads to an important | 230 | // _and_ to unplug it "manually". Unplugging leads to an important |
232 | // slowdown when e.g. closing the window, in which case we simply | 231 | // slowdown when e.g. closing the window, in which case we simply |
233 | // want to destroy everything asap, not to remove actions one by one | 232 | // want to destroy everything asap, not to remove actions one by one |
234 | // from the GUI. | 233 | // from the GUI. |
235 | 234 | ||
236 | delete d; d = 0; | 235 | delete d; d = 0; |
237 | } | 236 | } |
238 | 237 | ||
239 | void KAction::initPrivate( const QString& text, const KShortcut& cut, | 238 | void KAction::initPrivate( const QString& text, const KShortcut& cut, |
240 | const QObject* receiver, const char* slot ) | 239 | const QObject* receiver, const char* slot ) |
241 | { | 240 | { |
242 | d = new KActionPrivate; | 241 | d = new KActionPrivate; |
243 | 242 | ||
244 | d->m_cutDefault = cut; | 243 | d->m_cutDefault = cut; |
245 | 244 | ||
246 | //US m_parentCollection = dynamic_cast<KActionCollection *>( parent() ); | 245 | //US m_parentCollection = dynamic_cast<KActionCollection *>( parent() ); |
247 | m_parentCollection = (KActionCollection *)( parent() ); | 246 | m_parentCollection = (KActionCollection *)( parent() ); |
248 | kdDebug(129) << "KAction::initPrivate(): this = " << this << " name = \"" << name() << "\" cut = " << cut.toStringInternal() << " m_parentCollection = " << m_parentCollection << endl; | 247 | kdDebug(129) << "KAction::initPrivate(): this = " << this << " name = \"" << name() << "\" cut = " << cut.toStringInternal() << " m_parentCollection = " << m_parentCollection << endl; |
249 | if ( m_parentCollection ) | 248 | if ( m_parentCollection ) |
250 | m_parentCollection->insert( this ); | 249 | m_parentCollection->insert( this ); |
251 | 250 | ||
252 | if ( receiver && slot ) | 251 | if ( receiver && slot ) |
253 | connect( this, SIGNAL( activated() ), receiver, slot ); | 252 | connect( this, SIGNAL( activated() ), receiver, slot ); |
254 | 253 | ||
255 | if( !cut.isNull() && qstrcmp( name(), "unnamed" ) == 0 ) | 254 | if( !cut.isNull() && qstrcmp( name(), "unnamed" ) == 0 ) |
256 | kdWarning(129) << "KAction::initPrivate(): trying to assign a shortcut (" << cut.toStringInternal() << ") to an unnamed action." << endl; | 255 | kdWarning(129) << "KAction::initPrivate(): trying to assign a shortcut (" << cut.toStringInternal() << ") to an unnamed action." << endl; |
257 | d->setText( text ); | 256 | d->setText( text ); |
258 | initShortcut( cut ); | 257 | initShortcut( cut ); |
259 | 258 | ||
260 | } | 259 | } |
261 | 260 | ||
262 | bool KAction::isPlugged() const | 261 | bool KAction::isPlugged() const |
263 | { | 262 | { |
264 | return (containerCount() > 0) || d->m_kaccel; | 263 | return (containerCount() > 0) || d->m_kaccel; |
265 | } | 264 | } |
266 | 265 | ||
267 | bool KAction::isPlugged( const QWidget *container ) const | 266 | bool KAction::isPlugged( const QWidget *container ) const |
268 | { | 267 | { |
269 | return findContainer( container ) > -1; | 268 | return findContainer( container ) > -1; |
270 | } | 269 | } |
271 | 270 | ||
272 | bool KAction::isPlugged( const QWidget *container, int id ) const | 271 | bool KAction::isPlugged( const QWidget *container, int id ) const |
273 | { | 272 | { |
274 | int i = findContainer( container ); | 273 | int i = findContainer( container ); |
275 | return ( i > -1 && itemId( i ) == id ); | 274 | return ( i > -1 && itemId( i ) == id ); |
276 | } | 275 | } |
277 | 276 | ||
278 | bool KAction::isPlugged( const QWidget *container, const QWidget *_representative ) const | 277 | bool KAction::isPlugged( const QWidget *container, const QWidget *_representative ) const |
279 | { | 278 | { |
280 | int i = findContainer( container ); | 279 | int i = findContainer( container ); |
281 | return ( i > -1 && representative( i ) == _representative ); | 280 | return ( i > -1 && representative( i ) == _representative ); |
282 | } | 281 | } |
283 | 282 | ||
284 | 283 | ||
285 | /* | 284 | /* |
286 | Three actionCollection conditions: | 285 | Three actionCollection conditions: |
287 | 1) Scope is known on creation and KAccel object is created (e.g. KMainWindow) | 286 | 1) Scope is known on creation and KAccel object is created (e.g. KMainWindow) |
288 | 2) Scope is unknown and no KAccel object is available (e.g. KXMLGUIClient) | 287 | 2) Scope is unknown and no KAccel object is available (e.g. KXMLGUIClient) |
289 | a) addClient() will be called on object | 288 | a) addClient() will be called on object |
290 | b) we just want to add the actions to another KXMLGUIClient object | 289 | b) we just want to add the actions to another KXMLGUIClient object |
291 | 290 | ||
292 | The question is how to do we incorporate #2b into the XMLGUI framework? | 291 | The question is how to do we incorporate #2b into the XMLGUI framework? |
293 | 292 | ||
294 | 293 | ||
295 | We have a KCommandHistory object with undo and redo actions in a passed actionCollection | 294 | We have a KCommandHistory object with undo and redo actions in a passed actionCollection |
296 | We have a KoDoc object which holds a KCommandHistory object and the actionCollection | 295 | We have a KoDoc object which holds a KCommandHistory object and the actionCollection |
297 | We have two KoView objects which both point to the same KoDoc object | 296 | We have two KoView objects which both point to the same KoDoc object |
298 | Undo and Redo should be available in both KoView objects, and | 297 | Undo and Redo should be available in both KoView objects, and |
299 | calling the undo->setEnabled() should affect both KoViews | 298 | calling the undo->setEnabled() should affect both KoViews |
300 | 299 | ||
301 | When addClient is called, it needs to be able to find the undo and redo actions | 300 | When addClient is called, it needs to be able to find the undo and redo actions |
302 | When it calls plug() on them, they need to be inserted into the KAccel object of the appropriate KoView | 301 | When it calls plug() on them, they need to be inserted into the KAccel object of the appropriate KoView |
303 | 302 | ||
304 | In this case, the actionCollection belongs to KoDoc and we need to let it know that its shortcuts | 303 | In this case, the actionCollection belongs to KoDoc and we need to let it know that its shortcuts |
305 | have the same scope as the KoView actionCollection | 304 | have the same scope as the KoView actionCollection |
306 | 305 | ||
307 | KXMLGUIClient::addSubActionCollection | 306 | KXMLGUIClient::addSubActionCollection |
308 | 307 | ||
309 | Document: | 308 | Document: |
310 | create document actions | 309 | create document actions |
311 | 310 | ||
312 | View | 311 | View |
313 | create view actions | 312 | create view actions |
314 | add document actionCollection as sub-collection | 313 | add document actionCollection as sub-collection |
315 | 314 | ||
316 | A parentCollection is created | 315 | A parentCollection is created |
317 | Scenario 1: parentCollection has a focus widget set (e.g. via KMainWindow) | 316 | Scenario 1: parentCollection has a focus widget set (e.g. via KMainWindow) |
318 | A KAccel object is created in the parentCollection | 317 | A KAccel object is created in the parentCollection |
319 | A KAction is created with parent=parentCollection | 318 | A KAction is created with parent=parentCollection |
320 | The shortcut is inserted into this actionCollection | 319 | The shortcut is inserted into this actionCollection |
321 | Scenario 1a: xml isn't used | 320 | Scenario 1a: xml isn't used |
322 | done | 321 | done |
323 | Scenario 1b: KXMLGUIBuilder::addClient() called | 322 | Scenario 1b: KXMLGUIBuilder::addClient() called |
324 | setWidget is called -- ignore | 323 | setWidget is called -- ignore |
325 | shortcuts are set | 324 | shortcuts are set |
326 | Scenario 2: parentCollection has no focus widget (e.g., KParts) | 325 | Scenario 2: parentCollection has no focus widget (e.g., KParts) |
327 | A KAction is created with parent=parentCollection | 326 | A KAction is created with parent=parentCollection |
328 | Scenario 2a: xml isn't used | 327 | Scenario 2a: xml isn't used |
329 | no shortcuts | 328 | no shortcuts |
330 | Scenario 2b: KXMLGUIBuilder::addClient() called | 329 | Scenario 2b: KXMLGUIBuilder::addClient() called |
331 | setWidget is called | 330 | setWidget is called |
332 | shortcuts are inserted into current KAccel | 331 | shortcuts are inserted into current KAccel |
333 | shortcuts are set in all other KAccels, if the action is present in the other KAccels | 332 | shortcuts are set in all other KAccels, if the action is present in the other KAccels |
334 | */ | 333 | */ |
335 | 334 | ||
336 | /* | 335 | /* |
337 | shortcut may be set: | 336 | shortcut may be set: |
338 | - on construction | 337 | - on construction |
339 | - on plug | 338 | - on plug |
340 | - on reading XML | 339 | - on reading XML |
341 | - on plugAccel (deprecated) | 340 | - on plugAccel (deprecated) |
342 | 341 | ||
343 | On Construction: [via initShortcut()] | 342 | On Construction: [via initShortcut()] |
344 | insert into KAccel of m_parentCollection, | 343 | insert into KAccel of m_parentCollection, |
345 | if kaccel() && isAutoConnectShortcuts() exists | 344 | if kaccel() && isAutoConnectShortcuts() exists |
346 | 345 | ||
347 | On Plug: [via plug() -> plugShortcut()] | 346 | On Plug: [via plug() -> plugShortcut()] |
348 | insert into KAccel of m_parentCollection, if exists and not already inserted into | 347 | insert into KAccel of m_parentCollection, if exists and not already inserted into |
349 | 348 | ||
350 | On Read XML: [via setShortcut()] | 349 | On Read XML: [via setShortcut()] |
351 | set in all current KAccels | 350 | set in all current KAccels |
352 | insert into KAccel of m_parentCollection, if exists and not already inserted into | 351 | insert into KAccel of m_parentCollection, if exists and not already inserted into |
353 | */ | 352 | */ |
354 | 353 | ||
355 | KAccel* KAction::kaccelCurrent() | 354 | KAccel* KAction::kaccelCurrent() |
356 | { | 355 | { |
357 | if( m_parentCollection && m_parentCollection->builderKAccel() ) | 356 | if( m_parentCollection && m_parentCollection->builderKAccel() ) |
358 | return m_parentCollection->builderKAccel(); | 357 | return m_parentCollection->builderKAccel(); |
359 | else if( m_parentCollection && m_parentCollection->kaccel() ) | 358 | else if( m_parentCollection && m_parentCollection->kaccel() ) |
360 | return m_parentCollection->kaccel(); | 359 | return m_parentCollection->kaccel(); |
361 | else | 360 | else |
362 | return 0L; | 361 | return 0L; |
363 | } | 362 | } |
364 | 363 | ||
365 | // Only to be called from initPrivate() | 364 | // Only to be called from initPrivate() |
366 | bool KAction::initShortcut( const KShortcut& cut ) | 365 | bool KAction::initShortcut( const KShortcut& cut ) |
367 | { | 366 | { |
368 | d->m_cut = cut; | 367 | d->m_cut = cut; |
369 | 368 | ||
370 | // Only insert action into KAccel if it has a valid name, | 369 | // Only insert action into KAccel if it has a valid name, |
371 | if( qstrcmp( name(), "unnamed" ) != 0 && | 370 | if( qstrcmp( name(), "unnamed" ) != 0 && |
372 | m_parentCollection && | 371 | m_parentCollection && |
373 | m_parentCollection->isAutoConnectShortcuts() && | 372 | m_parentCollection->isAutoConnectShortcuts() && |
374 | m_parentCollection->kaccel() ) | 373 | m_parentCollection->kaccel() ) |
375 | { | 374 | { |
376 | insertKAccel( m_parentCollection->kaccel() ); | 375 | insertKAccel( m_parentCollection->kaccel() ); |
377 | return true; | 376 | return true; |
378 | } | 377 | } |
379 | return false; | 378 | return false; |
380 | } | 379 | } |
381 | 380 | ||
382 | // Only to be called from plug() | 381 | // Only to be called from plug() |
383 | void KAction::plugShortcut() | 382 | void KAction::plugShortcut() |
384 | { | 383 | { |
385 | KAccel* kaccel = kaccelCurrent(); | 384 | KAccel* kaccel = kaccelCurrent(); |
386 | 385 | ||
387 | //kdDebug(129) << "KAction::plugShortcut(): this = " << this << " kaccel() = " << (m_parentCollection ? m_parentCollection->kaccel() : 0) << endl; | 386 | //kdDebug(129) << "KAction::plugShortcut(): this = " << this << " kaccel() = " << (m_parentCollection ? m_parentCollection->kaccel() : 0) << endl; |
388 | if( kaccel && qstrcmp( name(), "unnamed" ) != 0 ) { | 387 | if( kaccel && qstrcmp( name(), "unnamed" ) != 0 ) { |
389 | // Check if already plugged into current KAccel object | 388 | // Check if already plugged into current KAccel object |
390 | for( uint i = 0; i < d->m_kaccelList.count(); i++ ) { | 389 | for( uint i = 0; i < d->m_kaccelList.count(); i++ ) { |
391 | if( d->m_kaccelList[i] == kaccel ) | 390 | if( d->m_kaccelList[i] == kaccel ) |
392 | return; | 391 | return; |
393 | } | 392 | } |
394 | 393 | ||
395 | insertKAccel( kaccel ); | 394 | insertKAccel( kaccel ); |
396 | } | 395 | } |
397 | } | 396 | } |
398 | 397 | ||
399 | bool KAction::setShortcut( const KShortcut& cut ) | 398 | bool KAction::setShortcut( const KShortcut& cut ) |
400 | { | 399 | { |
401 | qDebug("KAction::setShortcut~ ...1 has top be fixed"); | 400 | qDebug("KAction::setShortcut~ ...1 has top be fixed"); |
402 | /*US | 401 | /*US |
403 | bool bChanged = (d->m_cut != cut); | 402 | bool bChanged = (d->m_cut != cut); |
404 | d->m_cut = cut; | 403 | d->m_cut = cut; |
405 | 404 | ||
406 | KAccel* kaccel = kaccelCurrent(); | 405 | KAccel* kaccel = kaccelCurrent(); |
407 | bool bInsertRequired = true; | 406 | bool bInsertRequired = true; |
408 | // Apply new shortcut to all existing KAccel objects | 407 | // Apply new shortcut to all existing KAccel objects |
409 | for( uint i = 0; i < d->m_kaccelList.count(); i++ ) { | 408 | for( uint i = 0; i < d->m_kaccelList.count(); i++ ) { |
410 | // Check whether shortcut has already been plugged into | 409 | // Check whether shortcut has already been plugged into |
411 | // the current kaccel object. | 410 | // the current kaccel object. |
412 | if( d->m_kaccelList[i] == kaccel ) | 411 | if( d->m_kaccelList[i] == kaccel ) |
413 | bInsertRequired = false; | 412 | bInsertRequired = false; |
414 | if( bChanged ) | 413 | if( bChanged ) |
415 | updateKAccelShortcut( d->m_kaccelList[i] ); | 414 | updateKAccelShortcut( d->m_kaccelList[i] ); |
416 | } | 415 | } |
417 | 416 | ||
418 | // Only insert action into KAccel if it has a valid name, | 417 | // Only insert action into KAccel if it has a valid name, |
419 | if( kaccel && bInsertRequired && qstrcmp( name(), "unnamed" ) ) | 418 | if( kaccel && bInsertRequired && qstrcmp( name(), "unnamed" ) ) |
420 | insertKAccel( kaccel ); | 419 | insertKAccel( kaccel ); |
421 | 420 | ||
422 | if( bChanged ) { | 421 | if( bChanged ) { |
423 | // KDE 4: remove | 422 | // KDE 4: remove |
424 | if ( d->m_kaccel ) | 423 | if ( d->m_kaccel ) |
425 | d->m_kaccel->setShortcut( name(), cut ); | 424 | d->m_kaccel->setShortcut( name(), cut ); |
426 | // KDE 4: remove end | 425 | // KDE 4: remove end |
427 | int len = containerCount(); | 426 | int len = containerCount(); |
428 | for( int i = 0; i < len; ++i ) | 427 | for( int i = 0; i < len; ++i ) |
429 | updateShortcut( i ); | 428 | updateShortcut( i ); |
430 | } | 429 | } |
431 | */ | 430 | */ |
432 | 431 | ||
433 | return true; | 432 | return true; |
434 | } | 433 | } |
435 | 434 | ||
436 | bool KAction::updateKAccelShortcut( KAccel* kaccel ) | 435 | bool KAction::updateKAccelShortcut( KAccel* kaccel ) |
437 | { | 436 | { |
438 | qDebug("KAction::updateKAccelShortcut~ ...1 has top be fixed"); | 437 | //qDebug("KAction::updateKAccelShortcut~ ...1 has top be fixed"); |
438 | |||
439 | // Check if action is permitted | 439 | // Check if action is permitted |
440 | /*US | 440 | /*US |
441 | if (kapp && !kapp->authorizeKAction(name())) | 441 | if (kapp && !kapp->authorizeKAction(name())) |
442 | return false; | 442 | return false; |
443 | 443 | ||
444 | bool b = true; | 444 | bool b = true; |
445 | 445 | ||
446 | if ( !kaccel->actions().actionPtr( name() ) ) { | 446 | if ( !kaccel->actions().actionPtr( name() ) ) { |
447 | if(!d->m_cut.isNull() ) { | 447 | if(!d->m_cut.isNull() ) { |
448 | kdDebug(129) << "Inserting " << name() << ", " << d->text() << ", " << d->plainText() << endl; | 448 | kdDebug(129) << "Inserting " << name() << ", " << d->text() << ", " << d->plainText() << endl; |
449 | b = kaccel->insert( name(), d->plainText(), QString::null, | 449 | b = kaccel->insert( name(), d->plainText(), QString::null, |
450 | d->m_cut, | 450 | d->m_cut, |
451 | this, SLOT(slotActivated()), | 451 | this, SLOT(slotActivated()), |
452 | isShortcutConfigurable(), isEnabled() ); | 452 | isShortcutConfigurable(), isEnabled() ); |
453 | } | 453 | } |
454 | } | 454 | } |
455 | else | 455 | else |
456 | b = kaccel->setShortcut( name(), d->m_cut ); | 456 | b = kaccel->setShortcut( name(), d->m_cut ); |
457 | 457 | ||
458 | return b; | 458 | return b; |
459 | */ | 459 | */ |
460 | return true; | 460 | return true; |
461 | } | 461 | } |
462 | 462 | ||
463 | void KAction::insertKAccel( KAccel* kaccel ) | 463 | void KAction::insertKAccel( KAccel* kaccel ) |
464 | { | 464 | { |
465 | qDebug("KAction::updateKAccelShortcut~ ...1 has top be fixed"); | 465 | //qDebug("KAction::updateKAccelShortcut~ ...1 has top be fixed"); |
466 | |||
466 | /*US | 467 | /*US |
467 | //kdDebug(129) << "KAction::insertKAccel( " << kaccel << " ): this = " << this << endl; | 468 | //kdDebug(129) << "KAction::insertKAccel( " << kaccel << " ): this = " << this << endl; |
468 | if ( !kaccel->actions().actionPtr( name() ) ) { | 469 | if ( !kaccel->actions().actionPtr( name() ) ) { |
469 | if( updateKAccelShortcut( kaccel ) ) { | 470 | if( updateKAccelShortcut( kaccel ) ) { |
470 | d->m_kaccelList.append( kaccel ); | 471 | d->m_kaccelList.append( kaccel ); |
471 | connect( kaccel, SIGNAL(destroyed()), this, SLOT(slotDestroyed()) ); | 472 | connect( kaccel, SIGNAL(destroyed()), this, SLOT(slotDestroyed()) ); |
472 | } | 473 | } |
473 | } | 474 | } |
474 | else | 475 | else |
475 | kdWarning(129) << "KAction::insertKAccel( kaccel = " << kaccel << " ): KAccel object already contains an action name \"" << name() << "\"" << endl; // -- ellis | 476 | kdWarning(129) << "KAction::insertKAccel( kaccel = " << kaccel << " ): KAccel object already contains an action name \"" << name() << "\"" << endl; // -- ellis |
476 | */ | 477 | */ |
477 | } | 478 | } |
478 | 479 | ||
479 | void KAction::removeKAccel( KAccel* kaccel ) | 480 | void KAction::removeKAccel( KAccel* kaccel ) |
480 | { | 481 | { |
481 | qDebug("KAction::removeKAccel~ ...1 has top be fixed"); | 482 | // qDebug("KAction::removeKAccel~ ...1 has top be fixed"); |
483 | |||
482 | /*US | 484 | /*US |
483 | //kdDebug(129) << "KAction::removeKAccel( " << i << " ): this = " << this << endl; | 485 | //kdDebug(129) << "KAction::removeKAccel( " << i << " ): this = " << this << endl; |
484 | for( uint i = 0; i < d->m_kaccelList.count(); i++ ) { | 486 | for( uint i = 0; i < d->m_kaccelList.count(); i++ ) { |
485 | if( d->m_kaccelList[i] == kaccel ) { | 487 | if( d->m_kaccelList[i] == kaccel ) { |
486 | kaccel->remove( name() ); | 488 | kaccel->remove( name() ); |
487 | d->m_kaccelList.remove( d->m_kaccelList.at( i ) ); | 489 | d->m_kaccelList.remove( d->m_kaccelList.at( i ) ); |
488 | disconnect( kaccel, SIGNAL(destroyed()), this, SLOT(slotDestroyed()) ); | 490 | disconnect( kaccel, SIGNAL(destroyed()), this, SLOT(slotDestroyed()) ); |
489 | break; | 491 | break; |
490 | } | 492 | } |
491 | } | 493 | } |
492 | */ | 494 | */ |
493 | } | 495 | } |
494 | 496 | ||
495 | // KDE 4: remove | 497 | // KDE 4: remove |
496 | void KAction::setAccel( int keyQt ) | 498 | void KAction::setAccel( int keyQt ) |
497 | { | 499 | { |
498 | setShortcut( KShortcut(keyQt) ); | 500 | setShortcut( KShortcut(keyQt) ); |
499 | } | 501 | } |
500 | // KDE 4: remove end | 502 | // KDE 4: remove end |
501 | 503 | ||
502 | void KAction::updateShortcut( int i ) | 504 | void KAction::updateShortcut( int i ) |
503 | { | 505 | { |
504 | int id = itemId( i ); | 506 | int id = itemId( i ); |
505 | 507 | ||
506 | QWidget* w = container( i ); | 508 | QWidget* w = container( i ); |
507 | if ( w->inherits( "QPopupMenu" ) ) { | 509 | if ( w->inherits( "QPopupMenu" ) ) { |
508 | QPopupMenu* menu = static_cast<QPopupMenu*>(w); | 510 | QPopupMenu* menu = static_cast<QPopupMenu*>(w); |
509 | updateShortcut( menu, id ); | 511 | updateShortcut( menu, id ); |
510 | } | 512 | } |
511 | else if ( w->inherits( "QMenuBar" ) ) | 513 | else if ( w->inherits( "QMenuBar" ) ) |
512 | //US static_cast<QMenuBar*>(w)->setAccel( d->m_cut.keyCodeQt(), id ); | 514 | //US static_cast<QMenuBar*>(w)->setAccel( d->m_cut.keyCodeQt(), id ); |
513 | //US (QMenuBar*)(w)->setAccel( d->m_cut.keyCodeQt(), id ); | 515 | //US (QMenuBar*)(w)->setAccel( d->m_cut.keyCodeQt(), id ); |
514 | qDebug("KAction::updateShortcut( int i ) ...1 has top be fixed"); | 516 | |
517 | ; //qDebug("KAction::updateShortcut( int i ) ...1 has top be fixed"); | ||
515 | 518 | ||
516 | } | 519 | } |
517 | 520 | ||
518 | void KAction::updateShortcut( QPopupMenu* menu, int id ) | 521 | void KAction::updateShortcut( QPopupMenu* menu, int id ) |
519 | { | 522 | { |
520 | /*US | 523 | /*US |
521 | //kdDebug(129) << "KAction::updateShortcut(): this = " << this << " d->m_kaccelList.count() = " << d->m_kaccelList.count() << endl; | 524 | //kdDebug(129) << "KAction::updateShortcut(): this = " << this << " d->m_kaccelList.count() = " << d->m_kaccelList.count() << endl; |
522 | // If the action has a KAccel object, | 525 | // If the action has a KAccel object, |
523 | // show the string representation of its shortcut. | 526 | // show the string representation of its shortcut. |
524 | if ( d->m_kaccel || d->m_kaccelList.count() ) { | 527 | if ( d->m_kaccel || d->m_kaccelList.count() ) { |
525 | QString s = menu->text( id ); | 528 | QString s = menu->text( id ); |
526 | int i = s.find( '\t' ); | 529 | int i = s.find( '\t' ); |
527 | if ( i >= 0 ) | 530 | if ( i >= 0 ) |
528 | s.replace( i+1, s.length()-i, d->m_cut.seq(0).toString() ); | 531 | s.replace( i+1, s.length()-i, d->m_cut.seq(0).toString() ); |
529 | else | 532 | else |
530 | s += "\t" + d->m_cut.seq(0).toString(); | 533 | s += "\t" + d->m_cut.seq(0).toString(); |
531 | 534 | ||
532 | menu->changeItem( id, s ); | 535 | menu->changeItem( id, s ); |
533 | } | 536 | } |
534 | // Otherwise insert the shortcut itself into the popup menu. | 537 | // Otherwise insert the shortcut itself into the popup menu. |
535 | else { | 538 | else { |
536 | // This is a fall-hack in case the KAction is missing a proper parent collection. | 539 | // This is a fall-hack in case the KAction is missing a proper parent collection. |
537 | // It should be removed eventually. --ellis | 540 | // It should be removed eventually. --ellis |
538 | menu->setAccel( d->m_cut.keyCodeQt(), id ); | 541 | menu->setAccel( d->m_cut.keyCodeQt(), id ); |
539 | kdWarning(129) << "KAction::updateShortcut(): name = \"" << name() << "\", cut = " << d->m_cut.toStringInternal() << "; No KAccel, probably missing a parent collection." << endl; | 542 | kdWarning(129) << "KAction::updateShortcut(): name = \"" << name() << "\", cut = " << d->m_cut.toStringInternal() << "; No KAccel, probably missing a parent collection." << endl; |
540 | } | 543 | } |
541 | */ | 544 | */ |
542 | qDebug("KAction::updateShortcut( QPopupMenu* menu, int id ) ...1 has top be fixed"); | 545 | |
546 | |||
547 | //qDebug("KAction::updateShortcut( QPopupMenu* menu, int id ) ...1 has top be fixed"); | ||
543 | 548 | ||
544 | } | 549 | } |
545 | 550 | ||
546 | const KShortcut& KAction::shortcut() const | 551 | const KShortcut& KAction::shortcut() const |
547 | { | 552 | { |
548 | return d->m_cut; | 553 | return d->m_cut; |
549 | } | 554 | } |
550 | 555 | ||
551 | const KShortcut& KAction::shortcutDefault() const | 556 | const KShortcut& KAction::shortcutDefault() const |
552 | { | 557 | { |
553 | return d->m_cutDefault; | 558 | return d->m_cutDefault; |
554 | } | 559 | } |
555 | 560 | ||
556 | QString KAction::shortcutText() const | 561 | QString KAction::shortcutText() const |
557 | { | 562 | { |
558 | return d->m_cut.toStringInternal(); | 563 | return d->m_cut.toStringInternal(); |
559 | } | 564 | } |
560 | 565 | ||
561 | void KAction::setShortcutText( const QString& s ) | 566 | void KAction::setShortcutText( const QString& s ) |
562 | { | 567 | { |
563 | setShortcut( KShortcut(s) ); | 568 | setShortcut( KShortcut(s) ); |
564 | } | 569 | } |
565 | 570 | ||
566 | int KAction::accel() const | 571 | int KAction::accel() const |
567 | { | 572 | { |
568 | qDebug("KAction::accel() ...1 has top be fixed"); | 573 | // qDebug("KAction::accel() ...1 has top be fixed"); |
569 | //US return d->m_cut.keyCodeQt(); | 574 | //US return d->m_cut.keyCodeQt(); |
570 | return 0; | 575 | return 0; |
571 | } | 576 | } |
572 | 577 | ||
573 | void KAction::setGroup( const QString& grp ) | 578 | void KAction::setGroup( const QString& grp ) |
574 | { | 579 | { |
575 | d->m_group = grp; | 580 | d->m_group = grp; |
576 | 581 | ||
577 | int len = containerCount(); | 582 | int len = containerCount(); |
578 | for( int i = 0; i < len; ++i ) | 583 | for( int i = 0; i < len; ++i ) |
579 | updateGroup( i ); | 584 | updateGroup( i ); |
580 | } | 585 | } |
581 | 586 | ||
582 | void KAction::updateGroup( int ) | 587 | void KAction::updateGroup( int ) |
583 | { | 588 | { |
584 | // DO SOMETHING | 589 | // DO SOMETHING |
585 | } | 590 | } |
586 | 591 | ||
587 | QString KAction::group() const | 592 | QString KAction::group() const |
588 | { | 593 | { |
589 | return d->m_group; | 594 | return d->m_group; |
590 | } | 595 | } |
591 | 596 | ||
592 | bool KAction::isEnabled() const | 597 | bool KAction::isEnabled() const |
593 | { | 598 | { |
594 | return d->isEnabled(); | 599 | return d->isEnabled(); |
595 | } | 600 | } |
596 | 601 | ||
597 | bool KAction::isShortcutConfigurable() const | 602 | bool KAction::isShortcutConfigurable() const |
598 | { | 603 | { |
599 | return d->m_configurable; | 604 | return d->m_configurable; |
600 | } | 605 | } |
601 | 606 | ||
602 | void KAction::setToolTip( const QString& tt ) | 607 | void KAction::setToolTip( const QString& tt ) |
603 | { | 608 | { |
604 | qDebug("KAction::setToolTip ...1 has top be fixed"); | 609 | //qDebug("KAction::setToolTip ...1 has top be fixed"); |
605 | d->setToolTip( tt ); | 610 | d->setToolTip( tt ); |
606 | 611 | ||
607 | int len = containerCount(); | 612 | int len = containerCount(); |
608 | for( int i = 0; i < len; ++i ) | 613 | for( int i = 0; i < len; ++i ) |
609 | updateToolTip( i ); | 614 | updateToolTip( i ); |
610 | } | 615 | } |
611 | 616 | ||
612 | void KAction::updateToolTip( int i ) | 617 | void KAction::updateToolTip( int i ) |
613 | { | 618 | { |
614 | qDebug("KAction::updateToolTip ...1 has top be fixed"); | 619 | //qDebug("KAction::updateToolTip ...1 has top be fixed"); |
615 | QWidget *w = container( i ); | 620 | QWidget *w = container( i ); |
616 | 621 | ||
617 | if ( w->inherits( "KToolBar" ) ) | 622 | if ( w->inherits( "KToolBar" ) ) |
618 | QToolTip::add( static_cast<KToolBar*>(w)->getWidget( itemId( i ) ), d->toolTip() ); | 623 | QToolTip::add( static_cast<KToolBar*>(w)->getWidget( itemId( i ) ), d->toolTip() ); |
619 | else if ( w->inherits( "QToolBar" ) ) | 624 | else if ( w->inherits( "QToolBar" ) ) |
620 | QToolTip::add( static_cast<KToolBar*>(w)->getWidget( itemId( i ) ), d->toolTip() ); | 625 | QToolTip::add( static_cast<KToolBar*>(w)->getWidget( itemId( i ) ), d->toolTip() ); |
621 | } | 626 | } |
622 | 627 | ||
623 | QString KAction::toolTip() const | 628 | QString KAction::toolTip() const |
624 | { | 629 | { |
625 | return d->toolTip(); | 630 | return d->toolTip(); |
626 | } | 631 | } |
627 | 632 | ||
628 | int KAction::plug( QWidget *w, int index ) | 633 | int KAction::plug( QWidget *w, int index ) |
629 | { | 634 | { |
630 | //kdDebug(129) << "KAction::plug( " << w << ", " << index << " )" << endl; | 635 | //kdDebug(129) << "KAction::plug( " << w << ", " << index << " )" << endl; |
631 | if (w == 0) { | 636 | if (w == 0) { |
632 | kdWarning(129) << "KAction::plug called with 0 argument\n"; | 637 | kdWarning(129) << "KAction::plug called with 0 argument\n"; |
633 | return -1; | 638 | return -1; |
634 | } | 639 | } |
635 | 640 | ||
636 | #ifndef NDEBUG | 641 | |
637 | KAccel* kaccel = kaccelCurrent(); | ||
638 | // If there is a shortcut, but no KAccel available | ||
639 | if( !d->m_cut.isNull() && kaccel == 0 ) { | ||
640 | kdWarning(129) << "KAction::plug(): has no KAccel object; this = " << this << " name = " << name() << " parentCollection = " << m_parentCollection << endl; // ellis | ||
641 | //US kdDebug(129) << kdBacktrace() << endl; | ||
642 | } | ||
643 | #endif | ||
644 | 642 | ||
645 | // Check if action is permitted | 643 | // Check if action is permitted |
646 | //US if (kapp && !kapp->authorizeKAction(name())) | 644 | //US if (kapp && !kapp->authorizeKAction(name())) |
647 | //US return -1; | 645 | //US return -1; |
648 | 646 | ||
649 | plugShortcut(); | 647 | plugShortcut(); |
650 | 648 | ||
651 | if ( w->inherits("QPopupMenu") ) | 649 | if ( w->inherits("QPopupMenu") ) |
652 | { | 650 | { |
653 | QPopupMenu* menu = static_cast<QPopupMenu*>( w ); | 651 | QPopupMenu* menu = static_cast<QPopupMenu*>( w ); |
654 | int id; | 652 | int id; |
655 | // Don't insert shortcut into menu if it's already in a KAccel object. | 653 | // Don't insert shortcut into menu if it's already in a KAccel object. |
656 | //qDebug("KAction::plug warning: real shortcuts not available yet. "); | 654 | //qDebug("KAction::plug warning: real shortcuts not available yet. "); |
657 | //US int keyQt = (d->m_kaccelList.count() || d->m_kaccel) ? 0 : d->m_cut.keyCodeQt(); | 655 | //US int keyQt = (d->m_kaccelList.count() || d->m_kaccel) ? 0 : d->m_cut.keyCodeQt(); |
658 | int keyQt = 0; | 656 | int keyQt = 0; |
659 | 657 | ||
660 | if ( d->hasIcon() ) | 658 | if ( d->hasIcon() ) |
661 | { | 659 | { |
662 | /*US | 660 | /*US |
663 | KInstance *instance; | 661 | KInstance *instance; |
664 | if ( m_parentCollection ) | 662 | if ( m_parentCollection ) |
665 | instance = m_parentCollection->instance(); | 663 | instance = m_parentCollection->instance(); |
666 | else | 664 | else |
667 | instance = KGlobal::instance(); | 665 | instance = KGlobal::instance(); |
668 | */ | 666 | */ |
669 | id = menu->insertItem( d->iconSet( KIcon::Small, 0/*US , instance */), d->text(), this,//dsweet | 667 | id = menu->insertItem( d->iconSet( KIcon::Small, 0/*US , instance */), d->text(), this,//dsweet |
670 | SLOT( slotActivated() ), keyQt, | 668 | SLOT( slotActivated() ), keyQt, |
671 | -1, index ); | 669 | -1, index ); |
672 | } | 670 | } |
673 | else | 671 | else |
674 | id = menu->insertItem( d->text(), this, | 672 | id = menu->insertItem( d->text(), this, |
675 | SLOT( slotActivated() ), //dsweet | 673 | SLOT( slotActivated() ), //dsweet |
676 | keyQt, -1, index ); | 674 | keyQt, -1, index ); |
677 | 675 | ||
678 | // If the shortcut is already in a KAccel object, then | 676 | // If the shortcut is already in a KAccel object, then |
679 | // we need to set the menu item's shortcut text. | 677 | // we need to set the menu item's shortcut text. |
680 | /*US if ( d->m_kaccelList.count() || d->m_kaccel ) | 678 | /*US if ( d->m_kaccelList.count() || d->m_kaccel ) |
681 | updateShortcut( menu, id ); | 679 | updateShortcut( menu, id ); |
682 | */ | 680 | */ |
683 | // call setItemEnabled only if the item really should be disabled, | 681 | // call setItemEnabled only if the item really should be disabled, |
684 | // because that method is slow and the item is per default enabled | 682 | // because that method is slow and the item is per default enabled |
685 | if ( !d->isEnabled() ) | 683 | if ( !d->isEnabled() ) |
686 | menu->setItemEnabled( id, false ); | 684 | menu->setItemEnabled( id, false ); |
687 | 685 | ||
688 | if ( !d->whatsThis().isEmpty() ) | 686 | if ( !d->whatsThis().isEmpty() ) |
689 | menu->setWhatsThis( id, whatsThisWithIcon() ); | 687 | menu->setWhatsThis( id, whatsThisWithIcon() ); |
690 | 688 | ||
691 | addContainer( menu, id ); | 689 | addContainer( menu, id ); |
692 | connect( menu, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); | 690 | connect( menu, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); |
693 | 691 | ||
694 | if ( m_parentCollection ) | 692 | if ( m_parentCollection ) |
695 | m_parentCollection->connectHighlight( menu, this ); | 693 | m_parentCollection->connectHighlight( menu, this ); |
696 | 694 | ||
697 | return d->m_containers.count() - 1; | 695 | return d->m_containers.count() - 1; |
698 | } | 696 | } |
699 | else if ( w->inherits( "KToolBar" ) ) | 697 | else if ( w->inherits( "KToolBar" ) ) |
700 | { | 698 | { |
701 | KToolBar *bar = static_cast<KToolBar *>( w ); | 699 | KToolBar *bar = static_cast<KToolBar *>( w ); |
702 | 700 | ||
703 | int id_ = getToolButtonID(); | 701 | int id_ = getToolButtonID(); |
704 | /*US | 702 | /*US |
705 | KInstance *instance; | 703 | KInstance *instance; |
706 | if ( m_parentCollection ) | 704 | if ( m_parentCollection ) |
707 | instance = m_parentCollection->instance(); | 705 | instance = m_parentCollection->instance(); |
708 | else | 706 | else |
709 | instance = KGlobal::instance(); | 707 | instance = KGlobal::instance(); |
710 | */ | 708 | */ |
711 | if ( icon().isEmpty() && !iconSet().pixmap().isNull() ) // old code using QIconSet directly | 709 | if ( icon().isEmpty() && !iconSet().pixmap().isNull() ) // old code using QIconSet directly |
712 | { | 710 | { |
713 | bar->insertButton( iconSet().pixmap(), id_, SIGNAL( clicked() ), this, | 711 | bar->insertButton( iconSet().pixmap(), id_, SIGNAL( clicked() ), this, |
714 | SLOT( slotActivated() ), | 712 | SLOT( slotActivated() ), |
715 | d->isEnabled(), d->plainText(), index ); | 713 | d->isEnabled(), d->plainText(), index ); |
716 | } | 714 | } |
717 | else | 715 | else |
718 | { | 716 | { |
719 | QString icon = d->iconName(); | 717 | QString icon = d->iconName(); |
720 | if ( icon.isEmpty() ) | 718 | if ( icon.isEmpty() ) |
721 | icon = "unknown"; | 719 | icon = "unknown"; |
722 | bar->insertButton( icon, id_, SIGNAL( clicked() ), this, | 720 | bar->insertButton( icon, id_, SIGNAL( clicked() ), this, |
723 | SLOT( slotActivated() ), | 721 | SLOT( slotActivated() ), |
724 | d->isEnabled(), d->plainText(), index/*US, instance*/ ); | 722 | d->isEnabled(), d->plainText(), index/*US, instance*/ ); |
725 | } | 723 | } |
726 | bar->getButton( id_ )->setName( QCString("toolbutton_")+name() ); | 724 | bar->getButton( id_ )->setName( QCString("toolbutton_")+name() ); |
727 | 725 | ||
728 | //US if ( !d->whatsThis().isEmpty() ) | 726 | //US if ( !d->whatsThis().isEmpty() ) |
729 | //US QWhatsThis::add( bar->getButton(id_), whatsThisWithIcon() ); | 727 | //US QWhatsThis::add( bar->getButton(id_), whatsThisWithIcon() ); |
730 | if ( !d->toolTip().isEmpty() ) | 728 | if ( !d->toolTip().isEmpty() ) |
731 | QToolTip::add( bar->getButton(id_), d->toolTip() ); | 729 | QToolTip::add( bar->getButton(id_), d->toolTip() ); |
732 | 730 | ||
733 | addContainer( bar, id_ ); | 731 | addContainer( bar, id_ ); |
734 | 732 | ||
735 | connect( bar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); | 733 | connect( bar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); |
736 | 734 | ||
737 | if ( m_parentCollection ) | 735 | if ( m_parentCollection ) |
738 | m_parentCollection->connectHighlight( bar, this ); | 736 | m_parentCollection->connectHighlight( bar, this ); |
739 | 737 | ||
740 | return containerCount() - 1; | 738 | return containerCount() - 1; |
741 | 739 | ||
742 | } | 740 | } |
743 | 741 | ||
744 | return -1; | 742 | return -1; |
745 | } | 743 | } |
746 | 744 | ||
747 | void KAction::unplug( QWidget *w ) | 745 | void KAction::unplug( QWidget *w ) |
748 | { | 746 | { |
749 | int i = findContainer( w ); | 747 | int i = findContainer( w ); |
750 | if ( i == -1 ) | 748 | if ( i == -1 ) |
751 | return; | 749 | return; |
752 | int id = itemId( i ); | 750 | int id = itemId( i ); |
753 | 751 | ||
754 | if ( w->inherits( "QPopupMenu" ) ) | 752 | if ( w->inherits( "QPopupMenu" ) ) |
755 | { | 753 | { |
756 | QPopupMenu *menu = static_cast<QPopupMenu *>( w ); | 754 | QPopupMenu *menu = static_cast<QPopupMenu *>( w ); |
757 | menu->removeItem( id ); | 755 | menu->removeItem( id ); |
758 | } | 756 | } |
759 | else if ( w->inherits( "KToolBar" ) ) | 757 | else if ( w->inherits( "KToolBar" ) ) |
760 | { | 758 | { |
761 | KToolBar *bar = static_cast<KToolBar *>( w ); | 759 | KToolBar *bar = static_cast<KToolBar *>( w ); |
762 | bar->removeItemDelayed( id ); | 760 | bar->removeItemDelayed( id ); |
763 | } | 761 | } |
764 | else if ( w->inherits( "QMenuBar" ) ) | 762 | else if ( w->inherits( "QMenuBar" ) ) |
765 | { | 763 | { |
766 | QMenuBar *bar = static_cast<QMenuBar *>( w ); | 764 | QMenuBar *bar = static_cast<QMenuBar *>( w ); |
767 | bar->removeItem( id ); | 765 | bar->removeItem( id ); |
768 | } | 766 | } |
769 | 767 | ||
770 | removeContainer( i ); | 768 | removeContainer( i ); |
771 | 769 | ||
772 | if ( m_parentCollection ) | 770 | if ( m_parentCollection ) |
773 | m_parentCollection->disconnectHighlight( w, this ); | 771 | m_parentCollection->disconnectHighlight( w, this ); |
774 | } | 772 | } |
775 | 773 | ||
776 | void KAction::plugAccel(KAccel *kacc, bool configurable) | 774 | void KAction::plugAccel(KAccel *kacc, bool configurable) |
777 | { | 775 | { |
778 | qDebug("KAction::plugAccel ...1 has top be fixed"); | 776 | // qDebug("KAction::plugAccel ...1 has top be fixed"); |
777 | |||
779 | /*US | 778 | /*US |
780 | kdWarning(129) << "KAction::plugAccel(): call to deprecated action." << endl; | 779 | kdWarning(129) << "KAction::plugAccel(): call to deprecated action." << endl; |
781 | kdDebug(129) << kdBacktrace() << endl; | 780 | kdDebug(129) << kdBacktrace() << endl; |
782 | //kdDebug(129) << "KAction::plugAccel( kacc = " << kacc << " ): name \"" << name() << "\"" << endl; | 781 | //kdDebug(129) << "KAction::plugAccel( kacc = " << kacc << " ): name \"" << name() << "\"" << endl; |
783 | if ( d->m_kaccel ) | 782 | if ( d->m_kaccel ) |
784 | unplugAccel(); | 783 | unplugAccel(); |
785 | 784 | ||
786 | // If the parent collection's accel ptr isn't set yet | 785 | // If the parent collection's accel ptr isn't set yet |
787 | //if ( m_parentCollection && !m_parentCollection->accel() ) | 786 | //if ( m_parentCollection && !m_parentCollection->accel() ) |
788 | // m_parentCollection->setAccel( kacc ); | 787 | // m_parentCollection->setAccel( kacc ); |
789 | 788 | ||
790 | // We can only plug this action into the given KAccel object | 789 | // We can only plug this action into the given KAccel object |
791 | // if it does not already contain an action with the same name. | 790 | // if it does not already contain an action with the same name. |
792 | if ( !kacc->actions().actionPtr(name()) ) | 791 | if ( !kacc->actions().actionPtr(name()) ) |
793 | { | 792 | { |
794 | d->m_kaccel = kacc; | 793 | d->m_kaccel = kacc; |
795 | d->m_kaccel->insert(name(), d->plainText(), QString::null, | 794 | d->m_kaccel->insert(name(), d->plainText(), QString::null, |
796 | KShortcut(d->m_cut), | 795 | KShortcut(d->m_cut), |
797 | this, SLOT(slotActivated()), | 796 | this, SLOT(slotActivated()), |
798 | configurable, isEnabled()); | 797 | configurable, isEnabled()); |
799 | connect(d->m_kaccel, SIGNAL(destroyed()), this, SLOT(slotDestroyed())); | 798 | connect(d->m_kaccel, SIGNAL(destroyed()), this, SLOT(slotDestroyed())); |
800 | //connect(d->m_kaccel, SIGNAL(keycodeChanged()), this, SLOT(slotKeycodeChanged())); | 799 | //connect(d->m_kaccel, SIGNAL(keycodeChanged()), this, SLOT(slotKeycodeChanged())); |
801 | } | 800 | } |
802 | else | 801 | else |
803 | kdWarning(129) << "KAction::plugAccel( kacc = " << kacc << " ): KAccel object already contains an action name \"" << name() << "\"" << endl; // -- ellis | 802 | kdWarning(129) << "KAction::plugAccel( kacc = " << kacc << " ): KAccel object already contains an action name \"" << name() << "\"" << endl; // -- ellis |
804 | */ | 803 | */ |
805 | } | 804 | } |
806 | 805 | ||
807 | void KAction::unplugAccel() | 806 | void KAction::unplugAccel() |
808 | { | 807 | { |
809 | qDebug("KAction::unplugAccel ...1 has top be fixed"); | 808 | // qDebug("KAction::unplugAccel ...1 has top be fixed"); |
810 | /*US | 809 | /*US |
811 | //kdDebug(129) << "KAction::unplugAccel() " << this << " " << name() << endl; | 810 | //kdDebug(129) << "KAction::unplugAccel() " << this << " " << name() << endl; |
812 | if ( d->m_kaccel ) | 811 | if ( d->m_kaccel ) |
813 | { | 812 | { |
814 | d->m_kaccel->remove(name()); | 813 | d->m_kaccel->remove(name()); |
815 | d->m_kaccel = 0; | 814 | d->m_kaccel = 0; |
816 | } | 815 | } |
817 | */ | 816 | */ |
818 | } | 817 | } |
819 | 818 | ||
820 | void KAction::plugMainWindowAccel( QWidget *w ) | 819 | void KAction::plugMainWindowAccel( QWidget *w ) |
821 | { | 820 | { |
822 | qDebug("KAction::plugMainWindowAccel ...1 has top be fixed"); | 821 | // qDebug("KAction::plugMainWindowAccel ...1 has top be fixed"); |
822 | |||
823 | /*US | 823 | /*US |
824 | // Note: topLevelWidget() stops too early, we can't use it. | 824 | // Note: topLevelWidget() stops too early, we can't use it. |
825 | QWidget * tl = w; | 825 | QWidget * tl = w; |
826 | QWidget * n; | 826 | QWidget * n; |
827 | while ( !tl->isDialog() && ( n = tl->parentWidget() ) ) // lookup parent and store | 827 | while ( !tl->isDialog() && ( n = tl->parentWidget() ) ) // lookup parent and store |
828 | tl = n; | 828 | tl = n; |
829 | 829 | ||
830 | KMainWindow * mw = dynamic_cast<KMainWindow *>(tl); // try to see if it's a kmainwindow | 830 | KMainWindow * mw = dynamic_cast<KMainWindow *>(tl); // try to see if it's a kmainwindow |
831 | if (mw) | 831 | if (mw) |
832 | plugAccel( mw->accel() ); | 832 | plugAccel( mw->accel() ); |
833 | else | 833 | else |
834 | kdDebug(129) << "KAction::plugMainWindowAccel: Toplevel widget isn't a KMainWindow, can't plug accel. " << tl << endl; | 834 | kdDebug(129) << "KAction::plugMainWindowAccel: Toplevel widget isn't a KMainWindow, can't plug accel. " << tl << endl; |
835 | */ | 835 | */ |
836 | } | 836 | } |
837 | 837 | ||
838 | void KAction::setEnabled(bool enable) | 838 | void KAction::setEnabled(bool enable) |
839 | { | 839 | { |
840 | //kdDebug(129) << "KAction::setEnabled( " << enable << " ): this = " << this << " d->m_kaccelList.count() = " << d->m_kaccelList.count() << endl; | 840 | //kdDebug(129) << "KAction::setEnabled( " << enable << " ): this = " << this << " d->m_kaccelList.count() = " << d->m_kaccelList.count() << endl; |
841 | if ( enable == d->isEnabled() ) | 841 | if ( enable == d->isEnabled() ) |
842 | return; | 842 | return; |
843 | 843 | ||
844 | // KDE 4: remove | 844 | // KDE 4: remove |
845 | //US if (d->m_kaccel) | 845 | //US if (d->m_kaccel) |
846 | //US d->m_kaccel->setEnabled(name(), enable); | 846 | //US d->m_kaccel->setEnabled(name(), enable); |
847 | // KDE 4: remove end | 847 | // KDE 4: remove end |
848 | 848 | ||
849 | //US for ( uint i = 0; i < d->m_kaccelList.count(); i++ ) | 849 | //US for ( uint i = 0; i < d->m_kaccelList.count(); i++ ) |
850 | //US d->m_kaccelList[i]->setEnabled( name(), enable ); | 850 | //US d->m_kaccelList[i]->setEnabled( name(), enable ); |
851 | 851 | ||
852 | d->setEnabled( enable ); | 852 | d->setEnabled( enable ); |
853 | 853 | ||
854 | int len = containerCount(); | 854 | int len = containerCount(); |
855 | for( int i = 0; i < len; ++i ) | 855 | for( int i = 0; i < len; ++i ) |
856 | updateEnabled( i ); | 856 | updateEnabled( i ); |
857 | 857 | ||
858 | emit enabled( d->isEnabled() ); | 858 | emit enabled( d->isEnabled() ); |
859 | } | 859 | } |
860 | 860 | ||
861 | void KAction::updateEnabled( int i ) | 861 | void KAction::updateEnabled( int i ) |
862 | { | 862 | { |
863 | QWidget *w = container( i ); | 863 | QWidget *w = container( i ); |
864 | 864 | ||
865 | if ( w->inherits("QPopupMenu") ) | 865 | if ( w->inherits("QPopupMenu") ) |
866 | static_cast<QPopupMenu*>(w)->setItemEnabled( itemId( i ), d->isEnabled() ); | 866 | static_cast<QPopupMenu*>(w)->setItemEnabled( itemId( i ), d->isEnabled() ); |
867 | else if ( w->inherits("QMenuBar") ) | 867 | else if ( w->inherits("QMenuBar") ) |
868 | static_cast<QMenuBar*>(w)->setItemEnabled( itemId( i ), d->isEnabled() ); | 868 | static_cast<QMenuBar*>(w)->setItemEnabled( itemId( i ), d->isEnabled() ); |
869 | else if ( w->inherits( "KToolBar" ) ) | 869 | else if ( w->inherits( "KToolBar" ) ) |
870 | { | 870 | { |
871 | static_cast<KToolBar*>(w)->setItemEnabled( itemId( i ), d->isEnabled() ); | 871 | static_cast<KToolBar*>(w)->setItemEnabled( itemId( i ), d->isEnabled() ); |
872 | } | 872 | } |
873 | } | 873 | } |
874 | 874 | ||
875 | void KAction::setShortcutConfigurable( bool b ) | 875 | void KAction::setShortcutConfigurable( bool b ) |
876 | { | 876 | { |
877 | d->m_configurable = b; | 877 | d->m_configurable = b; |
878 | } | 878 | } |
879 | 879 | ||
880 | void KAction::setText( const QString& text ) | 880 | void KAction::setText( const QString& text ) |
881 | { | 881 | { |
882 | /*US | 882 | /*US |
883 | // KDE 4: remove | 883 | // KDE 4: remove |
884 | if (d->m_kaccel) { | 884 | if (d->m_kaccel) { |
885 | KAccelAction* pAction = d->m_kaccel->actions().actionPtr(name()); | 885 | KAccelAction* pAction = d->m_kaccel->actions().actionPtr(name()); |
886 | if (pAction) | 886 | if (pAction) |
887 | pAction->setLabel( text ); | 887 | pAction->setLabel( text ); |
888 | } | 888 | } |
889 | // KDE 4: remove end | 889 | // KDE 4: remove end |
890 | 890 | ||
891 | for( uint i = 0; i < d->m_kaccelList.count(); i++ ) { | 891 | for( uint i = 0; i < d->m_kaccelList.count(); i++ ) { |
892 | KAccelAction* pAction = d->m_kaccelList[i]->actions().actionPtr(name()); | 892 | KAccelAction* pAction = d->m_kaccelList[i]->actions().actionPtr(name()); |
893 | if (pAction) | 893 | if (pAction) |
894 | pAction->setLabel( text ); | 894 | pAction->setLabel( text ); |
895 | } | 895 | } |
896 | */ | 896 | */ |
897 | d->setText( text ); | 897 | d->setText( text ); |
898 | 898 | ||
899 | int len = containerCount(); | 899 | int len = containerCount(); |
900 | for( int i = 0; i < len; ++i ) | 900 | for( int i = 0; i < len; ++i ) |
901 | updateText( i ); | 901 | updateText( i ); |
902 | 902 | ||
903 | } | 903 | } |
904 | 904 | ||
905 | void KAction::updateText( int i ) | 905 | void KAction::updateText( int i ) |
906 | { | 906 | { |
907 | QWidget *w = container( i ); | 907 | QWidget *w = container( i ); |
908 | 908 | ||
909 | if ( w->inherits( "QPopupMenu" ) ) { | 909 | if ( w->inherits( "QPopupMenu" ) ) { |
910 | int id = itemId( i ); | 910 | int id = itemId( i ); |
911 | static_cast<QPopupMenu*>(w)->changeItem( id, d->text() ); | 911 | static_cast<QPopupMenu*>(w)->changeItem( id, d->text() ); |
912 | updateShortcut( static_cast<QPopupMenu*>(w), id ); | 912 | updateShortcut( static_cast<QPopupMenu*>(w), id ); |
913 | } | 913 | } |
914 | else if ( w->inherits( "QMenuBar" ) ) | 914 | else if ( w->inherits( "QMenuBar" ) ) |
915 | static_cast<QMenuBar*>(w)->changeItem( itemId( i ), d->text() ); | 915 | static_cast<QMenuBar*>(w)->changeItem( itemId( i ), d->text() ); |
916 | else if ( w->inherits( "KToolBar" ) ) | 916 | else if ( w->inherits( "KToolBar" ) ) |
917 | { | 917 | { |
918 | qDebug("KAction::updateText ...3 has top be fixed"); | 918 | //qDebug("KAction::updateText ...3 has top be fixed"); |
919 | QWidget *button = static_cast<KToolBar *>(w)->getWidget( itemId( i ) ); | 919 | QWidget *button = static_cast<KToolBar *>(w)->getWidget( itemId( i ) ); |
920 | if ( button->inherits( "KToolBarButton" ) ) | 920 | if ( button->inherits( "KToolBarButton" ) ) |
921 | static_cast<KToolBarButton *>(button)->setText( d->plainText() ); | 921 | static_cast<KToolBarButton *>(button)->setText( d->plainText() ); |
922 | 922 | ||
923 | } | 923 | } |
924 | } | 924 | } |
925 | 925 | ||
926 | QString KAction::text() const | 926 | QString KAction::text() const |
927 | { | 927 | { |
928 | return d->text(); | 928 | return d->text(); |
929 | } | 929 | } |
930 | 930 | ||
931 | QString KAction::plainText() const | 931 | QString KAction::plainText() const |
932 | { | 932 | { |
933 | return d->plainText( ); | 933 | return d->plainText( ); |
934 | } | 934 | } |
935 | 935 | ||
936 | void KAction::setIcon( const QString &icon ) | 936 | void KAction::setIcon( const QString &icon ) |
937 | { | 937 | { |
938 | d->setIconName( icon ); | 938 | d->setIconName( icon ); |
939 | 939 | ||
940 | // now handle any toolbars | 940 | // now handle any toolbars |
941 | int len = containerCount(); | 941 | int len = containerCount(); |
942 | for ( int i = 0; i < len; ++i ) | 942 | for ( int i = 0; i < len; ++i ) |
943 | updateIcon( i ); | 943 | updateIcon( i ); |
944 | } | 944 | } |
945 | 945 | ||
946 | void KAction::updateIcon( int id ) | 946 | void KAction::updateIcon( int id ) |
947 | { | 947 | { |
948 | QWidget* w = container( id ); | 948 | QWidget* w = container( id ); |
949 | 949 | ||
950 | if ( w->inherits( "QPopupMenu" ) ) { | 950 | if ( w->inherits( "QPopupMenu" ) ) { |
951 | int itemId_ = itemId( id ); | 951 | int itemId_ = itemId( id ); |
952 | static_cast<QPopupMenu*>(w)->changeItem( itemId_, d->iconSet( KIcon::Small ), d->text() ); | 952 | static_cast<QPopupMenu*>(w)->changeItem( itemId_, d->iconSet( KIcon::Small ), d->text() ); |
953 | updateShortcut( static_cast<QPopupMenu*>(w), itemId_ ); | 953 | updateShortcut( static_cast<QPopupMenu*>(w), itemId_ ); |
954 | } | 954 | } |
955 | else if ( w->inherits( "QMenuBar" ) ) | 955 | else if ( w->inherits( "QMenuBar" ) ) |
956 | static_cast<QMenuBar*>(w)->changeItem( itemId( id ), d->iconSet( KIcon::Small ), d->text() ); | 956 | static_cast<QMenuBar*>(w)->changeItem( itemId( id ), d->iconSet( KIcon::Small ), d->text() ); |
957 | else if ( w->inherits( "KToolBar" ) ) | 957 | else if ( w->inherits( "KToolBar" ) ) |
958 | static_cast<KToolBar *>(w)->setButtonIcon( itemId( id ), d->iconName() ); | 958 | static_cast<KToolBar *>(w)->setButtonIcon( itemId( id ), d->iconName() ); |
959 | else if ( w->inherits( "QToolBar" ) ) | 959 | else if ( w->inherits( "QToolBar" ) ) |
960 | { | 960 | { |
961 | qDebug("KAction::updateIcon has top be fixed"); | 961 | qDebug("KAction::updateIcon has top be fixed"); |
962 | //US static_cast<QToolBar *>(w)->setButtonIcon( itemId( id ), d->iconName() ); | 962 | //US static_cast<QToolBar *>(w)->setButtonIcon( itemId( id ), d->iconName() ); |
963 | } | 963 | } |
964 | } | 964 | } |
965 | 965 | ||
966 | QString KAction::icon() const | 966 | QString KAction::icon() const |
967 | { | 967 | { |
968 | return d->iconName( ); | 968 | return d->iconName( ); |
969 | } | 969 | } |
970 | 970 | ||
971 | void KAction::setIconSet( const QIconSet &iconset ) | 971 | void KAction::setIconSet( const QIconSet &iconset ) |
972 | { | 972 | { |
973 | d->setIconSet( iconset ); | 973 | d->setIconSet( iconset ); |
974 | 974 | ||
975 | int len = containerCount(); | 975 | int len = containerCount(); |
976 | for( int i = 0; i < len; ++i ) | 976 | for( int i = 0; i < len; ++i ) |
977 | updateIconSet( i ); | 977 | updateIconSet( i ); |
978 | } | 978 | } |
979 | 979 | ||
980 | 980 | ||
981 | void KAction::updateIconSet( int id ) | 981 | void KAction::updateIconSet( int id ) |
982 | { | 982 | { |
983 | QWidget *w = container( id ); | 983 | QWidget *w = container( id ); |
984 | 984 | ||
985 | if ( w->inherits( "QPopupMenu" ) ) | 985 | if ( w->inherits( "QPopupMenu" ) ) |
986 | { | 986 | { |
987 | int itemId_ = itemId( id ); | 987 | int itemId_ = itemId( id ); |
988 | static_cast<QPopupMenu*>(w)->changeItem( itemId_, d->iconSet(), d->text() ); | 988 | static_cast<QPopupMenu*>(w)->changeItem( itemId_, d->iconSet(), d->text() ); |
989 | updateShortcut( static_cast<QPopupMenu*>(w), itemId_ ); | 989 | updateShortcut( static_cast<QPopupMenu*>(w), itemId_ ); |
990 | } | 990 | } |
991 | else if ( w->inherits( "QMenuBar" ) ) | 991 | else if ( w->inherits( "QMenuBar" ) ) |
992 | static_cast<QMenuBar*>(w)->changeItem( itemId( id ), d->iconSet(), d->text() ); | 992 | static_cast<QMenuBar*>(w)->changeItem( itemId( id ), d->iconSet(), d->text() ); |
993 | else if ( w->inherits( "KToolBar" ) ) | 993 | else if ( w->inherits( "KToolBar" ) ) |
994 | { | 994 | { |
995 | if ( icon().isEmpty() && d->hasIconSet() ) // only if there is no named icon ( scales better ) | 995 | if ( icon().isEmpty() && d->hasIconSet() ) // only if there is no named icon ( scales better ) |
996 | static_cast<KToolBar *>(w)->setButtonIconSet( itemId( id ), d->iconSet() ); | 996 | static_cast<KToolBar *>(w)->setButtonIconSet( itemId( id ), d->iconSet() ); |
997 | else | 997 | else |
998 | static_cast<KToolBar *>(w)->setButtonIconSet( itemId( id ), d->iconSet( KIcon::Small ) ); | 998 | static_cast<KToolBar *>(w)->setButtonIconSet( itemId( id ), d->iconSet( KIcon::Small ) ); |
999 | } | 999 | } |
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | QIconSet KAction::iconSet( KIcon::Group group, int size ) const | 1002 | QIconSet KAction::iconSet( KIcon::Group group, int size ) const |
1003 | { | 1003 | { |
1004 | return d->iconSet( group, size ); | 1004 | return d->iconSet( group, size ); |
1005 | } | 1005 | } |
1006 | 1006 | ||
1007 | bool KAction::hasIcon() const | 1007 | bool KAction::hasIcon() const |
1008 | { | 1008 | { |
1009 | return d->hasIcon(); | 1009 | return d->hasIcon(); |
1010 | } | 1010 | } |
1011 | 1011 | ||
1012 | 1012 | ||
1013 | void KAction::setWhatsThis( const QString& text ) | 1013 | void KAction::setWhatsThis( const QString& text ) |
1014 | { | 1014 | { |
1015 | d->setWhatsThis( text ); | 1015 | d->setWhatsThis( text ); |
1016 | 1016 | ||
1017 | int len = containerCount(); | 1017 | int len = containerCount(); |
1018 | for( int i = 0; i < len; ++i ) | 1018 | for( int i = 0; i < len; ++i ) |
1019 | updateWhatsThis( i ); | 1019 | updateWhatsThis( i ); |
1020 | } | 1020 | } |
1021 | 1021 | ||
1022 | void KAction::updateWhatsThis( int i ) | 1022 | void KAction::updateWhatsThis( int i ) |
1023 | { | 1023 | { |
1024 | qDebug("KAction::updateWhatsThis ...1 has top be fixed"); | 1024 | qDebug("KAction::updateWhatsThis ...1 has top be fixed"); |
1025 | QPopupMenu* pm = popupMenu( i ); | 1025 | QPopupMenu* pm = popupMenu( i ); |
1026 | if ( pm ) | 1026 | if ( pm ) |
1027 | { | 1027 | { |
1028 | pm->setWhatsThis( itemId( i ), d->whatsThis() ); | 1028 | pm->setWhatsThis( itemId( i ), d->whatsThis() ); |
1029 | return; | 1029 | return; |
1030 | } | 1030 | } |
1031 | 1031 | ||
1032 | KToolBar *tb = toolBar( i ); | 1032 | KToolBar *tb = toolBar( i ); |
1033 | if ( tb ) | 1033 | if ( tb ) |
1034 | { | 1034 | { |
1035 | QWidget *w = tb->getButton( itemId( i ) ); | 1035 | QWidget *w = tb->getButton( itemId( i ) ); |
1036 | //US QWhatsThis::remove( w ); | 1036 | //US QWhatsThis::remove( w ); |
1037 | //US QWhatsThis::add( w, d->whatsThis() ); | 1037 | //US QWhatsThis::add( w, d->whatsThis() ); |
1038 | return; | 1038 | return; |
1039 | } | 1039 | } |
1040 | } | 1040 | } |
1041 | 1041 | ||
1042 | QString KAction::whatsThis() const | 1042 | QString KAction::whatsThis() const |
1043 | { | 1043 | { |
1044 | return d->whatsThis(); | 1044 | return d->whatsThis(); |
1045 | } | 1045 | } |
1046 | 1046 | ||
1047 | QString KAction::whatsThisWithIcon() const | 1047 | QString KAction::whatsThisWithIcon() const |
1048 | { | 1048 | { |
1049 | QString text = whatsThis(); | 1049 | QString text = whatsThis(); |
1050 | if (!d->iconName().isEmpty()) | 1050 | if (!d->iconName().isEmpty()) |
1051 | return QString::fromLatin1("<img source=\"small|%1\"> %2").arg(d->iconName() ).arg(text); | 1051 | return QString::fromLatin1("<img source=\"small|%1\"> %2").arg(d->iconName() ).arg(text); |
1052 | return text; | 1052 | return text; |
1053 | } | 1053 | } |
1054 | 1054 | ||
1055 | QWidget* KAction::container( int index ) const | 1055 | QWidget* KAction::container( int index ) const |
1056 | { | 1056 | { |
1057 | assert( index < containerCount() ); | 1057 | assert( index < containerCount() ); |
1058 | return d->m_containers[ index ].m_container; | 1058 | return d->m_containers[ index ].m_container; |
1059 | } | 1059 | } |
1060 | 1060 | ||
1061 | KToolBar* KAction::toolBar( int index ) const | 1061 | KToolBar* KAction::toolBar( int index ) const |
1062 | { | 1062 | { |
1063 | //US return dynamic_cast<KToolBar *>( d->m_containers[ index ].m_container ); | 1063 | //US return dynamic_cast<KToolBar *>( d->m_containers[ index ].m_container ); |
1064 | return (KToolBar *)( d->m_containers[ index ].m_container ); | 1064 | return (KToolBar *)( d->m_containers[ index ].m_container ); |
1065 | } | 1065 | } |
1066 | 1066 | ||
1067 | QPopupMenu* KAction::popupMenu( int index ) const | 1067 | QPopupMenu* KAction::popupMenu( int index ) const |
1068 | { | 1068 | { |
1069 | //US return dynamic_cast<QPopupMenu *>( d->m_containers[ index ].m_container ); | 1069 | //US return dynamic_cast<QPopupMenu *>( d->m_containers[ index ].m_container ); |
1070 | return (QPopupMenu *)( d->m_containers[ index ].m_container ); | 1070 | return (QPopupMenu *)( d->m_containers[ index ].m_container ); |
1071 | } | 1071 | } |
1072 | 1072 | ||
1073 | QWidget* KAction::representative( int index ) const | 1073 | QWidget* KAction::representative( int index ) const |
1074 | { | 1074 | { |
1075 | return d->m_containers[ index ].m_representative; | 1075 | return d->m_containers[ index ].m_representative; |
1076 | } | 1076 | } |
1077 | 1077 | ||
1078 | int KAction::itemId( int index ) const | 1078 | int KAction::itemId( int index ) const |
1079 | { | 1079 | { |
1080 | return d->m_containers[ index ].m_id; | 1080 | return d->m_containers[ index ].m_id; |
1081 | } | 1081 | } |
1082 | 1082 | ||
1083 | int KAction::containerCount() const | 1083 | int KAction::containerCount() const |
1084 | { | 1084 | { |
1085 | return d->m_containers.count(); | 1085 | return d->m_containers.count(); |
1086 | } | 1086 | } |
1087 | 1087 | ||
1088 | uint KAction::kaccelCount() const | 1088 | uint KAction::kaccelCount() const |
1089 | { | 1089 | { |
1090 | return d->m_kaccelList.count(); | 1090 | return d->m_kaccelList.count(); |
1091 | } | 1091 | } |
1092 | 1092 | ||
1093 | void KAction::addContainer( QWidget* c, int id ) | 1093 | void KAction::addContainer( QWidget* c, int id ) |
1094 | { | 1094 | { |
1095 | KActionPrivate::Container p; | 1095 | KActionPrivate::Container p; |
1096 | p.m_container = c; | 1096 | p.m_container = c; |
1097 | p.m_id = id; | 1097 | p.m_id = id; |
1098 | d->m_containers.append( p ); | 1098 | d->m_containers.append( p ); |
1099 | } | 1099 | } |
1100 | 1100 | ||
1101 | void KAction::addContainer( QWidget* c, QWidget* w ) | 1101 | void KAction::addContainer( QWidget* c, QWidget* w ) |
1102 | { | 1102 | { |
1103 | KActionPrivate::Container p; | 1103 | KActionPrivate::Container p; |
1104 | p.m_container = c; | 1104 | p.m_container = c; |
1105 | p.m_representative = w; | 1105 | p.m_representative = w; |
1106 | d->m_containers.append( p ); | 1106 | d->m_containers.append( p ); |
1107 | } | 1107 | } |
1108 | 1108 | ||
1109 | void KAction::activate() | 1109 | void KAction::activate() |
1110 | { | 1110 | { |
1111 | slotActivated(); | 1111 | slotActivated(); |
1112 | } | 1112 | } |
1113 | 1113 | ||
1114 | void KAction::slotActivated() | 1114 | void KAction::slotActivated() |
1115 | { | 1115 | { |
1116 | emit activated(); | 1116 | emit activated(); |
1117 | } | 1117 | } |
1118 | 1118 | ||
1119 | void KAction::slotDestroyed() | 1119 | void KAction::slotDestroyed() |
1120 | { | 1120 | { |
1121 | kdDebug(129) << "KAction::slotDestroyed(): this = " << this << ", name = \"" << name() << "\", sender = " << sender() << endl; | 1121 | |
1122 | const QObject* o = sender(); | 1122 | const QObject* o = sender(); |
1123 | 1123 | ||
1124 | /* | 1124 | /* |
1125 | 1125 | ||
1126 | 1126 | ||
1127 | // KDE 4: remove | 1127 | // KDE 4: remove |
1128 | if ( o == d->m_kaccel ) | 1128 | if ( o == d->m_kaccel ) |
1129 | { | 1129 | { |
1130 | d->m_kaccel = 0; | 1130 | d->m_kaccel = 0; |
1131 | return; | 1131 | return; |
1132 | } | 1132 | } |
1133 | // KDE 4: remove end | 1133 | // KDE 4: remove end |
1134 | 1134 | ||
1135 | for( uint i = 0; i < d->m_kaccelList.count(); i++ ) | 1135 | for( uint i = 0; i < d->m_kaccelList.count(); i++ ) |
1136 | { | 1136 | { |
1137 | if ( o == d->m_kaccelList[i] ) | 1137 | if ( o == d->m_kaccelList[i] ) |
1138 | { | 1138 | { |
1139 | disconnect( d->m_kaccelList[i], SIGNAL(destroyed()), this, SLOT(slotDestroyed()) ); | 1139 | disconnect( d->m_kaccelList[i], SIGNAL(destroyed()), this, SLOT(slotDestroyed()) ); |
1140 | d->m_kaccelList.remove( d->m_kaccelList.at( i ) ); | 1140 | d->m_kaccelList.remove( d->m_kaccelList.at( i ) ); |
1141 | return; | 1141 | return; |
1142 | } | 1142 | } |
1143 | } | 1143 | } |
1144 | */ | 1144 | */ |
1145 | int i; | 1145 | int i; |
1146 | do | 1146 | do |
1147 | { | 1147 | { |
1148 | i = findContainer( static_cast<const QWidget*>( o ) ); | 1148 | i = findContainer( static_cast<const QWidget*>( o ) ); |
1149 | if ( i != -1 ) | 1149 | if ( i != -1 ) |
1150 | removeContainer( i ); | 1150 | removeContainer( i ); |
1151 | } while ( i != -1 ); | 1151 | } while ( i != -1 ); |
1152 | 1152 | ||
1153 | } | 1153 | } |
1154 | 1154 | ||
1155 | int KAction::findContainer( const QWidget* widget ) const | 1155 | int KAction::findContainer( const QWidget* widget ) const |
1156 | { | 1156 | { |
1157 | int pos = 0; | 1157 | int pos = 0; |
1158 | QValueList<KActionPrivate::Container>::ConstIterator it = d->m_containers.begin(); | 1158 | QValueList<KActionPrivate::Container>::ConstIterator it = d->m_containers.begin(); |
1159 | while( it != d->m_containers.end() ) | 1159 | while( it != d->m_containers.end() ) |
1160 | { | 1160 | { |
1161 | if ( (*it).m_representative == widget || (*it).m_container == widget ) | 1161 | if ( (*it).m_representative == widget || (*it).m_container == widget ) |
1162 | return pos; | 1162 | return pos; |
1163 | ++it; | 1163 | ++it; |
1164 | ++pos; | 1164 | ++pos; |
1165 | } | 1165 | } |
1166 | 1166 | ||
1167 | return -1; | 1167 | return -1; |
1168 | } | 1168 | } |
1169 | 1169 | ||
1170 | void KAction::removeContainer( int index ) | 1170 | void KAction::removeContainer( int index ) |
1171 | { | 1171 | { |
1172 | int i = 0; | 1172 | int i = 0; |
1173 | QValueList<KActionPrivate::Container>::Iterator it = d->m_containers.begin(); | 1173 | QValueList<KActionPrivate::Container>::Iterator it = d->m_containers.begin(); |
1174 | while( it != d->m_containers.end() ) | 1174 | while( it != d->m_containers.end() ) |
1175 | { | 1175 | { |
1176 | if ( i == index ) | 1176 | if ( i == index ) |
1177 | { | 1177 | { |
1178 | d->m_containers.remove( it ); | 1178 | d->m_containers.remove( it ); |
1179 | return; | 1179 | return; |
1180 | } | 1180 | } |
1181 | ++it; | 1181 | ++it; |
1182 | ++i; | 1182 | ++i; |
1183 | } | 1183 | } |
1184 | } | 1184 | } |
1185 | 1185 | ||
1186 | // FIXME: Remove this (ellis) | 1186 | // FIXME: Remove this (ellis) |
1187 | void KAction::slotKeycodeChanged() | 1187 | void KAction::slotKeycodeChanged() |
1188 | { | 1188 | { |
1189 | qDebug("KAction::slotKeycodeChanged() ...44 has top be fixed"); | 1189 | qDebug("KAction::slotKeycodeChanged() ...44 has top be fixed"); |
1190 | /*US | 1190 | /*US |
1191 | kdDebug(129) << "KAction::slotKeycodeChanged()" << endl; // -- ellis | 1191 | kdDebug(129) << "KAction::slotKeycodeChanged()" << endl; // -- ellis |
1192 | KAccelAction* pAction = d->m_kaccel->actions().actionPtr(name()); | 1192 | KAccelAction* pAction = d->m_kaccel->actions().actionPtr(name()); |
1193 | if( pAction ) | 1193 | if( pAction ) |
1194 | setShortcut(pAction->shortcut()); | 1194 | setShortcut(pAction->shortcut()); |
1195 | */ | 1195 | */ |
1196 | } | 1196 | } |
1197 | 1197 | ||
1198 | KActionCollection *KAction::parentCollection() const | 1198 | KActionCollection *KAction::parentCollection() const |
1199 | { | 1199 | { |
1200 | return m_parentCollection; | 1200 | return m_parentCollection; |
1201 | } | 1201 | } |
1202 | 1202 | ||
1203 | void KAction::unplugAll() | 1203 | void KAction::unplugAll() |
1204 | { | 1204 | { |
1205 | while ( containerCount() != 0 ) | 1205 | while ( containerCount() != 0 ) |
1206 | unplug( container( 0 ) ); | 1206 | unplug( container( 0 ) ); |
1207 | } | 1207 | } |
1208 | 1208 | ||
1209 | void KAction::virtual_hook( int, void* ) | 1209 | void KAction::virtual_hook( int, void* ) |
1210 | { /*BASE::virtual_hook( id, data );*/ } | 1210 | { /*BASE::virtual_hook( id, data );*/ } |
1211 | 1211 | ||
1212 | /* vim: et sw=2 ts=2 | 1212 | /* vim: et sw=2 ts=2 |
1213 | */ | 1213 | */ |
1214 | 1214 | ||
1215 | //US #include "kaction.moc" | 1215 | //US #include "kaction.moc" |