-rw-r--r-- | kabc/addressee.cpp | 9 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 16 |
2 files changed, 12 insertions, 13 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index d6b70c4..c34f671 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1,1785 +1,1784 @@ | |||
1 | /*** Warning! This file has been generated by the script makeaddressee ***/ | 1 | /*** Warning! This file has been generated by the script makeaddressee ***/ |
2 | /* | 2 | /* |
3 | This file is part of libkabc. | 3 | This file is part of libkabc. |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <kconfig.h> | 29 | #include <kconfig.h> |
30 | 30 | ||
31 | #include <ksharedptr.h> | 31 | #include <ksharedptr.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <kapplication.h> | 33 | #include <kapplication.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kidmanager.h> | 35 | #include <kidmanager.h> |
36 | //US | 36 | //US |
37 | #include <kstandarddirs.h> | 37 | #include <kstandarddirs.h> |
38 | #include <libkcal/syncdefines.h> | 38 | #include <libkcal/syncdefines.h> |
39 | 39 | ||
40 | //US #include "resource.h" | 40 | //US #include "resource.h" |
41 | #include "addressee.h" | 41 | #include "addressee.h" |
42 | 42 | ||
43 | using namespace KABC; | 43 | using namespace KABC; |
44 | 44 | ||
45 | static bool matchBinaryPattern( int value, int pattern ); | 45 | static bool matchBinaryPattern( int value, int pattern ); |
46 | 46 | ||
47 | struct Addressee::AddresseeData : public KShared | 47 | struct Addressee::AddresseeData : public KShared |
48 | { | 48 | { |
49 | QString uid; | 49 | QString uid; |
50 | QString name; | 50 | QString name; |
51 | QString formattedName; | 51 | QString formattedName; |
52 | QString familyName; | 52 | QString familyName; |
53 | QString givenName; | 53 | QString givenName; |
54 | QString additionalName; | 54 | QString additionalName; |
55 | QString prefix; | 55 | QString prefix; |
56 | QString suffix; | 56 | QString suffix; |
57 | QString nickName; | 57 | QString nickName; |
58 | QDateTime birthday; | 58 | QDateTime birthday; |
59 | QString mailer; | 59 | QString mailer; |
60 | TimeZone timeZone; | 60 | TimeZone timeZone; |
61 | Geo geo; | 61 | Geo geo; |
62 | QString title; | 62 | QString title; |
63 | QString role; | 63 | QString role; |
64 | QString organization; | 64 | QString organization; |
65 | QString note; | 65 | QString note; |
66 | QString productId; | 66 | QString productId; |
67 | QDateTime revision; | 67 | QDateTime revision; |
68 | QString sortString; | 68 | QString sortString; |
69 | KURL url; | 69 | KURL url; |
70 | Secrecy secrecy; | 70 | Secrecy secrecy; |
71 | Picture logo; | 71 | Picture logo; |
72 | Picture photo; | 72 | Picture photo; |
73 | Sound sound; | 73 | Sound sound; |
74 | Agent agent; | 74 | Agent agent; |
75 | QString mExternalId; | 75 | QString mExternalId; |
76 | PhoneNumber::List phoneNumbers; | 76 | PhoneNumber::List phoneNumbers; |
77 | Address::List addresses; | 77 | Address::List addresses; |
78 | Key::List keys; | 78 | Key::List keys; |
79 | QStringList emails; | 79 | QStringList emails; |
80 | QStringList categories; | 80 | QStringList categories; |
81 | QStringList custom; | 81 | QStringList custom; |
82 | int mTempSyncStat; | 82 | int mTempSyncStat; |
83 | Resource *resource; | 83 | Resource *resource; |
84 | 84 | ||
85 | bool empty :1; | 85 | bool empty :1; |
86 | bool changed :1; | 86 | bool changed :1; |
87 | }; | 87 | }; |
88 | 88 | ||
89 | Addressee::Addressee() | 89 | Addressee::Addressee() |
90 | { | 90 | { |
91 | mData = new AddresseeData; | 91 | mData = new AddresseeData; |
92 | mData->empty = true; | 92 | mData->empty = true; |
93 | mData->changed = false; | 93 | mData->changed = false; |
94 | mData->resource = 0; | 94 | mData->resource = 0; |
95 | mData->mExternalId = ":"; | 95 | mData->mExternalId = ":"; |
96 | mData->revision = QDateTime ( QDate( 2004,1,1)); | 96 | mData->revision = QDateTime ( QDate( 2004,1,1)); |
97 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | 97 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
98 | } | 98 | } |
99 | 99 | ||
100 | Addressee::~Addressee() | 100 | Addressee::~Addressee() |
101 | { | 101 | { |
102 | } | 102 | } |
103 | 103 | ||
104 | Addressee::Addressee( const Addressee &a ) | 104 | Addressee::Addressee( const Addressee &a ) |
105 | { | 105 | { |
106 | mData = a.mData; | 106 | mData = a.mData; |
107 | } | 107 | } |
108 | 108 | ||
109 | Addressee &Addressee::operator=( const Addressee &a ) | 109 | Addressee &Addressee::operator=( const Addressee &a ) |
110 | { | 110 | { |
111 | mData = a.mData; | 111 | mData = a.mData; |
112 | return (*this); | 112 | return (*this); |
113 | } | 113 | } |
114 | 114 | ||
115 | Addressee Addressee::copy() | 115 | Addressee Addressee::copy() |
116 | { | 116 | { |
117 | Addressee a; | 117 | Addressee a; |
118 | *(a.mData) = *mData; | 118 | *(a.mData) = *mData; |
119 | return a; | 119 | return a; |
120 | } | 120 | } |
121 | 121 | ||
122 | void Addressee::detach() | 122 | void Addressee::detach() |
123 | { | 123 | { |
124 | if ( mData.count() == 1 ) return; | 124 | if ( mData.count() == 1 ) return; |
125 | *this = copy(); | 125 | *this = copy(); |
126 | } | 126 | } |
127 | 127 | ||
128 | bool Addressee::operator==( const Addressee &a ) const | 128 | bool Addressee::operator==( const Addressee &a ) const |
129 | { | 129 | { |
130 | if ( uid() != a.uid() ) return false; | 130 | if ( uid() != a.uid() ) return false; |
131 | if ( mData->name != a.mData->name ) return false; | 131 | if ( mData->name != a.mData->name ) return false; |
132 | if ( mData->formattedName != a.mData->formattedName ) return false; | 132 | if ( mData->formattedName != a.mData->formattedName ) return false; |
133 | if ( mData->familyName != a.mData->familyName ) return false; | 133 | if ( mData->familyName != a.mData->familyName ) return false; |
134 | if ( mData->givenName != a.mData->givenName ) return false; | 134 | if ( mData->givenName != a.mData->givenName ) return false; |
135 | if ( mData->additionalName != a.mData->additionalName ) return false; | 135 | if ( mData->additionalName != a.mData->additionalName ) return false; |
136 | if ( mData->prefix != a.mData->prefix ) return false; | 136 | if ( mData->prefix != a.mData->prefix ) return false; |
137 | if ( mData->suffix != a.mData->suffix ) return false; | 137 | if ( mData->suffix != a.mData->suffix ) return false; |
138 | if ( mData->nickName != a.mData->nickName ) return false; | 138 | if ( mData->nickName != a.mData->nickName ) return false; |
139 | if ( mData->birthday != a.mData->birthday ) return false; | 139 | if ( mData->birthday != a.mData->birthday ) return false; |
140 | if ( mData->mailer != a.mData->mailer ) return false; | 140 | if ( mData->mailer != a.mData->mailer ) return false; |
141 | if ( mData->timeZone != a.mData->timeZone ) return false; | 141 | if ( mData->timeZone != a.mData->timeZone ) return false; |
142 | if ( mData->geo != a.mData->geo ) return false; | 142 | if ( mData->geo != a.mData->geo ) return false; |
143 | if ( mData->title != a.mData->title ) return false; | 143 | if ( mData->title != a.mData->title ) return false; |
144 | if ( mData->role != a.mData->role ) return false; | 144 | if ( mData->role != a.mData->role ) return false; |
145 | if ( mData->organization != a.mData->organization ) return false; | 145 | if ( mData->organization != a.mData->organization ) return false; |
146 | if ( mData->note != a.mData->note ) return false; | 146 | if ( mData->note != a.mData->note ) return false; |
147 | if ( mData->productId != a.mData->productId ) return false; | 147 | if ( mData->productId != a.mData->productId ) return false; |
148 | if ( mData->revision != a.mData->revision ) return false; | 148 | if ( mData->revision != a.mData->revision ) return false; |
149 | if ( mData->sortString != a.mData->sortString ) return false; | 149 | if ( mData->sortString != a.mData->sortString ) return false; |
150 | if ( mData->secrecy != a.mData->secrecy ) return false; | 150 | if ( mData->secrecy != a.mData->secrecy ) return false; |
151 | if ( mData->logo != a.mData->logo ) return false; | 151 | if ( mData->logo != a.mData->logo ) return false; |
152 | if ( mData->photo != a.mData->photo ) return false; | 152 | if ( mData->photo != a.mData->photo ) return false; |
153 | if ( mData->sound != a.mData->sound ) return false; | 153 | if ( mData->sound != a.mData->sound ) return false; |
154 | if ( mData->agent != a.mData->agent ) return false; | 154 | if ( mData->agent != a.mData->agent ) return false; |
155 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && | 155 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && |
156 | ( mData->url != a.mData->url ) ) return false; | 156 | ( mData->url != a.mData->url ) ) return false; |
157 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; | 157 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; |
158 | if ( mData->addresses != a.mData->addresses ) return false; | 158 | if ( mData->addresses != a.mData->addresses ) return false; |
159 | if ( mData->keys != a.mData->keys ) return false; | 159 | if ( mData->keys != a.mData->keys ) return false; |
160 | if ( mData->emails != a.mData->emails ) return false; | 160 | if ( mData->emails != a.mData->emails ) return false; |
161 | if ( mData->categories != a.mData->categories ) return false; | 161 | if ( mData->categories != a.mData->categories ) return false; |
162 | if ( mData->custom != a.mData->custom ) return false; | 162 | if ( mData->custom != a.mData->custom ) return false; |
163 | 163 | ||
164 | return true; | 164 | return true; |
165 | } | 165 | } |
166 | 166 | ||
167 | bool Addressee::operator!=( const Addressee &a ) const | 167 | bool Addressee::operator!=( const Addressee &a ) const |
168 | { | 168 | { |
169 | return !( a == *this ); | 169 | return !( a == *this ); |
170 | } | 170 | } |
171 | 171 | ||
172 | bool Addressee::isEmpty() const | 172 | bool Addressee::isEmpty() const |
173 | { | 173 | { |
174 | return mData->empty; | 174 | return mData->empty; |
175 | } | 175 | } |
176 | ulong Addressee::getCsum4List( const QStringList & attList) | 176 | ulong Addressee::getCsum4List( const QStringList & attList) |
177 | { | 177 | { |
178 | int max = attList.count(); | 178 | int max = attList.count(); |
179 | ulong cSum = 0; | 179 | ulong cSum = 0; |
180 | int j,k,i; | 180 | int j,k,i; |
181 | int add; | 181 | int add; |
182 | for ( i = 0; i < max ; ++i ) { | 182 | for ( i = 0; i < max ; ++i ) { |
183 | QString s = attList[i]; | 183 | QString s = attList[i]; |
184 | if ( ! s.isEmpty() ){ | 184 | if ( ! s.isEmpty() ){ |
185 | j = s.length(); | 185 | j = s.length(); |
186 | for ( k = 0; k < j; ++k ) { | 186 | for ( k = 0; k < j; ++k ) { |
187 | int mul = k +1; | 187 | int mul = k +1; |
188 | add = s[k].unicode (); | 188 | add = s[k].unicode (); |
189 | if ( k < 16 ) | 189 | if ( k < 16 ) |
190 | mul = mul * mul; | 190 | mul = mul * mul; |
191 | int ii = i+1; | 191 | int ii = i+1; |
192 | add = add * mul *ii*ii*ii; | 192 | add = add * mul *ii*ii*ii; |
193 | cSum += add; | 193 | cSum += add; |
194 | } | 194 | } |
195 | } | 195 | } |
196 | 196 | ||
197 | } | 197 | } |
198 | //QString dump = attList.join(","); | 198 | //QString dump = attList.join(","); |
199 | //qDebug("csum: %d %s", cSum,dump.latin1()); | 199 | //qDebug("csum: %d %s", cSum,dump.latin1()); |
200 | 200 | ||
201 | return cSum; | 201 | return cSum; |
202 | 202 | ||
203 | } | 203 | } |
204 | void Addressee::computeCsum(const QString &dev) | 204 | void Addressee::computeCsum(const QString &dev) |
205 | { | 205 | { |
206 | QStringList l; | 206 | QStringList l; |
207 | if ( !mData->name.isEmpty() ) l.append(mData->name); | 207 | if ( !mData->name.isEmpty() ) l.append(mData->name); |
208 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); | 208 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); |
209 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); | 209 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); |
210 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); | 210 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); |
211 | if ( !mData->additionalName ) l.append( mData->additionalName ); | 211 | if ( !mData->additionalName ) l.append( mData->additionalName ); |
212 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); | 212 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); |
213 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); | 213 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); |
214 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); | 214 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); |
215 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); | 215 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); |
216 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); | 216 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); |
217 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); | 217 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); |
218 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | 218 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); |
219 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | 219 | if ( !mData->title .isEmpty() ) l.append( mData->title ); |
220 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | 220 | if ( !mData->role.isEmpty() ) l.append( mData->role ); |
221 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | 221 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); |
222 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | 222 | if ( !mData->note.isEmpty() ) l.append( mData->note ); |
223 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | 223 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); |
224 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | 224 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); |
225 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | 225 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); |
226 | // if ( !mData->logo.isEmpty() ) l.append( ); | 226 | // if ( !mData->logo.isEmpty() ) l.append( ); |
227 | //if ( !mData->photo.isEmpty() ) l.append( ); | 227 | //if ( !mData->photo.isEmpty() ) l.append( ); |
228 | //if ( !mData->sound.isEmpty() ) l.append( ); | 228 | //if ( !mData->sound.isEmpty() ) l.append( ); |
229 | //if ( !mData->agent.isEmpty() ) l.append( ); | 229 | //if ( !mData->agent.isEmpty() ) l.append( ); |
230 | //if ( mData->url.isValid() ) l.append( ); | 230 | //if ( mData->url.isValid() ) l.append( ); |
231 | #if 0 | 231 | #if 0 |
232 | if ( !mData->phoneNumbers.isEmpty() ) l.append( ); | 232 | if ( !mData->phoneNumbers.isEmpty() ) l.append( ); |
233 | if ( !mData->addresses.isEmpty() ) l.append( ); | 233 | if ( !mData->addresses.isEmpty() ) l.append( ); |
234 | //if ( !mData->keys.isEmpty() ) l.append( ); | 234 | //if ( !mData->keys.isEmpty() ) l.append( ); |
235 | if ( !mData->emails.isEmpty() ) l.append( ); | 235 | if ( !mData->emails.isEmpty() ) l.append( ); |
236 | if ( !mData->categories .isEmpty() ) l.append( ); | 236 | if ( !mData->categories .isEmpty() ) l.append( ); |
237 | if ( !mData->custom.isEmpty() ) l.append( ); | 237 | if ( !mData->custom.isEmpty() ) l.append( ); |
238 | #endif | 238 | #endif |
239 | KABC::PhoneNumber::List phoneNumbers; | 239 | KABC::PhoneNumber::List phoneNumbers; |
240 | KABC::PhoneNumber::List::Iterator phoneIter; | 240 | KABC::PhoneNumber::List::Iterator phoneIter; |
241 | 241 | ||
242 | QStringList t; | 242 | QStringList t; |
243 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 243 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
244 | ++phoneIter ) | 244 | ++phoneIter ) |
245 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 245 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); |
246 | t.sort(); | 246 | t.sort(); |
247 | uint iii; | 247 | uint iii; |
248 | for ( iii = 0; iii < t.count(); ++iii) | 248 | for ( iii = 0; iii < t.count(); ++iii) |
249 | l.append( t[iii] ); | 249 | l.append( t[iii] ); |
250 | t = mData->emails; | 250 | t = mData->emails; |
251 | t.sort(); | 251 | t.sort(); |
252 | for ( iii = 0; iii < t.count(); ++iii) | 252 | for ( iii = 0; iii < t.count(); ++iii) |
253 | l.append( t[iii] ); | 253 | l.append( t[iii] ); |
254 | t = mData->categories; | 254 | t = mData->categories; |
255 | t.sort(); | 255 | t.sort(); |
256 | for ( iii = 0; iii < t.count(); ++iii) | 256 | for ( iii = 0; iii < t.count(); ++iii) |
257 | l.append( t[iii] ); | 257 | l.append( t[iii] ); |
258 | t = mData->custom; | 258 | t = mData->custom; |
259 | t.sort(); | 259 | t.sort(); |
260 | for ( iii = 0; iii < t.count(); ++iii) | 260 | for ( iii = 0; iii < t.count(); ++iii) |
261 | l.append( t[iii] ); | 261 | l.append( t[iii] ); |
262 | KABC::Address::List::Iterator addressIter; | 262 | KABC::Address::List::Iterator addressIter; |
263 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 263 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
264 | ++addressIter ) { | 264 | ++addressIter ) { |
265 | t = (*addressIter).asList(); | 265 | t = (*addressIter).asList(); |
266 | t.sort(); | 266 | t.sort(); |
267 | for ( iii = 0; iii < t.count(); ++iii) | 267 | for ( iii = 0; iii < t.count(); ++iii) |
268 | l.append( t[iii] ); | 268 | l.append( t[iii] ); |
269 | } | 269 | } |
270 | uint cs = getCsum4List(l); | 270 | uint cs = getCsum4List(l); |
271 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 271 | // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); |
272 | setCsum( dev, QString::number (cs )); | 272 | setCsum( dev, QString::number (cs )); |
273 | } | 273 | } |
274 | void Addressee::removeID(const QString &prof) | 274 | void Addressee::removeID(const QString &prof) |
275 | { | 275 | { |
276 | detach(); | 276 | detach(); |
277 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | 277 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); |
278 | 278 | ||
279 | } | 279 | } |
280 | void Addressee::setID( const QString & prof , const QString & id ) | 280 | void Addressee::setID( const QString & prof , const QString & id ) |
281 | { | 281 | { |
282 | detach(); | 282 | detach(); |
283 | qDebug("setID1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | ||
284 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | 283 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); |
285 | qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 284 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
286 | } | 285 | } |
287 | void Addressee::setTempSyncStat( int id ) | 286 | void Addressee::setTempSyncStat( int id ) |
288 | { | 287 | { |
289 | if ( mData->mTempSyncStat == id ) return; | 288 | if ( mData->mTempSyncStat == id ) return; |
290 | detach(); | 289 | detach(); |
291 | mData->mTempSyncStat = id; | 290 | mData->mTempSyncStat = id; |
292 | } | 291 | } |
293 | int Addressee::tempSyncStat() const | 292 | int Addressee::tempSyncStat() const |
294 | { | 293 | { |
295 | return mData->mTempSyncStat; | 294 | return mData->mTempSyncStat; |
296 | } | 295 | } |
297 | 296 | ||
298 | QString Addressee::getID( const QString & prof) | 297 | QString Addressee::getID( const QString & prof) |
299 | { | 298 | { |
300 | return KIdManager::getId ( mData->mExternalId, prof ); | 299 | return KIdManager::getId ( mData->mExternalId, prof ); |
301 | } | 300 | } |
302 | 301 | ||
303 | void Addressee::setCsum( const QString & prof , const QString & id ) | 302 | void Addressee::setCsum( const QString & prof , const QString & id ) |
304 | { | 303 | { |
305 | detach(); | 304 | detach(); |
306 | qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 305 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
307 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | 306 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); |
308 | qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); | 307 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); |
309 | } | 308 | } |
310 | 309 | ||
311 | QString Addressee::getCsum( const QString & prof) | 310 | QString Addressee::getCsum( const QString & prof) |
312 | { | 311 | { |
313 | return KIdManager::getCsum ( mData->mExternalId, prof ); | 312 | return KIdManager::getCsum ( mData->mExternalId, prof ); |
314 | } | 313 | } |
315 | 314 | ||
316 | void Addressee::setIDStr( const QString & s ) | 315 | void Addressee::setIDStr( const QString & s ) |
317 | { | 316 | { |
318 | detach(); | 317 | detach(); |
319 | mData->mExternalId = s; | 318 | mData->mExternalId = s; |
320 | } | 319 | } |
321 | 320 | ||
322 | QString Addressee::IDStr() const | 321 | QString Addressee::IDStr() const |
323 | { | 322 | { |
324 | return mData->mExternalId; | 323 | return mData->mExternalId; |
325 | } | 324 | } |
326 | 325 | ||
327 | 326 | ||
328 | void Addressee::setUid( const QString &id ) | 327 | void Addressee::setUid( const QString &id ) |
329 | { | 328 | { |
330 | if ( id == mData->uid ) return; | 329 | if ( id == mData->uid ) return; |
331 | detach(); | 330 | detach(); |
332 | mData->empty = false; | 331 | mData->empty = false; |
333 | mData->uid = id; | 332 | mData->uid = id; |
334 | } | 333 | } |
335 | 334 | ||
336 | QString Addressee::uid() const | 335 | QString Addressee::uid() const |
337 | { | 336 | { |
338 | if ( mData->uid.isEmpty() ) | 337 | if ( mData->uid.isEmpty() ) |
339 | mData->uid = KApplication::randomString( 10 ); | 338 | mData->uid = KApplication::randomString( 10 ); |
340 | 339 | ||
341 | return mData->uid; | 340 | return mData->uid; |
342 | } | 341 | } |
343 | 342 | ||
344 | QString Addressee::uidLabel() | 343 | QString Addressee::uidLabel() |
345 | { | 344 | { |
346 | return i18n("Unique Identifier"); | 345 | return i18n("Unique Identifier"); |
347 | } | 346 | } |
348 | 347 | ||
349 | void Addressee::setName( const QString &name ) | 348 | void Addressee::setName( const QString &name ) |
350 | { | 349 | { |
351 | if ( name == mData->name ) return; | 350 | if ( name == mData->name ) return; |
352 | detach(); | 351 | detach(); |
353 | mData->empty = false; | 352 | mData->empty = false; |
354 | mData->name = name; | 353 | mData->name = name; |
355 | } | 354 | } |
356 | 355 | ||
357 | QString Addressee::name() const | 356 | QString Addressee::name() const |
358 | { | 357 | { |
359 | return mData->name; | 358 | return mData->name; |
360 | } | 359 | } |
361 | 360 | ||
362 | QString Addressee::nameLabel() | 361 | QString Addressee::nameLabel() |
363 | { | 362 | { |
364 | return i18n("Name"); | 363 | return i18n("Name"); |
365 | } | 364 | } |
366 | 365 | ||
367 | 366 | ||
368 | void Addressee::setFormattedName( const QString &formattedName ) | 367 | void Addressee::setFormattedName( const QString &formattedName ) |
369 | { | 368 | { |
370 | if ( formattedName == mData->formattedName ) return; | 369 | if ( formattedName == mData->formattedName ) return; |
371 | detach(); | 370 | detach(); |
372 | mData->empty = false; | 371 | mData->empty = false; |
373 | mData->formattedName = formattedName; | 372 | mData->formattedName = formattedName; |
374 | } | 373 | } |
375 | 374 | ||
376 | QString Addressee::formattedName() const | 375 | QString Addressee::formattedName() const |
377 | { | 376 | { |
378 | return mData->formattedName; | 377 | return mData->formattedName; |
379 | } | 378 | } |
380 | 379 | ||
381 | QString Addressee::formattedNameLabel() | 380 | QString Addressee::formattedNameLabel() |
382 | { | 381 | { |
383 | return i18n("Formatted Name"); | 382 | return i18n("Formatted Name"); |
384 | } | 383 | } |
385 | 384 | ||
386 | 385 | ||
387 | void Addressee::setFamilyName( const QString &familyName ) | 386 | void Addressee::setFamilyName( const QString &familyName ) |
388 | { | 387 | { |
389 | if ( familyName == mData->familyName ) return; | 388 | if ( familyName == mData->familyName ) return; |
390 | detach(); | 389 | detach(); |
391 | mData->empty = false; | 390 | mData->empty = false; |
392 | mData->familyName = familyName; | 391 | mData->familyName = familyName; |
393 | } | 392 | } |
394 | 393 | ||
395 | QString Addressee::familyName() const | 394 | QString Addressee::familyName() const |
396 | { | 395 | { |
397 | return mData->familyName; | 396 | return mData->familyName; |
398 | } | 397 | } |
399 | 398 | ||
400 | QString Addressee::familyNameLabel() | 399 | QString Addressee::familyNameLabel() |
401 | { | 400 | { |
402 | return i18n("Family Name"); | 401 | return i18n("Family Name"); |
403 | } | 402 | } |
404 | 403 | ||
405 | 404 | ||
406 | void Addressee::setGivenName( const QString &givenName ) | 405 | void Addressee::setGivenName( const QString &givenName ) |
407 | { | 406 | { |
408 | if ( givenName == mData->givenName ) return; | 407 | if ( givenName == mData->givenName ) return; |
409 | detach(); | 408 | detach(); |
410 | mData->empty = false; | 409 | mData->empty = false; |
411 | mData->givenName = givenName; | 410 | mData->givenName = givenName; |
412 | } | 411 | } |
413 | 412 | ||
414 | QString Addressee::givenName() const | 413 | QString Addressee::givenName() const |
415 | { | 414 | { |
416 | return mData->givenName; | 415 | return mData->givenName; |
417 | } | 416 | } |
418 | 417 | ||
419 | QString Addressee::givenNameLabel() | 418 | QString Addressee::givenNameLabel() |
420 | { | 419 | { |
421 | return i18n("Given Name"); | 420 | return i18n("Given Name"); |
422 | } | 421 | } |
423 | 422 | ||
424 | 423 | ||
425 | void Addressee::setAdditionalName( const QString &additionalName ) | 424 | void Addressee::setAdditionalName( const QString &additionalName ) |
426 | { | 425 | { |
427 | if ( additionalName == mData->additionalName ) return; | 426 | if ( additionalName == mData->additionalName ) return; |
428 | detach(); | 427 | detach(); |
429 | mData->empty = false; | 428 | mData->empty = false; |
430 | mData->additionalName = additionalName; | 429 | mData->additionalName = additionalName; |
431 | } | 430 | } |
432 | 431 | ||
433 | QString Addressee::additionalName() const | 432 | QString Addressee::additionalName() const |
434 | { | 433 | { |
435 | return mData->additionalName; | 434 | return mData->additionalName; |
436 | } | 435 | } |
437 | 436 | ||
438 | QString Addressee::additionalNameLabel() | 437 | QString Addressee::additionalNameLabel() |
439 | { | 438 | { |
440 | return i18n("Additional Names"); | 439 | return i18n("Additional Names"); |
441 | } | 440 | } |
442 | 441 | ||
443 | 442 | ||
444 | void Addressee::setPrefix( const QString &prefix ) | 443 | void Addressee::setPrefix( const QString &prefix ) |
445 | { | 444 | { |
446 | if ( prefix == mData->prefix ) return; | 445 | if ( prefix == mData->prefix ) return; |
447 | detach(); | 446 | detach(); |
448 | mData->empty = false; | 447 | mData->empty = false; |
449 | mData->prefix = prefix; | 448 | mData->prefix = prefix; |
450 | } | 449 | } |
451 | 450 | ||
452 | QString Addressee::prefix() const | 451 | QString Addressee::prefix() const |
453 | { | 452 | { |
454 | return mData->prefix; | 453 | return mData->prefix; |
455 | } | 454 | } |
456 | 455 | ||
457 | QString Addressee::prefixLabel() | 456 | QString Addressee::prefixLabel() |
458 | { | 457 | { |
459 | return i18n("Honorific Prefixes"); | 458 | return i18n("Honorific Prefixes"); |
460 | } | 459 | } |
461 | 460 | ||
462 | 461 | ||
463 | void Addressee::setSuffix( const QString &suffix ) | 462 | void Addressee::setSuffix( const QString &suffix ) |
464 | { | 463 | { |
465 | if ( suffix == mData->suffix ) return; | 464 | if ( suffix == mData->suffix ) return; |
466 | detach(); | 465 | detach(); |
467 | mData->empty = false; | 466 | mData->empty = false; |
468 | mData->suffix = suffix; | 467 | mData->suffix = suffix; |
469 | } | 468 | } |
470 | 469 | ||
471 | QString Addressee::suffix() const | 470 | QString Addressee::suffix() const |
472 | { | 471 | { |
473 | return mData->suffix; | 472 | return mData->suffix; |
474 | } | 473 | } |
475 | 474 | ||
476 | QString Addressee::suffixLabel() | 475 | QString Addressee::suffixLabel() |
477 | { | 476 | { |
478 | return i18n("Honorific Suffixes"); | 477 | return i18n("Honorific Suffixes"); |
479 | } | 478 | } |
480 | 479 | ||
481 | 480 | ||
482 | void Addressee::setNickName( const QString &nickName ) | 481 | void Addressee::setNickName( const QString &nickName ) |
483 | { | 482 | { |
484 | if ( nickName == mData->nickName ) return; | 483 | if ( nickName == mData->nickName ) return; |
485 | detach(); | 484 | detach(); |
486 | mData->empty = false; | 485 | mData->empty = false; |
487 | mData->nickName = nickName; | 486 | mData->nickName = nickName; |
488 | } | 487 | } |
489 | 488 | ||
490 | QString Addressee::nickName() const | 489 | QString Addressee::nickName() const |
491 | { | 490 | { |
492 | return mData->nickName; | 491 | return mData->nickName; |
493 | } | 492 | } |
494 | 493 | ||
495 | QString Addressee::nickNameLabel() | 494 | QString Addressee::nickNameLabel() |
496 | { | 495 | { |
497 | return i18n("Nick Name"); | 496 | return i18n("Nick Name"); |
498 | } | 497 | } |
499 | 498 | ||
500 | 499 | ||
501 | void Addressee::setBirthday( const QDateTime &birthday ) | 500 | void Addressee::setBirthday( const QDateTime &birthday ) |
502 | { | 501 | { |
503 | if ( birthday == mData->birthday ) return; | 502 | if ( birthday == mData->birthday ) return; |
504 | detach(); | 503 | detach(); |
505 | mData->empty = false; | 504 | mData->empty = false; |
506 | mData->birthday = birthday; | 505 | mData->birthday = birthday; |
507 | } | 506 | } |
508 | 507 | ||
509 | QDateTime Addressee::birthday() const | 508 | QDateTime Addressee::birthday() const |
510 | { | 509 | { |
511 | return mData->birthday; | 510 | return mData->birthday; |
512 | } | 511 | } |
513 | 512 | ||
514 | QString Addressee::birthdayLabel() | 513 | QString Addressee::birthdayLabel() |
515 | { | 514 | { |
516 | return i18n("Birthday"); | 515 | return i18n("Birthday"); |
517 | } | 516 | } |
518 | 517 | ||
519 | 518 | ||
520 | QString Addressee::homeAddressStreetLabel() | 519 | QString Addressee::homeAddressStreetLabel() |
521 | { | 520 | { |
522 | return i18n("Home Address Street"); | 521 | return i18n("Home Address Street"); |
523 | } | 522 | } |
524 | 523 | ||
525 | 524 | ||
526 | QString Addressee::homeAddressLocalityLabel() | 525 | QString Addressee::homeAddressLocalityLabel() |
527 | { | 526 | { |
528 | return i18n("Home Address Locality"); | 527 | return i18n("Home Address Locality"); |
529 | } | 528 | } |
530 | 529 | ||
531 | 530 | ||
532 | QString Addressee::homeAddressRegionLabel() | 531 | QString Addressee::homeAddressRegionLabel() |
533 | { | 532 | { |
534 | return i18n("Home Address Region"); | 533 | return i18n("Home Address Region"); |
535 | } | 534 | } |
536 | 535 | ||
537 | 536 | ||
538 | QString Addressee::homeAddressPostalCodeLabel() | 537 | QString Addressee::homeAddressPostalCodeLabel() |
539 | { | 538 | { |
540 | return i18n("Home Address Postal Code"); | 539 | return i18n("Home Address Postal Code"); |
541 | } | 540 | } |
542 | 541 | ||
543 | 542 | ||
544 | QString Addressee::homeAddressCountryLabel() | 543 | QString Addressee::homeAddressCountryLabel() |
545 | { | 544 | { |
546 | return i18n("Home Address Country"); | 545 | return i18n("Home Address Country"); |
547 | } | 546 | } |
548 | 547 | ||
549 | 548 | ||
550 | QString Addressee::homeAddressLabelLabel() | 549 | QString Addressee::homeAddressLabelLabel() |
551 | { | 550 | { |
552 | return i18n("Home Address Label"); | 551 | return i18n("Home Address Label"); |
553 | } | 552 | } |
554 | 553 | ||
555 | 554 | ||
556 | QString Addressee::businessAddressStreetLabel() | 555 | QString Addressee::businessAddressStreetLabel() |
557 | { | 556 | { |
558 | return i18n("Business Address Street"); | 557 | return i18n("Business Address Street"); |
559 | } | 558 | } |
560 | 559 | ||
561 | 560 | ||
562 | QString Addressee::businessAddressLocalityLabel() | 561 | QString Addressee::businessAddressLocalityLabel() |
563 | { | 562 | { |
564 | return i18n("Business Address Locality"); | 563 | return i18n("Business Address Locality"); |
565 | } | 564 | } |
566 | 565 | ||
567 | 566 | ||
568 | QString Addressee::businessAddressRegionLabel() | 567 | QString Addressee::businessAddressRegionLabel() |
569 | { | 568 | { |
570 | return i18n("Business Address Region"); | 569 | return i18n("Business Address Region"); |
571 | } | 570 | } |
572 | 571 | ||
573 | 572 | ||
574 | QString Addressee::businessAddressPostalCodeLabel() | 573 | QString Addressee::businessAddressPostalCodeLabel() |
575 | { | 574 | { |
576 | return i18n("Business Address Postal Code"); | 575 | return i18n("Business Address Postal Code"); |
577 | } | 576 | } |
578 | 577 | ||
579 | 578 | ||
580 | QString Addressee::businessAddressCountryLabel() | 579 | QString Addressee::businessAddressCountryLabel() |
581 | { | 580 | { |
582 | return i18n("Business Address Country"); | 581 | return i18n("Business Address Country"); |
583 | } | 582 | } |
584 | 583 | ||
585 | 584 | ||
586 | QString Addressee::businessAddressLabelLabel() | 585 | QString Addressee::businessAddressLabelLabel() |
587 | { | 586 | { |
588 | return i18n("Business Address Label"); | 587 | return i18n("Business Address Label"); |
589 | } | 588 | } |
590 | 589 | ||
591 | 590 | ||
592 | QString Addressee::homePhoneLabel() | 591 | QString Addressee::homePhoneLabel() |
593 | { | 592 | { |
594 | return i18n("Home Phone"); | 593 | return i18n("Home Phone"); |
595 | } | 594 | } |
596 | 595 | ||
597 | 596 | ||
598 | QString Addressee::businessPhoneLabel() | 597 | QString Addressee::businessPhoneLabel() |
599 | { | 598 | { |
600 | return i18n("Business Phone"); | 599 | return i18n("Business Phone"); |
601 | } | 600 | } |
602 | 601 | ||
603 | 602 | ||
604 | QString Addressee::mobilePhoneLabel() | 603 | QString Addressee::mobilePhoneLabel() |
605 | { | 604 | { |
606 | return i18n("Mobile Phone"); | 605 | return i18n("Mobile Phone"); |
607 | } | 606 | } |
608 | 607 | ||
609 | 608 | ||
610 | QString Addressee::homeFaxLabel() | 609 | QString Addressee::homeFaxLabel() |
611 | { | 610 | { |
612 | return i18n("Home Fax"); | 611 | return i18n("Home Fax"); |
613 | } | 612 | } |
614 | 613 | ||
615 | 614 | ||
616 | QString Addressee::businessFaxLabel() | 615 | QString Addressee::businessFaxLabel() |
617 | { | 616 | { |
618 | return i18n("Business Fax"); | 617 | return i18n("Business Fax"); |
619 | } | 618 | } |
620 | 619 | ||
621 | 620 | ||
622 | QString Addressee::carPhoneLabel() | 621 | QString Addressee::carPhoneLabel() |
623 | { | 622 | { |
624 | return i18n("Car Phone"); | 623 | return i18n("Car Phone"); |
625 | } | 624 | } |
626 | 625 | ||
627 | 626 | ||
628 | QString Addressee::isdnLabel() | 627 | QString Addressee::isdnLabel() |
629 | { | 628 | { |
630 | return i18n("ISDN"); | 629 | return i18n("ISDN"); |
631 | } | 630 | } |
632 | 631 | ||
633 | 632 | ||
634 | QString Addressee::pagerLabel() | 633 | QString Addressee::pagerLabel() |
635 | { | 634 | { |
636 | return i18n("Pager"); | 635 | return i18n("Pager"); |
637 | } | 636 | } |
638 | 637 | ||
639 | QString Addressee::sipLabel() | 638 | QString Addressee::sipLabel() |
640 | { | 639 | { |
641 | return i18n("SIP"); | 640 | return i18n("SIP"); |
642 | } | 641 | } |
643 | 642 | ||
644 | QString Addressee::emailLabel() | 643 | QString Addressee::emailLabel() |
645 | { | 644 | { |
646 | return i18n("Email Address"); | 645 | return i18n("Email Address"); |
647 | } | 646 | } |
648 | 647 | ||
649 | 648 | ||
650 | void Addressee::setMailer( const QString &mailer ) | 649 | void Addressee::setMailer( const QString &mailer ) |
651 | { | 650 | { |
652 | if ( mailer == mData->mailer ) return; | 651 | if ( mailer == mData->mailer ) return; |
653 | detach(); | 652 | detach(); |
654 | mData->empty = false; | 653 | mData->empty = false; |
655 | mData->mailer = mailer; | 654 | mData->mailer = mailer; |
656 | } | 655 | } |
657 | 656 | ||
658 | QString Addressee::mailer() const | 657 | QString Addressee::mailer() const |
659 | { | 658 | { |
660 | return mData->mailer; | 659 | return mData->mailer; |
661 | } | 660 | } |
662 | 661 | ||
663 | QString Addressee::mailerLabel() | 662 | QString Addressee::mailerLabel() |
664 | { | 663 | { |
665 | return i18n("Mail Client"); | 664 | return i18n("Mail Client"); |
666 | } | 665 | } |
667 | 666 | ||
668 | 667 | ||
669 | void Addressee::setTimeZone( const TimeZone &timeZone ) | 668 | void Addressee::setTimeZone( const TimeZone &timeZone ) |
670 | { | 669 | { |
671 | if ( timeZone == mData->timeZone ) return; | 670 | if ( timeZone == mData->timeZone ) return; |
672 | detach(); | 671 | detach(); |
673 | mData->empty = false; | 672 | mData->empty = false; |
674 | mData->timeZone = timeZone; | 673 | mData->timeZone = timeZone; |
675 | } | 674 | } |
676 | 675 | ||
677 | TimeZone Addressee::timeZone() const | 676 | TimeZone Addressee::timeZone() const |
678 | { | 677 | { |
679 | return mData->timeZone; | 678 | return mData->timeZone; |
680 | } | 679 | } |
681 | 680 | ||
682 | QString Addressee::timeZoneLabel() | 681 | QString Addressee::timeZoneLabel() |
683 | { | 682 | { |
684 | return i18n("Time Zone"); | 683 | return i18n("Time Zone"); |
685 | } | 684 | } |
686 | 685 | ||
687 | 686 | ||
688 | void Addressee::setGeo( const Geo &geo ) | 687 | void Addressee::setGeo( const Geo &geo ) |
689 | { | 688 | { |
690 | if ( geo == mData->geo ) return; | 689 | if ( geo == mData->geo ) return; |
691 | detach(); | 690 | detach(); |
692 | mData->empty = false; | 691 | mData->empty = false; |
693 | mData->geo = geo; | 692 | mData->geo = geo; |
694 | } | 693 | } |
695 | 694 | ||
696 | Geo Addressee::geo() const | 695 | Geo Addressee::geo() const |
697 | { | 696 | { |
698 | return mData->geo; | 697 | return mData->geo; |
699 | } | 698 | } |
700 | 699 | ||
701 | QString Addressee::geoLabel() | 700 | QString Addressee::geoLabel() |
702 | { | 701 | { |
703 | return i18n("Geographic Position"); | 702 | return i18n("Geographic Position"); |
704 | } | 703 | } |
705 | 704 | ||
706 | 705 | ||
707 | void Addressee::setTitle( const QString &title ) | 706 | void Addressee::setTitle( const QString &title ) |
708 | { | 707 | { |
709 | if ( title == mData->title ) return; | 708 | if ( title == mData->title ) return; |
710 | detach(); | 709 | detach(); |
711 | mData->empty = false; | 710 | mData->empty = false; |
712 | mData->title = title; | 711 | mData->title = title; |
713 | } | 712 | } |
714 | 713 | ||
715 | QString Addressee::title() const | 714 | QString Addressee::title() const |
716 | { | 715 | { |
717 | return mData->title; | 716 | return mData->title; |
718 | } | 717 | } |
719 | 718 | ||
720 | QString Addressee::titleLabel() | 719 | QString Addressee::titleLabel() |
721 | { | 720 | { |
722 | return i18n("Title"); | 721 | return i18n("Title"); |
723 | } | 722 | } |
724 | 723 | ||
725 | 724 | ||
726 | void Addressee::setRole( const QString &role ) | 725 | void Addressee::setRole( const QString &role ) |
727 | { | 726 | { |
728 | if ( role == mData->role ) return; | 727 | if ( role == mData->role ) return; |
729 | detach(); | 728 | detach(); |
730 | mData->empty = false; | 729 | mData->empty = false; |
731 | mData->role = role; | 730 | mData->role = role; |
732 | } | 731 | } |
733 | 732 | ||
734 | QString Addressee::role() const | 733 | QString Addressee::role() const |
735 | { | 734 | { |
736 | return mData->role; | 735 | return mData->role; |
737 | } | 736 | } |
738 | 737 | ||
739 | QString Addressee::roleLabel() | 738 | QString Addressee::roleLabel() |
740 | { | 739 | { |
741 | return i18n("Role"); | 740 | return i18n("Role"); |
742 | } | 741 | } |
743 | 742 | ||
744 | 743 | ||
745 | void Addressee::setOrganization( const QString &organization ) | 744 | void Addressee::setOrganization( const QString &organization ) |
746 | { | 745 | { |
747 | if ( organization == mData->organization ) return; | 746 | if ( organization == mData->organization ) return; |
748 | detach(); | 747 | detach(); |
749 | mData->empty = false; | 748 | mData->empty = false; |
750 | mData->organization = organization; | 749 | mData->organization = organization; |
751 | } | 750 | } |
752 | 751 | ||
753 | QString Addressee::organization() const | 752 | QString Addressee::organization() const |
754 | { | 753 | { |
755 | return mData->organization; | 754 | return mData->organization; |
756 | } | 755 | } |
757 | 756 | ||
758 | QString Addressee::organizationLabel() | 757 | QString Addressee::organizationLabel() |
759 | { | 758 | { |
760 | return i18n("Organization"); | 759 | return i18n("Organization"); |
761 | } | 760 | } |
762 | 761 | ||
763 | 762 | ||
764 | void Addressee::setNote( const QString ¬e ) | 763 | void Addressee::setNote( const QString ¬e ) |
765 | { | 764 | { |
766 | if ( note == mData->note ) return; | 765 | if ( note == mData->note ) return; |
767 | detach(); | 766 | detach(); |
768 | mData->empty = false; | 767 | mData->empty = false; |
769 | mData->note = note; | 768 | mData->note = note; |
770 | } | 769 | } |
771 | 770 | ||
772 | QString Addressee::note() const | 771 | QString Addressee::note() const |
773 | { | 772 | { |
774 | return mData->note; | 773 | return mData->note; |
775 | } | 774 | } |
776 | 775 | ||
777 | QString Addressee::noteLabel() | 776 | QString Addressee::noteLabel() |
778 | { | 777 | { |
779 | return i18n("Note"); | 778 | return i18n("Note"); |
780 | } | 779 | } |
781 | 780 | ||
782 | 781 | ||
783 | void Addressee::setProductId( const QString &productId ) | 782 | void Addressee::setProductId( const QString &productId ) |
784 | { | 783 | { |
785 | if ( productId == mData->productId ) return; | 784 | if ( productId == mData->productId ) return; |
786 | detach(); | 785 | detach(); |
787 | mData->empty = false; | 786 | mData->empty = false; |
788 | mData->productId = productId; | 787 | mData->productId = productId; |
789 | } | 788 | } |
790 | 789 | ||
791 | QString Addressee::productId() const | 790 | QString Addressee::productId() const |
792 | { | 791 | { |
793 | return mData->productId; | 792 | return mData->productId; |
794 | } | 793 | } |
795 | 794 | ||
796 | QString Addressee::productIdLabel() | 795 | QString Addressee::productIdLabel() |
797 | { | 796 | { |
798 | return i18n("Product Identifier"); | 797 | return i18n("Product Identifier"); |
799 | } | 798 | } |
800 | 799 | ||
801 | 800 | ||
802 | void Addressee::setRevision( const QDateTime &revision ) | 801 | void Addressee::setRevision( const QDateTime &revision ) |
803 | { | 802 | { |
804 | if ( revision == mData->revision ) return; | 803 | if ( revision == mData->revision ) return; |
805 | detach(); | 804 | detach(); |
806 | mData->empty = false; | 805 | mData->empty = false; |
807 | mData->revision = revision; | 806 | mData->revision = revision; |
808 | } | 807 | } |
809 | 808 | ||
810 | QDateTime Addressee::revision() const | 809 | QDateTime Addressee::revision() const |
811 | { | 810 | { |
812 | return mData->revision; | 811 | return mData->revision; |
813 | } | 812 | } |
814 | 813 | ||
815 | QString Addressee::revisionLabel() | 814 | QString Addressee::revisionLabel() |
816 | { | 815 | { |
817 | return i18n("Revision Date"); | 816 | return i18n("Revision Date"); |
818 | } | 817 | } |
819 | 818 | ||
820 | 819 | ||
821 | void Addressee::setSortString( const QString &sortString ) | 820 | void Addressee::setSortString( const QString &sortString ) |
822 | { | 821 | { |
823 | if ( sortString == mData->sortString ) return; | 822 | if ( sortString == mData->sortString ) return; |
824 | detach(); | 823 | detach(); |
825 | mData->empty = false; | 824 | mData->empty = false; |
826 | mData->sortString = sortString; | 825 | mData->sortString = sortString; |
827 | } | 826 | } |
828 | 827 | ||
829 | QString Addressee::sortString() const | 828 | QString Addressee::sortString() const |
830 | { | 829 | { |
831 | return mData->sortString; | 830 | return mData->sortString; |
832 | } | 831 | } |
833 | 832 | ||
834 | QString Addressee::sortStringLabel() | 833 | QString Addressee::sortStringLabel() |
835 | { | 834 | { |
836 | return i18n("Sort String"); | 835 | return i18n("Sort String"); |
837 | } | 836 | } |
838 | 837 | ||
839 | 838 | ||
840 | void Addressee::setUrl( const KURL &url ) | 839 | void Addressee::setUrl( const KURL &url ) |
841 | { | 840 | { |
842 | if ( url == mData->url ) return; | 841 | if ( url == mData->url ) return; |
843 | detach(); | 842 | detach(); |
844 | mData->empty = false; | 843 | mData->empty = false; |
845 | mData->url = url; | 844 | mData->url = url; |
846 | } | 845 | } |
847 | 846 | ||
848 | KURL Addressee::url() const | 847 | KURL Addressee::url() const |
849 | { | 848 | { |
850 | return mData->url; | 849 | return mData->url; |
851 | } | 850 | } |
852 | 851 | ||
853 | QString Addressee::urlLabel() | 852 | QString Addressee::urlLabel() |
854 | { | 853 | { |
855 | return i18n("URL"); | 854 | return i18n("URL"); |
856 | } | 855 | } |
857 | 856 | ||
858 | 857 | ||
859 | void Addressee::setSecrecy( const Secrecy &secrecy ) | 858 | void Addressee::setSecrecy( const Secrecy &secrecy ) |
860 | { | 859 | { |
861 | if ( secrecy == mData->secrecy ) return; | 860 | if ( secrecy == mData->secrecy ) return; |
862 | detach(); | 861 | detach(); |
863 | mData->empty = false; | 862 | mData->empty = false; |
864 | mData->secrecy = secrecy; | 863 | mData->secrecy = secrecy; |
865 | } | 864 | } |
866 | 865 | ||
867 | Secrecy Addressee::secrecy() const | 866 | Secrecy Addressee::secrecy() const |
868 | { | 867 | { |
869 | return mData->secrecy; | 868 | return mData->secrecy; |
870 | } | 869 | } |
871 | 870 | ||
872 | QString Addressee::secrecyLabel() | 871 | QString Addressee::secrecyLabel() |
873 | { | 872 | { |
874 | return i18n("Security Class"); | 873 | return i18n("Security Class"); |
875 | } | 874 | } |
876 | 875 | ||
877 | 876 | ||
878 | void Addressee::setLogo( const Picture &logo ) | 877 | void Addressee::setLogo( const Picture &logo ) |
879 | { | 878 | { |
880 | if ( logo == mData->logo ) return; | 879 | if ( logo == mData->logo ) return; |
881 | detach(); | 880 | detach(); |
882 | mData->empty = false; | 881 | mData->empty = false; |
883 | mData->logo = logo; | 882 | mData->logo = logo; |
884 | } | 883 | } |
885 | 884 | ||
886 | Picture Addressee::logo() const | 885 | Picture Addressee::logo() const |
887 | { | 886 | { |
888 | return mData->logo; | 887 | return mData->logo; |
889 | } | 888 | } |
890 | 889 | ||
891 | QString Addressee::logoLabel() | 890 | QString Addressee::logoLabel() |
892 | { | 891 | { |
893 | return i18n("Logo"); | 892 | return i18n("Logo"); |
894 | } | 893 | } |
895 | 894 | ||
896 | 895 | ||
897 | void Addressee::setPhoto( const Picture &photo ) | 896 | void Addressee::setPhoto( const Picture &photo ) |
898 | { | 897 | { |
899 | if ( photo == mData->photo ) return; | 898 | if ( photo == mData->photo ) return; |
900 | detach(); | 899 | detach(); |
901 | mData->empty = false; | 900 | mData->empty = false; |
902 | mData->photo = photo; | 901 | mData->photo = photo; |
903 | } | 902 | } |
904 | 903 | ||
905 | Picture Addressee::photo() const | 904 | Picture Addressee::photo() const |
906 | { | 905 | { |
907 | return mData->photo; | 906 | return mData->photo; |
908 | } | 907 | } |
909 | 908 | ||
910 | QString Addressee::photoLabel() | 909 | QString Addressee::photoLabel() |
911 | { | 910 | { |
912 | return i18n("Photo"); | 911 | return i18n("Photo"); |
913 | } | 912 | } |
914 | 913 | ||
915 | 914 | ||
916 | void Addressee::setSound( const Sound &sound ) | 915 | void Addressee::setSound( const Sound &sound ) |
917 | { | 916 | { |
918 | if ( sound == mData->sound ) return; | 917 | if ( sound == mData->sound ) return; |
919 | detach(); | 918 | detach(); |
920 | mData->empty = false; | 919 | mData->empty = false; |
921 | mData->sound = sound; | 920 | mData->sound = sound; |
922 | } | 921 | } |
923 | 922 | ||
924 | Sound Addressee::sound() const | 923 | Sound Addressee::sound() const |
925 | { | 924 | { |
926 | return mData->sound; | 925 | return mData->sound; |
927 | } | 926 | } |
928 | 927 | ||
929 | QString Addressee::soundLabel() | 928 | QString Addressee::soundLabel() |
930 | { | 929 | { |
931 | return i18n("Sound"); | 930 | return i18n("Sound"); |
932 | } | 931 | } |
933 | 932 | ||
934 | 933 | ||
935 | void Addressee::setAgent( const Agent &agent ) | 934 | void Addressee::setAgent( const Agent &agent ) |
936 | { | 935 | { |
937 | if ( agent == mData->agent ) return; | 936 | if ( agent == mData->agent ) return; |
938 | detach(); | 937 | detach(); |
939 | mData->empty = false; | 938 | mData->empty = false; |
940 | mData->agent = agent; | 939 | mData->agent = agent; |
941 | } | 940 | } |
942 | 941 | ||
943 | Agent Addressee::agent() const | 942 | Agent Addressee::agent() const |
944 | { | 943 | { |
945 | return mData->agent; | 944 | return mData->agent; |
946 | } | 945 | } |
947 | 946 | ||
948 | QString Addressee::agentLabel() | 947 | QString Addressee::agentLabel() |
949 | { | 948 | { |
950 | return i18n("Agent"); | 949 | return i18n("Agent"); |
951 | } | 950 | } |
952 | 951 | ||
953 | 952 | ||
954 | 953 | ||
955 | void Addressee::setNameFromString( const QString &str ) | 954 | void Addressee::setNameFromString( const QString &str ) |
956 | { | 955 | { |
957 | setFormattedName( str ); | 956 | setFormattedName( str ); |
958 | setName( str ); | 957 | setName( str ); |
959 | 958 | ||
960 | static bool first = true; | 959 | static bool first = true; |
961 | static QStringList titles; | 960 | static QStringList titles; |
962 | static QStringList suffixes; | 961 | static QStringList suffixes; |
963 | static QStringList prefixes; | 962 | static QStringList prefixes; |
964 | 963 | ||
965 | if ( first ) { | 964 | if ( first ) { |
966 | first = false; | 965 | first = false; |
967 | titles += i18n( "Dr." ); | 966 | titles += i18n( "Dr." ); |
968 | titles += i18n( "Miss" ); | 967 | titles += i18n( "Miss" ); |
969 | titles += i18n( "Mr." ); | 968 | titles += i18n( "Mr." ); |
970 | titles += i18n( "Mrs." ); | 969 | titles += i18n( "Mrs." ); |
971 | titles += i18n( "Ms." ); | 970 | titles += i18n( "Ms." ); |
972 | titles += i18n( "Prof." ); | 971 | titles += i18n( "Prof." ); |
973 | 972 | ||
974 | suffixes += i18n( "I" ); | 973 | suffixes += i18n( "I" ); |
975 | suffixes += i18n( "II" ); | 974 | suffixes += i18n( "II" ); |
976 | suffixes += i18n( "III" ); | 975 | suffixes += i18n( "III" ); |
977 | suffixes += i18n( "Jr." ); | 976 | suffixes += i18n( "Jr." ); |
978 | suffixes += i18n( "Sr." ); | 977 | suffixes += i18n( "Sr." ); |
979 | 978 | ||
980 | prefixes += "van"; | 979 | prefixes += "van"; |
981 | prefixes += "von"; | 980 | prefixes += "von"; |
982 | prefixes += "de"; | 981 | prefixes += "de"; |
983 | 982 | ||
984 | KConfig config( locateLocal( "config", "kabcrc") ); | 983 | KConfig config( locateLocal( "config", "kabcrc") ); |
985 | config.setGroup( "General" ); | 984 | config.setGroup( "General" ); |
986 | titles += config.readListEntry( "Prefixes" ); | 985 | titles += config.readListEntry( "Prefixes" ); |
987 | titles.remove( "" ); | 986 | titles.remove( "" ); |
988 | prefixes += config.readListEntry( "Inclusions" ); | 987 | prefixes += config.readListEntry( "Inclusions" ); |
989 | prefixes.remove( "" ); | 988 | prefixes.remove( "" ); |
990 | suffixes += config.readListEntry( "Suffixes" ); | 989 | suffixes += config.readListEntry( "Suffixes" ); |
991 | suffixes.remove( "" ); | 990 | suffixes.remove( "" ); |
992 | } | 991 | } |
993 | 992 | ||
994 | // clear all name parts | 993 | // clear all name parts |
995 | setPrefix( "" ); | 994 | setPrefix( "" ); |
996 | setGivenName( "" ); | 995 | setGivenName( "" ); |
997 | setAdditionalName( "" ); | 996 | setAdditionalName( "" ); |
998 | setFamilyName( "" ); | 997 | setFamilyName( "" ); |
999 | setSuffix( "" ); | 998 | setSuffix( "" ); |
1000 | 999 | ||
1001 | if ( str.isEmpty() ) | 1000 | if ( str.isEmpty() ) |
1002 | return; | 1001 | return; |
1003 | 1002 | ||
1004 | int i = str.find(','); | 1003 | int i = str.find(','); |
1005 | if( i < 0 ) { | 1004 | if( i < 0 ) { |
1006 | QStringList parts = QStringList::split( " ", str ); | 1005 | QStringList parts = QStringList::split( " ", str ); |
1007 | int leftOffset = 0; | 1006 | int leftOffset = 0; |
1008 | int rightOffset = parts.count() - 1; | 1007 | int rightOffset = parts.count() - 1; |
1009 | 1008 | ||
1010 | QString suffix; | 1009 | QString suffix; |
1011 | while ( rightOffset >= 0 ) { | 1010 | while ( rightOffset >= 0 ) { |
1012 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1011 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1013 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1012 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1014 | rightOffset--; | 1013 | rightOffset--; |
1015 | } else | 1014 | } else |
1016 | break; | 1015 | break; |
1017 | } | 1016 | } |
1018 | setSuffix( suffix ); | 1017 | setSuffix( suffix ); |
1019 | 1018 | ||
1020 | if ( rightOffset < 0 ) | 1019 | if ( rightOffset < 0 ) |
1021 | return; | 1020 | return; |
1022 | 1021 | ||
1023 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1022 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1024 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1023 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1025 | rightOffset--; | 1024 | rightOffset--; |
1026 | } else | 1025 | } else |
1027 | setFamilyName( parts[ rightOffset ] ); | 1026 | setFamilyName( parts[ rightOffset ] ); |
1028 | 1027 | ||
1029 | QString prefix; | 1028 | QString prefix; |
1030 | while ( leftOffset < rightOffset ) { | 1029 | while ( leftOffset < rightOffset ) { |
1031 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1030 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1032 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1031 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1033 | leftOffset++; | 1032 | leftOffset++; |
1034 | } else | 1033 | } else |
1035 | break; | 1034 | break; |
1036 | } | 1035 | } |
1037 | setPrefix( prefix ); | 1036 | setPrefix( prefix ); |
1038 | 1037 | ||
1039 | if ( leftOffset < rightOffset ) { | 1038 | if ( leftOffset < rightOffset ) { |
1040 | setGivenName( parts[ leftOffset ] ); | 1039 | setGivenName( parts[ leftOffset ] ); |
1041 | leftOffset++; | 1040 | leftOffset++; |
1042 | } | 1041 | } |
1043 | 1042 | ||
1044 | QString additionalName; | 1043 | QString additionalName; |
1045 | while ( leftOffset < rightOffset ) { | 1044 | while ( leftOffset < rightOffset ) { |
1046 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1045 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1047 | leftOffset++; | 1046 | leftOffset++; |
1048 | } | 1047 | } |
1049 | setAdditionalName( additionalName ); | 1048 | setAdditionalName( additionalName ); |
1050 | } else { | 1049 | } else { |
1051 | QString part1 = str.left( i ); | 1050 | QString part1 = str.left( i ); |
1052 | QString part2 = str.mid( i + 1 ); | 1051 | QString part2 = str.mid( i + 1 ); |
1053 | 1052 | ||
1054 | QStringList parts = QStringList::split( " ", part1 ); | 1053 | QStringList parts = QStringList::split( " ", part1 ); |
1055 | int leftOffset = 0; | 1054 | int leftOffset = 0; |
1056 | int rightOffset = parts.count() - 1; | 1055 | int rightOffset = parts.count() - 1; |
1057 | 1056 | ||
1058 | QString suffix; | 1057 | QString suffix; |
1059 | while ( rightOffset >= 0 ) { | 1058 | while ( rightOffset >= 0 ) { |
1060 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1059 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1061 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1060 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1062 | rightOffset--; | 1061 | rightOffset--; |
1063 | } else | 1062 | } else |
1064 | break; | 1063 | break; |
1065 | } | 1064 | } |
1066 | setSuffix( suffix ); | 1065 | setSuffix( suffix ); |
1067 | 1066 | ||
1068 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1067 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1069 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1068 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1070 | rightOffset--; | 1069 | rightOffset--; |
1071 | } else | 1070 | } else |
1072 | setFamilyName( parts[ rightOffset ] ); | 1071 | setFamilyName( parts[ rightOffset ] ); |
1073 | 1072 | ||
1074 | QString prefix; | 1073 | QString prefix; |
1075 | while ( leftOffset < rightOffset ) { | 1074 | while ( leftOffset < rightOffset ) { |
1076 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1075 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1077 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1076 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1078 | leftOffset++; | 1077 | leftOffset++; |
1079 | } else | 1078 | } else |
1080 | break; | 1079 | break; |
1081 | } | 1080 | } |
1082 | 1081 | ||
1083 | parts = QStringList::split( " ", part2 ); | 1082 | parts = QStringList::split( " ", part2 ); |
1084 | 1083 | ||
1085 | leftOffset = 0; | 1084 | leftOffset = 0; |
1086 | rightOffset = parts.count(); | 1085 | rightOffset = parts.count(); |
1087 | 1086 | ||
1088 | while ( leftOffset < rightOffset ) { | 1087 | while ( leftOffset < rightOffset ) { |
1089 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1088 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1090 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1089 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1091 | leftOffset++; | 1090 | leftOffset++; |
1092 | } else | 1091 | } else |
1093 | break; | 1092 | break; |
1094 | } | 1093 | } |
1095 | setPrefix( prefix ); | 1094 | setPrefix( prefix ); |
1096 | 1095 | ||
1097 | if ( leftOffset < rightOffset ) { | 1096 | if ( leftOffset < rightOffset ) { |
1098 | setGivenName( parts[ leftOffset ] ); | 1097 | setGivenName( parts[ leftOffset ] ); |
1099 | leftOffset++; | 1098 | leftOffset++; |
1100 | } | 1099 | } |
1101 | 1100 | ||
1102 | QString additionalName; | 1101 | QString additionalName; |
1103 | while ( leftOffset < rightOffset ) { | 1102 | while ( leftOffset < rightOffset ) { |
1104 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1103 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1105 | leftOffset++; | 1104 | leftOffset++; |
1106 | } | 1105 | } |
1107 | setAdditionalName( additionalName ); | 1106 | setAdditionalName( additionalName ); |
1108 | } | 1107 | } |
1109 | } | 1108 | } |
1110 | 1109 | ||
1111 | QString Addressee::realName() const | 1110 | QString Addressee::realName() const |
1112 | { | 1111 | { |
1113 | if ( !formattedName().isEmpty() ) | 1112 | if ( !formattedName().isEmpty() ) |
1114 | return formattedName(); | 1113 | return formattedName(); |
1115 | 1114 | ||
1116 | QString n = assembledName(); | 1115 | QString n = assembledName(); |
1117 | 1116 | ||
1118 | if ( n.isEmpty() ) | 1117 | if ( n.isEmpty() ) |
1119 | n = name(); | 1118 | n = name(); |
1120 | 1119 | ||
1121 | return n; | 1120 | return n; |
1122 | } | 1121 | } |
1123 | 1122 | ||
1124 | QString Addressee::assembledName() const | 1123 | QString Addressee::assembledName() const |
1125 | { | 1124 | { |
1126 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + | 1125 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + |
1127 | familyName() + " " + suffix(); | 1126 | familyName() + " " + suffix(); |
1128 | 1127 | ||
1129 | return name.simplifyWhiteSpace(); | 1128 | return name.simplifyWhiteSpace(); |
1130 | } | 1129 | } |
1131 | 1130 | ||
1132 | QString Addressee::fullEmail( const QString &email ) const | 1131 | QString Addressee::fullEmail( const QString &email ) const |
1133 | { | 1132 | { |
1134 | QString e; | 1133 | QString e; |
1135 | if ( email.isNull() ) { | 1134 | if ( email.isNull() ) { |
1136 | e = preferredEmail(); | 1135 | e = preferredEmail(); |
1137 | } else { | 1136 | } else { |
1138 | e = email; | 1137 | e = email; |
1139 | } | 1138 | } |
1140 | if ( e.isEmpty() ) return QString::null; | 1139 | if ( e.isEmpty() ) return QString::null; |
1141 | 1140 | ||
1142 | QString text; | 1141 | QString text; |
1143 | if ( realName().isEmpty() ) | 1142 | if ( realName().isEmpty() ) |
1144 | text = e; | 1143 | text = e; |
1145 | else | 1144 | else |
1146 | text = assembledName() + " <" + e + ">"; | 1145 | text = assembledName() + " <" + e + ">"; |
1147 | 1146 | ||
1148 | return text; | 1147 | return text; |
1149 | } | 1148 | } |
1150 | 1149 | ||
1151 | void Addressee::insertEmail( const QString &email, bool preferred ) | 1150 | void Addressee::insertEmail( const QString &email, bool preferred ) |
1152 | { | 1151 | { |
1153 | detach(); | 1152 | detach(); |
1154 | 1153 | ||
1155 | QStringList::Iterator it = mData->emails.find( email ); | 1154 | QStringList::Iterator it = mData->emails.find( email ); |
1156 | 1155 | ||
1157 | if ( it != mData->emails.end() ) { | 1156 | if ( it != mData->emails.end() ) { |
1158 | if ( !preferred || it == mData->emails.begin() ) return; | 1157 | if ( !preferred || it == mData->emails.begin() ) return; |
1159 | mData->emails.remove( it ); | 1158 | mData->emails.remove( it ); |
1160 | mData->emails.prepend( email ); | 1159 | mData->emails.prepend( email ); |
1161 | } else { | 1160 | } else { |
1162 | if ( preferred ) { | 1161 | if ( preferred ) { |
1163 | mData->emails.prepend( email ); | 1162 | mData->emails.prepend( email ); |
1164 | } else { | 1163 | } else { |
1165 | mData->emails.append( email ); | 1164 | mData->emails.append( email ); |
1166 | } | 1165 | } |
1167 | } | 1166 | } |
1168 | } | 1167 | } |
1169 | 1168 | ||
1170 | void Addressee::removeEmail( const QString &email ) | 1169 | void Addressee::removeEmail( const QString &email ) |
1171 | { | 1170 | { |
1172 | detach(); | 1171 | detach(); |
1173 | 1172 | ||
1174 | QStringList::Iterator it = mData->emails.find( email ); | 1173 | QStringList::Iterator it = mData->emails.find( email ); |
1175 | if ( it == mData->emails.end() ) return; | 1174 | if ( it == mData->emails.end() ) return; |
1176 | 1175 | ||
1177 | mData->emails.remove( it ); | 1176 | mData->emails.remove( it ); |
1178 | } | 1177 | } |
1179 | 1178 | ||
1180 | QString Addressee::preferredEmail() const | 1179 | QString Addressee::preferredEmail() const |
1181 | { | 1180 | { |
1182 | if ( mData->emails.count() == 0 ) return QString::null; | 1181 | if ( mData->emails.count() == 0 ) return QString::null; |
1183 | else return mData->emails.first(); | 1182 | else return mData->emails.first(); |
1184 | } | 1183 | } |
1185 | 1184 | ||
1186 | QStringList Addressee::emails() const | 1185 | QStringList Addressee::emails() const |
1187 | { | 1186 | { |
1188 | return mData->emails; | 1187 | return mData->emails; |
1189 | } | 1188 | } |
1190 | void Addressee::setEmails( const QStringList& emails ) { | 1189 | void Addressee::setEmails( const QStringList& emails ) { |
1191 | detach(); | 1190 | detach(); |
1192 | mData->emails = emails; | 1191 | mData->emails = emails; |
1193 | } | 1192 | } |
1194 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) | 1193 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) |
1195 | { | 1194 | { |
1196 | detach(); | 1195 | detach(); |
1197 | mData->empty = false; | 1196 | mData->empty = false; |
1198 | 1197 | ||
1199 | PhoneNumber::List::Iterator it; | 1198 | PhoneNumber::List::Iterator it; |
1200 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1199 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1201 | if ( (*it).id() == phoneNumber.id() ) { | 1200 | if ( (*it).id() == phoneNumber.id() ) { |
1202 | *it = phoneNumber; | 1201 | *it = phoneNumber; |
1203 | return; | 1202 | return; |
1204 | } | 1203 | } |
1205 | } | 1204 | } |
1206 | mData->phoneNumbers.append( phoneNumber ); | 1205 | mData->phoneNumbers.append( phoneNumber ); |
1207 | } | 1206 | } |
1208 | 1207 | ||
1209 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) | 1208 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) |
1210 | { | 1209 | { |
1211 | detach(); | 1210 | detach(); |
1212 | 1211 | ||
1213 | PhoneNumber::List::Iterator it; | 1212 | PhoneNumber::List::Iterator it; |
1214 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1213 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1215 | if ( (*it).id() == phoneNumber.id() ) { | 1214 | if ( (*it).id() == phoneNumber.id() ) { |
1216 | mData->phoneNumbers.remove( it ); | 1215 | mData->phoneNumbers.remove( it ); |
1217 | return; | 1216 | return; |
1218 | } | 1217 | } |
1219 | } | 1218 | } |
1220 | } | 1219 | } |
1221 | 1220 | ||
1222 | PhoneNumber Addressee::phoneNumber( int type ) const | 1221 | PhoneNumber Addressee::phoneNumber( int type ) const |
1223 | { | 1222 | { |
1224 | PhoneNumber phoneNumber( "", type ); | 1223 | PhoneNumber phoneNumber( "", type ); |
1225 | PhoneNumber::List::ConstIterator it; | 1224 | PhoneNumber::List::ConstIterator it; |
1226 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1225 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1227 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1226 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1228 | if ( (*it).type() & PhoneNumber::Pref ) | 1227 | if ( (*it).type() & PhoneNumber::Pref ) |
1229 | return (*it); | 1228 | return (*it); |
1230 | else if ( phoneNumber.number().isEmpty() ) | 1229 | else if ( phoneNumber.number().isEmpty() ) |
1231 | phoneNumber = (*it); | 1230 | phoneNumber = (*it); |
1232 | } | 1231 | } |
1233 | } | 1232 | } |
1234 | 1233 | ||
1235 | return phoneNumber; | 1234 | return phoneNumber; |
1236 | } | 1235 | } |
1237 | 1236 | ||
1238 | PhoneNumber::List Addressee::phoneNumbers() const | 1237 | PhoneNumber::List Addressee::phoneNumbers() const |
1239 | { | 1238 | { |
1240 | return mData->phoneNumbers; | 1239 | return mData->phoneNumbers; |
1241 | } | 1240 | } |
1242 | 1241 | ||
1243 | PhoneNumber::List Addressee::phoneNumbers( int type ) const | 1242 | PhoneNumber::List Addressee::phoneNumbers( int type ) const |
1244 | { | 1243 | { |
1245 | PhoneNumber::List list; | 1244 | PhoneNumber::List list; |
1246 | 1245 | ||
1247 | PhoneNumber::List::ConstIterator it; | 1246 | PhoneNumber::List::ConstIterator it; |
1248 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1247 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1249 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1248 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1250 | list.append( *it ); | 1249 | list.append( *it ); |
1251 | } | 1250 | } |
1252 | } | 1251 | } |
1253 | return list; | 1252 | return list; |
1254 | } | 1253 | } |
1255 | 1254 | ||
1256 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const | 1255 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const |
1257 | { | 1256 | { |
1258 | PhoneNumber::List::ConstIterator it; | 1257 | PhoneNumber::List::ConstIterator it; |
1259 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1258 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1260 | if ( (*it).id() == id ) { | 1259 | if ( (*it).id() == id ) { |
1261 | return *it; | 1260 | return *it; |
1262 | } | 1261 | } |
1263 | } | 1262 | } |
1264 | return PhoneNumber(); | 1263 | return PhoneNumber(); |
1265 | } | 1264 | } |
1266 | 1265 | ||
1267 | void Addressee::insertKey( const Key &key ) | 1266 | void Addressee::insertKey( const Key &key ) |
1268 | { | 1267 | { |
1269 | detach(); | 1268 | detach(); |
1270 | mData->empty = false; | 1269 | mData->empty = false; |
1271 | 1270 | ||
1272 | Key::List::Iterator it; | 1271 | Key::List::Iterator it; |
1273 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1272 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1274 | if ( (*it).id() == key.id() ) { | 1273 | if ( (*it).id() == key.id() ) { |
1275 | *it = key; | 1274 | *it = key; |
1276 | return; | 1275 | return; |
1277 | } | 1276 | } |
1278 | } | 1277 | } |
1279 | mData->keys.append( key ); | 1278 | mData->keys.append( key ); |
1280 | } | 1279 | } |
1281 | 1280 | ||
1282 | void Addressee::removeKey( const Key &key ) | 1281 | void Addressee::removeKey( const Key &key ) |
1283 | { | 1282 | { |
1284 | detach(); | 1283 | detach(); |
1285 | 1284 | ||
1286 | Key::List::Iterator it; | 1285 | Key::List::Iterator it; |
1287 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1286 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1288 | if ( (*it).id() == key.id() ) { | 1287 | if ( (*it).id() == key.id() ) { |
1289 | mData->keys.remove( key ); | 1288 | mData->keys.remove( key ); |
1290 | return; | 1289 | return; |
1291 | } | 1290 | } |
1292 | } | 1291 | } |
1293 | } | 1292 | } |
1294 | 1293 | ||
1295 | Key Addressee::key( int type, QString customTypeString ) const | 1294 | Key Addressee::key( int type, QString customTypeString ) const |
1296 | { | 1295 | { |
1297 | Key::List::ConstIterator it; | 1296 | Key::List::ConstIterator it; |
1298 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1297 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1299 | if ( (*it).type() == type ) { | 1298 | if ( (*it).type() == type ) { |
1300 | if ( type == Key::Custom ) { | 1299 | if ( type == Key::Custom ) { |
1301 | if ( customTypeString.isEmpty() ) { | 1300 | if ( customTypeString.isEmpty() ) { |
1302 | return *it; | 1301 | return *it; |
1303 | } else { | 1302 | } else { |
1304 | if ( (*it).customTypeString() == customTypeString ) | 1303 | if ( (*it).customTypeString() == customTypeString ) |
1305 | return (*it); | 1304 | return (*it); |
1306 | } | 1305 | } |
1307 | } else { | 1306 | } else { |
1308 | return *it; | 1307 | return *it; |
1309 | } | 1308 | } |
1310 | } | 1309 | } |
1311 | } | 1310 | } |
1312 | return Key( QString(), type ); | 1311 | return Key( QString(), type ); |
1313 | } | 1312 | } |
1314 | void Addressee::setKeys( const Key::List& list ) { | 1313 | void Addressee::setKeys( const Key::List& list ) { |
1315 | detach(); | 1314 | detach(); |
1316 | mData->keys = list; | 1315 | mData->keys = list; |
1317 | } | 1316 | } |
1318 | 1317 | ||
1319 | Key::List Addressee::keys() const | 1318 | Key::List Addressee::keys() const |
1320 | { | 1319 | { |
1321 | return mData->keys; | 1320 | return mData->keys; |
1322 | } | 1321 | } |
1323 | 1322 | ||
1324 | Key::List Addressee::keys( int type, QString customTypeString ) const | 1323 | Key::List Addressee::keys( int type, QString customTypeString ) const |
1325 | { | 1324 | { |
1326 | Key::List list; | 1325 | Key::List list; |
1327 | 1326 | ||
1328 | Key::List::ConstIterator it; | 1327 | Key::List::ConstIterator it; |
1329 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1328 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1330 | if ( (*it).type() == type ) { | 1329 | if ( (*it).type() == type ) { |
1331 | if ( type == Key::Custom ) { | 1330 | if ( type == Key::Custom ) { |
1332 | if ( customTypeString.isEmpty() ) { | 1331 | if ( customTypeString.isEmpty() ) { |
1333 | list.append(*it); | 1332 | list.append(*it); |
1334 | } else { | 1333 | } else { |
1335 | if ( (*it).customTypeString() == customTypeString ) | 1334 | if ( (*it).customTypeString() == customTypeString ) |
1336 | list.append(*it); | 1335 | list.append(*it); |
1337 | } | 1336 | } |
1338 | } else { | 1337 | } else { |
1339 | list.append(*it); | 1338 | list.append(*it); |
1340 | } | 1339 | } |
1341 | } | 1340 | } |
1342 | } | 1341 | } |
1343 | return list; | 1342 | return list; |
1344 | } | 1343 | } |
1345 | 1344 | ||
1346 | Key Addressee::findKey( const QString &id ) const | 1345 | Key Addressee::findKey( const QString &id ) const |
1347 | { | 1346 | { |
1348 | Key::List::ConstIterator it; | 1347 | Key::List::ConstIterator it; |
1349 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1348 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1350 | if ( (*it).id() == id ) { | 1349 | if ( (*it).id() == id ) { |
1351 | return *it; | 1350 | return *it; |
1352 | } | 1351 | } |
1353 | } | 1352 | } |
1354 | return Key(); | 1353 | return Key(); |
1355 | } | 1354 | } |
1356 | 1355 | ||
1357 | QString Addressee::asString() const | 1356 | QString Addressee::asString() const |
1358 | { | 1357 | { |
1359 | return "Smith, agent Smith..."; | 1358 | return "Smith, agent Smith..."; |
1360 | } | 1359 | } |
1361 | 1360 | ||
1362 | void Addressee::dump() const | 1361 | void Addressee::dump() const |
1363 | { | 1362 | { |
1364 | return; | 1363 | return; |
1365 | kdDebug(5700) << "Addressee {" << endl; | 1364 | kdDebug(5700) << "Addressee {" << endl; |
1366 | 1365 | ||
1367 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; | 1366 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; |
1368 | 1367 | ||
1369 | kdDebug(5700) << " Name: '" << name() << "'" << endl; | 1368 | kdDebug(5700) << " Name: '" << name() << "'" << endl; |
1370 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; | 1369 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; |
1371 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; | 1370 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; |
1372 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; | 1371 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; |
1373 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; | 1372 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; |
1374 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; | 1373 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; |
1375 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; | 1374 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; |
1376 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; | 1375 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; |
1377 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; | 1376 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; |
1378 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; | 1377 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; |
1379 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; | 1378 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; |
1380 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; | 1379 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; |
1381 | kdDebug(5700) << " Title: '" << title() << "'" << endl; | 1380 | kdDebug(5700) << " Title: '" << title() << "'" << endl; |
1382 | kdDebug(5700) << " Role: '" << role() << "'" << endl; | 1381 | kdDebug(5700) << " Role: '" << role() << "'" << endl; |
1383 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; | 1382 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; |
1384 | kdDebug(5700) << " Note: '" << note() << "'" << endl; | 1383 | kdDebug(5700) << " Note: '" << note() << "'" << endl; |
1385 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; | 1384 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; |
1386 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; | 1385 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; |
1387 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; | 1386 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; |
1388 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; | 1387 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; |
1389 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; | 1388 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; |
1390 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; | 1389 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; |
1391 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; | 1390 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; |
1392 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; | 1391 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; |
1393 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; | 1392 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; |
1394 | 1393 | ||
1395 | kdDebug(5700) << " Emails {" << endl; | 1394 | kdDebug(5700) << " Emails {" << endl; |
1396 | QStringList e = emails(); | 1395 | QStringList e = emails(); |
1397 | QStringList::ConstIterator it; | 1396 | QStringList::ConstIterator it; |
1398 | for( it = e.begin(); it != e.end(); ++it ) { | 1397 | for( it = e.begin(); it != e.end(); ++it ) { |
1399 | kdDebug(5700) << " " << (*it) << endl; | 1398 | kdDebug(5700) << " " << (*it) << endl; |
1400 | } | 1399 | } |
1401 | kdDebug(5700) << " }" << endl; | 1400 | kdDebug(5700) << " }" << endl; |
1402 | 1401 | ||
1403 | kdDebug(5700) << " PhoneNumbers {" << endl; | 1402 | kdDebug(5700) << " PhoneNumbers {" << endl; |
1404 | PhoneNumber::List p = phoneNumbers(); | 1403 | PhoneNumber::List p = phoneNumbers(); |
1405 | PhoneNumber::List::ConstIterator it2; | 1404 | PhoneNumber::List::ConstIterator it2; |
1406 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { | 1405 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { |
1407 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; | 1406 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; |
1408 | } | 1407 | } |
1409 | kdDebug(5700) << " }" << endl; | 1408 | kdDebug(5700) << " }" << endl; |
1410 | 1409 | ||
1411 | Address::List a = addresses(); | 1410 | Address::List a = addresses(); |
1412 | Address::List::ConstIterator it3; | 1411 | Address::List::ConstIterator it3; |
1413 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { | 1412 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { |
1414 | (*it3).dump(); | 1413 | (*it3).dump(); |
1415 | } | 1414 | } |
1416 | 1415 | ||
1417 | kdDebug(5700) << " Keys {" << endl; | 1416 | kdDebug(5700) << " Keys {" << endl; |
1418 | Key::List k = keys(); | 1417 | Key::List k = keys(); |
1419 | Key::List::ConstIterator it4; | 1418 | Key::List::ConstIterator it4; |
1420 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { | 1419 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { |
1421 | kdDebug(5700) << " Type: " << int((*it4).type()) << | 1420 | kdDebug(5700) << " Type: " << int((*it4).type()) << |
1422 | " Key: " << (*it4).textData() << | 1421 | " Key: " << (*it4).textData() << |
1423 | " CustomString: " << (*it4).customTypeString() << endl; | 1422 | " CustomString: " << (*it4).customTypeString() << endl; |
1424 | } | 1423 | } |
1425 | kdDebug(5700) << " }" << endl; | 1424 | kdDebug(5700) << " }" << endl; |
1426 | 1425 | ||
1427 | kdDebug(5700) << "}" << endl; | 1426 | kdDebug(5700) << "}" << endl; |
1428 | } | 1427 | } |
1429 | 1428 | ||
1430 | 1429 | ||
1431 | void Addressee::insertAddress( const Address &address ) | 1430 | void Addressee::insertAddress( const Address &address ) |
1432 | { | 1431 | { |
1433 | detach(); | 1432 | detach(); |
1434 | mData->empty = false; | 1433 | mData->empty = false; |
1435 | 1434 | ||
1436 | Address::List::Iterator it; | 1435 | Address::List::Iterator it; |
1437 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1436 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1438 | if ( (*it).id() == address.id() ) { | 1437 | if ( (*it).id() == address.id() ) { |
1439 | *it = address; | 1438 | *it = address; |
1440 | return; | 1439 | return; |
1441 | } | 1440 | } |
1442 | } | 1441 | } |
1443 | mData->addresses.append( address ); | 1442 | mData->addresses.append( address ); |
1444 | } | 1443 | } |
1445 | 1444 | ||
1446 | void Addressee::removeAddress( const Address &address ) | 1445 | void Addressee::removeAddress( const Address &address ) |
1447 | { | 1446 | { |
1448 | detach(); | 1447 | detach(); |
1449 | 1448 | ||
1450 | Address::List::Iterator it; | 1449 | Address::List::Iterator it; |
1451 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1450 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1452 | if ( (*it).id() == address.id() ) { | 1451 | if ( (*it).id() == address.id() ) { |
1453 | mData->addresses.remove( it ); | 1452 | mData->addresses.remove( it ); |
1454 | return; | 1453 | return; |
1455 | } | 1454 | } |
1456 | } | 1455 | } |
1457 | } | 1456 | } |
1458 | 1457 | ||
1459 | Address Addressee::address( int type ) const | 1458 | Address Addressee::address( int type ) const |
1460 | { | 1459 | { |
1461 | Address address( type ); | 1460 | Address address( type ); |
1462 | Address::List::ConstIterator it; | 1461 | Address::List::ConstIterator it; |
1463 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1462 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1464 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1463 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1465 | if ( (*it).type() & Address::Pref ) | 1464 | if ( (*it).type() & Address::Pref ) |
1466 | return (*it); | 1465 | return (*it); |
1467 | else if ( address.isEmpty() ) | 1466 | else if ( address.isEmpty() ) |
1468 | address = (*it); | 1467 | address = (*it); |
1469 | } | 1468 | } |
1470 | } | 1469 | } |
1471 | 1470 | ||
1472 | return address; | 1471 | return address; |
1473 | } | 1472 | } |
1474 | 1473 | ||
1475 | Address::List Addressee::addresses() const | 1474 | Address::List Addressee::addresses() const |
1476 | { | 1475 | { |
1477 | return mData->addresses; | 1476 | return mData->addresses; |
1478 | } | 1477 | } |
1479 | 1478 | ||
1480 | Address::List Addressee::addresses( int type ) const | 1479 | Address::List Addressee::addresses( int type ) const |
1481 | { | 1480 | { |
1482 | Address::List list; | 1481 | Address::List list; |
1483 | 1482 | ||
1484 | Address::List::ConstIterator it; | 1483 | Address::List::ConstIterator it; |
1485 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1484 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1486 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1485 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1487 | list.append( *it ); | 1486 | list.append( *it ); |
1488 | } | 1487 | } |
1489 | } | 1488 | } |
1490 | 1489 | ||
1491 | return list; | 1490 | return list; |
1492 | } | 1491 | } |
1493 | 1492 | ||
1494 | Address Addressee::findAddress( const QString &id ) const | 1493 | Address Addressee::findAddress( const QString &id ) const |
1495 | { | 1494 | { |
1496 | Address::List::ConstIterator it; | 1495 | Address::List::ConstIterator it; |
1497 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1496 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1498 | if ( (*it).id() == id ) { | 1497 | if ( (*it).id() == id ) { |
1499 | return *it; | 1498 | return *it; |
1500 | } | 1499 | } |
1501 | } | 1500 | } |
1502 | return Address(); | 1501 | return Address(); |
1503 | } | 1502 | } |
1504 | 1503 | ||
1505 | void Addressee::insertCategory( const QString &c ) | 1504 | void Addressee::insertCategory( const QString &c ) |
1506 | { | 1505 | { |
1507 | detach(); | 1506 | detach(); |
1508 | mData->empty = false; | 1507 | mData->empty = false; |
1509 | 1508 | ||
1510 | if ( mData->categories.contains( c ) ) return; | 1509 | if ( mData->categories.contains( c ) ) return; |
1511 | 1510 | ||
1512 | mData->categories.append( c ); | 1511 | mData->categories.append( c ); |
1513 | } | 1512 | } |
1514 | 1513 | ||
1515 | void Addressee::removeCategory( const QString &c ) | 1514 | void Addressee::removeCategory( const QString &c ) |
1516 | { | 1515 | { |
1517 | detach(); | 1516 | detach(); |
1518 | 1517 | ||
1519 | QStringList::Iterator it = mData->categories.find( c ); | 1518 | QStringList::Iterator it = mData->categories.find( c ); |
1520 | if ( it == mData->categories.end() ) return; | 1519 | if ( it == mData->categories.end() ) return; |
1521 | 1520 | ||
1522 | mData->categories.remove( it ); | 1521 | mData->categories.remove( it ); |
1523 | } | 1522 | } |
1524 | 1523 | ||
1525 | bool Addressee::hasCategory( const QString &c ) const | 1524 | bool Addressee::hasCategory( const QString &c ) const |
1526 | { | 1525 | { |
1527 | return ( mData->categories.contains( c ) ); | 1526 | return ( mData->categories.contains( c ) ); |
1528 | } | 1527 | } |
1529 | 1528 | ||
1530 | void Addressee::setCategories( const QStringList &c ) | 1529 | void Addressee::setCategories( const QStringList &c ) |
1531 | { | 1530 | { |
1532 | detach(); | 1531 | detach(); |
1533 | mData->empty = false; | 1532 | mData->empty = false; |
1534 | 1533 | ||
1535 | mData->categories = c; | 1534 | mData->categories = c; |
1536 | } | 1535 | } |
1537 | 1536 | ||
1538 | QStringList Addressee::categories() const | 1537 | QStringList Addressee::categories() const |
1539 | { | 1538 | { |
1540 | return mData->categories; | 1539 | return mData->categories; |
1541 | } | 1540 | } |
1542 | 1541 | ||
1543 | void Addressee::insertCustom( const QString &app, const QString &name, | 1542 | void Addressee::insertCustom( const QString &app, const QString &name, |
1544 | const QString &value ) | 1543 | const QString &value ) |
1545 | { | 1544 | { |
1546 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; | 1545 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; |
1547 | 1546 | ||
1548 | detach(); | 1547 | detach(); |
1549 | mData->empty = false; | 1548 | mData->empty = false; |
1550 | 1549 | ||
1551 | QString qualifiedName = app + "-" + name + ":"; | 1550 | QString qualifiedName = app + "-" + name + ":"; |
1552 | 1551 | ||
1553 | QStringList::Iterator it; | 1552 | QStringList::Iterator it; |
1554 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1553 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1555 | if ( (*it).startsWith( qualifiedName ) ) { | 1554 | if ( (*it).startsWith( qualifiedName ) ) { |
1556 | (*it) = qualifiedName + value; | 1555 | (*it) = qualifiedName + value; |
1557 | return; | 1556 | return; |
1558 | } | 1557 | } |
1559 | } | 1558 | } |
1560 | mData->custom.append( qualifiedName + value ); | 1559 | mData->custom.append( qualifiedName + value ); |
1561 | } | 1560 | } |
1562 | 1561 | ||
1563 | void Addressee::removeCustom( const QString &app, const QString &name) | 1562 | void Addressee::removeCustom( const QString &app, const QString &name) |
1564 | { | 1563 | { |
1565 | detach(); | 1564 | detach(); |
1566 | 1565 | ||
1567 | QString qualifiedName = app + "-" + name + ":"; | 1566 | QString qualifiedName = app + "-" + name + ":"; |
1568 | 1567 | ||
1569 | QStringList::Iterator it; | 1568 | QStringList::Iterator it; |
1570 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1569 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1571 | if ( (*it).startsWith( qualifiedName ) ) { | 1570 | if ( (*it).startsWith( qualifiedName ) ) { |
1572 | mData->custom.remove( it ); | 1571 | mData->custom.remove( it ); |
1573 | return; | 1572 | return; |
1574 | } | 1573 | } |
1575 | } | 1574 | } |
1576 | } | 1575 | } |
1577 | 1576 | ||
1578 | QString Addressee::custom( const QString &app, const QString &name ) const | 1577 | QString Addressee::custom( const QString &app, const QString &name ) const |
1579 | { | 1578 | { |
1580 | QString qualifiedName = app + "-" + name + ":"; | 1579 | QString qualifiedName = app + "-" + name + ":"; |
1581 | QString value; | 1580 | QString value; |
1582 | 1581 | ||
1583 | QStringList::ConstIterator it; | 1582 | QStringList::ConstIterator it; |
1584 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1583 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1585 | if ( (*it).startsWith( qualifiedName ) ) { | 1584 | if ( (*it).startsWith( qualifiedName ) ) { |
1586 | value = (*it).mid( (*it).find( ":" ) + 1 ); | 1585 | value = (*it).mid( (*it).find( ":" ) + 1 ); |
1587 | break; | 1586 | break; |
1588 | } | 1587 | } |
1589 | } | 1588 | } |
1590 | 1589 | ||
1591 | return value; | 1590 | return value; |
1592 | } | 1591 | } |
1593 | 1592 | ||
1594 | void Addressee::setCustoms( const QStringList &l ) | 1593 | void Addressee::setCustoms( const QStringList &l ) |
1595 | { | 1594 | { |
1596 | detach(); | 1595 | detach(); |
1597 | mData->empty = false; | 1596 | mData->empty = false; |
1598 | 1597 | ||
1599 | mData->custom = l; | 1598 | mData->custom = l; |
1600 | } | 1599 | } |
1601 | 1600 | ||
1602 | QStringList Addressee::customs() const | 1601 | QStringList Addressee::customs() const |
1603 | { | 1602 | { |
1604 | return mData->custom; | 1603 | return mData->custom; |
1605 | } | 1604 | } |
1606 | 1605 | ||
1607 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, | 1606 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, |
1608 | QString &email) | 1607 | QString &email) |
1609 | { | 1608 | { |
1610 | int startPos, endPos, len; | 1609 | int startPos, endPos, len; |
1611 | QString partA, partB, result; | 1610 | QString partA, partB, result; |
1612 | char endCh = '>'; | 1611 | char endCh = '>'; |
1613 | 1612 | ||
1614 | startPos = rawEmail.find('<'); | 1613 | startPos = rawEmail.find('<'); |
1615 | if (startPos < 0) | 1614 | if (startPos < 0) |
1616 | { | 1615 | { |
1617 | startPos = rawEmail.find('('); | 1616 | startPos = rawEmail.find('('); |
1618 | endCh = ')'; | 1617 | endCh = ')'; |
1619 | } | 1618 | } |
1620 | if (startPos < 0) | 1619 | if (startPos < 0) |
1621 | { | 1620 | { |
1622 | // We couldn't find any separators, so we assume the whole string | 1621 | // We couldn't find any separators, so we assume the whole string |
1623 | // is the email address | 1622 | // is the email address |
1624 | email = rawEmail; | 1623 | email = rawEmail; |
1625 | fullName = ""; | 1624 | fullName = ""; |
1626 | } | 1625 | } |
1627 | else | 1626 | else |
1628 | { | 1627 | { |
1629 | // We have a start position, try to find an end | 1628 | // We have a start position, try to find an end |
1630 | endPos = rawEmail.find(endCh, startPos+1); | 1629 | endPos = rawEmail.find(endCh, startPos+1); |
1631 | 1630 | ||
1632 | if (endPos < 0) | 1631 | if (endPos < 0) |
1633 | { | 1632 | { |
1634 | // We couldn't find the end of the email address. We can only | 1633 | // We couldn't find the end of the email address. We can only |
1635 | // assume the entire string is the email address. | 1634 | // assume the entire string is the email address. |
1636 | email = rawEmail; | 1635 | email = rawEmail; |
1637 | fullName = ""; | 1636 | fullName = ""; |
1638 | } | 1637 | } |
1639 | else | 1638 | else |
1640 | { | 1639 | { |
1641 | // We have a start and end to the email address | 1640 | // We have a start and end to the email address |
1642 | 1641 | ||
1643 | // Grab the name part | 1642 | // Grab the name part |
1644 | fullName = rawEmail.left(startPos).stripWhiteSpace(); | 1643 | fullName = rawEmail.left(startPos).stripWhiteSpace(); |
1645 | 1644 | ||
1646 | // grab the email part | 1645 | // grab the email part |
1647 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); | 1646 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); |
1648 | 1647 | ||
1649 | // Check that we do not have any extra characters on the end of the | 1648 | // Check that we do not have any extra characters on the end of the |
1650 | // strings | 1649 | // strings |
1651 | len = fullName.length(); | 1650 | len = fullName.length(); |
1652 | if (fullName[0]=='"' && fullName[len-1]=='"') | 1651 | if (fullName[0]=='"' && fullName[len-1]=='"') |
1653 | fullName = fullName.mid(1, len-2); | 1652 | fullName = fullName.mid(1, len-2); |
1654 | else if (fullName[0]=='<' && fullName[len-1]=='>') | 1653 | else if (fullName[0]=='<' && fullName[len-1]=='>') |
1655 | fullName = fullName.mid(1, len-2); | 1654 | fullName = fullName.mid(1, len-2); |
1656 | else if (fullName[0]=='(' && fullName[len-1]==')') | 1655 | else if (fullName[0]=='(' && fullName[len-1]==')') |
1657 | fullName = fullName.mid(1, len-2); | 1656 | fullName = fullName.mid(1, len-2); |
1658 | } | 1657 | } |
1659 | } | 1658 | } |
1660 | } | 1659 | } |
1661 | 1660 | ||
1662 | void Addressee::setResource( Resource *resource ) | 1661 | void Addressee::setResource( Resource *resource ) |
1663 | { | 1662 | { |
1664 | detach(); | 1663 | detach(); |
1665 | mData->resource = resource; | 1664 | mData->resource = resource; |
1666 | } | 1665 | } |
1667 | 1666 | ||
1668 | Resource *Addressee::resource() const | 1667 | Resource *Addressee::resource() const |
1669 | { | 1668 | { |
1670 | return mData->resource; | 1669 | return mData->resource; |
1671 | } | 1670 | } |
1672 | 1671 | ||
1673 | //US | 1672 | //US |
1674 | QString Addressee::resourceLabel() | 1673 | QString Addressee::resourceLabel() |
1675 | { | 1674 | { |
1676 | return i18n("Resource"); | 1675 | return i18n("Resource"); |
1677 | } | 1676 | } |
1678 | 1677 | ||
1679 | void Addressee::setChanged( bool value ) | 1678 | void Addressee::setChanged( bool value ) |
1680 | { | 1679 | { |
1681 | detach(); | 1680 | detach(); |
1682 | mData->changed = value; | 1681 | mData->changed = value; |
1683 | } | 1682 | } |
1684 | 1683 | ||
1685 | bool Addressee::changed() const | 1684 | bool Addressee::changed() const |
1686 | { | 1685 | { |
1687 | return mData->changed; | 1686 | return mData->changed; |
1688 | } | 1687 | } |
1689 | 1688 | ||
1690 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) | 1689 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) |
1691 | { | 1690 | { |
1692 | if (!a.mData) return s; | 1691 | if (!a.mData) return s; |
1693 | 1692 | ||
1694 | s << a.uid(); | 1693 | s << a.uid(); |
1695 | 1694 | ||
1696 | s << a.mData->name; | 1695 | s << a.mData->name; |
1697 | s << a.mData->formattedName; | 1696 | s << a.mData->formattedName; |
1698 | s << a.mData->familyName; | 1697 | s << a.mData->familyName; |
1699 | s << a.mData->givenName; | 1698 | s << a.mData->givenName; |
1700 | s << a.mData->additionalName; | 1699 | s << a.mData->additionalName; |
1701 | s << a.mData->prefix; | 1700 | s << a.mData->prefix; |
1702 | s << a.mData->suffix; | 1701 | s << a.mData->suffix; |
1703 | s << a.mData->nickName; | 1702 | s << a.mData->nickName; |
1704 | s << a.mData->birthday; | 1703 | s << a.mData->birthday; |
1705 | s << a.mData->mailer; | 1704 | s << a.mData->mailer; |
1706 | s << a.mData->timeZone; | 1705 | s << a.mData->timeZone; |
1707 | s << a.mData->geo; | 1706 | s << a.mData->geo; |
1708 | s << a.mData->title; | 1707 | s << a.mData->title; |
1709 | s << a.mData->role; | 1708 | s << a.mData->role; |
1710 | s << a.mData->organization; | 1709 | s << a.mData->organization; |
1711 | s << a.mData->note; | 1710 | s << a.mData->note; |
1712 | s << a.mData->productId; | 1711 | s << a.mData->productId; |
1713 | s << a.mData->revision; | 1712 | s << a.mData->revision; |
1714 | s << a.mData->sortString; | 1713 | s << a.mData->sortString; |
1715 | s << a.mData->url; | 1714 | s << a.mData->url; |
1716 | s << a.mData->secrecy; | 1715 | s << a.mData->secrecy; |
1717 | s << a.mData->logo; | 1716 | s << a.mData->logo; |
1718 | s << a.mData->photo; | 1717 | s << a.mData->photo; |
1719 | s << a.mData->sound; | 1718 | s << a.mData->sound; |
1720 | s << a.mData->agent; | 1719 | s << a.mData->agent; |
1721 | s << a.mData->phoneNumbers; | 1720 | s << a.mData->phoneNumbers; |
1722 | s << a.mData->addresses; | 1721 | s << a.mData->addresses; |
1723 | s << a.mData->emails; | 1722 | s << a.mData->emails; |
1724 | s << a.mData->categories; | 1723 | s << a.mData->categories; |
1725 | s << a.mData->custom; | 1724 | s << a.mData->custom; |
1726 | s << a.mData->keys; | 1725 | s << a.mData->keys; |
1727 | return s; | 1726 | return s; |
1728 | } | 1727 | } |
1729 | 1728 | ||
1730 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) | 1729 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) |
1731 | { | 1730 | { |
1732 | if (!a.mData) return s; | 1731 | if (!a.mData) return s; |
1733 | 1732 | ||
1734 | s >> a.mData->uid; | 1733 | s >> a.mData->uid; |
1735 | 1734 | ||
1736 | s >> a.mData->name; | 1735 | s >> a.mData->name; |
1737 | s >> a.mData->formattedName; | 1736 | s >> a.mData->formattedName; |
1738 | s >> a.mData->familyName; | 1737 | s >> a.mData->familyName; |
1739 | s >> a.mData->givenName; | 1738 | s >> a.mData->givenName; |
1740 | s >> a.mData->additionalName; | 1739 | s >> a.mData->additionalName; |
1741 | s >> a.mData->prefix; | 1740 | s >> a.mData->prefix; |
1742 | s >> a.mData->suffix; | 1741 | s >> a.mData->suffix; |
1743 | s >> a.mData->nickName; | 1742 | s >> a.mData->nickName; |
1744 | s >> a.mData->birthday; | 1743 | s >> a.mData->birthday; |
1745 | s >> a.mData->mailer; | 1744 | s >> a.mData->mailer; |
1746 | s >> a.mData->timeZone; | 1745 | s >> a.mData->timeZone; |
1747 | s >> a.mData->geo; | 1746 | s >> a.mData->geo; |
1748 | s >> a.mData->title; | 1747 | s >> a.mData->title; |
1749 | s >> a.mData->role; | 1748 | s >> a.mData->role; |
1750 | s >> a.mData->organization; | 1749 | s >> a.mData->organization; |
1751 | s >> a.mData->note; | 1750 | s >> a.mData->note; |
1752 | s >> a.mData->productId; | 1751 | s >> a.mData->productId; |
1753 | s >> a.mData->revision; | 1752 | s >> a.mData->revision; |
1754 | s >> a.mData->sortString; | 1753 | s >> a.mData->sortString; |
1755 | s >> a.mData->url; | 1754 | s >> a.mData->url; |
1756 | s >> a.mData->secrecy; | 1755 | s >> a.mData->secrecy; |
1757 | s >> a.mData->logo; | 1756 | s >> a.mData->logo; |
1758 | s >> a.mData->photo; | 1757 | s >> a.mData->photo; |
1759 | s >> a.mData->sound; | 1758 | s >> a.mData->sound; |
1760 | s >> a.mData->agent; | 1759 | s >> a.mData->agent; |
1761 | s >> a.mData->phoneNumbers; | 1760 | s >> a.mData->phoneNumbers; |
1762 | s >> a.mData->addresses; | 1761 | s >> a.mData->addresses; |
1763 | s >> a.mData->emails; | 1762 | s >> a.mData->emails; |
1764 | s >> a.mData->categories; | 1763 | s >> a.mData->categories; |
1765 | s >> a.mData->custom; | 1764 | s >> a.mData->custom; |
1766 | s >> a.mData->keys; | 1765 | s >> a.mData->keys; |
1767 | 1766 | ||
1768 | a.mData->empty = false; | 1767 | a.mData->empty = false; |
1769 | 1768 | ||
1770 | return s; | 1769 | return s; |
1771 | } | 1770 | } |
1772 | 1771 | ||
1773 | bool matchBinaryPattern( int value, int pattern ) | 1772 | bool matchBinaryPattern( int value, int pattern ) |
1774 | { | 1773 | { |
1775 | /** | 1774 | /** |
1776 | We want to match all telephonnumbers/addresses which have the bits in the | 1775 | We want to match all telephonnumbers/addresses which have the bits in the |
1777 | pattern set. More are allowed. | 1776 | pattern set. More are allowed. |
1778 | if pattern == 0 we have a special handling, then we want only those with | 1777 | if pattern == 0 we have a special handling, then we want only those with |
1779 | exactly no bit set. | 1778 | exactly no bit set. |
1780 | */ | 1779 | */ |
1781 | if ( pattern == 0 ) | 1780 | if ( pattern == 0 ) |
1782 | return ( value == 0 ); | 1781 | return ( value == 0 ); |
1783 | else | 1782 | else |
1784 | return ( pattern == ( pattern & value ) ); | 1783 | return ( pattern == ( pattern & value ) ); |
1785 | } | 1784 | } |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 56f6af2..fa0c51f 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -507,2516 +507,2516 @@ void KABCore::setContactSelected( const QString &uid ) | |||
507 | if (mActionBeamVCard) | 507 | if (mActionBeamVCard) |
508 | mActionBeamVCard->setEnabled( selected ); | 508 | mActionBeamVCard->setEnabled( selected ); |
509 | 509 | ||
510 | mActionWhoAmI->setEnabled( selected ); | 510 | mActionWhoAmI->setEnabled( selected ); |
511 | mActionCategories->setEnabled( selected ); | 511 | mActionCategories->setEnabled( selected ); |
512 | } | 512 | } |
513 | 513 | ||
514 | void KABCore::sendMail() | 514 | void KABCore::sendMail() |
515 | { | 515 | { |
516 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 516 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
517 | } | 517 | } |
518 | 518 | ||
519 | void KABCore::sendMail( const QString& emaillist ) | 519 | void KABCore::sendMail( const QString& emaillist ) |
520 | { | 520 | { |
521 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 521 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
522 | if (emaillist.contains(",") > 0) | 522 | if (emaillist.contains(",") > 0) |
523 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 523 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
524 | else | 524 | else |
525 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 525 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
526 | } | 526 | } |
527 | 527 | ||
528 | 528 | ||
529 | 529 | ||
530 | void KABCore::mailVCard() | 530 | void KABCore::mailVCard() |
531 | { | 531 | { |
532 | QStringList uids = mViewManager->selectedUids(); | 532 | QStringList uids = mViewManager->selectedUids(); |
533 | if ( !uids.isEmpty() ) | 533 | if ( !uids.isEmpty() ) |
534 | mailVCard( uids ); | 534 | mailVCard( uids ); |
535 | } | 535 | } |
536 | 536 | ||
537 | void KABCore::mailVCard( const QStringList& uids ) | 537 | void KABCore::mailVCard( const QStringList& uids ) |
538 | { | 538 | { |
539 | QStringList urls; | 539 | QStringList urls; |
540 | 540 | ||
541 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 541 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
542 | 542 | ||
543 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 543 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
544 | 544 | ||
545 | 545 | ||
546 | 546 | ||
547 | QDir().mkdir( dirName, true ); | 547 | QDir().mkdir( dirName, true ); |
548 | 548 | ||
549 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 549 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
550 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 550 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
551 | 551 | ||
552 | if ( a.isEmpty() ) | 552 | if ( a.isEmpty() ) |
553 | continue; | 553 | continue; |
554 | 554 | ||
555 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 555 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
556 | 556 | ||
557 | QString fileName = dirName + "/" + name; | 557 | QString fileName = dirName + "/" + name; |
558 | 558 | ||
559 | QFile outFile(fileName); | 559 | QFile outFile(fileName); |
560 | 560 | ||
561 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 561 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
562 | KABC::VCardConverter converter; | 562 | KABC::VCardConverter converter; |
563 | QString vcard; | 563 | QString vcard; |
564 | 564 | ||
565 | converter.addresseeToVCard( a, vcard ); | 565 | converter.addresseeToVCard( a, vcard ); |
566 | 566 | ||
567 | QTextStream t( &outFile ); // use a text stream | 567 | QTextStream t( &outFile ); // use a text stream |
568 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 568 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
569 | t << vcard; | 569 | t << vcard; |
570 | 570 | ||
571 | outFile.close(); | 571 | outFile.close(); |
572 | 572 | ||
573 | urls.append( fileName ); | 573 | urls.append( fileName ); |
574 | } | 574 | } |
575 | } | 575 | } |
576 | 576 | ||
577 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 577 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
578 | 578 | ||
579 | 579 | ||
580 | /*US | 580 | /*US |
581 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 581 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
582 | QString::null, // subject | 582 | QString::null, // subject |
583 | QString::null, // body | 583 | QString::null, // body |
584 | QString::null, | 584 | QString::null, |
585 | urls ); // attachments | 585 | urls ); // attachments |
586 | */ | 586 | */ |
587 | 587 | ||
588 | } | 588 | } |
589 | 589 | ||
590 | /** | 590 | /** |
591 | Beams the "WhoAmI contact. | 591 | Beams the "WhoAmI contact. |
592 | */ | 592 | */ |
593 | void KABCore::beamMySelf() | 593 | void KABCore::beamMySelf() |
594 | { | 594 | { |
595 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 595 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
596 | if (!a.isEmpty()) | 596 | if (!a.isEmpty()) |
597 | { | 597 | { |
598 | QStringList uids; | 598 | QStringList uids; |
599 | uids << a.uid(); | 599 | uids << a.uid(); |
600 | 600 | ||
601 | beamVCard(uids); | 601 | beamVCard(uids); |
602 | } else { | 602 | } else { |
603 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 603 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
604 | 604 | ||
605 | 605 | ||
606 | } | 606 | } |
607 | } | 607 | } |
608 | 608 | ||
609 | void KABCore::beamVCard() | 609 | void KABCore::beamVCard() |
610 | { | 610 | { |
611 | QStringList uids = mViewManager->selectedUids(); | 611 | QStringList uids = mViewManager->selectedUids(); |
612 | if ( !uids.isEmpty() ) | 612 | if ( !uids.isEmpty() ) |
613 | beamVCard( uids ); | 613 | beamVCard( uids ); |
614 | } | 614 | } |
615 | 615 | ||
616 | 616 | ||
617 | void KABCore::beamVCard(const QStringList& uids) | 617 | void KABCore::beamVCard(const QStringList& uids) |
618 | { | 618 | { |
619 | /*US | 619 | /*US |
620 | QString beamFilename; | 620 | QString beamFilename; |
621 | Opie::OPimContact c; | 621 | Opie::OPimContact c; |
622 | if ( actionPersonal->isOn() ) { | 622 | if ( actionPersonal->isOn() ) { |
623 | beamFilename = addressbookPersonalVCardName(); | 623 | beamFilename = addressbookPersonalVCardName(); |
624 | if ( !QFile::exists( beamFilename ) ) | 624 | if ( !QFile::exists( beamFilename ) ) |
625 | return; // can't beam a non-existent file | 625 | return; // can't beam a non-existent file |
626 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 626 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
627 | beamFilename ); | 627 | beamFilename ); |
628 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 628 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
629 | Opie::OPimContactAccess::List allList = access->allRecords(); | 629 | Opie::OPimContactAccess::List allList = access->allRecords(); |
630 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first | 630 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first |
631 | c = *it; | 631 | c = *it; |
632 | 632 | ||
633 | delete access; | 633 | delete access; |
634 | } else { | 634 | } else { |
635 | unlink( beamfile ); // delete if exists | 635 | unlink( beamfile ); // delete if exists |
636 | mkdir("/tmp/obex/", 0755); | 636 | mkdir("/tmp/obex/", 0755); |
637 | c = m_abView -> currentEntry(); | 637 | c = m_abView -> currentEntry(); |
638 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 638 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
639 | beamfile ); | 639 | beamfile ); |
640 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 640 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
641 | access->add( c ); | 641 | access->add( c ); |
642 | access->save(); | 642 | access->save(); |
643 | delete access; | 643 | delete access; |
644 | 644 | ||
645 | beamFilename = beamfile; | 645 | beamFilename = beamfile; |
646 | } | 646 | } |
647 | 647 | ||
648 | owarn << "Beaming: " << beamFilename << oendl; | 648 | owarn << "Beaming: " << beamFilename << oendl; |
649 | */ | 649 | */ |
650 | 650 | ||
651 | #if 0 | 651 | #if 0 |
652 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 652 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
653 | 653 | ||
654 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); | 654 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); |
655 | 655 | ||
656 | QString name = "contact.vcf"; | 656 | QString name = "contact.vcf"; |
657 | 657 | ||
658 | QString fileName = dirName + "/" + name; | 658 | QString fileName = dirName + "/" + name; |
659 | #endif | 659 | #endif |
660 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory | 660 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory |
661 | // | 661 | // |
662 | QString fileName = "/tmp/kapibeamfile.vcf"; | 662 | QString fileName = "/tmp/kapibeamfile.vcf"; |
663 | 663 | ||
664 | 664 | ||
665 | //QDir().mkdir( dirName, true ); | 665 | //QDir().mkdir( dirName, true ); |
666 | 666 | ||
667 | 667 | ||
668 | KABC::VCardConverter converter; | 668 | KABC::VCardConverter converter; |
669 | QString description; | 669 | QString description; |
670 | QString datastream; | 670 | QString datastream; |
671 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 671 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
672 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 672 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
673 | 673 | ||
674 | if ( a.isEmpty() ) | 674 | if ( a.isEmpty() ) |
675 | continue; | 675 | continue; |
676 | 676 | ||
677 | if (description.isEmpty()) | 677 | if (description.isEmpty()) |
678 | description = a.formattedName(); | 678 | description = a.formattedName(); |
679 | 679 | ||
680 | QString vcard; | 680 | QString vcard; |
681 | converter.addresseeToVCard( a, vcard ); | 681 | converter.addresseeToVCard( a, vcard ); |
682 | int start = 0; | 682 | int start = 0; |
683 | int next; | 683 | int next; |
684 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 684 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
685 | int semi = vcard.find(";", next); | 685 | int semi = vcard.find(";", next); |
686 | int dopp = vcard.find(":", next); | 686 | int dopp = vcard.find(":", next); |
687 | int sep; | 687 | int sep; |
688 | if ( semi < dopp && semi >= 0 ) | 688 | if ( semi < dopp && semi >= 0 ) |
689 | sep = semi ; | 689 | sep = semi ; |
690 | else | 690 | else |
691 | sep = dopp; | 691 | sep = dopp; |
692 | datastream +=vcard.mid( start, next - start); | 692 | datastream +=vcard.mid( start, next - start); |
693 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 693 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
694 | start = sep; | 694 | start = sep; |
695 | } | 695 | } |
696 | datastream += vcard.mid( start,vcard.length() ); | 696 | datastream += vcard.mid( start,vcard.length() ); |
697 | } | 697 | } |
698 | #ifndef DESKTOP_VERSION | 698 | #ifndef DESKTOP_VERSION |
699 | QFile outFile(fileName); | 699 | QFile outFile(fileName); |
700 | if ( outFile.open(IO_WriteOnly) ) { | 700 | if ( outFile.open(IO_WriteOnly) ) { |
701 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 701 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
702 | QTextStream t( &outFile ); // use a text stream | 702 | QTextStream t( &outFile ); // use a text stream |
703 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 703 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
704 | t <<datastream; | 704 | t <<datastream; |
705 | outFile.close(); | 705 | outFile.close(); |
706 | Ir *ir = new Ir( this ); | 706 | Ir *ir = new Ir( this ); |
707 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 707 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
708 | ir->send( fileName, description, "text/x-vCard" ); | 708 | ir->send( fileName, description, "text/x-vCard" ); |
709 | } else { | 709 | } else { |
710 | qDebug("Error open temp beam file "); | 710 | qDebug("Error open temp beam file "); |
711 | return; | 711 | return; |
712 | } | 712 | } |
713 | #endif | 713 | #endif |
714 | 714 | ||
715 | } | 715 | } |
716 | 716 | ||
717 | void KABCore::beamDone( Ir *ir ) | 717 | void KABCore::beamDone( Ir *ir ) |
718 | { | 718 | { |
719 | #ifndef DESKTOP_VERSION | 719 | #ifndef DESKTOP_VERSION |
720 | delete ir; | 720 | delete ir; |
721 | #endif | 721 | #endif |
722 | } | 722 | } |
723 | 723 | ||
724 | 724 | ||
725 | void KABCore::browse( const QString& url ) | 725 | void KABCore::browse( const QString& url ) |
726 | { | 726 | { |
727 | #ifndef KAB_EMBEDDED | 727 | #ifndef KAB_EMBEDDED |
728 | kapp->invokeBrowser( url ); | 728 | kapp->invokeBrowser( url ); |
729 | #else //KAB_EMBEDDED | 729 | #else //KAB_EMBEDDED |
730 | qDebug("KABCore::browse must be fixed"); | 730 | qDebug("KABCore::browse must be fixed"); |
731 | #endif //KAB_EMBEDDED | 731 | #endif //KAB_EMBEDDED |
732 | } | 732 | } |
733 | 733 | ||
734 | void KABCore::selectAllContacts() | 734 | void KABCore::selectAllContacts() |
735 | { | 735 | { |
736 | mViewManager->setSelected( QString::null, true ); | 736 | mViewManager->setSelected( QString::null, true ); |
737 | } | 737 | } |
738 | 738 | ||
739 | void KABCore::deleteContacts() | 739 | void KABCore::deleteContacts() |
740 | { | 740 | { |
741 | QStringList uidList = mViewManager->selectedUids(); | 741 | QStringList uidList = mViewManager->selectedUids(); |
742 | deleteContacts( uidList ); | 742 | deleteContacts( uidList ); |
743 | } | 743 | } |
744 | 744 | ||
745 | void KABCore::deleteContacts( const QStringList &uids ) | 745 | void KABCore::deleteContacts( const QStringList &uids ) |
746 | { | 746 | { |
747 | if ( uids.count() > 0 ) { | 747 | if ( uids.count() > 0 ) { |
748 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 748 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
749 | UndoStack::instance()->push( command ); | 749 | UndoStack::instance()->push( command ); |
750 | RedoStack::instance()->clear(); | 750 | RedoStack::instance()->clear(); |
751 | 751 | ||
752 | // now if we deleted anything, refresh | 752 | // now if we deleted anything, refresh |
753 | setContactSelected( QString::null ); | 753 | setContactSelected( QString::null ); |
754 | setModified( true ); | 754 | setModified( true ); |
755 | } | 755 | } |
756 | } | 756 | } |
757 | 757 | ||
758 | void KABCore::copyContacts() | 758 | void KABCore::copyContacts() |
759 | { | 759 | { |
760 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 760 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
761 | 761 | ||
762 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 762 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
763 | 763 | ||
764 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 764 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
765 | 765 | ||
766 | QClipboard *cb = QApplication::clipboard(); | 766 | QClipboard *cb = QApplication::clipboard(); |
767 | cb->setText( clipText ); | 767 | cb->setText( clipText ); |
768 | } | 768 | } |
769 | 769 | ||
770 | void KABCore::cutContacts() | 770 | void KABCore::cutContacts() |
771 | { | 771 | { |
772 | QStringList uidList = mViewManager->selectedUids(); | 772 | QStringList uidList = mViewManager->selectedUids(); |
773 | 773 | ||
774 | //US if ( uidList.size() > 0 ) { | 774 | //US if ( uidList.size() > 0 ) { |
775 | if ( uidList.count() > 0 ) { | 775 | if ( uidList.count() > 0 ) { |
776 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 776 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
777 | UndoStack::instance()->push( command ); | 777 | UndoStack::instance()->push( command ); |
778 | RedoStack::instance()->clear(); | 778 | RedoStack::instance()->clear(); |
779 | 779 | ||
780 | setModified( true ); | 780 | setModified( true ); |
781 | } | 781 | } |
782 | } | 782 | } |
783 | 783 | ||
784 | void KABCore::pasteContacts() | 784 | void KABCore::pasteContacts() |
785 | { | 785 | { |
786 | QClipboard *cb = QApplication::clipboard(); | 786 | QClipboard *cb = QApplication::clipboard(); |
787 | 787 | ||
788 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 788 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
789 | 789 | ||
790 | pasteContacts( list ); | 790 | pasteContacts( list ); |
791 | } | 791 | } |
792 | 792 | ||
793 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 793 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
794 | { | 794 | { |
795 | KABC::Resource *resource = requestResource( this ); | 795 | KABC::Resource *resource = requestResource( this ); |
796 | KABC::Addressee::List::Iterator it; | 796 | KABC::Addressee::List::Iterator it; |
797 | for ( it = list.begin(); it != list.end(); ++it ) | 797 | for ( it = list.begin(); it != list.end(); ++it ) |
798 | (*it).setResource( resource ); | 798 | (*it).setResource( resource ); |
799 | 799 | ||
800 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 800 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
801 | UndoStack::instance()->push( command ); | 801 | UndoStack::instance()->push( command ); |
802 | RedoStack::instance()->clear(); | 802 | RedoStack::instance()->clear(); |
803 | 803 | ||
804 | setModified( true ); | 804 | setModified( true ); |
805 | } | 805 | } |
806 | 806 | ||
807 | void KABCore::setWhoAmI() | 807 | void KABCore::setWhoAmI() |
808 | { | 808 | { |
809 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 809 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
810 | 810 | ||
811 | if ( addrList.count() > 1 ) { | 811 | if ( addrList.count() > 1 ) { |
812 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 812 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
813 | return; | 813 | return; |
814 | } | 814 | } |
815 | 815 | ||
816 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 816 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
817 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 817 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
818 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 818 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
819 | } | 819 | } |
820 | 820 | ||
821 | void KABCore::setCategories() | 821 | void KABCore::setCategories() |
822 | { | 822 | { |
823 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 823 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
824 | if ( !dlg.exec() ) | 824 | if ( !dlg.exec() ) |
825 | return; | 825 | return; |
826 | 826 | ||
827 | bool merge = false; | 827 | bool merge = false; |
828 | QString msg = i18n( "Merge with existing categories?" ); | 828 | QString msg = i18n( "Merge with existing categories?" ); |
829 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 829 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
830 | merge = true; | 830 | merge = true; |
831 | 831 | ||
832 | QStringList categories = dlg.selectedCategories(); | 832 | QStringList categories = dlg.selectedCategories(); |
833 | 833 | ||
834 | QStringList uids = mViewManager->selectedUids(); | 834 | QStringList uids = mViewManager->selectedUids(); |
835 | QStringList::Iterator it; | 835 | QStringList::Iterator it; |
836 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 836 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
837 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 837 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
838 | if ( !addr.isEmpty() ) { | 838 | if ( !addr.isEmpty() ) { |
839 | if ( !merge ) | 839 | if ( !merge ) |
840 | addr.setCategories( categories ); | 840 | addr.setCategories( categories ); |
841 | else { | 841 | else { |
842 | QStringList addrCategories = addr.categories(); | 842 | QStringList addrCategories = addr.categories(); |
843 | QStringList::Iterator catIt; | 843 | QStringList::Iterator catIt; |
844 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 844 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
845 | if ( !addrCategories.contains( *catIt ) ) | 845 | if ( !addrCategories.contains( *catIt ) ) |
846 | addrCategories.append( *catIt ); | 846 | addrCategories.append( *catIt ); |
847 | } | 847 | } |
848 | addr.setCategories( addrCategories ); | 848 | addr.setCategories( addrCategories ); |
849 | } | 849 | } |
850 | 850 | ||
851 | mAddressBook->insertAddressee( addr ); | 851 | mAddressBook->insertAddressee( addr ); |
852 | } | 852 | } |
853 | } | 853 | } |
854 | 854 | ||
855 | if ( uids.count() > 0 ) | 855 | if ( uids.count() > 0 ) |
856 | setModified( true ); | 856 | setModified( true ); |
857 | } | 857 | } |
858 | 858 | ||
859 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 859 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
860 | { | 860 | { |
861 | mIncSearchWidget->setFields( fields ); | 861 | mIncSearchWidget->setFields( fields ); |
862 | } | 862 | } |
863 | 863 | ||
864 | void KABCore::incrementalSearch( const QString& text ) | 864 | void KABCore::incrementalSearch( const QString& text ) |
865 | { | 865 | { |
866 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); | 866 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); |
867 | } | 867 | } |
868 | 868 | ||
869 | void KABCore::setModified() | 869 | void KABCore::setModified() |
870 | { | 870 | { |
871 | setModified( true ); | 871 | setModified( true ); |
872 | } | 872 | } |
873 | 873 | ||
874 | void KABCore::setModifiedWOrefresh() | 874 | void KABCore::setModifiedWOrefresh() |
875 | { | 875 | { |
876 | // qDebug("KABCore::setModifiedWOrefresh() "); | 876 | // qDebug("KABCore::setModifiedWOrefresh() "); |
877 | mModified = true; | 877 | mModified = true; |
878 | mActionSave->setEnabled( mModified ); | 878 | mActionSave->setEnabled( mModified ); |
879 | #ifdef DESKTOP_VERSION | 879 | #ifdef DESKTOP_VERSION |
880 | mDetails->refreshView(); | 880 | mDetails->refreshView(); |
881 | #endif | 881 | #endif |
882 | 882 | ||
883 | } | 883 | } |
884 | void KABCore::setModified( bool modified ) | 884 | void KABCore::setModified( bool modified ) |
885 | { | 885 | { |
886 | mModified = modified; | 886 | mModified = modified; |
887 | mActionSave->setEnabled( mModified ); | 887 | mActionSave->setEnabled( mModified ); |
888 | 888 | ||
889 | if ( modified ) | 889 | if ( modified ) |
890 | mJumpButtonBar->recreateButtons(); | 890 | mJumpButtonBar->recreateButtons(); |
891 | 891 | ||
892 | mViewManager->refreshView(); | 892 | mViewManager->refreshView(); |
893 | mDetails->refreshView(); | 893 | mDetails->refreshView(); |
894 | 894 | ||
895 | } | 895 | } |
896 | 896 | ||
897 | bool KABCore::modified() const | 897 | bool KABCore::modified() const |
898 | { | 898 | { |
899 | return mModified; | 899 | return mModified; |
900 | } | 900 | } |
901 | 901 | ||
902 | void KABCore::contactModified( const KABC::Addressee &addr ) | 902 | void KABCore::contactModified( const KABC::Addressee &addr ) |
903 | { | 903 | { |
904 | 904 | ||
905 | Command *command = 0; | 905 | Command *command = 0; |
906 | QString uid; | 906 | QString uid; |
907 | 907 | ||
908 | // check if it exists already | 908 | // check if it exists already |
909 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 909 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
910 | if ( origAddr.isEmpty() ) | 910 | if ( origAddr.isEmpty() ) |
911 | command = new PwNewCommand( mAddressBook, addr ); | 911 | command = new PwNewCommand( mAddressBook, addr ); |
912 | else { | 912 | else { |
913 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 913 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
914 | uid = addr.uid(); | 914 | uid = addr.uid(); |
915 | } | 915 | } |
916 | 916 | ||
917 | UndoStack::instance()->push( command ); | 917 | UndoStack::instance()->push( command ); |
918 | RedoStack::instance()->clear(); | 918 | RedoStack::instance()->clear(); |
919 | 919 | ||
920 | setModified( true ); | 920 | setModified( true ); |
921 | } | 921 | } |
922 | 922 | ||
923 | void KABCore::newContact() | 923 | void KABCore::newContact() |
924 | { | 924 | { |
925 | 925 | ||
926 | 926 | ||
927 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 927 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
928 | 928 | ||
929 | QPtrList<KRES::Resource> kresResources; | 929 | QPtrList<KRES::Resource> kresResources; |
930 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 930 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
931 | KABC::Resource *resource; | 931 | KABC::Resource *resource; |
932 | while ( ( resource = it.current() ) != 0 ) { | 932 | while ( ( resource = it.current() ) != 0 ) { |
933 | ++it; | 933 | ++it; |
934 | if ( !resource->readOnly() ) { | 934 | if ( !resource->readOnly() ) { |
935 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 935 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
936 | if ( res ) | 936 | if ( res ) |
937 | kresResources.append( res ); | 937 | kresResources.append( res ); |
938 | } | 938 | } |
939 | } | 939 | } |
940 | 940 | ||
941 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 941 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
942 | resource = static_cast<KABC::Resource*>( res ); | 942 | resource = static_cast<KABC::Resource*>( res ); |
943 | 943 | ||
944 | if ( resource ) { | 944 | if ( resource ) { |
945 | KABC::Addressee addr; | 945 | KABC::Addressee addr; |
946 | addr.setResource( resource ); | 946 | addr.setResource( resource ); |
947 | mEditorDialog->setAddressee( addr ); | 947 | mEditorDialog->setAddressee( addr ); |
948 | KApplication::execDialog ( mEditorDialog ); | 948 | KApplication::execDialog ( mEditorDialog ); |
949 | 949 | ||
950 | } else | 950 | } else |
951 | return; | 951 | return; |
952 | 952 | ||
953 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 953 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
954 | 954 | ||
955 | 955 | ||
956 | } | 956 | } |
957 | 957 | ||
958 | void KABCore::addEmail( QString aStr ) | 958 | void KABCore::addEmail( QString aStr ) |
959 | { | 959 | { |
960 | #ifndef KAB_EMBEDDED | 960 | #ifndef KAB_EMBEDDED |
961 | QString fullName, email; | 961 | QString fullName, email; |
962 | 962 | ||
963 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 963 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
964 | 964 | ||
965 | // Try to lookup the addressee matching the email address | 965 | // Try to lookup the addressee matching the email address |
966 | bool found = false; | 966 | bool found = false; |
967 | QStringList emailList; | 967 | QStringList emailList; |
968 | KABC::AddressBook::Iterator it; | 968 | KABC::AddressBook::Iterator it; |
969 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 969 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
970 | emailList = (*it).emails(); | 970 | emailList = (*it).emails(); |
971 | if ( emailList.contains( email ) > 0 ) { | 971 | if ( emailList.contains( email ) > 0 ) { |
972 | found = true; | 972 | found = true; |
973 | (*it).setNameFromString( fullName ); | 973 | (*it).setNameFromString( fullName ); |
974 | editContact( (*it).uid() ); | 974 | editContact( (*it).uid() ); |
975 | } | 975 | } |
976 | } | 976 | } |
977 | 977 | ||
978 | if ( !found ) { | 978 | if ( !found ) { |
979 | KABC::Addressee addr; | 979 | KABC::Addressee addr; |
980 | addr.setNameFromString( fullName ); | 980 | addr.setNameFromString( fullName ); |
981 | addr.insertEmail( email, true ); | 981 | addr.insertEmail( email, true ); |
982 | 982 | ||
983 | mAddressBook->insertAddressee( addr ); | 983 | mAddressBook->insertAddressee( addr ); |
984 | mViewManager->refreshView( addr.uid() ); | 984 | mViewManager->refreshView( addr.uid() ); |
985 | editContact( addr.uid() ); | 985 | editContact( addr.uid() ); |
986 | } | 986 | } |
987 | #else //KAB_EMBEDDED | 987 | #else //KAB_EMBEDDED |
988 | qDebug("KABCore::addEmail finsih method"); | 988 | qDebug("KABCore::addEmail finsih method"); |
989 | #endif //KAB_EMBEDDED | 989 | #endif //KAB_EMBEDDED |
990 | } | 990 | } |
991 | 991 | ||
992 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 992 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
993 | { | 993 | { |
994 | mXXPortManager->importVCard( url, showPreview ); | 994 | mXXPortManager->importVCard( url, showPreview ); |
995 | } | 995 | } |
996 | void KABCore::importFromOL() | 996 | void KABCore::importFromOL() |
997 | { | 997 | { |
998 | #ifdef _WIN32_ | 998 | #ifdef _WIN32_ |
999 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 999 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
1000 | idgl->exec(); | 1000 | idgl->exec(); |
1001 | KABC::Addressee::List list = idgl->getAddressList(); | 1001 | KABC::Addressee::List list = idgl->getAddressList(); |
1002 | if ( list.count() > 0 ) { | 1002 | if ( list.count() > 0 ) { |
1003 | KABC::Addressee::List listNew; | 1003 | KABC::Addressee::List listNew; |
1004 | KABC::Addressee::List listExisting; | 1004 | KABC::Addressee::List listExisting; |
1005 | KABC::Addressee::List::Iterator it; | 1005 | KABC::Addressee::List::Iterator it; |
1006 | KABC::AddressBook::Iterator iter; | 1006 | KABC::AddressBook::Iterator iter; |
1007 | for ( it = list.begin(); it != list.end(); ++it ) { | 1007 | for ( it = list.begin(); it != list.end(); ++it ) { |
1008 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1008 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1009 | listNew.append( (*it) ); | 1009 | listNew.append( (*it) ); |
1010 | else | 1010 | else |
1011 | listExisting.append( (*it) ); | 1011 | listExisting.append( (*it) ); |
1012 | } | 1012 | } |
1013 | if ( listExisting.count() > 0 ) | 1013 | if ( listExisting.count() > 0 ) |
1014 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1014 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1015 | if ( listNew.count() > 0 ) { | 1015 | if ( listNew.count() > 0 ) { |
1016 | pasteWithNewUid = false; | 1016 | pasteWithNewUid = false; |
1017 | pasteContacts( listNew ); | 1017 | pasteContacts( listNew ); |
1018 | pasteWithNewUid = true; | 1018 | pasteWithNewUid = true; |
1019 | } | 1019 | } |
1020 | } | 1020 | } |
1021 | delete idgl; | 1021 | delete idgl; |
1022 | #endif | 1022 | #endif |
1023 | } | 1023 | } |
1024 | 1024 | ||
1025 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1025 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1026 | { | 1026 | { |
1027 | mXXPortManager->importVCard( vCard, showPreview ); | 1027 | mXXPortManager->importVCard( vCard, showPreview ); |
1028 | } | 1028 | } |
1029 | 1029 | ||
1030 | //US added a second method without defaultparameter | 1030 | //US added a second method without defaultparameter |
1031 | void KABCore::editContact2() { | 1031 | void KABCore::editContact2() { |
1032 | editContact( QString::null ); | 1032 | editContact( QString::null ); |
1033 | } | 1033 | } |
1034 | 1034 | ||
1035 | void KABCore::editContact( const QString &uid ) | 1035 | void KABCore::editContact( const QString &uid ) |
1036 | { | 1036 | { |
1037 | 1037 | ||
1038 | if ( mExtensionManager->isQuickEditVisible() ) | 1038 | if ( mExtensionManager->isQuickEditVisible() ) |
1039 | return; | 1039 | return; |
1040 | 1040 | ||
1041 | // First, locate the contact entry | 1041 | // First, locate the contact entry |
1042 | QString localUID = uid; | 1042 | QString localUID = uid; |
1043 | if ( localUID.isNull() ) { | 1043 | if ( localUID.isNull() ) { |
1044 | QStringList uidList = mViewManager->selectedUids(); | 1044 | QStringList uidList = mViewManager->selectedUids(); |
1045 | if ( uidList.count() > 0 ) | 1045 | if ( uidList.count() > 0 ) |
1046 | localUID = *( uidList.at( 0 ) ); | 1046 | localUID = *( uidList.at( 0 ) ); |
1047 | } | 1047 | } |
1048 | 1048 | ||
1049 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1049 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1050 | if ( !addr.isEmpty() ) { | 1050 | if ( !addr.isEmpty() ) { |
1051 | mEditorDialog->setAddressee( addr ); | 1051 | mEditorDialog->setAddressee( addr ); |
1052 | KApplication::execDialog ( mEditorDialog ); | 1052 | KApplication::execDialog ( mEditorDialog ); |
1053 | } | 1053 | } |
1054 | } | 1054 | } |
1055 | 1055 | ||
1056 | /** | 1056 | /** |
1057 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1057 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1058 | the method will try to find a selected addressee in the view. | 1058 | the method will try to find a selected addressee in the view. |
1059 | */ | 1059 | */ |
1060 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1060 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1061 | { | 1061 | { |
1062 | if ( mMultipleViewsAtOnce ) | 1062 | if ( mMultipleViewsAtOnce ) |
1063 | { | 1063 | { |
1064 | editContact( uid ); | 1064 | editContact( uid ); |
1065 | } | 1065 | } |
1066 | else | 1066 | else |
1067 | { | 1067 | { |
1068 | setDetailsVisible( true ); | 1068 | setDetailsVisible( true ); |
1069 | mActionDetails->setChecked(true); | 1069 | mActionDetails->setChecked(true); |
1070 | } | 1070 | } |
1071 | 1071 | ||
1072 | } | 1072 | } |
1073 | 1073 | ||
1074 | void KABCore::save() | 1074 | void KABCore::save() |
1075 | { | 1075 | { |
1076 | if (mBlockSaveFlag) | 1076 | if (mBlockSaveFlag) |
1077 | return; | 1077 | return; |
1078 | mBlockSaveFlag = true; | 1078 | mBlockSaveFlag = true; |
1079 | if ( !mModified ) | 1079 | if ( !mModified ) |
1080 | return; | 1080 | return; |
1081 | QString text = i18n( "There was an error while attempting to save\n the " | 1081 | QString text = i18n( "There was an error while attempting to save\n the " |
1082 | "address book. Please check that some \nother application is " | 1082 | "address book. Please check that some \nother application is " |
1083 | "not using it. " ); | 1083 | "not using it. " ); |
1084 | statusMessage(i18n("Saving addressbook ... ")); | 1084 | statusMessage(i18n("Saving addressbook ... ")); |
1085 | #ifndef KAB_EMBEDDED | 1085 | #ifndef KAB_EMBEDDED |
1086 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1086 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1087 | if ( !b || !b->save() ) { | 1087 | if ( !b || !b->save() ) { |
1088 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1088 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1089 | } | 1089 | } |
1090 | #else //KAB_EMBEDDED | 1090 | #else //KAB_EMBEDDED |
1091 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1091 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1092 | if ( !b || !b->save() ) { | 1092 | if ( !b || !b->save() ) { |
1093 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1093 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1094 | } | 1094 | } |
1095 | #endif //KAB_EMBEDDED | 1095 | #endif //KAB_EMBEDDED |
1096 | 1096 | ||
1097 | statusMessage(i18n("Addressbook saved!")); | 1097 | statusMessage(i18n("Addressbook saved!")); |
1098 | setModified( false ); | 1098 | setModified( false ); |
1099 | mBlockSaveFlag = false; | 1099 | mBlockSaveFlag = false; |
1100 | } | 1100 | } |
1101 | 1101 | ||
1102 | void KABCore::statusMessage(QString mess , int time ) | 1102 | void KABCore::statusMessage(QString mess , int time ) |
1103 | { | 1103 | { |
1104 | //topLevelWidget()->setCaption( mess ); | 1104 | //topLevelWidget()->setCaption( mess ); |
1105 | // pending setting timer to revome message | 1105 | // pending setting timer to revome message |
1106 | } | 1106 | } |
1107 | void KABCore::undo() | 1107 | void KABCore::undo() |
1108 | { | 1108 | { |
1109 | UndoStack::instance()->undo(); | 1109 | UndoStack::instance()->undo(); |
1110 | 1110 | ||
1111 | // Refresh the view | 1111 | // Refresh the view |
1112 | mViewManager->refreshView(); | 1112 | mViewManager->refreshView(); |
1113 | } | 1113 | } |
1114 | 1114 | ||
1115 | void KABCore::redo() | 1115 | void KABCore::redo() |
1116 | { | 1116 | { |
1117 | RedoStack::instance()->redo(); | 1117 | RedoStack::instance()->redo(); |
1118 | 1118 | ||
1119 | // Refresh the view | 1119 | // Refresh the view |
1120 | mViewManager->refreshView(); | 1120 | mViewManager->refreshView(); |
1121 | } | 1121 | } |
1122 | 1122 | ||
1123 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1123 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1124 | { | 1124 | { |
1125 | if (mMultipleViewsAtOnce) | 1125 | if (mMultipleViewsAtOnce) |
1126 | { | 1126 | { |
1127 | if ( visible ) | 1127 | if ( visible ) |
1128 | mJumpButtonBar->show(); | 1128 | mJumpButtonBar->show(); |
1129 | else | 1129 | else |
1130 | mJumpButtonBar->hide(); | 1130 | mJumpButtonBar->hide(); |
1131 | } | 1131 | } |
1132 | else | 1132 | else |
1133 | { | 1133 | { |
1134 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1134 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1135 | if (mViewManager->isVisible()) | 1135 | if (mViewManager->isVisible()) |
1136 | { | 1136 | { |
1137 | if ( visible ) | 1137 | if ( visible ) |
1138 | mJumpButtonBar->show(); | 1138 | mJumpButtonBar->show(); |
1139 | else | 1139 | else |
1140 | mJumpButtonBar->hide(); | 1140 | mJumpButtonBar->hide(); |
1141 | } | 1141 | } |
1142 | else | 1142 | else |
1143 | { | 1143 | { |
1144 | mJumpButtonBar->hide(); | 1144 | mJumpButtonBar->hide(); |
1145 | } | 1145 | } |
1146 | } | 1146 | } |
1147 | } | 1147 | } |
1148 | 1148 | ||
1149 | 1149 | ||
1150 | void KABCore::setDetailsToState() | 1150 | void KABCore::setDetailsToState() |
1151 | { | 1151 | { |
1152 | setDetailsVisible( mActionDetails->isChecked() ); | 1152 | setDetailsVisible( mActionDetails->isChecked() ); |
1153 | } | 1153 | } |
1154 | 1154 | ||
1155 | 1155 | ||
1156 | 1156 | ||
1157 | void KABCore::setDetailsVisible( bool visible ) | 1157 | void KABCore::setDetailsVisible( bool visible ) |
1158 | { | 1158 | { |
1159 | if (visible && mDetails->isHidden()) | 1159 | if (visible && mDetails->isHidden()) |
1160 | { | 1160 | { |
1161 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1161 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1162 | if ( addrList.count() > 0 ) | 1162 | if ( addrList.count() > 0 ) |
1163 | mDetails->setAddressee( addrList[ 0 ] ); | 1163 | mDetails->setAddressee( addrList[ 0 ] ); |
1164 | } | 1164 | } |
1165 | 1165 | ||
1166 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1166 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1167 | // the listview and the detailview. We do that by changing the splitbar size. | 1167 | // the listview and the detailview. We do that by changing the splitbar size. |
1168 | if (mMultipleViewsAtOnce) | 1168 | if (mMultipleViewsAtOnce) |
1169 | { | 1169 | { |
1170 | if ( visible ) | 1170 | if ( visible ) |
1171 | mDetails->show(); | 1171 | mDetails->show(); |
1172 | else | 1172 | else |
1173 | mDetails->hide(); | 1173 | mDetails->hide(); |
1174 | } | 1174 | } |
1175 | else | 1175 | else |
1176 | { | 1176 | { |
1177 | if ( visible ) { | 1177 | if ( visible ) { |
1178 | mViewManager->hide(); | 1178 | mViewManager->hide(); |
1179 | mDetails->show(); | 1179 | mDetails->show(); |
1180 | } | 1180 | } |
1181 | else { | 1181 | else { |
1182 | mViewManager->show(); | 1182 | mViewManager->show(); |
1183 | mDetails->hide(); | 1183 | mDetails->hide(); |
1184 | } | 1184 | } |
1185 | setJumpButtonBarVisible( !visible ); | 1185 | setJumpButtonBarVisible( !visible ); |
1186 | } | 1186 | } |
1187 | 1187 | ||
1188 | } | 1188 | } |
1189 | 1189 | ||
1190 | void KABCore::extensionChanged( int id ) | 1190 | void KABCore::extensionChanged( int id ) |
1191 | { | 1191 | { |
1192 | //change the details view only for non desktop systems | 1192 | //change the details view only for non desktop systems |
1193 | #ifndef DESKTOP_VERSION | 1193 | #ifndef DESKTOP_VERSION |
1194 | 1194 | ||
1195 | if (id == 0) | 1195 | if (id == 0) |
1196 | { | 1196 | { |
1197 | //the user disabled the extension. | 1197 | //the user disabled the extension. |
1198 | 1198 | ||
1199 | if (mMultipleViewsAtOnce) | 1199 | if (mMultipleViewsAtOnce) |
1200 | { // enable detailsview again | 1200 | { // enable detailsview again |
1201 | setDetailsVisible( true ); | 1201 | setDetailsVisible( true ); |
1202 | mActionDetails->setChecked( true ); | 1202 | mActionDetails->setChecked( true ); |
1203 | } | 1203 | } |
1204 | else | 1204 | else |
1205 | { //go back to the listview | 1205 | { //go back to the listview |
1206 | setDetailsVisible( false ); | 1206 | setDetailsVisible( false ); |
1207 | mActionDetails->setChecked( false ); | 1207 | mActionDetails->setChecked( false ); |
1208 | mActionDetails->setEnabled(true); | 1208 | mActionDetails->setEnabled(true); |
1209 | } | 1209 | } |
1210 | 1210 | ||
1211 | } | 1211 | } |
1212 | else | 1212 | else |
1213 | { | 1213 | { |
1214 | //the user enabled the extension. | 1214 | //the user enabled the extension. |
1215 | setDetailsVisible( false ); | 1215 | setDetailsVisible( false ); |
1216 | mActionDetails->setChecked( false ); | 1216 | mActionDetails->setChecked( false ); |
1217 | 1217 | ||
1218 | if (!mMultipleViewsAtOnce) | 1218 | if (!mMultipleViewsAtOnce) |
1219 | { | 1219 | { |
1220 | mActionDetails->setEnabled(false); | 1220 | mActionDetails->setEnabled(false); |
1221 | } | 1221 | } |
1222 | 1222 | ||
1223 | mExtensionManager->setSelectionChanged(); | 1223 | mExtensionManager->setSelectionChanged(); |
1224 | 1224 | ||
1225 | } | 1225 | } |
1226 | 1226 | ||
1227 | #endif// DESKTOP_VERSION | 1227 | #endif// DESKTOP_VERSION |
1228 | 1228 | ||
1229 | } | 1229 | } |
1230 | 1230 | ||
1231 | 1231 | ||
1232 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1232 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1233 | { | 1233 | { |
1234 | 1234 | ||
1235 | if ( list.count() != 0 ) { | 1235 | if ( list.count() != 0 ) { |
1236 | KABC::Addressee::List::ConstIterator it; | 1236 | KABC::Addressee::List::ConstIterator it; |
1237 | for ( it = list.begin(); it != list.end(); ++it ) | 1237 | for ( it = list.begin(); it != list.end(); ++it ) |
1238 | mAddressBook->insertAddressee( *it ); | 1238 | mAddressBook->insertAddressee( *it ); |
1239 | if ( list.count() > 1 ) | 1239 | if ( list.count() > 1 ) |
1240 | setModified(); | 1240 | setModified(); |
1241 | else | 1241 | else |
1242 | setModifiedWOrefresh(); | 1242 | setModifiedWOrefresh(); |
1243 | } | 1243 | } |
1244 | if ( list.count() == 0 ) | 1244 | if ( list.count() == 0 ) |
1245 | mViewManager->refreshView(); | 1245 | mViewManager->refreshView(); |
1246 | else | 1246 | else |
1247 | mViewManager->refreshView( list[ 0 ].uid() ); | 1247 | mViewManager->refreshView( list[ 0 ].uid() ); |
1248 | 1248 | ||
1249 | 1249 | ||
1250 | 1250 | ||
1251 | } | 1251 | } |
1252 | 1252 | ||
1253 | QString KABCore::getNameByPhone( const QString &phone ) | 1253 | QString KABCore::getNameByPhone( const QString &phone ) |
1254 | { | 1254 | { |
1255 | #ifndef KAB_EMBEDDED | 1255 | #ifndef KAB_EMBEDDED |
1256 | QRegExp r( "[/*/-/ ]" ); | 1256 | QRegExp r( "[/*/-/ ]" ); |
1257 | QString localPhone( phone ); | 1257 | QString localPhone( phone ); |
1258 | 1258 | ||
1259 | bool found = false; | 1259 | bool found = false; |
1260 | QString ownerName = ""; | 1260 | QString ownerName = ""; |
1261 | KABC::AddressBook::Iterator iter; | 1261 | KABC::AddressBook::Iterator iter; |
1262 | KABC::PhoneNumber::List::Iterator phoneIter; | 1262 | KABC::PhoneNumber::List::Iterator phoneIter; |
1263 | KABC::PhoneNumber::List phoneList; | 1263 | KABC::PhoneNumber::List phoneList; |
1264 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1264 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1265 | phoneList = (*iter).phoneNumbers(); | 1265 | phoneList = (*iter).phoneNumbers(); |
1266 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1266 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1267 | ++phoneIter) { | 1267 | ++phoneIter) { |
1268 | // Get rid of separator chars so just the numbers are compared. | 1268 | // Get rid of separator chars so just the numbers are compared. |
1269 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1269 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1270 | ownerName = (*iter).formattedName(); | 1270 | ownerName = (*iter).formattedName(); |
1271 | found = true; | 1271 | found = true; |
1272 | } | 1272 | } |
1273 | } | 1273 | } |
1274 | } | 1274 | } |
1275 | 1275 | ||
1276 | return ownerName; | 1276 | return ownerName; |
1277 | #else //KAB_EMBEDDED | 1277 | #else //KAB_EMBEDDED |
1278 | qDebug("KABCore::getNameByPhone finsih method"); | 1278 | qDebug("KABCore::getNameByPhone finsih method"); |
1279 | return ""; | 1279 | return ""; |
1280 | #endif //KAB_EMBEDDED | 1280 | #endif //KAB_EMBEDDED |
1281 | 1281 | ||
1282 | } | 1282 | } |
1283 | 1283 | ||
1284 | void KABCore::openConfigDialog() | 1284 | void KABCore::openConfigDialog() |
1285 | { | 1285 | { |
1286 | KABPrefs* kab_prefs = KABPrefs::instance(); | 1286 | KABPrefs* kab_prefs = KABPrefs::instance(); |
1287 | KPimGlobalPrefs* kpim_prefs = KPimGlobalPrefs::instance(); | 1287 | KPimGlobalPrefs* kpim_prefs = KPimGlobalPrefs::instance(); |
1288 | 1288 | ||
1289 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1289 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1290 | KCMKabConfig* kabcfg = new KCMKabConfig( kab_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1290 | KCMKabConfig* kabcfg = new KCMKabConfig( kab_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1291 | ConfigureDialog->addModule(kabcfg ); | 1291 | ConfigureDialog->addModule(kabcfg ); |
1292 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( kpim_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1292 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( kpim_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1293 | ConfigureDialog->addModule(kdelibcfg ); | 1293 | ConfigureDialog->addModule(kdelibcfg ); |
1294 | 1294 | ||
1295 | 1295 | ||
1296 | 1296 | ||
1297 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1297 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1298 | this, SLOT( configurationChanged() ) ); | 1298 | this, SLOT( configurationChanged() ) ); |
1299 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1299 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1300 | this, SLOT( configurationChanged() ) ); | 1300 | this, SLOT( configurationChanged() ) ); |
1301 | saveSettings(); | 1301 | saveSettings(); |
1302 | #ifndef DESKTOP_VERSION | 1302 | #ifndef DESKTOP_VERSION |
1303 | ConfigureDialog->showMaximized(); | 1303 | ConfigureDialog->showMaximized(); |
1304 | #endif | 1304 | #endif |
1305 | if ( ConfigureDialog->exec() ) | 1305 | if ( ConfigureDialog->exec() ) |
1306 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1306 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1307 | delete ConfigureDialog; | 1307 | delete ConfigureDialog; |
1308 | } | 1308 | } |
1309 | 1309 | ||
1310 | void KABCore::openLDAPDialog() | 1310 | void KABCore::openLDAPDialog() |
1311 | { | 1311 | { |
1312 | #ifndef KAB_EMBEDDED | 1312 | #ifndef KAB_EMBEDDED |
1313 | if ( !mLdapSearchDialog ) { | 1313 | if ( !mLdapSearchDialog ) { |
1314 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1314 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1315 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1315 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1316 | SLOT( refreshView() ) ); | 1316 | SLOT( refreshView() ) ); |
1317 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1317 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1318 | SLOT( setModified() ) ); | 1318 | SLOT( setModified() ) ); |
1319 | } else | 1319 | } else |
1320 | mLdapSearchDialog->restoreSettings(); | 1320 | mLdapSearchDialog->restoreSettings(); |
1321 | 1321 | ||
1322 | if ( mLdapSearchDialog->isOK() ) | 1322 | if ( mLdapSearchDialog->isOK() ) |
1323 | mLdapSearchDialog->exec(); | 1323 | mLdapSearchDialog->exec(); |
1324 | #else //KAB_EMBEDDED | 1324 | #else //KAB_EMBEDDED |
1325 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1325 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1326 | #endif //KAB_EMBEDDED | 1326 | #endif //KAB_EMBEDDED |
1327 | } | 1327 | } |
1328 | 1328 | ||
1329 | void KABCore::print() | 1329 | void KABCore::print() |
1330 | { | 1330 | { |
1331 | #ifndef KAB_EMBEDDED | 1331 | #ifndef KAB_EMBEDDED |
1332 | KPrinter printer; | 1332 | KPrinter printer; |
1333 | if ( !printer.setup( this ) ) | 1333 | if ( !printer.setup( this ) ) |
1334 | return; | 1334 | return; |
1335 | 1335 | ||
1336 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1336 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1337 | mViewManager->selectedUids(), this ); | 1337 | mViewManager->selectedUids(), this ); |
1338 | 1338 | ||
1339 | wizard.exec(); | 1339 | wizard.exec(); |
1340 | #else //KAB_EMBEDDED | 1340 | #else //KAB_EMBEDDED |
1341 | qDebug("KABCore::print() finsih method"); | 1341 | qDebug("KABCore::print() finsih method"); |
1342 | #endif //KAB_EMBEDDED | 1342 | #endif //KAB_EMBEDDED |
1343 | 1343 | ||
1344 | } | 1344 | } |
1345 | 1345 | ||
1346 | 1346 | ||
1347 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1347 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1348 | { | 1348 | { |
1349 | if ( mGUIClient ) | 1349 | if ( mGUIClient ) |
1350 | mGUIClient->insertChildClient( client ); | 1350 | mGUIClient->insertChildClient( client ); |
1351 | else | 1351 | else |
1352 | KMessageBox::error( this, "no KXMLGUICLient"); | 1352 | KMessageBox::error( this, "no KXMLGUICLient"); |
1353 | } | 1353 | } |
1354 | 1354 | ||
1355 | 1355 | ||
1356 | void KABCore::configurationChanged() | 1356 | void KABCore::configurationChanged() |
1357 | { | 1357 | { |
1358 | mExtensionManager->reconfigure(); | 1358 | mExtensionManager->reconfigure(); |
1359 | } | 1359 | } |
1360 | 1360 | ||
1361 | void KABCore::addressBookChanged() | 1361 | void KABCore::addressBookChanged() |
1362 | { | 1362 | { |
1363 | /*US | 1363 | /*US |
1364 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1364 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1365 | while ( it.current() ) { | 1365 | while ( it.current() ) { |
1366 | if ( it.current()->dirty() ) { | 1366 | if ( it.current()->dirty() ) { |
1367 | QString text = i18n( "Data has been changed externally. Unsaved " | 1367 | QString text = i18n( "Data has been changed externally. Unsaved " |
1368 | "changes will be lost." ); | 1368 | "changes will be lost." ); |
1369 | KMessageBox::information( this, text ); | 1369 | KMessageBox::information( this, text ); |
1370 | } | 1370 | } |
1371 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1371 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1372 | ++it; | 1372 | ++it; |
1373 | } | 1373 | } |
1374 | */ | 1374 | */ |
1375 | if (mEditorDialog) | 1375 | if (mEditorDialog) |
1376 | { | 1376 | { |
1377 | if (mEditorDialog->dirty()) | 1377 | if (mEditorDialog->dirty()) |
1378 | { | 1378 | { |
1379 | QString text = i18n( "Data has been changed externally. Unsaved " | 1379 | QString text = i18n( "Data has been changed externally. Unsaved " |
1380 | "changes will be lost." ); | 1380 | "changes will be lost." ); |
1381 | KMessageBox::information( this, text ); | 1381 | KMessageBox::information( this, text ); |
1382 | } | 1382 | } |
1383 | QString currentuid = mEditorDialog->addressee().uid(); | 1383 | QString currentuid = mEditorDialog->addressee().uid(); |
1384 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1384 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1385 | } | 1385 | } |
1386 | mViewManager->refreshView(); | 1386 | mViewManager->refreshView(); |
1387 | // mDetails->refreshView(); | 1387 | // mDetails->refreshView(); |
1388 | 1388 | ||
1389 | 1389 | ||
1390 | } | 1390 | } |
1391 | 1391 | ||
1392 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1392 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1393 | const char *name ) | 1393 | const char *name ) |
1394 | { | 1394 | { |
1395 | 1395 | ||
1396 | if ( mEditorDialog == 0 ) { | 1396 | if ( mEditorDialog == 0 ) { |
1397 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1397 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1398 | name ? name : "editorDialog" ); | 1398 | name ? name : "editorDialog" ); |
1399 | 1399 | ||
1400 | 1400 | ||
1401 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1401 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1402 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1402 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1403 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1403 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1404 | // SLOT( slotEditorDestroyed( const QString& ) ) ; | 1404 | // SLOT( slotEditorDestroyed( const QString& ) ) ; |
1405 | } | 1405 | } |
1406 | 1406 | ||
1407 | return mEditorDialog; | 1407 | return mEditorDialog; |
1408 | } | 1408 | } |
1409 | 1409 | ||
1410 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1410 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1411 | { | 1411 | { |
1412 | //mEditorDict.remove( uid ); | 1412 | //mEditorDict.remove( uid ); |
1413 | } | 1413 | } |
1414 | 1414 | ||
1415 | void KABCore::initGUI() | 1415 | void KABCore::initGUI() |
1416 | { | 1416 | { |
1417 | #ifndef KAB_EMBEDDED | 1417 | #ifndef KAB_EMBEDDED |
1418 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1418 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1419 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1419 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1420 | 1420 | ||
1421 | mExtensionBarSplitter = new QSplitter( this ); | 1421 | mExtensionBarSplitter = new QSplitter( this ); |
1422 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1422 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1423 | 1423 | ||
1424 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1424 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1425 | 1425 | ||
1426 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1426 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1427 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1427 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1428 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1428 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1429 | SLOT( incrementalSearch( const QString& ) ) ); | 1429 | SLOT( incrementalSearch( const QString& ) ) ); |
1430 | 1430 | ||
1431 | mViewManager = new ViewManager( this, viewSpace ); | 1431 | mViewManager = new ViewManager( this, viewSpace ); |
1432 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1432 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1433 | 1433 | ||
1434 | mDetails = new ViewContainer( mDetailsSplitter ); | 1434 | mDetails = new ViewContainer( mDetailsSplitter ); |
1435 | 1435 | ||
1436 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1436 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1437 | 1437 | ||
1438 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1438 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1439 | 1439 | ||
1440 | topLayout->addWidget( mExtensionBarSplitter ); | 1440 | topLayout->addWidget( mExtensionBarSplitter ); |
1441 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1441 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1442 | topLayout->addWidget( mJumpButtonBar ); | 1442 | topLayout->addWidget( mJumpButtonBar ); |
1443 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1443 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1444 | 1444 | ||
1445 | mXXPortManager = new XXPortManager( this, this ); | 1445 | mXXPortManager = new XXPortManager( this, this ); |
1446 | 1446 | ||
1447 | #else //KAB_EMBEDDED | 1447 | #else //KAB_EMBEDDED |
1448 | //US initialize viewMenu before settingup viewmanager. | 1448 | //US initialize viewMenu before settingup viewmanager. |
1449 | // Viewmanager needs this menu to plugin submenues. | 1449 | // Viewmanager needs this menu to plugin submenues. |
1450 | viewMenu = new QPopupMenu( this ); | 1450 | viewMenu = new QPopupMenu( this ); |
1451 | settingsMenu = new QPopupMenu( this ); | 1451 | settingsMenu = new QPopupMenu( this ); |
1452 | //filterMenu = new QPopupMenu( this ); | 1452 | //filterMenu = new QPopupMenu( this ); |
1453 | ImportMenu = new QPopupMenu( this ); | 1453 | ImportMenu = new QPopupMenu( this ); |
1454 | ExportMenu = new QPopupMenu( this ); | 1454 | ExportMenu = new QPopupMenu( this ); |
1455 | syncMenu = new QPopupMenu( this ); | 1455 | syncMenu = new QPopupMenu( this ); |
1456 | changeMenu= new QPopupMenu( this ); | 1456 | changeMenu= new QPopupMenu( this ); |
1457 | 1457 | ||
1458 | //US since we have no splitter for the embedded system, setup | 1458 | //US since we have no splitter for the embedded system, setup |
1459 | // a layout with two frames. One left and one right. | 1459 | // a layout with two frames. One left and one right. |
1460 | 1460 | ||
1461 | QBoxLayout *topLayout; | 1461 | QBoxLayout *topLayout; |
1462 | 1462 | ||
1463 | // = new QHBoxLayout( this ); | 1463 | // = new QHBoxLayout( this ); |
1464 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1464 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1465 | 1465 | ||
1466 | // QWidget *mainBox = new QWidget( this ); | 1466 | // QWidget *mainBox = new QWidget( this ); |
1467 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1467 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1468 | 1468 | ||
1469 | #ifdef DESKTOP_VERSION | 1469 | #ifdef DESKTOP_VERSION |
1470 | topLayout = new QHBoxLayout( this ); | 1470 | topLayout = new QHBoxLayout( this ); |
1471 | 1471 | ||
1472 | 1472 | ||
1473 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1473 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1474 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1474 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1475 | 1475 | ||
1476 | topLayout->addWidget(mMiniSplitter ); | 1476 | topLayout->addWidget(mMiniSplitter ); |
1477 | 1477 | ||
1478 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1478 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1479 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1479 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1480 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1480 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1481 | mDetails = new ViewContainer( mMiniSplitter ); | 1481 | mDetails = new ViewContainer( mMiniSplitter ); |
1482 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1482 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1483 | #else | 1483 | #else |
1484 | if ( QApplication::desktop()->width() > 480 ) { | 1484 | if ( QApplication::desktop()->width() > 480 ) { |
1485 | topLayout = new QHBoxLayout( this ); | 1485 | topLayout = new QHBoxLayout( this ); |
1486 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1486 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1487 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1487 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1488 | } else { | 1488 | } else { |
1489 | 1489 | ||
1490 | topLayout = new QHBoxLayout( this ); | 1490 | topLayout = new QHBoxLayout( this ); |
1491 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1491 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1492 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1492 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1493 | } | 1493 | } |
1494 | 1494 | ||
1495 | topLayout->addWidget(mMiniSplitter ); | 1495 | topLayout->addWidget(mMiniSplitter ); |
1496 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1496 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1497 | mDetails = new ViewContainer( mMiniSplitter ); | 1497 | mDetails = new ViewContainer( mMiniSplitter ); |
1498 | 1498 | ||
1499 | 1499 | ||
1500 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1500 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1501 | #endif | 1501 | #endif |
1502 | //eh->hide(); | 1502 | //eh->hide(); |
1503 | // topLayout->addWidget(mExtensionManager ); | 1503 | // topLayout->addWidget(mExtensionManager ); |
1504 | 1504 | ||
1505 | 1505 | ||
1506 | /*US | 1506 | /*US |
1507 | #ifndef KAB_NOSPLITTER | 1507 | #ifndef KAB_NOSPLITTER |
1508 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1508 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1509 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1509 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1510 | topLayout->setSpacing( 10 ); | 1510 | topLayout->setSpacing( 10 ); |
1511 | 1511 | ||
1512 | mDetailsSplitter = new QSplitter( this ); | 1512 | mDetailsSplitter = new QSplitter( this ); |
1513 | 1513 | ||
1514 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1514 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1515 | 1515 | ||
1516 | mViewManager = new ViewManager( this, viewSpace ); | 1516 | mViewManager = new ViewManager( this, viewSpace ); |
1517 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1517 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1518 | 1518 | ||
1519 | mDetails = new ViewContainer( mDetailsSplitter ); | 1519 | mDetails = new ViewContainer( mDetailsSplitter ); |
1520 | 1520 | ||
1521 | topLayout->addWidget( mDetailsSplitter ); | 1521 | topLayout->addWidget( mDetailsSplitter ); |
1522 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1522 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1523 | #else //KAB_NOSPLITTER | 1523 | #else //KAB_NOSPLITTER |
1524 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1524 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1525 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1525 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1526 | topLayout->setSpacing( 10 ); | 1526 | topLayout->setSpacing( 10 ); |
1527 | 1527 | ||
1528 | // mDetailsSplitter = new QSplitter( this ); | 1528 | // mDetailsSplitter = new QSplitter( this ); |
1529 | 1529 | ||
1530 | QVBox *viewSpace = new QVBox( this ); | 1530 | QVBox *viewSpace = new QVBox( this ); |
1531 | 1531 | ||
1532 | mViewManager = new ViewManager( this, viewSpace ); | 1532 | mViewManager = new ViewManager( this, viewSpace ); |
1533 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1533 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1534 | 1534 | ||
1535 | mDetails = new ViewContainer( this ); | 1535 | mDetails = new ViewContainer( this ); |
1536 | 1536 | ||
1537 | topLayout->addWidget( viewSpace ); | 1537 | topLayout->addWidget( viewSpace ); |
1538 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1538 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1539 | topLayout->addWidget( mDetails ); | 1539 | topLayout->addWidget( mDetails ); |
1540 | #endif //KAB_NOSPLITTER | 1540 | #endif //KAB_NOSPLITTER |
1541 | */ | 1541 | */ |
1542 | 1542 | ||
1543 | 1543 | ||
1544 | #endif //KAB_EMBEDDED | 1544 | #endif //KAB_EMBEDDED |
1545 | initActions(); | 1545 | initActions(); |
1546 | 1546 | ||
1547 | #ifdef KAB_EMBEDDED | 1547 | #ifdef KAB_EMBEDDED |
1548 | addActionsManually(); | 1548 | addActionsManually(); |
1549 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1549 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1550 | mXXPortManager = new XXPortManager( this, this ); | 1550 | mXXPortManager = new XXPortManager( this, this ); |
1551 | 1551 | ||
1552 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1552 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1553 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1553 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1554 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1554 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1555 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1555 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1556 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1556 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1557 | // mIncSearchWidget->hide(); | 1557 | // mIncSearchWidget->hide(); |
1558 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1558 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1559 | SLOT( incrementalSearch( const QString& ) ) ); | 1559 | SLOT( incrementalSearch( const QString& ) ) ); |
1560 | 1560 | ||
1561 | 1561 | ||
1562 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1562 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1563 | 1563 | ||
1564 | topLayout->addWidget( mJumpButtonBar ); | 1564 | topLayout->addWidget( mJumpButtonBar ); |
1565 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1565 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1566 | 1566 | ||
1567 | // mMainWindow->getIconToolBar()->raise(); | 1567 | // mMainWindow->getIconToolBar()->raise(); |
1568 | 1568 | ||
1569 | #endif //KAB_EMBEDDED | 1569 | #endif //KAB_EMBEDDED |
1570 | 1570 | ||
1571 | } | 1571 | } |
1572 | void KABCore::initActions() | 1572 | void KABCore::initActions() |
1573 | { | 1573 | { |
1574 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1574 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1575 | 1575 | ||
1576 | #ifndef KAB_EMBEDDED | 1576 | #ifndef KAB_EMBEDDED |
1577 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1577 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1578 | SLOT( clipboardDataChanged() ) ); | 1578 | SLOT( clipboardDataChanged() ) ); |
1579 | #endif //KAB_EMBEDDED | 1579 | #endif //KAB_EMBEDDED |
1580 | 1580 | ||
1581 | // file menu | 1581 | // file menu |
1582 | if ( mIsPart ) { | 1582 | if ( mIsPart ) { |
1583 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, | 1583 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, |
1584 | SLOT( sendMail() ), actionCollection(), | 1584 | SLOT( sendMail() ), actionCollection(), |
1585 | "kaddressbook_mail" ); | 1585 | "kaddressbook_mail" ); |
1586 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, | 1586 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, |
1587 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); | 1587 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); |
1588 | 1588 | ||
1589 | } else { | 1589 | } else { |
1590 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1590 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1591 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1591 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1592 | } | 1592 | } |
1593 | 1593 | ||
1594 | 1594 | ||
1595 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1595 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1596 | SLOT( save() ), actionCollection(), "file_sync" ); | 1596 | SLOT( save() ), actionCollection(), "file_sync" ); |
1597 | 1597 | ||
1598 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1598 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1599 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1599 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1600 | 1600 | ||
1601 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1601 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1602 | this, SLOT( mailVCard() ), | 1602 | this, SLOT( mailVCard() ), |
1603 | actionCollection(), "file_mail_vcard"); | 1603 | actionCollection(), "file_mail_vcard"); |
1604 | 1604 | ||
1605 | mActionBeamVCard = 0; | 1605 | mActionBeamVCard = 0; |
1606 | mActionBeam = 0; | 1606 | mActionBeam = 0; |
1607 | 1607 | ||
1608 | #ifndef DESKTOP_VERSION | 1608 | #ifndef DESKTOP_VERSION |
1609 | if ( Ir::supported() ) { | 1609 | if ( Ir::supported() ) { |
1610 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, | 1610 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, |
1611 | SLOT( beamVCard() ), actionCollection(), | 1611 | SLOT( beamVCard() ), actionCollection(), |
1612 | "kaddressbook_beam_vcard" ); | 1612 | "kaddressbook_beam_vcard" ); |
1613 | 1613 | ||
1614 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1614 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1615 | SLOT( beamMySelf() ), actionCollection(), | 1615 | SLOT( beamMySelf() ), actionCollection(), |
1616 | "kaddressbook_beam_myself" ); | 1616 | "kaddressbook_beam_myself" ); |
1617 | } | 1617 | } |
1618 | #endif | 1618 | #endif |
1619 | 1619 | ||
1620 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1620 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1621 | this, SLOT( editContact2() ), | 1621 | this, SLOT( editContact2() ), |
1622 | actionCollection(), "file_properties" ); | 1622 | actionCollection(), "file_properties" ); |
1623 | 1623 | ||
1624 | #ifdef KAB_EMBEDDED | 1624 | #ifdef KAB_EMBEDDED |
1625 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1625 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1626 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1626 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1627 | mMainWindow, SLOT( exit() ), | 1627 | mMainWindow, SLOT( exit() ), |
1628 | actionCollection(), "quit" ); | 1628 | actionCollection(), "quit" ); |
1629 | #endif //KAB_EMBEDDED | 1629 | #endif //KAB_EMBEDDED |
1630 | 1630 | ||
1631 | // edit menu | 1631 | // edit menu |
1632 | if ( mIsPart ) { | 1632 | if ( mIsPart ) { |
1633 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1633 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1634 | SLOT( copyContacts() ), actionCollection(), | 1634 | SLOT( copyContacts() ), actionCollection(), |
1635 | "kaddressbook_copy" ); | 1635 | "kaddressbook_copy" ); |
1636 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1636 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1637 | SLOT( cutContacts() ), actionCollection(), | 1637 | SLOT( cutContacts() ), actionCollection(), |
1638 | "kaddressbook_cut" ); | 1638 | "kaddressbook_cut" ); |
1639 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1639 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1640 | SLOT( pasteContacts() ), actionCollection(), | 1640 | SLOT( pasteContacts() ), actionCollection(), |
1641 | "kaddressbook_paste" ); | 1641 | "kaddressbook_paste" ); |
1642 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1642 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1643 | SLOT( selectAllContacts() ), actionCollection(), | 1643 | SLOT( selectAllContacts() ), actionCollection(), |
1644 | "kaddressbook_select_all" ); | 1644 | "kaddressbook_select_all" ); |
1645 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1645 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1646 | SLOT( undo() ), actionCollection(), | 1646 | SLOT( undo() ), actionCollection(), |
1647 | "kaddressbook_undo" ); | 1647 | "kaddressbook_undo" ); |
1648 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1648 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1649 | this, SLOT( redo() ), actionCollection(), | 1649 | this, SLOT( redo() ), actionCollection(), |
1650 | "kaddressbook_redo" ); | 1650 | "kaddressbook_redo" ); |
1651 | } else { | 1651 | } else { |
1652 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1652 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1653 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1653 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1654 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1654 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1655 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1655 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1656 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1656 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1657 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1657 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1658 | } | 1658 | } |
1659 | 1659 | ||
1660 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1660 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1661 | Key_Delete, this, SLOT( deleteContacts() ), | 1661 | Key_Delete, this, SLOT( deleteContacts() ), |
1662 | actionCollection(), "edit_delete" ); | 1662 | actionCollection(), "edit_delete" ); |
1663 | 1663 | ||
1664 | mActionUndo->setEnabled( false ); | 1664 | mActionUndo->setEnabled( false ); |
1665 | mActionRedo->setEnabled( false ); | 1665 | mActionRedo->setEnabled( false ); |
1666 | 1666 | ||
1667 | // settings menu | 1667 | // settings menu |
1668 | #ifdef KAB_EMBEDDED | 1668 | #ifdef KAB_EMBEDDED |
1669 | //US special menuentry to configure the addressbook resources. On KDE | 1669 | //US special menuentry to configure the addressbook resources. On KDE |
1670 | // you do that through the control center !!! | 1670 | // you do that through the control center !!! |
1671 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1671 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1672 | SLOT( configureResources() ), actionCollection(), | 1672 | SLOT( configureResources() ), actionCollection(), |
1673 | "kaddressbook_configure_resources" ); | 1673 | "kaddressbook_configure_resources" ); |
1674 | #endif //KAB_EMBEDDED | 1674 | #endif //KAB_EMBEDDED |
1675 | 1675 | ||
1676 | if ( mIsPart ) { | 1676 | if ( mIsPart ) { |
1677 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1677 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1678 | SLOT( openConfigDialog() ), actionCollection(), | 1678 | SLOT( openConfigDialog() ), actionCollection(), |
1679 | "kaddressbook_configure" ); | 1679 | "kaddressbook_configure" ); |
1680 | 1680 | ||
1681 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1681 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1682 | this, SLOT( configureKeyBindings() ), actionCollection(), | 1682 | this, SLOT( configureKeyBindings() ), actionCollection(), |
1683 | "kaddressbook_configure_shortcuts" ); | 1683 | "kaddressbook_configure_shortcuts" ); |
1684 | #ifdef KAB_EMBEDDED | 1684 | #ifdef KAB_EMBEDDED |
1685 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1685 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1686 | mActionConfigureToolbars->setEnabled( false ); | 1686 | mActionConfigureToolbars->setEnabled( false ); |
1687 | #endif //KAB_EMBEDDED | 1687 | #endif //KAB_EMBEDDED |
1688 | 1688 | ||
1689 | } else { | 1689 | } else { |
1690 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1690 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1691 | 1691 | ||
1692 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1692 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1693 | } | 1693 | } |
1694 | 1694 | ||
1695 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 1695 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
1696 | actionCollection(), "options_show_jump_bar" ); | 1696 | actionCollection(), "options_show_jump_bar" ); |
1697 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 1697 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
1698 | 1698 | ||
1699 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 1699 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
1700 | actionCollection(), "options_show_details" ); | 1700 | actionCollection(), "options_show_details" ); |
1701 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 1701 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
1702 | 1702 | ||
1703 | // misc | 1703 | // misc |
1704 | // only enable LDAP lookup if we can handle the protocol | 1704 | // only enable LDAP lookup if we can handle the protocol |
1705 | #ifndef KAB_EMBEDDED | 1705 | #ifndef KAB_EMBEDDED |
1706 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 1706 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
1707 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 1707 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
1708 | this, SLOT( openLDAPDialog() ), actionCollection(), | 1708 | this, SLOT( openLDAPDialog() ), actionCollection(), |
1709 | "ldap_lookup" ); | 1709 | "ldap_lookup" ); |
1710 | } | 1710 | } |
1711 | #else //KAB_EMBEDDED | 1711 | #else //KAB_EMBEDDED |
1712 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1712 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1713 | #endif //KAB_EMBEDDED | 1713 | #endif //KAB_EMBEDDED |
1714 | 1714 | ||
1715 | 1715 | ||
1716 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1716 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1717 | SLOT( setWhoAmI() ), actionCollection(), | 1717 | SLOT( setWhoAmI() ), actionCollection(), |
1718 | "set_personal" ); | 1718 | "set_personal" ); |
1719 | 1719 | ||
1720 | 1720 | ||
1721 | 1721 | ||
1722 | 1722 | ||
1723 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1723 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1724 | SLOT( setCategories() ), actionCollection(), | 1724 | SLOT( setCategories() ), actionCollection(), |
1725 | "edit_set_categories" ); | 1725 | "edit_set_categories" ); |
1726 | 1726 | ||
1727 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1727 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
1728 | SLOT( removeVoice() ), actionCollection(), | 1728 | SLOT( removeVoice() ), actionCollection(), |
1729 | "remove_voice" ); | 1729 | "remove_voice" ); |
1730 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 1730 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
1731 | SLOT( importFromOL() ), actionCollection(), | 1731 | SLOT( importFromOL() ), actionCollection(), |
1732 | "import_OL" ); | 1732 | "import_OL" ); |
1733 | #ifdef KAB_EMBEDDED | 1733 | #ifdef KAB_EMBEDDED |
1734 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 1734 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
1735 | this, SLOT( showLicence() ), actionCollection(), | 1735 | this, SLOT( showLicence() ), actionCollection(), |
1736 | "licence_about_data" ); | 1736 | "licence_about_data" ); |
1737 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 1737 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
1738 | this, SLOT( faq() ), actionCollection(), | 1738 | this, SLOT( faq() ), actionCollection(), |
1739 | "faq_about_data" ); | 1739 | "faq_about_data" ); |
1740 | 1740 | ||
1741 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 1741 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
1742 | this, SLOT( createAboutData() ), actionCollection(), | 1742 | this, SLOT( createAboutData() ), actionCollection(), |
1743 | "kaddressbook_about_data" ); | 1743 | "kaddressbook_about_data" ); |
1744 | #endif //KAB_EMBEDDED | 1744 | #endif //KAB_EMBEDDED |
1745 | 1745 | ||
1746 | clipboardDataChanged(); | 1746 | clipboardDataChanged(); |
1747 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1747 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1748 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1748 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1749 | } | 1749 | } |
1750 | 1750 | ||
1751 | //US we need this function, to plug all actions into the correct menues. | 1751 | //US we need this function, to plug all actions into the correct menues. |
1752 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 1752 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
1753 | void KABCore::addActionsManually() | 1753 | void KABCore::addActionsManually() |
1754 | { | 1754 | { |
1755 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1755 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1756 | 1756 | ||
1757 | #ifdef KAB_EMBEDDED | 1757 | #ifdef KAB_EMBEDDED |
1758 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 1758 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
1759 | QPopupMenu *editMenu = new QPopupMenu( this ); | 1759 | QPopupMenu *editMenu = new QPopupMenu( this ); |
1760 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 1760 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
1761 | 1761 | ||
1762 | KToolBar* tb = mMainWindow->toolBar(); | 1762 | KToolBar* tb = mMainWindow->toolBar(); |
1763 | 1763 | ||
1764 | #ifdef DESKTOP_VERSION | 1764 | #ifdef DESKTOP_VERSION |
1765 | QMenuBar* mb = mMainWindow->menuBar(); | 1765 | QMenuBar* mb = mMainWindow->menuBar(); |
1766 | 1766 | ||
1767 | //US setup menubar. | 1767 | //US setup menubar. |
1768 | //Disable the following block if you do not want to have a menubar. | 1768 | //Disable the following block if you do not want to have a menubar. |
1769 | mb->insertItem( "&File", fileMenu ); | 1769 | mb->insertItem( "&File", fileMenu ); |
1770 | mb->insertItem( "&Edit", editMenu ); | 1770 | mb->insertItem( "&Edit", editMenu ); |
1771 | mb->insertItem( "&View", viewMenu ); | 1771 | mb->insertItem( "&View", viewMenu ); |
1772 | mb->insertItem( "&Settings", settingsMenu ); | 1772 | mb->insertItem( "&Settings", settingsMenu ); |
1773 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 1773 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
1774 | mb->insertItem( "&Change selected", changeMenu ); | 1774 | mb->insertItem( "&Change selected", changeMenu ); |
1775 | mb->insertItem( "&Help", helpMenu ); | 1775 | mb->insertItem( "&Help", helpMenu ); |
1776 | mIncSearchWidget = new IncSearchWidget( tb ); | 1776 | mIncSearchWidget = new IncSearchWidget( tb ); |
1777 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 1777 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
1778 | 1778 | ||
1779 | #else | 1779 | #else |
1780 | //US setup toolbar | 1780 | //US setup toolbar |
1781 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 1781 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
1782 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 1782 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
1783 | menuBarTB->insertItem( "ME", popupBarTB); | 1783 | menuBarTB->insertItem( "ME", popupBarTB); |
1784 | tb->insertWidget(-1, 0, menuBarTB); | 1784 | tb->insertWidget(-1, 0, menuBarTB); |
1785 | mIncSearchWidget = new IncSearchWidget( tb ); | 1785 | mIncSearchWidget = new IncSearchWidget( tb ); |
1786 | 1786 | ||
1787 | tb->enableMoving(false); | 1787 | tb->enableMoving(false); |
1788 | popupBarTB->insertItem( "&File", fileMenu ); | 1788 | popupBarTB->insertItem( "&File", fileMenu ); |
1789 | popupBarTB->insertItem( "&Edit", editMenu ); | 1789 | popupBarTB->insertItem( "&Edit", editMenu ); |
1790 | popupBarTB->insertItem( "&View", viewMenu ); | 1790 | popupBarTB->insertItem( "&View", viewMenu ); |
1791 | popupBarTB->insertItem( "&Settings", settingsMenu ); | 1791 | popupBarTB->insertItem( "&Settings", settingsMenu ); |
1792 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 1792 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
1793 | mViewManager->getFilterAction()->plug ( popupBarTB); | 1793 | mViewManager->getFilterAction()->plug ( popupBarTB); |
1794 | popupBarTB->insertItem( "&Change selected", changeMenu ); | 1794 | popupBarTB->insertItem( "&Change selected", changeMenu ); |
1795 | popupBarTB->insertItem( "&Help", helpMenu ); | 1795 | popupBarTB->insertItem( "&Help", helpMenu ); |
1796 | if (QApplication::desktop()->width() > 320 ) { | 1796 | if (QApplication::desktop()->width() > 320 ) { |
1797 | // mViewManager->getFilterAction()->plug ( tb); | 1797 | // mViewManager->getFilterAction()->plug ( tb); |
1798 | } | 1798 | } |
1799 | #endif | 1799 | #endif |
1800 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1800 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1801 | 1801 | ||
1802 | 1802 | ||
1803 | 1803 | ||
1804 | //US Now connect the actions with the menue entries. | 1804 | //US Now connect the actions with the menue entries. |
1805 | mActionPrint->plug( fileMenu ); | 1805 | mActionPrint->plug( fileMenu ); |
1806 | mActionMail->plug( fileMenu ); | 1806 | mActionMail->plug( fileMenu ); |
1807 | fileMenu->insertSeparator(); | 1807 | fileMenu->insertSeparator(); |
1808 | 1808 | ||
1809 | mActionNewContact->plug( fileMenu ); | 1809 | mActionNewContact->plug( fileMenu ); |
1810 | mActionNewContact->plug( tb ); | 1810 | mActionNewContact->plug( tb ); |
1811 | 1811 | ||
1812 | mActionEditAddressee->plug( fileMenu ); | 1812 | mActionEditAddressee->plug( fileMenu ); |
1813 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 1813 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
1814 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 1814 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
1815 | mActionEditAddressee->plug( tb ); | 1815 | mActionEditAddressee->plug( tb ); |
1816 | 1816 | ||
1817 | fileMenu->insertSeparator(); | 1817 | fileMenu->insertSeparator(); |
1818 | mActionSave->plug( fileMenu ); | 1818 | mActionSave->plug( fileMenu ); |
1819 | fileMenu->insertItem( "&Import", ImportMenu ); | 1819 | fileMenu->insertItem( "&Import", ImportMenu ); |
1820 | fileMenu->insertItem( "&Export", ExportMenu ); | 1820 | fileMenu->insertItem( "&Export", ExportMenu ); |
1821 | fileMenu->insertSeparator(); | 1821 | fileMenu->insertSeparator(); |
1822 | mActionMailVCard->plug( fileMenu ); | 1822 | mActionMailVCard->plug( fileMenu ); |
1823 | #ifndef DESKTOP_VERSION | 1823 | #ifndef DESKTOP_VERSION |
1824 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); | 1824 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); |
1825 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); | 1825 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); |
1826 | #endif | 1826 | #endif |
1827 | fileMenu->insertSeparator(); | 1827 | fileMenu->insertSeparator(); |
1828 | mActionQuit->plug( fileMenu ); | 1828 | mActionQuit->plug( fileMenu ); |
1829 | #ifdef _WIN32_ | 1829 | #ifdef _WIN32_ |
1830 | mActionImportOL->plug( ImportMenu ); | 1830 | mActionImportOL->plug( ImportMenu ); |
1831 | #endif | 1831 | #endif |
1832 | // edit menu | 1832 | // edit menu |
1833 | mActionUndo->plug( editMenu ); | 1833 | mActionUndo->plug( editMenu ); |
1834 | mActionRedo->plug( editMenu ); | 1834 | mActionRedo->plug( editMenu ); |
1835 | editMenu->insertSeparator(); | 1835 | editMenu->insertSeparator(); |
1836 | mActionCut->plug( editMenu ); | 1836 | mActionCut->plug( editMenu ); |
1837 | mActionCopy->plug( editMenu ); | 1837 | mActionCopy->plug( editMenu ); |
1838 | mActionPaste->plug( editMenu ); | 1838 | mActionPaste->plug( editMenu ); |
1839 | mActionDelete->plug( editMenu ); | 1839 | mActionDelete->plug( editMenu ); |
1840 | editMenu->insertSeparator(); | 1840 | editMenu->insertSeparator(); |
1841 | mActionSelectAll->plug( editMenu ); | 1841 | mActionSelectAll->plug( editMenu ); |
1842 | 1842 | ||
1843 | mActionRemoveVoice->plug( changeMenu ); | 1843 | mActionRemoveVoice->plug( changeMenu ); |
1844 | // settings menu | 1844 | // settings menu |
1845 | //US special menuentry to configure the addressbook resources. On KDE | 1845 | //US special menuentry to configure the addressbook resources. On KDE |
1846 | // you do that through the control center !!! | 1846 | // you do that through the control center !!! |
1847 | mActionConfigResources->plug( settingsMenu ); | 1847 | mActionConfigResources->plug( settingsMenu ); |
1848 | settingsMenu->insertSeparator(); | 1848 | settingsMenu->insertSeparator(); |
1849 | 1849 | ||
1850 | mActionConfigKAddressbook->plug( settingsMenu ); | 1850 | mActionConfigKAddressbook->plug( settingsMenu ); |
1851 | 1851 | ||
1852 | if ( mIsPart ) { | 1852 | if ( mIsPart ) { |
1853 | mActionConfigShortcuts->plug( settingsMenu ); | 1853 | mActionConfigShortcuts->plug( settingsMenu ); |
1854 | mActionConfigureToolbars->plug( settingsMenu ); | 1854 | mActionConfigureToolbars->plug( settingsMenu ); |
1855 | 1855 | ||
1856 | } else { | 1856 | } else { |
1857 | mActionKeyBindings->plug( settingsMenu ); | 1857 | mActionKeyBindings->plug( settingsMenu ); |
1858 | } | 1858 | } |
1859 | 1859 | ||
1860 | settingsMenu->insertSeparator(); | 1860 | settingsMenu->insertSeparator(); |
1861 | 1861 | ||
1862 | mActionJumpBar->plug( settingsMenu ); | 1862 | mActionJumpBar->plug( settingsMenu ); |
1863 | mActionDetails->plug( settingsMenu ); | 1863 | mActionDetails->plug( settingsMenu ); |
1864 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 1864 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
1865 | mActionDetails->plug( tb ); | 1865 | mActionDetails->plug( tb ); |
1866 | settingsMenu->insertSeparator(); | 1866 | settingsMenu->insertSeparator(); |
1867 | 1867 | ||
1868 | mActionWhoAmI->plug( settingsMenu ); | 1868 | mActionWhoAmI->plug( settingsMenu ); |
1869 | mActionCategories->plug( settingsMenu ); | 1869 | mActionCategories->plug( settingsMenu ); |
1870 | 1870 | ||
1871 | mActionLicence->plug( helpMenu ); | 1871 | mActionLicence->plug( helpMenu ); |
1872 | mActionFaq->plug( helpMenu ); | 1872 | mActionFaq->plug( helpMenu ); |
1873 | mActionAboutKAddressbook->plug( helpMenu ); | 1873 | mActionAboutKAddressbook->plug( helpMenu ); |
1874 | 1874 | ||
1875 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 1875 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
1876 | 1876 | ||
1877 | mActionSave->plug( tb ); | 1877 | mActionSave->plug( tb ); |
1878 | mViewManager->getFilterAction()->plug ( tb); | 1878 | mViewManager->getFilterAction()->plug ( tb); |
1879 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { | 1879 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { |
1880 | mActionUndo->plug( tb ); | 1880 | mActionUndo->plug( tb ); |
1881 | mActionDelete->plug( tb ); | 1881 | mActionDelete->plug( tb ); |
1882 | mActionRedo->plug( tb ); | 1882 | mActionRedo->plug( tb ); |
1883 | } | 1883 | } |
1884 | } | 1884 | } |
1885 | //mActionQuit->plug ( tb ); | 1885 | //mActionQuit->plug ( tb ); |
1886 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 1886 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
1887 | 1887 | ||
1888 | //US link the searchwidget first to this. | 1888 | //US link the searchwidget first to this. |
1889 | // The real linkage to the toolbar happens later. | 1889 | // The real linkage to the toolbar happens later. |
1890 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 1890 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
1891 | //US tb->insertItem( mIncSearchWidget ); | 1891 | //US tb->insertItem( mIncSearchWidget ); |
1892 | /*US | 1892 | /*US |
1893 | mIncSearchWidget = new IncSearchWidget( tb ); | 1893 | mIncSearchWidget = new IncSearchWidget( tb ); |
1894 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1894 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1895 | SLOT( incrementalSearch( const QString& ) ) ); | 1895 | SLOT( incrementalSearch( const QString& ) ) ); |
1896 | 1896 | ||
1897 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1897 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1898 | 1898 | ||
1899 | //US topLayout->addWidget( mJumpButtonBar ); | 1899 | //US topLayout->addWidget( mJumpButtonBar ); |
1900 | this->layout()->add( mJumpButtonBar ); | 1900 | this->layout()->add( mJumpButtonBar ); |
1901 | */ | 1901 | */ |
1902 | 1902 | ||
1903 | #endif //KAB_EMBEDDED | 1903 | #endif //KAB_EMBEDDED |
1904 | 1904 | ||
1905 | connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); | 1905 | connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); |
1906 | fillSyncMenu(); | 1906 | fillSyncMenu(); |
1907 | 1907 | ||
1908 | } | 1908 | } |
1909 | void KABCore::showLicence() | 1909 | void KABCore::showLicence() |
1910 | { | 1910 | { |
1911 | KApplication::showLicence(); | 1911 | KApplication::showLicence(); |
1912 | } | 1912 | } |
1913 | void KABCore::removeVoice() | 1913 | void KABCore::removeVoice() |
1914 | { | 1914 | { |
1915 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) | 1915 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) |
1916 | return; | 1916 | return; |
1917 | KABC::Addressee::List list = mViewManager->selectedAddressees(); | 1917 | KABC::Addressee::List list = mViewManager->selectedAddressees(); |
1918 | KABC::Addressee::List::Iterator it; | 1918 | KABC::Addressee::List::Iterator it; |
1919 | for ( it = list.begin(); it != list.end(); ++it ) { | 1919 | for ( it = list.begin(); it != list.end(); ++it ) { |
1920 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); | 1920 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); |
1921 | PhoneNumber::List::Iterator phoneIt; | 1921 | PhoneNumber::List::Iterator phoneIt; |
1922 | bool found = false; | 1922 | bool found = false; |
1923 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { | 1923 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { |
1924 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 1924 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
1925 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 1925 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
1926 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 1926 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
1927 | (*it).insertPhoneNumber( (*phoneIt) ); | 1927 | (*it).insertPhoneNumber( (*phoneIt) ); |
1928 | found = true; | 1928 | found = true; |
1929 | } | 1929 | } |
1930 | } | 1930 | } |
1931 | 1931 | ||
1932 | } | 1932 | } |
1933 | if ( found ) | 1933 | if ( found ) |
1934 | contactModified((*it) ); | 1934 | contactModified((*it) ); |
1935 | } | 1935 | } |
1936 | } | 1936 | } |
1937 | 1937 | ||
1938 | 1938 | ||
1939 | 1939 | ||
1940 | void KABCore::clipboardDataChanged() | 1940 | void KABCore::clipboardDataChanged() |
1941 | { | 1941 | { |
1942 | 1942 | ||
1943 | if ( mReadWrite ) | 1943 | if ( mReadWrite ) |
1944 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 1944 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
1945 | 1945 | ||
1946 | } | 1946 | } |
1947 | 1947 | ||
1948 | void KABCore::updateActionMenu() | 1948 | void KABCore::updateActionMenu() |
1949 | { | 1949 | { |
1950 | UndoStack *undo = UndoStack::instance(); | 1950 | UndoStack *undo = UndoStack::instance(); |
1951 | RedoStack *redo = RedoStack::instance(); | 1951 | RedoStack *redo = RedoStack::instance(); |
1952 | 1952 | ||
1953 | if ( undo->isEmpty() ) | 1953 | if ( undo->isEmpty() ) |
1954 | mActionUndo->setText( i18n( "Undo" ) ); | 1954 | mActionUndo->setText( i18n( "Undo" ) ); |
1955 | else | 1955 | else |
1956 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 1956 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
1957 | 1957 | ||
1958 | mActionUndo->setEnabled( !undo->isEmpty() ); | 1958 | mActionUndo->setEnabled( !undo->isEmpty() ); |
1959 | 1959 | ||
1960 | if ( !redo->top() ) | 1960 | if ( !redo->top() ) |
1961 | mActionRedo->setText( i18n( "Redo" ) ); | 1961 | mActionRedo->setText( i18n( "Redo" ) ); |
1962 | else | 1962 | else |
1963 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 1963 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
1964 | 1964 | ||
1965 | mActionRedo->setEnabled( !redo->isEmpty() ); | 1965 | mActionRedo->setEnabled( !redo->isEmpty() ); |
1966 | } | 1966 | } |
1967 | 1967 | ||
1968 | void KABCore::configureKeyBindings() | 1968 | void KABCore::configureKeyBindings() |
1969 | { | 1969 | { |
1970 | #ifndef KAB_EMBEDDED | 1970 | #ifndef KAB_EMBEDDED |
1971 | KKeyDialog::configure( actionCollection(), true ); | 1971 | KKeyDialog::configure( actionCollection(), true ); |
1972 | #else //KAB_EMBEDDED | 1972 | #else //KAB_EMBEDDED |
1973 | qDebug("KABCore::configureKeyBindings() not implemented"); | 1973 | qDebug("KABCore::configureKeyBindings() not implemented"); |
1974 | #endif //KAB_EMBEDDED | 1974 | #endif //KAB_EMBEDDED |
1975 | } | 1975 | } |
1976 | 1976 | ||
1977 | #ifdef KAB_EMBEDDED | 1977 | #ifdef KAB_EMBEDDED |
1978 | void KABCore::configureResources() | 1978 | void KABCore::configureResources() |
1979 | { | 1979 | { |
1980 | KRES::KCMKResources dlg( this, "" , 0 ); | 1980 | KRES::KCMKResources dlg( this, "" , 0 ); |
1981 | 1981 | ||
1982 | if ( !dlg.exec() ) | 1982 | if ( !dlg.exec() ) |
1983 | return; | 1983 | return; |
1984 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 1984 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
1985 | } | 1985 | } |
1986 | #endif //KAB_EMBEDDED | 1986 | #endif //KAB_EMBEDDED |
1987 | 1987 | ||
1988 | 1988 | ||
1989 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 1989 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
1990 | * for the attendees list of an event. | 1990 | * for the attendees list of an event. |
1991 | */ | 1991 | */ |
1992 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 1992 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
1993 | { | 1993 | { |
1994 | QStringList nameList; | 1994 | QStringList nameList; |
1995 | QStringList emailList; | 1995 | QStringList emailList; |
1996 | QStringList uidList; | 1996 | QStringList uidList; |
1997 | 1997 | ||
1998 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 1998 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
1999 | uint i=0; | 1999 | uint i=0; |
2000 | for (i=0; i < list.count(); i++) | 2000 | for (i=0; i < list.count(); i++) |
2001 | { | 2001 | { |
2002 | nameList.append(list[i].realName()); | 2002 | nameList.append(list[i].realName()); |
2003 | emailList.append(list[i].preferredEmail()); | 2003 | emailList.append(list[i].preferredEmail()); |
2004 | uidList.append(list[i].uid()); | 2004 | uidList.append(list[i].uid()); |
2005 | } | 2005 | } |
2006 | 2006 | ||
2007 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2007 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2008 | 2008 | ||
2009 | } | 2009 | } |
2010 | 2010 | ||
2011 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2011 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2012 | */ | 2012 | */ |
2013 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2013 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2014 | { | 2014 | { |
2015 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2015 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2016 | 2016 | ||
2017 | QString foundUid = QString::null; | 2017 | QString foundUid = QString::null; |
2018 | if ( ! uid.isEmpty() ) { | 2018 | if ( ! uid.isEmpty() ) { |
2019 | Addressee adrr = mAddressBook->findByUid( uid ); | 2019 | Addressee adrr = mAddressBook->findByUid( uid ); |
2020 | if ( !adrr.isEmpty() ) { | 2020 | if ( !adrr.isEmpty() ) { |
2021 | foundUid = uid; | 2021 | foundUid = uid; |
2022 | } | 2022 | } |
2023 | if ( email == "sendbacklist" ) { | 2023 | if ( email == "sendbacklist" ) { |
2024 | //qDebug("ssssssssssssssssssssssend "); | 2024 | //qDebug("ssssssssssssssssssssssend "); |
2025 | QStringList nameList; | 2025 | QStringList nameList; |
2026 | QStringList emailList; | 2026 | QStringList emailList; |
2027 | QStringList uidList; | 2027 | QStringList uidList; |
2028 | nameList.append(adrr.realName()); | 2028 | nameList.append(adrr.realName()); |
2029 | emailList = adrr.emails(); | 2029 | emailList = adrr.emails(); |
2030 | uidList.append( adrr.preferredEmail()); | 2030 | uidList.append( adrr.preferredEmail()); |
2031 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2031 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2032 | return; | 2032 | return; |
2033 | } | 2033 | } |
2034 | 2034 | ||
2035 | } | 2035 | } |
2036 | 2036 | ||
2037 | if ( email == "sendbacklist" ) | 2037 | if ( email == "sendbacklist" ) |
2038 | return; | 2038 | return; |
2039 | if (foundUid.isEmpty()) | 2039 | if (foundUid.isEmpty()) |
2040 | { | 2040 | { |
2041 | //find the uid of the person first | 2041 | //find the uid of the person first |
2042 | Addressee::List namelist; | 2042 | Addressee::List namelist; |
2043 | Addressee::List emaillist; | 2043 | Addressee::List emaillist; |
2044 | 2044 | ||
2045 | if (!name.isEmpty()) | 2045 | if (!name.isEmpty()) |
2046 | namelist = mAddressBook->findByName( name ); | 2046 | namelist = mAddressBook->findByName( name ); |
2047 | 2047 | ||
2048 | if (!email.isEmpty()) | 2048 | if (!email.isEmpty()) |
2049 | emaillist = mAddressBook->findByEmail( email ); | 2049 | emaillist = mAddressBook->findByEmail( email ); |
2050 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2050 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2051 | //check if we have a match in Namelist and Emaillist | 2051 | //check if we have a match in Namelist and Emaillist |
2052 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2052 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2053 | foundUid = emaillist[0].uid(); | 2053 | foundUid = emaillist[0].uid(); |
2054 | } | 2054 | } |
2055 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2055 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2056 | foundUid = namelist[0].uid(); | 2056 | foundUid = namelist[0].uid(); |
2057 | else | 2057 | else |
2058 | { | 2058 | { |
2059 | for (int i = 0; i < namelist.count(); i++) | 2059 | for (int i = 0; i < namelist.count(); i++) |
2060 | { | 2060 | { |
2061 | for (int j = 0; j < emaillist.count(); j++) | 2061 | for (int j = 0; j < emaillist.count(); j++) |
2062 | { | 2062 | { |
2063 | if (namelist[i] == emaillist[j]) | 2063 | if (namelist[i] == emaillist[j]) |
2064 | { | 2064 | { |
2065 | foundUid = namelist[i].uid(); | 2065 | foundUid = namelist[i].uid(); |
2066 | } | 2066 | } |
2067 | } | 2067 | } |
2068 | } | 2068 | } |
2069 | } | 2069 | } |
2070 | } | 2070 | } |
2071 | else | 2071 | else |
2072 | { | 2072 | { |
2073 | foundUid = uid; | 2073 | foundUid = uid; |
2074 | } | 2074 | } |
2075 | 2075 | ||
2076 | if (!foundUid.isEmpty()) | 2076 | if (!foundUid.isEmpty()) |
2077 | { | 2077 | { |
2078 | 2078 | ||
2079 | // raise Ka/Pi if it is in the background | 2079 | // raise Ka/Pi if it is in the background |
2080 | #ifndef DESKTOP_VERSION | 2080 | #ifndef DESKTOP_VERSION |
2081 | #ifndef KORG_NODCOP | 2081 | #ifndef KORG_NODCOP |
2082 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2082 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2083 | #endif | 2083 | #endif |
2084 | #endif | 2084 | #endif |
2085 | 2085 | ||
2086 | mMainWindow->showMaximized(); | 2086 | mMainWindow->showMaximized(); |
2087 | mMainWindow-> raise(); | 2087 | mMainWindow-> raise(); |
2088 | 2088 | ||
2089 | mViewManager->setSelected( "", false); | 2089 | mViewManager->setSelected( "", false); |
2090 | mViewManager->refreshView( "" ); | 2090 | mViewManager->refreshView( "" ); |
2091 | mViewManager->setSelected( foundUid, true ); | 2091 | mViewManager->setSelected( foundUid, true ); |
2092 | mViewManager->refreshView( foundUid ); | 2092 | mViewManager->refreshView( foundUid ); |
2093 | 2093 | ||
2094 | if ( !mMultipleViewsAtOnce ) | 2094 | if ( !mMultipleViewsAtOnce ) |
2095 | { | 2095 | { |
2096 | setDetailsVisible( true ); | 2096 | setDetailsVisible( true ); |
2097 | mActionDetails->setChecked(true); | 2097 | mActionDetails->setChecked(true); |
2098 | } | 2098 | } |
2099 | } | 2099 | } |
2100 | } | 2100 | } |
2101 | 2101 | ||
2102 | 2102 | ||
2103 | void KABCore::faq() | 2103 | void KABCore::faq() |
2104 | { | 2104 | { |
2105 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2105 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2106 | } | 2106 | } |
2107 | 2107 | ||
2108 | 2108 | ||
2109 | void KABCore::fillSyncMenu() | 2109 | void KABCore::fillSyncMenu() |
2110 | { | 2110 | { |
2111 | if ( syncMenu->count() ) | 2111 | if ( syncMenu->count() ) |
2112 | syncMenu->clear(); | 2112 | syncMenu->clear(); |
2113 | syncMenu->insertItem( i18n("Configure..."), 0 ); | 2113 | syncMenu->insertItem( i18n("Configure..."), 0 ); |
2114 | syncMenu->insertSeparator(); | 2114 | syncMenu->insertSeparator(); |
2115 | syncMenu->insertItem( i18n("Multiple sync"), 1 ); | 2115 | syncMenu->insertItem( i18n("Multiple sync"), 1 ); |
2116 | syncMenu->insertSeparator(); | 2116 | syncMenu->insertSeparator(); |
2117 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 2117 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
2118 | config.setGroup("General"); | 2118 | config.setGroup("General"); |
2119 | QStringList prof = config.readListEntry("SyncProfileNames"); | 2119 | QStringList prof = config.readListEntry("SyncProfileNames"); |
2120 | KABPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | 2120 | KABPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); |
2121 | if ( prof.count() < 3 ) { | 2121 | if ( prof.count() < 3 ) { |
2122 | prof.clear(); | 2122 | prof.clear(); |
2123 | prof << i18n("Sharp_DTM"); | 2123 | prof << i18n("Sharp_DTM"); |
2124 | prof << i18n("Local_file"); | 2124 | prof << i18n("Local_file"); |
2125 | prof << i18n("Last_file"); | 2125 | prof << i18n("Last_file"); |
2126 | KSyncProfile* temp = new KSyncProfile (); | 2126 | KSyncProfile* temp = new KSyncProfile (); |
2127 | temp->setName( prof[0] ); | 2127 | temp->setName( prof[0] ); |
2128 | temp->writeConfig(&config); | 2128 | temp->writeConfig(&config); |
2129 | temp->setName( prof[1] ); | 2129 | temp->setName( prof[1] ); |
2130 | temp->writeConfig(&config); | 2130 | temp->writeConfig(&config); |
2131 | temp->setName( prof[2] ); | 2131 | temp->setName( prof[2] ); |
2132 | temp->writeConfig(&config); | 2132 | temp->writeConfig(&config); |
2133 | config.setGroup("General"); | 2133 | config.setGroup("General"); |
2134 | config.writeEntry("SyncProfileNames",prof); | 2134 | config.writeEntry("SyncProfileNames",prof); |
2135 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); | 2135 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); |
2136 | config.sync(); | 2136 | config.sync(); |
2137 | delete temp; | 2137 | delete temp; |
2138 | } | 2138 | } |
2139 | KABPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 2139 | KABPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
2140 | KABPrefs::instance()->mSyncProfileNames = prof; | 2140 | KABPrefs::instance()->mSyncProfileNames = prof; |
2141 | int i; | 2141 | int i; |
2142 | for ( i = 0; i < prof.count(); ++i ) { | 2142 | for ( i = 0; i < prof.count(); ++i ) { |
2143 | 2143 | ||
2144 | syncMenu->insertItem( prof[i], 1000+i ); | 2144 | syncMenu->insertItem( prof[i], 1000+i ); |
2145 | if ( i == 2 ) | 2145 | if ( i == 2 ) |
2146 | syncMenu->insertSeparator(); | 2146 | syncMenu->insertSeparator(); |
2147 | } | 2147 | } |
2148 | QDir app_dir; | 2148 | QDir app_dir; |
2149 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 2149 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
2150 | syncMenu->setItemEnabled( false , 1000 ); | 2150 | syncMenu->setItemEnabled( false , 1000 ); |
2151 | } | 2151 | } |
2152 | //probaly useless | 2152 | //probaly useless |
2153 | //mView->setupExternSyncProfiles(); | 2153 | //mView->setupExternSyncProfiles(); |
2154 | } | 2154 | } |
2155 | void KABCore::slotSyncMenu( int action ) | 2155 | void KABCore::slotSyncMenu( int action ) |
2156 | { | 2156 | { |
2157 | //qDebug("syncaction %d ", action); | 2157 | //qDebug("syncaction %d ", action); |
2158 | if ( action == 0 ) { | 2158 | if ( action == 0 ) { |
2159 | 2159 | ||
2160 | // seems to be a Qt2 event handling bug | 2160 | // seems to be a Qt2 event handling bug |
2161 | // syncmenu.clear causes a segfault at first time | 2161 | // syncmenu.clear causes a segfault at first time |
2162 | // when we call it after the main event loop, it is ok | 2162 | // when we call it after the main event loop, it is ok |
2163 | // same behaviour when calling OM/Pi via QCOP for the first time | 2163 | // same behaviour when calling OM/Pi via QCOP for the first time |
2164 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 2164 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
2165 | //confSync(); | 2165 | //confSync(); |
2166 | 2166 | ||
2167 | return; | 2167 | return; |
2168 | } | 2168 | } |
2169 | if ( action == 1 ) { | 2169 | if ( action == 1 ) { |
2170 | multiSync( true ); | 2170 | multiSync( true ); |
2171 | return; | 2171 | return; |
2172 | } | 2172 | } |
2173 | 2173 | ||
2174 | if (mBlockSaveFlag) | 2174 | if (mBlockSaveFlag) |
2175 | return; | 2175 | return; |
2176 | mBlockSaveFlag = true; | 2176 | mBlockSaveFlag = true; |
2177 | mCurrentSyncProfile = action - 1000 ; | 2177 | mCurrentSyncProfile = action - 1000 ; |
2178 | mCurrentSyncDevice = KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ; | 2178 | mCurrentSyncDevice = KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ; |
2179 | mCurrentSyncName = KABPrefs::instance()->mLocalMachineName ; | 2179 | mCurrentSyncName = KABPrefs::instance()->mLocalMachineName ; |
2180 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 2180 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
2181 | KSyncProfile* temp = new KSyncProfile (); | 2181 | KSyncProfile* temp = new KSyncProfile (); |
2182 | temp->setName(KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 2182 | temp->setName(KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
2183 | temp->readConfig(&config); | 2183 | temp->readConfig(&config); |
2184 | KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 2184 | KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
2185 | KABPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); | 2185 | KABPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); |
2186 | KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 2186 | KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
2187 | KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 2187 | KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
2188 | KABPrefs::instance()->mWriteBackInFuture = 0; | 2188 | KABPrefs::instance()->mWriteBackInFuture = 0; |
2189 | if ( temp->getWriteBackFuture() ) | 2189 | if ( temp->getWriteBackFuture() ) |
2190 | KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 2190 | KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
2191 | KABPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); | 2191 | KABPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); |
2192 | if ( action == 1000 ) { | 2192 | if ( action == 1000 ) { |
2193 | syncSharp(); | 2193 | syncSharp(); |
2194 | 2194 | ||
2195 | } else if ( action == 1001 ) { | 2195 | } else if ( action == 1001 ) { |
2196 | syncLocalFile(); | 2196 | syncLocalFile(); |
2197 | 2197 | ||
2198 | } else if ( action == 1002 ) { | 2198 | } else if ( action == 1002 ) { |
2199 | quickSyncLocalFile(); | 2199 | quickSyncLocalFile(); |
2200 | 2200 | ||
2201 | } else if ( action >= 1003 ) { | 2201 | } else if ( action >= 1003 ) { |
2202 | if ( temp->getIsLocalFileSync() ) { | 2202 | if ( temp->getIsLocalFileSync() ) { |
2203 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 2203 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
2204 | KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 2204 | KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
2205 | } else { | 2205 | } else { |
2206 | if ( temp->getIsPhoneSync() ) { | 2206 | if ( temp->getIsPhoneSync() ) { |
2207 | KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | 2207 | KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; |
2208 | KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | 2208 | KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); |
2209 | KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | 2209 | KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); |
2210 | syncPhone(); | 2210 | syncPhone(); |
2211 | } else | 2211 | } else |
2212 | syncRemote( temp ); | 2212 | syncRemote( temp ); |
2213 | 2213 | ||
2214 | } | 2214 | } |
2215 | } | 2215 | } |
2216 | delete temp; | 2216 | delete temp; |
2217 | mBlockSaveFlag = false; | 2217 | mBlockSaveFlag = false; |
2218 | } | 2218 | } |
2219 | 2219 | ||
2220 | void KABCore::syncLocalFile() | 2220 | void KABCore::syncLocalFile() |
2221 | { | 2221 | { |
2222 | 2222 | ||
2223 | QString fn =KABPrefs::instance()->mLastSyncedLocalFile; | 2223 | QString fn =KABPrefs::instance()->mLastSyncedLocalFile; |
2224 | 2224 | ||
2225 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); | 2225 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); |
2226 | if ( fn == "" ) | 2226 | if ( fn == "" ) |
2227 | return; | 2227 | return; |
2228 | if ( syncWithFile( fn, false ) ) { | 2228 | if ( syncWithFile( fn, false ) ) { |
2229 | qDebug("syncLocalFile() successful "); | 2229 | qDebug("syncLocalFile() successful "); |
2230 | } | 2230 | } |
2231 | 2231 | ||
2232 | } | 2232 | } |
2233 | bool KABCore::syncWithFile( QString fn , bool quick ) | 2233 | bool KABCore::syncWithFile( QString fn , bool quick ) |
2234 | { | 2234 | { |
2235 | bool ret = false; | 2235 | bool ret = false; |
2236 | QFileInfo info; | 2236 | QFileInfo info; |
2237 | info.setFile( fn ); | 2237 | info.setFile( fn ); |
2238 | QString mess; | 2238 | QString mess; |
2239 | bool loadbup = true; | 2239 | bool loadbup = true; |
2240 | if ( !info. exists() ) { | 2240 | if ( !info. exists() ) { |
2241 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 2241 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
2242 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2242 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2243 | mess ); | 2243 | mess ); |
2244 | return ret; | 2244 | return ret; |
2245 | } | 2245 | } |
2246 | int result = 0; | 2246 | int result = 0; |
2247 | if ( !quick ) { | 2247 | if ( !quick ) { |
2248 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 2248 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
2249 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2249 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2250 | mess, | 2250 | mess, |
2251 | i18n("Sync"), i18n("Cancel"), 0, | 2251 | i18n("Sync"), i18n("Cancel"), 0, |
2252 | 0, 1 ); | 2252 | 0, 1 ); |
2253 | if ( result ) | 2253 | if ( result ) |
2254 | return false; | 2254 | return false; |
2255 | } | 2255 | } |
2256 | if ( KABPrefs::instance()->mAskForPreferences ) | 2256 | if ( KABPrefs::instance()->mAskForPreferences ) |
2257 | edit_sync_options(); | 2257 | edit_sync_options(); |
2258 | if ( result == 0 ) { | 2258 | if ( result == 0 ) { |
2259 | //qDebug("Now sycing ... "); | 2259 | //qDebug("Now sycing ... "); |
2260 | if ( ret = syncAB( fn, KABPrefs::instance()->mSyncAlgoPrefs ) ) | 2260 | if ( ret = syncAB( fn, KABPrefs::instance()->mSyncAlgoPrefs ) ) |
2261 | setCaption( i18n("Synchronization successful") ); | 2261 | setCaption( i18n("Synchronization successful") ); |
2262 | else | 2262 | else |
2263 | setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); | 2263 | setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); |
2264 | if ( ! quick ) | 2264 | if ( ! quick ) |
2265 | KABPrefs::instance()->mLastSyncedLocalFile = fn; | 2265 | KABPrefs::instance()->mLastSyncedLocalFile = fn; |
2266 | setModified(); | 2266 | setModified(); |
2267 | } | 2267 | } |
2268 | return ret; | 2268 | return ret; |
2269 | } | 2269 | } |
2270 | void KABCore::quickSyncLocalFile() | 2270 | void KABCore::quickSyncLocalFile() |
2271 | { | 2271 | { |
2272 | 2272 | ||
2273 | if ( syncWithFile( KABPrefs::instance()->mLastSyncedLocalFile, false ) ) { | 2273 | if ( syncWithFile( KABPrefs::instance()->mLastSyncedLocalFile, false ) ) { |
2274 | qDebug("quick syncLocalFile() successful "); | 2274 | qDebug("quick syncLocalFile() successful "); |
2275 | 2275 | ||
2276 | } | 2276 | } |
2277 | } | 2277 | } |
2278 | void KABCore::multiSync( bool askforPrefs ) | 2278 | void KABCore::multiSync( bool askforPrefs ) |
2279 | { | 2279 | { |
2280 | if (mBlockSaveFlag) | 2280 | if (mBlockSaveFlag) |
2281 | return; | 2281 | return; |
2282 | mBlockSaveFlag = true; | 2282 | mBlockSaveFlag = true; |
2283 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 2283 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
2284 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | 2284 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), |
2285 | question, | 2285 | question, |
2286 | i18n("Yes"), i18n("No"), | 2286 | i18n("Yes"), i18n("No"), |
2287 | 0, 0 ) != 0 ) { | 2287 | 0, 0 ) != 0 ) { |
2288 | mBlockSaveFlag = false; | 2288 | mBlockSaveFlag = false; |
2289 | setCaption(i18n("Aborted! Nothing synced!")); | 2289 | setCaption(i18n("Aborted! Nothing synced!")); |
2290 | return; | 2290 | return; |
2291 | } | 2291 | } |
2292 | mCurrentSyncDevice = i18n("Multiple profiles") ; | 2292 | mCurrentSyncDevice = i18n("Multiple profiles") ; |
2293 | KABPrefs::instance()->mSyncAlgoPrefs = KABPrefs::instance()->mRingSyncAlgoPrefs; | 2293 | KABPrefs::instance()->mSyncAlgoPrefs = KABPrefs::instance()->mRingSyncAlgoPrefs; |
2294 | if ( askforPrefs ) { | 2294 | if ( askforPrefs ) { |
2295 | edit_sync_options(); | 2295 | edit_sync_options(); |
2296 | KABPrefs::instance()->mRingSyncAlgoPrefs = KABPrefs::instance()->mSyncAlgoPrefs; | 2296 | KABPrefs::instance()->mRingSyncAlgoPrefs = KABPrefs::instance()->mSyncAlgoPrefs; |
2297 | } | 2297 | } |
2298 | setCaption(i18n("Multiple sync started.") ); | 2298 | setCaption(i18n("Multiple sync started.") ); |
2299 | qApp->processEvents(); | 2299 | qApp->processEvents(); |
2300 | int num = ringSync() ; | 2300 | int num = ringSync() ; |
2301 | if ( num > 1 ) | 2301 | if ( num > 1 ) |
2302 | ringSync(); | 2302 | ringSync(); |
2303 | mBlockSaveFlag = false; | 2303 | mBlockSaveFlag = false; |
2304 | if ( num ) | 2304 | if ( num ) |
2305 | save(); | 2305 | save(); |
2306 | if ( num ) | 2306 | if ( num ) |
2307 | setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); | 2307 | setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); |
2308 | else | 2308 | else |
2309 | setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 2309 | setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
2310 | return; | 2310 | return; |
2311 | } | 2311 | } |
2312 | int KABCore::ringSync() | 2312 | int KABCore::ringSync() |
2313 | { | 2313 | { |
2314 | int syncedProfiles = 0; | 2314 | int syncedProfiles = 0; |
2315 | int i; | 2315 | int i; |
2316 | QTime timer; | 2316 | QTime timer; |
2317 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 2317 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
2318 | QStringList syncProfileNames = KABPrefs::instance()->mSyncProfileNames; | 2318 | QStringList syncProfileNames = KABPrefs::instance()->mSyncProfileNames; |
2319 | KSyncProfile* temp = new KSyncProfile (); | 2319 | KSyncProfile* temp = new KSyncProfile (); |
2320 | KABPrefs::instance()->mAskForPreferences = false; | 2320 | KABPrefs::instance()->mAskForPreferences = false; |
2321 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 2321 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
2322 | mCurrentSyncProfile = i; | 2322 | mCurrentSyncProfile = i; |
2323 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 2323 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
2324 | temp->readConfig(&config); | 2324 | temp->readConfig(&config); |
2325 | if ( temp->getIncludeInRingSyncAB() && ( i < 1 || i > 2 )) { | 2325 | if ( temp->getIncludeInRingSyncAB() && ( i < 1 || i > 2 )) { |
2326 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 2326 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
2327 | ++syncedProfiles; | 2327 | ++syncedProfiles; |
2328 | // KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 2328 | // KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
2329 | KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 2329 | KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
2330 | KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 2330 | KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
2331 | KABPrefs::instance()->mWriteBackInFuture = 0; | 2331 | KABPrefs::instance()->mWriteBackInFuture = 0; |
2332 | if ( temp->getWriteBackFuture() ) | 2332 | if ( temp->getWriteBackFuture() ) |
2333 | KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 2333 | KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
2334 | KABPrefs::instance()->mShowSyncSummary = false; | 2334 | KABPrefs::instance()->mShowSyncSummary = false; |
2335 | mCurrentSyncDevice = syncProfileNames[i] ; | 2335 | mCurrentSyncDevice = syncProfileNames[i] ; |
2336 | mCurrentSyncName = KABPrefs::instance()->mLocalMachineName; | 2336 | mCurrentSyncName = KABPrefs::instance()->mLocalMachineName; |
2337 | if ( i == 0 ) { | 2337 | if ( i == 0 ) { |
2338 | syncSharp(); | 2338 | syncSharp(); |
2339 | } else { | 2339 | } else { |
2340 | if ( temp->getIsLocalFileSync() ) { | 2340 | if ( temp->getIsLocalFileSync() ) { |
2341 | if ( syncWithFile( temp->getRemoteFileNameAB( ), true ) ) | 2341 | if ( syncWithFile( temp->getRemoteFileNameAB( ), true ) ) |
2342 | KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 2342 | KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
2343 | } else { | 2343 | } else { |
2344 | if ( temp->getIsPhoneSync() ) { | 2344 | if ( temp->getIsPhoneSync() ) { |
2345 | KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | 2345 | KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; |
2346 | KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | 2346 | KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); |
2347 | KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | 2347 | KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); |
2348 | syncPhone(); | 2348 | syncPhone(); |
2349 | } else | 2349 | } else |
2350 | syncRemote( temp, false ); | 2350 | syncRemote( temp, false ); |
2351 | 2351 | ||
2352 | } | 2352 | } |
2353 | } | 2353 | } |
2354 | timer.start(); | 2354 | timer.start(); |
2355 | setCaption(i18n("Multiple sync in progress ... please wait!") ); | 2355 | setCaption(i18n("Multiple sync in progress ... please wait!") ); |
2356 | while ( timer.elapsed () < 2000 ) { | 2356 | while ( timer.elapsed () < 2000 ) { |
2357 | qApp->processEvents(); | 2357 | qApp->processEvents(); |
2358 | #ifndef _WIN32_ | 2358 | #ifndef _WIN32_ |
2359 | sleep (1); | 2359 | sleep (1); |
2360 | #endif | 2360 | #endif |
2361 | } | 2361 | } |
2362 | 2362 | ||
2363 | } | 2363 | } |
2364 | 2364 | ||
2365 | } | 2365 | } |
2366 | delete temp; | 2366 | delete temp; |
2367 | return syncedProfiles; | 2367 | return syncedProfiles; |
2368 | } | 2368 | } |
2369 | 2369 | ||
2370 | void KABCore::syncRemote( KSyncProfile* prof, bool ask) | 2370 | void KABCore::syncRemote( KSyncProfile* prof, bool ask) |
2371 | { | 2371 | { |
2372 | QString question; | 2372 | QString question; |
2373 | if ( ask ) { | 2373 | if ( ask ) { |
2374 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | 2374 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; |
2375 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | 2375 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), |
2376 | question, | 2376 | question, |
2377 | i18n("Yes"), i18n("No"), | 2377 | i18n("Yes"), i18n("No"), |
2378 | 0, 0 ) != 0 ) | 2378 | 0, 0 ) != 0 ) |
2379 | return; | 2379 | return; |
2380 | } | 2380 | } |
2381 | QString command = prof->getPreSyncCommandAB(); | 2381 | QString command = prof->getPreSyncCommandAB(); |
2382 | int fi; | 2382 | int fi; |
2383 | if ( (fi = command.find("$PWD$")) > 0 ) { | 2383 | if ( (fi = command.find("$PWD$")) > 0 ) { |
2384 | QString pwd = getPassword(); | 2384 | QString pwd = getPassword(); |
2385 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | 2385 | command = command.left( fi )+ pwd + command.mid( fi+5 ); |
2386 | 2386 | ||
2387 | } | 2387 | } |
2388 | int maxlen = 30; | 2388 | int maxlen = 30; |
2389 | if ( QApplication::desktop()->width() > 320 ) | 2389 | if ( QApplication::desktop()->width() > 320 ) |
2390 | maxlen += 25; | 2390 | maxlen += 25; |
2391 | setCaption ( i18n( "Copy remote file to local machine..." ) ); | 2391 | setCaption ( i18n( "Copy remote file to local machine..." ) ); |
2392 | int fileSize = 0; | 2392 | int fileSize = 0; |
2393 | int result = system ( command ); | 2393 | int result = system ( command ); |
2394 | // 0 : okay | 2394 | // 0 : okay |
2395 | // 256: no such file or dir | 2395 | // 256: no such file or dir |
2396 | // | 2396 | // |
2397 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); | 2397 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); |
2398 | if ( result != 0 ) { | 2398 | if ( result != 0 ) { |
2399 | int len = maxlen; | 2399 | int len = maxlen; |
2400 | while ( len < command.length() ) { | 2400 | while ( len < command.length() ) { |
2401 | command.insert( len , "\n" ); | 2401 | command.insert( len , "\n" ); |
2402 | len += maxlen +2; | 2402 | len += maxlen +2; |
2403 | } | 2403 | } |
2404 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; | 2404 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; |
2405 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), | 2405 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), |
2406 | question, | 2406 | question, |
2407 | i18n("Okay!")) ; | 2407 | i18n("Okay!")) ; |
2408 | setCaption ("KO/Pi"); | 2408 | setCaption ("KO/Pi"); |
2409 | return; | 2409 | return; |
2410 | } | 2410 | } |
2411 | setCaption ( i18n( "Copying succeed." ) ); | 2411 | setCaption ( i18n( "Copying succeed." ) ); |
2412 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | 2412 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); |
2413 | if ( syncWithFile( prof->getLocalTempFileAB(), true ) ) { | 2413 | if ( syncWithFile( prof->getLocalTempFileAB(), true ) ) { |
2414 | // Event* e = mView->getLastSyncEvent(); | 2414 | // Event* e = mView->getLastSyncEvent(); |
2415 | // e->setReadOnly( false ); | 2415 | // e->setReadOnly( false ); |
2416 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 2416 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
2417 | // e->setReadOnly( true ); | 2417 | // e->setReadOnly( true ); |
2418 | if ( KABPrefs::instance()->mWriteBackFile ) { | 2418 | if ( KABPrefs::instance()->mWriteBackFile ) { |
2419 | command = prof->getPostSyncCommandAB(); | 2419 | command = prof->getPostSyncCommandAB(); |
2420 | int fi; | 2420 | int fi; |
2421 | if ( (fi = command.find("$PWD$")) > 0 ) { | 2421 | if ( (fi = command.find("$PWD$")) > 0 ) { |
2422 | QString pwd = getPassword(); | 2422 | QString pwd = getPassword(); |
2423 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | 2423 | command = command.left( fi )+ pwd + command.mid( fi+5 ); |
2424 | 2424 | ||
2425 | } | 2425 | } |
2426 | setCaption ( i18n( "Writing back file ..." ) ); | 2426 | setCaption ( i18n( "Writing back file ..." ) ); |
2427 | result = system ( command ); | 2427 | result = system ( command ); |
2428 | qDebug("KO: Writing back file result: %d ", result); | 2428 | qDebug("KO: Writing back file result: %d ", result); |
2429 | if ( result != 0 ) { | 2429 | if ( result != 0 ) { |
2430 | setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | 2430 | setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); |
2431 | return; | 2431 | return; |
2432 | } else { | 2432 | } else { |
2433 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 2433 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
2434 | } | 2434 | } |
2435 | } | 2435 | } |
2436 | } | 2436 | } |
2437 | return; | 2437 | return; |
2438 | } | 2438 | } |
2439 | #include <qpushbutton.h> | 2439 | #include <qpushbutton.h> |
2440 | #include <qradiobutton.h> | 2440 | #include <qradiobutton.h> |
2441 | #include <qbuttongroup.h> | 2441 | #include <qbuttongroup.h> |
2442 | void KABCore::edit_sync_options() | 2442 | void KABCore::edit_sync_options() |
2443 | { | 2443 | { |
2444 | //mDialogManager->showSyncOptions(); | 2444 | //mDialogManager->showSyncOptions(); |
2445 | //KABPrefs::instance()->mSyncAlgoPrefs | 2445 | //KABPrefs::instance()->mSyncAlgoPrefs |
2446 | QDialog dia( this, "dia", true ); | 2446 | QDialog dia( this, "dia", true ); |
2447 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 2447 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
2448 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 2448 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
2449 | QVBoxLayout lay ( &dia ); | 2449 | QVBoxLayout lay ( &dia ); |
2450 | lay.setSpacing( 2 ); | 2450 | lay.setSpacing( 2 ); |
2451 | lay.setMargin( 3 ); | 2451 | lay.setMargin( 3 ); |
2452 | lay.addWidget(&gr); | 2452 | lay.addWidget(&gr); |
2453 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 2453 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
2454 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 2454 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
2455 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 2455 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
2456 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 2456 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
2457 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 2457 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
2458 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 2458 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
2459 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 2459 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
2460 | QPushButton pb ( "OK", &dia); | 2460 | QPushButton pb ( "OK", &dia); |
2461 | lay.addWidget( &pb ); | 2461 | lay.addWidget( &pb ); |
2462 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2462 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2463 | switch ( KABPrefs::instance()->mSyncAlgoPrefs ) { | 2463 | switch ( KABPrefs::instance()->mSyncAlgoPrefs ) { |
2464 | case 0: | 2464 | case 0: |
2465 | loc.setChecked( true); | 2465 | loc.setChecked( true); |
2466 | break; | 2466 | break; |
2467 | case 1: | 2467 | case 1: |
2468 | rem.setChecked( true ); | 2468 | rem.setChecked( true ); |
2469 | break; | 2469 | break; |
2470 | case 2: | 2470 | case 2: |
2471 | newest.setChecked( true); | 2471 | newest.setChecked( true); |
2472 | break; | 2472 | break; |
2473 | case 3: | 2473 | case 3: |
2474 | ask.setChecked( true); | 2474 | ask.setChecked( true); |
2475 | break; | 2475 | break; |
2476 | case 4: | 2476 | case 4: |
2477 | f_loc.setChecked( true); | 2477 | f_loc.setChecked( true); |
2478 | break; | 2478 | break; |
2479 | case 5: | 2479 | case 5: |
2480 | f_rem.setChecked( true); | 2480 | f_rem.setChecked( true); |
2481 | break; | 2481 | break; |
2482 | case 6: | 2482 | case 6: |
2483 | // both.setChecked( true); | 2483 | // both.setChecked( true); |
2484 | break; | 2484 | break; |
2485 | default: | 2485 | default: |
2486 | break; | 2486 | break; |
2487 | } | 2487 | } |
2488 | if ( dia.exec() ) { | 2488 | if ( dia.exec() ) { |
2489 | KABPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 2489 | KABPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
2490 | } | 2490 | } |
2491 | 2491 | ||
2492 | 2492 | ||
2493 | } | 2493 | } |
2494 | QString KABCore::getPassword( ) | 2494 | QString KABCore::getPassword( ) |
2495 | { | 2495 | { |
2496 | QString retfile = ""; | 2496 | QString retfile = ""; |
2497 | QDialog dia ( this, "input-dialog", true ); | 2497 | QDialog dia ( this, "input-dialog", true ); |
2498 | QLineEdit lab ( &dia ); | 2498 | QLineEdit lab ( &dia ); |
2499 | lab.setEchoMode( QLineEdit::Password ); | 2499 | lab.setEchoMode( QLineEdit::Password ); |
2500 | QVBoxLayout lay( &dia ); | 2500 | QVBoxLayout lay( &dia ); |
2501 | lay.setMargin(7); | 2501 | lay.setMargin(7); |
2502 | lay.setSpacing(7); | 2502 | lay.setSpacing(7); |
2503 | lay.addWidget( &lab); | 2503 | lay.addWidget( &lab); |
2504 | dia.setFixedSize( 230,50 ); | 2504 | dia.setFixedSize( 230,50 ); |
2505 | dia.setCaption( i18n("Enter password") ); | 2505 | dia.setCaption( i18n("Enter password") ); |
2506 | QPushButton pb ( "OK", &dia); | 2506 | QPushButton pb ( "OK", &dia); |
2507 | lay.addWidget( &pb ); | 2507 | lay.addWidget( &pb ); |
2508 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2508 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2509 | dia.show(); | 2509 | dia.show(); |
2510 | int res = dia.exec(); | 2510 | int res = dia.exec(); |
2511 | if ( res ) | 2511 | if ( res ) |
2512 | retfile = lab.text(); | 2512 | retfile = lab.text(); |
2513 | dia.hide(); | 2513 | dia.hide(); |
2514 | qApp->processEvents(); | 2514 | qApp->processEvents(); |
2515 | return retfile; | 2515 | return retfile; |
2516 | 2516 | ||
2517 | } | 2517 | } |
2518 | #include <libkcal/syncdefines.h> | 2518 | #include <libkcal/syncdefines.h> |
2519 | 2519 | ||
2520 | KABC::Addressee KABCore::getLastSyncAddressee() | 2520 | KABC::Addressee KABCore::getLastSyncAddressee() |
2521 | { | 2521 | { |
2522 | Addressee lse; | 2522 | Addressee lse; |
2523 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2523 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2524 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2524 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2525 | if (lse.isEmpty()) { | 2525 | if (lse.isEmpty()) { |
2526 | qDebug("Creating new last-syncAddressee "); | 2526 | qDebug("Creating new last-syncAddressee "); |
2527 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2527 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2528 | QString sum = ""; | 2528 | QString sum = ""; |
2529 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2529 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2530 | sum = "E: "; | 2530 | sum = "E: "; |
2531 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2531 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2532 | lse.setRevision( mLastAddressbookSync ); | 2532 | lse.setRevision( mLastAddressbookSync ); |
2533 | lse.setCategories( i18n("SyncEvent") ); | 2533 | lse.setCategories( i18n("SyncEvent") ); |
2534 | mAddressBook->insertAddressee( lse ); | 2534 | mAddressBook->insertAddressee( lse ); |
2535 | } | 2535 | } |
2536 | return lse; | 2536 | return lse; |
2537 | } | 2537 | } |
2538 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2538 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2539 | { | 2539 | { |
2540 | 2540 | ||
2541 | //void setZaurusId(int id); | 2541 | //void setZaurusId(int id); |
2542 | // int zaurusId() const; | 2542 | // int zaurusId() const; |
2543 | // void setZaurusUid(int id); | 2543 | // void setZaurusUid(int id); |
2544 | // int zaurusUid() const; | 2544 | // int zaurusUid() const; |
2545 | // void setZaurusStat(int id); | 2545 | // void setZaurusStat(int id); |
2546 | // int zaurusStat() const; | 2546 | // int zaurusStat() const; |
2547 | // 0 equal | 2547 | // 0 equal |
2548 | // 1 take local | 2548 | // 1 take local |
2549 | // 2 take remote | 2549 | // 2 take remote |
2550 | // 3 cancel | 2550 | // 3 cancel |
2551 | QDateTime lastSync = mLastAddressbookSync; | 2551 | QDateTime lastSync = mLastAddressbookSync; |
2552 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2552 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2553 | bool remCh, locCh; | 2553 | bool remCh, locCh; |
2554 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2554 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2555 | if ( remCh ) | 2555 | |
2556 | qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2556 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2557 | locCh = ( local->revision() > mLastAddressbookSync ); | 2557 | locCh = ( local->revision() > mLastAddressbookSync ); |
2558 | if ( !remCh && ! locCh ) { | 2558 | if ( !remCh && ! locCh ) { |
2559 | qDebug("both not changed "); | 2559 | //qDebug("both not changed "); |
2560 | lastSync = local->revision().addDays(1); | 2560 | lastSync = local->revision().addDays(1); |
2561 | if ( mode <= SYNC_PREF_ASK ) | 2561 | if ( mode <= SYNC_PREF_ASK ) |
2562 | return 0; | 2562 | return 0; |
2563 | } else { | 2563 | } else { |
2564 | if ( locCh ) { | 2564 | if ( locCh ) { |
2565 | qDebug("loc changed %s %s", local->revision().toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2565 | //qDebug("loc changed %s %s", local->revision().toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2566 | lastSync = local->revision().addDays( -1 ); | 2566 | lastSync = local->revision().addDays( -1 ); |
2567 | if ( !remCh ) | 2567 | if ( !remCh ) |
2568 | remote->setRevision( lastSync.addDays( -1 ) ); | 2568 | remote->setRevision( lastSync.addDays( -1 ) ); |
2569 | } else { | 2569 | } else { |
2570 | //qDebug(" not loc changed "); | 2570 | //qDebug(" not loc changed "); |
2571 | lastSync = local->revision().addDays( 1 ); | 2571 | lastSync = local->revision().addDays( 1 ); |
2572 | if ( remCh ) | 2572 | if ( remCh ) |
2573 | remote->setRevision( lastSync.addDays( 1 ) ); | 2573 | remote->setRevision( lastSync.addDays( 1 ) ); |
2574 | 2574 | ||
2575 | } | 2575 | } |
2576 | } | 2576 | } |
2577 | full = true; | 2577 | full = true; |
2578 | if ( mode < SYNC_PREF_ASK ) | 2578 | if ( mode < SYNC_PREF_ASK ) |
2579 | mode = SYNC_PREF_ASK; | 2579 | mode = SYNC_PREF_ASK; |
2580 | } else { | 2580 | } else { |
2581 | if ( local->revision() == remote->revision() ) | 2581 | if ( local->revision() == remote->revision() ) |
2582 | return 0; | 2582 | return 0; |
2583 | 2583 | ||
2584 | } | 2584 | } |
2585 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 2585 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
2586 | 2586 | ||
2587 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); | 2587 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); |
2588 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 2588 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
2589 | //full = true; //debug only | 2589 | //full = true; //debug only |
2590 | if ( full ) { | 2590 | if ( full ) { |
2591 | bool equ = ( (*local) == (*remote) ); | 2591 | bool equ = ( (*local) == (*remote) ); |
2592 | if ( equ ) { | 2592 | if ( equ ) { |
2593 | //qDebug("equal "); | 2593 | //qDebug("equal "); |
2594 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2594 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2595 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2595 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2596 | } | 2596 | } |
2597 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2597 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2598 | return 0; | 2598 | return 0; |
2599 | 2599 | ||
2600 | }//else //debug only | 2600 | }//else //debug only |
2601 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2601 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2602 | } | 2602 | } |
2603 | int result; | 2603 | int result; |
2604 | bool localIsNew; | 2604 | bool localIsNew; |
2605 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); | 2605 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); |
2606 | 2606 | ||
2607 | if ( full && mode < SYNC_PREF_NEWEST ) | 2607 | if ( full && mode < SYNC_PREF_NEWEST ) |
2608 | mode = SYNC_PREF_ASK; | 2608 | mode = SYNC_PREF_ASK; |
2609 | 2609 | ||
2610 | switch( mode ) { | 2610 | switch( mode ) { |
2611 | case SYNC_PREF_LOCAL: | 2611 | case SYNC_PREF_LOCAL: |
2612 | if ( lastSync > remote->revision() ) | 2612 | if ( lastSync > remote->revision() ) |
2613 | return 1; | 2613 | return 1; |
2614 | if ( lastSync > local->revision() ) | 2614 | if ( lastSync > local->revision() ) |
2615 | return 2; | 2615 | return 2; |
2616 | return 1; | 2616 | return 1; |
2617 | break; | 2617 | break; |
2618 | case SYNC_PREF_REMOTE: | 2618 | case SYNC_PREF_REMOTE: |
2619 | if ( lastSync > remote->revision() ) | 2619 | if ( lastSync > remote->revision() ) |
2620 | return 1; | 2620 | return 1; |
2621 | if ( lastSync > local->revision() ) | 2621 | if ( lastSync > local->revision() ) |
2622 | return 2; | 2622 | return 2; |
2623 | return 2; | 2623 | return 2; |
2624 | break; | 2624 | break; |
2625 | case SYNC_PREF_NEWEST: | 2625 | case SYNC_PREF_NEWEST: |
2626 | if ( local->revision() > remote->revision() ) | 2626 | if ( local->revision() > remote->revision() ) |
2627 | return 1; | 2627 | return 1; |
2628 | else | 2628 | else |
2629 | return 2; | 2629 | return 2; |
2630 | break; | 2630 | break; |
2631 | case SYNC_PREF_ASK: | 2631 | case SYNC_PREF_ASK: |
2632 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->revision().toString().latin1(), remote->revision().toString().latin1() ); | 2632 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->revision().toString().latin1(), remote->revision().toString().latin1() ); |
2633 | if ( lastSync > remote->revision() ) | 2633 | if ( lastSync > remote->revision() ) |
2634 | return 1; | 2634 | return 1; |
2635 | if ( lastSync > local->revision() ) | 2635 | if ( lastSync > local->revision() ) |
2636 | return 2; | 2636 | return 2; |
2637 | localIsNew = local->revision() >= remote->revision(); | 2637 | localIsNew = local->revision() >= remote->revision(); |
2638 | //qDebug("conflict! ************************************** "); | 2638 | //qDebug("conflict! ************************************** "); |
2639 | { | 2639 | { |
2640 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2640 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2641 | result = acd.executeD(localIsNew); | 2641 | result = acd.executeD(localIsNew); |
2642 | return result; | 2642 | return result; |
2643 | } | 2643 | } |
2644 | break; | 2644 | break; |
2645 | case SYNC_PREF_FORCE_LOCAL: | 2645 | case SYNC_PREF_FORCE_LOCAL: |
2646 | return 1; | 2646 | return 1; |
2647 | break; | 2647 | break; |
2648 | case SYNC_PREF_FORCE_REMOTE: | 2648 | case SYNC_PREF_FORCE_REMOTE: |
2649 | return 2; | 2649 | return 2; |
2650 | break; | 2650 | break; |
2651 | 2651 | ||
2652 | default: | 2652 | default: |
2653 | // SYNC_PREF_TAKE_BOTH not implemented | 2653 | // SYNC_PREF_TAKE_BOTH not implemented |
2654 | break; | 2654 | break; |
2655 | } | 2655 | } |
2656 | return 0; | 2656 | return 0; |
2657 | } | 2657 | } |
2658 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2658 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2659 | { | 2659 | { |
2660 | bool syncOK = true; | 2660 | bool syncOK = true; |
2661 | int addedAddressee = 0; | 2661 | int addedAddressee = 0; |
2662 | int addedAddresseeR = 0; | 2662 | int addedAddresseeR = 0; |
2663 | int deletedAddresseeR = 0; | 2663 | int deletedAddresseeR = 0; |
2664 | int deletedAddresseeL = 0; | 2664 | int deletedAddresseeL = 0; |
2665 | int changedLocal = 0; | 2665 | int changedLocal = 0; |
2666 | int changedRemote = 0; | 2666 | int changedRemote = 0; |
2667 | //QPtrList<Addressee> el = local->rawAddressees(); | 2667 | //QPtrList<Addressee> el = local->rawAddressees(); |
2668 | Addressee addresseeR; | 2668 | Addressee addresseeR; |
2669 | QString uid; | 2669 | QString uid; |
2670 | int take; | 2670 | int take; |
2671 | Addressee addresseeL; | 2671 | Addressee addresseeL; |
2672 | Addressee addresseeRSync; | 2672 | Addressee addresseeRSync; |
2673 | Addressee addresseeLSync; | 2673 | Addressee addresseeLSync; |
2674 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2674 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2675 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2675 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2676 | bool fullDateRange = false; | 2676 | bool fullDateRange = false; |
2677 | local->resetTempSyncStat(); | 2677 | local->resetTempSyncStat(); |
2678 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2678 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2679 | QDateTime modifiedCalendar = mLastAddressbookSync;; | 2679 | QDateTime modifiedCalendar = mLastAddressbookSync;; |
2680 | addresseeLSync = getLastSyncAddressee(); | 2680 | addresseeLSync = getLastSyncAddressee(); |
2681 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2681 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2682 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2682 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2683 | if ( !addresseeR.isEmpty() ) { | 2683 | if ( !addresseeR.isEmpty() ) { |
2684 | addresseeRSync = addresseeR; | 2684 | addresseeRSync = addresseeR; |
2685 | remote->removeAddressee(addresseeR ); | 2685 | remote->removeAddressee(addresseeR ); |
2686 | 2686 | ||
2687 | } else { | 2687 | } else { |
2688 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2688 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2689 | addresseeRSync = addresseeLSync ; | 2689 | addresseeRSync = addresseeLSync ; |
2690 | } else { | 2690 | } else { |
2691 | qDebug("FULLDATE 1"); | 2691 | qDebug("FULLDATE 1"); |
2692 | fullDateRange = true; | 2692 | fullDateRange = true; |
2693 | Addressee newAdd; | 2693 | Addressee newAdd; |
2694 | addresseeRSync = newAdd; | 2694 | addresseeRSync = newAdd; |
2695 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2695 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2696 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2696 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2697 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2697 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2698 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2698 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2699 | } | 2699 | } |
2700 | } | 2700 | } |
2701 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2701 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2702 | qDebug("FULLDATE 2"); | 2702 | qDebug("FULLDATE 2"); |
2703 | fullDateRange = true; | 2703 | fullDateRange = true; |
2704 | } | 2704 | } |
2705 | if ( ! fullDateRange ) { | 2705 | if ( ! fullDateRange ) { |
2706 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2706 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2707 | 2707 | ||
2708 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2708 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2709 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2709 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2710 | fullDateRange = true; | 2710 | fullDateRange = true; |
2711 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2711 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2712 | } | 2712 | } |
2713 | } | 2713 | } |
2714 | // fullDateRange = true; // debug only! | 2714 | // fullDateRange = true; // debug only! |
2715 | if ( fullDateRange ) | 2715 | if ( fullDateRange ) |
2716 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2716 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2717 | else | 2717 | else |
2718 | mLastAddressbookSync = addresseeLSync.revision(); | 2718 | mLastAddressbookSync = addresseeLSync.revision(); |
2719 | // for resyncing if own file has changed | 2719 | // for resyncing if own file has changed |
2720 | // PENDING fixme later when implemented | 2720 | // PENDING fixme later when implemented |
2721 | #if 0 | 2721 | #if 0 |
2722 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2722 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2723 | mLastAddressbookSync = loadedFileVersion; | 2723 | mLastAddressbookSync = loadedFileVersion; |
2724 | qDebug("setting mLastAddressbookSync "); | 2724 | qDebug("setting mLastAddressbookSync "); |
2725 | } | 2725 | } |
2726 | #endif | 2726 | #endif |
2727 | 2727 | ||
2728 | //qDebug("*************************** "); | 2728 | //qDebug("*************************** "); |
2729 | qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2729 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2730 | QStringList er = remote->uidList(); | 2730 | QStringList er = remote->uidList(); |
2731 | Addressee inR ;//= er.first(); | 2731 | Addressee inR ;//= er.first(); |
2732 | Addressee inL; | 2732 | Addressee inL; |
2733 | QProgressBar bar( er.count(),0 ); | 2733 | QProgressBar bar( er.count(),0 ); |
2734 | bar.setCaption (i18n("Syncing - close to abort!") ); | 2734 | bar.setCaption (i18n("Syncing - close to abort!") ); |
2735 | 2735 | ||
2736 | int w = 300; | 2736 | int w = 300; |
2737 | if ( QApplication::desktop()->width() < 320 ) | 2737 | if ( QApplication::desktop()->width() < 320 ) |
2738 | w = 220; | 2738 | w = 220; |
2739 | int h = bar.sizeHint().height() ; | 2739 | int h = bar.sizeHint().height() ; |
2740 | int dw = QApplication::desktop()->width(); | 2740 | int dw = QApplication::desktop()->width(); |
2741 | int dh = QApplication::desktop()->height(); | 2741 | int dh = QApplication::desktop()->height(); |
2742 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2742 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2743 | bar.show(); | 2743 | bar.show(); |
2744 | int modulo = (er.count()/10)+1; | 2744 | int modulo = (er.count()/10)+1; |
2745 | int incCounter = 0; | 2745 | int incCounter = 0; |
2746 | while ( incCounter < er.count()) { | 2746 | while ( incCounter < er.count()) { |
2747 | if ( ! bar.isVisible() ) | 2747 | if ( ! bar.isVisible() ) |
2748 | return false; | 2748 | return false; |
2749 | if ( incCounter % modulo == 0 ) | 2749 | if ( incCounter % modulo == 0 ) |
2750 | bar.setProgress( incCounter ); | 2750 | bar.setProgress( incCounter ); |
2751 | uid = er[ incCounter ]; | 2751 | uid = er[ incCounter ]; |
2752 | bool skipIncidence = false; | 2752 | bool skipIncidence = false; |
2753 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2753 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2754 | skipIncidence = true; | 2754 | skipIncidence = true; |
2755 | QString idS; | 2755 | QString idS; |
2756 | qApp->processEvents(); | 2756 | qApp->processEvents(); |
2757 | if ( !skipIncidence ) { | 2757 | if ( !skipIncidence ) { |
2758 | inL = local->findByUid( uid ); | 2758 | inL = local->findByUid( uid ); |
2759 | inR = remote->findByUid( uid ); | 2759 | inR = remote->findByUid( uid ); |
2760 | //inL.setResource( 0 ); | 2760 | //inL.setResource( 0 ); |
2761 | //inR.setResource( 0 ); | 2761 | //inR.setResource( 0 ); |
2762 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2762 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2763 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { | 2763 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { |
2764 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2764 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2765 | if ( take == 3 ) | 2765 | if ( take == 3 ) |
2766 | return false; | 2766 | return false; |
2767 | if ( take == 1 ) {// take local | 2767 | if ( take == 1 ) {// take local |
2768 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2768 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2769 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2769 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2770 | local->insertAddressee( inL, false ); | 2770 | local->insertAddressee( inL, false ); |
2771 | } | 2771 | } |
2772 | else | 2772 | else |
2773 | idS = inR.IDStr(); | 2773 | idS = inR.IDStr(); |
2774 | remote->removeAddressee( inR ); | 2774 | remote->removeAddressee( inR ); |
2775 | inR = inL; | 2775 | inR = inL; |
2776 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2776 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2777 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 2777 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
2778 | inR.setIDStr( idS ); | 2778 | inR.setIDStr( idS ); |
2779 | inR.setResource( 0 ); | 2779 | inR.setResource( 0 ); |
2780 | remote->insertAddressee( inR , false); | 2780 | remote->insertAddressee( inR , false); |
2781 | ++changedRemote; | 2781 | ++changedRemote; |
2782 | } else { | 2782 | } else { |
2783 | idS = inL.IDStr(); | 2783 | idS = inL.IDStr(); |
2784 | local->removeAddressee( inL ); | 2784 | local->removeAddressee( inL ); |
2785 | inL = inR; | 2785 | inL = inR; |
2786 | inL.setIDStr( idS ); | 2786 | inL.setIDStr( idS ); |
2787 | inL.setResource( 0 ); | 2787 | inL.setResource( 0 ); |
2788 | local->insertAddressee( inL , false ); | 2788 | local->insertAddressee( inL , false ); |
2789 | ++changedLocal; | 2789 | ++changedLocal; |
2790 | } | 2790 | } |
2791 | } | 2791 | } |
2792 | } else { // no conflict | 2792 | } else { // no conflict |
2793 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2793 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2794 | QString des = addresseeLSync.note(); | 2794 | QString des = addresseeLSync.note(); |
2795 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2795 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2796 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2796 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2797 | remote->insertAddressee( inR, false ); | 2797 | remote->insertAddressee( inR, false ); |
2798 | ++deletedAddresseeR; | 2798 | ++deletedAddresseeR; |
2799 | } else { | 2799 | } else { |
2800 | inR.setRevision( modifiedCalendar ); | 2800 | inR.setRevision( modifiedCalendar ); |
2801 | remote->insertAddressee( inR, false ); | 2801 | remote->insertAddressee( inR, false ); |
2802 | inL = inR; | 2802 | inL = inR; |
2803 | inL.setResource( 0 ); | 2803 | inL.setResource( 0 ); |
2804 | local->insertAddressee( inL , false); | 2804 | local->insertAddressee( inL , false); |
2805 | ++addedAddressee; | 2805 | ++addedAddressee; |
2806 | } | 2806 | } |
2807 | } else { | 2807 | } else { |
2808 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 2808 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
2809 | inR.setRevision( modifiedCalendar ); | 2809 | inR.setRevision( modifiedCalendar ); |
2810 | remote->insertAddressee( inR, false ); | 2810 | remote->insertAddressee( inR, false ); |
2811 | inR.setResource( 0 ); | 2811 | inR.setResource( 0 ); |
2812 | local->insertAddressee( inR, false ); | 2812 | local->insertAddressee( inR, false ); |
2813 | ++addedAddressee; | 2813 | ++addedAddressee; |
2814 | } else { | 2814 | } else { |
2815 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2815 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2816 | remote->removeAddressee( inR ); | 2816 | remote->removeAddressee( inR ); |
2817 | ++deletedAddresseeR; | 2817 | ++deletedAddresseeR; |
2818 | } | 2818 | } |
2819 | } | 2819 | } |
2820 | } | 2820 | } |
2821 | } | 2821 | } |
2822 | ++incCounter; | 2822 | ++incCounter; |
2823 | } | 2823 | } |
2824 | er.clear(); | 2824 | er.clear(); |
2825 | QStringList el = local->uidList(); | 2825 | QStringList el = local->uidList(); |
2826 | modulo = (el.count()/10)+1; | 2826 | modulo = (el.count()/10)+1; |
2827 | bar.setCaption (i18n("Add / remove addressees") ); | 2827 | bar.setCaption (i18n("Add / remove addressees") ); |
2828 | bar.setTotalSteps ( el.count() ) ; | 2828 | bar.setTotalSteps ( el.count() ) ; |
2829 | bar.show(); | 2829 | bar.show(); |
2830 | incCounter = 0; | 2830 | incCounter = 0; |
2831 | while ( incCounter < el.count()) { | 2831 | while ( incCounter < el.count()) { |
2832 | qApp->processEvents(); | 2832 | qApp->processEvents(); |
2833 | if ( ! bar.isVisible() ) | 2833 | if ( ! bar.isVisible() ) |
2834 | return false; | 2834 | return false; |
2835 | if ( incCounter % modulo == 0 ) | 2835 | if ( incCounter % modulo == 0 ) |
2836 | bar.setProgress( incCounter ); | 2836 | bar.setProgress( incCounter ); |
2837 | uid = el[ incCounter ]; | 2837 | uid = el[ incCounter ]; |
2838 | bool skipIncidence = false; | 2838 | bool skipIncidence = false; |
2839 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2839 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2840 | skipIncidence = true; | 2840 | skipIncidence = true; |
2841 | if ( !skipIncidence ) { | 2841 | if ( !skipIncidence ) { |
2842 | inL = local->findByUid( uid ); | 2842 | inL = local->findByUid( uid ); |
2843 | inR = remote->findByUid( uid ); | 2843 | inR = remote->findByUid( uid ); |
2844 | if ( inR.isEmpty() ) { | 2844 | if ( inR.isEmpty() ) { |
2845 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2845 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2846 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2846 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2847 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2847 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2848 | local->removeAddressee( inL ); | 2848 | local->removeAddressee( inL ); |
2849 | ++deletedAddresseeL; | 2849 | ++deletedAddresseeL; |
2850 | } else { | 2850 | } else { |
2851 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { | 2851 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { |
2852 | inL.removeID(mCurrentSyncDevice ); | 2852 | inL.removeID(mCurrentSyncDevice ); |
2853 | ++addedAddresseeR; | 2853 | ++addedAddresseeR; |
2854 | inL.setRevision( modifiedCalendar ); | 2854 | inL.setRevision( modifiedCalendar ); |
2855 | local->insertAddressee( inL, false ); | 2855 | local->insertAddressee( inL, false ); |
2856 | inR = inL; | 2856 | inR = inL; |
2857 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2857 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2858 | inR.setResource( 0 ); | 2858 | inR.setResource( 0 ); |
2859 | remote->insertAddressee( inR, false ); | 2859 | remote->insertAddressee( inR, false ); |
2860 | } | 2860 | } |
2861 | } | 2861 | } |
2862 | } else { | 2862 | } else { |
2863 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 2863 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
2864 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2864 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2865 | local->removeAddressee( inL ); | 2865 | local->removeAddressee( inL ); |
2866 | ++deletedAddresseeL; | 2866 | ++deletedAddresseeL; |
2867 | } else { | 2867 | } else { |
2868 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { | 2868 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { |
2869 | ++addedAddresseeR; | 2869 | ++addedAddresseeR; |
2870 | inL.setRevision( modifiedCalendar ); | 2870 | inL.setRevision( modifiedCalendar ); |
2871 | local->insertAddressee( inL, false ); | 2871 | local->insertAddressee( inL, false ); |
2872 | inR = inL; | 2872 | inR = inL; |
2873 | inR.setResource( 0 ); | 2873 | inR.setResource( 0 ); |
2874 | remote->insertAddressee( inR, false ); | 2874 | remote->insertAddressee( inR, false ); |
2875 | } | 2875 | } |
2876 | } | 2876 | } |
2877 | } | 2877 | } |
2878 | } | 2878 | } |
2879 | } | 2879 | } |
2880 | ++incCounter; | 2880 | ++incCounter; |
2881 | } | 2881 | } |
2882 | el.clear(); | 2882 | el.clear(); |
2883 | bar.hide(); | 2883 | bar.hide(); |
2884 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2884 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2885 | // get rid of micro seconds | 2885 | // get rid of micro seconds |
2886 | QTime t = mLastAddressbookSync.time(); | 2886 | QTime t = mLastAddressbookSync.time(); |
2887 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2887 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2888 | addresseeLSync.setRevision( mLastAddressbookSync ); | 2888 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2889 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2889 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2890 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2890 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2891 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2891 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2892 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 2892 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
2893 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 2893 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
2894 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 2894 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
2895 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 2895 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
2896 | addresseeRSync.setNote( "" ) ; | 2896 | addresseeRSync.setNote( "" ) ; |
2897 | addresseeLSync.setNote( "" ); | 2897 | addresseeLSync.setNote( "" ); |
2898 | 2898 | ||
2899 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2899 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2900 | remote->insertAddressee( addresseeRSync, false ); | 2900 | remote->insertAddressee( addresseeRSync, false ); |
2901 | local->insertAddressee( addresseeLSync, false ); | 2901 | local->insertAddressee( addresseeLSync, false ); |
2902 | QString mes; | 2902 | QString mes; |
2903 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); | 2903 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); |
2904 | if ( KABPrefs::instance()->mShowSyncSummary ) { | 2904 | if ( KABPrefs::instance()->mShowSyncSummary ) { |
2905 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); | 2905 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); |
2906 | } | 2906 | } |
2907 | qDebug( mes ); | 2907 | qDebug( mes ); |
2908 | return syncOK; | 2908 | return syncOK; |
2909 | } | 2909 | } |
2910 | 2910 | ||
2911 | bool KABCore::syncAB(QString filename, int mode) | 2911 | bool KABCore::syncAB(QString filename, int mode) |
2912 | { | 2912 | { |
2913 | 2913 | ||
2914 | //pending prepare addresseeview for output | 2914 | //pending prepare addresseeview for output |
2915 | //pending detect, if remote file has REV field. if not switch to external sync | 2915 | //pending detect, if remote file has REV field. if not switch to external sync |
2916 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2916 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2917 | AddressBook abLocal(filename,"syncContact"); | 2917 | AddressBook abLocal(filename,"syncContact"); |
2918 | bool syncOK = false; | 2918 | bool syncOK = false; |
2919 | if ( abLocal.load() ) { | 2919 | if ( abLocal.load() ) { |
2920 | qDebug("AB loaded %s mode %d",filename.latin1(), mode ); | 2920 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
2921 | bool external = false; | 2921 | bool external = false; |
2922 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2922 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2923 | if ( ! lse.isEmpty() ) { | 2923 | if ( ! lse.isEmpty() ) { |
2924 | if ( lse.familyName().left(4) == "!E: " ) | 2924 | if ( lse.familyName().left(4) == "!E: " ) |
2925 | external = true; | 2925 | external = true; |
2926 | } else { | 2926 | } else { |
2927 | bool found = false; | 2927 | bool found = false; |
2928 | QDateTime dt( QDate( 2004,1,1)); | 2928 | QDateTime dt( QDate( 2004,1,1)); |
2929 | AddressBook::Iterator it; | 2929 | AddressBook::Iterator it; |
2930 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2930 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2931 | if ( (*it).revision() != dt ) { | 2931 | if ( (*it).revision() != dt ) { |
2932 | found = true; | 2932 | found = true; |
2933 | break; | 2933 | break; |
2934 | } | 2934 | } |
2935 | } | 2935 | } |
2936 | external = ! found; | 2936 | external = ! found; |
2937 | } | 2937 | } |
2938 | 2938 | ||
2939 | if ( external ) { | 2939 | if ( external ) { |
2940 | qDebug("**********Setting vcf mode to external "); | 2940 | qDebug("Setting vcf mode to external "); |
2941 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2941 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2942 | AddressBook::Iterator it; | 2942 | AddressBook::Iterator it; |
2943 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2943 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2944 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 2944 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
2945 | (*it).computeCsum( mCurrentSyncDevice ); | 2945 | (*it).computeCsum( mCurrentSyncDevice ); |
2946 | } | 2946 | } |
2947 | } | 2947 | } |
2948 | //AddressBook::Iterator it; | 2948 | //AddressBook::Iterator it; |
2949 | //QStringList vcards; | 2949 | //QStringList vcards; |
2950 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2950 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2951 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2951 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2952 | //} | 2952 | //} |
2953 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2953 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2954 | if ( syncOK ) { | 2954 | if ( syncOK ) { |
2955 | if ( KABPrefs::instance()->mWriteBackFile ) | 2955 | if ( KABPrefs::instance()->mWriteBackFile ) |
2956 | { | 2956 | { |
2957 | if ( external ) | 2957 | if ( external ) |
2958 | abLocal.removeDeletedAddressees(); | 2958 | abLocal.removeDeletedAddressees(); |
2959 | qDebug("saving remote AB "); | 2959 | qDebug("Saving remote AB "); |
2960 | abLocal.saveAB(); | 2960 | abLocal.saveAB(); |
2961 | } | 2961 | } |
2962 | } | 2962 | } |
2963 | setModified(); | 2963 | setModified(); |
2964 | 2964 | ||
2965 | } | 2965 | } |
2966 | if ( syncOK ) | 2966 | if ( syncOK ) |
2967 | mViewManager->refreshView(); | 2967 | mViewManager->refreshView(); |
2968 | return syncOK; | 2968 | return syncOK; |
2969 | #if 0 | 2969 | #if 0 |
2970 | 2970 | ||
2971 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | 2971 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { |
2972 | getEventViewerDialog()->setSyncMode( true ); | 2972 | getEventViewerDialog()->setSyncMode( true ); |
2973 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 2973 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
2974 | getEventViewerDialog()->setSyncMode( false ); | 2974 | getEventViewerDialog()->setSyncMode( false ); |
2975 | if ( syncOK ) { | 2975 | if ( syncOK ) { |
2976 | if ( KOPrefs::instance()->mWriteBackFile ) | 2976 | if ( KOPrefs::instance()->mWriteBackFile ) |
2977 | { | 2977 | { |
2978 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 2978 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
2979 | storage->save(); | 2979 | storage->save(); |
2980 | } | 2980 | } |
2981 | } | 2981 | } |
2982 | setModified(); | 2982 | setModified(); |
2983 | } | 2983 | } |
2984 | 2984 | ||
2985 | #endif | 2985 | #endif |
2986 | } | 2986 | } |
2987 | 2987 | ||
2988 | void KABCore::confSync() | 2988 | void KABCore::confSync() |
2989 | { | 2989 | { |
2990 | static KSyncPrefsDialog* sp = 0; | 2990 | static KSyncPrefsDialog* sp = 0; |
2991 | if ( ! sp ) { | 2991 | if ( ! sp ) { |
2992 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); | 2992 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); |
2993 | } | 2993 | } |
2994 | sp->usrReadConfig(); | 2994 | sp->usrReadConfig(); |
2995 | #ifndef DESKTOP_VERSION | 2995 | #ifndef DESKTOP_VERSION |
2996 | sp->showMaximized(); | 2996 | sp->showMaximized(); |
2997 | #else | 2997 | #else |
2998 | sp->show(); | 2998 | sp->show(); |
2999 | #endif | 2999 | #endif |
3000 | sp->exec(); | 3000 | sp->exec(); |
3001 | KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); | 3001 | KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); |
3002 | KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); | 3002 | KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); |
3003 | fillSyncMenu(); | 3003 | fillSyncMenu(); |
3004 | } | 3004 | } |
3005 | void KABCore::syncSharp() | 3005 | void KABCore::syncSharp() |
3006 | { | 3006 | { |
3007 | if ( mModified ) | 3007 | if ( mModified ) |
3008 | save(); | 3008 | save(); |
3009 | qDebug("pending syncSharp() "); | 3009 | qDebug("pending syncSharp() "); |
3010 | //mView->syncSharp(); | 3010 | //mView->syncSharp(); |
3011 | setModified(); | 3011 | setModified(); |
3012 | 3012 | ||
3013 | } | 3013 | } |
3014 | void KABCore::syncPhone() | 3014 | void KABCore::syncPhone() |
3015 | { | 3015 | { |
3016 | if ( mModified ) | 3016 | if ( mModified ) |
3017 | save(); | 3017 | save(); |
3018 | qDebug("pending syncPhone(); "); | 3018 | qDebug("pending syncPhone(); "); |
3019 | //mView->syncPhone(); | 3019 | //mView->syncPhone(); |
3020 | setModified(); | 3020 | setModified(); |
3021 | 3021 | ||
3022 | } | 3022 | } |